agent-tower 0.7.1 → 0.7.2-beta.4
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/dist/executors/base.executor.d.ts.map +1 -1
- package/dist/executors/base.executor.js +6 -3
- package/dist/executors/base.executor.js.map +1 -1
- package/dist/routes/__tests__/workspaces.test.js +244 -0
- package/dist/routes/__tests__/workspaces.test.js.map +1 -1
- package/dist/routes/workspaces.d.ts.map +1 -1
- package/dist/routes/workspaces.js +11 -0
- package/dist/routes/workspaces.js.map +1 -1
- package/dist/runtime/__tests__/cli-driver-lifecycle.test.js +37 -0
- package/dist/runtime/__tests__/cli-driver-lifecycle.test.js.map +1 -1
- package/dist/runtime/__tests__/runtime-coordinator.test.js +13 -0
- package/dist/runtime/__tests__/runtime-coordinator.test.js.map +1 -1
- package/dist/runtime/cli-driver.js +17 -3
- package/dist/runtime/cli-driver.js.map +1 -1
- package/dist/runtime/contracts.d.ts +9 -2
- package/dist/runtime/contracts.d.ts.map +1 -1
- package/dist/runtime/runtime-coordinator.d.ts +2 -0
- package/dist/runtime/runtime-coordinator.d.ts.map +1 -1
- package/dist/runtime/runtime-coordinator.js +10 -0
- package/dist/runtime/runtime-coordinator.js.map +1 -1
- package/dist/services/__tests__/session-manager.lifecycle.test.js +67 -0
- package/dist/services/__tests__/session-manager.lifecycle.test.js.map +1 -1
- package/dist/services/__tests__/session-manager.team-run.test.js +41 -46
- package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -1
- package/dist/services/__tests__/team-reconciler.service.test.js +30 -0
- package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -1
- package/dist/services/project.service.d.ts.map +1 -1
- package/dist/services/project.service.js +30 -4
- package/dist/services/project.service.js.map +1 -1
- package/dist/services/session-manager.d.ts +1 -0
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +38 -3
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/session-runtime-cleanup-gate.d.ts +1 -0
- package/dist/services/session-runtime-cleanup-gate.d.ts.map +1 -1
- package/dist/services/session-runtime-cleanup-gate.js +5 -3
- package/dist/services/session-runtime-cleanup-gate.js.map +1 -1
- package/dist/services/team-reconciler.service.d.ts +1 -0
- package/dist/services/team-reconciler.service.d.ts.map +1 -1
- package/dist/services/team-reconciler.service.js +1 -0
- package/dist/services/team-reconciler.service.js.map +1 -1
- package/dist/services/workspace.service.d.ts +7 -1
- package/dist/services/workspace.service.d.ts.map +1 -1
- package/dist/services/workspace.service.js +111 -9
- package/dist/services/workspace.service.js.map +1 -1
- package/dist/utils/__tests__/spawned-process-identity.test.d.ts +2 -0
- package/dist/utils/__tests__/spawned-process-identity.test.d.ts.map +1 -0
- package/dist/utils/__tests__/spawned-process-identity.test.js +31 -0
- package/dist/utils/__tests__/spawned-process-identity.test.js.map +1 -0
- package/dist/utils/spawned-process-identity.d.ts +1 -1
- package/dist/utils/spawned-process-identity.d.ts.map +1 -1
- package/dist/utils/spawned-process-identity.js +11 -3
- package/dist/utils/spawned-process-identity.js.map +1 -1
- package/dist/web/assets/AgentDemoPage-Svq9Baa7.js +1 -0
- package/dist/web/assets/{AgentEnvironmentSettingsPage-b0XzUzna.js → AgentEnvironmentSettingsPage-DQjnDr-h.js} +1 -1
- package/dist/web/assets/AgentLogo-I2etsqym.js +1 -0
- package/dist/web/assets/BranchSelect-Eb5UGWWX.js +1 -0
- package/dist/web/assets/BrandLogo-BjC1hcgv.js +1 -0
- package/dist/web/assets/{ConversationPage-DQRA8WuD.js → ConversationPage-jEYUuSPT.js} +2 -2
- package/dist/web/assets/CreateTaskInput-B_cRDkVq.js +1 -0
- package/dist/web/assets/{DemoPage-DaDC_MIJ.js → DemoPage-BkkueMuL.js} +1 -1
- package/dist/web/assets/DesignSystemPage-oM16R2Ta.js +16 -0
- package/dist/web/assets/{ExecutionPermissionSelector-DglILGVC.js → ExecutionPermissionSelector-BX5Xx8ta.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-BKRf-usO.js → GeneralSettingsPage-B0jFlgDl.js} +1 -1
- package/dist/web/assets/{LoadingPreviewPage-BHAQCQDA.js → LoadingPreviewPage-BxjpxLLP.js} +1 -1
- package/dist/web/assets/McpSettingsPage-BErvd619.js +1 -0
- package/dist/web/assets/{MemberAvatar-DUXHTIXf.js → MemberAvatar-TVtoxQe8.js} +1 -1
- package/dist/web/assets/NotificationSettingsPage-BETMBdj1.js +1 -0
- package/dist/web/assets/{ProfileSettingsPage-DwziCseV.js → ProfileSettingsPage-C03ZAft-.js} +1 -1
- package/dist/web/assets/ProjectKanbanPage-DsPxwoVf.js +86 -0
- package/dist/web/assets/ProjectSettingsPage-BwNM6VWs.js +2 -0
- package/dist/web/assets/{ProviderSettingsPage-CC3zkdf6.js → ProviderSettingsPage-CeNQPd74.js} +3 -3
- package/dist/web/assets/{SettingsMasterDetail-D5lNH2f6.js → SettingsMasterDetail-B_SI2h_k.js} +1 -1
- package/dist/web/assets/TeamSettingsPage-BfgtMl_n.js +1 -0
- package/dist/web/assets/agent-meta-DOylIs2N.js +1 -0
- package/dist/web/assets/arc-BlZww3MO.js +1 -0
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-C_p9_AH2.js → architectureDiagram-3BPJPVTR-DWO_DRgk.js} +1 -1
- package/dist/web/assets/at-sign-BFf8Sz8T.js +1 -0
- package/dist/web/assets/{blockDiagram-GPEHLZMM-CKsR1Tax.js → blockDiagram-GPEHLZMM-CJPYhE52.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-BBUKt2FW.js → c4Diagram-AAUBKEIU-Cx5IvcjB.js} +1 -1
- package/dist/web/assets/channel-D9sA6Wxp.js +1 -0
- package/dist/web/assets/check-Cm7Vstpm.js +1 -0
- package/dist/web/assets/chevron-down-C6Ta4vyM.js +1 -0
- package/dist/web/assets/chevron-up-BwJT7iif.js +1 -0
- package/dist/web/assets/{chunk-2J33WTMH-BcGNhDoU.js → chunk-2J33WTMH-D9cBNYgd.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-9dL7TVjW.js → chunk-4BX2VUAB-BY8TNt6E.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-CzJzh0tH.js → chunk-55IACEB6-pT-HP-28.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-Bp5EOgoG.js → chunk-727SXJPM-hy95xDLb.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-BaLnh9ac.js → chunk-AQP2D5EJ-DlUN-icr.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-BcbzC8r4.js → chunk-FMBD7UC4-Dg2iMKZR.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-DkT5Stbd.js → chunk-ND2GUHAM-DMzFIsJ-.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-DszScpAV.js → chunk-QZHKN3VN-C6CgmKuM.js} +1 -1
- package/dist/web/assets/{circle-alert-ChWS5BPS.js → circle-alert-Dm2Pl-rU.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-2e2YVo9r.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-2e2YVo9r.js +1 -0
- package/dist/web/assets/code-block-OCS4YCEC-DizntuP_.js +2 -0
- package/dist/web/assets/{confirm-dialog-0vHzUzvI.js → confirm-dialog-DRpyE_qU.js} +1 -1
- package/dist/web/assets/copy-r0aUdsl8.js +1 -0
- package/dist/web/assets/{cose-bilkent-S5V4N54A-DueZsNr5.js → cose-bilkent-S5V4N54A-D-fvmvw-.js} +1 -1
- package/dist/web/assets/cssMode-DVorIr82.js +1 -0
- package/dist/web/assets/{dagre-BM42HDAG-BkQGrA8s.js → dagre-BM42HDAG-H0bYI1f3.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-D4qtEjjj.js → diagram-2AECGRRQ-DI568fLp.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-ZuFk-7GO.js → diagram-5GNKFQAL-BLcaBzw2.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-kwBr5lw0.js → diagram-KO2AKTUF-aL1cvl23.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-m88-mNyr.js → diagram-LMA3HP47-DbOutAfH.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-B9gV1dxA.js → diagram-OG6HWLK6-D_cWftAX.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-De_DsoOX.js → erDiagram-TEJ5UH35-DRe5V8Dx.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-9VwLS0b3.js → flowDiagram-I6XJVG4X-B5-vg_Nh.js} +1 -1
- package/dist/web/assets/{freemarker2-CLp1Yffb.js → freemarker2-CXlYb2yX.js} +3 -3
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-DoOyYr5i.js → ganttDiagram-6RSMTGT7-B3iBFICN.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-CMGuTxMz.js → gitGraphDiagram-PVQCEYII-CZ9zsKVw.js} +1 -1
- package/dist/web/assets/globe-JXfw4MCF.js +1 -0
- package/dist/web/assets/handlebars-BL0prPVZ.js +1 -0
- package/dist/web/assets/html-DJWeRkWe.js +1 -0
- package/dist/web/assets/htmlMode-D_fekqg9.js +1 -0
- package/dist/web/assets/{index-DI7lHrAR.js → index-CWEbo6pZ.js} +5 -5
- package/dist/web/assets/index-CWbMMO6g.js +122 -0
- package/dist/web/assets/index-uXglTJ2_.css +1 -0
- package/dist/web/assets/{infoDiagram-5YYISTIA-gUCDmQX7.js → infoDiagram-5YYISTIA-DQU_sN8x.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-CmfFhhIz.js → ishikawaDiagram-YF4QCWOH-BVGrNzJa.js} +1 -1
- package/dist/web/assets/javascript-CDfuzdfe.js +1 -0
- package/dist/web/assets/{journeyDiagram-JHISSGLW-BvV5GoR_.js → journeyDiagram-JHISSGLW-DU4Md1Tq.js} +1 -1
- package/dist/web/assets/{jsonMode-BbjYNQ7Q.js → jsonMode-BMSvHUHa.js} +4 -4
- package/dist/web/assets/{kanban-definition-UN3LZRKU-BpTm0MC-.js → kanban-definition-UN3LZRKU-DDPgCucq.js} +1 -1
- package/dist/web/assets/key-round-BHVp7u3Z.js +1 -0
- package/dist/web/assets/{layers-DslPQJ3T.js → layers-2tjjhM75.js} +1 -1
- package/dist/web/assets/{linear-BJ_g8wqu.js → linear-D8yLBTVY.js} +1 -1
- package/dist/web/assets/link-CnunXc7X.js +1 -0
- package/dist/web/assets/liquid-DHrNpv6c.js +1 -0
- package/dist/web/assets/{lspLanguageFeatures-PSX0tqnR.js → lspLanguageFeatures-BiYvrSP0.js} +1 -1
- package/dist/web/assets/mdx-CIEpgUOV.js +1 -0
- package/dist/web/assets/mermaid-NOHMQCX5-9-DTTfp6.js +124 -0
- package/dist/web/assets/{message-square-C-22K3oa.js → message-square-QM0c6Dcv.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-DS5GLydx.js → mindmap-definition-RKZ34NQL-CCAuuWFZ.js} +1 -1
- package/dist/web/assets/{modal-CFVLBZ5p.js → modal-BRoNvfhw.js} +1 -1
- package/dist/web/assets/{monaco-CkaUvvB4.js → monaco-CrBn9oMJ.js} +3 -3
- package/dist/web/assets/paperclip-CC7nHUQ7.js +1 -0
- package/dist/web/assets/pencil-DIY0Hu5t.js +1 -0
- package/dist/web/assets/{pieDiagram-4H26LBE5-C1PJJGsh.js → pieDiagram-4H26LBE5-CXy_N5QX.js} +2 -2
- package/dist/web/assets/play-CIZVXiwM.js +1 -0
- package/dist/web/assets/python-BIs0pClJ.js +1 -0
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-CzDfs-TQ.js → quadrantDiagram-W4KKPZXB-Dt44QsS8.js} +1 -1
- package/dist/web/assets/razor-JCx8NEwU.js +1 -0
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-qHbU7oZa.js → requirementDiagram-4Y6WPE33-BL8D7Np0.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-BfRgrEeN.js → sankeyDiagram-5OEKKPKP-I5nefO3A.js} +1 -1
- package/dist/web/assets/{select-CL78HCY0.js → select-BmjoUfrV.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-CGTNzKk3.js → sequenceDiagram-3UESZ5HK-lbPrhX8g.js} +1 -1
- package/dist/web/assets/server-BNBdQGor.js +1 -0
- package/dist/web/assets/stateDiagram-AJRCARHV-Bw3qtv2M.js +1 -0
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Xbc4HxDQ.js +1 -0
- package/dist/web/assets/{switch-DmQ0Brgd.js → switch-CEUHI4gI.js} +1 -1
- package/dist/web/assets/task-kalEmHDc.js +42 -0
- package/dist/web/assets/task-priority-wLXAgVZZ.js +1 -0
- package/dist/web/assets/{textarea-DOte4pMQ.js → textarea-CD82lB0Z.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-BBhCKsly.js → timeline-definition-PNZ67QCA-Cfg_kgoa.js} +1 -1
- package/dist/web/assets/{trash-2-BSAHXKfW.js → trash-2-BF_3L-qk.js} +1 -1
- package/dist/web/assets/{tsMode-B6rHoWny.js → tsMode-DAHSkTAr.js} +2 -2
- package/dist/web/assets/typescript-CptiLWGr.js +1 -0
- package/dist/web/assets/{upload-e87qV_RH.js → upload-B2AMXrU-.js} +1 -1
- package/dist/web/assets/{use-profiles-Cv2zBJOC.js → use-profiles-CQ-jIuiI.js} +1 -1
- package/dist/web/assets/use-projects-BYUZwQ-q.js +1 -0
- package/dist/web/assets/{use-providers-CnpIgITQ.js → use-providers-DdV9gbj1.js} +1 -1
- package/dist/web/assets/useNormalizedLogs-DdFsf-Z1.js +1 -0
- package/dist/web/assets/{vennDiagram-CIIHVFJN-DrDrt_Jg.js → vennDiagram-CIIHVFJN-CdEP03CK.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-CMYQm14y.js → wardley-L42UT6IY-q_Enplrs.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-COLA9A80.js → wardleyDiagram-YWT4CUSO-DlL6fsid.js} +1 -1
- package/dist/web/assets/xml-DbPqkgZW.js +1 -0
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-BDegkKoT.js → xychartDiagram-2RQKCTM6-B2OGqVKA.js} +1 -1
- package/dist/web/assets/yaml-Deyq6Z5-.js +1 -0
- package/dist/web/index.html +2 -2
- package/node_modules/@agent-tower/shared/dist/socket/events.d.ts +2 -2
- package/node_modules/@agent-tower/shared/dist/socket/events.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.d.ts +19 -2
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/dist/web/assets/AgentDemoPage-Gr8q6VxC.js +0 -1
- package/dist/web/assets/AgentLogo-q8Chady2.js +0 -1
- package/dist/web/assets/CreateTaskInput-Dr6Lvllw.js +0 -1
- package/dist/web/assets/Icons-7lThaqQv.js +0 -1
- package/dist/web/assets/McpSettingsPage-CVOEPwCv.js +0 -1
- package/dist/web/assets/NotificationSettingsPage-DBe1YCNN.js +0 -1
- package/dist/web/assets/ProjectKanbanPage-Dcz8KXWU.js +0 -86
- package/dist/web/assets/ProjectSettingsPage-hzSrj79M.js +0 -2
- package/dist/web/assets/TeamSettingsPage-Cdbvh2ne.js +0 -1
- package/dist/web/assets/arc-d2D24uRQ.js +0 -1
- package/dist/web/assets/channel-D0hF47LU.js +0 -1
- package/dist/web/assets/check-BqhuHtHP.js +0 -1
- package/dist/web/assets/chevron-down-Bw_76CB_.js +0 -1
- package/dist/web/assets/chevron-right-DbcFf_Dw.js +0 -1
- package/dist/web/assets/chevron-up-x1n3MhC-.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-ulXJsBKw.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-ulXJsBKw.js +0 -1
- package/dist/web/assets/code-block-OCS4YCEC-G8tEtSdL.js +0 -2
- package/dist/web/assets/cssMode-Dqx3XDOC.js +0 -1
- package/dist/web/assets/folder-picker-B0khMt7A.js +0 -1
- package/dist/web/assets/handlebars-CmLfR6Uy.js +0 -1
- package/dist/web/assets/html-D34UDOLc.js +0 -1
- package/dist/web/assets/htmlMode-qjrvkZFJ.js +0 -1
- package/dist/web/assets/index-DrzmyANC.js +0 -122
- package/dist/web/assets/index-MMCbS8_L.css +0 -1
- package/dist/web/assets/javascript-D5tp0LcO.js +0 -1
- package/dist/web/assets/liquid-DBu3_6XS.js +0 -1
- package/dist/web/assets/mdx-Bb4nrA8s.js +0 -1
- package/dist/web/assets/mermaid-NOHMQCX5-B44shuzc.js +0 -124
- package/dist/web/assets/pencil-DB3VPszm.js +0 -1
- package/dist/web/assets/python-BfodDYt4.js +0 -1
- package/dist/web/assets/razor-DdED1MBH.js +0 -1
- package/dist/web/assets/server-Cd7APx6v.js +0 -1
- package/dist/web/assets/stateDiagram-AJRCARHV-BY1LJ4b7.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BV_JKRZC.js +0 -1
- package/dist/web/assets/typescript-C2A3q8UY.js +0 -1
- package/dist/web/assets/use-projects-C8WDJXdj.js +0 -1
- package/dist/web/assets/useNormalizedLogs-AbIXa8s-.js +0 -1
- package/dist/web/assets/xml-D4xDxfjR.js +0 -1
- package/dist/web/assets/yaml-yJExA7tq.js +0 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-CrBn9oMJ.js","assets/index-CWbMMO6g.js","assets/index-uXglTJ2_.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{as as yd,at as _o,au as Sd,av as wd,aw as Cd,c as et,r as _,ax as ue,D as ws,u as ce,j as t,l as Z,ar as kd,a3 as Ua,a8 as Ed,a1 as Us,B as je,ay as $a,az as Ka,aA as qa,aj as Es,X as Xt,aB as Tn,aC as jd,P as Cr,aD as Nd,E as Rd,aE as Ad,aF as Td,aG as Md,T as Ns,t as Je,_ as ls,$ as dt,a0 as Fs,p as Ae,m as Pt,o as Lt,q as be,V as Be,a9 as Rs,Z as fr,n as kr,aH as Dd,ad as Xs,aI as Er,ak as Pd,af as Va,s as $s,a7 as Tt,ai as Ld,aJ as Ya,aK as Mn,W as Id,aL as Xa,aM as Ga,aN as Qa,aO as Za,aP as Od,aQ as Bd,ab as Fd,aR as zd,aS as Wd,aT as Hd,a5 as yo,a6 as So}from"./index-CWbMMO6g.js";import{S as ut,C as Nt,T as Jr,F as Ja,e as Mt,W as xt,f as xr,A as Et,h as Vt}from"./agent-meta-DOylIs2N.js";import{C as Dn}from"./confirm-dialog-DRpyE_qU.js";import{a as Pn,g as el,u as Ud,b as $d,B as Kd,c as Ln,d as tl,e as sl,f as In,h as qd,i as rl,j as On,k as Vd,F as Yd}from"./BranchSelect-Eb5UGWWX.js";import{f as Ks,U as Ee,g as Xd,a as Gd,F as Qd}from"./task-kalEmHDc.js";import{c as wo,u as Bn,Z as Zd,d as Fn,T as zn,e as Jd,f as Wn,g as Co,h as eu,b as il,i as nl,a as ol,j as al,k as ll,R as cl,P as dl,S as ei,l as tu,C as ko}from"./CreateTaskInput-B_cRDkVq.js";import{T as su,S as Hn,A as br,a as Un,G as ul,F as $n}from"./task-priority-wLXAgVZZ.js";import{C as Wt}from"./check-Cm7Vstpm.js";import{T as gi,P as ds}from"./trash-2-BF_3L-qk.js";import{S as ru,B as Eo}from"./BrandLogo-BjC1hcgv.js";import{M as vi}from"./message-square-QM0c6Dcv.js";import{L as qs}from"./layers-2tjjhM75.js";import{u as Kn,A as qn,d as iu,p as nu,e as ou,f as au,Q as Vn,h as lu,i as hl,r as $r,j as cu,k as du,l as uu,T as hu,a as ti,m as fl}from"./mermaid-NOHMQCX5-9-DTTfp6.js";import{C as fu,u as ml,a as pl,L as si,T as ri}from"./useNormalizedLogs-DdFsf-Z1.js";import{a as es,l as mu,g as gl}from"./ExecutionPermissionSelector-BX5Xx8ta.js";import{u as Gs}from"./use-providers-DdV9gbj1.js";import{A as xi}from"./AgentLogo-I2etsqym.js";import{M as Yt}from"./MemberAvatar-TVtoxQe8.js";import{C as Ct}from"./chevron-down-C6Ta4vyM.js";import{C as vl}from"./chevron-up-BwJT7iif.js";import{A as jo}from"./at-sign-BFf8Sz8T.js";import{P as Yn}from"./paperclip-CC7nHUQ7.js";import{M as ps}from"./modal-BRoNvfhw.js";import{S as cs}from"./select-BmjoUfrV.js";import{T as pu}from"./textarea-CD82lB0Z.js";import{P as Cs,F as bi,H as Vs,C as _i}from"./play-CIZVXiwM.js";import{S as fn}from"./server-BNBdQGor.js";import{U as ii}from"./upload-B2AMXrU-.js";import{e as gu,d as vu,f as xu,a as bu}from"./use-projects-BYUZwQ-q.js";import{G as xl}from"./globe-JXfw4MCF.js";import{P as _u}from"./pencil-DIY0Hu5t.js";import{C as No}from"./copy-r0aUdsl8.js";var yu=class extends yd{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:_o()})}getOptimisticResult(e){return e.behavior=_o(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,s){const{state:r}=e,o=super.createResult(e,s),{isFetching:p,isRefetching:m,isError:x,isRefetchError:i}=o,n=r.fetchMeta?.fetchMore?.direction,a=x&&n==="forward",d=p&&n==="forward",c=x&&n==="backward",g=p&&n==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:wd(s,r.data),hasPreviousPage:Sd(s,r.data),isFetchNextPageError:a,isFetchingNextPage:d,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:i&&!a&&!c,isRefetching:m&&!d&&!g}}};function Xn(e,s){return Cd(e,yu)}const Su=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],bl=et("arrow-right",Su);const wu=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],_l=et("ban",wu);const Cu=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ku=et("chevron-left",Cu);const Eu=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],ju=et("clipboard-paste",Eu);const Nu=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],us=et("clock-3",Nu);const Ru=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Ro=et("copy-plus",Ru);const Au=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Tu=et("earth",Au);const Mu=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],yl=et("ellipsis-vertical",Mu);const Du=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],Pu=et("file-braces-corner",Du);const Lu=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],ni=et("file-code-corner",Lu);const Iu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ou=et("file-exclamation-point",Iu);const Bu=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],Qs=et("git-graph",Bu);const Fu=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],zu=et("maximize",Fu);const Wu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],Hu=et("panel-left-close",Wu);const Uu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],$u=et("panel-left-open",Uu);const Ku=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],qu=et("panel-right-close",Ku);const Vu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],mn=et("panel-right-open",Vu);const Yu=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Xu=et("pen-line",Yu);const Gu=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Sl=et("settings-2",Gu);const Qu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Ao=et("smartphone",Qu);const Zu=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Kr=et("user-plus",Zu);const Ju=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],eh=et("zoom-in",Ju);const th=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],sh=et("zoom-out",th),yi=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Zs(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function Gn(e){return"nodeType"in e}function yt(e){var s,r;return e?Zs(e)?e:Gn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Qn(e){const{Document:s}=yt(e);return e instanceof s}function jr(e){return Zs(e)?!1:e instanceof yt(e).HTMLElement}function wl(e){return e instanceof yt(e).SVGElement}function Js(e){return e?Zs(e)?e.document:Gn(e)?Qn(e)?e:jr(e)||wl(e)?e.ownerDocument:document:document:document}const ts=yi?_.useLayoutEffect:_.useEffect;function Si(e){const s=_.useRef(e);return ts(()=>{s.current=e}),_.useCallback(function(){for(var r=arguments.length,o=new Array(r),p=0;p<r;p++)o[p]=arguments[p];return s.current==null?void 0:s.current(...o)},[])}function rh(){const e=_.useRef(null),s=_.useCallback((o,p)=>{e.current=setInterval(o,p)},[]),r=_.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function _r(e,s){s===void 0&&(s=[e]);const r=_.useRef(e);return ts(()=>{r.current!==e&&(r.current=e)},s),r}function Nr(e,s){const r=_.useRef();return _.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function oi(e){const s=Si(e),r=_.useRef(null),o=_.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function ai(e){const s=_.useRef();return _.useEffect(()=>{s.current=e},[e]),s.current}let Wi={};function wi(e,s){return _.useMemo(()=>{if(s)return s;const r=Wi[e]==null?0:Wi[e]+1;return Wi[e]=r,e+"-"+r},[e,s])}function Cl(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),p=1;p<r;p++)o[p-1]=arguments[p];return o.reduce((m,x)=>{const i=Object.entries(x);for(const[n,a]of i){const d=m[n];d!=null&&(m[n]=d+e*a)}return m},{...s})}}const Hs=Cl(1),li=Cl(-1);function ih(e){return"clientX"in e&&"clientY"in e}function Zn(e){if(!e)return!1;const{KeyboardEvent:s}=yt(e.target);return s&&e instanceof s}function nh(e){if(!e)return!1;const{TouchEvent:s}=yt(e.target);return s&&e instanceof s}function ci(e){if(nh(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return ih(e)?{x:e.clientX,y:e.clientY}:null}const yr=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[yr.Translate.toString(e),yr.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),To="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function oh(e){return e.matches(To)?e:e.querySelector(To)}const ah={display:"none"};function lh(e){let{id:s,value:r}=e;return ue.createElement("div",{id:s,style:ah},r)}function ch(e){let{id:s,announcement:r,ariaLiveType:o="assertive"}=e;const p={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ue.createElement("div",{id:s,style:p,role:"status","aria-live":o,"aria-atomic":!0},r)}function dh(){const[e,s]=_.useState("");return{announce:_.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const kl=_.createContext(null);function uh(e){const s=_.useContext(kl);_.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function hh(){const[e]=_.useState(()=>new Set),s=_.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[_.useCallback(o=>{let{type:p,event:m}=o;e.forEach(x=>{var i;return(i=x[p])==null?void 0:i.call(x,m)})},[e]),s]}const fh={draggable:`
|
|
3
|
+
To pick up a draggable item, press the space bar.
|
|
4
|
+
While dragging, use the arrow keys to move the item.
|
|
5
|
+
Press space again to drop the item in its new position, or press escape to cancel.
|
|
6
|
+
`},mh={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function ph(e){let{announcements:s=mh,container:r,hiddenTextDescribedById:o,screenReaderInstructions:p=fh}=e;const{announce:m,announcement:x}=dh(),i=wi("DndLiveRegion"),[n,a]=_.useState(!1);if(_.useEffect(()=>{a(!0)},[]),uh(_.useMemo(()=>({onDragStart(c){let{active:g}=c;m(s.onDragStart({active:g}))},onDragMove(c){let{active:g,over:v}=c;s.onDragMove&&m(s.onDragMove({active:g,over:v}))},onDragOver(c){let{active:g,over:v}=c;m(s.onDragOver({active:g,over:v}))},onDragEnd(c){let{active:g,over:v}=c;m(s.onDragEnd({active:g,over:v}))},onDragCancel(c){let{active:g,over:v}=c;m(s.onDragCancel({active:g,over:v}))}}),[m,s])),!n)return null;const d=ue.createElement(ue.Fragment,null,ue.createElement(lh,{id:o,value:p.draggable}),ue.createElement(ch,{id:i,announcement:x}));return r?ws.createPortal(d,r):d}var ct;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ct||(ct={}));function di(){}function gh(e,s){return _.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function vh(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return _.useMemo(()=>[...s].filter(o=>o!=null),[...s])}const Ht=Object.freeze({x:0,y:0});function xh(e,s){const r=ci(e);if(!r)return"0 0";const o={x:(r.x-s.left)/s.width*100,y:(r.y-s.top)/s.height*100};return o.x+"% "+o.y+"%"}function bh(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function _h(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function yh(e,s){const r=Math.max(s.top,e.top),o=Math.max(s.left,e.left),p=Math.min(s.left+s.width,e.left+e.width),m=Math.min(s.top+s.height,e.top+e.height),x=p-o,i=m-r;if(o<p&&r<m){const n=s.width*s.height,a=e.width*e.height,d=x*i,c=d/(n+a-d);return Number(c.toFixed(4))}return 0}const Sh=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:o}=e;const p=[];for(const m of o){const{id:x}=m,i=r.get(x);if(i){const n=yh(i,s);n>0&&p.push({id:x,data:{droppableContainer:m,value:n}})}}return p.sort(bh)};function wh(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function El(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Ht}function Ch(e){return function(r){for(var o=arguments.length,p=new Array(o>1?o-1:0),m=1;m<o;m++)p[m-1]=arguments[m];return p.reduce((x,i)=>({...x,top:x.top+e*i.y,bottom:x.bottom+e*i.y,left:x.left+e*i.x,right:x.right+e*i.x}),{...r})}}const kh=Ch(1);function jl(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function Eh(e,s,r){const o=jl(s);if(!o)return e;const{scaleX:p,scaleY:m,x,y:i}=o,n=e.left-x-(1-p)*parseFloat(r),a=e.top-i-(1-m)*parseFloat(r.slice(r.indexOf(" ")+1)),d=p?e.width/p:e.width,c=m?e.height/m:e.height;return{width:d,height:c,top:a,right:n+d,bottom:a+c,left:n}}const jh={ignoreTransform:!1};function Rr(e,s){s===void 0&&(s=jh);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:a,transformOrigin:d}=yt(e).getComputedStyle(e);a&&(r=Eh(r,a,d))}const{top:o,left:p,width:m,height:x,bottom:i,right:n}=r;return{top:o,left:p,width:m,height:x,bottom:i,right:n}}function Mo(e){return Rr(e,{ignoreTransform:!0})}function Nh(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function Rh(e,s){return s===void 0&&(s=yt(e).getComputedStyle(e)),s.position==="fixed"}function Ah(e,s){s===void 0&&(s=yt(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(p=>{const m=s[p];return typeof m=="string"?r.test(m):!1})}function Jn(e,s){const r=[];function o(p){if(s!=null&&r.length>=s||!p)return r;if(Qn(p)&&p.scrollingElement!=null&&!r.includes(p.scrollingElement))return r.push(p.scrollingElement),r;if(!jr(p)||wl(p)||r.includes(p))return r;const m=yt(e).getComputedStyle(p);return p!==e&&Ah(p,m)&&r.push(p),Rh(p,m)?r:o(p.parentNode)}return e?o(e):r}function Nl(e){const[s]=Jn(e,1);return s??null}function Hi(e){return!yi||!e?null:Zs(e)?e:Gn(e)?Qn(e)||e===Js(e).scrollingElement?window:jr(e)?e:null:null}function Rl(e){return Zs(e)?e.scrollX:e.scrollLeft}function Al(e){return Zs(e)?e.scrollY:e.scrollTop}function pn(e){return{x:Rl(e),y:Al(e)}}var ht;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ht||(ht={}));function Tl(e){return!yi||!e?!1:e===document.scrollingElement}function Ml(e){const s={x:0,y:0},r=Tl(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},p=e.scrollTop<=s.y,m=e.scrollLeft<=s.x,x=e.scrollTop>=o.y,i=e.scrollLeft>=o.x;return{isTop:p,isLeft:m,isBottom:x,isRight:i,maxScroll:o,minScroll:s}}const Th={x:.2,y:.2};function Mh(e,s,r,o,p){let{top:m,left:x,right:i,bottom:n}=r;o===void 0&&(o=10),p===void 0&&(p=Th);const{isTop:a,isBottom:d,isLeft:c,isRight:g}=Ml(e),v={x:0,y:0},b={x:0,y:0},y={height:s.height*p.y,width:s.width*p.x};return!a&&m<=s.top+y.height?(v.y=ht.Backward,b.y=o*Math.abs((s.top+y.height-m)/y.height)):!d&&n>=s.bottom-y.height&&(v.y=ht.Forward,b.y=o*Math.abs((s.bottom-y.height-n)/y.height)),!g&&i>=s.right-y.width?(v.x=ht.Forward,b.x=o*Math.abs((s.right-y.width-i)/y.width)):!c&&x<=s.left+y.width&&(v.x=ht.Backward,b.x=o*Math.abs((s.left+y.width-x)/y.width)),{direction:v,speed:b}}function Dh(e){if(e===document.scrollingElement){const{innerWidth:m,innerHeight:x}=window;return{top:0,left:0,right:m,bottom:x,width:m,height:x}}const{top:s,left:r,right:o,bottom:p}=e.getBoundingClientRect();return{top:s,left:r,right:o,bottom:p,width:e.clientWidth,height:e.clientHeight}}function Dl(e){return e.reduce((s,r)=>Hs(s,pn(r)),Ht)}function Ph(e){return e.reduce((s,r)=>s+Rl(r),0)}function Lh(e){return e.reduce((s,r)=>s+Al(r),0)}function Pl(e,s){if(s===void 0&&(s=Rr),!e)return;const{top:r,left:o,bottom:p,right:m}=s(e);Nl(e)&&(p<=0||m<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Ih=[["x",["left","right"],Ph],["y",["top","bottom"],Lh]];class eo{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const o=Jn(r),p=Dl(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[m,x,i]of Ih)for(const n of x)Object.defineProperty(this,n,{get:()=>{const a=i(o),d=p[m]-a;return this.rect[n]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class mr{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...r)})},this.target=s}add(s,r,o){var p;(p=this.target)==null||p.addEventListener(s,r,o),this.listeners.push([s,r,o])}}function Oh(e){const{EventTarget:s}=yt(e);return e instanceof s?e:Js(e)}function Ui(e,s){const r=Math.abs(e.x),o=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+o**2)>s:"x"in s&&"y"in s?r>s.x&&o>s.y:"x"in s?r>s.x:"y"in s?o>s.y:!1}var At;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(At||(At={}));function Do(e){e.preventDefault()}function Bh(e){e.stopPropagation()}var qe;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(qe||(qe={}));const Ll={start:[qe.Space,qe.Enter],cancel:[qe.Esc],end:[qe.Space,qe.Enter,qe.Tab]},Fh=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case qe.Right:return{...r,x:r.x+25};case qe.Left:return{...r,x:r.x-25};case qe.Down:return{...r,y:r.y+25};case qe.Up:return{...r,y:r.y-25}}};class Il{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new mr(Js(r)),this.windowListeners=new mr(yt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(At.Resize,this.handleCancel),this.windowListeners.add(At.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(At.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&Pl(o),r(Ht)}handleKeyDown(s){if(Zn(s)){const{active:r,context:o,options:p}=this.props,{keyboardCodes:m=Ll,coordinateGetter:x=Fh,scrollBehavior:i="smooth"}=p,{code:n}=s;if(m.end.includes(n)){this.handleEnd(s);return}if(m.cancel.includes(n)){this.handleCancel(s);return}const{collisionRect:a}=o.current,d=a?{x:a.left,y:a.top}:Ht;this.referenceCoordinates||(this.referenceCoordinates=d);const c=x(s,{active:r,context:o.current,currentCoordinates:d});if(c){const g=li(c,d),v={x:0,y:0},{scrollableAncestors:b}=o.current;for(const y of b){const l=s.code,{isTop:h,isRight:u,isLeft:f,isBottom:S,maxScroll:C,minScroll:k}=Ml(y),E=Dh(y),w={x:Math.min(l===qe.Right?E.right-E.width/2:E.right,Math.max(l===qe.Right?E.left:E.left+E.width/2,c.x)),y:Math.min(l===qe.Down?E.bottom-E.height/2:E.bottom,Math.max(l===qe.Down?E.top:E.top+E.height/2,c.y))},j=l===qe.Right&&!u||l===qe.Left&&!f,A=l===qe.Down&&!S||l===qe.Up&&!h;if(j&&w.x!==c.x){const D=y.scrollLeft+g.x,T=l===qe.Right&&D<=C.x||l===qe.Left&&D>=k.x;if(T&&!g.y){y.scrollTo({left:D,behavior:i});return}T?v.x=y.scrollLeft-D:v.x=l===qe.Right?y.scrollLeft-C.x:y.scrollLeft-k.x,v.x&&y.scrollBy({left:-v.x,behavior:i});break}else if(A&&w.y!==c.y){const D=y.scrollTop+g.y,T=l===qe.Down&&D<=C.y||l===qe.Up&&D>=k.y;if(T&&!g.x){y.scrollTo({top:D,behavior:i});return}T?v.y=y.scrollTop-D:v.y=l===qe.Down?y.scrollTop-C.y:y.scrollTop-k.y,v.y&&y.scrollBy({top:-v.y,behavior:i});break}}this.handleMove(s,Hs(li(c,this.referenceCoordinates),v))}}}handleMove(s,r){const{onMove:o}=this.props;s.preventDefault(),o(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Il.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=Ll,onActivation:p}=s,{active:m}=r;const{code:x}=e.nativeEvent;if(o.start.includes(x)){const i=m.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),p?.({event:e.nativeEvent}),!0)}return!1}}];function Po(e){return!!(e&&"distance"in e)}function Lo(e){return!!(e&&"delay"in e)}class to{constructor(s,r,o){var p;o===void 0&&(o=Oh(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:m}=s,{target:x}=m;this.props=s,this.events=r,this.document=Js(x),this.documentListeners=new mr(this.document),this.listeners=new mr(o),this.windowListeners=new mr(yt(x)),this.initialCoordinates=(p=ci(m))!=null?p:Ht,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:o}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(At.Resize,this.handleCancel),this.windowListeners.add(At.DragStart,Do),this.windowListeners.add(At.VisibilityChange,this.handleCancel),this.windowListeners.add(At.ContextMenu,Do),this.documentListeners.add(At.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Lo(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Po(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:o,onPending:p}=this.props;p(o,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(At.Click,Bh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(At.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:o,initialCoordinates:p,props:m}=this,{onMove:x,options:{activationConstraint:i}}=m;if(!p)return;const n=(r=ci(s))!=null?r:Ht,a=li(p,n);if(!o&&i){if(Po(i)){if(i.tolerance!=null&&Ui(a,i.tolerance))return this.handleCancel();if(Ui(a,i.distance))return this.handleStart()}if(Lo(i)&&Ui(a,i.tolerance))return this.handleCancel();this.handlePending(i,a);return}s.cancelable&&s.preventDefault(),x(n)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===qe.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const zh={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class so extends to{constructor(s){const{event:r}=s,o=Js(r.target);super(s,zh,o)}}so.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return!r.isPrimary||r.button!==0?!1:(o?.({event:r}),!0)}}];const Wh={move:{name:"mousemove"},end:{name:"mouseup"}};var gn;(function(e){e[e.RightClick=2]="RightClick"})(gn||(gn={}));class Hh extends to{constructor(s){super(s,Wh,Js(s.event.target))}}Hh.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===gn.RightClick?!1:(o?.({event:r}),!0)}}];const $i={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Uh extends to{constructor(s){super(s,$i)}static setup(){return window.addEventListener($i.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener($i.move.name,s)};function s(){}}}Uh.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;const{touches:p}=r;return p.length>1?!1:(o?.({event:r}),!0)}}];var pr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(pr||(pr={}));var ui;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ui||(ui={}));function $h(e){let{acceleration:s,activator:r=pr.Pointer,canScroll:o,draggingRect:p,enabled:m,interval:x=5,order:i=ui.TreeOrder,pointerCoordinates:n,scrollableAncestors:a,scrollableAncestorRects:d,delta:c,threshold:g}=e;const v=qh({delta:c,disabled:!m}),[b,y]=rh(),l=_.useRef({x:0,y:0}),h=_.useRef({x:0,y:0}),u=_.useMemo(()=>{switch(r){case pr.Pointer:return n?{top:n.y,bottom:n.y,left:n.x,right:n.x}:null;case pr.DraggableRect:return p}},[r,p,n]),f=_.useRef(null),S=_.useCallback(()=>{const k=f.current;if(!k)return;const E=l.current.x*h.current.x,w=l.current.y*h.current.y;k.scrollBy(E,w)},[]),C=_.useMemo(()=>i===ui.TreeOrder?[...a].reverse():a,[i,a]);_.useEffect(()=>{if(!m||!a.length||!u){y();return}for(const k of C){if(o?.(k)===!1)continue;const E=a.indexOf(k),w=d[E];if(!w)continue;const{direction:j,speed:A}=Mh(k,w,u,s,g);for(const D of["x","y"])v[D][j[D]]||(A[D]=0,j[D]=0);if(A.x>0||A.y>0){y(),f.current=k,b(S,x),l.current=A,h.current=j;return}}l.current={x:0,y:0},h.current={x:0,y:0},y()},[s,S,o,y,m,x,JSON.stringify(u),JSON.stringify(v),b,a,C,d,JSON.stringify(g)])}const Kh={x:{[ht.Backward]:!1,[ht.Forward]:!1},y:{[ht.Backward]:!1,[ht.Forward]:!1}};function qh(e){let{delta:s,disabled:r}=e;const o=ai(s);return Nr(p=>{if(r||!o||!p)return Kh;const m={x:Math.sign(s.x-o.x),y:Math.sign(s.y-o.y)};return{x:{[ht.Backward]:p.x[ht.Backward]||m.x===-1,[ht.Forward]:p.x[ht.Forward]||m.x===1},y:{[ht.Backward]:p.y[ht.Backward]||m.y===-1,[ht.Forward]:p.y[ht.Forward]||m.y===1}}},[r,s,o])}function Vh(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return Nr(p=>{var m;return s==null?null:(m=o??p)!=null?m:null},[o,s])}function Yh(e,s){return _.useMemo(()=>e.reduce((r,o)=>{const{sensor:p}=o,m=p.activators.map(x=>({eventName:x.eventName,handler:s(x.handler,o)}));return[...r,...m]},[]),[e,s])}var Sr;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Sr||(Sr={}));var vn;(function(e){e.Optimized="optimized"})(vn||(vn={}));const Io=new Map;function Xh(e,s){let{dragging:r,dependencies:o,config:p}=s;const[m,x]=_.useState(null),{frequency:i,measure:n,strategy:a}=p,d=_.useRef(e),c=l(),g=_r(c),v=_.useCallback(function(h){h===void 0&&(h=[]),!g.current&&x(u=>u===null?h:u.concat(h.filter(f=>!u.includes(f))))},[g]),b=_.useRef(null),y=Nr(h=>{if(c&&!r)return Io;if(!h||h===Io||d.current!==e||m!=null){const u=new Map;for(let f of e){if(!f)continue;if(m&&m.length>0&&!m.includes(f.id)&&f.rect.current){u.set(f.id,f.rect.current);continue}const S=f.node.current,C=S?new eo(n(S),S):null;f.rect.current=C,C&&u.set(f.id,C)}return u}return h},[e,m,r,c,n]);return _.useEffect(()=>{d.current=e},[e]),_.useEffect(()=>{c||v()},[r,c]),_.useEffect(()=>{m&&m.length>0&&x(null)},[JSON.stringify(m)]),_.useEffect(()=>{c||typeof i!="number"||b.current!==null||(b.current=setTimeout(()=>{v(),b.current=null},i))},[i,c,v,...o]),{droppableRects:y,measureDroppableContainers:v,measuringScheduled:m!=null};function l(){switch(a){case Sr.Always:return!1;case Sr.BeforeDragging:return r;default:return!r}}}function ro(e,s){return Nr(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function Gh(e,s){return ro(e,s)}function Qh(e){let{callback:s,disabled:r}=e;const o=Si(s),p=_.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:m}=window;return new m(o)},[o,r]);return _.useEffect(()=>()=>p?.disconnect(),[p]),p}function Ci(e){let{callback:s,disabled:r}=e;const o=Si(s),p=_.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:m}=window;return new m(o)},[r]);return _.useEffect(()=>()=>p?.disconnect(),[p]),p}function Zh(e){return new eo(Rr(e),e)}function Oo(e,s,r){s===void 0&&(s=Zh);const[o,p]=_.useState(null);function m(){p(n=>{if(!e)return null;if(e.isConnected===!1){var a;return(a=n??r)!=null?a:null}const d=s(e);return JSON.stringify(n)===JSON.stringify(d)?n:d})}const x=Qh({callback(n){if(e)for(const a of n){const{type:d,target:c}=a;if(d==="childList"&&c instanceof HTMLElement&&c.contains(e)){m();break}}}}),i=Ci({callback:m});return ts(()=>{m(),e?(i?.observe(e),x?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),x?.disconnect())},[e]),o}function Jh(e){const s=ro(e);return El(e,s)}const Bo=[];function ef(e){const s=_.useRef(e),r=Nr(o=>e?o&&o!==Bo&&e&&s.current&&e.parentNode===s.current.parentNode?o:Jn(e):Bo,[e]);return _.useEffect(()=>{s.current=e},[e]),r}function tf(e){const[s,r]=_.useState(null),o=_.useRef(e),p=_.useCallback(m=>{const x=Hi(m.target);x&&r(i=>i?(i.set(x,pn(x)),new Map(i)):null)},[]);return _.useEffect(()=>{const m=o.current;if(e!==m){x(m);const i=e.map(n=>{const a=Hi(n);return a?(a.addEventListener("scroll",p,{passive:!0}),[a,pn(a)]):null}).filter(n=>n!=null);r(i.length?new Map(i):null),o.current=e}return()=>{x(e),x(m)};function x(i){i.forEach(n=>{const a=Hi(n);a?.removeEventListener("scroll",p)})}},[p,e]),_.useMemo(()=>e.length?s?Array.from(s.values()).reduce((m,x)=>Hs(m,x),Ht):Dl(e):Ht,[e,s])}function Fo(e,s){s===void 0&&(s=[]);const r=_.useRef(null);return _.useEffect(()=>{r.current=null},s),_.useEffect(()=>{const o=e!==Ht;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?li(e,r.current):Ht}function sf(e){_.useEffect(()=>{if(!yi)return;const s=e.map(r=>{let{sensor:o}=r;return o.setup==null?void 0:o.setup()});return()=>{for(const r of s)r?.()}},e.map(s=>{let{sensor:r}=s;return r}))}function rf(e,s){return _.useMemo(()=>e.reduce((r,o)=>{let{eventName:p,handler:m}=o;return r[p]=x=>{m(x,s)},r},{}),[e,s])}function Ol(e){return _.useMemo(()=>e?Nh(e):null,[e])}const zo=[];function nf(e,s){s===void 0&&(s=Rr);const[r]=e,o=Ol(r?yt(r):null),[p,m]=_.useState(zo);function x(){m(()=>e.length?e.map(n=>Tl(n)?o:new eo(s(n),n)):zo)}const i=Ci({callback:x});return ts(()=>{i?.disconnect(),x(),e.forEach(n=>i?.observe(n))},[e]),p}function Bl(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return jr(s)?s:e}function of(e){let{measure:s}=e;const[r,o]=_.useState(null),p=_.useCallback(a=>{for(const{target:d}of a)if(jr(d)){o(c=>{const g=s(d);return c?{...c,width:g.width,height:g.height}:g});break}},[s]),m=Ci({callback:p}),x=_.useCallback(a=>{const d=Bl(a);m?.disconnect(),d&&m?.observe(d),o(d?s(d):null)},[s,m]),[i,n]=oi(x);return _.useMemo(()=>({nodeRef:i,rect:r,setRef:n}),[r,i,n])}const af=[{sensor:so,options:{}},{sensor:Il,options:{}}],lf={current:{}},Qr={draggable:{measure:Mo},droppable:{measure:Mo,strategy:Sr.WhileDragging,frequency:vn.Optimized},dragOverlay:{measure:Rr}};class gr extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,o;return(r=(o=this.get(s))==null?void 0:o.node.current)!=null?r:void 0}}const cf={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new gr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:di},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Qr,measureDroppableContainers:di,windowRect:null,measuringScheduled:!1},Fl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:di,draggableNodes:new Map,over:null,measureDroppableContainers:di},Ar=_.createContext(Fl),zl=_.createContext(cf);function df(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new gr}}}function uf(e,s){switch(s.type){case ct.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case ct.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case ct.DragEnd:case ct.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ct.RegisterDroppable:{const{element:r}=s,{id:o}=r,p=new gr(e.droppable.containers);return p.set(o,r),{...e,droppable:{...e.droppable,containers:p}}}case ct.SetDroppableDisabled:{const{id:r,key:o,disabled:p}=s,m=e.droppable.containers.get(r);if(!m||o!==m.key)return e;const x=new gr(e.droppable.containers);return x.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:x}}}case ct.UnregisterDroppable:{const{id:r,key:o}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const m=new gr(e.droppable.containers);return m.delete(r),{...e,droppable:{...e.droppable,containers:m}}}default:return e}}function hf(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:p}=_.useContext(Ar),m=ai(o),x=ai(r?.id);return _.useEffect(()=>{if(!s&&!o&&m&&x!=null){if(!Zn(m)||document.activeElement===m.target)return;const i=p.get(x);if(!i)return;const{activatorNode:n,node:a}=i;if(!n.current&&!a.current)return;requestAnimationFrame(()=>{for(const d of[n.current,a.current]){if(!d)continue;const c=oh(d);if(c){c.focus();break}}})}},[o,s,p,x,m]),null}function Wl(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((p,m)=>m({transform:p,...o}),r):r}function ff(e){return _.useMemo(()=>({draggable:{...Qr.draggable,...e?.draggable},droppable:{...Qr.droppable,...e?.droppable},dragOverlay:{...Qr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function mf(e){let{activeNode:s,measure:r,initialRect:o,config:p=!0}=e;const m=_.useRef(!1),{x,y:i}=typeof p=="boolean"?{x:p,y:p}:p;ts(()=>{if(!x&&!i||!s){m.current=!1;return}if(m.current||!o)return;const a=s?.node.current;if(!a||a.isConnected===!1)return;const d=r(a),c=El(d,o);if(x||(c.x=0),i||(c.y=0),m.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){const g=Nl(a);g&&g.scrollBy({top:c.y,left:c.x})}},[s,x,i,o,r])}const ki=_.createContext({...Ht,scaleX:1,scaleY:1});var as;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(as||(as={}));const pf=_.memo(function(s){var r,o,p,m;let{id:x,accessibility:i,autoScroll:n=!0,children:a,sensors:d=af,collisionDetection:c=Sh,measuring:g,modifiers:v,...b}=s;const y=_.useReducer(uf,void 0,df),[l,h]=y,[u,f]=hh(),[S,C]=_.useState(as.Uninitialized),k=S===as.Initialized,{draggable:{active:E,nodes:w,translate:j},droppable:{containers:A}}=l,D=E!=null?w.get(E):null,T=_.useRef({initial:null,translated:null}),P=_.useMemo(()=>{var se;return E!=null?{id:E,data:(se=D?.data)!=null?se:lf,rect:T}:null},[E,D]),F=_.useRef(null),[I,z]=_.useState(null),[$,R]=_.useState(null),L=_r(b,Object.values(b)),M=wi("DndDescribedBy",x),O=_.useMemo(()=>A.getEnabled(),[A]),q=ff(g),{droppableRects:V,measureDroppableContainers:H,measuringScheduled:W}=Xh(O,{dragging:k,dependencies:[j.x,j.y],config:q.droppable}),U=Vh(w,E),N=_.useMemo(()=>$?ci($):null,[$]),B=X(),K=Gh(U,q.draggable.measure);mf({activeNode:E!=null?w.get(E):null,config:B.layoutShiftCompensation,initialRect:K,measure:q.draggable.measure});const Y=Oo(U,q.draggable.measure,K),J=Oo(U?U.parentElement:null),G=_.useRef({activatorEvent:null,active:null,activeNode:U,collisionRect:null,collisions:null,droppableRects:V,draggableNodes:w,draggingNode:null,draggingNodeRect:null,droppableContainers:A,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),de=A.getNodeFor((r=G.current.over)==null?void 0:r.id),he=of({measure:q.dragOverlay.measure}),re=(o=he.nodeRef.current)!=null?o:U,ne=k?(p=he.rect)!=null?p:Y:null,le=!!(he.nodeRef.current&&he.rect),_e=Jh(le?null:Y),We=Ol(re?yt(re):null),Ce=ef(k?de??U:null),He=nf(Ce),at=Wl(v,{transform:{x:j.x-_e.x,y:j.y-_e.y,scaleX:1,scaleY:1},activatorEvent:$,active:P,activeNodeRect:Y,containerNodeRect:J,draggingNodeRect:ne,over:G.current.over,overlayNodeRect:he.rect,scrollableAncestors:Ce,scrollableAncestorRects:He,windowRect:We}),Me=N?Hs(N,j):null,Ne=tf(Ce),Oe=Fo(Ne),$e=Fo(Ne,[Y]),Ke=Hs(at,Oe),De=ne?kh(ne,at):null,Xe=P&&De?c({active:P,collisionRect:De,droppableRects:V,droppableContainers:O,pointerCoordinates:Me}):null,Ge=_h(Xe,"id"),[Te,pe]=_.useState(null),tt=le?at:Hs(at,$e),Ye=wh(tt,(m=Te?.rect)!=null?m:null,Y),Ue=_.useRef(null),ft=_.useCallback((se,ie)=>{let{sensor:ae,options:Se}=ie;if(F.current==null)return;const we=w.get(F.current);if(!we)return;const Pe=se.nativeEvent,Ze=new ae({active:F.current,activeNode:we,event:Pe,options:Se,context:G,onAbort(ve){if(!w.get(ve))return;const{onDragAbort:Fe}=L.current,rt={id:ve};Fe?.(rt),u({type:"onDragAbort",event:rt})},onPending(ve,me,Fe,rt){if(!w.get(ve))return;const{onDragPending:kt}=L.current,St={id:ve,constraint:me,initialCoordinates:Fe,offset:rt};kt?.(St),u({type:"onDragPending",event:St})},onStart(ve){const me=F.current;if(me==null)return;const Fe=w.get(me);if(!Fe)return;const{onDragStart:rt}=L.current,lt={activatorEvent:Pe,active:{id:me,data:Fe.data,rect:T}};ws.unstable_batchedUpdates(()=>{rt?.(lt),C(as.Initializing),h({type:ct.DragStart,initialCoordinates:ve,active:me}),u({type:"onDragStart",event:lt}),z(Ue.current),R(Pe)})},onMove(ve){h({type:ct.DragMove,coordinates:ve})},onEnd:xe(ct.DragEnd),onCancel:xe(ct.DragCancel)});Ue.current=Ze;function xe(ve){return async function(){const{active:Fe,collisions:rt,over:lt,scrollAdjustedTranslate:kt}=G.current;let St=null;if(Fe&&kt){const{cancelDrop:vt}=L.current;St={activatorEvent:Pe,active:Fe,collisions:rt,delta:kt,over:lt},ve===ct.DragEnd&&typeof vt=="function"&&await Promise.resolve(vt(St))&&(ve=ct.DragCancel)}F.current=null,ws.unstable_batchedUpdates(()=>{h({type:ve}),C(as.Uninitialized),pe(null),z(null),R(null),Ue.current=null;const vt=ve===ct.DragEnd?"onDragEnd":"onDragCancel";if(St){const It=L.current[vt];It?.(St),u({type:vt,event:St})}})}}},[w]),st=_.useCallback((se,ie)=>(ae,Se)=>{const we=ae.nativeEvent,Pe=w.get(Se);if(F.current!==null||!Pe||we.dndKit||we.defaultPrevented)return;const Ze={active:Pe};se(ae,ie.options,Ze)===!0&&(we.dndKit={capturedBy:ie.sensor},F.current=Se,ft(ae,ie))},[w,ft]),te=Yh(d,st);sf(d),ts(()=>{Y&&S===as.Initializing&&C(as.Initialized)},[Y,S]),_.useEffect(()=>{const{onDragMove:se}=L.current,{active:ie,activatorEvent:ae,collisions:Se,over:we}=G.current;if(!ie||!ae)return;const Pe={active:ie,activatorEvent:ae,collisions:Se,delta:{x:Ke.x,y:Ke.y},over:we};ws.unstable_batchedUpdates(()=>{se?.(Pe),u({type:"onDragMove",event:Pe})})},[Ke.x,Ke.y]),_.useEffect(()=>{const{active:se,activatorEvent:ie,collisions:ae,droppableContainers:Se,scrollAdjustedTranslate:we}=G.current;if(!se||F.current==null||!ie||!we)return;const{onDragOver:Pe}=L.current,Ze=Se.get(Ge),xe=Ze&&Ze.rect.current?{id:Ze.id,rect:Ze.rect.current,data:Ze.data,disabled:Ze.disabled}:null,ve={active:se,activatorEvent:ie,collisions:ae,delta:{x:we.x,y:we.y},over:xe};ws.unstable_batchedUpdates(()=>{pe(xe),Pe?.(ve),u({type:"onDragOver",event:ve})})},[Ge]),ts(()=>{G.current={activatorEvent:$,active:P,activeNode:U,collisionRect:De,collisions:Xe,droppableRects:V,draggableNodes:w,draggingNode:re,draggingNodeRect:ne,droppableContainers:A,over:Te,scrollableAncestors:Ce,scrollAdjustedTranslate:Ke},T.current={initial:ne,translated:De}},[P,U,Xe,De,w,re,ne,V,A,Te,Ce,Ke]),$h({...B,delta:j,draggingRect:De,pointerCoordinates:Me,scrollableAncestors:Ce,scrollableAncestorRects:He});const fe=_.useMemo(()=>({active:P,activeNode:U,activeNodeRect:Y,activatorEvent:$,collisions:Xe,containerNodeRect:J,dragOverlay:he,draggableNodes:w,droppableContainers:A,droppableRects:V,over:Te,measureDroppableContainers:H,scrollableAncestors:Ce,scrollableAncestorRects:He,measuringConfiguration:q,measuringScheduled:W,windowRect:We}),[P,U,Y,$,Xe,J,he,w,A,V,Te,H,Ce,He,q,W,We]),ye=_.useMemo(()=>({activatorEvent:$,activators:te,active:P,activeNodeRect:Y,ariaDescribedById:{draggable:M},dispatch:h,draggableNodes:w,over:Te,measureDroppableContainers:H}),[$,te,P,Y,h,M,w,Te,H]);return ue.createElement(kl.Provider,{value:f},ue.createElement(Ar.Provider,{value:ye},ue.createElement(zl.Provider,{value:fe},ue.createElement(ki.Provider,{value:Ye},a)),ue.createElement(hf,{disabled:i?.restoreFocus===!1})),ue.createElement(ph,{...i,hiddenTextDescribedById:M}));function X(){const se=I?.autoScrollEnabled===!1,ie=typeof n=="object"?n.enabled===!1:n===!1,ae=k&&!se&&!ie;return typeof n=="object"?{...n,enabled:ae}:{enabled:ae}}}),gf=_.createContext(null),Wo="button",vf="Draggable";function xf(e){let{id:s,data:r,disabled:o=!1,attributes:p}=e;const m=wi(vf),{activators:x,activatorEvent:i,active:n,activeNodeRect:a,ariaDescribedById:d,draggableNodes:c,over:g}=_.useContext(Ar),{role:v=Wo,roleDescription:b="draggable",tabIndex:y=0}=p??{},l=n?.id===s,h=_.useContext(l?ki:gf),[u,f]=oi(),[S,C]=oi(),k=rf(x,s),E=_r(r);ts(()=>(c.set(s,{id:s,key:m,node:u,activatorNode:S,data:E}),()=>{const j=c.get(s);j&&j.key===m&&c.delete(s)}),[c,s]);const w=_.useMemo(()=>({role:v,tabIndex:y,"aria-disabled":o,"aria-pressed":l&&v===Wo?!0:void 0,"aria-roledescription":b,"aria-describedby":d.draggable}),[o,v,y,l,b,d.draggable]);return{active:n,activatorEvent:i,activeNodeRect:a,attributes:w,isDragging:l,listeners:o?void 0:k,node:u,over:g,setNodeRef:f,setActivatorNodeRef:C,transform:h}}function bf(){return _.useContext(zl)}const _f="Droppable",yf={timeout:25};function Sf(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:p}=e;const m=wi(_f),{active:x,dispatch:i,over:n,measureDroppableContainers:a}=_.useContext(Ar),d=_.useRef({disabled:r}),c=_.useRef(!1),g=_.useRef(null),v=_.useRef(null),{disabled:b,updateMeasurementsFor:y,timeout:l}={...yf,...p},h=_r(y??o),u=_.useCallback(()=>{if(!c.current){c.current=!0;return}v.current!=null&&clearTimeout(v.current),v.current=setTimeout(()=>{a(Array.isArray(h.current)?h.current:[h.current]),v.current=null},l)},[l]),f=Ci({callback:u,disabled:b||!x}),S=_.useCallback((w,j)=>{f&&(j&&(f.unobserve(j),c.current=!1),w&&f.observe(w))},[f]),[C,k]=oi(S),E=_r(s);return _.useEffect(()=>{!f||!C.current||(f.disconnect(),c.current=!1,f.observe(C.current))},[C,f]),_.useEffect(()=>(i({type:ct.RegisterDroppable,element:{id:o,key:m,disabled:r,node:C,rect:g,data:E}}),()=>i({type:ct.UnregisterDroppable,key:m,id:o})),[o]),_.useEffect(()=>{r!==d.current.disabled&&(i({type:ct.SetDroppableDisabled,id:o,key:m,disabled:r}),d.current.disabled=r)},[o,m,r,i]),{active:x,rect:g,isOver:n?.id===o,node:C,over:n,setNodeRef:k}}function wf(e){let{animation:s,children:r}=e;const[o,p]=_.useState(null),[m,x]=_.useState(null),i=ai(r);return!r&&!o&&i&&p(i),ts(()=>{if(!m)return;const n=o?.key,a=o?.props.id;if(n==null||a==null){p(null);return}Promise.resolve(s(a,m)).then(()=>{p(null)})},[s,o,m]),ue.createElement(ue.Fragment,null,r,o?_.cloneElement(o,{ref:x}):null)}const Cf={x:0,y:0,scaleX:1,scaleY:1};function kf(e){let{children:s}=e;return ue.createElement(Ar.Provider,{value:Fl},ue.createElement(ki.Provider,{value:Cf},s))}const Ef={position:"fixed",touchAction:"none"},jf=e=>Zn(e)?"transform 250ms ease":void 0,Nf=_.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:p,children:m,className:x,rect:i,style:n,transform:a,transition:d=jf}=e;if(!i)return null;const c=p?a:{...a,scaleX:1,scaleY:1},g={...Ef,width:i.width,height:i.height,top:i.top,left:i.left,transform:yr.Transform.toString(c),transformOrigin:p&&o?xh(o,i):void 0,transition:typeof d=="function"?d(o):d,...n};return ue.createElement(r,{className:x,style:g,ref:s},m)}),Rf=e=>s=>{let{active:r,dragOverlay:o}=s;const p={},{styles:m,className:x}=e;if(m!=null&&m.active)for(const[i,n]of Object.entries(m.active))n!==void 0&&(p[i]=r.node.style.getPropertyValue(i),r.node.style.setProperty(i,n));if(m!=null&&m.dragOverlay)for(const[i,n]of Object.entries(m.dragOverlay))n!==void 0&&o.node.style.setProperty(i,n);return x!=null&&x.active&&r.node.classList.add(x.active),x!=null&&x.dragOverlay&&o.node.classList.add(x.dragOverlay),function(){for(const[n,a]of Object.entries(p))r.node.style.setProperty(n,a);x!=null&&x.active&&r.node.classList.remove(x.active)}},Af=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:yr.Transform.toString(s)},{transform:yr.Transform.toString(r)}]},Tf={duration:250,easing:"ease",keyframes:Af,sideEffects:Rf({styles:{active:{opacity:"0"}}})};function Mf(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:p}=e;return Si((m,x)=>{if(s===null)return;const i=r.get(m);if(!i)return;const n=i.node.current;if(!n)return;const a=Bl(x);if(!a)return;const{transform:d}=yt(x).getComputedStyle(x),c=jl(d);if(!c)return;const g=typeof s=="function"?s:Df(s);return Pl(n,p.draggable.measure),g({active:{id:m,data:i.data,node:n,rect:p.draggable.measure(n)},draggableNodes:r,dragOverlay:{node:x,rect:p.dragOverlay.measure(a)},droppableContainers:o,measuringConfiguration:p,transform:c})})}function Df(e){const{duration:s,easing:r,sideEffects:o,keyframes:p}={...Tf,...e};return m=>{let{active:x,dragOverlay:i,transform:n,...a}=m;if(!s)return;const d={x:i.rect.left-x.rect.left,y:i.rect.top-x.rect.top},c={scaleX:n.scaleX!==1?x.rect.width*n.scaleX/i.rect.width:1,scaleY:n.scaleY!==1?x.rect.height*n.scaleY/i.rect.height:1},g={x:n.x-d.x,y:n.y-d.y,...c},v=p({...a,active:x,dragOverlay:i,transform:{initial:n,final:g}}),[b]=v,y=v[v.length-1];if(JSON.stringify(b)===JSON.stringify(y))return;const l=o?.({active:x,dragOverlay:i,...a}),h=i.node.animate(v,{duration:s,easing:r,fill:"forwards"});return new Promise(u=>{h.onfinish=()=>{l?.(),u()}})}}let Ho=0;function Pf(e){return _.useMemo(()=>{if(e!=null)return Ho++,Ho},[e])}const Lf=ue.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:o,style:p,transition:m,modifiers:x,wrapperElement:i="div",className:n,zIndex:a=999}=e;const{activatorEvent:d,active:c,activeNodeRect:g,containerNodeRect:v,draggableNodes:b,droppableContainers:y,dragOverlay:l,over:h,measuringConfiguration:u,scrollableAncestors:f,scrollableAncestorRects:S,windowRect:C}=bf(),k=_.useContext(ki),E=Pf(c?.id),w=Wl(x,{activatorEvent:d,active:c,activeNodeRect:g,containerNodeRect:v,draggingNodeRect:l.rect,over:h,overlayNodeRect:l.rect,scrollableAncestors:f,scrollableAncestorRects:S,transform:k,windowRect:C}),j=ro(g),A=Mf({config:o,draggableNodes:b,droppableContainers:y,measuringConfiguration:u}),D=j?l.setRef:void 0;return ue.createElement(kf,null,ue.createElement(wf,{animation:A},c&&E?ue.createElement(Nf,{key:E,id:c.id,ref:D,as:i,activatorEvent:d,adjustScale:s,className:n,transition:m,rect:j,style:{zIndex:a,...p},transform:w},r):null))}),Hl=768;function If(e){const s=window.matchMedia(`(max-width: ${Hl-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function Of(){return window.innerWidth<Hl}function Bf(){return!1}function Ul(){return _.useSyncExternalStore(If,Of,Bf)}function Ff(e,s){const r=[];if(!e||e.length===0)return r;const o=e.some(m=>m.status==="ACTIVE");return e.some(m=>m.sessions?.some(x=>x.status===ut.RUNNING||x.status===ut.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function io({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:p,workspaces:m,isLoading:x}){const{t:i}=ce(),{data:n,isLoading:a}=Pn(m===void 0&&e?o:""),d=m??n,c=m===void 0&&e&&a,g=_.useMemo(()=>Ff(d,i),[d,i]);return t.jsx(Dn,{isOpen:e,onClose:s,onConfirm:r,title:i("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:i("确认删除任务「{title}」?此操作不可撤销。",{title:p})}),c?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:i("加载中...")}):g.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:g.map((v,b)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[t.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),t.jsx("span",{children:v})]},b))}):null]}),confirmText:i("删除"),variant:"danger",isLoading:x||c})}const zf="flex w-full min-w-0 items-center gap-2.5 rounded-md px-2 text-sm text-left transition-[background-color,box-shadow,color] duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",Wf="h-8 pointer-coarse:h-10";function ur(e){return Z(zf,Wf,e?"bg-background text-foreground shadow-xs ring-1 ring-border/80":"text-foreground/80 hover:bg-accent hover:text-foreground active:bg-foreground/[0.06]")}const $l=_.createContext(null),Hf=3e4;function Uf(e=Hf){const[,s]=_.useState(0);_.useEffect(()=>{const r=setInterval(()=>s(o=>o+1),e);return()=>clearInterval(r)},[e])}const xn=60,bn=60*xn,Ki=24*bn;function $f(e,s,r){const o=new Date(e),p=Math.max(0,Math.floor((Date.now()-o.getTime())/1e3));if(p<xn)return s("now");if(p<bn)return s("{count}m",{count:Math.floor(p/xn)});if(p<Ki)return s("{count}h",{count:Math.floor(p/bn)});if(p<7*Ki)return s("{count}d",{count:Math.floor(p/Ki)});const m=o.getFullYear()===new Date().getFullYear();return o.toLocaleDateString(r,m?{month:"numeric",day:"numeric"}:{year:"numeric",month:"numeric"})}function Kf(e){const s=kd(e,9,"..");if(s===e)return e;const r=s.slice(0,-2),o=r.search(/[-_.\s][^-_.\s]*$/);return`${o>=3?r.slice(0,o):r}..`}const qi="flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-foreground/80 transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:outline-none",Uo="px-2 pb-1 pt-1.5 text-[11px] font-medium text-muted-foreground",$o=t.jsx("div",{className:"-mx-1 my-1 h-px bg-border/60"});function qf({task:e,status:s,isSelected:r,project:o,showProject:p,onSelectTask:m,onTaskStatusChange:x,onDeleteTask:i,onTaskPriorityChange:n,disableDrag:a}){const{t:d,locale:c}=ce(),g=_.useContext($l),v=_.useRef(null),b=!!e.projectArchivedAt,y=b||!!a,{attributes:l,listeners:h,setNodeRef:u,isDragging:f}=xf({id:e.id,data:{task:e,fromStatus:s},disabled:y}),S=_.useCallback(R=>{v.current=R,u(R),g&&(R?g.registry.set(e.id,R):g.registry.delete(e.id))},[u,g,e.id]);_.useEffect(()=>()=>{g?.registry.delete(e.id)},[e.id,g]);const[C,k]=_.useState(null),[E,w]=_.useState(!1),j=_.useRef(null),A=_.useRef(null),D=_.useCallback(R=>{b||!x&&!i&&!n||(R.preventDefault(),k({x:R.clientX,y:R.clientY}))},[b,x,i,n]),T=_.useCallback(()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]),P=_.useCallback(R=>{if(!a||b||!x&&!i)return;const L=R.touches[0];if(!L)return;const{clientX:M,clientY:O}=L;A.current=setTimeout(()=>{A.current=null,k({x:M,y:O})},500)},[a,b,x,i]);_.useEffect(()=>{if(!C)return;const R=()=>k(null),L=O=>{j.current&&!j.current.contains(O.target)&&R()},M=O=>{O.key==="Escape"&&R()};return document.addEventListener("mousedown",L),document.addEventListener("touchstart",L),document.addEventListener("keydown",M),window.addEventListener("scroll",R,!0),window.addEventListener("resize",R),()=>{document.removeEventListener("mousedown",L),document.removeEventListener("touchstart",L),document.removeEventListener("keydown",M),window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R)}},[C]),_.useLayoutEffect(()=>{const R=j.current;if(!C||!R)return;const L=8;R.style.left=`${Math.max(L,Math.min(C.x,window.innerWidth-R.offsetWidth-L))}px`,R.style.top=`${Math.max(L,Math.min(C.y,window.innerHeight-R.offsetHeight-L))}px`},[C]);const F=o?o.name:void 0,I=p?o:void 0,z=e.updatedAt?$f(e.updatedAt,d,c):null,{titleClass:$}=Ks[s];return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:S,type:"button",onClick:()=>m(e.id),onContextMenu:D,onTouchStart:P,onTouchEnd:T,onTouchMove:T,title:I?`${e.title} · ${I.name}`:e.title,"aria-label":F?`${e.title} — ${F}`:e.title,"aria-current":r||void 0,"data-sidebar-item":"",className:Z("task-row animate-task-enter",ur(r),f&&"opacity-30"),...y?{}:h,...y?{}:l,children:[t.jsx("span",{className:Z("min-w-0 flex-1 truncate",$),children:e.title}),e.priority!==void 0&&e.priority!==Jr.NORMAL&&t.jsx(wo,{priority:e.priority}),e.projectArchivedAt&&t.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full bg-foreground/[0.06] px-1.5 py-0.5 text-[10px] font-medium leading-none text-muted-foreground",children:e.projectRepoDeletedAt?d("源码已删除"):d("已删除")}),(z||I)&&t.jsx("span",{className:"task-row-meta",children:t.jsxs("span",{className:"flex items-center gap-1",children:[I&&t.jsx("span",{className:"shrink-0 whitespace-nowrap rounded bg-foreground/[0.05] px-1 py-0.5 text-[10px] font-medium leading-none @max-[22rem]:hidden",children:t.jsx("span",{className:Z(I.color,"bg-[linear-gradient(90deg,currentColor_0.6em,var(--muted-foreground)_2.6em)] bg-clip-text [-webkit-text-fill-color:transparent]"),children:Kf(I.name)})}),z&&t.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:z})]})})]}),C&&t.jsxs("div",{ref:j,role:"menu",className:"fixed z-[100] w-48 rounded-lg border border-border bg-popover p-1 shadow-lg shadow-black/5 animate-in fade-in zoom-in-95 duration-100",children:[x&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Uo,children:d("Move to")}),Xd.filter(R=>R!==s).map(R=>{const{icon:L,label:M,accentClass:O}=Ks[R];return t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{x(e.id,R),k(null)},className:qi,children:[t.jsx(L,{className:Z("size-3.5 shrink-0",O)}),t.jsx("span",{children:d(M)})]},R)})]}),n&&t.jsxs(t.Fragment,{children:[x&&$o,t.jsx("div",{className:Uo,children:d("Priority")}),su.map(R=>{const L=(e.priority??Jr.NORMAL)===R.value;return t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":L,onClick:()=>{n(e.id,R.value),k(null)},className:qi,children:[t.jsx(wo,{priority:R.value}),t.jsx("span",{className:"flex-1",children:d(R.label)}),L&&t.jsx(Wt,{className:"size-3.5 shrink-0 text-foreground","aria-hidden":!0})]},R.value)})]}),i&&t.jsxs(t.Fragment,{children:[(x||n)&&$o,t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{w(!0),k(null)},className:Z(qi,"text-destructive hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10"),children:[t.jsx(gi,{className:"size-3.5 shrink-0","aria-hidden":!0}),t.jsx("span",{children:d("Delete Task")})]})]})]}),t.jsx(io,{isOpen:E,onClose:()=>w(!1),onConfirm:()=>{i?.(e.id),w(!1)},taskId:e.id,taskTitle:e.title})]})}const Vf=_.memo(function({title:s,tasks:r,status:o,defaultOpen:p,selectedTaskId:m,onSelectTask:x,projects:i,showProject:n=!0,isDragging:a,dragFromStatus:d,onTaskStatusChange:c,onDeleteTask:g,onTaskPriorityChange:v,disableDrag:b}){const{t:y}=ce(),[l,h]=_.useState(p);Uf();const u=r.length===0,f=a&&d===o,S=a&&d!==o,{setNodeRef:C,isOver:k}=Sf({id:`group-${o}`,data:{status:o}}),E=o===Ee.Review,w=y(s),{icon:j,accentClass:A}=Ks[o],D=_.useId(),T=a?f:l,P=T&&!S&&!u;return t.jsxs("div",{className:P?"mb-4":"mb-2","data-task-group-status":o,children:[t.jsx("div",{className:"sticky top-0 z-10 bg-sidebar px-2",children:t.jsxs("button",{type:"button",onClick:()=>!a&&h(F=>!F),"aria-expanded":l,"data-sidebar-item":"",className:"group/header flex h-7 w-full items-center gap-1 rounded-md px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx(j,{className:Z("mr-0.5 size-3.5 shrink-0",A)}),t.jsx("span",{id:D,className:"truncate",children:w}),t.jsx(Nt,{size:12,"aria-hidden":!0,className:Z("shrink-0 text-muted-foreground/60 transition-transform duration-150 group-hover/header:text-muted-foreground",T&&"rotate-90")}),E&&!u?t.jsx("span",{className:"ml-auto rounded-full bg-warning/15 px-1.5 text-[11px] font-semibold leading-4 tabular-nums text-warning",children:r.length}):t.jsx("span",{className:"ml-auto text-[11px] font-normal tabular-nums text-muted-foreground/80",children:r.length})]})}),S&&t.jsx("div",{ref:C,className:Z("mx-2 mt-0.5 flex h-9 items-center justify-center rounded-md border border-dashed text-xs font-medium transition-colors duration-150",k?"border-info/50 bg-info/5 text-info":"border-border bg-foreground/[0.02] text-muted-foreground"),children:k?y("Drop into {title}",{title:w}):y("Drop here")}),P&&t.jsx("div",{ref:f?void 0:C,role:"group","aria-labelledby":D,className:"mt-0.5 flex flex-col gap-px px-2",children:r.map(F=>{const I=m===F.id,z=F.projectId?i.find($=>$.id===F.projectId):void 0;return t.jsx(qf,{task:F,status:o,isSelected:I,project:z,showProject:n,onSelectTask:x,onTaskStatusChange:F.projectArchivedAt?void 0:c,onDeleteTask:F.projectArchivedAt?void 0:g,onTaskPriorityChange:F.projectArchivedAt?void 0:v,disableDrag:b},F.id)})})]})}),Yf=12,Xf=50;function Gf({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:p}){const{t:m}=ce(),[x,i]=_.useState(""),[n,a]=_.useState(0),d=_.useRef(null);_.useEffect(()=>{e&&(i(""),a(0))},[e]);const c=_.useMemo(()=>{const b=x.trim().toLowerCase();return b?r.filter(y=>y.title.toLowerCase().includes(b)).slice(0,Xf):r.slice(0,Yf)},[r,x]);_.useEffect(()=>{a(0)},[x]),_.useEffect(()=>{d.current?.children[n]?.scrollIntoView({block:"nearest"})},[n]);const g=_.useCallback(b=>{p(b),s()},[p,s]),v=_.useCallback(b=>{if(b.key==="Escape")b.preventDefault(),s();else if(b.key==="ArrowDown")b.preventDefault(),a(y=>Math.min(y+1,c.length-1));else if(b.key==="ArrowUp")b.preventDefault(),a(y=>Math.max(y-1,0));else if(b.key==="Enter"&&!b.nativeEvent.isComposing){b.preventDefault();const y=c[n];y&&g(y.id)}},[s,c,n,g]);return e?t.jsxs("div",{className:"fixed inset-0 z-90",role:"dialog","aria-modal":"true",children:[t.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:s}),t.jsxs("div",{className:"absolute left-1/2 top-[18vh] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 bg-popover rounded-xl border border-border shadow-lg overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[t.jsxs("div",{className:"flex items-center gap-2.5 px-4 border-b border-border/60",children:[t.jsx(Hn,{size:15,className:"text-muted-foreground/70 shrink-0"}),t.jsx("input",{value:x,onChange:b=>i(b.target.value),onKeyDown:v,placeholder:m("Search tasks..."),"aria-label":m("Search tasks..."),autoFocus:!0,className:"flex-1 py-3 bg-transparent border-none focus:outline-none text-sm text-foreground placeholder-muted-foreground/60"})]}),c.length>0?t.jsxs(t.Fragment,{children:[!x.trim()&&t.jsx("div",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium text-muted-foreground/70",children:m("Recent tasks")}),t.jsx("div",{ref:d,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:c.map((b,y)=>{const l=o.find(f=>f.id===b.projectId),{icon:h,iconClass:u}=Ks[b.status];return t.jsxs("button",{onClick:()=>g(b.id),onMouseEnter:()=>a(y),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
|
|
7
|
+
${y===n?"bg-accent":""}`,children:[t.jsx(h,{className:`${u} size-4 shrink-0`}),t.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-foreground/90",title:b.title,children:b.title}),l&&t.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground/70",children:l.name})]},b.id)})})]}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:m("No matching tasks")})]})]}):null}const Qf=260,Zf=220;function Jf(e){const s={[Ee.Review]:[],[Ee.Running]:[],[Ee.Pending]:[],[Ee.Done]:[],[Ee.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s[Ee.Review].sort((r,o)=>(o.priority??Jr.NORMAL)-(r.priority??Jr.NORMAL)),s}const em=[{status:Ee.Review,title:"Review",defaultOpen:!0},{status:Ee.Running,title:"Running",defaultOpen:!0},{status:Ee.Pending,title:"Pending",defaultOpen:!1},{status:Ee.Done,title:"Done",defaultOpen:!1},{status:Ee.Cancelled,title:"Cancelled",defaultOpen:!1}];function tm(){return t.jsx("div",{className:"flex-1 overflow-hidden px-2 pt-3 motion-safe:animate-pulse","aria-hidden":!0,children:[3,4].map((e,s)=>t.jsxs("div",{className:"mb-4",children:[t.jsxs("div",{className:"flex h-7 items-center gap-1.5 px-2",children:[t.jsx("div",{className:"size-3.5 shrink-0 rounded-full bg-foreground/[0.06]"}),t.jsx("div",{className:"h-2.5 w-12 rounded-full bg-foreground/[0.06]"})]}),Array.from({length:e}).map((r,o)=>t.jsxs("div",{className:"flex h-8 items-center gap-2.5 px-2 pointer-coarse:h-10",children:[t.jsx("div",{className:"h-3 rounded-full bg-foreground/[0.06]",style:{width:`${64-(o+s)%3*14}%`}}),t.jsx("div",{className:"ml-auto h-2.5 w-8 shrink-0 rounded-full bg-foreground/[0.05]"})]},o))]},s))})}function Ko({tasks:e=[],projects:s=[],selectedTaskId:r,onSelectTask:o,filterProjectId:p,setFilterProjectId:m,width:x=320,onCreateTask:i,onCreateProject:n,isCreateActive:a,onTaskStatusChange:d,onDeleteTask:c,onTaskPriorityChange:g,isLoading:v=!1}){const{t:b}=ce(),{preserveDesktopSearch:y}=Ua(),l=Ul(),[h,u]=_.useState(null),[f,S]=_.useState(null),[C,k]=_.useState(!1),E=_.useRef(new Map),w=_.useRef(new Set),j=_.useRef(new Map),A=_.useMemo(()=>({registry:E.current}),[]),D=_.useCallback(H=>{H.remove(),w.current.delete(H)},[]),T=p?e.filter(H=>H.projectId===p):e,P=_.useCallback((H,W)=>{const U=document.querySelector(`[data-task-group-status="${H}"]`);if(!U)return null;const B=(U.querySelector("button")??U).getBoundingClientRect();return B.width===0||B.height===0?null:new DOMRect(B.left,B.bottom+2,W.width,W.height)},[]),F=_.useCallback((H,W,U,N=!1)=>{const B=document.createElement("div");B.setAttribute("aria-hidden","true"),B.innerHTML=U;const K=B.firstElementChild;K&&(K.style.cssText="",K.className=K.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),K.style.pointerEvents="none",K.style.width=`${H.width}px`,K.style.height=`${H.height}px`,K.style.margin="0",K.style.backgroundColor="var(--background)",K.style.borderRadius="0.5rem",K.style.boxShadow="0 4px 6px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border)",K.style.opacity="0.96",K.style.transition="none",K.setAttribute("tabindex","-1")),Object.assign(B.style,{position:"fixed",left:`${H.left}px`,top:`${H.top}px`,width:`${H.width}px`,height:`${H.height}px`,zIndex:"9999",pointerEvents:"none",overflow:"visible",transformOrigin:"top left",willChange:"transform, opacity"}),document.body.appendChild(B),w.current.add(B);const Y=W.left-H.left,J=W.top-H.top;B.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${Y}px, ${J}px)`,opacity:N?.12:.96,offset:1}],{duration:N?Zf:Qf,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>D(B),()=>D(B))},[D]);_.useLayoutEffect(()=>{const H=window.matchMedia("(prefers-reduced-motion: reduce)").matches,W=new Map;for(const U of T){const N=E.current.get(U.id);if(!N)continue;const B={status:U.status,rect:N.getBoundingClientRect(),html:N.outerHTML};if(W.set(U.id,B),H)continue;const K=j.current.get(U.id);if(!K||K.status===U.status)continue;const Y=B.rect.left-K.rect.left,J=B.rect.top-K.rect.top;Math.abs(Y)<1&&Math.abs(J)<1||F(K.rect,B.rect,K.html)}if(!H)for(const[U,N]of j.current){if(W.has(U))continue;const B=T.find(Y=>Y.id===U);if(!B||B.status===N.status)continue;const K=P(B.status,N.rect);K&&F(N.rect,K,N.html,!0)}j.current=W},[T,F,P]),_.useEffect(()=>()=>{for(const H of w.current)H.remove();w.current.clear()},[]);const I=vh(gh(so,{activationConstraint:{distance:8}})),z=_.useCallback(H=>{const W=H.active.data.current?.task,U=H.active.data.current?.fromStatus;W&&u(W),U&&S(U)},[]),$=_.useCallback(H=>{u(null),S(null);const{active:W,over:U}=H;if(!U)return;const N=W.data.current?.task,B=W.data.current?.fromStatus,K=U.data.current?.status;!N||!B||!K||N.projectArchivedAt||B!==K&&d?.(N.id,K)},[d]),M=!!!(p?s.find(H=>H.id===p)??null:null)?.archivedAt,O=Jf(T),q=h?Ks[h.status]:null,V=_.useCallback(H=>{if(H.key!=="ArrowDown"&&H.key!=="ArrowUp"||H.altKey||H.ctrlKey||H.metaKey||H.shiftKey)return;const W=Array.from(H.currentTarget.querySelectorAll("[data-sidebar-item]:not(:disabled)")),U=W.indexOf(H.target);U!==-1&&(H.preventDefault(),W[U+(H.key==="ArrowDown"?1:-1)]?.focus())},[]);return t.jsxs("div",{className:"@container h-full flex flex-col flex-shrink-0",style:{width:x},onKeyDown:V,children:[t.jsxs("div",{className:"px-2 pt-2 pb-1 flex flex-col gap-px flex-shrink-0",children:[n&&t.jsxs("button",{type:"button",onClick:n,"data-sidebar-item":"",className:ur(!1),children:[t.jsx(Gd,{size:16,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"truncate",children:b("New Project")})]}),t.jsxs("button",{type:"button",onClick:i,disabled:!M,"aria-current":a||void 0,"data-sidebar-item":"",className:Z(ur(!!a),"disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent"),title:M?void 0:b("Deleted projects are read-only"),children:[t.jsx(ru,{size:16,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"truncate",children:b("New Task")})]}),t.jsxs("button",{type:"button",onClick:()=>k(!0),"data-sidebar-item":"",className:ur(!1),children:[t.jsx(Hn,{size:16,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"truncate",children:b("Search")})]}),t.jsxs(Ed,{to:y("/conversations"),"data-sidebar-item":"",className:ur(!1),children:[t.jsx(vi,{size:16,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"truncate",children:b("对话")})]})]}),v?t.jsx(tm,{}):T.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 pb-[10vh] text-center select-none",children:[t.jsx(qs,{size:36,className:"text-muted-foreground/40 mb-3",strokeWidth:1.5}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:b("No tasks")}),M&&i?t.jsx("button",{type:"button",onClick:i,className:"px-3.5 py-1.5 rounded-md bg-brand text-brand-foreground text-xs font-medium hover:bg-brand/90 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-2",children:b("New Task")}):null]}):t.jsx($l.Provider,{value:A,children:t.jsxs(pf,{sensors:I,onDragStart:z,onDragEnd:$,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin scroll-pt-8 relative",children:t.jsx("div",{className:"pt-3 pb-4",children:em.map(({status:H,title:W,defaultOpen:U})=>t.jsx(Vf,{title:W,tasks:O[H],status:H,defaultOpen:U,selectedTaskId:r,onSelectTask:o,projects:s,showProject:!p,isDragging:h!==null,dragFromStatus:f,onTaskStatusChange:d,onDeleteTask:c,onTaskPriorityChange:g,disableDrag:l},H))})}),t.jsx(Lf,{dropAnimation:null,children:h&&q?t.jsxs("div",{className:"flex h-8 w-fit max-w-[280px] items-center gap-2.5 rounded-md bg-background px-2 text-sm text-foreground shadow-[0_12px_16px_-4px_rgba(36,36,36,0.08)] ring-1 ring-border/80",children:[t.jsx(q.icon,{className:Z("size-4 shrink-0",q.iconClass)}),t.jsx("span",{className:"truncate",title:h.title,children:h.title})]}):null})]})}),!v&&t.jsxs("div",{className:"h-9 px-4 flex flex-shrink-0 items-center justify-between border-t border-border/60 text-xs text-muted-foreground",children:[t.jsx("span",{className:"tabular-nums",children:b("{count} tasks",{count:T.length})}),p?t.jsx("button",{type:"button",onClick:()=>m(null),className:"rounded-sm hover:text-foreground underline decoration-border underline-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:b("Clear filter")}):null]}),t.jsx(Gf,{isOpen:C,onClose:()=>k(!1),tasks:T,projects:s,onSelectTask:o})]})}const sm=10,rm=24,Kl=sm*rm,im=8;function nm(e,s=Kl){return e>s+im}function om(e,s){return e.includes(s)?e:[...e,s]}function am(e,s){return e.filter(r=>r!==s)}function lm(e,s){const r=new Map(s.map(o=>[o.id,o]));return e.map(o=>r.get(o)).filter(o=>!!o).map(o=>({memberId:o.id,label:o.name}))}const Ei=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function qo(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function cm(e,s=[],r=[]){const o=new Set(r.filter(m=>Ei.has(m.status)).map(m=>m.workRequestId));return[...e.map(m=>({kind:"message",key:`message:${m.id}`,sortTime:m.createdAt,order:0,message:m})),...s.filter(m=>m.status==="PENDING_APPROVAL").filter(m=>!o.has(m.id)).map(m=>({kind:"pendingApproval",key:`pending-approval:${m.id}`,sortTime:m.updatedAt??m.createdAt,order:1,request:m}))].sort((m,x)=>{const i=qo(m.sortTime)-qo(x.sortTime);return i!==0?i:m.order!==x.order?m.order-x.order:m.key.localeCompare(x.key)})}function dm(e){switch(e){case"RUNNING":return"Working";case"QUEUED":return"Queued...";case"WAITING_ROOM_REPLY":return"Waiting reply...";case"SESSION_ENDED":return"Session ended";default:return e}}function um(e){switch(e){case"FAILED":return"text-red-500";case"RUNNING":case"WAITING_ROOM_REPLY":case"QUEUED":case"SESSION_ENDED":return"text-neutral-500";default:return"text-neutral-500"}}function hm(e,s){const r=e.reduce((p,m)=>(p[m.status]=(p[m.status]??0)+1,p),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([p,m])=>{const x=r[p];return x?`${x} ${s(m)}`:null}).filter(p=>!!p).join(" · ")}function fm(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function mm({status:e}){const{t:s}=ce();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[s("Working"),t.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[t.jsx("span",{children:"."}),t.jsx("span",{className:"active-work-dots__second",children:"."}),t.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):t.jsx(t.Fragment,{children:s(dm(e))})}function pm({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:o,onStopMember:p,isStopPending:m,stoppingMemberId:x,stopPromptInvocationId:i,onToggleStopConfirm:n}){const{t:a}=ce(),[d,c]=_.useState(fm),g=_.useMemo(()=>e.filter(b=>Ei.has(b.status)).sort((b,y)=>Date.parse(y.updatedAt??y.createdAt??"")-Date.parse(b.updatedAt??b.createdAt??"")),[e]);if(g.length===0)return null;const v=hm(g,a);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>c(b=>!b),"aria-expanded":d,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-neutral-600 transition-colors hover:bg-neutral-100",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-medium text-neutral-800",children:a("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:v})]}),d?t.jsx(Ct,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(vl,{size:15,className:"shrink-0 text-neutral-400"})]}),d&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:g.map(b=>{const y=s.get(b.memberId),l=r.get(b.workRequestId),h=!!(b.sessionId&&o),u=!!y,f=i===b.id,S=m&&x===b.memberId,C=l?.instruction??b.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:C,className:Z("group flex h-8 items-center gap-2 px-3 text-xs text-neutral-700",h?"cursor-pointer hover:bg-white":"cursor-default"),role:h?"button":void 0,tabIndex:h?0:void 0,onClick:()=>b.sessionId&&o?.(b.sessionId),onKeyDown:k=>{!h||!b.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(b.sessionId))},children:[t.jsx(Yt,{name:y?.name??a("Agent"),avatar:y?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate font-medium text-neutral-800",children:y?.name??a("Agent")}),t.jsx("span",{className:Z("shrink-0",um(b.status)),children:t.jsx(mm,{status:b.status})})]}),h&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),b.sessionId&&o?.(b.sessionId)},onKeyDown:k=>k.stopPropagation(),className:"hidden shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700 group-hover:inline-flex",title:a("View log"),"aria-label":`${a("View log")} ${y?.name??a("Agent")}`,children:t.jsx(mn,{size:13})}),u&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),n(b.id)},onKeyDown:k=>k.stopPropagation(),disabled:S,className:"shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-700 disabled:cursor-not-allowed disabled:opacity-50",title:a("Stop"),"aria-label":`${a("Stop")} ${y?.name??a("Agent")}`,children:t.jsx(Us,{size:12})})]}),u&&f&&y&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-neutral-100 bg-white px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-[11px] text-neutral-600",children:a("Stop running work?")}),t.jsxs(je,{type:"button",size:"xs",variant:"outline",disabled:S,onClick:()=>p(y.id,!1),children:[t.jsx(Us,{size:11}),t.jsx("span",{children:a(S?"Stopping":"Stop only")})]}),t.jsxs(je,{type:"button",size:"xs",variant:"outline",disabled:S,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>p(y.id,!0),children:[t.jsx(_l,{size:11}),t.jsx("span",{children:a(S?"Stopping":"Stop + clear queue")})]})]})]},b.id)})})]})}const _n=Cr(),gm=240;let Vo=0;function vm(e,s){return Vo+=1,{id:`pending-room-message-${Date.now()}-${Vo}`,teamRunId:e,senderType:s.senderType??"user",senderId:s.senderId??null,senderInvocationId:s.senderInvocationId??null,kind:s.kind??((s.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:s.content,mentions:s.mentions??[],workRequestIds:[],artifactRefs:s.artifactRefs??[],attachmentIds:s.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function ql(e){return"pendingStatus"in e}function xm(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function bm(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function yn(e,s){if(s.length===0)return e;const r=new Set(s.map(bm));return e.split(`
|
|
8
|
+
`).map(o=>{const p=o.match(/^\s*/)?.[0]??"",m=o.trimStart();for(const x of r){if(m===x)return null;if(m.startsWith(`${x} `)||m.startsWith(`${x} `))return`${p}${m.slice(x.length).trimStart()}`}return o}).filter(o=>o!=null).join(`
|
|
9
|
+
`).replace(/\n{3,}/g,`
|
|
10
|
+
|
|
11
|
+
`).trim()}function _m(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Sn(e,s){return e instanceof Error?e.message:s}function ym(e,s=gm){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Sm(e,s){const o=e.slice(0,s).match(/(^|\s)@([^\s@]*)$/);return!o||o.index==null?null:{start:o.index+o[1].length,end:s,query:o[2]??""}}function wm(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(p=>p.toLowerCase().includes(r)):!0}function Yo(e){return e.membershipStatus!=="REMOVED"}function Cm(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function km(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function Em(e,s){const r=e.mentions??[],o=e.contentPreview??e.content;if(r.length===0)return o;const p=r.map(x=>Cm(x,s)).filter(x=>x&&!o.includes(`@${x}`));if(p.length===0)return o;const m=p.map(x=>`@${x}`).join(" ");return o.trimEnd()?`${o.trimEnd()} ${m}`:m}function jm(e,s,r){if(e.senderType!=="agent")return null;if(e.senderId&&s.has(e.senderId))return s.get(e.senderId)??null;if(e.senderInvocationId){const o=r.get(e.senderInvocationId);if(o?.memberId&&s.has(o.memberId))return s.get(o.memberId)??null}return null}function Nm({content:e,isUser:s,workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:p,onOpenVisualization:m,downloadSessionId:x}){const i=_.useMemo(()=>m||x?nu(e):e,[e,x,m]),n=ou(i),a=_.useMemo(()=>au({workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:p,onOpenVisualization:m,downloadSessionId:x}),[x,p,m,o,r]);return t.jsx("div",{className:Z("team-room-message-markdown prose prose-sm max-w-none break-words [overflow-wrap:anywhere]","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0 prose-p:leading-6","prose-ul:my-2 prose-ol:my-2 prose-li:my-1 prose-li:pl-0 prose-li:leading-6 prose-li:marker:text-neutral-400","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-neutral-300 prose-blockquote:pl-3 prose-blockquote:text-neutral-600","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-neutral-800 prose-pre:bg-neutral-950 prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed prose-pre:shadow-inner","prose-code:break-words prose-code:rounded prose-code:bg-neutral-100 prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-neutral-800","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-neutral-100","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-a:text-blue-600 prose-a:underline-offset-2 hover:prose-a:text-blue-700","prose-hr:my-3 prose-hr:border-neutral-200",s?["text-white prose-strong:text-white prose-headings:text-white prose-blockquote:border-white/30 prose-blockquote:text-neutral-200","prose-code:bg-white/15 prose-code:text-white prose-pre:border-neutral-700 prose-a:text-blue-200 hover:prose-a:text-blue-100 prose-hr:border-white/15"]:"text-neutral-800 prose-strong:text-neutral-900"),children:t.jsx(Vn,{components:a,plugins:n,controls:n?lu:void 0,children:i})})}function Rm({hasAttachmentIds:e,attachments:s,isLoading:r,onOpenImage:o}){if(!e)return null;if(r&&s.length===0)return t.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(s.length===0)return null;const p=s.filter(x=>x.mimeType.startsWith("image/")),m=new Map(p.map((x,i)=>[x.id,i]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:s.map(x=>{const i=`${_n}${x.url}`;if(x.mimeType.startsWith("image/")){const a=m.get(x.id)??0;return t.jsxs("button",{type:"button",onClick:()=>o(p,a),className:"group relative h-24 w-24 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-50 shadow-sm transition-opacity hover:opacity-90",title:x.originalName,children:[t.jsx("img",{src:i,alt:x.originalName,className:"h-full w-full object-cover",loading:"lazy"}),t.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-black/55 px-1.5 py-1 text-left text-[10px] text-white",children:x.originalName})]},x.id)}return t.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 text-xs text-neutral-700 shadow-sm hover:bg-neutral-50",title:x.originalName,children:[t.jsx(Ja,{size:16,className:"shrink-0 text-neutral-400","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate font-medium",children:x.originalName}),t.jsx("span",{className:"text-neutral-400",children:xm(x.sizeBytes)})]}),t.jsx(Tn,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},x.id)})})}function Am({message:e,content:s,attachmentIds:r,isUser:o,tone:p,onOpenImage:m,workingDir:x,onOpenWorkspaceFile:i,onOpenPreviewUrl:n,onOpenVisualization:a,downloadSessionId:d}){const c=_.useMemo(()=>Array.from(new Set(r??[])),[r]),{data:g=[],isLoading:v}=iu(c),b=g.length>0?yn(s,g):s;return t.jsxs(t.Fragment,{children:[b.trim()&&t.jsx(Dm,{message:e,content:b,attachments:g,isUser:o,tone:p,workingDir:x,onOpenWorkspaceFile:i,onOpenPreviewUrl:n,onOpenVisualization:a,downloadSessionId:d}),t.jsx(Rm,{hasAttachmentIds:c.length>0,attachments:g,isLoading:v,onOpenImage:m})]})}function Tm({images:e,index:s,onClose:r,onSelect:o}){const p=e[s];if(!p)return null;const m=s>0,x=s<e.length-1;return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",role:"dialog","aria-modal":"true",children:[t.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 rounded-full bg-white/10 p-2 text-white transition-colors hover:bg-white/20","aria-label":"Close image preview",children:t.jsx(Xt,{size:20})}),m&&t.jsx("button",{type:"button",onClick:()=>o(s-1),className:"absolute left-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Previous image",children:t.jsx(ku,{size:24,"aria-hidden":!0})}),t.jsxs("div",{className:"flex max-h-full max-w-full flex-col items-center gap-3",children:[t.jsx("img",{src:`${_n}${p.url}`,alt:p.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),t.jsxs("div",{className:"flex items-center gap-3 text-sm text-white",children:[t.jsx("span",{className:"max-w-[70vw] truncate",children:p.originalName}),t.jsxs("a",{href:`${_n}${p.url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-white/10 px-2 py-1 text-xs hover:bg-white/20",children:[t.jsx(Tn,{size:13,"aria-hidden":!0}),"Open"]})]})]}),x&&t.jsx("button",{type:"button",onClick:()=>o(s+1),className:"absolute right-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Next image",children:t.jsx(Nt,{size:24,"aria-hidden":!0})})]})}function Mm({draft:e,attachmentMarkdown:s,attachmentIds:r,mentions:o}){const m=[e.trim(),s].filter(Boolean).join(`
|
|
12
|
+
|
|
13
|
+
`);return m?{content:m,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function Dm({message:e,content:s,attachments:r,isUser:o,tone:p=o?"user":"agent",workingDir:m,onOpenWorkspaceFile:x,onOpenPreviewUrl:i,onOpenVisualization:n,downloadSessionId:a}){const{t:d}=ce(),c=_.useId(),g=_.useRef(null),[v,b]=_.useState(null),[y,l]=_.useState(!1),[h,u]=_.useState(null),f=Nd(e.teamRunId,e.id,!1),S=f.data?.content,C=S?yn(S,r):void 0,E=!!(C&&C!==s)?C:s,w=!!(e.isTruncated&&!ql(e)),j=v?.messageId===e.id&&v.content===E&&v.expanded,A=_.useCallback(()=>{const I=g.current;I&&l(nm(I.scrollHeight))},[]);_.useLayoutEffect(()=>{A();const I=g.current;if(!I)return;const z=window.requestAnimationFrame(A),$=typeof ResizeObserver>"u"?null:new ResizeObserver(A);return $?.observe(I),window.addEventListener("resize",A),()=>{window.cancelAnimationFrame(z),$?.disconnect(),window.removeEventListener("resize",A)}},[E,A]);const D=_.useCallback(async()=>{if(u(null),j){b({messageId:e.id,content:E,expanded:!1});return}if(w&&!S){const I=await f.refetch();if(I.error){u(Sn(I.error,d("Failed to load full message")));return}const z=I.data?.content?yn(I.data.content,r):E;b({messageId:e.id,content:z,expanded:!0});return}b({messageId:e.id,content:E,expanded:!0})},[r,w,S,f,j,e.id,E,d]),T=(y||w)&&!j,P=y||w,F=f.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:c,ref:g,onLoadCapture:A,className:Z("relative transition-[max-height] duration-200 ease-out",T?"overflow-hidden":""),style:T?{maxHeight:Kl}:void 0,children:[t.jsx(Nm,{content:E,isUser:o,workingDir:m,onOpenWorkspaceFile:x,onOpenPreviewUrl:i,onOpenVisualization:n,downloadSessionId:a}),T&&t.jsx("div",{className:Z("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",p==="system"?"to-amber-50":p==="user"?"to-neutral-900":"to-neutral-100")})]}),P&&t.jsxs("button",{type:"button","aria-expanded":j,"aria-controls":c,"aria-label":d(j?"Collapse message":"Expand full message"),disabled:F,onClick:()=>{D()},className:Z("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300",p==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":p==="user"?"bg-white/10 text-neutral-100 hover:bg-white/15 hover:text-white":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-900",F?"cursor-wait opacity-70":""),children:[j?t.jsx(vl,{size:13}):t.jsx(Ct,{size:13}),t.jsx("span",{children:d(F?"Loading":j?"Collapse message":"Expand full message")})]}),h&&t.jsx("div",{className:Z("mt-1 text-xs",p==="user"?"text-red-200":"text-red-600"),children:h})]})}function Vl({senderName:e,avatar:s,createdAt:r,isUser:o,isSystem:p,children:m,headerAddon:x,bubbleClassName:i,isPending:n}){return p?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-amber-200/80 bg-amber-50 px-3 py-2 text-xs text-amber-900 shadow-sm",children:m})}):t.jsxs("div",{className:Z("group flex items-start gap-3",o?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!o&&t.jsx(Yt,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:Z("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:Z("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",o?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),t.jsx(us,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:_m(r)}),x]}),t.jsx("div",{className:Z("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",o?"rounded-tr-[2px] border border-neutral-900 bg-neutral-900 text-white shadow-sm":"rounded-tl-[2px] bg-neutral-100 text-neutral-900 shadow-sm",i,n?"opacity-70":""),children:m})]}),o&&t.jsx(Yt,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function Pm({provider:e}){return t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[10rem] shrink items-center gap-1 rounded-full bg-neutral-900/5 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:[t.jsx(xi,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function Lm({message:e,senderName:s,senderMember:r,senderProvider:o,memberById:p,displayContent:m,onOpenImage:x,workingDir:i,onOpenWorkspaceFile:n,onOpenPreviewUrl:a,onOpenVisualization:d,previewWorkspaceId:c,previewSessionId:g}){const{t:v}=ce(),b=e.senderType==="user",y=e.senderType==="system",l=ql(e)?e.pendingStatus:null,h=e.mentions??[],u=e.workRequestIds?.length??0,f=e.visibility==="PRIVATE",S=_.useCallback(w=>{a?.(w,c)},[a,c]),C=_.useCallback(w=>{g&&d?.(g,w,c)},[d,g,c]),k=f?km(e,p):[],E=t.jsxs(t.Fragment,{children:[!b&&!y&&o&&t.jsx(Pm,{provider:o}),f&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-sky-700",title:k.join(", "),children:[t.jsx(jd,{size:10}),t.jsxs("span",{className:"truncate",children:[v("Private"),k.length>0?`: ${k.join(", ")}`:""]})]}),!y&&u>0&&h.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-600",children:[v("Work requests"),": ",u]}),l==="sending"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:v("发送中...")}),l==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-red-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-red-600",children:v("发送失败")})]});return t.jsx(Vl,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:b,isSystem:y,headerAddon:E,bubbleClassName:b&&l==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:l==="sending",children:t.jsx(Am,{message:e,content:m,attachmentIds:e.attachmentIds,isUser:b&&l!=="failed",tone:y?"system":void 0,onOpenImage:x,workingDir:i,onOpenWorkspaceFile:n,onOpenPreviewUrl:a?S:void 0,onOpenVisualization:d&&g?C:void 0,downloadSessionId:g})})}function Im({request:e,member:s,onApprove:r,onReject:o,isActionPending:p,isApprovePending:m,isRejectPending:x}){const{t:i}=ce();return t.jsx(Vl,{senderName:s?.name??i("Agent"),avatar:s?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700",children:[t.jsx(us,{size:11}),i("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[i("Requester"),": ",i(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instructionPreview??ym(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(je,{type:"button",size:"xs",variant:"outline",disabled:p,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(Wt,{size:12}),t.jsx("span",{children:i(m?"Approving":"Approve")})]}),t.jsxs(je,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:o,children:[t.jsx(Xt,{size:12}),t.jsx("span",{children:i(x?"Rejecting":"Reject")})]})]})]})})}function Yl({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:p,onViewInvocationSession:m,changeSummaryBar:x,compactComposer:i,centered:n,workingDir:a,onOpenWorkspaceFile:d,onOpenPreviewUrl:c,onOpenVisualization:g}){const{t:v}=ce(),b=$a(e.id),y=Ka(e.id),l=qa(e.id),[h,u]=_.useState(""),[f,S]=_.useState(!1),[C,k]=_.useState(null),[E,w]=_.useState(0),[j,A]=_.useState([]),[D,T]=_.useState(!1),[P,F]=_.useState(null),[I,z]=_.useState([]),[$,R]=_.useState(null),L=_.useRef(null),M=_.useRef(null),{files:O,addFiles:q,removeFile:V,clear:H,restoreFiles:W,buildMarkdownLinks:U,getDoneAttachments:N,isUploading:B}=Kn(),K=O.some(X=>X.status==="done"&&X.attachment),[Y,J]=_.useState(null),{scrollRef:G,contentRef:de,isAtBottom:he,scrollToBottom:re}=Bn({resize:"smooth",initial:"instant"}),ne=_.useRef(!1),le=_.useRef(null);_.useEffect(()=>{const X=G.current;if(!X)return;const se=ie=>{if(ie.deltaY<0){ne.current=!0;return}ie.deltaY>0&&X.scrollHeight-X.scrollTop-X.clientHeight<=70&&(ne.current=!1)};return X.addEventListener("wheel",se,{passive:!0}),()=>X.removeEventListener("wheel",se)},[G]);const{data:_e}=Gs(),We=_.useMemo(()=>{const X=new Map;for(const se of _e??[])X.set(se.provider.id,se.provider);return X},[_e]),Ce=_.useMemo(()=>new Map((e.members??[]).map(X=>[X.id,X])),[e.members]),He=_.useMemo(()=>(e.members??[]).filter(Yo),[e.members]),at=_.useMemo(()=>new Map((e.invocations??[]).map(X=>[X.id,X])),[e.invocations]),Me=_.useMemo(()=>{const X=new Set(s.map(ie=>ie.id)),se=I.filter(ie=>!X.has(ie.id));return[...s,...se].sort((ie,ae)=>{const Se=Date.parse(ie.createdAt??""),we=Date.parse(ae.createdAt??"");return(Number.isNaN(Se)?0:Se)-(Number.isNaN(we)?0:we)})},[s,I]),Ne=_.useMemo(()=>new Map((e.workRequests??[]).map(X=>[X.id,X])),[e.workRequests]),Oe=_.useMemo(()=>cm(Me,e.workRequests??[],e.invocations??[]),[Me,e.invocations,e.workRequests]);_.useEffect(()=>{const X=Oe.at(-1)?.key??null,se=le.current;le.current=X,!(se==null||X==null||X===se||ne.current)&&requestAnimationFrame(()=>{re({animation:"smooth",ignoreEscapes:!0})})},[re,Oe]);const $e=_.useMemo(()=>(e.invocations??[]).filter(X=>Ei.has(X.status)),[e.invocations]),Ke=_.useMemo(()=>j.map(X=>Ce.get(X)).filter(X=>!!X).filter(Yo),[Ce,j]),De=_.useMemo(()=>{const X=C?.query??"";return He.filter(se=>wm(se,X)).sort((se,ie)=>{const ae=j.includes(se.id),Se=j.includes(ie.id);return ae!==Se?ae?1:-1:se.name.localeCompare(ie.name)})},[He,C?.query,j]),Xe=!r&&(f||!!C)&&De.length>0,Ge=_.useCallback((X,se)=>{if(se==null){k(null);return}k(Sm(X,se)),w(0)},[]),Te=_.useCallback(X=>{A(we=>om(we,X.id));const se=`@${X.name} `;if(C){const we=`${h.slice(0,C.start)}${se}${h.slice(C.end)}`,Pe=C.start+se.length;u(we),k(null),S(!1),requestAnimationFrame(()=>{L.current?.focus(),L.current?.setSelectionRange(Pe,Pe)});return}const ie=h.length===0||/\s$/.test(h)?"":" ",ae=`${h}${ie}${se}`,Se=ae.length;u(ae),S(!1),requestAnimationFrame(()=>{L.current?.focus(),L.current?.setSelectionRange(Se,Se)})},[h,C]),pe=_.useCallback(X=>{A(se=>am(se,X))},[]),tt=_.useCallback(X=>{const se=X.target.value;u(se),F(null);const ie=X.target;ie.style.height="auto",ie.style.height=`${Math.max(i?40:72,Math.min(ie.scrollHeight,i?140:240))}px`,S(!1),Ge(se,ie.selectionStart)},[i,Ge]),Ye=_.useCallback(X=>{const se=X.target.files;se&&se.length>0&&(q(Array.from(se)),F(null)),X.target.value=""},[q]),Ue=_.useCallback(X=>{const se=[];for(const ie of X.clipboardData.items)if(ie.kind==="file"){const ae=ie.getAsFile();ae&&se.push(ae)}se.length>0&&(X.preventDefault(),q(se),F(null))},[q]),ft=_.useCallback(async()=>{if(r||D||B)return;const X=U(),se=N().map(xe=>xe.id),ie=lm(j,He),ae=Mm({draft:h,attachmentMarkdown:X,attachmentIds:se,mentions:ie});if(!ae||!h.trim()&&!K)return;const Se=vm(e.id,ae),we=h,Pe=j,Ze=O;z(xe=>[...xe,Se]),u(""),A([]),S(!1),k(null),H(),L.current&&(L.current.style.height=i?"40px":"72px"),requestAnimationFrame(()=>re()),T(!0),F(null);try{const xe=await p(ae);z(ve=>ve.filter(me=>me.id!==Se.id)),xe&&typeof xe=="object"&&"id"in xe&&requestAnimationFrame(()=>re())}catch(xe){const ve=xe instanceof Error?xe.message:"Failed to send room message";z(me=>me.map(Fe=>Fe.id===Se.id?{...Fe,pendingStatus:"failed",error:ve}:Fe)),u(me=>me.length===0?we:me),A(me=>me.length===0?Pe:me),W(Ze),F(ve),requestAnimationFrame(()=>re())}finally{T(!1)}},[He,O,U,H,i,h,N,K,D,B,p,r,W,re,j,e.id]),st=_.useCallback(X=>{const se=X.nativeEvent.isComposing||X.nativeEvent.keyCode===229;if(Xe){if(X.key==="ArrowDown"){X.preventDefault(),w(ie=>(ie+1)%De.length);return}if(X.key==="ArrowUp"){X.preventDefault(),w(ie=>(ie-1+De.length)%De.length);return}if(X.key==="Enter"&&!se||X.key==="Tab"){X.preventDefault();const ie=De[E]??De[0];ie&&Te(ie);return}if(X.key==="Escape"){X.preventDefault(),k(null),S(!1);return}}X.key==="Enter"&&!X.shiftKey&&!X.repeat&&!se&&(X.preventDefault(),ft())},[Te,ft,E,De,Xe]);_.useEffect(()=>{u(""),A([]),S(!1),k(null),F(null),z([]),H(),ne.current=!1,le.current=null,R(null),L.current&&(L.current.style.height=i?"40px":"72px")},[H,i,e.id]);const te=b.isError?b.error:y.isError?y.error:null,fe=b.isPending||y.isPending,ye=_.useCallback((X,se)=>{l.mutate({memberId:X,cancelQueued:se},{onSuccess:()=>R(null)})},[l]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[Y&&t.jsx(Tm,{images:Y.images,index:Y.index,onClose:()=>J(null),onSelect:X=>J(se=>se&&{...se,index:X})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:G,className:Z("h-full overflow-y-auto scrollbar-app-thin bg-white",i?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:de,className:Z(i?"space-y-2.5":"space-y-3",n&&"max-w-4xl mx-auto"),children:[Oe.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-white text-neutral-500",children:[t.jsx(Es,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:v("No room messages yet")})]}):Oe.map(X=>{if(X.kind==="pendingApproval"){const ve=X.request,me=Ce.get(ve.targetMemberId),Fe=b.isPending&&b.variables===ve.id,rt=y.isPending&&y.variables===ve.id;return t.jsx(Im,{request:ve,member:me,onApprove:()=>b.mutate(ve.id),onReject:()=>y.mutate(ve.id),isActionPending:fe,isApprovePending:Fe,isRejectPending:rt},X.key)}const se=X.message,ie=jm(se,Ce,at),ae=se.senderType==="user"?v("你"):se.senderType==="system"?v("System"):ie?.name??v("Agent"),Se=Em(se,Ce),we=ie?.providerId?We.get(ie.providerId)??null:null,Pe=se.senderInvocationId?at.get(se.senderInvocationId):void 0,Ze=Pe?.workspaceId??void 0,xe=Pe?.sessionId??void 0;return t.jsx(Lm,{message:se,senderName:ae,senderMember:ie,senderProvider:we,memberById:Ce,displayContent:Se,onOpenImage:(ve,me)=>J({images:ve,index:me}),workingDir:a,onOpenWorkspaceFile:d,onOpenPreviewUrl:c,onOpenVisualization:g,previewWorkspaceId:Ze,previewSessionId:xe},X.key)}),te&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Sn(te,v("Failed to update work request"))}),l.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Sn(l.error,v("Failed to stop member work"))})]})}),!he&&t.jsxs("button",{type:"button",onClick:()=>re(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-neutral-200 bg-white/90 px-3 py-1.5 text-xs text-neutral-600 shadow-md backdrop-blur-sm hover:bg-white hover:text-neutral-900 transition-colors",children:[t.jsx(br,{size:14}),t.jsx("span",{children:v("Back to bottom")})]})]}),t.jsx("div",{className:Z("shrink-0 border-t border-transparent bg-white",i?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:Z(n&&"max-w-4xl mx-auto"),children:[t.jsx(pm,{invocations:$e,memberById:Ce,workRequestById:Ne,onViewInvocationSession:m,onStopMember:ye,isStopPending:l.isPending,stoppingMemberId:l.variables?.memberId??null,stopPromptInvocationId:$,onToggleStopConfirm:X=>R(se=>se===X?null:X)}),!r&&x,r?t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:o??v("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white shadow-sm transition-all duration-200 hover:shadow-md focus-within:border-neutral-300 focus-within:shadow-md",children:[Xe&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xl",children:[t.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:v(C?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:De.map((X,se)=>{const ie=j.includes(X.id),ae=se===E;return t.jsxs("button",{type:"button",onMouseEnter:()=>w(se),onMouseDown:Se=>{Se.preventDefault(),Te(X)},className:Z("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",ae?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(Yt,{name:X.name,avatar:X.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:X.name}),ie&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:v("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[X.providerId,X.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(jo,{size:15,className:"text-neutral-400"})]},X.id)})})]}),Ke.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:Ke.map(X=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-1 text-xs text-neutral-700",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",X.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:X.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>pe(X.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:v("Remove mention"),"aria-label":`${v("Remove mention")} ${X.name}`,children:t.jsx(Xt,{size:12})})]},X.id))}),t.jsx(qn,{files:O,onRemove:V}),t.jsx("textarea",{ref:L,value:h,rows:i?1:void 0,onChange:tt,onKeyDown:st,onPaste:Ue,onClick:X=>Ge(h,X.currentTarget.selectionStart),onSelect:X=>Ge(h,X.currentTarget.selectionStart),placeholder:v("Message the team room..."),className:Z("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",i?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:i?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:Z("flex items-center justify-between",i?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{ref:M,type:"file",multiple:!0,className:"hidden",onChange:Ye}),t.jsx("button",{type:"button",onClick:()=>M.current?.click(),title:v("Upload file"),"aria-label":v("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(Yn,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{S(X=>!X),k(null),requestAnimationFrame(()=>L.current?.focus())},disabled:Ke.length===0&&He.length===0,title:v("Mention members"),"aria-label":v("Mention members"),className:Z("rounded-lg transition-colors",i?"p-1.5":"p-2",f?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",Ke.length===0&&He.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(jo,{size:i?15:18})}),Ke.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[Ke.length," ",v("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{ft()},disabled:r||D||B||!h.trim()&&!K,title:v(B?"Uploading...":D?"发送中...":"发送"),"aria-label":v(B?"Uploading...":D?"发送中...":"发送"),className:Z("rounded-lg transition-all duration-200",i?"p-1.5":"p-2",(h.trim()||K)&&!r&&!D&&!B?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",D||B?"opacity-70":""),children:t.jsx(Un,{size:i?15:18})})]}),P&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:P})]})]})})]})}function Om(e){return e?e.slice(0,8):""}function Xo(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function no(e){return e?.workspaceKind===xt.MAIN_DIRECTORY}function Ys(e){return e?no(e)?"Project directory":e.branchName:"—"}function hs(e){return e?.workingDir||e?.worktreePath||void 0}function oo(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(m=>[m.id,m])),o=new Map(e.map(m=>[m.id,m])),p=s?.mainWorkspaceId??null;return e.map(m=>{const x=m.parentWorkspaceId?o.get(m.parentWorkspaceId):void 0,i=m.ownerMemberId?r.get(m.ownerMemberId):void 0,n=!!(p&&m.id===p),a=n?"main":m.parentWorkspaceId?"child":"root",d=i?.name??(m.ownerMemberId?`Member ${Om(m.ownerMemberId)}`:void 0),c=no(m)?"Project directory":n?"Main workspace":a==="child"?d?`${d} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:m,kind:a,roleLabel:n?"Main":a==="child"?"Child":"Root",displayName:c,ownerName:d,parentBranchName:x?Ys(x):void 0,isMain:n}}).sort((m,x)=>{const i=a=>a.kind==="main"?0:a.kind==="child"?1:2,n=i(m)-i(x);return n!==0?n:Xo(m.workspace.createdAt)-Xo(x.workspace.createdAt)})}function Xl(e,s,r){if(e?.length)return r&&e.some(o=>o.id===r)?r:s?.mainWorkspaceId&&e.some(o=>o.id===s.mainWorkspaceId)?s.mainWorkspaceId:e.find(o=>o.status===Mt.ACTIVE)?.id??e[0]?.id}function Gl(e,s){return!e||e.status!==Mt.ACTIVE||no(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function Ql(e,s,r){return e?.parentWorkspaceId?s?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:e?.baseBranch||r}const ao={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},Bm=[{key:"readRoom",label:"读房间"},{key:"postRoomMessage",label:"发房间消息"},{key:"mentionMembers",label:"提及成员"},{key:"stopMemberWork",label:"停止成员工作"},{key:"markReadyForReview",label:"标记可审查"},{key:"readFiles",label:"读文件"},{key:"writeFiles",label:"写文件"},{key:"runCommands",label:"运行命令"},{key:"readDiff",label:"读 diff"},{key:"mergeWorkspace",label:"合并工作区"}],Zl=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],Fm=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],Jl=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],zm=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function ar(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...ao},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function Is(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...ao,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Vi(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...ao,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Wm(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function Hm(e){return{name:e.name.trim(),aliases:Wm(e.aliasesText),providerId:e.providerId.trim(),rolePrompt:e.rolePrompt.trim(),capabilities:{...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar.trim()||null}}function Go(e,s){return e instanceof Error?e.message:s}function Qo(e){return e.membershipStatus!=="REMOVED"}function wn(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function Zo(e){return wn(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function Jo(e){return Zl.find(s=>s.value===e)?.label??e}function Um(e){return Jl.find(s=>s.value===e)?.label??e}function qt({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function ea({icon:e,title:s,description:r,action:o}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-neutral-200 bg-white px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-neutral-100 text-neutral-500",children:e}),t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:s}),r?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-neutral-500",children:r}):null,o?t.jsx("div",{className:"mt-4",children:o}):null]})}function $m({isOpen:e,onClose:s,teamRun:r}){const{t:o}=ce(),{data:p=[]}=Rd(),{data:m=[]}=Gs(),x=Ad(r.id),i=Td(r.id),n=Md(r.id),a=_.useRef(!1),[d,c]=_.useState("edit"),[g,v]=_.useState(null),[b,y]=_.useState(""),[l,h]=_.useState(ar()),[u,f]=_.useState(null),[S,C]=_.useState(null),k=r.members??[],E=_.useMemo(()=>k.filter(Qo),[k]),w=_.useMemo(()=>S&&Qo(S)&&!E.some(U=>U.id===S.id)?[...E,S]:E,[S,E]),j=g?E.find(U=>U.id===g)??null:null,A=S?.id===g?S:j,D=b?p.find(U=>U.id===b)??null:null,T=x.isPending||i.isPending||n.isPending,P=w.filter(wn).length,F=_.useMemo(()=>{const U=m.map(({provider:N,availability:B})=>({value:N.id,label:N.name+(B.type==="NOT_FOUND"?o(" (不可用)"):""),icon:t.jsx(xi,{agentType:N.agentType,className:"size-4"}),disabled:B.type==="NOT_FOUND"}));return l.providerId&&!U.some(N=>N.value===l.providerId)&&U.unshift({value:l.providerId,label:`${l.providerId}${o(" (不可用)")}`,disabled:!0}),U},[l.providerId,m,o]);_.useEffect(()=>{if(!e){a.current=!1,C(null);return}if(a.current)return;a.current=!0;const U=w[0]??null;c(U?"edit":"add-preset"),v(U?.id??null),y(""),h(U?Is(U):ar()),f(null)},[w,e]),_.useEffect(()=>{S&&E.some(U=>U.id===S.id)&&C(null)},[S,E]),_.useEffect(()=>{d==="add-preset"&&D&&h(Vi(D))},[d,D]);const I=(U,N)=>{h(B=>({...B,[U]:N}))},z=(U,N)=>{h(B=>({...B,capabilities:{...B.capabilities,[U]:N}}))},$=U=>{c("edit"),v(U.id),y(""),h(Is(U))},R=()=>{c("add-preset"),v(null);const U=D??p[0]??null;y(U?.id??""),h(U?Vi(U):ar())},L=()=>{c("add-custom"),v(null),y(""),h(ar())},M=!!(l.name.trim()&&l.providerId.trim()&&l.rolePrompt.trim()),O=d==="add-preset"?!!b:d==="edit"?!!(A&&M):M,q=async()=>{try{if(d==="add-preset"){if(!b)return;const N=await x.mutateAsync({memberPresetId:b});Je.success(o("Member added")),C(N),c("edit"),v(N.id),y(""),h(Is(N));return}const U=Hm(l);if(!U.name||!U.providerId||!U.rolePrompt){Je.error(o("Name, provider, and role prompt are required"));return}if(d==="add-custom"){const N=await x.mutateAsync({member:U});Je.success(o("Member added")),C(N),c("edit"),v(N.id),h(Is(N));return}if(A){const N=await i.mutateAsync({memberId:A.id,data:U});Je.success(o("Member updated")),C(B=>B?.id===N.id?N:B),v(N.id),h(Is(N))}}catch(U){Je.error(Go(U,o("Failed to save member")))}},V=async()=>{if(u)try{if(await n.mutateAsync({memberId:u.id,stopActive:!0,cancelQueued:!0}),g===u.id){const U=w.find(N=>N.id!==u.id)??null;v(U?.id??null),c(U?"edit":"add-preset"),h(U?Is(U):ar())}C(U=>U?.id===u.id?null:U),f(null),Je.success(o("Member removed"))}catch(U){Je.error(Go(U,o("Failed to remove member")))}},H=()=>t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(Kr,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(je,{type:"button",variant:"outline",size:"sm",onClick:L,disabled:T,children:[t.jsx(Ro,{size:13}),o("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:p.length===0?t.jsx(ea,{icon:t.jsx(Kr,{size:18}),title:o("No member presets"),description:o("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(je,{type:"button",variant:"outline",size:"sm",onClick:L,disabled:T,children:[t.jsx(ds,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:p.map(U=>{const N=b===U.id;return t.jsxs("button",{type:"button",onClick:()=>{y(U.id),h(Vi(U))},className:Z("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",N?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx(Yt,{name:U.name,avatar:U.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-neutral-900",children:U.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:U.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(Jo(U.workspacePolicy))," · ",o(Um(U.sessionPolicy))]})]}),N?t.jsx(Wt,{size:16,className:"shrink-0 text-neutral-900"}):null]},U.id)})})})]}),W=()=>{const U=d==="edit";return U&&!A?t.jsx("div",{className:"p-5",children:t.jsx(ea,{icon:t.jsx(Es,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(je,{type:"button",variant:"outline",size:"sm",onClick:R,disabled:T,children:[t.jsx(ds,{size:13}),o("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[U?t.jsx(Sl,{size:15,className:"text-neutral-500"}):t.jsx(ds,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(U?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(U?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),U&&A?t.jsxs(je,{type:"button",variant:"outline",size:"sm",onClick:()=>f(A),disabled:T,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(gi,{size:13}),o("Remove")]}):t.jsxs(je,{type:"button",variant:"outline",size:"sm",onClick:R,disabled:T,children:[t.jsx(Kr,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[U&&A?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2.5",children:[t.jsx(Yt,{name:A.name,avatar:A.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:Z("h-2 w-2 shrink-0 rounded-full",Zo(A))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:A.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[A.providerId," · ",o(Jo(A.workspacePolicy))]})]})]}):null,t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(qt,{children:o("Name")}),t.jsx("input",{value:l.name,onChange:N=>I("name",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(qt,{children:o("Aliases")}),t.jsx("input",{value:l.aliasesText,onChange:N=>I("aliasesText",N.target.value),placeholder:o("Comma separated"),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(qt,{children:o("Provider")}),t.jsx(cs,{value:l.providerId,onChange:N=>I("providerId",N),options:F})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(qt,{children:o("Avatar")}),t.jsx("input",{value:l.avatar,onChange:N=>I("avatar",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(qt,{children:o("Workspace policy")}),t.jsx(cs,{value:l.workspacePolicy,onChange:N=>I("workspacePolicy",N),options:Zl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(qt,{children:o("Trigger policy")}),t.jsx(cs,{value:l.triggerPolicy,onChange:N=>I("triggerPolicy",N),options:Fm.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(qt,{children:o("Session policy")}),t.jsx(cs,{value:l.sessionPolicy,onChange:N=>I("sessionPolicy",N),options:Jl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(qt,{children:o("Queue policy")}),t.jsx(cs,{value:l.queueManagementPolicy,onChange:N=>I("queueManagementPolicy",N),options:zm.map(N=>({value:N.value,label:o(N.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(qt,{children:o("Role prompt")}),t.jsx("textarea",{value:l.rolePrompt,onChange:N=>I("rolePrompt",N.target.value),rows:7,className:"w-full resize-y rounded-lg border border-neutral-200 px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(qt,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:Bm.map(N=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 py-2 text-xs text-neutral-700",children:[t.jsx("input",{type:"checkbox",checked:!!l.capabilities[N.key],onChange:B=>z(N.key,B.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:o(N.label)})]},N.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(ps,{isOpen:e,onClose:T?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(je,{type:"button",variant:"outline",onClick:s,disabled:T,children:o("Close")}),t.jsx(je,{type:"button",onClick:q,disabled:T||!O,children:o(T?"Processing...":d==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-neutral-200 bg-white lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-neutral-200 bg-neutral-50/70 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-neutral-200 px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(Es,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[w.length," ",o("active")," · ",P," ",o("working")]})]}),t.jsx(je,{type:"button",size:"icon-sm",variant:"outline",onClick:R,disabled:T,title:o("Add member"),children:t.jsx(ds,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:w.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-5 text-center text-xs text-neutral-400",children:o("No active members")}):t.jsx("div",{className:"space-y-1",children:w.map(U=>{const N=d==="edit"&&g===U.id;return t.jsxs("button",{type:"button",onClick:()=>$(U),className:Z("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",N?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx(Yt,{name:U.name,avatar:U.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:Z("h-1.5 w-1.5 shrink-0 rounded-full",Zo(U))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:U.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:U.providerId})]}),t.jsx(Xu,{size:13,className:Z("shrink-0 text-neutral-300 transition-opacity",N?"opacity-100":"opacity-0 group-hover:opacity-100")})]},U.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:R,disabled:T,className:Z("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",d==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(Kr,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:L,disabled:T,className:Z("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",d==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(Ro,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:d==="add-preset"?H():W()})]})}),t.jsx(Dn,{isOpen:!!u,onClose:()=>f(null),onConfirm:V,title:o("Remove member"),variant:"danger",isLoading:n.isPending,confirmText:o("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:u?o("Remove this member from future TeamRun work?"):""}),u&&wn(u)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-left text-red-700",children:[t.jsx(Ns,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const Km=[],qm=[],Vm=[],Ym=240;function Xm(e){switch(e){case"RUNNING":return"running";case"WAITING":case"WAITING_ROOM_REPLY":return"waiting room reply";case"QUEUED":return"queued";case"SESSION_ENDED":return"session ended";case"PENDING_APPROVAL":return"pending approval";case"REMOVED":return"removed";default:return"idle"}}const ta={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function Yi(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function sa(e,s){return e instanceof Error?e.message:s}function Gm(e,s=Ym){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function qr(e){return e?e.instructionPreview??Gm(e.instruction):""}function Qm(e){switch(e){case"running":return"Running";case"waiting room reply":return"Waiting room reply";case"queued":return"Queued";case"session ended":return"Session ended";case"pending approval":return"Pending approval";case"removed":return"Removed";case"idle":return"Idle"}}function Zm(e){switch(e){case"running":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"waiting room reply":return"border-amber-200 bg-amber-50 text-amber-700";case"queued":case"session ended":return"border-blue-200 bg-blue-50 text-blue-700";case"pending approval":return"border-neutral-200 bg-neutral-50 text-neutral-600";case"removed":return"border-neutral-200 bg-neutral-50 text-neutral-400";case"idle":return"border-neutral-200 bg-white text-neutral-500"}}function Jm(e){switch(e){case"running":return"bg-emerald-500";case"waiting room reply":return"bg-amber-500";case"queued":case"session ended":return"bg-blue-500";case"pending approval":return"bg-neutral-400";case"removed":return"bg-neutral-300";case"idle":return"bg-neutral-300"}}function ep(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function tp(e){switch(e){case"RUNNING":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"WAITING_ROOM_REPLY":return"border-amber-200 bg-amber-50 text-amber-700";case"QUEUED":case"SESSION_ENDED":return"border-blue-200 bg-blue-50 text-blue-700";case"COMPLETED":return"border-neutral-200 bg-neutral-50 text-neutral-700";case"FAILED":return"border-red-200 bg-red-50 text-red-700";case"CANCELLED":return"border-neutral-200 bg-white text-neutral-500"}}function sp(e){switch(e){case Mt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Mt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Mt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Mt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function rp(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function ip(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function np(e,s){return s.find(r=>r.memberId===e.id&&Ei.has(r.status))}function ec({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:p}){const{t:m}=ce(),x=$a(e.id),i=Ka(e.id),n=qa(e.id),[a,d]=_.useState(null),[c,g]=_.useState(null),[v,b]=_.useState(!1),[y,l]=_.useState(!1),h=e.members??Km,u=_.useMemo(()=>h.filter(I=>I.membershipStatus!=="REMOVED"),[h]),f=e.workRequests??qm,S=e.invocations??Vm,C=_.useMemo(()=>oo(s,e),[e,s]),k=_.useMemo(()=>new Map(f.map(I=>[I.id,I])),[f]),E=_.useMemo(()=>[...f].filter(I=>I.status==="PENDING_APPROVAL").sort((I,z)=>Date.parse(z.updatedAt??z.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),w=_.useMemo(()=>[...f].filter(I=>I.status==="QUEUED").sort((I,z)=>Date.parse(z.updatedAt??z.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),j=_.useMemo(()=>[...h].map(I=>({member:I,status:Xm(I.status)})).sort((I,z)=>ta[I.status]-ta[z.status]),[h]),A=x.isError?x.error:i.isError?i.error:null,D=x.isPending||i.isPending,T=C.find(I=>I.workspace.id===r),P=e.messages??[],F=j.filter(({status:I})=>I==="running"||I==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx($m,{isOpen:y,onClose:()=>l(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(qs,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:m("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:[t.jsx("span",{children:m("Team mode")}),t.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-neutral-100 px-4 py-1.5 shrink-0 text-[10px] text-neutral-500",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Messages"),children:[t.jsx(vi,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:P.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Members"),children:[t.jsx(Es,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:F>0?`${F}/${u.length}`:u.length}),F>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),w.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Queue"),children:[t.jsx(us,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:w.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:m("Pending approval"),children:[t.jsx(us,{size:11}),t.jsx("span",{className:"tabular-nums",children:E.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[E.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-amber-600",children:[t.jsx(us,{size:13}),t.jsx("span",{children:m("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:E.length})]}),t.jsx("div",{className:"space-y-1.5",children:E.map(I=>{const z=h.find(L=>L.id===I.targetMemberId),$=x.isPending&&x.variables===I.id,R=i.isPending&&i.variables===I.id;return t.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Yt,{name:z?.name??"Agent",avatar:z?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:z?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:qr(I)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:m(ep(I.requesterType))}),t.jsx("span",{children:Yi(I.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>x.mutate(I.id),disabled:D,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-emerald-200 bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 transition-colors hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Wt,{size:11}),t.jsx("span",{className:"truncate",children:m($?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>i.mutate(I.id),disabled:D,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Xt,{size:11}),t.jsx("span",{className:"truncate",children:m(R?"Rejecting":"Reject")})]})]})]},I.id)})}),A&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:sa(A,m("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(Es,{size:13}),t.jsx("span",{children:m("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:u.length}),t.jsx("button",{type:"button",onClick:()=>l(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("Manage Team Members"),"aria-label":m("Manage Team Members"),children:t.jsx(Sl,{size:13})})]}),h.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:m("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:j.map(({member:I,status:z})=>{const $=np(I,S),R=ip(S.filter(W=>W.memberId===I.id)),L=$?k.get($.workRequestId):void 0,M=c===I.id,O=z==="running"||z==="waiting room reply",q=O&&!!$,V=a===I.id,H=n.isPending&&n.variables?.memberId===I.id;return t.jsxs("div",{className:Z("bg-white",M&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Yt,{name:I.name,avatar:I.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:Z("h-1.5 w-1.5 shrink-0 rounded-full",Jm(z))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:I.name}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Zm(z)),children:m(Qm(z))})]}),O&&L?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:qr(L)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[q&&t.jsx("button",{type:"button",onClick:()=>d(V?null:I.id),disabled:n.isPending,className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-50",title:m("Stop"),"aria-label":m("Stop"),children:t.jsx(Us,{size:12})}),$?.sessionId&&p&&t.jsx("button",{type:"button",onClick:()=>p($.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("View log"),"aria-label":m("View log"),children:t.jsx(mn,{size:12})}),t.jsx("button",{type:"button",onClick:()=>g(M?null:I.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:m("Details"),"aria-label":m("Details"),"aria-expanded":M,children:M?t.jsx(Ct,{size:13}):t.jsx(Nt,{size:13})})]})]}),q&&V&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:m("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:I.id,cancelQueued:!1},{onSuccess:()=>d(null)})},disabled:n.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Us,{size:10}),t.jsx("span",{children:H&&n.variables?.cancelQueued===!1?m("Stopping"):m("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:I.id,cancelQueued:!0},{onSuccess:()=>d(null)})},disabled:n.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(_l,{size:10}),t.jsx("span",{children:H&&n.variables?.cancelQueued===!0?m("Stopping"):m("Stop + clear queue")})]})]})]}),M&&t.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[t.jsx("span",{children:I.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.sessionPolicy==="resume_last"?m("Resume last session"):m("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:m("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:R.length})]}),R.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:R.map(W=>{const U=k.get(W.workRequestId),N=!!(W.sessionId&&p);return t.jsx("div",{className:"rounded-md border border-neutral-100 bg-white px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:Z("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",tp(W.status)),children:W.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:Yi(W.updatedAt??W.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:qr(U)||W.workRequestId})]}),N&&t.jsxs("button",{type:"button",onClick:()=>W.sessionId&&p?.(W.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-neutral-200 bg-white px-1.5 text-[10px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100",title:m("View log"),"aria-label":m("View log"),children:[t.jsx(mn,{size:10}),t.jsx("span",{children:m("Log")})]})]})},W.id)})})]}),j[j.length-1]?.member.id!==I.id&&!M&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},I.id)})}),n.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:sa(n.error,m("Failed to stop member work"))})]}),w.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(us,{size:13}),t.jsx("span",{children:m("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:w.length})]}),t.jsx("div",{className:"space-y-1",children:w.map(I=>{const z=h.find($=>$.id===I.targetMemberId);return t.jsx("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Yt,{name:z?.name??"Agent",avatar:z?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:z?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:qr(I)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Yi(I.createdAt)})]})},I.id)})})]}),C.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>b(I=>!I),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500 transition-colors hover:text-neutral-700","aria-expanded":v,"aria-label":m("Workspaces"),children:[t.jsx(qs,{size:13}),t.jsx("span",{children:m("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[T&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:Ys(T.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:C.length}),v?t.jsx(Ct,{size:13,className:"text-neutral-400"}):t.jsx(Nt,{size:13,className:"text-neutral-400"})]})]}),v&&t.jsx("div",{className:"space-y-1.5",children:C.map(I=>{const z=r===I.workspace.id;return t.jsx("div",{className:Z("rounded-md border bg-white px-3 py-2",z?"border-neutral-400 shadow-sm":"border-neutral-200"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:m(I.displayName)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",rp(I.roleLabel)),children:m(I.roleLabel)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",sp(I.workspace.status)),children:I.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:Ys(I.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[I.ownerName&&t.jsxs("span",{children:[m("Owner"),": ",I.ownerName]}),I.parentBranchName&&t.jsxs("span",{children:[m("Parent"),": ",I.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(I.workspace.id),disabled:!o||z,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:m("View workspace"),children:[z?t.jsx(Wt,{size:11}):t.jsx(ul,{size:11}),t.jsx("span",{children:m(z?"Selected":"Select")})]})]})},I.workspace.id)})})]}),E.length===0&&w.length===0&&j.every(({status:I})=>I==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("All members idle")})]})]})}var Xi={exports:{}},ra;function op(){return ra||(ra=1,(function(e,s){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(x,i,n){var a=this&&this.__decorate||function(f,S,C,k){var E,w=arguments.length,j=w<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,S,C,k);else for(var A=f.length-1;A>=0;A--)(E=f[A])&&(j=(w<3?E(j):w>3?E(S,C,j):E(S,C))||j);return w>3&&j&&Object.defineProperty(S,C,j),j},d=this&&this.__param||function(f,S){return function(C,k){S(C,k,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.AccessibilityManager=void 0;const c=n(9042),g=n(6114),v=n(9924),b=n(844),y=n(5596),l=n(4725),h=n(3656);let u=i.AccessibilityManager=class extends b.Disposable{constructor(f,S){super(),this._terminal=f,this._renderService=S,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new v.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
14
|
+
`)))),this.register(this._terminal.onA11yTab((C=>this._handleTab(C)))),this.register(this._terminal.onKey((C=>this._handleKey(C.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new y.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,h.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,b.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(f){for(let S=0;S<f;S++)this._handleChar(" ")}_handleChar(f){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==f&&(this._charsToAnnounce+=f):this._charsToAnnounce+=f,f===`
|
|
15
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=c.tooMuchOutput)),g.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((()=>{this._accessibilityContainer.appendChild(this._liveRegion)}),0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,g.isMac&&this._liveRegion.remove()}_handleKey(f){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(f)||this._charsToConsume.push(f)}_refreshRows(f,S){this._liveRegionDebouncer.refresh(f,S,this._terminal.rows)}_renderRows(f,S){const C=this._terminal.buffer,k=C.lines.length.toString();for(let E=f;E<=S;E++){const w=C.translateBufferLineToString(C.ydisp+E,!0),j=(C.ydisp+E+1).toString(),A=this._rowElements[E];A&&(w.length===0?A.innerText=" ":A.textContent=w,A.setAttribute("aria-posinset",j),A.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(f,S){const C=f.target,k=this._rowElements[S===0?1:this._rowElements.length-2];if(C.getAttribute("aria-posinset")===(S===0?"1":`${this._terminal.buffer.lines.length}`)||f.relatedTarget!==k)return;let E,w;if(S===0?(E=C,w=this._rowElements.pop(),this._rowContainer.removeChild(w)):(E=this._rowElements.shift(),w=C,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),w.removeEventListener("focus",this._bottomBoundaryFocusListener),S===0){const j=this._createAccessibilityTreeNode();this._rowElements.unshift(j),this._rowContainer.insertAdjacentElement("afterbegin",j)}else{const j=this._createAccessibilityTreeNode();this._rowElements.push(j),this._rowContainer.appendChild(j)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(S===0?-1:1),this._rowElements[S===0?1:this._rowElements.length-2].focus(),f.preventDefault(),f.stopImmediatePropagation()}_handleResize(f){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let S=this._rowContainer.children.length;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);for(;this._rowElements.length>f;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const f=document.createElement("div");return f.setAttribute("role","listitem"),f.tabIndex=-1,this._refreshRowDimensions(f),f}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let f=0;f<this._terminal.rows;f++)this._refreshRowDimensions(this._rowElements[f])}}_refreshRowDimensions(f){f.style.height=`${this._renderService.dimensions.css.cell.height}px`}};i.AccessibilityManager=u=a([d(1,l.IRenderService)],u)},3614:(x,i)=>{function n(g){return g.replace(/\r?\n/g,"\r")}function a(g,v){return v?"\x1B[200~"+g+"\x1B[201~":g}function d(g,v,b,y){g=a(g=n(g),b.decPrivateModes.bracketedPasteMode&&y.rawOptions.ignoreBracketedPasteMode!==!0),b.triggerDataEvent(g,!0),v.value=""}function c(g,v,b){const y=b.getBoundingClientRect(),l=g.clientX-y.left-10,h=g.clientY-y.top-10;v.style.width="20px",v.style.height="20px",v.style.left=`${l}px`,v.style.top=`${h}px`,v.style.zIndex="1000",v.focus()}Object.defineProperty(i,"__esModule",{value:!0}),i.rightClickHandler=i.moveTextAreaUnderMouseCursor=i.paste=i.handlePasteEvent=i.copyHandler=i.bracketTextForPaste=i.prepareTextForTerminal=void 0,i.prepareTextForTerminal=n,i.bracketTextForPaste=a,i.copyHandler=function(g,v){g.clipboardData&&g.clipboardData.setData("text/plain",v.selectionText),g.preventDefault()},i.handlePasteEvent=function(g,v,b,y){g.stopPropagation(),g.clipboardData&&d(g.clipboardData.getData("text/plain"),v,b,y)},i.paste=d,i.moveTextAreaUnderMouseCursor=c,i.rightClickHandler=function(g,v,b,y,l){c(g,v,b),l&&y.rightClickSelect(g),v.value=y.selectionText,v.select()}},7239:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorContrastCache=void 0;const a=n(1505);i.ColorContrastCache=class{constructor(){this._color=new a.TwoKeyMap,this._css=new a.TwoKeyMap}setCss(d,c,g){this._css.set(d,c,g)}getCss(d,c){return this._css.get(d,c)}setColor(d,c,g){this._color.set(d,c,g)}getColor(d,c){return this._color.get(d,c)}clear(){this._color.clear(),this._css.clear()}}},3656:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=void 0,i.addDisposableDomListener=function(n,a,d,c){n.addEventListener(a,d,c);let g=!1;return{dispose:()=>{g||(g=!0,n.removeEventListener(a,d,c))}}}},6465:function(x,i,n){var a=this&&this.__decorate||function(l,h,u,f){var S,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,h,u,f);else for(var E=l.length-1;E>=0;E--)(S=l[E])&&(k=(C<3?S(k):C>3?S(h,u,k):S(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(l,h){return function(u,f){h(u,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Linkifier2=void 0;const c=n(3656),g=n(8460),v=n(844),b=n(2585);let y=i.Linkifier2=class extends v.Disposable{get currentLink(){return this._currentLink}constructor(l){super(),this._bufferService=l,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,v.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,v.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(l){return this._linkProviders.push(l),{dispose:()=>{const h=this._linkProviders.indexOf(l);h!==-1&&this._linkProviders.splice(h,1)}}}attachToDom(l,h,u){this._element=l,this._mouseService=h,this._renderService=u,this.register((0,c.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,c.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(l){if(this._lastMouseEvent=l,!this._element||!this._mouseService)return;const h=this._positionFromMouseEvent(l,this._element,this._mouseService);if(!h)return;this._isMouseOut=!1;const u=l.composedPath();for(let f=0;f<u.length;f++){const S=u[f];if(S.classList.contains("xterm"))break;if(S.classList.contains("xterm-hover"))return}this._lastBufferCell&&h.x===this._lastBufferCell.x&&h.y===this._lastBufferCell.y||(this._handleHover(h),this._lastBufferCell=h)}_handleHover(l){if(this._activeLine!==l.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(l,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,l)||(this._clearCurrentLink(),this._askForLink(l,!0))}_askForLink(l,h){var u,f;this._activeProviderReplies&&h||((u=this._activeProviderReplies)===null||u===void 0||u.forEach((C=>{C?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=l.y);let S=!1;for(const[C,k]of this._linkProviders.entries())h?!((f=this._activeProviderReplies)===null||f===void 0)&&f.get(C)&&(S=this._checkLinkProviderResult(C,l,S)):k.provideLinks(l.y,(E=>{var w,j;if(this._isMouseOut)return;const A=E?.map((D=>({link:D})));(w=this._activeProviderReplies)===null||w===void 0||w.set(C,A),S=this._checkLinkProviderResult(C,l,S),((j=this._activeProviderReplies)===null||j===void 0?void 0:j.size)===this._linkProviders.length&&this._removeIntersectingLinks(l.y,this._activeProviderReplies)}))}_removeIntersectingLinks(l,h){const u=new Set;for(let f=0;f<h.size;f++){const S=h.get(f);if(S)for(let C=0;C<S.length;C++){const k=S[C],E=k.link.range.start.y<l?0:k.link.range.start.x,w=k.link.range.end.y>l?this._bufferService.cols:k.link.range.end.x;for(let j=E;j<=w;j++){if(u.has(j)){S.splice(C--,1);break}u.add(j)}}}}_checkLinkProviderResult(l,h,u){var f;if(!this._activeProviderReplies)return u;const S=this._activeProviderReplies.get(l);let C=!1;for(let k=0;k<l;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(C=!0);if(!C&&S){const k=S.find((E=>this._linkAtPosition(E.link,h)));k&&(u=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!u)for(let k=0;k<this._activeProviderReplies.size;k++){const E=(f=this._activeProviderReplies.get(k))===null||f===void 0?void 0:f.find((w=>this._linkAtPosition(w.link,h)));if(E){u=!0,this._handleNewLink(E);break}}return u}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(l){if(!this._element||!this._mouseService||!this._currentLink)return;const h=this._positionFromMouseEvent(l,this._element,this._mouseService);h&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,h)&&this._currentLink.link.activate(l,this._currentLink.link.text)}_clearCurrentLink(l,h){this._element&&this._currentLink&&this._lastMouseEvent&&(!l||!h||this._currentLink.link.range.start.y>=l&&this._currentLink.link.range.end.y<=h)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,v.disposeArray)(this._linkCacheDisposables))}_handleNewLink(l){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const h=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);h&&this._linkAtPosition(l.link,h)&&(this._currentLink=l,this._currentLink.state={decorations:{underline:l.link.decorations===void 0||l.link.decorations.underline,pointerCursor:l.link.decorations===void 0||l.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,l.link,this._lastMouseEvent),l.link.decorations={},Object.defineProperties(l.link.decorations,{pointerCursor:{get:()=>{var u,f;return(f=(u=this._currentLink)===null||u===void 0?void 0:u.state)===null||f===void 0?void 0:f.decorations.pointerCursor},set:u=>{var f,S;!((f=this._currentLink)===null||f===void 0)&&f.state&&this._currentLink.state.decorations.pointerCursor!==u&&(this._currentLink.state.decorations.pointerCursor=u,this._currentLink.state.isHovered&&((S=this._element)===null||S===void 0||S.classList.toggle("xterm-cursor-pointer",u)))}},underline:{get:()=>{var u,f;return(f=(u=this._currentLink)===null||u===void 0?void 0:u.state)===null||f===void 0?void 0:f.decorations.underline},set:u=>{var f,S,C;!((f=this._currentLink)===null||f===void 0)&&f.state&&((C=(S=this._currentLink)===null||S===void 0?void 0:S.state)===null||C===void 0?void 0:C.decorations.underline)!==u&&(this._currentLink.state.decorations.underline=u,this._currentLink.state.isHovered&&this._fireUnderlineEvent(l.link,u))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((u=>{if(!this._currentLink)return;const f=u.start===0?0:u.start+1+this._bufferService.buffer.ydisp,S=this._bufferService.buffer.ydisp+1+u.end;if(this._currentLink.link.range.start.y>=f&&this._currentLink.link.range.end.y<=S&&(this._clearCurrentLink(f,S),this._lastMouseEvent&&this._element)){const C=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);C&&this._askForLink(C,!1)}}))))}_linkHover(l,h,u){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!0),this._currentLink.state.decorations.pointerCursor&&l.classList.add("xterm-cursor-pointer")),h.hover&&h.hover(u,h.text)}_fireUnderlineEvent(l,h){const u=l.range,f=this._bufferService.buffer.ydisp,S=this._createLinkUnderlineEvent(u.start.x-1,u.start.y-f-1,u.end.x,u.end.y-f-1,void 0);(h?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(S)}_linkLeave(l,h,u){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!1),this._currentLink.state.decorations.pointerCursor&&l.classList.remove("xterm-cursor-pointer")),h.leave&&h.leave(u,h.text)}_linkAtPosition(l,h){const u=l.range.start.y*this._bufferService.cols+l.range.start.x,f=l.range.end.y*this._bufferService.cols+l.range.end.x,S=h.y*this._bufferService.cols+h.x;return u<=S&&S<=f}_positionFromMouseEvent(l,h,u){const f=u.getCoords(l,h,this._bufferService.cols,this._bufferService.rows);if(f)return{x:f[0],y:f[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(l,h,u,f,S){return{x1:l,y1:h,x2:u,y2:f,cols:this._bufferService.cols,fg:S}}};i.Linkifier2=y=a([d(0,b.IBufferService)],y)},9042:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.tooMuchOutput=i.promptLabel=void 0,i.promptLabel="Terminal input",i.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(x,i,n){var a=this&&this.__decorate||function(y,l,h,u){var f,S=arguments.length,C=S<3?l:u===null?u=Object.getOwnPropertyDescriptor(l,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(y,l,h,u);else for(var k=y.length-1;k>=0;k--)(f=y[k])&&(C=(S<3?f(C):S>3?f(l,h,C):f(l,h))||C);return S>3&&C&&Object.defineProperty(l,h,C),C},d=this&&this.__param||function(y,l){return function(h,u){l(h,u,y)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const c=n(511),g=n(2585);let v=i.OscLinkProvider=class{constructor(y,l,h){this._bufferService=y,this._optionsService=l,this._oscLinkService=h}provideLinks(y,l){var h;const u=this._bufferService.buffer.lines.get(y-1);if(!u)return void l(void 0);const f=[],S=this._optionsService.rawOptions.linkHandler,C=new c.CellData,k=u.getTrimmedLength();let E=-1,w=-1,j=!1;for(let A=0;A<k;A++)if(w!==-1||u.hasContent(A)){if(u.loadCell(A,C),C.hasExtendedAttrs()&&C.extended.urlId){if(w===-1){w=A,E=C.extended.urlId;continue}j=C.extended.urlId!==E}else w!==-1&&(j=!0);if(j||w!==-1&&A===k-1){const D=(h=this._oscLinkService.getLinkData(E))===null||h===void 0?void 0:h.uri;if(D){const T={start:{x:w+1,y},end:{x:A+(j||A!==k-1?0:1),y}};let P=!1;if(!S?.allowNonHttpProtocols)try{const F=new URL(D);["http:","https:"].includes(F.protocol)||(P=!0)}catch{P=!0}P||f.push({text:D,range:T,activate:(F,I)=>S?S.activate(F,I,T):b(0,I),hover:(F,I)=>{var z;return(z=S?.hover)===null||z===void 0?void 0:z.call(S,F,I,T)},leave:(F,I)=>{var z;return(z=S?.leave)===null||z===void 0?void 0:z.call(S,F,I,T)}})}j=!1,C.hasExtendedAttrs()&&C.extended.urlId?(w=A,E=C.extended.urlId):(w=-1,E=-1)}}l(f)}};function b(y,l){if(confirm(`Do you want to navigate to ${l}?
|
|
16
|
+
|
|
17
|
+
WARNING: This link could potentially be dangerous`)){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=l}else console.warn("Opening link blocked as opener could not be cleared")}}i.OscLinkProvider=v=a([d(0,g.IBufferService),d(1,g.IOptionsService),d(2,g.IOscLinkService)],v)},6193:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RenderDebouncer=void 0,i.RenderDebouncer=class{constructor(n,a){this._parentWindow=n,this._renderCallback=a,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(n){return this._refreshCallbacks.push(n),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(n,a,d){this._rowCount=d,n=n!==void 0?n:0,a=a!==void 0?a:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,a):a,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const n=Math.max(this._rowStart,0),a=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,a),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const n of this._refreshCallbacks)n(0);this._refreshCallbacks=[]}}},5596:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ScreenDprMonitor=void 0;const a=n(844);class d extends a.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,a.toDisposable)((()=>{this.clearListener()})))}setListener(g){this._listener&&this.clearListener(),this._listener=g,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var g;this._outerListener&&((g=this._resolutionMediaMatchList)===null||g===void 0||g.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}i.ScreenDprMonitor=d},3236:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Terminal=void 0;const a=n(3614),d=n(3656),c=n(6465),g=n(9042),v=n(3730),b=n(1680),y=n(3107),l=n(5744),h=n(2950),u=n(1296),f=n(428),S=n(4269),C=n(5114),k=n(8934),E=n(3230),w=n(9312),j=n(4725),A=n(6731),D=n(8055),T=n(8969),P=n(8460),F=n(844),I=n(6114),z=n(8437),$=n(2584),R=n(7399),L=n(5941),M=n(9074),O=n(2585),q=n(5435),V=n(4567),H=typeof window<"u"?window.document:null;class W extends T.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(N={}){super(N),this.browser=I,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new F.MutableDisposable),this._onCursorMove=this.register(new P.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new P.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new P.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new P.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new P.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new P.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new P.EventEmitter),this._onBlur=this.register(new P.EventEmitter),this._onA11yCharEmitter=this.register(new P.EventEmitter),this._onA11yTabEmitter=this.register(new P.EventEmitter),this._onWillOpen=this.register(new P.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(v.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(M.DecorationService),this._instantiationService.setService(O.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((B,K)=>this.refresh(B,K)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((B=>this._reportWindowsOptions(B)))),this.register(this._inputHandler.onColor((B=>this._handleColorEvent(B)))),this.register((0,P.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,P.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,P.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,P.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((B=>this._afterResize(B.cols,B.rows)))),this.register((0,F.toDisposable)((()=>{var B,K;this._customKeyEventHandler=void 0,(K=(B=this.element)===null||B===void 0?void 0:B.parentNode)===null||K===void 0||K.removeChild(this.element)})))}_handleColorEvent(N){if(this._themeService)for(const B of N){let K,Y="";switch(B.index){case 256:K="foreground",Y="10";break;case 257:K="background",Y="11";break;case 258:K="cursor",Y="12";break;default:K="ansi",Y="4;"+B.index}switch(B.type){case 0:const J=D.color.toColorRGB(K==="ansi"?this._themeService.colors.ansi[B.index]:this._themeService.colors[K]);this.coreService.triggerDataEvent(`${$.C0.ESC}]${Y};${(0,L.toRgbString)(J)}${$.C1_ESCAPED.ST}`);break;case 1:if(K==="ansi")this._themeService.modifyColors((G=>G.ansi[B.index]=D.rgba.toColor(...B.color)));else{const G=K;this._themeService.modifyColors((de=>de[G]=D.rgba.toColor(...B.color)))}break;case 2:this._themeService.restoreColor(B.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(N){N?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(V.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(N){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.C0.ESC+"[I"),this.updateCursorStyle(N),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var N;return(N=this.textarea)===null||N===void 0?void 0:N.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const N=this.buffer.ybase+this.buffer.y,B=this.buffer.lines.get(N);if(!B)return;const K=Math.min(this.buffer.x,this.cols-1),Y=this._renderService.dimensions.css.cell.height,J=B.getWidth(K),G=this._renderService.dimensions.css.cell.width*J,de=this.buffer.y*this._renderService.dimensions.css.cell.height,he=K*this._renderService.dimensions.css.cell.width;this.textarea.style.left=he+"px",this.textarea.style.top=de+"px",this.textarea.style.width=G+"px",this.textarea.style.height=Y+"px",this.textarea.style.lineHeight=Y+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,d.addDisposableDomListener)(this.element,"copy",(B=>{this.hasSelection()&&(0,a.copyHandler)(B,this._selectionService)})));const N=B=>(0,a.handlePasteEvent)(B,this.textarea,this.coreService,this.optionsService);this.register((0,d.addDisposableDomListener)(this.textarea,"paste",N)),this.register((0,d.addDisposableDomListener)(this.element,"paste",N)),I.isFirefox?this.register((0,d.addDisposableDomListener)(this.element,"mousedown",(B=>{B.button===2&&(0,a.rightClickHandler)(B,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,d.addDisposableDomListener)(this.element,"contextmenu",(B=>{(0,a.rightClickHandler)(B,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),I.isLinux&&this.register((0,d.addDisposableDomListener)(this.element,"auxclick",(B=>{B.button===1&&(0,a.moveTextAreaUnderMouseCursor)(B,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,d.addDisposableDomListener)(this.textarea,"keyup",(N=>this._keyUp(N)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keydown",(N=>this._keyDown(N)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keypress",(N=>this._keyPress(N)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionupdate",(N=>this._compositionHelper.compositionupdate(N)))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,d.addDisposableDomListener)(this.textarea,"input",(N=>this._inputEvent(N)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(N){var B;if(!N)throw new Error("Terminal requires a parent element.");N.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=N.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),N.appendChild(this.element);const K=H.createDocumentFragment();this._viewportElement=H.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),K.appendChild(this._viewportElement),this._viewportScrollArea=H.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=H.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=H.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),K.appendChild(this.screenElement),this.textarea=H.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),I.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(C.CoreBrowserService,this.textarea,(B=this._document.defaultView)!==null&&B!==void 0?B:window),this._instantiationService.setService(j.ICoreBrowserService,this._coreBrowserService),this.register((0,d.addDisposableDomListener)(this.textarea,"focus",(Y=>this._handleTextAreaFocus(Y)))),this.register((0,d.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(f.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(j.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(A.ThemeService),this._instantiationService.setService(j.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(S.CharacterJoinerService),this._instantiationService.setService(j.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(E.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(j.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((Y=>this._onRender.fire(Y)))),this.onResize((Y=>this._renderService.resize(Y.cols,Y.rows))),this._compositionView=H.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(h.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(K);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(j.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(b.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((Y=>this.scrollLines(Y.amount,Y.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(w.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(j.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((Y=>this.scrollLines(Y.amount,Y.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((Y=>this._renderService.handleSelectionChanged(Y.start,Y.end,Y.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((Y=>{this.textarea.value=Y,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((Y=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,d.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(y.BufferDecorationRenderer,this.screenElement)),this.register((0,d.addDisposableDomListener)(this.element,"mousedown",(Y=>this._selectionService.handleMouseDown(Y)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(V.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(Y=>this._handleScreenReaderModeOptionChange(Y)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(l.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(Y=>{!this._overviewRulerRenderer&&Y&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(l.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(u.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const N=this,B=this.element;function K(G){const de=N._mouseService.getMouseReportCoords(G,N.screenElement);if(!de)return!1;let he,re;switch(G.overrideType||G.type){case"mousemove":re=32,G.buttons===void 0?(he=3,G.button!==void 0&&(he=G.button<3?G.button:3)):he=1&G.buttons?0:4&G.buttons?1:2&G.buttons?2:3;break;case"mouseup":re=0,he=G.button<3?G.button:3;break;case"mousedown":re=1,he=G.button<3?G.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(G)===0)return!1;re=G.deltaY<0?0:1,he=4;break;default:return!1}return!(re===void 0||he===void 0||he>4)&&N.coreMouseService.triggerMouseEvent({col:de.col,row:de.row,x:de.x,y:de.y,button:he,action:re,ctrl:G.ctrlKey,alt:G.altKey,shift:G.shiftKey})}const Y={mouseup:null,wheel:null,mousedrag:null,mousemove:null},J={mouseup:G=>(K(G),G.buttons||(this._document.removeEventListener("mouseup",Y.mouseup),Y.mousedrag&&this._document.removeEventListener("mousemove",Y.mousedrag)),this.cancel(G)),wheel:G=>(K(G),this.cancel(G,!0)),mousedrag:G=>{G.buttons&&K(G)},mousemove:G=>{G.buttons||K(G)}};this.register(this.coreMouseService.onProtocolChange((G=>{G?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(G)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&G?Y.mousemove||(B.addEventListener("mousemove",J.mousemove),Y.mousemove=J.mousemove):(B.removeEventListener("mousemove",Y.mousemove),Y.mousemove=null),16&G?Y.wheel||(B.addEventListener("wheel",J.wheel,{passive:!1}),Y.wheel=J.wheel):(B.removeEventListener("wheel",Y.wheel),Y.wheel=null),2&G?Y.mouseup||(B.addEventListener("mouseup",J.mouseup),Y.mouseup=J.mouseup):(this._document.removeEventListener("mouseup",Y.mouseup),B.removeEventListener("mouseup",Y.mouseup),Y.mouseup=null),4&G?Y.mousedrag||(Y.mousedrag=J.mousedrag):(this._document.removeEventListener("mousemove",Y.mousedrag),Y.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,d.addDisposableDomListener)(B,"mousedown",(G=>{if(G.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(G))return K(G),Y.mouseup&&this._document.addEventListener("mouseup",Y.mouseup),Y.mousedrag&&this._document.addEventListener("mousemove",Y.mousedrag),this.cancel(G)}))),this.register((0,d.addDisposableDomListener)(B,"wheel",(G=>{if(!Y.wheel){if(!this.buffer.hasScrollback){const de=this.viewport.getLinesScrolled(G);if(de===0)return;const he=$.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(G.deltaY<0?"A":"B");let re="";for(let ne=0;ne<Math.abs(de);ne++)re+=he;return this.coreService.triggerDataEvent(re,!0),this.cancel(G,!0)}return this.viewport.handleWheel(G)?this.cancel(G):void 0}}),{passive:!1})),this.register((0,d.addDisposableDomListener)(B,"touchstart",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(G),this.cancel(G)}),{passive:!0})),this.register((0,d.addDisposableDomListener)(B,"touchmove",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(G)?void 0:this.cancel(G)}),{passive:!1}))}refresh(N,B){var K;(K=this._renderService)===null||K===void 0||K.refreshRows(N,B)}updateCursorStyle(N){var B;!((B=this._selectionService)===null||B===void 0)&&B.shouldColumnSelect(N)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(N,B,K=0){var Y;K===1?(super.scrollLines(N,B,K),this.refresh(0,this.rows-1)):(Y=this.viewport)===null||Y===void 0||Y.scrollLines(N)}paste(N){(0,a.paste)(N,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(N){this._customKeyEventHandler=N}registerLinkProvider(N){return this.linkifier2.registerLinkProvider(N)}registerCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const B=this._characterJoinerService.register(N);return this.refresh(0,this.rows-1),B}deregisterCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(N)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(N){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+N)}registerDecoration(N){return this._decorationService.registerDecoration(N)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(N,B,K){this._selectionService.setSelection(N,B,K)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var N;(N=this._selectionService)===null||N===void 0||N.clearSelection()}selectAll(){var N;(N=this._selectionService)===null||N===void 0||N.selectAll()}selectLines(N,B){var K;(K=this._selectionService)===null||K===void 0||K.selectLines(N,B)}_keyDown(N){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;const B=this.browser.isMac&&this.options.macOptionIsMeta&&N.altKey;if(!B&&!this._compositionHelper.keydown(N))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;B||N.key!=="Dead"&&N.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const K=(0,R.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),K.type===3||K.type===2){const Y=this.rows-1;return this.scrollLines(K.type===2?-Y:Y),this.cancel(N,!0)}return K.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,N)||(K.cancel&&this.cancel(N,!0),!K.key||!!(N.key&&!N.ctrlKey&&!N.altKey&&!N.metaKey&&N.key.length===1&&N.key.charCodeAt(0)>=65&&N.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(K.key!==$.C0.ETX&&K.key!==$.C0.CR||(this.textarea.value=""),this._onKey.fire({key:K.key,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(K.key,!0),!this.optionsService.rawOptions.screenReaderMode||N.altKey||N.ctrlKey?this.cancel(N,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(N,B){const K=N.isMac&&!this.options.macOptionIsMeta&&B.altKey&&!B.ctrlKey&&!B.metaKey||N.isWindows&&B.altKey&&B.ctrlKey&&!B.metaKey||N.isWindows&&B.getModifierState("AltGraph");return B.type==="keypress"?K:K&&(!B.keyCode||B.keyCode>47)}_keyUp(N){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1||((function(B){return B.keyCode===16||B.keyCode===17||B.keyCode===18})(N)||this.focus(),this.updateCursorStyle(N),this._keyPressHandled=!1)}_keyPress(N){let B;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;if(this.cancel(N),N.charCode)B=N.charCode;else if(N.which===null||N.which===void 0)B=N.keyCode;else{if(N.which===0||N.charCode===0)return!1;B=N.which}return!(!B||(N.altKey||N.ctrlKey||N.metaKey)&&!this._isThirdLevelShift(this.browser,N)||(B=String.fromCharCode(B),this._onKey.fire({key:B,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(B,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(N){if(N.data&&N.inputType==="insertText"&&(!N.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const B=N.data;return this.coreService.triggerDataEvent(B,!0),this.cancel(N),!0}return!1}resize(N,B){N!==this.cols||B!==this.rows?super.resize(N,B):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(N,B){var K,Y;(K=this._charSizeService)===null||K===void 0||K.measure(),(Y=this.viewport)===null||Y===void 0||Y.syncScrollArea(!0)}clear(){var N;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let B=1;B<this.rows;B++)this.buffer.lines.push(this.buffer.getBlankLine(z.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(N=this.viewport)===null||N===void 0||N.reset(),this.refresh(0,this.rows-1)}}reset(){var N,B;this.options.rows=this.rows,this.options.cols=this.cols;const K=this._customKeyEventHandler;this._setup(),super.reset(),(N=this._selectionService)===null||N===void 0||N.reset(),this._decorationService.reset(),(B=this.viewport)===null||B===void 0||B.reset(),this._customKeyEventHandler=K,this.refresh(0,this.rows-1)}clearTextureAtlas(){var N;(N=this._renderService)===null||N===void 0||N.clearTextureAtlas()}_reportFocus(){var N;!((N=this.element)===null||N===void 0)&&N.classList.contains("focus")?this.coreService.triggerDataEvent($.C0.ESC+"[I"):this.coreService.triggerDataEvent($.C0.ESC+"[O")}_reportWindowsOptions(N){if(this._renderService)switch(N){case q.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const B=this._renderService.dimensions.css.canvas.width.toFixed(0),K=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.C0.ESC}[4;${K};${B}t`);break;case q.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const Y=this._renderService.dimensions.css.cell.width.toFixed(0),J=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.C0.ESC}[6;${J};${Y}t`)}}cancel(N,B){if(this.options.cancelEvents||B)return N.preventDefault(),N.stopPropagation(),!1}}i.Terminal=W},9924:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TimeBasedDebouncer=void 0,i.TimeBasedDebouncer=class{constructor(n,a=1e3){this._renderCallback=n,this._debounceThresholdMS=a,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(n,a,d){this._rowCount=d,n=n!==void 0?n:0,a=a!==void 0?a:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,a):a;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=c-this._lastRefreshMs,v=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),v)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const n=Math.max(this._rowStart,0),a=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,a)}}},1680:function(x,i,n){var a=this&&this.__decorate||function(h,u,f,S){var C,k=arguments.length,E=k<3?u:S===null?S=Object.getOwnPropertyDescriptor(u,f):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,u,f,S);else for(var w=h.length-1;w>=0;w--)(C=h[w])&&(E=(k<3?C(E):k>3?C(u,f,E):C(u,f))||E);return k>3&&E&&Object.defineProperty(u,f,E),E},d=this&&this.__param||function(h,u){return function(f,S){u(f,S,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Viewport=void 0;const c=n(3656),g=n(4725),v=n(8460),b=n(844),y=n(2585);let l=i.Viewport=class extends b.Disposable{constructor(h,u,f,S,C,k,E,w){super(),this._viewportElement=h,this._scrollArea=u,this._bufferService=f,this._optionsService=S,this._charSizeService=C,this._renderService=k,this._coreBrowserService=E,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new v.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((j=>this._activeBuffer=j.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((j=>this._renderDimensions=j))),this._handleThemeChange(w.colors),this.register(w.onChangeColors((j=>this._handleThemeChange(j)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(h){this._viewportElement.style.backgroundColor=h.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(h){if(h)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const u=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==u&&(this._lastRecordedBufferHeight=u,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const h=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==h&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=h),this._refreshAnimationFrame=null}syncScrollArea(h=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(h);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(h)}_handleScroll(h){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const u=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:u,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const h=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(h*(this._smoothScrollState.target-this._smoothScrollState.origin)),h<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(h,u){const f=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(u<0&&this._viewportElement.scrollTop!==0||u>0&&f<this._lastRecordedBufferHeight)||(h.cancelable&&h.preventDefault(),!1)}handleWheel(h){const u=this._getPixelsScrolled(h);return u!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+u:this._smoothScrollState.target+=u,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=u,this._bubbleScroll(h,u))}scrollLines(h){if(h!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const u=h*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+u,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:h,suppressScrollEvent:!1})}_getPixelsScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let u=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_LINE?u*=this._currentRowHeight:h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(u*=this._currentRowHeight*this._bufferService.rows),u}getBufferElements(h,u){var f;let S,C="";const k=[],E=u??this._bufferService.buffer.lines.length,w=this._bufferService.buffer.lines;for(let j=h;j<E;j++){const A=w.get(j);if(!A)continue;const D=(f=w.get(j+1))===null||f===void 0?void 0:f.isWrapped;if(C+=A.translateToString(!D),!D||j===w.length-1){const T=document.createElement("div");T.textContent=C,k.push(T),C.length>0&&(S=T),C=""}}return{bufferElements:k,cursorElement:S}}getLinesScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let u=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(u/=this._currentRowHeight+0,this._wheelPartialScroll+=u,u=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(u*=this._bufferService.rows),u}_applyScrollModifier(h,u){const f=this._optionsService.rawOptions.fastScrollModifier;return f==="alt"&&u.altKey||f==="ctrl"&&u.ctrlKey||f==="shift"&&u.shiftKey?h*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:h*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(h){this._lastTouchY=h.touches[0].pageY}handleTouchMove(h){const u=this._lastTouchY-h.touches[0].pageY;return this._lastTouchY=h.touches[0].pageY,u!==0&&(this._viewportElement.scrollTop+=u,this._bubbleScroll(h,u))}};i.Viewport=l=a([d(2,y.IBufferService),d(3,y.IOptionsService),d(4,g.ICharSizeService),d(5,g.IRenderService),d(6,g.ICoreBrowserService),d(7,g.IThemeService)],l)},3107:function(x,i,n){var a=this&&this.__decorate||function(l,h,u,f){var S,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,h,u,f);else for(var E=l.length-1;E>=0;E--)(S=l[E])&&(k=(C<3?S(k):C>3?S(h,u,k):S(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(l,h){return function(u,f){h(u,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferDecorationRenderer=void 0;const c=n(3656),g=n(4725),v=n(844),b=n(2585);let y=i.BufferDecorationRenderer=class extends v.Disposable{constructor(l,h,u,f){super(),this._screenElement=l,this._bufferService=h,this._decorationService=u,this._renderService=f,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,c.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((S=>this._removeDecoration(S)))),this.register((0,v.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const l of this._decorationService.decorations)this._renderDecoration(l);this._dimensionsChanged=!1}_renderDecoration(l){this._refreshStyle(l),this._dimensionsChanged&&this._refreshXPosition(l)}_createElement(l){var h,u;const f=document.createElement("div");f.classList.add("xterm-decoration"),f.classList.toggle("xterm-decoration-top-layer",((h=l?.options)===null||h===void 0?void 0:h.layer)==="top"),f.style.width=`${Math.round((l.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,f.style.height=(l.options.height||1)*this._renderService.dimensions.css.cell.height+"px",f.style.top=(l.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",f.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const S=(u=l.options.x)!==null&&u!==void 0?u:0;return S&&S>this._bufferService.cols&&(f.style.display="none"),this._refreshXPosition(l,f),f}_refreshStyle(l){const h=l.marker.line-this._bufferService.buffers.active.ydisp;if(h<0||h>=this._bufferService.rows)l.element&&(l.element.style.display="none",l.onRenderEmitter.fire(l.element));else{let u=this._decorationElements.get(l);u||(u=this._createElement(l),l.element=u,this._decorationElements.set(l,u),this._container.appendChild(u),l.onDispose((()=>{this._decorationElements.delete(l),u.remove()}))),u.style.top=h*this._renderService.dimensions.css.cell.height+"px",u.style.display=this._altBufferIsActive?"none":"block",l.onRenderEmitter.fire(u)}}_refreshXPosition(l,h=l.element){var u;if(!h)return;const f=(u=l.options.x)!==null&&u!==void 0?u:0;(l.options.anchor||"left")==="right"?h.style.right=f?f*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=f?f*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(l){var h;(h=this._decorationElements.get(l))===null||h===void 0||h.remove(),this._decorationElements.delete(l),l.dispose()}};i.BufferDecorationRenderer=y=a([d(1,b.IBufferService),d(2,b.IDecorationService),d(3,g.IRenderService)],y)},5871:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorZoneStore=void 0,i.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(n){if(n.options.overviewRulerOptions){for(const a of this._zones)if(a.color===n.options.overviewRulerOptions.color&&a.position===n.options.overviewRulerOptions.position){if(this._lineIntersectsZone(a,n.marker.line))return;if(this._lineAdjacentToZone(a,n.marker.line,n.options.overviewRulerOptions.position))return void this._addLineToZone(a,n.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=n.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=n.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=n.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=n.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:n.options.overviewRulerOptions.color,position:n.options.overviewRulerOptions.position,startBufferLine:n.marker.line,endBufferLine:n.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(n){this._linePadding=n}_lineIntersectsZone(n,a){return a>=n.startBufferLine&&a<=n.endBufferLine}_lineAdjacentToZone(n,a,d){return a>=n.startBufferLine-this._linePadding[d||"full"]&&a<=n.endBufferLine+this._linePadding[d||"full"]}_addLineToZone(n,a){n.startBufferLine=Math.min(n.startBufferLine,a),n.endBufferLine=Math.max(n.endBufferLine,a)}}},5744:function(x,i,n){var a=this&&this.__decorate||function(S,C,k,E){var w,j=arguments.length,A=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(S,C,k,E);else for(var D=S.length-1;D>=0;D--)(w=S[D])&&(A=(j<3?w(A):j>3?w(C,k,A):w(C,k))||A);return j>3&&A&&Object.defineProperty(C,k,A),A},d=this&&this.__param||function(S,C){return function(k,E){C(k,E,S)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OverviewRulerRenderer=void 0;const c=n(5871),g=n(3656),v=n(4725),b=n(844),y=n(2585),l={full:0,left:0,center:0,right:0},h={full:0,left:0,center:0,right:0},u={full:0,left:0,center:0,right:0};let f=i.OverviewRulerRenderer=class extends b.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(S,C,k,E,w,j,A){var D;super(),this._viewportElement=S,this._screenElement=C,this._bufferService=k,this._decorationService=E,this._renderService=w,this._optionsService=j,this._coreBrowseService=A,this._colorZoneStore=new c.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(D=this._viewportElement.parentElement)===null||D===void 0||D.insertBefore(this._canvas,this._viewportElement);const T=this._canvas.getContext("2d");if(!T)throw new Error("Ctx cannot be null");this._ctx=T,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,b.toDisposable)((()=>{var P;(P=this._canvas)===null||P===void 0||P.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register((0,g.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const S=Math.floor(this._canvas.width/3),C=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=S,h.center=C,h.right=S,this._refreshDrawHeightConstants(),u.full=0,u.left=0,u.center=h.left,u.right=h.left+h.center}_refreshDrawHeightConstants(){l.full=Math.round(2*this._coreBrowseService.dpr);const S=this._canvas.height/this._bufferService.buffer.lines.length,C=Math.round(Math.max(Math.min(S,12),6)*this._coreBrowseService.dpr);l.left=C,l.center=C,l.right=C}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const C of this._decorationService.decorations)this._colorZoneStore.addDecoration(C);this._ctx.lineWidth=1;const S=this._colorZoneStore.zones;for(const C of S)C.position!=="full"&&this._renderColorZone(C);for(const C of S)C.position==="full"&&this._renderColorZone(C);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(S){this._ctx.fillStyle=S.color,this._ctx.fillRect(u[S.position||"full"],Math.round((this._canvas.height-1)*(S.startBufferLine/this._bufferService.buffers.active.lines.length)-l[S.position||"full"]/2),h[S.position||"full"],Math.round((this._canvas.height-1)*((S.endBufferLine-S.startBufferLine)/this._bufferService.buffers.active.lines.length)+l[S.position||"full"]))}_queueRefresh(S,C){this._shouldUpdateDimensions=S||this._shouldUpdateDimensions,this._shouldUpdateAnchor=C||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};i.OverviewRulerRenderer=f=a([d(2,y.IBufferService),d(3,y.IDecorationService),d(4,v.IRenderService),d(5,y.IOptionsService),d(6,v.ICoreBrowserService)],f)},2950:function(x,i,n){var a=this&&this.__decorate||function(y,l,h,u){var f,S=arguments.length,C=S<3?l:u===null?u=Object.getOwnPropertyDescriptor(l,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(y,l,h,u);else for(var k=y.length-1;k>=0;k--)(f=y[k])&&(C=(S<3?f(C):S>3?f(l,h,C):f(l,h))||C);return S>3&&C&&Object.defineProperty(l,h,C),C},d=this&&this.__param||function(y,l){return function(h,u){l(h,u,y)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const c=n(4725),g=n(2585),v=n(2584);let b=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(y,l,h,u,f,S){this._textarea=y,this._compositionView=l,this._bufferService=h,this._optionsService=u,this._coreService=f,this._renderService=S,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(y){this._compositionView.textContent=y.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(y){if(this._isComposing||this._isSendingComposition){if(y.keyCode===229||y.keyCode===16||y.keyCode===17||y.keyCode===18)return!1;this._finalizeComposition(!1)}return y.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(y){if(this._compositionView.classList.remove("active"),this._isComposing=!1,y){const l={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let h;this._isSendingComposition=!1,l.start+=this._dataAlreadySent.length,h=this._isComposing?this._textarea.value.substring(l.start,l.end):this._textarea.value.substring(l.start),h.length>0&&this._coreService.triggerDataEvent(h,!0)}}),0)}else{this._isSendingComposition=!1;const l=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(l,!0)}}_handleAnyTextareaChanges(){const y=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const l=this._textarea.value,h=l.replace(y,"");this._dataAlreadySent=h,l.length>y.length?this._coreService.triggerDataEvent(h,!0):l.length<y.length?this._coreService.triggerDataEvent(`${v.C0.DEL}`,!0):l.length===y.length&&l!==y&&this._coreService.triggerDataEvent(l,!0)}}),0)}updateCompositionElements(y){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const l=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),h=this._renderService.dimensions.css.cell.height,u=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,f=l*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=f+"px",this._compositionView.style.top=u+"px",this._compositionView.style.height=h+"px",this._compositionView.style.lineHeight=h+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const S=this._compositionView.getBoundingClientRect();this._textarea.style.left=f+"px",this._textarea.style.top=u+"px",this._textarea.style.width=Math.max(S.width,1)+"px",this._textarea.style.height=Math.max(S.height,1)+"px",this._textarea.style.lineHeight=S.height+"px"}y||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};i.CompositionHelper=b=a([d(2,g.IBufferService),d(3,g.IOptionsService),d(4,g.ICoreService),d(5,c.IRenderService)],b)},9806:(x,i)=>{function n(a,d,c){const g=c.getBoundingClientRect(),v=a.getComputedStyle(c),b=parseInt(v.getPropertyValue("padding-left")),y=parseInt(v.getPropertyValue("padding-top"));return[d.clientX-g.left-b,d.clientY-g.top-y]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=n,i.getCoords=function(a,d,c,g,v,b,y,l,h){if(!b)return;const u=n(a,d,c);return u?(u[0]=Math.ceil((u[0]+(h?y/2:0))/y),u[1]=Math.ceil(u[1]/l),u[0]=Math.min(Math.max(u[0],1),g+(h?1:0)),u[1]=Math.min(Math.max(u[1],1),v),u):void 0}},9504:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.moveToCellSequence=void 0;const a=n(2584);function d(l,h,u,f){const S=l-c(l,u),C=h-c(h,u),k=Math.abs(S-C)-(function(E,w,j){let A=0;const D=E-c(E,j),T=w-c(w,j);for(let P=0;P<Math.abs(D-T);P++){const F=g(E,w)==="A"?-1:1,I=j.buffer.lines.get(D+F*P);I?.isWrapped&&A++}return A})(l,h,u);return y(k,b(g(l,h),f))}function c(l,h){let u=0,f=h.buffer.lines.get(l),S=f?.isWrapped;for(;S&&l>=0&&l<h.rows;)u++,f=h.buffer.lines.get(--l),S=f?.isWrapped;return u}function g(l,h){return l>h?"A":"B"}function v(l,h,u,f,S,C){let k=l,E=h,w="";for(;k!==u||E!==f;)k+=S?1:-1,S&&k>C.cols-1?(w+=C.buffer.translateBufferLineToString(E,!1,l,k),k=0,l=0,E++):!S&&k<0&&(w+=C.buffer.translateBufferLineToString(E,!1,0,l+1),k=C.cols-1,l=k,E--);return w+C.buffer.translateBufferLineToString(E,!1,l,k)}function b(l,h){const u=h?"O":"[";return a.C0.ESC+u+l}function y(l,h){l=Math.floor(l);let u="";for(let f=0;f<l;f++)u+=h;return u}i.moveToCellSequence=function(l,h,u,f){const S=u.buffer.x,C=u.buffer.y;if(!u.buffer.hasScrollback)return(function(w,j,A,D,T,P){return d(j,D,T,P).length===0?"":y(v(w,j,w,j-c(j,T),!1,T).length,b("D",P))})(S,C,0,h,u,f)+d(C,h,u,f)+(function(w,j,A,D,T,P){let F;F=d(j,D,T,P).length>0?D-c(D,T):j;const I=D,z=(function($,R,L,M,O,q){let V;return V=d(L,M,O,q).length>0?M-c(M,O):R,$<L&&V<=M||$>=L&&V<M?"C":"D"})(w,j,A,D,T,P);return y(v(w,F,A,I,z==="C",T).length,b(z,P))})(S,C,l,h,u,f);let k;if(C===h)return k=S>l?"D":"C",y(Math.abs(S-l),b(k,f));k=C>h?"D":"C";const E=Math.abs(C-h);return y((function(w,j){return j.cols-w})(C>h?l:S,u)+(E-1)*u.cols+1+((C>h?S:l)-1),b(k,f))}},1296:function(x,i,n){var a=this&&this.__decorate||function(T,P,F,I){var z,$=arguments.length,R=$<3?P:I===null?I=Object.getOwnPropertyDescriptor(P,F):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(T,P,F,I);else for(var L=T.length-1;L>=0;L--)(z=T[L])&&(R=($<3?z(R):$>3?z(P,F,R):z(P,F))||R);return $>3&&R&&Object.defineProperty(P,F,R),R},d=this&&this.__param||function(T,P){return function(F,I){P(F,I,T)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const c=n(3787),g=n(2550),v=n(2223),b=n(6171),y=n(4725),l=n(8055),h=n(8460),u=n(844),f=n(2585),S="xterm-dom-renderer-owner-",C="xterm-rows",k="xterm-fg-",E="xterm-bg-",w="xterm-focus",j="xterm-selection";let A=1,D=i.DomRenderer=class extends u.Disposable{constructor(T,P,F,I,z,$,R,L,M,O){super(),this._element=T,this._screenElement=P,this._viewportElement=F,this._linkifier2=I,this._charSizeService=$,this._optionsService=R,this._bufferService=L,this._coreBrowserService=M,this._themeService=O,this._terminalClass=A++,this._rowElements=[],this.onRequestRedraw=this.register(new h.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(C),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(j),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,b.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((q=>this._injectCss(q)))),this._injectCss(this._themeService.colors),this._rowFactory=z.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(S+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((q=>this._handleLinkHover(q)))),this.register(this._linkifier2.onHideLinkUnderline((q=>this._handleLinkLeave(q)))),this.register((0,u.toDisposable)((()=>{this._element.classList.remove(S+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new g.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const T=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*T,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*T),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/T),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/T),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const F of this._rowElements)F.style.width=`${this.dimensions.css.canvas.width}px`,F.style.height=`${this.dimensions.css.cell.height}px`,F.style.lineHeight=`${this.dimensions.css.cell.height}px`,F.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const P=`${this._terminalSelector} .${C} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=P,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(T){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let P=`${this._terminalSelector} .${C} { color: ${T.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;P+=`${this._terminalSelector} .${C} .xterm-dim { color: ${l.color.multiplyOpacity(T.foreground,.5).css};}`,P+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`,P+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",P+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css}; } 50% { background-color: inherit; color: ${T.cursor.css}; }}`,P+=`${this._terminalSelector} .${C}.${w} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C}.${w} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css};}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${T.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${T.cursor.css} inset;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${T.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,P+=`${this._terminalSelector} .${j} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${j} div { position: absolute; background-color: ${T.selectionBackgroundOpaque.css};}${this._terminalSelector} .${j} div { position: absolute; background-color: ${T.selectionInactiveBackgroundOpaque.css};}`;for(const[F,I]of T.ansi.entries())P+=`${this._terminalSelector} .${k}${F} { color: ${I.css}; }${this._terminalSelector} .${k}${F}.xterm-dim { color: ${l.color.multiplyOpacity(I,.5).css}; }${this._terminalSelector} .${E}${F} { background-color: ${I.css}; }`;P+=`${this._terminalSelector} .${k}${v.INVERTED_DEFAULT_COLOR} { color: ${l.color.opaque(T.background).css}; }${this._terminalSelector} .${k}${v.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${l.color.multiplyOpacity(l.color.opaque(T.background),.5).css}; }${this._terminalSelector} .${E}${v.INVERTED_DEFAULT_COLOR} { background-color: ${T.foreground.css}; }`,this._themeStyleElement.textContent=P}_setDefaultSpacing(){const T=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${T}px`,this._rowFactory.defaultSpacing=T}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(T,P){for(let F=this._rowElements.length;F<=P;F++){const I=document.createElement("div");this._rowContainer.appendChild(I),this._rowElements.push(I)}for(;this._rowElements.length>P;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(T,P){this._refreshRowElements(T,P),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(w)}handleFocus(){this._rowContainer.classList.add(w),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(T,P,F){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(T,P,F),this.renderRows(0,this._bufferService.rows-1),!T||!P)return;const I=T[1]-this._bufferService.buffer.ydisp,z=P[1]-this._bufferService.buffer.ydisp,$=Math.max(I,0),R=Math.min(z,this._bufferService.rows-1);if($>=this._bufferService.rows||R<0)return;const L=document.createDocumentFragment();if(F){const M=T[0]>P[0];L.appendChild(this._createSelectionElement($,M?P[0]:T[0],M?T[0]:P[0],R-$+1))}else{const M=I===$?T[0]:0,O=$===z?P[0]:this._bufferService.cols;L.appendChild(this._createSelectionElement($,M,O));const q=R-$-1;if(L.appendChild(this._createSelectionElement($+1,0,this._bufferService.cols,q)),$!==R){const V=z===R?P[0]:this._bufferService.cols;L.appendChild(this._createSelectionElement(R,0,V))}}this._selectionContainer.appendChild(L)}_createSelectionElement(T,P,F,I=1){const z=document.createElement("div");return z.style.height=I*this.dimensions.css.cell.height+"px",z.style.top=T*this.dimensions.css.cell.height+"px",z.style.left=P*this.dimensions.css.cell.width+"px",z.style.width=this.dimensions.css.cell.width*(F-P)+"px",z}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const T of this._rowElements)T.replaceChildren()}renderRows(T,P){const F=this._bufferService.buffer,I=F.ybase+F.y,z=Math.min(F.x,this._bufferService.cols-1),$=this._optionsService.rawOptions.cursorBlink,R=this._optionsService.rawOptions.cursorStyle,L=this._optionsService.rawOptions.cursorInactiveStyle;for(let M=T;M<=P;M++){const O=M+F.ydisp,q=this._rowElements[M],V=F.lines.get(O);if(!q||!V)break;q.replaceChildren(...this._rowFactory.createRow(V,O,O===I,R,L,z,$,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${S}${this._terminalClass}`}_handleLinkHover(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!0)}_handleLinkLeave(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!1)}_setCellUnderline(T,P,F,I,z,$){F<0&&(T=0),I<0&&(P=0);const R=this._bufferService.rows-1;F=Math.max(Math.min(F,R),0),I=Math.max(Math.min(I,R),0),z=Math.min(z,this._bufferService.cols);const L=this._bufferService.buffer,M=L.ybase+L.y,O=Math.min(L.x,z-1),q=this._optionsService.rawOptions.cursorBlink,V=this._optionsService.rawOptions.cursorStyle,H=this._optionsService.rawOptions.cursorInactiveStyle;for(let W=F;W<=I;++W){const U=W+L.ydisp,N=this._rowElements[W],B=L.lines.get(U);if(!N||!B)break;N.replaceChildren(...this._rowFactory.createRow(B,U,U===M,V,H,O,q,this.dimensions.css.cell.width,this._widthCache,$?W===F?T:0:-1,$?(W===I?P:z)-1:-1))}}};i.DomRenderer=D=a([d(4,f.IInstantiationService),d(5,y.ICharSizeService),d(6,f.IOptionsService),d(7,f.IBufferService),d(8,y.ICoreBrowserService),d(9,y.IThemeService)],D)},3787:function(x,i,n){var a=this&&this.__decorate||function(k,E,w,j){var A,D=arguments.length,T=D<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,w):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(k,E,w,j);else for(var P=k.length-1;P>=0;P--)(A=k[P])&&(T=(D<3?A(T):D>3?A(E,w,T):A(E,w))||T);return D>3&&T&&Object.defineProperty(E,w,T),T},d=this&&this.__param||function(k,E){return function(w,j){E(w,j,k)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRendererRowFactory=void 0;const c=n(2223),g=n(643),v=n(511),b=n(2585),y=n(8055),l=n(4725),h=n(4269),u=n(6171),f=n(3734);let S=i.DomRendererRowFactory=class{constructor(k,E,w,j,A,D,T){this._document=k,this._characterJoinerService=E,this._optionsService=w,this._coreBrowserService=j,this._coreService=A,this._decorationService=D,this._themeService=T,this._workCell=new v.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,w){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=w}createRow(k,E,w,j,A,D,T,P,F,I,z){const $=[],R=this._characterJoinerService.getJoinedCharacters(E),L=this._themeService.colors;let M,O=k.getNoBgTrimmedLength();w&&O<D+1&&(O=D+1);let q=0,V="",H=0,W=0,U=0,N=!1,B=0,K=!1,Y=0;const J=[],G=I!==-1&&z!==-1;for(let de=0;de<O;de++){k.loadCell(de,this._workCell);let he=this._workCell.getWidth();if(he===0)continue;let re=!1,ne=de,le=this._workCell;if(R.length>0&&de===R[0][0]){re=!0;const pe=R.shift();le=new h.JoinedCellData(this._workCell,k.translateToString(!0,pe[0],pe[1]),pe[1]-pe[0]),ne=pe[1]-1,he=le.getWidth()}const _e=this._isCellInSelection(de,E),We=w&&de===D,Ce=G&&de>=I&&de<=z;let He=!1;this._decorationService.forEachDecorationAtCell(de,E,void 0,(pe=>{He=!0}));let at=le.getChars()||g.WHITESPACE_CELL_CHAR;if(at===" "&&(le.isUnderline()||le.isOverline())&&(at=" "),Y=he*P-F.get(at,le.isBold(),le.isItalic()),M){if(q&&(_e&&K||!_e&&!K&&le.bg===H)&&(_e&&K&&L.selectionForeground||le.fg===W)&&le.extended.ext===U&&Ce===N&&Y===B&&!We&&!re&&!He){V+=at,q++;continue}q&&(M.textContent=V),M=this._document.createElement("span"),q=0,V=""}else M=this._document.createElement("span");if(H=le.bg,W=le.fg,U=le.extended.ext,N=Ce,B=Y,K=_e,re&&D>=de&&D<=ne&&(D=de),!this._coreService.isCursorHidden&&We){if(J.push("xterm-cursor"),this._coreBrowserService.isFocused)T&&J.push("xterm-cursor-blink"),J.push(j==="bar"?"xterm-cursor-bar":j==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(A)switch(A){case"outline":J.push("xterm-cursor-outline");break;case"block":J.push("xterm-cursor-block");break;case"bar":J.push("xterm-cursor-bar");break;case"underline":J.push("xterm-cursor-underline")}}if(le.isBold()&&J.push("xterm-bold"),le.isItalic()&&J.push("xterm-italic"),le.isDim()&&J.push("xterm-dim"),V=le.isInvisible()?g.WHITESPACE_CELL_CHAR:le.getChars()||g.WHITESPACE_CELL_CHAR,le.isUnderline()&&(J.push(`xterm-underline-${le.extended.underlineStyle}`),V===" "&&(V=" "),!le.isUnderlineColorDefault()))if(le.isUnderlineColorRGB())M.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(le.getUnderlineColor()).join(",")})`;else{let pe=le.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&le.isBold()&&pe<8&&(pe+=8),M.style.textDecorationColor=L.ansi[pe].css}le.isOverline()&&(J.push("xterm-overline"),V===" "&&(V=" ")),le.isStrikethrough()&&J.push("xterm-strikethrough"),Ce&&(M.style.textDecoration="underline");let Me=le.getFgColor(),Ne=le.getFgColorMode(),Oe=le.getBgColor(),$e=le.getBgColorMode();const Ke=!!le.isInverse();if(Ke){const pe=Me;Me=Oe,Oe=pe;const tt=Ne;Ne=$e,$e=tt}let De,Xe,Ge,Te=!1;switch(this._decorationService.forEachDecorationAtCell(de,E,void 0,(pe=>{pe.options.layer!=="top"&&Te||(pe.backgroundColorRGB&&($e=50331648,Oe=pe.backgroundColorRGB.rgba>>8&16777215,De=pe.backgroundColorRGB),pe.foregroundColorRGB&&(Ne=50331648,Me=pe.foregroundColorRGB.rgba>>8&16777215,Xe=pe.foregroundColorRGB),Te=pe.options.layer==="top")})),!Te&&_e&&(De=this._coreBrowserService.isFocused?L.selectionBackgroundOpaque:L.selectionInactiveBackgroundOpaque,Oe=De.rgba>>8&16777215,$e=50331648,Te=!0,L.selectionForeground&&(Ne=50331648,Me=L.selectionForeground.rgba>>8&16777215,Xe=L.selectionForeground)),Te&&J.push("xterm-decoration-top"),$e){case 16777216:case 33554432:Ge=L.ansi[Oe],J.push(`xterm-bg-${Oe}`);break;case 50331648:Ge=y.rgba.toColor(Oe>>16,Oe>>8&255,255&Oe),this._addStyle(M,`background-color:#${C((Oe>>>0).toString(16),"0",6)}`);break;default:Ke?(Ge=L.foreground,J.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):Ge=L.background}switch(De||le.isDim()&&(De=y.color.multiplyOpacity(Ge,.5)),Ne){case 16777216:case 33554432:le.isBold()&&Me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Me+=8),this._applyMinimumContrast(M,Ge,L.ansi[Me],le,De,void 0)||J.push(`xterm-fg-${Me}`);break;case 50331648:const pe=y.rgba.toColor(Me>>16&255,Me>>8&255,255&Me);this._applyMinimumContrast(M,Ge,pe,le,De,Xe)||this._addStyle(M,`color:#${C(Me.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(M,Ge,L.foreground,le,De,void 0)||Ke&&J.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}J.length&&(M.className=J.join(" "),J.length=0),We||re||He?M.textContent=V:q++,Y!==this.defaultSpacing&&(M.style.letterSpacing=`${Y}px`),$.push(M),de=ne}return M&&q&&(M.textContent=V),$}_applyMinimumContrast(k,E,w,j,A,D){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,u.excludeFromContrastRatioDemands)(j.getCode()))return!1;const T=this._getContrastCache(j);let P;if(A||D||(P=T.getColor(E.rgba,w.rgba)),P===void 0){const F=this._optionsService.rawOptions.minimumContrastRatio/(j.isDim()?2:1);P=y.color.ensureContrastRatio(A||E,D||w,F),T.setColor((A||E).rgba,(D||w).rgba,P??null)}return!!P&&(this._addStyle(k,`color:${P.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,E){k.setAttribute("style",`${k.getAttribute("style")||""}${E};`)}_isCellInSelection(k,E){const w=this._selectionStart,j=this._selectionEnd;return!(!w||!j)&&(this._columnSelectMode?w[0]<=j[0]?k>=w[0]&&E>=w[1]&&k<j[0]&&E<=j[1]:k<w[0]&&E>=w[1]&&k>=j[0]&&E<=j[1]:E>w[1]&&E<j[1]||w[1]===j[1]&&E===w[1]&&k>=w[0]&&k<j[0]||w[1]<j[1]&&E===j[1]&&k<j[0]||w[1]<j[1]&&E===w[1]&&k>=w[0])}};function C(k,E,w){for(;k.length<w;)k=E+k;return k}i.DomRendererRowFactory=S=a([d(1,l.ICharacterJoinerService),d(2,b.IOptionsService),d(3,l.ICoreBrowserService),d(4,b.ICoreService),d(5,b.IDecorationService),d(6,l.IThemeService)],S)},2550:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WidthCache=void 0,i.WidthCache=class{constructor(n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=n.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const a=n.createElement("span"),d=n.createElement("span");d.style.fontWeight="bold";const c=n.createElement("span");c.style.fontStyle="italic";const g=n.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[a,d,c,g],this._container.appendChild(a),this._container.appendChild(d),this._container.appendChild(c),this._container.appendChild(g),n.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(n,a,d,c){n===this._font&&a===this._fontSize&&d===this._weight&&c===this._weightBold||(this._font=n,this._fontSize=a,this._weight=d,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${d}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${d}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(n,a,d){let c=0;if(!a&&!d&&n.length===1&&(c=n.charCodeAt(0))<256)return this._flat[c]!==-9999?this._flat[c]:this._flat[c]=this._measure(n,0);let g=n;a&&(g+="B"),d&&(g+="I");let v=this._holey.get(g);if(v===void 0){let b=0;a&&(b|=1),d&&(b|=2),v=this._measure(n,b),this._holey.set(g,v)}return v}_measure(n,a){const d=this._measureElements[a];return d.textContent=n.repeat(32),d.offsetWidth/32}}},2223:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TEXT_BASELINE=i.DIM_OPACITY=i.INVERTED_DEFAULT_COLOR=void 0;const a=n(6114);i.INVERTED_DEFAULT_COLOR=257,i.DIM_OPACITY=.5,i.TEXT_BASELINE=a.isFirefox||a.isLegacyEdge?"bottom":"ideographic"},6171:(x,i)=>{function n(a){return 57508<=a&&a<=57558}Object.defineProperty(i,"__esModule",{value:!0}),i.createRenderDimensions=i.excludeFromContrastRatioDemands=i.isRestrictedPowerlineGlyph=i.isPowerlineGlyph=i.throwIfFalsy=void 0,i.throwIfFalsy=function(a){if(!a)throw new Error("value must not be falsy");return a},i.isPowerlineGlyph=n,i.isRestrictedPowerlineGlyph=function(a){return 57520<=a&&a<=57527},i.excludeFromContrastRatioDemands=function(a){return n(a)||(function(d){return 9472<=d&&d<=9631})(a)},i.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionModel=void 0,i.SelectionModel=class{constructor(n){this._bufferService=n,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?n%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)-1]:[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[n,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[Math.max(n,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const n=this.selectionStart,a=this.selectionEnd;return!(!n||!a)&&(n[1]>a[1]||n[1]===a[1]&&n[0]>a[0])}handleTrim(n){return this.selectionStart&&(this.selectionStart[1]-=n),this.selectionEnd&&(this.selectionEnd[1]-=n),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(x,i,n){var a=this&&this.__decorate||function(l,h,u,f){var S,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,h,u,f);else for(var E=l.length-1;E>=0;E--)(S=l[E])&&(k=(C<3?S(k):C>3?S(h,u,k):S(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(l,h){return function(u,f){h(u,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharSizeService=void 0;const c=n(2585),g=n(8460),v=n(844);let b=i.CharSizeService=class extends v.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(l,h,u){super(),this._optionsService=u,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new y(l,h,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const l=this._measureStrategy.measure();l.width===this.width&&l.height===this.height||(this.width=l.width,this.height=l.height,this._onCharSizeChange.fire())}};i.CharSizeService=b=a([d(2,c.IOptionsService)],b);class y{constructor(h,u,f){this._document=h,this._parentElement=u,this._optionsService=f,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const h={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return h.width!==0&&h.height!==0&&(this._result.width=h.width/32,this._result.height=Math.ceil(h.height)),this._result}}},4269:function(x,i,n){var a=this&&this.__decorate||function(h,u,f,S){var C,k=arguments.length,E=k<3?u:S===null?S=Object.getOwnPropertyDescriptor(u,f):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,u,f,S);else for(var w=h.length-1;w>=0;w--)(C=h[w])&&(E=(k<3?C(E):k>3?C(u,f,E):C(u,f))||E);return k>3&&E&&Object.defineProperty(u,f,E),E},d=this&&this.__param||function(h,u){return function(f,S){u(f,S,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharacterJoinerService=i.JoinedCellData=void 0;const c=n(3734),g=n(643),v=n(511),b=n(2585);class y extends c.AttributeData{constructor(u,f,S){super(),this.content=0,this.combinedData="",this.fg=u.fg,this.bg=u.bg,this.combinedData=f,this._width=S}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(u){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.JoinedCellData=y;let l=i.CharacterJoinerService=class tc{constructor(u){this._bufferService=u,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new v.CellData}register(u){const f={id:this._nextCharacterJoinerId++,handler:u};return this._characterJoiners.push(f),f.id}deregister(u){for(let f=0;f<this._characterJoiners.length;f++)if(this._characterJoiners[f].id===u)return this._characterJoiners.splice(f,1),!0;return!1}getJoinedCharacters(u){if(this._characterJoiners.length===0)return[];const f=this._bufferService.buffer.lines.get(u);if(!f||f.length===0)return[];const S=[],C=f.translateToString(!0);let k=0,E=0,w=0,j=f.getFg(0),A=f.getBg(0);for(let D=0;D<f.getTrimmedLength();D++)if(f.loadCell(D,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==j||this._workCell.bg!==A){if(D-k>1){const T=this._getJoinedRanges(C,w,E,f,k);for(let P=0;P<T.length;P++)S.push(T[P])}k=D,w=E,j=this._workCell.fg,A=this._workCell.bg}E+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const D=this._getJoinedRanges(C,w,E,f,k);for(let T=0;T<D.length;T++)S.push(D[T])}return S}_getJoinedRanges(u,f,S,C,k){const E=u.substring(f,S);let w=[];try{w=this._characterJoiners[0].handler(E)}catch(j){console.error(j)}for(let j=1;j<this._characterJoiners.length;j++)try{const A=this._characterJoiners[j].handler(E);for(let D=0;D<A.length;D++)tc._mergeRanges(w,A[D])}catch(A){console.error(A)}return this._stringRangesToCellRanges(w,C,k),w}_stringRangesToCellRanges(u,f,S){let C=0,k=!1,E=0,w=u[C];if(w){for(let j=S;j<this._bufferService.cols;j++){const A=f.getWidth(j),D=f.getString(j).length||g.WHITESPACE_CELL_CHAR.length;if(A!==0){if(!k&&w[0]<=E&&(w[0]=j,k=!0),w[1]<=E){if(w[1]=j,w=u[++C],!w)break;w[0]<=E?(w[0]=j,k=!0):k=!1}E+=D}}w&&(w[1]=this._bufferService.cols)}}static _mergeRanges(u,f){let S=!1;for(let C=0;C<u.length;C++){const k=u[C];if(S){if(f[1]<=k[0])return u[C-1][1]=f[1],u;if(f[1]<=k[1])return u[C-1][1]=Math.max(f[1],k[1]),u.splice(C,1),u;u.splice(C,1),C--}else{if(f[1]<=k[0])return u.splice(C,0,f),u;if(f[1]<=k[1])return k[0]=Math.min(f[0],k[0]),u;f[0]<k[1]&&(k[0]=Math.min(f[0],k[0]),S=!0)}}return S?u[u.length-1][1]=f[1]:u.push(f),u}};i.CharacterJoinerService=l=a([d(0,b.IBufferService)],l)},5114:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreBrowserService=void 0,i.CoreBrowserService=class{constructor(n,a){this._textarea=n,this.window=a,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(x,i,n){var a=this&&this.__decorate||function(b,y,l,h){var u,f=arguments.length,S=f<3?y:h===null?h=Object.getOwnPropertyDescriptor(y,l):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(b,y,l,h);else for(var C=b.length-1;C>=0;C--)(u=b[C])&&(S=(f<3?u(S):f>3?u(y,l,S):u(y,l))||S);return f>3&&S&&Object.defineProperty(y,l,S),S},d=this&&this.__param||function(b,y){return function(l,h){y(l,h,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const c=n(4725),g=n(9806);let v=i.MouseService=class{constructor(b,y){this._renderService=b,this._charSizeService=y}getCoords(b,y,l,h,u){return(0,g.getCoords)(window,b,y,l,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,u)}getMouseReportCoords(b,y){const l=(0,g.getCoordsRelativeToElement)(window,b,y);if(this._charSizeService.hasValidSize)return l[0]=Math.min(Math.max(l[0],0),this._renderService.dimensions.css.canvas.width-1),l[1]=Math.min(Math.max(l[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(l[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(l[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(l[0]),y:Math.floor(l[1])}}};i.MouseService=v=a([d(0,c.IRenderService),d(1,c.ICharSizeService)],v)},3230:function(x,i,n){var a=this&&this.__decorate||function(S,C,k,E){var w,j=arguments.length,A=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(S,C,k,E);else for(var D=S.length-1;D>=0;D--)(w=S[D])&&(A=(j<3?w(A):j>3?w(C,k,A):w(C,k))||A);return j>3&&A&&Object.defineProperty(C,k,A),A},d=this&&this.__param||function(S,C){return function(k,E){C(k,E,S)}};Object.defineProperty(i,"__esModule",{value:!0}),i.RenderService=void 0;const c=n(3656),g=n(6193),v=n(5596),b=n(4725),y=n(8460),l=n(844),h=n(7226),u=n(2585);let f=i.RenderService=class extends l.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(S,C,k,E,w,j,A,D){if(super(),this._rowCount=S,this._charSizeService=E,this._renderer=this.register(new l.MutableDisposable),this._pausedResizeTask=new h.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new y.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new y.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new y.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new y.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(A.window,((T,P)=>this._renderRows(T,P))),this.register(this._renderDebouncer),this._screenDprMonitor=new v.ScreenDprMonitor(A.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(j.onResize((()=>this._fullRefresh()))),this.register(j.buffers.onBufferActivate((()=>{var T;return(T=this._renderer.value)===null||T===void 0?void 0:T.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(w.onDecorationRegistered((()=>this._fullRefresh()))),this.register(w.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(j.cols,j.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(j.buffer.y,j.buffer.y,!0)))),this.register((0,c.addDisposableDomListener)(A.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(D.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in A.window){const T=new A.window.IntersectionObserver((P=>this._handleIntersectionChange(P[P.length-1])),{threshold:0});T.observe(C),this.register({dispose:()=>T.disconnect()})}}_handleIntersectionChange(S){this._isPaused=S.isIntersecting===void 0?S.intersectionRatio===0:!S.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(S,C,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(S,C,this._rowCount))}_renderRows(S,C){this._renderer.value&&(S=Math.min(S,this._rowCount-1),C=Math.min(C,this._rowCount-1),this._renderer.value.renderRows(S,C),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:S,end:C}),this._onRender.fire({start:S,end:C}),this._isNextRenderRedrawOnly=!0)}resize(S,C){this._rowCount=C,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(S){this._renderer.value=S,this._renderer.value.onRequestRedraw((C=>this.refreshRows(C.start,C.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(S){return this._renderDebouncer.addRefreshCallback(S)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var S,C;this._renderer.value&&((C=(S=this._renderer.value).clearTextureAtlas)===null||C===void 0||C.call(S),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(S,C){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(S,C))):this._renderer.value.handleResize(S,C),this._fullRefresh())}handleCharSizeChanged(){var S;(S=this._renderer.value)===null||S===void 0||S.handleCharSizeChanged()}handleBlur(){var S;(S=this._renderer.value)===null||S===void 0||S.handleBlur()}handleFocus(){var S;(S=this._renderer.value)===null||S===void 0||S.handleFocus()}handleSelectionChanged(S,C,k){var E;this._selectionState.start=S,this._selectionState.end=C,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(S,C,k)}handleCursorMove(){var S;(S=this._renderer.value)===null||S===void 0||S.handleCursorMove()}clear(){var S;(S=this._renderer.value)===null||S===void 0||S.clear()}};i.RenderService=f=a([d(2,u.IOptionsService),d(3,b.ICharSizeService),d(4,u.IDecorationService),d(5,u.IBufferService),d(6,b.ICoreBrowserService),d(7,b.IThemeService)],f)},9312:function(x,i,n){var a=this&&this.__decorate||function(w,j,A,D){var T,P=arguments.length,F=P<3?j:D===null?D=Object.getOwnPropertyDescriptor(j,A):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(w,j,A,D);else for(var I=w.length-1;I>=0;I--)(T=w[I])&&(F=(P<3?T(F):P>3?T(j,A,F):T(j,A))||F);return P>3&&F&&Object.defineProperty(j,A,F),F},d=this&&this.__param||function(w,j){return function(A,D){j(A,D,w)}};Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionService=void 0;const c=n(9806),g=n(9504),v=n(456),b=n(4725),y=n(8460),l=n(844),h=n(6114),u=n(4841),f=n(511),S=n(2585),C=" ",k=new RegExp(C,"g");let E=i.SelectionService=class extends l.Disposable{constructor(w,j,A,D,T,P,F,I,z){super(),this._element=w,this._screenElement=j,this._linkifier=A,this._bufferService=D,this._coreService=T,this._mouseService=P,this._optionsService=F,this._renderService=I,this._coreBrowserService=z,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new f.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new y.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new y.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new y.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new y.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=$=>this._handleMouseMove($),this._mouseUpListener=$=>this._handleMouseUp($),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim(($=>this._handleTrim($))),this.register(this._bufferService.buffers.onBufferActivate(($=>this._handleBufferActivate($)))),this.enable(),this._model=new v.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,l.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const w=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!(!w||!j||w[0]===j[0]&&w[1]===j[1])}get selectionText(){const w=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;if(!w||!j)return"";const A=this._bufferService.buffer,D=[];if(this._activeSelectionMode===3){if(w[0]===j[0])return"";const T=w[0]<j[0]?w[0]:j[0],P=w[0]<j[0]?j[0]:w[0];for(let F=w[1];F<=j[1];F++){const I=A.translateBufferLineToString(F,!0,T,P);D.push(I)}}else{const T=w[1]===j[1]?j[0]:void 0;D.push(A.translateBufferLineToString(w[1],!0,w[0],T));for(let P=w[1]+1;P<=j[1]-1;P++){const F=A.lines.get(P),I=A.translateBufferLineToString(P,!0);F?.isWrapped?D[D.length-1]+=I:D.push(I)}if(w[1]!==j[1]){const P=A.lines.get(j[1]),F=A.translateBufferLineToString(j[1],!0,0,j[0]);P&&P.isWrapped?D[D.length-1]+=F:D.push(F)}}return D.map((T=>T.replace(k," "))).join(h.isWindows?`\r
|
|
18
|
+
`:`
|
|
19
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(w){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&w&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(w){const j=this._getMouseBufferCoords(w),A=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!!(A&&D&&j)&&this._areCoordsInSelection(j,A,D)}isCellInSelection(w,j){const A=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!(!A||!D)&&this._areCoordsInSelection([w,j],A,D)}_areCoordsInSelection(w,j,A){return w[1]>j[1]&&w[1]<A[1]||j[1]===A[1]&&w[1]===j[1]&&w[0]>=j[0]&&w[0]<A[0]||j[1]<A[1]&&w[1]===A[1]&&w[0]<A[0]||j[1]<A[1]&&w[1]===j[1]&&w[0]>=j[0]}_selectWordAtCursor(w,j){var A,D;const T=(D=(A=this._linkifier.currentLink)===null||A===void 0?void 0:A.link)===null||D===void 0?void 0:D.range;if(T)return this._model.selectionStart=[T.start.x-1,T.start.y-1],this._model.selectionStartLength=(0,u.getRangeLength)(T,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const P=this._getMouseBufferCoords(w);return!!P&&(this._selectWordAt(P,j),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(w,j){this._model.clearSelection(),w=Math.max(w,0),j=Math.min(j,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,w],this._model.selectionEnd=[this._bufferService.cols,j],this.refresh(),this._onSelectionChange.fire()}_handleTrim(w){this._model.handleTrim(w)&&this.refresh()}_getMouseBufferCoords(w){const j=this._mouseService.getCoords(w,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(j)return j[0]--,j[1]--,j[1]+=this._bufferService.buffer.ydisp,j}_getMouseEventScrollAmount(w){let j=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,w,this._screenElement)[1];const A=this._renderService.dimensions.css.canvas.height;return j>=0&&j<=A?0:(j>A&&(j-=A),j=Math.min(Math.max(j,-50),50),j/=50,j/Math.abs(j)+Math.round(14*j))}shouldForceSelection(w){return h.isMac?w.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:w.shiftKey}handleMouseDown(w){if(this._mouseDownTimeStamp=w.timeStamp,(w.button!==2||!this.hasSelection)&&w.button===0){if(!this._enabled){if(!this.shouldForceSelection(w))return;w.stopPropagation()}w.preventDefault(),this._dragScrollAmount=0,this._enabled&&w.shiftKey?this._handleIncrementalClick(w):w.detail===1?this._handleSingleClick(w):w.detail===2?this._handleDoubleClick(w):w.detail===3&&this._handleTripleClick(w),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(w){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(w))}_handleSingleClick(w){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(w)?3:0,this._model.selectionStart=this._getMouseBufferCoords(w),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const j=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);j&&j.length!==this._model.selectionStart[0]&&j.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(w){this._selectWordAtCursor(w,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(w){const j=this._getMouseBufferCoords(w);j&&(this._activeSelectionMode=2,this._selectLineAt(j[1]))}shouldColumnSelect(w){return w.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(w){if(w.stopImmediatePropagation(),!this._model.selectionStart)return;const j=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(w),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(w),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const A=this._bufferService.buffer;if(this._model.selectionEnd[1]<A.lines.length){const D=A.lines.get(this._model.selectionEnd[1]);D&&D.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}j&&j[0]===this._model.selectionEnd[0]&&j[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const w=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(w.ydisp+this._bufferService.rows,w.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=w.ydisp),this.refresh()}}_handleMouseUp(w){const j=w.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&j<500&&w.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const A=this._mouseService.getCoords(w,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(A&&A[0]!==void 0&&A[1]!==void 0){const D=(0,g.moveToCellSequence)(A[0]-1,A[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(D,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const w=this._model.finalSelectionStart,j=this._model.finalSelectionEnd,A=!(!w||!j||w[0]===j[0]&&w[1]===j[1]);A?w&&j&&(this._oldSelectionStart&&this._oldSelectionEnd&&w[0]===this._oldSelectionStart[0]&&w[1]===this._oldSelectionStart[1]&&j[0]===this._oldSelectionEnd[0]&&j[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(w,j,A)):this._oldHasSelection&&this._fireOnSelectionChange(w,j,A)}_fireOnSelectionChange(w,j,A){this._oldSelectionStart=w,this._oldSelectionEnd=j,this._oldHasSelection=A,this._onSelectionChange.fire()}_handleBufferActivate(w){this.clearSelection(),this._trimListener.dispose(),this._trimListener=w.activeBuffer.lines.onTrim((j=>this._handleTrim(j)))}_convertViewportColToCharacterIndex(w,j){let A=j;for(let D=0;j>=D;D++){const T=w.loadCell(D,this._workCell).getChars().length;this._workCell.getWidth()===0?A--:T>1&&j!==D&&(A+=T-1)}return A}setSelection(w,j,A){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[w,j],this._model.selectionStartLength=A,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(w){this._isClickInSelection(w)||(this._selectWordAtCursor(w,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(w,j,A=!0,D=!0){if(w[0]>=this._bufferService.cols)return;const T=this._bufferService.buffer,P=T.lines.get(w[1]);if(!P)return;const F=T.translateBufferLineToString(w[1],!1);let I=this._convertViewportColToCharacterIndex(P,w[0]),z=I;const $=w[0]-I;let R=0,L=0,M=0,O=0;if(F.charAt(I)===" "){for(;I>0&&F.charAt(I-1)===" ";)I--;for(;z<F.length&&F.charAt(z+1)===" ";)z++}else{let H=w[0],W=w[0];P.getWidth(H)===0&&(R++,H--),P.getWidth(W)===2&&(L++,W++);const U=P.getString(W).length;for(U>1&&(O+=U-1,z+=U-1);H>0&&I>0&&!this._isCharWordSeparator(P.loadCell(H-1,this._workCell));){P.loadCell(H-1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===0?(R++,H--):N>1&&(M+=N-1,I-=N-1),I--,H--}for(;W<P.length&&z+1<F.length&&!this._isCharWordSeparator(P.loadCell(W+1,this._workCell));){P.loadCell(W+1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===2?(L++,W++):N>1&&(O+=N-1,z+=N-1),z++,W++}}z++;let q=I+$-R+M,V=Math.min(this._bufferService.cols,z-I+R+L-M-O);if(j||F.slice(I,z).trim()!==""){if(A&&q===0&&P.getCodePoint(0)!==32){const H=T.lines.get(w[1]-1);if(H&&P.isWrapped&&H.getCodePoint(this._bufferService.cols-1)!==32){const W=this._getWordAt([this._bufferService.cols-1,w[1]-1],!1,!0,!1);if(W){const U=this._bufferService.cols-W.start;q-=U,V+=U}}}if(D&&q+V===this._bufferService.cols&&P.getCodePoint(this._bufferService.cols-1)!==32){const H=T.lines.get(w[1]+1);if(H?.isWrapped&&H.getCodePoint(0)!==32){const W=this._getWordAt([0,w[1]+1],!1,!1,!0);W&&(V+=W.length)}}return{start:q,length:V}}}_selectWordAt(w,j){const A=this._getWordAt(w,j);if(A){for(;A.start<0;)A.start+=this._bufferService.cols,w[1]--;this._model.selectionStart=[A.start,w[1]],this._model.selectionStartLength=A.length}}_selectToWordAt(w){const j=this._getWordAt(w,!0);if(j){let A=w[1];for(;j.start<0;)j.start+=this._bufferService.cols,A--;if(!this._model.areSelectionValuesReversed())for(;j.start+j.length>this._bufferService.cols;)j.length-=this._bufferService.cols,A++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?j.start:j.start+j.length,A]}}_isCharWordSeparator(w){return w.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(w.getChars())>=0}_selectLineAt(w){const j=this._bufferService.buffer.getWrappedRangeForLine(w),A={start:{x:0,y:j.first},end:{x:this._bufferService.cols-1,y:j.last}};this._model.selectionStart=[0,j.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,u.getRangeLength)(A,this._bufferService.cols)}};i.SelectionService=E=a([d(3,S.IBufferService),d(4,S.ICoreService),d(5,b.IMouseService),d(6,S.IOptionsService),d(7,b.IRenderService),d(8,b.ICoreBrowserService)],E)},4725:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IThemeService=i.ICharacterJoinerService=i.ISelectionService=i.IRenderService=i.IMouseService=i.ICoreBrowserService=i.ICharSizeService=void 0;const a=n(8343);i.ICharSizeService=(0,a.createDecorator)("CharSizeService"),i.ICoreBrowserService=(0,a.createDecorator)("CoreBrowserService"),i.IMouseService=(0,a.createDecorator)("MouseService"),i.IRenderService=(0,a.createDecorator)("RenderService"),i.ISelectionService=(0,a.createDecorator)("SelectionService"),i.ICharacterJoinerService=(0,a.createDecorator)("CharacterJoinerService"),i.IThemeService=(0,a.createDecorator)("ThemeService")},6731:function(x,i,n){var a=this&&this.__decorate||function(E,w,j,A){var D,T=arguments.length,P=T<3?w:A===null?A=Object.getOwnPropertyDescriptor(w,j):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(E,w,j,A);else for(var F=E.length-1;F>=0;F--)(D=E[F])&&(P=(T<3?D(P):T>3?D(w,j,P):D(w,j))||P);return T>3&&P&&Object.defineProperty(w,j,P),P},d=this&&this.__param||function(E,w){return function(j,A){w(j,A,E)}};Object.defineProperty(i,"__esModule",{value:!0}),i.ThemeService=i.DEFAULT_ANSI_COLORS=void 0;const c=n(7239),g=n(8055),v=n(8460),b=n(844),y=n(2585),l=g.css.toColor("#ffffff"),h=g.css.toColor("#000000"),u=g.css.toColor("#ffffff"),f=g.css.toColor("#000000"),S={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};i.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const E=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],w=[0,95,135,175,215,255];for(let j=0;j<216;j++){const A=w[j/36%6|0],D=w[j/6%6|0],T=w[j%6];E.push({css:g.channels.toCss(A,D,T),rgba:g.channels.toRgba(A,D,T)})}for(let j=0;j<24;j++){const A=8+10*j;E.push({css:g.channels.toCss(A,A,A),rgba:g.channels.toRgba(A,A,A)})}return E})());let C=i.ThemeService=class extends b.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new c.ColorContrastCache,this._halfContrastCache=new c.ColorContrastCache,this._onChangeColors=this.register(new v.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:l,background:h,cursor:u,cursorAccent:f,selectionForeground:void 0,selectionBackgroundTransparent:S,selectionBackgroundOpaque:g.color.blend(h,S),selectionInactiveBackgroundTransparent:S,selectionInactiveBackgroundOpaque:g.color.blend(h,S),ansi:i.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(E={}){const w=this._colors;if(w.foreground=k(E.foreground,l),w.background=k(E.background,h),w.cursor=k(E.cursor,u),w.cursorAccent=k(E.cursorAccent,f),w.selectionBackgroundTransparent=k(E.selectionBackground,S),w.selectionBackgroundOpaque=g.color.blend(w.background,w.selectionBackgroundTransparent),w.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,w.selectionBackgroundTransparent),w.selectionInactiveBackgroundOpaque=g.color.blend(w.background,w.selectionInactiveBackgroundTransparent),w.selectionForeground=E.selectionForeground?k(E.selectionForeground,g.NULL_COLOR):void 0,w.selectionForeground===g.NULL_COLOR&&(w.selectionForeground=void 0),g.color.isOpaque(w.selectionBackgroundTransparent)&&(w.selectionBackgroundTransparent=g.color.opacity(w.selectionBackgroundTransparent,.3)),g.color.isOpaque(w.selectionInactiveBackgroundTransparent)&&(w.selectionInactiveBackgroundTransparent=g.color.opacity(w.selectionInactiveBackgroundTransparent,.3)),w.ansi=i.DEFAULT_ANSI_COLORS.slice(),w.ansi[0]=k(E.black,i.DEFAULT_ANSI_COLORS[0]),w.ansi[1]=k(E.red,i.DEFAULT_ANSI_COLORS[1]),w.ansi[2]=k(E.green,i.DEFAULT_ANSI_COLORS[2]),w.ansi[3]=k(E.yellow,i.DEFAULT_ANSI_COLORS[3]),w.ansi[4]=k(E.blue,i.DEFAULT_ANSI_COLORS[4]),w.ansi[5]=k(E.magenta,i.DEFAULT_ANSI_COLORS[5]),w.ansi[6]=k(E.cyan,i.DEFAULT_ANSI_COLORS[6]),w.ansi[7]=k(E.white,i.DEFAULT_ANSI_COLORS[7]),w.ansi[8]=k(E.brightBlack,i.DEFAULT_ANSI_COLORS[8]),w.ansi[9]=k(E.brightRed,i.DEFAULT_ANSI_COLORS[9]),w.ansi[10]=k(E.brightGreen,i.DEFAULT_ANSI_COLORS[10]),w.ansi[11]=k(E.brightYellow,i.DEFAULT_ANSI_COLORS[11]),w.ansi[12]=k(E.brightBlue,i.DEFAULT_ANSI_COLORS[12]),w.ansi[13]=k(E.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),w.ansi[14]=k(E.brightCyan,i.DEFAULT_ANSI_COLORS[14]),w.ansi[15]=k(E.brightWhite,i.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const j=Math.min(w.ansi.length-16,E.extendedAnsi.length);for(let A=0;A<j;A++)w.ansi[A+16]=k(E.extendedAnsi[A],i.DEFAULT_ANSI_COLORS[A+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(E){this._restoreColor(E),this._onChangeColors.fire(this.colors)}_restoreColor(E){if(E!==void 0)switch(E){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[E]=this._restoreColors.ansi[E]}else for(let w=0;w<this._restoreColors.ansi.length;++w)this._colors.ansi[w]=this._restoreColors.ansi[w]}modifyColors(E){E(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function k(E,w){if(E!==void 0)try{return g.css.toColor(E)}catch{}return w}i.ThemeService=C=a([d(0,y.IOptionsService)],C)},6349:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CircularList=void 0;const a=n(8460),d=n(844);class c extends d.Disposable{constructor(v){super(),this._maxLength=v,this.onDeleteEmitter=this.register(new a.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new a.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new a.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(v){if(this._maxLength===v)return;const b=new Array(v);for(let y=0;y<Math.min(v,this.length);y++)b[y]=this._array[this._getCyclicIndex(y)];this._array=b,this._maxLength=v,this._startIndex=0}get length(){return this._length}set length(v){if(v>this._length)for(let b=this._length;b<v;b++)this._array[b]=void 0;this._length=v}get(v){return this._array[this._getCyclicIndex(v)]}set(v,b){this._array[this._getCyclicIndex(v)]=b}push(v){this._array[this._getCyclicIndex(this._length)]=v,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(v,b,...y){if(b){for(let l=v;l<this._length-b;l++)this._array[this._getCyclicIndex(l)]=this._array[this._getCyclicIndex(l+b)];this._length-=b,this.onDeleteEmitter.fire({index:v,amount:b})}for(let l=this._length-1;l>=v;l--)this._array[this._getCyclicIndex(l+y.length)]=this._array[this._getCyclicIndex(l)];for(let l=0;l<y.length;l++)this._array[this._getCyclicIndex(v+l)]=y[l];if(y.length&&this.onInsertEmitter.fire({index:v,amount:y.length}),this._length+y.length>this._maxLength){const l=this._length+y.length-this._maxLength;this._startIndex+=l,this._length=this._maxLength,this.onTrimEmitter.fire(l)}else this._length+=y.length}trimStart(v){v>this._length&&(v=this._length),this._startIndex+=v,this._length-=v,this.onTrimEmitter.fire(v)}shiftElements(v,b,y){if(!(b<=0)){if(v<0||v>=this._length)throw new Error("start argument out of range");if(v+y<0)throw new Error("Cannot shift elements in list beyond index 0");if(y>0){for(let h=b-1;h>=0;h--)this.set(v+h+y,this.get(v+h));const l=v+b+y-this._length;if(l>0)for(this._length+=l;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let l=0;l<b;l++)this.set(v+l+y,this.get(v+l))}}_getCyclicIndex(v){return(this._startIndex+v)%this._maxLength}}i.CircularList=c},1439:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.clone=void 0,i.clone=function n(a,d=5){if(typeof a!="object")return a;const c=Array.isArray(a)?[]:{};for(const g in a)c[g]=d<=1?a[g]:a[g]&&n(a[g],d-1);return c}},8055:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.contrastRatio=i.toPaddedHex=i.rgba=i.rgb=i.css=i.color=i.channels=i.NULL_COLOR=void 0;const a=n(6114);let d=0,c=0,g=0,v=0;var b,y,l,h,u;function f(C){const k=C.toString(16);return k.length<2?"0"+k:k}function S(C,k){return C<k?(k+.05)/(C+.05):(C+.05)/(k+.05)}i.NULL_COLOR={css:"#00000000",rgba:0},(function(C){C.toCss=function(k,E,w,j){return j!==void 0?`#${f(k)}${f(E)}${f(w)}${f(j)}`:`#${f(k)}${f(E)}${f(w)}`},C.toRgba=function(k,E,w,j=255){return(k<<24|E<<16|w<<8|j)>>>0}})(b||(i.channels=b={})),(function(C){function k(E,w){return v=Math.round(255*w),[d,c,g]=u.toChannels(E.rgba),{css:b.toCss(d,c,g,v),rgba:b.toRgba(d,c,g,v)}}C.blend=function(E,w){if(v=(255&w.rgba)/255,v===1)return{css:w.css,rgba:w.rgba};const j=w.rgba>>24&255,A=w.rgba>>16&255,D=w.rgba>>8&255,T=E.rgba>>24&255,P=E.rgba>>16&255,F=E.rgba>>8&255;return d=T+Math.round((j-T)*v),c=P+Math.round((A-P)*v),g=F+Math.round((D-F)*v),{css:b.toCss(d,c,g),rgba:b.toRgba(d,c,g)}},C.isOpaque=function(E){return(255&E.rgba)==255},C.ensureContrastRatio=function(E,w,j){const A=u.ensureContrastRatio(E.rgba,w.rgba,j);if(A)return u.toColor(A>>24&255,A>>16&255,A>>8&255)},C.opaque=function(E){const w=(255|E.rgba)>>>0;return[d,c,g]=u.toChannels(w),{css:b.toCss(d,c,g),rgba:w}},C.opacity=k,C.multiplyOpacity=function(E,w){return v=255&E.rgba,k(E,v*w/255)},C.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(y||(i.color=y={})),(function(C){let k,E;if(!a.isNode){const w=document.createElement("canvas");w.width=1,w.height=1;const j=w.getContext("2d",{willReadFrequently:!0});j&&(k=j,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}C.toColor=function(w){if(w.match(/#[\da-f]{3,8}/i))switch(w.length){case 4:return d=parseInt(w.slice(1,2).repeat(2),16),c=parseInt(w.slice(2,3).repeat(2),16),g=parseInt(w.slice(3,4).repeat(2),16),u.toColor(d,c,g);case 5:return d=parseInt(w.slice(1,2).repeat(2),16),c=parseInt(w.slice(2,3).repeat(2),16),g=parseInt(w.slice(3,4).repeat(2),16),v=parseInt(w.slice(4,5).repeat(2),16),u.toColor(d,c,g,v);case 7:return{css:w,rgba:(parseInt(w.slice(1),16)<<8|255)>>>0};case 9:return{css:w,rgba:parseInt(w.slice(1),16)>>>0}}const j=w.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(j)return d=parseInt(j[1]),c=parseInt(j[2]),g=parseInt(j[3]),v=Math.round(255*(j[5]===void 0?1:parseFloat(j[5]))),u.toColor(d,c,g,v);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=w,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[d,c,g,v]=k.getImageData(0,0,1,1).data,v!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:b.toRgba(d,c,g,v),css:w}}})(l||(i.css=l={})),(function(C){function k(E,w,j){const A=E/255,D=w/255,T=j/255;return .2126*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.7152*(D<=.03928?D/12.92:Math.pow((D+.055)/1.055,2.4))+.0722*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))}C.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},C.relativeLuminance2=k})(h||(i.rgb=h={})),(function(C){function k(w,j,A){const D=w>>24&255,T=w>>16&255,P=w>>8&255;let F=j>>24&255,I=j>>16&255,z=j>>8&255,$=S(h.relativeLuminance2(F,I,z),h.relativeLuminance2(D,T,P));for(;$<A&&(F>0||I>0||z>0);)F-=Math.max(0,Math.ceil(.1*F)),I-=Math.max(0,Math.ceil(.1*I)),z-=Math.max(0,Math.ceil(.1*z)),$=S(h.relativeLuminance2(F,I,z),h.relativeLuminance2(D,T,P));return(F<<24|I<<16|z<<8|255)>>>0}function E(w,j,A){const D=w>>24&255,T=w>>16&255,P=w>>8&255;let F=j>>24&255,I=j>>16&255,z=j>>8&255,$=S(h.relativeLuminance2(F,I,z),h.relativeLuminance2(D,T,P));for(;$<A&&(F<255||I<255||z<255);)F=Math.min(255,F+Math.ceil(.1*(255-F))),I=Math.min(255,I+Math.ceil(.1*(255-I))),z=Math.min(255,z+Math.ceil(.1*(255-z))),$=S(h.relativeLuminance2(F,I,z),h.relativeLuminance2(D,T,P));return(F<<24|I<<16|z<<8|255)>>>0}C.ensureContrastRatio=function(w,j,A){const D=h.relativeLuminance(w>>8),T=h.relativeLuminance(j>>8);if(S(D,T)<A){if(T<D){const I=k(w,j,A),z=S(D,h.relativeLuminance(I>>8));if(z<A){const $=E(w,j,A);return z>S(D,h.relativeLuminance($>>8))?I:$}return I}const P=E(w,j,A),F=S(D,h.relativeLuminance(P>>8));if(F<A){const I=k(w,j,A);return F>S(D,h.relativeLuminance(I>>8))?P:I}return P}},C.reduceLuminance=k,C.increaseLuminance=E,C.toChannels=function(w){return[w>>24&255,w>>16&255,w>>8&255,255&w]},C.toColor=function(w,j,A,D){return{css:b.toCss(w,j,A,D),rgba:b.toRgba(w,j,A,D)}}})(u||(i.rgba=u={})),i.toPaddedHex=f,i.contrastRatio=S},8969:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreTerminal=void 0;const a=n(844),d=n(2585),c=n(4348),g=n(7866),v=n(744),b=n(7302),y=n(6975),l=n(8460),h=n(1753),u=n(1480),f=n(7994),S=n(9282),C=n(5435),k=n(5981),E=n(2660);let w=!1;class j extends a.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new l.EventEmitter),this._onScroll.event((D=>{var T;(T=this._onScrollApi)===null||T===void 0||T.fire(D.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(D){for(const T in D)this.optionsService.options[T]=D[T]}constructor(D){super(),this._windowsWrappingHeuristics=this.register(new a.MutableDisposable),this._onBinary=this.register(new l.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new l.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new l.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new l.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new l.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new l.EventEmitter),this._instantiationService=new c.InstantiationService,this.optionsService=this.register(new b.OptionsService(D)),this._instantiationService.setService(d.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(v.BufferService)),this._instantiationService.setService(d.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(d.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(y.CoreService)),this._instantiationService.setService(d.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(d.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(u.UnicodeService)),this._instantiationService.setService(d.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(f.CharsetService),this._instantiationService.setService(d.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(d.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new C.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,l.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,l.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,l.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,l.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((T=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((T=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new k.WriteBuffer(((T,P)=>this._inputHandler.parse(T,P)))),this.register((0,l.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(D,T){this._writeBuffer.write(D,T)}writeSync(D,T){this._logService.logLevel<=d.LogLevelEnum.WARN&&!w&&(this._logService.warn("writeSync is unreliable and will be removed soon."),w=!0),this._writeBuffer.writeSync(D,T)}resize(D,T){isNaN(D)||isNaN(T)||(D=Math.max(D,v.MINIMUM_COLS),T=Math.max(T,v.MINIMUM_ROWS),this._bufferService.resize(D,T))}scroll(D,T=!1){this._bufferService.scroll(D,T)}scrollLines(D,T,P){this._bufferService.scrollLines(D,T,P)}scrollPages(D){this.scrollLines(D*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(D){const T=D-this._bufferService.buffer.ydisp;T!==0&&this.scrollLines(T)}registerEscHandler(D,T){return this._inputHandler.registerEscHandler(D,T)}registerDcsHandler(D,T){return this._inputHandler.registerDcsHandler(D,T)}registerCsiHandler(D,T){return this._inputHandler.registerCsiHandler(D,T)}registerOscHandler(D,T){return this._inputHandler.registerOscHandler(D,T)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let D=!1;const T=this.optionsService.rawOptions.windowsPty;T&&T.buildNumber!==void 0&&T.buildNumber!==void 0?D=T.backend==="conpty"&&T.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(D=!0),D?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const D=[];D.push(this.onLineFeed(S.updateWindowsModeWrappedState.bind(null,this._bufferService))),D.push(this.registerCsiHandler({final:"H"},(()=>((0,S.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,a.toDisposable)((()=>{for(const T of D)T.dispose()}))}}}i.CoreTerminal=j},8460:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.forwardEvent=i.EventEmitter=void 0,i.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=n=>(this._listeners.push(n),{dispose:()=>{if(!this._disposed){for(let a=0;a<this._listeners.length;a++)if(this._listeners[a]===n)return void this._listeners.splice(a,1)}}})),this._event}fire(n,a){const d=[];for(let c=0;c<this._listeners.length;c++)d.push(this._listeners[c]);for(let c=0;c<d.length;c++)d[c].call(void 0,n,a)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},i.forwardEvent=function(n,a){return n((d=>a.fire(d)))}},5435:function(x,i,n){var a=this&&this.__decorate||function($,R,L,M){var O,q=arguments.length,V=q<3?R:M===null?M=Object.getOwnPropertyDescriptor(R,L):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")V=Reflect.decorate($,R,L,M);else for(var H=$.length-1;H>=0;H--)(O=$[H])&&(V=(q<3?O(V):q>3?O(R,L,V):O(R,L))||V);return q>3&&V&&Object.defineProperty(R,L,V),V},d=this&&this.__param||function($,R){return function(L,M){R(L,M,$)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const c=n(2584),g=n(7116),v=n(2015),b=n(844),y=n(482),l=n(8437),h=n(8460),u=n(643),f=n(511),S=n(3734),C=n(2585),k=n(6242),E=n(6351),w=n(5941),j={"(":0,")":1,"*":2,"+":3,"-":1,".":2},A=131072;function D($,R){if($>24)return R.setWinLines||!1;switch($){case 1:return!!R.restoreWin;case 2:return!!R.minimizeWin;case 3:return!!R.setWinPosition;case 4:return!!R.setWinSizePixels;case 5:return!!R.raiseWin;case 6:return!!R.lowerWin;case 7:return!!R.refreshWin;case 8:return!!R.setWinSizeChars;case 9:return!!R.maximizeWin;case 10:return!!R.fullscreenWin;case 11:return!!R.getWinState;case 13:return!!R.getWinPosition;case 14:return!!R.getWinSizePixels;case 15:return!!R.getScreenSizePixels;case 16:return!!R.getCellSizePixels;case 18:return!!R.getWinSizeChars;case 19:return!!R.getScreenSizeChars;case 20:return!!R.getIconTitle;case 21:return!!R.getWinTitle;case 22:return!!R.pushTitle;case 23:return!!R.popTitle;case 24:return!!R.setWinLines}return!1}var T;(function($){$[$.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",$[$.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(T||(i.WindowsOptionsReportType=T={}));let P=0;class F extends b.Disposable{getAttrData(){return this._curAttrData}constructor(R,L,M,O,q,V,H,W,U=new v.EscapeSequenceParser){super(),this._bufferService=R,this._charsetService=L,this._coreService=M,this._logService=O,this._optionsService=q,this._oscLinkService=V,this._coreMouseService=H,this._unicodeService=W,this._parser=U,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new y.StringToUtf32,this._utf8Decoder=new y.Utf8ToUtf32,this._workCell=new f.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=l.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=l.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new h.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new h.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new h.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new h.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new h.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new h.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new h.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new h.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new h.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new h.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new h.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new h.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new h.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new I(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((N=>this._activeBuffer=N.activeBuffer))),this._parser.setCsiHandlerFallback(((N,B)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(N),params:B.toArray()})})),this._parser.setEscHandlerFallback((N=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(N)})})),this._parser.setExecuteHandlerFallback((N=>{this._logService.debug("Unknown EXECUTE code: ",{code:N})})),this._parser.setOscHandlerFallback(((N,B,K)=>{this._logService.debug("Unknown OSC code: ",{identifier:N,action:B,data:K})})),this._parser.setDcsHandlerFallback(((N,B,K)=>{B==="HOOK"&&(K=K.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(N),action:B,payload:K})})),this._parser.setPrintHandler(((N,B,K)=>this.print(N,B,K))),this._parser.registerCsiHandler({final:"@"},(N=>this.insertChars(N))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(N=>this.scrollLeft(N))),this._parser.registerCsiHandler({final:"A"},(N=>this.cursorUp(N))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(N=>this.scrollRight(N))),this._parser.registerCsiHandler({final:"B"},(N=>this.cursorDown(N))),this._parser.registerCsiHandler({final:"C"},(N=>this.cursorForward(N))),this._parser.registerCsiHandler({final:"D"},(N=>this.cursorBackward(N))),this._parser.registerCsiHandler({final:"E"},(N=>this.cursorNextLine(N))),this._parser.registerCsiHandler({final:"F"},(N=>this.cursorPrecedingLine(N))),this._parser.registerCsiHandler({final:"G"},(N=>this.cursorCharAbsolute(N))),this._parser.registerCsiHandler({final:"H"},(N=>this.cursorPosition(N))),this._parser.registerCsiHandler({final:"I"},(N=>this.cursorForwardTab(N))),this._parser.registerCsiHandler({final:"J"},(N=>this.eraseInDisplay(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(N=>this.eraseInDisplay(N,!0))),this._parser.registerCsiHandler({final:"K"},(N=>this.eraseInLine(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(N=>this.eraseInLine(N,!0))),this._parser.registerCsiHandler({final:"L"},(N=>this.insertLines(N))),this._parser.registerCsiHandler({final:"M"},(N=>this.deleteLines(N))),this._parser.registerCsiHandler({final:"P"},(N=>this.deleteChars(N))),this._parser.registerCsiHandler({final:"S"},(N=>this.scrollUp(N))),this._parser.registerCsiHandler({final:"T"},(N=>this.scrollDown(N))),this._parser.registerCsiHandler({final:"X"},(N=>this.eraseChars(N))),this._parser.registerCsiHandler({final:"Z"},(N=>this.cursorBackwardTab(N))),this._parser.registerCsiHandler({final:"`"},(N=>this.charPosAbsolute(N))),this._parser.registerCsiHandler({final:"a"},(N=>this.hPositionRelative(N))),this._parser.registerCsiHandler({final:"b"},(N=>this.repeatPrecedingCharacter(N))),this._parser.registerCsiHandler({final:"c"},(N=>this.sendDeviceAttributesPrimary(N))),this._parser.registerCsiHandler({prefix:">",final:"c"},(N=>this.sendDeviceAttributesSecondary(N))),this._parser.registerCsiHandler({final:"d"},(N=>this.linePosAbsolute(N))),this._parser.registerCsiHandler({final:"e"},(N=>this.vPositionRelative(N))),this._parser.registerCsiHandler({final:"f"},(N=>this.hVPosition(N))),this._parser.registerCsiHandler({final:"g"},(N=>this.tabClear(N))),this._parser.registerCsiHandler({final:"h"},(N=>this.setMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(N=>this.setModePrivate(N))),this._parser.registerCsiHandler({final:"l"},(N=>this.resetMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(N=>this.resetModePrivate(N))),this._parser.registerCsiHandler({final:"m"},(N=>this.charAttributes(N))),this._parser.registerCsiHandler({final:"n"},(N=>this.deviceStatus(N))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(N=>this.deviceStatusPrivate(N))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(N=>this.softReset(N))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(N=>this.setCursorStyle(N))),this._parser.registerCsiHandler({final:"r"},(N=>this.setScrollRegion(N))),this._parser.registerCsiHandler({final:"s"},(N=>this.saveCursor(N))),this._parser.registerCsiHandler({final:"t"},(N=>this.windowOptions(N))),this._parser.registerCsiHandler({final:"u"},(N=>this.restoreCursor(N))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(N=>this.insertColumns(N))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(N=>this.deleteColumns(N))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(N=>this.selectProtected(N))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(N=>this.requestMode(N,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(N=>this.requestMode(N,!1))),this._parser.setExecuteHandler(c.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(c.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(c.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(c.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(c.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(c.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(c.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(c.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(c.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((N=>(this.setTitle(N),this.setIconName(N),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((N=>this.setIconName(N)))),this._parser.registerOscHandler(2,new k.OscHandler((N=>this.setTitle(N)))),this._parser.registerOscHandler(4,new k.OscHandler((N=>this.setOrReportIndexedColor(N)))),this._parser.registerOscHandler(8,new k.OscHandler((N=>this.setHyperlink(N)))),this._parser.registerOscHandler(10,new k.OscHandler((N=>this.setOrReportFgColor(N)))),this._parser.registerOscHandler(11,new k.OscHandler((N=>this.setOrReportBgColor(N)))),this._parser.registerOscHandler(12,new k.OscHandler((N=>this.setOrReportCursorColor(N)))),this._parser.registerOscHandler(104,new k.OscHandler((N=>this.restoreIndexedColor(N)))),this._parser.registerOscHandler(110,new k.OscHandler((N=>this.restoreFgColor(N)))),this._parser.registerOscHandler(111,new k.OscHandler((N=>this.restoreBgColor(N)))),this._parser.registerOscHandler(112,new k.OscHandler((N=>this.restoreCursorColor(N)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const N in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:N},(()=>this.selectCharset("("+N))),this._parser.registerEscHandler({intermediates:")",final:N},(()=>this.selectCharset(")"+N))),this._parser.registerEscHandler({intermediates:"*",final:N},(()=>this.selectCharset("*"+N))),this._parser.registerEscHandler({intermediates:"+",final:N},(()=>this.selectCharset("+"+N))),this._parser.registerEscHandler({intermediates:"-",final:N},(()=>this.selectCharset("-"+N))),this._parser.registerEscHandler({intermediates:".",final:N},(()=>this.selectCharset("."+N))),this._parser.registerEscHandler({intermediates:"/",final:N},(()=>this.selectCharset("/"+N)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((N=>(this._logService.error("Parsing error: ",N),N))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((N,B)=>this.requestStatusString(N,B))))}_preserveStack(R,L,M,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=R,this._parseStack.cursorStartY=L,this._parseStack.decodedLength=M,this._parseStack.position=O}_logSlowResolvingAsync(R){this._logService.logLevel<=C.LogLevelEnum.WARN&&Promise.race([R,new Promise(((L,M)=>setTimeout((()=>M("#SLOW_TIMEOUT")),5e3)))]).catch((L=>{if(L!=="#SLOW_TIMEOUT")throw L;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(R,L){let M,O=this._activeBuffer.x,q=this._activeBuffer.y,V=0;const H=this._parseStack.paused;if(H){if(M=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,L))return this._logSlowResolvingAsync(M),M;O=this._parseStack.cursorStartX,q=this._parseStack.cursorStartY,this._parseStack.paused=!1,R.length>A&&(V=this._parseStack.position+A)}if(this._logService.logLevel<=C.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof R=="string"?` "${R}"`:` "${Array.prototype.map.call(R,(W=>String.fromCharCode(W))).join("")}"`),typeof R=="string"?R.split("").map((W=>W.charCodeAt(0))):R),this._parseBuffer.length<R.length&&this._parseBuffer.length<A&&(this._parseBuffer=new Uint32Array(Math.min(R.length,A))),H||this._dirtyRowTracker.clearRange(),R.length>A)for(let W=V;W<R.length;W+=A){const U=W+A<R.length?W+A:R.length,N=typeof R=="string"?this._stringDecoder.decode(R.substring(W,U),this._parseBuffer):this._utf8Decoder.decode(R.subarray(W,U),this._parseBuffer);if(M=this._parser.parse(this._parseBuffer,N))return this._preserveStack(O,q,N,W),this._logSlowResolvingAsync(M),M}else if(!H){const W=typeof R=="string"?this._stringDecoder.decode(R,this._parseBuffer):this._utf8Decoder.decode(R,this._parseBuffer);if(M=this._parser.parse(this._parseBuffer,W))return this._preserveStack(O,q,W,0),this._logSlowResolvingAsync(M),M}this._activeBuffer.x===O&&this._activeBuffer.y===q||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(R,L,M){let O,q;const V=this._charsetService.charset,H=this._optionsService.rawOptions.screenReaderMode,W=this._bufferService.cols,U=this._coreService.decPrivateModes.wraparound,N=this._coreService.modes.insertMode,B=this._curAttrData;let K=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&M-L>0&&K.getWidth(this._activeBuffer.x-1)===2&&K.setCellFromCodePoint(this._activeBuffer.x-1,0,1,B.fg,B.bg,B.extended);for(let Y=L;Y<M;++Y){if(O=R[Y],q=this._unicodeService.wcwidth(O),O<127&&V){const J=V[String.fromCharCode(O)];J&&(O=J.charCodeAt(0))}if(H&&this._onA11yChar.fire((0,y.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),q||!this._activeBuffer.x){if(this._activeBuffer.x+q-1>=W){if(U){for(;this._activeBuffer.x<W;)K.setCellFromCodePoint(this._activeBuffer.x++,0,1,B.fg,B.bg,B.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),K=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=W-1,q===2)continue}if(N&&(K.insertCells(this._activeBuffer.x,q,this._activeBuffer.getNullCell(B),B),K.getWidth(W-1)===2&&K.setCellFromCodePoint(W-1,u.NULL_CELL_CODE,u.NULL_CELL_WIDTH,B.fg,B.bg,B.extended)),K.setCellFromCodePoint(this._activeBuffer.x++,O,q,B.fg,B.bg,B.extended),q>0)for(;--q;)K.setCellFromCodePoint(this._activeBuffer.x++,0,0,B.fg,B.bg,B.extended)}else K.getWidth(this._activeBuffer.x-1)?K.addCodepointToCell(this._activeBuffer.x-1,O):K.addCodepointToCell(this._activeBuffer.x-2,O)}M-L>0&&(K.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<W&&M-L>0&&K.getWidth(this._activeBuffer.x)===0&&!K.hasContent(this._activeBuffer.x)&&K.setCellFromCodePoint(this._activeBuffer.x,0,1,B.fg,B.bg,B.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(R,L){return R.final!=="t"||R.prefix||R.intermediates?this._parser.registerCsiHandler(R,L):this._parser.registerCsiHandler(R,(M=>!D(M.params[0],this._optionsService.rawOptions.windowOptions)||L(M)))}registerDcsHandler(R,L){return this._parser.registerDcsHandler(R,new E.DcsHandler(L))}registerEscHandler(R,L){return this._parser.registerEscHandler(R,L)}registerOscHandler(R,L){return this._parser.registerOscHandler(R,new k.OscHandler(L))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var R;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((R=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||R===void 0)&&R.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);L.hasWidth(this._activeBuffer.x)&&!L.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const R=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-R),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(R=this._bufferService.cols-1){this._activeBuffer.x=Math.min(R,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(R,L){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=R,this._activeBuffer.y=this._activeBuffer.scrollTop+L):(this._activeBuffer.x=R,this._activeBuffer.y=L),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(R,L){this._restrictCursor(),this._setCursor(this._activeBuffer.x+R,this._activeBuffer.y+L)}cursorUp(R){const L=this._activeBuffer.y-this._activeBuffer.scrollTop;return L>=0?this._moveCursor(0,-Math.min(L,R.params[0]||1)):this._moveCursor(0,-(R.params[0]||1)),!0}cursorDown(R){const L=this._activeBuffer.scrollBottom-this._activeBuffer.y;return L>=0?this._moveCursor(0,Math.min(L,R.params[0]||1)):this._moveCursor(0,R.params[0]||1),!0}cursorForward(R){return this._moveCursor(R.params[0]||1,0),!0}cursorBackward(R){return this._moveCursor(-(R.params[0]||1),0),!0}cursorNextLine(R){return this.cursorDown(R),this._activeBuffer.x=0,!0}cursorPrecedingLine(R){return this.cursorUp(R),this._activeBuffer.x=0,!0}cursorCharAbsolute(R){return this._setCursor((R.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(R){return this._setCursor(R.length>=2?(R.params[1]||1)-1:0,(R.params[0]||1)-1),!0}charPosAbsolute(R){return this._setCursor((R.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(R){return this._moveCursor(R.params[0]||1,0),!0}linePosAbsolute(R){return this._setCursor(this._activeBuffer.x,(R.params[0]||1)-1),!0}vPositionRelative(R){return this._moveCursor(0,R.params[0]||1),!0}hVPosition(R){return this.cursorPosition(R),!0}tabClear(R){const L=R.params[0];return L===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:L===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(R){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let L=R.params[0]||1;for(;L--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(R){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let L=R.params[0]||1;for(;L--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(R){const L=R.params[0];return L===1&&(this._curAttrData.bg|=536870912),L!==2&&L!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(R,L,M,O=!1,q=!1){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);V.replaceCells(L,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),q),O&&(V.isWrapped=!1)}_resetBufferLine(R,L=!1){const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);M&&(M.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),L),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+R),M.isWrapped=!1)}eraseInDisplay(R,L=!1){let M;switch(this._restrictCursor(this._bufferService.cols),R.params[0]){case 0:for(M=this._activeBuffer.y,this._dirtyRowTracker.markDirty(M),this._eraseInBufferLine(M++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,L);M<this._bufferService.rows;M++)this._resetBufferLine(M,L);this._dirtyRowTracker.markDirty(M);break;case 1:for(M=this._activeBuffer.y,this._dirtyRowTracker.markDirty(M),this._eraseInBufferLine(M,0,this._activeBuffer.x+1,!0,L),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(M+1).isWrapped=!1);M--;)this._resetBufferLine(M,L);this._dirtyRowTracker.markDirty(0);break;case 2:for(M=this._bufferService.rows,this._dirtyRowTracker.markDirty(M-1);M--;)this._resetBufferLine(M,L);this._dirtyRowTracker.markDirty(0);break;case 3:const O=this._activeBuffer.lines.length-this._bufferService.rows;O>0&&(this._activeBuffer.lines.trimStart(O),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-O,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-O,0),this._onScroll.fire(0))}return!0}eraseInLine(R,L=!1){switch(this._restrictCursor(this._bufferService.cols),R.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,L);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,L);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,L)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(R){this._restrictCursor();let L=R.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=this._activeBuffer.ybase+this._activeBuffer.y,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,q=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;L--;)this._activeBuffer.lines.splice(q-1,1),this._activeBuffer.lines.splice(M,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(R){this._restrictCursor();let L=R.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=this._activeBuffer.ybase+this._activeBuffer.y;let O;for(O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,O=this._bufferService.rows-1+this._activeBuffer.ybase-O;L--;)this._activeBuffer.lines.splice(M,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(R){this._restrictCursor();const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return L&&(L.insertCells(this._activeBuffer.x,R.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(R){this._restrictCursor();const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return L&&(L.deleteCells(this._activeBuffer.x,R.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(R){let L=R.params[0]||1;for(;L--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(R){let L=R.params[0]||1;for(;L--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(l.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=R.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);O.deleteCells(0,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=R.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);O.insertCells(0,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=R.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);O.insertCells(this._activeBuffer.x,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=R.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);O.deleteCells(this._activeBuffer.x,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(R){this._restrictCursor();const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return L&&(L.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(R.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(R){if(!this._parser.precedingCodepoint)return!0;const L=R.params[0]||1,M=new Uint32Array(L);for(let O=0;O<L;++O)M[O]=this._parser.precedingCodepoint;return this.print(M,0,M.length),!0}sendDeviceAttributesPrimary(R){return R.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(R){return R.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(R.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(R){return(this._optionsService.rawOptions.termName+"").indexOf(R)===0}setMode(R){for(let L=0;L<R.length;L++)switch(R.params[L]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(R){for(let L=0;L<R.length;L++)switch(R.params[L]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(R){for(let L=0;L<R.length;L++)switch(R.params[L]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(R){for(let L=0;L<R.length;L++)switch(R.params[L]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),R.params[L]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(R,L){const M=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:q}=this._coreMouseService,V=this._coreService,{buffers:H,cols:W}=this._bufferService,{active:U,alt:N}=H,B=this._optionsService.rawOptions,K=de=>de?1:2,Y=R.params[0];return J=Y,G=L?Y===2?4:Y===4?K(V.modes.insertMode):Y===12?3:Y===20?K(B.convertEol):0:Y===1?K(M.applicationCursorKeys):Y===3?B.windowOptions.setWinLines?W===80?2:W===132?1:0:0:Y===6?K(M.origin):Y===7?K(M.wraparound):Y===8?3:Y===9?K(O==="X10"):Y===12?K(B.cursorBlink):Y===25?K(!V.isCursorHidden):Y===45?K(M.reverseWraparound):Y===66?K(M.applicationKeypad):Y===67?4:Y===1e3?K(O==="VT200"):Y===1002?K(O==="DRAG"):Y===1003?K(O==="ANY"):Y===1004?K(M.sendFocus):Y===1005?4:Y===1006?K(q==="SGR"):Y===1015?4:Y===1016?K(q==="SGR_PIXELS"):Y===1048?1:Y===47||Y===1047||Y===1049?K(U===N):Y===2004?K(M.bracketedPasteMode):0,V.triggerDataEvent(`${c.C0.ESC}[${L?"":"?"}${J};${G}$y`),!0;var J,G}_updateAttrColor(R,L,M,O,q){return L===2?(R|=50331648,R&=-16777216,R|=S.AttributeData.fromColorRGB([M,O,q])):L===5&&(R&=-50331904,R|=33554432|255&M),R}_extractColor(R,L,M){const O=[0,0,-1,0,0,0];let q=0,V=0;do{if(O[V+q]=R.params[L+V],R.hasSubParams(L+V)){const H=R.getSubParams(L+V);let W=0;do O[1]===5&&(q=1),O[V+W+1+q]=H[W];while(++W<H.length&&W+V+1+q<O.length);break}if(O[1]===5&&V+q>=2||O[1]===2&&V+q>=5)break;O[1]&&(q=1)}while(++V+L<R.length&&V+q<O.length);for(let H=2;H<O.length;++H)O[H]===-1&&(O[H]=0);switch(O[0]){case 38:M.fg=this._updateAttrColor(M.fg,O[1],O[3],O[4],O[5]);break;case 48:M.bg=this._updateAttrColor(M.bg,O[1],O[3],O[4],O[5]);break;case 58:M.extended=M.extended.clone(),M.extended.underlineColor=this._updateAttrColor(M.extended.underlineColor,O[1],O[3],O[4],O[5])}return V}_processUnderline(R,L){L.extended=L.extended.clone(),(!~R||R>5)&&(R=1),L.extended.underlineStyle=R,L.fg|=268435456,R===0&&(L.fg&=-268435457),L.updateExtended()}_processSGR0(R){R.fg=l.DEFAULT_ATTR_DATA.fg,R.bg=l.DEFAULT_ATTR_DATA.bg,R.extended=R.extended.clone(),R.extended.underlineStyle=0,R.extended.underlineColor&=-67108864,R.updateExtended()}charAttributes(R){if(R.length===1&&R.params[0]===0)return this._processSGR0(this._curAttrData),!0;const L=R.length;let M;const O=this._curAttrData;for(let q=0;q<L;q++)M=R.params[q],M>=30&&M<=37?(O.fg&=-50331904,O.fg|=16777216|M-30):M>=40&&M<=47?(O.bg&=-50331904,O.bg|=16777216|M-40):M>=90&&M<=97?(O.fg&=-50331904,O.fg|=16777224|M-90):M>=100&&M<=107?(O.bg&=-50331904,O.bg|=16777224|M-100):M===0?this._processSGR0(O):M===1?O.fg|=134217728:M===3?O.bg|=67108864:M===4?(O.fg|=268435456,this._processUnderline(R.hasSubParams(q)?R.getSubParams(q)[0]:1,O)):M===5?O.fg|=536870912:M===7?O.fg|=67108864:M===8?O.fg|=1073741824:M===9?O.fg|=2147483648:M===2?O.bg|=134217728:M===21?this._processUnderline(2,O):M===22?(O.fg&=-134217729,O.bg&=-134217729):M===23?O.bg&=-67108865:M===24?(O.fg&=-268435457,this._processUnderline(0,O)):M===25?O.fg&=-536870913:M===27?O.fg&=-67108865:M===28?O.fg&=-1073741825:M===29?O.fg&=2147483647:M===39?(O.fg&=-67108864,O.fg|=16777215&l.DEFAULT_ATTR_DATA.fg):M===49?(O.bg&=-67108864,O.bg|=16777215&l.DEFAULT_ATTR_DATA.bg):M===38||M===48||M===58?q+=this._extractColor(R,q,O):M===53?O.bg|=1073741824:M===55?O.bg&=-1073741825:M===59?(O.extended=O.extended.clone(),O.extended.underlineColor=-1,O.updateExtended()):M===100?(O.fg&=-67108864,O.fg|=16777215&l.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&l.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",M);return!0}deviceStatus(R){switch(R.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const L=this._activeBuffer.y+1,M=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${L};${M}R`)}return!0}deviceStatusPrivate(R){if(R.params[0]===6){const L=this._activeBuffer.y+1,M=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${L};${M}R`)}return!0}softReset(R){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=l.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(R){const L=R.params[0]||1;switch(L){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const M=L%2==1;return this._optionsService.options.cursorBlink=M,!0}setScrollRegion(R){const L=R.params[0]||1;let M;return(R.length<2||(M=R.params[1])>this._bufferService.rows||M===0)&&(M=this._bufferService.rows),M>L&&(this._activeBuffer.scrollTop=L-1,this._activeBuffer.scrollBottom=M-1,this._setCursor(0,0)),!0}windowOptions(R){if(!D(R.params[0],this._optionsService.rawOptions.windowOptions))return!0;const L=R.length>1?R.params[1]:0;switch(R.params[0]){case 14:L!==2&&this._onRequestWindowsOptionsReport.fire(T.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(T.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${c.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:L!==0&&L!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),L!==0&&L!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:L!==0&&L!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),L!==0&&L!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(R){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(R){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(R){return this._windowTitle=R,this._onTitleChange.fire(R),!0}setIconName(R){return this._iconName=R,!0}setOrReportIndexedColor(R){const L=[],M=R.split(";");for(;M.length>1;){const O=M.shift(),q=M.shift();if(/^\d+$/.exec(O)){const V=parseInt(O);if(z(V))if(q==="?")L.push({type:0,index:V});else{const H=(0,w.parseColor)(q);H&&L.push({type:1,index:V,color:H})}}}return L.length&&this._onColor.fire(L),!0}setHyperlink(R){const L=R.split(";");return!(L.length<2)&&(L[1]?this._createHyperlink(L[0],L[1]):!L[0]&&this._finishHyperlink())}_createHyperlink(R,L){this._getCurrentLinkId()&&this._finishHyperlink();const M=R.split(":");let O;const q=M.findIndex((V=>V.startsWith("id=")));return q!==-1&&(O=M[q].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:L}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(R,L){const M=R.split(";");for(let O=0;O<M.length&&!(L>=this._specialColors.length);++O,++L)if(M[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[L]}]);else{const q=(0,w.parseColor)(M[O]);q&&this._onColor.fire([{type:1,index:this._specialColors[L],color:q}])}return!0}setOrReportFgColor(R){return this._setOrReportSpecialColor(R,0)}setOrReportBgColor(R){return this._setOrReportSpecialColor(R,1)}setOrReportCursorColor(R){return this._setOrReportSpecialColor(R,2)}restoreIndexedColor(R){if(!R)return this._onColor.fire([{type:2}]),!0;const L=[],M=R.split(";");for(let O=0;O<M.length;++O)if(/^\d+$/.exec(M[O])){const q=parseInt(M[O]);z(q)&&L.push({type:2,index:q})}return L.length&&this._onColor.fire(L),!0}restoreFgColor(R){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(R){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(R){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(R){return R.length!==2?(this.selectDefaultCharset(),!0):(R[0]==="/"||this._charsetService.setgCharset(j[R[0]],g.CHARSETS[R[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const R=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,R,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=l.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=l.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(R){return this._charsetService.setgLevel(R),!0}screenAlignmentPattern(){const R=new f.CellData;R.content=4194373,R.fg=this._curAttrData.fg,R.bg=this._curAttrData.bg,this._setCursor(0,0);for(let L=0;L<this._bufferService.rows;++L){const M=this._activeBuffer.ybase+this._activeBuffer.y+L,O=this._activeBuffer.lines.get(M);O&&(O.fill(R),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(R,L){const M=this._bufferService.buffer,O=this._optionsService.rawOptions;return(q=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${q}${c.C0.ESC}\\`),!0))(R==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:R==='"p'?'P1$r61;1"p':R==="r"?`P1$r${M.scrollTop+1};${M.scrollBottom+1}r`:R==="m"?"P1$r0m":R===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(R,L){this._dirtyRowTracker.markRangeDirty(R,L)}}i.InputHandler=F;let I=class{constructor($){this._bufferService=$,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty($){$<this.start?this.start=$:$>this.end&&(this.end=$)}markRangeDirty($,R){$>R&&(P=$,$=R,R=P),$<this.start&&(this.start=$),R>this.end&&(this.end=R)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function z($){return 0<=$&&$<256}I=a([d(0,C.IBufferService)],I)},844:(x,i)=>{function n(a){for(const d of a)d.dispose();a.length=0}Object.defineProperty(i,"__esModule",{value:!0}),i.getDisposeArrayDisposable=i.disposeArray=i.toDisposable=i.MutableDisposable=i.Disposable=void 0,i.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const a of this._disposables)a.dispose();this._disposables.length=0}register(a){return this._disposables.push(a),a}unregister(a){const d=this._disposables.indexOf(a);d!==-1&&this._disposables.splice(d,1)}},i.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(a){var d;this._isDisposed||a===this._value||((d=this._value)===null||d===void 0||d.dispose(),this._value=a)}clear(){this.value=void 0}dispose(){var a;this._isDisposed=!0,(a=this._value)===null||a===void 0||a.dispose(),this._value=void 0}},i.toDisposable=function(a){return{dispose:a}},i.disposeArray=n,i.getDisposeArrayDisposable=function(a){return{dispose:()=>n(a)}}},1505:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.FourKeyMap=i.TwoKeyMap=void 0;class n{constructor(){this._data={}}set(d,c,g){this._data[d]||(this._data[d]={}),this._data[d][c]=g}get(d,c){return this._data[d]?this._data[d][c]:void 0}clear(){this._data={}}}i.TwoKeyMap=n,i.FourKeyMap=class{constructor(){this._data=new n}set(a,d,c,g,v){this._data.get(a,d)||this._data.set(a,d,new n),this._data.get(a,d).set(c,g,v)}get(a,d,c,g){var v;return(v=this._data.get(a,d))===null||v===void 0?void 0:v.get(c,g)}clear(){this._data.clear()}}},6114:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.isChromeOS=i.isLinux=i.isWindows=i.isIphone=i.isIpad=i.isMac=i.getSafariVersion=i.isSafari=i.isLegacyEdge=i.isFirefox=i.isNode=void 0,i.isNode=typeof navigator>"u";const n=i.isNode?"node":navigator.userAgent,a=i.isNode?"node":navigator.platform;i.isFirefox=n.includes("Firefox"),i.isLegacyEdge=n.includes("Edge"),i.isSafari=/^((?!chrome|android).)*safari/i.test(n),i.getSafariVersion=function(){if(!i.isSafari)return 0;const d=n.match(/Version\/(\d+)/);return d===null||d.length<2?0:parseInt(d[1])},i.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(a),i.isIpad=a==="iPad",i.isIphone=a==="iPhone",i.isWindows=["Windows","Win16","Win32","WinCE"].includes(a),i.isLinux=a.indexOf("Linux")>=0,i.isChromeOS=/\bCrOS\b/.test(n)},6106:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SortedList=void 0;let n=0;i.SortedList=class{constructor(a){this._getKey=a,this._array=[]}clear(){this._array.length=0}insert(a){this._array.length!==0?(n=this._search(this._getKey(a)),this._array.splice(n,0,a)):this._array.push(a)}delete(a){if(this._array.length===0)return!1;const d=this._getKey(a);if(d===void 0||(n=this._search(d),n===-1)||this._getKey(this._array[n])!==d)return!1;do if(this._array[n]===a)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===d);return!1}*getKeyIterator(a){if(this._array.length!==0&&(n=this._search(a),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===a))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===a)}forEachByKey(a,d){if(this._array.length!==0&&(n=this._search(a),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===a))do d(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===a)}values(){return[...this._array].values()}_search(a){let d=0,c=this._array.length-1;for(;c>=d;){let g=d+c>>1;const v=this._getKey(this._array[g]);if(v>a)c=g-1;else{if(!(v<a)){for(;g>0&&this._getKey(this._array[g-1])===a;)g--;return g}d=g+1}}return d}}},7226:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DebouncedIdleTask=i.IdleTaskQueue=i.PriorityTaskQueue=void 0;const a=n(6114);class d{constructor(){this._tasks=[],this._i=0}enqueue(v){this._tasks.push(v),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(v){this._idleCallback=void 0;let b=0,y=0,l=v.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(b=Date.now(),this._tasks[this._i]()||this._i++,b=Math.max(1,Date.now()-b),y=Math.max(b,y),h=v.timeRemaining(),1.5*y>h)return l-b<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(l-b))}ms`),void this._start();l=h}this.clear()}}class c extends d{_requestCallback(v){return setTimeout((()=>v(this._createDeadline(16))))}_cancelCallback(v){clearTimeout(v)}_createDeadline(v){const b=Date.now()+v;return{timeRemaining:()=>Math.max(0,b-Date.now())}}}i.PriorityTaskQueue=c,i.IdleTaskQueue=!a.isNode&&"requestIdleCallback"in window?class extends d{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:c,i.DebouncedIdleTask=class{constructor(){this._queue=new i.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.updateWindowsModeWrappedState=void 0;const a=n(643);i.updateWindowsModeWrappedState=function(d){const c=d.buffer.lines.get(d.buffer.ybase+d.buffer.y-1),g=c?.get(d.cols-1),v=d.buffer.lines.get(d.buffer.ybase+d.buffer.y);v&&g&&(v.isWrapped=g[a.CHAR_DATA_CODE_INDEX]!==a.NULL_CELL_CODE&&g[a.CHAR_DATA_CODE_INDEX]!==a.WHITESPACE_CELL_CODE)}},3734:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ExtendedAttrs=i.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new a}static toColorRGB(c){return[c>>>16&255,c>>>8&255,255&c]}static fromColorRGB(c){return(255&c[0])<<16|(255&c[1])<<8|255&c[2]}clone(){const c=new n;return c.fg=this.fg,c.bg=this.bg,c.extended=this.extended.clone(),c}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}i.AttributeData=n;class a{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(c){this._ext=c}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(c){this._ext&=-469762049,this._ext|=c<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(c){this._ext&=-67108864,this._ext|=67108863&c}get urlId(){return this._urlId}set urlId(c){this._urlId=c}constructor(c=0,g=0){this._ext=0,this._urlId=0,this._ext=c,this._urlId=g}clone(){return new a(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}i.ExtendedAttrs=a},9092:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Buffer=i.MAX_BUFFER_SIZE=void 0;const a=n(6349),d=n(7226),c=n(3734),g=n(8437),v=n(4634),b=n(511),y=n(643),l=n(4863),h=n(7116);i.MAX_BUFFER_SIZE=4294967295,i.Buffer=class{constructor(u,f,S){this._hasScrollback=u,this._optionsService=f,this._bufferService=S,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=h.DEFAULT_CHARSET,this.markers=[],this._nullCell=b.CellData.fromCharData([0,y.NULL_CELL_CHAR,y.NULL_CELL_WIDTH,y.NULL_CELL_CODE]),this._whitespaceCell=b.CellData.fromCharData([0,y.WHITESPACE_CELL_CHAR,y.WHITESPACE_CELL_WIDTH,y.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new d.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new a.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(u){return u?(this._nullCell.fg=u.fg,this._nullCell.bg=u.bg,this._nullCell.extended=u.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new c.ExtendedAttrs),this._nullCell}getWhitespaceCell(u){return u?(this._whitespaceCell.fg=u.fg,this._whitespaceCell.bg=u.bg,this._whitespaceCell.extended=u.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new c.ExtendedAttrs),this._whitespaceCell}getBlankLine(u,f){return new g.BufferLine(this._bufferService.cols,this.getNullCell(u),f)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const u=this.ybase+this.y-this.ydisp;return u>=0&&u<this._rows}_getCorrectBufferLength(u){if(!this._hasScrollback)return u;const f=u+this._optionsService.rawOptions.scrollback;return f>i.MAX_BUFFER_SIZE?i.MAX_BUFFER_SIZE:f}fillViewportRows(u){if(this.lines.length===0){u===void 0&&(u=g.DEFAULT_ATTR_DATA);let f=this._rows;for(;f--;)this.lines.push(this.getBlankLine(u))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new a.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(u,f){const S=this.getNullCell(g.DEFAULT_ATTR_DATA);let C=0;const k=this._getCorrectBufferLength(f);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<u)for(let w=0;w<this.lines.length;w++)C+=+this.lines.get(w).resize(u,S);let E=0;if(this._rows<f)for(let w=this._rows;w<f;w++)this.lines.length<f+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new g.BufferLine(u,S)):this.ybase>0&&this.lines.length<=this.ybase+this.y+E+1?(this.ybase--,E++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(u,S)));else for(let w=this._rows;w>f;w--)this.lines.length>f+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const w=this.lines.length-k;w>0&&(this.lines.trimStart(w),this.ybase=Math.max(this.ybase-w,0),this.ydisp=Math.max(this.ydisp-w,0),this.savedY=Math.max(this.savedY-w,0)),this.lines.maxLength=k}this.x=Math.min(this.x,u-1),this.y=Math.min(this.y,f-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,u-1),this.scrollTop=0}if(this.scrollBottom=f-1,this._isReflowEnabled&&(this._reflow(u,f),this._cols>u))for(let E=0;E<this.lines.length;E++)C+=+this.lines.get(E).resize(u,S);this._cols=u,this._rows=f,this._memoryCleanupQueue.clear(),C>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let u=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,u=!1);let f=0;for(;this._memoryCleanupPosition<this.lines.length;)if(f+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),f>100)return!0;return u}get _isReflowEnabled(){const u=this._optionsService.rawOptions.windowsPty;return u&&u.buildNumber?this._hasScrollback&&u.backend==="conpty"&&u.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(u,f){this._cols!==u&&(u>this._cols?this._reflowLarger(u,f):this._reflowSmaller(u,f))}_reflowLarger(u,f){const S=(0,v.reflowLargerGetLinesToRemove)(this.lines,this._cols,u,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(S.length>0){const C=(0,v.reflowLargerCreateNewLayout)(this.lines,S);(0,v.reflowLargerApplyNewLayout)(this.lines,C.layout),this._reflowLargerAdjustViewport(u,f,C.countRemoved)}}_reflowLargerAdjustViewport(u,f,S){const C=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=S;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<f&&this.lines.push(new g.BufferLine(u,C))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-S,0)}_reflowSmaller(u,f){const S=this.getNullCell(g.DEFAULT_ATTR_DATA),C=[];let k=0;for(let E=this.lines.length-1;E>=0;E--){let w=this.lines.get(E);if(!w||!w.isWrapped&&w.getTrimmedLength()<=u)continue;const j=[w];for(;w.isWrapped&&E>0;)w=this.lines.get(--E),j.unshift(w);const A=this.ybase+this.y;if(A>=E&&A<E+j.length)continue;const D=j[j.length-1].getTrimmedLength(),T=(0,v.reflowSmallerGetNewLineLengths)(j,this._cols,u),P=T.length-j.length;let F;F=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+P):Math.max(0,this.lines.length-this.lines.maxLength+P);const I=[];for(let O=0;O<P;O++){const q=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);I.push(q)}I.length>0&&(C.push({start:E+j.length+k,newLines:I}),k+=I.length),j.push(...I);let z=T.length-1,$=T[z];$===0&&(z--,$=T[z]);let R=j.length-P-1,L=D;for(;R>=0;){const O=Math.min(L,$);if(j[z]===void 0)break;if(j[z].copyCellsFrom(j[R],L-O,$-O,O,!0),$-=O,$===0&&(z--,$=T[z]),L-=O,L===0){R--;const q=Math.max(R,0);L=(0,v.getWrappedLineTrimmedLength)(j,q,this._cols)}}for(let O=0;O<j.length;O++)T[O]<u&&j[O].setCell(T[O],S);let M=P-F;for(;M-- >0;)this.ybase===0?this.y<f-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-f&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+P,this.ybase+f-1)}if(C.length>0){const E=[],w=[];for(let z=0;z<this.lines.length;z++)w.push(this.lines.get(z));const j=this.lines.length;let A=j-1,D=0,T=C[D];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let P=0;for(let z=Math.min(this.lines.maxLength-1,j+k-1);z>=0;z--)if(T&&T.start>A+P){for(let $=T.newLines.length-1;$>=0;$--)this.lines.set(z--,T.newLines[$]);z++,E.push({index:A+1,amount:T.newLines.length}),P+=T.newLines.length,T=C[++D]}else this.lines.set(z,w[A--]);let F=0;for(let z=E.length-1;z>=0;z--)E[z].index+=F,this.lines.onInsertEmitter.fire(E[z]),F+=E[z].amount;const I=Math.max(0,j+k-this.lines.maxLength);I>0&&this.lines.onTrimEmitter.fire(I)}}translateBufferLineToString(u,f,S=0,C){const k=this.lines.get(u);return k?k.translateToString(f,S,C):""}getWrappedRangeForLine(u){let f=u,S=u;for(;f>0&&this.lines.get(f).isWrapped;)f--;for(;S+1<this.lines.length&&this.lines.get(S+1).isWrapped;)S++;return{first:f,last:S}}setupTabStops(u){for(u!=null?this.tabs[u]||(u=this.prevStop(u)):(this.tabs={},u=0);u<this._cols;u+=this._optionsService.rawOptions.tabStopWidth)this.tabs[u]=!0}prevStop(u){for(u==null&&(u=this.x);!this.tabs[--u]&&u>0;);return u>=this._cols?this._cols-1:u<0?0:u}nextStop(u){for(u==null&&(u=this.x);!this.tabs[++u]&&u<this._cols;);return u>=this._cols?this._cols-1:u<0?0:u}clearMarkers(u){this._isClearing=!0;for(let f=0;f<this.markers.length;f++)this.markers[f].line===u&&(this.markers[f].dispose(),this.markers.splice(f--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let u=0;u<this.markers.length;u++)this.markers[u].dispose(),this.markers.splice(u--,1);this._isClearing=!1}addMarker(u){const f=new l.Marker(u);return this.markers.push(f),f.register(this.lines.onTrim((S=>{f.line-=S,f.line<0&&f.dispose()}))),f.register(this.lines.onInsert((S=>{f.line>=S.index&&(f.line+=S.amount)}))),f.register(this.lines.onDelete((S=>{f.line>=S.index&&f.line<S.index+S.amount&&f.dispose(),f.line>S.index&&(f.line-=S.amount)}))),f.register(f.onDispose((()=>this._removeMarker(f)))),f}_removeMarker(u){this._isClearing||this.markers.splice(this.markers.indexOf(u),1)}}},8437:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLine=i.DEFAULT_ATTR_DATA=void 0;const a=n(3734),d=n(511),c=n(643),g=n(482);i.DEFAULT_ATTR_DATA=Object.freeze(new a.AttributeData);let v=0;class b{constructor(l,h,u=!1){this.isWrapped=u,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*l);const f=h||d.CellData.fromCharData([0,c.NULL_CELL_CHAR,c.NULL_CELL_WIDTH,c.NULL_CELL_CODE]);for(let S=0;S<l;++S)this.setCell(S,f);this.length=l}get(l){const h=this._data[3*l+0],u=2097151&h;return[this._data[3*l+1],2097152&h?this._combined[l]:u?(0,g.stringFromCodePoint)(u):"",h>>22,2097152&h?this._combined[l].charCodeAt(this._combined[l].length-1):u]}set(l,h){this._data[3*l+1]=h[c.CHAR_DATA_ATTR_INDEX],h[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[l]=h[1],this._data[3*l+0]=2097152|l|h[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*l+0]=h[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|h[c.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(l){return this._data[3*l+0]>>22}hasWidth(l){return 12582912&this._data[3*l+0]}getFg(l){return this._data[3*l+1]}getBg(l){return this._data[3*l+2]}hasContent(l){return 4194303&this._data[3*l+0]}getCodePoint(l){const h=this._data[3*l+0];return 2097152&h?this._combined[l].charCodeAt(this._combined[l].length-1):2097151&h}isCombined(l){return 2097152&this._data[3*l+0]}getString(l){const h=this._data[3*l+0];return 2097152&h?this._combined[l]:2097151&h?(0,g.stringFromCodePoint)(2097151&h):""}isProtected(l){return 536870912&this._data[3*l+2]}loadCell(l,h){return v=3*l,h.content=this._data[v+0],h.fg=this._data[v+1],h.bg=this._data[v+2],2097152&h.content&&(h.combinedData=this._combined[l]),268435456&h.bg&&(h.extended=this._extendedAttrs[l]),h}setCell(l,h){2097152&h.content&&(this._combined[l]=h.combinedData),268435456&h.bg&&(this._extendedAttrs[l]=h.extended),this._data[3*l+0]=h.content,this._data[3*l+1]=h.fg,this._data[3*l+2]=h.bg}setCellFromCodePoint(l,h,u,f,S,C){268435456&S&&(this._extendedAttrs[l]=C),this._data[3*l+0]=h|u<<22,this._data[3*l+1]=f,this._data[3*l+2]=S}addCodepointToCell(l,h){let u=this._data[3*l+0];2097152&u?this._combined[l]+=(0,g.stringFromCodePoint)(h):(2097151&u?(this._combined[l]=(0,g.stringFromCodePoint)(2097151&u)+(0,g.stringFromCodePoint)(h),u&=-2097152,u|=2097152):u=h|4194304,this._data[3*l+0]=u)}insertCells(l,h,u,f){if((l%=this.length)&&this.getWidth(l-1)===2&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),h<this.length-l){const S=new d.CellData;for(let C=this.length-l-h-1;C>=0;--C)this.setCell(l+h+C,this.loadCell(l+C,S));for(let C=0;C<h;++C)this.setCell(l+C,u)}else for(let S=l;S<this.length;++S)this.setCell(S,u);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs)}deleteCells(l,h,u,f){if(l%=this.length,h<this.length-l){const S=new d.CellData;for(let C=0;C<this.length-l-h;++C)this.setCell(l+C,this.loadCell(l+h+C,S));for(let C=this.length-h;C<this.length;++C)this.setCell(C,u)}else for(let S=l;S<this.length;++S)this.setCell(S,u);l&&this.getWidth(l-1)===2&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),this.getWidth(l)!==0||this.hasContent(l)||this.setCellFromCodePoint(l,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs)}replaceCells(l,h,u,f,S=!1){if(S)for(l&&this.getWidth(l-1)===2&&!this.isProtected(l-1)&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&!this.isProtected(h)&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs);l<h&&l<this.length;)this.isProtected(l)||this.setCell(l,u),l++;else for(l&&this.getWidth(l-1)===2&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs);l<h&&l<this.length;)this.setCell(l++,u)}resize(l,h){if(l===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const u=3*l;if(l>this.length){if(this._data.buffer.byteLength>=4*u)this._data=new Uint32Array(this._data.buffer,0,u);else{const f=new Uint32Array(u);f.set(this._data),this._data=f}for(let f=this.length;f<l;++f)this.setCell(f,h)}else{this._data=this._data.subarray(0,u);const f=Object.keys(this._combined);for(let C=0;C<f.length;C++){const k=parseInt(f[C],10);k>=l&&delete this._combined[k]}const S=Object.keys(this._extendedAttrs);for(let C=0;C<S.length;C++){const k=parseInt(S[C],10);k>=l&&delete this._extendedAttrs[k]}}return this.length=l,4*u*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const l=new Uint32Array(this._data.length);return l.set(this._data),this._data=l,1}return 0}fill(l,h=!1){if(h)for(let u=0;u<this.length;++u)this.isProtected(u)||this.setCell(u,l);else{this._combined={},this._extendedAttrs={};for(let u=0;u<this.length;++u)this.setCell(u,l)}}copyFrom(l){this.length!==l.length?this._data=new Uint32Array(l._data):this._data.set(l._data),this.length=l.length,this._combined={};for(const h in l._combined)this._combined[h]=l._combined[h];this._extendedAttrs={};for(const h in l._extendedAttrs)this._extendedAttrs[h]=l._extendedAttrs[h];this.isWrapped=l.isWrapped}clone(){const l=new b(0);l._data=new Uint32Array(this._data),l.length=this.length;for(const h in this._combined)l._combined[h]=this._combined[h];for(const h in this._extendedAttrs)l._extendedAttrs[h]=this._extendedAttrs[h];return l.isWrapped=this.isWrapped,l}getTrimmedLength(){for(let l=this.length-1;l>=0;--l)if(4194303&this._data[3*l+0])return l+(this._data[3*l+0]>>22);return 0}getNoBgTrimmedLength(){for(let l=this.length-1;l>=0;--l)if(4194303&this._data[3*l+0]||50331648&this._data[3*l+2])return l+(this._data[3*l+0]>>22);return 0}copyCellsFrom(l,h,u,f,S){const C=l._data;if(S)for(let E=f-1;E>=0;E--){for(let w=0;w<3;w++)this._data[3*(u+E)+w]=C[3*(h+E)+w];268435456&C[3*(h+E)+2]&&(this._extendedAttrs[u+E]=l._extendedAttrs[h+E])}else for(let E=0;E<f;E++){for(let w=0;w<3;w++)this._data[3*(u+E)+w]=C[3*(h+E)+w];268435456&C[3*(h+E)+2]&&(this._extendedAttrs[u+E]=l._extendedAttrs[h+E])}const k=Object.keys(l._combined);for(let E=0;E<k.length;E++){const w=parseInt(k[E],10);w>=h&&(this._combined[w-h+u]=l._combined[w])}}translateToString(l=!1,h=0,u=this.length){l&&(u=Math.min(u,this.getTrimmedLength()));let f="";for(;h<u;){const S=this._data[3*h+0],C=2097151&S;f+=2097152&S?this._combined[h]:C?(0,g.stringFromCodePoint)(C):c.WHITESPACE_CELL_CHAR,h+=S>>22||1}return f}}i.BufferLine=b},4841:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getRangeLength=void 0,i.getRangeLength=function(n,a){if(n.start.y>n.end.y)throw new Error(`Buffer range end (${n.end.x}, ${n.end.y}) cannot be before start (${n.start.x}, ${n.start.y})`);return a*(n.end.y-n.start.y)+(n.end.x-n.start.x+1)}},4634:(x,i)=>{function n(a,d,c){if(d===a.length-1)return a[d].getTrimmedLength();const g=!a[d].hasContent(c-1)&&a[d].getWidth(c-1)===1,v=a[d+1].getWidth(0)===2;return g&&v?c-1:c}Object.defineProperty(i,"__esModule",{value:!0}),i.getWrappedLineTrimmedLength=i.reflowSmallerGetNewLineLengths=i.reflowLargerApplyNewLayout=i.reflowLargerCreateNewLayout=i.reflowLargerGetLinesToRemove=void 0,i.reflowLargerGetLinesToRemove=function(a,d,c,g,v){const b=[];for(let y=0;y<a.length-1;y++){let l=y,h=a.get(++l);if(!h.isWrapped)continue;const u=[a.get(y)];for(;l<a.length&&h.isWrapped;)u.push(h),h=a.get(++l);if(g>=y&&g<l){y+=u.length-1;continue}let f=0,S=n(u,f,d),C=1,k=0;for(;C<u.length;){const w=n(u,C,d),j=w-k,A=c-S,D=Math.min(j,A);u[f].copyCellsFrom(u[C],k,S,D,!1),S+=D,S===c&&(f++,S=0),k+=D,k===w&&(C++,k=0),S===0&&f!==0&&u[f-1].getWidth(c-1)===2&&(u[f].copyCellsFrom(u[f-1],c-1,S++,1,!1),u[f-1].setCell(c-1,v))}u[f].replaceCells(S,c,v);let E=0;for(let w=u.length-1;w>0&&(w>f||u[w].getTrimmedLength()===0);w--)E++;E>0&&(b.push(y+u.length-E),b.push(E)),y+=u.length-1}return b},i.reflowLargerCreateNewLayout=function(a,d){const c=[];let g=0,v=d[g],b=0;for(let y=0;y<a.length;y++)if(v===y){const l=d[++g];a.onDeleteEmitter.fire({index:y-b,amount:l}),y+=l-1,b+=l,v=d[++g]}else c.push(y);return{layout:c,countRemoved:b}},i.reflowLargerApplyNewLayout=function(a,d){const c=[];for(let g=0;g<d.length;g++)c.push(a.get(d[g]));for(let g=0;g<c.length;g++)a.set(g,c[g]);a.length=d.length},i.reflowSmallerGetNewLineLengths=function(a,d,c){const g=[],v=a.map(((h,u)=>n(a,u,d))).reduce(((h,u)=>h+u));let b=0,y=0,l=0;for(;l<v;){if(v-l<c){g.push(v-l);break}b+=c;const h=n(a,y,d);b>h&&(b-=h,y++);const u=a[y].getWidth(b-1)===2;u&&b--;const f=u?c-1:c;g.push(f),l+=f}return g},i.getWrappedLineTrimmedLength=n},5295:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferSet=void 0;const a=n(8460),d=n(844),c=n(9092);class g extends d.Disposable{constructor(b,y){super(),this._optionsService=b,this._bufferService=y,this._onBufferActivate=this.register(new a.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new c.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new c.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(b){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(b),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(b,y){this._normal.resize(b,y),this._alt.resize(b,y),this.setupTabStops(b)}setupTabStops(b){this._normal.setupTabStops(b),this._alt.setupTabStops(b)}}i.BufferSet=g},511:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CellData=void 0;const a=n(482),d=n(643),c=n(3734);class g extends c.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new c.ExtendedAttrs,this.combinedData=""}static fromCharData(b){const y=new g;return y.setFromCharData(b),y}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,a.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(b){this.fg=b[d.CHAR_DATA_ATTR_INDEX],this.bg=0;let y=!1;if(b[d.CHAR_DATA_CHAR_INDEX].length>2)y=!0;else if(b[d.CHAR_DATA_CHAR_INDEX].length===2){const l=b[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=l&&l<=56319){const h=b[d.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(l-55296)+h-56320+65536|b[d.CHAR_DATA_WIDTH_INDEX]<<22:y=!0}else y=!0}else this.content=b[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|b[d.CHAR_DATA_WIDTH_INDEX]<<22;y&&(this.combinedData=b[d.CHAR_DATA_CHAR_INDEX],this.content=2097152|b[d.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.CellData=g},643:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WHITESPACE_CELL_CODE=i.WHITESPACE_CELL_WIDTH=i.WHITESPACE_CELL_CHAR=i.NULL_CELL_CODE=i.NULL_CELL_WIDTH=i.NULL_CELL_CHAR=i.CHAR_DATA_CODE_INDEX=i.CHAR_DATA_WIDTH_INDEX=i.CHAR_DATA_CHAR_INDEX=i.CHAR_DATA_ATTR_INDEX=i.DEFAULT_EXT=i.DEFAULT_ATTR=i.DEFAULT_COLOR=void 0,i.DEFAULT_COLOR=0,i.DEFAULT_ATTR=256|i.DEFAULT_COLOR<<9,i.DEFAULT_EXT=0,i.CHAR_DATA_ATTR_INDEX=0,i.CHAR_DATA_CHAR_INDEX=1,i.CHAR_DATA_WIDTH_INDEX=2,i.CHAR_DATA_CODE_INDEX=3,i.NULL_CELL_CHAR="",i.NULL_CELL_WIDTH=1,i.NULL_CELL_CODE=0,i.WHITESPACE_CELL_CHAR=" ",i.WHITESPACE_CELL_WIDTH=1,i.WHITESPACE_CELL_CODE=32},4863:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Marker=void 0;const a=n(8460),d=n(844);class c{get id(){return this._id}constructor(v){this.line=v,this.isDisposed=!1,this._disposables=[],this._id=c._nextId++,this._onDispose=this.register(new a.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,d.disposeArray)(this._disposables),this._disposables.length=0)}register(v){return this._disposables.push(v),v}}i.Marker=c,c._nextId=1},7116:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DEFAULT_CHARSET=i.CHARSETS=void 0,i.CHARSETS={},i.DEFAULT_CHARSET=i.CHARSETS.B,i.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},i.CHARSETS.A={"#":"£"},i.CHARSETS.B=void 0,i.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},i.CHARSETS.C=i.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},i.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},i.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},i.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},i.CHARSETS.E=i.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},i.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},i.CHARSETS.H=i.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(x,i)=>{var n,a,d;Object.defineProperty(i,"__esModule",{value:!0}),i.C1_ESCAPED=i.C1=i.C0=void 0,(function(c){c.NUL="\0",c.SOH="",c.STX="",c.ETX="",c.EOT="",c.ENQ="",c.ACK="",c.BEL="\x07",c.BS="\b",c.HT=" ",c.LF=`
|
|
20
|
+
`,c.VT="\v",c.FF="\f",c.CR="\r",c.SO="",c.SI="",c.DLE="",c.DC1="",c.DC2="",c.DC3="",c.DC4="",c.NAK="",c.SYN="",c.ETB="",c.CAN="",c.EM="",c.SUB="",c.ESC="\x1B",c.FS="",c.GS="",c.RS="",c.US="",c.SP=" ",c.DEL=""})(n||(i.C0=n={})),(function(c){c.PAD="",c.HOP="",c.BPH="",c.NBH="",c.IND="",c.NEL="
",c.SSA="",c.ESA="",c.HTS="",c.HTJ="",c.VTS="",c.PLD="",c.PLU="",c.RI="",c.SS2="",c.SS3="",c.DCS="",c.PU1="",c.PU2="",c.STS="",c.CCH="",c.MW="",c.SPA="",c.EPA="",c.SOS="",c.SGCI="",c.SCI="",c.CSI="",c.ST="",c.OSC="",c.PM="",c.APC=""})(a||(i.C1=a={})),(function(c){c.ST=`${n.ESC}\\`})(d||(i.C1_ESCAPED=d={}))},7399:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.evaluateKeyboardEvent=void 0;const a=n(2584),d={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};i.evaluateKeyboardEvent=function(c,g,v,b){const y={type:0,cancel:!1,key:void 0},l=(c.shiftKey?1:0)|(c.altKey?2:0)|(c.ctrlKey?4:0)|(c.metaKey?8:0);switch(c.keyCode){case 0:c.key==="UIKeyInputUpArrow"?y.key=g?a.C0.ESC+"OA":a.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?y.key=g?a.C0.ESC+"OD":a.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?y.key=g?a.C0.ESC+"OC":a.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(y.key=g?a.C0.ESC+"OB":a.C0.ESC+"[B");break;case 8:if(c.altKey){y.key=a.C0.ESC+a.C0.DEL;break}y.key=a.C0.DEL;break;case 9:if(c.shiftKey){y.key=a.C0.ESC+"[Z";break}y.key=a.C0.HT,y.cancel=!0;break;case 13:y.key=c.altKey?a.C0.ESC+a.C0.CR:a.C0.CR,y.cancel=!0;break;case 27:y.key=a.C0.ESC,c.altKey&&(y.key=a.C0.ESC+a.C0.ESC),y.cancel=!0;break;case 37:if(c.metaKey)break;l?(y.key=a.C0.ESC+"[1;"+(l+1)+"D",y.key===a.C0.ESC+"[1;3D"&&(y.key=a.C0.ESC+(v?"b":"[1;5D"))):y.key=g?a.C0.ESC+"OD":a.C0.ESC+"[D";break;case 39:if(c.metaKey)break;l?(y.key=a.C0.ESC+"[1;"+(l+1)+"C",y.key===a.C0.ESC+"[1;3C"&&(y.key=a.C0.ESC+(v?"f":"[1;5C"))):y.key=g?a.C0.ESC+"OC":a.C0.ESC+"[C";break;case 38:if(c.metaKey)break;l?(y.key=a.C0.ESC+"[1;"+(l+1)+"A",v||y.key!==a.C0.ESC+"[1;3A"||(y.key=a.C0.ESC+"[1;5A")):y.key=g?a.C0.ESC+"OA":a.C0.ESC+"[A";break;case 40:if(c.metaKey)break;l?(y.key=a.C0.ESC+"[1;"+(l+1)+"B",v||y.key!==a.C0.ESC+"[1;3B"||(y.key=a.C0.ESC+"[1;5B")):y.key=g?a.C0.ESC+"OB":a.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(y.key=a.C0.ESC+"[2~");break;case 46:y.key=l?a.C0.ESC+"[3;"+(l+1)+"~":a.C0.ESC+"[3~";break;case 36:y.key=l?a.C0.ESC+"[1;"+(l+1)+"H":g?a.C0.ESC+"OH":a.C0.ESC+"[H";break;case 35:y.key=l?a.C0.ESC+"[1;"+(l+1)+"F":g?a.C0.ESC+"OF":a.C0.ESC+"[F";break;case 33:c.shiftKey?y.type=2:c.ctrlKey?y.key=a.C0.ESC+"[5;"+(l+1)+"~":y.key=a.C0.ESC+"[5~";break;case 34:c.shiftKey?y.type=3:c.ctrlKey?y.key=a.C0.ESC+"[6;"+(l+1)+"~":y.key=a.C0.ESC+"[6~";break;case 112:y.key=l?a.C0.ESC+"[1;"+(l+1)+"P":a.C0.ESC+"OP";break;case 113:y.key=l?a.C0.ESC+"[1;"+(l+1)+"Q":a.C0.ESC+"OQ";break;case 114:y.key=l?a.C0.ESC+"[1;"+(l+1)+"R":a.C0.ESC+"OR";break;case 115:y.key=l?a.C0.ESC+"[1;"+(l+1)+"S":a.C0.ESC+"OS";break;case 116:y.key=l?a.C0.ESC+"[15;"+(l+1)+"~":a.C0.ESC+"[15~";break;case 117:y.key=l?a.C0.ESC+"[17;"+(l+1)+"~":a.C0.ESC+"[17~";break;case 118:y.key=l?a.C0.ESC+"[18;"+(l+1)+"~":a.C0.ESC+"[18~";break;case 119:y.key=l?a.C0.ESC+"[19;"+(l+1)+"~":a.C0.ESC+"[19~";break;case 120:y.key=l?a.C0.ESC+"[20;"+(l+1)+"~":a.C0.ESC+"[20~";break;case 121:y.key=l?a.C0.ESC+"[21;"+(l+1)+"~":a.C0.ESC+"[21~";break;case 122:y.key=l?a.C0.ESC+"[23;"+(l+1)+"~":a.C0.ESC+"[23~";break;case 123:y.key=l?a.C0.ESC+"[24;"+(l+1)+"~":a.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(v&&!b||!c.altKey||c.metaKey)!v||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?y.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(y.key=a.C0.US),c.key==="@"&&(y.key=a.C0.NUL)):c.keyCode===65&&(y.type=1);else{const h=d[c.keyCode],u=h?.[c.shiftKey?1:0];if(u)y.key=a.C0.ESC+u;else if(c.keyCode>=65&&c.keyCode<=90){const f=c.ctrlKey?c.keyCode-64:c.keyCode+32;let S=String.fromCharCode(f);c.shiftKey&&(S=S.toUpperCase()),y.key=a.C0.ESC+S}else if(c.keyCode===32)y.key=a.C0.ESC+(c.ctrlKey?a.C0.NUL:" ");else if(c.key==="Dead"&&c.code.startsWith("Key")){let f=c.code.slice(3,4);c.shiftKey||(f=f.toLowerCase()),y.key=a.C0.ESC+f,y.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?y.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?y.key=a.C0.NUL:c.keyCode>=51&&c.keyCode<=55?y.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?y.key=a.C0.DEL:c.keyCode===219?y.key=a.C0.ESC:c.keyCode===220?y.key=a.C0.FS:c.keyCode===221&&(y.key=a.C0.GS)}return y}},482:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Utf8ToUtf32=i.StringToUtf32=i.utf32ToString=i.stringFromCodePoint=void 0,i.stringFromCodePoint=function(n){return n>65535?(n-=65536,String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)},i.utf32ToString=function(n,a=0,d=n.length){let c="";for(let g=a;g<d;++g){let v=n[g];v>65535?(v-=65536,c+=String.fromCharCode(55296+(v>>10))+String.fromCharCode(v%1024+56320)):c+=String.fromCharCode(v)}return c},i.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(n,a){const d=n.length;if(!d)return 0;let c=0,g=0;if(this._interim){const v=n.charCodeAt(g++);56320<=v&&v<=57343?a[c++]=1024*(this._interim-55296)+v-56320+65536:(a[c++]=this._interim,a[c++]=v),this._interim=0}for(let v=g;v<d;++v){const b=n.charCodeAt(v);if(55296<=b&&b<=56319){if(++v>=d)return this._interim=b,c;const y=n.charCodeAt(v);56320<=y&&y<=57343?a[c++]=1024*(b-55296)+y-56320+65536:(a[c++]=b,a[c++]=y)}else b!==65279&&(a[c++]=b)}return c}},i.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(n,a){const d=n.length;if(!d)return 0;let c,g,v,b,y=0,l=0,h=0;if(this.interim[0]){let S=!1,C=this.interim[0];C&=(224&C)==192?31:(240&C)==224?15:7;let k,E=0;for(;(k=63&this.interim[++E])&&E<4;)C<<=6,C|=k;const w=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,j=w-E;for(;h<j;){if(h>=d)return 0;if(k=n[h++],(192&k)!=128){h--,S=!0;break}this.interim[E++]=k,C<<=6,C|=63&k}S||(w===2?C<128?h--:a[y++]=C:w===3?C<2048||C>=55296&&C<=57343||C===65279||(a[y++]=C):C<65536||C>1114111||(a[y++]=C)),this.interim.fill(0)}const u=d-4;let f=h;for(;f<d;){for(;!(!(f<u)||128&(c=n[f])||128&(g=n[f+1])||128&(v=n[f+2])||128&(b=n[f+3]));)a[y++]=c,a[y++]=g,a[y++]=v,a[y++]=b,f+=4;if(c=n[f++],c<128)a[y++]=c;else if((224&c)==192){if(f>=d)return this.interim[0]=c,y;if(g=n[f++],(192&g)!=128){f--;continue}if(l=(31&c)<<6|63&g,l<128){f--;continue}a[y++]=l}else if((240&c)==224){if(f>=d)return this.interim[0]=c,y;if(g=n[f++],(192&g)!=128){f--;continue}if(f>=d)return this.interim[0]=c,this.interim[1]=g,y;if(v=n[f++],(192&v)!=128){f--;continue}if(l=(15&c)<<12|(63&g)<<6|63&v,l<2048||l>=55296&&l<=57343||l===65279)continue;a[y++]=l}else if((248&c)==240){if(f>=d)return this.interim[0]=c,y;if(g=n[f++],(192&g)!=128){f--;continue}if(f>=d)return this.interim[0]=c,this.interim[1]=g,y;if(v=n[f++],(192&v)!=128){f--;continue}if(f>=d)return this.interim[0]=c,this.interim[1]=g,this.interim[2]=v,y;if(b=n[f++],(192&b)!=128){f--;continue}if(l=(7&c)<<18|(63&g)<<12|(63&v)<<6|63&b,l<65536||l>1114111)continue;a[y++]=l}}return y}}},225:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeV6=void 0;const n=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],a=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let d;i.UnicodeV6=class{constructor(){if(this.version="6",!d){d=new Uint8Array(65536),d.fill(1),d[0]=0,d.fill(0,1,32),d.fill(0,127,160),d.fill(2,4352,4448),d[9001]=2,d[9002]=2,d.fill(2,11904,42192),d[12351]=1,d.fill(2,44032,55204),d.fill(2,63744,64256),d.fill(2,65040,65050),d.fill(2,65072,65136),d.fill(2,65280,65377),d.fill(2,65504,65511);for(let c=0;c<n.length;++c)d.fill(0,n[c][0],n[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?d[c]:(function(g,v){let b,y=0,l=v.length-1;if(g<v[0][0]||g>v[l][1])return!1;for(;l>=y;)if(b=y+l>>1,g>v[b][1])y=b+1;else{if(!(g<v[b][0]))return!0;l=b-1}return!1})(c,a)?0:c>=131072&&c<=196605||c>=196608&&c<=262141?2:1}}},5981:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WriteBuffer=void 0;const a=n(8460),d=n(844);class c extends d.Disposable{constructor(v){super(),this._action=v,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new a.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(v,b){if(b!==void 0&&this._syncCalls>b)return void(this._syncCalls=0);if(this._pendingData+=v.length,this._writeBuffer.push(v),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let y;for(this._isSyncWriting=!0;y=this._writeBuffer.shift();){this._action(y);const l=this._callbacks.shift();l&&l()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(v,b){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=v.length,this._writeBuffer.push(v),this._callbacks.push(b),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=v.length,this._writeBuffer.push(v),this._callbacks.push(b)}_innerWrite(v=0,b=!0){const y=v||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const l=this._writeBuffer[this._bufferOffset],h=this._action(l,b);if(h){const f=S=>Date.now()-y>=12?setTimeout((()=>this._innerWrite(0,S))):this._innerWrite(y,S);return void h.catch((S=>(queueMicrotask((()=>{throw S})),Promise.resolve(!1)))).then(f)}const u=this._callbacks[this._bufferOffset];if(u&&u(),this._bufferOffset++,this._pendingData-=l.length,Date.now()-y>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}i.WriteBuffer=c},5941:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.toRgbString=i.parseColor=void 0;const n=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,a=/^[\da-f]+$/;function d(c,g){const v=c.toString(16),b=v.length<2?"0"+v:v;switch(g){case 4:return v[0];case 8:return b;case 12:return(b+b).slice(0,3);default:return b+b}}i.parseColor=function(c){if(!c)return;let g=c.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const v=n.exec(g);if(v){const b=v[1]?15:v[4]?255:v[7]?4095:65535;return[Math.round(parseInt(v[1]||v[4]||v[7]||v[10],16)/b*255),Math.round(parseInt(v[2]||v[5]||v[8]||v[11],16)/b*255),Math.round(parseInt(v[3]||v[6]||v[9]||v[12],16)/b*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),a.exec(g)&&[3,6,9,12].includes(g.length))){const v=g.length/3,b=[0,0,0];for(let y=0;y<3;++y){const l=parseInt(g.slice(v*y,v*y+v),16);b[y]=v===1?l<<4:v===2?l:v===3?l>>4:l>>8}return b}},i.toRgbString=function(c,g=16){const[v,b,y]=c;return`rgb:${d(v,g)}/${d(b,g)}/${d(y,g)}`}},5770:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.PAYLOAD_LIMIT=void 0,i.PAYLOAD_LIMIT=1e7},6351:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DcsHandler=i.DcsParser=void 0;const a=n(482),d=n(8742),c=n(5770),g=[];i.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(b,y){this._handlers[b]===void 0&&(this._handlers[b]=[]);const l=this._handlers[b];return l.push(y),{dispose:()=>{const h=l.indexOf(y);h!==-1&&l.splice(h,1)}}}clearHandler(b){this._handlers[b]&&delete this._handlers[b]}setHandlerFallback(b){this._handlerFb=b}reset(){if(this._active.length)for(let b=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;b>=0;--b)this._active[b].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(b,y){if(this.reset(),this._ident=b,this._active=this._handlers[b]||g,this._active.length)for(let l=this._active.length-1;l>=0;l--)this._active[l].hook(y);else this._handlerFb(this._ident,"HOOK",y)}put(b,y,l){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(b,y,l);else this._handlerFb(this._ident,"PUT",(0,a.utf32ToString)(b,y,l))}unhook(b,y=!0){if(this._active.length){let l=!1,h=this._active.length-1,u=!1;if(this._stack.paused&&(h=this._stack.loopPosition-1,l=y,u=this._stack.fallThrough,this._stack.paused=!1),!u&&l===!1){for(;h>=0&&(l=this._active[h].unhook(b),l!==!0);h--)if(l instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!1,l;h--}for(;h>=0;h--)if(l=this._active[h].unhook(!1),l instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!0,l}else this._handlerFb(this._ident,"UNHOOK",b);this._active=g,this._ident=0}};const v=new d.Params;v.addParam(0),i.DcsHandler=class{constructor(b){this._handler=b,this._data="",this._params=v,this._hitLimit=!1}hook(b){this._params=b.length>1||b.params[0]?b.clone():v,this._data="",this._hitLimit=!1}put(b,y,l){this._hitLimit||(this._data+=(0,a.utf32ToString)(b,y,l),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(b){let y=!1;if(this._hitLimit)y=!1;else if(b&&(y=this._handler(this._data,this._params),y instanceof Promise))return y.then((l=>(this._params=v,this._data="",this._hitLimit=!1,l)));return this._params=v,this._data="",this._hitLimit=!1,y}}},2015:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.EscapeSequenceParser=i.VT500_TRANSITION_TABLE=i.TransitionTable=void 0;const a=n(844),d=n(8742),c=n(6242),g=n(6351);class v{constructor(h){this.table=new Uint8Array(h)}setDefault(h,u){this.table.fill(h<<4|u)}add(h,u,f,S){this.table[u<<8|h]=f<<4|S}addMany(h,u,f,S){for(let C=0;C<h.length;C++)this.table[u<<8|h[C]]=f<<4|S}}i.TransitionTable=v;const b=160;i.VT500_TRANSITION_TABLE=(function(){const l=new v(4095),h=Array.apply(null,Array(256)).map(((E,w)=>w)),u=(E,w)=>h.slice(E,w),f=u(32,127),S=u(0,24);S.push(25),S.push.apply(S,u(28,32));const C=u(0,14);let k;for(k in l.setDefault(1,0),l.addMany(f,0,2,0),C)l.addMany([24,26,153,154],k,3,0),l.addMany(u(128,144),k,3,0),l.addMany(u(144,152),k,3,0),l.add(156,k,0,0),l.add(27,k,11,1),l.add(157,k,4,8),l.addMany([152,158,159],k,0,7),l.add(155,k,11,3),l.add(144,k,11,9);return l.addMany(S,0,3,0),l.addMany(S,1,3,1),l.add(127,1,0,1),l.addMany(S,8,0,8),l.addMany(S,3,3,3),l.add(127,3,0,3),l.addMany(S,4,3,4),l.add(127,4,0,4),l.addMany(S,6,3,6),l.addMany(S,5,3,5),l.add(127,5,0,5),l.addMany(S,2,3,2),l.add(127,2,0,2),l.add(93,1,4,8),l.addMany(f,8,5,8),l.add(127,8,5,8),l.addMany([156,27,24,26,7],8,6,0),l.addMany(u(28,32),8,0,8),l.addMany([88,94,95],1,0,7),l.addMany(f,7,0,7),l.addMany(S,7,0,7),l.add(156,7,0,0),l.add(127,7,0,7),l.add(91,1,11,3),l.addMany(u(64,127),3,7,0),l.addMany(u(48,60),3,8,4),l.addMany([60,61,62,63],3,9,4),l.addMany(u(48,60),4,8,4),l.addMany(u(64,127),4,7,0),l.addMany([60,61,62,63],4,0,6),l.addMany(u(32,64),6,0,6),l.add(127,6,0,6),l.addMany(u(64,127),6,0,0),l.addMany(u(32,48),3,9,5),l.addMany(u(32,48),5,9,5),l.addMany(u(48,64),5,0,6),l.addMany(u(64,127),5,7,0),l.addMany(u(32,48),4,9,5),l.addMany(u(32,48),1,9,2),l.addMany(u(32,48),2,9,2),l.addMany(u(48,127),2,10,0),l.addMany(u(48,80),1,10,0),l.addMany(u(81,88),1,10,0),l.addMany([89,90,92],1,10,0),l.addMany(u(96,127),1,10,0),l.add(80,1,11,9),l.addMany(S,9,0,9),l.add(127,9,0,9),l.addMany(u(28,32),9,0,9),l.addMany(u(32,48),9,9,12),l.addMany(u(48,60),9,8,10),l.addMany([60,61,62,63],9,9,10),l.addMany(S,11,0,11),l.addMany(u(32,128),11,0,11),l.addMany(u(28,32),11,0,11),l.addMany(S,10,0,10),l.add(127,10,0,10),l.addMany(u(28,32),10,0,10),l.addMany(u(48,60),10,8,10),l.addMany([60,61,62,63],10,0,11),l.addMany(u(32,48),10,9,12),l.addMany(S,12,0,12),l.add(127,12,0,12),l.addMany(u(28,32),12,0,12),l.addMany(u(32,48),12,9,12),l.addMany(u(48,64),12,0,11),l.addMany(u(64,127),12,12,13),l.addMany(u(64,127),10,12,13),l.addMany(u(64,127),9,12,13),l.addMany(S,13,13,13),l.addMany(f,13,13,13),l.add(127,13,0,13),l.addMany([27,156,24,26],13,14,0),l.add(b,0,2,0),l.add(b,8,5,8),l.add(b,6,0,6),l.add(b,11,0,11),l.add(b,13,13,13),l})();class y extends a.Disposable{constructor(h=i.VT500_TRANSITION_TABLE){super(),this._transitions=h,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new d.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(u,f,S)=>{},this._executeHandlerFb=u=>{},this._csiHandlerFb=(u,f)=>{},this._escHandlerFb=u=>{},this._errorHandlerFb=u=>u,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,a.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new c.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(h,u=[64,126]){let f=0;if(h.prefix){if(h.prefix.length>1)throw new Error("only one byte as prefix supported");if(f=h.prefix.charCodeAt(0),f&&60>f||f>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(h.intermediates){if(h.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let C=0;C<h.intermediates.length;++C){const k=h.intermediates.charCodeAt(C);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");f<<=8,f|=k}}if(h.final.length!==1)throw new Error("final must be a single byte");const S=h.final.charCodeAt(0);if(u[0]>S||S>u[1])throw new Error(`final must be in range ${u[0]} .. ${u[1]}`);return f<<=8,f|=S,f}identToString(h){const u=[];for(;h;)u.push(String.fromCharCode(255&h)),h>>=8;return u.reverse().join("")}setPrintHandler(h){this._printHandler=h}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(h,u){const f=this._identifier(h,[48,126]);this._escHandlers[f]===void 0&&(this._escHandlers[f]=[]);const S=this._escHandlers[f];return S.push(u),{dispose:()=>{const C=S.indexOf(u);C!==-1&&S.splice(C,1)}}}clearEscHandler(h){this._escHandlers[this._identifier(h,[48,126])]&&delete this._escHandlers[this._identifier(h,[48,126])]}setEscHandlerFallback(h){this._escHandlerFb=h}setExecuteHandler(h,u){this._executeHandlers[h.charCodeAt(0)]=u}clearExecuteHandler(h){this._executeHandlers[h.charCodeAt(0)]&&delete this._executeHandlers[h.charCodeAt(0)]}setExecuteHandlerFallback(h){this._executeHandlerFb=h}registerCsiHandler(h,u){const f=this._identifier(h);this._csiHandlers[f]===void 0&&(this._csiHandlers[f]=[]);const S=this._csiHandlers[f];return S.push(u),{dispose:()=>{const C=S.indexOf(u);C!==-1&&S.splice(C,1)}}}clearCsiHandler(h){this._csiHandlers[this._identifier(h)]&&delete this._csiHandlers[this._identifier(h)]}setCsiHandlerFallback(h){this._csiHandlerFb=h}registerDcsHandler(h,u){return this._dcsParser.registerHandler(this._identifier(h),u)}clearDcsHandler(h){this._dcsParser.clearHandler(this._identifier(h))}setDcsHandlerFallback(h){this._dcsParser.setHandlerFallback(h)}registerOscHandler(h,u){return this._oscParser.registerHandler(h,u)}clearOscHandler(h){this._oscParser.clearHandler(h)}setOscHandlerFallback(h){this._oscParser.setHandlerFallback(h)}setErrorHandler(h){this._errorHandler=h}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(h,u,f,S,C){this._parseStack.state=h,this._parseStack.handlers=u,this._parseStack.handlerPos=f,this._parseStack.transition=S,this._parseStack.chunkPos=C}parse(h,u,f){let S,C=0,k=0,E=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,E=this._parseStack.chunkPos+1;else{if(f===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const w=this._parseStack.handlers;let j=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(f===!1&&j>-1){for(;j>=0&&(S=w[j](this._params),S!==!0);j--)if(S instanceof Promise)return this._parseStack.handlerPos=j,S}this._parseStack.handlers=[];break;case 4:if(f===!1&&j>-1){for(;j>=0&&(S=w[j](),S!==!0);j--)if(S instanceof Promise)return this._parseStack.handlerPos=j,S}this._parseStack.handlers=[];break;case 6:if(C=h[this._parseStack.chunkPos],S=this._dcsParser.unhook(C!==24&&C!==26,f),S)return S;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(C=h[this._parseStack.chunkPos],S=this._oscParser.end(C!==24&&C!==26,f),S)return S;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,E=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let w=E;w<u;++w){switch(C=h[w],k=this._transitions.table[this.currentState<<8|(C<160?C:b)],k>>4){case 2:for(let P=w+1;;++P){if(P>=u||(C=h[P])<32||C>126&&C<b){this._printHandler(h,w,P),w=P-1;break}if(++P>=u||(C=h[P])<32||C>126&&C<b){this._printHandler(h,w,P),w=P-1;break}if(++P>=u||(C=h[P])<32||C>126&&C<b){this._printHandler(h,w,P),w=P-1;break}if(++P>=u||(C=h[P])<32||C>126&&C<b){this._printHandler(h,w,P),w=P-1;break}}break;case 3:this._executeHandlers[C]?this._executeHandlers[C]():this._executeHandlerFb(C),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:w,code:C,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const j=this._csiHandlers[this._collect<<8|C];let A=j?j.length-1:-1;for(;A>=0&&(S=j[A](this._params),S!==!0);A--)if(S instanceof Promise)return this._preserveStack(3,j,A,k,w),S;A<0&&this._csiHandlerFb(this._collect<<8|C,this._params),this.precedingCodepoint=0;break;case 8:do switch(C){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(C-48)}while(++w<u&&(C=h[w])>47&&C<60);w--;break;case 9:this._collect<<=8,this._collect|=C;break;case 10:const D=this._escHandlers[this._collect<<8|C];let T=D?D.length-1:-1;for(;T>=0&&(S=D[T](),S!==!0);T--)if(S instanceof Promise)return this._preserveStack(4,D,T,k,w),S;T<0&&this._escHandlerFb(this._collect<<8|C),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|C,this._params);break;case 13:for(let P=w+1;;++P)if(P>=u||(C=h[P])===24||C===26||C===27||C>127&&C<b){this._dcsParser.put(h,w,P),w=P-1;break}break;case 14:if(S=this._dcsParser.unhook(C!==24&&C!==26),S)return this._preserveStack(6,[],0,k,w),S;C===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let P=w+1;;P++)if(P>=u||(C=h[P])<32||C>127&&C<b){this._oscParser.put(h,w,P),w=P-1;break}break;case 6:if(S=this._oscParser.end(C!==24&&C!==26),S)return this._preserveStack(5,[],0,k,w),S;C===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}i.EscapeSequenceParser=y},6242:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OscHandler=i.OscParser=void 0;const a=n(5770),d=n(482),c=[];i.OscParser=class{constructor(){this._state=0,this._active=c,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,v){this._handlers[g]===void 0&&(this._handlers[g]=[]);const b=this._handlers[g];return b.push(v),{dispose:()=>{const y=b.indexOf(v);y!==-1&&b.splice(y,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=c}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=c,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||c,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,v,b){if(this._active.length)for(let y=this._active.length-1;y>=0;y--)this._active[y].put(g,v,b);else this._handlerFb(this._id,"PUT",(0,d.utf32ToString)(g,v,b))}start(){this.reset(),this._state=1}put(g,v,b){if(this._state!==3){if(this._state===1)for(;v<b;){const y=g[v++];if(y===59){this._state=2,this._start();break}if(y<48||57<y)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+y-48}this._state===2&&b-v>0&&this._put(g,v,b)}}end(g,v=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let b=!1,y=this._active.length-1,l=!1;if(this._stack.paused&&(y=this._stack.loopPosition-1,b=v,l=this._stack.fallThrough,this._stack.paused=!1),!l&&b===!1){for(;y>=0&&(b=this._active[y].end(g),b!==!0);y--)if(b instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=y,this._stack.fallThrough=!1,b;y--}for(;y>=0;y--)if(b=this._active[y].end(!1),b instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=y,this._stack.fallThrough=!0,b}else this._handlerFb(this._id,"END",g);this._active=c,this._id=-1,this._state=0}}},i.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,v,b){this._hitLimit||(this._data+=(0,d.utf32ToString)(g,v,b),this._data.length>a.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let v=!1;if(this._hitLimit)v=!1;else if(g&&(v=this._handler(this._data),v instanceof Promise))return v.then((b=>(this._data="",this._hitLimit=!1,b)));return this._data="",this._hitLimit=!1,v}}},8742:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Params=void 0;const n=2147483647;class a{static fromArray(c){const g=new a;if(!c.length)return g;for(let v=Array.isArray(c[0])?1:0;v<c.length;++v){const b=c[v];if(Array.isArray(b))for(let y=0;y<b.length;++y)g.addSubParam(b[y]);else g.addParam(b)}return g}constructor(c=32,g=32){if(this.maxLength=c,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(c),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(c),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const c=new a(this.maxLength,this.maxSubParamsLength);return c.params.set(this.params),c.length=this.length,c._subParams.set(this._subParams),c._subParamsLength=this._subParamsLength,c._subParamsIdx.set(this._subParamsIdx),c._rejectDigits=this._rejectDigits,c._rejectSubDigits=this._rejectSubDigits,c._digitIsSub=this._digitIsSub,c}toArray(){const c=[];for(let g=0;g<this.length;++g){c.push(this.params[g]);const v=this._subParamsIdx[g]>>8,b=255&this._subParamsIdx[g];b-v>0&&c.push(Array.prototype.slice.call(this._subParams,v,b))}return c}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(c){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=c>n?n:c}}addSubParam(c){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=c>n?n:c,this._subParamsIdx[this.length-1]++}}hasSubParams(c){return(255&this._subParamsIdx[c])-(this._subParamsIdx[c]>>8)>0}getSubParams(c){const g=this._subParamsIdx[c]>>8,v=255&this._subParamsIdx[c];return v-g>0?this._subParams.subarray(g,v):null}getSubParamsAll(){const c={};for(let g=0;g<this.length;++g){const v=this._subParamsIdx[g]>>8,b=255&this._subParamsIdx[g];b-v>0&&(c[g]=this._subParams.slice(v,b))}return c}addDigit(c){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const v=this._digitIsSub?this._subParams:this.params,b=v[g-1];v[g-1]=~b?Math.min(10*b+c,n):c}}i.Params=a},5741:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.AddonManager=void 0,i.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let n=this._addons.length-1;n>=0;n--)this._addons[n].instance.dispose()}loadAddon(n,a){const d={instance:a,dispose:a.dispose,isDisposed:!1};this._addons.push(d),a.dispose=()=>this._wrappedAddonDispose(d),a.activate(n)}_wrappedAddonDispose(n){if(n.isDisposed)return;let a=-1;for(let d=0;d<this._addons.length;d++)if(this._addons[d]===n){a=d;break}if(a===-1)throw new Error("Could not dispose an addon that has not been loaded");n.isDisposed=!0,n.dispose.apply(n.instance),this._addons.splice(a,1)}}},8771:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferApiView=void 0;const a=n(3785),d=n(511);i.BufferApiView=class{constructor(c,g){this._buffer=c,this.type=g}init(c){return this._buffer=c,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(c){const g=this._buffer.lines.get(c);if(g)return new a.BufferLineApiView(g)}getNullCell(){return new d.CellData}}},3785:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLineApiView=void 0;const a=n(511);i.BufferLineApiView=class{constructor(d){this._line=d}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(d,c){if(!(d<0||d>=this._line.length))return c?(this._line.loadCell(d,c),c):this._line.loadCell(d,new a.CellData)}translateToString(d,c,g){return this._line.translateToString(d,c,g)}}},8285:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferNamespaceApi=void 0;const a=n(8771),d=n(8460),c=n(844);class g extends c.Disposable{constructor(b){super(),this._core=b,this._onBufferChange=this.register(new d.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new a.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new a.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}i.BufferNamespaceApi=g},7975:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ParserApi=void 0,i.ParserApi=class{constructor(n){this._core=n}registerCsiHandler(n,a){return this._core.registerCsiHandler(n,(d=>a(d.toArray())))}addCsiHandler(n,a){return this.registerCsiHandler(n,a)}registerDcsHandler(n,a){return this._core.registerDcsHandler(n,((d,c)=>a(d,c.toArray())))}addDcsHandler(n,a){return this.registerDcsHandler(n,a)}registerEscHandler(n,a){return this._core.registerEscHandler(n,a)}addEscHandler(n,a){return this.registerEscHandler(n,a)}registerOscHandler(n,a){return this._core.registerOscHandler(n,a)}addOscHandler(n,a){return this.registerOscHandler(n,a)}}},7090:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeApi=void 0,i.UnicodeApi=class{constructor(n){this._core=n}register(n){this._core.unicodeService.register(n)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(n){this._core.unicodeService.activeVersion=n}}},744:function(x,i,n){var a=this&&this.__decorate||function(l,h,u,f){var S,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,h,u,f);else for(var E=l.length-1;E>=0;E--)(S=l[E])&&(k=(C<3?S(k):C>3?S(h,u,k):S(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(l,h){return function(u,f){h(u,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferService=i.MINIMUM_ROWS=i.MINIMUM_COLS=void 0;const c=n(8460),g=n(844),v=n(5295),b=n(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let y=i.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(l){super(),this.isUserScrolling=!1,this._onResize=this.register(new c.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new c.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(l.rawOptions.cols||0,i.MINIMUM_COLS),this.rows=Math.max(l.rawOptions.rows||0,i.MINIMUM_ROWS),this.buffers=this.register(new v.BufferSet(l,this))}resize(l,h){this.cols=l,this.rows=h,this.buffers.resize(l,h),this._onResize.fire({cols:l,rows:h})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(l,h=!1){const u=this.buffer;let f;f=this._cachedBlankLine,f&&f.length===this.cols&&f.getFg(0)===l.fg&&f.getBg(0)===l.bg||(f=u.getBlankLine(l,h),this._cachedBlankLine=f),f.isWrapped=h;const S=u.ybase+u.scrollTop,C=u.ybase+u.scrollBottom;if(u.scrollTop===0){const k=u.lines.isFull;C===u.lines.length-1?k?u.lines.recycle().copyFrom(f):u.lines.push(f.clone()):u.lines.splice(C+1,0,f.clone()),k?this.isUserScrolling&&(u.ydisp=Math.max(u.ydisp-1,0)):(u.ybase++,this.isUserScrolling||u.ydisp++)}else{const k=C-S+1;u.lines.shiftElements(S+1,k-1,-1),u.lines.set(C,f.clone())}this.isUserScrolling||(u.ydisp=u.ybase),this._onScroll.fire(u.ydisp)}scrollLines(l,h,u){const f=this.buffer;if(l<0){if(f.ydisp===0)return;this.isUserScrolling=!0}else l+f.ydisp>=f.ybase&&(this.isUserScrolling=!1);const S=f.ydisp;f.ydisp=Math.max(Math.min(f.ydisp+l,f.ybase),0),S!==f.ydisp&&(h||this._onScroll.fire(f.ydisp))}};i.BufferService=y=a([d(0,b.IOptionsService)],y)},7994:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CharsetService=void 0,i.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(n){this.glevel=n,this.charset=this._charsets[n]}setgCharset(n,a){this._charsets[n]=a,this.glevel===n&&(this.charset=a)}}},1753:function(x,i,n){var a=this&&this.__decorate||function(f,S,C,k){var E,w=arguments.length,j=w<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,S,C,k);else for(var A=f.length-1;A>=0;A--)(E=f[A])&&(j=(w<3?E(j):w>3?E(S,C,j):E(S,C))||j);return w>3&&j&&Object.defineProperty(S,C,j),j},d=this&&this.__param||function(f,S){return function(C,k){S(C,k,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreMouseService=void 0;const c=n(2585),g=n(8460),v=n(844),b={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:f=>f.button!==4&&f.action===1&&(f.ctrl=!1,f.alt=!1,f.shift=!1,!0)},VT200:{events:19,restrict:f=>f.action!==32},DRAG:{events:23,restrict:f=>f.action!==32||f.button!==3},ANY:{events:31,restrict:f=>!0}};function y(f,S){let C=(f.ctrl?16:0)|(f.shift?4:0)|(f.alt?8:0);return f.button===4?(C|=64,C|=f.action):(C|=3&f.button,4&f.button&&(C|=64),8&f.button&&(C|=128),f.action===32?C|=32:f.action!==0||S||(C|=3)),C}const l=String.fromCharCode,h={DEFAULT:f=>{const S=[y(f,!1)+32,f.col+32,f.row+32];return S[0]>255||S[1]>255||S[2]>255?"":`\x1B[M${l(S[0])}${l(S[1])}${l(S[2])}`},SGR:f=>{const S=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${y(f,!0)};${f.col};${f.row}${S}`},SGR_PIXELS:f=>{const S=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${y(f,!0)};${f.x};${f.y}${S}`}};let u=i.CoreMouseService=class extends v.Disposable{constructor(f,S){super(),this._bufferService=f,this._coreService=S,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const C of Object.keys(b))this.addProtocol(C,b[C]);for(const C of Object.keys(h))this.addEncoding(C,h[C]);this.reset()}addProtocol(f,S){this._protocols[f]=S}addEncoding(f,S){this._encodings[f]=S}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(f){if(!this._protocols[f])throw new Error(`unknown protocol "${f}"`);this._activeProtocol=f,this._onProtocolChange.fire(this._protocols[f].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(f){if(!this._encodings[f])throw new Error(`unknown encoding "${f}"`);this._activeEncoding=f}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(f){if(f.col<0||f.col>=this._bufferService.cols||f.row<0||f.row>=this._bufferService.rows||f.button===4&&f.action===32||f.button===3&&f.action!==32||f.button!==4&&(f.action===2||f.action===3)||(f.col++,f.row++,f.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,f,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(f))return!1;const S=this._encodings[this._activeEncoding](f);return S&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(S):this._coreService.triggerDataEvent(S,!0)),this._lastEvent=f,!0}explainEvents(f){return{down:!!(1&f),up:!!(2&f),drag:!!(4&f),move:!!(8&f),wheel:!!(16&f)}}_equalEvents(f,S,C){if(C){if(f.x!==S.x||f.y!==S.y)return!1}else if(f.col!==S.col||f.row!==S.row)return!1;return f.button===S.button&&f.action===S.action&&f.ctrl===S.ctrl&&f.alt===S.alt&&f.shift===S.shift}};i.CoreMouseService=u=a([d(0,c.IBufferService),d(1,c.ICoreService)],u)},6975:function(x,i,n){var a=this&&this.__decorate||function(u,f,S,C){var k,E=arguments.length,w=E<3?f:C===null?C=Object.getOwnPropertyDescriptor(f,S):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(u,f,S,C);else for(var j=u.length-1;j>=0;j--)(k=u[j])&&(w=(E<3?k(w):E>3?k(f,S,w):k(f,S))||w);return E>3&&w&&Object.defineProperty(f,S,w),w},d=this&&this.__param||function(u,f){return function(S,C){f(S,C,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreService=void 0;const c=n(1439),g=n(8460),v=n(844),b=n(2585),y=Object.freeze({insertMode:!1}),l=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let h=i.CoreService=class extends v.Disposable{constructor(u,f,S){super(),this._bufferService=u,this._logService=f,this._optionsService=S,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,c.clone)(y),this.decPrivateModes=(0,c.clone)(l)}reset(){this.modes=(0,c.clone)(y),this.decPrivateModes=(0,c.clone)(l)}triggerDataEvent(u,f=!1){if(this._optionsService.rawOptions.disableStdin)return;const S=this._bufferService.buffer;f&&this._optionsService.rawOptions.scrollOnUserInput&&S.ybase!==S.ydisp&&this._onRequestScrollToBottom.fire(),f&&this._onUserInput.fire(),this._logService.debug(`sending data "${u}"`,(()=>u.split("").map((C=>C.charCodeAt(0))))),this._onData.fire(u)}triggerBinaryEvent(u){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${u}"`,(()=>u.split("").map((f=>f.charCodeAt(0))))),this._onBinary.fire(u))}};i.CoreService=h=a([d(0,b.IBufferService),d(1,b.ILogService),d(2,b.IOptionsService)],h)},9074:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DecorationService=void 0;const a=n(8055),d=n(8460),c=n(844),g=n(6106);let v=0,b=0;class y extends c.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((u=>u?.marker.line)),this._onDecorationRegistered=this.register(new d.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new d.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,c.toDisposable)((()=>this.reset())))}registerDecoration(u){if(u.marker.isDisposed)return;const f=new l(u);if(f){const S=f.marker.onDispose((()=>f.dispose()));f.onDispose((()=>{f&&(this._decorations.delete(f)&&this._onDecorationRemoved.fire(f),S.dispose())})),this._decorations.insert(f),this._onDecorationRegistered.fire(f)}return f}reset(){for(const u of this._decorations.values())u.dispose();this._decorations.clear()}*getDecorationsAtCell(u,f,S){var C,k,E;let w=0,j=0;for(const A of this._decorations.getKeyIterator(f))w=(C=A.options.x)!==null&&C!==void 0?C:0,j=w+((k=A.options.width)!==null&&k!==void 0?k:1),u>=w&&u<j&&(!S||((E=A.options.layer)!==null&&E!==void 0?E:"bottom")===S)&&(yield A)}forEachDecorationAtCell(u,f,S,C){this._decorations.forEachByKey(f,(k=>{var E,w,j;v=(E=k.options.x)!==null&&E!==void 0?E:0,b=v+((w=k.options.width)!==null&&w!==void 0?w:1),u>=v&&u<b&&(!S||((j=k.options.layer)!==null&&j!==void 0?j:"bottom")===S)&&C(k)}))}}i.DecorationService=y;class l extends c.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=a.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=a.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(u){super(),this.options=u,this.onRenderEmitter=this.register(new d.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new d.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=u.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.InstantiationService=i.ServiceCollection=void 0;const a=n(2585),d=n(8343);class c{constructor(...v){this._entries=new Map;for(const[b,y]of v)this.set(b,y)}set(v,b){const y=this._entries.get(v);return this._entries.set(v,b),y}forEach(v){for(const[b,y]of this._entries.entries())v(b,y)}has(v){return this._entries.has(v)}get(v){return this._entries.get(v)}}i.ServiceCollection=c,i.InstantiationService=class{constructor(){this._services=new c,this._services.set(a.IInstantiationService,this)}setService(g,v){this._services.set(g,v)}getService(g){return this._services.get(g)}createInstance(g,...v){const b=(0,d.getServiceDependencies)(g).sort(((h,u)=>h.index-u.index)),y=[];for(const h of b){const u=this._services.get(h.id);if(!u)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${h.id}.`);y.push(u)}const l=b.length>0?b[0].index:v.length;if(v.length!==l)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${l+1} conflicts with ${v.length} static arguments`);return new g(...v,...y)}}},7866:function(x,i,n){var a=this&&this.__decorate||function(l,h,u,f){var S,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,h,u,f);else for(var E=l.length-1;E>=0;E--)(S=l[E])&&(k=(C<3?S(k):C>3?S(h,u,k):S(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(l,h){return function(u,f){h(u,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.traceCall=i.setTraceLogger=i.LogService=void 0;const c=n(844),g=n(2585),v={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let b,y=i.LogService=class extends c.Disposable{get logLevel(){return this._logLevel}constructor(l){super(),this._optionsService=l,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),b=this}_updateLogLevel(){this._logLevel=v[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(l){for(let h=0;h<l.length;h++)typeof l[h]=="function"&&(l[h]=l[h]())}_log(l,h,u){this._evalLazyOptionalParams(u),l.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+h,...u)}trace(l,...h){var u,f;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.trace.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,l,h)}debug(l,...h){var u,f;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.debug.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,l,h)}info(l,...h){var u,f;this._logLevel<=g.LogLevelEnum.INFO&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.info.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.info,l,h)}warn(l,...h){var u,f;this._logLevel<=g.LogLevelEnum.WARN&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.warn.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.warn,l,h)}error(l,...h){var u,f;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.error.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.error,l,h)}};i.LogService=y=a([d(0,g.IOptionsService)],y),i.setTraceLogger=function(l){b=l},i.traceCall=function(l,h,u){if(typeof u.value!="function")throw new Error("not supported");const f=u.value;u.value=function(...S){if(b.logLevel!==g.LogLevelEnum.TRACE)return f.apply(this,S);b.trace(`GlyphRenderer#${f.name}(${S.map((k=>JSON.stringify(k))).join(", ")})`);const C=f.apply(this,S);return b.trace(`GlyphRenderer#${f.name} return`,C),C}}},7302:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OptionsService=i.DEFAULT_OPTIONS=void 0;const a=n(8460),d=n(844),c=n(6114);i.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:c.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class v extends d.Disposable{constructor(y){super(),this._onOptionChange=this.register(new a.EventEmitter),this.onOptionChange=this._onOptionChange.event;const l=Object.assign({},i.DEFAULT_OPTIONS);for(const h in y)if(h in l)try{const u=y[h];l[h]=this._sanitizeAndValidateOption(h,u)}catch(u){console.error(u)}this.rawOptions=l,this.options=Object.assign({},l),this._setupOptions()}onSpecificOptionChange(y,l){return this.onOptionChange((h=>{h===y&&l(this.rawOptions[y])}))}onMultipleOptionChange(y,l){return this.onOptionChange((h=>{y.indexOf(h)!==-1&&l()}))}_setupOptions(){const y=h=>{if(!(h in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);return this.rawOptions[h]},l=(h,u)=>{if(!(h in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);u=this._sanitizeAndValidateOption(h,u),this.rawOptions[h]!==u&&(this.rawOptions[h]=u,this._onOptionChange.fire(h))};for(const h in this.rawOptions){const u={get:y.bind(this,h),set:l.bind(this,h)};Object.defineProperty(this.options,h,u)}}_sanitizeAndValidateOption(y,l){switch(y){case"cursorStyle":if(l||(l=i.DEFAULT_OPTIONS[y]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(l))throw new Error(`"${l}" is not a valid value for ${y}`);break;case"wordSeparator":l||(l=i.DEFAULT_OPTIONS[y]);break;case"fontWeight":case"fontWeightBold":if(typeof l=="number"&&1<=l&&l<=1e3)break;l=g.includes(l)?l:i.DEFAULT_OPTIONS[y];break;case"cursorWidth":l=Math.floor(l);case"lineHeight":case"tabStopWidth":if(l<1)throw new Error(`${y} cannot be less than 1, value: ${l}`);break;case"minimumContrastRatio":l=Math.max(1,Math.min(21,Math.round(10*l)/10));break;case"scrollback":if((l=Math.min(l,4294967295))<0)throw new Error(`${y} cannot be less than 0, value: ${l}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(l<=0)throw new Error(`${y} cannot be less than or equal to 0, value: ${l}`);break;case"rows":case"cols":if(!l&&l!==0)throw new Error(`${y} must be numeric, value: ${l}`);break;case"windowsPty":l=l??{}}return l}}i.OptionsService=v},2660:function(x,i,n){var a=this&&this.__decorate||function(v,b,y,l){var h,u=arguments.length,f=u<3?b:l===null?l=Object.getOwnPropertyDescriptor(b,y):l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(v,b,y,l);else for(var S=v.length-1;S>=0;S--)(h=v[S])&&(f=(u<3?h(f):u>3?h(b,y,f):h(b,y))||f);return u>3&&f&&Object.defineProperty(b,y,f),f},d=this&&this.__param||function(v,b){return function(y,l){b(y,l,v)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const c=n(2585);let g=i.OscLinkService=class{constructor(v){this._bufferService=v,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(v){const b=this._bufferService.buffer;if(v.id===void 0){const S=b.addMarker(b.ybase+b.y),C={data:v,id:this._nextId++,lines:[S]};return S.onDispose((()=>this._removeMarkerFromLink(C,S))),this._dataByLinkId.set(C.id,C),C.id}const y=v,l=this._getEntryIdKey(y),h=this._entriesWithId.get(l);if(h)return this.addLineToLink(h.id,b.ybase+b.y),h.id;const u=b.addMarker(b.ybase+b.y),f={id:this._nextId++,key:this._getEntryIdKey(y),data:y,lines:[u]};return u.onDispose((()=>this._removeMarkerFromLink(f,u))),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(v,b){const y=this._dataByLinkId.get(v);if(y&&y.lines.every((l=>l.line!==b))){const l=this._bufferService.buffer.addMarker(b);y.lines.push(l),l.onDispose((()=>this._removeMarkerFromLink(y,l)))}}getLinkData(v){var b;return(b=this._dataByLinkId.get(v))===null||b===void 0?void 0:b.data}_getEntryIdKey(v){return`${v.id};;${v.uri}`}_removeMarkerFromLink(v,b){const y=v.lines.indexOf(b);y!==-1&&(v.lines.splice(y,1),v.lines.length===0&&(v.data.id!==void 0&&this._entriesWithId.delete(v.key),this._dataByLinkId.delete(v.id)))}};i.OscLinkService=g=a([d(0,c.IBufferService)],g)},8343:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.createDecorator=i.getServiceDependencies=i.serviceRegistry=void 0;const n="di$target",a="di$dependencies";i.serviceRegistry=new Map,i.getServiceDependencies=function(d){return d[a]||[]},i.createDecorator=function(d){if(i.serviceRegistry.has(d))return i.serviceRegistry.get(d);const c=function(g,v,b){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(y,l,h){l[n]===l?l[a].push({id:y,index:h}):(l[a]=[{id:y,index:h}],l[n]=l)})(c,g,b)};return c.toString=()=>d,i.serviceRegistry.set(d,c),c}},2585:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IDecorationService=i.IUnicodeService=i.IOscLinkService=i.IOptionsService=i.ILogService=i.LogLevelEnum=i.IInstantiationService=i.ICharsetService=i.ICoreService=i.ICoreMouseService=i.IBufferService=void 0;const a=n(8343);var d;i.IBufferService=(0,a.createDecorator)("BufferService"),i.ICoreMouseService=(0,a.createDecorator)("CoreMouseService"),i.ICoreService=(0,a.createDecorator)("CoreService"),i.ICharsetService=(0,a.createDecorator)("CharsetService"),i.IInstantiationService=(0,a.createDecorator)("InstantiationService"),(function(c){c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.OFF=5]="OFF"})(d||(i.LogLevelEnum=d={})),i.ILogService=(0,a.createDecorator)("LogService"),i.IOptionsService=(0,a.createDecorator)("OptionsService"),i.IOscLinkService=(0,a.createDecorator)("OscLinkService"),i.IUnicodeService=(0,a.createDecorator)("UnicodeService"),i.IDecorationService=(0,a.createDecorator)("DecorationService")},1480:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeService=void 0;const a=n(8460),d=n(225);i.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new a.EventEmitter,this.onChange=this._onChange.event;const c=new d.UnicodeV6;this.register(c),this._active=c.version,this._activeProvider=c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(c){if(!this._providers[c])throw new Error(`unknown Unicode version "${c}"`);this._active=c,this._activeProvider=this._providers[c],this._onChange.fire(c)}register(c){this._providers[c.version]=c}wcwidth(c){return this._activeProvider.wcwidth(c)}getStringCellWidth(c){let g=0;const v=c.length;for(let b=0;b<v;++b){let y=c.charCodeAt(b);if(55296<=y&&y<=56319){if(++b>=v)return g+this.wcwidth(y);const l=c.charCodeAt(b);56320<=l&&l<=57343?y=1024*(y-55296)+l-56320+65536:g+=this.wcwidth(l)}g+=this.wcwidth(y)}return g}}}},o={};function p(x){var i=o[x];if(i!==void 0)return i.exports;var n=o[x]={exports:{}};return r[x].call(n.exports,n,n.exports,p),n.exports}var m={};return(()=>{var x=m;Object.defineProperty(x,"__esModule",{value:!0}),x.Terminal=void 0;const i=p(9042),n=p(3236),a=p(844),d=p(5741),c=p(8285),g=p(7975),v=p(7090),b=["cols","rows"];class y extends a.Disposable{constructor(h){super(),this._core=this.register(new n.Terminal(h)),this._addonManager=this.register(new d.AddonManager),this._publicOptions=Object.assign({},this._core.options);const u=S=>this._core.options[S],f=(S,C)=>{this._checkReadonlyOptions(S),this._core.options[S]=C};for(const S in this._core.options){const C={get:u.bind(this,S),set:f.bind(this,S)};Object.defineProperty(this._publicOptions,S,C)}}_checkReadonlyOptions(h){if(b.includes(h))throw new Error(`Option "${h}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new g.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new v.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new c.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const h=this._core.coreService.decPrivateModes;let u="none";switch(this._core.coreMouseService.activeProtocol){case"X10":u="x10";break;case"VT200":u="vt200";break;case"DRAG":u="drag";break;case"ANY":u="any"}return{applicationCursorKeysMode:h.applicationCursorKeys,applicationKeypadMode:h.applicationKeypad,bracketedPasteMode:h.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:u,originMode:h.origin,reverseWraparoundMode:h.reverseWraparound,sendFocusMode:h.sendFocus,wraparoundMode:h.wraparound}}get options(){return this._publicOptions}set options(h){for(const u in h)this._publicOptions[u]=h[u]}blur(){this._core.blur()}focus(){this._core.focus()}resize(h,u){this._verifyIntegers(h,u),this._core.resize(h,u)}open(h){this._core.open(h)}attachCustomKeyEventHandler(h){this._core.attachCustomKeyEventHandler(h)}registerLinkProvider(h){return this._core.registerLinkProvider(h)}registerCharacterJoiner(h){return this._checkProposedApi(),this._core.registerCharacterJoiner(h)}deregisterCharacterJoiner(h){this._checkProposedApi(),this._core.deregisterCharacterJoiner(h)}registerMarker(h=0){return this._verifyIntegers(h),this._core.registerMarker(h)}registerDecoration(h){var u,f,S;return this._checkProposedApi(),this._verifyPositiveIntegers((u=h.x)!==null&&u!==void 0?u:0,(f=h.width)!==null&&f!==void 0?f:0,(S=h.height)!==null&&S!==void 0?S:0),this._core.registerDecoration(h)}hasSelection(){return this._core.hasSelection()}select(h,u,f){this._verifyIntegers(h,u,f),this._core.select(h,u,f)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(h,u){this._verifyIntegers(h,u),this._core.selectLines(h,u)}dispose(){super.dispose()}scrollLines(h){this._verifyIntegers(h),this._core.scrollLines(h)}scrollPages(h){this._verifyIntegers(h),this._core.scrollPages(h)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(h){this._verifyIntegers(h),this._core.scrollToLine(h)}clear(){this._core.clear()}write(h,u){this._core.write(h,u)}writeln(h,u){this._core.write(h),this._core.write(`\r
|
|
21
|
+
`,u)}paste(h){this._core.paste(h)}refresh(h,u){this._verifyIntegers(h,u),this._core.refresh(h,u)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(h){this._addonManager.loadAddon(this,h)}static get strings(){return i}_verifyIntegers(...h){for(const u of h)if(u===1/0||isNaN(u)||u%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...h){for(const u of h)if(u&&(u===1/0||isNaN(u)||u%1!=0||u<0))throw new Error("This API only accepts positive integers")}}x.Terminal=y})(),m})()))})(Xi)),Xi.exports}var ap=op();var lp=2,cp=1,dp=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let s=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(s._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),p=Math.max(0,parseInt(r.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),x={top:parseInt(m.getPropertyValue("padding-top")),bottom:parseInt(m.getPropertyValue("padding-bottom")),right:parseInt(m.getPropertyValue("padding-right")),left:parseInt(m.getPropertyValue("padding-left"))},i=x.top+x.bottom,n=x.right+x.left,a=o-i,d=p-n-s;return{cols:Math.max(lp,Math.floor(d/e.css.cell.width)),rows:Math.max(cp,Math.floor(a/e.css.cell.height))}}};function up(e={}){const{cwd:s,cols:r,rows:o,onOutput:p,onExit:m}=e,[x,i]=_.useState(null),[n,a]=_.useState(()=>ls.isConnected()),[d,c]=_.useState(!1),[g,v]=_.useState(!1),[b,y]=_.useState(!1),l=_.useRef({onOutput:p,onExit:m});l.current={onOutput:p,onExit:m};const h=_.useRef(null);h.current=x,_.useEffect(()=>{if(!x)return;const k=ls.getSocket(),E=()=>{a(!0),c(!1),i(null),y(!0)},w=()=>{a(!1),c(!1)},j=P=>{P.terminalId===x&&l.current.onOutput?.(P.data)},A=P=>{P.terminalId===x&&(c(!1),l.current.onExit?.(P.exitCode),i(null))},D=P=>{P.terminalId===x&&c(!0)},T=P=>{P.terminalId===x&&c(!1)};return k.on("connect",E),k.on("disconnect",w),k.on(dt.TERMINAL_STDOUT,j),k.on(dt.TERMINAL_EXIT,A),k.on(dt.TERMINAL_SUBSCRIBED,D),k.on(dt.TERMINAL_UNSUBSCRIBED,T),a(k.connected),k.connected&&k.emit(Fs.SUBSCRIBE,{topic:"terminal",id:x},P=>{P.success&&c(!0)}),()=>{k.off("connect",E),k.off("disconnect",w),k.off(dt.TERMINAL_STDOUT,j),k.off(dt.TERMINAL_EXIT,A),k.off(dt.TERMINAL_SUBSCRIBED,D),k.off(dt.TERMINAL_UNSUBSCRIBED,T),k.emit(Fs.UNSUBSCRIBE,{topic:"terminal",id:x})}},[x]);const u=_.useCallback(async()=>{const k=ls.getSocket();if(!k.connected)return null;v(!0);try{const E=await Ae.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return i(E.terminalId),y(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{v(!1)}},[s,r,o]),f=_.useCallback(async()=>{const k=h.current;if(k){try{await Ae.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}i(null),c(!1)}},[]),S=_.useCallback(k=>{const E=h.current;if(!E)return;ls.getSocket().emit(Fs.TERMINAL_INPUT,{terminalId:E,data:k})},[]),C=_.useCallback((k,E)=>{const w=h.current;if(!w)return;ls.getSocket().emit(Fs.TERMINAL_RESIZE,{terminalId:w,cols:k,rows:E})},[]);return _.useEffect(()=>()=>{const k=h.current;k&&Ae.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:x,isConnected:n,isAttached:d,isCreating:g,needsRecreate:b,create:u,destroy:f,sendInput:S,resize:C}}function hp({terminalRef:e,xtermRef:s,fitAddonRef:r,isVisible:o=!0,onResize:p}){const m=_.useRef(null),x=_.useRef(null),i=_.useRef(0),n=_.useCallback(()=>{m.current!=null&&(window.clearTimeout(m.current),m.current=null),x.current!=null&&(window.cancelAnimationFrame(x.current),x.current=null)},[]),a=_.useCallback(()=>{const g=r.current,v=s.current,b=e.current;if(!g||!v||!b||b.clientWidth<=0||b.clientHeight<=0)return!1;try{return g.fit(),v.cols>0&&v.rows>0&&p(v.cols,v.rows),!0}catch{return!1}},[r,p,e,s]),d=_.useCallback((g=6)=>{n();const v=i.current+1;i.current=v;let b=0;const y=()=>{i.current===v&&(x.current=window.requestAnimationFrame(()=>{if(x.current=null,i.current!==v)return;const l=a(),h=b<2;b<g&&(!l||h)&&(b+=1,m.current=window.setTimeout(y,50))}))};y()},[n,a]),c=_.useCallback(()=>{i.current+=1,n()},[n]);return _.useEffect(()=>c,[c]),_.useEffect(()=>{o&&d(8)},[o,d]),_.useEffect(()=>{const g=e.current;if(!g)return;if(typeof ResizeObserver>"u"){d(8);return}const v=new ResizeObserver(()=>{d(4)});return v.observe(g),g.parentElement&&v.observe(g.parentElement),d(8),()=>{v.disconnect()}},[d,e]),{fitNow:a,scheduleFit:d}}const fp={background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78",black:"#1e1e1e",red:"#f44747",green:"#6a9955",yellow:"#d7ba7d",blue:"#569cd6",magenta:"#c586c0",cyan:"#4ec9b0",white:"#d4d4d4",brightBlack:"#808080",brightRed:"#f44747",brightGreen:"#6a9955",brightYellow:"#d7ba7d",brightBlue:"#569cd6",brightMagenta:"#c586c0",brightCyan:"#4ec9b0",brightWhite:"#ffffff"},mp=ue.memo(function({cwd:s,isVisible:r=!0,onExit:o,onReady:p}){const m=_.useRef(null),x=_.useRef(null),i=_.useRef(null),n=_.useRef(!1),{terminalId:a,isAttached:d,needsRecreate:c,create:g,sendInput:v,resize:b}=up({cwd:s,onOutput:_.useCallback(h=>{x.current?.write(h)},[]),onExit:_.useCallback(h=>{x.current?.writeln(`\r
|
|
22
|
+
\x1B[90m[Process exited with code ${h}]\x1B[0m`),o?.(h)},[o])}),{scheduleFit:y}=hp({terminalRef:m,xtermRef:x,fitAddonRef:i,isVisible:r,onResize:b}),l=_.useCallback(h=>{x.current?.paste(h)},[]);return _.useEffect(()=>{r||x.current?.blur()},[r]),_.useEffect(()=>{if(!c)return;const h=x.current;h&&h.writeln(`\r
|
|
23
|
+
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[c,g]),_.useLayoutEffect(()=>{if(!m.current)return;const h=new ap.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:fp,scrollback:5e3,convertEol:!0}),u=new dp;return h.loadAddon(u),h.open(m.current),x.current=h,i.current=u,y(8),()=>{h.dispose(),x.current=null,i.current=null}},[y]),_.useEffect(()=>{n.current||(n.current=!0,g())},[g]),_.useEffect(()=>{const h=x.current;if(!h||!d)return;const u=h.onData(f=>{v(f)});return()=>u.dispose()},[v,d]),_.useEffect(()=>{d&&(y(4),p?.({sendInput:v,paste:l}))},[d,p,l,y,v]),t.jsxs("div",{className:"relative flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[!a&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),t.jsx("div",{ref:m,className:"terminal-xterm-host flex-1 min-h-0 min-w-0 w-full overflow-hidden"})]})}),pp=ue.memo(function({commands:s,onSelect:r}){const{t:o}=ce(),[p,m]=_.useState(!1),x=_.useRef(null),i=_.useRef(null);return _.useEffect(()=>{if(!p)return;const n=a=>{x.current&&!x.current.contains(a.target)&&i.current&&!i.current.contains(a.target)&&m(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[p]),s.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:i,onClick:()=>m(!p),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${p?"bg-amber-500/20 text-amber-300":"bg-amber-500/10 text-amber-400/80 hover:bg-amber-500/20 hover:text-amber-300"}`,children:[t.jsx(Zd,{size:12}),t.jsx("span",{children:o("快捷命令")}),t.jsx(Ct,{size:10,className:`transition-transform ${p?"rotate-180":""}`})]}),p&&t.jsx("div",{ref:x,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:t.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:s.map((n,a)=>t.jsxs("button",{onClick:()=>{r(n.command),m(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[t.jsx(Cs,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:n.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:n.command})]})]},a))})})]})]})}),sc="\x1B",gp="\x07",vp="";function xp(e){const s=e.charCodeAt(0);return s>=64&&s<=126}function ia(e,s){let r=s;for(;r<e.length;){if(e[r]===gp||e[r]===vp)return r+1;if(e[r]===sc&&e[r+1]==="\\")return r+2;r+=1}return r}function na(e,s){let r=s;for(;r<e.length&&!xp(e[r]);)r+=1;return r<e.length?r+1:r}function bp(e){let s="";for(let r=0;r<e.length;){if(e[r]===""){r=na(e,r+1);continue}if(e[r]===""){r=ia(e,r+1);continue}if(e[r]!==sc){s+=e[r],r+=1;continue}const o=e[r+1];if(o==="["){r=na(e,r+2);continue}if(o==="]"||o==="P"||o==="X"||o==="^"||o==="_"){r=ia(e,r+2);continue}for(r+=1;r<e.length;){const p=e.charCodeAt(r);if(p<32||p>47)break;r+=1}r<e.length&&(r+=1)}return s}const _p=200,yp=1e3,Sp=512*1024;function wp(e){let s=e.reduce((o,p)=>o+p.data.length,0),r=0;for(;e.length-r>yp||s>Sp&&e.length-r>1;)s-=e[r].data.length,r+=1;return{entries:r>0?e.slice(r):e,trimmed:r>0}}function Cp(e,s){const r=!!e&&e.runtimeInstanceId!==s.runtimeInstanceId,o=r||s.reset,p=o?[]:e?.entries??[],m=new Set(p.map(n=>n.seq)),x=[...p,...s.entries.filter(n=>!m.has(n.seq))].sort((n,a)=>n.seq-a.seq),i=wp(x);return{...s,entries:i.entries,reset:s.reset||r||!o&&(e?.reset??!1),truncated:s.truncated||!o&&(e?.truncated??!1)||i.trimmed}}function lo(e,s=!0){return Pt({queryKey:be.workspaceServices.list(e),queryFn:async()=>(await Ae.get(`/workspaces/${encodeURIComponent(e)}/services`)).services,enabled:s&&!!e,refetchInterval:s&&e?3e3:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}function kp(e,s,r,o=!0){const p=Lt(),m=be.workspaceServices.logs(e,s);return Pt({queryKey:m,queryFn:async()=>{const x=p.getQueryData(m),i=x?Math.max(0,x.nextSeq-1):0,n=x===void 0?r:x.runtimeInstanceId,a=new URLSearchParams({limit:String(_p)});n!==null&&a.set("runtimeInstanceId",n),a.set("afterSeq",String(i));const d=await Ae.get(`/workspaces/${encodeURIComponent(e)}/services/${encodeURIComponent(s)}/logs?${a}`);return Cp(x,d)},enabled:o&&!!e&&!!s,refetchInterval:x=>x.state.data?.hasMore?250:1e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}const Ep=[];function Gi(e){return JSON.stringify([e.command,...e.args])}function oa(e,s,r){if(!e)return r;const o=new Date(e);return Number.isNaN(o.getTime())?r:new Intl.DateTimeFormat(s,{dateStyle:"medium",timeStyle:"medium"}).format(o)}function jp(e){switch(e){case"RUNNING":return{label:"Running",dotClassName:"bg-emerald-400"};case"STARTING":return{label:"Starting",dotClassName:"bg-amber-400"};case"STOPPING":return{label:"Stopping",dotClassName:"bg-amber-400"};case"FAILED":return{label:"Failed",dotClassName:"bg-red-400"};case"EXITED":return{label:"Exited",dotClassName:"bg-neutral-400"};default:return{label:"Stopped",dotClassName:"bg-neutral-500"}}}function aa({state:e}){const{t:s}=ce(),r=jp(e);return t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-[11px] text-neutral-300",children:[t.jsx("span",{className:Z("h-1.5 w-1.5 rounded-full",r.dotClassName),"aria-hidden":"true"}),s(r.label)]})}function Np({message:e,onRetry:s}){const{t:r}=ce();return t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 px-4 text-xs text-red-300",role:"alert",children:[t.jsx(Ns,{size:14,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{children:e}),t.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded text-neutral-400 transition-colors hover:bg-[#333] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",title:r("Retry"),"aria-label":r("Retry"),children:t.jsx(Rs,{size:13})})]})}function Rp({workspaceId:e,enabled:s=!0}){const{locale:r,t:o}=ce(),p=lo(e,s),m=p.data??Ep,[x,i]=_.useState(null),n=m.find(v=>v.name===x)??m[0]??null,a=kp(e,n?.name??"",n?.runtimeInstanceId??null,s&&!!n),d=_.useMemo(()=>bp(a.data?.entries.map(v=>v.data).join("")??""),[a.data?.entries]),c=_.useRef(null),g=_.useRef(!0);return _.useEffect(()=>{g.current=!0},[n?.id,n?.runtimeInstanceId]),_.useEffect(()=>{const v=c.current;v&&g.current&&(v.scrollTop=v.scrollHeight)},[d]),t.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col bg-[#1e1e1e] text-neutral-200 md:flex-row",children:[t.jsxs("aside",{className:"flex max-h-[44%] min-h-32 shrink-0 flex-col border-b border-[#343434] bg-[#252526] md:max-h-none md:min-h-0 md:w-72 md:border-b-0 md:border-r",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between border-b border-[#343434] px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(fn,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":"true"}),t.jsx("h2",{className:"truncate text-xs font-medium",children:o("Background services")})]}),!p.isLoading&&!p.isError&&t.jsx("span",{className:"text-[11px] tabular-nums text-neutral-500",children:m.length})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto scrollbar-app-thin",children:p.isLoading?t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 text-xs text-neutral-500",children:[t.jsx(Be,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading background services...")]}):p.isError?t.jsx(Np,{message:o("Failed to load background services."),onRetry:()=>{p.refetch()}}):m.length===0?t.jsxs("div",{className:"flex min-h-24 flex-col items-center justify-center gap-2 px-4 text-center text-xs text-neutral-500",children:[t.jsx(fn,{size:22,"aria-hidden":"true"}),t.jsx("span",{children:o("No background services")})]}):m.map(v=>{const b=v.name===n?.name;return t.jsxs("button",{type:"button",onClick:()=>i(v.name),"aria-pressed":b,className:Z("block w-full border-b border-[#343434] px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-neutral-400",b?"bg-[#1e1e1e]":"hover:bg-[#2d2d2d]"),children:[t.jsxs("span",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-100",children:v.name}),t.jsx(aa,{state:v.runtimeState})]}),t.jsx("span",{className:"mt-1 block truncate font-mono text-[10px] text-neutral-500",title:Gi(v),children:Gi(v)}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx($n,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:v.relativeCwd||"."})]}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx(us,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:oa(v.startedAt,r,o("Not started"))})]})]},v.id)})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-[#1e1e1e]","aria-label":o("Background service logs"),children:n?t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"shrink-0 border-b border-[#343434] bg-[#252526]",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 px-3 pt-2",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold text-neutral-100",children:n.name}),t.jsx(aa,{state:n.runtimeState})]}),t.jsxs("div",{className:"max-h-32 overflow-y-auto overscroll-y-contain px-3 pb-2 scrollbar-app-thin focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-neutral-400",tabIndex:0,"aria-label":`${n.name} ${o("Details")}`,children:[t.jsxs("dl",{className:"mt-1.5 grid min-w-0 gap-x-4 gap-y-1 text-[10px] text-neutral-500 sm:grid-cols-2",children:[t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[o("Command"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-neutral-400",children:Gi(n)})]}),t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[o("Working directory"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-neutral-400",children:n.relativeCwd||"."})]}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 sm:col-span-2",children:[t.jsx(us,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsxs("dt",{className:"shrink-0",children:[o("Started"),":"]}),t.jsx("dd",{className:"truncate text-neutral-400",children:oa(n.startedAt,r,o("Not started"))})]})]}),n.lastError&&t.jsx("p",{className:"mt-1.5 break-words text-[10px] text-red-300",role:"alert",children:n.lastError})]})]}),(a.data?.truncated||a.data?.reset)&&t.jsx("div",{className:"shrink-0 border-b border-amber-400/20 bg-amber-400/10 px-3 py-1.5 text-[10px] text-amber-200",children:o("Earlier log output is unavailable.")}),a.isError&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-red-400/20 bg-red-400/10 px-3 py-1.5 text-[10px] text-red-200",role:"alert",children:[t.jsx("span",{children:o("Failed to refresh service logs.")}),t.jsx("button",{type:"button",onClick:()=>{a.refetch()},className:"flex h-6 w-6 items-center justify-center rounded text-red-100 transition-colors hover:bg-red-300/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-200",title:o("Retry"),"aria-label":o("Retry"),children:t.jsx(Rs,{size:11})})]}),t.jsx("div",{ref:c,onScroll:v=>{const b=v.currentTarget;g.current=b.scrollHeight-b.scrollTop-b.clientHeight<32},className:"min-h-0 flex-1 overflow-auto p-3 scrollbar-app-thin",role:"log","aria-live":"off",tabIndex:0,children:a.isLoading&&!a.data?t.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-neutral-500",children:[t.jsx(Be,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading service logs...")]}):d?t.jsx("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono text-[11px] leading-5 text-neutral-300",children:d}):t.jsx("div",{className:"flex h-full items-center justify-center text-xs text-neutral-500",children:o("No logs yet")})})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-xs text-neutral-500",children:p.isLoading?o("Loading background services..."):o("Select a background service")})})]})}let Qi=0;function la(){return Qi+=1,{id:`shell-${Qi}`,order:Qi}}const Ap=ue.memo(function({cwd:s,isVisible:r=!0,workspaceId:o,quickCommands:p=[]}){const{t:m}=ce(),[x,i]=_.useState(()=>[la()]),[n,a]=_.useState(()=>x[0].id),[d,c]=_.useState(()=>new Set),[g,v]=_.useState(!1),[b,y]=_.useState(!1),[l,h]=_.useState(""),[u,f]=_.useState(null),[S,C]=_.useState("terminals"),k=_.useRef(new Map),E=o?S:"terminals",w=_.useCallback(M=>{k.current.delete(M),c(O=>{if(!O.has(M))return O;const q=new Set(O);return q.delete(M),q})},[]),j=_.useCallback(()=>{const M=la();i(O=>[...O,M]),a(M.id)},[]),A=_.useCallback((M,O)=>{O.stopPropagation(),w(M),i(q=>{const V=q.filter(H=>H.id!==M);return M===n&&V.length>0&&a(V[V.length-1].id),V})},[n,w]),D=_.useCallback(M=>{w(M),i(O=>{const q=O.filter(V=>V.id!==M);return M===n&&q.length>0&&a(q[q.length-1].id),q})},[n,w]),T=_.useCallback((M,O)=>{k.current.set(M,O),c(q=>{if(q.has(M))return q;const V=new Set(q);return V.add(M),V})},[]),P=_.useCallback(M=>{const O=k.current.get(n);O&&O.sendInput(M+"\r")},[n]),F=_.useCallback((M,O="")=>{f(M),h(O),y(!0)},[]),I=_.useCallback((M,O)=>{const q=k.current.get(M);return q?(q.paste(O),Je.success(m("Pasted into terminal")),!0):(Je.error(m("Terminal is not ready")),!1)},[m]),z=_.useCallback(async()=>{if(!k.current.has(n)){Je.error(m("Terminal is not ready"));return}const M=navigator.clipboard;if(!M?.readText){F(n);return}v(!0);try{const O=await M.readText();if(!O||O.includes(`
|
|
24
|
+
`)||O.includes("\r")){F(n,O);return}I(n,O)}catch{F(n)}finally{v(!1)}},[n,F,I,m]),$=_.useCallback(()=>{!l||!u||!I(u,l)||(y(!1),h(""),f(null))},[l,I,u]),R=_.useCallback(()=>{y(!1),h(""),f(null)},[]),L=d.has(n);return t.jsxs("div",{className:"flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[o&&t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-[#343434] bg-[#202020] px-2 select-none",children:[t.jsxs("button",{type:"button",onClick:()=>C("terminals"),"aria-pressed":E==="terminals",className:Z("flex h-7 items-center gap-1.5 rounded px-2.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",E==="terminals"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(fr,{size:12,"aria-hidden":"true"}),m("Interactive terminals")]}),t.jsxs("button",{type:"button",onClick:()=>C("services"),"aria-pressed":E==="services",className:Z("flex h-7 items-center gap-1.5 rounded px-2.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",E==="services"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(fn,{size:12,"aria-hidden":"true"}),m("Background services")]})]}),t.jsxs("div",{"aria-hidden":E!=="terminals",className:Z("min-h-0 flex-1 flex-col",E==="terminals"?"flex":"hidden"),children:[t.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin flex-1 min-w-0",children:x.map(M=>t.jsxs("button",{onClick:()=>a(M.id),className:Z("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",M.id===n?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(fr,{size:11,className:"shrink-0"}),t.jsx("span",{children:m("Shell {count}",{count:M.order})}),x.length>1&&t.jsx("span",{onClick:O=>A(M.id,O),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(Xt,{size:10})})]},M.id))}),x.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-0.5 block h-5 w-px shrink-0 bg-[#3a3a3a] md:hidden","aria-hidden":"true"}),t.jsx("button",{type:"button",onClick:z,disabled:!L||g,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-400 transition-colors hover:bg-[#333] hover:text-neutral-100 active:bg-[#3a3a3a] disabled:cursor-not-allowed disabled:opacity-40 md:hidden",title:m("Paste into terminal"),"aria-label":m("Paste into terminal"),children:g?t.jsx(Be,{size:18,className:"animate-spin"}):t.jsx(ju,{size:18})})]}),t.jsx("button",{type:"button",onClick:j,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-500 transition-colors hover:bg-[#333] hover:text-neutral-300 active:bg-[#3a3a3a] md:h-auto md:w-auto md:px-2 md:py-1.5",title:m("New Terminal"),"aria-label":m("New Terminal"),children:t.jsx(ds,{size:14})}),p.length>0&&t.jsx(pp,{commands:p,onSelect:P})]}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden relative",children:x.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(fr,{size:28}),t.jsx("span",{className:"text-xs",children:m("No terminals open")}),t.jsx("button",{onClick:j,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:m("New Terminal")})]})}):x.map(M=>t.jsx("div",{"aria-hidden":M.id!==n,className:Z("absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",M.id===n?"visible pointer-events-auto":"invisible pointer-events-none"),children:t.jsx(mp,{cwd:s,isVisible:r&&E==="terminals"&&M.id===n,onExit:()=>D(M.id),onReady:O=>T(M.id,O)})},M.id))})]}),o&&E==="services"&&t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Rp,{workspaceId:o,enabled:r})}),t.jsx(ps,{isOpen:b,onClose:R,title:m("Paste into terminal"),className:"fixed inset-x-0 bottom-0 max-h-[70dvh] max-w-none rounded-b-none rounded-t-lg border-x-0 border-b-0 sm:relative sm:inset-auto sm:max-w-lg sm:rounded-lg sm:border",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:R,className:"min-h-11 px-4 text-sm font-medium text-neutral-600 transition-colors hover:text-neutral-900",children:m("Cancel")}),t.jsx("button",{type:"button",onClick:$,disabled:!l,className:"min-h-11 rounded-md bg-neutral-900 px-4 text-sm font-medium text-white transition-colors hover:bg-black disabled:cursor-not-allowed disabled:opacity-40",children:m("Paste")})]}),children:t.jsx(pu,{autoFocus:!0,value:l,onChange:M=>h(M.target.value),placeholder:m("Paste terminal input here"),"aria-label":m("Terminal paste content"),className:"min-h-32 resize-none bg-white font-mono"})})]})});function ca(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,o=Array(s);r<s;r++)o[r]=e[r];return o}function Tp(e){if(Array.isArray(e))return e}function Mp(e,s,r){return(s=Fp(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Dp(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,p,m,x,i=[],n=!0,a=!1;try{if(m=(r=r.call(e)).next,s!==0)for(;!(n=(o=m.call(r)).done)&&(i.push(o.value),i.length!==s);n=!0);}catch(d){a=!0,p=d}finally{try{if(!n&&r.return!=null&&(x=r.return(),Object(x)!==x))return}finally{if(a)throw p}}return i}}function Pp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
25
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function da(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,o)}return r}function ua(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?da(Object(r),!0).forEach(function(o){Mp(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):da(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Lp(e,s){if(e==null)return{};var r,o,p=Ip(e,s);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(e);for(o=0;o<m.length;o++)r=m[o],s.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(p[r]=e[r])}return p}function Ip(e,s){if(e==null)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(s.indexOf(o)!==-1)continue;r[o]=e[o]}return r}function Op(e,s){return Tp(e)||Dp(e,s)||zp(e,s)||Pp()}function Bp(e,s){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function Fp(e){var s=Bp(e,"string");return typeof s=="symbol"?s:s+""}function zp(e,s){if(e){if(typeof e=="string")return ca(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ca(e,s):void 0}}function Wp(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function ha(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,o)}return r}function fa(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?ha(Object(r),!0).forEach(function(o){Wp(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ha(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Hp(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return function(o){return s.reduceRight(function(p,m){return m(p)},o)}}function hr(e){return function s(){for(var r=this,o=arguments.length,p=new Array(o),m=0;m<o;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var x=arguments.length,i=new Array(x),n=0;n<x;n++)i[n]=arguments[n];return s.apply(r,[].concat(p,i))}}}function hi(e){return{}.toString.call(e).includes("Object")}function Up(e){return!Object.keys(e).length}function wr(e){return typeof e=="function"}function $p(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function Kp(e,s){return hi(s)||fs("changeType"),Object.keys(s).some(function(r){return!$p(e,r)})&&fs("changeField"),s}function qp(e){wr(e)||fs("selectorType")}function Vp(e){wr(e)||hi(e)||fs("handlerType"),hi(e)&&Object.values(e).some(function(s){return!wr(s)})&&fs("handlersType")}function Yp(e){e||fs("initialIsRequired"),hi(e)||fs("initialType"),Up(e)&&fs("initialContent")}function Xp(e,s){throw new Error(e[s]||e.default)}var Gp={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},fs=hr(Xp)(Gp),Vr={changes:Kp,selector:qp,handler:Vp,initial:Yp};function Qp(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Vr.initial(e),Vr.handler(s);var r={current:e},o=hr(eg)(r,s),p=hr(Jp)(r),m=hr(Vr.changes)(e),x=hr(Zp)(r);function i(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(d){return d};return Vr.selector(a),a(r.current)}function n(a){Hp(o,p,m,x)(a)}return[i,n]}function Zp(e,s){return wr(s)?s(e.current):s}function Jp(e,s){return e.current=fa(fa({},e.current),s),s}function eg(e,s,r){return wr(s)?s(e.current):Object.keys(r).forEach(function(o){var p;return(p=s[o])===null||p===void 0?void 0:p.call(s,e.current[o])}),r}var tg={create:Qp},sg={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function rg(e){return function s(){for(var r=this,o=arguments.length,p=new Array(o),m=0;m<o;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var x=arguments.length,i=new Array(x),n=0;n<x;n++)i[n]=arguments[n];return s.apply(r,[].concat(p,i))}}}function ig(e){return{}.toString.call(e).includes("Object")}function ng(e){return e||ma("configIsRequired"),ig(e)||ma("configType"),e.urls?(og(),{paths:{vs:e.urls.monacoBase}}):e}function og(){console.warn(rc.deprecation)}function ag(e,s){throw new Error(e[s]||e.default)}var rc={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
26
|
+
You are using deprecated way of configuration.
|
|
27
|
+
|
|
28
|
+
Instead of using
|
|
29
|
+
monaco.config({ urls: { monacoBase: '...' } })
|
|
30
|
+
use
|
|
31
|
+
monaco.config({ paths: { vs: '...' } })
|
|
32
|
+
|
|
33
|
+
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
34
|
+
`},ma=rg(ag)(rc),lg={config:ng},cg=function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return function(p){return r.reduceRight(function(m,x){return x(m)},p)}};function ic(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],ic(e[r],s[r]))}),ua(ua({},e),s)}var dg={type:"cancelation",msg:"operation is manually canceled"};function Zi(e){var s=!1,r=new Promise(function(o,p){e.then(function(m){return s?p(dg):o(m)}),e.catch(p)});return r.cancel=function(){return s=!0},r}var ug=["monaco"],hg=tg.create({config:sg,isInitialized:!1,resolve:null,reject:null,monaco:null}),nc=Op(hg,2),Tr=nc[0],ji=nc[1];function fg(e){var s=lg.config(e),r=s.monaco,o=Lp(s,ug);ji(function(p){return{config:ic(p.config,o),monaco:r}})}function mg(){var e=Tr(function(s){var r=s.monaco,o=s.isInitialized,p=s.resolve;return{monaco:r,isInitialized:o,resolve:p}});if(!e.isInitialized){if(ji({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Zi(Ji);if(window.monaco&&window.monaco.editor)return oc(window.monaco),e.resolve(window.monaco),Zi(Ji);cg(pg,vg)(xg)}return Zi(Ji)}function pg(e){return document.body.appendChild(e)}function gg(e){var s=document.createElement("script");return e&&(s.src=e),s}function vg(e){var s=Tr(function(o){var p=o.config,m=o.reject;return{config:p,reject:m}}),r=gg("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function xg(){var e=Tr(function(r){var o=r.config,p=r.resolve,m=r.reject;return{config:o,resolve:p,reject:m}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var o=r.m||r;oc(o),e.resolve(o)},function(r){e.reject(r)})}function oc(e){Tr().monaco||ji({monaco:e})}function bg(){return Tr(function(e){var s=e.monaco;return s})}var Ji=new Promise(function(e,s){return ji({resolve:e,reject:s})}),ac={config:fg,init:mg,__getMonacoInstance:bg},_g={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},en=_g,yg={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Sg=yg;function wg({children:e}){return ue.createElement("div",{style:Sg.container},e)}var Cg=wg,kg=Cg;function Eg({width:e,height:s,isEditorReady:r,loading:o,_ref:p,className:m,wrapperProps:x}){return ue.createElement("section",{style:{...en.wrapper,width:e,height:s},...x},!r&&ue.createElement(kg,null,o),ue.createElement("div",{ref:p,style:{...en.fullWidth,...!r&&en.hide},className:m}))}var jg=Eg,lc=_.memo(jg);function Ng(e){_.useEffect(e,[])}var cc=Ng;function Rg(e,s,r=!0){let o=_.useRef(!0);_.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var jt=Rg;function vr(){}function zs(e,s,r,o){return Ag(e,o)||Tg(e,s,r,o)}function Ag(e,s){return e.editor.getModel(dc(e,s))}function Tg(e,s,r,o){return e.editor.createModel(s,r,o?dc(e,o):void 0)}function dc(e,s){return e.Uri.parse(s)}function Mg({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:p,originalModelPath:m,modifiedModelPath:x,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:n=!1,theme:a="light",loading:d="Loading...",options:c={},height:g="100%",width:v="100%",className:b,wrapperProps:y={},beforeMount:l=vr,onMount:h=vr}){let[u,f]=_.useState(!1),[S,C]=_.useState(!0),k=_.useRef(null),E=_.useRef(null),w=_.useRef(null),j=_.useRef(h),A=_.useRef(l),D=_.useRef(!1);cc(()=>{let I=ac.init();return I.then(z=>(E.current=z)&&C(!1)).catch(z=>z?.type!=="cancelation"&&console.error("Monaco initialization: error:",z)),()=>k.current?F():I.cancel()}),jt(()=>{if(k.current&&E.current){let I=k.current.getOriginalEditor(),z=zs(E.current,e||"",o||r||"text",m||"");z!==I.getModel()&&I.setModel(z)}},[m],u),jt(()=>{if(k.current&&E.current){let I=k.current.getModifiedEditor(),z=zs(E.current,s||"",p||r||"text",x||"");z!==I.getModel()&&I.setModel(z)}},[x],u),jt(()=>{let I=k.current.getModifiedEditor();I.getOption(E.current.editor.EditorOption.readOnly)?I.setValue(s||""):s!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[s],u),jt(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],u),jt(()=>{let{original:I,modified:z}=k.current.getModel();E.current.editor.setModelLanguage(I,o||r||"text"),E.current.editor.setModelLanguage(z,p||r||"text")},[r,o,p],u),jt(()=>{E.current?.editor.setTheme(a)},[a],u),jt(()=>{k.current?.updateOptions(c)},[c],u);let T=_.useCallback(()=>{if(!E.current)return;A.current(E.current);let I=zs(E.current,e||"",o||r||"text",m||""),z=zs(E.current,s||"",p||r||"text",x||"");k.current?.setModel({original:I,modified:z})},[r,s,p,e,o,m,x]),P=_.useCallback(()=>{!D.current&&w.current&&(k.current=E.current.editor.createDiffEditor(w.current,{automaticLayout:!0,...c}),T(),E.current?.editor.setTheme(a),f(!0),D.current=!0)},[c,a,T]);_.useEffect(()=>{u&&j.current(k.current,E.current)},[u]),_.useEffect(()=>{!S&&!u&&P()},[S,u,P]);function F(){let I=k.current?.getModel();i||I?.original?.dispose(),n||I?.modified?.dispose(),k.current?.dispose()}return ue.createElement(lc,{width:v,height:g,isEditorReady:u,loading:d,_ref:w,className:b,wrapperProps:y})}var Dg=Mg;_.memo(Dg);function Pg(e){let s=_.useRef();return _.useEffect(()=>{s.current=e},[e]),s.current}var Lg=Pg,Yr=new Map;function Ig({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:p,path:m,theme:x="light",line:i,loading:n="Loading...",options:a={},overrideServices:d={},saveViewState:c=!0,keepCurrentModel:g=!1,width:v="100%",height:b="100%",className:y,wrapperProps:l={},beforeMount:h=vr,onMount:u=vr,onChange:f,onValidate:S=vr}){let[C,k]=_.useState(!1),[E,w]=_.useState(!0),j=_.useRef(null),A=_.useRef(null),D=_.useRef(null),T=_.useRef(u),P=_.useRef(h),F=_.useRef(),I=_.useRef(o),z=Lg(m),$=_.useRef(!1),R=_.useRef(!1);cc(()=>{let O=ac.init();return O.then(q=>(j.current=q)&&w(!1)).catch(q=>q?.type!=="cancelation"&&console.error("Monaco initialization: error:",q)),()=>A.current?M():O.cancel()}),jt(()=>{let O=zs(j.current,e||o||"",s||p||"",m||r||"");O!==A.current?.getModel()&&(c&&Yr.set(z,A.current?.saveViewState()),A.current?.setModel(O),c&&A.current?.restoreViewState(Yr.get(m)))},[m],C),jt(()=>{A.current?.updateOptions(a)},[a],C),jt(()=>{!A.current||o===void 0||(A.current.getOption(j.current.editor.EditorOption.readOnly)?A.current.setValue(o):o!==A.current.getValue()&&(R.current=!0,A.current.executeEdits("",[{range:A.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),A.current.pushUndoStop(),R.current=!1))},[o],C),jt(()=>{let O=A.current?.getModel();O&&p&&j.current?.editor.setModelLanguage(O,p)},[p],C),jt(()=>{i!==void 0&&A.current?.revealLine(i)},[i],C),jt(()=>{j.current?.editor.setTheme(x)},[x],C);let L=_.useCallback(()=>{if(!(!D.current||!j.current)&&!$.current){P.current(j.current);let O=m||r,q=zs(j.current,o||e||"",s||p||"",O||"");A.current=j.current?.editor.create(D.current,{model:q,automaticLayout:!0,...a},d),c&&A.current.restoreViewState(Yr.get(O)),j.current.editor.setTheme(x),i!==void 0&&A.current.revealLine(i),k(!0),$.current=!0}},[e,s,r,o,p,m,a,d,c,x,i]);_.useEffect(()=>{C&&T.current(A.current,j.current)},[C]),_.useEffect(()=>{!E&&!C&&L()},[E,C,L]),I.current=o,_.useEffect(()=>{C&&f&&(F.current?.dispose(),F.current=A.current?.onDidChangeModelContent(O=>{R.current||f(A.current.getValue(),O)}))},[C,f]),_.useEffect(()=>{if(C){let O=j.current.editor.onDidChangeMarkers(q=>{let V=A.current.getModel()?.uri;if(V&&q.find(H=>H.path===V.path)){let H=j.current.editor.getModelMarkers({resource:V});S?.(H)}});return()=>{O?.dispose()}}return()=>{}},[C,S]);function M(){F.current?.dispose(),g?c&&Yr.set(m,A.current.saveViewState()):A.current.getModel()?.dispose(),A.current.dispose()}return ue.createElement(lc,{width:v,height:b,isEditorReady:C,loading:n,_ref:D,className:y,wrapperProps:l})}var Og=Ig,Bg=_.memo(Og),Fg=Bg,Dt=function(e,s){return Number(e.toFixed(s))},zg=function(e,s){return typeof e=="number"?e:s},Qe=function(e,s,r){r&&typeof r=="function"&&r(e,s)},Wg=function(e){return-Math.cos(e*Math.PI)/2+.5},Hg=function(e){return e},Ug=function(e){return e*e},$g=function(e){return e*(2-e)},Kg=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},qg=function(e){return e*e*e},Vg=function(e){return--e*e*e+1},Yg=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Xg=function(e){return e*e*e*e},Gg=function(e){return 1- --e*e*e*e},Qg=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Zg=function(e){return e*e*e*e*e},Jg=function(e){return 1+--e*e*e*e*e},ev=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},uc={easeOut:Wg,linear:Hg,easeInQuad:Ug,easeOutQuad:$g,easeInOutQuad:Kg,easeInCubic:qg,easeOutCubic:Vg,easeInOutCubic:Yg,easeInQuart:Xg,easeOutQuart:Gg,easeInOutQuart:Qg,easeInQuint:Zg,easeOutQuint:Jg,easeInOutQuint:ev},hc=function(e){typeof e=="number"&&cancelAnimationFrame(e)},zt=function(e){e.mounted&&(hc(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function fc(e,s,r,o){if(e.mounted){var p=new Date().getTime(),m=1;zt(e),e.animation=function(){if(!e.mounted)return hc(e.animation);var x=new Date().getTime()-p,i=x/r,n=uc[s],a=n(i);x>=r?(o(m),e.animation=null):e.animation&&(o(a),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function tv(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function vs(e,s,r,o){var p=tv(s);if(!(!e.mounted||!p)){var m=e.setTransformState,x=e.transformState,i=x.scale,n=x.positionX,a=x.positionY,d=s.scale-i,c=s.positionX-n,g=s.positionY-a;r===0?m(s.scale,s.positionX,s.positionY):fc(e,o,r,function(v){var b=i+d*v,y=n+c*v,l=a+g*v;m(b,y,l)})}}function sv(e,s,r){var o=e.offsetWidth,p=e.offsetHeight,m=s.offsetWidth,x=s.offsetHeight,i=m*r,n=x*r,a=o-i,d=p-n;return{wrapperWidth:o,wrapperHeight:p,newContentWidth:i,newDiffWidth:a,newContentHeight:n,newDiffHeight:d}}var rv=function(e,s,r,o,p,m,x){var i=e>s?r*(x?1:.5):0,n=o>p?m*(x?1:.5):0,a=e-s-i,d=i,c=o-p-n,g=n;return{minPositionX:a,maxPositionX:d,minPositionY:c,maxPositionY:g}},co=function(e,s){var r=e.wrapperComponent,o=e.contentComponent,p=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var m=sv(r,o,s),x=m.wrapperWidth,i=m.wrapperHeight,n=m.newContentWidth,a=m.newDiffWidth,d=m.newContentHeight,c=m.newDiffHeight,g=rv(x,n,a,i,d,c,!!p);return g},Cn=function(e,s,r,o){return o?e<s?Dt(s,2):e>r?Dt(r,2):Dt(e,2):Dt(e,2)},ks=function(e,s){var r=co(e,s);return e.bounds=r,r};function Mr(e,s,r,o,p,m,x){var i=r.minPositionX,n=r.minPositionY,a=r.maxPositionX,d=r.maxPositionY,c=0,g=0;x&&(c=p,g=m);var v=Cn(e,i-c,a+c,o),b=Cn(s,n-g,d+g,o);return{x:v,y:b}}function Ni(e,s,r,o,p,m){var x=e.transformState,i=x.scale,n=x.positionX,a=x.positionY,d=o-i;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:n,y:a};var c=n-s*d,g=a-r*d,v=Mr(c,g,p,m,0,0,null);return v}function Dr(e,s,r,o,p){var m=p?o:0,x=s-m;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=x?x:e}var pa=function(e,s){var r=e.setup.panning.excluded,o=e.isInitialized,p=e.wrapperComponent,m=s.target,x="shadowRoot"in m&&"composedPath"in s,i=x?s.composedPath().some(function(d){return d instanceof Element?p?.contains(d):!1}):p?.contains(m),n=o&&m&&i;if(!n)return!1;var a=Ri(m,r);return!a},ga=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,p=o.panning.disabled,m=s&&r&&!p;return!!m},iv=function(e,s){var r=e.transformState,o=r.positionX,p=r.positionY;e.isPanning=!0;var m=s.clientX,x=s.clientY;e.startCoords={x:m-o,y:x-p}},nv=function(e,s){var r=s.touches,o=e.transformState,p=o.positionX,m=o.positionY;e.isPanning=!0;var x=r.length===1;if(x){var i=r[0].clientX,n=r[0].clientY;e.startCoords={x:i-p,y:n-m}}};function ov(e){var s=e.transformState,r=s.positionX,o=s.positionY,p=s.scale,m=e.setup,x=m.disabled,i=m.limitToBounds,n=m.centerZoomedOut,a=e.wrapperComponent;if(!(x||!a||!e.bounds)){var d=e.bounds,c=d.maxPositionX,g=d.minPositionX,v=d.maxPositionY,b=d.minPositionY,y=r>c||r<g,l=o>v||o<b,h=r>c?a.offsetWidth:e.setup.minPositionX||0,u=o>v?a.offsetHeight:e.setup.minPositionY||0,f=Ni(e,h,u,p,e.bounds,i||n),S=f.x,C=f.y;return{scale:p,positionX:y?S:r,positionY:l?C:o}}}function mc(e,s,r,o,p){var m=e.setup.limitToBounds,x=e.wrapperComponent,i=e.bounds,n=e.transformState,a=n.scale,d=n.positionX,c=n.positionY;if(!(x===null||i===null||s===d&&r===c)){var g=Mr(s,r,i,m,o,p,x),v=g.x,b=g.y;e.setTransformState(a,v,b)}}var av=function(e,s,r){var o=e.startCoords,p=e.transformState,m=e.setup.panning,x=m.lockAxisX,i=m.lockAxisY,n=p.positionX,a=p.positionY;if(!o)return{x:n,y:a};var d=s-o.x,c=r-o.y,g=x?n:d,v=i?a:c;return{x:g,y:v}},gs=function(e,s){var r=e.setup,o=e.transformState,p=o.scale,m=r.minScale,x=r.disablePadding;return s>0&&p>=m&&!x?s:0},lv=function(e){var s=e.mounted,r=e.setup,o=r.disabled,p=r.velocityAnimation,m=e.transformState.scale,x=p.disabled,i=!x||m>1||!o||s;return!!i},cv=function(e){var s=e.mounted,r=e.velocity,o=e.bounds,p=e.setup,m=p.disabled,x=p.velocityAnimation,i=e.transformState.scale,n=x.disabled,a=!n||i>1||!m||s;return!(!a||!r||!o)};function dv(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,p=r.animationTime,m=r.sensitivity;return o?p*s*m:p}function va(e,s,r,o,p,m,x,i,n,a){if(p){if(s>x&&r>x){var d=x+(e-x)*a;return d>n?n:d<x?x:d}if(s<m&&r<m){var d=m+(e-m)*a;return d<i?i:d>m?m:d}}return o?s:Cn(e,m,x,p)}function uv(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function hv(e,s){var r=lv(e);if(r){var o=e.lastMousePosition,p=e.velocityTime,m=e.setup,x=e.wrapperComponent,i=m.velocityAnimation.equalToMove,n=Date.now();if(o&&p&&x){var a=uv(x,i),d=s.x-o.x,c=s.y-o.y,g=d/a,v=c/a,b=n-p,y=d*d+c*c,l=Math.sqrt(y)/b;e.velocity={velocityX:g,velocityY:v,total:l}}e.lastMousePosition=s,e.velocityTime=n}}function fv(e){var s=e.velocity,r=e.bounds,o=e.setup,p=e.wrapperComponent,m=cv(e);if(!(!m||!s||!r||!p)){var x=s.velocityX,i=s.velocityY,n=s.total,a=r.maxPositionX,d=r.minPositionX,c=r.maxPositionY,g=r.minPositionY,v=o.limitToBounds,b=o.alignmentAnimation,y=o.zoomAnimation,l=o.panning,h=l.lockAxisY,u=l.lockAxisX,f=y.animationType,S=b.sizeX,C=b.sizeY,k=b.velocityAlignmentTime,E=k,w=dv(e,n),j=Math.max(w,E),A=gs(e,S),D=gs(e,C),T=A*p.offsetWidth/100,P=D*p.offsetHeight/100,F=a+T,I=d-T,z=c+P,$=g-P,R=e.transformState,L=new Date().getTime();fc(e,f,j,function(M){var O=e.transformState,q=O.scale,V=O.positionX,H=O.positionY,W=new Date().getTime()-L,U=W/E,N=uc[b.animationType],B=1-N(Math.min(1,U)),K=1-M,Y=V+x*K,J=H+i*K,G=va(Y,R.positionX,V,u,v,d,a,I,F,B),de=va(J,R.positionY,H,h,v,g,c,$,z,B);(V!==Y||H!==J)&&e.setTransformState(q,G,de)})}}function xa(e,s){var r=e.transformState.scale;zt(e),ks(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?nv(e,s):iv(e,s)}function uo(e,s){var r=e.transformState.scale,o=e.setup,p=o.minScale,m=o.alignmentAnimation,x=m.disabled,i=m.sizeX,n=m.sizeY,a=m.animationTime,d=m.animationType,c=x||r<p||!i&&!n;if(!c){var g=ov(e);g&&vs(e,g,s??a,d)}}function ba(e,s,r){var o=e.startCoords,p=e.setup,m=p.alignmentAnimation,x=m.sizeX,i=m.sizeY;if(o){var n=av(e,s,r),a=n.x,d=n.y,c=gs(e,x),g=gs(e,i);hv(e,{x:a,y:d}),mc(e,a,d,c,g)}}function mv(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,o=e.wrapperComponent,p=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var m=o?.getBoundingClientRect(),x=p?.getBoundingClientRect(),i=m?.width||0,n=m?.height||0,a=x?.width||0,d=x?.height||0,c=i<a||n<d,g=!s&&r&&r?.total>.1&&c;g?fv(e):uo(e)}}function ho(e,s,r,o){var p=e.setup,m=p.minScale,x=p.maxScale,i=p.limitToBounds,n=Dr(Dt(s,2),m,x,0,!1),a=ks(e,n),d=Ni(e,r,o,n,a,i),c=d.x,g=d.y;return{scale:n,positionX:c,positionY:g}}function pc(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,x=m.minScale,i=m.limitToBounds,n=m.zoomAnimation,a=n.disabled,d=n.animationTime,c=n.animationType,g=a||o>=x;if((o>=1||i)&&uo(e),!(g||!p||!e.mounted)){var v=s||p.offsetWidth/2,b=r||p.offsetHeight/2,y=ho(e,x,v,b);y&&vs(e,y,d,c)}}var ms=function(){return ms=Object.assign||function(s){for(var r,o=1,p=arguments.length;o<p;o++){r=arguments[o];for(var m in r)Object.prototype.hasOwnProperty.call(r,m)&&(s[m]=r[m])}return s},ms.apply(this,arguments)};function _a(e,s,r){for(var o=0,p=s.length,m;o<p;o++)(m||!(o in s))&&(m||(m=Array.prototype.slice.call(s,0,o)),m[o]=s[o]);return e.concat(m||Array.prototype.slice.call(s))}var Xr={scale:1,positionX:0,positionY:0},lr={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,wheel:{step:.2,disabled:!1,smoothStep:.001,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,wheelPanning:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},kn={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},gc=function(e){var s,r,o,p;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:Xr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:Xr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:Xr.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:Xr.positionY}},ya=function(e){var s=ms({},lr);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",p=typeof lr[r]<"u";if(p&&o){var m=Object.prototype.toString.call(lr[r]),x=m==="[object Object]",i=m==="[object Array]";x?s[r]=ms(ms({},lr[r]),e[r]):i?s[r]=_a(_a([],lr[r],!0),e[r]):s[r]=e[r]}}),s},vc=function(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,x=m.maxScale,i=m.minScale,n=m.zoomAnimation,a=m.smooth,d=n.size;if(!p)throw new Error("Wrapper is not mounted");var c=a?o*Math.exp(s*r):o+s*r,g=Dr(Dt(c,3),i,x,d,!1);return g};function xc(e,s,r,o,p){var m=e.wrapperComponent,x=e.transformState,i=x.scale,n=x.positionX,a=x.positionY;if(!m)return console.error("No WrapperComponent found");var d=m.offsetWidth,c=m.offsetHeight,g=(d/2-n)/i,v=(c/2-a)/i,b=vc(e,s,r),y=ho(e,b,g,v);if(!y)return console.error("Error during zoom event. New transformation state was not calculated.");vs(e,y,o,p)}function bc(e,s,r,o){var p=e.setup,m=e.wrapperComponent,x=p.limitToBounds,i=gc(e.props),n=e.transformState,a=n.scale,d=n.positionX,c=n.positionY;if(m){var g=co(e,i.scale),v=Mr(i.positionX,i.positionY,g,x,0,0,m),b={scale:i.scale,positionX:v.x,positionY:v.y};a===i.scale&&d===i.positionX&&c===i.positionY||(o?.(),vs(e,b,s,r))}}function pv(e,s,r,o){var p=e.getBoundingClientRect(),m=s.getBoundingClientRect(),x=r.getBoundingClientRect(),i=m.x*o.scale,n=m.y*o.scale;return{x:(p.x-x.x+i)/o.scale,y:(p.y-x.y+n)/o.scale}}function gv(e,s,r){var o=e.wrapperComponent,p=e.contentComponent,m=e.transformState,x=e.setup,i=x.limitToBounds,n=x.minScale,a=x.maxScale;if(!o||!p)return m;var d=o.getBoundingClientRect(),c=s.getBoundingClientRect(),g=pv(s,o,p,m),v=g.x,b=g.y,y=c.width/m.scale,l=c.height/m.scale,h=o.offsetWidth/y,u=o.offsetHeight/l,f=Dr(r||Math.min(h,u),n,a,0,!1),S=(d.width-y*f)/2,C=(d.height-l*f)/2,k=(d.left-v)*f+S,E=(d.top-b)*f+C,w=co(e,f),j=Mr(k,E,w,i,0,0,o),A=j.x,D=j.y;return{positionX:A,positionY:D,scale:f}}var vv=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),xc(e,1,s,r,o)}},xv=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),xc(e,-1,s,r,o)}},bv=function(e){return function(s,r,o,p,m){p===void 0&&(p=300),m===void 0&&(m="easeOut");var x=e.transformState,i=x.positionX,n=x.positionY,a=x.scale,d=e.wrapperComponent,c=e.contentComponent,g=e.setup.disabled;if(!(g||!d||!c)){var v={positionX:Number.isNaN(s)?i:s,positionY:Number.isNaN(r)?n:r,scale:Number.isNaN(o)?a:o};vs(e,v,p,m)}}},_v=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),bc(e,s,r)}},yv=function(e){return function(s,r,o){r===void 0&&(r=200),o===void 0&&(o="easeOut");var p=e.transformState,m=e.wrapperComponent,x=e.contentComponent;if(m&&x){var i=_c(s||p.scale,m,x);vs(e,i,r,o)}}},Sv=function(e){return function(s,r,o,p){o===void 0&&(o=600),p===void 0&&(p="easeOut"),zt(e);var m=e.wrapperComponent,x=typeof s=="string"?document.getElementById(s):s;if(m&&x&&m.contains(x)){var i=gv(e,x,r);vs(e,i,o,p)}}},fi=function(e){return{instance:e,zoomIn:vv(e),zoomOut:xv(e),setTransform:bv(e),resetTransform:_v(e),centerView:yv(e),zoomToElement:Sv(e)}},En=function(e){return{instance:e,state:e.transformState}},Ve=function(e){var s={};return Object.assign(s,En(e)),Object.assign(s,fi(e)),s},tn=!1;function sn(){try{var e={get passive(){return tn=!0,!1}};return e}catch{return tn=!1,tn}}var Gr=".".concat(kn.wrapperClass),Ri=function(e,s){return s.some(function(r){return e.matches("".concat(Gr," ").concat(r,", ").concat(Gr," .").concat(r,", ").concat(Gr," ").concat(r," *, ").concat(Gr," .").concat(r," *"))})},jn=function(e){e&&clearTimeout(e)},wv=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},_c=function(e,s,r){var o=r.offsetWidth*e,p=r.offsetHeight*e,m=(s.offsetWidth-o)/2,x=(s.offsetHeight-p)/2;return{scale:e,positionX:m,positionY:x}};function Cv(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var kv=function(e,s){var r=e.setup.wheel,o=r.disabled,p=r.wheelDisabled,m=r.touchPadDisabled,x=r.excluded,i=e.isInitialized,n=e.isPanning,a=s.target,d=i&&!n&&!o&&a;if(!d||p&&!s.ctrlKey||m&&s.ctrlKey)return!1;var c=Ri(a,x);return!c},Ev=function(e){return e?e.deltaY<0?1:-1:0};function jv(e,s){var r=Ev(e),o=zg(s,r);return o}function yc(e,s,r){var o=s.getBoundingClientRect(),p=0,m=0;if("clientX"in e)p=(e.clientX-o.left)/r,m=(e.clientY-o.top)/r;else{var x=e.touches[0];p=(x.clientX-o.left)/r,m=(x.clientY-o.top)/r}return(Number.isNaN(p)||Number.isNaN(m))&&console.error("No mouse or touch offset found"),{x:p,y:m}}var Nv=function(e,s,r,o,p){var m=e.transformState.scale,x=e.wrapperComponent,i=e.setup,n=i.maxScale,a=i.minScale,d=i.zoomAnimation,c=i.disablePadding,g=d.size,v=d.disabled;if(!x)throw new Error("Wrapper is not mounted");var b=m+s*r,y=o?!1:!v,l=Dr(Dt(b,3),a,n,g,y&&!c);return l},Rv=function(e,s){var r=e.previousWheelEvent,o=e.transformState.scale,p=e.setup,m=p.maxScale,x=p.minScale;return r?o<m||o>x||Math.sign(r.deltaY)!==Math.sign(s.deltaY)||r.deltaY>0&&r.deltaY<s.deltaY||r.deltaY<0&&r.deltaY>s.deltaY||Math.sign(r.deltaY)!==Math.sign(s.deltaY):!1},Av=function(e,s){var r=e.setup.pinch,o=r.disabled,p=r.excluded,m=e.isInitialized,x=s.target,i=m&&!o&&x;if(!i)return!1;var n=Ri(x,p);return!n},Tv=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,p=r&&!s&&o;return!!p},Mv=function(e,s,r){var o=r.getBoundingClientRect(),p=e.touches,m=Dt(p[0].clientX-o.left,5),x=Dt(p[0].clientY-o.top,5),i=Dt(p[1].clientX-o.left,5),n=Dt(p[1].clientY-o.top,5);return{x:(m+i)/2/s,y:(x+n)/2/s}},Sc=function(e){return Math.sqrt(Math.pow(e.touches[0].pageX-e.touches[1].pageX,2)+Math.pow(e.touches[0].pageY-e.touches[1].pageY,2))},Dv=function(e,s){var r=e.pinchStartScale,o=e.pinchStartDistance,p=e.setup,m=p.maxScale,x=p.minScale,i=p.zoomAnimation,n=p.disablePadding,a=i.size,d=i.disabled;if(!r||o===null||!s)throw new Error("Pinch touches distance was not provided");if(s<0)return e.transformState.scale;var c=s/o,g=c*r;return Dr(Dt(g,2),x,m,a,!d&&!n)},Pv=160,Lv=100,Iv=function(e,s){var r=e.props,o=r.onWheelStart,p=r.onZoomStart;e.wheelStopEventTimer||(zt(e),Qe(Ve(e),s,o),Qe(Ve(e),s,p))},Ov=function(e,s){var r=e.props,o=r.onWheel,p=r.onZoom,m=e.contentComponent,x=e.setup,i=e.transformState,n=i.scale,a=x.limitToBounds,d=x.centerZoomedOut,c=x.zoomAnimation,g=x.wheel,v=x.disablePadding,b=x.smooth,y=c.size,l=c.disabled,h=g.step,u=g.smoothStep;if(!m)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var f=jv(s,null),S=b?u*Math.abs(s.deltaY):h,C=Nv(e,f,S,!s.ctrlKey);if(n!==C){var k=ks(e,C),E=yc(s,m,n),w=l||y===0||d||v,j=a&&w,A=Ni(e,E.x,E.y,C,k,j),D=A.x,T=A.y;e.previousWheelEvent=s,e.setTransformState(C,D,T),Qe(Ve(e),s,o),Qe(Ve(e),s,p)}},Bv=function(e,s){var r=e.props,o=r.onWheelStop,p=r.onZoomStop;jn(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(pc(e,s.x,s.y),e.wheelAnimationTimer=null)},Lv);var m=Rv(e,s);m&&(jn(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Qe(Ve(e),s,o),Qe(Ve(e),s,p))},Pv))},wc=function(e){for(var s=0,r=0,o=0;o<2;o+=1)s+=e.touches[o].clientX,r+=e.touches[o].clientY;var p=s/2,m=r/2;return{x:p,y:m}},Fv=function(e,s){var r=Sc(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=wc(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,zt(e)},zv=function(e,s){var r=e.contentComponent,o=e.pinchStartDistance,p=e.wrapperComponent,m=e.transformState.scale,x=e.setup,i=x.limitToBounds,n=x.centerZoomedOut,a=x.zoomAnimation,d=x.alignmentAnimation,c=a.disabled,g=a.size;if(!(o===null||!r)){var v=Mv(s,m,r);if(!(!Number.isFinite(v.x)||!Number.isFinite(v.y))){var b=Sc(s),y=Dv(e,b),l=wc(s),h=l.x-(e.pinchLastCenterX||0),u=l.y-(e.pinchLastCenterY||0);if(!(y===m&&h===0&&u===0)){e.pinchLastCenterX=l.x,e.pinchLastCenterY=l.y;var f=ks(e,y),S=c||g===0||n,C=i&&S,k=Ni(e,v.x,v.y,y,f,C),E=k.x,w=k.y;e.pinchMidpoint=v,e.lastDistance=b;var j=d.sizeX,A=d.sizeY,D=gs(e,j),T=gs(e,A),P=E+h,F=w+u,I=Mr(P,F,f,i,D,T,p),z=I.x,$=I.y;e.setTransformState(y,z,$)}}}},Wv=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,pc(e,s?.x,s?.y)},Cc=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;jn(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Qe(Ve(e),s,r)},o)},Hv=function(e,s){var r=e.props,o=r.onZoomStart,p=r.onZoom,m=e.setup.doubleClick,x=m.animationTime,i=m.animationType;Qe(Ve(e),s,o),bc(e,x,i,function(){return Qe(Ve(e),s,p)}),Cc(e,s)};function Uv(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function $v(e,s){var r=e.setup,o=e.doubleClickStopEventTimer,p=e.transformState,m=e.contentComponent,x=p.scale,i=e.props,n=i.onZoomStart,a=i.onZoom,d=r.doubleClick,c=d.disabled,g=d.mode,v=d.step,b=d.animationTime,y=d.animationType;if(!c&&!o){if(g==="reset")return Hv(e,s);if(!m)return console.error("No ContentComponent found");var l=Uv(g,e.transformState.scale),h=vc(e,l,v);if(x!==h){Qe(Ve(e),s,n);var u=yc(s,m,x),f=ho(e,h,u.x,u.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(Ve(e),s,a),vs(e,f,b,y),Cc(e,s)}}}var Kv=function(e,s){var r=e.isInitialized,o=e.setup,p=e.wrapperComponent,m=o.doubleClick,x=m.disabled,i=m.excluded,n=s.target,a=p?.contains(n),d=r&&n&&a&&!x;if(!d)return!1;var c=Ri(n,i);return!c},qv=(function(){function e(s){var r=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){r.initializeWindowEvents()},this.unmount=function(){r.cleanupWindowEvents()},this.update=function(o){r.props=o,ks(r,r.transformState.scale),r.setup=ya(o)},this.initializeWindowEvents=function(){var o,p,m=sn(),x=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,i=x?.defaultView;(p=r.wrapperComponent)===null||p===void 0||p.addEventListener("wheel",r.onWheelPanning,m),i?.addEventListener("mousedown",r.onPanningStart,m),i?.addEventListener("mousemove",r.onPanning,m),i?.addEventListener("mouseup",r.onPanningStop,m),x?.addEventListener("mouseleave",r.clearPanning,m),i?.addEventListener("keyup",r.setKeyUnPressed,m),i?.addEventListener("keydown",r.setKeyPressed,m)},this.cleanupWindowEvents=function(){var o,p,m=sn(),x=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,i=x?.defaultView;i?.removeEventListener("mousedown",r.onPanningStart,m),i?.removeEventListener("mousemove",r.onPanning,m),i?.removeEventListener("mouseup",r.onPanningStop,m),x?.removeEventListener("mouseleave",r.clearPanning,m),i?.removeEventListener("keyup",r.setKeyUnPressed,m),i?.removeEventListener("keydown",r.setKeyPressed,m),document.removeEventListener("mouseleave",r.clearPanning,m),zt(r),(p=r.observer)===null||p===void 0||p.disconnect()},this.handleInitializeWrapperEvents=function(o){var p=sn();o.addEventListener("wheel",r.onWheelZoom,p),o.addEventListener("dblclick",r.onDoubleClick,p),o.addEventListener("touchstart",r.onTouchPanningStart,p),o.addEventListener("touchmove",r.onTouchPanning,p),o.addEventListener("touchend",r.onTouchPanningStop,p)},this.handleInitialize=function(o,p){var m=!1,x=r.setup.centerOnInit,i=function(n,a){for(var d=0,c=n;d<c.length;d++){var g=c[d];if(g.target===a)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(n){n(Ve(r))}),r.observer=new ResizeObserver(function(n){if(i(n,o)||i(n,p))if(x&&!m){var a=p.offsetWidth,d=p.offsetHeight;(a>0||d>0)&&(m=!0,r.setCenter())}else zt(r),ks(r,r.transformState.scale),uo(r,0)}),r.observer.observe(o),r.observer.observe(p)},this.onWheelZoom=function(o){var p=r.setup.disabled;if(!p){var m=kv(r,o);if(m){var x=r.isPressingKeys(r.setup.wheel.activationKeys);x&&(Iv(r,o),Ov(r,o),Bv(r,o))}}},this.onWheelPanning=function(o){var p=r.setup,m=p.disabled,x=p.wheel,i=p.panning;if(!(!r.wrapperComponent||!r.contentComponent||m||!x.wheelDisabled||i.disabled||!i.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var n=r.transformState,a=n.positionX,d=n.positionY,c=a-o.deltaX,g=d-o.deltaY,v=i.lockAxisX?a:c,b=i.lockAxisY?d:g,y=r.setup.alignmentAnimation,l=y.sizeX,h=y.sizeY,u=gs(r,l),f=gs(r,h);v===a&&b===d||mc(r,v,b,u,f)}},this.onPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var x=pa(r,o);if(x){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(o.button===0&&!r.setup.panning.allowLeftClickPan||o.button===1&&!r.setup.panning.allowMiddleClickPan||o.button===2&&!r.setup.panning.allowRightClickPan||(o.preventDefault(),o.stopPropagation(),zt(r),xa(r,o),Qe(Ve(r),o,m)))}}},this.onPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(!p){var x=ga(r);if(x){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(o.preventDefault(),o.stopPropagation(),ba(r,o.clientX,o.clientY),Qe(Ve(r),o,m))}}},this.onPanningStop=function(o){var p=r.props.onPanningStop;r.isPanning&&(mv(r),Qe(Ve(r),o,p))},this.onPinchStart=function(o){var p=r.setup.disabled,m=r.props,x=m.onPinchingStart,i=m.onZoomStart;if(!p){var n=Av(r,o);n&&(Fv(r,o),zt(r),Qe(Ve(r),o,x),Qe(Ve(r),o,i))}},this.onPinch=function(o){var p=r.setup.disabled,m=r.props,x=m.onPinching,i=m.onZoom;if(!p){var n=Tv(r);n&&(o.preventDefault(),o.stopPropagation(),zv(r,o),Qe(Ve(r),o,x),Qe(Ve(r),o,i))}},this.onPinchStop=function(o){var p=r.props,m=p.onPinchingStop,x=p.onZoomStop;r.pinchStartScale&&(Wv(r),Qe(Ve(r),o,m),Qe(Ve(r),o,x))},this.onTouchPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var x=pa(r,o);if(x){var i=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!i){r.lastTouch=+new Date,zt(r);var n=o.touches,a=n.length===1,d=n.length===2;a&&(zt(r),xa(r,o),Qe(Ve(r),o,m)),d&&r.onPinchStart(o)}}}},this.onTouchPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(r.isPanning&&o.touches.length===1){if(p)return;var x=ga(r);if(!x)return;o.preventDefault(),o.stopPropagation();var i=o.touches[0];ba(r,i.clientX,i.clientY),Qe(Ve(r),o,m)}else o.touches.length>1&&r.onPinch(o)},this.onTouchPanningStop=function(o){r.onPanningStop(o),r.onPinchStop(o)},this.onDoubleClick=function(o){var p=r.setup.disabled;if(!p){var m=Kv(r,o);m&&$v(r,o)}},this.clearPanning=function(o){r.isPanning&&r.onPanningStop(o)},this.setKeyPressed=function(o){r.pressedKeys[o.key]=!0},this.setKeyUnPressed=function(o){r.pressedKeys[o.key]=!1},this.isPressingKeys=function(o){return o.length?!!o.find(function(p){return r.pressedKeys[p]}):!0},this.setTransformState=function(o,p,m){var x=r.props.onTransformed;if(!Number.isNaN(o)&&!Number.isNaN(p)&&!Number.isNaN(m)){o!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=o),r.transformState.positionX=p,r.transformState.positionY=m,r.applyTransformation();var i=Ve(r);r.onChangeCallbacks.forEach(function(n){return n(i)}),Qe(i,{scale:o,positionX:p,positionY:m},x)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var o=_c(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(o.scale,o.positionX,o.positionY)}},this.handleTransformStyles=function(o,p,m){return r.props.customTransform?r.props.customTransform(o,p,m):wv(o,p,m)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,p=o.scale,m=o.positionX,x=o.positionY,i=r.handleTransformStyles(m,x,p);r.contentComponent.style.transform=i}},this.getContext=function(){return Ve(r)},this.onChange=function(o){return r.onChangeCallbacks.has(o)||r.onChangeCallbacks.add(o),function(){r.onChangeCallbacks.delete(o)}},this.onInit=function(o){return r.onInitCallbacks.has(o)||r.onInitCallbacks.add(o),function(){r.onInitCallbacks.delete(o)}},this.init=function(o,p){r.cleanupWindowEvents(),r.wrapperComponent=o,r.contentComponent=p,ks(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,p),r.initializeWindowEvents(),r.isInitialized=!0;var m=Ve(r);Qe(m,void 0,r.props.onInit)},this.props=s,this.setup=ya(this.props),this.transformState=gc(this.props)}return e})(),Ai=ue.createContext(null),Vv=function(e,s){return typeof e=="function"?e(s):e},Yv=ue.forwardRef(function(e,s){var r=_.useRef(new qv(e)).current,o=Vv(e.children,fi(r));return _.useImperativeHandle(s,function(){return fi(r)},[r]),_.useEffect(function(){r.update(e)},[r,e]),ue.createElement(Ai.Provider,{value:r},o)});ue.forwardRef(function(e,s){var r=_.useRef(null),o=_.useContext(Ai);return _.useEffect(function(){return o.onChange(function(p){if(r.current){var m=0,x=0;r.current.style.transform=o.handleTransformStyles(m,x,1/p.instance.transformState.scale)}})},[o]),ue.createElement("div",ms({},e,{ref:Cv([r,s])}))});function Xv(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css",r==="top"&&o.firstChild?o.insertBefore(p,o.firstChild):o.appendChild(p),p.styleSheet?p.styleSheet.cssText=e:p.appendChild(document.createTextNode(e))}}var Gv=`.transform-component-module_wrapper__SPB86 {
|
|
35
|
+
position: relative;
|
|
36
|
+
width: -moz-fit-content;
|
|
37
|
+
width: fit-content;
|
|
38
|
+
height: -moz-fit-content;
|
|
39
|
+
height: fit-content;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
42
|
+
-webkit-user-select: none; /* Safari */
|
|
43
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
44
|
+
-moz-user-select: none; /* Firefox */
|
|
45
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
46
|
+
user-select: none;
|
|
47
|
+
margin: 0;
|
|
48
|
+
padding: 0;
|
|
49
|
+
transform: translate3d(0, 0, 0);
|
|
50
|
+
}
|
|
51
|
+
.transform-component-module_content__FBWxo {
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-wrap: wrap;
|
|
54
|
+
width: -moz-fit-content;
|
|
55
|
+
width: fit-content;
|
|
56
|
+
height: -moz-fit-content;
|
|
57
|
+
height: fit-content;
|
|
58
|
+
margin: 0;
|
|
59
|
+
padding: 0;
|
|
60
|
+
transform-origin: 0% 0%;
|
|
61
|
+
}
|
|
62
|
+
.transform-component-module_content__FBWxo img {
|
|
63
|
+
pointer-events: none;
|
|
64
|
+
}
|
|
65
|
+
`,Sa={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Xv(Gv);var Qv=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,p=e.contentClass,m=p===void 0?"":p,x=e.wrapperStyle,i=e.contentStyle,n=e.wrapperProps,a=n===void 0?{}:n,d=e.contentProps,c=d===void 0?{}:d,g=_.useContext(Ai),v=g.init,b=g.cleanupWindowEvents,y=_.useRef(null),l=_.useRef(null);return _.useEffect(function(){var h=y.current,u=l.current;return h!==null&&u!==null&&v&&v?.(h,u),function(){b?.()}},[]),ue.createElement("div",ms({},a,{ref:y,className:"".concat(kn.wrapperClass," ").concat(Sa.wrapper," ").concat(o),style:x}),ue.createElement("div",ms({},c,{ref:l,className:"".concat(kn.contentClass," ").concat(Sa.content," ").concat(m),style:i}),s))},kc=function(){var e=_.useContext(Ai);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Zv=function(){var e=kc();return fi(e)};function Jv(e){var s=kc(),r=_.useState(e(En(s))),o=r[0],p=r[1];return _.useEffect(function(){var m=!0,x=s.onChange(function(i){m&&p(e(En(i.instance)))});return function(){x(),m=!1}},[e,s]),o}function e0(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function t0(e,s){return Pt({queryKey:be.files.tree(e||"",s),queryFn:()=>Ae.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function s0(e,s){return Pt({queryKey:be.files.content(e||"",s||""),queryFn:()=>Ae.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function r0(e){const s=Lt();return _.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function i0(){const e=Lt();return kr({mutationFn:s=>Ae.post("/files/write",s),onSuccess:(s,r)=>{const o=be.files.content(r.workingDir,r.path),p=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:p?.language||e0(r.path)})}})}function n0(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function o0(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const a0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function l0(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&a0.has(s)?hl:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?ni:s==="json"?Pu:s==="md"||s==="mdx"||s==="txt"?Ja:Qd}const wa=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:p,label:m})=>t.jsxs("button",{type:"button",onClick:r,className:Z("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:p}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:m})]}),Ec=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:x})=>{const{t:i}=ce(),{data:n,isLoading:a,isError:d}=t0(e,s),c=_.useMemo(()=>n?.items??[],[n?.items]);return a?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Loading...")}):d?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(g=>{if(g.type==="directory"){const h=n0(s,g.name),u=o.has(h);return t.jsxs("div",{children:[t.jsx(wa,{depth:r,onClick:()=>p(h),rightIcon:u?t.jsx(Ct,{size:14,className:"text-neutral-400"}):t.jsx(Nt,{size:14,className:"text-neutral-400"}),leftIcon:u?t.jsx(bi,{size:14,className:"text-amber-500"}):t.jsx($n,{size:14,className:"text-amber-500"}),label:g.name}),u&&t.jsx(Ec,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:x})]},h)}const v=o0(s,g.name),b=l0(g),y=x===v,l=b===hl;return t.jsx(wa,{depth:r,active:y,onClick:()=>m(v),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:b?t.jsx(b,{size:14,className:l?"text-emerald-600":"text-sky-600"}):null,label:g.name},v)})})},c0=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=ce(),[x,i]=_.useState(()=>new Set),n=r0(e),a=_.useCallback(d=>{i(c=>{const g=new Set(c);return g.has(d)?g.delete(d):g.add(d),g})},[]);return t.jsxs("div",{className:Z("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:m("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||m("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:n,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Refresh file tree"),children:t.jsx(Rs,{size:13})}),p&&t.jsx("button",{type:"button",onClick:p,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Collapse file tree"),children:t.jsx(Hu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(Ec,{workingDir:e,path:"/",depth:0,expanded:x,toggleDir:a,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},d0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function u0(e){const s=e.split(".").pop()?.toLowerCase();return s?d0.has(s):!1}function h0(e,s){const r=Cr(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const f0=({filePath:e})=>{const{t:s}=ce(),{zoomIn:r,zoomOut:o,centerView:p}=Zv(),m=Jv(i=>i.state.scale),x=Math.round(m*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-neutral-200 bg-neutral-50/80 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>o(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(sh,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>p(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:s("Reset zoom"),children:[x,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(eh,{size:14})}),t.jsx("button",{type:"button",onClick:()=>p(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(zu,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},m0=({workingDir:e,filePath:s})=>{const{t:r}=ce(),[o,p]=_.useState(!1),m=h0(e,s);return o?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(Yv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(f0,{filePath:s}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx(Qv,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:m,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>p(!0)})})})]})})};function p0(e){const s=e.split("/");return s[s.length-1]||e}function g0(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}const v0=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=ce();return t.jsxs("button",{type:"button",onClick:o,className:Z("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[t.jsx("span",{className:Z("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:p,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":m("Close tab"),title:m("Close"),children:t.jsx(Xt,{size:12})})]})},x0=ue.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},p){const{t:m}=ce(),[x,i]=_.useState([]),[n,a]=_.useState(null),[d,c]=_.useState(!1),[g,v]=_.useState(!1),[b,y]=_.useState(0),[l,h]=_.useState(null),u=_.useRef(null),f=i0();_.useEffect(()=>{let H=!1;return Dd(async()=>{const{preloadMonaco:W}=await import("./monaco-CrBn9oMJ.js").then(U=>U.m);return{preloadMonaco:W}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:W})=>W()).then(()=>{H||c(!0)}).catch(()=>{H||v(!0)}),()=>{H=!0}},[]);const[S,C]=_.useState(280),[k,E]=_.useState(!1),[w,j]=_.useState(!1),A=_.useRef(280),D=_.useCallback(()=>{E(H=>(H?C(A.current):A.current=S,!H))},[S]),T=_.useCallback(H=>{H.preventDefault(),j(!0);const W=H.clientX,U=S,N=K=>{const Y=K.clientX-W,J=Math.min(480,Math.max(160,U+Y));C(J)},B=()=>{j(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",B)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",B)},[S]);_.useEffect(()=>{i([]),a(null),h(null)},[s]);const P=_.useMemo(()=>x.find(H=>H.path===n)||null,[x,n]),{data:F,isFetching:I,isError:z,error:$}=s0(s,P?.isImage?null:n);_.useEffect(()=>{!n||!F||i(H=>H.map(W=>W.path!==n||W.isDirty||W.loaded?W:{...W,language:F.language||W.language,content:F.content,savedContent:F.content,isDirty:!1,loaded:!0}))},[n,F]);const R=_.useCallback((H,W,U)=>{i(N=>{if(N.find(Y=>Y.path===H))return N;const K=u0(H);return[...N,{path:H,name:p0(H),language:g0(H),content:"",savedContent:"",isDirty:!1,loaded:K,isImage:K}]}),a(H),h(W?{path:H,line:W,column:U}:null)},[]);ue.useImperativeHandle(p,()=>({openFile:R}),[R]);const L=_.useCallback(H=>{i(W=>{const U=W.filter(N=>N.path!==H);return a(N=>N!==H?N:U.length?U[U.length-1].path:null),U})},[]),M=_.useCallback(H=>{i(W=>W.map(U=>{if(U.path!==n)return U;const N=H!==U.savedContent;return{...U,content:H,isDirty:N}}))},[n]),O=_.useCallback(async()=>{o||!s||!P||(await f.mutateAsync({workingDir:s,path:P.path,content:P.content}),i(H=>H.map(W=>W.path===P.path?{...W,savedContent:W.content,isDirty:!1,loaded:!0}:W)))},[P,o,f,s]),q=_.useRef(()=>{});_.useEffect(()=>{q.current=()=>{O().catch(()=>{})}},[O]),_.useEffect(()=>{const H=W=>{o||(W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="s"&&(W.preventDefault(),q.current())};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[o]);const V=_.useCallback((H,W)=>{u.current=H,y(U=>U+1),H.addCommand(W.KeyMod.CtrlCmd|W.KeyCode.KeyS,()=>{q.current()})},[]);return _.useEffect(()=>{if(!l||l.path!==n||!P?.loaded)return;const H=u.current,W=H?.getModel();if(!H||!W)return;const U=Math.min(l.line,W.getLineCount()),N=Math.min(l.column??1,W.getLineMaxColumn(U)),B={lineNumber:U,column:N};H.setPosition(B),H.revealPositionInCenter(B),H.focus(),h(null)},[n,P?.loaded,b,l]),t.jsxs("div",{className:Z("flex h-full overflow-hidden bg-white",r),style:w?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:k?36:S,transition:w?"none":"width 0.15s ease"},children:k?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:D,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:m("Expand file tree"),children:t.jsx($u,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(c0,{workingDir:s,onFileSelect:R,selectedFilePath:P?.path||null,onCollapse:D},s||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:T,className:Z("w-1 shrink-0 cursor-col-resize transition-colors",w?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[x.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:m("No open files")}):x.map(H=>t.jsx(v0,{active:H.path===n,name:H.name,isDirty:H.isDirty,onClick:()=>a(H.path),onClose:W=>{W.stopPropagation(),L(H.path)}},H.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[o&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:m("Read-only")}),f.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(Be,{size:14,className:"animate-spin"}),m("Saving")]}),P?.isDirty&&!f.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:m("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:s?P?P.isImage?t.jsx(m0,{workingDir:s,filePath:P.path}):g?t.jsx("div",{className:"h-full flex items-center justify-center text-red-600 text-sm",children:m("Failed to load editor.")}):d?t.jsxs(t.Fragment,{children:[t.jsx(Fg,{path:P.path,value:P.content,language:P.language,theme:"vs-light",height:"100%",onChange:o?void 0:H=>M(H??""),onMount:V,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:o}}),I&&!P.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(Be,{size:14,className:"animate-spin"}),m("Loading file...")]})}),z&&t.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1",children:[m("Failed to load file"),$ instanceof Error?`: ${$.message}`:""]})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),m("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("No workspace selected.")})})]})]})});function Ti(e,s={}){const r=Xs(p=>p.visibleContext),o=el(e,r);return Pt({queryKey:be.git.changes(e||""),queryFn:()=>Ae.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function jc(e,s,r){const o=Xs(m=>m.visibleContext),p=el(e,o);return Pt({queryKey:be.git.diff(e||"",s||"",r),queryFn:()=>Ae.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s,refetchInterval:p,refetchIntervalInBackground:!1,refetchOnWindowFocus:p?"always":!1,refetchOnReconnect:p?"always":!1})}function fo(e,s){return Pt({queryKey:be.git.commitFiles(e||"",s||""),queryFn:()=>Ae.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function mo(e,s,r){return Pt({queryKey:be.git.commitDiff(e||"",s||"",r||""),queryFn:()=>Ae.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}const b0=new Set(["STARTING","RUNNING","STOPPING"]);function Nc(e){return b0.has(e.runtimeState)||e.runtimeInstanceId!==null}function Rc(e){return e instanceof Er&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}function _0({services:e,isLoading:s,isError:r}){const{t:o}=ce();return s?t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(Be,{size:13,className:"animate-spin shrink-0","aria-hidden":"true"}),t.jsx("span",{children:o("正在检查后台服务...")})]}):e.length>0?t.jsxs("div",{className:"flex gap-2.5 rounded-md border border-amber-200 bg-amber-50 px-3 py-2.5 text-amber-900",children:[t.jsx(Ns,{size:16,className:"mt-0.5 shrink-0","aria-hidden":"true"}),t.jsxs("div",{className:"min-w-0 text-xs leading-relaxed",children:[t.jsx("p",{className:"font-medium",children:o("合并前将停止 {count} 个后台服务",{count:e.length})}),t.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-amber-800",children:e.map(p=>p.name).join(", ")}),t.jsx("p",{className:"mt-1 text-amber-700",children:o("停止后不会自动恢复。")})]})]}):r?t.jsx("p",{className:"text-xs text-amber-700",role:"status",children:o("无法检查后台服务状态,提交时会再次确认。")}):null}const y0={INVALID_BASE_BRANCH:"Choose an existing local branch different from the workspace branch.",BASE_BRANCH_UNRELATED:"The selected branch has no shared commit history with this workspace.",WORKSPACE_BASE_BRANCH_BUSY:"Wait for the Agent to finish or stop it before changing the base branch.",WORKSPACE_GIT_OPERATION_IN_PROGRESS:"Finish or abort the current Git operation before changing the base branch.",WORKSPACE_BASE_BRANCH_CHANGED:"The workspace changed. Refresh and select the base branch again.",INVALID_WORKSPACE_STATE:"Only active workspaces can change base branch. Refresh the list.",WORKSPACE_BASE_BRANCH_MANAGED:"TeamRun member base branches are managed by their parent workspace."};function Ac(e){return e.isOpen?t.jsx(S0,{...e},e.workspaceId):null}function S0({isOpen:e,onClose:s,onBaseBranchSaved:r,projectId:o,workspaceId:p,branchName:m,targetBranch:x,commitMessage:i,isPending:n,canMerge:a,activeServices:d,isCheckingServices:c,serviceCheckFailed:g,error:v,onConfirm:b}){const{t:y}=ce(),l=_.useId(),h=Ud(o),u=$d(),f=h.data?.workspaces.find(R=>R.id===p),S=f?.baseBranch||h.data?.mainBranch||x,[C,k]=_.useState(null),E=C??S,w=h.data?.branches.filter(R=>R!==m)??[],j=!!f&&E!==S,A=n||u.isPending,D=h.isPending||h.isFetching||h.isError,T=u.error instanceof Er?String(u.error.details.code):"",[P,F]=_.useState(null),I=P??i??"",z=()=>{A||s()},$=async()=>{if(!(!f||!j))try{await u.mutateAsync({id:p,baseBranch:E,expectedBaseBranch:f.baseBranch}),Je.success(y("Workspace base branch saved. Review the changes before merging.")),s(),r?.()}catch{}};return t.jsx(ps,{isOpen:e,onClose:z,title:y("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:z,disabled:A,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:y("取消")}),t.jsx("button",{onClick:()=>b(I.trim()||void 0,d.length>0),disabled:A||c||D||j||!a,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:n||c?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:14,className:"animate-spin"}),c?y("正在检查后台服务..."):d.length>0?y("正在停止服务并提交..."):y("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(ii,{size:14}),d.length>0?y("停止服务并提交"):y("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:m}),t.jsx(bl,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:f?S:x})]}),h.isPending?t.jsx("p",{className:"text-xs text-muted-foreground",children:y("Loading...")}):h.isError?t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:y("Could not load branches. Refresh to try again.")}),t.jsx(je,{size:"sm",variant:"outline",onClick:()=>{h.refetch()},children:y("Refresh")})]}):f&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:l,className:"block text-xs font-medium",children:y("Base branch for this workspace")}),t.jsx(Kd,{id:l,label:y("Base branch for this workspace"),value:E,branches:w,disabled:A,isRefreshing:h.isFetching,onOpen:()=>{h.refetch()},onChange:R=>{k(R),u.reset()}}),t.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:y("Changing this base branch updates the comparison, update and merge target for this workspace only. Save and review the changes before merging.")}),j&&t.jsx(je,{size:"sm",onClick:()=>{$()},disabled:A||D||!w.includes(E),children:u.isPending?y("Saving"):y("Save base branch and review changes")}),u.isError&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:y(y0[T]??"Could not save the base branch. Refresh and try again.")})]}),!a&&t.jsx("p",{className:"text-xs text-muted-foreground",children:y("Review the changes and sync the base branch before submitting.")}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:y("提交消息")}),t.jsx("textarea",{value:I,onChange:R=>F(R.target.value),placeholder:y("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:y("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!I.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:y("留空将使用默认消息")})]}),t.jsx(_0,{services:d,isLoading:c,isError:g}),v&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:v})]})})}function Os(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function Tc(e){if(!(e instanceof Er)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==xr.REBASE&&s.conflictOp!==xr.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(o=>typeof o=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:Os(s,"sourceBranch"),targetBranch:Os(s,"targetBranch"),sourceWorktreePath:Os(s,"sourceWorktreePath"),targetWorktreePath:Os(s,"targetWorktreePath"),sourceWorkspaceId:Os(s,"sourceWorkspaceId"),targetWorkspaceId:Os(s,"targetWorkspaceId")}}function Ca(e,s,r,o){const p=Tc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Mc({projectId:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,committedFileCount:m,onRefreshCommitMessage:x,onConflict:i,onResolveConflicts:n}){const{t:a}=ce(),{data:d,isLoading:c}=Ln(s),g=tl(),v=sl(),b=In(),[y,l]=_.useState(!1),[h,u]=_.useState(null),f=lo(s,y),S=(f.data??[]).filter(Nc);if(_.useEffect(()=>{y&&x?.()},[y,x]),c||!d)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:a("正在检查工作区状态...")})]});const C=d.conflictedFiles.length>0,k=d.operation!=="idle",E=d.hasUncommittedChanges||d.untrackedCount>0,w=d.uncommittedCount+d.untrackedCount,j=!C&&!k&&!E,A=d.operation==="idle"&&d.ahead===0&&d.behind===0&&!E&&!C,D=()=>{u(null),g.mutate(s,{onError:I=>{Ca(I,a("更新失败,请稍后重试"),z=>i(z),u)}})},T=()=>{u(null),l(!0)},P=(I,z)=>{u(null),v.mutate({id:s,commitMessage:I,stopActiveServices:z},{onSuccess:()=>l(!1),onError:$=>{if(Rc($)){u(a("后台服务仍在运行,请确认停止服务后再提交。"));return}Ca($,a("提交失败,请稍后重试"),R=>{l(!1),i(R)},u)}})},F=()=>{v.isPending||(l(!1),u(null))};return A?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Pd,{size:13}),t.jsx("span",{className:"text-xs",children:a("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[h&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:h}),E&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx(Ou,{size:12,className:"shrink-0"}),t.jsx("span",{children:a("{count} 个本地改动未处理,需要先整理后再继续",{count:w})})]}),C&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[t.jsx(Ns,{size:13,className:"shrink-0"}),t.jsx("span",{children:a("{count} 个文件存在冲突,需要处理后继续",{count:d.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:n,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:a("处理冲突")}),t.jsx("button",{onClick:()=>b.mutate(s),disabled:b.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:b.isPending?a("正在撤销..."):a("撤销操作")})]})]}),k&&!C&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-info",children:[t.jsx(Be,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:d.operation==="rebase"?a("正在同步源分支更新..."):a("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>b.mutate(s),disabled:b.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(Va,{size:12}),b.isPending?a("正在撤销..."):a("撤销操作")]})]}),!C&&!k&&(d.behind>0||d.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[d.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:a("源分支 {branch} 有 {count} 个更新",{branch:o,count:d.behind})}),t.jsxs("button",{onClick:D,disabled:!j||g.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Rs,{size:12}),g.isPending?a("正在同步..."):a("同步更新")]})]}),d.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:a("{count} 个文件变更,可以安全提交",{count:m??d.ahead})}),E?t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:a(E?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(ii,{size:12}),a("提交变更")]}):t.jsxs("button",{onClick:T,disabled:v.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(ii,{size:12}),a("提交变更")]})]})]})]})}),t.jsx(Ac,{projectId:e,workspaceId:s,canMerge:j&&d.ahead>0&&d.behind===0,isOpen:y,onClose:F,branchName:r,targetBranch:o,commitMessage:p,isPending:v.isPending,activeServices:S,isCheckingServices:f.isLoading,serviceCheckFailed:f.isError,error:h,onConfirm:P})]})}const rn=50,nn=400,ka={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"},Ea={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function Dc(e){const s=e.split("/");return s[s.length-1]||e}function w0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function C0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Tt("{count}s ago",{count:r}):r<3600?Tt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Tt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Tt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Zr(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const Nn=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:Z("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),k0=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:Z("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:Z("pl-2 whitespace-pre",o),children:e})]})},Pc=({diff:e})=>{const{t:s}=ce(),[r,o]=_.useState(!1),p=_.useMemo(()=>e.split(`
|
|
66
|
+
`),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:s("没有可显示的差异内容")});const m=!r&&p.length>nn,x=m?p.slice(0,nn):p;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[x.map((i,n)=>t.jsx(k0,{line:i,lineNum:n+1},n)),m&&t.jsx("button",{type:"button",onClick:()=>o(!0),className:"w-full py-2 text-xs text-info hover:bg-info/5 transition-colors",children:s("还有 {count} 行变更被折叠,点击展开全部",{count:p.length-nn})})]})},E0=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:p}=ce(),{data:m,isLoading:x,isError:i}=jc(e,o?s:null,r);return!o||x?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Pc,{diff:m?.diff||""})},j0=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:p}=ce(),{data:m,isLoading:x,isError:i}=mo(e,o?s:null,o?r:null);return!o||x?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Pc,{diff:m?.diff||""})},on=({entry:e,source:s,workingDir:r,flash:o,registerNode:p})=>{const[m,x]=_.useState(!1),[i,n]=_.useState(!1),a=_.useRef(null),d=Zr(s,e.path);_.useEffect(()=>(p(d,a.current),()=>p(d,null)),[d,p]),_.useEffect(()=>{const v=a.current;if(!v||i)return;const b=new IntersectionObserver(y=>{y.some(l=>l.isIntersecting)&&(n(!0),b.disconnect())},{rootMargin:"300px 0px"});return b.observe(v),()=>b.disconnect()},[i]);const c=ka[e.status]||ka.M,g=w0(e.path);return t.jsxs("div",{ref:a,"data-card-key":d,className:Z("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>x(v=>!v),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[m?t.jsx(Nt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Ct,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:Z("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",c),children:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:Dc(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(Nn,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(E0,{workingDir:r,path:e.path,diffType:s.diffType,enabled:i}):t.jsx(j0,{workingDir:r,hash:s.hash,path:e.path,enabled:i})})]})};function N0(e){const s={name:"",path:"",dirs:new Map,files:[]};for(const r of e){const o=r.path.split("/");let p=s;for(let m=0;m<o.length-1;m++){const x=o[m];p.dirs.has(x)||p.dirs.set(x,{name:x,path:p.path?`${p.path}/${x}`:x,dirs:new Map,files:[]}),p=p.dirs.get(x)}p.files.push(r)}return Lc(s)}function Lc(e){const s=new Map;for(const r of e.dirs.values()){let o=Lc(r);for(;o.dirs.size===1&&o.files.length===0;){const p=[...o.dirs.values()][0];o={...p,name:`${o.name}/${p.name}`}}s.set(o.name,o)}return{...e,dirs:s}}const R0=({dir:e,depth:s,activeKey:r,onSelect:o})=>{const[p,m]=_.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>m(x=>!x),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+s*12},children:[p?t.jsx(bi,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx($n,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),p&&t.jsx(Ic,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},Ic=({node:e,depth:s,activeKey:r,onSelect:o})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((p,m)=>p.name.localeCompare(m.name)).map(p=>t.jsx(R0,{dir:p,depth:s,activeKey:r,onSelect:o},p.path)),e.files.slice().sort((p,m)=>p.path.localeCompare(m.path)).map(p=>{const m=r===p.cardKey;return t.jsxs("button",{type:"button",onClick:()=>o(p),className:Z("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",m?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+s*12},title:p.path,children:[t.jsx("span",{className:Z("w-1.5 h-1.5 rounded-full shrink-0",Ea[p.status]||Ea.M)}),t.jsx("span",{className:Z("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:Dc(p.path)})]},p.cardKey)})]}),A0=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=ce(),{data:p,isLoading:m,fetchNextPage:x,hasNextPage:i,isFetchingNextPage:n}=Xn({queryKey:be.git.log(e),queryFn:({pageParam:d=0})=>Ae.get("/git/log",{params:{workingDir:e,limit:String(rn),skip:String(d)}}),initialPageParam:0,getNextPageParam:(d,c)=>d.commits.length<rn?void 0:c.length*rn}),a=p?.pages.flatMap(d=>d.commits)||[];return m?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(Be,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):a.length===0?t.jsx("div",{className:"px-3 py-2 text-[11px] text-muted-foreground/60",children:o("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[a.map(d=>{const c=s===d.hash;return t.jsxs("button",{type:"button",onClick:()=>r(d),className:Z("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",c?"bg-muted":"hover:bg-muted/60"),title:d.message,children:[t.jsx("span",{className:Z("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",c?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:Z("block text-xs truncate",c?"text-foreground font-medium":"text-foreground/90"),children:d.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:d.shortHash})," · ",d.author," · ",C0(d.timestamp)]})]})]},d.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>x(),disabled:n,className:"w-full py-1.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:n?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},T0=({projectId:e,workingDir:s,workspaceId:r,branchName:o,targetBranch:p,commitMessage:m,canRunGitOperations:x,onRefreshCommitMessage:i,onConflict:n,onResolveConflicts:a})=>{const{t:d}=ce(),[c,g]=_.useState({kind:"overview"}),[v,b]=_.useState(""),[y,l]=_.useState(null),[h,u]=_.useState(null),{data:f,isLoading:S,isError:C}=Ti(s),k=c.kind==="commit"?c.commit.hash:null,{data:E,isLoading:w}=fo(s,k),j=_.useRef(new Map),A=_.useRef(null),D=_.useRef(null),T=_.useCallback((W,U)=>{U?j.current.set(W,U):j.current.delete(W)},[]),{uncommitted:P,committed:F,commitFiles:I}=_.useMemo(()=>{const W=B=>!v.trim()||B.path.toLowerCase().includes(v.trim().toLowerCase());if(c.kind==="commit"){const B={kind:"commit",hash:c.commit.hash},K=(E?.files||[]).filter(W).map(Y=>({...Y,cardKey:Zr(B,Y.path)}));return{uncommitted:[],committed:[],commitFiles:K}}const U=(f?.uncommitted||[]).filter(W).map(B=>({...B,cardKey:Zr({kind:"working",diffType:"uncommitted"},B.path)})),N=(f?.committed||[]).filter(W).map(B=>({...B,cardKey:Zr({kind:"working",diffType:"committed"},B.path)}));return{uncommitted:U,committed:N,commitFiles:[]}},[c,f,E,v]),z=c.kind==="commit"?I:[...P,...F],$=_.useMemo(()=>N0(z),[z]),R=_.useMemo(()=>{let W=0,U=0;for(const N of z)W+=N.additions??0,U+=N.deletions??0;return{additions:W,deletions:U,files:z.length}},[z]),L=_.useCallback(()=>{const W=A.current;if(!W)return;const U=W.getBoundingClientRect().top;let N=null,B=Number.NEGATIVE_INFINITY;for(const[K,Y]of j.current){const J=Y.getBoundingClientRect().top-U;J<=48&&J>B&&(B=J,N=K)}if(!N){let K=null,Y=Number.POSITIVE_INFINITY;for(const[J,G]of j.current){const de=G.getBoundingClientRect().top-U;de<Y&&(Y=de,K=J)}N=K}l(N)},[]);_.useEffect(()=>{const W=A.current;if(!W)return;let U=0;const N=()=>{cancelAnimationFrame(U),U=requestAnimationFrame(L)};return W.addEventListener("scroll",N,{passive:!0}),()=>{W.removeEventListener("scroll",N),cancelAnimationFrame(U)}},[L]);const M=_.useCallback(W=>{const U=j.current.get(W.cardKey);U&&(U.scrollIntoView({behavior:"smooth",block:"start"}),l(W.cardKey),u(W.cardKey),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>u(null),1200))},[]),O=_.useCallback(W=>{g(U=>U.kind==="commit"&&U.commit.hash===W.hash?{kind:"overview"}:{kind:"commit",commit:W}),b(""),l(null),A.current?.scrollTo({top:0})},[]),q=_.useCallback(()=>{g({kind:"overview"}),b(""),l(null),A.current?.scrollTo({top:0})},[]);if(!s)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:d("未选择工作区")});const V=x&&e&&r&&o&&p,H=c.kind==="commit"?w:S;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[V&&n&&a&&t.jsx(Mc,{projectId:e,workspaceId:r,branchName:o,targetBranch:p,commitMessage:m,committedFileCount:f?.committed?.length,onRefreshCommitMessage:i,onConflict:n,onResolveConflicts:a}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:c.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Qs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:d("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:d("{count} 个文件",{count:R.files})}),t.jsx(Nn,{additions:R.additions,deletions:R.deletions}),o&&p&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground/70 font-mono truncate",children:[t.jsx("span",{className:"truncate",children:o}),t.jsx($s,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:p})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:q,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx($s,{size:12}),d("全部变更")]}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:c.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:c.commit.message}),t.jsx(Nn,{className:"ml-auto",additions:R.additions,deletions:R.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:A,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:H?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(W=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse rounded-sm"})]})]},W))}):C&&c.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:d("变更加载失败")}):z.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(ni,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:v.trim()?d("没有匹配筛选条件的文件"):c.kind==="commit"?d("该提交没有文件变更"):d("没有待审查的变更")})]}):c.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:I.map(W=>t.jsx(on,{entry:W,source:{kind:"commit",hash:c.commit.hash},workingDir:s,flash:h===W.cardKey,registerNode:T},W.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[P.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:d("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:P.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:P.map(W=>t.jsx(on,{entry:W,source:{kind:"working",diffType:"uncommitted"},workingDir:s,flash:h===W.cardKey,registerNode:T},W.cardKey))})]}),F.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:d("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:F.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:F.map(W=>t.jsx(on,{entry:W,source:{kind:"working",diffType:"committed"},workingDir:s,flash:h===W.cardKey,registerNode:T},W.cardKey))})]})]})}),t.jsxs("aside",{className:"shrink-0 border-l border-border flex flex-col min-h-0",style:{width:"clamp(15rem, 24%, 22rem)"},children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsxs("div",{className:"relative",children:[t.jsx(Hn,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:v,onChange:W=>b(W.target.value),placeholder:d("筛选文件..."),className:"w-full pl-6.5 pr-2 py-1.5 rounded-md border border-input bg-background text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:z.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:v.trim()?d("无匹配文件"):d("暂无变更文件")}):t.jsx(Ic,{node:$,depth:0,activeKey:y,onSelect:M})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(Vs,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:d("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(A0,{workingDir:s,selectedHash:k,onSelectCommit:O})})]})]})]})]})},an=50,ja={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function M0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Tt("{count}s ago",{count:r}):r<3600?Tt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Tt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Tt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function D0(e){const s=e.split("/");return s[s.length-1]||e}function P0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const L0=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:Z("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:Z("pl-2 whitespace-pre",o),children:e})]})},I0=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=ce(),{data:p,isLoading:m,isError:x}=mo(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(x)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:o("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/70 text-xs",children:o("No diff content available.")});const n=i.split(`
|
|
67
|
+
`);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:n.map((a,d)=>t.jsx(L0,{line:a,lineNum:d+1},d))})},O0=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:p}=ce(),{data:m,isLoading:x}=fo(e,s);if(x)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(Be,{size:12,className:"animate-spin"}),t.jsx("span",{children:p("Loading...")})]});const i=m?.files||[];return i.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:p("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:i.map(n=>{const a=ja[n.status]||ja.M,d=P0(n.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(n.path)},className:Z("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===n.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:Z("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",a),children:n.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:D0(n.path)}),d&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:d})]},n.path)})})},B0=({workingDir:e})=>{const{t:s}=ce(),r=Xs(E=>E.visibleContext),o=qd(e,r),{data:p,isLoading:m,isError:x,fetchNextPage:i,hasNextPage:n,isFetchingNextPage:a}=Xn({queryKey:be.git.log(e||""),queryFn:({pageParam:E=0})=>Ae.get("/git/log",{params:{workingDir:e||"",limit:String(an),skip:String(E)}}),initialPageParam:0,getNextPageParam:(E,w)=>E.commits.length<an?void 0:w.length*an,enabled:!!e,refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1}),d=p?.pages.flatMap(E=>E.commits)||[],[c,g]=_.useState(null),[v,b]=_.useState(null),[y,l]=_.useState(280),[h,u]=_.useState(!1),f=_.useCallback(E=>{E.preventDefault(),u(!0);const w=E.clientX,j=y,A=T=>{const P=Math.min(480,Math.max(180,j+(T.clientX-w)));l(P)},D=()=>{u(!1),document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",D)};document.addEventListener("mousemove",A),document.addEventListener("mouseup",D)},[y]),S=E=>{c===E?(g(null),b(null)):(g(E),b(null))},C=_.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:s("No workspace selected.")});if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(x)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-sm bg-background h-full",children:s("Failed to load history.")});if(d.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground/60 bg-background h-full",children:[t.jsx(Vs,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const k=d.find(E=>E.hash===c);return t.jsxs("div",{className:"flex h-full bg-background",style:h?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:y},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Vs,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:s("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:d.length})]})}),t.jsxs("div",{ref:C,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[d.map(E=>{const w=c===E.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>S(E.hash),className:Z("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",w?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:Z("w-2 h-2 rounded-full shrink-0 transition-colors",w?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:E.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:E.message}),t.jsx(Nt,{size:12,className:Z("shrink-0 text-muted-foreground/70 transition-transform",w&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:E.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:M0(E.timestamp)})]})]})]}),w&&t.jsxs(t.Fragment,{children:[E.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:E.body}),t.jsx(O0,{workingDir:e,hash:E.hash,selectedPath:v,onSelectFile:b})]})]},E.hash)}),n&&t.jsx("button",{type:"button",onClick:()=>i(),disabled:a,className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:a?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:f,className:Z("w-1 shrink-0 cursor-col-resize transition-colors",h?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:v&&c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border/60 flex items-center gap-2 shrink-0",children:[t.jsx(ni,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:v}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",k?.shortHash,")"]})]}),t.jsx(I0,{workingDir:e,hash:c,filePath:v})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/60",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(ni,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},Na=Cr();function F0(e){if(!Na)return e;try{const s=new URL(Na);return new URL(e,s.origin).toString()}catch{return e}}function Oc(e){return{...e,viewUrl:e.viewUrl?F0(e.viewUrl):null}}function z0(e,s=!0){return Pt({queryKey:be.previews.status(e??""),queryFn:async()=>{const r=await Ae.get(`/previews/${e}/status`);return Oc(r)},enabled:!!e&&s,refetchOnWindowFocus:!1})}function W0(e){const s=Lt();return kr({mutationFn:async r=>{const o=await Ae.put(`/previews/${e}/config`,{target:r});return Oc(o)},onSuccess:r=>{e&&(s.setQueryData(be.previews.status(e),r),s.invalidateQueries({queryKey:be.workspaces.all}))}})}function H0(){return window.location.protocol==="https:"?"remote":"local"}function U0(e,s,r=!0){const[o,p]=_.useState(null),[m,x]=_.useState(!1),[i,n]=_.useState(null),[a,d]=_.useState(0);return _.useEffect(()=>{if(!r||!e||!s?.ready||!s.target){p(null),x(!1),n(null);return}let c=!1,g=null,v=null;p(null);const b=l=>{Ae.delete(`/previews/${e}/sessions/${l}`).catch(()=>{})};return(async()=>{x(!0),n(null);try{const l={mode:H0(),localHostname:window.location.hostname},h=await Ae.post(`/previews/${e}/sessions`,l);if(c){b(h.id);return}g=h.id,p(h),v=window.setInterval(async()=>{if(g)try{const u=await Ae.post(`/previews/${e}/sessions/${g}/heartbeat`);c||(p(u),n(null))}catch(u){!c&&u instanceof Er&&u.status===404?d(f=>f+1):c||n(u instanceof Error?u:new Error("Preview session heartbeat failed"))}},3e4)}catch(l){c||(p(null),n(l instanceof Error?l:new Error("Failed to open preview session")))}finally{c||x(!1)}})(),()=>{c=!0,v!==null&&window.clearInterval(v),g&&b(g)}},[r,a,s?.ready,s?.target,e]),{session:o,isOpening:m,error:i,retry:()=>d(c=>c+1)}}const $0="agent-tower-preview",K0="agent-tower-preview-host";function q0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function V0(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function Y0(e){return t.jsx(X0,{...e},e.workspaceId??"no-workspace")}function X0({workspaceId:e,readOnly:s,navigationRequest:r,onNavigationRequestHandled:o}){const{t:p}=ce(),[m,x]=_.useState(null),n=!(r?.source.kind==="visualization")&&!m,{data:a,isLoading:d,refetch:c,isFetching:g}=z0(e,n),v=W0(e),{session:b,isOpening:y,error:l,retry:h}=U0(e,a,n),u=_.useRef(null),f=_.useRef(null),S=_.useRef(null),C=_.useRef(null),k=_.useRef(null),E=_.useRef(null),[w,j]=_.useState(0),[A,D]=_.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),T=V0(b?.viewUrl),P=a&&A.target!==a.target?{target:a.target,address:a.target??"",iframeSrc:null,isFrameLoading:!1}:a&&!a.ready&&A.iframeSrc?{...A,iframeSrc:null,isFrameLoading:!1}:A,F=_.useCallback(V=>{D(H=>({...a&&H.target!==a.target?{target:a.target,address:a.target??"",iframeSrc:null,isFrameLoading:!1}:H,...V}))},[a]);_.useEffect(()=>{if(!b||b.target!==a?.target)return;const V=k.current!==T;k.current=T,D(H=>{const W=r?.source.kind==="web"&&E.current!==r.id?$r(r.source.url,b.target,b.viewUrl):null;if(!V&&H.iframeSrc&&H.target===b.target&&W?.kind!=="proxy")return H;let U=H.iframeSrc;if(W?.kind==="proxy")U=W.url;else if(!U||H.target!==b.target||V){const B=S.current;if(B)U=cu(b.viewUrl,B);else{const K=$r(H.address||b.target,b.target,b.viewUrl);U=K?.kind==="proxy"?K.url:b.viewUrl}}S.current=null;const N=C.current;return N&&!N.closed&&U&&N.location.replace(U),C.current=null,{target:b.target,address:W?.kind==="proxy"?r?.source.kind==="web"?r.source.url:H.address:H.address||b.target,iframeSrc:U,isFrameLoading:!!U}})},[r,b,T,a?.target]),_.useEffect(()=>()=>{C.current?.close()},[]);const I=_.useCallback(async(V,H=!1)=>{const W=$r(V,a?.target??null,b?.viewUrl??null);if(!W||!e)return;if(x(null),W.kind==="proxy"){if(H){window.open(W.url,"_blank","noopener,noreferrer");return}D({target:a?.target??null,address:V,iframeSrc:W.url,isFrameLoading:!0});return}if(s)return;const U=H?window.open("about:blank","_blank"):null;U&&(U.opener=null);try{S.current=W.path,C.current=U;const N=await v.mutateAsync(W.target);D({target:N.target,address:V.trim(),iframeSrc:null,isFrameLoading:!!N.ready}),j(B=>B+1),Je.success(p("Preview target saved")),N.ready||(C.current?.close(),C.current=null)}catch(N){C.current?.close(),C.current=null,S.current=null;const B=N instanceof Error?N.message:p("Failed to save preview target");Je.error(B)}},[b?.viewUrl,s,a?.target,p,v,e]);_.useEffect(()=>{if(!r||E.current===r.id||r.source.kind==="web"&&d)return;const V=window.setTimeout(()=>{E.current=r.id,o?.(r.id),r.source.kind==="visualization"?(x({source:r.source,iframeSrc:du(r.source.sessionId,r.source.file),isFrameLoading:!0}),j(H=>H+1)):(x(null),I(r.source.url))},0);return()=>window.clearTimeout(V)},[d,I,r,o]),_.useEffect(()=>{if(m)return;const V=H=>{if(H.source!==u.current?.contentWindow)return;const W=H.data;if(!(!W||W.source!==$0)){if(W.type==="location"&&typeof W.href=="string"){const U=uu(a?.target??null,b?.viewUrl??null,W.href,window.location.href);U&&document.activeElement!==f.current&&F({target:a?.target??P.target,address:U,isFrameLoading:!1});return}W.type==="navigate-loopback"&&typeof W.href=="string"&&I(W.href,W.newTab===!0)}};return window.addEventListener("message",V),()=>window.removeEventListener("message",V)},[P.target,I,F,b?.viewUrl,a?.target,m]);const z=V=>{u.current?.contentWindow?.postMessage({source:K0,action:V},"*")},$=V=>{V.preventDefault(),I(P.address)},R=async()=>{if(m){x(H=>H&&{...H,isFrameLoading:!0}),j(H=>H+1);return}const V=await c();if(!V.data?.ready){F({target:V.data?.target??P.target,iframeSrc:null,isFrameLoading:!1});return}if(!b||!P.iframeSrc){h();return}F({isFrameLoading:!0}),z("reload")},L=()=>{if(m){window.open(m.iframeSrc,"_blank","noopener,noreferrer");return}if(!b?.viewUrl)return;const V=$r(P.address||b.target,b.target,b.viewUrl),H=V?.kind==="proxy"?V.url:b.viewUrl;window.open(H,"_blank","noopener,noreferrer")};if(!e)return t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:p("No active workspace.")});const M=m?.iframeSrc??P.iframeSrc,O=!!m,q=!O&&(d||g||v.isPending||y);return t.jsxs("div",{className:"h-full flex flex-col bg-white",children:[t.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-2 py-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(je,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>{O?x(null):z("back")},disabled:!O&&!P.iframeSrc,title:p("Back"),"aria-label":p("Back"),children:t.jsx($s,{})}),t.jsx(je,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>z("forward"),disabled:O||!P.iframeSrc,title:p("Forward"),"aria-label":p("Forward"),children:t.jsx(bl,{})}),t.jsx(je,{type:"button",size:"icon-sm",variant:"ghost",onClick:!O&&P.isFrameLoading?()=>{z("stop"),F({isFrameLoading:!1})}:R,disabled:!O&&!P.isFrameLoading&&g,title:!O&&P.isFrameLoading?p("Stop loading"):p("Refresh preview"),"aria-label":!O&&P.isFrameLoading?p("Stop loading"):p("Refresh preview"),children:!O&&P.isFrameLoading?t.jsx(Xt,{}):g?t.jsx(Be,{className:"animate-spin"}):t.jsx(Rs,{})}),t.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:$,children:[t.jsx(Tu,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-neutral-400"}),t.jsx("input",{ref:f,value:m?.source.file??P.address,onChange:V=>F({address:V.target.value}),onKeyDown:V=>{V.key==="Enter"&&V.nativeEvent.isComposing&&V.preventDefault()},disabled:O||s||v.isPending,placeholder:q0(),"aria-label":p("Preview address"),className:"h-8 w-full min-w-0 rounded-md border border-neutral-200 bg-white pl-8 pr-2.5 text-xs text-neutral-800 outline-none transition-colors placeholder:text-neutral-400 focus:border-neutral-400 disabled:bg-neutral-100 disabled:text-neutral-400"})]}),t.jsx(je,{type:"button",size:"icon-sm",variant:"ghost",onClick:L,disabled:!M,title:p("Open preview in new tab"),"aria-label":p("Open preview in new tab"),children:t.jsx(Tn,{})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 px-1 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:O?p("Viewing agent visualization"):q?p("Checking preview target..."):l?l.message:a?.ready?`${p("Proxying")} ${a.target}`:a?.configured?`${p("Preview target is not reachable")}${a.error?`: ${a.error}`:""}`:p("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:p(O?"Session file":"Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:M?t.jsx("iframe",{ref:u,src:M,title:p("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:O?"allow-modals allow-pointer-lock allow-presentation allow-scripts":"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",allow:"clipboard-read; clipboard-write; fullscreen",onLoad:()=>{O?x(V=>V&&{...V,isFrameLoading:!1}):F({isFrameLoading:!1})}},w):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:a?.configured?a.ready&&y?p("Checking preview target..."):p("Start the preview server, then refresh."):p("Configure a local preview target to display it here.")})})]})}function G0(e){switch(e){case Mt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Mt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Mt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Mt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Ra(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function Q0(e){return e.length<=34?e:`...${e.slice(-31)}`}function Bc({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:p,className:m,buttonClassName:x}){const{t:i}=ce(),[n,a]=_.useState(!1),d=_.useRef(null),c=_.useMemo(()=>oo(e,s),[e,s]),g=c.find(v=>v.workspace.id===r)??c[0];return _.useEffect(()=>{if(!n)return;const v=b=>{d.current&&!d.current.contains(b.target)&&a(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[n]),c.length<=1?null:t.jsxs("div",{ref:d,className:Z("relative",m),children:[t.jsxs("button",{type:"button",onClick:()=>a(v=>!v),disabled:p,className:Z("inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 text-left text-xs text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50",x),title:i("Workspace"),children:[t.jsx(qs,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Ra(g.roleLabel)),children:i(g.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:i(g.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:Q0(Ys(g.workspace))}),t.jsx(Ct,{size:13,className:Z("shrink-0 text-neutral-400 transition-transform",n&&"rotate-180")})]}),n&&t.jsx("div",{className:"absolute left-0 top-full z-50 mt-2 w-[420px] max-w-[calc(100vw-2rem)] rounded-lg border border-neutral-200 bg-white py-1.5 shadow-lg",children:c.map(v=>{const b=v.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(v.workspace.id),a(!1)},className:Z("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",b&&"bg-neutral-50"),children:[t.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-neutral-200 bg-white text-neutral-500",children:b?t.jsx(Wt,{size:13}):t.jsx(ul,{size:13})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:i(v.displayName)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Ra(v.roleLabel)),children:i(v.roleLabel)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",G0(v.workspace.status)),children:v.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:Ys(v.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[v.ownerName&&t.jsxs("span",{children:[i("Owner"),": ",v.ownerName]}),v.parentBranchName&&t.jsxs("span",{children:[i("Parent"),": ",v.parentBranchName]}),t.jsx("span",{children:v.workspace.id.slice(0,8)})]})]})]},v.workspace.id)})})]})}const Z0=[{key:"review",label:"Changes",icon:t.jsx(Qs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(_i,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(fr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(xl,{size:14})}],J0=[{key:"history",label:"History",icon:t.jsx(Vs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(_i,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(fr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(xl,{size:14})}],ex=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{type:"button",onClick:s,className:Z("flex shrink-0 items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px whitespace-nowrap",e?"bg-white border-neutral-200 text-neutral-900 shadow-[0_-2px_6px_rgba(0,0,0,0.02)] z-10":"bg-transparent border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-200/50"),children:[r,t.jsx("span",{children:o})]}),tx=({active:e,onClick:s,icon:r,label:o})=>t.jsx("button",{type:"button",onClick:s,title:o,"aria-label":o,"aria-pressed":e,className:Z("flex h-9 w-9 items-center justify-center rounded-lg border text-muted-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",e?"border-neutral-900 bg-neutral-900 text-white shadow-sm":"border-transparent hover:border-border hover:bg-background hover:text-foreground"),children:r}),Fc=ue.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:p,projectId:m,hideChanges:x,gitAvailable:i=!0,readOnly:n,repoDeleted:a,teamRun:d,teamStatus:c,gitProps:g,workspaces:v,selectedWorkspaceId:b,onSelectWorkspace:y,variant:l="tabs",expanded:h,onExpandedChange:u,minContentWidth:f=520,tabRef:S,previewRequest:C,onPreviewRequestHandled:k}){const{t:E}=ce(),w=Xs(re=>re.setVisibleContext),j=l==="rail",[A,D]=_.useState(!1),T=j?h??A:!0,P=_.useCallback(re=>{h===void 0&&D(re),u?.(re)},[h,u]),F=_.useMemo(()=>{const re=x?J0:Z0,ne=i?re:re.filter(_e=>_e.key!=="review"&&_e.key!=="history"),le=n?ne.filter(_e=>_e.key!=="terminal"):ne;return d?[{key:"team-status",label:"Team Status",icon:t.jsx(Es,{size:14})},...le]:le},[i,x,n,d]),[I,z]=_.useState(()=>C?"preview":i?x?"history":"review":"editor"),$=_.useRef(null),R=_.useRef(0),[L,M]=_.useState(),O=_.useCallback(re=>{z(re),j&&P(!0)},[j,P]);_.useImperativeHandle(S,()=>({setTab:re=>O(re),openFile:(re,ne,le)=>{O("editor"),requestAnimationFrame(()=>$.current?.openFile(re,ne,le))},openPreview:(re,ne)=>{R.current+=1,M({id:R.current,source:re,workspaceId:ne}),O("preview")}}),[O]);const q=C??L,V=q?.workspaceId&&q.workspaceId!==o?void 0:q,H=_.useCallback(re=>{M(ne=>ne?.id===re?void 0:ne),k?.(re)},[k]),{data:W}=gu(m??""),U=_.useMemo(()=>{if(!W?.quickCommands)return[];try{return JSON.parse(W.quickCommands)}catch{return[]}},[W?.quickCommands]),[N,B]=_.useState([]),K=_.useRef(void 0);_.useEffect(()=>{p&&p!==K.current&&(K.current=p,B(re=>re.includes(p)?re:[...re,p]))},[p]),_.useEffect(()=>{F.some(re=>re.key===I)||z(F[0]?.key??"editor")},[I,F]),_.useEffect(()=>{if(j&&!T)return;const re=I==="review"?"changes":I==="history"?"history":null;if(!o||!p||!re){w(null);return}return w({workspaceId:o,workingDir:p,tab:re}),()=>{w(null)}},[I,T,j,w,p,o]);const Y=!!y&&oo(v,d).length>1,J=F.find(re=>re.key===I)??F[0],G=J?E(J.label):"",de=n?t.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:E(a?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,he=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[Y&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(Bc,{workspaces:v,teamRun:d,selectedWorkspaceId:b,onSelectWorkspace:y,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[I==="team-status"&&d&&c,I==="editor"&&t.jsx(x0,{ref:$,workingDir:p,readOnly:n}),N.map(re=>{const ne=I==="terminal"&&p===re;return t.jsx("div",{"aria-hidden":!ne,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:ne?"block":"none"},children:t.jsx(Ap,{cwd:re,workspaceId:ne?o:void 0,isVisible:ne,quickCommands:U})},re)}),I==="preview"&&t.jsx(Y0,{workspaceId:o,readOnly:n,navigationRequest:V,onNavigationRequestHandled:H}),I==="review"&&t.jsx(T0,{projectId:m,workingDir:p,workspaceId:o,branchName:g?.branchName,targetBranch:g?.targetBranch,commitMessage:g?.commitMessage,canRunGitOperations:g?.canRunGitOperations,onRefreshCommitMessage:g?.onRefreshCommitMessage,onConflict:g?.onConflict,onResolveConflicts:g?.onResolveConflicts}),I==="history"&&t.jsx(B0,{workingDir:p})]})]});return j?t.jsxs("div",{className:Z("flex h-full w-full min-w-0 bg-white",s),children:[t.jsx("div",{className:"flex h-full w-12 shrink-0 flex-col items-center gap-1 border-l border-border bg-muted/35 px-1.5 py-2",children:F.map(re=>t.jsx(tx,{active:T&&I===re.key,onClick:()=>O(re.key),icon:re.icon,label:E(re.label)},re.key))}),T&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:f},children:[de,t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border bg-muted/35 text-muted-foreground",children:J?.icon}),t.jsx("span",{className:"truncate",children:G})]}),t.jsx("button",{type:"button",onClick:()=>P(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:E("收起"),"aria-label":E("收起"),children:t.jsx(qu,{size:15})})]}),he]})]}):t.jsxs("div",{className:Z("flex h-full w-full min-w-0 flex-col bg-white",s),children:[n&&de,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:F.map(re=>t.jsx(ex,{active:I===re.key,onClick:()=>O(re.key),icon:re.icon,label:E(re.label)},re.key))}),he]})}),sx=3e3;function Aa(e,s){const r=new Map(e.map(o=>[o.workspaceId,o]));for(const o of s){const p=r.get(o.workspaceId);(!p||o.updatedAt>=p.updatedAt)&&r.set(o.workspaceId,o)}return[...r.values()]}function zc(e){const s=Lt(),r=_.useRef({version:0,values:new Map}),[o,p]=_.useState(0),{data:m=[]}=Pt({queryKey:be.workspaces.setupProgress(e??""),enabled:!!e,refetchOnMount:"always",refetchInterval:a=>a.state.data?.some(d=>d.status==="running")?3e3:!1,queryFn:async({signal:a})=>{const d=r.current.version,c=await Ae.get(`/tasks/${e}/setup-progress`,{signal:a}),g=[...r.current.values.values()].filter(v=>v.version>d&&v.progress.taskId===e).map(v=>v.progress);return Aa(c,g)}});_.useEffect(()=>{if(!e)return;const a=ls.connect(),d=be.workspaces.setupProgress(e),c=v=>{if(v.taskId!==e)return;const b=r.current.values.get(v.workspaceId);b&&b.progress.updatedAt>v.updatedAt||(r.current.values.set(v.workspaceId,{version:++r.current.version,progress:v}),s.setQueryData(d,y=>Aa(y??[],[v])))},g=()=>{s.invalidateQueries({queryKey:d})};return a.on(dt.WORKSPACE_SETUP_PROGRESS,c),a.on("connect",g),()=>{a.off(dt.WORKSPACE_SETUP_PROGRESS,c),a.off("connect",g)}},[e,s]);const x=[...m].sort((a,d)=>d.updatedAt-a.updatedAt),i=x.find(a=>a.status==="running")??x.find(a=>a.status!=="running"&&a.updatedAt>o),n=i?.status!=="running"?i?.updatedAt??null:null;return _.useEffect(()=>{if(n===null)return;const a=setTimeout(()=>p(n),sx);return()=>clearTimeout(a)},[n]),i??null}function Wc({isOpen:e,onClose:s,onStarted:r,taskId:o,projectId:p,taskTitle:m,taskDescription:x,taskPrompt:i,projectIsGitRepo:n=!0,projectWorktreeReady:a=!0,projectGitReason:d}){const{t:c}=ce(),[g,v]=_.useState(""),[b,y]=_.useState(""),[l,h]=_.useState(xt.WORKTREE),[u,f]=_.useState(null),[S,C]=_.useState("idle"),[k,E]=_.useState(null),w=Lt(),j=rl(o),A=Fn(),D=vu(),{data:T,isLoading:P}=Gs(),F=u?.isGitRepo??n,I=u?.worktreeReady??a,z=u?.reason??d,$=F!==!1&&I!==!1;_.useEffect(()=>{if(!e||!T)return;const J=T.find(G=>!es(G));v(G=>G&&T.some(de=>de.provider.id===G)?G:J?.provider.id??"")},[e,T]),_.useEffect(()=>{if(e){const J=[m];x&&J.push(x),y(i?.trim()||J.join(`
|
|
68
|
+
|
|
69
|
+
`)),f(null),h(n!==!1&&a!==!1?xt.WORKTREE:xt.MAIN_DIRECTORY),C("idle"),E(null)}},[e,n,a,o,m,x,i]),_.useEffect(()=>{$||h(xt.MAIN_DIRECTORY)},[$]);const R=async()=>{if(!p||D.isPending)return;const J=await D.mutateAsync({id:p});f(J),J.worktreeReady&&h(xt.WORKTREE)},L=S!=="idle",M=async()=>{if(!g||!b.trim())return;const J=T?.find(G=>G.provider.id===g);if(!(!J||es(J))){E(null);try{C("creating-workspace");const G=await j.mutateAsync({workspaceKind:$?l:xt.MAIN_DIRECTORY});C("creating-session");const de=await Ae.post(`/workspaces/${G.id}/sessions`,{providerId:g,prompt:b.trim()});C("starting-session"),await A.mutateAsync(de.id),await w.invalidateQueries({queryKey:be.workspaces.list(o)}),C("idle"),r?.(),s()}catch(G){C("idle"),E(G instanceof Error?G.message:c("启动失败,请重试"))}}},O={idle:c("启动"),"creating-workspace":c("创建工作空间..."),"creating-session":c("创建会话..."),"starting-session":c("启动 Agent...")},q=(T??[]).map(J=>{const G=J.provider,de=es(J),he=!de,re=G.executionPermission?c("Required permission: {mode}",{mode:c(mu[G.executionPermission])}):void 0;return{value:G.id,label:he?G.name:`${G.name}${c(" (不可用)")}`,description:[re,de&&c(de)].filter(Boolean).join(" · "),icon:t.jsx(xi,{agentType:G.agentType,className:"size-4"}),disabled:!he}}),V=T?.find(J=>J.provider.id===g),H=V?es(V):void 0,W=!!T?.length&&T.every(J=>!!es(J)),U=!P&&!T?.length,N=c("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),B=c("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),K=c(z==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"非 Git 项目只能使用本地模式。"),Y=[{value:xt.WORKTREE,label:c("工作树模式"),description:N,disabled:!$},{value:xt.MAIN_DIRECTORY,label:c("本地模式"),description:B}];return t.jsx(ps,{isOpen:e,onClose:L?()=>{}:s,title:c("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(je,{variant:"outline",onClick:s,disabled:L,children:c("取消")}),t.jsx(je,{onClick:M,disabled:L||!V||!b.trim()||!!H,children:O[S]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsx("div",{children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("Agent")}),t.jsx(cs,{value:g,onChange:v,options:q,placeholder:c(P?"加载中...":"选择 Agent"),disabled:L||P}),H?t.jsx("p",{role:"alert",className:"mt-2 break-words text-xs leading-snug text-destructive",children:c(H)}):null,W&&!V?t.jsxs("div",{role:"alert",className:"mt-2 space-y-1 break-words text-xs leading-snug text-destructive",children:[t.jsx("p",{children:c("No available Provider for this session.")}),t.jsx("ul",{className:"space-y-1",children:T.map(J=>t.jsxs("li",{children:[J.provider.name,": ",c(es(J))]},J.provider.id))})]}):null,U?t.jsx("p",{role:"alert",className:"mt-2 text-xs text-destructive",children:c("No available Provider for this session.")}):null]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("模式")}),$?t.jsx(cs,{value:l,onChange:J=>h(J),options:Y,disabled:L}):t.jsx(hu,{side:"bottom",className:"w-full",content:K,children:t.jsxs("div",{tabIndex:0,"aria-label":K,className:"rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx(cs,{value:l,onChange:J=>h(J),options:Y,disabled:!0}),t.jsx("button",{type:"button",onClick:R,disabled:L||D.isPending,className:"mt-2 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:D.isPending?c("检测中..."):c("重新检测 Git 状态")})]})})]})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("任务描述")}),t.jsx("textarea",{value:b,onChange:J=>y(J.target.value),rows:5,disabled:L,placeholder:c("描述你想让 Agent 完成的任务..."),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-300 focus:border-neutral-300 resize-none disabled:opacity-50 disabled:bg-neutral-50"})]}),k&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:k})]})})}function Hc(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function rx(e,s,r){const o=e?.providerId??r?.providerId??null,p=o?s?.find(n=>n.provider.id===o)?.provider:null,m=p?.name??o??e?.agentType??r?.agentType??null;if(!m)return null;const x=e?.agentType??p?.agentType??r?.agentType??null,i=o&&p?.name&&o!==p.name?`${p.name} (${o})`:m;return{label:m,title:i,agentType:x}}function Uc({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:p,agentTypeFallback:m,tokenTooltipSide:x="top"}){const{t:i}=ce(),n=rx(e,s,{providerId:p,agentType:m});return!n&&!r?null:t.jsxs("div",{className:`flex shrink-0 items-center ${o?"gap-1":"gap-2"}`,children:[n&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-neutral-500 ${o?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-[11px]":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${i("Provider")}: ${n.title}`,children:[t.jsx(xi,{agentType:n.agentType,className:o?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:Ld(n.label,o?12:18)})]}),t.jsx(zn,{usage:r,tooltipSide:x})]})}function ix({isOpen:e,onClose:s,taskId:r}){const{t:o}=ce(),[p,m]=_.useState("AUTO"),[x,i]=_.useState(null),[n,a]=_.useState([]),[d,c]=_.useState(null),g=Ya();_.useEffect(()=>{e&&(m("AUTO"),i(null),a([]),c(null))},[e]);const v=g.isPending,b=!!x||n.length>0,y=async()=>{if(!v){if(!x&&n.length===0){c(o("请选择至少一个团队模板或成员预设。"));return}c(null);try{await g.mutateAsync({taskId:r,mode:p,...x?{teamTemplateId:x}:{},...n.length>0?{memberPresetIds:n}:{}}),s()}catch(h){if(h instanceof Er&&h.status===409){c(o("该任务已经存在 TeamRun。请刷新后再试。"));return}c(h instanceof Error?h.message:o("创建 TeamRun 失败"))}}},l=v||!b;return t.jsxs(ps,{isOpen:e,onClose:v?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(je,{type:"button",variant:"outline",onClick:s,disabled:v,children:o("取消")}),t.jsx(je,{type:"button",onClick:y,disabled:l,children:o(v?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(Jd,{mode:p,setMode:m,selectedTemplateId:x,setSelectedTemplateId:i,selectedMemberPresetIds:n,setSelectedMemberPresetIds:a,disabled:v}),d&&t.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:d})]})}function nx({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=ce(),p=In();if(s.operation==="idle"||s.conflictedFiles.length===0)return null;const m=s.operation==="rebase"?"Rebase":"Merge";return t.jsxs("div",{className:"mx-6 mt-3 flex items-center gap-3 rounded-lg border border-warning/25 bg-warning/[0.06] px-4 py-2.5",children:[t.jsx(Ns,{size:15,className:"text-warning shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[t.jsxs("span",{className:"text-sm font-medium text-foreground",children:[m," ",o("冲突")]}),t.jsxs("span",{className:"inline-flex items-center rounded-full bg-warning/15 px-2 py-0.5 text-xs font-semibold text-warning tabular-nums",children:[s.conflictedFiles.length," ",o("个文件")]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx(je,{variant:"ghost",size:"sm",onClick:()=>p.mutate(e),disabled:p.isPending,className:"text-muted-foreground hover:text-foreground",children:o("中止操作")}),t.jsx(je,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function $c(e){return e.length>0?e.map(s=>`- ${s}`).join(`
|
|
70
|
+
`):"- 未获取到冲突文件列表"}function Kc(e){if(!e)return[];const s=[];return e.workspaceId&&s.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&s.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&s.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&s.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&s.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&s.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&s.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&s.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&s.push("- Merge state: conflict detected and already aborted by Agent Tower"),s}function ox(e,s){if(!s?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=s.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,o=s.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${r}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${o} 完成合并`]}function ax(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const s=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,r=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${s}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function lx(e,s,r,o,p){const m=$c(r),x=Kc(p);return o===xr.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${s}\` 时发生了冲突。`,...x.length>0?["","### 上下文",...x]:[],"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
|
|
71
|
+
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...x.length>0?["","### 上下文",...x]:[],"","### 冲突文件",m,"","### 解决步骤",...ox(e,p)].join(`
|
|
72
|
+
`)}function cx(e){const s=e.conflictOp===xr.REBASE?"Rebase":"Merge",r=$c(e.conflictedFiles),o=[...Kc(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===xr.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":ax(e)].join(`
|
|
73
|
+
`)}function dx(e){if(e.teamRunId)return{type:"team_room",message:cx(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:lx(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function qc({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:p,sourceBranch:m,targetBranch:x,operation:i,worktreePath:n,mergeAborted:a,mergeStrategy:d,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:v,targetWorktreePath:b,sessions:y,currentSessionId:l,teamRunId:h}){const{t:u}=ce(),[f,S]=_.useState(""),C=Wn(),k=Mn(h??""),E=On(),w=!!h,j=l||f,A=w?k.isPending:C.isPending,D=()=>{const z=dx({workspaceId:r,worktreePath:n,operation:i,mergeAborted:a,mergeStrategy:d,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:v,targetWorktreePath:b,sourceBranch:m,targetBranch:x,conflictedFiles:p,conflictOp:o,teamRunId:h,currentSessionId:l,selectedSessionId:f});if(z.type==="team_room"){k.mutate({content:z.message,kind:"chat"},{onSuccess:()=>{Je.success(u("已发送到 Team Room")),s(!1)}});return}z.type==="session"&&C.mutate({id:z.sessionId,message:z.message},{onSuccess:()=>s(!1)})},T=()=>{E.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},P=o==="REBASE"?"Rebase":"Merge",F=!w&&!l&&y.length>0,I=w||!!j;return t.jsx(ps,{isOpen:e,onClose:()=>s(!1),title:u("解决 {opLabel} 冲突",{opLabel:P}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(je,{variant:"outline",onClick:T,children:u("在 IDE 中打开")}),t.jsx(je,{onClick:D,disabled:!I||A,children:u(A?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:u("冲突文件({count})",{count:p.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:p.map(z=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-neutral-700 border-b border-neutral-100 last:border-b-0",children:z},z))})]}),w&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:u("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),F&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:u("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:f,onChange:z=>S(z.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[t.jsx("option",{value:"",children:u("选择一个 Session...")}),y.map(z=>t.jsxs("option",{value:z.id,children:[z.agentType," — ",z.status]},z.id))]})]}),!w&&!j&&y.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:u("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function ux(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((r,o)=>({files:r.files+1,additions:r.additions+(o.additions??0),deletions:r.deletions+(o.deletions??0)}),{files:0,additions:0,deletions:0})}function Ta(e,s,r,o){const p=Tc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Vc({projectId:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,changes:m,gitStatus:x,isGitStatusLoading:i,canRunGitOperations:n,onOpenChanges:a,onRefreshCommitMessage:d,onConflict:c,className:g}){const{t:v}=ce(),b=tl(),y=sl(),l=In(),[h,u]=_.useState(!1),[f,S]=_.useState(null),C=lo(s,h),k=(C.data??[]).filter(Nc),E=_.useMemo(()=>ux(m),[m]),w=E.additions+E.deletions,j=E.files>0&&w>0,A=(x?.conflictedFiles.length??0)>0,D=!!(x&&x.operation!=="idle"),T=!!(x&&(x.hasUncommittedChanges||x.untrackedCount>0)),P=(x?.uncommittedCount??0)+(x?.untrackedCount??0),F=(x?.behind??0)>0,I=(x?.ahead??0)>0,z=i||!x&&n,$=!!(n&&s&&x&&F&&!A&&!D&&!T),R=!!(n&&s&&x&&I&&!F&&!A&&!D&&!T),L=!!(n&&s&&x&&!A&&!D&&!T);if(_.useEffect(()=>{h&&d?.()},[h,d]),!j)return null;const M=A?v("冲突"):x?.operation==="rebase"?v("变基中"):x?.operation==="merge"?v("合并中"):P>0?v("{count} 未提交",{count:P}):F?v("落后 {count}",{count:x?.behind??0}):v(I?"可合并":"已是最新"),O=v("{files} 个文件 · {lines} 行",{files:E.files,lines:w}),q=()=>{$&&(S(null),b.mutate(s,{onError:U=>{Ta(U,v("更新失败,请稍后重试"),N=>c(N),S)}}))},V=()=>{L&&(S(null),u(!0))},H=(U,N)=>{S(null),y.mutate({id:s,commitMessage:U,stopActiveServices:N},{onSuccess:()=>u(!1),onError:B=>{if(Rc(B)){S(v("后台服务仍在运行,请确认停止服务后再提交。"));return}Ta(B,v("提交失败,请稍后重试"),K=>{u(!1),c(K)},S)}})},W=()=>{y.isPending||(u(!1),S(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:Z("space-y-1",g),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:a,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":v("查看变更详情"),children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background/70 text-muted-foreground",children:t.jsx(Qs,{size:13})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:O}),t.jsxs("span",{className:"hidden shrink-0 items-center gap-1 font-mono text-[11px] sm:inline-flex",children:[E.additions>0&&t.jsxs("span",{className:"text-success",children:["+",E.additions]}),E.deletions>0&&t.jsxs("span",{className:"text-destructive",children:["-",E.deletions]})]}),A&&t.jsx(Ns,{size:13,className:"shrink-0 text-amber-600"}),t.jsxs("span",{className:"hidden min-w-0 items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:r}),t.jsx("span",{className:"text-muted-foreground/40",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:o})]}),t.jsx("span",{className:"shrink-0 rounded-full bg-background/75 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:M})]}),t.jsx(Nt,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[D&&t.jsx("button",{type:"button",onClick:()=>l.mutate(s),disabled:l.isPending,className:"hidden h-7 items-center rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 sm:inline-flex",children:l.isPending?v("正在撤销..."):v("撤销操作")}),t.jsxs("button",{type:"button",onClick:q,disabled:!$||b.isPending||z,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:v(F?"同步更新":"已是最新"),children:[b.isPending?t.jsx(Be,{size:12,className:"animate-spin"}):t.jsx(Rs,{size:12}),t.jsx("span",{children:b.isPending?v("正在同步..."):v("更新")})]}),t.jsxs("button",{type:"button",onClick:V,disabled:!L||y.isPending||z,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",title:R?v("合并到 {target}",{target:o}):v("提交变更"),children:[y.isPending?t.jsx(Be,{size:12,className:"animate-spin"}):t.jsx(ii,{size:12}),t.jsx("span",{children:y.isPending?v("正在提交..."):v("合并")})]})]})]}),f&&t.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:f})]}),t.jsx(Ac,{projectId:e,workspaceId:s,canMerge:R,isOpen:h,onClose:W,onBaseBranchSaved:a,branchName:r,targetBranch:o,commitMessage:p,isPending:y.isPending,activeServices:k,isCheckingServices:C.isLoading,serviceCheckFailed:C.isError,error:f,onConfirm:H})]})}const Ma=["creating-workspace","creating-session","starting-session"];function Yc({state:e,setupProgress:s,sessionStarted:r=!1,onRetry:o,compact:p=!1}){const{t:m}=ce(),[x,i]=_.useState(!1),n=e?.status==="failed",a=s?.status==="failed",d=n||a,c=e?Ma.indexOf(e.status):Ma.length,g=[m("Preparing workspace"),m("Creating session"),m("Starting agent")],v=(e?.setupScript??"").split(`
|
|
74
|
+
`).map(l=>l.trim()).filter(Boolean),b=e||r?g.map((l,h)=>({label:l,status:n?"pending":h<c?"completed":h===c?"active":"pending"})):[];(s||v.length>0)&&b.push({label:s?.status==="running"?m("Running setup ({current}/{total})",{current:s.currentIndex??0,total:s.totalCommands}):s?.status==="completed"?m("Setup complete"):s?.status==="failed"?m("Setup failed"):m("Run setup script"),status:s?.status==="running"?"active":s?.status??"pending",description:s?.currentCommand||v.join(`
|
|
75
|
+
`)});const y=!!s?.output?.trim();return!e&&!s?null:t.jsxs("div",{className:`${p?"my-2 mb-4":"my-3 mb-6"} mx-auto w-full max-w-2xl rounded-xl border ${d?"border-destructive/30 bg-destructive/[0.03]":"border-border/70 bg-background"} px-4 py-3 text-left shadow-sm`,role:d?"alert":"status","aria-live":d?"assertive":"polite",children:[d&&(e?.error||s?.error||n)?t.jsx("p",{className:"mb-2 break-words text-xs text-destructive/80",children:e?.error||s?.error||m("Agent start failed")}):null,t.jsx("div",{className:"space-y-2",children:b.map(({label:l,status:h,description:u})=>{const f=h==="completed",S=h==="active";return t.jsxs("div",{className:`flex items-start gap-2 text-sm ${h==="failed"?"text-destructive":f||S?"text-info":"text-muted-foreground"}`,children:[f?t.jsx(Id,{className:"h-4 w-4 shrink-0"}):S?t.jsx(Be,{className:"h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none"}):h==="failed"?t.jsx(Va,{className:"h-4 w-4 shrink-0"}):t.jsx(fu,{className:"h-4 w-4 shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{children:l}),u&&t.jsx("code",{className:"mt-1 block whitespace-pre-wrap break-all rounded-md bg-muted/35 px-2.5 py-2 text-xs leading-relaxed text-muted-foreground",children:u})]})]},l)})}),(y||n)&&t.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 border-t border-border/50 pt-2",children:[y?t.jsxs("button",{type:"button",onClick:()=>i(l=>!l),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":x,"aria-controls":"task-start-progress-details",children:[x?t.jsx(Ct,{className:"h-3.5 w-3.5"}):t.jsx(Nt,{className:"h-3.5 w-3.5"}),m(x?"Hide setup output":"View setup output")]}):t.jsx("span",{}),n&&o?t.jsx(je,{size:"sm",variant:"outline",onClick:o,children:m("Retry start")}):null]}),x&&t.jsx("div",{id:"task-start-progress-details",className:"mt-2 rounded-md bg-muted/35 px-2.5 py-2 text-xs leading-relaxed text-muted-foreground",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono",children:s?.output??""})})]})}function hx({agentType:e,workingDir:s}){return Pt({queryKey:be.system.skillCatalog(e,s),queryFn:async()=>(await Ae.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Et.CODEX,staleTime:3e4})}function fx(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function Xc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:x}){const[i,n]=_.useState(0),{data:a=[]}=hx({agentType:e,workingDir:s}),c=_.useMemo(()=>e===Et.CODEX?Co(r):null,[e,r])?.query??null,g=_.useMemo(()=>c===null?[]:eu(a,c),[c,a]),v=_.useCallback(()=>{const l=p.current;l&&(l.style.height="auto",l.style.height=`${Math.max(m,Math.min(l.scrollHeight,x))}px`)},[x,m,p]);_.useEffect(()=>{n(0)},[e,c]),_.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const b=_.useCallback(l=>{const h=Co(r);if(!h)return;const u=`${r.slice(0,h.replaceStart)}${l.command} `;o(u),requestAnimationFrame(()=>{const f=p.current;f&&(v(),f.focus(),f.setSelectionRange(u.length,u.length))})},[r,v,o,p]),y=_.useCallback(l=>c===null||g.length===0?!1:l.key==="ArrowDown"?(l.preventDefault(),n(h=>(h+1)%g.length),!0):l.key==="ArrowUp"?(l.preventDefault(),n(h=>(h-1+g.length)%g.length),!0):fx(l)?(l.preventDefault(),b(g[i]??g[0]),!0):!1,[b,g,c,i]);return{allSkills:a,query:c,filteredSkills:g,selectedIndex:i,setSelectedIndex:n,applySkill:b,handleKeyDown:y}}const ln=200,mx=180;function Gc({taskId:e,title:s,readOnly:r=!1,onTitleChange:o,className:p,titleClassName:m,compact:x=!1}){const{t:i}=ce(),[n,a]=_.useState(!1),[d,c]=_.useState(s),[g,v]=_.useState(!1),b=_.useRef(null),y=_.useRef(null),l=Xa();_.useEffect(()=>{n||c(s)},[s,n]),_.useEffect(()=>{n&&b.current&&(b.current.focus(),b.current.select())},[n]),_.useEffect(()=>{if(!n)return;const j=A=>{y.current&&!y.current.contains(A.target)&&f()};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[n,d]);const h=_.useCallback(()=>{r||(a(!0),c(s))},[r,s]),u=_.useCallback(()=>{a(!1),c(s)},[s]),f=_.useCallback(async()=>{const j=d.trim();if(!j){c(s),a(!1);return}if(j===s){a(!1);return}try{await l.mutateAsync({id:e,title:j}),o?.(j),a(!1)}catch(A){console.error("Failed to update task title:",A),c(s)}},[d,s,e,l,o]),S=_.useCallback(j=>{j.key==="Enter"&&!j.shiftKey?(j.preventDefault(),f()):j.key==="Escape"&&(j.preventDefault(),u())},[f,u]),C=_.useCallback(j=>{const A=j.target.value;A.length<=ln&&c(A)},[]),k=d.length,E=k>=mx,w=k>=ln;return n?t.jsxs("div",{ref:y,className:Z("flex flex-col gap-2",p),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{ref:b,type:"text",value:d,onChange:C,onKeyDown:S,disabled:l.isPending,className:Z("flex-1 min-w-0 px-2 py-1 text-lg font-semibold bg-background border border-input rounded-md","focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent","disabled:opacity-50 disabled:cursor-not-allowed",x&&"text-base py-0.5",m),placeholder:i("输入任务标题")}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(je,{size:x?"sm":"default",variant:"ghost",onClick:f,disabled:l.isPending||!d.trim(),className:"h-8 w-8 p-0",children:l.isPending?t.jsx(Be,{size:16,className:"animate-spin"}):t.jsx(Wt,{size:16})}),t.jsx(je,{size:x?"sm":"default",variant:"ghost",onClick:u,disabled:l.isPending,className:"h-8 w-8 p-0",children:t.jsx(Xt,{size:16})})]})]}),E&&t.jsxs("div",{className:Z("text-xs",w?"text-destructive":"text-muted-foreground"),children:[k," / ",ln," ",i("字符")]})]}):t.jsxs("div",{ref:y,className:Z("group flex items-center gap-2 min-w-0",p),onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),children:[t.jsx("h2",{onClick:h,className:Z("flex-1 min-w-0 text-lg font-semibold text-foreground break-words line-clamp-2",!r&&"cursor-text hover:text-foreground/80 transition-colors",x&&"text-base",m),children:s}),!r&&g&&t.jsx(je,{size:"sm",variant:"ghost",onClick:h,className:"h-7 w-7 p-0 shrink-0 opacity-60 hover:opacity-100",title:i("编辑标题"),children:t.jsx(_u,{size:14})})]})}const px=Cr(),gx=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${px}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Bs=520,cn=48,vx=4,xx=420;function bx(){const{t:e}=ce();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground/70 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-6",children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground/50",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),t.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t.jsx("h3",{className:"text-foreground font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}function cr(e){const s=Ks[e].icon;return t.jsx(s,{className:"size-3"})}const Da=[{status:Ee.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:cr(Ee.Review)},{status:Ee.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:cr(Ee.Running)},{status:Ee.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:cr(Ee.Pending)},{status:Ee.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:cr(Ee.Done)},{status:Ee.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:cr(Ee.Cancelled)}];function _x({status:e,onChangeStatus:s}){const{t:r}=ce(),[o,p]=_.useState(!1),m=_.useRef(null);_.useEffect(()=>{if(!o)return;const i=n=>{m.current&&!m.current.contains(n.target)&&p(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[o]);const x=Da.find(i=>i.status===e);return t.jsxs("div",{className:"relative",ref:m,children:[t.jsxs("button",{onClick:()=>s&&p(i=>!i),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${x.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[x.icon,t.jsx("span",{children:r(e)}),s&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${o?"rotate-180":""}`,children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),o&&t.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:Da.filter(i=>i.status!==e).map(i=>t.jsxs("button",{onClick:()=>{s?.(i.status),p(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${i.hoverClass}`,children:[t.jsx("span",{className:i.className.split(" ").find(n=>n.startsWith("text-")),children:i.icon}),t.jsx("span",{className:"text-foreground/80",children:r(i.status)})]},i.status))})]})}function yx({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,onTaskPriorityChange:p,autoStartState:m,onAutoStartRecovered:x}){const{t:i}=ce(),[n,a]=_.useState(""),[d,c]=_.useState(!1),[g,v]=_.useState(!1),[b,y]=_.useState(!1),[l,h]=_.useState(!1),[u,f]=_.useState(!1),[S,C]=_.useState(!1),[k,E]=_.useState(null),w=_.useRef(null),[j,A]=_.useState(!1),[D,T]=_.useState(null),[P,F]=_.useState(void 0),[I,z]=_.useState(!1),$=_.useRef(null),R=_.useRef(null),L=_.useRef(null),M=_.useRef(null),{scrollRef:O,contentRef:q,isAtBottom:V,scrollToBottom:H,stopScroll:W}=Bn({resize:"smooth",initial:"instant"}),[U,N]=_.useState(!1),[B,K]=_.useState(Bs),[Y,J]=_.useState(!1),G=_.useRef(0),de=_.useRef(Bs),he=_.useRef(null),re=_.useCallback((Q,oe,Ie)=>{w.current?.openFile(Q,oe,Ie)},[]),{data:ne,isLoading:le}=Pn(e?.id??""),_e=zc(e?.id),We=_e?.status==="completed"&&m?.status!=="failed"?null:m,Ce=!!(We||_e&&_e.status!=="completed"),{data:He}=Ga(e?.id??""),{data:at}=Qa(He?.id??""),Me=Mn(He?.id??""),Ne=He??null,Oe=!!Ne,$e=e?.isGitRepo!==!1&&e?.worktreeReady!==!1,Ke=He===null&&$e,De=!!(e?.id&&He===null),{data:Xe,isLoading:Ge}=Za(e?.id??"",De);_.useEffect(()=>{z(!1),T(null),F(void 0)},[e?.id]);const Te=_.useMemo(()=>Xl(ne,Ne,P),[P,Ne,ne]);_.useEffect(()=>{P&&!ne?.some(Q=>Q.id===P)&&F(void 0)},[P,ne]);const pe=_.useMemo(()=>ne?.find(Q=>Q.id===Te),[Te,ne]),tt=pe?.status===Mt.ACTIVE?pe.id:void 0,Ye=$e&&Gl(pe,Ne);_.useEffect(()=>{if(!I||!ne)return;ne.some(oe=>oe.status==="ACTIVE"&&oe.sessions&&oe.sessions.length>0)&&z(!1)},[ne,I]);const Ue=_.useMemo(()=>{if(I||!ne)return null;const Q=gt=>{const zi=gt.createdAt,or=gt.endedAt??gt.startedAt??zi;if(!or)return 0;const Ls=Date.parse(or);return Number.isNaN(Ls)?0:Ls},oe=(gt,zi)=>{const or=gt.filter(Ls=>zi.includes(Ls.status));return or.length===0?null:or.sort((Ls,_d)=>Q(_d)-Q(Ls))[0]??null},Ie=ne.filter(gt=>gt.status==="ACTIVE"&&Array.isArray(gt.sessions)).flatMap(gt=>gt.sessions??[]),mt=oe(Ie,[ut.RUNNING])??oe(Ie,[ut.PENDING])??oe(Ie,[ut.COMPLETED,ut.FAILED,ut.CANCELLED]);if(mt)return mt;const pt=ne.filter(gt=>(gt.status==="MERGED"||gt.status==="ABANDONED"||gt.status==="HIBERNATED")&&Array.isArray(gt.sessions)).flatMap(gt=>gt.sessions??[]);return oe(pt,[ut.COMPLETED,ut.FAILED,ut.CANCELLED])},[ne,I]),ft=Ue?.id??"",st=Oe?D??"":ft,te=_.useMemo(()=>{if(!D||!ne)return null;for(const Q of ne){const oe=Q.sessions?.find(Ie=>Ie.id===D);if(oe)return oe}return null},[D,ne]),fe=_.useMemo(()=>{if(!D||!Ne?.invocations)return null;const Q=Ne.invocations.filter(oe=>oe.sessionId===D);return Q.length===0?null:Q.sort((oe,Ie)=>{const mt=Date.parse(oe.updatedAt??oe.createdAt??""),pt=Date.parse(Ie.updatedAt??Ie.createdAt??"");return(Number.isNaN(pt)?0:pt)-(Number.isNaN(mt)?0:mt)})[0]??null},[D,Ne?.invocations]),ye=_.useMemo(()=>!fe?.memberId||!Ne?.members?null:Ne.members.find(Q=>Q.id===fe.memberId)??null,[fe?.memberId,Ne?.members]),X=D?te:Ue??null,se=X?.id,ie=_.useMemo(()=>{if(X?.workspaceId)return X.workspaceId;if(!(!X||!ne))return ne.find(Q=>Q.sessions?.some(oe=>oe.id===X.id))?.id},[X,ne]),ae=_.useCallback((Q,oe)=>{const mt=(oe&&ne?.some(pt=>pt.id===oe)?oe:void 0)??ie??Te??void 0;mt&&F(mt),w.current?.openPreview(Q,mt)},[ie,Te,ne]),Se=_.useCallback((Q,oe)=>{ae({kind:"web",url:Q},oe)},[ae]),we=_.useCallback((Q,oe,Ie)=>{ae({kind:"visualization",sessionId:Q,file:oe},Ie)},[ae]),Pe=_.useCallback(Q=>{Se(Q,ie)},[ie,Se]),Ze=_.useCallback(Q=>{se&&we(se,Q,ie)},[se,ie,we]),{isActive:xe,isCancelling:ve}=il(se??"",X?.status),me=!!e?.projectArchivedAt,Fe=!!e?.projectRepoDeletedAt,rt=i(Fe?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:lt}=Gs(),[kt,St]=_.useState(null),vt=Ue?gl(lt,kt??Ue.providerId):void 0;_.useEffect(()=>{St(Ue?.providerId??null)},[Ue?.providerId]);const It=_.useMemo(()=>!Ue||!ne?!1:!ne.some(oe=>oe.status==="ACTIVE"&&oe.sessions?.some(Ie=>Ie.id===Ue.id)),[Ue,ne]),wt=_.useMemo(()=>{if(!(!ne||I)){if(pe)return hs(pe);for(const Q of ne)if(Q.status==="ACTIVE"&&hs(Q))return hs(Q);return hs(ne[0])}},[I,pe,ne]),Rt=nl({agentType:Ue?.agentType,workingDir:wt,input:n,setInput:a,textareaRef:L,minHeight:60,maxHeight:300}),Ut=Xc({agentType:Ue?.agentType,workingDir:wt,input:n,setInput:a,textareaRef:L,minHeight:60,maxHeight:300}),er=Xs(Q=>Q.setVisibleContext),$t=!!(Ye&&tt&&wt&&!me),{data:bt,isLoading:Mi}=Ln(tt??"",{enabled:$t}),{data:Gt}=Ti(wt,{enabled:$t});_.useEffect(()=>{if(!(U||!$t||!tt||!wt))return er({workspaceId:tt,workingDir:wt,tab:"changes"}),()=>{er(null)}},[U,tt,er,$t,wt]);const Qt=pe?.sessions??[],ss=Ys(pe),xs=pe?.commitMessage,As=_.useMemo(()=>Ql(pe,ne,e?.mainBranch??""),[pe,e?.mainBranch,ne]),it=_.useMemo(()=>bt?.conflictOp&&bt.conflictedFiles.length>0?{conflictOp:bt.conflictOp,conflictedFiles:bt.conflictedFiles}:k,[bt?.conflictOp,bt?.conflictedFiles,k]),tr=it?.targetWorkspaceId??tt,Pr=it?.targetWorktreePath??pe?.worktreePath,Lr=it?.sourceBranch??ss,Ir=it?.targetBranch??As,nt=Lt(),Ts=_.useCallback(async()=>e?.id?nt.fetchQuery({queryKey:be.tasks.body(e.id),queryFn:()=>Ae.get(`/tasks/${e.id}/body`)}):null,[nt,e?.id]),bs=_.useCallback(()=>e?.id?nt.invalidateQueries({queryKey:be.workspaces.list(e.id)}):Promise.resolve(),[e?.id,nt]);_.useEffect(()=>{if(!j)return;const Q=oe=>{R.current&&!R.current.contains(oe.target)&&A(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[j]);const Zt=Wn(),Or=On(),_s=Od(),Br=rl(e?.id??""),sr=Fn(),Ms=Vd(),Ot=_.useMemo(()=>!ne||ne.some(oe=>oe.status==="ACTIVE")?null:ne.find(oe=>oe.status==="HIBERNATED")??null,[ne]),rs=_.useRef(null);_.useEffect(()=>{Ot&&rs.current!==Ot.id&&(Ms.isPending||(rs.current=Ot.id,Ms.mutate(Ot.id,{onSettled:()=>{rs.current=null}})))},[Ot,Ms]);const Di=_.useCallback(async()=>{if(!e?.id)return;const Q=Ue?.providerId??lt?.find(oe=>oe.availability.type!=="NOT_FOUND")?.provider.id;if(Q){h(!1),f(!0);try{const Ie=(await Ts())?.prompt??e.title;await _s.mutateAsync(e.id),z(!0);const mt=await Br.mutateAsync({workspaceKind:$e?void 0:xt.MAIN_DIRECTORY}),pt=await Ae.post(`/workspaces/${mt.id}/sessions`,{providerId:Q,prompt:Ie});await sr.mutateAsync(pt.id),await nt.invalidateQueries({queryKey:be.workspaces.list(e.id)})}catch(oe){console.error("[retry] failed:",oe),z(!1)}finally{f(!1)}}},[e?.id,e?.title,$e,Ue?.providerId,lt,Ts,_s,Br,sr,nt]),Ds=_.useCallback(async()=>{e?.id&&(await Ts(),c(!0))},[Ts,e?.id]),Fr=_.useCallback(()=>{pe?.id&&Or.mutate({workspaceId:pe.id})},[Or,pe?.id]),rr=_.useCallback(()=>{!e?.id||!s||(s(e.id),y(!1))},[e?.id,s]),ir=_.useCallback(Q=>{T(Q),requestAnimationFrame(()=>{H()})},[H]),Pi=_.useCallback(()=>{T(null)},[]),Ps=_.useCallback(Q=>{E(Q??null),C(!0)},[]),zr=_.useCallback(Q=>Me.mutateAsync(Q),[Me]),is=_.useCallback(()=>{nt.invalidateQueries({queryKey:Bd.all})},[nt]),{isConnected:Wr,isLoadingSnapshot:nr,isOutputActive:Hr,lastExitAt:Ur,logs:ys,entries:Li,attach:Kt}=ml({sessionId:st,sessionStatus:X?.status,sessionStartedAt:X?.startedAt??X?.createdAt,sessionEndedAt:X?.endedAt??(xe?null:X?.updatedAt),onExit:_.useCallback(()=>{nt.invalidateQueries({queryKey:["workspaces"]})},[nt])});_.useEffect(()=>{if(!e?.id)return;const Q=ls.connect();Q.emit(Fs.SUBSCRIBE,{topic:"task",id:e.id});const oe=pt=>{pt.taskId===e.id&&(nt.invalidateQueries({queryKey:["tasks"]}),is())},Ie=pt=>{pt.taskId===e.id&&(nt.invalidateQueries({queryKey:be.workspaces.list(e.id)}),is())},mt=pt=>{pt.taskId===e.id&&(nt.invalidateQueries({queryKey:be.workspaces.list(e.id)}),is())};return Q.on(dt.TASK_UPDATED,oe),Q.on(dt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ie),Q.on(dt.WORKSPACE_HIBERNATED,mt),()=>{Q.off(dt.TASK_UPDATED,oe),Q.off(dt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ie),Q.off(dt.WORKSPACE_HIBERNATED,mt),Q.emit(Fs.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,nt,is]),_.useEffect(()=>{if(!st)return;const Q=ls.connect(),oe=Ie=>{Ie.sessionId===st&&(nt.invalidateQueries({queryKey:["workspaces"]}),is())};return Q.on(dt.SESSION_COMPLETED,oe),()=>{Q.off(dt.SESSION_COMPLETED,oe)}},[st,nt,is]);const{todos:ee}=pl(Li),{files:ge,addFiles:Re,removeFile:ze,clear:_t,buildMarkdownLinks:Bt,hasFiles:Le,isUploading:Ft}=Kn(),ns=_.useMemo(()=>Hc(X),[X?.tokenUsage]),Ss=ol(ys,ns);_.useEffect(()=>{st&&Wr&&Kt()},[st,Wr,Kt]);const go=_.useRef(e?.id);_.useEffect(()=>{if(go.current!==e?.id&&O.current){const Q=O.current;requestAnimationFrame(()=>{Q.scrollTop=Q.scrollHeight})}go.current=e?.id},[e?.id,O]);const os=al(),Ii=_.useRef(!1),vo=_.useCallback(async()=>{if(!n.trim()&&!Le||!st||Ii.current||os.isPending||ve||Ft||vt)return;Ii.current=!0;const Q=Bt(),oe=[n.trim(),Q].filter(Boolean).join(`
|
|
76
|
+
|
|
77
|
+
`);a(""),_t(),L.current&&(L.current.style.height="60px"),Zt.mutate({id:st,message:oe,providerId:kt??void 0},{onSuccess:()=>{Kt()},onError:()=>{a(Ie=>Ie||oe)},onSettled:()=>{Ii.current=!1}})},[n,st,Zt,Kt,Le,Ft,Bt,_t,kt,vt,os.isPending,ve]),ud=_.useCallback(()=>{!st||os.isPending||os.mutate(st)},[st,os]),hd=_.useCallback(Q=>{const oe=Q.target.files;oe&&oe.length>0&&Re(Array.from(oe)),Q.target.value=""},[Re]),fd=_.useCallback(Q=>{const oe=Q.clipboardData.items,Ie=[];for(const mt of oe)if(mt.kind==="file"){const pt=mt.getAsFile();pt&&Ie.push(pt)}Ie.length>0&&(Q.preventDefault(),Re(Ie))},[Re]),[xo,Oi]=_.useState(!1),md=_.useCallback(Q=>{Q.preventDefault(),Oi(!0)},[]),pd=_.useCallback(Q=>{Q.preventDefault(),Oi(!1)},[]),gd=_.useCallback(Q=>{Q.preventDefault(),Oi(!1);const oe=Q.dataTransfer.files;oe.length>0&&Re(Array.from(oe))},[Re]),Jt=_.useCallback(Q=>{const oe=he.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Ie=oe?Math.max(Bs,oe-cn-vx-xx):Bs;return Math.max(Bs,Math.min(Math.round(Q),Ie))},[]),Bi=_.useCallback(Q=>{const oe=Q.clientX-G.current;K(Jt(de.current-oe))},[Jt]),Fi=_.useCallback(()=>{J(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);_.useEffect(()=>{if(Y)return document.addEventListener("mousemove",Bi),document.addEventListener("mouseup",Fi),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Bi),document.removeEventListener("mouseup",Fi),document.body.style.cursor="",document.body.style.userSelect=""}},[Fi,Bi,Y]);const vd=_.useCallback(Q=>{Q.preventDefault(),G.current=Q.clientX,de.current=B,J(!0)},[B]);_.useEffect(()=>{!U||Y||K(Q=>Jt(Q))},[Jt,U,Y]),_.useEffect(()=>{if(!U)return;const Q=()=>{K(oe=>Jt(oe))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[Jt,U]);const xd=_.useCallback(()=>{K(Q=>Jt(Q)),N(!0),requestAnimationFrame(()=>{w.current?.setTab("review")})},[Jt]),bd=_.useCallback(Q=>{a(Q.target.value);const oe=Q.target;oe.style.height="auto";const Ie=oe.scrollHeight;oe.style.height=`${Math.max(60,Math.min(Ie,300))}px`},[]),bo=$t&&tt?t.jsx(Vc,{projectId:e?.projectId??"",workspaceId:tt,branchName:ss,targetBranch:As,commitMessage:xs,changes:Gt,gitStatus:bt,isGitStatusLoading:Mi,canRunGitOperations:Ye,onOpenChanges:xd,onRefreshCommitMessage:bs,onConflict:Ps,className:"mb-1.5"}):null;return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?i("源码已删除"):i("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx(Gc,{taskId:e.id,title:e.title,readOnly:me})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(_x,{status:e.status,onChangeStatus:!me&&o?Q=>o(e.id,Q):void 0}),t.jsx(ll,{value:e.priority,onChange:!me&&p?Q=>p(e.id,Q):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:Fr,disabled:!wt||me,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:i("Open in IDE"),children:t.jsx(_i,{size:16})}),(s||Ke)&&!me&&t.jsxs("div",{className:"relative",ref:R,children:[t.jsx("button",{onClick:()=>A(Q=>!Q),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:i("More actions"),children:t.jsx(yl,{size:16})}),j&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[Ke&&t.jsxs("button",{onClick:()=>{v(!0),A(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(ds,{size:15}),t.jsx("span",{children:i("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{h(!0),A(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(Fd,{size:15}),t.jsx("span",{children:i("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{y(!0),A(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(gi,{size:15}),t.jsx("span",{children:i("删除任务")})]})]})]})]})]})]})]}),Ye&&tt&&bt&&t.jsx(nx,{workspaceId:tt,gitStatus:bt,onResolve:()=>Ps()}),t.jsxs("div",{ref:he,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:Oe&&Ne?D?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:i("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:D})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Uc,{session:X,providers:lt,usage:Ss,providerIdFallback:ye?.providerId,agentTypeFallback:X?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(je,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:Pi,children:[t.jsx($s,{size:13}),t.jsx("span",{children:i("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:O,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:q,className:"w-full max-w-4xl mx-auto",children:nr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:i("Loading logs...")})]}):ys.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:i(xe?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(si,{children:t.jsx(ti,{logs:ys,downloadSessionId:se,isOutputActive:Hr,lastExitAt:Ur,onUserToggleDetails:W,workingDir:wt,scrollElementRef:O,onOpenWorkspaceFile:re,onOpenPreviewUrl:Pe,onOpenVisualization:Ze})})})}),!V&&t.jsxs("button",{onClick:()=>H(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":i("Scroll to bottom"),children:[t.jsx(br,{size:14}),t.jsx("span",{children:i("回到底部")})]})]}),ee.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(ri,{todos:ee})})})]}):t.jsx(Yl,{teamRun:Ne,messages:at??Ne.messages??[],readOnly:me,readOnlyMessage:rt,onSendMessage:zr,onViewInvocationSession:ir,changeSummaryBar:bo,centered:!0,workingDir:wt,onOpenWorkspaceFile:re,onOpenPreviewUrl:Se,onOpenVisualization:we}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:O,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:q,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(Ge||Xe?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Ge?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:i("Loading...")}):Xe?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(Vn,{urlTransform:gx,components:fl,children:Xe.body})}):null}),!me&&t.jsx(Yc,{state:We,setupProgress:_e,sessionStarted:!!Ue?.startedAt,onRetry:ft&&m?.status==="failed"?Ds:void 0},e.id),le?(!Ce||me)&&t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:i("Loading...")})]}):ft?nr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:i("Loading logs...")})]}):ys.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:i(xe?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(si,{children:t.jsx(ti,{logs:ys,downloadSessionId:se,isOutputActive:Hr,lastExitAt:Ur,onUserToggleDetails:W,workingDir:wt,scrollElementRef:O,onOpenWorkspaceFile:re,onOpenPreviewUrl:Pe,onOpenVisualization:Ze})}):!Ce||m?.status==="failed"||_e?.status==="failed"||me?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(!Ce||me)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(Cs,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:i(me?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:me?rt:i("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")})]}),!me&&(!m||m.status==="failed")&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(je,{onClick:Ds,disabled:!!(m&&m.status!=="failed"),children:[t.jsx(Cs,{size:16,className:"mr-1.5"}),m?.status==="failed"?i("重试启动 Agent"):i("启动 Agent")]}),Ke&&t.jsxs(je,{variant:"outline",onClick:()=>v(!0),children:[t.jsx(ds,{size:16,className:"mr-1.5"}),i("创建 TeamRun")]})]})]}):null]})}),!V&&t.jsxs("button",{onClick:()=>H(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":i("Scroll to bottom"),children:[t.jsx(br,{size:14}),t.jsx("span",{children:i("回到底部")})]})]}),ee.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(ri,{todos:ee})})}),me?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:rt})})}):It?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:i("代码已合并,以上为历史沟通记录")}),t.jsxs(je,{size:"sm",onClick:Ds,children:[t.jsx(Cs,{size:14,className:"mr-1.5"}),i("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:md,onDragLeave:pd,onDrop:gd,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[bo,st?t.jsx(cl,{sessionId:st}):null,t.jsxs("div",{ref:$,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${xo?"border-info bg-info/5":"border-border"}`,children:[t.jsx(qn,{files:ge,onRemove:ze}),t.jsx("textarea",{ref:L,value:n,onChange:bd,onPaste:fd,onKeyDown:Q=>{Ut.handleKeyDown(Q)||Rt.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),vo())},rows:1,placeholder:i(xo?"Drop files here...":ft&&!xe?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:M,type:"file",multiple:!0,className:"hidden",onChange:hd}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>M.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:i("Upload file"),children:t.jsx(Yn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[Ue&<&&t.jsx(dl,{providers:lt,currentProviderId:kt,agentType:Ue.agentType,runtimeType:Ue.runtimeType,onSelect:St}),t.jsx(zn,{usage:Ss}),xe&&!n.trim()&&!Le?t.jsx("button",{onClick:ud,disabled:os.isPending||ve,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Us,{size:14})}):t.jsx("button",{onClick:vo,disabled:!n.trim()&&!Le||Ft||Zt.isPending||os.isPending||ve||!!vt,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||Le)&&!Ft&&!Zt.isPending&&!os.isPending&&!ve&&!vt?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(Un,{size:18})})]})]})]})]}),t.jsx(ei,{open:Rt.query!==null,anchorRef:$,commands:Rt.filteredCommands,selectedIndex:Rt.selectedIndex,query:Rt.query??"",hasCatalog:Rt.allCommands.length>0,onSelect:Rt.applyCommand}),t.jsx(ei,{open:Ut.query!==null,anchorRef:$,commands:Ut.filteredSkills,selectedIndex:Ut.selectedIndex,query:Ut.query??"",hasCatalog:Ut.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:Ut.applySkill})]})]})}),U&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:vd,role:"separator","aria-orientation":"vertical","aria-label":i("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:U?cn+B:cn},children:t.jsx(Fc,{sessionId:ft||void 0,workspaceId:Te,workingDir:wt,projectId:e.projectId,readOnly:me,repoDeleted:Fe,teamRun:Ne,teamStatus:Ne?t.jsx(ec,{teamRun:Ne,workspaces:ne,selectedWorkspaceId:Te,onSelectWorkspace:F,onViewInvocationSession:ir}):void 0,workspaces:ne,selectedWorkspaceId:Te,onSelectWorkspace:F,variant:"rail",expanded:U,onExpandedChange:Q=>{Q&&K(oe=>Jt(oe)),N(Q)},minContentWidth:Bs,tabRef:w,gitAvailable:$e,gitProps:Ye&&tt?{branchName:ss,targetBranch:As,commitMessage:xs,canRunGitOperations:!0,onRefreshCommitMessage:bs,onConflict:Ps,onResolveConflicts:()=>Ps()}:void 0})})]}),!me&&t.jsx(Wc,{isOpen:d,onClose:()=>c(!1),taskId:e.id,projectId:e.projectId,taskTitle:Xe?.title??e.title,taskDescription:Xe?.body??"",taskPrompt:Xe?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>x?.(e.id)}),Ke&&!me&&t.jsx(ix,{isOpen:g,onClose:()=>v(!1),taskId:e.id}),Ye&&tr&&it&&t.jsx(qc,{open:S,onOpenChange:Q=>{C(Q),Q||E(null)},workspaceId:tr,conflictOp:it.conflictOp,conflictedFiles:it.conflictedFiles,sourceBranch:Lr,targetBranch:Ir,operation:bt?.operation,worktreePath:Pr,mergeAborted:it.mergeAborted,mergeStrategy:it.mergeStrategy,sourceWorkspaceId:it.sourceWorkspaceId,targetWorkspaceId:it.targetWorkspaceId,sourceWorktreePath:it.sourceWorktreePath,targetWorktreePath:it.targetWorktreePath,sessions:Qt,currentSessionId:Oe?void 0:ft,teamRunId:Ne?.id}),t.jsx(Dn,{isOpen:l,onClose:()=>h(!1),onConfirm:Di,title:i("重新开始任务"),description:t.jsx("p",{children:i("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:i("确认重试"),variant:"default",isLoading:u}),t.jsx(io,{isOpen:b,onClose:()=>y(!1),onConfirm:rr,taskId:e.id,taskTitle:e.title,workspaces:ne,isLoading:r})]}):t.jsx(bx,{})}function po(e){switch(e){case Vt.TODO:return Ee.Pending;case Vt.IN_PROGRESS:return Ee.Running;case Vt.IN_REVIEW:return Ee.Review;case Vt.DONE:return Ee.Done;case Vt.CANCELLED:return Ee.Cancelled}}function Sx(e){switch(e){case Ee.Pending:return Vt.TODO;case Ee.Running:return Vt.IN_PROGRESS;case Ee.Review:return Vt.IN_REVIEW;case Ee.Done:return Vt.DONE;case Ee.Cancelled:return Vt.CANCELLED}}function wx(e){switch(e){case Et.CLAUDE_CODE:return"Claude Code";case Et.GEMINI_CLI:return"Gemini CLI";case Et.CURSOR_AGENT:return"Cursor Agent";case Et.CODEX:return"Codex";case Et.QWEN_CODE:return"Qwen Code";case Et.KIRO_CLI:return"Kiro CLI";case Et.OPENCODE:return"OpenCode";case Et.PI_CODING_AGENT:return"Pi Coding Agent";case Et.GROK_BUILD:return"Grok Build";case Et.MINION_CODE:return"Minion Code";case Et.DEEPSEEK_HERMES:return"DeepSeek Harness"}}const mi=["text-indigo-600","text-emerald-600","text-rose-600","text-amber-600","text-cyan-600","text-violet-600","text-teal-600","text-pink-600"];function Qc(e,s){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%s}function Cx(e){return{id:e.id,name:e.name,color:e.color||mi[Qc(e.name,mi.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function kx(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===xt.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:e.projectId,title:e.title,status:po(e.status),priority:e.priority,agent:e.latestAgentType?wx(e.latestAgentType):"—",branch:r,description:"",updatedAt:new Date(e.updatedAt).toISOString(),isGitRepo:s?.isGitRepo,worktreeReady:s?.worktreeReady,reason:s?.reason,projectArchivedAt:s?.archivedAt??null,projectRepoDeletedAt:s?.repoDeletedAt??null}}function Ex(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===xt.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||mi[Qc(s.name,mi.length)],title:e.title,status:po(e.status),priority:e.priority,branch:r,mainBranch:s.mainBranch??"main",description:"",isGitRepo:s.isGitRepo,worktreeReady:s.worktreeReady,reason:s.reason,projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const Pa={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function jx(e){const s=e.split("/");return s[s.length-1]||e}function Nx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function Rx({workingDir:e,filePath:s,type:r}){const{t:o}=ce(),{data:p,isLoading:m,isError:x}=jc(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(x)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const n=i.split(`
|
|
78
|
+
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:n.map((a,d)=>{let c="",g="text-neutral-400";return a.startsWith("+")&&!a.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):a.startsWith("-")&&!a.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):a.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:Z("px-3 whitespace-pre",c,g),children:a},d)})})}function Ax({entry:e,type:s,workingDir:r}){const[o,p]=_.useState(!1),m=Pa[e.status]||Pa.M,x=Nx(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:Z("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:Z("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:jx(e.path)}),x&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:x})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(Ct,{size:14}):t.jsx(Nt,{size:14})})]}),o&&t.jsx(Rx,{workingDir:r,filePath:e.path,type:s})]})}function La({title:e,entries:s,type:r,workingDir:o,defaultOpen:p}){const{t:m}=ce(),[x,i]=_.useState(p);return s.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>i(n=>!n),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[t.jsx("span",{className:"text-neutral-400",children:x?t.jsx(Ct,{size:14}):t.jsx(Nt,{size:14})}),t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:m(e)}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:s.length})]}),x&&t.jsx("div",{className:"divide-y divide-neutral-100",children:s.map(n=>t.jsx(Ax,{entry:n,type:r,workingDir:o},`${r}:${n.path}`))})]})}function Tx({workingDir:e}){const{t:s}=ce(),{data:r,isLoading:o,isError:p}=Ti(e);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")});if(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading changes...")})]});if(p)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load changes.")});const m=r?.uncommitted||[],x=r?.committed||[];return m.length+x.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Qs,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No pending changes")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx(La,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(La,{title:"Committed",entries:x,type:"committed",workingDir:e,defaultOpen:!1})]})}const dn=50,Ia={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function Mx(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Tt("{count}s ago",{count:r}):r<3600?Tt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Tt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Tt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Dx(e){const s=e.split("/");return s[s.length-1]||e}function Px(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function Lx({workingDir:e,hash:s,filePath:r}){const{t:o}=ce(),{data:p,isLoading:m,isError:x}=mo(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(x)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const n=i.split(`
|
|
79
|
+
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:n.map((a,d)=>{let c="",g="text-neutral-400";return a.startsWith("+")&&!a.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):a.startsWith("-")&&!a.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):a.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:Z("px-3 whitespace-pre",c,g),children:a},d)})})}function Ix({entry:e,workingDir:s,hash:r}){const[o,p]=_.useState(!1),m=Ia[e.status]||Ia.M,x=Px(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:Z("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:Z("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Dx(e.path)}),x&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:x})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(Ct,{size:14}):t.jsx(Nt,{size:14})})]}),o&&t.jsx(Lx,{workingDir:s,hash:r,filePath:e.path})]})}function Ox({commit:e,workingDir:s}){const{t:r}=ce(),[o,p]=_.useState(!1),{data:m,isLoading:x}=fo(s,o?e.hash:null),i=m?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(n=>!n),className:Z("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:t.jsx("div",{className:Z("w-2.5 h-2.5 rounded-full shrink-0",o?"bg-blue-500":"bg-neutral-300")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),t.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),t.jsx("span",{className:"text-[11px] text-neutral-400",children:Mx(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(Ct,{size:14}):t.jsx(Nt,{size:14})})]}),o&&t.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&t.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),x?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):i.length===0?t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):t.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(n=>t.jsx(Ix,{entry:n,workingDir:s,hash:e.hash},n.path))})]})]})}function Bx({workingDir:e}){const{t:s}=ce(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:x,isFetchingNextPage:i}=Xn({queryKey:be.git.log(e||""),queryFn:({pageParam:a=0})=>Ae.get("/git/log",{params:{workingDir:e||"",limit:String(dn),skip:String(a)}}),initialPageParam:0,getNextPageParam:(a,d)=>a.commits.length<dn?void 0:d.length*dn,enabled:!!e}),n=r?.pages.flatMap(a=>a.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):p?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):n.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Vs,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No commit history")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(a=>t.jsx(Ox,{commit:a,workingDir:e},a.hash))}),x&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:i,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:i?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:14,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")})}const Fx=Cr(),zx=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Fx}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function Wx({status:e}){const s={[Ee.Running]:"bg-blue-500",[Ee.Review]:"bg-amber-500",[Ee.Pending]:"bg-neutral-400",[Ee.Done]:"bg-emerald-500",[Ee.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const Hx=[{key:"chat",label:"Chat",icon:vi},{key:"changes",label:"Changes",icon:Qs},{key:"history",label:"History",icon:Vs},{key:"workspace",label:"Workspace",icon:bi}],Ux=[{key:"chat",label:"Team room",icon:vi},{key:"team-status",label:"Team Status",icon:Es},{key:"changes",label:"Changes",icon:Qs},{key:"workspace",label:"Workspace",icon:bi}];function $x({task:e,onBack:s,onDeleteTask:r,onTaskPriorityChange:o,isDeleting:p,autoStartState:m,onAutoStartRecovered:x}){const{t:i}=ce(),n=Xs(ee=>ee.setVisibleContext),[a,d]=_.useState("chat"),[c,g]=_.useState(""),[v,b]=_.useState(!1),[y,l]=_.useState(!1),[h,u]=_.useState(!1),[f,S]=_.useState(null),[C,k]=_.useState(void 0),E=_.useRef(0),[w,j]=_.useState(),A=_.useRef(null),D=_.useRef(null),T=_.useRef(null),P=_.useRef(null),{scrollRef:F,contentRef:I,isAtBottom:z,scrollToBottom:$,stopScroll:R}=Bn({resize:"smooth",initial:"instant"}),L=Lt();_.useEffect(()=>{if(!h)return;const ee=ge=>{D.current&&!D.current.contains(ge.target)&&u(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[h]);const{data:M,isLoading:O}=Pn(e.id),q=zc(e.id),V=q?.status==="completed"&&m?.status!=="failed"?null:m,H=!!(V||q&&q.status!=="completed"),{data:W}=Ga(e.id),{data:U}=Qa(W?.id??""),N=Mn(W?.id??""),B=W??null,K=e.isGitRepo!==!1&&e.worktreeReady!==!1,Y=_.useMemo(()=>(B?Ux:Hx).filter(ee=>K||ee.key!=="changes"&&ee.key!=="history"),[K,B]),J=W===null,{data:G,isLoading:de}=Za(e.id,J),he=!!e.projectArchivedAt,re=!!e.projectRepoDeletedAt,ne=i(re?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");_.useEffect(()=>{k(void 0),S(null),j(void 0)},[e.id]),_.useEffect(()=>{B&&a==="history"&&d("chat"),!B&&a==="team-status"&&d("chat"),Y.some(ee=>ee.key===a)||d("chat")},[a,Y,B]);const le=_.useMemo(()=>Xl(M,B,C),[C,B,M]);_.useEffect(()=>{C&&!M?.some(ee=>ee.id===C)&&k(void 0)},[C,M]);const _e=_.useMemo(()=>M?.find(ee=>ee.id===le),[le,M]),We=_.useMemo(()=>{if(M){if(_e)return hs(_e);for(const ee of M)if(ee.status==="ACTIVE"&&hs(ee))return hs(ee);return hs(M[0])}},[_e,M]),Ce=_e?.status===Mt.ACTIVE?_e.id:void 0,He=K&&Gl(_e,B),at=_e?.branchName??"",Me=_e?.commitMessage,Ne=_.useMemo(()=>Ql(_e,M,e?.mainBranch??""),[_e,e?.mainBranch,M]),Oe=!!(He&&Ce&&We&&!he),{data:$e,isLoading:Ke}=Ln(Ce??"",{enabled:Oe}),{data:De}=Ti(We,{enabled:Oe}),Xe=De?.committed?.length,[Ge,Te]=_.useState(!1),[pe,tt]=_.useState(null);_.useEffect(()=>{const ee=K&&(a==="changes"||a==="chat"&&Oe)?"changes":K&&a==="history"?"history":null;if(!Ce||!We||!ee){n(null);return}return n({workspaceId:Ce,workingDir:We,tab:ee}),()=>{n(null)}},[a,K,Ce,n,Oe,We]);const Ye=_.useMemo(()=>$e?.conflictOp&&$e.conflictedFiles.length>0?{conflictOp:$e.conflictOp,conflictedFiles:$e.conflictedFiles}:pe,[$e?.conflictOp,$e?.conflictedFiles,pe]),Ue=Ye?.targetWorkspaceId??Ce,ft=Ye?.targetWorktreePath??_e?.worktreePath,st=Ye?.sourceBranch??at,te=Ye?.targetBranch??Ne,fe=_e?.sessions??[],ye=_.useCallback(ee=>{tt(ee??null),Te(!0)},[]),X=_.useCallback(()=>e?.id?L.invalidateQueries({queryKey:be.workspaces.list(e.id)}):Promise.resolve(),[e?.id,L]),se=_.useCallback(async()=>L.fetchQuery({queryKey:be.tasks.body(e.id),queryFn:()=>Ae.get(`/tasks/${e.id}/body`)}),[L,e.id]),ie=_.useMemo(()=>{if(!M)return null;const ee=M.filter(Le=>Le.status==="ACTIVE"&&Array.isArray(Le.sessions)).flatMap(Le=>Le.sessions??[]),ge=Le=>{const Ft=Le.createdAt,ns=Le.endedAt??Le.startedAt??Ft;if(!ns)return 0;const Ss=Date.parse(ns);return Number.isNaN(Ss)?0:Ss},Re=Le=>{const Ft=ee.filter(ns=>Le.includes(ns.status));return Ft.length===0?null:Ft.sort((ns,Ss)=>ge(Ss)-ge(ns))[0]??null},ze=Re([ut.RUNNING])??Re([ut.PENDING])??Re([ut.COMPLETED,ut.FAILED,ut.CANCELLED]);if(ze)return ze;const Bt=M.filter(Le=>(Le.status==="ABANDONED"||Le.status==="MERGED"||Le.status==="HIBERNATED")&&Array.isArray(Le.sessions)).flatMap(Le=>Le.sessions??[]).filter(Le=>[ut.COMPLETED,ut.FAILED,ut.CANCELLED].includes(Le.status));return Bt.length===0?null:Bt.sort((Le,Ft)=>ge(Ft)-ge(Le))[0]??null},[M]),ae=ie?.id??"",Se=B?f??"":ae,we=_.useMemo(()=>{if(!f||!M)return null;for(const ee of M){const ge=ee.sessions?.find(Re=>Re.id===f);if(ge)return ge}return null},[f,M]),Pe=_.useMemo(()=>{if(!f||!B?.invocations)return null;const ee=B.invocations.filter(ge=>ge.sessionId===f);return ee.length===0?null:ee.sort((ge,Re)=>{const ze=Date.parse(ge.updatedAt??ge.createdAt??""),_t=Date.parse(Re.updatedAt??Re.createdAt??"");return(Number.isNaN(_t)?0:_t)-(Number.isNaN(ze)?0:ze)})[0]??null},[f,B?.invocations]),Ze=_.useMemo(()=>!Pe?.memberId||!B?.members?null:B.members.find(ee=>ee.id===Pe.memberId)??null,[Pe?.memberId,B?.members]),xe=f?we:ie??null,ve=xe?.id,me=_.useMemo(()=>{if(xe?.workspaceId)return xe.workspaceId;if(!(!xe||!M))return M.find(ee=>ee.sessions?.some(ge=>ge.id===xe.id))?.id},[xe,M]),Fe=_.useCallback((ee,ge)=>{const ze=(ge&&M?.some(_t=>_t.id===ge)?ge:void 0)??me??le??void 0;ze&&k(ze),E.current+=1,j({id:E.current,source:ee,workspaceId:ze}),d("workspace")},[me,le,M]),rt=_.useCallback((ee,ge)=>{Fe({kind:"web",url:ee},ge)},[Fe]),lt=_.useCallback((ee,ge,Re)=>{Fe({kind:"visualization",sessionId:ee,file:ge},Re)},[Fe]),kt=_.useCallback(ee=>{rt(ee,me)},[me,rt]),St=_.useCallback(ee=>{ve&<(ve,ee,me)},[ve,me,lt]),{isActive:vt,isCancelling:It}=il(ve??"",xe?.status),wt=_.useMemo(()=>!ie||!M?!1:!M.some(ge=>ge.status==="ACTIVE"&&ge.sessions?.some(Re=>Re.id===ie.id)),[ie,M]),{data:Rt}=Gs(),[Ut,er]=_.useState(null),$t=Ut?.sessionId===ae?Ut.providerId:ie?.providerId??null,bt=ie?gl(Rt,$t):void 0,Mi=_.useCallback(ee=>{er({sessionId:ae,providerId:ee})},[ae]),Gt=nl({agentType:ie?.agentType,workingDir:We,input:c,setInput:g,textareaRef:T,minHeight:40,maxHeight:140}),Qt=Xc({agentType:ie?.agentType,workingDir:We,input:c,setInput:g,textareaRef:T,minHeight:40,maxHeight:140}),ss=We&&_e?_e.id:void 0,xs=Wn(),As=On(),it=al(),{isConnected:tr,isLoadingSnapshot:Pr,isOutputActive:Lr,lastExitAt:Ir,logs:nt,entries:Ts,attach:bs}=ml({sessionId:Se,sessionStatus:xe?.status,sessionStartedAt:xe?.startedAt??xe?.createdAt,sessionEndedAt:xe?.endedAt??(vt?null:xe?.updatedAt),onExit:_.useCallback(()=>{L.invalidateQueries({queryKey:["workspaces"]})},[L])}),{todos:Zt}=pl(Ts),{files:Or,addFiles:_s,removeFile:Br,clear:sr,buildMarkdownLinks:Ms,hasFiles:Ot,isUploading:rs}=Kn(),Di=_.useMemo(()=>Hc(xe),[xe?.tokenUsage]),Ds=ol(nt,Di);_.useEffect(()=>{Se&&tr&&bs()},[Se,tr,bs]);const Fr=_.useRef(null);_.useEffect(()=>{if(Fr.current!==e.id&&F.current){const ee=F.current;requestAnimationFrame(()=>{ee.scrollTop=ee.scrollHeight})}Fr.current=e.id},[e.id,F]);const rr=_.useRef(!1),ir=_.useCallback(async()=>{if(!c.trim()&&!Ot||!ae||rr.current||it.isPending||It||rs||bt)return;rr.current=!0;const ee=Ms(),ge=[c.trim(),ee].filter(Boolean).join(`
|
|
80
|
+
|
|
81
|
+
`);g(""),sr(),T.current&&(T.current.style.height="40px"),xs.mutate({id:ae,message:ge,providerId:$t??void 0},{onSuccess:()=>bs(),onError:()=>g(Re=>Re||ge),onSettled:()=>{rr.current=!1}})},[c,ae,xs,bs,Ot,rs,Ms,sr,$t,bt,it.isPending,It]),Pi=_.useCallback(()=>{!ae||it.isPending||it.mutate(ae)},[ae,it]),Ps=_.useCallback(ee=>N.mutateAsync(ee),[N]),zr=_.useCallback(ee=>{S(ee),d("chat"),requestAnimationFrame(()=>{$()})},[$]),is=_.useCallback(()=>{S(null)},[]),Wr=_.useCallback(()=>{d("changes")},[]),nr=Oe&&Ce?t.jsx(Vc,{projectId:e?.projectId??"",workspaceId:Ce,branchName:at,targetBranch:Ne,commitMessage:Me,changes:De,gitStatus:$e,isGitStatusLoading:Ke,canRunGitOperations:He,onOpenChanges:Wr,onRefreshCommitMessage:X,onConflict:ye,className:"mb-2"}):null,Hr=_.useCallback(ee=>{const ge=ee.target.files;ge&&ge.length>0&&_s(Array.from(ge)),ee.target.value=""},[_s]),Ur=_.useCallback(ee=>{const ge=ee.clipboardData.items,Re=[];for(const ze of ge)if(ze.kind==="file"){const _t=ze.getAsFile();_t&&Re.push(_t)}Re.length>0&&(ee.preventDefault(),_s(Re))},[_s]),ys=_.useCallback(ee=>{g(ee.target.value);const ge=ee.target;ge.style.height="auto",ge.style.height=`${Math.max(40,Math.min(ge.scrollHeight,140))}px`},[]),Li=_.useCallback(()=>{ss&&As.mutate({workspaceId:ss})},[As,ss]),Kt=_.useRef(null);return _.useEffect(()=>{const ee=window.visualViewport;if(!ee)return;let ge=!1;const Re=()=>{Kt.current&&(Kt.current.style.height=`${ee.height}px`,Kt.current.style.top=`${ee.offsetTop}px`)},ze=()=>Re(),_t=()=>{ge||Re()},Bt=()=>{ge=!0},Le=()=>{ge=!1,requestAnimationFrame(Re)};return ee.addEventListener("resize",ze),ee.addEventListener("scroll",_t),document.addEventListener("touchstart",Bt,{passive:!0}),document.addEventListener("touchend",Le,{passive:!0}),document.addEventListener("touchcancel",Le,{passive:!0}),()=>{ee.removeEventListener("resize",ze),ee.removeEventListener("scroll",_t),document.removeEventListener("touchstart",Bt),document.removeEventListener("touchend",Le),document.removeEventListener("touchcancel",Le)}},[]),_.useEffect(()=>{const ee=Kt.current;if(!ee)return;const ge=Re=>{let ze=Re.target;for(;ze&&ze!==ee;){if(ze.tagName==="TEXTAREA"){if(ze.scrollHeight>ze.clientHeight)return;ze=ze.parentElement;continue}const Bt=window.getComputedStyle(ze).overflowY;if((Bt==="auto"||Bt==="scroll")&&ze.scrollHeight>ze.clientHeight)return;ze=ze.parentElement}Re.preventDefault()};return ee.addEventListener("touchmove",ge,{passive:!1}),()=>ee.removeEventListener("touchmove",ge)},[]),t.jsxs("div",{ref:Kt,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx($s,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx(Gc,{taskId:e.id,title:e.title,readOnly:he,titleClassName:"text-[13px] font-bold text-neutral-900 truncate leading-tight",compact:!0}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?i("源码已删除"):i("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(Wx,{status:e.status}),t.jsx(ll,{value:e.priority,compact:!0,onChange:!he&&o?ee=>o(e.id,ee):void 0}),t.jsx("button",{onClick:Li,disabled:!ss||he,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(_i,{size:16})}),r&&!he&&t.jsxs("div",{className:"relative",ref:D,children:[t.jsx("button",{onClick:()=>u(ee=>!ee),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(yl,{size:16})}),h&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:t.jsxs("button",{onClick:()=>{l(!0),u(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[t.jsx(gi,{size:15}),t.jsx("span",{children:i("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:Y.map(({key:ee,label:ge,icon:Re})=>t.jsxs("button",{onClick:()=>d(ee),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${a===ee?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Re,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:i(ge)})]},ee))})]}),a==="chat"&&(B?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:f?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:i("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:f})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Uc,{session:xe,providers:Rt,usage:Ds,compact:!0,providerIdFallback:Ze?.providerId,agentTypeFallback:xe?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(je,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:is,children:[t.jsx($s,{size:12}),t.jsx("span",{children:i("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:F,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:I,children:Pr?t.jsx(un,{label:i("Loading logs...")}):nt.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:i(vt?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(si,{children:t.jsx(ti,{logs:nt,downloadSessionId:ve,isOutputActive:Lr,lastExitAt:Ir,onUserToggleDetails:R,scrollElementRef:F,onOpenPreviewUrl:kt,onOpenVisualization:St})})})}),!z&&t.jsxs("button",{onClick:()=>$(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":i("Scroll to bottom"),children:[t.jsx(br,{size:12}),t.jsx("span",{children:i("回到底部")})]})]}),Zt.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(ri,{todos:Zt,compact:!0})})]}):t.jsx(Yl,{teamRun:B,messages:U??B.messages??[],readOnly:he,readOnlyMessage:ne,onSendMessage:Ps,onViewInvocationSession:zr,changeSummaryBar:nr,compactComposer:!0,workingDir:We,onOpenPreviewUrl:rt,onOpenVisualization:lt})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:F,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:I,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:de?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:i("Loading...")}):G?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(Vn,{urlTransform:zx,components:fl,children:G.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!he&&t.jsx(Yc,{state:V,setupProgress:q,sessionStarted:!!ie?.startedAt,onRetry:ae&&m?.status==="failed"?async()=>{await se(),b(!0)}:void 0,compact:!0},e.id),O?(!H||he)&&t.jsx(un,{label:"Loading..."}):ae?Pr?t.jsx(un,{label:"Loading logs..."}):nt.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:vt?"Waiting for agent output...":"No logs recorded."}):t.jsx(si,{children:t.jsx(ti,{logs:nt,downloadSessionId:ve,isOutputActive:Lr,lastExitAt:Ir,onUserToggleDetails:R,scrollElementRef:F,onOpenPreviewUrl:kt,onOpenVisualization:St})}):!H||m?.status==="failed"||q?.status==="failed"||he?t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(!H||he)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(Cs,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:i("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:he?ne:i("选择一个 Agent 来执行此任务")})]}),!he&&(!m||m.status==="failed")&&t.jsxs(je,{onClick:async()=>{await se(),b(!0)},disabled:!!(m&&m.status!=="failed"),children:[t.jsx(Cs,{size:16,className:"mr-1.5"}),m?.status==="failed"?i("重试启动 Agent"):i("启动 Agent")]})]}):null]})}),!z&&t.jsxs("button",{onClick:()=>$(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[t.jsx(br,{size:12}),t.jsx("span",{children:i("回到底部")})]})]}),Zt.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(ri,{todos:Zt,compact:!0})}),he?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:ne})}):wt?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:i("代码已合并,以上为历史沟通记录")}),t.jsxs(je,{size:"sm",onClick:async()=>{await se(),b(!0)},children:[t.jsx(Cs,{size:14,className:"mr-1.5"}),i("启动新 Agent")]})]})}):ae&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[nr,t.jsx(cl,{sessionId:Se||ae,compact:!0}),t.jsxs("div",{ref:A,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(qn,{files:Or,onRemove:Br}),t.jsx("textarea",{ref:T,value:c,onChange:ys,onPaste:Ur,onKeyDown:ee=>{Qt.handleKeyDown(ee)||Gt.handleKeyDown(ee)||ee.key==="Enter"&&!ee.shiftKey&&!ee.repeat&&!ee.nativeEvent.isComposing&&ee.nativeEvent.keyCode!==229&&(ee.preventDefault(),ir())},rows:1,placeholder:vt?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),t.jsx("input",{ref:P,type:"file",multiple:!0,className:"hidden",onChange:Hr}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>P.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(Yn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[ie&&Rt&&t.jsx(dl,{providers:Rt,currentProviderId:$t,agentType:ie.agentType,runtimeType:ie.runtimeType,onSelect:Mi}),t.jsx(zn,{usage:Ds}),vt&&!c.trim()&&!Ot?t.jsx("button",{onClick:Pi,disabled:it.isPending||It,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Us,{size:12})}):t.jsx("button",{onClick:ir,disabled:!c.trim()&&!Ot||rs||xs.isPending||it.isPending||It||!!bt,className:`p-1.5 rounded-lg transition-colors ${(c.trim()||Ot)&&!rs&&!xs.isPending&&!it.isPending&&!It&&!bt?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(Un,{size:15})})]})]})]}),t.jsx(ei,{open:Gt.query!==null,anchorRef:A,commands:Gt.filteredCommands,selectedIndex:Gt.selectedIndex,query:Gt.query??"",hasCatalog:Gt.allCommands.length>0,compact:!0,onSelect:Gt.applyCommand}),t.jsx(ei,{open:Qt.query!==null,anchorRef:A,commands:Qt.filteredSkills,selectedIndex:Qt.selectedIndex,query:Qt.query??"",hasCatalog:Qt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Qt.applySkill})]})]})),a==="team-status"&&B&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(ec,{teamRun:B,workspaces:M,selectedWorkspaceId:le,onSelectWorkspace:k,onViewInvocationSession:zr})}),a==="changes"&&K&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[M&&M.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(Bc,{workspaces:M,teamRun:B,selectedWorkspaceId:le,onSelectWorkspace:k,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),He&&Ce&&t.jsx("div",{className:"shrink-0",children:t.jsx(Mc,{projectId:e.projectId,workspaceId:Ce,branchName:at,targetBranch:Ne,commitMessage:Me,committedFileCount:Xe,onRefreshCommitMessage:X,onConflict:ye,onResolveConflicts:()=>ye()})}),t.jsx(Tx,{workingDir:We})]}),a==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(Bx,{workingDir:We})}),a==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(Fc,{sessionId:ae||void 0,workspaceId:le,workingDir:We,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:K,readOnly:he,repoDeleted:re,previewRequest:w,onPreviewRequestHandled:ee=>{j(ge=>ge?.id===ee?void 0:ge)}})}),!he&&t.jsx(Wc,{isOpen:v,onClose:()=>b(!1),taskId:e.id,projectId:e.projectId,taskTitle:G?.title??e.title,taskDescription:G?.body??"",taskPrompt:G?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>x?.(e.id)}),t.jsx(io,{isOpen:y,onClose:()=>l(!1),onConfirm:()=>{r?.(e.id),l(!1)},taskId:e.id,taskTitle:e.title,workspaces:M,isLoading:p}),Ge&&Ye&&Ue&&t.jsx(qc,{open:Ge,onOpenChange:ee=>{Te(ee),ee||tt(null)},workspaceId:Ue,conflictOp:Ye.conflictOp,conflictedFiles:Ye.conflictedFiles,sourceBranch:st,targetBranch:te,operation:$e?.operation,worktreePath:ft,mergeAborted:Ye.mergeAborted,mergeStrategy:Ye.mergeStrategy,sourceWorkspaceId:Ye.sourceWorkspaceId,targetWorkspaceId:Ye.targetWorkspaceId,sourceWorktreePath:Ye.sourceWorktreePath,targetWorktreePath:Ye.targetWorktreePath,sessions:fe,currentSessionId:B?void 0:ae,teamRunId:B?.id})]})}function un({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var Kx=Object.defineProperty,pi=Object.getOwnPropertySymbols,Zc=Object.prototype.hasOwnProperty,Jc=Object.prototype.propertyIsEnumerable,Oa=(e,s,r)=>s in e?Kx(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,Rn=(e,s)=>{for(var r in s||(s={}))Zc.call(s,r)&&Oa(e,r,s[r]);if(pi)for(var r of pi(s))Jc.call(s,r)&&Oa(e,r,s[r]);return e},An=(e,s)=>{var r={};for(var o in e)Zc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&pi)for(var o of pi(e))s.indexOf(o)<0&&Jc.call(e,o)&&(r[o]=e[o]);return r};var js;(e=>{const s=class ke{constructor(n,a,d,c){if(this.version=n,this.errorCorrectionLevel=a,this.modules=[],this.isFunction=[],n<ke.MIN_VERSION||n>ke.MAX_VERSION)throw new RangeError("Version value out of range");if(c<-1||c>7)throw new RangeError("Mask value out of range");this.size=n*4+17;let g=[];for(let b=0;b<this.size;b++)g.push(!1);for(let b=0;b<this.size;b++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const v=this.addEccAndInterleave(d);if(this.drawCodewords(v),c==-1){let b=1e9;for(let y=0;y<8;y++){this.applyMask(y),this.drawFormatBits(y);const l=this.getPenaltyScore();l<b&&(c=y,b=l),this.applyMask(y)}}p(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(n,a){const d=e.QrSegment.makeSegments(n);return ke.encodeSegments(d,a)}static encodeBinary(n,a){const d=e.QrSegment.makeBytes(n);return ke.encodeSegments([d],a)}static encodeSegments(n,a,d=1,c=40,g=-1,v=!0){if(!(ke.MIN_VERSION<=d&&d<=c&&c<=ke.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let b,y;for(b=d;;b++){const f=ke.getNumDataCodewords(b,a)*8,S=x.getTotalBits(n,b);if(S<=f){y=S;break}if(b>=c)throw new RangeError("Data too long")}for(const f of[ke.Ecc.MEDIUM,ke.Ecc.QUARTILE,ke.Ecc.HIGH])v&&y<=ke.getNumDataCodewords(b,f)*8&&(a=f);let l=[];for(const f of n){r(f.mode.modeBits,4,l),r(f.numChars,f.mode.numCharCountBits(b),l);for(const S of f.getData())l.push(S)}p(l.length==y);const h=ke.getNumDataCodewords(b,a)*8;p(l.length<=h),r(0,Math.min(4,h-l.length),l),r(0,(8-l.length%8)%8,l),p(l.length%8==0);for(let f=236;l.length<h;f^=253)r(f,8,l);let u=[];for(;u.length*8<l.length;)u.push(0);return l.forEach((f,S)=>u[S>>>3]|=f<<7-(S&7)),new ke(b,a,u,g)}getModule(n,a){return 0<=n&&n<this.size&&0<=a&&a<this.size&&this.modules[a][n]}getModules(){return this.modules}drawFunctionPatterns(){for(let d=0;d<this.size;d++)this.setFunctionModule(6,d,d%2==0),this.setFunctionModule(d,6,d%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const n=this.getAlignmentPatternPositions(),a=n.length;for(let d=0;d<a;d++)for(let c=0;c<a;c++)d==0&&c==0||d==0&&c==a-1||d==a-1&&c==0||this.drawAlignmentPattern(n[d],n[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(n){const a=this.errorCorrectionLevel.formatBits<<3|n;let d=a;for(let g=0;g<10;g++)d=d<<1^(d>>>9)*1335;const c=(a<<10|d)^21522;p(c>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,o(c,g));this.setFunctionModule(8,7,o(c,6)),this.setFunctionModule(8,8,o(c,7)),this.setFunctionModule(7,8,o(c,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,o(c,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,o(c,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,o(c,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let n=this.version;for(let d=0;d<12;d++)n=n<<1^(n>>>11)*7973;const a=this.version<<12|n;p(a>>>18==0);for(let d=0;d<18;d++){const c=o(a,d),g=this.size-11+d%3,v=Math.floor(d/3);this.setFunctionModule(g,v,c),this.setFunctionModule(v,g,c)}}drawFinderPattern(n,a){for(let d=-4;d<=4;d++)for(let c=-4;c<=4;c++){const g=Math.max(Math.abs(c),Math.abs(d)),v=n+c,b=a+d;0<=v&&v<this.size&&0<=b&&b<this.size&&this.setFunctionModule(v,b,g!=2&&g!=4)}}drawAlignmentPattern(n,a){for(let d=-2;d<=2;d++)for(let c=-2;c<=2;c++)this.setFunctionModule(n+c,a+d,Math.max(Math.abs(c),Math.abs(d))!=1)}setFunctionModule(n,a,d){this.modules[a][n]=d,this.isFunction[a][n]=!0}addEccAndInterleave(n){const a=this.version,d=this.errorCorrectionLevel;if(n.length!=ke.getNumDataCodewords(a,d))throw new RangeError("Invalid argument");const c=ke.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][a],g=ke.ECC_CODEWORDS_PER_BLOCK[d.ordinal][a],v=Math.floor(ke.getNumRawDataModules(a)/8),b=c-v%c,y=Math.floor(v/c);let l=[];const h=ke.reedSolomonComputeDivisor(g);for(let f=0,S=0;f<c;f++){let C=n.slice(S,S+y-g+(f<b?0:1));S+=C.length;const k=ke.reedSolomonComputeRemainder(C,h);f<b&&C.push(0),l.push(C.concat(k))}let u=[];for(let f=0;f<l[0].length;f++)l.forEach((S,C)=>{(f!=y-g||C>=b)&&u.push(S[f])});return p(u.length==v),u}drawCodewords(n){if(n.length!=Math.floor(ke.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let a=0;for(let d=this.size-1;d>=1;d-=2){d==6&&(d=5);for(let c=0;c<this.size;c++)for(let g=0;g<2;g++){const v=d-g,y=(d+1&2)==0?this.size-1-c:c;!this.isFunction[y][v]&&a<n.length*8&&(this.modules[y][v]=o(n[a>>>3],7-(a&7)),a++)}}p(a==n.length*8)}applyMask(n){if(n<0||n>7)throw new RangeError("Mask value out of range");for(let a=0;a<this.size;a++)for(let d=0;d<this.size;d++){let c;switch(n){case 0:c=(d+a)%2==0;break;case 1:c=a%2==0;break;case 2:c=d%3==0;break;case 3:c=(d+a)%3==0;break;case 4:c=(Math.floor(d/3)+Math.floor(a/2))%2==0;break;case 5:c=d*a%2+d*a%3==0;break;case 6:c=(d*a%2+d*a%3)%2==0;break;case 7:c=((d+a)%2+d*a%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[a][d]&&c&&(this.modules[a][d]=!this.modules[a][d])}}getPenaltyScore(){let n=0;for(let g=0;g<this.size;g++){let v=!1,b=0,y=[0,0,0,0,0,0,0];for(let l=0;l<this.size;l++)this.modules[g][l]==v?(b++,b==5?n+=ke.PENALTY_N1:b>5&&n++):(this.finderPenaltyAddHistory(b,y),v||(n+=this.finderPenaltyCountPatterns(y)*ke.PENALTY_N3),v=this.modules[g][l],b=1);n+=this.finderPenaltyTerminateAndCount(v,b,y)*ke.PENALTY_N3}for(let g=0;g<this.size;g++){let v=!1,b=0,y=[0,0,0,0,0,0,0];for(let l=0;l<this.size;l++)this.modules[l][g]==v?(b++,b==5?n+=ke.PENALTY_N1:b>5&&n++):(this.finderPenaltyAddHistory(b,y),v||(n+=this.finderPenaltyCountPatterns(y)*ke.PENALTY_N3),v=this.modules[l][g],b=1);n+=this.finderPenaltyTerminateAndCount(v,b,y)*ke.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let v=0;v<this.size-1;v++){const b=this.modules[g][v];b==this.modules[g][v+1]&&b==this.modules[g+1][v]&&b==this.modules[g+1][v+1]&&(n+=ke.PENALTY_N2)}let a=0;for(const g of this.modules)a=g.reduce((v,b)=>v+(b?1:0),a);const d=this.size*this.size,c=Math.ceil(Math.abs(a*20-d*10)/d)-1;return p(0<=c&&c<=9),n+=c*ke.PENALTY_N4,p(0<=n&&n<=2568888),n}getAlignmentPatternPositions(){if(this.version==1)return[];{const n=Math.floor(this.version/7)+2,a=this.version==32?26:Math.ceil((this.version*4+4)/(n*2-2))*2;let d=[6];for(let c=this.size-7;d.length<n;c-=a)d.splice(1,0,c);return d}}static getNumRawDataModules(n){if(n<ke.MIN_VERSION||n>ke.MAX_VERSION)throw new RangeError("Version number out of range");let a=(16*n+128)*n+64;if(n>=2){const d=Math.floor(n/7)+2;a-=(25*d-10)*d-55,n>=7&&(a-=36)}return p(208<=a&&a<=29648),a}static getNumDataCodewords(n,a){return Math.floor(ke.getNumRawDataModules(n)/8)-ke.ECC_CODEWORDS_PER_BLOCK[a.ordinal][n]*ke.NUM_ERROR_CORRECTION_BLOCKS[a.ordinal][n]}static reedSolomonComputeDivisor(n){if(n<1||n>255)throw new RangeError("Degree out of range");let a=[];for(let c=0;c<n-1;c++)a.push(0);a.push(1);let d=1;for(let c=0;c<n;c++){for(let g=0;g<a.length;g++)a[g]=ke.reedSolomonMultiply(a[g],d),g+1<a.length&&(a[g]^=a[g+1]);d=ke.reedSolomonMultiply(d,2)}return a}static reedSolomonComputeRemainder(n,a){let d=a.map(c=>0);for(const c of n){const g=c^d.shift();d.push(0),a.forEach((v,b)=>d[b]^=ke.reedSolomonMultiply(v,g))}return d}static reedSolomonMultiply(n,a){if(n>>>8||a>>>8)throw new RangeError("Byte out of range");let d=0;for(let c=7;c>=0;c--)d=d<<1^(d>>>7)*285,d^=(a>>>c&1)*n;return p(d>>>8==0),d}finderPenaltyCountPatterns(n){const a=n[1];p(a<=this.size*3);const d=a>0&&n[2]==a&&n[3]==a*3&&n[4]==a&&n[5]==a;return(d&&n[0]>=a*4&&n[6]>=a?1:0)+(d&&n[6]>=a*4&&n[0]>=a?1:0)}finderPenaltyTerminateAndCount(n,a,d){return n&&(this.finderPenaltyAddHistory(a,d),a=0),a+=this.size,this.finderPenaltyAddHistory(a,d),this.finderPenaltyCountPatterns(d)}finderPenaltyAddHistory(n,a){a[0]==0&&(n+=this.size),a.pop(),a.unshift(n)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=s;function r(i,n,a){if(n<0||n>31||i>>>n)throw new RangeError("Value out of range");for(let d=n-1;d>=0;d--)a.push(i>>>d&1)}function o(i,n){return(i>>>n&1)!=0}function p(i){if(!i)throw new Error("Assertion error")}const m=class ot{constructor(n,a,d){if(this.mode=n,this.numChars=a,this.bitData=d,a<0)throw new RangeError("Invalid argument");this.bitData=d.slice()}static makeBytes(n){let a=[];for(const d of n)r(d,8,a);return new ot(ot.Mode.BYTE,n.length,a)}static makeNumeric(n){if(!ot.isNumeric(n))throw new RangeError("String contains non-numeric characters");let a=[];for(let d=0;d<n.length;){const c=Math.min(n.length-d,3);r(parseInt(n.substring(d,d+c),10),c*3+1,a),d+=c}return new ot(ot.Mode.NUMERIC,n.length,a)}static makeAlphanumeric(n){if(!ot.isAlphanumeric(n))throw new RangeError("String contains unencodable characters in alphanumeric mode");let a=[],d;for(d=0;d+2<=n.length;d+=2){let c=ot.ALPHANUMERIC_CHARSET.indexOf(n.charAt(d))*45;c+=ot.ALPHANUMERIC_CHARSET.indexOf(n.charAt(d+1)),r(c,11,a)}return d<n.length&&r(ot.ALPHANUMERIC_CHARSET.indexOf(n.charAt(d)),6,a),new ot(ot.Mode.ALPHANUMERIC,n.length,a)}static makeSegments(n){return n==""?[]:ot.isNumeric(n)?[ot.makeNumeric(n)]:ot.isAlphanumeric(n)?[ot.makeAlphanumeric(n)]:[ot.makeBytes(ot.toUtf8ByteArray(n))]}static makeEci(n){let a=[];if(n<0)throw new RangeError("ECI assignment value out of range");if(n<128)r(n,8,a);else if(n<16384)r(2,2,a),r(n,14,a);else if(n<1e6)r(6,3,a),r(n,21,a);else throw new RangeError("ECI assignment value out of range");return new ot(ot.Mode.ECI,0,a)}static isNumeric(n){return ot.NUMERIC_REGEX.test(n)}static isAlphanumeric(n){return ot.ALPHANUMERIC_REGEX.test(n)}getData(){return this.bitData.slice()}static getTotalBits(n,a){let d=0;for(const c of n){const g=c.mode.numCharCountBits(a);if(c.numChars>=1<<g)return 1/0;d+=4+g+c.bitData.length}return d}static toUtf8ByteArray(n){n=encodeURI(n);let a=[];for(let d=0;d<n.length;d++)n.charAt(d)!="%"?a.push(n.charCodeAt(d)):(a.push(parseInt(n.substring(d+1,d+3),16)),d+=2);return a}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let x=m;e.QrSegment=m})(js||(js={}));(e=>{(s=>{const r=class{constructor(p,m){this.ordinal=p,this.formatBits=m}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(js||(js={}));(e=>{(s=>{const r=class{constructor(p,m){this.modeBits=p,this.numBitsCharCount=m}numCharCountBits(p){return this.numBitsCharCount[Math.floor((p+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(js||(js={}));var Ws=js;var qx={L:Ws.QrCode.Ecc.LOW,M:Ws.QrCode.Ecc.MEDIUM,Q:Ws.QrCode.Ecc.QUARTILE,H:Ws.QrCode.Ecc.HIGH},ed=128,td="L",sd="#FFFFFF",rd="#000000",id=!1,nd=1,Vx=4,Yx=0,Xx=.1;function od(e,s=0){const r=[];return e.forEach(function(o,p){let m=null;o.forEach(function(x,i){if(!x&&m!==null){r.push(`M${m+s} ${p+s}h${i-m}v1H${m+s}z`),m=null;return}if(i===o.length-1){if(!x)return;m===null?r.push(`M${i+s},${p+s} h1v1H${i+s}z`):r.push(`M${m+s},${p+s} h${i+1-m}v1H${m+s}z`);return}x&&m===null&&(m=i)})}),r.join("")}function ad(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((p,m)=>m<s.x||m>=s.x+s.w?p:!1))}function Gx(e,s,r,o){if(o==null)return null;const p=e.length+r*2,m=Math.floor(s*Xx),x=p/s,i=(o.width||m)*x,n=(o.height||m)*x,a=o.x==null?e.length/2-i/2:o.x*x,d=o.y==null?e.length/2-n/2:o.y*x,c=o.opacity==null?1:o.opacity;let g=null;if(o.excavate){let b=Math.floor(a),y=Math.floor(d),l=Math.ceil(i+a-b),h=Math.ceil(n+d-y);g={x:b,y,w:l,h}}const v=o.crossOrigin;return{x:a,y:d,h:n,w:i,excavation:g,opacity:c,crossOrigin:v}}function Qx(e,s){return s!=null?Math.max(Math.floor(s),0):e?Vx:Yx}function ld({value:e,level:s,minVersion:r,includeMargin:o,marginSize:p,imageSettings:m,size:x,boostLevel:i}){let n=ue.useMemo(()=>{const b=(Array.isArray(e)?e:[e]).reduce((y,l)=>(y.push(...Ws.QrSegment.makeSegments(l)),y),[]);return Ws.QrCode.encodeSegments(b,qx[s],r,void 0,void 0,i)},[e,s,r,i]);const{cells:a,margin:d,numCells:c,calculatedImageSettings:g}=ue.useMemo(()=>{let v=n.getModules();const b=Qx(o,p),y=v.length+b*2,l=Gx(v,x,b,m);return{cells:v,margin:b,numCells:y,calculatedImageSettings:l}},[n,x,m,o,p]);return{qrcode:n,margin:d,cells:a,numCells:c,calculatedImageSettings:g}}var Zx=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Jx=ue.forwardRef(function(s,r){const o=s,{value:p,size:m=ed,level:x=td,bgColor:i=sd,fgColor:n=rd,includeMargin:a=id,minVersion:d=nd,boostLevel:c,marginSize:g,imageSettings:v}=o,y=An(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:l}=y,h=An(y,["style"]),u=v?.src,f=ue.useRef(null),S=ue.useRef(null),C=ue.useCallback(F=>{f.current=F,typeof r=="function"?r(F):r&&(r.current=F)},[r]),[k,E]=ue.useState(!1),{margin:w,cells:j,numCells:A,calculatedImageSettings:D}=ld({value:p,level:x,minVersion:d,boostLevel:c,includeMargin:a,marginSize:g,imageSettings:v,size:m});ue.useEffect(()=>{if(f.current!=null){const F=f.current,I=F.getContext("2d");if(!I)return;let z=j;const $=S.current,R=D!=null&&$!==null&&$.complete&&$.naturalHeight!==0&&$.naturalWidth!==0;R&&D.excavation!=null&&(z=ad(j,D.excavation));const L=window.devicePixelRatio||1;F.height=F.width=m*L;const M=m/A*L;I.scale(M,M),I.fillStyle=i,I.fillRect(0,0,A,A),I.fillStyle=n,Zx?I.fill(new Path2D(od(z,w))):j.forEach(function(O,q){O.forEach(function(V,H){V&&I.fillRect(H+w,q+w,1,1)})}),D&&(I.globalAlpha=D.opacity),R&&I.drawImage($,D.x+w,D.y+w,D.w,D.h)}}),ue.useEffect(()=>{E(!1)},[u]);const T=Rn({height:m,width:m},l);let P=null;return u!=null&&(P=ue.createElement("img",{src:u,key:u,style:{display:"none"},onLoad:()=>{E(!0)},ref:S,crossOrigin:D?.crossOrigin})),ue.createElement(ue.Fragment,null,ue.createElement("canvas",Rn({style:T,height:m,width:m,ref:C,role:"img"},h)),P)});Jx.displayName="QRCodeCanvas";var cd=ue.forwardRef(function(s,r){const o=s,{value:p,size:m=ed,level:x=td,bgColor:i=sd,fgColor:n=rd,includeMargin:a=id,minVersion:d=nd,boostLevel:c,title:g,marginSize:v,imageSettings:b}=o,y=An(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:l,cells:h,numCells:u,calculatedImageSettings:f}=ld({value:p,level:x,minVersion:d,boostLevel:c,includeMargin:a,marginSize:v,imageSettings:b,size:m});let S=h,C=null;b!=null&&f!=null&&(f.excavation!=null&&(S=ad(h,f.excavation)),C=ue.createElement("image",{href:b.src,height:f.h,width:f.w,x:f.x+l,y:f.y+l,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=od(S,l);return ue.createElement("svg",Rn({height:m,width:m,viewBox:`0 0 ${u} ${u}`,ref:r,role:"img"},y),!!g&&ue.createElement("title",null,g),ue.createElement("path",{fill:i,d:`M0,0 h${u}v${u}H0z`,shapeRendering:"crispEdges"}),ue.createElement("path",{fill:n,d:k,shapeRendering:"crispEdges"}),C)});cd.displayName="QRCodeSVG";function dd(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function eb(){return Pt({queryKey:be.tunnel.status,queryFn:()=>Ae.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function tb(){const e=Lt();return kr({mutationFn:()=>Ae.post("/tunnel/start",{port:dd()}),onSuccess:()=>{e.invalidateQueries({queryKey:be.tunnel.status})}})}function sb(){const e=Lt();return kr({mutationFn:()=>Ae.post("/tunnel/regenerate",{port:dd()}),onSuccess:()=>{e.invalidateQueries({queryKey:be.tunnel.status})}})}function rb(){const e=Lt();return kr({mutationFn:()=>Ae.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:be.tunnel.status})}})}function ib(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function nb(e){if(!e||e.status==="stopped")return"Tunnel is off";switch(e.status){case"healthy":return"Tunnel healthy";case"checking":return"Checking tunnel health";case"degraded":return"Observing original link";case"localUnhealthy":return"Local service unavailable";case"exited":return"Tunnel process exited";case"error":return"Tunnel error";case"linkReplaced":return"New link generated";case"starting":return"Tunnel starting"}}function ob(e){if(!e||e.status==="stopped")return"Start a temporary Quick Tunnel when you need to share this Agent Tower session.";switch(e.status){case"healthy":return"The Cloudflare tunnel is running and the local Agent Tower health check passed.";case"checking":return"The Cloudflare tunnel is running. Agent Tower is waiting for the first local health check.";case"degraded":return"The original public URL is currently unreachable. Agent Tower is watching for it to recover and will not generate a new link automatically.";case"localUnhealthy":return"The local Agent Tower target is not responding, so the tunnel cannot be considered healthy.";case"exited":return"The tunnel process has exited. The old Quick Tunnel link is unlikely to recover.";case"error":return"The tunnel reported an error. Check the diagnostics before generating a new link.";case"linkReplaced":return"A new Quick Tunnel link was generated. The old link and token are no longer valid.";case"starting":return"Agent Tower is asking Cloudflare Quick Tunnel for a temporary public URL."}}function Ba(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const o=Math.round(r/60);if(o<60)return`${o}m ago`;const p=Math.round(o/60);return p<24?`${p}h ago`:`${Math.round(p/24)}d ago`}function dr(e){const s=e?.trim();return s||null}function ab(e){if(!e)return"";const s=[dr(e.lastLocalError),dr(e.lastRemoteError),dr(e.lastError)].filter(p=>p!==null),r=dr(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!dr(e.lastError));return r&&o&&s.push(r),s.join(`
|
|
82
|
+
`)}function Fa(){const{t:e}=ce(),{data:s}=eb(),r=tb(),o=rb(),p=sb(),[m,x]=_.useState(!1),[i,n]=_.useState(null),a=_.useRef(null),[d,c]=_.useState({top:0,right:0}),[g,v]=_.useState(!1),[b,y]=_.useState(!1),l=s?.status!==void 0&&s.status!=="stopped",h=r.isPending||s?.status==="starting",u=p.isPending,f=s?.shareableUrl,S=s?.token,C=ib(s),k=nb(s),E=ab(s);_.useEffect(()=>{if(m&&a.current){const F=a.current.getBoundingClientRect();c({top:F.bottom+8,right:window.innerWidth-F.right})}},[m]);const w=_.useCallback(()=>{x(!0)},[l]),j=_.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>x(!0)})},[r]),A=_.useCallback(()=>{f&&(navigator.clipboard.writeText(f),n("url"),setTimeout(()=>n(null),2e3))},[f]),D=_.useCallback(()=>{S&&(navigator.clipboard.writeText(S),n("token"),setTimeout(()=>n(null),2e3))},[S]),T=_.useCallback(()=>{o.mutate(),x(!1),v(!1),y(!1)},[o]),P=_.useCallback(()=>{p.mutate(void 0,{onSuccess:()=>{y(!1),x(!0)}})},[p]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:a,onClick:w,disabled:h,className:`p-1.5 rounded-md transition-colors ${C.button}`,title:e(C.label),children:h?t.jsx(Be,{size:16,className:"animate-spin"}):C.icon==="warn"?t.jsx(Ns,{size:16}):t.jsx(Ao,{size:16})}),l&&!h&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${C.dot} rounded-full`}),m&&!l&&ws.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>x(!1)}),t.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:d.top,right:d.right},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:t.jsx(Ao,{size:16})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:e("After enabling the tunnel, you can scan a QR code with your phone to visit this Agent Tower instance, assign tasks, and check agent status.")})]})]}),t.jsx("button",{onClick:()=>x(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Xt,{size:14})})]}),t.jsxs("button",{onClick:j,disabled:h,className:"mt-3 w-full px-3 py-2 text-xs font-medium text-white bg-neutral-900 hover:bg-neutral-800 rounded-md transition-colors disabled:opacity-50 flex items-center justify-center gap-1.5",children:[h&&t.jsx(Be,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&l&&ws.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>x(!1)}),t.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:d.top,right:d.right},children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{children:[t.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${s?.status==="healthy"||s?.status==="checking"?"text-emerald-600":s?.status==="exited"||s?.status==="error"?"text-red-600":"text-amber-600"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 ${C.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(ob(s))})]}),t.jsx("button",{onClick:()=>x(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Xt,{size:14})})]}),S&&t.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-neutral-50 rounded text-xs text-neutral-700",children:[t.jsx(tu,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(cd,{value:f,size:160})}),f||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:f??s?.url??"",className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:F=>F.target.select()}),t.jsx("button",{onClick:A,disabled:!f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:i==="url"?t.jsx(Wt,{size:14,className:"text-emerald-500"}):t.jsx(No,{size:14})})]}):t.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 text-xs text-neutral-500",children:e("No tunnel link available")}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:Ba(s?.lastCheckedAt)})]}),t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:Ba(s?.lastHealthyAt)})]})]}),E&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800 whitespace-pre-wrap break-words max-h-28 overflow-auto",children:E}),s?.status==="degraded"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),s?.status==="linkReplaced"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("The previous tunnel link and token are no longer valid.")}),S&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>v(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:S}),t.jsx("button",{onClick:D,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:i==="token"?t.jsx(Wt,{size:14,className:"text-emerald-500"}):t.jsx(No,{size:14})})]})]}),b&&t.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[t.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{onClick:()=>y(!1),className:"flex-1 px-2 py-1 rounded-md bg-white text-neutral-700 border border-neutral-200 hover:bg-neutral-50",children:e("Cancel")}),t.jsx("button",{onClick:P,disabled:u,className:"flex-1 px-2 py-1 rounded-md bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:e(u?"Generating...":"Regenerate link")})]})]}),!b&&t.jsxs("button",{onClick:()=>y(!0),disabled:u||s?.canRegenerate===!1,className:"mt-3 w-full px-3 py-1.5 text-xs text-amber-700 hover:bg-amber-50 rounded-md transition-colors disabled:opacity-40 flex items-center justify-center gap-1.5",children:[t.jsx(Rs,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:T,disabled:o.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:o.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function hn({isOpen:e,onClose:s}){const{t:r}=ce(),o=xu(),[p,m]=_.useState(""),[x,i]=_.useState(""),[n,a]=_.useState(null),[d,c]=_.useState(!1),[g,v]=_.useState(!1),b=p.trim(),y=x.trim(),l=d||o.isPending,h=_.useMemo(()=>!!(b&&y&&!l),[b,y,l]),u=_.useCallback(()=>{m(""),i(""),a(null),v(!1)},[]),f=_.useCallback(()=>{l||(u(),s())},[l,s,u]);_.useEffect(()=>{e||u()},[e,u]);const S=_.useCallback(async w=>{try{await o.mutateAsync({name:b,repoPath:y,initEmptyRepo:w}),u(),s()}catch(j){const A=j instanceof Error?j.message:r("Failed to create project");a(A),Je.error(A)}},[o,s,u,r,b,y]),C=_.useCallback(async()=>{if(!(!b||!y||l)){a(null),c(!0);try{const w=await Ae.get("/filesystem/validate",{params:{path:y}});if(!w.valid){a(w.error??r("Selected path is not a valid directory"));return}if(w.isGitRepo){await S(!1);return}if(w.reason==="no_git"&&w.isEmpty){v(!0);return}if(w.reason==="no_git"){await S(!1);return}await S(!1)}catch(w){a(w instanceof Error?w.message:r("Could not check project path"))}finally{c(!1)}}},[S,l,r,b,y]),k=_.useCallback(()=>{v(!1),S(!1)},[S]),E=_.useCallback(()=>{v(!1),S(!0)},[S]);return t.jsxs(t.Fragment,{children:[t.jsx(ps,{isOpen:e,onClose:f,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:f,disabled:l,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:C,disabled:!h,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${h?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:d?r("Checking..."):o.isPending?r("Creating..."):r("Create Project")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),t.jsx("input",{type:"text",value:p,onChange:w=>m(w.target.value),placeholder:r("e.g., Agent Tower"),disabled:l,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors disabled:bg-neutral-50 disabled:text-neutral-400",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Path")}),t.jsx(Yd,{value:x,onChange:i,validationMode:"directory"})]}),n&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:n})]})}),t.jsx(ps,{isOpen:g,onClose:()=>{o.isPending||v(!1)},title:r("Initialize Git repository?"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>v(!1),disabled:o.isPending,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:k,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg border border-neutral-200 text-neutral-700 hover:bg-neutral-50 transition-colors disabled:opacity-50",children:r("Create Local Project")}),t.jsx("button",{onClick:E,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg bg-neutral-900 text-white hover:bg-black transition-colors disabled:opacity-50",children:o.isPending?r("Creating..."):r("Initialize and Create")})]}),children:t.jsxs("div",{className:"space-y-3 text-sm text-neutral-600 leading-relaxed",children:[t.jsx("p",{children:r("This directory is empty and does not have Git version control yet. Agent Tower can initialize Git and create the initial commit before creating the project.")}),t.jsx("p",{children:r("You can also create it as a local project now. Local projects only support local Solo tasks until Git is initialized.")})]})})]})}function za(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function lb(e){return e.map((s,r)=>({project:s,index:r,activityTime:za(s.lastActivityAt??s.createdAt),createdTime:za(s.createdAt)})).sort((s,r)=>{const o=r.activityTime-s.activityTime;if(o!==0)return o;const p=r.createdTime-s.createdTime;return p!==0?p:s.index-r.index}).map(({project:s})=>s)}function Wa({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:p}){const{t:m}=ce(),[x,i]=_.useState(!1),n=e.filter(d=>!d.archivedAt),a=s?e.find(d=>d.id===s)??null:null;return t.jsxs("div",{className:Z("relative flex items-center min-w-0",p),children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>i(d=>!d),className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm text-foreground/90 hover:bg-accent transition-colors min-w-0",children:[a?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${a.color.replace("text-","bg-")}`}):t.jsx(qs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:a?a.name:m("All Projects")}),t.jsx(Ct,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${x?"rotate-180":""}`})]}),x?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>i(!1)}),t.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-lg shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsxs("button",{onClick:()=>{r(null),i(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx(qs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${s===null?"text-foreground font-medium":"text-muted-foreground"}`,children:m("All Projects")}),s===null?t.jsx(Wt,{size:14,className:"text-foreground shrink-0"}):null]}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:n.map(d=>{const c=s===d.id;return t.jsxs("button",{onClick:()=>{r(d.id),i(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${d.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${c?"text-foreground font-medium":"text-muted-foreground"}`,children:d.name}),c?t.jsx(Wt,{size:14,className:"text-foreground shrink-0"}):null]},d.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{i(!1),o()},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors",children:[t.jsx(ds,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}const cb=260,db=600,Ha=400,ub=100,hb=1e3;function fb(e){const s=e.workspaces?.find(o=>o.status==="ACTIVE")??e.workspaces?.[0],r=s?.sessions?.at(-1);return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:e.status,priority:e.priority,...s?{preferredWorkspace:{...s.workspaceKind===xt.MAIN_DIRECTORY?{workspaceKind:xt.MAIN_DIRECTORY}:{},branchName:s.branchName}}:{},...r?{latestAgentType:r.agentType}:{},...e.workspaces?.some(o=>o.sessions?.some(p=>p.status==="RUNNING"||p.status==="PENDING"))?{hasRunningSession:!0}:{},updatedAt:e.updatedAt?new Date(e.updatedAt).getTime():Date.now()}}function mb(){const{t:e,locale:s}=ce(),[r,o]=_.useState(null),[p,m]=_.useState(null),[x,i]=_.useState(Ha),[n,a]=_.useState(!1),[d,c]=_.useState("idle"),[g,v]=_.useState({}),b=_.useRef(!1),y=_.useRef(0),l=_.useRef(Ha),h=_.useRef(null),u=Lt(),{data:f,isLoading:S}=Gs(),{data:C,isLoading:k}=bu({limit:ub}),E=_.useMemo(()=>C?.data??[],[C?.data]),w=p&&E.some(te=>te.id===p)?p:null,{data:j,isLoading:A}=zd({...w?{projectId:w}:{},limit:hb}),D=_.useMemo(()=>j?.data??[],[j?.data]),[T,P]=_.useState([]),F=_.useMemo(()=>{if(T.length===0)return D;const te=new Set(D.map(fe=>fe.id));return[...T.filter(fe=>!te.has(fe.id)),...D]},[D,T]),[I,z]=_.useState(null),$=_.useMemo(()=>r&&F.some(te=>te.id===r)?r:I&&r===I?I:null,[r,F,I]);_.useEffect(()=>{I&&F.some(te=>te.id===I)&&z(null)},[I,F]),_.useEffect(()=>{if(T.length===0)return;const te=new Set(D.map(fe=>fe.id));T.some(fe=>te.has(fe.id))&&P(fe=>fe.filter(ye=>!te.has(ye.id)))},[D,T]);const R=_.useMemo(()=>lb(E),[E]),L=_.useMemo(()=>R.map(Cx),[R]),M=_.useMemo(()=>R.filter(te=>!te.archivedAt),[R]),O=_.useMemo(()=>{if(!f)return[];const te=localStorage.getItem("providerUsageCount"),fe=te?JSON.parse(te):{};return[...f].sort((ye,X)=>{const se=ye.availability.type!=="NOT_FOUND",ie=X.availability.type!=="NOT_FOUND";if(se!==ie)return se?-1:1;const ae=fe[ye.provider.id]??0;return(fe[X.provider.id]??0)-ae})},[f]),q=_.useMemo(()=>F.map(te=>kx(te,E.find(fe=>fe.id===te.projectId))),[E,F]),V=_.useMemo(()=>{if(!$)return null;const te=F.find(ye=>ye.id===$);if(!te)return null;const fe=E.find(ye=>ye.id===te.projectId);if(!fe){const ye=te.preferredWorkspace?te.preferredWorkspace.workspaceKind===xt.MAIN_DIRECTORY?"Project directory":te.preferredWorkspace.branchName:"—";return{id:te.id,projectId:te.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:te.title,status:po(te.status),priority:te.priority,branch:ye,mainBranch:"main",description:"",isGitRepo:!1,worktreeReady:!1,reason:"NO_GIT",projectArchivedAt:null,projectRepoDeletedAt:null}}return Ex(te,fe)},[$,F,E]),H=Ya(),W=Wd(),U=Hd(),N=Xa(),B=Fn(),K=_.useCallback(te=>{const fe=fb(te);P(ye=>ye.some(X=>X.id===te.id)?ye.map(X=>X.id===te.id?fe:X):[fe,...ye]),u.setQueryData(be.tasks.detail(te.id),te),z(te.id),o(te.id)},[u]),Y=_.useCallback((te,fe,ye)=>{const X=te.id,se=[te.title,te.description].filter(Boolean).join(`
|
|
83
|
+
|
|
84
|
+
`),ie=ye===xt.WORKTREE?M.find(ae=>ae.id===te.projectId)?.setupScript??null:null;v(ae=>({...ae,[X]:{status:"creating-workspace",setupScript:ie}})),(async()=>{try{const ae=await Ae.post(`/tasks/${X}/workspaces`,{workspaceKind:ye});v(we=>({...we,[X]:{status:"creating-session",setupScript:ie}}));const Se=await Ae.post(`/workspaces/${ae.id}/sessions`,{providerId:fe,prompt:se});v(we=>({...we,[X]:{status:"starting-session",setupScript:ie}})),await B.mutateAsync(Se.id),await u.invalidateQueries({queryKey:be.workspaces.list(X)}),await u.invalidateQueries({queryKey:be.workspaces.setupProgress(X)}),await u.invalidateQueries({queryKey:be.tasks.all}),v(we=>{const{[X]:Pe,...Ze}=we;return Ze})}catch(ae){const Se=ae instanceof Error?ae.message:e("启动 Agent 失败");v(we=>({...we,[X]:{status:"failed",error:Se,setupScript:ie}})),Je.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),u.invalidateQueries({queryKey:be.workspaces.list(X)}),u.invalidateQueries({queryKey:be.tasks.all})}})()},[M,u,B,e]),J=_.useCallback(te=>{v(fe=>{const{[te]:ye,...X}=fe;return X}),u.invalidateQueries({queryKey:be.workspaces.list(te)}),u.invalidateQueries({queryKey:be.tasks.all})},[u]),G=_.useCallback(te=>{W.mutate(te,{onSuccess:()=>{$===te&&o(null),v(fe=>{const{[te]:ye,...X}=fe;return X}),P(fe=>fe.filter(ye=>ye.id!==te)),u.invalidateQueries({queryKey:be.tasks.all})},onError:()=>{Je.error(e("删除任务失败"))}})},[W,$,u,e]),de=_.useCallback((te,fe)=>{U.mutate({id:te,status:Sx(fe)},{onError:()=>{Je.error(e("状态变更失败,该操作不被允许"))}})},[U,e]),he=_.useCallback((te,fe)=>{N.mutate({id:te,priority:fe},{onError:()=>{Je.error(e("优先级变更失败"))}})},[N,e]),re=_.useCallback(te=>{te.preventDefault(),b.current=!0,y.current=te.clientX,l.current=x,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[x]);_.useEffect(()=>{const te=ye=>{if(!b.current)return;const X=ye.clientX-y.current,se=Math.max(cb,Math.min(db,l.current+X));i(se)},fe=()=>{b.current&&(b.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",te),document.addEventListener("mouseup",fe),()=>{document.removeEventListener("mousemove",te),document.removeEventListener("mouseup",fe)}},[]);const ne=_.useCallback(()=>{a(!0)},[]),le=_.useCallback(()=>{if(M.length===0){Je.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[M,e]),_e=_.useCallback(()=>{a(!1)},[]),We=_.useCallback(async te=>{const{title:fe,description:ye,projectId:X,providerId:se,mode:ie,workspaceMode:ae,teamRunMode:Se,teamTemplateId:we,memberPresetIds:Pe,attachmentLinks:Ze,priority:xe}=te,ve=[ye,Ze].filter(Boolean).join(`
|
|
85
|
+
|
|
86
|
+
`);let me=null;try{if(c("creating-task"),me=await Ae.post(`/projects/${X}/tasks`,{title:fe,description:ve||void 0,priority:xe}),localStorage.setItem("lastSelectedProjectId",X),ie==="SOLO"&&se){localStorage.setItem("lastSelectedProviderId",se);const rt=localStorage.getItem("providerUsageCount"),lt=rt?JSON.parse(rt):{};lt[se]=(lt[se]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(lt))}ie==="TEAM"?(c("creating-teamrun"),await H.mutateAsync({taskId:me.id,mode:Se,...we?{teamTemplateId:we}:{},...Pe.length>0?{memberPresetIds:Pe}:{}})):se&&Y(me,se,ae),w&&X!==w&&m(null),K(me),c("idle"),u.invalidateQueries({queryKey:be.tasks.all}),u.invalidateQueries({queryKey:be.projects.all})}catch(Fe){if(c("idle"),me&&ie==="TEAM"){try{await W.mutateAsync(me.id)}catch{}throw Je.error(e("TeamRun 创建失败,请检查团队配置后重试")),Fe}else if(me)w&&X!==w&&m(null),K(me),u.invalidateQueries({queryKey:be.tasks.all}),u.invalidateQueries({queryKey:be.projects.all});else throw Je.error(Fe instanceof Error?Fe.message:e("Failed to create task")),Fe}},[M,H,Y,W,u,e,w,K]),Ce=k||A,He=_.useMemo(()=>M.map(te=>({id:te.id,name:te.name,color:L.find(fe=>fe.id===te.id)?.color,repoPath:te.repoPath,isGitRepo:te.isGitRepo,worktreeReady:te.worktreeReady,reason:te.reason})),[M,L]),at=_.useMemo(()=>O.map(te=>{const fe=es(te);return{id:te.provider.id,name:te.provider.name,agentType:te.provider.agentType,available:!fe,permissionMode:te.provider.executionPermission,reason:fe}}),[O]),Me=_.useMemo(()=>{if(w&&M.find(fe=>fe.id===w))return w;const te=localStorage.getItem("lastSelectedProjectId");return te&&M.find(fe=>fe.id===te)?te:M[0]?.id??""},[M,w]),[Ne,Oe]=_.useState(Me);_.useEffect(()=>{Oe(Me)},[Me]);const $e=_.useMemo(()=>M.find(te=>te.id===Ne)?.name??M.find(te=>te.id===Me)?.name??e("Project"),[M,Ne,Me,e]),Ke=s==="zh-CN"?`你需要在 ${$e} 中做点什么?`:`What do you need to do in ${$e}?`,De=_.useMemo(()=>{const te=localStorage.getItem("lastSelectedProviderId");return te&&O.find(ye=>ye.provider.id===te&&!es(ye))?te:O.find(ye=>!es(ye))?.provider.id??""},[O]),Xe=Ul(),[Ge,Te]=_.useState(!1),{usesIntegratedTitlebar:pe,desktopPlatform:tt,hasMacTrafficLights:Ye}=Ua(),Ue=pe&&tt==="win32",ft=_.useCallback(()=>{if(M.length===0){Je.error(e("没有可用项目,请先创建或恢复项目"));return}Te(!0)},[M,e]),st=_.useCallback(async te=>{await We(te),Te(!1)},[We]);return Xe?Ge?t.jsxs("div",{className:"flex flex-col h-dvh bg-background overflow-hidden text-sm",children:[t.jsx("header",{className:"h-12 border-b border-border/60 flex items-center px-4 shrink-0",children:t.jsx("button",{onClick:()=>Te(!1),className:"text-sm text-muted-foreground active:text-foreground",children:e("Cancel")})}),t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4 pb-[8vh]",children:[t.jsx("h1",{className:"max-w-full text-center text-[20px] font-medium tracking-tight leading-snug text-foreground mb-5 break-words",children:Ke}),t.jsx(ko,{projects:He,providers:at,isProvidersLoading:S,onSubmit:st,defaultProjectId:Me,defaultProviderId:De,onProjectChange:Oe,createStep:d})]})]}):$&&V?t.jsxs(t.Fragment,{children:[t.jsx($x,{task:V,onBack:()=>o(null),onDeleteTask:V.projectArchivedAt?void 0:G,onTaskPriorityChange:V.projectArchivedAt?void 0:he,isDeleting:W.isPending,autoStartState:g[V.id]??null,onAutoStartRecovered:J}),t.jsx(hn,{isOpen:n,onClose:_e})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col h-dvh bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-sidebar flex items-center px-4 justify-between shrink-0 z-20",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Eo,{}),t.jsx(Wa,{projects:L,filterProjectId:w,setFilterProjectId:m,onCreateProject:ne})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Fa,{}),t.jsx("button",{onClick:()=>So.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx(yo,{size:16})})]})]}),t.jsx(Ko,{tasks:q,projects:L,selectedTaskId:null,onSelectTask:o,filterProjectId:w,setFilterProjectId:m,width:"100%",onCreateTask:ft,onCreateProject:ne,onTaskStatusChange:de,onTaskPriorityChange:he,isLoading:Ce&&q.length===0})]}),t.jsx(hn,{isOpen:n,onClose:_e})]}):t.jsxs("div",{ref:h,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:Z("h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",pe&&"app-region-drag",Ue&&"pr-[150px]"),children:[t.jsxs("div",{className:Z("flex items-center gap-2 min-w-0",Ye&&"pl-[72px]"),children:[t.jsx(Eo,{}),t.jsx(Wa,{projects:L,filterProjectId:w,setFilterProjectId:m,onCreateProject:ne,className:pe?"app-region-no-drag":void 0})]}),t.jsxs("div",{className:Z("flex items-center gap-1",pe&&"app-region-no-drag"),children:[t.jsx("div",{className:pe?"app-region-no-drag":void 0,children:t.jsx(Fa,{})}),t.jsx("button",{onClick:()=>So.getState().openSettings(),className:Z("p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",pe&&"app-region-no-drag"),children:t.jsx(yo,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[t.jsx(Ko,{tasks:q,projects:L,selectedTaskId:$,onSelectTask:o,filterProjectId:w,setFilterProjectId:m,width:x,onCreateTask:le,onCreateProject:ne,isCreateActive:!$,onTaskStatusChange:de,onDeleteTask:G,onTaskPriorityChange:he,isLoading:Ce&&q.length===0}),t.jsx("div",{onMouseDown:re,className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),t.jsx("div",{className:"flex-1 flex min-w-0 mb-2 mr-2 rounded-xl border border-border/50 bg-background overflow-hidden",children:$&&V?t.jsx(yx,{task:V,onDeleteTask:V.projectArchivedAt?void 0:G,isDeleting:W.isPending,onTaskStatusChange:V.projectArchivedAt?void 0:de,onTaskPriorityChange:V.projectArchivedAt?void 0:he,autoStartState:g[V.id]??null,onAutoStartRecovered:J}):$&&!V?t.jsx("div",{className:"flex-1 flex items-center justify-center bg-background min-w-0",children:t.jsx("span",{className:"text-sm text-muted-foreground/70",children:e("Loading...")})}):t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center bg-background min-w-0 px-8 pb-[10vh]",children:t.jsxs("div",{className:"w-full max-w-2xl flex flex-col items-center animate-[fadeInUp_0.5s_cubic-bezier(0.16,1,0.3,1)]",children:[t.jsx("h1",{className:"max-w-full text-center text-[26px] font-medium tracking-tight leading-snug text-foreground mb-6 break-words",children:Ke}),t.jsx(ko,{projects:He,providers:at,isProvidersLoading:S,onSubmit:We,defaultProjectId:Me,defaultProviderId:De,onProjectChange:Oe,createStep:d})]})})})]}),t.jsx(hn,{isOpen:n,onClose:_e})]})}const Xb=Object.freeze(Object.defineProperty({__proto__:null,ProjectKanbanPage:mb},Symbol.toStringTag,{value:"Module"}));export{Xb as P,ac as l};
|