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.
- package/backend/dist/index.d.ts.map +1 -1
- package/backend/dist/index.js +24 -7
- package/backend/dist/index.js.map +1 -1
- package/backend/dist/persistence/postgresAutomationWebhooksMigration.d.ts +9 -0
- package/backend/dist/persistence/postgresAutomationWebhooksMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresAutomationWebhooksMigration.js +38 -0
- package/backend/dist/persistence/postgresAutomationWebhooksMigration.js.map +1 -0
- package/backend/dist/persistence/postgresMigrationRegistry.d.ts.map +1 -1
- package/backend/dist/persistence/postgresMigrationRegistry.js +4 -0
- package/backend/dist/persistence/postgresMigrationRegistry.js.map +1 -1
- package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/postgresResourceRepositories.js +5 -0
- package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
- package/backend/dist/persistence/postgresWorkApprovalsMigration.d.ts +13 -0
- package/backend/dist/persistence/postgresWorkApprovalsMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresWorkApprovalsMigration.js +69 -0
- package/backend/dist/persistence/postgresWorkApprovalsMigration.js.map +1 -0
- package/backend/dist/persistence/resourceTypes.d.ts +4 -0
- package/backend/dist/persistence/resourceTypes.d.ts.map +1 -1
- package/backend/dist/persistence/resourceTypes.js.map +1 -1
- package/backend/dist/persistence/sqliteMigrations.d.ts +3 -0
- package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteMigrations.js +156 -2
- package/backend/dist/persistence/sqliteMigrations.js.map +1 -1
- package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteResourceRepositories.js +7 -0
- package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.js +32 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -1
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.d.ts +10 -1
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.d.ts.map +1 -1
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.js +85 -5
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.js.map +1 -1
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.d.ts +10 -1
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.d.ts.map +1 -1
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js +67 -7
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js.map +1 -1
- package/backend/dist/platform/workPersistence/types.d.ts +37 -0
- package/backend/dist/platform/workPersistence/types.d.ts.map +1 -1
- package/backend/dist/platform/workPersistence/types.js.map +1 -1
- package/backend/dist/routes/automations.d.ts.map +1 -1
- package/backend/dist/routes/automations.js +83 -1
- package/backend/dist/routes/automations.js.map +1 -1
- package/backend/dist/routes/ollama.d.ts.map +1 -1
- package/backend/dist/routes/ollama.js +64 -0
- package/backend/dist/routes/ollama.js.map +1 -1
- package/backend/dist/routes/plugins.d.ts.map +1 -1
- package/backend/dist/routes/plugins.js +90 -0
- package/backend/dist/routes/plugins.js.map +1 -1
- package/backend/dist/routes/work.d.ts.map +1 -1
- package/backend/dist/routes/work.js +83 -0
- package/backend/dist/routes/work.js.map +1 -1
- package/backend/dist/services/authService.d.ts +2 -0
- package/backend/dist/services/authService.d.ts.map +1 -1
- package/backend/dist/services/authService.js +2 -0
- package/backend/dist/services/authService.js.map +1 -1
- package/backend/dist/services/automationService.d.ts +13 -1
- package/backend/dist/services/automationService.d.ts.map +1 -1
- package/backend/dist/services/automationService.js +31 -0
- package/backend/dist/services/automationService.js.map +1 -1
- package/backend/dist/services/notificationService.d.ts.map +1 -1
- package/backend/dist/services/notificationService.js +1 -0
- package/backend/dist/services/notificationService.js.map +1 -1
- package/backend/dist/services/ollamaService.d.ts +12 -0
- package/backend/dist/services/ollamaService.d.ts.map +1 -1
- package/backend/dist/services/ollamaService.js +26 -0
- package/backend/dist/services/ollamaService.js.map +1 -1
- package/backend/dist/services/ollamaSettingsService.d.ts +10 -0
- package/backend/dist/services/ollamaSettingsService.d.ts.map +1 -0
- package/backend/dist/services/ollamaSettingsService.js +83 -0
- package/backend/dist/services/ollamaSettingsService.js.map +1 -0
- package/backend/dist/services/workAgentGuidance.d.ts +11 -0
- package/backend/dist/services/workAgentGuidance.d.ts.map +1 -1
- package/backend/dist/services/workAgentGuidance.js +16 -2
- package/backend/dist/services/workAgentGuidance.js.map +1 -1
- package/backend/dist/services/workAgentService.d.ts +56 -0
- package/backend/dist/services/workAgentService.d.ts.map +1 -1
- package/backend/dist/services/workAgentService.js +467 -17
- package/backend/dist/services/workAgentService.js.map +1 -1
- package/backend/dist/services/workApprovalService.d.ts +67 -0
- package/backend/dist/services/workApprovalService.d.ts.map +1 -0
- package/backend/dist/services/workApprovalService.js +273 -0
- package/backend/dist/services/workApprovalService.js.map +1 -0
- package/backend/dist/services/workEventService.d.ts.map +1 -1
- package/backend/dist/services/workEventService.js +25 -0
- package/backend/dist/services/workEventService.js.map +1 -1
- package/backend/dist/services/workPolicyService.d.ts +4 -0
- package/backend/dist/services/workPolicyService.d.ts.map +1 -1
- package/backend/dist/services/workPolicyService.js +19 -0
- package/backend/dist/services/workPolicyService.js.map +1 -1
- package/backend/dist/services/workRuntimeShared.d.ts +2 -0
- package/backend/dist/services/workRuntimeShared.d.ts.map +1 -1
- package/backend/dist/services/workRuntimeShared.js.map +1 -1
- package/backend/dist/services/workTaskService.d.ts +3 -1
- package/backend/dist/services/workTaskService.d.ts.map +1 -1
- package/backend/dist/services/workTaskService.js +21 -4
- package/backend/dist/services/workTaskService.js.map +1 -1
- package/backend/dist/types/index.d.ts +3 -1
- package/backend/dist/types/index.d.ts.map +1 -1
- package/backend/dist/types/index.js.map +1 -1
- package/backend/dist/types/work.d.ts +32 -11
- package/backend/dist/types/work.d.ts.map +1 -1
- package/backend/dist/websocketServer.d.ts.map +1 -1
- package/backend/dist/websocketServer.js +14 -2
- package/backend/dist/websocketServer.js.map +1 -1
- package/backend/package.json +2 -2
- package/deploy/work-computer/Dockerfile +1 -0
- package/deploy/work-computer/tint2rc +1 -0
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
- package/frontend/dist/artifact-runtime/mermaid.js +8 -8
- package/frontend/dist/artifact-runtime/papaparse.js +2 -2
- package/frontend/dist/artifact-runtime/plotly.js +371 -652
- package/frontend/dist/assets/index-B6xMZpzA.js +76 -0
- package/frontend/dist/assets/index-BjipfsCP.css +1 -0
- package/frontend/dist/index.html +28 -28
- package/frontend/dist/js/{ArtifactContainer-CTXxnWRo.js → ArtifactContainer-Bn6iJtaJ.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-CEYuIhJA.js → ArtifactDemoPage-BLF8Ok-o.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-DLOy2VOm.js → ArtifactSandboxFrame-Cs1Gu1WB.js} +1 -1
- package/frontend/dist/js/{ArtifactSlideOutPanel-DnTTc1VY.js → ArtifactSlideOutPanel-CuKq5cL0.js} +1 -1
- package/frontend/dist/js/AutomationModal-Dha4KgLI.js +1 -0
- package/frontend/dist/js/AutomationsPage-HcMCRV-D.js +1 -0
- package/frontend/dist/js/{AvatarUpload-DzL00yOL.js → AvatarUpload-CFrlSszY.js} +1 -1
- package/frontend/dist/js/{Button--pDOakZx.js → Button-CgN11mgY.js} +1 -1
- package/frontend/dist/js/{CalendarPage-Bls3TBeZ.js → CalendarPage-D_K-XrG9.js} +1 -1
- package/frontend/dist/js/ChannelsPage-D3CoImOT.js +1 -0
- package/frontend/dist/js/ChatPage-C0iBDbOq.js +14 -0
- package/frontend/dist/js/ConnectModels-D_ZbZQub.js +1 -0
- package/frontend/dist/js/{EvaluationsPage-DSgj9dT5.js → EvaluationsPage-DOJLpauA.js} +2 -2
- package/frontend/dist/js/FirstTimeSetup-DDIP_4Dd.js +1 -0
- package/frontend/dist/js/GalleryPage-C8U_F7Ns.js +1 -0
- package/frontend/dist/js/{HomePage-BebX3v-x.js → HomePage-B_aotoDU.js} +1 -1
- package/frontend/dist/js/LibreClawPage-cr2N6W00.js +1 -0
- package/frontend/dist/js/{Logo-BE9SvCC5.js → Logo-B7o7eaPU.js} +1 -1
- package/frontend/dist/js/{LogoMark-C8x1yyP3.js → LogoMark-D9g6ls0h.js} +1 -1
- package/frontend/dist/js/{ModelManagerModals-CpWAltRA.js → ModelManagerModals-C-J1d7GL.js} +1 -1
- package/frontend/dist/js/NotesPage-Bgr7R_Vm.js +3 -0
- package/frontend/dist/js/{PasswordStrengthMeter-Cdq2oQbc.js → PasswordStrengthMeter-DR-mGbLF.js} +1 -1
- package/frontend/dist/js/PersonasPage-C3D_6lIx.js +13 -0
- package/frontend/dist/js/{PluginUsagePage-jMrpL2Jb.js → PluginUsagePage-DK7MgSiu.js} +1 -1
- package/frontend/dist/js/RichMessageContent-7FxrZ4A8.js +1 -0
- package/frontend/dist/js/{RichMessageContent-CC9QZQKd.js → RichMessageContent-CQkLI7Dt.js} +1 -1
- package/frontend/dist/js/SettingsModal-CIV_Bgsf.js +19 -0
- package/frontend/dist/js/{SettingsToggle-C16gtVyi.js → SettingsToggle-Cw4OhW7B.js} +1 -1
- package/frontend/dist/js/ShareDialog-BCEVgtbN.js +1 -0
- package/frontend/dist/js/{SystemPage-Drd1neLN.js → SystemPage-BNVZtLe9.js} +1 -1
- package/frontend/dist/js/{UserManagementPage-CquciWKV.js → UserManagementPage-pPC_Svj9.js} +1 -1
- package/frontend/dist/js/WorkPage-Q33nIqkM.js +7 -0
- package/frontend/dist/js/{api-2DulPtq1.js → api-D-5hpGht.js} +3 -3
- package/frontend/dist/js/api-WR1CTYO5.js +1 -0
- package/frontend/dist/js/{appNavigation-DAGh98Yj.js → appNavigation-DfHbXBey.js} +1 -1
- package/frontend/dist/js/{appStore-Ci1X0yA-.js → appStore-B136FGdu.js} +2 -2
- package/frontend/dist/js/appVersion-Ck7dYiHe.js +1 -0
- package/frontend/dist/js/ar-Cq-nC6v9.js +2 -0
- package/frontend/dist/js/authStore-6AJLgQsD.js +1 -0
- package/frontend/dist/js/authStore-Ckz37pwu.js +4 -0
- package/frontend/dist/js/axios-CUerAKcc.js +1 -0
- package/frontend/dist/js/{babel-D7QYvEns.js → babel-8afoxhZ7.js} +1 -1
- package/frontend/dist/js/bn-BFSKytYs.js +2 -0
- package/frontend/dist/js/chatStore-Dpm3g_Ln.js +3 -0
- package/frontend/dist/js/classPrivateMethodInitSpec-DE0XIqc_.js +1 -0
- package/frontend/dist/js/config-DJwXAf8i.js +1 -0
- package/frontend/dist/js/cs-BKWXa629.js +2 -0
- package/frontend/dist/js/da-Cra_DJnV.js +2 -0
- package/frontend/dist/js/de-BQa6_UuE.js +2 -0
- package/frontend/dist/js/es-BBOHFrx1.js +2 -0
- package/frontend/dist/js/{estree-D7xT4AeP.js → estree-qxY7ACbu.js} +3 -3
- package/frontend/dist/js/{evaluationsApi-Cu5PH_qi.js → evaluationsApi-BKY-maUM.js} +1 -1
- package/frontend/dist/js/fr-C8kXs5c0.js +2 -0
- package/frontend/dist/js/hi-BEef4bjU.js +2 -0
- package/frontend/dist/js/{html-HvA9vEyn.js → html-B_cUU1Gi.js} +2 -2
- package/frontend/dist/js/id-Djipic7Y.js +2 -0
- package/frontend/dist/js/is-pazl6RLG.js +2 -0
- package/frontend/dist/js/it-DobPbTwl.js +2 -0
- package/frontend/dist/js/ja-DwYNaMNX.js +2 -0
- package/frontend/dist/js/ko-BQfXE7_o.js +2 -0
- package/frontend/dist/js/{markdown-DaF0SXNk.js → markdown-BAF0w-jL.js} +3 -3
- package/frontend/dist/js/{messageCodeStyles-DKq3DH1W.js → messageCodeStyles-CkxF6yil.js} +2 -2
- package/frontend/dist/js/ms-CkPQoE5T.js +2 -0
- package/frontend/dist/js/nl-X_QsDAtu.js +2 -0
- package/frontend/dist/js/pl-CK39gUsy.js +2 -0
- package/frontend/dist/js/{postcss-RCIJRrFm.js → postcss-B2vYq4-H.js} +1 -1
- package/frontend/dist/js/pt-C0dWyR_I.js +2 -0
- package/frontend/dist/js/{router-vendor-BGP0k6Y2.js → router-vendor-CIwPu612.js} +1 -1
- package/frontend/dist/js/ru-sNJkEz1G.js +2 -0
- package/frontend/dist/js/{standalone-BMD7E0jY.js → standalone-BqZmfuRy.js} +2 -2
- package/frontend/dist/js/sv-Bh-uxdF3.js +2 -0
- package/frontend/dist/js/{teamEventStream-C4u_py2D.js → teamEventStream-DUodK0-C.js} +1 -1
- package/frontend/dist/js/th-DPVtwZj2.js +2 -0
- package/frontend/dist/js/tr-BYNM_Tm7.js +2 -0
- package/frontend/dist/js/{ttsBatching-C9kQXFB1.js → ttsBatching-7_-p2nxR.js} +1 -1
- package/frontend/dist/js/{typescript-LOiqVRM1.js → typescript-DokwN-5Y.js} +1 -1
- package/frontend/dist/js/{ui-DUzqxWMk.js → ui-BK53RPmS.js} +2 -2
- package/frontend/dist/js/ui-vendor-CPdYrKhz.js +177 -0
- package/frontend/dist/js/uk-kvNBuYin.js +2 -0
- package/frontend/dist/js/{useChat-6yDWZSTz.js → useChat-Czg2p4Rr.js} +1 -1
- package/frontend/dist/js/useDictation-B2lYEYKn.js +1 -0
- package/frontend/dist/js/useQuery-ClAiNxQ7.js +1 -0
- package/frontend/dist/js/{useTranslation-DrnYb6Cx.js → useTranslation-C7GwbUQA.js} +1 -1
- package/frontend/dist/js/{utils-D9UstwTG.js → utils-nNyg0lfc.js} +1 -1
- package/frontend/dist/js/utils-vendor-CeUf_ngc.js +9 -0
- package/frontend/dist/js/vi-CmLoaP0K.js +2 -0
- package/frontend/dist/js/workApi-BoJb9aVF.js +1 -0
- package/frontend/dist/js/{workApi-BwDBwG62.js → workApi-CFH097y5.js} +3 -3
- package/frontend/dist/js/{yaml-CyhEdlt2.js → yaml-BXEpxPn2.js} +2 -2
- package/frontend/dist/js/zh-D2zvmvrj.js +2 -0
- package/frontend/dist/sw.js +7 -1
- package/package.json +5 -5
- package/frontend/dist/assets/index-O8rtJINp.css +0 -1
- package/frontend/dist/assets/index-f1s6QpC5.js +0 -93
- package/frontend/dist/js/AutomationModal-DB3lrK2K.js +0 -1
- package/frontend/dist/js/AutomationsPage-D3v0Cra1.js +0 -1
- package/frontend/dist/js/ChannelsPage-BnoCniNf.js +0 -1
- package/frontend/dist/js/ChatPage-BMcigJWr.js +0 -14
- package/frontend/dist/js/FirstTimeSetup-BRysXCjP.js +0 -1
- package/frontend/dist/js/GalleryPage-DUcM4dg0.js +0 -1
- package/frontend/dist/js/LibreClawPage-A37KF9_G.js +0 -1
- package/frontend/dist/js/ModelSelector-C1ipX-44.js +0 -1
- package/frontend/dist/js/NotesPage-CXSz7Hde.js +0 -3
- package/frontend/dist/js/PersonasPage-CiOBffF3.js +0 -13
- package/frontend/dist/js/RichMessageContent-CU6WTuOs.js +0 -1
- package/frontend/dist/js/SettingsModal-DP_wKehV.js +0 -19
- package/frontend/dist/js/ShareDialog-BW8iGd_i.js +0 -1
- package/frontend/dist/js/WorkPage-BgASwAGs.js +0 -6
- package/frontend/dist/js/api-BmIdrQfK.js +0 -1
- package/frontend/dist/js/appVersion-BRMnr50t.js +0 -1
- package/frontend/dist/js/ar-CpmN0TY8.js +0 -2
- package/frontend/dist/js/authStore-DIvsSaOt.js +0 -4
- package/frontend/dist/js/authStore-DoxafXFR.js +0 -1
- package/frontend/dist/js/axios-C8xWfUG8.js +0 -1
- package/frontend/dist/js/bn-BwrMg_Oh.js +0 -2
- package/frontend/dist/js/chatStore-DkpmZLOG.js +0 -3
- package/frontend/dist/js/classPrivateMethodInitSpec-DUpGnGHL.js +0 -1
- package/frontend/dist/js/config-Ckn9cand.js +0 -1
- package/frontend/dist/js/cs-f72Fnxz3.js +0 -2
- package/frontend/dist/js/da-qp8lOgkJ.js +0 -2
- package/frontend/dist/js/de-CpcLHr97.js +0 -2
- package/frontend/dist/js/es-gZHsxjG4.js +0 -2
- package/frontend/dist/js/fr-BY5aUofi.js +0 -2
- package/frontend/dist/js/hi-KCn9gIiT.js +0 -2
- package/frontend/dist/js/id-C7U6kS0J.js +0 -2
- package/frontend/dist/js/is-N9Ek-Usz.js +0 -2
- package/frontend/dist/js/it-CqaqWB8D.js +0 -2
- package/frontend/dist/js/ja-C5f9HAm1.js +0 -2
- package/frontend/dist/js/ko-BuoboDvb.js +0 -2
- package/frontend/dist/js/ms-Cu-UWc6j.js +0 -2
- package/frontend/dist/js/nl-nOUc4C_i.js +0 -2
- package/frontend/dist/js/pl-BKKwFhxj.js +0 -2
- package/frontend/dist/js/pt-B18-KYtS.js +0 -2
- package/frontend/dist/js/ru-DflEWNyb.js +0 -2
- package/frontend/dist/js/sv-CU-nPjr8.js +0 -2
- package/frontend/dist/js/th-dOxm2Hhl.js +0 -2
- package/frontend/dist/js/tr-7ThM4F8q.js +0 -2
- package/frontend/dist/js/ui-vendor-C0KwbTD4.js +0 -177
- package/frontend/dist/js/uk-Cl7Pk0Yf.js +0 -2
- package/frontend/dist/js/useQuery-CoWV2PmJ.js +0 -1
- package/frontend/dist/js/utils-vendor-DtsgPwcz.js +0 -9
- package/frontend/dist/js/vi-eljYUBOk.js +0 -2
- package/frontend/dist/js/workApi-uXUZSjsf.js +0 -1
- package/frontend/dist/js/zh-B0sinUfQ.js +0 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/babel-8afoxhZ7.js","js/router-vendor-CIwPu612.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-CsTEqgp1.js","js/estree-qxY7ACbu.js","js/classPrivateMethodInitSpec-DE0XIqc_.js","js/typescript-DokwN-5Y.js","js/postcss-B2vYq4-H.js","js/html-B_cUU1Gi.js","js/markdown-BAF0w-jL.js","js/yaml-BXEpxPn2.js","js/standalone-BqZmfuRy.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-CIwPu612.js";import{t as c}from"./useTranslation-C7GwbUQA.js";import{t as l}from"./utils-nNyg0lfc.js";import{T as u,t as d}from"./chatStore-Dpm3g_Ln.js";import{$t as f,A as p,Bn as m,E as h,F as g,Fn as _,G as v,Gn as y,Kn as b,Kt as x,L as S,Nt as C,O as w,Q as T,Sn as E,U as D,Vn as O,Y as k,Yt as A,a as j,an as M,bn as ee,c as N,cn as P,dn as F,er as I,fn as L,fr as R,gr as te,gt as z,hn as B,i as ne,l as re,mt as ie,n as V,nr as ae,o as oe,ot as se,pr as ce,q as le,qn as ue,qt as de,tn as fe,tt as pe,un as me,ur as he,v as ge,wt as _e,xt as ve,yr as H,yt as ye}from"./ui-vendor-CPdYrKhz.js";import{r as be}from"./logger-CpCQz3Vi.js";import{t as xe}from"./config-DJwXAf8i.js";import{n as U,t as W}from"./workApi-CFH097y5.js";import{T as G,_ as K,f as Se,g as Ce,h as we,s as Te}from"./api-D-5hpGht.js";import{a as Ee,c as De,d as Oe,f as q,i as ke,l as Ae,o as je,r as Me,s as Ne,t as Pe}from"./authStore-Ckz37pwu.js";import{t as Fe}from"./appStore-B136FGdu.js";import{t as J}from"./Button-CgN11mgY.js";import{h as Ie,s as Le}from"./ui-BK53RPmS.js";import{t as Re}from"./LogoMark-D9g6ls0h.js";import{t as ze}from"./workStatus-CcO9Fg41.js";import{t as Be}from"./RichMessageContent-CQkLI7Dt.js";import{n as Ve,t as He}from"./AutomationModal-Dha4KgLI.js";import{n as Ue,t as We}from"./useDictation-B2lYEYKn.js";import{n as Ge,t as Ke}from"./work-DVgm81bJ.js";var Y=e(t(),1),X=n(),Z=e=>Ge({model:e.name,providerType:e.isPlugin?`plugin`:`ollama`,providerId:e.isPlugin?e.pluginId:void 0}),qe=e=>{let t=e.name.split(`/`).filter(Boolean),n=t[t.length-1]||e.name;return t.length>1?n.replace(/[-_]+/g,` `):n},Je=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 Ye({models:e,selectorModels:t,modelKey:n,running:r,loading:i,variant:a=`task`,disabled:o=!1,mentionAgents:s,dictationOwnerKey:u,remoteDisclosureDismissed:d,remoteDisclosureSaving:f,onModelChange:p,onDismissRemoteDisclosure:g,onModelsRefresh:_,onSubmit:v,onCancel:y}){let{t:b}=c(),[x,S]=(0,Y.useState)(``),w=(0,Y.useRef)(null),T=(0,Y.useRef)(``),E=We({onStart:()=>{T.current=w.current?.value??``},onText:e=>{let t=T.current;S(t?`${t} ${e}`:e)},ownerKey:u}),D=E.phase!==`idle`,O=(0,Y.useRef)(null),k=(0,Y.useRef)(null),A=e.find(e=>e.key===n),j=A?.remote===!0,M=a===`landing`,ee=(0,Y.useMemo)(()=>{let n=new Set(t.map(Z)),r=e.filter(e=>!n.has(e.key)).map(Je);return[...t,...r]},[e,t]);(0,Y.useEffect)(()=>{let e=w.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,160)}px`)},[x]);let N=async()=>{await g()&&([O.current,k.current].find(e=>e&&e.offsetParent!==null)||O.current)?.focus()},P=t=>{let n=e.find(e=>e.key===t)||e.find(e=>e.providerType===`ollama`&&e.model===t);n&&p(n.key)},F=async()=>{let e=x.trim();!e||i||o||!r&&!A||await v(e)&&S(``)},[I,L]=(0,Y.useState)(null),[R,te]=(0,Y.useState)(0),z=(e,t)=>{if(!s?.length){L(null);return}let n=/(?:^|\s)@([^\n@]{0,60})$/.exec(e.slice(0,t));if(!n){L(null);return}let r=n[1];L({start:t-r.length-1,end:t,query:r}),te(0)},B=I===null?[]:(s??[]).filter(e=>e.name.toLowerCase().startsWith(I.query.trimStart().toLowerCase())),ne=I!==null&&B.length>0,re=e=>{if(!I)return;let t=`${x.slice(0,I.start)}@${e.name} ${x.slice(I.end)}`,n=I.start+e.name.length+2;S(t),L(null),requestAnimationFrame(()=>{let e=w.current;e&&(e.focus(),e.setSelectionRange(n,n))})};return(0,X.jsxs)(`div`,{"data-testid":M?`work-landing-composer`:`work-task-composer`,"data-variant":a,className:l(`relative shrink-0`,M?`mt-10 w-full`:`border-t border-line bg-surface/95 px-3 py-3 backdrop-blur md:px-5`),children:[j&&!d&&(0,X.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,X.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,X.jsx)(`button`,{type:`button`,onClick:()=>void N(),disabled:f,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":b(`work.composer.remoteDismissLabel`,{defaultValue:`Dismiss remote provider notice`}),children:(0,X.jsx)(V,{className:`h-4 w-4`})}),(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.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,X.jsx)(m,{"data-testid":`work-provider-disclosure-accent`,className:`h-4 w-4 text-warning-500`,"aria-hidden":`true`})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`p`,{id:`work-provider-disclosure-title`,className:`text-sm font-semibold text-ink`,children:b(`work.composer.remoteTitle`,{defaultValue:`Remote provider`})}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-ink-muted`,children:b(`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,X.jsx)(`div`,{className:`mt-2.5 flex justify-end`,children:(0,X.jsx)(J,{"data-testid":`work-provider-disclosure-dismiss`,type:`button`,variant:`ghost`,size:`sm`,loading:f,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 N(),children:b(`work.composer.remoteDismiss`,{defaultValue:`Dismiss`})})})]})]})]})}),(0,X.jsxs)(`form`,{className:`relative mx-auto w-full max-w-3xl`,onSubmit:e=>{e.preventDefault(),F()},children:[ne&&(0,X.jsx)(`div`,{"data-testid":`work-mention-menu`,role:`listbox`,"aria-label":b(`work.composer.mentionAgents`,{defaultValue:`Mention an agent`}),className:`absolute bottom-full start-2 z-40 mb-2 w-64 overflow-hidden rounded-xl border border-line bg-surface-overlay shadow-overlay backdrop-blur`,children:B.slice(0,6).map((e,t)=>(0,X.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":t===R,"data-testid":`work-mention-option`,className:l(`flex w-full items-center gap-2 px-3 py-2 text-start text-sm transition-colors`,t===R?`bg-primary-500/10 text-ink`:`text-ink-muted hover:bg-surface-subtle hover:text-ink`),onMouseDown:t=>{t.preventDefault(),re(e)},children:(0,X.jsxs)(`span`,{dir:`auto`,className:`truncate`,children:[`@`,e.name]})},e.id))}),(0,X.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,X.jsx)(`textarea`,{ref:w,"data-testid":`work-composer-input`,dir:`auto`,value:x,onChange:e=>{S(e.target.value),z(e.target.value,e.target.selectionStart??e.target.value.length)},onClick:e=>z(e.currentTarget.value,e.currentTarget.selectionStart??e.currentTarget.value.length),onBlur:()=>L(null),onKeyDown:e=>{if(ne){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=Math.min(B.length,6);te(n=>e.key===`ArrowDown`?(n+1)%t:(n-1+t)%t);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),re(B[R]);return}if(e.key===`Escape`){e.preventDefault(),L(null);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),F())},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:b(`work.composer.placeholder`,{defaultValue:`Describe what you want to build or change…`})}),(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,X.jsx)(`div`,{className:`hidden shrink-0 sm:block`,children:(0,X.jsx)(Ue,{models:ee,selectedModel:n,onModelChange:e=>P(e.target.value),onModelsRefresh:()=>void _(),getModelValue:Z,getModelLabel:qe,getModelTitle:e=>e.name,triggerRef:O,triggerTestId:`work-model-selector-trigger`,selectTestId:`work-model-select`,ariaLabel:b(`work.composer.model`,{defaultValue:`Work model`}),disabled:r||e.length===0,className:`min-w-[150px] max-w-[230px]`,compact:!0})}),E.supported&&(0,X.jsx)(J,{"data-testid":`work-voice-input`,type:`button`,variant:`ghost`,size:`sm`,disabled:o,"aria-pressed":D,className:l(`flex h-9 w-9 shrink-0 touch-manipulation items-center justify-center rounded-full p-0 transition-colors duration-150`,D?`animate-pulse bg-red-50 text-red-500 dark:bg-red-900/20`:`text-ink-muted hover:bg-surface-subtle hover:text-ink`),title:b(D?`chat.input.voiceStop`:`chat.input.voiceInput`),"aria-label":b(D?`chat.input.voiceStop`:`chat.input.voiceInput`),onClick:()=>void E.toggle(),children:E.phase===`starting`?(0,X.jsx)(C,{className:`h-4 w-4 animate-spin`}):E.phase===`transcribing`?(0,X.jsx)(h,{className:`h-4 w-4 fill-current`}):(0,X.jsx)(ve,{className:`h-4 w-4`})}),r&&(0,X.jsx)(J,{"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:b(`work.composer.cancel`,{defaultValue:`Stop`}),"aria-label":b(`work.composer.cancel`,{defaultValue:`Stop`}),onClick:()=>void y(),children:i?(0,X.jsx)(C,{className:`h-4 w-4 animate-spin`}):(0,X.jsx)(h,{className:`h-4 w-4 fill-current`})}),(0,X.jsx)(J,{"data-testid":`work-submit-button`,type:`submit`,variant:`ghost`,size:`sm`,disabled:i||o||!x.trim()||!r&&!A,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:b(`work.composer.send`,{defaultValue:`Run`}),"aria-label":b(`work.composer.send`,{defaultValue:`Run`}),children:i?(0,X.jsx)(C,{className:`h-4 w-4 animate-spin`}):(0,X.jsx)(he,{className:`h-4 w-4`})})]})]})]}),(0,X.jsx)(`div`,{className:`mx-auto mt-3 w-full max-w-3xl sm:hidden`,children:(0,X.jsx)(Ue,{models:ee,selectedModel:n,onModelChange:e=>P(e.target.value),onModelsRefresh:()=>void _(),getModelValue:Z,getModelLabel:qe,getModelTitle:e=>e.name,triggerRef:k,triggerTestId:`work-model-selector-trigger-mobile`,selectTestId:`work-model-select-mobile`,ariaLabel:b(`work.composer.model`,{defaultValue:`Work model`}),disabled:r||e.length===0,className:`w-full`,compact:!0})})]})}var Xe=e=>{let t=e.summary??{},n=[];for(let e of[`command`,`path`,`from`,`to`,`actions`]){let r=t[e];typeof r==`string`&&r&&n.push(`${e}: ${r}`)}return typeof t.actionCount==`number`&&n.push(`actions: ${t.actionCount}`),t.recursive===!0&&n.push(`recursive: true`),n.join(`
|
|
3
|
+
`)||e.name},Ze=({taskId:e,approval:t,className:n})=>{let{t:r}=c(),[i,a]=(0,Y.useState)(!1),o=async(n,i)=>{a(!0);try{await W.decideApproval(e,t.approvalId,n,i)}catch{a(!1),H.error(r(`work.approval.failed`))}};return(0,X.jsxs)(`div`,{role:`alertdialog`,"aria-label":r(`work.approval.title`),"data-testid":`work-approval-card`,className:l(`rounded-lg border border-primary-300/70 bg-primary-50 p-3 text-sm dark:border-primary-700/60 dark:bg-primary-900/20`,n),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-primary-800 dark:text-primary-200`,children:[(0,X.jsx)(g,{className:`h-4 w-4 shrink-0`}),r(`work.approval.title`)]}),(0,X.jsx)(`p`,{className:`mt-1 text-primary-800/90 dark:text-primary-100/80`,children:r(`work.approval.description`,{tool:t.name})}),(0,X.jsx)(`pre`,{dir:`ltr`,className:`mt-2 max-h-32 overflow-auto whitespace-pre-wrap rounded bg-white/70 p-2 font-mono text-xs text-gray-700 dark:bg-dark-100 dark:text-gray-300`,children:Xe(t)}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,X.jsx)(J,{size:`sm`,disabled:i,"data-testid":`work-approval-allow-once`,onClick:()=>void o(!0,`once`),children:r(`work.approval.allowOnce`)}),(0,X.jsx)(J,{size:`sm`,variant:`secondary`,disabled:i,"data-testid":`work-approval-allow-always`,onClick:()=>void o(!0,`always`),children:r(`work.approval.allowAlways`)}),(0,X.jsx)(J,{size:`sm`,variant:`ghost`,disabled:i,"data-testid":`work-approval-deny`,onClick:()=>void o(!1,`once`),children:r(`work.approval.deny`)})]})]})};function Qe({stats:e,budgetReason:t,className:n}){let{t:r}=c(),i=[[`rounds`,r(`work.live.stats.rounds`,{defaultValue:`Rounds`})],[`toolCalls`,r(`work.live.stats.toolCalls`,{defaultValue:`Tool calls`})],[`screenshots`,r(`work.live.stats.screenshots`,{defaultValue:`Screenshots`})],[`fences`,r(`work.live.stats.fences`,{defaultValue:`Fences`})],[`expectationsPassed`,r(`work.live.stats.checksPassed`,{defaultValue:`Checks passed`})],[`expectationsPending`,r(`work.live.stats.checksPending`,{defaultValue:`Checks pending`})],[`stallNudges`,r(`work.live.stats.stallNudges`,{defaultValue:`Stall nudges`})],[`ambiguityNudges`,r(`work.live.stats.ambiguityNudges`,{defaultValue:`Re-grounding nudges`})]].flatMap(([t,n])=>{let r=e[t];return typeof r==`number`&&r>0?[{key:t,label:n,value:r}]:[]});return i.length===0&&!t?null:(0,X.jsxs)(`div`,{"data-testid":`work-run-stats`,className:l(`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-ink-subtle`,n),children:[(0,X.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:r(`work.live.stats.title`,{defaultValue:`Run summary`})}),i.map(e=>(0,X.jsxs)(`span`,{className:`whitespace-nowrap`,children:[e.label,` `,(0,X.jsx)(`span`,{className:`font-medium text-ink-muted`,children:e.value})]},e.key)),t&&(0,X.jsxs)(`span`,{className:`whitespace-nowrap`,children:[r(`work.live.stats.stoppedBy`,{defaultValue:`Stopped by`}),` `,(0,X.jsx)(`span`,{className:`font-medium text-ink-muted`,children:t})]})]})}async function $e(e){return{viewOnlyPassword:(await U.post(`/work/tasks/${encodeURIComponent(e)}/computer/start`)).data.data?.viewOnlyPassword}}async function et(e){return(await U.get(`/work/tasks/${encodeURIComponent(e)}/computer/control`)).data.data??{agentWaiting:!1}}async function tt(e){let t=(await U.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 nt(e){await U.delete(`/work/tasks/${encodeURIComponent(e)}/computer/control`)}async function rt(e,t,n){await U.post(`/work/computer/skills/${encodeURIComponent(e)}/trace`,{outcome:t,...n?{note:n}:{}})}async function it(e,t,n){return(await U.post(`/work/tasks/${encodeURIComponent(e)}/computer/anchor`,{x:t,y:n})).data.data??{}}async function at(e,t){let n=(await U.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 ot(e){return ct(e,ke)}async function st(e){return ct(e,Me)}async function ct(e,t){let n=(await U.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 lt=e=>{if(e==null||e===``)return null;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}},ut=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`},dt=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 ft({run:e}){let[t,n]=(0,Y.useState)();if((0,Y.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,X.jsx)(`span`,{dir:`ltr`,className:`tabular-nums text-ink-subtle`,"aria-hidden":`true`,children:ut(r-e.startedAt)}):null}function pt({tool:e,expandedByDefault:t}){let{t:n}=c(),[r]=(0,Y.useState)(e.status),[i,a]=(0,Y.useState)(null),o=(0,Y.useMemo)(()=>lt(e.arguments),[e.arguments]),s=e.output||null,u=!!(o||s),d=e.status===`error`,f=e.status===`running`,p=(0,Y.useId)(),h=d?n(`work.activity.kinds.error`,{defaultValue:`Error`}):f?n(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}):n(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),g=i??(e.status===r?t:e.status===`error`);return(0,X.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,X.jsxs)(`button`,{type:`button`,disabled:!u,onClick:()=>{a(!g)},"aria-expanded":u?g:void 0,"aria-controls":u?p:void 0,"aria-label":`${h}: ${e.name}`,className:`flex min-h-10 w-full items-center gap-2 px-3 py-2 text-start outline-none hover:bg-surface-subtle focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500 disabled:cursor-default disabled:hover:bg-transparent`,children:[(0,X.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:d?(0,X.jsx)(m,{className:`h-3.5 w-3.5 text-error-500`}):f?(0,X.jsx)(C,{className:`h-3.5 w-3.5 animate-spin text-[rgb(48,121,255)] motion-reduce:animate-none`}):(0,X.jsx)(ue,{className:`h-3.5 w-3.5 text-[rgb(76,212,117)]`})}),(0,X.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,X.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-ink-subtle`,children:ut(e.durationMs)}),u&&(0,X.jsx)(b,{"aria-hidden":`true`,className:l(`h-3.5 w-3.5 shrink-0 text-ink-subtle transition-transform`,g&&`rotate-180`)})]}),u&&g&&(0,X.jsxs)(`div`,{id:p,className:`border-t border-line bg-surface-subtle/50`,children:[o&&(0,X.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,X.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 mt=e=>{let t=e.split(`
|
|
4
|
+
`);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n)return n}return``};function ht({content:e,streaming:t}){let{t:n}=c(),[r,i]=(0,Y.useState)(!1),a=t&&!r?mt(e):``;return(0,X.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,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-col gap-1 px-3 py-2 marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,X.jsxs)(`span`,{className:`flex items-center justify-between gap-3 text-xs font-medium text-ink-muted`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(I,{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,X.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,X.jsx)(`span`,{className:`truncate`,children:n(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,X.jsx)(b,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),a&&(0,X.jsx)(`span`,{dir:`auto`,"data-testid":`work-live-reasoning-preview`,className:`block truncate text-[11px] leading-relaxed text-ink-subtle`,children:a})]}),(0,X.jsx)(`div`,{className:`border-t border-line px-3 py-2.5`,children:(0,X.jsx)(Ie,{content:e,isStreaming:t,className:`text-xs text-ink-muted`})})]})}var gt=(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`}),_t=(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 vt({run:e,variant:t=`conversation`}){let{t:n}=c(),r=[...e.tools].reverse().find(e=>e.status===`running`),i=_t(e.connection,n)||gt(e.phase,n,r),a=!e.terminal,[o,s]=(0,Y.useState)({}),u=(0,Y.useCallback)((e,t)=>{s(n=>({...n,[e]:t})),rt(e,t).catch(()=>{s(t=>{let n={...t};return delete n[e],n})})},[]),d=e.usage?.outputTokens,f=e.reasoning+e.response,h=d!==void 0&&d>0?d:f?dt(f):d,g=(d===void 0||d===0)&&!!f&&h!==void 0,_=e.usage?.tokensPerSecond;return(0,X.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,X.jsxs)(`div`,{className:`mb-3 flex min-h-6 items-center gap-2 text-xs`,children:[(0,X.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,X.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,X.jsx)(`span`,{dir:`ltr`,className:`shrink-0 tabular-nums text-ink-subtle`,children:e.roundLimit===void 0?`#${e.round}`:`${e.round}/${e.roundLimit}`}),(0,X.jsx)(ft,{run:e})]}),t===`conversation`&&(0,X.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:i}),e.skills.length>0&&(0,X.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-1.5`,children:[(0,X.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,X.jsx)(p,{className:`h-3 w-3 text-primary-500`,"aria-hidden":`true`}),(0,X.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,X.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,X.jsx)(`span`,{dir:`auto`,children:e.name}),r?(0,X.jsx)(`span`,{className:`text-primary-500`,children:n(`work.live.skillTraceSaved`,{defaultValue:`noted`})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.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,X.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,X.jsx)(ht,{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,X.jsx)(pt,{tool:n,expandedByDefault:n.status===`error`},n.id):null}return(0,X.jsx)(Ie,{content:t.text,isStreaming:a&&r,className:`text-ink`},`segment-${n}`)})}):e.tools.length>0&&(0,X.jsx)(`div`,{"data-testid":`work-live-tools`,className:`space-y-1.5`,children:e.tools.map(e=>(0,X.jsx)(pt,{tool:e,expandedByDefault:e.status===`running`||e.status===`error`},e.id))}),e.error&&(0,X.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,X.jsx)(m,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{children:e.error})]}),(h!==void 0||_!==void 0)&&(0,X.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:[h!==void 0&&(0,X.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.generatedTokens`,{defaultValue:`Generated tokens:`}),` `,(0,X.jsxs)(`bdi`,{dir:`ltr`,children:[g&&`≈`,h.toLocaleString()]})]}),_!==void 0&&(0,X.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.speed`,{defaultValue:`Speed:`}),` `,(0,X.jsxs)(`bdi`,{dir:`ltr`,children:[_.toFixed(1),` t/s`]})]})]}),e.terminal&&e.loopStats&&(0,X.jsx)(Qe,{stats:e.loopStats,budgetReason:e.budgetReason,className:`mt-2`}),a&&!e.reasoning&&!e.response&&e.tools.length===0&&(0,X.jsxs)(`div`,{"aria-hidden":`true`,className:`flex h-5 items-center gap-1 text-[rgb(48,121,255)]`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current motion-reduce:animate-none`}),(0,X.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:160ms] motion-reduce:animate-none`}),(0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-ink-muted`,children:[(0,X.jsx)(w,{className:`h-3.5 w-3.5`}),n(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]})]})}var yt=e=>typeof e==`object`&&e?e:void 0;function bt(e){let t=[];for(let n of e){let e=yt(n.metadata)??yt(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 Q({role:e,user:t,persona:n,size:r=`message`}){let[i,a]=(0,Y.useState)(null);if(e===`assistant`)return n?(0,X.jsx)(`img`,{src:Ce(n,64),alt:n.name,"data-testid":`work-assistant-avatar`,onError:e=>K(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,X.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,X.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,X.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,X.jsx)(`img`,{src:s,alt:o,className:`h-full w-full object-cover`,onError:()=>a(s)}):t?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs font-medium uppercase leading-none`,children:t.username.charAt(0)}):(0,X.jsx)(N,{"aria-hidden":`true`,className:`h-4 w-4`})})}var xt=(e,t)=>{let n=e.metadata,r=n?.name??n?.toolName??n?.tool??n?.command;return typeof r==`string`&&r?r:t},St=e=>{let t=e.metadata?.toolCallId;return typeof t==`string`&&t?t:null},Ct=(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?xt(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}},wt=(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=St(a);if(a.kind===`tool_call`&&e){let o=i(Ct(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]=Ct(i.call,a,t),r.delete(e);continue}}}i(Ct(a.kind===`tool_call`?a:void 0,a.kind===`tool_call`?void 0:a,t),a.id)}return n};function Tt({message:e}){let{t}=c();return(0,X.jsxs)(`details`,{"data-testid":`work-provider-reasoning`,className:`group ms-14 overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,X.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,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(I,{className:`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`}),(0,X.jsx)(`span`,{className:`truncate`,children:t(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,X.jsx)(b,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),(0,X.jsx)(`div`,{dir:`auto`,className:`border-t border-line px-3 py-2.5 text-xs leading-relaxed text-ink-muted`,children:(0,X.jsx)(Be,{content:e.content,className:`text-xs`})})]})}function Et({task:e,user:t,loading:n,loadingOlder:r,liveRun:i,onLoadOlder:a,onOpenFile:o}){let{t:s}=c(),u=(0,Y.useRef)(null),f=(0,Y.useRef)(!0),[p,m]=(0,Y.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,Y.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,Y.useMemo)(()=>wt(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,Y.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,Y.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,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-ink-muted`,children:(0,X.jsx)(C,{className:`h-6 w-6 animate-spin`})}):(0,X.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,X.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,X.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,X.jsxs)(`div`,{className:`m-auto max-w-md text-center`,children:[(0,X.jsx)(Q,{role:`assistant`,persona:_,size:`empty`}),(0,X.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-ink`,children:s(`work.conversation.ready`,{defaultValue:`Workspace ready`})}),(0,X.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,X.jsxs)(`div`,{className:`space-y-6`,children:[e.hasMoreMessages&&(0,X.jsx)(`div`,{className:`flex justify-center`,children:(0,X.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,X.jsx)(C,{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,X.jsx)(Tt,{message:r.message},n);if(r.type===`tools`){let e=o?bt(r.tools):[];return(0,X.jsxs)(`div`,{className:`ms-14 space-y-1.5`,children:[r.tools.map(e=>(0,X.jsx)(pt,{tool:e,expandedByDefault:!1},e.id)),e.length>0&&(0,X.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,X.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,X.jsx)(L,{className:`h-3 w-3 shrink-0 text-ink-muted`}),(0,X.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,u=e=>e&&typeof e==`object`&&typeof e.fromAgent==`string`?e.fromAgent:void 0,d=u(i.metadata?.delegation),f=u(i.metadata?.delegationReport),p=q(i.metadata?.loopStats);return(0,X.jsxs)(`article`,{className:l(`flex gap-3`,a&&`flex-row-reverse`),children:[(0,X.jsx)(Q,{role:a?`user`:`assistant`,user:a?t:void 0,persona:a?void 0:_}),(0,X.jsxs)(`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,X.jsxs)(X.Fragment,{children:[(d||f)&&(0,X.jsx)(`p`,{"data-testid":`work-delegation-label`,className:`mb-1 text-[11px] font-medium uppercase tracking-wide opacity-70`,children:d?s(`work.conversation.delegatedBy`,{defaultValue:`Delegated by {{agent}}`,agent:d}):s(`work.conversation.reportFrom`,{defaultValue:`Report from {{agent}}`,agent:f})}),(0,X.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words text-sm leading-relaxed`,children:i.content})]}):c?(0,X.jsx)(Ie,{content:i.content,className:`text-ink`}):(0,X.jsx)(Be,{content:i.content,className:`text-sm text-ink`}),!a&&p&&(0,X.jsx)(Qe,{stats:p,budgetReason:typeof i.metadata?.budgetReason==`string`?i.metadata.budgetReason:void 0,className:`mt-1.5`})]})]},i.id)}),i&&(0,X.jsxs)(`article`,{className:`flex gap-3`,"data-testid":`work-live-run-message`,children:[(0,X.jsx)(Q,{role:`assistant`,persona:_}),(0,X.jsxs)(`div`,{className:`min-w-0 max-w-[92%] flex-1`,children:[(0,X.jsx)(vt,{run:i}),i.pendingApproval&&(0,X.jsx)(Ze,{taskId:e.id,approval:i.pendingApproval,className:`mt-2`})]})]}),!i&&(e.status===`preparing`||e.status===`running`)&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 ps-14 text-xs text-ink-muted`,children:[(0,X.jsx)(C,{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,X.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,X.jsx)(ce,{className:`h-3.5 w-3.5`}),s(`work.live.newActivity`,{defaultValue:`New activity`})]})]})}var Dt=45,Ot=30,kt=70,At=360,jt=480,Mt=9,Nt=2,Pt=10,Ft=`libre-webui-work-split:`,It=(e,t,n)=>Math.min(n,Math.max(t,e)),Lt=e=>`${Ft}${encodeURIComponent(e||`local`)}`,Rt=e=>{if(typeof window>`u`)return Dt;try{let t=window.localStorage.getItem(e);if(t===null||t.trim()===``)return Dt;let n=Number(t);return Number.isFinite(n)?It(n,Ot,kt):Dt}catch{return Dt}},zt=(e,t)=>{if(!(typeof window>`u`))try{window.localStorage.setItem(e,t.toFixed(2))}catch{}},Bt=e=>{let t=Math.max(0,e-Mt);if(t===0)return{min:Ot,max:kt};let n=Math.max(Ot,At/t*100),r=Math.min(kt,(t-jt)/t*100);if(n<=r)return{min:n,max:r};let i=It(At/840*100,Ot,kt);return{min:i,max:i}},Vt=(e,t)=>It(e,t.min,t.max);function Ht({conversation:e,workspace:t,userId:n,mobileSurface:r=`conversation`,className:i}){let{t:a,i18n:o}=c(),s=u(o.language),d=Lt(n),[f,p]=(0,Y.useState)(()=>({storageKey:d,percent:Rt(d)})),[m,h]=(0,Y.useState)(0),[g,_]=(0,Y.useState)(!1),v=(0,Y.useRef)(null),y=(0,Y.useRef)(null),b=(0,Y.useRef)(null),x=(0,Y.useRef)(d),S=(0,Y.useRef)(f.percent),C=(0,Y.useRef)(null),w=f.storageKey===d?f.percent:Rt(d),T=(0,Y.useMemo)(()=>Bt(m),[m]),E=Vt(w,T),D=Math.round(E),O=100-D,k=(0,Y.useCallback)(e=>{p({storageKey:d,percent:e})},[d]),A=(0,Y.useCallback)(e=>{let t=Vt(e,Bt(v.current?.getBoundingClientRect().width??0));S.current=t,C.current===null&&(C.current=window.requestAnimationFrame(()=>{C.current=null,k(S.current)}))},[k]),j=(0,Y.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=Vt(S.current,Bt(e));S.current=t,k(t),zt(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,Y.useCallback)(e=>{let t=v.current?.getBoundingClientRect();if(!t)return S.current;let n=Math.max(1,t.width-Mt);return((s?t.right-e:e-t.left)-Mt/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,Y.useCallback)(e=>{let t=Vt(e,T);S.current=t,k(t),zt(d,t)},[T,k,d]),P=(0,Y.useCallback)(()=>{N(Dt)},[N]),F=e=>{let t=e.shiftKey?Pt:Nt,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=Dt),n!==null&&(e.preventDefault(),N(n))};(0,Y.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,Y.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,Y.useEffect)(()=>()=>{C.current!==null&&window.cancelAnimationFrame(C.current),b.current!==null&&zt(x.current,S.current)},[]);let I={gridTemplateColumns:`minmax(0, ${E}fr) ${Mt}px minmax(0, ${100-E}fr)`};return(0,X.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:I,children:[(0,X.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,X.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:P,onKeyDown:F,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,X.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,X.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,X.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,X.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 Ut=`/assets/workAudioProcessor-CLKlf7Jk.js`,Wt=44100,Gt=2;async function Kt(e,t){let n=new AudioContext,r;try{await n.audioWorklet.addModule(Ut),r=new AudioWorkletNode(n,`libre-work-audio`,{outputChannelCount:[2],processorOptions:{sourceRate:Wt}}),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/Gt,c=new Float32Array(s),l=new Float32Array(s);for(let e=0;e<s;e++)c[e]=o[e*Gt]/32768,l[e]=o[e*Gt+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 qt=3e3,Jt=6e4,Yt=5e3;function Xt({taskId:e,active:t,variant:n=`full`,onExpand:i}){let{t:a}=c(),o=(0,Y.useRef)(null),s=(0,Y.useRef)(null),[l,u]=(0,Y.useState)(`view`),[d,f]=(0,Y.useState)(0),[p,m]=(0,Y.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:v,error:y}=g,b=(0,Y.useCallback)(n=>{m(r=>r.taskId!==e||r.active!==t||r.attempt!==d||r.mode!==l?r:{...r,...n})},[e,t,d,l]),[x,S]=(0,Y.useState)({agentWaiting:!1}),[w,T]=(0,Y.useState)(!1),[E,D]=(0,Y.useState)(`idle`),[O,M]=(0,Y.useState)(``),[ee,N]=(0,Y.useState)(null),P=(0,Y.useRef)([]),F=(0,Y.useRef)(0),I=(0,Y.useRef)(null),[L,R]=(0,Y.useState)(!1),te=(0,Y.useRef)(null),z=(0,Y.useRef)(0),B=(0,Y.useCallback)(()=>{z.current+=1;let e=te.current;te.current=null,e?.stop(),R(!1)},[]),ne=(0,Y.useCallback)(async()=>{if(te.current){B();return}let t=z.current+1;z.current=t;try{let n=await st(e);if(z.current!==t)return;let r=await Kt(n,()=>{z.current===t&&(z.current+=1,te.current=null,R(!1))});if(z.current!==t){r.stop();return}te.current=r,R(!0)}catch(e){if(z.current!==t)return;be.warn(`Work screen audio failed to start:`,e),B()}},[e,B]);(0,Y.useEffect)(()=>{if(!(!t||v!==`connected`))return B},[t,v,B]);let re=(0,Y.useCallback)(()=>{try{s.current?.disconnect()}catch{}s.current=null},[]);(0,Y.useEffect)(()=>{if(!t)return;let n=!1,i;return(async()=>{try{let t=await $e(e);n||T(!!t.viewOnlyPassword);let a=t.viewOnlyPassword;l===`control`&&(a=(await tt(e)).controlPassword,i=setInterval(()=>{tt(e).catch(e=>{be.warn(`Screen control renewal failed:`,e),n||u(`view`)})},Jt));let[{default:c},d]=await Promise.all([r(()=>import(`./rfb-BOfFBtVG.js`),[]),ot(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||b({state:`connected`})}),f.addEventListener(`disconnect`,()=>{n||b({state:`disconnected`})}),s.current=f}catch(e){if(be.error(`Work screen connection failed:`,e),n)return;b({error:e.response?.data?.message??null,state:`disconnected`}),l===`control`&&u(`view`)}})(),()=>{n=!0,i&&clearInterval(i),re(),l===`control`&&nt(e).catch(()=>void 0)}},[e,t,d,l,re,b]),(0,Y.useEffect)(()=>{if(!t||n===`mini`)return;let r=!1,i=async()=>{try{let t=await et(e);r||S(t)}catch{}};i();let a=setInterval(i,qt);return()=>{r=!0,clearInterval(a)}},[e,t,n]),(0,Y.useEffect)(()=>{if(E!==`recording`||v!==`connected`||l!==`control`)return;let t=o.current;if(!t)return;F.current=performance.now(),P.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;I.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()-F.current),i=e=>{P.current.length<Yt&&P.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`&&it(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,v,l,e]);let V=(0,Y.useCallback)(()=>{u(`control`)},[]),ae=(0,Y.useCallback)(()=>{nt(e).catch(()=>void 0),u(`view`)},[e]),se=(0,Y.useCallback)(()=>{N(null),D(`recording`),u(`control`)},[]),ce=(0,Y.useCallback)(()=>{nt(e).catch(()=>void 0),u(`view`),D(`naming`)},[e]),le=(0,Y.useCallback)(()=>{P.current=[],M(``),D(`idle`),l===`control`&&(nt(e).catch(()=>void 0),u(`view`))},[e,l]),ue=(0,Y.useCallback)(async()=>{let t=O.trim();if(t){D(`saving`);try{let n=await at(e,{name:t,events:P.current,...I.current?{screenWidth:I.current.width,screenHeight:I.current.height}:{}});P.current=[],M(``),D(`idle`),N(n.name),setTimeout(()=>N(null),6e3)}catch(e){be.error(`Saving the demonstration failed:`,e),b({error:e.response?.data?.message??null}),D(`naming`)}}},[e,O,b]),fe=l===`control`&&v===`connected`,pe=x.holder!==void 0&&!x.holder.you,me=x.takeoverEnabled!==!1,he=w&&me&&v===`connected`&&l===`view`&&!pe,ge=E===`recording`&&v===`connected`,_e=`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,X.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,X.jsx)(`div`,{ref:o,className:`h-full w-full`}),v!==`connected`&&(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-2 px-4 text-center`,children:v===`starting`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(C,{size:16,className:`animate-spin text-white/60`}),(0,X.jsx)(`p`,{className:`text-xs text-white/70`,children:a(`work.screen.starting`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ye,{size:18,className:`text-white/40`}),(0,X.jsx)(`p`,{className:`text-xs text-white/70`,children:y??a(`work.screen.disconnected`)})]})}),(0,X.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,X.jsxs)(`div`,{className:`flex h-full min-h-[16rem] w-full flex-col`,"data-testid":`work-screen`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-line bg-surface px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`rounded-md px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide ${ge?`bg-red-500/15 text-red-500`:fe?`bg-emerald-500/15 text-emerald-500`:`bg-surface-subtle text-ink-muted`}`,"data-testid":`work-screen-mode`,children:ge?a(`work.screen.recording`):fe?a(`work.screen.youHaveControl`):pe?a(`work.screen.otherHasControl`,{name:x.holder?.username??`…`}):a(`work.screen.viewOnly`)}),ee&&(0,X.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:ee})}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,X.jsx)(`button`,{type:`button`,"data-testid":`work-screen-audio`,onClick:()=>void ne(),disabled:v!==`connected`,"aria-label":a(L?`work.screen.mute`:`work.screen.unmute`),className:`${_e} disabled:opacity-40 ${L?`border-emerald-500/50 text-emerald-500`:``}`,children:L?(0,X.jsx)(oe,{size:13}):(0,X.jsx)(j,{size:13})}),he&&E===`idle`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,"data-testid":`work-screen-take-over`,onClick:V,className:_e,children:[(0,X.jsx)(ie,{size:13}),a(`work.screen.takeOver`)]}),(0,X.jsxs)(`button`,{type:`button`,"data-testid":`work-screen-teach`,onClick:se,className:_e,children:[(0,X.jsx)(A,{size:13}),a(`work.screen.teach`)]})]}),fe&&E===`idle`&&(0,X.jsxs)(`button`,{type:`button`,"data-testid":`work-screen-hand-back`,onClick:ae,className:`${_e} border-emerald-500/50 text-emerald-500`,children:[(0,X.jsx)(de,{size:13}),a(`work.screen.handBack`)]}),fe&&E===`recording`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,"data-testid":`work-screen-teach-stop`,onClick:ce,className:`${_e} border-red-500/50 text-red-500`,children:[(0,X.jsx)(_,{size:9,className:`animate-pulse fill-current`}),a(`work.screen.teachSave`)]}),(0,X.jsx)(`button`,{type:`button`,onClick:le,className:_e,children:a(`work.screen.teachDiscard`)})]})]}),(0,X.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-canvas ${ge?`ring-2 ring-inset ring-red-500`:fe?`ring-2 ring-inset ring-emerald-500`:``}`,children:[ge&&(0,X.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,X.jsx)(_,{size:8,className:`animate-pulse fill-current`}),a(`work.screen.watchingLearning`)]}),(0,X.jsx)(`div`,{ref:o,className:`h-full w-full`}),v!==`connected`&&(0,X.jsx)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-3 px-6 text-center`,children:v===`starting`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(C,{size:20,className:`animate-spin text-white/60`}),(0,X.jsx)(`p`,{className:`text-sm text-white/70`,children:a(`work.screen.starting`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ye,{size:22,className:`text-white/40`}),(0,X.jsx)(`p`,{className:`text-sm text-white/70`,children:y??a(`work.screen.disconnected`)}),(0,X.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,X.jsx)(k,{size:12}),a(`work.screen.reconnect`)]})]})}),(E===`naming`||E===`saving`)&&(0,X.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center bg-black/60`,children:(0,X.jsxs)(`div`,{className:`flex w-72 flex-col gap-3 rounded-xl border border-line bg-surface-raised p-4 shadow-xl`,children:[(0,X.jsx)(`input`,{autoFocus:!0,value:O,onChange:e=>M(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ue()},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,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:le,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,X.jsxs)(`button`,{type:`button`,"data-testid":`work-screen-teach-confirm`,onClick:()=>void ue(),disabled:E===`saving`||!O.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,X.jsx)(C,{size:12,className:`animate-spin`}),a(`work.screen.teachSave`)]})]})]})}),x.agentWaiting&&!fe&&v===`connected`&&(0,X.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,X.jsx)(`span`,{className:`font-medium`,children:a(`work.screen.agentWaiting`)}),x.agentWaitingReason&&(0,X.jsx)(`span`,{className:`truncate opacity-80`,children:x.agentWaitingReason}),w&&me&&!pe&&(0,X.jsx)(`button`,{type:`button`,onClick:V,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 Zt=`taught-`,Qt=`mb-2 text-[11px] font-medium uppercase tracking-wide text-ink-subtle`;function $t({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,Y.useState)([]),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)([]),[C,w]=(0,Y.useState)(!1),[E,D]=(0,Y.useState)(null),[O,k]=(0,Y.useState)(!1),j=(0,Y.useCallback)(async()=>{try{let t=await G.getAutomations();t.success&&Array.isArray(t.data)&&d(t.data.filter(t=>t.workTaskId===e.id))}catch{}finally{p(!0)}},[e.id]),M=(0,Y.useCallback)(async()=>{try{let e=await Se.list();e.success&&Array.isArray(e.data)&&x(e.data.filter(e=>e.slug.startsWith(Zt)))}catch{}finally{w(!0)}},[]),ee=(0,Y.useCallback)(async()=>{try{let t=await W.getApprovals(e.id);t.success&&t.data&&D(t.data)}catch{}finally{k(!0)}},[e.id]);(0,Y.useEffect)(()=>{if(!n)return;let e=window.setTimeout(()=>{j(),M(),ee()},0);return()=>window.clearTimeout(e)},[n,j,M,ee]);let N=async t=>{let n=E;D(e=>e&&{...e,approvalsEnabled:t});try{await W.setApprovalsEnabled(e.id,t?!0:null)}catch{D(n),H.error(i(`work.agent.approvalsToggleFailed`,{defaultValue:`Could not update approvals.`}))}},P=async t=>{try{await W.deleteApprovalRule(e.id,t),await ee()}catch{H.error(i(`work.agent.approvalRuleDeleteFailed`,{defaultValue:`Could not remove the rule.`}))}},F=async e=>{h(e.id);try{let t=e.status===`active`?await G.pauseAutomation(e.id):await G.resumeAutomation(e.id);if(!t.success)throw Error(t.message);await j()}catch{H.error(i(`work.agent.routineToggleFailed`,{defaultValue:`Could not update the routine.`}))}finally{h(null)}},I=async e=>{y(!0);try{let t=await G.createAutomation(e);if(!t.success)throw Error(t.message);_(!1),await j()}catch{H.error(i(`work.agent.routineSaveFailed`,{defaultValue:`Could not save the routine.`}))}finally{y(!1)}},L=async(e,t)=>{x(n=>n.map(n=>n.id===e.id?{...n,enabled:t}:n));try{await Se.update(e.id,{enabled:t})}catch{x(t=>t.map(t=>t.id===e.id?{...t,enabled:e.enabled}:t)),H.error(i(`work.agent.skillToggleFailed`,{defaultValue:`Could not update the skill.`}))}};return(0,X.jsxs)(`div`,{"data-testid":`work-agent-panel`,className:`flex flex-col gap-6 p-4 sm:p-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,X.jsx)(`img`,{src:t?Ce(t,96):we(e.title,96),alt:``,"aria-hidden":`true`,"data-testid":`work-agent-avatar`,onError:n=>K(n.currentTarget,t?.name??e.title,96),className:`h-12 w-12 rounded-xl object-cover`}),(0,X.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,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h3`,{dir:`auto`,className:`truncate text-[15px] font-medium leading-6 text-ink`,title:e.title,children:e.title}),(0,X.jsx)(`p`,{className:`text-xs text-ink-muted`,children:t?i(`work.agent.personaLine`,{defaultValue:`Persona: {{name}}`,name:t.name}):s}),e.statusBlurb&&(0,X.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,X.jsxs)(`section`,{children:[(0,X.jsx)(`h4`,{className:Qt,children:i(`work.agent.screen`,{defaultValue:`Screen`})}),(0,X.jsx)(Xt,{taskId:e.id,active:n,variant:`mini`,onExpand:r})]}),(0,X.jsxs)(`section`,{"data-testid":`work-agent-routines`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,X.jsx)(`h4`,{className:l(Qt,`mb-0`),children:i(`work.agent.routines`,{defaultValue:`Routines`})}),(0,X.jsxs)(`button`,{type:`button`,"data-testid":`work-agent-add-routine`,onClick:()=>_(!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,X.jsx)(T,{className:`h-3.5 w-3.5`}),i(`work.agent.addRoutine`,{defaultValue:`Routine`})]})]}),u.length===0?(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-ink-subtle`,children:f?i(`work.agent.noRoutines`,{defaultValue:`No routines yet. A routine runs an instruction on a schedule, inside this agent’s workspace.`}):`…`}):(0,X.jsx)(`ul`,{className:`space-y-1`,children:u.map(e=>(0,X.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,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.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,X.jsx)(`p`,{className:`truncate text-[11px] text-ink-subtle`,children:Ve(e.triggers,a.language,i)})]}),(0,X.jsx)(`button`,{type:`button`,"data-testid":`work-agent-routine-toggle`,disabled:m===e.id,onClick:()=>void F(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,X.jsx)(se,{className:`h-3.5 w-3.5`}):(0,X.jsx)(pe,{className:`h-3.5 w-3.5`})})]},e.id))})]}),(0,X.jsxs)(`section`,{"data-testid":`work-agent-approvals`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,X.jsx)(`h4`,{className:l(Qt,`mb-0`),children:i(`work.agent.approvals`,{defaultValue:`Auto Review`})}),(0,X.jsx)(Le,{checked:E?.policyRequired===!0||E?.approvalsEnabled===!0,disabled:!O||E?.policyRequired===!0,onChange:e=>void N(e)})]}),(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-ink-subtle`,children:E?.policyRequired===!0?i(`work.agent.approvalsPolicyForced`,{defaultValue:`This agent’s Work policy requires approval for side-effecting actions.`}):i(`work.agent.approvalsHint`,{defaultValue:`When on, commands, file deletions and moves, and computer actions pause until you approve them.`})}),E&&E.rules.length>0&&(0,X.jsx)(`ul`,{className:`mt-2 space-y-1`,children:E.rules.map(e=>(0,X.jsxs)(`li`,{"data-testid":`work-agent-approval-rule`,className:`flex items-center gap-3 rounded-xl border border-line bg-surface px-3 py-2`,children:[(0,X.jsx)(S,{className:`h-4 w-4 shrink-0 text-ink-muted`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`p`,{className:`truncate text-[13px] leading-5 text-ink`,children:[(0,X.jsx)(`code`,{dir:`ltr`,children:e.toolName}),e.pattern&&(0,X.jsxs)(X.Fragment,{children:[` · `,(0,X.jsx)(`code`,{dir:`ltr`,children:e.pattern})]})]}),(0,X.jsx)(`p`,{className:`truncate text-[11px] text-ink-subtle`,children:i(`work.agent.approvalRuleLine`,{defaultValue:`Always allowed`})})]}),(0,X.jsx)(`button`,{type:`button`,"data-testid":`work-agent-approval-rule-delete`,onClick:()=>void P(e.id),"aria-label":i(`work.agent.approvalRuleDelete`,{defaultValue:`Remove rule`}),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`,children:(0,X.jsx)(V,{className:`h-3.5 w-3.5`})})]},e.id))})]}),(0,X.jsxs)(`section`,{"data-testid":`work-agent-skills`,children:[(0,X.jsx)(`h4`,{className:Qt,children:i(`work.agent.skills`,{defaultValue:`Taught skills`})}),b.length===0?(0,X.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,X.jsx)(`ul`,{className:`space-y-1`,children:b.map(e=>(0,X.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,X.jsx)(A,{className:`h-4 w-4 shrink-0 text-ink-muted`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`p`,{dir:`auto`,className:`truncate text-[13px] leading-5 text-ink`,title:e.name,children:e.name}),e.description&&(0,X.jsx)(`p`,{className:`truncate text-[11px] text-ink-subtle`,children:e.description})]}),(0,X.jsx)(Le,{checked:e.enabled,onChange:t=>void L(e,t)})]},e.id))})]}),(0,X.jsx)(He,{open:g,automation:null,fixedWorkTaskId:e.id,models:[],saving:v,onClose:()=>_(!1),onSave:e=>void I(e)})]})}var en=1e5,tn=4e3,nn={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`},rn={".bashrc":`bash`,".zshrc":`bash`},an={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`}},on=e=>e.split(/[\\/]/).pop()?.toLowerCase()??``,sn=e=>{let t=on(e),n=t.lastIndexOf(`.`);return n>-1?t.slice(n+1):``},cn=e=>rn[on(e)]??nn[sn(e)]??`text`,ln=e=>an[sn(e)],un=e=>ln(e)!==void 0,dn=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,fn=async(e,t)=>{switch(e.family){case`babel`:return Promise.all([$(r(()=>import(`./babel-8afoxhZ7.js`),__vite__mapDeps([0,1,2,3]))),$(r(()=>import(`./estree-qxY7ACbu.js`),__vite__mapDeps([4,1,2,3,5])))]);case`typescript`:return Promise.all([$(r(()=>import(`./typescript-DokwN-5Y.js`),__vite__mapDeps([6,1,2,3,5]))),$(r(()=>import(`./estree-qxY7ACbu.js`),__vite__mapDeps([4,1,2,3,5])))]);case`postcss`:return[await $(r(()=>import(`./postcss-B2vYq4-H.js`),__vite__mapDeps([7,1,2,3])))];case`html`:{let e=[await $(r(()=>import(`./html-B_cUU1Gi.js`),__vite__mapDeps([8,1,2,3,5])))];return/<script\b/i.test(t)&&e.push(await $(r(()=>import(`./babel-8afoxhZ7.js`),__vite__mapDeps([0,1,2,3]))),await $(r(()=>import(`./estree-qxY7ACbu.js`),__vite__mapDeps([4,1,2,3,5])))),/<script\b[^>]*\blang\s*=\s*["']?(?:ts|typescript)/i.test(t)&&e.push(await $(r(()=>import(`./typescript-DokwN-5Y.js`),__vite__mapDeps([6,1,2,3,5])))),/<style\b/i.test(t)&&e.push(await $(r(()=>import(`./postcss-B2vYq4-H.js`),__vite__mapDeps([7,1,2,3])))),[...new Set(e)]}case`markdown`:{let n=[await $(r(()=>import(`./markdown-BAF0w-jL.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-8afoxhZ7.js`),__vite__mapDeps([0,1,2,3]))),await $(r(()=>import(`./estree-qxY7ACbu.js`),__vite__mapDeps([4,1,2,3,5])))),i(`js|jsx|javascript|json|json5|jsonc`)&&n.push(await $(r(()=>import(`./babel-8afoxhZ7.js`),__vite__mapDeps([0,1,2,3]))),await $(r(()=>import(`./estree-qxY7ACbu.js`),__vite__mapDeps([4,1,2,3,5])))),i(`ts|tsx|typescript`)&&n.push(await $(r(()=>import(`./typescript-DokwN-5Y.js`),__vite__mapDeps([6,1,2,3,5]))),await $(r(()=>import(`./estree-qxY7ACbu.js`),__vite__mapDeps([4,1,2,3,5])))),i(`css|scss|less`)&&n.push(await $(r(()=>import(`./postcss-B2vYq4-H.js`),__vite__mapDeps([7,1,2,3])))),i(`html`)&&n.push(await $(r(()=>import(`./html-B_cUU1Gi.js`),__vite__mapDeps([8,1,2,3,5]))),await $(r(()=>import(`./babel-8afoxhZ7.js`),__vite__mapDeps([0,1,2,3]))),await $(r(()=>import(`./estree-qxY7ACbu.js`),__vite__mapDeps([4,1,2,3,5]))),await $(r(()=>import(`./typescript-DokwN-5Y.js`),__vite__mapDeps([6,1,2,3,5]))),await $(r(()=>import(`./postcss-B2vYq4-H.js`),__vite__mapDeps([7,1,2,3])))),i(`yaml|yml`)&&n.push(await $(r(()=>import(`./yaml-BXEpxPn2.js`),__vite__mapDeps([10,1,2,3])))),[...new Set(n)]}case`yaml`:return[await $(r(()=>import(`./yaml-BXEpxPn2.js`),__vite__mapDeps([10,1,2,3])))]}},pn=async(e,t)=>{let n=ln(e);if(!n)throw Error(`Formatting is not supported for “${on(e)||e}”.`);if(!dn(t))throw Error(`Could not format “${on(e)||e}”: files are limited to ${en.toLocaleString()} characters and ${tn.toLocaleString()} lines.`);try{let[{format:e},i]=await Promise.all([r(()=>import(`./standalone-BqZmfuRy.js`),__vite__mapDeps([11,1,2,3,5])),fn(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 “${on(e)||e}”: ${n}`)}},mn=(0,Y.lazy)(async()=>({default:(await r(()=>import(`./OptimizedSyntaxHighlighter-oiyvxgDA.js`),__vite__mapDeps([12,13,2,3,14]))).OptimizedSyntaxHighlighter})),hn=8e3,gn=400,_n=500;function vn({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,Y.useRef)(null),f=(0,Y.useRef)(null),[p,m]=(0,Y.useState)(``),h=(0,Y.useMemo)(()=>cn(e),[e]),g=(0,Y.useMemo)(()=>{if(t.length>hn)return 401;let e=1;for(let n=0;n<t.length&&!(t.charCodeAt(n)===10&&(e+=1,e>gn));n+=1);return e},[t]),_=t.length>hn||g>gn,v=h!==`text`&&!_,y=v&&p===t;return(0,Y.useEffect)(()=>{if(!v)return;let e=window.setTimeout(()=>m(t),_n);return()=>window.clearTimeout(e)},[v,e,t]),(0,Y.useLayoutEffect)(()=>{!y||!d.current||!f.current||(d.current.style.transform=`translate3d(${-f.current.scrollLeft}px, ${-f.current.scrollTop}px, 0)`)},[y,e]),(0,X.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,X.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`work-file-highlight`,className:`pointer-events-none absolute inset-0 z-0 overflow-hidden`,children:(0,X.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,X.jsx)(Y.Suspense,{fallback:(0,X.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,X.jsx)(mn,{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,X.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,X.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 yn=4e6,bn=e=>{if(e===``)return[];let t=e.split(`
|
|
5
|
+
`);return t[t.length-1]===``&&t.pop(),t},xn=(e,t)=>{let n=bn(e),r=bn(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=Sn(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},Sn=(e,t)=>{if(e.length===0&&t.length===0)return[];if(e.length>0&&t.length>0&&e.length*t.length>yn)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},Cn=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}},wn=3,Tn=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-wn),i=Math.min(e.length-1,n+wn);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 En({line:e}){return(0,X.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,X.jsx)(`td`,{className:`w-10 select-none px-2 text-right align-top text-[10px] tabular-nums text-ink-subtle`,children:e.beforeLine??``}),(0,X.jsx)(`td`,{className:`w-10 select-none px-2 text-right align-top text-[10px] tabular-nums text-ink-subtle`,children:e.afterLine??``}),(0,X.jsxs)(`td`,{className:`w-full whitespace-pre-wrap break-all px-3 align-top`,children:[(0,X.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 Dn=new Set,On=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 kn({lines:e}){let{t}=c(),n=(0,Y.useMemo)(()=>Tn(e),[e]),r=(0,Y.useMemo)(()=>On(n),[n]),[i,a]=(0,Y.useState)({rows:null,set:Dn}),o=i.rows===n?i.set:Dn,s=e=>a({rows:n,set:new Set(o).add(e)});return(0,X.jsx)(`table`,{className:`w-full border-collapse`,children:(0,X.jsx)(`tbody`,{children:n.map((e,n)=>{let i=r[n];return(0,X.jsxs)(Y.Fragment,{children:[i>0&&(0,X.jsx)(`tr`,{"data-testid":`work-diff-gap`,children:(0,X.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,X.jsx)(Y.Fragment,{children:e.lines.map((e,t)=>(0,X.jsx)(En,{line:e},t))},`fold-${n}`):(0,X.jsx)(`tr`,{children:(0,X.jsx)(`td`,{colSpan:3,className:`p-0`,children:(0,X.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,X.jsx)(O,{className:`h-3 w-3 shrink-0`}),t(`work.files.diffFolded`,{count:e.count,defaultValue:`{{count}} unchanged lines`})]})})},`fold-${n}`):(0,X.jsx)(En,{line:e.line},`line-${n}`)}}function An({lines:e,ariaLabel:t}){return(0,X.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,X.jsx)(kn,{lines:e})})}var jn=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+=`
|
|
6
|
+
`;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},Mn=e=>{let t=jn(e);return t.startsWith(`a/`)||t.startsWith(`b/`)?t.slice(2):t},Nn=e=>{let t=e.slice(11).trim();if(t.startsWith(`"`)){let e=t.indexOf(`" `,1);return e===-1?null:{oldPath:Mn(t.slice(0,e+1)),newPath:Mn(t.slice(e+2).trim())}}let n=t.lastIndexOf(` b/`);if(n===-1){let e=t.indexOf(` `);return e===-1?null:{oldPath:Mn(t.slice(0,e)),newPath:Mn(t.slice(e+1))}}return{oldPath:Mn(t.slice(0,n)),newPath:Mn(t.slice(n+1))}},Pn=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/,Fn=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:Cn(e.lines)}),In=e=>{let t=[],n=null;for(let r of e.split(`
|
|
7
|
+
`)){if(r.startsWith(`diff --git `)){n&&t.push(Fn(n));let e=Nn(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=jn(r.slice(12));continue}if(r.startsWith(`rename to `)){n.status=`renamed`,n.newPath=jn(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=Mn(e));continue}if(r.startsWith(`+++ `)){let e=r.slice(4).trim();e!==`/dev/null`&&n.status!==`renamed`&&(n.newPath=Mn(e));continue}let e=r.match(Pn);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(Fn(n)),t},Ln=e=>{let t=0,n=0;for(let r of e)t+=r.stats.added,n+=r.stats.removed;return{added:t,removed:n}},Rn=(e,t)=>{if(e.success&&e.data)return e.data;throw Error(e.error||t)},zn=(e,t)=>{let n=e?.response?.data?.error;return typeof n==`string`&&n?n:e instanceof Error&&e.message?e.message:t},Bn=e=>e.indexStatus===`?`,Vn=e=>Bn(e)?`U`:e.workingTreeStatus===`.`?e.indexStatus:e.workingTreeStatus,Hn=e=>({modified:`M`,added:`A`,deleted:`D`,renamed:`R`})[e],Un=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`,Wn=e=>{let t=e.lastIndexOf(`/`);return t===-1?{name:e,directory:``}:{name:e.slice(t+1),directory:e.slice(0,t)}};function Gn({added:e,removed:t,muted:n=!1}){return(0,X.jsxs)(`span`,{dir:`ltr`,className:`shrink-0 font-mono text-[10px] tabular-nums`,children:[(0,X.jsxs)(`span`,{className:n?`text-ink-subtle`:`text-[rgb(46,164,79)]`,children:[`+`,e]}),` `,(0,X.jsxs)(`span`,{className:n?`text-ink-subtle`:`text-[rgb(255,61,129)]`,children:[`−`,t]})]})}function Kn({letter:e,path:t,oldPath:n,added:r,removed:i}){return(0,X.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,X.jsx)(`span`,{"aria-hidden":`true`,className:l(`w-4 shrink-0 text-center font-mono text-[11px] font-semibold`,Un(e)),children:e}),(0,X.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,X.jsx)(Gn,{added:r,removed:i})]})}function qn({taskId:e,mutationsDisabled:t=!1,disabledReason:n}){let{t:r}=c(),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(!0),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)([]),[g,_]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)(``),[S,w]=(0,Y.useState)(null),[E,O]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(null),[M,ee]=(0,Y.useState)(!1),N=(0,Y.useRef)(0),P=(0,Y.useRef)(0),F=(0,Y.useCallback)(async()=>{let t=++N.current;s(!0),p(null);try{let n=Rn(await W.getGitStatus(e),r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`}));if(t!==N.current)return;a(n),h([])}catch(e){if(t!==N.current)return;p(zn(e,r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`})))}finally{t===N.current&&s(!1)}},[r,e]);(0,Y.useEffect)(()=>{let e=window.setTimeout(()=>void F(),0);return()=>{window.clearTimeout(e),N.current+=1}},[F]),(0,Y.useEffect)(()=>{let t=!1,n=window.setTimeout(async()=>{if(!i?.initialized){j(null);return}if(!i.changes.some(e=>!Bn(e))){j(i.changes.length>0?{files:[],truncated:!1}:null);return}ee(!0);try{let n=await W.getGitDiff(e);if(t||!n.success||!n.data)return;j({files:In(n.data.patch),truncated:n.data.truncated})}catch{}finally{t||ee(!1)}},0);return()=>{t=!0,window.clearTimeout(n)}},[i,e]);let I=async(e,n)=>{if(t||u)return!1;d(!0),p(null);try{let t=Rn(await e(),r(`work.git.actionFailed`,{defaultValue:`Git action failed.`}));return P.current+=1,a(t),h([]),w(null),H.success(n),!0}catch(e){let t=zn(e,r(`work.git.actionFailed`,{defaultValue:`Git action failed.`}));return p(t),H.error(t),!1}finally{d(!1)}},L=async t=>{let n=++P.current;O(!0),p(null);try{if(Bn(t)){let i=Rn(await W.getFile(e,t.path),r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`}));if(n!==P.current)return;w({path:t.path,status:`added`,lines:xn(``,i.content),binary:!1,truncated:!1})}else{let i=Rn(await W.getGitDiff(e,t.path),r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`}));if(n!==P.current)return;let a=In(i.patch)[0];w({path:t.path,status:a?.status??`modified`,lines:a?.lines??[],binary:a?.binary??!1,truncated:i.truncated})}}catch(e){if(n!==P.current)return;p(zn(e,r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`})))}finally{n===P.current&&O(!1)}},te=(0,Y.useMemo)(()=>{let e=new Map;for(let t of A?.files??[])e.set(t.path,t);return e},[A]),z=(0,Y.useMemo)(()=>Ln(A?.files??[]),[A]),ne=b.trim().toLowerCase(),re=(0,Y.useMemo)(()=>{let e=i?.changes??[];return ne?e.filter(e=>e.path.toLowerCase().includes(ne)):e},[ne,i]);if(o&&!i)return(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center text-ink-muted`,children:(0,X.jsx)(C,{className:`h-5 w-5 animate-spin`})});if(!i)return(0,X.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,X.jsx)(fe,{className:`mb-3 h-8 w-8 text-error-500`}),(0,X.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,X.jsxs)(J,{size:`sm`,variant:`secondary`,className:`mt-4`,onClick:()=>void F(),children:[(0,X.jsx)(k,{className:`h-3.5 w-3.5`}),r(`common.retry`,{defaultValue:`Retry`})]})]});if(!i.initialized)return(0,X.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,X.jsx)(fe,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,X.jsx)(`h3`,{className:`text-sm font-medium text-ink`,children:r(`work.git.notInitialized`,{defaultValue:`Git is not initialized`})}),(0,X.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,X.jsx)(`p`,{className:`mt-3 text-xs text-error-600`,children:f}),(0,X.jsxs)(J,{"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 I(()=>W.initializeGit(e),r(`work.git.initialized`,{defaultValue:`Git repository initialized.`})),children:[u?(0,X.jsx)(C,{className:`me-2 h-3.5 w-3.5 animate-spin`}):(0,X.jsx)(T,{className:`me-2 h-3.5 w-3.5`}),r(`work.git.initialize`,{defaultValue:`Initialize Git`})]}),t&&n&&(0,X.jsx)(`p`,{className:`mt-2 text-[11px] text-ink-subtle`,children:n})]});let ie=i.changes.filter(e=>e.staged).length,V=i.changes.length>0,ae=re.filter(Bn),oe=ne?(A?.files??[]).filter(e=>e.path.toLowerCase().includes(ne)):A?.files??[];return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`work-git-panel`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-3 py-2`,children:[(0,X.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,X.jsx)(fe,{className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:i.detached?r(`work.git.detached`,{defaultValue:`detached HEAD`}):i.branch||`main`})]}),A&&(z.added>0||z.removed>0)&&(0,X.jsxs)(`span`,{"data-testid":`work-git-total-stats`,dir:`ltr`,className:`font-mono text-[11px] font-medium tabular-nums`,children:[(0,X.jsxs)(`span`,{className:`text-[rgb(46,164,79)]`,children:[`+`,z.added]}),` `,(0,X.jsxs)(`span`,{className:`text-[rgb(255,61,129)]`,children:[`−`,z.removed]})]}),(i.ahead>0||i.behind>0)&&(0,X.jsxs)(`span`,{className:`text-[10px] text-ink-muted`,children:[`↑`,i.ahead,` ↓`,i.behind]}),(0,X.jsxs)(`select`,{"data-testid":`work-git-branch-select`,"aria-label":r(`work.git.switchBranch`,{defaultValue:`Switch local branch`}),value:i.branch||``,disabled:t||u||V,onChange:t=>{let n=t.target.value;!n||n===i.branch||I(()=>W.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,X.jsx)(`option`,{value:``,disabled:!0,children:r(`work.git.detached`,{defaultValue:`detached HEAD`})}),i.branches.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))]}),(0,X.jsxs)(`div`,{className:`flex min-w-44 flex-1 items-center gap-1`,children:[(0,X.jsx)(`input`,{"data-testid":`work-git-branch-input`,value:v,maxLength:200,onChange:e=>y(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,X.jsxs)(J,{"data-testid":`work-git-create-branch-button`,size:`sm`,variant:`ghost`,className:`h-7 px-2`,disabled:t||u||!i.head||!v.trim(),onClick:()=>{let t=v.trim();I(()=>W.createGitBranch(e,t),r(`work.git.branchCreated`,{name:t,defaultValue:`Created {{name}}.`})).then(e=>{e&&y(``)})},children:[(0,X.jsx)(T,{className:`h-3.5 w-3.5`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:r(`work.git.createBranch`,{defaultValue:`Create`})})]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void F(),disabled:o||u,"aria-label":r(`common.refresh`,{defaultValue:`Refresh`}),className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-ink-muted hover:bg-surface-subtle hover:text-ink disabled:opacity-50`,children:(0,X.jsx)(k,{className:l(`h-3.5 w-3.5`,o&&`animate-spin`)})})]}),f&&(0,X.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,X.jsx)(`div`,{className:`border-b border-line px-3 py-1.5 text-[11px] text-ink-subtle`,children:n}),(0,X.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,X.jsxs)(`section`,{className:`flex min-h-0 flex-col border-b border-line lg:border-b-0 lg:border-e`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,X.jsxs)(`h3`,{className:`text-xs font-medium text-ink`,children:[r(`work.git.changes`,{defaultValue:`Changes`}),` `,(0,X.jsx)(`span`,{className:`text-ink-subtle`,children:i.changes.length})]}),(0,X.jsxs)(J,{"data-testid":`work-git-stage-button`,size:`sm`,variant:`ghost`,className:`h-7 px-2 text-[11px]`,disabled:t||u||m.length===0&&i.changes.length===0,onClick:()=>{let t=m.length>0?m:i.changes.map(e=>e.path);I(()=>W.stageGitPaths(e,t),r(`work.git.staged`,{defaultValue:`Changes staged.`}))},children:[(0,X.jsx)(ue,{className:`h-3.5 w-3.5`}),m.length>0?r(`work.git.stageSelected`,{count:m.length,defaultValue:`Stage {{count}}`}):r(`work.git.stageAll`,{defaultValue:`Stage all`})]})]}),i.changes.length>0&&(0,X.jsxs)(`div`,{className:`relative px-2 pb-1.5`,children:[(0,X.jsx)(D,{className:`pointer-events-none absolute start-4 top-1/2 h-3 w-3 -translate-y-[calc(50%+3px)] text-ink-subtle`}),(0,X.jsx)(`input`,{"data-testid":`work-git-filter`,value:b,maxLength:500,onChange:e=>x(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,X.jsx)(`div`,{className:`min-h-32 flex-1 overflow-y-auto px-2 pb-2`,children:i.changes.length===0?(0,X.jsx)(`p`,{className:`px-2 py-8 text-center text-xs text-ink-muted`,children:r(`work.git.clean`,{defaultValue:`Working tree is clean.`})}):re.length===0?(0,X.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.`})}):re.map(e=>{let t=Vn(e),{name:n,directory:i}=Wn(e.path),a=te.get(e.path);return(0,X.jsxs)(`div`,{className:l(`flex items-center gap-1 rounded-lg hover:bg-surface-subtle`,S?.path===e.path&&`bg-surface-subtle`),children:[(0,X.jsx)(`input`,{type:`checkbox`,"aria-label":r(`work.git.selectPath`,{path:e.path,defaultValue:`Select {{path}}`}),checked:m.includes(e.path),onChange:t=>h(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,X.jsxs)(`button`,{type:`button`,"data-testid":`work-git-change`,onClick:()=>void L(e),className:`flex min-w-0 flex-1 items-center gap-2 px-1.5 py-2 text-start`,title:e.path,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:l(`w-3.5 shrink-0 text-center font-mono text-[10px] font-semibold`,Un(t),e.staged&&`underline underline-offset-2`),children:t}),(0,X.jsxs)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate text-start font-mono text-[11px]`,children:[(0,X.jsx)(`span`,{className:`text-ink`,children:n}),i&&(0,X.jsxs)(`span`,{className:`text-ink-subtle`,children:[` `,i]})]}),a&&(a.stats.added>0||a.stats.removed>0)&&(0,X.jsx)(Gn,{added:a.stats.added,removed:a.stats.removed})]})]},`${e.path}:${e.originalPath||``}`)})}),(0,X.jsxs)(`div`,{className:`border-t border-line p-2`,children:[(0,X.jsx)(`textarea`,{"data-testid":`work-git-commit-input`,value:g,maxLength:4e3,rows:2,onChange:e=>_(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,X.jsxs)(J,{"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||ie===0||!g.trim(),onClick:()=>{let t=g.trim();I(()=>W.commitGit(e,t),r(`work.git.committed`,{defaultValue:`Commit created.`})).then(e=>{e&&_(``)})},children:[u&&(0,X.jsx)(C,{className:`h-3.5 w-3.5 animate-spin`}),r(`work.git.commit`,{defaultValue:`Commit staged changes`})]})]}),(0,X.jsxs)(`div`,{className:`max-h-56 shrink-0 overflow-y-auto border-t border-line p-3`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-medium text-ink`,children:[(0,X.jsx)(le,{className:`h-3.5 w-3.5`}),r(`work.git.history`,{defaultValue:`Local history`})]}),i.commits.length===0?(0,X.jsx)(`p`,{className:`py-3 text-center text-xs text-ink-muted`,children:r(`work.git.noCommits`,{defaultValue:`No commits yet.`})}):(0,X.jsx)(`ol`,{className:`space-y-2`,children:i.commits.map(e=>(0,X.jsxs)(`li`,{className:`rounded-lg border border-line bg-surface px-2.5 py-2`,children:[(0,X.jsx)(`p`,{dir:`auto`,className:`text-xs text-ink`,children:e.subject}),(0,X.jsxs)(`p`,{className:`mt-1 flex flex-wrap gap-x-2 text-[10px] text-ink-subtle`,children:[(0,X.jsx)(`span`,{dir:`ltr`,className:`font-mono`,children:e.shortHash}),(0,X.jsx)(`span`,{dir:`auto`,children:e.author}),(0,X.jsx)(`time`,{dateTime:e.authoredAt,children:new Date(e.authoredAt).toLocaleDateString()})]})]},e.hash))}),(0,X.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,X.jsx)(`section`,{className:`flex min-h-48 min-w-0 flex-col`,children:S||E?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-2 py-1.5`,children:[(0,X.jsxs)(`button`,{type:`button`,"data-testid":`work-git-all-changes-button`,onClick:()=>{P.current+=1,w(null),O(!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,X.jsx)(R,{className:`h-3 w-3 rtl:rotate-180`}),r(`work.git.allChanges`,{defaultValue:`All changes`})]}),S&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:l(`w-4 shrink-0 text-center font-mono text-[11px] font-semibold`,Un(Hn(S.status))),children:Hn(S.status)}),(0,X.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink`,title:S.path,children:S.path}),!S.binary&&(0,X.jsx)(Gn,{added:S.lines.filter(e=>e.type===`added`).length,removed:S.lines.filter(e=>e.type===`removed`).length})]})]}),E?(0,X.jsx)(C,{className:`m-auto h-5 w-5 animate-spin text-ink-muted`}):S?(0,X.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:[S.truncated&&(0,X.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.`})}),S.binary?(0,X.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.`})}):S.lines.length===0?(0,X.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,X.jsx)(kn,{lines:S.lines})]}):null]}):i.changes.length===0?(0,X.jsx)(`p`,{className:`m-auto px-5 text-center text-xs text-ink-muted`,children:r(`work.git.clean`,{defaultValue:`Working tree is clean.`})}):M&&!A?(0,X.jsx)(C,{className:`m-auto h-5 w-5 animate-spin text-ink-muted`}):(0,X.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:[A?.truncated&&(0,X.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.`})}),oe.map(e=>(0,X.jsxs)(`div`,{"data-testid":`work-git-review-file`,children:[(0,X.jsx)(Kn,{letter:Hn(e.status),path:e.path,oldPath:e.oldPath,added:e.stats.added,removed:e.stats.removed}),e.binary?(0,X.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,X.jsx)(kn,{lines:e.lines})]},e.path)),ae.map(e=>(0,X.jsx)(`div`,{"data-testid":`work-git-review-file`,children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void L(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,X.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,X.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink`,children:e.path}),(0,X.jsx)(B,{className:`h-3 w-3 shrink-0 text-ink-subtle`})]})},e.path)),oe.length===0&&ae.length===0&&(0,X.jsx)(`p`,{className:`px-5 py-10 text-center font-sans text-xs text-ink-muted`,children:ne?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 Jn(e,t){return Ee(e,t.ticket,t)}async function Yn(e){let t=(await U.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 Jn(e,{protocol:window.location.protocol,host:window.location.host,hostname:window.location.hostname,apiBaseUrl:void 0,websocketBaseUrl:void 0,production:!0,ticket:t})}var Xn=(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})`},Zn=()=>({background:`#ffffff`,foreground:`#1f2328`,cursor:`#1f2328`,selectionBackground:Xn(500,.28)}),Qn=()=>({background:`#0f1115`,foreground:`#e6e6e6`,cursor:Xn(400),selectionBackground:Xn(500,.32)});function $n({taskId:e,active:t,disabledReason:n}){let{t:i}=c(),a=Fe(e=>e.theme.mode!==`light`),o=(0,Y.useRef)(null),s=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useRef)(null),[f,p]=(0,Y.useState)(`idle`),[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(0),v=(0,Y.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,Y.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?Qn():Zn()});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 Yn(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,Y.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,X.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,X.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,X.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center gap-2 text-xs text-ink-muted`,children:[(0,X.jsx)(C,{className:`h-4 w-4 animate-spin`}),i(`work.terminal.connecting`,{defaultValue:`Opening a shell in the sandbox…`})]}),b&&(0,X.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,X.jsx)(w,{className:`h-6 w-6 text-ink-subtle`}),(0,X.jsx)(`p`,{dir:`auto`,"data-testid":`work-terminal-status`,className:`max-w-md text-xs leading-relaxed text-ink-muted`,children:b}),!n&&(0,X.jsx)(J,{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 er=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},tr=e=>{let t=e.split(`/`).filter(Boolean);return t.pop(),t.join(`/`)},nr=(e,t)=>{let n=e.metadata?.name??e.metadata?.toolName??e.metadata?.tool??e.metadata?.command;return typeof n==`string`&&n?n:t};function rr({task:e,persona:t,openFileRequest:n,liveRun:r,files:i,selectedFile:a,loadingFiles:o,actionLoading:s,onLoadFiles:d,onLoadFile:p,onClearSelectedFile:m,onSaveFile:g,onStartPreview:_,onStopPreview:y,onDirtyChange:b,terminal:x}){let{t:S,i18n:T}=c(),E=u(T.language),[D,O]=(0,Y.useState)(e.isAgent?`agent`:`files`),[A,j]=(0,Y.useState)(``),[N,P]=(0,Y.useState)(``),[I,L]=(0,Y.useState)(),[B,ie]=(0,Y.useState)(``),[V,ae]=(0,Y.useState)(!1),[oe,se]=(0,Y.useState)(!1),ce=(0,Y.useRef)(new Map),[le,ue]=(0,Y.useState)(()=>new Map),de=er(e.previewUrl),he=r?.runId,ge=r?.error,_e=r?.tools,ve=(0,Y.useMemo)(()=>{let t=new Set(_e?.map(e=>e.id)||[]);return(e.messages||[]).filter(e=>{if(e.kind===`reasoning`||e.role!==`tool`&&e.kind===`message`)return!1;if(!he||e.runId!==he)return!0;if(e.kind===`error`&&ge)return!1;let n=e.metadata?.toolCallId;return typeof n!=`string`||!t.has(n)})},[ge,he,_e,e.messages]),be=ve.length+(_e?.length||0),xe=!!a&&N!==(a?.content??``),U=e.status===`preparing`||e.status===`running`,W=(0,Y.useRef)(U),G=(0,Y.useRef)(0),K=(0,Y.useRef)(N),Se=(0,Y.useRef)(I),Ce=(0,Y.useRef)(a),we=(0,Y.useRef)(e.id),Te=(0,Y.useRef)(d),Ee=(0,Y.useRef)(p),Oe=(0,Y.useRef)(b),q=(0,Y.useRef)(!0),ke=a?le.get(a.path):void 0,Me=(0,Y.useMemo)(()=>a&&ke!==void 0&&ke!==a.content?xn(ke,a.content):null,[ke,a]),Ne=(0,Y.useMemo)(()=>Me?Cn(Me):null,[Me]),Pe=!!(Ne&&(Ne.added>0||Ne.removed>0)),Fe=a?un(a.path):!1,Ie=!a||dn(N),Le=Fe&&Ie;(0,Y.useEffect)(()=>{K.current=N,Se.current=I,Ce.current=a,we.current=e.id,Oe.current=b},[I,N,b,a,e.id]),(0,Y.useEffect)(()=>{Te.current=d,Ee.current=p},[p,d]),(0,Y.useEffect)(()=>(q.current=!0,()=>{q.current=!1,G.current+=1,Oe.current(!1)}),[]),(0,Y.useEffect)(()=>{if(!W.current&&U&&ue(new Map(ce.current)),W.current&&!U&&(Te.current(A),a&&!xe)){let e=++G.current,t=a.path,n=K.current,r=Se.current;Ee.current(t).then(i=>{if(!q.current||e!==G.current||i.path!==t||K.current!==n||Se.current!==r)return;ce.current.set(i.path,i.content);let a=le.get(i.path);a!==void 0&&a!==i.content&&se(!0),K.current=i.content,Se.current=i.updatedAt??i.modifiedAt,P(i.content),L(i.updatedAt??i.modifiedAt)}).catch(()=>void 0)}W.current=U},[A,xe,a,U,le]);let Re=()=>!xe||window.confirm(S(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),ze=()=>{a&&je(e.id,a.path)},Be=async e=>{Re()&&(G.current+=1,ze(),m(),b(!1),se(!1),j(e),await d(e).catch(()=>void 0))},Ve=async t=>{if(!Re())return;let n=++G.current;ze();let r=await p(t).catch(()=>void 0);if(!q.current||!r||n!==G.current)return;ce.current.set(r.path,r.content);let i=le.get(r.path);se(i!==void 0&&i!==r.content);let a=De(e.id,r.path),o=a?.content??r.content,s=a?.baseUpdatedAt??r.updatedAt??r.modifiedAt;K.current=o,Se.current=s,P(o),L(s),b(a!==null&&a.content!==r.content)},He=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{!n||n.nonce===He.current||(He.current=n.nonce,O(`files`),Ve(n.path))},[n]);let Ue=()=>{Re()&&(G.current+=1,ze(),m(),b(!1),se(!1))},We=t=>{a&&(K.current=t,P(t),t===a.content?je(e.id,a.path):Ae(e.id,a.path,{content:t,baseUpdatedAt:I??a.updatedAt??a.modifiedAt}),b(t!==a.content))},Ge=async()=>{if(!a)return;let t=e.id,n=a.path,r=N,i=G.current,o=await g(n,r,I).catch(()=>!1);if(!q.current||o===!1||i!==G.current||we.current!==t||Ce.current?.path!==n)return;let s=o.updatedAt??o.modifiedAt;ce.current.set(n,typeof o.content==`string`?o.content:r),Se.current=s,L(s);let c=K.current;if(c===r){je(t,n),b(!1);return}Ae(t,n,{content:c,baseUpdatedAt:s}),b(!0)},Ke=async()=>{if(!a||U||V||!Le)return;ae(!0);let e=G.current,t=a.path,n=K.current;try{let r=await pn(t,n);if(!q.current||e!==G.current||Ce.current?.path!==t||K.current!==n)return;We(r),H.success(S(`work.files.formatted`,{defaultValue:`Code formatted.`}))}catch(r){if(!q.current||e!==G.current||Ce.current?.path!==t||K.current!==n)return;H.error(r instanceof Error?r.message:S(`work.files.formatFailed`,{defaultValue:`Could not format this file.`}))}finally{q.current&&ae(!1)}},Z=[...e.isAgent?[{id:`agent`,label:S(`work.workspace.agent`,{defaultValue:`Agent`}),icon:re,testId:`work-agent-tab`}]:[],{id:`files`,label:S(`work.workspace.files`,{defaultValue:`Files`}),icon:me,testId:`work-files-tab`},{id:`activity`,label:S(`work.workspace.activity`,{defaultValue:`Activity`}),icon:te,testId:`work-activity-tab`},{id:`git`,label:S(`work.workspace.git`,{defaultValue:`Git`}),icon:fe,testId:`work-git-tab`},{id:`terminal`,label:S(`work.workspace.terminal`,{defaultValue:`Terminal`}),icon:w,testId:`work-terminal-tab`},{id:`preview`,label:S(`work.workspace.preview`,{defaultValue:`Preview`}),icon:z,testId:`work-preview-tab`},...e.computerAvailable?[{id:`screen`,label:S(`work.workspace.screen`,{defaultValue:`Screen`}),icon:ye,testId:`work-screen-tab`}]:[]],qe=(e,t)=>{let n=null;if(e.key===`ArrowRight`&&(n=(t+(E?-1:1)+Z.length)%Z.length),e.key===`ArrowLeft`&&(n=(t+(E?1:-1)+Z.length)%Z.length),e.key===`Home`&&(n=0),e.key===`End`&&(n=Z.length-1),n===null)return;e.preventDefault();let r=Z[n];O(r.id),e.currentTarget.parentElement?.querySelector(`#work-workspace-tab-${r.id}`)?.focus()};return(0,X.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-transparent`,children:[(0,X.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,X.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,"aria-label":S(`work.workspace.label`,{defaultValue:`Workspace views`}),className:`flex min-w-0 items-center overflow-x-auto rounded-xl border border-line bg-surface-subtle p-0.5 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:Z.map((e,t)=>{let n=e.icon;return(0,X.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:()=>O(e.id),onKeyDown:e=>qe(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,X.jsx)(n,{className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`hidden xs:inline`,children:e.label}),e.id===`activity`&&be>0&&(0,X.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-[10px] text-ink-muted`,children:be})]},e.id)})}),D===`files`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[a&&(0,X.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:Ue,"aria-label":S(`work.files.back`,{defaultValue:`Back to files`}),children:(0,X.jsx)(R,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,X.jsxs)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,title:a?.path??`/workspace${A?`/${A}`:``}`,children:[a?.path??`/workspace${A?`/${A}`:``}`,xe&&` •`]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:!A,onClick:()=>void Be(tr(A)),className:l(`hidden h-8 w-8 items-center justify-center rounded-lg border border-transparent text-ink-muted hover:border-line hover:bg-surface-subtle hover:text-ink disabled:opacity-30 sm:inline-flex`,!a&&`inline-flex`),"aria-label":S(`work.files.up`,{defaultValue:`Parent folder`}),title:S(`work.files.up`,{defaultValue:`Parent folder`}),children:(0,X.jsx)(R,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,X.jsx)(`button`,{type:`button`,"data-testid":`work-refresh-files-button`,onClick:()=>void d(A).catch(()=>void 0),className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-transparent text-ink-muted hover:border-line hover:bg-surface-subtle hover:text-ink`,"aria-label":S(`common.refresh`,{defaultValue:`Refresh`}),title:S(`common.refresh`,{defaultValue:`Refresh`}),children:(0,X.jsx)(k,{className:l(`h-3.5 w-3.5`,o&&`animate-spin`)})}),a&&Pe&&Ne&&(0,X.jsxs)(`button`,{type:`button`,"data-testid":`work-diff-toggle-button`,"aria-pressed":oe,onClick:()=>se(e=>!e),title:S(`work.files.changesSince`,{defaultValue:`What changed since the last turn`}),className:l(`inline-flex h-8 items-center gap-1.5 rounded-lg border px-2 text-[11px] font-medium transition-colors`,oe?`border-transparent bg-ink text-ink-inverse`:`border-line text-ink-muted hover:bg-surface-subtle hover:text-ink`),children:[(0,X.jsx)(f,{className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:S(`work.files.changes`,{defaultValue:`Changes`})}),(0,X.jsxs)(`span`,{dir:`ltr`,className:`tabular-nums`,children:[(0,X.jsxs)(`span`,{className:oe?void 0:`text-[rgb(46,164,79)]`,children:[`+`,Ne.added]}),` `,(0,X.jsxs)(`span`,{className:oe?void 0:`text-[rgb(255,61,129)]`,children:[`−`,Ne.removed]})]})]}),a&&!oe&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(J,{"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||V||!Le,onClick:()=>void Ke(),"aria-busy":V||void 0,title:Le?S(`work.files.formatShortcut`,{defaultValue:`Format (Shift+Alt+F)`}):Fe?S(`work.files.formatTooLarge`,{defaultValue:`Formatting is limited to files under 100,000 characters and 4,000 lines.`}):S(`work.files.formatUnsupported`,{defaultValue:`Formatting is not available for this file type.`}),"aria-label":S(`work.files.format`,{defaultValue:`Format file`}),children:[V?(0,X.jsx)(C,{className:`h-3.5 w-3.5 animate-spin`}):(0,X.jsx)(ne,{className:`h-3.5 w-3.5`}),(0,X.jsx)(`span`,{className:`hidden 2xl:inline`,children:S(`work.files.format`,{defaultValue:`Format`})})]}),(0,X.jsxs)(J,{"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:!xe||U||V||s,onClick:()=>void Ge(),"aria-busy":s||void 0,title:S(`work.files.saveShortcut`,{defaultValue:`Save (⌘/Ctrl+S)`}),"aria-label":S(`common.save`),children:[s?(0,X.jsx)(C,{className:`h-3.5 w-3.5 animate-spin`}):(0,X.jsx)(v,{className:`h-3.5 w-3.5`}),(0,X.jsx)(`span`,{className:`hidden 2xl:inline`,children:S(`common.save`)})]})]})]})]}),(D===`activity`||D===`git`||D===`screen`)&&(0,X.jsx)(`div`,{className:`min-w-0 flex-1`}),D===`terminal`&&(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,X.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,children:`/workspace`}),U&&(0,X.jsx)(`span`,{className:`shrink-0 text-[10px] text-ink-subtle`,children:S(`work.terminal.taskRunning`,{defaultValue:`Model turn in progress`})})]}),D===`preview`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{dir:`auto`,value:B,onChange:e=>ie(e.target.value),placeholder:S(`work.preview.command`,{defaultValue:`Optional start command`}),"aria-label":S(`work.preview.command`,{defaultValue:`Optional start command`}),className:`h-8 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2.5 font-mono text-[11px] text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.previewStatus===`running`||e.previewStatus===`starting`?(0,X.jsxs)(J,{"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 y(),"aria-busy":s||void 0,"aria-label":S(`work.preview.stop`,{defaultValue:`Stop preview`}),children:[s?(0,X.jsx)(C,{className:`h-3.5 w-3.5 animate-spin`}):(0,X.jsx)(h,{className:`h-3.5 w-3.5 fill-current`}),(0,X.jsx)(`span`,{className:`hidden 2xl:inline`,children:S(`work.preview.stop`,{defaultValue:`Stop preview`})})]}):(0,X.jsxs)(J,{"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 _(B.trim()||void 0),"aria-busy":s||void 0,"aria-label":S(`work.preview.start`,{defaultValue:`Start preview`}),children:[s?(0,X.jsx)(C,{className:`h-3.5 w-3.5 animate-spin`}):(0,X.jsx)(pe,{className:`h-3.5 w-3.5 fill-current`}),(0,X.jsx)(`span`,{className:`hidden 2xl:inline`,children:S(`work.preview.start`,{defaultValue:`Start preview`})})]}),de&&(0,X.jsx)(`a`,{href:de,target:`_blank`,rel:`noopener noreferrer`,"aria-label":S(`work.preview.open`,{defaultValue:`Open`}),title:S(`work.preview.open`,{defaultValue:`Open`}),className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-line text-ink-muted hover:bg-surface-subtle hover:text-ink`,children:(0,X.jsx)(ee,{className:`h-3.5 w-3.5`})})]})]})]}),D===`files`&&(0,X.jsxs)(`div`,{id:`work-workspace-panel-files`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-files`,className:`flex min-h-0 flex-1`,children:[(0,X.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,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-1.5`,children:o&&i.length===0?(0,X.jsx)(`div`,{className:`flex justify-center py-8 text-ink-muted`,children:(0,X.jsx)(C,{className:`h-5 w-5 animate-spin`})}):i.length===0?(0,X.jsx)(`p`,{className:`px-3 py-8 text-center text-xs text-ink-muted`,children:S(`work.files.empty`,{defaultValue:`No files in this folder yet.`})}):[...i].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1).map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-testid":`work-file-item`,"data-path":e.path,onClick:()=>{e.type===`directory`?Be(e.path):Ve(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,X.jsx)(M,{className:`h-3.5 w-3.5 shrink-0 text-amber-500`}):(0,X.jsx)(F,{className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{dir:`auto`,className:`truncate`,children:e.name})]},e.path))})}),(0,X.jsx)(`div`,{className:l(`min-h-0 min-w-0 flex-1 flex-col`,a?`flex`:`hidden sm:flex`),children:a&&oe&&Me?(0,X.jsx)(An,{lines:Me,ariaLabel:S(`work.files.diffLabel`,{path:a.path,defaultValue:`Changes since the last turn: {{path}}`})}):a?(0,X.jsx)(vn,{path:a.path,value:N,ariaLabel:S(`work.files.editorLabel`,{path:a.path,defaultValue:`File editor: {{path}}`}),onChange:We,onSaveShortcut:()=>{xe&&!U&&!s&&!V&&Ge()},onFormatShortcut:()=>void Ke(),disabled:U||V}):(0,X.jsxs)(`div`,{className:`m-auto px-6 text-center text-xs text-ink-muted`,children:[(0,X.jsx)(F,{className:`mx-auto mb-3 h-7 w-7 text-ink-subtle`}),S(`work.files.select`,{defaultValue:`Select a file to inspect and edit it.`})]})})]}),D===`activity`&&(0,X.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,X.jsx)(`div`,{className:`mb-3`,children:(0,X.jsx)(vt,{run:r,variant:`activity`})}),ve.length===0&&!r?(0,X.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center text-xs text-ink-muted`,children:[(0,X.jsx)(w,{className:`mb-3 h-7 w-7 text-ink-subtle`}),S(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]}):(0,X.jsx)(`div`,{className:`space-y-2`,children:ve.map(e=>(0,X.jsxs)(`div`,{className:`rounded-xl border border-line bg-surface p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{dir:`auto`,className:`truncate font-mono text-xs font-medium text-ink`,children:nr(e,S(`work.activity.toolActivity`,{defaultValue:`Tool activity`}))}),(0,X.jsx)(`span`,{className:`shrink-0 text-[10px] uppercase tracking-wide text-ink-subtle rtl:tracking-normal`,children:{message:S(`work.activity.kinds.message`,{defaultValue:`Message`}),reasoning:S(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`}),tool_call:S(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}),tool_result:S(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),error:S(`work.activity.kinds.error`,{defaultValue:`Error`})}[e.kind]})]}),e.content&&(0,X.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,X.jsx)(`div`,{id:`work-workspace-panel-git`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-git`,className:`min-h-0 flex-1`,children:(0,X.jsx)(qn,{taskId:e.id,mutationsDisabled:U||e.previewStatus===`starting`||e.previewStatus===`running`,disabledReason:U?S(`work.git.blockedByRun`,{defaultValue:`Git write actions unlock when the model turn finishes.`}):e.previewStatus===`starting`||e.previewStatus===`running`?S(`work.git.blockedByPreview`,{defaultValue:`Stop the preview before changing Git state.`}):void 0})}),D===`agent`&&(0,X.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,X.jsx)($t,{task:e,persona:t,active:D===`agent`,onOpenScreen:()=>O(`screen`)})}),D===`screen`&&(0,X.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,X.jsx)(Xt,{taskId:e.id,active:D===`screen`})}),D===`terminal`&&(0,X.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,X.jsx)($n,{taskId:e.id,active:D===`terminal`,disabledReason:x&&!x.available?x.reason??S(`work.terminal.unavailable`,{defaultValue:`The interactive terminal is not available in this deployment.`}):U?S(`work.terminal.blockedByRun`,{defaultValue:`The model is using this container. The terminal opens when the turn finishes.`}):void 0})}),D===`preview`&&(0,X.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,X.jsxs)(`div`,{className:`m-auto flex items-center gap-2 text-xs text-ink-muted`,children:[(0,X.jsx)(C,{className:`h-4 w-4 animate-spin`}),S(`work.preview.starting`,{defaultValue:`Starting preview…`})]}):de&&e.previewStatus===`running`?(0,X.jsx)(`iframe`,{"data-testid":`work-preview-frame`,title:S(`work.preview.frameTitle`,{defaultValue:`Workspace preview`}),src:de,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,X.jsxs)(`div`,{className:`m-auto max-w-sm px-6 text-center text-xs leading-relaxed text-ink-muted`,children:[(0,X.jsx)(z,{className:`mx-auto mb-3 h-8 w-8 text-ink-subtle`}),e.previewStatus===`failed`?S(`work.preview.failed`,{defaultValue:`The preview could not start. Check Activity, then try another command.`}):S(`work.preview.empty`,{defaultValue:`Start the app inside this workspace to inspect it here.`})]})})]})}var ir=e=>{let t=e.trim().toLowerCase();return!!t&&!t.includes(`embed`)},ar=(e,t)=>e instanceof Error&&e.message?e.message:t,or=(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 sr(){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),h=p?.id??null,[g,_]=(0,Y.useState)(!1),v=d(e=>e.models),b=d(e=>e.selectedModel),S=d(e=>e.selectedProviderType),C=d(e=>e.selectedProviderId),w=d(e=>e.loadModels),{capabilities:T,tasks:D,selectedTask:O,files:k,selectedFile:A,liveRuns:j,loadingTask:M,loadingOlderMessages:ee,loadingFiles:N,actionLoading:F,error:I,loadCapabilities:L,loadTasks:R,selectTask:te,loadTask:B,loadOlderMessages:ne,createTask:re,updateTask:ie,deleteTask:V,markTaskSeen:oe,startRun:se,cancelRun:ce,beginLiveRun:le,applyRunEvents:ue,setLiveRunConnection:de,clearLiveRun:fe,loadFiles:pe,loadFile:me,clearSelectedFile:he,saveFile:ve,startPreview:ye,stopPreview:be,clearError:xe}=Oe(),U=(0,Y.useMemo)(()=>v.filter(e=>!e.isPersona&&!e.isAgent&&ir(e.name)&&(!e.isPlugin||!!e.pluginId)),[v]),G=(0,Y.useMemo)(()=>U.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:Ge(i),label:e.isPlugin&&e.pluginName?`${e.name} · ${e.pluginName}`:e.name,remote:e.isPlugin||r.endsWith(`:cloud`)||r.endsWith(`-cloud`)}]}),[U]),[K,Se]=(0,Y.useState)(``),[Ce,we]=(0,Y.useState)({locationKey:t.key,value:`conversation`}),Ee=Ce.locationKey===t.key?Ce.value:`conversation`,De=(0,Y.useCallback)(e=>we({locationKey:t.key,value:e}),[t.key]),[q,ke]=(0,Y.useState)(!1),[Ae,Me]=(0,Y.useState)(null),J=Ae?.locationKey===t.key&&Ae.taskId===r?Ae:null;Ae&&!J&&Me(null);let Ie=(0,Y.useCallback)(e=>{r&&(De(`workspace`),Me(n=>({locationKey:t.key,taskId:r,path:e,nonce:n?.locationKey===t.key&&n.taskId===r?n.nonce+1:1})))},[t.key,De,r]),[Le,Be]=(0,Y.useState)(``),Ve=T?.hostWorkspaces?.enabled===!0,He=T?.hostWorkspaces?.roots??[],[Ue,We]=(0,Y.useState)([]),[Z,qe]=(0,Y.useState)(``),Je=d(e=>e.personas),Xe=d(e=>e.loadPersonas),[Ze,Qe]=(0,Y.useState)(``),$e=(0,Y.useMemo)(()=>Object.values(Je).sort((e,t)=>e.name.localeCompare(t.name)),[Je]);Ze&&$e.length>0&&!Je[Ze]&&Qe(``);let et=!O;(0,Y.useEffect)(()=>{if(!et)return;let e=!1;return W.listPolicies().then(t=>{if(e||!t.success||!t.data)return;let n=t.data;We(n),qe(e=>e&&!n.some(t=>t.id===e)?``:e)}).catch(()=>{}),()=>{e=!0}},[et]),(0,Y.useEffect)(()=>{et&&Xe().catch(()=>{})},[et,Xe]);let[tt,nt]=(0,Y.useState)(!1),[rt,it]=(0,Y.useState)(null),at=Ue.some(e=>e.guiEnabled===!0),ot=(0,Y.useCallback)(async()=>{nt(!0),it(null);try{let e=(await W.startComputerSetup()).data;for(;e?.building;)await new Promise(e=>window.setTimeout(e,4e3)),e=(await W.getComputerSetup()).data;if(e?.buildError){it(e.buildError);return}let t=await W.listPolicies();t.success&&t.data&&(We(t.data),e?.policyId&&qe(e.policyId))}catch(e){it(ar(e,`The Work Computer could not be set up.`))}finally{nt(!1)}},[]),st=O?.id,ct=O?.previewStatus===`running`||O?.previewStatus===`starting`;(0,Y.useEffect)(()=>{if(!st||!ct)return;let e=window.setInterval(()=>{document.visibilityState===`visible`&&B(st,!0).catch(()=>{})},3e4);return()=>window.clearInterval(e)},[st,ct,B]);let[lt,ut]=(0,Y.useState)({taskId:null,open:!1}),dt=lt.open&<.taskId===O?.id,ft=(0,Y.useRef)(null),pt=(0,Y.useRef)(null),mt=(0,Y.useRef)(null),ht=(0,Y.useCallback)((e=!1)=>{ut(e=>({...e,open:!1})),e&&window.requestAnimationFrame(()=>pt.current?.focus())},[]);(0,Y.useEffect)(()=>{if(!dt)return;let e=window.requestAnimationFrame(()=>{mt.current?.querySelector(`[role="menuitem"]`)?.focus()}),t=e=>{e.target instanceof Node&&!ft.current?.contains(e.target)&&ht()},n=e=>{e.key===`Escape`&&(e.preventDefault(),ht(!0))};return document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{window.cancelAnimationFrame(e),document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[ht,dt]);let gt=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),ht(!0);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;let t=[...mt.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,Y.useEffect)(()=>{L(),R()},[L,R]),(0,Y.useEffect)(()=>{if(!r){te(null);return}te(r),B(r).catch(()=>void 0),pe(r,``).catch(()=>void 0)},[r,pe,B,te]);let _t=G.find(e=>e.key===K)||G.find(e=>e.model===b&&(S===`plugin`?e.providerType===`plugin`&&e.providerId===C:e.providerType===`ollama`))||G[0],vt=r?D.find(e=>e.id===r):void 0,yt=vt?.status??O?.status;(0,Y.useEffect)(()=>{r&&oe(r)},[r,yt,oe]);let bt=O?.activeRun??vt?.activeRun??null,Q=bt?.id,xt=bt?.status===`queued`||bt?.status===`preparing`||bt?.status===`running`,St=r&&j[r]?.runId===Q?j[r]:void 0,Ct=yt===`preparing`||yt===`running`?1e3:4e3;(0,Y.useEffect)(()=>{let e,t=!1,n=async()=>{await R(!0),t||(e=setTimeout(n,Ct))};return e=setTimeout(n,Ct),()=>{t=!0,e&&clearTimeout(e)}},[R,Ct]);let wt=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(!r||!yt){wt.current=null;return}let e=wt.current;wt.current={taskId:r,status:yt},e?.taskId===r&&(e.status===`preparing`||e.status===`running`)&&yt!==`preparing`&&yt!==`running`&&(B(r,!0).catch(()=>void 0),pe(r,``).catch(()=>void 0))},[pe,B,yt,r]),(0,Y.useEffect)(()=>{if(!r||!Q||!xt)return;let e=new AbortController,t=!1,n=0,i=Oe.getState().liveRuns[r]?.runId===Q&&Oe.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=[],ue(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 le(r,Q,bt?.startedAt||void 0),(async()=>{for(;!t&&!e.signal.aborted&&!a;){de(r,Q,n>=3?`error`:n===0?`connecting`:`reconnecting`);let o=Date.now();try{if(await W.streamRunEvents({taskId:r,runId:Q,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,de(r,Q,n>=3?`error`:`reconnecting`,n>=3?ar(i,`Live updates are reconnecting in the background.`):void 0),await or(Math.min(4e3,250*2**Math.min(n,4)),e.signal)}}if(c(),!(!a||e.signal.aborted)){de(r,Q,`closed`);try{await Promise.all([B(r,!0),pe(r,``),R(!0)])}catch{}finally{fe(r,Q)}}})(),()=>{t=!0,e.abort(),c()}},[ue,le,fe,pe,B,R,bt?.startedAt,xt,Q,de,r]),(0,Y.useEffect)(()=>{if(!q)return;let e=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[q]);let Tt=(0,Y.useCallback)(()=>!q||window.confirm(e(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),[e,q]),Dt=(0,Y.useCallback)(()=>!q||window.confirm(e(`work.files.leaveWithDraft`,{defaultValue:`Leave this file? Your unsaved edit will remain as a browser draft.`})),[e,q]),Ot=()=>{O&&A&&je(O.id,A.path)},kt=s(({currentLocation:e,nextLocation:t})=>{let n=t.state;return q&&n?.deletedWorkTaskId!==r&&`${e.pathname}${e.search}${e.hash}`!=`${t.pathname}${t.search}${t.hash}`});(0,Y.useEffect)(()=>{if(kt.state!==`blocked`)return;if(!Dt()){kt.reset();return}let e=kt.proceed,t=window.setTimeout(()=>{ke(!1),window.setTimeout(e,0)},0);return()=>window.clearTimeout(t)},[Dt,kt]);let At=()=>{xe(),De(`conversation`),n(`/work`)},jt=async t=>{if(O&&!Tt())return!1;O&&q&&(Ot(),he(),ke(!1));try{if(O&&Ke(O)){let e=await W.sendRunMessage(O.id,t);if(!e.success)throw Error(e.message||`The message could not be sent.`);await B(O.id)}else if(O)await se(O.id,{message:t,model:O.model,providerType:O.providerType,providerId:O.providerId||void 0});else{if(!_t)throw Error(e(`work.composer.noModelSelected`,{defaultValue:`No Work-compatible model is selected.`}));let r=await re({message:t,model:_t.model,providerType:_t.providerType,providerId:_t.providerId,networkEnabled:!0,...Ve&&Le.trim()?{hostPath:Le.trim()}:{},...Z?{policyId:Z}:{},...Ze?{personaId:Ze,isAgent:!0}:{}});n(`/work/${r.id}`)}return!0}catch(t){return H.error(ar(t,e(`work.toasts.runFailed`,{defaultValue:`Could not start the Work task.`}))),!1}},Mt=async t=>{let n=Kt.find(e=>e.key===t);if(n){if(!O){Se(t);return}try{await ie(O.id,{model:n.model,providerType:n.providerType,providerId:n.providerId})}catch(t){H.error(ar(t,e(`work.toasts.updateFailed`,{defaultValue:`Could not update this task.`})))}}},Nt=async()=>{if(O)try{await ce(O.id),H.success(e(`work.toasts.cancelled`,{defaultValue:`Work run stopped.`}))}catch(t){H.error(ar(t,e(`work.toasts.cancelFailed`,{defaultValue:`Could not stop the Work run.`})))}},Pt=async t=>{let i=D.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&&q;a&&ke(!1);try{await V(t),Ne(t),r===t&&n(`/work`)}catch(t){a&&ke(!0),H.error(ar(t,e(`work.toasts.deleteFailed`,{defaultValue:`Could not delete this Work task.`})))}},Ft=async t=>{if(!O)return!1;let n=t.trim();if(!n||n===O.title)return!!n;try{return await ie(O.id,{title:n}),!0}catch(t){return H.error(ar(t,e(`work.toasts.renameFailed`,{defaultValue:`Could not rename this task.`}))),!1}},It=async(e,t,n)=>{try{return await e(),n&&H.success(n),!0}catch(e){return H.error(ar(e,t)),!1}},Lt=async(t,n,r)=>{if(!O)return!1;let i=O.id;try{let a=await ve(i,t,n,r);return Oe.getState().selectedTaskId===i&&H.success(e(`work.toasts.saved`,{defaultValue:`File saved.`})),a}catch(t){return Oe.getState().selectedTaskId===i&&H.error(ar(t,e(`work.toasts.saveFailed`,{defaultValue:`Could not save this file.`}))),!1}},Rt=T?.available===!1,zt=e(`work.runtime.ready`,{defaultValue:`Runtime ready`}),Bt=T?.runtime===`kubernetes`?`Kubernetes · ${zt}`: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`}),Vt=O?Ke(O):!1,Ut=O?{model:O.model,providerType:O.providerType,providerId:O.providerId||void 0}:void 0,Wt=Ut?Ge(Ut):_t?.key||``,Gt=Ut&&!G.some(e=>e.key===Wt)?{...Ut,key:Wt,label:`${Ut.model} · ${Ut.providerType===`plugin`?Ut.providerId||`plugin`:`Ollama`}`,remote:Ut.providerType===`plugin`||Ut.model.toLowerCase().endsWith(`:cloud`)||Ut.model.toLowerCase().endsWith(`-cloud`)}:void 0,Kt=Gt?[Gt,...G]:G,qt=ze[O?.status??`idle`],Jt=e(qt.labelKey,{defaultValue:qt.label}),Yt=async()=>{if(u.workRemoteProviderDisclosureDismissed||g)return!1;let t=h;_(!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 H.error(e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`})),!1}finally{_(!1)}};return(0,X.jsx)(`div`,{"data-testid":`work-page`,className:`relative flex h-full min-h-0 overflow-hidden bg-transparent`,children:(0,X.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,X.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,X.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}Ft(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,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(`h1`,{className:`truncate text-sm font-semibold text-ink`,children:e(`work.title`,{defaultValue:`Work`})})}),O?.hostPath&&(0,X.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,X.jsx)(P,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),(0,X.jsx)(`span`,{className:`max-w-[16rem] truncate`,children:O.hostPath})]}),O&&(0,X.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,X.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,X.jsx)(`span`,{className:`hidden md:inline`,children:Jt})]}),O&&(0,X.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,X.jsxs)(`button`,{type:`button`,onClick:()=>De(`conversation`),"aria-label":e(`work.mobile.conversation`,{defaultValue:`Conversation`}),"aria-pressed":Ee===`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`,Ee===`conversation`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,X.jsx)(_e,{className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.conversation`,{defaultValue:`Conversation`})})]}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>De(`workspace`),"aria-label":e(`work.mobile.workspace`,{defaultValue:`Workspace`}),"aria-pressed":Ee===`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`,Ee===`workspace`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,X.jsx)(z,{className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.workspace`,{defaultValue:`Workspace`})})]})]}),(0,X.jsxs)(`div`,{className:l(`ms-auto hidden min-w-0 items-center gap-2`,O?`xl:flex`:`sm:flex`),children:[O&&(0,X.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,X.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,X.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`,Rt?`border-transparent bg-error-500 text-[#0D0D0C]`:`border-transparent bg-success-500 text-[#0D0D0C]`),title:Rt?T?.reason||e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):T?.image?`${Bt} · ${T.image}`:Bt,children:[(0,X.jsx)(ae,{className:`h-3.5 w-3.5`}),Rt?e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):zt]}),O&&(0,X.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,X.jsx)(x,{className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{dir:`ltr`,className:`truncate`,children:O.model})]})]}),O&&(0,X.jsxs)(`div`,{ref:ft,className:`relative shrink-0`,children:[(0,X.jsx)(`button`,{ref:pt,id:`work-task-actions-trigger`,type:`button`,"data-testid":`work-task-actions-button`,onClick:()=>ut(e=>({taskId:O.id,open:e.taskId!==O.id||!e.open})),onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),ut({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":dt,"aria-controls":dt?`work-task-actions-menu`:void 0,children:(0,X.jsx)(E,{className:`h-4 w-4`})}),dt&&(0,X.jsx)(`div`,{ref:mt,id:`work-task-actions-menu`,role:`menu`,"aria-labelledby":`work-task-actions-trigger`,onKeyDown:gt,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,X.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`work-delete-task-button`,onClick:()=>{ht(!0),Pt(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,X.jsx)(ge,{className:`h-3.5 w-3.5`}),e(`work.tasks.delete`,{defaultValue:`Delete task`})]})})]})]}),(Rt||I)&&(0,X.jsxs)(`div`,{className:l(`flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs`,Rt?`border-error-500/20 bg-error-500/10 text-error-700`:`border-amber-500/20 bg-amber-500/10 text-ink`),children:[(0,X.jsx)(m,{className:`h-4 w-4 shrink-0`}),(0,X.jsx)(`span`,{dir:`auto`,className:`min-w-0 flex-1`,children:Rt?T?.reason||e(`work.runtime.reason`,{defaultValue:`A Work runtime and an available Ollama or plugin model provider are required.`}):I}),I&&!Rt&&(0,X.jsx)(`button`,{type:`button`,className:`rounded-md p-1 hover:bg-black/5`,onClick:xe,"aria-label":e(`common.close`),children:`×`})]}),r?O?(0,X.jsx)(Ht,{userId:h,mobileSurface:Ee,conversation:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Et,{task:O,user:p,liveRun:St,loading:M,loadingOlder:ee,onLoadOlder:()=>ne(O.id),onOpenFile:Ie}),(0,X.jsx)(Ye,{dictationOwnerKey:O.id,mentionAgents:D.filter(e=>e.isAgent===!0&&e.id!==O.id).map(e=>({id:e.id,name:e.title})),models:Kt,selectorModels:U,modelKey:Wt,running:Vt,loading:F,disabled:Rt,remoteDisclosureDismissed:u.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:g,onModelChange:Mt,onDismissRemoteDisclosure:Yt,onModelsRefresh:w,onSubmit:jt,onCancel:Nt},O.id)]}),workspace:(0,X.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:(0,X.jsx)(rr,{task:O,openFileRequest:J?.taskId===O.id?J:null,persona:O.personaId?Je[O.personaId]:void 0,liveRun:St,files:k,selectedFile:A,loadingFiles:N,actionLoading:F,onLoadFiles:e=>pe(O.id,e),onLoadFile:e=>me(O.id,e),onClearSelectedFile:he,onSaveFile:Lt,onStartPreview:t=>It(()=>ye(O.id,t),e(`work.toasts.previewFailed`,{defaultValue:`Could not start the preview.`})),onStopPreview:()=>It(()=>be(O.id),e(`work.toasts.previewStopFailed`,{defaultValue:`Could not stop the preview.`})),onDirtyChange:ke,terminal:T?.terminal},O.id)})}):(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center`,children:M?(0,X.jsx)(`div`,{className:`text-sm text-ink-muted`,children:e(`work.tasks.loading`,{defaultValue:`Loading task…`})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(m,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,X.jsx)(`h2`,{className:`text-lg font-semibold text-ink`,children:e(`work.tasks.notFound`,{defaultValue:`This Work task is unavailable`})}),(0,X.jsxs)(`button`,{type:`button`,onClick:At,className:`mt-4 inline-flex items-center gap-1.5 text-sm font-medium text-primary-600 hover:text-primary-700`,children:[(0,X.jsx)(y,{className:`h-4 w-4 rtl:rotate-180`}),e(`work.tasks.back`,{defaultValue:`Start a new task`})]})]})}):(0,X.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-y-auto`,children:[(0,X.jsxs)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0`,children:[(0,X.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,X.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,X.jsx)(`div`,{className:`absolute left-1/2 top-0 h-16 w-px bg-gray-300/60 dark:bg-white/10`})]}),(0,X.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,X.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-center justify-center gap-3`,children:[(0,X.jsx)(Re,{size:`sm`,label:null,className:`h-9 w-9 shrink-0 p-0 text-ink`}),(0,X.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,X.jsx)(`p`,{className:`max-w-xl text-balance text-[15px] leading-relaxed text-ink-subtle`,children:e(`work.landing.description`,{defaultValue:`Give a local model a durable, isolated workspace. It can inspect files, run tools, and continue where it left off when you return.`})})]}),Ue.length>0&&(0,X.jsxs)(`div`,{className:`mt-8 w-full max-w-2xl`,children:[(0,X.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,X.jsxs)(`select`,{id:`work-policy`,"data-testid":`work-policy`,value:Z,onChange:e=>qe(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,X.jsx)(`option`,{value:``,children:e(`work.policy.default`,{defaultValue:`Default (global limits)`})}),Ue.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),$e.length>0&&(0,X.jsxs)(`div`,{className:`mt-8 w-full max-w-2xl`,children:[(0,X.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,X.jsxs)(`select`,{id:`work-persona`,"data-testid":`work-persona`,value:Ze,onChange:e=>Qe(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,X.jsx)(`option`,{value:``,children:e(`work.persona.none`,{defaultValue:`No persona (one-off task)`})}),$e.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,X.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-ink-subtle`,children:Ze?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.`})})]}),!at&&p?.role===`admin`&&(0,X.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,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-[13px] font-medium text-ink`,children:e(`work.computerSetup.title`)}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-muted`,children:rt??e(tt?`work.computerSetup.building`:`work.computerSetup.description`)})]}),(0,X.jsxs)(`button`,{type:`button`,"data-testid":`work-computer-enable`,onClick:()=>void ot(),disabled:tt,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:[tt&&(0,X.jsx)(`span`,{className:`h-3 w-3 animate-spin rounded-full border border-white/40 border-t-white`}),e(rt?`work.computerSetup.retry`:`work.computerSetup.enable`)]})]}),Ve&&(0,X.jsxs)(`div`,{className:`mt-8 w-full max-w-2xl`,children:[(0,X.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,X.jsx)(`input`,{id:`work-host-path`,"data-testid":`work-host-path`,value:Le,onChange:e=>Be(e.target.value),spellCheck:!1,placeholder:He[0]?`${He[0]}/my-project`:`/path/to/folder`,className:`w-full rounded-xl border border-line bg-surface px-3 py-2 font-mono text-[13px] text-ink outline-none transition-colors placeholder:text-ink-subtle focus:border-line-strong focus-visible:ring-2 focus-visible:ring-primary-500/30`}),(0,X.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-ink-subtle`,children:Le.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,X.jsx)(Ye,{variant:`landing`,dictationOwnerKey:`landing`,models:G,selectorModels:U,modelKey:_t?.key||``,running:!1,loading:F,disabled:Rt,remoteDisclosureDismissed:u.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:g,onModelChange:Mt,onDismissRemoteDisclosure:Yt,onModelsRefresh:w,onSubmit:jt,onCancel:Nt}),(0,X.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,X.jsx)(ae,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),(0,X.jsx)(`span`,{children:e(`work.composer.hint`,{defaultValue:`Each task keeps its own files and history. Review model output before using it.`})})]})]})]})]})})}export{sr as default};
|