libre-webui 0.29.0 → 0.31.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 (261) hide show
  1. package/backend/dist/index.d.ts.map +1 -1
  2. package/backend/dist/index.js +24 -7
  3. package/backend/dist/index.js.map +1 -1
  4. package/backend/dist/persistence/postgresAutomationWebhooksMigration.d.ts +9 -0
  5. package/backend/dist/persistence/postgresAutomationWebhooksMigration.d.ts.map +1 -0
  6. package/backend/dist/persistence/postgresAutomationWebhooksMigration.js +38 -0
  7. package/backend/dist/persistence/postgresAutomationWebhooksMigration.js.map +1 -0
  8. package/backend/dist/persistence/postgresMigrationRegistry.d.ts.map +1 -1
  9. package/backend/dist/persistence/postgresMigrationRegistry.js +4 -0
  10. package/backend/dist/persistence/postgresMigrationRegistry.js.map +1 -1
  11. package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -1
  12. package/backend/dist/persistence/postgresResourceRepositories.js +5 -0
  13. package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
  14. package/backend/dist/persistence/postgresWorkApprovalsMigration.d.ts +13 -0
  15. package/backend/dist/persistence/postgresWorkApprovalsMigration.d.ts.map +1 -0
  16. package/backend/dist/persistence/postgresWorkApprovalsMigration.js +69 -0
  17. package/backend/dist/persistence/postgresWorkApprovalsMigration.js.map +1 -0
  18. package/backend/dist/persistence/resourceTypes.d.ts +4 -0
  19. package/backend/dist/persistence/resourceTypes.d.ts.map +1 -1
  20. package/backend/dist/persistence/resourceTypes.js.map +1 -1
  21. package/backend/dist/persistence/sqliteMigrations.d.ts +3 -0
  22. package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -1
  23. package/backend/dist/persistence/sqliteMigrations.js +156 -2
  24. package/backend/dist/persistence/sqliteMigrations.js.map +1 -1
  25. package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -1
  26. package/backend/dist/persistence/sqliteResourceRepositories.js +7 -0
  27. package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
  28. package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -1
  29. package/backend/dist/persistence/sqliteToPostgresMigration.js +32 -1
  30. package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -1
  31. package/backend/dist/platform/workPersistence/postgresWorkPersistence.d.ts +10 -1
  32. package/backend/dist/platform/workPersistence/postgresWorkPersistence.d.ts.map +1 -1
  33. package/backend/dist/platform/workPersistence/postgresWorkPersistence.js +85 -5
  34. package/backend/dist/platform/workPersistence/postgresWorkPersistence.js.map +1 -1
  35. package/backend/dist/platform/workPersistence/sqliteWorkPersistence.d.ts +10 -1
  36. package/backend/dist/platform/workPersistence/sqliteWorkPersistence.d.ts.map +1 -1
  37. package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js +67 -7
  38. package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js.map +1 -1
  39. package/backend/dist/platform/workPersistence/types.d.ts +37 -0
  40. package/backend/dist/platform/workPersistence/types.d.ts.map +1 -1
  41. package/backend/dist/platform/workPersistence/types.js.map +1 -1
  42. package/backend/dist/routes/automations.d.ts.map +1 -1
  43. package/backend/dist/routes/automations.js +83 -1
  44. package/backend/dist/routes/automations.js.map +1 -1
  45. package/backend/dist/routes/ollama.d.ts.map +1 -1
  46. package/backend/dist/routes/ollama.js +64 -0
  47. package/backend/dist/routes/ollama.js.map +1 -1
  48. package/backend/dist/routes/plugins.d.ts.map +1 -1
  49. package/backend/dist/routes/plugins.js +90 -0
  50. package/backend/dist/routes/plugins.js.map +1 -1
  51. package/backend/dist/routes/work.d.ts.map +1 -1
  52. package/backend/dist/routes/work.js +83 -0
  53. package/backend/dist/routes/work.js.map +1 -1
  54. package/backend/dist/services/authService.d.ts +2 -0
  55. package/backend/dist/services/authService.d.ts.map +1 -1
  56. package/backend/dist/services/authService.js +2 -0
  57. package/backend/dist/services/authService.js.map +1 -1
  58. package/backend/dist/services/automationService.d.ts +13 -1
  59. package/backend/dist/services/automationService.d.ts.map +1 -1
  60. package/backend/dist/services/automationService.js +31 -0
  61. package/backend/dist/services/automationService.js.map +1 -1
  62. package/backend/dist/services/notificationService.d.ts.map +1 -1
  63. package/backend/dist/services/notificationService.js +1 -0
  64. package/backend/dist/services/notificationService.js.map +1 -1
  65. package/backend/dist/services/ollamaService.d.ts +12 -0
  66. package/backend/dist/services/ollamaService.d.ts.map +1 -1
  67. package/backend/dist/services/ollamaService.js +26 -0
  68. package/backend/dist/services/ollamaService.js.map +1 -1
  69. package/backend/dist/services/ollamaSettingsService.d.ts +10 -0
  70. package/backend/dist/services/ollamaSettingsService.d.ts.map +1 -0
  71. package/backend/dist/services/ollamaSettingsService.js +83 -0
  72. package/backend/dist/services/ollamaSettingsService.js.map +1 -0
  73. package/backend/dist/services/workAgentGuidance.d.ts +11 -0
  74. package/backend/dist/services/workAgentGuidance.d.ts.map +1 -1
  75. package/backend/dist/services/workAgentGuidance.js +16 -2
  76. package/backend/dist/services/workAgentGuidance.js.map +1 -1
  77. package/backend/dist/services/workAgentService.d.ts +56 -0
  78. package/backend/dist/services/workAgentService.d.ts.map +1 -1
  79. package/backend/dist/services/workAgentService.js +467 -17
  80. package/backend/dist/services/workAgentService.js.map +1 -1
  81. package/backend/dist/services/workApprovalService.d.ts +67 -0
  82. package/backend/dist/services/workApprovalService.d.ts.map +1 -0
  83. package/backend/dist/services/workApprovalService.js +273 -0
  84. package/backend/dist/services/workApprovalService.js.map +1 -0
  85. package/backend/dist/services/workEventService.d.ts.map +1 -1
  86. package/backend/dist/services/workEventService.js +25 -0
  87. package/backend/dist/services/workEventService.js.map +1 -1
  88. package/backend/dist/services/workPolicyService.d.ts +4 -0
  89. package/backend/dist/services/workPolicyService.d.ts.map +1 -1
  90. package/backend/dist/services/workPolicyService.js +19 -0
  91. package/backend/dist/services/workPolicyService.js.map +1 -1
  92. package/backend/dist/services/workRuntimeShared.d.ts +2 -0
  93. package/backend/dist/services/workRuntimeShared.d.ts.map +1 -1
  94. package/backend/dist/services/workRuntimeShared.js.map +1 -1
  95. package/backend/dist/services/workTaskService.d.ts +3 -1
  96. package/backend/dist/services/workTaskService.d.ts.map +1 -1
  97. package/backend/dist/services/workTaskService.js +21 -4
  98. package/backend/dist/services/workTaskService.js.map +1 -1
  99. package/backend/dist/types/index.d.ts +3 -1
  100. package/backend/dist/types/index.d.ts.map +1 -1
  101. package/backend/dist/types/index.js.map +1 -1
  102. package/backend/dist/types/work.d.ts +32 -11
  103. package/backend/dist/types/work.d.ts.map +1 -1
  104. package/backend/dist/websocketServer.d.ts.map +1 -1
  105. package/backend/dist/websocketServer.js +14 -2
  106. package/backend/dist/websocketServer.js.map +1 -1
  107. package/backend/package.json +2 -2
  108. package/deploy/work-computer/Dockerfile +1 -0
  109. package/deploy/work-computer/tint2rc +1 -0
  110. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  111. package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
  112. package/frontend/dist/artifact-runtime/mermaid.js +8 -8
  113. package/frontend/dist/artifact-runtime/papaparse.js +2 -2
  114. package/frontend/dist/artifact-runtime/plotly.js +371 -652
  115. package/frontend/dist/assets/index-B6xMZpzA.js +76 -0
  116. package/frontend/dist/assets/index-BjipfsCP.css +1 -0
  117. package/frontend/dist/index.html +28 -28
  118. package/frontend/dist/js/{ArtifactContainer-CTXxnWRo.js → ArtifactContainer-Bn6iJtaJ.js} +1 -1
  119. package/frontend/dist/js/{ArtifactDemoPage-CEYuIhJA.js → ArtifactDemoPage-BLF8Ok-o.js} +1 -1
  120. package/frontend/dist/js/{ArtifactSandboxFrame-DLOy2VOm.js → ArtifactSandboxFrame-Cs1Gu1WB.js} +1 -1
  121. package/frontend/dist/js/{ArtifactSlideOutPanel-DnTTc1VY.js → ArtifactSlideOutPanel-CuKq5cL0.js} +1 -1
  122. package/frontend/dist/js/AutomationModal-Dha4KgLI.js +1 -0
  123. package/frontend/dist/js/AutomationsPage-HcMCRV-D.js +1 -0
  124. package/frontend/dist/js/{AvatarUpload-DzL00yOL.js → AvatarUpload-CFrlSszY.js} +1 -1
  125. package/frontend/dist/js/{Button--pDOakZx.js → Button-CgN11mgY.js} +1 -1
  126. package/frontend/dist/js/{CalendarPage-Bls3TBeZ.js → CalendarPage-D_K-XrG9.js} +1 -1
  127. package/frontend/dist/js/ChannelsPage-D3CoImOT.js +1 -0
  128. package/frontend/dist/js/ChatPage-C0iBDbOq.js +14 -0
  129. package/frontend/dist/js/ConnectModels-D_ZbZQub.js +1 -0
  130. package/frontend/dist/js/{EvaluationsPage-DSgj9dT5.js → EvaluationsPage-DOJLpauA.js} +2 -2
  131. package/frontend/dist/js/FirstTimeSetup-DDIP_4Dd.js +1 -0
  132. package/frontend/dist/js/GalleryPage-C8U_F7Ns.js +1 -0
  133. package/frontend/dist/js/{HomePage-BebX3v-x.js → HomePage-B_aotoDU.js} +1 -1
  134. package/frontend/dist/js/LibreClawPage-cr2N6W00.js +1 -0
  135. package/frontend/dist/js/{Logo-BE9SvCC5.js → Logo-B7o7eaPU.js} +1 -1
  136. package/frontend/dist/js/{LogoMark-C8x1yyP3.js → LogoMark-D9g6ls0h.js} +1 -1
  137. package/frontend/dist/js/{ModelManagerModals-CpWAltRA.js → ModelManagerModals-C-J1d7GL.js} +1 -1
  138. package/frontend/dist/js/NotesPage-Bgr7R_Vm.js +3 -0
  139. package/frontend/dist/js/{PasswordStrengthMeter-Cdq2oQbc.js → PasswordStrengthMeter-DR-mGbLF.js} +1 -1
  140. package/frontend/dist/js/PersonasPage-C3D_6lIx.js +13 -0
  141. package/frontend/dist/js/{PluginUsagePage-jMrpL2Jb.js → PluginUsagePage-DK7MgSiu.js} +1 -1
  142. package/frontend/dist/js/RichMessageContent-7FxrZ4A8.js +1 -0
  143. package/frontend/dist/js/{RichMessageContent-CC9QZQKd.js → RichMessageContent-CQkLI7Dt.js} +1 -1
  144. package/frontend/dist/js/SettingsModal-CIV_Bgsf.js +19 -0
  145. package/frontend/dist/js/{SettingsToggle-C16gtVyi.js → SettingsToggle-Cw4OhW7B.js} +1 -1
  146. package/frontend/dist/js/ShareDialog-BCEVgtbN.js +1 -0
  147. package/frontend/dist/js/{SystemPage-Drd1neLN.js → SystemPage-BNVZtLe9.js} +1 -1
  148. package/frontend/dist/js/{UserManagementPage-CquciWKV.js → UserManagementPage-pPC_Svj9.js} +1 -1
  149. package/frontend/dist/js/WorkPage-Q33nIqkM.js +7 -0
  150. package/frontend/dist/js/{api-2DulPtq1.js → api-D-5hpGht.js} +3 -3
  151. package/frontend/dist/js/api-WR1CTYO5.js +1 -0
  152. package/frontend/dist/js/{appNavigation-DAGh98Yj.js → appNavigation-DfHbXBey.js} +1 -1
  153. package/frontend/dist/js/{appStore-Ci1X0yA-.js → appStore-B136FGdu.js} +2 -2
  154. package/frontend/dist/js/appVersion-Ck7dYiHe.js +1 -0
  155. package/frontend/dist/js/ar-Cq-nC6v9.js +2 -0
  156. package/frontend/dist/js/authStore-6AJLgQsD.js +1 -0
  157. package/frontend/dist/js/authStore-Ckz37pwu.js +4 -0
  158. package/frontend/dist/js/axios-CUerAKcc.js +1 -0
  159. package/frontend/dist/js/{babel-D7QYvEns.js → babel-8afoxhZ7.js} +1 -1
  160. package/frontend/dist/js/bn-BFSKytYs.js +2 -0
  161. package/frontend/dist/js/chatStore-Dpm3g_Ln.js +3 -0
  162. package/frontend/dist/js/classPrivateMethodInitSpec-DE0XIqc_.js +1 -0
  163. package/frontend/dist/js/config-DJwXAf8i.js +1 -0
  164. package/frontend/dist/js/cs-BKWXa629.js +2 -0
  165. package/frontend/dist/js/da-Cra_DJnV.js +2 -0
  166. package/frontend/dist/js/de-BQa6_UuE.js +2 -0
  167. package/frontend/dist/js/es-BBOHFrx1.js +2 -0
  168. package/frontend/dist/js/{estree-D7xT4AeP.js → estree-qxY7ACbu.js} +3 -3
  169. package/frontend/dist/js/{evaluationsApi-Cu5PH_qi.js → evaluationsApi-BKY-maUM.js} +1 -1
  170. package/frontend/dist/js/fr-C8kXs5c0.js +2 -0
  171. package/frontend/dist/js/hi-BEef4bjU.js +2 -0
  172. package/frontend/dist/js/{html-HvA9vEyn.js → html-B_cUU1Gi.js} +2 -2
  173. package/frontend/dist/js/id-Djipic7Y.js +2 -0
  174. package/frontend/dist/js/is-pazl6RLG.js +2 -0
  175. package/frontend/dist/js/it-DobPbTwl.js +2 -0
  176. package/frontend/dist/js/ja-DwYNaMNX.js +2 -0
  177. package/frontend/dist/js/ko-BQfXE7_o.js +2 -0
  178. package/frontend/dist/js/{markdown-DaF0SXNk.js → markdown-BAF0w-jL.js} +3 -3
  179. package/frontend/dist/js/{messageCodeStyles-DKq3DH1W.js → messageCodeStyles-CkxF6yil.js} +2 -2
  180. package/frontend/dist/js/ms-CkPQoE5T.js +2 -0
  181. package/frontend/dist/js/nl-X_QsDAtu.js +2 -0
  182. package/frontend/dist/js/pl-CK39gUsy.js +2 -0
  183. package/frontend/dist/js/{postcss-RCIJRrFm.js → postcss-B2vYq4-H.js} +1 -1
  184. package/frontend/dist/js/pt-C0dWyR_I.js +2 -0
  185. package/frontend/dist/js/{router-vendor-BGP0k6Y2.js → router-vendor-CIwPu612.js} +1 -1
  186. package/frontend/dist/js/ru-sNJkEz1G.js +2 -0
  187. package/frontend/dist/js/{standalone-BMD7E0jY.js → standalone-BqZmfuRy.js} +2 -2
  188. package/frontend/dist/js/sv-Bh-uxdF3.js +2 -0
  189. package/frontend/dist/js/{teamEventStream-C4u_py2D.js → teamEventStream-DUodK0-C.js} +1 -1
  190. package/frontend/dist/js/th-DPVtwZj2.js +2 -0
  191. package/frontend/dist/js/tr-BYNM_Tm7.js +2 -0
  192. package/frontend/dist/js/{ttsBatching-C9kQXFB1.js → ttsBatching-7_-p2nxR.js} +1 -1
  193. package/frontend/dist/js/{typescript-LOiqVRM1.js → typescript-DokwN-5Y.js} +1 -1
  194. package/frontend/dist/js/{ui-DUzqxWMk.js → ui-BK53RPmS.js} +2 -2
  195. package/frontend/dist/js/ui-vendor-CPdYrKhz.js +177 -0
  196. package/frontend/dist/js/uk-kvNBuYin.js +2 -0
  197. package/frontend/dist/js/{useChat-6yDWZSTz.js → useChat-Czg2p4Rr.js} +1 -1
  198. package/frontend/dist/js/useDictation-B2lYEYKn.js +1 -0
  199. package/frontend/dist/js/useQuery-ClAiNxQ7.js +1 -0
  200. package/frontend/dist/js/{useTranslation-DrnYb6Cx.js → useTranslation-C7GwbUQA.js} +1 -1
  201. package/frontend/dist/js/{utils-D9UstwTG.js → utils-nNyg0lfc.js} +1 -1
  202. package/frontend/dist/js/utils-vendor-CeUf_ngc.js +9 -0
  203. package/frontend/dist/js/vi-CmLoaP0K.js +2 -0
  204. package/frontend/dist/js/workApi-BoJb9aVF.js +1 -0
  205. package/frontend/dist/js/{workApi-BwDBwG62.js → workApi-CFH097y5.js} +3 -3
  206. package/frontend/dist/js/{yaml-CyhEdlt2.js → yaml-BXEpxPn2.js} +2 -2
  207. package/frontend/dist/js/zh-D2zvmvrj.js +2 -0
  208. package/frontend/dist/sw.js +7 -1
  209. package/package.json +5 -5
  210. package/frontend/dist/assets/index-O8rtJINp.css +0 -1
  211. package/frontend/dist/assets/index-f1s6QpC5.js +0 -93
  212. package/frontend/dist/js/AutomationModal-DB3lrK2K.js +0 -1
  213. package/frontend/dist/js/AutomationsPage-D3v0Cra1.js +0 -1
  214. package/frontend/dist/js/ChannelsPage-BnoCniNf.js +0 -1
  215. package/frontend/dist/js/ChatPage-BMcigJWr.js +0 -14
  216. package/frontend/dist/js/FirstTimeSetup-BRysXCjP.js +0 -1
  217. package/frontend/dist/js/GalleryPage-DUcM4dg0.js +0 -1
  218. package/frontend/dist/js/LibreClawPage-A37KF9_G.js +0 -1
  219. package/frontend/dist/js/ModelSelector-C1ipX-44.js +0 -1
  220. package/frontend/dist/js/NotesPage-CXSz7Hde.js +0 -3
  221. package/frontend/dist/js/PersonasPage-CiOBffF3.js +0 -13
  222. package/frontend/dist/js/RichMessageContent-CU6WTuOs.js +0 -1
  223. package/frontend/dist/js/SettingsModal-DP_wKehV.js +0 -19
  224. package/frontend/dist/js/ShareDialog-BW8iGd_i.js +0 -1
  225. package/frontend/dist/js/WorkPage-BgASwAGs.js +0 -6
  226. package/frontend/dist/js/api-BmIdrQfK.js +0 -1
  227. package/frontend/dist/js/appVersion-BRMnr50t.js +0 -1
  228. package/frontend/dist/js/ar-CpmN0TY8.js +0 -2
  229. package/frontend/dist/js/authStore-DIvsSaOt.js +0 -4
  230. package/frontend/dist/js/authStore-DoxafXFR.js +0 -1
  231. package/frontend/dist/js/axios-C8xWfUG8.js +0 -1
  232. package/frontend/dist/js/bn-BwrMg_Oh.js +0 -2
  233. package/frontend/dist/js/chatStore-DkpmZLOG.js +0 -3
  234. package/frontend/dist/js/classPrivateMethodInitSpec-DUpGnGHL.js +0 -1
  235. package/frontend/dist/js/config-Ckn9cand.js +0 -1
  236. package/frontend/dist/js/cs-f72Fnxz3.js +0 -2
  237. package/frontend/dist/js/da-qp8lOgkJ.js +0 -2
  238. package/frontend/dist/js/de-CpcLHr97.js +0 -2
  239. package/frontend/dist/js/es-gZHsxjG4.js +0 -2
  240. package/frontend/dist/js/fr-BY5aUofi.js +0 -2
  241. package/frontend/dist/js/hi-KCn9gIiT.js +0 -2
  242. package/frontend/dist/js/id-C7U6kS0J.js +0 -2
  243. package/frontend/dist/js/is-N9Ek-Usz.js +0 -2
  244. package/frontend/dist/js/it-CqaqWB8D.js +0 -2
  245. package/frontend/dist/js/ja-C5f9HAm1.js +0 -2
  246. package/frontend/dist/js/ko-BuoboDvb.js +0 -2
  247. package/frontend/dist/js/ms-Cu-UWc6j.js +0 -2
  248. package/frontend/dist/js/nl-nOUc4C_i.js +0 -2
  249. package/frontend/dist/js/pl-BKKwFhxj.js +0 -2
  250. package/frontend/dist/js/pt-B18-KYtS.js +0 -2
  251. package/frontend/dist/js/ru-DflEWNyb.js +0 -2
  252. package/frontend/dist/js/sv-CU-nPjr8.js +0 -2
  253. package/frontend/dist/js/th-dOxm2Hhl.js +0 -2
  254. package/frontend/dist/js/tr-7ThM4F8q.js +0 -2
  255. package/frontend/dist/js/ui-vendor-C0KwbTD4.js +0 -177
  256. package/frontend/dist/js/uk-Cl7Pk0Yf.js +0 -2
  257. package/frontend/dist/js/useQuery-CoWV2PmJ.js +0 -1
  258. package/frontend/dist/js/utils-vendor-DtsgPwcz.js +0 -9
  259. package/frontend/dist/js/vi-eljYUBOk.js +0 -2
  260. package/frontend/dist/js/workApi-uXUZSjsf.js +0 -1
  261. package/frontend/dist/js/zh-B0sinUfQ.js +0 -2
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{t as r}from"./useTranslation-DrnYb6Cx.js";import{R as i,_r as a,jt as o,n as s,s as c}from"./ui-vendor-C0KwbTD4.js";import{t as l}from"./logger-CpCQz3Vi.js";import{k as u}from"./api-2DulPtq1.js";import{t as d}from"./Button--pDOakZx.js";import{n as f,r as p}from"./ui-DUzqxWMk.js";var m=e(t(),1),h=n(),g=l(`share-dialog`),_=({resourceType:e,resourceId:t,resourceLabel:n,onClose:l})=>{let{t:_}=r(),[v,y]=(0,m.useState)(null),[b,x]=(0,m.useState)(`user`),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(`read`),[E,D]=(0,m.useState)(!1),O=(0,m.useCallback)(()=>{u.listGrants(e,t).then(e=>{e.success&&Array.isArray(e.data)&&y(e.data)}).catch(e=>g.error(`Failed to load shares:`,e))},[e,t]);(0,m.useEffect)(()=>{O()},[O]);let k=async()=>{let n=S.trim();if(n){D(!0);try{let r=b===`user`?await u.resolvePrincipal(n):await u.resolveGroup(n);if(!r.success||!r.data){a.error(_(b===`user`?`share.userNotFound`:`share.groupNotFound`));return}let i=await u.createGrant({resourceType:e,resourceId:t,principalType:b,principalId:r.data.id,permission:w});i.success?(C(``),O(),a.success(_(`share.added`,{name:n}))):a.error(i.error||_(`share.failed`))}catch(e){g.error(`Failed to share resource:`,e),a.error(_(`share.failed`))}finally{D(!1)}}},A=async e=>{try{(await u.deleteGrant(e)).success&&O()}catch(e){g.error(`Failed to revoke share:`,e)}};return(0,h.jsxs)(f,{titleId:`share-dialog-title`,title:_(`share.title`,{name:n}),subtitle:_(`share.subtitle`),onClose:l,testId:`share-dialog`,children:[(0,h.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,h.jsxs)(`select`,{value:b,onChange:e=>x(e.target.value),className:`${p} w-auto`,"data-testid":`share-principal-kind`,children:[(0,h.jsx)(`option`,{value:`user`,children:_(`share.kindUser`)}),(0,h.jsx)(`option`,{value:`group`,children:_(`share.kindGroup`)})]}),(0,h.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Enter`&&k()},placeholder:_(b===`user`?`share.usernamePlaceholder`:`share.groupPlaceholder`),className:`${p} min-w-0 flex-1`,"data-testid":`share-principal-name`}),(0,h.jsxs)(`select`,{value:w,onChange:e=>T(e.target.value),className:`${p} w-auto`,"data-testid":`share-permission`,children:[(0,h.jsx)(`option`,{value:`read`,children:_(`share.permissionRead`)}),(0,h.jsx)(`option`,{value:`write`,children:_(`share.permissionWrite`)})]}),(0,h.jsx)(d,{size:`sm`,disabled:E||!S.trim(),onClick:()=>void k(),"data-testid":`share-submit`,children:E?(0,h.jsx)(o,{className:`h-3.5 w-3.5 animate-spin`}):_(`share.action`)})]}),v===null?(0,h.jsx)(o,{className:`mx-auto h-4 w-4 animate-spin text-gray-400`}):v.length===0?(0,h.jsx)(`p`,{className:`text-center text-xs text-gray-400 dark:text-dark-500`,children:_(`share.empty`)}):(0,h.jsx)(`div`,{className:`space-y-2`,children:v.map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-black/[0.06] px-2.5 py-2 dark:border-white/[0.08]`,"data-testid":`share-item`,children:[e.principalType===`group`?(0,h.jsx)(c,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 dark:text-dark-500`}):(0,h.jsx)(i,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 dark:text-dark-500`}),(0,h.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] text-gray-800 dark:text-dark-800`,children:e.principalName??e.principalId}),(0,h.jsx)(`span`,{className:`shrink-0 text-[11px] uppercase text-gray-400 dark:text-dark-500`,children:e.permission}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void A(e.id),className:`rounded-md p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,title:_(`share.revoke`),children:(0,h.jsx)(s,{className:`h-3.5 w-3.5`})})]},e.id))}),(0,h.jsx)(`p`,{className:`text-[11px] leading-relaxed text-gray-400 dark:text-dark-500`,children:_(`share.hint`)})]})};export{_ as t};
@@ -1,6 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/babel-D7QYvEns.js","js/router-vendor-BGP0k6Y2.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-CsTEqgp1.js","js/estree-D7xT4AeP.js","js/classPrivateMethodInitSpec-DUpGnGHL.js","js/typescript-LOiqVRM1.js","js/postcss-RCIJRrFm.js","js/html-HvA9vEyn.js","js/markdown-DaF0SXNk.js","js/yaml-CyhEdlt2.js","js/standalone-BMD7E0jY.js","js/OptimizedSyntaxHighlighter-oiyvxgDA.js","js/OptimizedSyntaxHighlighter-BwKLuOu-.js","js/syntax-highlight-DY6Hwrri.js","assets/xterm-DHcfr8qj.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{a as r,d as i,f as a,p as o,u as s}from"./router-vendor-BGP0k6Y2.js";import{t as c}from"./useTranslation-DrnYb6Cx.js";import{t as l}from"./utils-D9UstwTG.js";import{T as u,t as d}from"./chatStore-DkpmZLOG.js";import{$ as f,$t as p,A as m,E as h,G as g,Gn as _,Gt as v,Hn as y,Nn as b,O as x,Qn as S,Rn as C,St as w,U as T,Wn as E,Wt as D,Y as O,Z as k,Zt as A,_r as j,a as M,bn as ee,c as N,cn as te,cr as P,dr as F,er as I,ft as ne,gt as re,ht as ie,i as L,it as R,jt as z,l as ae,ln as oe,mr as se,n as B,o as ce,on as le,pn as ue,q as de,qt as fe,rn as pe,un as V,ur as me,v as he,vn as ge,yt as _e,zn as ve}from"./ui-vendor-C0KwbTD4.js";import{r as ye,t as be}from"./logger-CpCQz3Vi.js";import{t as xe}from"./config-Ckn9cand.js";import{n as H,t as U}from"./workApi-BwDBwG62.js";import{T as Se,_ as W,f as G,g as Ce,h as we,s as Te,t as Ee}from"./api-2DulPtq1.js";import{a as De,c as Oe,d as ke,i as K,l as Ae,o as je,r as Me,s as Ne,t as Pe}from"./authStore-DIvsSaOt.js";import{t as Fe}from"./appStore-Ci1X0yA-.js";import{t as q}from"./Button--pDOakZx.js";import{h as Ie,s as Le}from"./ui-DUzqxWMk.js";import{t as Re}from"./LogoMark-C8x1yyP3.js";import{t as ze}from"./workStatus-CcO9Fg41.js";import{t as Be}from"./RichMessageContent-CC9QZQKd.js";import{n as Ve,t as He}from"./AutomationModal-DB3lrK2K.js";import{t as Ue}from"./ModelSelector-C1ipX-44.js";import{n as We,t as Ge}from"./work-DVgm81bJ.js";var J=e(t(),1),Ke=be(`hooks:dictation`),qe=()=>{if(typeof window>`u`)return;let e=window;return e.SpeechRecognition||e.webkitSpeechRecognition},Je=[{mimeType:`audio/webm;codecs=opus`,format:`webm`}],Ye=300,Xe=.25;function Ze(e){if(typeof MediaRecorder>`u`)return;let t=new Set((e.config?.formats||[]).map(e=>e.toLowerCase()));return Je.find(e=>(t.size===0||t.has(e.format))&&(typeof MediaRecorder.isTypeSupported!=`function`||MediaRecorder.isTypeSupported(e.mimeType)))?.mimeType}function Qe({onStart:e,onText:t,ownerKey:n}){let{t:r,i18n:i}=c(),[a,o]=(0,J.useState)(`idle`),[s,l]=(0,J.useState)([]),u=(0,J.useRef)(null),d=(0,J.useRef)(null),f=(0,J.useRef)(null),p=(0,J.useRef)(null),m=(0,J.useRef)(null),h=(0,J.useRef)(0),g=(0,J.useRef)(`idle`),_=(0,J.useRef)(void 0),v=(0,J.useRef)(e),y=(0,J.useRef)(t);(0,J.useEffect)(()=>{v.current=e,y.current=t},[e,t]),(0,J.useEffect)(()=>{let e=!1;return Ee.getModels().then(t=>{!e&&t.success&&t.data&&l(t.data)}).catch(()=>{e||l([])}),()=>{e=!0}},[]);let b=(0,J.useMemo)(()=>typeof window<`u`&&window.isSecureContext&&typeof navigator<`u`&&!!navigator.mediaDevices&&!!qe(),[]),x=typeof window<`u`&&window.isSecureContext&&typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia,S=(0,J.useMemo)(()=>x?s.find(e=>!!Ze(e)):void 0,[x,s]),C=b||!!S,w=(0,J.useCallback)(()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null)},[]),T=(0,J.useCallback)(e=>{g.current=e,o(e)},[]),E=(0,J.useCallback)(()=>{h.current+=1,w(),u.current?.stop(),u.current=null,p.current?.abort(),p.current=null;let e=d.current;d.current=null,e&&(e.ondataavailable=null,e.onerror=null,e.onstop=null,e.state===`recording`&&e.stop()),f.current?.getTracks().forEach(e=>e.stop()),f.current=null,T(`idle`)},[w,T]);return(0,J.useEffect)(()=>(_.current=n,E),[E,n]),{supported:C,phase:a,toggle:(0,J.useCallback)(async()=>{let e=g.current;if(e===`starting`||e===`transcribing`){E();return}if(e===`recording`){d.current?.state===`recording`?(T(`transcribing`),d.current.stop()):E();return}if(!b&&S){let e=h.current+1;h.current=e;let t=_.current;v.current(),T(`starting`);try{let n=await navigator.mediaDevices.getUserMedia({audio:!0});if(h.current!==e||_.current!==t){n.getTracks().forEach(e=>e.stop());return}f.current=n;let a=Ze(S),o=a?new MediaRecorder(n,{mimeType:a}):new MediaRecorder(n),s=[];o.ondataavailable=e=>{e.data.size>0&&s.push(e.data)},o.onerror=()=>{n.getTracks().forEach(e=>e.stop()),w(),h.current===e&&(d.current=null,f.current=null,T(`idle`),j.error(r(`voiceMode.transcriptionFailed`)))},o.onstop=()=>{if(n.getTracks().forEach(e=>e.stop()),w(),h.current!==e||_.current!==t)return;if(d.current=null,f.current=null,s.length===0){T(`idle`);return}let a=new Blob(s,{type:o.mimeType||s[0].type||`audio/webm`}),c=new AbortController;p.current=c,T(`transcribing`),Ee.transcribe(a,S,{language:i.language,signal:c.signal,fallbackMessage:r(`voiceMode.transcriptionFailed`)}).then(n=>{h.current!==e||_.current!==t||c.signal.aborted||y.current(n.text.trim())}).catch(e=>{c.signal.aborted||(Ke.error(`Provider transcription failed:`,e),j.error(e instanceof Error?e.message:r(`voiceMode.transcriptionFailed`)))}).finally(()=>{p.current===c&&h.current===e&&(p.current=null,T(`idle`))})},d.current=o,o.start(250);let c=S.config?.max_duration_seconds,l=typeof c==`number`&&c>0?Math.min(c,Ye):Ye;m.current=window.setTimeout(()=>{h.current===e&&o.state===`recording`&&o.stop()},Math.max(.1,l-Xe)*1e3),T(`recording`);return}catch(t){if(h.current!==e)return;Ke.error(`Failed to start provider dictation:`,t),w(),f.current?.getTracks().forEach(e=>e.stop()),f.current=null,d.current=null,T(`idle`),j.error(r(`voiceMode.transcriptionFailed`));return}}let t=qe();if(!t)return;let n=h.current+1;h.current=n;let a=_.current,o=new t;o.lang=i.language,o.continuous=!0,o.interimResults=!0,v.current(),o.onresult=e=>{if(h.current!==n||_.current!==a||u.current!==o)return;let t=``;for(let n=0;n<e.results.length;n++)t+=e.results[n][0]?.transcript??``;y.current(t.trim())},o.onend=()=>{h.current===n&&(u.current=null,T(`idle`))},o.onerror=()=>{h.current===n&&(u.current=null,T(`idle`))},u.current=o,T(`recording`);try{o.start()}catch(e){Ke.error(`Failed to start dictation:`,e),u.current=null,T(`idle`)}},[b,E,w,i.language,S,T,r]),cancel:E}}var Y=n(),$e=e=>We({model:e.name,providerType:e.isPlugin?`plugin`:`ollama`,providerId:e.isPlugin?e.pluginId:void 0}),et=e=>{let t=e.name.split(`/`).filter(Boolean),n=t[t.length-1]||e.name;return t.length>1?n.replace(/[-_]+/g,` `):n},tt=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 nt({models:e,selectorModels:t,modelKey:n,running:r,loading:i,variant:a=`task`,disabled:o=!1,dictationOwnerKey:s,remoteDisclosureDismissed:u,remoteDisclosureSaving:d,onModelChange:f,onDismissRemoteDisclosure:p,onModelsRefresh:m,onSubmit:g,onCancel:_}){let{t:v}=c(),[y,b]=(0,J.useState)(``),x=(0,J.useRef)(null),S=(0,J.useRef)(``),w=Qe({onStart:()=>{S.current=x.current?.value??``},onText:e=>{let t=S.current;b(t?`${t} ${e}`:e)},ownerKey:s}),T=w.phase!==`idle`,E=(0,J.useRef)(null),D=(0,J.useRef)(null),O=e.find(e=>e.key===n),k=O?.remote===!0,A=a===`landing`,j=(0,J.useMemo)(()=>{let n=new Set(t.map($e)),r=e.filter(e=>!n.has(e.key)).map(tt);return[...t,...r]},[e,t]);(0,J.useEffect)(()=>{let e=x.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,160)}px`)},[y]);let M=async()=>{await p()&&([E.current,D.current].find(e=>e&&e.offsetParent!==null)||E.current)?.focus()},ee=t=>{let n=e.find(e=>e.key===t)||e.find(e=>e.providerType===`ollama`&&e.model===t);n&&f(n.key)},N=async()=>{let e=y.trim();!e||i||o||!r&&!O||await g(e)&&b(``)};return(0,Y.jsxs)(`div`,{"data-testid":A?`work-landing-composer`:`work-task-composer`,"data-variant":a,className:l(`relative shrink-0`,A?`mt-10 w-full`:`border-t border-line bg-surface/95 px-3 py-3 backdrop-blur md:px-5`),children:[k&&!u&&(0,Y.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,Y.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,Y.jsx)(`button`,{type:`button`,onClick:()=>void M(),disabled:d,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,Y.jsx)(B,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Y.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,Y.jsx)(C,{"data-testid":`work-provider-disclosure-accent`,className:`h-4 w-4 text-warning-500`,"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{id:`work-provider-disclosure-title`,className:`text-sm font-semibold text-ink`,children:v(`work.composer.remoteTitle`,{defaultValue:`Remote provider`})}),(0,Y.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,Y.jsx)(`div`,{className:`mt-2.5 flex justify-end`,children:(0,Y.jsx)(q,{"data-testid":`work-provider-disclosure-dismiss`,type:`button`,variant:`ghost`,size:`sm`,loading:d,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 M(),children:v(`work.composer.remoteDismiss`,{defaultValue:`Dismiss`})})})]})]})]})}),(0,Y.jsx)(`form`,{className:`mx-auto w-full max-w-3xl`,onSubmit:e=>{e.preventDefault(),N()},children:(0,Y.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,Y.jsx)(`textarea`,{ref:x,"data-testid":`work-composer-input`,dir:`auto`,value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),N())},disabled:o,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,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,Y.jsx)(`div`,{className:`hidden shrink-0 sm:block`,children:(0,Y.jsx)(Ue,{models:j,selectedModel:n,onModelChange:e=>ee(e.target.value),onModelsRefresh:()=>void m(),getModelValue:$e,getModelLabel:et,getModelTitle:e=>e.name,triggerRef:E,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})}),w.supported&&(0,Y.jsx)(q,{"data-testid":`work-voice-input`,type:`button`,variant:`ghost`,size:`sm`,disabled:o,"aria-pressed":T,className:l(`flex h-9 w-9 shrink-0 touch-manipulation items-center justify-center rounded-full p-0 transition-colors duration-150`,T?`animate-pulse bg-red-50 text-red-500 dark:bg-red-900/20`:`text-ink-muted hover:bg-surface-subtle hover:text-ink`),title:v(T?`chat.input.voiceStop`:`chat.input.voiceInput`),"aria-label":v(T?`chat.input.voiceStop`:`chat.input.voiceInput`),onClick:()=>void w.toggle(),children:w.phase===`starting`?(0,Y.jsx)(z,{className:`h-4 w-4 animate-spin`}):w.phase===`transcribing`?(0,Y.jsx)(h,{className:`h-4 w-4 fill-current`}):(0,Y.jsx)(_e,{className:`h-4 w-4`})}),r&&(0,Y.jsx)(q,{"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,Y.jsx)(z,{className:`h-4 w-4 animate-spin`}):(0,Y.jsx)(h,{className:`h-4 w-4 fill-current`})}),(0,Y.jsx)(q,{"data-testid":`work-submit-button`,type:`submit`,variant:`ghost`,size:`sm`,disabled:i||o||!y.trim()||!r&&!O,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,Y.jsx)(z,{className:`h-4 w-4 animate-spin`}):(0,Y.jsx)(P,{className:`h-4 w-4`})})]})]})}),(0,Y.jsx)(`div`,{className:`mx-auto mt-3 w-full max-w-3xl sm:hidden`,children:(0,Y.jsx)(Ue,{models:j,selectedModel:n,onModelChange:e=>ee(e.target.value),onModelsRefresh:()=>void m(),getModelValue:$e,getModelLabel:et,getModelTitle:e=>e.name,triggerRef:D,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})})]})}async function rt(e){return{viewOnlyPassword:(await H.post(`/work/tasks/${encodeURIComponent(e)}/computer/start`)).data.data?.viewOnlyPassword}}async function it(e){return(await H.get(`/work/tasks/${encodeURIComponent(e)}/computer/control`)).data.data??{agentWaiting:!1}}async function at(e){let t=(await H.post(`/work/tasks/${encodeURIComponent(e)}/computer/control`)).data.data;if(!t?.controlPassword)throw Error(`The server did not grant screen control.`);return t}async function ot(e){await H.delete(`/work/tasks/${encodeURIComponent(e)}/computer/control`)}async function st(e,t,n){await H.post(`/work/computer/skills/${encodeURIComponent(e)}/trace`,{outcome:t,...n?{note:n}:{}})}async function ct(e,t,n){return(await H.post(`/work/tasks/${encodeURIComponent(e)}/computer/anchor`,{x:t,y:n})).data.data??{}}async function lt(e,t){let n=(await H.post(`/work/tasks/${encodeURIComponent(e)}/computer/teach`,t)).data.data;if(!n?.skill)throw Error(`The server did not save the recording.`);return{slug:n.skill.slug,name:n.skill.name,steps:n.steps,redactions:n.redactions}}async function ut(e){return ft(e,K)}async function dt(e){return ft(e,Me)}async function ft(e,t){let n=(await H.post(`/auth/websocket-ticket`,{audience:`work-screen`,taskId:e})).data.data?.ticket;if(!n)throw Error(`The server did not issue a screen ticket.`);return t(e,n,{protocol:window.location.protocol,host:window.location.host,hostname:window.location.hostname,apiBaseUrl:void 0,websocketBaseUrl:void 0,production:!0})}var pt=e=>{if(e==null||e===``)return null;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}},mt=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`},ht=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 gt({run:e}){let[t,n]=(0,J.useState)();if((0,J.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,Y.jsx)(`span`,{dir:`ltr`,className:`tabular-nums text-ink-subtle`,"aria-hidden":`true`,children:mt(r-e.startedAt)}):null}function _t({tool:e,expandedByDefault:t}){let{t:n}=c(),[r]=(0,J.useState)(e.status),[i,a]=(0,J.useState)(null),o=(0,J.useMemo)(()=>pt(e.arguments),[e.arguments]),s=e.output||null,u=!!(o||s),d=e.status===`error`,f=e.status===`running`,p=(0,J.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,Y.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,Y.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-primary-500 disabled:cursor-default disabled:hover:bg-transparent`,children:[(0,Y.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:d?(0,Y.jsx)(C,{className:`h-3.5 w-3.5 text-error-500`}):f?(0,Y.jsx)(z,{className:`h-3.5 w-3.5 animate-spin text-[rgb(48,121,255)] motion-reduce:animate-none`}):(0,Y.jsx)(_,{className:`h-3.5 w-3.5 text-[rgb(76,212,117)]`})}),(0,Y.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,Y.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-ink-subtle`,children:mt(e.durationMs)}),u&&(0,Y.jsx)(E,{"aria-hidden":`true`,className:l(`h-3.5 w-3.5 shrink-0 text-ink-subtle transition-transform`,h&&`rotate-180`)})]}),u&&h&&(0,Y.jsxs)(`div`,{id:p,className:`border-t border-line bg-surface-subtle/50`,children:[o&&(0,Y.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,Y.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 vt=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 yt({content:e,streaming:t}){let{t:n}=c(),[r,i]=(0,J.useState)(!1),a=t&&!r?vt(e):``;return(0,Y.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,Y.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-col gap-1 px-3 py-2 marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center justify-between gap-3 text-xs font-medium text-ink-muted`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(S,{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,Y.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,Y.jsx)(`span`,{className:`truncate`,children:n(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,Y.jsx)(E,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),a&&(0,Y.jsx)(`span`,{dir:`auto`,"data-testid":`work-live-reasoning-preview`,className:`block truncate text-[11px] leading-relaxed text-ink-subtle`,children:a})]}),(0,Y.jsx)(`div`,{className:`border-t border-line px-3 py-2.5`,children:(0,Y.jsx)(Ie,{content:e,isStreaming:t,className:`text-xs text-ink-muted`})})]})}var bt=(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`}),xt=(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 St({run:e,variant:t=`conversation`}){let{t:n}=c(),r=[...e.tools].reverse().find(e=>e.status===`running`),i=xt(e.connection,n)||bt(e.phase,n,r),a=!e.terminal,[o,s]=(0,J.useState)({}),u=(0,J.useCallback)((e,t)=>{s(n=>({...n,[e]:t})),st(e,t).catch(()=>{s(t=>{let n={...t};return delete n[e],n})})},[]),d=e.usage?.outputTokens,f=e.reasoning+e.response,p=d!==void 0&&d>0?d:f?ht(f):d,h=(d===void 0||d===0)&&!!f&&p!==void 0,g=e.usage?.tokensPerSecond;return(0,Y.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,Y.jsxs)(`div`,{className:`mb-3 flex min-h-6 items-center gap-2 text-xs`,children:[(0,Y.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,Y.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,Y.jsx)(`span`,{dir:`ltr`,className:`shrink-0 tabular-nums text-ink-subtle`,children:e.roundLimit===void 0?`#${e.round}`:`${e.round}/${e.roundLimit}`}),(0,Y.jsx)(gt,{run:e})]}),t===`conversation`&&(0,Y.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:i}),e.skills.length>0&&(0,Y.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-1.5`,children:[(0,Y.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,Y.jsx)(m,{className:`h-3 w-3 text-primary-500`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{dir:`auto`,children:n(`work.live.skillsLoaded`,{count:e.skills.length,defaultValue:`Workspace skills · {{count}}`})})]}),e.terminal&&e.skills.filter(e=>e.id.startsWith(`taught:`)).map(e=>{let t=e.id.slice(7),r=o[t];return(0,Y.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,Y.jsx)(`span`,{dir:`auto`,children:e.name}),r?(0,Y.jsx)(`span`,{className:`text-primary-500`,children:n(`work.live.skillTraceSaved`,{defaultValue:`noted`})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,"data-testid":`skill-trace-success-${t}`,"aria-label":n(`work.live.skillWorked`,{defaultValue:`This procedure worked`}),title:n(`work.live.skillWorked`,{defaultValue:`This procedure worked`}),onClick:()=>u(t,`success`),className:`rounded px-1 hover:text-primary-600`,children:`✓`}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`skill-trace-failure-${t}`,"aria-label":n(`work.live.skillFailed`,{defaultValue:`This procedure failed`}),title:n(`work.live.skillFailed`,{defaultValue:`This procedure failed`}),onClick:()=>u(t,`failure`),className:`rounded px-1 hover:text-red-600`,children:`✕`})]})]},e.id)})]}),t===`conversation`?e.timeline.length>0&&(0,Y.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,Y.jsx)(yt,{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,Y.jsx)(_t,{tool:n,expandedByDefault:n.status===`error`},n.id):null}return(0,Y.jsx)(Ie,{content:t.text,isStreaming:a&&r,className:`text-ink`},`segment-${n}`)})}):e.tools.length>0&&(0,Y.jsx)(`div`,{"data-testid":`work-live-tools`,className:`space-y-1.5`,children:e.tools.map(e=>(0,Y.jsx)(_t,{tool:e,expandedByDefault:e.status===`running`||e.status===`error`},e.id))}),e.error&&(0,Y.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,Y.jsx)(C,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{children:e.error})]}),(p!==void 0||g!==void 0)&&(0,Y.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:[p!==void 0&&(0,Y.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.generatedTokens`,{defaultValue:`Generated tokens:`}),` `,(0,Y.jsxs)(`bdi`,{dir:`ltr`,children:[h&&`≈`,p.toLocaleString()]})]}),g!==void 0&&(0,Y.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.speed`,{defaultValue:`Speed:`}),` `,(0,Y.jsxs)(`bdi`,{dir:`ltr`,children:[g.toFixed(1),` t/s`]})]})]}),a&&!e.reasoning&&!e.response&&e.tools.length===0&&(0,Y.jsxs)(`div`,{"aria-hidden":`true`,className:`flex h-5 items-center gap-1 text-[rgb(48,121,255)]`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current motion-reduce:animate-none`}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:160ms] motion-reduce:animate-none`}),(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-ink-muted`,children:[(0,Y.jsx)(x,{className:`h-3.5 w-3.5`}),n(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]})]})}var X=e=>typeof e==`object`&&e?e:void 0;function Ct(e){let t=[];for(let n of e){let e=X(n.metadata)??X(n.arguments);if(!e)continue;let r=n.name===`write_file`?e.path:n.name===`move_file`?e.to:void 0;typeof r==`string`&&r&&!t.includes(r)&&t.push(r)}return t}function wt({role:e,user:t,persona:n,size:r=`message`}){let[i,a]=(0,J.useState)(null);if(e===`assistant`)return n?(0,Y.jsx)(`img`,{src:Ce(n,64),alt:n.name,"data-testid":`work-assistant-avatar`,onError:e=>W(e.currentTarget,n.name,64),className:l(`shrink-0 rounded-lg object-cover`,r===`empty`?`mx-auto mb-4 h-12 w-12`:`mt-0.5 h-8 w-8`)}):(0,Y.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`,r===`empty`?`mx-auto mb-4 h-12 w-12`:`mt-0.5 h-8 w-8`),children:(0,Y.jsx)(Re,{label:null,className:l(r===`empty`?`h-6 w-6`:`h-4 w-4`)})});let o=t?.username||`User`,s=t?.avatar?.trim()||``,c=!!s&&s!==i;return(0,Y.jsx)(`div`,{role:c?void 0:`img`,"aria-label":c?void 0:o,"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`,c?`border border-line bg-surface-raised`:`bg-ink text-ink-inverse`),title:o,children:c?(0,Y.jsx)(`img`,{src:s,alt:o,className:`h-full w-full object-cover`,onError:()=>a(s)}):t?(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs font-medium uppercase leading-none`,children:t.username.charAt(0)}):(0,Y.jsx)(N,{"aria-hidden":`true`,className:`h-4 w-4`})})}var Tt=(e,t)=>{let n=e.metadata,r=n?.name??n?.toolName??n?.tool??n?.command;return typeof r==`string`&&r?r:t},Et=e=>{let t=e.metadata?.toolCallId;return typeof t==`string`&&t?t:null},Dt=(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?Tt(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}},Ot=(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=Et(a);if(a.kind===`tool_call`&&e){let o=i(Dt(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]=Dt(i.call,a,t),r.delete(e);continue}}}i(Dt(a.kind===`tool_call`?a:void 0,a.kind===`tool_call`?void 0:a,t),a.id)}return n};function kt({message:e}){let{t}=c();return(0,Y.jsxs)(`details`,{"data-testid":`work-provider-reasoning`,className:`group ms-14 overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,Y.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,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(S,{className:`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`}),(0,Y.jsx)(`span`,{className:`truncate`,children:t(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,Y.jsx)(E,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),(0,Y.jsx)(`div`,{dir:`auto`,className:`border-t border-line px-3 py-2.5 text-xs leading-relaxed text-ink-muted`,children:(0,Y.jsx)(Be,{content:e.content,className:`text-xs`})})]})}function At({task:e,user:t,loading:n,loadingOlder:r,liveRun:i,onLoadOlder:a,onOpenFile:o}){let{t:s}=c(),u=(0,J.useRef)(null),f=(0,J.useRef)(!0),[p,m]=(0,J.useState)(!1),h=d(e=>e.personas),g=e.personaId??(e.model?.startsWith(`persona:`)?e.model.slice(8):null),_=g?h[g]??null:null,v=(0,J.useMemo)(()=>[...e.messages||[]].sort((e,t)=>e.messageIndex-t.messageIndex||e.createdAt-t.createdAt||e.id.localeCompare(t.id)),[e.messages]),y=i?.runId,b=(0,J.useMemo)(()=>Ot(v.filter(e=>!(y&&e.runId===y&&e.role!==`user`)),s(`work.activity.toolActivity`,{defaultValue:`Tool activity`})),[y,v,s]),x=[...v].reverse().find(e=>e.role===`assistant`&&e.kind===`message`)?.id;(0,J.useEffect)(()=>{f.current=!0;let e=u.current;e&&(e.scrollTop=e.scrollHeight);let t=window.requestAnimationFrame(()=>m(!1));return()=>window.cancelAnimationFrame(t)},[e.id]),(0,J.useEffect)(()=>{let e=u.current,t;return e&&f.current?(e.scrollTop=e.scrollHeight,t=window.requestAnimationFrame(()=>m(!1))):e&&i&&(t=window.requestAnimationFrame(()=>m(!0))),()=>{t!==void 0&&window.cancelAnimationFrame(t)}},[i,v,e.status]);let S=async()=>{let e=u.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;f.current=!1;try{await a(),requestAnimationFrame(()=>{let e=u.current;e&&(e.scrollTop=n+e.scrollHeight-t)})}catch{}};return n&&v.length===0?(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-ink-muted`,children:(0,Y.jsx)(z,{className:`h-6 w-6 animate-spin`})}):(0,Y.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,Y.jsx)(`div`,{ref:u,onScroll:e=>{let t=e.currentTarget;f.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,f.current&&m(!1)},className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Y.jsx)(`div`,{className:`mx-auto flex min-h-full max-w-3xl flex-col px-4 py-6 md:px-6`,children:v.length===0&&!i?(0,Y.jsxs)(`div`,{className:`m-auto max-w-md text-center`,children:[(0,Y.jsx)(wt,{role:`assistant`,persona:_,size:`empty`}),(0,Y.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-ink`,children:s(`work.conversation.ready`,{defaultValue:`Workspace ready`})}),(0,Y.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-ink-muted`,children:s(`work.conversation.empty`,{defaultValue:`Continue the task below. This conversation and its files stay attached to this workspace.`})})]}):(0,Y.jsxs)(`div`,{className:`space-y-6`,children:[e.hasMoreMessages&&(0,Y.jsx)(`div`,{className:`flex justify-center`,children:(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-load-older-messages`,disabled:r,onClick:()=>void S(),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,Y.jsx)(z,{className:`h-3.5 w-3.5 animate-spin`}),s(`work.conversation.loadOlder`,{defaultValue:`Load older messages`})]})}),b.map(({key:n,item:r})=>{if(r.type===`reasoning`)return(0,Y.jsx)(kt,{message:r.message},n);if(r.type===`tools`){let e=o?Ct(r.tools):[];return(0,Y.jsxs)(`div`,{className:`ms-14 space-y-1.5`,children:[r.tools.map(e=>(0,Y.jsx)(_t,{tool:e,expandedByDefault:!1},e.id)),e.length>0&&(0,Y.jsx)(`div`,{"data-testid":`work-file-chips`,className:`flex flex-wrap gap-1.5 pt-0.5`,children:e.map(e=>{let t=e.split(`/`).filter(Boolean).pop()??e;return(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-file-chip`,"data-path":e,onClick:()=>o?.(e),title:e,"aria-label":s(`work.conversation.openFile`,{defaultValue:`Open {{name}}`,name:t}),className:`flex max-w-full items-center gap-1.5 rounded-lg border border-line bg-surface px-2 py-1 text-[11px] text-ink transition-colors hover:border-line-strong hover:bg-surface-subtle`,children:[(0,Y.jsx)(V,{className:`h-3 w-3 shrink-0 text-ink-muted`}),(0,Y.jsx)(`span`,{className:`truncate`,dir:`ltr`,children:t})]},e)})})]},n)}let i=r.message,a=i.role===`user`,c=!a&&e.status===`running`&&i.id===x&&i.runId===e.activeRun?.id;return(0,Y.jsxs)(`article`,{className:l(`flex gap-3`,a&&`flex-row-reverse`),children:[(0,Y.jsx)(wt,{role:a?`user`:`assistant`,user:a?t:void 0,persona:a?void 0:_}),(0,Y.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,Y.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words text-sm leading-relaxed`,children:i.content}):c?(0,Y.jsx)(Ie,{content:i.content,className:`text-ink`}):(0,Y.jsx)(Be,{content:i.content,className:`text-sm text-ink`})})]},i.id)}),i&&(0,Y.jsxs)(`article`,{className:`flex gap-3`,"data-testid":`work-live-run-message`,children:[(0,Y.jsx)(wt,{role:`assistant`,persona:_}),(0,Y.jsx)(`div`,{className:`min-w-0 max-w-[92%] flex-1`,children:(0,Y.jsx)(St,{run:i})})]}),!i&&(e.status===`preparing`||e.status===`running`)&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 ps-14 text-xs text-ink-muted`,children:[(0,Y.jsx)(z,{className:`h-3.5 w-3.5 animate-spin`}),e.status===`preparing`?s(`work.status.preparing`,{defaultValue:`Preparing isolated workspace…`}):s(`work.status.running`,{defaultValue:`Working in the local workspace…`})]})]})})}),p&&(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-new-activity-button`,onClick:()=>{let e=u.current;e&&(e.scrollTop=e.scrollHeight),f.current=!0,m(!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,Y.jsx)(F,{className:`h-3.5 w-3.5`}),s(`work.live.newActivity`,{defaultValue:`New activity`})]})]})}var jt=45,Mt=30,Nt=70,Pt=360,Ft=480,It=9,Lt=2,Rt=10,zt=`libre-webui-work-split:`,Z=(e,t,n)=>Math.min(n,Math.max(t,e)),Bt=e=>`${zt}${encodeURIComponent(e||`local`)}`,Vt=e=>{if(typeof window>`u`)return jt;try{let t=window.localStorage.getItem(e);if(t===null||t.trim()===``)return jt;let n=Number(t);return Number.isFinite(n)?Z(n,Mt,Nt):jt}catch{return jt}},Ht=(e,t)=>{if(!(typeof window>`u`))try{window.localStorage.setItem(e,t.toFixed(2))}catch{}},Q=e=>{let t=Math.max(0,e-It);if(t===0)return{min:Mt,max:Nt};let n=Math.max(Mt,Pt/t*100),r=Math.min(Nt,(t-Ft)/t*100);if(n<=r)return{min:n,max:r};let i=Z(Pt/840*100,Mt,Nt);return{min:i,max:i}},Ut=(e,t)=>Z(e,t.min,t.max);function Wt({conversation:e,workspace:t,userId:n,mobileSurface:r=`conversation`,className:i}){let{t:a,i18n:o}=c(),s=u(o.language),d=Bt(n),[f,p]=(0,J.useState)(()=>({storageKey:d,percent:Vt(d)})),[m,h]=(0,J.useState)(0),[g,_]=(0,J.useState)(!1),v=(0,J.useRef)(null),y=(0,J.useRef)(null),b=(0,J.useRef)(null),x=(0,J.useRef)(d),S=(0,J.useRef)(f.percent),C=(0,J.useRef)(null),w=f.storageKey===d?f.percent:Vt(d),T=(0,J.useMemo)(()=>Q(m),[m]),E=Ut(w,T),D=Math.round(E),O=100-D,k=(0,J.useCallback)(e=>{p({storageKey:d,percent:e})},[d]),A=(0,J.useCallback)(e=>{let t=Ut(e,Q(v.current?.getBoundingClientRect().width??0));S.current=t,C.current===null&&(C.current=window.requestAnimationFrame(()=>{C.current=null,k(S.current)}))},[k]),j=(0,J.useCallback)(()=>{if(b.current===null&&!g)return;C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null);let e=v.current?.getBoundingClientRect().width??0,t=Ut(S.current,Q(e));S.current=t,k(t),Ht(x.current,t);let n=b.current;b.current=null,n!==null&&y.current?.hasPointerCapture(n)&&y.current.releasePointerCapture(n),_(!1)},[g,k]),M=(0,J.useCallback)(e=>{let t=v.current?.getBoundingClientRect();if(!t)return S.current;let n=Math.max(1,t.width-It);return((s?t.right-e:e-t.left)-It/2)/n*100},[s]),ee=e=>{e.button!==0||!e.isPrimary||(e.preventDefault(),e.stopPropagation(),b.current=e.pointerId,x.current=d,S.current=E,e.currentTarget.setPointerCapture(e.pointerId),_(!0))},N=(0,J.useCallback)(e=>{let t=Ut(e,T);S.current=t,k(t),Ht(d,t)},[T,k,d]),te=(0,J.useCallback)(()=>{N(jt)},[N]),P=e=>{let t=e.shiftKey?Rt:Lt,n=null;e.key===`ArrowLeft`?n=E+(s?t:-t):e.key===`ArrowRight`?n=E+(s?-t:t):e.key===`Home`?n=T.min:e.key===`End`?n=T.max:e.key===`Enter`&&(n=jt),n!==null&&(e.preventDefault(),N(n))};(0,J.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,J.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(),A(M(e.clientX)))},r=e=>{e.pointerId===b.current&&j()};return window.addEventListener(`pointermove`,n,{passive:!1}),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r),window.addEventListener(`blur`,j),()=>{window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r),window.removeEventListener(`blur`,j),document.body.style.cursor=e,document.body.style.userSelect=t}},[j,g,M,A]),(0,J.useEffect)(()=>()=>{C.current!==null&&window.cancelAnimationFrame(C.current),b.current!==null&&Ht(x.current,S.current)},[]);let F={gridTemplateColumns:`minmax(0, ${E}fr) ${It}px minmax(0, ${100-E}fr)`};return(0,Y.jsxs)(`div`,{ref:v,"data-testid":`work-split-pane`,"data-split-percent":E.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:F,children:[(0,Y.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,Y.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(T.min),"aria-valuemax":Math.round(T.max),"aria-valuenow":D,"aria-valuetext":a(`work.workspace.splitSize`,{conversation:D,workspace:O,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:ee,onDoubleClick:te,onKeyDown:P,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-primary-500`),children:[(0,Y.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-primary-500 group-focus-visible:bg-primary-500`,g&&`bg-primary-500`)}),(0,Y.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-primary-500 group-hover:opacity-100`,`group-focus-visible:h-20 group-focus-visible:bg-primary-500 group-focus-visible:opacity-100`,g&&`h-20 bg-primary-500 opacity-100`)})]}),(0,Y.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,Y.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 Gt=`/assets/workAudioProcessor-CLKlf7Jk.js`,Kt=44100,qt=2;async function Jt(e,t){let n=new AudioContext,r;try{await n.audioWorklet.addModule(Gt),r=new AudioWorkletNode(n,`libre-work-audio`,{outputChannelCount:[2],processorOptions:{sourceRate:Kt}}),r.connect(n.destination),await n.resume()}catch(e){throw await n.close().catch(()=>void 0),e}let i;try{i=new WebSocket(e)}catch(e){throw r.disconnect(),await n.close().catch(()=>void 0),e}i.binaryType=`arraybuffer`;let a=new Uint8Array;i.onmessage=e=>{if(!(e.data instanceof ArrayBuffer))return;let t=new Uint8Array(e.data),n=new Uint8Array(a.length+t.length);n.set(a,0),n.set(t,a.length);let i=n.length-n.length%4;if(a=n.slice(i),i===0)return;let o=new Int16Array(n.buffer,0,i/2),s=o.length/qt,c=new Float32Array(s),l=new Float32Array(s);for(let e=0;e<s;e++)c[e]=o[e*qt]/32768,l[e]=o[e*qt+1]/32768;r.port.postMessage({left:c,right:l},[c.buffer,l.buffer])};let o=()=>{i.onmessage=null,i.onclose=null;try{i.close()}catch{}r.disconnect(),n.close().catch(()=>void 0)};return i.onclose=()=>{o(),t()},i.onerror=()=>{o(),t()},{stop:o}}var Yt=3e3,Xt=6e4,Zt=5e3;function Qt({taskId:e,active:t,variant:n=`full`,onExpand:i}){let{t:a}=c(),o=(0,J.useRef)(null),s=(0,J.useRef)(null),[l,u]=(0,J.useState)(`view`),[d,f]=(0,J.useState)(0),[p,m]=(0,J.useState)(()=>({taskId:e,active:t,attempt:d,mode:l,state:t?`starting`:`idle`,error:null})),h=p.taskId===e&&p.active===t&&p.attempt===d&&p.mode===l,g=h?p:{taskId:e,active:t,attempt:d,mode:l,state:t?`starting`:`idle`,error:null};h||m(g);let{state:_,error:y}=g,x=(0,J.useCallback)(n=>{m(r=>r.taskId!==e||r.active!==t||r.attempt!==d||r.mode!==l?r:{...r,...n})},[e,t,d,l]),[S,C]=(0,J.useState)({agentWaiting:!1}),[w,T]=(0,J.useState)(!1),[E,D]=(0,J.useState)(`idle`),[k,A]=(0,J.useState)(``),[j,ee]=(0,J.useState)(null),N=(0,J.useRef)([]),te=(0,J.useRef)(0),P=(0,J.useRef)(null),[F,I]=(0,J.useState)(!1),ie=(0,J.useRef)(null),L=(0,J.useRef)(0),R=(0,J.useCallback)(()=>{L.current+=1;let e=ie.current;ie.current=null,e?.stop(),I(!1)},[]),ae=(0,J.useCallback)(async()=>{if(ie.current){R();return}let t=L.current+1;L.current=t;try{let n=await dt(e);if(L.current!==t)return;let r=await Jt(n,()=>{L.current===t&&(L.current+=1,ie.current=null,I(!1))});if(L.current!==t){r.stop();return}ie.current=r,I(!0)}catch(e){if(L.current!==t)return;ye.warn(`Work screen audio failed to start:`,e),R()}},[e,R]);(0,J.useEffect)(()=>{if(!(!t||_!==`connected`))return R},[t,_,R]);let oe=(0,J.useCallback)(()=>{try{s.current?.disconnect()}catch{}s.current=null},[]);(0,J.useEffect)(()=>{if(!t)return;let n=!1,i;return(async()=>{try{let t=await rt(e);n||T(!!t.viewOnlyPassword);let a=t.viewOnlyPassword;l===`control`&&(a=(await at(e)).controlPassword,i=setInterval(()=>{at(e).catch(e=>{ye.warn(`Screen control renewal failed:`,e),n||u(`view`)})},Xt));let[{default:c},d]=await Promise.all([r(()=>import(`./rfb-BOfFBtVG.js`),[]),ut(e)]);if(n||!o.current)return;let f=new c(o.current,d,{shared:!0,...a?{credentials:{password:a}}:{}});f.viewOnly=l!==`control`,f.scaleViewport=!0,f.background=`transparent`,f.addEventListener(`connect`,()=>{n||x({state:`connected`})}),f.addEventListener(`disconnect`,()=>{n||x({state:`disconnected`})}),s.current=f}catch(e){if(ye.error(`Work screen connection failed:`,e),n)return;x({error:e.response?.data?.message??null,state:`disconnected`}),l===`control`&&u(`view`)}})(),()=>{n=!0,i&&clearInterval(i),oe(),l===`control`&&ot(e).catch(()=>void 0)}},[e,t,d,l,oe,x]),(0,J.useEffect)(()=>{if(!t||n===`mini`)return;let r=!1,i=async()=>{try{let t=await it(e);r||C(t)}catch{}};i();let a=setInterval(i,Yt);return()=>{r=!0,clearInterval(a)}},[e,t,n]),(0,J.useEffect)(()=>{if(E!==`recording`||_!==`connected`||l!==`control`)return;let t=o.current;if(!t)return;te.current=performance.now(),N.current=[];let n=(e,n)=>{let r=t.querySelector(`canvas`);if(!r)return;let i=r.getBoundingClientRect();if(i.width<=0||i.height<=0)return;P.current={width:r.width,height:r.height};let a=(e,t)=>Math.max(0,Math.min(t,Math.round(e)));return{x:a((e-i.left)*r.width/i.width,r.width),y:a((n-i.top)*r.height/i.height,r.height)}},r=()=>Math.round(performance.now()-te.current),i=e=>{N.current.length<Zt&&N.current.push(e)},a=t=>a=>{let o=n(a.clientX,a.clientY);if(!o)return;let s={t:r(),kind:t,...o,button:a.button};i(s),t===`down`&&ct(e,o.x,o.y).then(({anchor:e,url:t})=>{e&&(s.anchor=e),t&&(s.url=t)}).catch(()=>void 0)},s=e=>{let t=n(e.clientX,e.clientY);t&&i({t:r(),kind:`wheel`,...t,dy:Math.sign(e.deltaY)})},c=e=>{i({t:r(),kind:`key`,key:e.key,...e.ctrlKey?{ctrl:!0}:{},...e.altKey?{alt:!0}:{},...e.metaKey?{meta:!0}:{},...e.shiftKey?{shift:!0}:{}})},u=a(`down`),d=a(`up`);return t.addEventListener(`pointerdown`,u,!0),t.addEventListener(`pointerup`,d,!0),t.addEventListener(`wheel`,s,!0),t.addEventListener(`keydown`,c,!0),()=>{t.removeEventListener(`pointerdown`,u,!0),t.removeEventListener(`pointerup`,d,!0),t.removeEventListener(`wheel`,s,!0),t.removeEventListener(`keydown`,c,!0)}},[E,_,l,e]);let se=(0,J.useCallback)(()=>{u(`control`)},[]),B=(0,J.useCallback)(()=>{ot(e).catch(()=>void 0),u(`view`)},[e]),le=(0,J.useCallback)(()=>{ee(null),D(`recording`),u(`control`)},[]),ue=(0,J.useCallback)(()=>{ot(e).catch(()=>void 0),u(`view`),D(`naming`)},[e]),de=(0,J.useCallback)(()=>{N.current=[],A(``),D(`idle`),l===`control`&&(ot(e).catch(()=>void 0),u(`view`))},[e,l]),pe=(0,J.useCallback)(async()=>{let t=k.trim();if(t){D(`saving`);try{let n=await lt(e,{name:t,events:N.current,...P.current?{screenWidth:P.current.width,screenHeight:P.current.height}:{}});N.current=[],A(``),D(`idle`),ee(n.name),setTimeout(()=>ee(null),6e3)}catch(e){ye.error(`Saving the demonstration failed:`,e),x({error:e.response?.data?.message??null}),D(`naming`)}}},[e,k,x]),V=l===`control`&&_===`connected`,me=S.holder!==void 0&&!S.holder.you,he=S.takeoverEnabled!==!1,ge=w&&he&&_===`connected`&&l===`view`&&!me,_e=E===`recording`&&_===`connected`,ve=`flex items-center gap-1.5 rounded-lg border border-line px-2.5 py-1 text-xs text-ink transition-colors hover:bg-surface-subtle`;return n===`mini`?(0,Y.jsxs)(`div`,{className:`relative aspect-[8/5] w-full overflow-hidden rounded-xl border border-line bg-canvas`,"data-testid":`work-screen-mini`,children:[(0,Y.jsx)(`div`,{ref:o,className:`h-full w-full`}),_!==`connected`&&(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-2 px-4 text-center`,children:_===`starting`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{size:16,className:`animate-spin text-white/60`}),(0,Y.jsx)(`p`,{className:`text-xs text-white/70`,children:a(`work.screen.starting`)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(re,{size:18,className:`text-white/40`}),(0,Y.jsx)(`p`,{className:`text-xs text-white/70`,children:y??a(`work.screen.disconnected`)})]})}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`work-screen-mini-expand`,onClick:i,"aria-label":a(`work.agent.openScreen`,{defaultValue:`Open the full screen view`}),className:`absolute inset-0 cursor-pointer bg-transparent transition-colors hover:bg-white/5 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500/60`})]}):(0,Y.jsxs)(`div`,{className:`flex h-full min-h-[16rem] w-full flex-col`,"data-testid":`work-screen`,children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-line bg-surface px-3 py-2`,children:[(0,Y.jsx)(`div`,{className:`rounded-md px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide ${_e?`bg-red-500/15 text-red-500`:V?`bg-emerald-500/15 text-emerald-500`:`bg-surface-subtle text-ink-muted`}`,"data-testid":`work-screen-mode`,children:_e?a(`work.screen.recording`):V?a(`work.screen.youHaveControl`):me?a(`work.screen.otherHasControl`,{name:S.holder?.username??`…`}):a(`work.screen.viewOnly`)}),j&&(0,Y.jsx)(`div`,{className:`rounded-md bg-emerald-500/15 px-2 py-0.5 text-[11px] text-emerald-500`,children:a(`work.screen.teachSaved`,{name:j})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`work-screen-audio`,onClick:()=>void ae(),disabled:_!==`connected`,"aria-label":a(F?`work.screen.mute`:`work.screen.unmute`),className:`${ve} disabled:opacity-40 ${F?`border-emerald-500/50 text-emerald-500`:``}`,children:F?(0,Y.jsx)(ce,{size:13}):(0,Y.jsx)(M,{size:13})}),ge&&E===`idle`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-screen-take-over`,onClick:se,className:ve,children:[(0,Y.jsx)(ne,{size:13}),a(`work.screen.takeOver`)]}),(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-screen-teach`,onClick:le,className:ve,children:[(0,Y.jsx)(fe,{size:13}),a(`work.screen.teach`)]})]}),V&&E===`idle`&&(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-screen-hand-back`,onClick:B,className:`${ve} border-emerald-500/50 text-emerald-500`,children:[(0,Y.jsx)(v,{size:13}),a(`work.screen.handBack`)]}),V&&E===`recording`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-screen-teach-stop`,onClick:ue,className:`${ve} border-red-500/50 text-red-500`,children:[(0,Y.jsx)(b,{size:9,className:`animate-pulse fill-current`}),a(`work.screen.teachSave`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:de,className:ve,children:a(`work.screen.teachDiscard`)})]})]}),(0,Y.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-canvas ${_e?`ring-2 ring-inset ring-red-500`:V?`ring-2 ring-inset ring-emerald-500`:``}`,children:[_e&&(0,Y.jsxs)(`div`,{className:`absolute inset-x-0 top-0 z-10 flex items-center justify-center gap-2 bg-red-600/95 py-1 text-[11px] font-medium text-white`,"data-testid":`work-screen-watching-banner`,children:[(0,Y.jsx)(b,{size:8,className:`animate-pulse fill-current`}),a(`work.screen.watchingLearning`)]}),(0,Y.jsx)(`div`,{ref:o,className:`h-full w-full`}),_!==`connected`&&(0,Y.jsx)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-3 px-6 text-center`,children:_===`starting`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{size:20,className:`animate-spin text-white/60`}),(0,Y.jsx)(`p`,{className:`text-sm text-white/70`,children:a(`work.screen.starting`)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(re,{size:22,className:`text-white/40`}),(0,Y.jsx)(`p`,{className:`text-sm text-white/70`,children:y??a(`work.screen.disconnected`)}),(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-screen-reconnect`,onClick:()=>f(e=>e+1),className:`flex items-center gap-2 rounded-lg border border-white/20 px-3 py-1.5 text-xs text-white/80 transition-colors hover:bg-white/10`,children:[(0,Y.jsx)(O,{size:12}),a(`work.screen.reconnect`)]})]})}),(E===`naming`||E===`saving`)&&(0,Y.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center bg-black/60`,children:(0,Y.jsxs)(`div`,{className:`flex w-72 flex-col gap-3 rounded-xl border border-line bg-surface-raised p-4 shadow-xl`,children:[(0,Y.jsx)(`input`,{autoFocus:!0,value:k,onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Enter`&&pe()},placeholder:a(`work.screen.teachNamePlaceholder`),"data-testid":`work-screen-teach-name`,className:`rounded-lg border border-line bg-surface px-3 py-2 text-sm text-ink outline-none placeholder:text-ink-subtle focus:border-line-strong`}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:de,disabled:E===`saving`,className:`rounded-lg px-3 py-1.5 text-xs text-ink-muted transition-colors hover:bg-surface-subtle`,children:a(`work.screen.teachDiscard`)}),(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-screen-teach-confirm`,onClick:()=>void pe(),disabled:E===`saving`||!k.trim(),className:`flex items-center gap-2 rounded-lg bg-emerald-600 px-3 py-1.5 text-xs text-white transition-colors hover:bg-emerald-500 disabled:opacity-50`,children:[E===`saving`&&(0,Y.jsx)(z,{size:12,className:`animate-spin`}),a(`work.screen.teachSave`)]})]})]})}),S.agentWaiting&&!V&&_===`connected`&&(0,Y.jsxs)(`div`,{className:`absolute bottom-3 left-1/2 flex max-w-[90%] -translate-x-1/2 items-center gap-3 rounded-lg bg-amber-500/90 px-3 py-2 text-xs text-black shadow-lg backdrop-blur`,"data-testid":`work-screen-agent-waiting`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:a(`work.screen.agentWaiting`)}),S.agentWaitingReason&&(0,Y.jsx)(`span`,{className:`truncate opacity-80`,children:S.agentWaitingReason}),w&&he&&!me&&(0,Y.jsx)(`button`,{type:`button`,onClick:se,className:`shrink-0 rounded-md bg-black/80 px-2 py-1 text-[11px] text-white transition-colors hover:bg-black`,children:a(`work.screen.takeOver`)})]})]})]})}var $t=`taught-`,en=`mb-2 text-[11px] font-medium uppercase tracking-wide text-ink-subtle`;function tn({task:e,persona:t,active:n,onOpenScreen:r}){let{t:i,i18n:a}=c(),o=ze[e.status],s=i(o.labelKey,{defaultValue:o.label}),[u,d]=(0,J.useState)([]),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(!1),[y,b]=(0,J.useState)(!1),[x,S]=(0,J.useState)([]),[C,w]=(0,J.useState)(!1),T=(0,J.useCallback)(async()=>{try{let t=await Se.getAutomations();t.success&&Array.isArray(t.data)&&d(t.data.filter(t=>t.workTaskId===e.id))}catch{}finally{m(!0)}},[e.id]),E=(0,J.useCallback)(async()=>{try{let e=await G.list();e.success&&Array.isArray(e.data)&&S(e.data.filter(e=>e.slug.startsWith($t)))}catch{}finally{w(!0)}},[]);(0,J.useEffect)(()=>{if(!n)return;let e=window.setTimeout(()=>{T(),E()},0);return()=>window.clearTimeout(e)},[n,T,E]);let D=async e=>{g(e.id);try{let t=e.status===`active`?await Se.pauseAutomation(e.id):await Se.resumeAutomation(e.id);if(!t.success)throw Error(t.message);await T()}catch{j.error(i(`work.agent.routineToggleFailed`,{defaultValue:`Could not update the routine.`}))}finally{g(null)}},O=async e=>{b(!0);try{let t=await Se.createAutomation(e);if(!t.success)throw Error(t.message);v(!1),await T()}catch{j.error(i(`work.agent.routineSaveFailed`,{defaultValue:`Could not save the routine.`}))}finally{b(!1)}},A=async(e,t)=>{S(n=>n.map(n=>n.id===e.id?{...n,enabled:t}:n));try{await G.update(e.id,{enabled:t})}catch{S(t=>t.map(t=>t.id===e.id?{...t,enabled:e.enabled}:t)),j.error(i(`work.agent.skillToggleFailed`,{defaultValue:`Could not update the skill.`}))}};return(0,Y.jsxs)(`div`,{"data-testid":`work-agent-panel`,className:`flex flex-col gap-6 p-4 sm:p-5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Y.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,Y.jsx)(`img`,{src:t?Ce(t,96):we(e.title,96),alt:``,"aria-hidden":`true`,"data-testid":`work-agent-avatar`,onError:n=>W(n.currentTarget,t?.name??e.title,96),className:`h-12 w-12 rounded-xl object-cover`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:l(`absolute -bottom-0.5 -end-0.5 h-3 w-3 rounded-full border-2 border-surface`,o.animated&&`animate-pulse`),style:{backgroundColor:o.color}})]}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`h3`,{dir:`auto`,className:`truncate text-[15px] font-medium leading-6 text-ink`,title:e.title,children:e.title}),(0,Y.jsx)(`p`,{className:`text-xs text-ink-muted`,children:t?i(`work.agent.personaLine`,{defaultValue:`Persona: {{name}}`,name:t.name}):s}),e.statusBlurb&&(0,Y.jsx)(`p`,{dir:`auto`,"data-testid":`work-agent-blurb`,className:`mt-1 text-[13px] leading-5 text-ink-subtle`,children:e.statusBlurb})]})]}),e.computerAvailable&&(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:en,children:i(`work.agent.screen`,{defaultValue:`Screen`})}),(0,Y.jsx)(Qt,{taskId:e.id,active:n,variant:`mini`,onExpand:r})]}),(0,Y.jsxs)(`section`,{"data-testid":`work-agent-routines`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,Y.jsx)(`h4`,{className:l(en,`mb-0`),children:i(`work.agent.routines`,{defaultValue:`Routines`})}),(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-agent-add-routine`,onClick:()=>v(!0),className:`flex items-center gap-1 rounded-lg px-2 py-1 text-[12px] font-medium text-primary-600 transition-colors hover:bg-primary-500/10 dark:text-primary-400`,children:[(0,Y.jsx)(k,{className:`h-3.5 w-3.5`}),i(`work.agent.addRoutine`,{defaultValue:`Routine`})]})]}),u.length===0?(0,Y.jsx)(`p`,{className:`text-xs leading-relaxed text-ink-subtle`,children:p?i(`work.agent.noRoutines`,{defaultValue:`No routines yet. A routine runs an instruction on a schedule, inside this agent’s workspace.`}):`…`}):(0,Y.jsx)(`ul`,{className:`space-y-1`,children:u.map(e=>(0,Y.jsxs)(`li`,{"data-testid":`work-agent-routine`,className:`flex items-center gap-3 rounded-xl border border-line bg-surface px-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{dir:`auto`,className:l(`truncate text-[13px] leading-5`,e.status===`active`?`text-ink`:`text-ink-subtle line-through decoration-ink-subtle/40`),title:e.name,children:e.name}),(0,Y.jsx)(`p`,{className:`truncate text-[11px] text-ink-subtle`,children:Ve(e.triggers,a.language,i)})]}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`work-agent-routine-toggle`,disabled:h===e.id,onClick:()=>void D(e),"aria-label":e.status===`active`?i(`automations.pause`,{defaultValue:`Pause`}):i(`automations.resume`,{defaultValue:`Resume`}),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg text-ink-muted transition-colors hover:bg-surface-subtle hover:text-ink disabled:opacity-40`,children:e.status===`active`?(0,Y.jsx)(R,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(f,{className:`h-3.5 w-3.5`})})]},e.id))})]}),(0,Y.jsxs)(`section`,{"data-testid":`work-agent-skills`,children:[(0,Y.jsx)(`h4`,{className:en,children:i(`work.agent.skills`,{defaultValue:`Taught skills`})}),x.length===0?(0,Y.jsx)(`p`,{className:`text-xs leading-relaxed text-ink-subtle`,children:C?i(`work.agent.noSkills`,{defaultValue:`Nothing taught yet. Use Teach on the Screen tab to demonstrate a procedure once; it becomes a replayable skill.`}):`…`}):(0,Y.jsx)(`ul`,{className:`space-y-1`,children:x.map(e=>(0,Y.jsxs)(`li`,{"data-testid":`work-agent-skill`,className:`flex items-center gap-3 rounded-xl border border-line bg-surface px-3 py-2`,children:[(0,Y.jsx)(fe,{className:`h-4 w-4 shrink-0 text-ink-muted`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{dir:`auto`,className:`truncate text-[13px] leading-5 text-ink`,title:e.name,children:e.name}),e.description&&(0,Y.jsx)(`p`,{className:`truncate text-[11px] text-ink-subtle`,children:e.description})]}),(0,Y.jsx)(Le,{checked:e.enabled,onChange:t=>void A(e,t)})]},e.id))})]}),(0,Y.jsx)(He,{open:_,automation:null,fixedWorkTaskId:e.id,models:[],saving:y,onClose:()=>v(!1),onSave:e=>void O(e)})]})}var nn=1e5,rn=4e3,an={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`},on={".bashrc":`bash`,".zshrc":`bash`},sn={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`}},cn=e=>e.split(/[\\/]/).pop()?.toLowerCase()??``,ln=e=>{let t=cn(e),n=t.lastIndexOf(`.`);return n>-1?t.slice(n+1):``},un=e=>on[cn(e)]??an[ln(e)]??`text`,dn=e=>sn[ln(e)],fn=e=>dn(e)!==void 0,pn=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},$=async e=>(await e).default,mn=async(e,t)=>{switch(e.family){case`babel`:return Promise.all([$(r(()=>import(`./babel-D7QYvEns.js`),__vite__mapDeps([0,1,2,3]))),$(r(()=>import(`./estree-D7xT4AeP.js`),__vite__mapDeps([4,1,2,3,5])))]);case`typescript`:return Promise.all([$(r(()=>import(`./typescript-LOiqVRM1.js`),__vite__mapDeps([6,1,2,3,5]))),$(r(()=>import(`./estree-D7xT4AeP.js`),__vite__mapDeps([4,1,2,3,5])))]);case`postcss`:return[await $(r(()=>import(`./postcss-RCIJRrFm.js`),__vite__mapDeps([7,1,2,3])))];case`html`:{let e=[await $(r(()=>import(`./html-HvA9vEyn.js`),__vite__mapDeps([8,1,2,3,5])))];return/<script\b/i.test(t)&&e.push(await $(r(()=>import(`./babel-D7QYvEns.js`),__vite__mapDeps([0,1,2,3]))),await $(r(()=>import(`./estree-D7xT4AeP.js`),__vite__mapDeps([4,1,2,3,5])))),/<script\b[^>]*\blang\s*=\s*["']?(?:ts|typescript)/i.test(t)&&e.push(await $(r(()=>import(`./typescript-LOiqVRM1.js`),__vite__mapDeps([6,1,2,3,5])))),/<style\b/i.test(t)&&e.push(await $(r(()=>import(`./postcss-RCIJRrFm.js`),__vite__mapDeps([7,1,2,3])))),[...new Set(e)]}case`markdown`:{let n=[await $(r(()=>import(`./markdown-DaF0SXNk.js`),__vite__mapDeps([9,1,2,3,5])))],i=e=>RegExp(`^(?: {0,3})(?:\`{3,}|~{3,})\\s*(?:${e})(?:\\s|$)`,`im`).test(t);return e.parser===`mdx`&&n.push(await $(r(()=>import(`./babel-D7QYvEns.js`),__vite__mapDeps([0,1,2,3]))),await $(r(()=>import(`./estree-D7xT4AeP.js`),__vite__mapDeps([4,1,2,3,5])))),i(`js|jsx|javascript|json|json5|jsonc`)&&n.push(await $(r(()=>import(`./babel-D7QYvEns.js`),__vite__mapDeps([0,1,2,3]))),await $(r(()=>import(`./estree-D7xT4AeP.js`),__vite__mapDeps([4,1,2,3,5])))),i(`ts|tsx|typescript`)&&n.push(await $(r(()=>import(`./typescript-LOiqVRM1.js`),__vite__mapDeps([6,1,2,3,5]))),await $(r(()=>import(`./estree-D7xT4AeP.js`),__vite__mapDeps([4,1,2,3,5])))),i(`css|scss|less`)&&n.push(await $(r(()=>import(`./postcss-RCIJRrFm.js`),__vite__mapDeps([7,1,2,3])))),i(`html`)&&n.push(await $(r(()=>import(`./html-HvA9vEyn.js`),__vite__mapDeps([8,1,2,3,5]))),await $(r(()=>import(`./babel-D7QYvEns.js`),__vite__mapDeps([0,1,2,3]))),await $(r(()=>import(`./estree-D7xT4AeP.js`),__vite__mapDeps([4,1,2,3,5]))),await $(r(()=>import(`./typescript-LOiqVRM1.js`),__vite__mapDeps([6,1,2,3,5]))),await $(r(()=>import(`./postcss-RCIJRrFm.js`),__vite__mapDeps([7,1,2,3])))),i(`yaml|yml`)&&n.push(await $(r(()=>import(`./yaml-CyhEdlt2.js`),__vite__mapDeps([10,1,2,3])))),[...new Set(n)]}case`yaml`:return[await $(r(()=>import(`./yaml-CyhEdlt2.js`),__vite__mapDeps([10,1,2,3])))]}},hn=async(e,t)=>{let n=dn(e);if(!n)throw Error(`Formatting is not supported for “${cn(e)||e}”.`);if(!pn(t))throw Error(`Could not format “${cn(e)||e}”: files are limited to ${nn.toLocaleString()} characters and ${rn.toLocaleString()} lines.`);try{let[{format:e},i]=await Promise.all([r(()=>import(`./standalone-BMD7E0jY.js`),__vite__mapDeps([11,1,2,3,5])),mn(n,t)]);return await e(t,{parser:n.parser,plugins:i,tabWidth:2,useTabs:!1})}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Could not format “${cn(e)||e}”: ${n}`)}},gn=(0,J.lazy)(async()=>({default:(await r(()=>import(`./OptimizedSyntaxHighlighter-oiyvxgDA.js`),__vite__mapDeps([12,13,2,3,14]))).OptimizedSyntaxHighlighter})),_n=8e3,vn=400,yn=500;function bn({path:e,value:t,ariaLabel:n,disabled:r=!1,onChange:i,onSaveShortcut:a,onFormatShortcut:o}){let{t:s}=c(),u=Fe(e=>e.theme.mode!==`light`),d=(0,J.useRef)(null),f=(0,J.useRef)(null),[p,m]=(0,J.useState)(``),h=(0,J.useMemo)(()=>un(e),[e]),g=(0,J.useMemo)(()=>{if(t.length>_n)return 401;let e=1;for(let n=0;n<t.length&&!(t.charCodeAt(n)===10&&(e+=1,e>vn));n+=1);return e},[t]),_=t.length>_n||g>vn,v=h!==`text`&&!_,y=v&&p===t;return(0,J.useEffect)(()=>{if(!v)return;let e=window.setTimeout(()=>m(t),yn);return()=>window.clearTimeout(e)},[v,e,t]),(0,J.useLayoutEffect)(()=>{!y||!d.current||!f.current||(d.current.style.transform=`translate3d(${-f.current.scrollLeft}px, ${-f.current.scrollTop}px, 0)`)},[y,e]),(0,Y.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,Y.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`work-file-highlight`,className:`pointer-events-none absolute inset-0 z-0 overflow-hidden`,children:(0,Y.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,Y.jsx)(J.Suspense,{fallback:(0,Y.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,Y.jsx)(gn,{language:h,isDark:u,codeTheme:`night`,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,Y.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,Y.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 xn=4e6,Sn=e=>{if(e===``)return[];let t=e.split(`
4
- `);return t[t.length-1]===``&&t.pop(),t},Cn=(e,t)=>{let n=Sn(e),r=Sn(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=wn(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},wn=(e,t)=>{if(e.length===0&&t.length===0)return[];if(e.length>0&&t.length>0&&e.length*t.length>xn)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},Tn=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}},En=3,Dn=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-En),i=Math.min(e.length-1,n+En);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 On({line:e}){return(0,Y.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,Y.jsx)(`td`,{className:`w-10 select-none px-2 text-right align-top text-[10px] tabular-nums text-ink-subtle`,children:e.beforeLine??``}),(0,Y.jsx)(`td`,{className:`w-10 select-none px-2 text-right align-top text-[10px] tabular-nums text-ink-subtle`,children:e.afterLine??``}),(0,Y.jsxs)(`td`,{className:`w-full whitespace-pre-wrap break-all px-3 align-top`,children:[(0,Y.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 kn=new Set,An=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 jn({lines:e}){let{t}=c(),n=(0,J.useMemo)(()=>Dn(e),[e]),r=(0,J.useMemo)(()=>An(n),[n]),[i,a]=(0,J.useState)({rows:null,set:kn}),o=i.rows===n?i.set:kn,s=e=>a({rows:n,set:new Set(o).add(e)});return(0,Y.jsx)(`table`,{className:`w-full border-collapse`,children:(0,Y.jsx)(`tbody`,{children:n.map((e,n)=>{let i=r[n];return(0,Y.jsxs)(J.Fragment,{children:[i>0&&(0,Y.jsx)(`tr`,{"data-testid":`work-diff-gap`,children:(0,Y.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,Y.jsx)(J.Fragment,{children:e.lines.map((e,t)=>(0,Y.jsx)(On,{line:e},t))},`fold-${n}`):(0,Y.jsx)(`tr`,{children:(0,Y.jsx)(`td`,{colSpan:3,className:`p-0`,children:(0,Y.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,Y.jsx)(ve,{className:`h-3 w-3 shrink-0`}),t(`work.files.diffFolded`,{count:e.count,defaultValue:`{{count}} unchanged lines`})]})})},`fold-${n}`):(0,Y.jsx)(On,{line:e.line},`line-${n}`)}}function Mn({lines:e,ariaLabel:t}){return(0,Y.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,Y.jsx)(jn,{lines:e})})}var Nn=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},Pn=e=>{let t=Nn(e);return t.startsWith(`a/`)||t.startsWith(`b/`)?t.slice(2):t},Fn=e=>{let t=e.slice(11).trim();if(t.startsWith(`"`)){let e=t.indexOf(`" `,1);return e===-1?null:{oldPath:Pn(t.slice(0,e+1)),newPath:Pn(t.slice(e+2).trim())}}let n=t.lastIndexOf(` b/`);if(n===-1){let e=t.indexOf(` `);return e===-1?null:{oldPath:Pn(t.slice(0,e)),newPath:Pn(t.slice(e+1))}}return{oldPath:Pn(t.slice(0,n)),newPath:Pn(t.slice(n+1))}},In=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/,Ln=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:Tn(e.lines)}),Rn=e=>{let t=[],n=null;for(let r of e.split(`
6
- `)){if(r.startsWith(`diff --git `)){n&&t.push(Ln(n));let e=Fn(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=Nn(r.slice(12));continue}if(r.startsWith(`rename to `)){n.status=`renamed`,n.newPath=Nn(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=Pn(e));continue}if(r.startsWith(`+++ `)){let e=r.slice(4).trim();e!==`/dev/null`&&n.status!==`renamed`&&(n.newPath=Pn(e));continue}let e=r.match(In);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(Ln(n)),t},zn=e=>{let t=0,n=0;for(let r of e)t+=r.stats.added,n+=r.stats.removed;return{added:t,removed:n}},Bn=(e,t)=>{if(e.success&&e.data)return e.data;throw Error(e.error||t)},Vn=(e,t)=>{let n=e?.response?.data?.error;return typeof n==`string`&&n?n:e instanceof Error&&e.message?e.message:t},Hn=e=>e.indexStatus===`?`,Un=e=>Hn(e)?`U`:e.workingTreeStatus===`.`?e.indexStatus:e.workingTreeStatus,Wn=e=>({modified:`M`,added:`A`,deleted:`D`,renamed:`R`})[e],Gn=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`,Kn=e=>{let t=e.lastIndexOf(`/`);return t===-1?{name:e,directory:``}:{name:e.slice(t+1),directory:e.slice(0,t)}};function qn({added:e,removed:t,muted:n=!1}){return(0,Y.jsxs)(`span`,{dir:`ltr`,className:`shrink-0 font-mono text-[10px] tabular-nums`,children:[(0,Y.jsxs)(`span`,{className:n?`text-ink-subtle`:`text-[rgb(46,164,79)]`,children:[`+`,e]}),` `,(0,Y.jsxs)(`span`,{className:n?`text-ink-subtle`:`text-[rgb(255,61,129)]`,children:[`−`,t]})]})}function Jn({letter:e,path:t,oldPath:n,added:r,removed:i}){return(0,Y.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,Y.jsx)(`span`,{"aria-hidden":`true`,className:l(`w-4 shrink-0 text-center font-mono text-[11px] font-semibold`,Gn(e)),children:e}),(0,Y.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,Y.jsx)(qn,{added:r,removed:i})]})}function Yn({taskId:e,mutationsDisabled:t=!1,disabledReason:n}){let{t:r}=c(),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(!0),[u,d]=(0,J.useState)(!1),[f,m]=(0,J.useState)(null),[h,g]=(0,J.useState)([]),[v,y]=(0,J.useState)(``),[b,x]=(0,J.useState)(``),[S,C]=(0,J.useState)(``),[w,E]=(0,J.useState)(null),[D,A]=(0,J.useState)(!1),[M,ee]=(0,J.useState)(null),[N,te]=(0,J.useState)(!1),P=(0,J.useRef)(0),F=(0,J.useRef)(0),I=(0,J.useCallback)(async()=>{let t=++P.current;s(!0),m(null);try{let n=Bn(await U.getGitStatus(e),r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`}));if(t!==P.current)return;a(n),g([])}catch(e){if(t!==P.current)return;m(Vn(e,r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`})))}finally{t===P.current&&s(!1)}},[r,e]);(0,J.useEffect)(()=>{let e=window.setTimeout(()=>void I(),0);return()=>{window.clearTimeout(e),P.current+=1}},[I]),(0,J.useEffect)(()=>{let t=!1,n=window.setTimeout(async()=>{if(!i?.initialized){ee(null);return}if(!i.changes.some(e=>!Hn(e))){ee(i.changes.length>0?{files:[],truncated:!1}:null);return}te(!0);try{let n=await U.getGitDiff(e);if(t||!n.success||!n.data)return;ee({files:Rn(n.data.patch),truncated:n.data.truncated})}catch{}finally{t||te(!1)}},0);return()=>{t=!0,window.clearTimeout(n)}},[i,e]);let ne=async(e,n)=>{if(t||u)return!1;d(!0),m(null);try{let t=Bn(await e(),r(`work.git.actionFailed`,{defaultValue:`Git action failed.`}));return F.current+=1,a(t),g([]),E(null),j.success(n),!0}catch(e){let t=Vn(e,r(`work.git.actionFailed`,{defaultValue:`Git action failed.`}));return m(t),j.error(t),!1}finally{d(!1)}},re=async t=>{let n=++F.current;A(!0),m(null);try{if(Hn(t)){let i=Bn(await U.getFile(e,t.path),r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`}));if(n!==F.current)return;E({path:t.path,status:`added`,lines:Cn(``,i.content),binary:!1,truncated:!1})}else{let i=Bn(await U.getGitDiff(e,t.path),r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`}));if(n!==F.current)return;let a=Rn(i.patch)[0];E({path:t.path,status:a?.status??`modified`,lines:a?.lines??[],binary:a?.binary??!1,truncated:i.truncated})}}catch(e){if(n!==F.current)return;m(Vn(e,r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`})))}finally{n===F.current&&A(!1)}},ie=(0,J.useMemo)(()=>{let e=new Map;for(let t of M?.files??[])e.set(t.path,t);return e},[M]),L=(0,J.useMemo)(()=>zn(M?.files??[]),[M]),R=S.trim().toLowerCase(),ae=(0,J.useMemo)(()=>{let e=i?.changes??[];return R?e.filter(e=>e.path.toLowerCase().includes(R)):e},[R,i]);if(o&&!i)return(0,Y.jsx)(`div`,{className:`flex h-full items-center justify-center text-ink-muted`,children:(0,Y.jsx)(z,{className:`h-5 w-5 animate-spin`})});if(!i)return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,Y.jsx)(p,{className:`mb-3 h-8 w-8 text-error-500`}),(0,Y.jsx)(`p`,{className:`max-w-sm text-xs leading-relaxed text-error-600`,children:f||r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`})}),(0,Y.jsxs)(q,{size:`sm`,variant:`secondary`,className:`mt-4`,onClick:()=>void I(),children:[(0,Y.jsx)(O,{className:`h-3.5 w-3.5`}),r(`common.retry`,{defaultValue:`Retry`})]})]});if(!i.initialized)return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,Y.jsx)(p,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,Y.jsx)(`h3`,{className:`text-sm font-medium text-ink`,children:r(`work.git.notInitialized`,{defaultValue:`Git is not initialized`})}),(0,Y.jsx)(`p`,{className:`mt-1 max-w-sm text-xs leading-relaxed text-ink-muted`,children:r(`work.git.initializeDescription`,{defaultValue:`Create a local repository for status, diffs, branches, and commits. No remote credentials are connected.`})}),f&&(0,Y.jsx)(`p`,{className:`mt-3 text-xs text-error-600`,children:f}),(0,Y.jsxs)(q,{"data-testid":`work-git-init-button`,size:`sm`,className:`mt-4 bg-primary-600 text-white hover:bg-primary-500`,disabled:t||u,onClick:()=>void ne(()=>U.initializeGit(e),r(`work.git.initialized`,{defaultValue:`Git repository initialized.`})),children:[u?(0,Y.jsx)(z,{className:`me-2 h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(k,{className:`me-2 h-3.5 w-3.5`}),r(`work.git.initialize`,{defaultValue:`Initialize Git`})]}),t&&n&&(0,Y.jsx)(`p`,{className:`mt-2 text-[11px] text-ink-subtle`,children:n})]});let oe=i.changes.filter(e=>e.staged).length,se=i.changes.length>0,B=ae.filter(Hn),ce=R?(M?.files??[]).filter(e=>e.path.toLowerCase().includes(R)):M?.files??[];return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`work-git-panel`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-3 py-2`,children:[(0,Y.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,Y.jsx)(p,{className:`h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:i.detached?r(`work.git.detached`,{defaultValue:`detached HEAD`}):i.branch||`main`})]}),M&&(L.added>0||L.removed>0)&&(0,Y.jsxs)(`span`,{"data-testid":`work-git-total-stats`,dir:`ltr`,className:`font-mono text-[11px] font-medium tabular-nums`,children:[(0,Y.jsxs)(`span`,{className:`text-[rgb(46,164,79)]`,children:[`+`,L.added]}),` `,(0,Y.jsxs)(`span`,{className:`text-[rgb(255,61,129)]`,children:[`−`,L.removed]})]}),(i.ahead>0||i.behind>0)&&(0,Y.jsxs)(`span`,{className:`text-[10px] text-ink-muted`,children:[`↑`,i.ahead,` ↓`,i.behind]}),(0,Y.jsxs)(`select`,{"data-testid":`work-git-branch-select`,"aria-label":r(`work.git.switchBranch`,{defaultValue:`Switch local branch`}),value:i.branch||``,disabled:t||u||se,onChange:t=>{let n=t.target.value;!n||n===i.branch||ne(()=>U.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,Y.jsx)(`option`,{value:``,disabled:!0,children:r(`work.git.detached`,{defaultValue:`detached HEAD`})}),i.branches.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))]}),(0,Y.jsxs)(`div`,{className:`flex min-w-44 flex-1 items-center gap-1`,children:[(0,Y.jsx)(`input`,{"data-testid":`work-git-branch-input`,value:b,maxLength:200,onChange:e=>x(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,Y.jsxs)(q,{"data-testid":`work-git-create-branch-button`,size:`sm`,variant:`ghost`,className:`h-7 px-2`,disabled:t||u||!i.head||!b.trim(),onClick:()=>{let t=b.trim();ne(()=>U.createGitBranch(e,t),r(`work.git.branchCreated`,{name:t,defaultValue:`Created {{name}}.`})).then(e=>{e&&x(``)})},children:[(0,Y.jsx)(k,{className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:r(`work.git.createBranch`,{defaultValue:`Create`})})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void I(),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,Y.jsx)(O,{className:l(`h-3.5 w-3.5`,o&&`animate-spin`)})})]}),f&&(0,Y.jsx)(`div`,{className:`border-b border-error-200 bg-error-50 px-3 py-2 text-xs text-error-700 dark:border-error-900/60 dark:bg-error-900/30 dark:text-error-300`,children:f}),t&&n&&(0,Y.jsx)(`div`,{className:`border-b border-line px-3 py-1.5 text-[11px] text-ink-subtle`,children:n}),(0,Y.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,Y.jsxs)(`section`,{className:`flex min-h-0 flex-col border-b border-line lg:border-b-0 lg:border-e`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,Y.jsxs)(`h3`,{className:`text-xs font-medium text-ink`,children:[r(`work.git.changes`,{defaultValue:`Changes`}),` `,(0,Y.jsx)(`span`,{className:`text-ink-subtle`,children:i.changes.length})]}),(0,Y.jsxs)(q,{"data-testid":`work-git-stage-button`,size:`sm`,variant:`ghost`,className:`h-7 px-2 text-[11px]`,disabled:t||u||h.length===0&&i.changes.length===0,onClick:()=>{let t=h.length>0?h:i.changes.map(e=>e.path);ne(()=>U.stageGitPaths(e,t),r(`work.git.staged`,{defaultValue:`Changes staged.`}))},children:[(0,Y.jsx)(_,{className:`h-3.5 w-3.5`}),h.length>0?r(`work.git.stageSelected`,{count:h.length,defaultValue:`Stage {{count}}`}):r(`work.git.stageAll`,{defaultValue:`Stage all`})]})]}),i.changes.length>0&&(0,Y.jsxs)(`div`,{className:`relative px-2 pb-1.5`,children:[(0,Y.jsx)(T,{className:`pointer-events-none absolute start-4 top-1/2 h-3 w-3 -translate-y-[calc(50%+3px)] text-ink-subtle`}),(0,Y.jsx)(`input`,{"data-testid":`work-git-filter`,value:S,maxLength:500,onChange:e=>C(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,Y.jsx)(`div`,{className:`min-h-32 flex-1 overflow-y-auto px-2 pb-2`,children:i.changes.length===0?(0,Y.jsx)(`p`,{className:`px-2 py-8 text-center text-xs text-ink-muted`,children:r(`work.git.clean`,{defaultValue:`Working tree is clean.`})}):ae.length===0?(0,Y.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.`})}):ae.map(e=>{let t=Un(e),{name:n,directory:i}=Kn(e.path),a=ie.get(e.path);return(0,Y.jsxs)(`div`,{className:l(`flex items-center gap-1 rounded-lg hover:bg-surface-subtle`,w?.path===e.path&&`bg-surface-subtle`),children:[(0,Y.jsx)(`input`,{type:`checkbox`,"aria-label":r(`work.git.selectPath`,{path:e.path,defaultValue:`Select {{path}}`}),checked:h.includes(e.path),onChange:t=>g(n=>t.target.checked?[...n,e.path]:n.filter(t=>t!==e.path)),className:`ms-2 h-3.5 w-3.5 accent-primary-600`}),(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-git-change`,onClick:()=>void re(e),className:`flex min-w-0 flex-1 items-center gap-2 px-1.5 py-2 text-start`,title:e.path,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:l(`w-3.5 shrink-0 text-center font-mono text-[10px] font-semibold`,Gn(t),e.staged&&`underline underline-offset-2`),children:t}),(0,Y.jsxs)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate text-start font-mono text-[11px]`,children:[(0,Y.jsx)(`span`,{className:`text-ink`,children:n}),i&&(0,Y.jsxs)(`span`,{className:`text-ink-subtle`,children:[` `,i]})]}),a&&(a.stats.added>0||a.stats.removed>0)&&(0,Y.jsx)(qn,{added:a.stats.added,removed:a.stats.removed})]})]},`${e.path}:${e.originalPath||``}`)})}),(0,Y.jsxs)(`div`,{className:`border-t border-line p-2`,children:[(0,Y.jsx)(`textarea`,{"data-testid":`work-git-commit-input`,value:v,maxLength:4e3,rows:2,onChange:e=>y(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,Y.jsxs)(q,{"data-testid":`work-git-commit-button`,size:`sm`,className:`mt-1.5 w-full bg-primary-600 text-white hover:bg-primary-500`,disabled:t||u||oe===0||!v.trim(),onClick:()=>{let t=v.trim();ne(()=>U.commitGit(e,t),r(`work.git.committed`,{defaultValue:`Commit created.`})).then(e=>{e&&y(``)})},children:[u&&(0,Y.jsx)(z,{className:`h-3.5 w-3.5 animate-spin`}),r(`work.git.commit`,{defaultValue:`Commit staged changes`})]})]}),(0,Y.jsxs)(`div`,{className:`max-h-56 shrink-0 overflow-y-auto border-t border-line p-3`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-medium text-ink`,children:[(0,Y.jsx)(de,{className:`h-3.5 w-3.5`}),r(`work.git.history`,{defaultValue:`Local history`})]}),i.commits.length===0?(0,Y.jsx)(`p`,{className:`py-3 text-center text-xs text-ink-muted`,children:r(`work.git.noCommits`,{defaultValue:`No commits yet.`})}):(0,Y.jsx)(`ol`,{className:`space-y-2`,children:i.commits.map(e=>(0,Y.jsxs)(`li`,{className:`rounded-lg border border-line bg-surface px-2.5 py-2`,children:[(0,Y.jsx)(`p`,{dir:`auto`,className:`text-xs text-ink`,children:e.subject}),(0,Y.jsxs)(`p`,{className:`mt-1 flex flex-wrap gap-x-2 text-[10px] text-ink-subtle`,children:[(0,Y.jsx)(`span`,{dir:`ltr`,className:`font-mono`,children:e.shortHash}),(0,Y.jsx)(`span`,{dir:`auto`,children:e.author}),(0,Y.jsx)(`time`,{dateTime:e.authoredAt,children:new Date(e.authoredAt).toLocaleDateString()})]})]},e.hash))}),(0,Y.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,Y.jsx)(`section`,{className:`flex min-h-48 min-w-0 flex-col`,children:w||D?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-2 py-1.5`,children:[(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-git-all-changes-button`,onClick:()=>{F.current+=1,E(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,Y.jsx)(me,{className:`h-3 w-3 rtl:rotate-180`}),r(`work.git.allChanges`,{defaultValue:`All changes`})]}),w&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:l(`w-4 shrink-0 text-center font-mono text-[11px] font-semibold`,Gn(Wn(w.status))),children:Wn(w.status)}),(0,Y.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink`,title:w.path,children:w.path}),!w.binary&&(0,Y.jsx)(qn,{added:w.lines.filter(e=>e.type===`added`).length,removed:w.lines.filter(e=>e.type===`removed`).length})]})]}),D?(0,Y.jsx)(z,{className:`m-auto h-5 w-5 animate-spin text-ink-muted`}):w?(0,Y.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:[w.truncated&&(0,Y.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.`})}),w.binary?(0,Y.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.`})}):w.lines.length===0?(0,Y.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,Y.jsx)(jn,{lines:w.lines})]}):null]}):i.changes.length===0?(0,Y.jsx)(`p`,{className:`m-auto px-5 text-center text-xs text-ink-muted`,children:r(`work.git.clean`,{defaultValue:`Working tree is clean.`})}):N&&!M?(0,Y.jsx)(z,{className:`m-auto h-5 w-5 animate-spin text-ink-muted`}):(0,Y.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:[M?.truncated&&(0,Y.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.`})}),ce.map(e=>(0,Y.jsxs)(`div`,{"data-testid":`work-git-review-file`,children:[(0,Y.jsx)(Jn,{letter:Wn(e.status),path:e.path,oldPath:e.oldPath,added:e.stats.added,removed:e.stats.removed}),e.binary?(0,Y.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,Y.jsx)(jn,{lines:e.lines})]},e.path)),B.map(e=>(0,Y.jsx)(`div`,{"data-testid":`work-git-review-file`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>void re(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,Y.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,Y.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink`,children:e.path}),(0,Y.jsx)(ue,{className:`h-3 w-3 shrink-0 text-ink-subtle`})]})},e.path)),ce.length===0&&B.length===0&&(0,Y.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 Xn(e,t){return De(e,t.ticket,t)}async function Zn(e){let t=(await H.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 Xn(e,{protocol:window.location.protocol,host:window.location.host,hostname:window.location.hostname,apiBaseUrl:void 0,websocketBaseUrl:void 0,production:!0,ticket:t})}var Qn=(e,t)=>{let n=getComputedStyle(document.documentElement).getPropertyValue(`--color-primary-${e}`).trim();if(!n)return t===void 0?`#4176e6`:`rgba(65, 118, 230, ${t})`;let[r,i,a]=n.split(/\s+/);return t===void 0?`rgb(${r}, ${i}, ${a})`:`rgba(${r}, ${i}, ${a}, ${t})`},$n=()=>({background:`#ffffff`,foreground:`#1f2328`,cursor:`#1f2328`,selectionBackground:Qn(500,.28)}),er=()=>({background:`#0f1115`,foreground:`#e6e6e6`,cursor:Qn(400),selectionBackground:Qn(500,.32)});function tr({taskId:e,active:t,disabledReason:n}){let{t:i}=c(),a=Fe(e=>e.theme.mode!==`light`),o=(0,J.useRef)(null),s=(0,J.useRef)(null),u=(0,J.useRef)(null),d=(0,J.useRef)(null),[f,p]=(0,J.useState)(`idle`),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(0),v=(0,J.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,J.useEffect)(()=>{if(!t||n)return;let i=!1,c,l;return(async()=>{p(`connecting`),h(null);let[{Terminal:t},{FitAddon:n}]=await Promise.all([r(()=>import(`./xterm-CdjKCQM7.js`),[]),r(()=>import(`./addon-fit-DIOBYJe3.js`),[])]);if(await r(()=>Promise.resolve({}),__vite__mapDeps([15])),i||!o.current)return;c=new t({allowProposedApi:!0,convertEol:!1,cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,fontSize:12,scrollback:5e3,theme:a?er():$n()});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 Zn(e)}catch(e){i||(p(`error`),h(e instanceof Error?e.message:null));return}if(i)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=()=>{i||p(e=>e===`error`||e===`closed`?e:`closed`)},l.onerror=()=>{i||p(`error`)},c.onData(e=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify({type:`input`,data:e}))})})(),()=>{i=!0,l?.close(),s.current=null,c?.dispose(),u.current=null,d.current=null}},[t,n,g,a,v,e]),(0,J.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??i(`work.terminal.failed`,{defaultValue:`The terminal session could not start.`}):f===`closed`?i(`work.terminal.closed`,{defaultValue:`Terminal session ended.`}):null);return(0,Y.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,Y.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,Y.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center gap-2 text-xs text-ink-muted`,children:[(0,Y.jsx)(z,{className:`h-4 w-4 animate-spin`}),i(`work.terminal.connecting`,{defaultValue:`Opening a shell in the sandbox…`})]}),b&&(0,Y.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,Y.jsx)(x,{className:`h-6 w-6 text-ink-subtle`}),(0,Y.jsx)(`p`,{dir:`auto`,"data-testid":`work-terminal-status`,className:`max-w-md text-xs leading-relaxed text-ink-muted`,children:b}),!n&&(0,Y.jsx)(q,{size:`sm`,"data-testid":`work-terminal-reconnect-button`,className:`h-8 rounded-lg bg-primary-600 px-3 text-white hover:bg-primary-500`,onClick:y,children:i(`work.terminal.reconnect`,{defaultValue:`Reconnect`})})]})]})}var nr=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(xe,window.location.origin).origin;return new URL(e,`${t}/`).toString()}catch{return null}return null},rr=e=>{let t=e.split(`/`).filter(Boolean);return t.pop(),t.join(`/`)},ir=(e,t)=>{let n=e.metadata?.name??e.metadata?.toolName??e.metadata?.tool??e.metadata?.command;return typeof n==`string`&&n?n:t};function ar({task:e,persona:t,openFileRequest:n,liveRun:r,files:i,selectedFile:a,loadingFiles:o,actionLoading:s,onLoadFiles:d,onLoadFile:m,onClearSelectedFile:_,onSaveFile:v,onStartPreview:y,onStopPreview:b,onDirtyChange:S,terminal:C}){let{t:w,i18n:T}=c(),E=u(T.language),[D,k]=(0,J.useState)(e.isAgent?`agent`:`files`),[M,ee]=(0,J.useState)(``),[N,P]=(0,J.useState)(``),[F,I]=(0,J.useState)(),[ne,R]=(0,J.useState)(``),[B,ce]=(0,J.useState)(!1),[le,ue]=(0,J.useState)(!1),de=(0,J.useRef)(new Map),[fe,V]=(0,J.useState)(()=>new Map),he=nr(e.previewUrl),_e=r?.runId,ve=r?.error,ye=r?.tools,be=(0,J.useMemo)(()=>{let t=new Set(ye?.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,ye,e.messages]),xe=be.length+(ye?.length||0),H=!!a&&N!==(a?.content??``),U=e.status===`preparing`||e.status===`running`,Se=(0,J.useRef)(U),W=(0,J.useRef)(0),G=(0,J.useRef)(N),Ce=(0,J.useRef)(F),we=(0,J.useRef)(a),Te=(0,J.useRef)(e.id),Ee=(0,J.useRef)(d),De=(0,J.useRef)(m),ke=(0,J.useRef)(S),K=(0,J.useRef)(!0),Me=a?fe.get(a.path):void 0,Ne=(0,J.useMemo)(()=>a&&Me!==void 0&&Me!==a.content?Cn(Me,a.content):null,[Me,a]),Pe=(0,J.useMemo)(()=>Ne?Tn(Ne):null,[Ne]),Fe=!!(Pe&&(Pe.added>0||Pe.removed>0)),Ie=a?fn(a.path):!1,Le=!a||pn(N),Re=Ie&&Le;(0,J.useEffect)(()=>{G.current=N,Ce.current=F,we.current=a,Te.current=e.id,ke.current=S},[F,N,S,a,e.id]),(0,J.useEffect)(()=>{Ee.current=d,De.current=m},[m,d]),(0,J.useEffect)(()=>(K.current=!0,()=>{K.current=!1,W.current+=1,ke.current(!1)}),[]),(0,J.useEffect)(()=>{if(!Se.current&&U&&V(new Map(de.current)),Se.current&&!U&&(Ee.current(M),a&&!H)){let e=++W.current,t=a.path,n=G.current,r=Ce.current;De.current(t).then(i=>{if(!K.current||e!==W.current||i.path!==t||G.current!==n||Ce.current!==r)return;de.current.set(i.path,i.content);let a=fe.get(i.path);a!==void 0&&a!==i.content&&ue(!0),G.current=i.content,Ce.current=i.updatedAt??i.modifiedAt,P(i.content),I(i.updatedAt??i.modifiedAt)}).catch(()=>void 0)}Se.current=U},[M,H,a,U,fe]);let ze=()=>!H||window.confirm(w(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),Be=()=>{a&&je(e.id,a.path)},Ve=async e=>{ze()&&(W.current+=1,Be(),_(),S(!1),ue(!1),ee(e),await d(e).catch(()=>void 0))},He=async t=>{if(!ze())return;let n=++W.current;Be();let r=await m(t).catch(()=>void 0);if(!K.current||!r||n!==W.current)return;de.current.set(r.path,r.content);let i=fe.get(r.path);ue(i!==void 0&&i!==r.content);let a=Oe(e.id,r.path),o=a?.content??r.content,s=a?.baseUpdatedAt??r.updatedAt??r.modifiedAt;G.current=o,Ce.current=s,P(o),I(s),S(a!==null&&a.content!==r.content)},Ue=(0,J.useRef)(0);(0,J.useEffect)(()=>{!n||n.nonce===Ue.current||(Ue.current=n.nonce,k(`files`),He(n.path))},[n]);let We=()=>{ze()&&(W.current+=1,Be(),_(),S(!1),ue(!1))},Ge=t=>{a&&(G.current=t,P(t),t===a.content?je(e.id,a.path):Ae(e.id,a.path,{content:t,baseUpdatedAt:F??a.updatedAt??a.modifiedAt}),S(t!==a.content))},Ke=async()=>{if(!a)return;let t=e.id,n=a.path,r=N,i=W.current,o=await v(n,r,F).catch(()=>!1);if(!K.current||o===!1||i!==W.current||Te.current!==t||we.current?.path!==n)return;let s=o.updatedAt??o.modifiedAt;de.current.set(n,typeof o.content==`string`?o.content:r),Ce.current=s,I(s);let c=G.current;if(c===r){je(t,n),S(!1);return}Ae(t,n,{content:c,baseUpdatedAt:s}),S(!0)},qe=async()=>{if(!a||U||B||!Re)return;ce(!0);let e=W.current,t=a.path,n=G.current;try{let r=await hn(t,n);if(!K.current||e!==W.current||we.current?.path!==t||G.current!==n)return;Ge(r),j.success(w(`work.files.formatted`,{defaultValue:`Code formatted.`}))}catch(r){if(!K.current||e!==W.current||we.current?.path!==t||G.current!==n)return;j.error(r instanceof Error?r.message:w(`work.files.formatFailed`,{defaultValue:`Could not format this file.`}))}finally{K.current&&ce(!1)}},Je=[...e.isAgent?[{id:`agent`,label:w(`work.workspace.agent`,{defaultValue:`Agent`}),icon:ae,testId:`work-agent-tab`}]:[],{id:`files`,label:w(`work.workspace.files`,{defaultValue:`Files`}),icon:te,testId:`work-files-tab`},{id:`activity`,label:w(`work.workspace.activity`,{defaultValue:`Activity`}),icon:se,testId:`work-activity-tab`},{id:`git`,label:w(`work.workspace.git`,{defaultValue:`Git`}),icon:p,testId:`work-git-tab`},{id:`terminal`,label:w(`work.workspace.terminal`,{defaultValue:`Terminal`}),icon:x,testId:`work-terminal-tab`},{id:`preview`,label:w(`work.workspace.preview`,{defaultValue:`Preview`}),icon:ie,testId:`work-preview-tab`},...e.computerAvailable?[{id:`screen`,label:w(`work.workspace.screen`,{defaultValue:`Screen`}),icon:re,testId:`work-screen-tab`}]:[]],Ye=(e,t)=>{let n=null;if(e.key===`ArrowRight`&&(n=(t+(E?-1:1)+Je.length)%Je.length),e.key===`ArrowLeft`&&(n=(t+(E?1:-1)+Je.length)%Je.length),e.key===`Home`&&(n=0),e.key===`End`&&(n=Je.length-1),n===null)return;e.preventDefault();let r=Je[n];k(r.id),e.currentTarget.parentElement?.querySelector(`#work-workspace-tab-${r.id}`)?.focus()};return(0,Y.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-transparent`,children:[(0,Y.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,Y.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,"aria-label":w(`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:Je.map((e,t)=>{let n=e.icon;return(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,id:`work-workspace-tab-${e.id}`,"aria-selected":D===e.id,"aria-controls":D===e.id?`work-workspace-panel-${e.id}`:void 0,"aria-label":e.label,tabIndex:D===e.id?0:-1,title:e.label,"data-testid":e.testId,onClick:()=>k(e.id),onKeyDown:e=>Ye(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]`,D===e.id?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:text-ink`),children:[(0,Y.jsx)(n,{className:`h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`hidden xs:inline`,children:e.label}),e.id===`activity`&&xe>0&&(0,Y.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-[10px] text-ink-muted`,children:xe})]},e.id)})}),D===`files`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[a&&(0,Y.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:We,"aria-label":w(`work.files.back`,{defaultValue:`Back to files`}),children:(0,Y.jsx)(me,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,Y.jsxs)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,title:a?.path??`/workspace${M?`/${M}`:``}`,children:[a?.path??`/workspace${M?`/${M}`:``}`,H&&` •`]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:!M,onClick:()=>void Ve(rr(M)),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`,!a&&`inline-flex`),"aria-label":w(`work.files.up`,{defaultValue:`Parent folder`}),title:w(`work.files.up`,{defaultValue:`Parent folder`}),children:(0,Y.jsx)(me,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`work-refresh-files-button`,onClick:()=>void d(M).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":w(`common.refresh`,{defaultValue:`Refresh`}),title:w(`common.refresh`,{defaultValue:`Refresh`}),children:(0,Y.jsx)(O,{className:l(`h-3.5 w-3.5`,o&&`animate-spin`)})}),a&&Fe&&Pe&&(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-diff-toggle-button`,"aria-pressed":le,onClick:()=>ue(e=>!e),title:w(`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,Y.jsx)(A,{className:`h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:w(`work.files.changes`,{defaultValue:`Changes`})}),(0,Y.jsxs)(`span`,{dir:`ltr`,className:`tabular-nums`,children:[(0,Y.jsxs)(`span`,{className:le?void 0:`text-[rgb(46,164,79)]`,children:[`+`,Pe.added]}),` `,(0,Y.jsxs)(`span`,{className:le?void 0:`text-[rgb(255,61,129)]`,children:[`−`,Pe.removed]})]})]}),a&&!le&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(q,{"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:U||B||!Re,onClick:()=>void qe(),"aria-busy":B||void 0,title:Re?w(`work.files.formatShortcut`,{defaultValue:`Format (Shift+Alt+F)`}):Ie?w(`work.files.formatTooLarge`,{defaultValue:`Formatting is limited to files under 100,000 characters and 4,000 lines.`}):w(`work.files.formatUnsupported`,{defaultValue:`Formatting is not available for this file type.`}),"aria-label":w(`work.files.format`,{defaultValue:`Format file`}),children:[B?(0,Y.jsx)(z,{className:`h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(L,{className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`hidden 2xl:inline`,children:w(`work.files.format`,{defaultValue:`Format`})})]}),(0,Y.jsxs)(q,{"data-testid":`work-save-file-button`,size:`sm`,className:`h-8 w-8 rounded-lg bg-primary-600 px-0 text-white hover:bg-primary-500 sm:w-auto sm:px-2.5`,disabled:!H||U||B||s,onClick:()=>void Ke(),"aria-busy":s||void 0,title:w(`work.files.saveShortcut`,{defaultValue:`Save (⌘/Ctrl+S)`}),"aria-label":w(`common.save`),children:[s?(0,Y.jsx)(z,{className:`h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(g,{className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`hidden 2xl:inline`,children:w(`common.save`)})]})]})]})]}),(D===`activity`||D===`git`||D===`screen`)&&(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`}),D===`terminal`&&(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Y.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,children:`/workspace`}),U&&(0,Y.jsx)(`span`,{className:`shrink-0 text-[10px] text-ink-subtle`,children:w(`work.terminal.taskRunning`,{defaultValue:`Model turn in progress`})})]}),D===`preview`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`input`,{dir:`auto`,value:ne,onChange:e=>R(e.target.value),placeholder:w(`work.preview.command`,{defaultValue:`Optional start command`}),"aria-label":w(`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,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.previewStatus===`running`||e.previewStatus===`starting`?(0,Y.jsxs)(q,{"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:s,onClick:()=>void b(),"aria-busy":s||void 0,"aria-label":w(`work.preview.stop`,{defaultValue:`Stop preview`}),children:[s?(0,Y.jsx)(z,{className:`h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(h,{className:`h-3.5 w-3.5 fill-current`}),(0,Y.jsx)(`span`,{className:`hidden 2xl:inline`,children:w(`work.preview.stop`,{defaultValue:`Stop preview`})})]}):(0,Y.jsxs)(q,{"data-testid":`work-start-preview-button`,size:`sm`,className:`h-8 w-8 rounded-lg bg-primary-600 px-0 text-white hover:bg-primary-500 sm:w-auto sm:px-2.5`,disabled:s,onClick:()=>void y(ne.trim()||void 0),"aria-busy":s||void 0,"aria-label":w(`work.preview.start`,{defaultValue:`Start preview`}),children:[s?(0,Y.jsx)(z,{className:`h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(f,{className:`h-3.5 w-3.5 fill-current`}),(0,Y.jsx)(`span`,{className:`hidden 2xl:inline`,children:w(`work.preview.start`,{defaultValue:`Start preview`})})]}),he&&(0,Y.jsx)(`a`,{href:he,target:`_blank`,rel:`noopener noreferrer`,"aria-label":w(`work.preview.open`,{defaultValue:`Open`}),title:w(`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,Y.jsx)(ge,{className:`h-3.5 w-3.5`})})]})]})]}),D===`files`&&(0,Y.jsxs)(`div`,{id:`work-workspace-panel-files`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-files`,className:`flex min-h-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:l(`flex min-h-0 w-full flex-col border-e border-line bg-surface-raised`,a?`hidden sm:flex sm:w-52 xl:w-60`:`flex`),children:(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-1.5`,children:o&&i.length===0?(0,Y.jsx)(`div`,{className:`flex justify-center py-8 text-ink-muted`,children:(0,Y.jsx)(z,{className:`h-5 w-5 animate-spin`})}):i.length===0?(0,Y.jsx)(`p`,{className:`px-3 py-8 text-center text-xs text-ink-muted`,children:w(`work.files.empty`,{defaultValue:`No files in this folder yet.`})}):[...i].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1).map(e=>(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-file-item`,"data-path":e.path,onClick:()=>{e.type===`directory`?Ve(e.path):He(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`,a?.path===e.path?`bg-surface-subtle text-ink`:`text-ink-muted`),children:[e.type===`directory`?(0,Y.jsx)(pe,{className:`h-3.5 w-3.5 shrink-0 text-amber-500`}):(0,Y.jsx)(oe,{className:`h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{dir:`auto`,className:`truncate`,children:e.name})]},e.path))})}),(0,Y.jsx)(`div`,{className:l(`min-h-0 min-w-0 flex-1 flex-col`,a?`flex`:`hidden sm:flex`),children:a&&le&&Ne?(0,Y.jsx)(Mn,{lines:Ne,ariaLabel:w(`work.files.diffLabel`,{path:a.path,defaultValue:`Changes since the last turn: {{path}}`})}):a?(0,Y.jsx)(bn,{path:a.path,value:N,ariaLabel:w(`work.files.editorLabel`,{path:a.path,defaultValue:`File editor: {{path}}`}),onChange:Ge,onSaveShortcut:()=>{H&&!U&&!s&&!B&&Ke()},onFormatShortcut:()=>void qe(),disabled:U||B}):(0,Y.jsxs)(`div`,{className:`m-auto px-6 text-center text-xs text-ink-muted`,children:[(0,Y.jsx)(oe,{className:`mx-auto mb-3 h-7 w-7 text-ink-subtle`}),w(`work.files.select`,{defaultValue:`Select a file to inspect and edit it.`})]})})]}),D===`activity`&&(0,Y.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:[r&&(0,Y.jsx)(`div`,{className:`mb-3`,children:(0,Y.jsx)(St,{run:r,variant:`activity`})}),be.length===0&&!r?(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center text-xs text-ink-muted`,children:[(0,Y.jsx)(x,{className:`mb-3 h-7 w-7 text-ink-subtle`}),w(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]}):(0,Y.jsx)(`div`,{className:`space-y-2`,children:be.map(e=>(0,Y.jsxs)(`div`,{className:`rounded-xl border border-line bg-surface p-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{dir:`auto`,className:`truncate font-mono text-xs font-medium text-ink`,children:ir(e,w(`work.activity.toolActivity`,{defaultValue:`Tool activity`}))}),(0,Y.jsx)(`span`,{className:`shrink-0 text-[10px] uppercase tracking-wide text-ink-subtle rtl:tracking-normal`,children:{message:w(`work.activity.kinds.message`,{defaultValue:`Message`}),reasoning:w(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`}),tool_call:w(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}),tool_result:w(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),error:w(`work.activity.kinds.error`,{defaultValue:`Error`})}[e.kind]})]}),e.content&&(0,Y.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))})]}),D===`git`&&(0,Y.jsx)(`div`,{id:`work-workspace-panel-git`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-git`,className:`min-h-0 flex-1`,children:(0,Y.jsx)(Yn,{taskId:e.id,mutationsDisabled:U||e.previewStatus===`starting`||e.previewStatus===`running`,disabledReason:U?w(`work.git.blockedByRun`,{defaultValue:`Git write actions unlock when the model turn finishes.`}):e.previewStatus===`starting`||e.previewStatus===`running`?w(`work.git.blockedByPreview`,{defaultValue:`Stop the preview before changing Git state.`}):void 0})}),D===`agent`&&(0,Y.jsx)(`div`,{id:`work-workspace-panel-agent`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-agent`,className:`min-h-0 flex-1 overflow-y-auto scrollbar-thin`,children:(0,Y.jsx)(tn,{task:e,persona:t,active:D===`agent`,onOpenScreen:()=>k(`screen`)})}),D===`screen`&&(0,Y.jsx)(`div`,{id:`work-workspace-panel-screen`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-screen`,className:`flex min-h-0 flex-1 flex-col`,children:(0,Y.jsx)(Qt,{taskId:e.id,active:D===`screen`})}),D===`terminal`&&(0,Y.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,Y.jsx)(tr,{taskId:e.id,active:D===`terminal`,disabledReason:C&&!C.available?C.reason??w(`work.terminal.unavailable`,{defaultValue:`The interactive terminal is not available in this deployment.`}):U?w(`work.terminal.blockedByRun`,{defaultValue:`The model is using this container. The terminal opens when the turn finishes.`}):void 0})}),D===`preview`&&(0,Y.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,Y.jsxs)(`div`,{className:`m-auto flex items-center gap-2 text-xs text-ink-muted`,children:[(0,Y.jsx)(z,{className:`h-4 w-4 animate-spin`}),w(`work.preview.starting`,{defaultValue:`Starting preview…`})]}):he&&e.previewStatus===`running`?(0,Y.jsx)(`iframe`,{"data-testid":`work-preview-frame`,title:w(`work.preview.frameTitle`,{defaultValue:`Workspace preview`}),src:he,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,Y.jsxs)(`div`,{className:`m-auto max-w-sm px-6 text-center text-xs leading-relaxed text-ink-muted`,children:[(0,Y.jsx)(ie,{className:`mx-auto mb-3 h-8 w-8 text-ink-subtle`}),e.previewStatus===`failed`?w(`work.preview.failed`,{defaultValue:`The preview could not start. Check Activity, then try another command.`}):w(`work.preview.empty`,{defaultValue:`Start the app inside this workspace to inspect it here.`})]})})]})}var or=e=>{let t=e.trim().toLowerCase();return!!t&&!t.includes(`embed`)},sr=(e,t)=>e instanceof Error&&e.message?e.message:t,cr=(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 lr(){let{t:e}=c(),t=i(),n=a(),{taskId:r}=o(),u=Fe(e=>e.preferences),f=Fe(e=>e.setPreferences),p=Pe(e=>e.user),m=p?.id??null,[h,g]=(0,J.useState)(!1),_=d(e=>e.models),v=d(e=>e.selectedModel),b=d(e=>e.selectedProviderType),x=d(e=>e.selectedProviderId),S=d(e=>e.loadModels),{capabilities:T,tasks:E,selectedTask:O,files:k,selectedFile:A,liveRuns:M,loadingTask:N,loadingOlderMessages:te,loadingFiles:P,actionLoading:F,error:ne,loadCapabilities:re,loadTasks:L,selectTask:R,loadTask:z,loadOlderMessages:ae,createTask:oe,updateTask:se,deleteTask:B,markTaskSeen:ce,startRun:ue,cancelRun:de,beginLiveRun:fe,applyRunEvents:pe,setLiveRunConnection:V,clearLiveRun:me,loadFiles:ge,loadFile:_e,clearSelectedFile:ve,saveFile:ye,startPreview:be,stopPreview:xe,clearError:H}=ke(),Se=(0,J.useMemo)(()=>_.filter(e=>!e.isPersona&&!e.isAgent&&or(e.name)&&(!e.isPlugin||!!e.pluginId)),[_]),W=(0,J.useMemo)(()=>Se.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:We(i),label:e.isPlugin&&e.pluginName?`${e.name} · ${e.pluginName}`:e.name,remote:e.isPlugin||r.endsWith(`:cloud`)||r.endsWith(`-cloud`)}]}),[Se]),[G,Ce]=(0,J.useState)(``),[we,Ee]=(0,J.useState)({locationKey:t.key,value:`conversation`}),De=we.locationKey===t.key?we.value:`conversation`,Oe=(0,J.useCallback)(e=>Ee({locationKey:t.key,value:e}),[t.key]),[K,Ae]=(0,J.useState)(!1),[Me,q]=(0,J.useState)(null),Ie=Me?.locationKey===t.key&&Me.taskId===r?Me:null;Me&&!Ie&&q(null);let Le=(0,J.useCallback)(e=>{r&&(Oe(`workspace`),q(n=>({locationKey:t.key,taskId:r,path:e,nonce:n?.locationKey===t.key&&n.taskId===r?n.nonce+1:1})))},[t.key,Oe,r]),[Be,Ve]=(0,J.useState)(``),He=T?.hostWorkspaces?.enabled===!0,Ue=T?.hostWorkspaces?.roots??[],[Ke,qe]=(0,J.useState)([]),[Je,Ye]=(0,J.useState)(``),Xe=d(e=>e.personas),Ze=d(e=>e.loadPersonas),[Qe,$e]=(0,J.useState)(``),et=(0,J.useMemo)(()=>Object.values(Xe).sort((e,t)=>e.name.localeCompare(t.name)),[Xe]);Qe&&et.length>0&&!Xe[Qe]&&$e(``);let tt=!O;(0,J.useEffect)(()=>{if(!tt)return;let e=!1;return U.listPolicies().then(t=>{if(e||!t.success||!t.data)return;let n=t.data;qe(n),Ye(e=>e&&!n.some(t=>t.id===e)?``:e)}).catch(()=>{}),()=>{e=!0}},[tt]),(0,J.useEffect)(()=>{tt&&Ze().catch(()=>{})},[tt,Ze]);let[rt,it]=(0,J.useState)(!1),[at,ot]=(0,J.useState)(null),st=Ke.some(e=>e.guiEnabled===!0),ct=(0,J.useCallback)(async()=>{it(!0),ot(null);try{let e=(await U.startComputerSetup()).data;for(;e?.building;)await new Promise(e=>window.setTimeout(e,4e3)),e=(await U.getComputerSetup()).data;if(e?.buildError){ot(e.buildError);return}let t=await U.listPolicies();t.success&&t.data&&(qe(t.data),e?.policyId&&Ye(e.policyId))}catch(e){ot(sr(e,`The Work Computer could not be set up.`))}finally{it(!1)}},[]),lt=O?.id,ut=O?.previewStatus===`running`||O?.previewStatus===`starting`;(0,J.useEffect)(()=>{if(!lt||!ut)return;let e=window.setInterval(()=>{document.visibilityState===`visible`&&z(lt,!0).catch(()=>{})},3e4);return()=>window.clearInterval(e)},[lt,ut,z]);let[dt,ft]=(0,J.useState)({taskId:null,open:!1}),pt=dt.open&&dt.taskId===O?.id,mt=(0,J.useRef)(null),ht=(0,J.useRef)(null),gt=(0,J.useRef)(null),_t=(0,J.useCallback)((e=!1)=>{ft(e=>({...e,open:!1})),e&&window.requestAnimationFrame(()=>ht.current?.focus())},[]);(0,J.useEffect)(()=>{if(!pt)return;let e=window.requestAnimationFrame(()=>{gt.current?.querySelector(`[role="menuitem"]`)?.focus()}),t=e=>{e.target instanceof Node&&!mt.current?.contains(e.target)&&_t()},n=e=>{e.key===`Escape`&&(e.preventDefault(),_t(!0))};return document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{window.cancelAnimationFrame(e),document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[_t,pt]);let vt=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),_t(!0);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;let t=[...gt.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,J.useEffect)(()=>{re(),L()},[re,L]),(0,J.useEffect)(()=>{if(!r){R(null);return}R(r),z(r).catch(()=>void 0),ge(r,``).catch(()=>void 0)},[r,ge,z,R]);let yt=W.find(e=>e.key===G)||W.find(e=>e.model===v&&(b===`plugin`?e.providerType===`plugin`&&e.providerId===x:e.providerType===`ollama`))||W[0],bt=r?E.find(e=>e.id===r):void 0,xt=bt?.status??O?.status;(0,J.useEffect)(()=>{r&&ce(r)},[r,xt,ce]);let St=O?.activeRun??bt?.activeRun??null,X=St?.id,Ct=St?.status===`queued`||St?.status===`preparing`||St?.status===`running`,wt=r&&M[r]?.runId===X?M[r]:void 0,Tt=xt===`preparing`||xt===`running`?1e3:4e3;(0,J.useEffect)(()=>{let e,t=!1,n=async()=>{await L(!0),t||(e=setTimeout(n,Tt))};return e=setTimeout(n,Tt),()=>{t=!0,e&&clearTimeout(e)}},[L,Tt]);let Et=(0,J.useRef)(null);(0,J.useEffect)(()=>{if(!r||!xt){Et.current=null;return}let e=Et.current;Et.current={taskId:r,status:xt},e?.taskId===r&&(e.status===`preparing`||e.status===`running`)&&xt!==`preparing`&&xt!==`running`&&(z(r,!0).catch(()=>void 0),ge(r,``).catch(()=>void 0))},[ge,z,xt,r]),(0,J.useEffect)(()=>{if(!r||!X||!Ct)return;let e=new AbortController,t=!1,n=0,i=ke.getState().liveRuns[r]?.runId===X&&ke.getState().liveRuns[r]?.lastEventId||0,a=!1,o=[],s=null,c=()=>{if(s!==null&&(window.cancelAnimationFrame(s),s=null),o.length===0)return;let e=o;o=[],pe(e)},l=e=>{if(e.type!==`snapshot`&&(n=0),i=Math.max(i,e.id),o.push(e),e.type===`done`||e.type===`error`&&e.data.terminal!==!1){a=!0,c();return}s===null&&(s=window.requestAnimationFrame(c))};return fe(r,X,St?.startedAt||void 0),(async()=>{for(;!t&&!e.signal.aborted&&!a;){V(r,X,n>=3?`error`:n===0?`connecting`:`reconnecting`);let o=Date.now();try{if(await U.streamRunEvents({taskId:r,runId:X,after:i,signal:e.signal,onEvent:l}),c(),a||t||e.signal.aborted)break;throw Error(`The live Work connection closed.`)}catch(i){if(c(),t||e.signal.aborted)return;Date.now()-o>=5e3&&(n=0),n+=1,V(r,X,n>=3?`error`:`reconnecting`,n>=3?sr(i,`Live updates are reconnecting in the background.`):void 0),await cr(Math.min(4e3,250*2**Math.min(n,4)),e.signal)}}if(c(),!(!a||e.signal.aborted)){V(r,X,`closed`);try{await Promise.all([z(r,!0),ge(r,``),L(!0)])}catch{}finally{me(r,X)}}})(),()=>{t=!0,e.abort(),c()}},[pe,fe,me,ge,z,L,St?.startedAt,Ct,X,V,r]),(0,J.useEffect)(()=>{if(!K)return;let e=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[K]);let Dt=(0,J.useCallback)(()=>!K||window.confirm(e(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),[e,K]),Ot=(0,J.useCallback)(()=>!K||window.confirm(e(`work.files.leaveWithDraft`,{defaultValue:`Leave this file? Your unsaved edit will remain as a browser draft.`})),[e,K]),kt=()=>{O&&A&&je(O.id,A.path)},jt=s(({currentLocation:e,nextLocation:t})=>{let n=t.state;return K&&n?.deletedWorkTaskId!==r&&`${e.pathname}${e.search}${e.hash}`!=`${t.pathname}${t.search}${t.hash}`});(0,J.useEffect)(()=>{if(jt.state!==`blocked`)return;if(!Ot()){jt.reset();return}let e=jt.proceed,t=window.setTimeout(()=>{Ae(!1),window.setTimeout(e,0)},0);return()=>window.clearTimeout(t)},[Ot,jt]);let Mt=()=>{H(),Oe(`conversation`),n(`/work`)},Nt=async t=>{if(O&&!Dt())return!1;O&&K&&(kt(),ve(),Ae(!1));try{if(O&&Ge(O)){let e=await U.sendRunMessage(O.id,t);if(!e.success)throw Error(e.message||`The message could not be sent.`);await z(O.id)}else if(O)await ue(O.id,{message:t,model:O.model,providerType:O.providerType,providerId:O.providerId||void 0});else{if(!yt)throw Error(e(`work.composer.noModelSelected`,{defaultValue:`No Work-compatible model is selected.`}));let r=await oe({message:t,model:yt.model,providerType:yt.providerType,providerId:yt.providerId,networkEnabled:!0,...He&&Be.trim()?{hostPath:Be.trim()}:{},...Je?{policyId:Je}:{},...Qe?{personaId:Qe,isAgent:!0}:{}});n(`/work/${r.id}`)}return!0}catch(t){return j.error(sr(t,e(`work.toasts.runFailed`,{defaultValue:`Could not start the Work task.`}))),!1}},Pt=async t=>{let n=Kt.find(e=>e.key===t);if(n){if(!O){Ce(t);return}try{await se(O.id,{model:n.model,providerType:n.providerType,providerId:n.providerId})}catch(t){j.error(sr(t,e(`work.toasts.updateFailed`,{defaultValue:`Could not update this task.`})))}}},Ft=async()=>{if(O)try{await de(O.id),j.success(e(`work.toasts.cancelled`,{defaultValue:`Work run stopped.`}))}catch(t){j.error(sr(t,e(`work.toasts.cancelFailed`,{defaultValue:`Could not stop the Work run.`})))}},It=async t=>{let i=E.find(e=>e.id===t);if(!window.confirm(e(`work.tasks.deleteConfirm`,{defaultValue:`Delete “{{title}}” and its workspace permanently?`,title:i?.title||e(`work.tasks.untitled`,{defaultValue:`Untitled task`})})))return;let a=r===t&&K;a&&Ae(!1);try{await B(t),Ne(t),r===t&&n(`/work`)}catch(t){a&&Ae(!0),j.error(sr(t,e(`work.toasts.deleteFailed`,{defaultValue:`Could not delete this Work task.`})))}},Lt=async t=>{if(!O)return!1;let n=t.trim();if(!n||n===O.title)return!!n;try{return await se(O.id,{title:n}),!0}catch(t){return j.error(sr(t,e(`work.toasts.renameFailed`,{defaultValue:`Could not rename this task.`}))),!1}},Rt=async(e,t,n)=>{try{return await e(),n&&j.success(n),!0}catch(e){return j.error(sr(e,t)),!1}},zt=async(t,n,r)=>{if(!O)return!1;let i=O.id;try{let a=await ye(i,t,n,r);return ke.getState().selectedTaskId===i&&j.success(e(`work.toasts.saved`,{defaultValue:`File saved.`})),a}catch(t){return ke.getState().selectedTaskId===i&&j.error(sr(t,e(`work.toasts.saveFailed`,{defaultValue:`Could not save this file.`}))),!1}},Z=T?.available===!1,Bt=e(`work.runtime.ready`,{defaultValue:`Runtime ready`}),Vt=T?.runtime===`kubernetes`?`Kubernetes · ${Bt}`:T?.pluginAvailable?T.ollamaAvailable?e(`work.runtime.readyHybrid`,{defaultValue:`Docker + models ready`}):e(`work.runtime.readyPlugin`,{defaultValue:`Docker + plugin ready`}):e(`work.runtime.readyOllama`,{defaultValue:`Docker ready`}),Ht=O?Ge(O):!1,Q=O?{model:O.model,providerType:O.providerType,providerId:O.providerId||void 0}:void 0,Ut=Q?We(Q):yt?.key||``,Gt=Q&&!W.some(e=>e.key===Ut)?{...Q,key:Ut,label:`${Q.model} · ${Q.providerType===`plugin`?Q.providerId||`plugin`:`Ollama`}`,remote:Q.providerType===`plugin`||Q.model.toLowerCase().endsWith(`:cloud`)||Q.model.toLowerCase().endsWith(`-cloud`)}:void 0,Kt=Gt?[Gt,...W]:W,qt=ze[O?.status??`idle`],Jt=e(qt.labelKey,{defaultValue:qt.label}),Yt=async()=>{if(u.workRemoteProviderDisclosureDismissed||h)return!1;let t=m;g(!0);try{let n=await Te.updatePreferences({workRemoteProviderDisclosureDismissed:!0});if(!n.success)throw Error(n.error||e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`}));return(Pe.getState().user?.id??null)===t&&(f({workRemoteProviderDisclosureDismissed:!0}),!0)}catch{return j.error(e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`})),!1}finally{g(!1)}};return(0,Y.jsx)(`div`,{"data-testid":`work-page`,className:`relative flex h-full min-h-0 overflow-hidden bg-transparent`,children:(0,Y.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Y.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:[O?(0,Y.jsx)(`input`,{"data-testid":`work-task-title`,dir:`auto`,defaultValue:O.title,onBlur:e=>{let t=e.currentTarget;if(!t.value.trim()){t.value=O.title;return}Lt(t.value).then(e=>{e||(t.value=O.title)})},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=O.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`})},`${O.id}:${O.title}`):(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(`h1`,{className:`truncate text-sm font-semibold text-ink`,children:e(`work.title`,{defaultValue:`Work`})})}),O?.hostPath&&(0,Y.jsxs)(`span`,{"data-testid":`work-host-path-chip`,title:O.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,Y.jsx)(le,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`max-w-[16rem] truncate`,children:O.hostPath})]}),O&&(0,Y.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,Y.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`work-compact-status-indicator`,className:l(`h-1.5 w-1.5 rounded-full`,qt.animated&&`animate-pulse`,O.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:qt.color}}),(0,Y.jsx)(`span`,{className:`hidden md:inline`,children:Jt})]}),O&&(0,Y.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,Y.jsxs)(`button`,{type:`button`,onClick:()=>Oe(`conversation`),"aria-label":e(`work.mobile.conversation`,{defaultValue:`Conversation`}),"aria-pressed":De===`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`,De===`conversation`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,Y.jsx)(w,{className:`h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.conversation`,{defaultValue:`Conversation`})})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>Oe(`workspace`),"aria-label":e(`work.mobile.workspace`,{defaultValue:`Workspace`}),"aria-pressed":De===`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`,De===`workspace`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,Y.jsx)(ie,{className:`h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.workspace`,{defaultValue:`Workspace`})})]})]}),(0,Y.jsxs)(`div`,{className:l(`ms-auto hidden min-w-0 items-center gap-2`,O?`xl:flex`:`sm:flex`),children:[O&&(0,Y.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,Y.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`work-status-indicator`,className:l(`h-1.5 w-1.5 rounded-full`,qt.animated&&`animate-pulse`,O.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:qt.color}}),Jt]}),(0,Y.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`,Z?`border-transparent bg-error-500 text-[#0D0D0C]`:`border-transparent bg-success-500 text-[#0D0D0C]`),title:Z?T?.reason||e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):T?.image?`${Vt} · ${T.image}`:Vt,children:[(0,Y.jsx)(I,{className:`h-3.5 w-3.5`}),Z?e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):Bt]}),O&&(0,Y.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,Y.jsx)(D,{className:`h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{dir:`ltr`,className:`truncate`,children:O.model})]})]}),O&&(0,Y.jsxs)(`div`,{ref:mt,className:`relative shrink-0`,children:[(0,Y.jsx)(`button`,{ref:ht,id:`work-task-actions-trigger`,type:`button`,"data-testid":`work-task-actions-button`,onClick:()=>ft(e=>({taskId:O.id,open:e.taskId!==O.id||!e.open})),onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),ft({taskId:O.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":pt,"aria-controls":pt?`work-task-actions-menu`:void 0,children:(0,Y.jsx)(ee,{className:`h-4 w-4`})}),pt&&(0,Y.jsx)(`div`,{ref:gt,id:`work-task-actions-menu`,role:`menu`,"aria-labelledby":`work-task-actions-trigger`,onKeyDown:vt,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,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`work-delete-task-button`,onClick:()=>{_t(!0),It(O.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,Y.jsx)(he,{className:`h-3.5 w-3.5`}),e(`work.tasks.delete`,{defaultValue:`Delete task`})]})})]})]}),(Z||ne)&&(0,Y.jsxs)(`div`,{className:l(`flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs`,Z?`border-error-500/20 bg-error-500/10 text-error-700`:`border-amber-500/20 bg-amber-500/10 text-ink`),children:[(0,Y.jsx)(C,{className:`h-4 w-4 shrink-0`}),(0,Y.jsx)(`span`,{dir:`auto`,className:`min-w-0 flex-1`,children:Z?T?.reason||e(`work.runtime.reason`,{defaultValue:`A Work runtime and an available Ollama or plugin model provider are required.`}):ne}),ne&&!Z&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded-md p-1 hover:bg-black/5`,onClick:H,"aria-label":e(`common.close`),children:`×`})]}),r?O?(0,Y.jsx)(Wt,{userId:m,mobileSurface:De,conversation:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(At,{task:O,user:p,liveRun:wt,loading:N,loadingOlder:te,onLoadOlder:()=>ae(O.id),onOpenFile:Le}),(0,Y.jsx)(nt,{dictationOwnerKey:O.id,models:Kt,selectorModels:Se,modelKey:Ut,running:Ht,loading:F,disabled:Z,remoteDisclosureDismissed:u.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:h,onModelChange:Pt,onDismissRemoteDisclosure:Yt,onModelsRefresh:S,onSubmit:Nt,onCancel:Ft},O.id)]}),workspace:(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:(0,Y.jsx)(ar,{task:O,openFileRequest:Ie?.taskId===O.id?Ie:null,persona:O.personaId?Xe[O.personaId]:void 0,liveRun:wt,files:k,selectedFile:A,loadingFiles:P,actionLoading:F,onLoadFiles:e=>ge(O.id,e),onLoadFile:e=>_e(O.id,e),onClearSelectedFile:ve,onSaveFile:zt,onStartPreview:t=>Rt(()=>be(O.id,t),e(`work.toasts.previewFailed`,{defaultValue:`Could not start the preview.`})),onStopPreview:()=>Rt(()=>xe(O.id),e(`work.toasts.previewStopFailed`,{defaultValue:`Could not stop the preview.`})),onDirtyChange:Ae,terminal:T?.terminal},O.id)})}):(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center`,children:N?(0,Y.jsx)(`div`,{className:`text-sm text-ink-muted`,children:e(`work.tasks.loading`,{defaultValue:`Loading task…`})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(C,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,Y.jsx)(`h2`,{className:`text-lg font-semibold text-ink`,children:e(`work.tasks.notFound`,{defaultValue:`This Work task is unavailable`})}),(0,Y.jsxs)(`button`,{type:`button`,onClick:Mt,className:`mt-4 inline-flex items-center gap-1.5 text-sm font-medium text-primary-600 hover:text-primary-700`,children:[(0,Y.jsx)(y,{className:`h-4 w-4 rtl:rotate-180`}),e(`work.tasks.back`,{defaultValue:`Start a new task`})]})]})}):(0,Y.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-y-auto`,children:[(0,Y.jsxs)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0`,children:[(0,Y.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,Y.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,Y.jsx)(`div`,{className:`absolute left-1/2 top-0 h-16 w-px bg-gray-300/60 dark:bg-white/10`})]}),(0,Y.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,Y.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-center justify-center gap-3`,children:[(0,Y.jsx)(Re,{size:`sm`,label:null,className:`h-9 w-9 shrink-0 p-0 text-ink`}),(0,Y.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,Y.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.`})})]}),Ke.length>0&&(0,Y.jsxs)(`div`,{className:`mt-8 w-full max-w-2xl`,children:[(0,Y.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,Y.jsxs)(`select`,{id:`work-policy`,"data-testid":`work-policy`,value:Je,onChange:e=>Ye(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,Y.jsx)(`option`,{value:``,children:e(`work.policy.default`,{defaultValue:`Default (global limits)`})}),Ke.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),et.length>0&&(0,Y.jsxs)(`div`,{className:`mt-8 w-full max-w-2xl`,children:[(0,Y.jsx)(`label`,{htmlFor:`work-persona`,className:`mb-1.5 block text-xs font-medium text-ink-muted`,children:e(`work.persona.label`,{defaultValue:`Hire as an agent (optional)`})}),(0,Y.jsxs)(`select`,{id:`work-persona`,"data-testid":`work-persona`,value:Qe,onChange:e=>$e(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,Y.jsx)(`option`,{value:``,children:e(`work.persona.none`,{defaultValue:`No persona (one-off task)`})}),et.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,Y.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-ink-subtle`,children:Qe?e(`work.persona.hint`,{defaultValue:`This task becomes a named agent: it keeps the persona, stays pinned in the sidebar, and reports a one-line status after each run.`}):e(`work.persona.description`,{defaultValue:`Pick a persona to turn this task into a persistent agent with its own identity.`})})]}),!st&&p?.role===`admin`&&(0,Y.jsxs)(`div`,{className:`mt-8 flex w-full max-w-2xl items-center justify-between gap-4 rounded-xl border border-line bg-surface px-4 py-3`,"data-testid":`work-policy-setup-hint`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`text-[13px] font-medium text-ink`,children:e(`work.computerSetup.title`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-muted`,children:at??e(rt?`work.computerSetup.building`:`work.computerSetup.description`)})]}),(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`work-computer-enable`,onClick:()=>void ct(),disabled:rt,className:`flex shrink-0 items-center gap-2 rounded-lg bg-primary-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-primary-500 disabled:opacity-60`,children:[rt&&(0,Y.jsx)(`span`,{className:`h-3 w-3 animate-spin rounded-full border border-white/40 border-t-white`}),e(at?`work.computerSetup.retry`:`work.computerSetup.enable`)]})]}),He&&(0,Y.jsxs)(`div`,{className:`mt-8 w-full max-w-2xl`,children:[(0,Y.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,Y.jsx)(`input`,{id:`work-host-path`,"data-testid":`work-host-path`,value:Be,onChange:e=>Ve(e.target.value),spellCheck:!1,placeholder:Ue[0]?`${Ue[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,Y.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-ink-subtle`,children:Be.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,Y.jsx)(nt,{variant:`landing`,dictationOwnerKey:`landing`,models:W,selectorModels:Se,modelKey:yt?.key||``,running:!1,loading:F,disabled:Z,remoteDisclosureDismissed:u.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:h,onModelChange:Pt,onDismissRemoteDisclosure:Yt,onModelsRefresh:S,onSubmit:Nt,onCancel:Ft}),(0,Y.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,Y.jsx)(I,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{children:e(`work.composer.hint`,{defaultValue:`Each task keeps its own files and history. Review model output before using it.`})})]})]})]})]})})}export{lr as default};
@@ -1 +0,0 @@
1
- import"./workApi-BwDBwG62.js";import{m as e,s as t,z as n}from"./api-2DulPtq1.js";import"./imageGenModels-Dx_QMLJQ.js";export{n as agentCliApi,e as personaApi,t as preferencesApi};
@@ -1 +0,0 @@
1
- function e(e,t=`0.29.0`){return t?.trim()||e?.trim()||``}export{e as t};