@ensocode/server 0.3.11 → 0.3.13
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/LICENSE +679 -19
- package/out/phone/assets/EditDiff-B3HxLrbF.js +28 -0
- package/out/phone/assets/ReadFileView-BFpGH-kK.js +7 -0
- package/out/phone/assets/{abnfDiagram-VCTEODGH-DeKO4j9Y.js → abnfDiagram-VCTEODGH-BNvyPGoF.js} +1 -1
- package/out/phone/assets/architecture-7GRP2DOG-Duql1LsL.js +1 -0
- package/out/phone/assets/{architectureDiagram-5GKGNRK7-DhPgDhMQ.js → architectureDiagram-5GKGNRK7-1bhpTEFA.js} +1 -1
- package/out/phone/assets/{blockDiagram-I7D4REHJ-CHjEV4S2.js → blockDiagram-I7D4REHJ-Bo9UMudu.js} +1 -1
- package/out/phone/assets/{c4Diagram-7LVT6UL2-C_w2ZiGg.js → c4Diagram-7LVT6UL2-YS11cig2.js} +1 -1
- package/out/phone/assets/channel-BPoIHov1.js +1 -0
- package/out/phone/assets/{chunk-4HAMMTFA-DsFB5306.js → chunk-4HAMMTFA-gA-CzNGD.js} +1 -1
- package/out/phone/assets/{chunk-75Z2AOVW-D-GYq_Mf.js → chunk-75Z2AOVW-BL_5b1Dw.js} +1 -1
- package/out/phone/assets/{chunk-DU6HZSFF-CfnOn1uu.js → chunk-DU6HZSFF-BpNlAs9R.js} +1 -1
- package/out/phone/assets/{chunk-F27PBJKO-DFQr9a2N.js → chunk-F27PBJKO-lsKx96Nt.js} +1 -1
- package/out/phone/assets/{chunk-GMAD6QVW--AoHkXxN.js → chunk-GMAD6QVW-CxbljbtE.js} +1 -1
- package/out/phone/assets/{chunk-GVQU2GXP-CzbFqhoi.js → chunk-GVQU2GXP-CTO3kTOF.js} +1 -1
- package/out/phone/assets/{chunk-IMKFNOWR-DT26rqUA.js → chunk-IMKFNOWR-Cq8XlkcB.js} +1 -1
- package/out/phone/assets/{chunk-L3NEJ4N5-CvadXD9U.js → chunk-L3NEJ4N5-CvIm0JX7.js} +1 -1
- package/out/phone/assets/{chunk-OSK3NFVY-DROHZT6z.js → chunk-OSK3NFVY-Cj3ilTL-.js} +1 -1
- package/out/phone/assets/{chunk-P2QGCYS3-BcsvTFQT.js → chunk-P2QGCYS3-B-twI_Fz.js} +1 -1
- package/out/phone/assets/{chunk-POPQ4Y6H-Bib7YUpn.js → chunk-POPQ4Y6H-lPQttJ5s.js} +1 -1
- package/out/phone/assets/{chunk-PWAF6VOD-CrsdfQvi.js → chunk-PWAF6VOD-DjwqZuIR.js} +1 -1
- package/out/phone/assets/{chunk-SHT3W25Y-BSSsjkbn.js → chunk-SHT3W25Y-BWRVin1H.js} +1 -1
- package/out/phone/assets/{chunk-SVP7TREG-BorYBfcS.js → chunk-SVP7TREG-CGLhvnsS.js} +1 -1
- package/out/phone/assets/{chunk-TICWLB2K-DwWprz_z.js → chunk-TICWLB2K-DkFUa03q.js} +1 -1
- package/out/phone/assets/classDiagram-ZZMXUADV-CIR76lHP.js +1 -0
- package/out/phone/assets/classDiagram-v2-VYDZK3BY-CIR76lHP.js +1 -0
- package/out/phone/assets/codeHighlighter-jQti-W31.js +1346 -0
- package/out/phone/assets/{cynefin-OW5HDTMX-UxW1ctBn.js → cynefin-OW5HDTMX-L8oWVu5S.js} +1 -1
- package/out/phone/assets/{cynefinDiagram-5FMLGOSQ-3xyjt_Zk.js → cynefinDiagram-5FMLGOSQ-DH8-4p4N.js} +1 -1
- package/out/phone/assets/{dagre-GXQ25YYZ-BA8g5sNo.js → dagre-GXQ25YYZ-HhLDmcu9.js} +1 -1
- package/out/phone/assets/desk-CixRGdTk.js +52 -0
- package/out/phone/assets/{diagram-S7CK7UJ4-CqaAk0xY.js → diagram-S7CK7UJ4-CeIbR3Ir.js} +1 -1
- package/out/phone/assets/{diagram-UQ7AKVKN-BJs2alr_.js → diagram-UQ7AKVKN-BQ84Qnq6.js} +1 -1
- package/out/phone/assets/{diagram-VSXAHHWV-goFBlClH.js → diagram-VSXAHHWV-aF_J57fD.js} +1 -1
- package/out/phone/assets/{diagram-VX7I27RA-NC_soOMz.js → diagram-VX7I27RA-Bg1ZqM4Y.js} +1 -1
- package/out/phone/assets/{diagram-Z3DM3KII-CPBmdhd-.js → diagram-Z3DM3KII-DjTkPAqa.js} +1 -1
- package/out/phone/assets/{ebnfDiagram-PWID7BFC-e_KXtWp1.js → ebnfDiagram-PWID7BFC-DPsH5Eky.js} +1 -1
- package/out/phone/assets/{erDiagram-RLTQ6QDP-BV3oU6Yk.js → erDiagram-RLTQ6QDP-ExvY7e6T.js} +1 -1
- package/out/phone/assets/eventmodeling-NTZA5JFV-DYp-zWcL.js +1 -0
- package/out/phone/assets/flowDiagram-HODETNUW-CIU32By5.js +1 -0
- package/out/phone/assets/{ganttDiagram-EL5Y4UJY-DOtr1Ilh.js → ganttDiagram-EL5Y4UJY-hCe06ucl.js} +1 -1
- package/out/phone/assets/{gitGraph-4MIJSDKK-D0CbVtzh.js → gitGraph-4MIJSDKK-BuZ6lDat.js} +1 -1
- package/out/phone/assets/{gitGraphDiagram-WWUBYQGX-C6wXAX8a.js → gitGraphDiagram-WWUBYQGX-D-8aVxvj.js} +1 -1
- package/out/phone/assets/{info-A6RAGUB7-BLbppMXJ.js → info-A6RAGUB7-CrZtdoYs.js} +1 -1
- package/out/phone/assets/{infoDiagram-27XIBGKW-DOlhaNYG.js → infoDiagram-27XIBGKW-BLRFHxtO.js} +1 -1
- package/out/phone/assets/{ishikawaDiagram-5VMMS53U-BtaSUSnr.js → ishikawaDiagram-5VMMS53U-D7SYWKoj.js} +1 -1
- package/out/phone/assets/{journeyDiagram-3NMN7TZE-C6DElK_Y.js → journeyDiagram-3NMN7TZE-BPsg7CQD.js} +1 -1
- package/out/phone/assets/{kanban-definition-UXKFOSKX-WqCAwlkm.js → kanban-definition-UXKFOSKX-CbPuNr-E.js} +1 -1
- package/out/phone/assets/{line-CvY1fizC.js → line-CkpKMiqK.js} +1 -1
- package/out/phone/assets/main-BCnf7dVM.js +264 -0
- package/out/phone/assets/main-nqB-uD3v.css +2 -0
- package/out/phone/assets/{mermaid-parser.core-BNyl33x8.js → mermaid-parser.core-RTq_mEm1.js} +3 -3
- package/out/phone/assets/{mermaid.core-BnUF0ZCX.js → mermaid.core-D9LtIKua.js} +4 -4
- package/out/phone/assets/{mindmap-definition-YA3MSWOX-CsORTLIm.js → mindmap-definition-YA3MSWOX-8cGgRiRD.js} +1 -1
- package/out/phone/assets/{packet-AYTQ26CC-CoxwVVdp.js → packet-AYTQ26CC-D9-eSn0v.js} +1 -1
- package/out/phone/assets/{pegDiagram-XKGWAZYB-BI2W6aLH.js → pegDiagram-XKGWAZYB-DztU_rIE.js} +1 -1
- package/out/phone/assets/{pie-WAS4IAKB-CQD3JNcj.js → pie-WAS4IAKB-Bk2Tqaq_.js} +1 -1
- package/out/phone/assets/{pieDiagram-E7YTZNPT-aLnzVgco.js → pieDiagram-E7YTZNPT-Dm_3mJ9_.js} +1 -1
- package/out/phone/assets/{quadrantDiagram-AXDQQJYC-Cbl0x-Id.js → quadrantDiagram-AXDQQJYC-lKskzjzu.js} +1 -1
- package/out/phone/assets/{radar-RG4KPBEZ-Bu2EN1RM.js → radar-RG4KPBEZ-B2z8Txd8.js} +1 -1
- package/out/phone/assets/{railroad-74A4TZTK-DiiOMWSM.js → railroad-74A4TZTK-11VmdALq.js} +1 -1
- package/out/phone/assets/railroad-abnf-HS5TGJTU-BkSycwye.js +1 -0
- package/out/phone/assets/railroad-ebnf-LZEXJU2U-BsPIU3iV.js +1 -0
- package/out/phone/assets/railroad-peg-WCYAUIDC-Cy8G7u5C.js +1 -0
- package/out/phone/assets/{railroadDiagram-O6MQD6OU-r5JJp9nP.js → railroadDiagram-O6MQD6OU-Dr0NTIA6.js} +1 -1
- package/out/phone/assets/{requirementDiagram-BXWQKSXE-Bh86zb_w.js → requirementDiagram-BXWQKSXE-C0W6h_5I.js} +1 -1
- package/out/phone/assets/{sankeyDiagram-P5KCCOFB-CykRlthT.js → sankeyDiagram-P5KCCOFB-CVJDathY.js} +1 -1
- package/out/phone/assets/{sequenceDiagram-WJ2MYXX4-BPLcD6MF.js → sequenceDiagram-WJ2MYXX4-BxHQTG6x.js} +1 -1
- package/out/phone/assets/shellUpdate-DPSfgHG3.js +36 -0
- package/out/phone/assets/{stateDiagram-D77RDMKH-DWXApcUM.js → stateDiagram-D77RDMKH-BO5MAjhs.js} +1 -1
- package/out/phone/assets/stateDiagram-v2-MP3YSRHH-B8IHc2bm.js +1 -0
- package/out/phone/assets/{swimlanes-42K2YHIH-BVi6IPTq.js → swimlanes-42K2YHIH-DnhDPyy6.js} +1 -1
- package/out/phone/assets/swimlanesDiagram-VR7AAH4N-dmSDAN2F.js +8 -0
- package/out/phone/assets/{timeline-definition-24CTP7MA-xf--BXjO.js → timeline-definition-24CTP7MA-bLEjS7re.js} +1 -1
- package/out/phone/assets/{treeView-Q6P3EWNA-DzJs7PRI.js → treeView-Q6P3EWNA-Ci-sA9wK.js} +1 -1
- package/out/phone/assets/{treemap-WGGIJYW6-AXb7EeRP.js → treemap-WGGIJYW6-BXCjzK65.js} +1 -1
- package/out/phone/assets/{vennDiagram-4TSXK5OY-CXDX5KG5.js → vennDiagram-4TSXK5OY-DHsj5dRx.js} +1 -1
- package/out/phone/assets/{wardley-WFR3VGLG-DrSIz3RL.js → wardley-WFR3VGLG-d8TdCu-H.js} +1 -1
- package/out/phone/assets/{wardleyDiagram-VM6X3IG4-DFL8ndUf.js → wardleyDiagram-VM6X3IG4-DQFVP9qu.js} +1 -1
- package/out/phone/assets/{xychartDiagram-S5SC5T6Z-CZZX0maW.js → xychartDiagram-S5SC5T6Z-Dni2Y0ov.js} +1 -1
- package/out/phone/desk.html +81 -2
- package/out/phone/index.html +51 -3
- package/out/phone/manifest.webmanifest +1 -0
- package/out/phone/splash/1125x2436-dark.png +0 -0
- package/out/phone/splash/1125x2436-light.png +0 -0
- package/out/phone/splash/1170x2532-dark.png +0 -0
- package/out/phone/splash/1170x2532-light.png +0 -0
- package/out/phone/splash/1179x2556-dark.png +0 -0
- package/out/phone/splash/1179x2556-light.png +0 -0
- package/out/phone/splash/1206x2622-dark.png +0 -0
- package/out/phone/splash/1206x2622-light.png +0 -0
- package/out/phone/splash/1242x2208-dark.png +0 -0
- package/out/phone/splash/1242x2208-light.png +0 -0
- package/out/phone/splash/1242x2688-dark.png +0 -0
- package/out/phone/splash/1242x2688-light.png +0 -0
- package/out/phone/splash/1260x2736-dark.png +0 -0
- package/out/phone/splash/1260x2736-light.png +0 -0
- package/out/phone/splash/1284x2778-dark.png +0 -0
- package/out/phone/splash/1284x2778-light.png +0 -0
- package/out/phone/splash/1290x2796-dark.png +0 -0
- package/out/phone/splash/1290x2796-light.png +0 -0
- package/out/phone/splash/1320x2868-dark.png +0 -0
- package/out/phone/splash/1320x2868-light.png +0 -0
- package/out/phone/splash/750x1334-dark.png +0 -0
- package/out/phone/splash/750x1334-light.png +0 -0
- package/out/phone/splash/828x1792-dark.png +0 -0
- package/out/phone/splash/828x1792-light.png +0 -0
- package/out/phone/sw.js +219 -6
- package/out/renderer/assets/EditDiff-DxxLuCEI.js +1 -0
- package/out/renderer/assets/File-Tz3MUtN6.js +1 -0
- package/out/renderer/assets/ReadFileView-DFoLPU04.js +4 -0
- package/out/renderer/assets/SidePanel-CL40W2RY.js +47 -0
- package/out/renderer/assets/SidePanel-D0m4IYxS.css +1 -0
- package/out/renderer/assets/Virtualizer-B0uwx_XV.js +1345 -0
- package/out/renderer/assets/{abnfDiagram-VCTEODGH-C03tURh9.js → abnfDiagram-VCTEODGH-CJ9nn9eH.js} +1 -1
- package/out/renderer/assets/{arc-B9ePZBoh.js → arc-B8im8n0O.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-5GKGNRK7-xqG-LPqx.js → architectureDiagram-5GKGNRK7-BRSi5FBk.js} +1 -1
- package/out/renderer/assets/{blockDiagram-I7D4REHJ-BJCB1uWW.js → blockDiagram-I7D4REHJ-CQ1wirIl.js} +1 -1
- package/out/renderer/assets/{c4Diagram-7LVT6UL2-B8YiLE3O.js → c4Diagram-7LVT6UL2-9HyLIioe.js} +1 -1
- package/out/renderer/assets/channel-DjB0ww6b.js +1 -0
- package/out/renderer/assets/{chunk-2Q5K7J3B-BfCgzuF1.js → chunk-2Q5K7J3B-BwC9g3bx.js} +1 -1
- package/out/renderer/assets/{chunk-5VM5RSS4-j2RDggaS.js → chunk-5VM5RSS4-DMtgxPBL.js} +1 -1
- package/out/renderer/assets/{chunk-F27PBJKO-D1w1G98C.js → chunk-F27PBJKO-DSi_XV5v.js} +1 -1
- package/out/renderer/assets/{chunk-IMKFNOWR-HX7TqjEn.js → chunk-IMKFNOWR-Dctc6Apj.js} +1 -1
- package/out/renderer/assets/{chunk-JWPE2WC7-Ee_2ucfe.js → chunk-JWPE2WC7-I2BD5qM7.js} +1 -1
- package/out/renderer/assets/{chunk-POPQ4Y6H-DuxBT9GV.js → chunk-POPQ4Y6H-k60pc4eT.js} +1 -1
- package/out/renderer/assets/{chunk-SVP7TREG-DFjkSsO8.js → chunk-SVP7TREG-zCGemfqm.js} +1 -1
- package/out/renderer/assets/{chunk-TICWLB2K-1B31w-4D.js → chunk-TICWLB2K-CdDiHIq-.js} +1 -1
- package/out/renderer/assets/{chunk-XXDRQBXY-DZ7nGbEc.js → chunk-XXDRQBXY-GYVDxVfN.js} +1 -1
- package/out/renderer/assets/classDiagram-ZZMXUADV-6SiAw1np.js +1 -0
- package/out/renderer/assets/classDiagram-v2-VYDZK3BY-6SiAw1np.js +1 -0
- package/out/renderer/assets/{cose-bilkent-JH36ORCC-k2aKhVw_.js → cose-bilkent-JH36ORCC-BnSAtUh-.js} +1 -1
- package/out/renderer/assets/{cynefin-OW5HDTMX-xPUo1qjT.js → cynefin-OW5HDTMX-DnQaS9VN.js} +1 -1
- package/out/renderer/assets/{cynefinDiagram-5FMLGOSQ-KbWg9eRv.js → cynefinDiagram-5FMLGOSQ-BNQdw0PV.js} +1 -1
- package/out/renderer/assets/{cytoscape-fcose-CLBXU3_O.js → cytoscape-fcose-CzkrRInm.js} +1 -1
- package/out/renderer/assets/{dagre-GXQ25YYZ-ilq61to2.js → dagre-GXQ25YYZ-fG1vMsyn.js} +1 -1
- package/out/renderer/assets/{diagram-S7CK7UJ4-DsRzYvTT.js → diagram-S7CK7UJ4-BcfAFVc2.js} +1 -1
- package/out/renderer/assets/{diagram-UQ7AKVKN-nE6Ly2i6.js → diagram-UQ7AKVKN-D8f3Tsx9.js} +1 -1
- package/out/renderer/assets/{diagram-VSXAHHWV-B9Crbma_.js → diagram-VSXAHHWV-B-U9CIWt.js} +1 -1
- package/out/renderer/assets/{diagram-VX7I27RA-Bm5JhnFh.js → diagram-VX7I27RA-CX6ifTkJ.js} +1 -1
- package/out/renderer/assets/{diagram-Z3DM3KII-ZD7ANoYg.js → diagram-Z3DM3KII-49dS9s3L.js} +1 -1
- package/out/renderer/assets/{ebnfDiagram-PWID7BFC-CT3pW9tk.js → ebnfDiagram-PWID7BFC-CraGJRI7.js} +1 -1
- package/out/renderer/assets/{erDiagram-RLTQ6QDP-D0ikskdu.js → erDiagram-RLTQ6QDP-CfMNvEoW.js} +1 -1
- package/out/renderer/assets/{flowDiagram-HODETNUW-BOF_JMXY.js → flowDiagram-HODETNUW-C8XM3p4T.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-EL5Y4UJY-BCEnP39-.js → ganttDiagram-EL5Y4UJY-DlJBMKFX.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-WWUBYQGX-WpPHHkc3.js → gitGraphDiagram-WWUBYQGX-DvEzDsKF.js} +1 -1
- package/out/renderer/assets/globals-BFf1P-Y5.js +715 -0
- package/out/renderer/assets/globals-DUBhAVpU.css +1 -0
- package/out/renderer/assets/index-L4TTIP10.js +89 -0
- package/out/renderer/assets/{infoDiagram-27XIBGKW-nRW-sje9.js → infoDiagram-27XIBGKW-CckfBO-R.js} +1 -1
- package/out/renderer/assets/{ishikawaDiagram-5VMMS53U-CEfZo_k8.js → ishikawaDiagram-5VMMS53U-mUoXchkB.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-3NMN7TZE-C5hopb9Y.js → journeyDiagram-3NMN7TZE-zzLL0HFW.js} +1 -1
- package/out/renderer/assets/{kanban-definition-UXKFOSKX-D9XV2n-x.js → kanban-definition-UXKFOSKX-BJ_9aIhB.js} +1 -1
- package/out/renderer/assets/{layout-t2tiRL7x.js → layout-3SRMHY7n.js} +1 -1
- package/out/renderer/assets/{linear-DJLwPmUz.js → linear-CWpclK_R.js} +1 -1
- package/out/renderer/assets/manifest-DOzTaB8J.js +525 -0
- package/out/renderer/assets/{mermaid.core-C0XHWibr.js → mermaid.core-DORpmVi3.js} +5 -5
- package/out/renderer/assets/{mindmap-definition-YA3MSWOX-DD-erShR.js → mindmap-definition-YA3MSWOX-CYBlCqIB.js} +1 -1
- package/out/renderer/assets/{pegDiagram-XKGWAZYB-DZ0Jk0gq.js → pegDiagram-XKGWAZYB-DhWwLs4v.js} +1 -1
- package/out/renderer/assets/{pieDiagram-E7YTZNPT-E7wG7xIV.js → pieDiagram-E7YTZNPT-Bzpc57-A.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-AXDQQJYC-iyjmw417.js → quadrantDiagram-AXDQQJYC-spKXEbds.js} +1 -1
- package/out/renderer/assets/{railroadDiagram-O6MQD6OU-vCkzrMpv.js → railroadDiagram-O6MQD6OU-Br553px3.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-BXWQKSXE-DJ7nU4ps.js → requirementDiagram-BXWQKSXE-CX-Dqij_.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-P5KCCOFB-1TKFsYjQ.js → sankeyDiagram-P5KCCOFB-Bgx1W6B9.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-WJ2MYXX4-C3ajyWo7.js → sequenceDiagram-WJ2MYXX4-CKQv6pcU.js} +1 -1
- package/out/renderer/assets/sessionChanges-BLzNhRuv.js +31 -0
- package/out/renderer/assets/settings-Bsrw4ERp.js +25 -0
- package/out/renderer/assets/{sizeCapture-INFHLROL-BKripAfM.js → sizeCapture-INFHLROL-DtRedfRe.js} +1 -1
- package/out/renderer/assets/{stateDiagram-D77RDMKH-DSqc4avN.js → stateDiagram-D77RDMKH-CMP5owem.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-6-731AqJ.js +1 -0
- package/out/renderer/assets/{swimlanes-42K2YHIH-C2Jeg683.js → swimlanes-42K2YHIH-D30AvvmW.js} +1 -1
- package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-B8KijqIT.js +8 -0
- package/out/renderer/assets/{timeline-definition-24CTP7MA-rvOKRLqz.js → timeline-definition-24CTP7MA-CsZAMmMZ.js} +1 -1
- package/out/renderer/assets/{vennDiagram-4TSXK5OY-Cig1eOav.js → vennDiagram-4TSXK5OY-COQ7L1f7.js} +1 -1
- package/out/renderer/assets/{wardleyDiagram-VM6X3IG4-C8spX5XL.js → wardleyDiagram-VM6X3IG4-dqMWLTCs.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-S5SC5T6Z-DHQsGiFY.js → xychartDiagram-S5SC5T6Z-DX4clIYP.js} +1 -1
- package/out/renderer/index.html +3 -4
- package/out/renderer/plugin-view.html +37 -0
- package/out/renderer/settings.html +7 -4
- package/out/renderer/web-preload.js +40 -40
- package/out/server/agent.js +915 -606
- package/out/server/chunks/{agent-BbLTL3oo.js → agent-BbNq8i9j.js} +987 -689
- package/out/server/chunks/conversationsMove-CvFPFHaa.js +587 -0
- package/out/server/chunks/dispatchModel-CsfmL396.js +20 -0
- package/out/server/chunks/gpuBackendInstall-jAzoFq7U.js +237 -0
- package/out/server/chunks/{loadProvider-ff0h4G9y.js → loadProvider-NdOVbsHi.js} +2 -2
- package/out/server/chunks/{manifest-DjsZzZuh.js → manifest-BPXFscqI.js} +9 -3
- package/out/server/chunks/registry-BhoHPSKn.js +3353 -0
- package/out/server/chunks/{resources-DmaKIeBc.js → resources-BfbTkFP0.js} +23 -12
- package/out/server/chunks/sendImage-BCNW9JRV.js +418 -0
- package/out/server/chunks/{storageScanWorker-Bebego8l.js → storageScanWorker-CR7HbOWG.js} +2 -2
- package/out/server/chunks/{storageScanWorker-BQ1LXUu7.js → storageScanWorker-DjFyHTye.js} +2 -2
- package/out/server/chunks/{workflowPresets-XbQNDJh1.js → workflowPresets-C2T1BzA2.js} +1725 -720
- package/out/server/index.js +14387 -16832
- package/out/server/memory-service.js +5008 -0
- package/out/server/plugin-host.js +2 -2
- package/package.json +2 -3
- package/out/phone/assets/EnsoNerdSymbolsMono-Regular-TdeMQojc.ttf +0 -0
- package/out/phone/assets/architecture-7GRP2DOG-C-qor9pl.js +0 -1
- package/out/phone/assets/channel-X_IbcoWa.js +0 -1
- package/out/phone/assets/classDiagram-ZZMXUADV-BM8gYXGQ.js +0 -1
- package/out/phone/assets/classDiagram-v2-VYDZK3BY-BM8gYXGQ.js +0 -1
- package/out/phone/assets/desk-BNoyCelL.js +0 -2
- package/out/phone/assets/eventmodeling-NTZA5JFV-BdEBApKV.js +0 -1
- package/out/phone/assets/flowDiagram-HODETNUW-OPg41_ia.js +0 -1
- package/out/phone/assets/main-BU1pbfVw.css +0 -1
- package/out/phone/assets/main-ZLMPRLjZ.js +0 -1658
- package/out/phone/assets/railroad-abnf-HS5TGJTU-BoQXwOPL.js +0 -1
- package/out/phone/assets/railroad-ebnf-LZEXJU2U-1G126duh.js +0 -1
- package/out/phone/assets/railroad-peg-WCYAUIDC-C7pIuHge.js +0 -1
- package/out/phone/assets/stateDiagram-v2-MP3YSRHH-BMZswIYt.js +0 -1
- package/out/phone/assets/storage-dUWOZ2xo.js +0 -36
- package/out/phone/assets/swimlanesDiagram-VR7AAH4N-RYt3eASc.js +0 -8
- package/out/renderer/assets/channel-DwCSANyp.js +0 -1
- package/out/renderer/assets/classDiagram-ZZMXUADV-BT-9dtRl.js +0 -1
- package/out/renderer/assets/classDiagram-v2-VYDZK3BY-BT-9dtRl.js +0 -1
- package/out/renderer/assets/globals-DWAN16wT.js +0 -2603
- package/out/renderer/assets/globals-DoPyZAQo.css +0 -1
- package/out/renderer/assets/index-DOUivox4.js +0 -133
- package/out/renderer/assets/index-F_0FxVZ_.css +0 -1
- package/out/renderer/assets/settings-BmMFkVO5.js +0 -27
- package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-JOz8ISDT.js +0 -1
- package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-Km8IGI0J.js +0 -8
- package/out/server/chunks/conversationsMove-CJZfkj55.js +0 -57
- package/out/server/chunks/engine-IZbRceya.js +0 -70
- package/out/server/chunks/engineWorker-CQxNRdLD.js +0 -6
- package/out/server/chunks/engineWorker-CrUIcXCt.js +0 -73
- package/out/server/chunks/gpuBackendInstall-COO4pT2M.js +0 -158
- package/out/server/chunks/hanbao-_aDjow_f.js +0 -187
- package/out/server/chunks/speech-CqK6_tIR.js +0 -25
- package/out/server/chunks/wetype-CR0YLhHP.js +0 -677
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import{aj as Dt,aR as af,aS as lf,aT as ns,c as Un,aU as hf,aV as df,aW as cf,D as uf,A as pf,r as b,W as ff,aX as gr,j as d,aY as oe,aZ as mf,a_ as ue,a$ as gf,b0 as vl,b1 as vf,b2 as _f,b3 as bf,b4 as wf,b5 as yf,u as he,b6 as Os,b7 as Sf,b8 as Gs,b9 as Wr,ba as _i,bb as bi,ax as Y,bc as Kn,bd as Fd,be as xf,bf as Cf,bg as Df,bh as Zi,bi as Vd,bj as ha,bk as Ud,bl as zs,bm as Bi,bn as da,bo as Kd,bp as Hr,bq as yi,br as Ue,aQ as ca,bs as kf,bt as qd,aP as Pf,bu as Yd,bv as Ef,bw as Tf,bx as If,by as Af,bz as Xd,bA as Rf,bB as Lf,bC as Jd,bD as Zd,bE as Qd,bF as Nf,bG as Mf,M as Of,bH as Gf,bI as zf,bJ as kr,bK as ec,a as ua,C as pa,e as fa,aO as Ne,bL as ma,bM as tc,bN as Bf,bO as jf,bP as $f,bQ as Wf,bR as Hf,bS as Ff,bT as Vf,bU as _l,aF as Uf,bV as qn,bW as De,bX as ic,bY as sc,bZ as Yn,t as Kf,i as qf,b_ as Yf,b$ as Xf,c0 as rc,c1 as nc,aE as oc,c2 as Fr,c3 as Jf,c4 as Ys,c5 as Zf,c6 as Qf,c7 as em,c8 as tm,c9 as im,ca as sm,cb as rm,cc as nm,cd as om,ce as bl,cf as am,cg as ga,ch as lm,ci as hm,cj as dm,ck as cm,cl as ac,cm as va,cn as _a,co as ba,cp as et,cq as um,cr as lc,cs as un,ct as wl,cu as pm,cv as wa,cw as fm,cx as Si,cy as mm,cz as gm,cA as hc,cB as vm,cC as Xn,cD as _m,cE as bm,cF as wm,cG as ym,cH as Sm,cI as xm,cJ as Cm,cK as Dm,cL as km,cM as Pm,cN as Em,cO as Tm,cP as Im,cQ as Am,cR as Rm,cS as yl,cT as Lm,cU as Nm,cV as Mm,cW as Om,cX as Gm,cY as zm,cZ as Bm,c_ as jm,c$ as $m,d0 as dc,d1 as cc,d2 as uc,d3 as Wm,d4 as Hm,d5 as Fm,d6 as Vm,d7 as Um,d8 as oi,d9 as Km}from"./globals-BFf1P-Y5.js";import{S as ya,I as qm,i as Ym,U as Sa,o as xa,u as Xm,t as Jm,a as Zm,K as Qm,s as eg,k as tg,b as ig,c as Et,m as sg,A as pc,e as rg,C as ng,R as og,f as ag,g as fc,h as mc,j as gc,l as vc,n as lg,p as hg,q as dg,r as cg,v as ug,w as Sl,x as pg,M as Ca,y as fg,z as mg,T as gg,B as vg,D as _g,F as bg,G as wg,H as _c,J as Da,d as yg,L as Sg,N as xg,O as Cg,P as Dg,Q as Vr,V as Ur,W as kg,X as Pg,Y as Xs,Z as os,_ as Jn,$ as Eg,a0 as xl,a1 as Tg,a2 as Ig,a3 as Ag,a4 as Rg,a5 as Lg,a6 as ka,a7 as bc,a8 as Ng,a9 as Mg,aa as Og,ab as Gg}from"./index-L4TTIP10.js";import{i as Cl,Q as zg,H as Bs,L as Bg,M as jg,a as $g,b as Wg,c as Kr,F as Hg,E as Fg}from"./manifest-DOzTaB8J.js";import{P as Dl,L as kl,c as wc,Q as Vg,V as Ug,W as Kg,F as qg,a as Yg,b as mi,X as Xg,Y as Jg}from"./Virtualizer-B0uwx_XV.js";import{V as Zg,f as Qg,r as ev,p as tv,s as iv,b as sv,c as rv}from"./sessionChanges-BLzNhRuv.js";import{V as nv,r as ov,F as av}from"./File-Tz3MUtN6.js";const lv=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],hv=Dt("chevrons-down-up",lv);const dv=[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]],cv=Dt("coffee",dv);const uv=[["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"}]],pv=Dt("earth",uv);const fv=[["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:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]],mv=Dt("file-diff",fv);const gv=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],vv=Dt("git-commit-horizontal",gv);const _v=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],yc=Dt("layout-grid",_v);const bv=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]],wv=Dt("list-checks",bv);const yv=[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]],Sv=Dt("list-tree",yv);const xv=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],Sc=Dt("lock",xv);const Cv=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],Dv=Dt("radio-tower",Cv);const kv=[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]],Pv=Dt("sunrise",kv);const Ev=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],Tv=Dt("unlink",Ev);function Iv(e){const t=[];for(const i of e){const s=t.at(-1);if(s&&s.batch===i.batch&&s.phase===i.phase){s.members.push(i);continue}t.push({batch:i.batch,members:[i],...i.phase?{phase:i.phase}:{}})}return t}const Av=new Set(["failed","needs-user"]),Pl=40,xc={"goal-complete":{tone:"ok",label:"Goal complete"},"turn-ended":{tone:"ok",label:"Turn ended"},"goal-blocked":{tone:"warn",label:"Goal blocked"},"needs-user":{tone:"warn",label:"Waiting for you"},stalled:{tone:"warn",label:"Stalled"},interrupted:{tone:"warn",label:"Interrupted"},failed:{tone:"bad",label:"Failed"}},Rv={running:{tone:"run",label:"Started"},idle:{tone:"idle",label:"Idle"},waiting:{tone:"idle",label:"Waiting for you"},error:{tone:"idle",label:"Failed"},"not-started":{tone:"idle",label:"Not started"}};function Cc(e){return e.continuing?{tone:"run",label:"In progress",at:e.stateSince}:e.result&&e.state!=="running"?{...xc[e.result],at:e.resultAt??e.stateSince}:{...Rv[e.state],at:e.stateSince}}function Lv(e){const t=Cc(e);return{id:`session:${e.conversationId}`,at:t.at,tone:t.tone,projectName:e.projectName,title:e.title,label:t.label,...e.lastText?{detail:e.lastText}:{},conversationId:e.conversationId,...e.state==="running"?{running:!0}:{}}}function Nv(e){return e.kind==="profile"?"Update the secretary profile":e.kind==="skill"?`Skill: ${e.draft.name}`:e.kind==="tool"?`Tool: ${e.draft.name}`:e.kind==="takeover"?e.draft.title??e.draft.conversationId:e.kind==="cleanup"?`Clean up ${e.draft.items.length} items`:e.draft.title?.trim()||e.draft.prompt.split(`
|
|
2
|
+
`)[0]?.trim()||""}function Mv(e){return{id:`proposal:${e.proposal.id}`,at:e.proposal.createdAt,tone:"warn",projectName:e.projectName??"",title:Nv(e.proposal),label:"Waiting for your confirmation"}}function Ov(e){const t=e.pending.status==="failed";return{id:`pending:${e.pending.id}`,at:e.pending.updatedAt,tone:t?"bad":"run",projectName:e.projectName,title:e.pending.draft.title?.trim()||e.pending.draft.prompt.split(`
|
|
3
|
+
`)[0]?.trim()||"",label:t?"Dispatch problem":"Waiting for dependencies"}}function Gv(e,t){const i=e.kind==="seen"?{tone:"idle",label:"Secretary saw this"}:xc[e.kind];return{id:`activity:${e.conversationId}:${e.at}:${e.kind}`,at:e.at,tone:i.tone,projectName:t?.projectName??"",title:t?.title||e.conversationId,label:i.label,...e.text?{detail:e.text}:{},conversationId:e.conversationId}}function zv(e,t){return t.at-e.at||e.id.localeCompare(t.id)}function Bv(e){const t=[...e.needsYou,...e.running,...e.done].filter(s=>s.kind==="session"),i=new Map(t.map(s=>[s.conversationId,s]));return[...e.needsYou,...e.running,...e.done].map(s=>s.kind==="proposal"?Mv(s):s.kind==="pending"?Ov(s):Lv(s)).concat((e.activity??[]).map(s=>Gv(s,i.get(s.conversationId)))).sort(zv)}function pn(e,t,i){const s=new Map(t.map(a=>[a.id,a])),r=new Set(e.map(a=>a.id)),n=e.map(a=>s.get(a.id)??a),o=t.filter(a=>!r.has(a.id));return i?{events:[...o,...n],pending:[]}:{events:n,pending:o}}function jv(e,t){const i=new Map(e.map((n,o)=>[n.id,o])),s=e.slice(),r=[];for(const n of t){const o=i.get(n.id);o===void 0?r.push(n):s[o]=n}return[...s,...r]}function Dc(e,t){return e==null||t==null?e===t:e.header!==t.header||e.footer!==t.footer?!1:$v(e.items,t.items)}function $v(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++){const s=e[i],r=t[i];if(s==null||r==null||s.id!==r.id||s.type!==r.type||s.element!==r.element||s.instance!==r.instance||s.version!==r.version)return!1}return!0}function Wv(e,t,i){const s=document.createElement("div");return s.style.display="flow-root",e==="header"?(s.setAttribute(af,""),t.before(s)):(s.setAttribute(lf,""),t.after(s)),i?.observe(s),s}function Hv(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Rt(e){const t=window.devicePixelRatio??1;return Math.round(e*t)/t}const Fv=["theme","disableLineNumbers","overflow","themeType","disableFileHeader","disableVirtualizationBuffers","preferredHighlighter","useCSSClasses","useTokenTransformer","tokenizeMaxLineLength","tokenizeMaxLength","unsafeCSS","diffStyle","diffIndicators","disableBackground","expandUnchanged","loadDiffFiles","collapsedContextThreshold","lineDiffType","maxLineDiffLength","expansionLineCount","lineHoverHighlight","enableTokenInteractionsOnWhitespace","enableGutterUtility","__debugPointerEvents","enableLineSelection","controlledSelection","disableErrorHandling"],Vv=["theme","disableLineNumbers","overflow","themeType","disableFileHeader","disableVirtualizationBuffers","preferredHighlighter","useCSSClasses","useTokenTransformer","tokenizeMaxLineLength","tokenizeMaxLength","unsafeCSS","lineHoverHighlight","enableTokenInteractionsOnWhitespace","enableGutterUtility","__debugPointerEvents","enableLineSelection","controlledSelection","disableErrorHandling"],El=["renderCustomHeader","renderHeaderPrefix","renderHeaderFilenameSuffix","renderHeaderMetadata","renderAnnotation","renderGutterUtility","onPostRender","onGutterUtilityClick","onLineClick","onLineNumberClick","onLineEnter","onLineLeave","onTokenClick","onTokenEnter","onTokenLeave"],Tl=["onLineSelected","onLineSelectionStart","onLineSelectionChange","onLineSelectionEnd"],kc=Symbol("CodeView.itemOptionsState");function Il(e,t){Object.defineProperty(e,kc,{configurable:!1,enumerable:!1,value:t})}function as(e){return e[kc]}function Vt(e,t,i){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get(){return i(this)}})}const Uv=120,Al=1,Rl="--diffs-overflow-override",Pa=12e6,Pc=1e6,Ec=2e6,Kv=Pa-Ec,Ll=Pa-Pc;function qv(e){if(e==null)throw new Error("CodeView: createEditor is required for items with edit: true")}const Yv=(()=>{const{navigator:e}=globalThis,t=e.userAgent,i=/iP(?:hone|ad|od)/.test(t),s=e.platform==="MacIntel"&&e.maxTouchPoints>1;return(i||s)&&/AppleWebKit/.test(t)&&/Safari/.test(t)&&!/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(t)})();var Xv=class Yt{static __STOP=!1;static __lastScrollPosition=0;type="advanced";config={overscrollSize:200,intersectionObserverMargin:0,resizeDebugging:!1};items=[];idToItem=new Map;selectedLines=null;itemEditors=new Map;attachedEditors=new Set;instanceToItem=new Map;layoutDirtyIndex;pendingLayoutReset;renderOptionsRevision=0;slotCoordinator;slotSnapshot;scrollListeners=new Set;scrollHeight=0;containerHeight=-1;scrollTop=0;scrollPageOffset=0;scrollDirty=!0;scrollInteractionFixTimer;pointerEventsDisabled=!1;codeOverflowFix=!1;height=0;heightDirty=!0;windowSpecs={top:0,bottom:0};renderState={scrollTop:-1,firstIndex:-1,lastIndex:-1,stickyHeight:0,stickyTop:-1,stickyBottom:-1};itemMetricsCache=ns;fileOptionsPrototype;diffOptionsPrototype;pendingScrollTarget;pendingLayoutAnchor;shouldFixContainerFocus=!1;scrollAnimation;root;resizeObserver;container=document.createElement("div");stickyContainer=document.createElement("div");stickyOffset=document.createElement("div");header={element:void 0,render:void 0,height:0};footer={element:void 0,render:void 0,height:0};elementPool=[];elementPoolVersion=0;elementPoolTracker=new WeakMap;pendingElementPool=[];options;workerManager;isReadySubscription;isContainerManaged;constructor(t={theme:Un},i,s=!1){this.options=t,this.computeMetricsCache(t.itemMetrics),this.fileOptionsPrototype=this.createFileOptionsPrototype(),this.diffOptionsPrototype=this.createDiffOptionsPrototype(),this.workerManager=i,this.isContainerManaged=s,this.stickyOffset.style.contain="layout size",this.stickyContainer.style.position="sticky",this.stickyContainer.style.width="100%",this.stickyContainer.style.contain="layout style inline-size",this.stickyContainer.style.isolation="isolate",this.stickyContainer.style.display="flex",this.stickyContainer.style.flexDirection="column"}getLayout(){return this.options.layout??hf}getItemTopOffset(){return this.getLayout().paddingTop+this.header.height}computeMetricsCache(t){return this.itemMetricsCache={hunkLineCount:t?.hunkLineCount??ns.hunkLineCount,lineHeight:t?.lineHeight??ns.lineHeight,diffHeaderHeight:t?.diffHeaderHeight??ns.diffHeaderHeight,hunkSeparatorHeight:t?.hunkSeparatorHeight,spacing:t?.spacing??ns.spacing,paddingTop:t?.paddingTop,paddingBottom:t?.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??df}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return cf&&this.options.__devOnlyValidateItemHeights===!0}validateRenderedItemHeight(t){if(!this.shouldValidateItemHeights()||t.element==null)return;const i=t.instance.getAdvancedStickySpecs();if(i==null)return;const s=i.height,r=t.element.getBoundingClientRect().height;s!==r&&console.error("CodeView: reconciled item height does not match DOM height",{id:t.item.id,type:t.type,index:t.index,version:t.version,expectedHeight:s,actualHeight:r,delta:r-s,stickyTopOffset:i.topOffset,virtualizedHeight:t.instance.getVirtualizedHeight(),top:t.top,scrollTop:this.getScrollTop(),windowSpecs:{...this.windowSpecs},element:t.element,instance:t.instance})}validateStickyContainerHeight(){if(!this.shouldValidateItemHeights())return;const{firstIndex:t,lastIndex:i,stickyHeight:s,stickyTop:r,stickyBottom:n}=this.renderState;if(t===-1||i===-1)return;const o=this.stickyContainer.getBoundingClientRect().height;Math.abs(o-s)<Al||console.error("CodeView: sticky container height does not match computed layout",{computedStickyHeight:s,actualStickyHeight:o,delta:o-s,stickyTop:r,stickyBottom:n,firstIndex:t,lastIndex:i,firstStickySpecs:this.items[t]?.instance.getAdvancedStickySpecs(),lastStickySpecs:this.items[i]?.instance.getAdvancedStickySpecs(),scrollTop:this.getScrollTop(),scrollPageOffset:this.scrollPageOffset,windowSpecs:{...this.windowSpecs},stickyContainer:this.stickyContainer})}clearScrollInteractionTimer(){this.scrollInteractionFixTimer!=null&&(clearTimeout(this.scrollInteractionFixTimer),this.scrollInteractionFixTimer=void 0)}suspendScrollInteractions(){this.clearScrollInteractionTimer(),this.shouldDisablePointerEvents()&&!this.pointerEventsDisabled&&(this.stickyContainer.style.pointerEvents="none",this.pointerEventsDisabled=!0),Yv&&!this.codeOverflowFix&&(this.stickyContainer.style.setProperty(Rl,"hidden"),this.codeOverflowFix=!0),this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,Uv)}restoreScrollInteractions=()=>{this.clearScrollInteractionTimer(),this.pointerEventsDisabled&&(this.stickyContainer.style.removeProperty("pointer-events"),this.pointerEventsDisabled=!1),this.codeOverflowFix&&(this.stickyContainer.style.setProperty(Rl,"auto"),this.codeOverflowFix=!1)};syncLayout(){const{gap:t,paddingBottom:i,paddingTop:s}=this.getLayout();this.stickyContainer.style.gap=`${t}px`,this.container?.style.setProperty("margin-top",`${s}px`),this.container?.style.setProperty("margin-bottom",`${i}px`)}reconcileHeaderFooterHosts(){const t=this.reconcileHost("header"),i=this.reconcileHost("footer");return t||i}reconcileHost(t){const{root:i,container:s}=this;if(i==null||s==null)return!1;const r=t==="header"?this.header:this.footer,n=t==="header"?this.options.renderCodeViewHeader:this.options.renderCodeViewFooter;if(n==null)return r.element==null||(this.resizeObserver?.unobserve(r.element),r.element.remove(),r.element=void 0,r.render=void 0,this.setHostHeight(r,0)),!1;if(r.element!=null&&n===r.render)return!1;const o=r.element??Wv(t,s,this.resizeObserver);r.element=o;const a=n();return a!=null?o.replaceChildren(a):!this.isContainerManaged&&o.children.length>0&&(o.textContent=""),r.render=n,!0}setHostHeight(t,i){t.height!==i&&(t.height=i,this.scrollDirty=!0)}measureMountedHosts(){this.header.element!=null&&this.setHostHeight(this.header,this.header.element.getBoundingClientRect().height),this.footer.element!=null&&this.setHostHeight(this.footer,this.footer.element.getBoundingClientRect().height)}setup(t){if(this.root!=null)throw new Error("CodeView.setup: already setup");this.workerManager?.subscribeToThemeChanges(this),this.root=t,this.root.style.overflowAnchor="none",this.root.hasAttribute("tabindex")||(this.root.tabIndex=-1),this.container??=document.createElement("div"),this.container.style.contain="layout style",this.syncLayout(),this.container.appendChild(this.stickyOffset),this.container.appendChild(this.stickyContainer),this.root.appendChild(this.container),this.scrollDirty=!0,this.heightDirty=!0,this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.stickyContainer),this.root.addEventListener("scroll",this.handleScroll,{passive:!0}),this.root.addEventListener("wheel",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("touchstart",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("pointerdown",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("keydown",this.clearPendingScroll,{passive:!0}),this.resizeObserver.observe(this.root),this.render(!0),window.__INSTANCE=this,window.__TOGGLE=()=>{Yt.__STOP?(Yt.__STOP=!1,this.scrollTo({type:"position",position:Yt.__lastScrollPosition,behavior:"instant"})):(Yt.__lastScrollPosition=this.getScrollTop(),Yt.__STOP=!0)}}reset(){Dl(this.computeRenderRangeAndEmit),this.clearReadySubscription(),this.restoreScrollInteractions(),this.cleanAllRenderedItems();for(const t of this.itemEditors.values())t.editor.cleanUp();this.itemEditors.clear(),this.attachedEditors.clear(),this.selectedLines=null,this.items.length=0,this.idToItem.clear(),this.instanceToItem.clear(),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,this.stickyContainer.textContent="",this.stickyOffset.style.height="",this.container?.style.removeProperty("height"),this.containerHeight=-1,this.windowSpecs={top:0,bottom:0},this.pendingLayoutAnchor=void 0,this.shouldFixContainerFocus=!1,this.height=0,this.scrollTop=0,this.scrollPageOffset=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.resetRenderState(),this.isContainerManaged||this.flushSlotCoordinator()}cleanUp(){this.reset(),this.clearElementPool(),this.restoreScrollInteractions(),this.workerManager?.unsubscribeToThemeChanges(this),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.root?.removeEventListener("scroll",this.handleScroll),this.root?.removeEventListener("wheel",this.clearPendingScroll),this.root?.removeEventListener("touchstart",this.clearPendingScroll),this.root?.removeEventListener("pointerdown",this.clearPendingScroll),this.root?.removeEventListener("keydown",this.clearPendingScroll),this.root?.style.removeProperty("overflow-anchor"),this.container?.remove(),this.stickyOffset.remove(),this.stickyContainer.remove(),this.stickyContainer.textContent="",this.header.element?.remove(),this.header.element=void 0,this.header.render=void 0,this.header.height=0,this.footer.element?.remove(),this.footer.element=void 0,this.footer.render=void 0,this.footer.height=0,this.root=void 0,this.container=void 0}cleanAllRenderedItems(){if(this.renderState.firstIndex!==-1)for(let t=this.renderState.firstIndex;t<=this.renderState.lastIndex;t++){const i=this.items[t];if(i==null)throw new Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${t}`);this.releaseRenderedItem(i)}}primeScrollTarget(t){if(t.type==="position")return;const i=this.idToItem.get(t.id);i?.instance.primeHighlightCache()}getElementPoolLimit(){const t=this.getHeight()+this.config.overscrollSize*2,{diffHeaderHeight:i}=this.itemMetricsCache;return Math.max(8,Math.ceil(t/Math.max(i,10))+1)*(this.isContainerManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let t=this.elementPool.pop();for(;t!=null&&!this.isElementPoolGenerationCurrent(t);)t=this.elementPool.pop();return t??=document.createElement(uf),this.markElementPoolGenerationCurrent(t),t}releaseRenderedItem(t){const{element:i}=t;i!=null&&this.renderedItemOwnsFocus(i)&&(this.shouldFixContainerFocus=!0),t.instance.cleanUp(!0),this.attachedEditors.delete(t.item.id),t.element=void 0,i!=null&&(i.remove(),this.cleanElement(i),this.queueElementForPool(i))}renderedItemOwnsFocus(t){const{activeElement:i}=document;return i===t||t.contains(i)||t.shadowRoot?.activeElement!=null}fixContainerFocus(){this.shouldFixContainerFocus&&(this.shouldFixContainerFocus=!1,this.root?.focus({preventScroll:!0}))}cleanElement(t){const{shadowRoot:i}=t;if(i!=null)for(const s of Array.from(i.children))t_(s)||s.remove();this.isContainerManaged||t.replaceChildren()}queueElementForPool(t){const i=this.getElementPoolLimit();!this.isElementPoolGenerationCurrent(t)||this.getElementPoolSize()>=i||(this.isElementClean(t)?this.elementPool.push(t):this.pendingElementPool.push(t))}promotePendingPooledElements(){if(this.pendingElementPool.length===0)return;const{pendingElementPool:t}=this;this.pendingElementPool=[];const i=this.getElementPoolLimit();for(const s of t)this.isElementPoolGenerationCurrent(s)&&this.isElementClean(s)&&this.elementPool.length<i?this.elementPool.push(s):this.isElementPoolGenerationCurrent(s)&&this.getElementPoolSize()<i&&this.pendingElementPool.push(s)}isElementClean(t){return t.childNodes.length===0}getElementPoolSize(){return this.elementPool.length+this.pendingElementPool.length}clearElementPool(){this.elementPool.length=0,this.pendingElementPool.length=0}invalidateElementPool(){this.elementPoolVersion++,this.clearElementPool()}markElementPoolGenerationCurrent(t){this.elementPoolTracker.set(t,this.elementPoolVersion)}isElementPoolGenerationCurrent(t){return this.elementPoolTracker.get(t)===this.elementPoolVersion}resolveEffectiveScrollBehavior(t,i){return Hv()?"instant":t.behavior!=="smooth-auto"?t.behavior??"instant":Math.abs(i-this.getScrollTop())<=this.getHeight()*10?"smooth":"instant"}scrollTo(t){if(this.root==null)return;const i=this.normalizeScrollTarget(t);if(i==null)return;const s=this.resolveScrollTargetTop(i);s!=null&&(this.primeScrollTarget(i),this.resolveEffectiveScrollBehavior(i,s)==="smooth"?this.scrollAnimation??={position:this.getScrollTop(),velocity:0,lastTimestamp:performance.now()}:this.scrollAnimation=void 0,this.suspendScrollInteractions(),this.pendingLayoutAnchor=void 0,this.pendingScrollTarget=i,this.render())}setSelectedLines(t,i){this.applySelectedLines(t,i)}getSelectedLines(){return this.selectedLines}clearSelectedLines(t){this.applySelectedLines(null,t)}getItem(t){return this.idToItem.get(t)?.item}getEditor(t){return this.itemEditors.get(t)?.editor}updateItem(t){const i=this.idToItem.get(t.id);return i==null?(console.error(`CodeView.updateItem: unknown item id "${t.id}"`),!1):this.syncItemRecord(i,t)?(this.markItemLayoutDirty(i),this.scrollDirty=!0,this.render(),this.syncItemEditors(),this.syncSelection(),!0):!1}updateItemId(t,i){if(t===i)return!0;const s=this.idToItem.get(t);if(s==null)return console.error(`CodeView.updateItemId: unknown item id "${t}"`),!1;if(this.idToItem.has(i))return console.error(`CodeView.updateItemId: duplicate item id "${i}"`),!1;this.idToItem.delete(t),s.item.id=i,this.idToItem.set(i,s),this.updateItemOptionsId(s.instance.options,i),this.selectedLines?.id===t&&(this.selectedLines={...this.selectedLines,id:i},this.options.onSelectedLinesChange?.(this.selectedLines));const r=this.itemEditors.get(t);return r!=null&&(r.state.id=i,this.itemEditors.delete(t),this.itemEditors.set(i,r),this.attachedEditors.delete(t)&&this.attachedEditors.add(i)),this.renamePendingScrollTarget(t,i),this.renamePendingLayoutAnchor(t,i),this.render(),!0}addItem(t){this.addItems([t])}addItems(t){this.appendItemsInternal(t),this.syncItemEditors(),this.syncSelection()}removeItem(t){const i=this.idToItem.get(t);if(i==null)return console.error(`CodeView.removeItem: unknown item id "${t}"`),!1;const s=[];for(const r of this.items)r!==i&&s.push(r.item);return this.setItems(s),!0}setItems(t){let i;this.items.length===0?this.appendItemsInternal(t):this.tryAppendItems(t)||(i=this.reconcileItems(t)),this.syncItemEditors(i),this.syncSelection()}appendItemsInternal(t,i=!0){if(t.length===0)return;const s=this.getLayout();let r=this.items.length===0?0:this.scrollHeight+s.gap;const n=r;for(let o=0;o<t.length;o++){const a=t[o];if(a==null)throw new Error("CodeView.appendItemsInternal: missing input item");if(this.idToItem.has(a.id))throw new Error(`CodeView.addItem: duplicate id "${a.id}"`);const l=this.createItem(a,this.items.length,r);this.items.push(l),this.idToItem.set(l.item.id,l),this.instanceToItem.set(l.instance,l),l.height=Jv(l),r+=l.height+s.gap}this.scrollHeight=r-s.gap,this.scrollDirty=!0,i&&(this.canSkipRenderForAppend(n)?this.syncContainerHeight():this.render())}canSkipRenderForAppend(t){return this.container!=null&&this.renderState.firstIndex!==-1&&this.pendingScrollTarget==null&&this.scrollAnimation==null&&this.layoutDirtyIndex==null&&t>this.windowSpecs.bottom}onThemeChange(){this.invalidateElementPool()}setOptions(t){if(t==null)return;this.capturePendingLayoutAnchor();const{options:i}=this,s=this.getLayout(),{itemMetricsCache:r}=this;Zv(i,t)&&this.invalidateElementPool(),this.options=t;const n=this.computeMetricsCache(t.itemMetrics),o=!kl(r,n),a=!kl(s,this.getLayout());a&&this.syncLayout();const l=o||Qv(i,t);if(l){const c=this.pendingLayoutReset;this.pendingLayoutReset={metrics:o?n:c?.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:c?.includeEstimatedDiffHeights===!0||o||e_(i,t)}}(a||l)&&(this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0),wc(i,t)||this.renderOptionsRevision++,this.syncItemEditors();const h=i.renderCodeViewHeader!==t.renderCodeViewHeader||i.renderCodeViewFooter!==t.renderCodeViewFooter;!this.isContainerManaged&&(this.items.length>0||h)&&this.render()}capturePendingLayoutAnchor(t=this.idToItem){this.root==null||this.items.length===0||this.pendingScrollTarget!=null||(this.pendingLayoutAnchor=this.getScrollAnchor(this.getScrollTop(),t))}render(t=!1){Yt.__STOP||(t?(Dl(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit()):Vg(this.computeRenderRangeAndEmit))}isReady(){const{workerManager:t}=this;return t==null||t.isInitialized()||t.getStats().workersFailed?(this.clearReadySubscription(),!0):(this.isReadySubscription??=t.subscribeToStatChanges(i=>{i.managerState!=="initialized"&&!i.workersFailed||(this.clearReadySubscription(),this.render(!0))}),t.getStats().managerState==="waiting"&&t.initialize().catch(()=>{}),!1)}clearReadySubscription(){this.isReadySubscription!=null&&(this.isReadySubscription(),this.isReadySubscription=void 0)}instanceChanged(t,i){const s=this.instanceToItem.get(t);if(s==null)throw new Error("CodeView.instanceChanged: An instance has changed that is not registered");i&&this.markItemLayoutDirty(s),this.render()}getWindowSpecs(){return this.windowSpecs}getContainerElement(){return this.root}getHeaderElement(){return this.header.element}getFooterElement(){return this.footer.element}getRenderedItems(){const{firstIndex:t,lastIndex:i}=this.renderState;if(t===-1||i===-1||i<t)return[];const s=[];for(let r=t;r<=i;r++){const n=this.items[r];n?.element!=null&&(n.type==="diff"?s.push({id:n.item.id,type:"diff",item:n.item,version:n.version,element:n.element,instance:n.instance}):s.push({id:n.item.id,type:"file",item:n.item,version:n.version,element:n.element,instance:n.instance}))}return s}setSlotCoordinator(t){return t===this.slotCoordinator?!1:(this.slotCoordinator=t,this.slotSnapshot=void 0,!0)}getSlotSnapshot(t){return this.buildSlotSnapshot(t)}buildSlotSnapshot(t){const i=s_(this.getRenderedItems(),t),{element:s}=this.header,{element:r}=this.footer;if(!(i==null&&s==null&&r==null))return{items:i,header:s,footer:r}}subscribeToScroll(t){return this.scrollListeners.add(t),()=>{this.scrollListeners.delete(t)}}getLocalTopForInstance(t){const i=this.instanceToItem.get(t);if(i==null)throw new Error("CodeView.getLocalTopForInstance: unknown virtualized instance");return i.top}getTopForItem(t){const i=this.idToItem.get(t);if(i!=null)return i.top+this.getItemTopOffset()}createItem(t,i,s){const{itemMetricsCache:r}=this;if(t.type==="diff"){const o=new Zg(this.createDiffOptions(t.id),this,r,this.workerManager,this.isContainerManaged);return{type:"diff",item:t,version:t.version,index:i,top:s,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:o}}const n=new nv(this.createFileOptions(t.id),this,r,this.workerManager,this.isContainerManaged);return{type:"file",item:t,version:t.version,index:i,top:s,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:n}}applySelectedLines(t,i){const{selectedLines:s}=this;t==null&&s==null||t!=null&&s?.id===t.id&&Ug(s.range,t.range)||(s!=null&&s.id!==t?.id&&this.idToItem.get(s.id)?.instance.setSelectedLines(null,{notify:!1}),this.selectedLines=t,this.idToItem.get(t?.id??"")?.instance.setSelectedLines(t?.range??null,i))}syncSelection(){if(this.selectedLines==null)return;const t=this.idToItem.get(this.selectedLines.id);if(t==null){this.selectedLines=null,this.options.onSelectedLinesChange?.(null);return}t.instance.setSelectedLines(this.selectedLines.range,{notify:!1})}isItemInEditMode(t){return t.item.edit===!0&&t.item.collapsed!==!0}attachItemEditor(t){const{id:i}=t.item,{createEditor:s}=this.options;if(t.element==null||this.attachedEditors.has(i)||!this.isItemInEditMode(t))return;let r=this.itemEditors.get(i),n=!1;try{if(r==null){qv(s);const o={id:i},a=s({onChange:(l,h)=>{const c=this.idToItem.get(o.id);c!=null&&(o.lastChange={item:c.item,file:l,lineAnnotations:h},this.options.onItemEditChange?.(c.item,l,h))}});if(a==null)return;r={editor:a,state:o},this.itemEditors.set(i,r),n=!0}r.editor.edit(t.instance),this.attachedEditors.add(i)}catch(o){throw n&&r!=null&&(this.itemEditors.delete(i),r.editor.cleanUp()),this.releaseRenderedItem(t),o}}syncItemEditors(t){if(this.itemEditors.size===0)return;const i=[];for(const[s,r]of this.itemEditors){const n=this.idToItem.get(s),o=t?.get(s);if(o==null&&n!=null&&this.isItemInEditMode(n))continue;r.editor.cleanUp(),this.itemEditors.delete(s),this.attachedEditors.delete(s);const{lastChange:a}=r.state,l=o==null?n?.item??a?.item:a?.item??o.item;l?.type==="diff"&&(o==null&&n!=null&&n.type==="diff"&&n.instance.completeEditSession()&&(this.markItemLayoutDirty(n),this.render()),Qg(l.fileDiff)),a!=null&&i.push(o!=null||n==null?a:{...a,item:n.item})}for(const{item:s,file:r,lineAnnotations:n}of i)this.options.onItemEditComplete?.(s,r,n)}renamePendingScrollTarget(t,i){const{pendingScrollTarget:s}=this;s==null||s.type==="position"||s.id!==t||(this.pendingScrollTarget={...s,id:i})}renamePendingLayoutAnchor(t,i){this.pendingLayoutAnchor?.id===t&&(this.pendingLayoutAnchor.id=i)}createFileOptionsPrototype(){const t={};for(const i of Vv)Vt(t,i,()=>this.options[i]);Vt(t,"stickyHeader",()=>this.options.stickyHeaders),Vt(t,"collapsed",i=>{const s=as(i);if(s!=null)return this.getItemOptions(s,"file")?.item.collapsed});for(const i of El)this.defineItemSharedCallback(t,"file",i);for(const i of Tl)this.defineItemSelectionCallback(t,"file",i);return t}createDiffOptionsPrototype(){const t={};for(const i of Fv)Vt(t,i,()=>this.options[i]);Vt(t,"stickyHeader",()=>this.options.stickyHeaders),Vt(t,"hunkSeparators",()=>this.options.hunkSeparators),Vt(t,"collapsed",i=>{const s=as(i);if(s!=null)return this.getItemOptions(s,"diff")?.item.collapsed});for(const i of El)this.defineItemSharedCallback(t,"diff",i);for(const i of Tl)this.defineItemSelectionCallback(t,"diff",i);return t}createFileOptions(t){const i=Object.create(this.fileOptionsPrototype);return Il(i,{id:t}),i}createDiffOptions(t){const i=Object.create(this.diffOptionsPrototype);return Il(i,{id:t}),i}updateItemOptionsId(t,i){const s=as(t);if(s==null)throw new Error("CodeView.updateItemOptionsId: No valid state");s.id=i}getItemOptions(t,i){const s=this.idToItem.get(t.id);if(!(s==null||s.type!==i))return s}defineItemSharedCallback(t,i,s){Vt(t,s,r=>{if(this.options[s]==null)return;const n=as(r);if(n==null)return;const o=n.callbackCache??={};let a=o[s];return a==null&&(a=((...l)=>{const h=this.getItemOptions(n,i);if(h==null)return;const c=this.options[s];return c?.(...l,h)}),o[s]=a),a})}defineItemSelectionCallback(t,i,s){Vt(t,s,r=>{const n=as(r);if(n==null)return;const o=n.callbackCache??={};let a=o[s];return a==null&&(a=(l=>{const h=this.getItemOptions(n,i);if(h==null)return;const c=l==null?null:{id:h.item.id,range:l};this.options.controlledSelection!==!0&&(l!=null||this.selectedLines?.id===h.item.id)&&this.applySelectedLines(c,{notify:!1}),this.options.onSelectedLinesChange?.(c);const u=this.options[s];return u?.(l,h)}),o[s]=a),a})}markLayoutDirtyFromIndex(t){this.layoutDirtyIndex=Math.min(this.layoutDirtyIndex??t,t)}markItemLayoutDirty(t){if(this.items[t.index]!==t)throw new Error(`CodeView.markItemLayoutDirty: unknown item id "${t.item.id}"`);this.markLayoutDirtyFromIndex(t.index)}tryAppendItems(t){if(t.length<=this.items.length)return!1;for(let i=0;i<this.items.length;i++){const s=this.items[i];if(s==null)throw new Error("CodeView.tryAppendItems: missing existing item");const r=t[i];if(r==null||s.item.id!==r.id||s.type!==r.type)return!1}for(let i=0;i<this.items.length;i++){const s=this.items[i];if(s==null)throw new Error("CodeView.tryAppendItems: missing existing item");const r=t[i];if(r==null)throw new Error("CodeView.tryAppendItems: append candidate missing prefix item");this.syncItemRecord(s,r)&&this.markLayoutDirtyFromIndex(i)}return this.appendItemsInternal(t.slice(this.items.length),!1),this.scrollDirty=!0,this.render(),!0}reconcileItems(t){const{items:i,idToItem:s}=this,r=new Set(i),n=[],o=new Map,a=new Map,l=new Map;let h;for(let c=0;c<t.length;c++){const u=t[c];if(u==null)throw new Error("CodeView.reconcileItems: missing input item");if(o.has(u.id))throw new Error(`CodeView.setItems: duplicate id "${u.id}"`);const p=s.get(u.id),f=p!=null&&p.type===u.type?p:this.createItem(u,c,0);f.index=c,p!=null&&p.type===u.type?(r.delete(p),this.syncItemRecord(f,u)&&(h=Math.min(h??c,c))):h=Math.min(h??c,c),i[c]!==f&&(h=Math.min(h??c,c)),n.push(f),o.set(u.id,f),a.set(f.instance,f)}if(h==null){if(r.size===0)return;h=Math.max(n.length-1,0)}this.capturePendingLayoutAnchor(o);for(let c=0;c<i.length;c++){const u=i[c];if(u==null||!r.has(u))continue;l.set(u.item.id,u),this.releaseRenderedItem(u);const p=Math.max(n.length-1,0);h=Math.min(h??p,p)}return this.items=n,this.idToItem=o,this.instanceToItem=a,this.renderState.firstIndex>=n.length?this.resetRenderState():this.renderState.lastIndex>=n.length&&(this.renderState.lastIndex=n.length-1),this.markLayoutDirtyFromIndex(h),this.scrollDirty=!0,this.render(),l.size>0?l:void 0}syncItemRecord(t,i){if(t.type!==i.type)throw new Error(`CodeView.syncItemRecord: type mismatch for id "${i.id}"`);return t.version===i.version?!1:(t.item=i,t.version=i.version,t.renderedOptionsRevision=-1,!0)}getMaxScrollTopForHeight(t){const{paddingBottom:i,paddingTop:s}=this.getLayout();return Math.max(s+this.header.height+t+this.footer.height+i-this.getHeight(),0)}getMaxScrollTop(){return this.getMaxScrollTopForHeight(this.getScrollHeight())}shouldRebaseScroll(){return this.getMaxScrollTop()>Ll}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),Pa):this.getScrollHeight()}getMaxPagedScrollTop(){return this.getMaxScrollTopForHeight(this.getPagedScrollHeight())}clampPagedScrollTop(t){const i=this.getMaxPagedScrollTop();return Math.max(0,Math.min(t,i))}clampScrollTop(t){const i=this.getMaxScrollTop();return Math.max(0,Math.min(t,i))}getMaxScrollPageOffset(){return Math.max(this.getMaxScrollTop()-this.getMaxPagedScrollTop(),0)}clampScrollPageOffset(t){const i=this.getMaxScrollPageOffset();return Math.max(0,Math.min(t,i))}resolveScrollPageWindow(t,i){let s=Rt(this.clampPagedScrollTop(i)),r=this.clampScrollPageOffset(t-s);return s=Rt(this.clampPagedScrollTop(t-r)),r=this.clampScrollPageOffset(t-s),{pagedScrollTop:s,scrollPageOffset:r}}resolvePagedScrollPosition(t){if(!this.shouldRebaseScroll())return{pagedScrollTop:this.clampPagedScrollTop(t),scrollPageOffset:0};const i=this.clampScrollPageOffset(this.scrollPageOffset),s=t-i,r=this.getMaxPagedScrollTop(),n=this.getMaxScrollPageOffset(),o=s>Ll&&i<n,a=s<Pc&&i>0;return s<0||s>r||o||a?this.resolveScrollPageWindow(t,a?Math.min(Kv,r):Ec):{pagedScrollTop:Rt(this.clampPagedScrollTop(s)),scrollPageOffset:i}}needsScrollPageUpdate(t){const i=Rt(this.clampScrollTop(t)),{scrollPageOffset:s}=this.resolvePagedScrollPosition(i);return s!==this.scrollPageOffset}getPagedLayoutTop(t){return this.shouldRebaseScroll()?Math.max(t-this.scrollPageOffset,0):t}getStickyHeaderOffset(){return this.options.stickyHeaders===!0&&this.options.disableFileHeader!==!0?this.itemMetricsCache.diffHeaderHeight:0}getScrollTargetRect(t){const i=this.idToItem.get(t.id);if(i==null){console.warn(`CodeView.scrollTo: unknown item id "${t.id}"`);return}if(t.type==="item")return{top:i.top,height:i.height};if(t.type==="range"){const r=this.getRangeScrollPosition(i,t);if(r==null){console.warn(`CodeView.scrollTo: unable to resolve range ${Nl(t.range)} for item "${t.id}"`);return}return{top:i.top+r.top,height:r.height}}const s=this.getLineScrollPosition(i,t);if(s==null){console.warn(`CodeView.scrollTo: unable to resolve line ${t.lineNumber} for item "${t.id}"`);return}return{top:i.top+s.top,height:s.height}}normalizeScrollTarget(t){if(t.type==="position"||t.align!=="nearest")return t;const i=this.getScrollTargetRect(t);if(i==null)return;const s=t.offset??0,r=this.getItemTopOffset()+i.top,n=r+i.height,o=this.getScrollTop(),a=o+(t.type==="line"||t.type==="range"?this.getStickyHeaderOffset():0),l=o+this.getHeight();if(!(r-s<=a&&n+s>=l)){if(r-s<a)return{...t,align:"start"};if(n+s>l)return{...t,align:"end"}}}resolveScrollTargetTop(t){if(t.type==="position"){const r=this.clampScrollTop(t.position);return r!==t.position?r:this.clampScrollTop(t.position-this.getStickyHeaderOffset())}const i=this.idToItem.get(t.id);if(i==null){console.warn(`CodeView.scrollTo: unknown item id "${t.id}"`);return}if(t.type==="item")return this.clampScrollTop(this.resolveAlignedScrollPosition(i.top,i.height,t.align,t.offset));if(t.type==="range"){const r=this.getRangeScrollPosition(i,t);if(r==null){console.warn(`CodeView.scrollTo: unable to resolve range ${Nl(t.range)} for item "${t.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(i.top+r.top,r.height,t.align,t.offset,this.getStickyHeaderOffset()))}const s=this.getLineScrollPosition(i,t);if(s==null){console.warn(`CodeView.scrollTo: unable to resolve line ${t.lineNumber} for item "${t.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(i.top+s.top,s.height,t.align,t.offset,this.getStickyHeaderOffset()))}resolveAlignedScrollPosition(t,i,s,r=0,n=0){t+=this.getItemTopOffset();const o=this.getHeight();return s==="center"&&i+r<o?t-(o-i)/2+r:s==="end"?t-(o-i)+r:t-n-r}getLineScrollPosition(t,i){return t.type==="diff"?t.instance.getLinePosition(i.lineNumber,i.side):t.instance.getLinePosition(i.lineNumber)}getRangeScrollPosition(t,i){const{range:s}=i,r=this.getLineScrollPosition(t,{type:"line",id:i.id,lineNumber:s.start,side:s.side}),n=this.getLineScrollPosition(t,{type:"line",id:i.id,lineNumber:s.end,side:s.endSide??s.side});if(r==null||n==null)return;const o=r.top,a=o+r.height,l=n.top,h=l+n.height,c=Math.min(o,l);return{top:c,height:Math.max(a,h)-c}}computeTargetScrollTopForFrame(t,i){if(this.pendingScrollTarget==null)return t;const s=this.resolveScrollTargetTop(this.pendingScrollTarget);if(s==null)return t;const{scrollAnimation:r}=this;return r==null?s:this.computeSpringStep(r,s,i).position}computeSpringStep(t,i,s){const r=Math.max(0,s-t.lastTimestamp),{omega:n}=this.getSmoothScrollSettings(),o=Math.exp(-n*r),a=t.position-i,l=t.velocity+n*a;return{position:i+(a+l*r)*o,velocity:(l*(1-n*r)-n*a)*o}}advanceScrollAnimation(t,i){if(this.pendingScrollTarget==null)return;const s=this.resolveScrollTargetTop(this.pendingScrollTarget);if(s==null){this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;return}const r=this.scrollAnimation;if(r==null)return s;r.position+=i;const{position:n,velocity:o}=this.computeSpringStep(r,s,t);r.lastTimestamp=t,r.position=n,r.velocity=o;const{positionEpsilon:a,velocityEpsilon:l}=this.getSmoothScrollSettings();return Math.abs(s-n)<=a&&Math.abs(o)<=l?(r.position=s,r.velocity=0,this.scrollAnimation=void 0,s):r.position}computeRenderRangeAndEmit=(t=performance.now())=>{if(Yt.__STOP||this.container==null||!this.isReady())return;const i=this.getHeight(),s=this.getScrollTop();let r=s,n=this.pendingLayoutAnchor!=null,o=this.getScrollAnchor(r);if(this.layoutDirtyIndex!=null&&(this.recomputeLayout(this.layoutDirtyIndex,this.pendingLayoutReset),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,n=!0),n&&o!=null){const N=this.resolveAnchoredScrollTop(o);if(N!=null){const O=N-r;r=N,this.scrollAnimation!=null&&(this.scrollAnimation.position+=O)}}n&&(r=this.clampScrollTop(r),this.syncContainerHeight());const a=this.computeTargetScrollTopForFrame(r,t),l=!n&&(this.renderState.scrollTop===-1||Math.abs(a-this.renderState.scrollTop)>i+this.config.overscrollSize*2);l&&(o=void 0),this.windowSpecs=Kg({scrollTop:a-this.header.height,height:i,scrollHeight:this.getScrollHeight(),fitPerfectly:l,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let h=s;(this.pendingScrollTarget!=null&&a!==h||this.needsScrollPageUpdate(a))&&(this.applyScrollFix(a,h,this.windowSpecs),h=a);const{top:c,bottom:u}=this.windowSpecs,{firstIndex:p,lastIndex:f}=this.renderState;if(p>=0)for(let N=p;N<=f;N++){const O=this.items[N];if(O==null)throw new Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${N}`);O.top>c-O.height&&O.top<=u||this.releaseRenderedItem(O)}const m=this.reconcileHeaderFooterHosts();let g;const _=new Set,E=this.findFirstVisibleIndex(c),C=this.findLastVisibleIndex(u);for(let N=E;N<=C;N++){const O=this.items[N];if(O==null)throw new Error("CodeView.computeRenderRangeAndEmit: missing item");const{instance:z}=O;O.element==null?(O.element=this.acquireElement(),Gl(this.stickyContainer,O.element,g),z.virtualizedSetup(),Ol(O,O.element)&&(O.renderedOptionsRevision=this.renderOptionsRevision,_.add(O)),g=O.element):(Gl(this.stickyContainer,O.element,g),Ol(O,void 0,O.renderedOptionsRevision!==this.renderOptionsRevision)&&(O.renderedOptionsRevision=this.renderOptionsRevision,_.add(O)),g=O.element),O.item.edit===!0&&this.attachItemEditor(O)}this.renderState.firstIndex=E<=C?E:-1,this.renderState.lastIndex=C,this.flushSlotCoordinator(),this.flushManagers(_),m&&this.measureMountedHosts(),this.reconcileRenderedItems(_),this.syncContainerHeight(),this.updateStickyPositioning();const T=o!=null?this.resolveAnchoredScrollTop(o):void 0;o===this.pendingLayoutAnchor&&(this.pendingLayoutAnchor=void 0);const x=T!=null?T-r:0;let A=a,k=!1;if(this.pendingScrollTarget!=null){const N=this.advanceScrollAnimation(t,x);N!=null?(A=N,k=!0):A=r}else A=T??a;A!==h&&(this.applyScrollFix(A,h,this.windowSpecs),h=A),k&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),this.renderState.scrollTop=Rt(h),this.updateStickyPositioning(),this.validateStickyContainerHeight(),this.fixContainerFocus(),(l||this.scrollAnimation!=null)&&this.render()};flushManagers(t){for(const i of t)i.instance.flushManagers()}syncContainerHeight(){const t=this.getPagedScrollHeight();this.container==null||this.containerHeight===t||(this.container.style.height=`${t}px`,this.containerHeight=t)}getStickyBounds(t){const{firstIndex:i,lastIndex:s}=t!=null?{firstIndex:this.findFirstVisibleIndex(t.top),lastIndex:this.findLastVisibleIndex(t.bottom)}:this.renderState;if(i===-1||s===-1||i>s)return;const r=this.items[i]?.instance.getAdvancedStickySpecs(t),n=this.items[s]?.instance.getAdvancedStickySpecs(t);if(!(r==null||n==null))return{stickyTop:this.getPagedLayoutTop(Math.max(r.topOffset,0)),stickyBottom:this.getPagedLayoutTop(n.topOffset+n.height)}}applyStickyPositioning({stickyTop:t,stickyBottom:i}){const s=this.getHeight(),{itemMetricsCache:r}=this,n=i-t;this.renderState.stickyHeight=n,this.renderState.stickyTop=t,this.renderState.stickyBottom=i,this.stickyOffset.style.height=`${t}px`;const o=(Math.random()*r.lineHeight>>0)*-1,a=-Math.max(n+o,0)+s;this.stickyContainer.style.top=`${a}px`,this.stickyContainer.style.bottom=`${a+r.diffHeaderHeight}px`}syncPagedScrollScaffolding(t){this.syncContainerHeight();const i=this.getStickyBounds(t);i!=null&&this.applyStickyPositioning(i)}reconcileRenderedItems(t){const{firstIndex:i,lastIndex:s}=this.renderState;if(i===-1)return;let r=-1,n=!1;for(let o=i;o<this.items.length&&!(!n&&o>s);o++){const a=this.items[o];if(a==null)throw new Error("CodeView.reconcileRenderedItems: Invalid item");r===-1?r=a.top:a.top!==r&&(a.top=r,a.instance.syncVirtualizedTop(),n=!0),(t==null?o<=s:t.has(a))&&(a.instance.reconcileHeights()&&(n=!0,a.height=a.instance.getVirtualizedHeight()),this.validateRenderedItemHeight(a)),r+=a.instance.getVirtualizedHeight(),o<this.items.length-1&&(r+=this.getLayout().gap)}n&&r!=null&&(this.scrollDirty=!0,this.scrollHeight=r)}updateStickyPositioning(){const t=this.getStickyBounds();if(t==null){this.renderState.firstIndex===-1&&(this.stickyOffset.style.height="");return}const{stickyTop:i,stickyBottom:s}=t;s-i===this.renderState.stickyHeight&&i===this.renderState.stickyTop&&s===this.renderState.stickyBottom||this.applyStickyPositioning(t)}handleScroll=()=>{Yt.__STOP||(this.suspendScrollInteractions(),this.scrollDirty=!0,this.notifyScroll(),this.render())};clearPendingScroll=()=>{this.pendingScrollTarget=void 0,this.pendingLayoutAnchor=void 0,this.scrollAnimation=void 0};handleResize=t=>{let i=!1;for(const s of t)if(s.target===this.stickyContainer){const r=s.borderBoxSize[0].blockSize;if(Math.abs(r-this.renderState.stickyHeight)>=Al){const n=this.getScrollTop(),o=this.getScrollAnchor(n);this.reconcileRenderedItems(),this.updateStickyPositioning();const a=o!=null?this.resolveAnchoredScrollTop(o):void 0;if(a!=null){const l=a-n;this.applyScrollFix(a,n,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=l)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),i=!0}}else if(s.target===this.header.element||s.target===this.footer.element){const r=s.target===this.header.element?this.header:this.footer,n=s.borderBoxSize[0].blockSize;if(n!==r.height){const o=this.getScrollTop(),a=this.getScrollAnchor(o);this.setHostHeight(r,n);const l=a!=null?this.resolveAnchoredScrollTop(a):void 0;if(l!=null){const h=l-o;this.applyScrollFix(l,o,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=h)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),i=!0}}else this.scrollDirty=!0,this.heightDirty=!0,i=!0;i&&this.render(!0)};getScrollAnchorViewportTop(t,i){return t<i?i+this.getStickyHeaderOffset():i}getScrollAnchor(t,i=this.idToItem){let s;const{pendingLayoutAnchor:r}=this;if(r!=null){const c=this.idToItem.get(r.id);if(c!=null&&i.get(r.id)===c)return r;c!=null&&(s=c)}if(t<=0)return;const{firstIndex:n,lastIndex:o,stickyTop:a,stickyBottom:l}=this.renderState;if(n===-1||o===-1)return;const h=this.getHeight();if(!(a===-1||l===-1)){for(let c=n;c<=o;c++){const u=this.items[c];if(u==null)continue;const p=this.getItemTopOffset()+u.top;if(p+u.height<=t)continue;if(p>=t+h)break;if(i.get(u.item.id)!==u){s??=u;continue}if(p>=t)return{type:"item",id:u.item.id,viewportOffset:p-t};const f=this.getScrollAnchorViewportTop(p,t)-p,m=u.instance.getNumericScrollAnchor(f);if(m!=null){const g=p+m.top;return{type:"line",id:u.item.id,lineNumber:m.lineNumber,side:m.side,viewportOffset:g-t}}}if(s!=null)for(let c=s.index+1;c<this.items.length;c++){const u=this.items[c];if(u!=null&&i.get(u.item.id)===u)return{type:"item",id:u.item.id,viewportOffset:0}}}}resolveAnchoredScrollTop(t){const i=this.idToItem.get(t.id);if(i==null)return;const s=this.getItemTopOffset();if(t.type==="item"){const o=s+i.top;return this.clampScrollTop(o-t.viewportOffset)}const r=i.type==="diff"?i.instance.getLinePosition(t.lineNumber,t.side):i.instance.getLinePosition(t.lineNumber);if(r==null)return;const n=s+i.top+r.top;return this.clampScrollTop(n-t.viewportOffset)}applyScrollFix(t,i,s){if(this.root==null)return;const r=Rt(this.clampScrollTop(t)),n=Rt(i),{scrollPageOffset:o}=this,a=Rt(this.clampPagedScrollTop(n-o)),{pagedScrollTop:l,scrollPageOffset:h}=this.resolvePagedScrollPosition(r),c=l,u=o!==h;r===this.renderState.scrollTop&&r===n&&c===a&&!u||(this.suspendScrollInteractions(),(c!==a||u)&&(this.scrollPageOffset=h,this.syncPagedScrollScaffolding(s)),c!==a&&this.root.scrollTo({top:c,behavior:"instant"}),this.renderState.scrollTop=r,this.scrollTop=r,this.scrollDirty=!1)}isPendingTargetSettled(t){const i=this.resolveScrollTargetTop(t);return i==null?!0:Rt(this.getScrollTop())===Rt(i)}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;const t=this.root?.scrollTop??0;return this.scrollTop=this.clampScrollTop(t+this.scrollPageOffset),this.scrollTop}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root?.getBoundingClientRect().height??0,this.height):this.height}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;const t=this.buildSlotSnapshot(this.slotCoordinator);Dc(this.slotSnapshot,t)||(this.slotSnapshot=t,this.slotCoordinator.onSnapshotChange(t))}notifyScroll(){if(this.scrollListeners.size===0)return;const t=this.getScrollTop();for(const i of this.scrollListeners)i(t,this)}findFirstVisibleIndex(t){let i=0,s=this.items.length-1,r=this.items.length;for(;i<=s;){const n=i+s>>1,o=this.items[n];if(o==null)throw new Error("CodeView.findFirstVisibleIndex: invalid item index");o.top+o.height>t?(r=n,s=n-1):i=n+1}return r}findLastVisibleIndex(t){let i=0,s=this.items.length-1,r=-1;for(;i<=s;){const n=i+s>>1,o=this.items[n];if(o==null)throw new Error("CodeView.findLastVisibleIndex: invalid item index");o.top<=t?(r=n,i=n+1):s=n-1}return r}recomputeLayout(t=0,i){if(this.items.length===0){this.scrollHeight=0;return}const s=this.getLayout();let r=0;if(t>0){const n=this.items[t-1];if(n==null)throw new Error("CodeView.recomputeLayout: invalid dirty index");r=n.top+n.height+s.gap}for(let n=t;n<this.items.length;n++){const o=this.items[n];if(o==null)throw new Error("CodeView.recomputeLayout: invalid item index");if(o.top=r,o.type==="diff"){const a=o.instance.consumeCodeViewLayoutChanges(o.item.fileDiff);a!=null&&Object.assign(o.item.fileDiff,a),o.height=o.instance.prepareCodeViewItem(o.item.fileDiff,r,i,o.item.annotations??[])}else o.height=o.instance.prepareCodeViewItem(o.item.file,r,i,o.item.annotations??[]);r+=o.height,n<this.items.length-1&&(r+=s.gap)}r!==this.scrollHeight&&(this.scrollDirty=!0),this.scrollHeight=r}resetRenderState(){this.renderState.scrollTop=-1,this.renderState.firstIndex=-1,this.renderState.lastIndex=-1,this.renderState.stickyHeight=0,this.renderState.stickyTop=-1,this.renderState.stickyBottom=-1}getFitPerfectlyOverscroll(){return this.getLayout().gap+this.itemMetricsCache.diffHeaderHeight}};function Jv(e){return e.instance.cleanUp(!0),e.type==="diff"?e.instance.prepareCodeViewItem(e.item.fileDiff,e.top,void 0,e.item.annotations??[]):e.instance.prepareCodeViewItem(e.item.file,e.top,void 0,e.item.annotations??[])}function Zv(e,t){return!pf(e.theme??Un,t.theme??Un)||(e.themeType??"system")!==(t.themeType??"system")||e.unsafeCSS!==t.unsafeCSS}function Qv(e,t){return(e.overflow??"scroll")!==(t.overflow??"scroll")||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS||(e.diffStyle??"split")!==(t.diffStyle??"split")||(e.diffIndicators??"bars")!==(t.diffIndicators??"bars")||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function e_(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function t_(e){return e instanceof SVGElement?!0:qg(e)&&(e.hasAttribute("data-core-css")||e.hasAttribute("data-theme-css")||e.hasAttribute("data-unsafe-css"))}function Nl(e){const t=Ml(e.start,e.side),i=Ml(e.end,e.endSide??e.side);return t===i?t:`${t}-${i}`}function Ml(e,t){return t==null?`${e}`:`${t==="deletions"?"D":"A"}${e}`}function Ol(e,t,i=!1){return e.type==="diff"?e.instance.render({deferManagers:!0,fileContainer:t,fileDiff:e.item.fileDiff,forceRender:i,lineAnnotations:e.item.annotations??[]}):e.instance.render({deferManagers:!0,fileContainer:t,file:e.item.file,forceRender:i,lineAnnotations:e.item.annotations??[]})}function Gl(e,t,i){if(i==null){e.firstChild!==t&&e.prepend(t);return}i.nextSibling!==t&&i.after(t)}function i_(e){return(e.annotations?.length??0)>0}function s_(e,{hasHeaderRenderers:t,hasAnnotationRenderer:i,hasGutterRenderer:s}){if(e.length===0)return;if(t||s)return e;if(!i)return;const r=[];for(const n of e)i_(n.item)&&r.push(n);return r.length>0?r:void 0}const zl=typeof window>"u"?b.useEffect:b.useLayoutEffect;function Bl(e){return{instance:void 0,items:void 0,controlled:e,managedOptions:void 0,disableFlushSync:!1,slotCoordinator:void 0}}function r_(e,t){const{className:i,containerRef:s,disableWorkerPool:r=!1,editorOptions:n,initialItems:o,items:a,onItemEditChange:l,onItemEditComplete:h,onScroll:c,onSelectedLinesChange:u,options:p,renderAnnotation:f,renderCodeViewFooter:m,renderCodeViewHeader:g,renderCustomHeader:_,renderGutterUtility:E,renderHeaderFilenameSuffix:C,renderHeaderMetadata:T,renderHeaderPrefix:x,selectedLines:A,style:k}=e,N=a!==void 0,O=Yg(),z=b.useContext(ff),R=b.useRef(Bl(N)),I=_!=null,w=f!=null,v=E!=null,S=I||x!=null||C!=null||T!=null,D=S||w||v,y=g!=null,L=m!=null,M=mi(X=>{u?.(X)}),H=A!==void 0,j=mi(X=>{if(O==null)throw new Error("CodeView: EditContext is not attached");const ve=O({...n,...X});if(ve==null)throw new Error("CodeView: EditProvider.createEditor must return an editor instance");return ve}),J=mi((X,ve,ye)=>{l?.(X,ve,ye)}),te=mi((X,ve,ye)=>{h?.(X,ve,ye)}),ie=b.useMemo(()=>l_({options:p,hasCustomHeader:I,hasGutterRenderer:v,hasCodeViewHeader:y,hasCodeViewFooter:L,onSelectedLinesChange:u!=null?M:void 0,controlledSelection:H,createEditor:O!=null?j:void 0,onItemEditChange:l!=null?J:void 0,onItemEditComplete:h!=null?te:void 0}),[O,H,j,J,te,M,L,y,I,v,l,h,u,p]),[le]=b.useState(()=>a_()),[,me]=b.useState({}),ne=mi(X=>{R.current.instance!=null&&(X==null||X!==R.current.instance.getContainerElement())&&(R.current.instance.cleanUp(),le.publish(void 0),R.current=Bl(N)),X!=null&&X!==R.current.instance?.getContainerElement()&&(R.current.instance=new Xv(ie,r?void 0:z,!0),R.current.instance.setup(X)),typeof s=="function"?s(X):s!=null&&(s.current=X)}),W=mi(X=>{R.current.disableFlushSync?le.publish(X):gr.flushSync(()=>{le.publish(X)})}),ge=b.useMemo(()=>{if(!(!S&&!w&&!v&&!y&&!L))return{hasHeaderRenderers:S,hasAnnotationRenderer:w,hasGutterRenderer:v,onSnapshotChange:W}},[W,w,v,S,y,L]);return zl(()=>c!=null?R.current.instance?.subscribeToScroll(c):void 0),zl(()=>{const{instance:X,controlled:ve,items:ye,managedOptions:ke,slotCoordinator:we}=R.current;if(X!=null)try{R.current.disableFlushSync=!0;let it=!1;if(wc(ie,ke)||(R.current.managedOptions=ie,X.setOptions(ie),it=!0),ve!==N){console.error("CodeView: cannot switch between controlled and uncontrolled modes. Remount with a new key instead.");return}if(N)a!==ye&&(o_(ye,a)?R.current.items=a:n_(ye,a)?(R.current.items=a,X.addItems(a.slice(ye.length))):(R.current.items=a,X.setItems(a),it=!0));else if(ye==null){const Ge=o??[];R.current.items=Ge,Ge.length>0&&(X.setItems(Ge),it=!0)}A!==void 0&&X.setSelectedLines(A,{notify:!1});const Q=X.setSlotCoordinator(ge);let de=!1;ge!==we&&((ge==null||we==null)&&(de=!0),R.current.slotCoordinator=ge),(it||Q)&&X.render(!0),Q&&ge==null&&le.publish(void 0),de&&me({})}finally{R.current.disableFlushSync=!1}}),b.useImperativeHandle(t,()=>({addItems(X){const{controlled:ve,instance:ye}=R.current;Js(ve,"addItems"),ye==null?console.error("CodeView.addItems: no valid instance to append items with",X):ye.addItems(X)},getItem(X){const{instance:ve}=R.current;if(ve==null){console.error("CodeView.getItem: no valid instance exists",X);return}else return ve.getItem(X)},removeItem(X){const{controlled:ve,instance:ye}=R.current;return Js(ve,"removeItem"),ye==null?(console.error("CodeView.removeItem: no valid instance to remove item from",X),!1):ye.removeItem(X)},updateItem(X){const{controlled:ve,instance:ye}=R.current;return Js(ve,"updateItem"),ye==null?(console.error("CodeView.updateItem: no valid instance to update item with",X),!1):ye.updateItem(X)},updateItemId(X,ve){const{controlled:ye,instance:ke}=R.current;return Js(ye,"updateItemId"),ke==null?(console.error("CodeView.updateItemId: no valid instance to update item id with",X,ve),!1):ke.updateItemId(X,ve)},scrollTo(X){const{instance:ve}=R.current;ve==null?console.error("CodeView.scrollTo: no valid instance to scroll with",X):ve.scrollTo(X)},setSelectedLines(X){const{instance:ve}=R.current;ve==null?console.error("CodeView.setSelectedLines: no valid instance to update selection with",X):(ve.setSelectedLines(X,{notify:!1}),M(X))},getSelectedLines(){const{instance:X}=R.current;return X==null?(console.error("CodeView.getSelectedLines: no valid instance exists"),null):X.getSelectedLines()},clearSelectedLines(){const{instance:X}=R.current;X==null?console.error("CodeView.clearSelectedLines: no valid instance to update selection with"):(X.clearSelectedLines({notify:!1}),M(null))},getEditor(X){const{instance:ve}=R.current;if(ve==null){console.error("CodeView.getEditor: no valid instance exists",X);return}return ve.getEditor(X)},getInstance(){return R.current.instance}}),[M]),d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:ne,className:i,style:k}),(D||y||L)&&d.jsx(h_,{managedContentStore:le,renderCustomHeader:_,renderHeaderPrefix:x,renderHeaderFilenameSuffix:C,renderHeaderMetadata:T,renderAnnotation:f,renderGutterUtility:E,renderCodeViewHeader:g,renderCodeViewFooter:m})]})}const Tc=b.forwardRef(r_);function n_(e,t){if(e==null||t.length<=e.length)return!1;if(e.length===0)return!0;for(let i=0;i<e.length;i++)if(t[i]!==e[i])return!1;return!0}function o_(e,t){if(e==null||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}function Js(e,t){if(e)throw new Error(`CodeView.${t} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`)}function a_(){let e;const t=new Set;return{getSnapshot(){return e},publish(i){if(!Dc(e,i)){e=i;for(const s of t)s()}},subscribe(i){return t.add(i),()=>{t.delete(i)}}}}function l_({options:e,hasCustomHeader:t,hasGutterRenderer:i,hasCodeViewHeader:s,hasCodeViewFooter:r,onSelectedLinesChange:n,controlledSelection:o,createEditor:a,onItemEditChange:l,onItemEditComplete:h}){const c={...e,controlledSelection:o,onSelectedLinesChange:n,createEditor:a};return l!=null&&(c.onItemEditChange=l),h!=null&&(c.onItemEditComplete=h),t&&(c.renderCustomHeader=Zs),i&&(c.renderGutterUtility=Zs),s&&(c.renderCodeViewHeader=Zs),r&&(c.renderCodeViewFooter=Zs),c}const h_=b.memo(function({managedContentStore:t,renderCustomHeader:i,renderHeaderPrefix:s,renderHeaderFilenameSuffix:r,renderHeaderMetadata:n,renderAnnotation:o,renderGutterUtility:a,renderCodeViewHeader:l,renderCodeViewFooter:h}){"use no memo";const c=mi(m=>t.subscribe(m)),u=mi(()=>t.getSnapshot()),p=b.useSyncExternalStore(c,u,u);let f="";for(const m of p?.items??[])f+=`${m.id}:${m.version}:${m.type}`;return d.jsxs(d.Fragment,{children:[b.useMemo(()=>p?.items?.map(m=>gr.createPortal(d_({renderedItem:m,renderCustomHeader:i,renderHeaderPrefix:s,renderHeaderFilenameSuffix:r,renderHeaderMetadata:n,renderAnnotation:o,renderGutterUtility:a}),m.element,m.id)),[i,s,r,n,o,a,f]),b.useMemo(()=>l!=null&&p?.header!=null?gr.createPortal(l(),p.header):null,[l,p?.header]),b.useMemo(()=>h!=null&&p?.footer!=null?gr.createPortal(h(),p.footer):null,[h,p?.footer])]})});function d_({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:i,renderHeaderFilenameSuffix:s,renderHeaderMetadata:r,renderAnnotation:n,renderGutterUtility:o}){if(e.type==="diff"){const{item:a,instance:l}=e;return ev({fileDiff:a.fileDiff,renderCustomHeader:t!=null?()=>t(a):void 0,renderHeaderPrefix:i!=null?()=>i(a):void 0,renderHeaderFilenameSuffix:s!=null?()=>s(a):void 0,renderHeaderMetadata:r!=null?()=>r(a):void 0,renderAnnotation:n!=null?h=>n(h,a):void 0,lineAnnotations:a.annotations,renderGutterUtility:o!=null?h=>o(h,a):void 0,getHoveredLine:l.getHoveredLine})}else{const{item:a,instance:l}=e;return ov({file:a.file,renderCustomHeader:t!=null?()=>t(a):void 0,renderHeaderPrefix:i!=null?()=>i(a):void 0,renderHeaderFilenameSuffix:s!=null?()=>s(a):void 0,renderHeaderMetadata:r!=null?()=>r(a):void 0,renderAnnotation:n!=null?h=>n(h,a):void 0,lineAnnotations:a.annotations,renderGutterUtility:o!=null?h=>o(h,a):void 0,getHoveredLine:l.getHoveredLine})}}function Zs(){}var Ic,Ac=class{constructor(){}},St=class extends Ac{constructor(e,t,i,s){super(),this.viewId=e,this.groupId=t,this.panelId=i,this.tabGroupId=s}},Cs=class extends Ac{constructor(e,t){super(),this.viewId=e,this.paneId=t}},ei=class Rc{constructor(){}static getInstance(){return Rc.INSTANCE}hasData(t){return t&&t===this.proto}clearData(t){this.hasData(t)&&(this.proto=void 0,this.data=void 0)}getData(t){if(this.hasData(t))return this.data}setData(t,i){i&&(this.data=t,this.proto=i)}};Ic=ei;ei.INSTANCE=new Ic;function Te(){const e=ei.getInstance();if(e.hasData(St.prototype))return e.getData(St.prototype)[0]}function ls(){const e=ei.getInstance();if(e.hasData(Cs.prototype))return e.getData(Cs.prototype)[0]}let Se;(function(e){e.NONE={dispose:()=>{}};function t(i){return{dispose:()=>{i()}}}e.from=t})(Se||(Se={}));var se=class{get isDisposed(){return this._isDisposed}constructor(...e){this._isDisposed=!1,this._disposables=new Set(e)}addDisposables(...e){e.forEach(t=>this._disposables.add(t))}removeDisposable(e){this._disposables.delete(e)}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposables.forEach(e=>e.dispose()),this._disposables.clear())}},Me=class{constructor(){this._disposable=Se.NONE}get value(){return this._disposable===Se.NONE?void 0:this._disposable}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&(this._disposable.dispose(),this._disposable=Se.NONE)}};let xt;(function(e){e.any=(...t)=>i=>{const s=t.map(r=>r(i));return{dispose:()=>{s.forEach(r=>{r.dispose()})}}}})(xt||(xt={}));var Ea=class{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}},Lc=class{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}},c_=class{constructor(){this.events=new Map}get size(){return this.events.size}add(e,t){this.events.set(e,t)}delete(e){this.events.delete(e)}clear(){this.events.clear()}},jl=class Nc{static create(){var t;return new Nc((t=new Error("listener stacktrace").stack)!==null&&t!==void 0?t:"")}constructor(t){this.value=t}print(){console.warn("dockview: stacktrace",this.value)}},u_=class{constructor(e,t){this.callback=e,this.stacktrace=t}},G=class Mt{static setLeakageMonitorEnabled(t){t!==Mt.ENABLE_TRACKING&&Mt.MEMORY_LEAK_WATCHER.clear(),Mt.ENABLE_TRACKING=t}get value(){return this._last}constructor(t){this.options=t,this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=t=>{var i;!((i=this.options)===null||i===void 0)&&i.replay&&this._last!==void 0&&t(this._last);const s=new u_(t,Mt.ENABLE_TRACKING?jl.create():void 0);return this._listeners.push(s),{dispose:()=>{const r=this._listeners.indexOf(s);r>-1&&this._listeners.splice(r,1)}}},Mt.ENABLE_TRACKING&&Mt.MEMORY_LEAK_WATCHER.add(this._event,jl.create())),this._event}fire(t){var i;if(this._pauseTokens!==void 0&&this._pauseTokens.size>0)return;!((i=this.options)===null||i===void 0)&&i.replay&&(this._last=t);const s=this._listeners,r=s.length;if(r!==0){if(r===1){s[0].callback(t);return}for(const n of s.slice())n.callback(t)}}pause(){var t;const i={};return(t=this._pauseTokens)!==null&&t!==void 0||(this._pauseTokens=new Set),this._pauseTokens.add(i),Se.from(()=>{var s;return(s=this._pauseTokens)===null||s===void 0?void 0:s.delete(i)})}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(Mt.ENABLE_TRACKING?queueMicrotask(()=>{for(const i of this._listeners){var t;console.warn("dockview: stacktrace",(t=i.stacktrace)===null||t===void 0?void 0:t.print())}this._listeners=[]}):this._listeners=[]),Mt.ENABLE_TRACKING&&this._event&&Mt.MEMORY_LEAK_WATCHER.delete(this._event))}};G.ENABLE_TRACKING=!1;G.MEMORY_LEAK_WATCHER=new c_;function Z(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i,s)}}}var $l=class{constructor(){this._onFired=new G,this._currentFireCount=0,this._queued=!1,this.onEvent=e=>{const t=this._currentFireCount;return this._onFired.event(()=>{this._currentFireCount>t&&e()})}}fire(){this._currentFireCount++,!this._queued&&(this._queued=!0,queueMicrotask(()=>{this._queued=!1,this._onFired.fire()}))}dispose(){this._onFired.dispose()}},p_=class extends se{constructor(e){super(),this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,ji(e,t=>{const i=t.target.scrollWidth>t.target.clientWidth,s=t.target.scrollHeight>t.target.clientHeight;this._value={hasScrollX:i,hasScrollY:s},this._onDidChange.fire(this._value)}))}};function ji(e,t){const i=new ResizeObserver(s=>{requestAnimationFrame(()=>{const r=s[0];t(r)})});return i.observe(e),{dispose:()=>{i.unobserve(e),i.disconnect()}}}const It=(e,...t)=>{for(const i of t)e.classList.contains(i)&&e.classList.remove(i)},At=(e,...t)=>{for(const i of t)e.classList.contains(i)||e.classList.add(i)},K=(e,t,i)=>{const s=e.classList.contains(t);i&&!s&&e.classList.add(t),!i&&s&&e.classList.remove(t)};function Zn(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function Mc(e){return new f_(e)}var f_=class extends se{constructor(e){super(),this._onDidFocus=new G,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new G,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=Zn(document.activeElement,e),i=!1;const s=()=>{i=!1,t||(t=!0,this._onDidFocus.fire())},r=()=>{t&&(i=!0,globalThis.setTimeout(()=>{i&&(i=!1,t=!1,this._onDidBlur.fire())},0))};this._refreshStateHandler=()=>{Zn(document.activeElement,e)!==t&&(t?r():s())},this.addDisposables(Z(e,"focus",s,!0)),this.addDisposables(Z(e,"blur",r,!0))}refreshState(){this._refreshStateHandler()}};const Oc="dv-quasiPreventDefault";function Gc(e){e[Oc]=!0}function Wl(e){return e[Oc]}function m_(e,t,i={}){const s=Array.from(t),{nonce:r}=i,n=typeof r=="function"?r(e):r;for(const o of s){if(o.href){const h=e.createElement("link");h.href=o.href,h.type=o.type,h.rel="stylesheet",e.head.appendChild(h);continue}let a=[];try{o.cssRules&&(a=Array.from(o.cssRules).map(h=>h.cssText))}catch(h){console.warn("dockview: failed to access stylesheet rules due to security restrictions",h)}const l=e.createDocumentFragment();for(const h of a){const c=e.createElement("style");n&&c.setAttribute("nonce",n),c.appendChild(e.createTextNode(h)),l.appendChild(c)}e.head.appendChild(l)}}function Qn(e){const{left:t,top:i,width:s,height:r}=e.getBoundingClientRect();return{left:t+window.scrollX,top:i+window.scrollY,width:s,height:r}}function zc(e){let t=e;for(;t?.parentNode;){if(t.parentNode===document)return!0;t.parentNode instanceof DocumentFragment?t=t.parentNode.host:t=t.parentNode}return!1}function g_(e,t){e.dataset.testid=t}function v_(e,t){const i=[];function s(r){if(r.nodeType===Node.ELEMENT_NODE){e.includes(r.tagName)&&i.push(r),r.shadowRoot&&s(r.shadowRoot);for(const n of r.children)s(n)}}return s(t instanceof Document?t.documentElement:t),i}function Es(e=document){const t=v_(["IFRAME","WEBVIEW"],e),i=new WeakMap;for(const s of t)i.set(s,s.style.pointerEvents),s.style.pointerEvents="none";return{release:()=>{for(const r of t){var s;r.style.pointerEvents=(s=i.get(r))!==null&&s!==void 0?s:"auto"}t.splice(0,t.length)}}}function __(e){function t(r){const n=[];for(let o=0;o<r.classList.length;o++)n.push(r.classList.item(o));return n}let i,s=e;for(;s!==null&&(i=t(s).find(r=>r.startsWith("dockview-theme-")),typeof i!="string");)s=s.parentElement;return i}var qr=class{constructor(e){this.element=e,this._classNames=[]}setClassNames(e){for(const t of this._classNames)K(this.element,t,!1);this._classNames=e.split(" ").filter(t=>t.trim().length>0);for(const t of this._classNames)K(this.element,t,!0)}};const Bc=100;function fn(e,t){const i=Qn(e),s=Qn(t);return!(i.left<s.left||i.left+i.width>s.left+s.width||i.top<s.top||i.top+i.height>s.top+s.height)}function b_(e){const t=new G;let i=e.screenX,s=e.screenY,r,n=0,o=!1;const a=()=>{if(o||e.closed)return;const h=e.screenX,c=e.screenY;(h!==i||c!==s)&&(clearTimeout(r),r=setTimeout(()=>{t.fire()},Bc),i=h,s=c),n=requestAnimationFrame(a)};a();const l=t.dispose.bind(t);return t.dispose=()=>{o||(o=!0,cancelAnimationFrame(n),clearTimeout(r)),l()},t}function w_(e,t){let i;return new se(Z(e,"resize",()=>{clearTimeout(i),i=setTimeout(()=>{t()},Bc)}))}function y_(e,t,i){var s;const r=(s=void 0)!==null&&s!==void 0?s:10,n=e.getBoundingClientRect(),o=t.getBoundingClientRect();let a=0,l=0;const h=n.left-o.left,c=n.top-o.top,u=n.bottom-o.bottom,p=n.right-o.right;h<r?a=r-h:p>r&&(a=-r-p),c<r?l=r-c:u>r&&(l=-u-r),(a!==0||l!==0)&&(e.style.transform=`translate(${a}px, ${l}px)`)}function S_(e){let t=e;for(;t&&(t.style.zIndex==="auto"||t.style.zIndex==="");)t=t.parentElement;return t}function Zt(e){if(e.length===0)throw new Error("Invalid tail call");return[e.slice(0,e.length-1),e[e.length-1]]}function jc(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}function mn(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.unshift(t))}function Qs(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.push(t))}function x_(e,t){for(let i=0;i<e.length;i++){const s=e[i];if(t(s))return i}return-1}function $c(e,t){const i=e.indexOf(t);return i>-1?(e.splice(i,1),!0):!1}const Ee=(e,t,i)=>t>i?t:Math.min(i,Math.max(e,t)),Ta=()=>{let e=1;return{next:()=>(e++).toString()}},Pt=(e,t)=>{const i=[];if(typeof t!="number"&&(t=e,e=0),e<=t)for(let s=e;s<t;s++)i.push(s);else for(let s=e;s>t;s--)i.push(s);return i};var C_=class{set size(e){this._size=e}setContainerGeometry(e,t){this._appliedStyles[e]!==t&&(this._appliedStyles[e]=t,this.container.style[e]=t)}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return this._cachedVisibleSize===void 0}get minimumSize(){return this.visible?this.view.minimumSize:0}get viewMinimumSize(){return this.view.minimumSize}get maximumSize(){return this.visible?this.view.maximumSize:0}get viewMaximumSize(){return this.view.maximumSize}get priority(){return this.view.priority}get snap(){return!!this.view.snap}set enabled(e){this.container.style.pointerEvents=e?"":"none"}constructor(e,t,i,s){this.container=e,this.view=t,this.disposable=s,this._cachedVisibleSize=void 0,this._appliedStyles={},typeof i=="number"?(this._size=i,this._cachedVisibleSize=void 0,e.classList.add("visible")):(this._size=0,this._cachedVisibleSize=i.cachedVisibleSize)}setVisible(e,t){if(e!==this.visible){if(e){var i;this.size=Ee((i=this._cachedVisibleSize)!==null&&i!==void 0?i:0,this.viewMinimumSize,this.viewMaximumSize),this._cachedVisibleSize=void 0}else this._cachedVisibleSize=typeof t=="number"?t:this.size,this.size=0;this.container.classList.toggle("visible",e),this.view.setVisible&&this.view.setVisible(e)}}dispose(){return this.disposable.dispose(),this.view}};function Hl(e,t,i){e.appliedLeft!==t&&(e.appliedLeft=t,e.container.style.left=t),e.appliedTop!==i&&(e.appliedTop=i,e.container.style.top=i)}let nt;(function(e){e.Distribute={type:"distribute"};function t(s){return{type:"split",index:s}}e.Split=t;function i(s){return{type:"invisible",cachedVisibleSize:s}}e.Invisible=i})(nt||(nt={}));var Oi=class{get contentSize(){return this._contentSize}get size(){return this._size}set size(e){this._size=e}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get length(){return this.viewItems.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get orientation(){return this._orientation}set orientation(e){this._orientation=e;const t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,It(this.element,"dv-horizontal","dv-vertical"),this.element.classList.add(this.orientation=="HORIZONTAL"?"dv-horizontal":"dv-vertical")}get minimumSize(){return this.viewItems.reduce((e,t)=>e+t.minimumSize,0)}get maximumSize(){return this.length===0?Number.POSITIVE_INFINITY:this.viewItems.reduce((e,t)=>e+t.maximumSize,0)}get startSnappingEnabled(){return this._startSnappingEnabled}set startSnappingEnabled(e){this._startSnappingEnabled!==e&&(this._startSnappingEnabled=e,this.updateSashEnablement())}get endSnappingEnabled(){return this._endSnappingEnabled}set endSnappingEnabled(e){this._endSnappingEnabled!==e&&(this._endSnappingEnabled=e,this.updateSashEnablement())}get disabled(){return this._disabled}set disabled(e){this._disabled=e,K(this.element,"dv-splitview-disabled",e)}get margin(){return this._margin}set margin(e){this._margin=e,K(this.element,"dv-splitview-has-margin",e!==0)}constructor(e,t){var i,s;this.container=e,this.viewItems=[],this.sashes=[],this._size=0,this._orthogonalSize=0,this._contentSize=0,this._proportions=void 0,this._startSnappingEnabled=!0,this._endSnappingEnabled=!0,this._disabled=!1,this._margin=0,this._onDidSashEnd=new G,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new G,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new G,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(r,n,o=this.viewItems.map(f=>f.size),a,l,h=Number.NEGATIVE_INFINITY,c=Number.POSITIVE_INFINITY,u,p)=>{if(r<0||r>this.viewItems.length)return 0;const f=Pt(r,-1),m=Pt(r+1,this.viewItems.length);if(l)for(const R of l)mn(f,R),mn(m,R);if(a)for(const R of a)Qs(f,R),Qs(m,R);const g=f.reduce((R,I)=>R+this.viewItems[I].minimumSize-o[I],0),_=f.reduce((R,I)=>R+this.viewItems[I].maximumSize-o[I],0),E=m.length===0?Number.POSITIVE_INFINITY:m.reduce((R,I)=>R+o[I]-this.viewItems[I].minimumSize,0),C=m.length===0?Number.NEGATIVE_INFINITY:m.reduce((R,I)=>R+o[I]-this.viewItems[I].maximumSize,0),T=Math.max(g,C),x=Math.min(E,_);let A=!1;if(u){const R=this.viewItems[u.index],I=n>=u.limitDelta;A=I!==R.visible,R.setVisible(I,u.size)}if(!A&&p){const R=this.viewItems[p.index],I=n<p.limitDelta;A=I!==R.visible,R.setVisible(I,p.size)}if(A)return this.resize(r,n,o,a,l,h,c);const k=Ee(n,T,x);let N=0,O=k;for(const R of f){const I=this.viewItems[R],w=o[R],v=Ee(w+O,I.minimumSize,I.maximumSize),S=v-w;N+=S,O-=S,I.size=v}let z=N;for(const R of m){const I=this.viewItems[R],w=o[R],v=Ee(w-z,I.minimumSize,I.maximumSize),S=v-w;z+=S,I.size=v}return n},this._orientation=(i=t.orientation)!==null&&i!==void 0?i:"VERTICAL",this.element=this.createContainer(),this.margin=(s=t.margin)!==null&&s!==void 0?s:0,this.proportionalLayout=t.proportionalLayout===void 0?!0:!!t.proportionalLayout,this.viewContainer=this.createViewContainer(),this.sashContainer=this.createSashContainer(),this.element.appendChild(this.sashContainer),this.element.appendChild(this.viewContainer),this.container.appendChild(this.element),this.style(t.styles),t.descriptor&&(this._size=t.descriptor.size,t.descriptor.views.forEach((r,n)=>{const o=r.visible===void 0||r.visible?r.size:{type:"invisible",cachedVisibleSize:r.size},a=r.view;this.addView(a,o,n,!0)}),this._contentSize=this.viewItems.reduce((r,n)=>r+n.size,0),this.saveProportions())}style(e){e?.separatorBorder==="transparent"?(It(this.element,"dv-separator-border"),this.element.style.removeProperty("--dv-separator-border")):(At(this.element,"dv-separator-border"),e?.separatorBorder&&this.element.style.setProperty("--dv-separator-border",e.separatorBorder))}isViewVisible(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].visible}setViewVisible(e,t){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");const i=this.viewItems[e];i.setVisible(t,i.size),this.distributeEmptySpace(e),this.layoutViews(),this.saveProportions()}getViewSize(e){return e<0||e>=this.viewItems.length?-1:this.viewItems[e].size}resizeView(e,t){if(e<0||e>=this.viewItems.length)return;const i=Pt(this.viewItems.length).filter(o=>o!==e),s=[...i.filter(o=>this.viewItems[o].priority==="low"),e],r=i.filter(o=>this.viewItems[o].priority==="high"),n=this.viewItems[e];t=Math.round(t),t=Ee(t,n.minimumSize,Math.min(n.maximumSize,this._size)),n.size=t,this.relayout(s,r)}getViews(){return this.viewItems.map(e=>e.view)}onDidChange(e,t){const i=this.viewItems.indexOf(e);if(i<0||i>=this.viewItems.length)return;t=typeof t=="number"?t:e.size,t=Ee(t,e.minimumSize,e.maximumSize),e.size=t;const s=Pt(this.viewItems.length).filter(o=>o!==i),r=[...s.filter(o=>this.viewItems[o].priority==="low"),i],n=s.filter(o=>this.viewItems[o].priority==="high");this.relayout([...r,i],n)}addView(e,t=nt.Distribute,i=this.viewItems.length,s){const r=document.createElement("div");r.className="dv-view",r.appendChild(e.element);let n;typeof t=="number"?n=t:t.type==="split"?n=this.getViewSize(t.index)/2:t.type==="invisible"?n={cachedVisibleSize:t.cachedVisibleSize}:n=e.minimumSize;const o=e.onDidChange(l=>this.onDidChange(a,l.size)),a=new C_(r,e,n,{dispose:()=>{o.dispose(),r.remove()}});if(i===this.viewItems.length?this.viewContainer.appendChild(r):this.viewContainer.insertBefore(r,this.viewContainer.children.item(i)),this.viewItems.splice(i,0,a),this.viewItems.length>1){const l=document.createElement("div");l.className="dv-sash";const h=u=>{var p;for(const y of this.viewItems)y.enabled=!1;const f=(p=l.ownerDocument)!==null&&p!==void 0?p:document,m=Es(f),g=this._orientation==="HORIZONTAL"?u.clientX:u.clientY,_=x_(this.sashes,y=>y.container===l),E=this.viewItems.map(y=>y.size);let C,T;const x=Pt(_,-1),A=Pt(_+1,this.viewItems.length),k=x.reduce((y,L)=>y+(this.viewItems[L].minimumSize-E[L]),0),N=x.reduce((y,L)=>y+(this.viewItems[L].viewMaximumSize-E[L]),0),O=A.length===0?Number.POSITIVE_INFINITY:A.reduce((y,L)=>y+(E[L]-this.viewItems[L].minimumSize),0),z=A.length===0?Number.NEGATIVE_INFINITY:A.reduce((y,L)=>y+(E[L]-this.viewItems[L].viewMaximumSize),0),R=Math.max(k,z),I=Math.min(O,N),w=this.findFirstSnapIndex(x),v=this.findFirstSnapIndex(A);if(typeof w=="number"){const y=this.viewItems[w],L=Math.floor(y.viewMinimumSize/2);C={index:w,limitDelta:y.visible?R-L:R+L,size:y.size}}if(typeof v=="number"){const y=this.viewItems[v],L=Math.floor(y.viewMinimumSize/2);T={index:v,limitDelta:y.visible?I+L:I-L,size:y.size}}const S=y=>{const L=(this._orientation==="HORIZONTAL"?y.clientX:y.clientY)-g;this.resize(_,L,E,void 0,void 0,R,I,C,T),this.distributeEmptySpace(),this.layoutViews()},D=()=>{for(const y of this.viewItems)y.enabled=!0;m.release(),this.saveProportions(),f.removeEventListener("pointermove",S),f.removeEventListener("pointerup",D),f.removeEventListener("pointercancel",D),f.removeEventListener("contextmenu",D),this._onDidSashEnd.fire(void 0)};f.addEventListener("pointermove",S),f.addEventListener("pointerup",D),f.addEventListener("pointercancel",D),f.addEventListener("contextmenu",D)};l.addEventListener("pointerdown",h);const c={container:l,disposable:()=>{l.removeEventListener("pointerdown",h),l.remove()}};this.sashContainer.appendChild(l),this.sashes.push(c)}s||this.relayout([i]),!s&&typeof t!="number"&&t.type==="distribute"&&this.distributeViewSizes(),this._onDidAddView.fire(e)}distributeViewSizes(){const e=[];let t=0;for(const o of this.viewItems)o.maximumSize-o.minimumSize>0&&(e.push(o),t+=o.size);const i=Math.floor(t/e.length);for(const o of e)o.size=Ee(i,o.minimumSize,o.maximumSize);const s=Pt(this.viewItems.length),r=s.filter(o=>this.viewItems[o].priority==="low"),n=s.filter(o=>this.viewItems[o].priority==="high");this.relayout(r,n)}removeView(e,t,i=!1){const s=this.viewItems.splice(e,1)[0];if(s.dispose(),this.viewItems.length>=1){const r=Math.max(e-1,0);this.sashes.splice(r,1)[0].disposable()}return i||this.relayout(),t?.type==="distribute"&&this.distributeViewSizes(),this._onDidRemoveView.fire(s.view),s.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].cachedVisibleSize}moveView(e,t){const i=this.getViewCachedVisibleSize(e),s=i===void 0?this.getViewSize(e):nt.Invisible(i),r=this.removeView(e,void 0,!0);this.addView(r,s,t)}layout(e,t){const i=Math.max(this.size,this._contentSize);if(this.size=e,this.orthogonalSize=t,this.proportions){let s=0;for(let r=0;r<this.viewItems.length;r++){const n=this.viewItems[r],o=this.proportions[r];typeof o=="number"?s+=o:e-=n.size}for(let r=0;r<this.viewItems.length;r++){const n=this.viewItems[r],o=this.proportions[r];typeof o=="number"&&s>0&&(n.size=Ee(Math.round(o*e/s),n.minimumSize,n.maximumSize))}}else{const s=Pt(this.viewItems.length),r=s.filter(o=>this.viewItems[o].priority==="low"),n=s.filter(o=>this.viewItems[o].priority==="high");this.resize(this.viewItems.length-1,e-i,void 0,r,n)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){const i=this.viewItems.reduce((s,r)=>s+r.size,0);this.resize(this.viewItems.length-1,this._size-i,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(e){let t=0;for(const n of this.viewItems)t+=n.size;let i=this.size-t;if(i===0)return;const s=Pt(this.viewItems.length-1,-1);let r=!1;for(const n of this.viewItems)if(n.priority==="low"||n.priority==="high"){r=!0;break}if(r){const n=s.filter(a=>this.viewItems[a].priority==="low"),o=s.filter(a=>this.viewItems[a].priority==="high");for(const a of o)mn(s,a);for(const a of n)Qs(s,a)}typeof e=="number"&&Qs(s,e);for(let n=0;i!==0&&n<s.length;n++){const o=this.viewItems[s[n]],a=Ee(o.size+i,o.minimumSize,o.maximumSize),l=a-o.size;i-=l,o.size=a}}saveProportions(){this.proportionalLayout&&this._contentSize>0&&(this._proportions=this.viewItems.map(e=>e.visible?e.size/this._contentSize:void 0))}layoutViews(){let e=0,t=0;for(const l of this.viewItems)e+=l.size,l.visible&&t++;if(this._contentSize=e,this.updateSashEnablement(),this.viewItems.length===0)return;const i=Math.max(0,t-1),s=this.margin*i/Math.max(1,t);let r=0;const n=[],o=4;let a=0;this.viewItems.forEach((l,h)=>{r+=this.viewItems[h].size,n.push(r),a+=l.visible?1:0;const c=l.visible?l.size-s:0,u=Math.max(0,a-1),p=h===0||u===0?0:n[h-1]+u/i*s;if(h<this.viewItems.length-1){const f=l.visible?p+c-o/2+this.margin/2:p,m=this.sashes[h];this._orientation==="HORIZONTAL"&&Hl(m,`${f}px`,"0px"),this._orientation==="VERTICAL"&&Hl(m,"0px",`${f}px`)}this._orientation==="HORIZONTAL"&&(l.setContainerGeometry("width",`${c}px`),l.setContainerGeometry("left",`${p}px`),l.setContainerGeometry("top",""),l.setContainerGeometry("height","")),this._orientation==="VERTICAL"&&(l.setContainerGeometry("height",`${c}px`),l.setContainerGeometry("top",`${p}px`),l.setContainerGeometry("width",""),l.setContainerGeometry("left","")),l.view.layout(l.size-s,this._orthogonalSize)})}findFirstSnapIndex(e){for(const t of e){const i=this.viewItems[t];if(i.visible&&i.snap)return t}for(const t of e){const i=this.viewItems[t];if(i.visible&&i.maximumSize-i.minimumSize>0)return;if(!i.visible&&i.snap)return t}}updateSashEnablement(){if(this.sashes.length===0)return;let e=!1;const t=this.viewItems.map(a=>e=a.size-a.minimumSize>0||e);e=!1;const i=this.viewItems.map(a=>e=a.maximumSize-a.size>0||e),s=[...this.viewItems].reverse();e=!1;const r=s.map(a=>e=a.size-a.minimumSize>0||e).reverse();e=!1;const n=s.map(a=>e=a.maximumSize-a.size>0||e).reverse();let o=0;for(let a=0;a<this.sashes.length;a++){const l=this.sashes[a],h=this.viewItems[a];o+=h.size;const c=!(t[a]&&n[a+1]),u=!(i[a]&&r[a+1]);if(c&&u){const p=Pt(a,-1),f=Pt(a+1,this.viewItems.length),m=this.findFirstSnapIndex(p),g=this.findFirstSnapIndex(f),_=typeof m=="number"&&!this.viewItems[m].visible,E=typeof g=="number"&&!this.viewItems[g].visible;_&&r[a]&&(o>0||this.startSnappingEnabled)?this.updateSash(l,1):E&&t[a]&&(o<this._contentSize||this.endSnappingEnabled)?this.updateSash(l,0):this.updateSash(l,2)}else c&&!u?this.updateSash(l,1):!c&&u?this.updateSash(l,0):this.updateSash(l,3)}}updateSash(e,t){K(e.container,"dv-disabled",t===2),K(e.container,"dv-enabled",t===3),K(e.container,"dv-maximum",t===0),K(e.container,"dv-minimum",t===1)}createViewContainer(){const e=document.createElement("div");return e.className="dv-view-container",e}createSashContainer(){const e=document.createElement("div");return e.className="dv-sash-container",e}createContainer(){const e=document.createElement("div");return e.className=`dv-split-view-container ${this._orientation==="HORIZONTAL"?"dv-horizontal":"dv-vertical"}`,e}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.remove();break}for(const e of this.viewItems)e.dispose();this.element.remove()}};const eo=Object.keys({orientation:void 0,descriptor:void 0,proportionalLayout:void 0,styles:void 0,margin:void 0,disableAutoResizing:void 0,className:void 0});var Fl=class extends se{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(e,t){var i;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._orientation=(i=t.orientation)!==null&&i!==void 0?i:"VERTICAL",this.element=document.createElement("div"),this.element.className="dv-pane-container",e.appendChild(this.element),this.splitview=new Oi(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:t.descriptor}),this.getPanes().forEach(s=>{const r=new se(s.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),n={pane:s,disposable:{dispose:()=>{r.dispose()}}};this.paneItems.push(n),s.orthogonalSize=this.splitview.orthogonalSize}),this.addDisposables(this._onDidChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire(void 0)}),this.splitview.onDidAddView(()=>{this._onDidChange.fire()}),this.splitview.onDidRemoveView(()=>{this._onDidChange.fire()}))}setViewVisible(e,t){this.splitview.setViewVisible(e,t)}addPane(e,t,i=this.splitview.length,s=!1){const r=e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}),n={pane:e,disposable:{dispose:()=>{r.dispose()}}};this.paneItems.splice(i,0,n),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,i,s)}getViewSize(e){return this.splitview.getViewSize(e)}getViewCachedVisibleSize(e){return this.splitview.getViewCachedVisibleSize(e)}getPanes(){return this.splitview.getViews()}removePane(e,t){const i=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t?.skipDispose||(i.disposable.dispose(),i.pane.dispose()),i}moveView(e,t){if(e===t)return;const i=this.removePane(e,{skipDispose:!0});i.disposable.dispose(),this.skipAnimation=!0;try{this.addPane(i.pane,i.pane.size,t,!1)}finally{this.skipAnimation=!1}}layout(e,t){this.splitview.layout(e,t)}setupAnimation(){this.skipAnimation||(this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),At(this.element,"dv-animated"),this.animationTimer=setTimeout(()=>{this.animationTimer=void 0,It(this.element,"dv-animated")},200))}dispose(){super.dispose(),this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),this.paneItems.forEach(e=>{e.disposable.dispose(),e.pane.dispose()}),this.paneItems=[],this.splitview.dispose(),this.element.remove()}},Qe=class{get minimumWidth(){return this.view.minimumWidth}get maximumWidth(){return this.view.maximumWidth}get minimumHeight(){return this.view.minimumHeight}get maximumHeight(){return this.view.maximumHeight}get priority(){return this.view.priority}get snap(){return this.view.snap}get minimumSize(){return this.orientation==="HORIZONTAL"?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation==="HORIZONTAL"?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation==="HORIZONTAL"?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation==="HORIZONTAL"?this.maximumWidth:this.maximumHeight}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get element(){return this.view.element}get width(){return this.orientation==="HORIZONTAL"?this.orthogonalSize:this.size}get height(){return this.orientation==="HORIZONTAL"?this.size:this.orthogonalSize}constructor(e,t,i,s=0){this.view=e,this.orientation=t,this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._orthogonalSize=i,this._size=s,this._disposable=this.view.onDidChange(r=>{r?this._onDidChange.fire({size:this.orientation==="VERTICAL"?r.width:r.height,orthogonalSize:this.orientation==="VERTICAL"?r.height:r.width}):this._onDidChange.fire({})})}setVisible(e){this.view.setVisible&&this.view.setVisible(e)}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._onDidChange.dispose(),this._disposable.dispose()}},Ve=class to extends se{get width(){return this.orientation==="HORIZONTAL"?this.size:this.orthogonalSize}get height(){return this.orientation==="HORIZONTAL"?this.orthogonalSize:this.size}get minimumSize(){if(this._cachedMinimumSize===void 0){let t=0;for(let i=0;i<this.children.length;i++)this.splitview.isViewVisible(i)&&(t=Math.max(t,this.children[i].minimumOrthogonalSize));this._cachedMinimumSize=t}return this._cachedMinimumSize}get maximumSize(){if(this._cachedMaximumSize===void 0){let t=Number.POSITIVE_INFINITY;for(let i=0;i<this.children.length;i++)this.splitview.isViewVisible(i)&&(t=Math.min(t,this.children[i].maximumOrthogonalSize));this._cachedMaximumSize=t}return this._cachedMaximumSize}get minimumOrthogonalSize(){return this.splitview.minimumSize}get maximumOrthogonalSize(){return this.splitview.maximumSize}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get minimumWidth(){return this.orientation==="HORIZONTAL"?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation==="HORIZONTAL"?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation==="HORIZONTAL"?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation==="HORIZONTAL"?this.maximumSize:this.maximumOrthogonalSize}get priority(){var t;return(t=this._cachedPriority)!==null&&t!==void 0||(this._cachedPriority=this.computePriority()),this._cachedPriority}computePriority(){if(this.children.length===0)return"normal";let t=!1,i=!1;for(const r of this.children){var s;const n=(s=r.priority)!==null&&s!==void 0?s:"normal";n==="high"?t=!0:n==="low"&&(i=!0)}return t?"high":i?"low":"normal"}invalidateCachedSizes(){this._cachedMinimumSize=void 0,this._cachedMaximumSize=void 0,this._cachedPriority=void 0}get disabled(){return this.splitview.disabled}set disabled(t){this.splitview.disabled=t}get margin(){return this.splitview.margin}set margin(t){this.splitview.margin=t,this.children.forEach(i=>{i instanceof to&&(i.margin=t)})}constructor(t,i,s,r,n,o,a,l){if(super(),this.orientation=t,this.proportionalLayout=i,this.styles=s,this._childrenDisposable=Se.NONE,this.children=[],this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new G,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=n,this._size=r,this.element=document.createElement("div"),this.element.className="dv-branch-node",l){const h={views:l.map(c=>{var u;return{view:c.node,size:c.node.size,visible:(u=c.visible)!==null&&u!==void 0?u:!0}}),size:this.orthogonalSize};this.children=l.map(c=>c.node),this.splitview=new Oi(this.element,{orientation:this.orientation,descriptor:h,proportionalLayout:i,styles:s,margin:a})}else this.splitview=new Oi(this.element,{orientation:this.orientation,proportionalLayout:i,styles:s,margin:a}),this.splitview.layout(this.size,this.orthogonalSize);this.disabled=o,this.addDisposables(this._onDidChange,this._onDidVisibilityChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire({})})),this.setupChildrenEvents()}setVisible(t){}isChildVisible(t){if(t<0||t>=this.children.length)throw new Error("Invalid index");return this.splitview.isViewVisible(t)}setChildVisible(t,i){if(t<0||t>=this.children.length)throw new Error("Invalid index");if(this.splitview.isViewVisible(t)===i)return;const s=this.splitview.contentSize===0;this.splitview.setViewVisible(t,i),this.invalidateCachedSizes();const r=this.splitview.contentSize===0;(i&&s||!i&&r)&&this._onDidVisibilityChange.fire({visible:i})}moveChild(t,i){if(t===i)return;if(t<0||t>=this.children.length)throw new Error("Invalid from index");t<i&&i--,this.splitview.moveView(t,i);const s=this._removeChild(t);this._addChild(s,i)}getChildSize(t){if(t<0||t>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewSize(t)}resizeChild(t,i){if(t<0||t>=this.children.length)throw new Error("Invalid index");this.splitview.resizeView(t,i)}layout(t,i){this._size=i,this._orthogonalSize=t,this.splitview.layout(i,t)}addChild(t,i,s,r){if(s<0||s>this.children.length)throw new Error("Invalid index");this.splitview.addView(t,i,s,r),this._addChild(t,s)}getChildCachedVisibleSize(t){if(t<0||t>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewCachedVisibleSize(t)}removeChild(t,i){if(t<0||t>=this.children.length)throw new Error("Invalid index");return this.splitview.removeView(t,i),this._removeChild(t)}_addChild(t,i){this.children.splice(i,0,t),this.setupChildrenEvents()}_removeChild(t){const[i]=this.children.splice(t,1);return this.setupChildrenEvents(),i}setupChildrenEvents(){this.invalidateCachedSizes(),this._childrenDisposable.dispose(),this._childrenDisposable=new se(xt.any(...this.children.map(t=>t.onDidChange))(t=>{this.invalidateCachedSizes(),this._onDidChange.fire({size:t.orthogonalSize})}),...this.children.map((t,i)=>t instanceof to?t.onDidVisibilityChange(({visible:s})=>{this.setChildVisible(i,s)}):Se.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(t=>t.dispose()),super.dispose()}};function io(e,t){if(e instanceof Qe)return e;if(e instanceof Ve)return io(e.children[t?e.children.length-1:0],t);throw new Error("invalid node")}function Wc(e,t,i){if(e instanceof Ve){const s=new Ve(e.orientation,e.proportionalLayout,e.styles,t,i,e.disabled,e.margin);for(let r=e.children.length-1;r>=0;r--){const n=e.children[r];s.addChild(Wc(n,n.size,n.orthogonalSize),n.size,0,!0)}return s}else return new Qe(e.view,e.orientation,i)}function so(e,t,i){if(e instanceof Ve){const s=new Ve(zt(e.orientation),e.proportionalLayout,e.styles,t,i,e.disabled,e.margin);let r=0;for(let n=e.children.length-1;n>=0;n--){const o=e.children[n],a=o instanceof Ve?o.orthogonalSize:o.size;let l=e.size===0?0:Math.round(t*a/e.size);r+=l,n===0&&(l+=t-r),s.addChild(so(o,i,l),l,0,!0)}return s}else return new Qe(e.view,zt(e.orientation),i)}function D_(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");let i=t.firstElementChild,s=0;for(;i!==e&&i!==t.lastElementChild&&i;)i=i.nextElementSibling,s++;return s}function Ce(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");if(/\bdv-grid-view\b/.test(t.className))return[];const i=D_(t),s=t.parentElement.parentElement.parentElement;return[...Ce(s),i]}function wt(e,t,i){if(P_(e,t)===k_(i)){const[s,r]=Zt(t);let n=r;return(i==="right"||i==="bottom")&&(n+=1),[...s,n]}else{const s=i==="right"||i==="bottom"?1:0;return[...t,s]}}function k_(e){return e==="top"||e==="bottom"?"VERTICAL":"HORIZONTAL"}function P_(e,t){return t.length%2===0?zt(e):e}const zt=e=>e==="HORIZONTAL"?"VERTICAL":"HORIZONTAL";function E_(e){return!!e.children}const ro=(e,t)=>{const i=t==="VERTICAL"?e.box.width:e.box.height;if(!E_(e))return typeof e.cachedVisibleSize=="number"?{type:"leaf",data:e.view.toJSON(),size:e.cachedVisibleSize,visible:!1}:{type:"leaf",data:e.view.toJSON(),size:i};const s=e.children.map(r=>ro(r,zt(t)));return typeof e.cachedVisibleSize=="number"?{type:"branch",data:s,size:e.cachedVisibleSize,visible:!1}:{type:"branch",data:s,size:i}};var Hc=class{get length(){return this._root?this._root.children.length:0}get orientation(){return this.root.orientation}set orientation(e){if(this.root.orientation===e)return;const{size:t,orthogonalSize:i}=this.root;this.root=so(this.root,i,t),this.root.layout(t,i)}get width(){return this.root.width}get height(){return this.root.height}get minimumWidth(){return this.root.minimumWidth}get minimumHeight(){return this.root.minimumHeight}get maximumWidth(){return this.root.maximumWidth}get maximumHeight(){return this.root.maximumHeight}get locked(){return this._locked}set locked(e){this._locked=e;const t=[this.root];for(;t.length>0;){const i=t.pop();i instanceof Ve&&(i.disabled=e,t.push(...i.children))}}get margin(){return this._margin}set margin(e){this._margin=e,this.root.margin=e}maximizedView(){var e;return(e=this._maximizedNode)===null||e===void 0?void 0:e.leaf.view}hasMaximizedView(){return this._maximizedNode!==void 0}maximizeView(e){var t;const i=Ce(e.element),[s,r]=this.getNode(i);if(!(r instanceof Qe)||((t=this._maximizedNode)===null||t===void 0?void 0:t.leaf)===r)return;this.hasMaximizedView()&&this.exitMaximizedView(),ro(this.getView(),this.orientation);const n=[];function o(a,l){for(let h=0;h<a.children.length;h++){const c=a.children[h];c instanceof Qe?c!==l&&(a.isChildVisible(h)?a.setChildVisible(h,!1):n.push(c)):o(c,l)}}o(this.root,r),this._maximizedNode={leaf:r,hiddenOnMaximize:n},this._onDidMaximizedNodeChange.fire({view:r.view,isMaximized:!0})}exitMaximizedView(){if(!this._maximizedNode)return;const e=this._maximizedNode.hiddenOnMaximize;function t(s){for(let r=s.children.length-1;r>=0;r--){const n=s.children[r];n instanceof Qe?e.includes(n)||s.setChildVisible(r,!0):t(n)}}t(this.root);const i=this._maximizedNode.leaf;this._maximizedNode=void 0,this._onDidMaximizedNodeChange.fire({view:i.view,isMaximized:!1})}serialize(){const e=this.maximizedView();let t;e&&(t=Ce(e.element));const i=this._onDidMaximizedNodeChange.pause();try{this.hasMaximizedView()&&this.exitMaximizedView();const s={root:ro(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation};return t&&(s.maximizedNode={location:t}),e&&this.maximizeView(e),s}finally{i.dispose()}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this._onDidMaximizedNodeChange.dispose(),this._onDidViewVisibilityChange.dispose(),this.root.dispose(),this._maximizedNode=void 0,this.element.remove()}clear(){const e=this.root.orientation;this.root=new Ve(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize,this.locked,this.margin)}deserialize(e,t){const i=e.orientation,s=i==="VERTICAL"?e.height:e.width;if(this._deserialize(e.root,i,t,s),this.layout(e.width,e.height),e.maximizedNode){const r=e.maximizedNode.location,[n,o]=this.getNode(r);if(!(o instanceof Qe))return;this.maximizeView(o.view)}}_deserialize(e,t,i,s){this.root=this._deserializeNode(e,t,i,s)}_deserializeNode(e,t,i,s){let r;if(e.type==="branch"){const o=e.data.map(a=>({node:this._deserializeNode(a,zt(t),i,e.size),visible:a.visible}));r=new Ve(t,this.proportionalLayout,this.styles,e.size,s,this.locked,this.margin,o)}else{const o=i.fromJSON(e);if(typeof e.visible=="boolean"){var n;(n=o.setVisible)===null||n===void 0||n.call(o,e.visible)}r=new Qe(o,t,s,e.size)}return r}get root(){return this._root}set root(e){const t=this._root;t&&(t.dispose(),this._maximizedNode=void 0,t.element.remove()),this._root=e,this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(i=>{this._onDidChange.fire(i)})}normalize(){if(!this._root||this._root.children.length!==1)return;const e=this.root,t=e.children[0];if(t instanceof Qe)return;e.element.remove();const i=e.removeChild(0);e.dispose(),i.dispose(),this._root=Wc(t,t.size,t.orthogonalSize),this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(s=>{this._onDidChange.fire(s)})}insertOrthogonalSplitviewAtRoot(){if(!this._root)return;const e=this.root;if(e.element.remove(),this._root=new Ve(zt(e.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size,this.locked,this.margin),e.children.length!==0)if(e.children.length===1){const t=e.children[0];e.removeChild(0).dispose(),e.dispose(),this._root.addChild(so(t,t.orthogonalSize,t.size),nt.Distribute,0)}else this._root.addChild(e,nt.Distribute,0);this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(t=>{this._onDidChange.fire(t)})}next(e){return this.progmaticSelect(e)}previous(e){return this.progmaticSelect(e,!0)}getView(e){const t=e?this.getNode(e)[1]:this.root;return this._getViews(t,this.orientation)}_getViews(e,t,i){const s={height:e.height,width:e.width};if(e instanceof Qe)return{box:s,view:e.view,cachedVisibleSize:i};const r=[];for(let n=0;n<e.children.length;n++){const o=e.children[n],a=e.getChildCachedVisibleSize(n);r.push(this._getViews(o,zt(t),a))}return{box:s,children:r,cachedVisibleSize:i}}progmaticSelect(e,t=!1){const[i,s]=this.getNode(e);if(!(s instanceof Qe))throw new TypeError("invalid location");for(let r=i.length-1;r>-1;r--){const n=i[r],o=e[r]||0;if(t?o-1>-1:o+1<n.children.length)return io(n.children[t?o-1:o+1],t)}return io(this.root,t)}constructor(e,t,i,s,r){this.proportionalLayout=e,this.styles=t,this._locked=!1,this._margin=0,this._maximizedNode=void 0,this.disposable=new Me,this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._onDidViewVisibilityChange=new G,this.onDidViewVisibilityChange=this._onDidViewVisibilityChange.event,this._onDidMaximizedNodeChange=new G,this.onDidMaximizedNodeChange=this._onDidMaximizedNodeChange.event,this.element=document.createElement("div"),this.element.className="dv-grid-view",this._locked=s??!1,this._margin=r??0,this.root=new Ve(i,e,t,0,0,this.locked,this.margin)}isViewVisible(e){const[t,i]=Zt(e),[,s]=this.getNode(t);if(!(s instanceof Ve))throw new TypeError("Invalid from location");return s.isChildVisible(i)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,s]=Zt(e),[,r]=this.getNode(i);if(!(r instanceof Ve))throw new TypeError("Invalid from location");this._onDidViewVisibilityChange.fire(),r.setChildVisible(s,t)}moveView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[,s]=this.getNode(e);if(!(s instanceof Ve))throw new TypeError("Invalid location");s.moveChild(t,i)}addView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[s,r]=Zt(i),[n,o]=this.getNode(s);if(o instanceof Ve){const a=new Qe(e,zt(o.orientation),o.orthogonalSize);o.addChild(a,t,r)}else{const[a,...l]=[...n].reverse(),[h,...c]=[...s].reverse();let u=0;const p=a.getChildCachedVisibleSize(h);typeof p=="number"&&(u=nt.Invisible(p)),a.removeChild(h).dispose();const f=new Ve(o.orientation,this.proportionalLayout,this.styles,o.size,o.orthogonalSize,this.locked,this.margin);a.addChild(f,o.size,h);const m=new Qe(o.view,a.orientation,o.size);f.addChild(m,u,0),typeof t!="number"&&t.type==="split"&&(t={type:"split",index:0});const g=new Qe(e,a.orientation,o.size);f.addChild(g,t,r)}}remove(e,t){const i=Ce(e.element);return this.removeView(i,t)}removeView(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,s]=Zt(e),[r,n]=this.getNode(i);if(!(n instanceof Ve))throw new TypeError("Invalid location");const o=n.children[s];if(!(o instanceof Qe))throw new TypeError("Invalid location");if(n.removeChild(s,t),o.dispose(),n.children.length!==1)return o.view;const a=n.children[0];if(r.length===0)return a instanceof Qe||(n.removeChild(0,t),this.root=a),o.view;const[l,...h]=[...r].reverse(),[c,...u]=[...i].reverse(),p=n.isChildVisible(0);n.removeChild(0,t);const f=l.children.map((m,g)=>l.getChildSize(g));if(l.removeChild(c,t).dispose(),a instanceof Ve){f.splice(c,1,...a.children.map(m=>m.size));for(let m=0;m<a.children.length;m++){const g=a.children[m];l.addChild(g,g.size,c+m)}for(;a.children.length>0;)a.removeChild(0)}else{const m=new Qe(a.view,zt(a.orientation),a.size),g=p?a.orthogonalSize:nt.Invisible(a.orthogonalSize);l.addChild(m,g,c)}a.dispose();for(let m=0;m<f.length;m++)l.resizeChild(m,f[m]);return o.view}layout(e,t){const[i,s]=this.root.orientation==="HORIZONTAL"?[t,e]:[e,t];this.root.layout(i,s)}getNode(e,t=this.root,i=[]){if(e.length===0)return[i,t];if(!(t instanceof Ve))throw new TypeError("Invalid location");const[s,...r]=e;if(s<0||s>=t.children.length)throw new Error("Invalid location");const n=t.children[s];return i.push(t),this.getNode(r,n,i)}};const no=Object.keys({disableAutoResizing:void 0,proportionalLayout:void 0,orientation:void 0,hideBorders:void 0,className:void 0});var Ia=class extends se{get element(){return this._element}get disableResizing(){return this._disableResizing}set disableResizing(e){this._disableResizing=e}constructor(e,t=!1){super(),this._lastWidth=-1,this._lastHeight=-1,this._disableResizing=t,this._element=e,this.addDisposables(ji(this._element,i=>{if(this.isDisposed||this.disableResizing||!this._element.offsetParent||!zc(this._element))return;const s=Math.round(i.contentRect.width),r=Math.round(i.contentRect.height);s===this._lastWidth&&r===this._lastHeight||(this._lastWidth=s,this._lastHeight=r,this.layout(s,r))}))}};const T_=Ta();function Pr(e){switch(e){case"left":return"left";case"right":return"right";case"above":return"top";case"below":return"bottom";default:return"center"}}var Fc=class extends Ia{get id(){return this._id}get size(){return this._groups.size}get groups(){return Array.from(this._groups.values()).map(e=>e.value)}get width(){return this.gridview.width}get height(){return this.gridview.height}get minimumHeight(){return this.gridview.minimumHeight}get maximumHeight(){return this.gridview.maximumHeight}get minimumWidth(){return this.gridview.minimumWidth}get maximumWidth(){return this.gridview.maximumWidth}get activeGroup(){return this._activeGroup}get locked(){return this.gridview.locked}set locked(e){this.gridview.locked=e}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._id=T_.next(),this._groups=new Map,this._onDidRemove=new G,this.onDidRemove=this._onDidRemove.event,this._onDidAdd=new G,this.onDidAdd=this._onDidAdd.event,this._onDidMaximizedChange=new G,this.onDidMaximizedChange=this._onDidMaximizedChange.event,this._onDidActiveChange=new G,this.onDidActiveChange=this._onDidActiveChange.event,this._bufferOnDidLayoutChange=new $l,this.onDidLayoutChange=this._bufferOnDidLayoutChange.onEvent,this._onDidViewVisibilityChangeMicroTaskQueue=new $l,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new qr(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this.gridview=new Hc(!!t.proportionalLayout,t.styles,t.orientation,t.locked,t.margin),this.gridview.locked=!!t.locked,this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidMaximizedNodeChange(s=>{this._onDidMaximizedChange.fire({panel:s.view,isMaximized:s.isMaximized})}),this.gridview.onDidViewVisibilityChange(()=>this._onDidViewVisibilityChangeMicroTaskQueue.fire()),this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.forceRelayout()}),Se.from(()=>{this.element.remove()}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire()}),xt.any(this.onDidAdd,this.onDidRemove,this.onDidActiveChange)(()=>{this._bufferOnDidLayoutChange.fire()}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(Ce(e.element),t),this._bufferOnDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(Ce(e.element))}updateOptions(e){if(e.proportionalLayout,e.orientation&&(this.gridview.orientation=e.orientation),"disableAutoResizing"in e){var t;this.disableResizing=(t=e.disableAutoResizing)!==null&&t!==void 0?t:!1}if("locked"in e){var i;this.locked=(i=e.locked)!==null&&i!==void 0?i:!1}if("margin"in e){var s;this.gridview.margin=(s=e.margin)!==null&&s!==void 0?s:0}if("className"in e){var r;this._classNames.setClassNames((r=e.className)!==null&&r!==void 0?r:"")}}maximizeGroup(e){this.gridview.maximizeView(e),this.doSetGroupActive(e)}isMaximizedGroup(e){return this.gridview.maximizedView()===e}exitMaximizedGroup(){this.gridview.exitMaximizedView()}hasMaximizedGroup(){return this.gridview.hasMaximizedView()}doAddGroup(e,t=[0],i,s=this.gridview){s.addView(e,i??nt.Distribute,t),this._onDidAdd.fire(e)}doRemoveGroup(e,t){if(!this._groups.has(e.id))throw new Error("invalid operation");const i=this._groups.get(e.id),s=this.gridview.remove(e,nt.Distribute);if(i&&!t?.skipDispose&&(i.disposable.dispose(),i.value.dispose(),this._groups.delete(e.id),this._onDidRemove.fire(e)),!t?.skipActive&&this._activeGroup===e){const r=Array.from(this._groups.values());this.doSetGroupActive(r.length>0?r[0].value:void 0)}return s}getPanel(e){var t;return(t=this._groups.get(e))===null||t===void 0?void 0:t.value}doSetGroupActive(e){this._activeGroup!==e&&(this._activeGroup&&this._activeGroup.setActive(!1),e&&e.setActive(!0),this._activeGroup=e,this._onDidActiveChange.fire(e))}removeGroup(e){this.doRemoveGroup(e)}activateNext(e){var t,i;if((t=e)!==null&&t!==void 0||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const s=Ce(e.group.element),r=(i=this.gridview.next(s))===null||i===void 0?void 0:i.view;this.doSetGroupActive(r)}activatePrevious(e){var t,i;if((t=e)!==null&&t!==void 0||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const s=Ce(e.group.element),r=(i=this.gridview.previous(s))===null||i===void 0?void 0:i.view;this.doSetGroupActive(r)}forceRelayout(){this.layout(this.width,this.height,!0)}layout(e,t,i){(i||e!==this.width||t!==this.height)&&(this.gridview.element.style.height=`${t}px`,this.gridview.element.style.width=`${e}px`,this.gridview.layout(e,t))}dispose(){this._onDidActiveChange.dispose(),this._onDidAdd.dispose(),this._onDidRemove.dispose();for(const e of this.groups)e.dispose();this.gridview.dispose(),super.dispose()}};function Ts(e){"@babel/helpers - typeof";return Ts=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ts(e)}function I_(e,t){if(Ts(e)!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var s=i.call(e,t);if(Ts(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function A_(e){var t=I_(e,"string");return Ts(t)=="symbol"?t:t+""}function R_(e,t,i){return(t=A_(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Vl(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),i.push.apply(i,s)}return i}function re(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?Vl(Object(i),!0).forEach(function(s){R_(e,s,i[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Vl(Object(i)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(i,s))})}return e}function L_(e,t){return e==="center"?`Tab into ${t}`:`Split ${e} of ${t}`}function N_(e,t){return e==="center"?`docked into ${t}`:`split ${e} of ${t}`}const Er={panelOpened:e=>`${e} opened`,panelClosed:e=>`${e} closed`,groupMaximized:e=>`${e} maximized`,groupRestored:e=>`${e} restored`,groupFloated:e=>`${e} floated`,groupDocked:e=>`${e} docked`,groupPoppedOut:e=>`${e} opened in a new window`,closeTab:e=>`Close ${e}`,closeTabPlain:()=>"Close",movePickTarget:(e,t,i,s)=>`Moving ${e}. Target ${t}, ${i} of ${s}. Enter to choose where, Escape to cancel.`,movePickEdge:(e,t)=>`${L_(e,t)}. Arrows to change, Enter to confirm, Escape to go back.`,moveCommitted:(e,t,i)=>`${e} ${N_(i,t)}.`,moveCancelled:()=>"Move cancelled.",moveNotAllowed:()=>"That move is not allowed.",moveFloated:e=>`${e} floated.`};function Vc(e){return e?re(re({},Er),e):Er}var Uc=class{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get length(){return this.component.length}get orientation(){return this.component.orientation}get panels(){return this.component.panels}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}constructor(e){this.component=e}removePanel(e,t){this.component.removePanel(e,t)}focus(){this.component.focus()}getPanel(e){return this.component.getPanel(e)}layout(e,t){return this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},Is=class{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get panels(){return this.component.panels}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}get onDidDrop(){return this.component.onDidDrop}get onUnhandledDragOver(){return this.component.onUnhandledDragOver}constructor(e){this.component=e}removePanel(e){this.component.removePanel(e)}getPanel(e){return this.component.getPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}focus(){this.component.focus()}layout(e,t){this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},Kc=class{get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddPanel(){return this.component.onDidAddGroup}get onDidRemovePanel(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActiveGroupChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get panels(){return this.component.groups}get orientation(){return this.component.orientation}set orientation(e){this.component.updateOptions({orientation:e})}constructor(e){this.component=e}focus(){this.component.focus()}layout(e,t,i=!1){this.component.layout(e,t,i)}addPanel(e){return this.component.addPanel(e)}removePanel(e,t){this.component.removePanel(e,t)}movePanel(e,t){this.component.movePanel(e,t)}getPanel(e){return this.component.getPanel(e)}fromJSON(e){return this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},Aa=class{get id(){return this.component.id}get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get size(){return this.component.size}get tabGroupColors(){return this.component.tabGroupColorPalette.entries()}get totalPanels(){return this.component.totalPanels}get onDidActiveGroupChange(){return this.component.onDidActiveGroupChange}get onDidAddGroup(){return this.component.onDidAddGroup}get onDidRemoveGroup(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActivePanelChange}get onDidPanelPinnedChange(){return this.component.onDidPanelPinnedChange}get onDidAddPanel(){return this.component.onDidAddPanel}get onDidRemovePanel(){return this.component.onDidRemovePanel}get onDidMovePanel(){return this.component.onDidMovePanel}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidDrop(){return this.component.onDidDrop}get onWillDrop(){return this.component.onWillDrop}get onWillMutateLayout(){return this.component.onWillMutateLayout}get onDidMutateLayout(){return this.component.onDidMutateLayout}get onWillShowOverlay(){return this.component.onWillShowOverlay}get onWillDragGroup(){return this.component.onWillDragGroup}get onWillDragPanel(){return this.component.onWillDragPanel}get onUnhandledDragOver(){return this.component.onUnhandledDragOver}get onDidPopoutGroupSizeChange(){return this.component.onDidPopoutGroupSizeChange}get onDidPopoutGroupPositionChange(){return this.component.onDidPopoutGroupPositionChange}get onDidAddPopoutGroup(){return this.component.onDidAddPopoutGroup}get onDidRemovePopoutGroup(){return this.component.onDidRemovePopoutGroup}get onDidOpenPopoutWindowFail(){return this.component.onDidOpenPopoutWindowFail}getPopouts(){return this.component.getPopouts()}get onDidCreateTabGroup(){return this.component.onDidCreateTabGroup}get onDidDestroyTabGroup(){return this.component.onDidDestroyTabGroup}get onDidAddPanelToTabGroup(){return this.component.onDidAddPanelToTabGroup}get onDidRemovePanelFromTabGroup(){return this.component.onDidRemovePanelFromTabGroup}get onDidTabGroupChange(){return this.component.onDidTabGroupChange}get onDidTabGroupCollapsedChange(){return this.component.onDidTabGroupCollapsedChange}get panels(){return this.component.panels}get groups(){return this.component.groups}adjacentGroupInDirection(e,t){return this.component.adjacentGroupInDirection(e,t)}get activePanel(){return this.component.activePanel}get activeGroup(){return this.component.activeGroup}get messages(){return Vc(this.component.options.messages)}constructor(e){this.component=e}focus(){this.component.focus()}getPanel(e){return this.component.getGroupPanel(e)}layout(e,t,i=!1){this.component.layout(e,t,i)}addPanel(e){return this.component.withOrigin("api",()=>this.component.addPanel(e))}removePanel(e){this.component.withOrigin("api",()=>this.component.removePanel(e))}addGroup(e){return this.component.withOrigin("api",()=>this.component.addGroup(e))}closeAllGroups(){return this.component.withOrigin("api",()=>this.component.closeAllGroups())}removeGroup(e){this.component.withOrigin("api",()=>this.component.removeGroup(e))}getGroup(e){return this.component.getPanel(e)}addFloatingGroup(e,t){return this.component.withOrigin("api",()=>this.component.addFloatingGroup(e,t))}fromJSON(e,t){this.component.withOrigin("api",()=>this.component.fromJSON(e,t))}toJSON(){return this.component.toJSON()}clear(){this.component.withOrigin("api",()=>this.component.clear())}undo(){this.component.undo()}redo(){this.component.redo()}get canUndo(){return this.component.canUndo}get canRedo(){return this.component.canRedo}clearHistory(){this.component.clearHistory()}get onDidChangeHistory(){return this.component.onDidChangeHistory}get smartGuidesEnabled(){return this.component.smartGuidesEnabled}setSmartGuidesEnabled(e){this.component.setSmartGuidesEnabled(e)}updateSmartGuidesOptions(e){this.component.updateSmartGuidesOptions(e)}get onDidSnapFloat(){return this.component.onDidSnapFloat}get onDidSnapTogether(){return this.component.onDidSnapTogether}get popoutRestorationPromise(){return this.component.popoutRestorationPromise}activateNext(e){this.component.activateNext(e)}activatePrevious(e){this.component.activatePrevious(e)}moveToNext(e){this.activateNext(e)}moveToPrevious(e){this.activatePrevious(e)}maximizeGroup(e){this.component.withOrigin("api",()=>this.component.maximizeGroup(e.group))}hasMaximizedGroup(){return this.component.hasMaximizedGroup()}exitMaximizedGroup(){this.component.withOrigin("api",()=>this.component.exitMaximizedGroup())}get onDidMaximizedGroupChange(){return this.component.onDidMaximizedGroupChange}addPopoutGroup(e,t){return this.component.withOrigin("api",()=>this.component.addPopoutGroup(e,t))}addEdgeGroup(e,t){return this.component.addEdgeGroup(e,t)}revealEdgeGroupWithData(e,t,i){this.component.revealEdgeGroupWithData(e,t,i)}getEdgeGroup(e){return this.component.getEdgeGroup(e)}setEdgeGroupVisible(e,t){this.component.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this.component.isEdgeGroupVisible(e)}removeEdgeGroup(e){this.component.removeEdgeGroup(e)}pinEdgeGroup(e){this.component.pinEdgeGroup(e)}autoHideEdgeGroup(e){this.component.autoHideEdgeGroup(e)}peekEdgeGroup(e,t){this.component.peekEdgeGroup(e,t)}updateOptions(e){this.component.updateOptions(e)}_getGroupModel(e){const t=this.component.getPanel(e);if(!t)throw new Error(`dockview: group '${e}' not found`);return t.model}createTabGroup(e){const t=this._getGroupModel(e.groupId);return this.component.withOrigin("api",()=>t.createTabGroup({label:e.label,color:e.color,componentParams:e.componentParams}))}dissolveTabGroup(e){const t=this._getGroupModel(e.groupId);this.component.withOrigin("api",()=>t.dissolveTabGroup(e.tabGroupId))}addPanelToTabGroup(e){const t=this._getGroupModel(e.groupId);this.component.withOrigin("api",()=>t.addPanelToTabGroup(e.tabGroupId,e.panelId,e.index))}removePanelFromTabGroup(e){const t=this._getGroupModel(e.groupId);this.component.withOrigin("api",()=>t.removePanelFromTabGroup(e.panelId))}getTabGroups(e){return this._getGroupModel(e.groupId).getTabGroups()}getTabGroupForPanel(e){return this._getGroupModel(e.groupId).getTabGroupForPanel(e.panelId)}moveTabGroup(e){this._getGroupModel(e.groupId).moveTabGroup(e.tabGroupId,e.index)}dispose(){this.component.dispose()}},qc=class extends se{constructor(e,t){super(),this.element=e,this.callbacks=t,this.target=null,this.registerListeners()}onDragEnter(e){this.target=e.target,this.callbacks.onDragEnter(e)}onDragOver(e){e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}onDragLeave(e){this.target===e.target&&(this.target=null,this.callbacks.onDragLeave(e))}onDragEnd(e){this.target=null,this.callbacks.onDragEnd(e)}onDrop(e){this.callbacks.onDrop(e)}registerListeners(){this.addDisposables(Z(this.element,"dragenter",e=>{this.onDragEnter(e)},!0)),this.addDisposables(Z(this.element,"dragover",e=>{this.onDragOver(e)},!0)),this.addDisposables(Z(this.element,"dragleave",e=>{this.onDragLeave(e)})),this.addDisposables(Z(this.element,"dragend",e=>{this.onDragEnd(e)})),this.addDisposables(Z(this.element,"drop",e=>{this.onDrop(e)}))}};const M_={value:50,type:"percentage"},O_=100,G_=100;function oo(){const e=document.createElement("div");e.className="dv-drop-target-dropzone";const t=document.createElement("div");return t.className="dv-drop-target-selection",e.appendChild(t),{dropzone:e,selection:t}}function Yc(e,t,i,s){var r,n,o;const a=(r=s?.smallWidthBoundary)!==null&&r!==void 0?r:O_,l=(n=s?.smallHeightBoundary)!==null&&n!==void 0?n:G_,h=t<a,c=i<l,u=e==="left",p=e==="right",f=e==="top",m=e==="bottom",g=!h&&p,_=!h&&u,E=!c&&f,C=!c&&m;let T=1;const x=(o=s?.size)!==null&&o!==void 0?o:M_;return x.type==="percentage"?T=Ee(x.value,0,100)/100:((g||_)&&(T=Ee(0,x.value,t)/t),(E||C)&&(T=Ee(0,x.value,i)/i)),{isSmallX:h,isSmallY:c,isLeft:u,isRight:p,isTop:f,isBottom:m,rightClass:g,leftClass:_,topClass:E,bottomClass:C,size:T}}function Xc(e,t,i,s,r){const n=Yc(t,i,s,r),{rightClass:o,leftClass:a,topClass:l,bottomClass:h,size:c}=n,u={top:"0px",left:"0px",width:"100%",height:"100%"};o?(u.left=`${100*(1-c)}%`,u.width=`${100*c}%`):a?u.width=`${100*c}%`:l?u.height=`${100*c}%`:h&&(u.top=`${100*(1-c)}%`,u.height=`${100*c}%`),n.isSmallX&&n.isLeft&&(u.width="4px"),n.isSmallX&&n.isRight&&(u.left=`${i-4}px`,u.width="4px"),n.isSmallY&&n.isTop&&(u.height="4px"),n.isSmallY&&n.isBottom&&(u.top=`${s-4}px`,u.height="4px"),e.style.top=u.top,e.style.left=u.left,e.style.width=u.width,e.style.height=u.height,e.style.visibility="visible",(!e.style.transform||e.style.transform==="")&&(e.style.transform="translate3d(0, 0, 0)");const p=n.isSmallX&&(n.isLeft||n.isRight)||n.isSmallY&&(n.isTop||n.isBottom);K(e,"dv-drop-target-small-vertical",n.isSmallY),K(e,"dv-drop-target-small-horizontal",n.isSmallX),K(e,"dv-drop-target-selection-line",p),K(e,"dv-drop-target-left",n.isLeft),K(e,"dv-drop-target-right",n.isRight),K(e,"dv-drop-target-top",n.isTop),K(e,"dv-drop-target-bottom",n.isBottom),K(e,"dv-drop-target-center",t==="center")}function z_(e,t){const i=`${Math.round(t.top)}px`,s=`${Math.round(t.left)}px`,r=`${Math.round(t.width)}px`,n=`${Math.round(t.height)}px`;return e.style.top!==i||e.style.left!==s||e.style.width!==r||e.style.height!==n}function B_(e,t){e.style.top=`${Math.round(t.top)}px`,e.style.left=`${Math.round(t.left)}px`,e.style.width=`${Math.round(t.width)}px`,e.style.height=`${Math.round(t.height)}px`,e.style.visibility="visible",(!e.style.transform||e.style.transform==="")&&(e.style.transform="translate3d(0, 0, 0)")}function Jc(e){const t=Yc(e.quadrant,e.width,e.height,e.overlayModel),{rightClass:i,leftClass:s,topClass:r,bottomClass:n,size:o}=t,a=e.outlineElement.getBoundingClientRect(),l=e.targetModel.getElements(void 0,e.outlineElement),h=l.root,c=l.overlay,u=h.getBoundingClientRect(),p=a.top-u.top,f=a.left-u.left,m={top:p,left:f,width:e.width,height:e.height};return i?(m.left=f+e.width*(1-o),m.width=e.width*o):s?m.width=e.width*o:r?m.height=e.height*o:n&&(m.top=p+e.height*(1-o),m.height=e.height*o),t.isSmallX&&t.isLeft&&(m.width=4),t.isSmallX&&t.isRight&&(m.left=f+e.width-4,m.width=4),t.isSmallY&&t.isTop&&(m.height=4),t.isSmallY&&t.isBottom&&(m.top=p+e.height-4,m.height=4),z_(c,m)?(B_(c,m),c.className=`dv-drop-target-anchor${e.className?` ${e.className}`:""}`,K(c,"dv-drop-target-left",t.isLeft),K(c,"dv-drop-target-right",t.isRight),K(c,"dv-drop-target-top",t.isTop),K(c,"dv-drop-target-bottom",t.isBottom),K(c,"dv-drop-target-anchor-line",t.isSmallX&&(t.isLeft||t.isRight)||t.isSmallY&&(t.isTop||t.isBottom)),K(c,"dv-drop-target-center",e.quadrant==="center"),l.changed&&(K(c,"dv-drop-target-anchor-container-changed",!0),setTimeout(()=>{K(c,"dv-drop-target-anchor-container-changed",!1)},10)),{boundsChanged:!0,targetChanged:l.changed}):{boundsChanged:!1,targetChanged:l.changed}}var Zc=class extends Ea{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get edge(){return!!this.options.edge}get edgeGroup(){return!!this.options.edgeGroup}constructor(e){super(),this.options=e}};function Ul(e){switch(e){case"above":return"top";case"below":return"bottom";case"left":return"left";case"right":return"right";case"within":return"center";default:throw new Error(`invalid direction '${e}'`)}}function j_(e){switch(e){case"top":return"above";case"bottom":return"below";case"left":return"left";case"right":return"right";case"center":return"within";default:throw new Error(`invalid position '${e}'`)}}const $_={value:20,type:"percentage"};var Yr=class vs extends se{get disabled(){return this._disabled}set disabled(t){this._disabled=t}get state(){return this._state}constructor(t,i){super(),this.element=t,this.options=i,this._edge=!1,this._onDrop=new G,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new G,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(this.options.acceptedTargetZones),this.dnd=new qc(this.element,{onDragEnter:()=>{var s,r;(s=(r=this.options).getOverrideTarget)===null||s===void 0||(s=s.call(r))===null||s===void 0||s.getElements()},onDragOver:s=>{var r,n,o,a,l,h,c;if(this._disabled){this.clearOwnOverlay();return}vs.ACTUAL_TARGET=this;const u=(r=(n=this.options).getOverrideTarget)===null||r===void 0?void 0:r.call(n);if(this._acceptedTargetZonesSet.size===0){this.clearOwnOverlay();return}const p=(o=(a=(l=this.options).getOverlayOutline)===null||a===void 0?void 0:a.call(l))!==null&&o!==void 0?o:this.element,f=p.offsetWidth,m=p.offsetHeight;if(f===0||m===0)return;const g=p.getBoundingClientRect(),_=((h=s.clientX)!==null&&h!==void 0?h:0)-g.left,E=((c=s.clientY)!==null&&c!==void 0?c:0)-g.top,C=this.resolvePosition(_,E,f,m,s);if(this.isAlreadyUsed(s)){this.removeDropTarget();return}if(C===null){this.clearOwnOverlay();return}const T=C.position;if(!this.options.canDisplayOverlay(s,T)){this.clearOwnOverlay();return}const x=new Zc({nativeEvent:s,position:T,edge:C.edge,edgeGroup:C.edgeGroup});if(this._onWillShowOverlay.fire(x),x.defaultPrevented){this.clearOwnOverlay();return}if(this.markAsUsed(s),C.edge){this.clearOwnOverlay(),this._state=T,this._edge=!0;return}if(this._edge=!1,!u){if(!this.targetElement){const A=oo();this.targetElement=A.dropzone,this.overlayElement=A.selection,this._state="center",p.classList.add("dv-drop-target"),p.append(this.targetElement)}}this.toggleClasses(T,f,m),this._state=T},onDragLeave:()=>{var s,r;const n=(s=(r=this.options).getOverrideTarget)===null||s===void 0?void 0:s.call(r);if(n){var o;this._state=void 0,this._edge=!1,(o=n.scheduleClear)===null||o===void 0||o.call(n);return}this.removeDropTarget()},onDragEnd:s=>{var r,n;const o=(r=(n=this.options).getOverrideTarget)===null||r===void 0?void 0:r.call(n);o&&vs.ACTUAL_TARGET===this&&this._state&&(s.stopPropagation(),this._onDrop.fire({position:this._state,nativeEvent:s,edge:this._edge})),this.removeDropTarget(),o?.clear()},onDrop:s=>{var r,n;s.preventDefault();const o=this._state,a=this._edge;this.removeDropTarget(),(r=(n=this.options).getOverrideTarget)===null||r===void 0||(r=r.call(n))===null||r===void 0||r.clear(),o&&(s.stopPropagation(),this._onDrop.fire({position:o,nativeEvent:s,edge:a}))}}),this.addDisposables(this._onDrop,this._onWillShowOverlay,this.dnd)}setTargetZones(t){this._acceptedTargetZonesSet=new Set(t)}setOverlayModel(t){this.options.overlayModel=t}dispose(){this.removeDropTarget(),super.dispose()}markAsUsed(t){t[vs.USED_EVENT_ID]=!0}isAlreadyUsed(t){const i=t[vs.USED_EVENT_ID];return typeof i=="boolean"&&i}toggleClasses(t,i,s){var r,n;const o=(r=(n=this.options).getOverrideTarget)===null||r===void 0?void 0:r.call(n);if(o){var a,l,h;Jc({outlineElement:(a=(l=(h=this.options).getOverlayOutline)===null||l===void 0?void 0:l.call(h))!==null&&a!==void 0?a:this.element,targetModel:o,quadrant:t,width:i,height:s,overlayModel:this.options.overlayModel,className:this.options.className});return}this.overlayElement&&Xc(this.overlayElement,t,i,s,this.options.overlayModel)}resolvePosition(t,i,s,r,n){var o,a;const l=(o=(a=this.options).getPositionResolver)===null||o===void 0?void 0:o.call(a);if(l){const c=l.resolve({x:t,y:i,width:s,height:r,zones:this._acceptedTargetZonesSet,event:n});return c?{position:c.position,edge:!!c.edge,edgeGroup:!!c.edgeGroup}:null}const h=this.calculateQuadrant(this._acceptedTargetZonesSet,t,i,s,r);return h?{position:h,edge:!1,edgeGroup:!1}:null}calculateQuadrant(t,i,s,r,n){var o,a;const l=(o=(a=this.options.overlayModel)===null||a===void 0?void 0:a.activationSize)!==null&&o!==void 0?o:$_;return l.type==="percentage"?Qc(t,i,s,r,n,l.value):eu(t,i,s,r,n,l.value)}clearOwnOverlay(){const t=this._state!==void 0;if(this.removeDropTarget(),t){var i,s;(i=(s=this.options).getOverrideTarget)===null||i===void 0||(i=i.call(s))===null||i===void 0||i.clear()}}removeDropTarget(){if(this._state=void 0,this._edge=!1,this.targetElement){var t;(t=this.targetElement.parentElement)===null||t===void 0||t.classList.remove("dv-drop-target"),this.targetElement.remove(),this.targetElement=void 0,this.overlayElement=void 0}}showOverlay(t){var i,s,r,n,o;const a=(i=(s=this.options).getOverrideTarget)===null||i===void 0?void 0:i.call(s),l=(r=(n=(o=this.options).getOverlayOutline)===null||n===void 0?void 0:n.call(o))!==null&&r!==void 0?r:this.element,h=l.offsetWidth,c=l.offsetHeight;if(!a&&!this.targetElement){const u=oo();this.targetElement=u.dropzone,this.overlayElement=u.selection,l.classList.add("dv-drop-target"),l.append(this.targetElement)}this.toggleClasses(t,h,c),this._state=t}clearOverlay(){var t,i;this.removeDropTarget(),(t=(i=this.options).getOverrideTarget)===null||t===void 0||(t=t.call(i))===null||t===void 0||t.clear(),this._state=void 0}};Yr.USED_EVENT_ID="__dockview_droptarget_event_is_used__";function Qc(e,t,i,s,r,n){const o=100*t/s,a=100*i/r;return e.has("left")&&o<n?"left":e.has("right")&&o>100-n?"right":e.has("top")&&a<n?"top":e.has("bottom")&&a>100-n?"bottom":e.has("center")?"center":null}function eu(e,t,i,s,r,n){return e.has("left")&&t<n?"left":e.has("right")&&t>s-n?"right":e.has("top")&&i<n?"top":e.has("bottom")&&i>r-n?"bottom":e.has("center")?"center":null}function W_(e,t,i){var s,r,n;At(t,"dv-dragged"),t.style.top="-9999px",((s=i?.ownerDocument)!==null&&s!==void 0?s:document).body.appendChild(t),e.setDragImage(t,(r=i?.x)!==null&&r!==void 0?r:0,(n=i?.y)!==null&&n!==void 0?n:0),setTimeout(()=>{It(t,"dv-dragged"),t.remove()},0)}var Tr=class _s extends se{static getInstance(){var t;return(t=_s._instance)!==null&&t!==void 0||(_s._instance=new _s),_s._instance}constructor(){super(),this._targets=new Set,this._targetByElement=new Map,this._onDragStart=new G,this.onDragStart=this._onDragStart.event,this._onDragMove=new G,this.onDragMove=this._onDragMove.event,this._onDragEnd=new G,this.onDragEnd=this._onDragEnd.event,this.addDisposables(this._onDragStart,this._onDragMove,this._onDragEnd)}get active(){return this._active}registerTarget(t){return this._targets.add(t),this._targetByElement.set(t.element,t),{dispose:()=>{this._targets.delete(t),this._targetByElement.get(t.element)===t&&this._targetByElement.delete(t.element),this._currentTarget===t&&(this._currentTarget=void 0)}}}beginDrag(t){var i,s,r;this._active&&this.cancel();const{pointerEvent:n,source:o}=t,a=t.getData();this._active={pointerId:n.pointerId,startX:n.clientX,startY:n.clientY,source:o},this._lastPointerEvent=n,this._onDragMoveCallback=t.onDragMove,this._onDragEndCallback=t.onDragEnd,this._dataDisposable=a,this._ghost=t.ghost,this._iframeShield=Es((i=o.ownerDocument)!==null&&i!==void 0?i:document);const l={clientX:n.clientX,clientY:n.clientY,pointerEvent:n};this._onDragStart.fire(l);const h=(s=(r=o.ownerDocument)===null||r===void 0?void 0:r.defaultView)!==null&&s!==void 0?s:globalThis.window;this._moveListener=Z(h,"pointermove",c=>{var u;c.pointerId===((u=this._active)===null||u===void 0?void 0:u.pointerId)&&this._handleMove(c)}),this._upListener=Z(h,"pointerup",c=>{var u;c.pointerId===((u=this._active)===null||u===void 0?void 0:u.pointerId)&&this._handleEnd(c,!0)}),this._cancelListener=Z(h,"pointercancel",c=>{var u;c.pointerId===((u=this._active)===null||u===void 0?void 0:u.pointerId)&&this._handleEnd(c,!1)})}cancel(){var t,i;if(!this._active)return;const s=this._onDragEndCallback,r=this._lastPointerEvent;if((t=this._currentTarget)===null||t===void 0||t.handleDragLeave(),this._teardown(),(i=this._dataDisposable)===null||i===void 0||i.dispose(),this._dataDisposable=void 0,r){const n={clientX:r.clientX,clientY:r.clientY,pointerEvent:r};s?.(n,!1),this._onDragEnd.fire(n)}}_findTargetUnder(t,i){var s,r;const n=((s=(r=this._active)===null||r===void 0?void 0:r.source.ownerDocument)!==null&&s!==void 0?s:document).elementsFromPoint(t,i);for(const o of n){let a=o;for(;a;){const l=this._targetByElement.get(a);if(l)return l;a=a.parentElement}}}_handleMove(t){var i,s;this._lastPointerEvent=t,(i=this._ghost)===null||i===void 0||i.update(t.clientX,t.clientY);const r={clientX:t.clientX,clientY:t.clientY,pointerEvent:t},n=this._findTargetUnder(t.clientX,t.clientY);if(n!==this._currentTarget){var o;(o=this._currentTarget)===null||o===void 0||o.handleDragLeave(),this._currentTarget=n}n&&n.handleDragOver(r),(s=this._onDragMoveCallback)===null||s===void 0||s.call(this,r),this._onDragMove.fire(r)}_handleEnd(t,i){const s={clientX:t.clientX,clientY:t.clientY,pointerEvent:t};if(i&&this._currentTarget)this._currentTarget.handleDrop(s);else{var r;(r=this._currentTarget)===null||r===void 0||r.handleDragLeave()}const n=this._onDragEndCallback,o=this._dataDisposable;this._teardown(),this._dataDisposable=void 0,setTimeout(()=>o?.dispose(),0),n?.(s,i),this._onDragEnd.fire(s)}_teardown(){var t,i,s,r,n;this._currentTarget=void 0,this._active=void 0,this._lastPointerEvent=void 0,this._onDragMoveCallback=void 0,this._onDragEndCallback=void 0,(t=this._ghost)===null||t===void 0||t.dispose(),this._ghost=void 0,(i=this._iframeShield)===null||i===void 0||i.release(),this._iframeShield=void 0,(s=this._moveListener)===null||s===void 0||s.dispose(),(r=this._upListener)===null||r===void 0||r.dispose(),(n=this._cancelListener)===null||n===void 0||n.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}};const H_={value:20,type:"percentage"};var F_=class extends se{get disabled(){return this._disabled}set disabled(e){this._disabled=e,e&&this._removeOverlay()}get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._edge=!1,this._onDrop=new G,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new G,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(t.acceptedTargetZones);const i={element:this.element,handleDragOver:s=>this._onDragOver(s),handleDragLeave:()=>this._onDragLeave(),handleDrop:s=>this._onDropEvent(s)};this.addDisposables(this._onDrop,this._onWillShowOverlay,Tr.getInstance().registerTarget(i))}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this._removeOverlay(),super.dispose()}_onDragOver(e){var t,i,s,r,n;if(this._disabled){this._clearOwnOverlay();return}const o=(t=(i=this.options).getOverrideTarget)===null||t===void 0?void 0:t.call(i);if(this._acceptedTargetZonesSet.size===0){this._clearOwnOverlay();return}const a=(s=(r=(n=this.options).getOverlayOutline)===null||r===void 0?void 0:r.call(n))!==null&&s!==void 0?s:this.element,l=a.offsetWidth,h=a.offsetHeight;if(l===0||h===0)return;const c=a.getBoundingClientRect(),u=e.clientX-c.left,p=e.clientY-c.top,f=this._resolvePosition(u,p,l,h,e.pointerEvent);if(f===null){this._clearOwnOverlay();return}const m=f.position;if(!this.options.canDisplayOverlay(e.pointerEvent,m)){this._clearOwnOverlay();return}const g=new Zc({nativeEvent:e.pointerEvent,position:m,edge:f.edge});if(this._onWillShowOverlay.fire(g),g.defaultPrevented){this._clearOwnOverlay();return}if(f.edge){this._clearOwnOverlay(),this._state=m,this._edge=!0;return}if(this._edge=!1,o){Jc({outlineElement:a,targetModel:o,quadrant:m,width:l,height:h,overlayModel:this.options.overlayModel,className:this.options.className}),this._state=m;return}if(!this._targetElement){const _=oo();this._targetElement=_.dropzone,this._overlayElement=_.selection,this._state="center",this.element.classList.add("dv-drop-target"),this.element.append(this._targetElement)}this._overlayElement&&Xc(this._overlayElement,m,l,h,this.options.overlayModel),this._state=m}_onDragLeave(){var e,t;const i=(e=(t=this.options).getOverrideTarget)===null||e===void 0?void 0:e.call(t);if(i){this._state=void 0,i.clear();return}this._removeOverlay()}_onDropEvent(e){var t,i;const s=this._state,r=this._edge,n=(t=(i=this.options).getOverrideTarget)===null||t===void 0?void 0:t.call(i);this._removeOverlay(),n?.clear(),s&&this._onDrop.fire({position:s,nativeEvent:e.pointerEvent,edge:r})}_resolvePosition(e,t,i,s,r){var n,o;const a=(n=(o=this.options).getPositionResolver)===null||n===void 0?void 0:n.call(o);if(a){const h=a.resolve({x:e,y:t,width:i,height:s,zones:this._acceptedTargetZonesSet,event:r});return h?{position:h.position,edge:!!h.edge}:null}const l=this._calculateQuadrant(e,t,i,s);return l?{position:l,edge:!1}:null}_calculateQuadrant(e,t,i,s){var r,n;const o=(r=(n=this.options.overlayModel)===null||n===void 0?void 0:n.activationSize)!==null&&r!==void 0?r:H_;return o.type==="percentage"?Qc(this._acceptedTargetZonesSet,e,t,i,s,o.value):eu(this._acceptedTargetZonesSet,e,t,i,s,o.value)}_clearOwnOverlay(){const e=this._state!==void 0;if(this._removeOverlay(),e){var t,i;(t=(i=this.options).getOverrideTarget)===null||t===void 0||(t=t.call(i))===null||t===void 0||t.clear()}}_removeOverlay(){if(this._edge=!1,this._targetElement){var e;this._state=void 0,(e=this._targetElement.parentElement)===null||e===void 0||e.classList.remove("dv-drop-target"),this._targetElement.remove(),this._targetElement=void 0,this._overlayElement=void 0}else this._state=void 0}};const V_=5,U_=250,K_=8;var q_=class extends se{constructor(e,t){var i;super(),this.element=e,this.options=t,this._disabled=!1,this._armed=!1,this._startX=0,this._startY=0,this._touchOnly=(i=t.touchOnly)!==null&&i!==void 0?i:!0,this.addDisposables(Z(this.element,"pointerdown",s=>{this._onPointerDown(s)}))}setDisabled(e){this._disabled=e,e&&this._cancelPending()}setTouchOnly(e){this._touchOnly!==e&&(this._touchOnly=e,e&&this._cancelPending())}_shouldHandle(e){var t,i;return!(this._disabled||this._touchOnly&&e.pointerType!=="touch"&&e.pointerType!=="pen"||!((t=(i=this.options).isCancelled)===null||t===void 0)&&t.call(i,e))}_onPointerDown(e){var t,i,s,r,n;if(!this._shouldHandle(e))return;this._cancelPending(),this._pendingPointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY,this._startEvent=e;const o=e.pointerType==="touch"||e.pointerType==="pen",a=this.options.touchInitiationDelay,l=(t=typeof a=="function"?a():a)!==null&&t!==void 0?t:U_;this._armed=!o||l<=0,o&&l>0&&Number.isFinite(l)&&(this._armTimer=setTimeout(()=>{this._armTimer=void 0,this._armed=!0},l));const h=(i=this.options.threshold)!==null&&i!==void 0?i:V_,c=this.options.pressTolerance,u=(s=typeof c=="function"?c():c)!==null&&s!==void 0?s:K_,p=(r=(n=this.element.ownerDocument)===null||n===void 0?void 0:n.defaultView)!==null&&r!==void 0?r:globalThis.window;this._pendingMoveListener=Z(p,"pointermove",f=>{if(f.pointerId!==this._pendingPointerId)return;const m=f.clientX-this._startX,g=f.clientY-this._startY,_=Math.hypot(m,g);if(this._armed){_>=h&&this._beginDrag(f);return}_>u&&this._beginDrag(f)}),this._pendingUpListener=Z(p,"pointerup",f=>{f.pointerId===this._pendingPointerId&&this._cancelPending()}),this._pendingCancelListener=Z(p,"pointercancel",f=>{f.pointerId===this._pendingPointerId&&this._cancelPending()})}cancelPending(){this._cancelPending()}_cancelPending(){var e,t,i;this._pendingPointerId=void 0,this._armTimer!==void 0&&(clearTimeout(this._armTimer),this._armTimer=void 0),this._armed=!1,(e=this._pendingMoveListener)===null||e===void 0||e.dispose(),(t=this._pendingUpListener)===null||t===void 0||t.dispose(),(i=this._pendingCancelListener)===null||i===void 0||i.dispose(),this._pendingMoveListener=void 0,this._pendingUpListener=void 0,this._pendingCancelListener=void 0,this._startEvent=void 0}_beginDrag(e){var t,i,s,r,n;const o=(t=this._startEvent)!==null&&t!==void 0?t:e;this._cancelPending(),(i=(s=this.options).onDragStart)===null||i===void 0||i.call(s,o);const a=(r=(n=this.options).createGhost)===null||r===void 0?void 0:r.call(n,o);Tr.getInstance().beginDrag({pointerEvent:e,source:this.element,getData:()=>this.options.getData(o),ghost:a,onDragMove:this.options.onDragMove,onDragEnd:this.options.onDragEnd})}dispose(){this._cancelPending(),super.dispose()}},Y_=class{constructor(e){var t,i,s,r,n;this._disposed=!1,this.element=e.element,this.offsetX=(t=e.offsetX)!==null&&t!==void 0?t:0,this.offsetY=(i=e.offsetY)!==null&&i!==void 0?i:0,this.element.style.position="fixed",this.element.style.left="0px",this.element.style.top="0px",this.element.style.pointerEvents="none",this.element.style.zIndex="99999",this.element.style.opacity=String((s=e.opacity)!==null&&s!==void 0?s:.8),this.element.style.willChange="transform",this.element.style.transform=`translate3d(${e.initialX-this.offsetX}px, ${e.initialY-this.offsetY}px, 0)`,((r=(n=e.owner)===null||n===void 0?void 0:n.ownerDocument)!==null&&r!==void 0?r:document).body.appendChild(this.element)}update(e,t){this._disposed||(this.element.style.transform=`translate3d(${e-this.offsetX}px, ${t-this.offsetY}px, 0)`)}dispose(){this._disposed||(this._disposed=!0,this.element.remove())}},X_=class extends se{constructor(e,t){super(),this.el=e,this.opts=t,this._dataDisposable=new Me,this._pointerEventsDisposable=new Me,this._disabled=!!t.disabled,this.addDisposables(this._dataDisposable,this._pointerEventsDisposable,Z(this.el,"dragstart",i=>{var s,r,n,o,a,l,h;if(i.defaultPrevented||this._disabled||!((s=(r=this.opts).isCancelled)===null||s===void 0)&&s.call(r,i)){i.preventDefault();return}const c=Es((n=this.el.ownerDocument)!==null&&n!==void 0?n:document);this._pointerEventsDisposable.value={dispose:()=>c.release()},this.el.classList.add("dv-dragged"),setTimeout(()=>this.el.classList.remove("dv-dragged"),0),this._dataDisposable.value=this.opts.getData(i);const u=(o=(a=this.opts).createGhost)===null||o===void 0?void 0:o.call(a,i);if(u&&i.dataTransfer){var p,f,m;if(W_(i.dataTransfer,u.element,{x:(p=u.offsetX)!==null&&p!==void 0?p:0,y:(f=u.offsetY)!==null&&f!==void 0?f:0,ownerDocument:(m=this.el.ownerDocument)!==null&&m!==void 0?m:void 0}),u.dispose){const g=u.dispose;setTimeout(()=>g(),0)}}i.dataTransfer&&(i.dataTransfer.effectAllowed="move",i.dataTransfer.items.length===0&&i.dataTransfer.setData("text/plain","")),(l=(h=this.opts).onDragStart)===null||l===void 0||l.call(h,i)}),Z(this.el,"dragend",i=>{var s,r;this._pointerEventsDisposable.dispose(),setTimeout(()=>this._dataDisposable.dispose(),0),(s=(r=this.opts).onDragEnd)===null||s===void 0||s.call(r,i)}))}setDisabled(e){this._disabled=e}setTouchOnly(e){}cancelPending(){}},J_=class{constructor(){this.kind="html5"}createDropTarget(e,t){return new Yr(e,t)}createDragSource(e,t){return new X_(e,t)}},Z_=class{constructor(){this.kind="pointer"}createDropTarget(e,t){return new F_(e,t)}createDragSource(e,t){const i=t.createGhost?r=>{const n=t.createGhost(r);if(!n)return;const o=new Y_({element:n.element,initialX:r.clientX,initialY:r.clientY,offsetX:n.offsetX,offsetY:n.offsetY,owner:e});if(n.dispose){const a=o.dispose.bind(o),l=n.dispose;o.dispose=()=>{a(),l()}}return o}:void 0,s=new q_(e,{getData:t.getData,isCancelled:t.isCancelled,onDragStart:t.onDragStart,onDragEnd:t.onDragEnd?r=>t.onDragEnd(r.pointerEvent):void 0,createGhost:i,touchOnly:t.touchOnly,touchInitiationDelay:t.touchInitiationDelay,pressTolerance:t.pressTolerance,threshold:t.threshold});return t.disabled&&s.setDisabled(!0),s}};const xi=new J_,ti=new Z_,ao=Object.keys({disableAutoResizing:void 0,disableDnd:void 0,className:void 0});var Q_=class extends Lc{constructor(e,t,i,s){super(),this.nativeEvent=e,this.position=t,this.getData=i,this.panel=s}},tu=class extends Ea{constructor(){super()}},iu=class extends se{get isFocused(){return this._isFocused}get isActive(){return this._isActive}get isVisible(){return this._isVisible}get width(){return this._width}get height(){return this._height}constructor(e,t){super(),this.id=e,this.component=t,this._isFocused=!1,this._isActive=!1,this._isVisible=!0,this._width=0,this._height=0,this._parameters={},this.panelUpdatesDisposable=new Me,this._onDidDimensionChange=new G,this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new G,this.onDidFocusChange=this._onDidChangeFocus.event,this._onWillFocus=new G,this.onWillFocus=this._onWillFocus.event,this._onDidVisibilityChange=new G,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onWillVisibilityChange=new G,this.onWillVisibilityChange=this._onWillVisibilityChange.event,this._onDidActiveChange=new G,this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new G,this.onActiveChange=this._onActiveChange.event,this._onDidParametersChange=new G,this.onDidParametersChange=this._onDidParametersChange.event,this.addDisposables(this.onDidFocusChange(i=>{this._isFocused=i.isFocused}),this.onDidActiveChange(i=>{this._isActive=i.isActive}),this.onDidVisibilityChange(i=>{this._isVisible=i.isVisible}),this.onDidDimensionsChange(i=>{this._width=i.width,this._height=i.height}),this.panelUpdatesDisposable,this._onDidDimensionChange,this._onDidChangeFocus,this._onDidVisibilityChange,this._onDidActiveChange,this._onWillFocus,this._onActiveChange,this._onWillFocus,this._onWillVisibilityChange,this._onDidParametersChange)}getParameters(){return this._parameters}initialize(e){this.panelUpdatesDisposable.value=this._onDidParametersChange.event(t=>{this._parameters=t,e.update({params:t})})}setVisible(e){this._onWillVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}updateParameters(e){this._onDidParametersChange.fire(e)}},su=class extends iu{constructor(e,t){super(e,t),this._onDidConstraintsChangeInternal=new G,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new G({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new G,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}},eb=class extends su{set pane(e){this._pane=e}constructor(e,t){super(e,t),this._onDidExpansionChange=new G({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new G({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new G({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}setExpanded(e){var t;(t=this._pane)===null||t===void 0||t.setExpanded(e)}get isExpanded(){var e;return!!(!((e=this._pane)===null||e===void 0)&&e.isExpanded())}},Ra=class extends se{get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){var e;return(e=this._params)===null||e===void 0?void 0:e.params}constructor(e,t,i){super(),this.id=e,this.component=t,this.api=i,this._height=0,this._width=0,this._element=document.createElement("div"),this._element.tabIndex=-1,this._element.style.outline="none",this._element.style.height="100%",this._element.style.width="100%",this._element.style.overflow="hidden";const s=Mc(this._element);this.addDisposables(this.api,s.onDidFocus(()=>{this.api._onDidChangeFocus.fire({isFocused:!0})}),s.onDidBlur(()=>{this.api._onDidChangeFocus.fire({isFocused:!1})}),s)}focus(){const e=new tu;this.api._onWillFocus.fire(e),!e.defaultPrevented&&this._element.focus()}layout(e,t){this._width=e,this._height=t,this.api._onDidDimensionChange.fire({width:e,height:t}),this.part&&this._params&&this.part.update(this._params.params)}init(e){this._params=e,this.part=this.getComponent()}update(e){var t,i;this._params=re(re({},this._params),{},{params:re(re({},(t=this._params)===null||t===void 0?void 0:t.params),e.params)});for(const s of Object.keys(e.params))e.params[s]===void 0&&delete this._params.params[s];(i=this.part)===null||i===void 0||i.update({params:this._params.params})}toJSON(){var e,t;const i=(e=(t=this._params)===null||t===void 0?void 0:t.params)!==null&&e!==void 0?e:{};return{id:this.id,component:this.component,params:Object.keys(i).length>0?i:void 0}}dispose(){var e;this.api.dispose(),(e=this.part)===null||e===void 0||e.dispose(),super.dispose()}},tb=class extends Ra{set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){return this.headerSize+(this.isExpanded()?this._minimumBodySize:0)}get maximumSize(){return this.headerSize+(this.isExpanded()?this._maximumBodySize:0)}get size(){return this._size}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get minimumBodySize(){return this._minimumBodySize}set minimumBodySize(e){this._minimumBodySize=typeof e=="number"?e:0}get maximumBodySize(){return this._maximumBodySize}set maximumBodySize(e){this._maximumBodySize=typeof e=="number"?e:Number.POSITIVE_INFINITY}get headerVisible(){return this._headerVisible}set headerVisible(e){this._headerVisible=e,this.header.style.display=e?"":"none"}constructor(e){super(e.id,e.component,new eb(e.id,e.component)),this._onDidChangeExpansionState=new G({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._orthogonalSize=0,this._size=0,this._isExpanded=!1,this.api.pane=this,this.api.initialize(this),this.headerSize=e.headerSize,this.headerComponent=e.headerComponent,this._minimumBodySize=e.minimumBodySize,this._maximumBodySize=e.maximumBodySize,this._isExpanded=e.isExpanded,this._headerVisible=e.isHeaderVisible,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=e.orientation,this.element.classList.add("dv-pane"),this.addDisposables(this.api.onWillVisibilityChange(t=>{const{isVisible:i}=t,{accessor:s}=this._params;s.setVisible(this,i)}),this.api.onDidSizeChange(t=>{this._onDidChange.fire({size:t.size})}),Z(this.element,"mouseenter",t=>{this.api._onMouseEnter.fire(t)}),Z(this.element,"mouseleave",t=>{this.api._onMouseLeave.fire(t)})),this.addDisposables(this._onDidChangeExpansionState,this.onDidChangeExpansionState(t=>{this.api._onDidExpansionChange.fire({isExpanded:t})}),this.api.onDidFocusChange(t=>{this.header&&(t.isFocused?At(this.header,"focused"):It(this.header,"focused"))})),this.renderOnce()}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}isExpanded(){return this._isExpanded}setExpanded(e){var t;this._isExpanded!==e&&(this._isExpanded=e,e?(this.animationTimer&&clearTimeout(this.animationTimer),this.body&&this.element.appendChild(this.body)):(this._expandedSize=this._size,this.animationTimer=setTimeout(()=>{var i;(i=this.body)===null||i===void 0||i.remove()},200)),this._onDidChange.fire(e?{size:(t=this._expandedSize)!==null&&t!==void 0?t:this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(e,t){this._size=e,this._orthogonalSize=t;const[i,s]=this.orientation==="HORIZONTAL"?[e,t]:[t,e];super.layout(i,s)}init(e){var t,i;super.init(e),typeof e.minimumBodySize=="number"&&(this.minimumBodySize=e.minimumBodySize),typeof e.maximumBodySize=="number"&&(this.maximumBodySize=e.maximumBodySize),this.bodyPart=this.getBodyComponent(),this.headerPart=this.getHeaderComponent(),this.bodyPart.init(re(re({},e),{},{api:this.api})),this.headerPart.init(re(re({},e),{},{api:this.api})),(t=this.body)===null||t===void 0||t.append(this.bodyPart.element),(i=this.header)===null||i===void 0||i.append(this.headerPart.element),typeof e.isExpanded=="boolean"&&this.setExpanded(e.isExpanded)}toJSON(){const e=this._params;return re(re({},super.toJSON()),{},{headerComponent:this.headerComponent,title:e.title})}renderOnce(){this.header=document.createElement("div"),this.header.tabIndex=0,this.header.className="dv-pane-header",this.header.style.height=`${this.headerSize}px`,this.header.style.lineHeight=`${this.headerSize}px`,this.header.style.minHeight=`${this.headerSize}px`,this.header.style.maxHeight=`${this.headerSize}px`,this.element.appendChild(this.header),this.body=document.createElement("div"),this.body.className="dv-pane-body",this.element.appendChild(this.body)}getComponent(){return{update:e=>{var t,i;(t=this.bodyPart)===null||t===void 0||t.update({params:e}),(i=this.headerPart)===null||i===void 0||i.update({params:e})},dispose:()=>{var e,t;(e=this.bodyPart)===null||e===void 0||e.dispose(),(t=this.headerPart)===null||t===void 0||t.dispose()}}}},ib=class extends tb{constructor(e){super({id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,isHeaderVisible:!0,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this._onDidDrop=new G,this.onDidDrop=this._onDidDrop.event,this._onUnhandledDragOver=new G,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this.accessor=e.accessor,this.addDisposables(this._onDidDrop,this._onUnhandledDragOver),e.disableDnd||this.initDragFeatures()}initDragFeatures(){if(!this.header)return;const e=this.id,t=this.accessor.id;this.header.draggable=!0;const i={getData:()=>(ei.getInstance().setData([new Cs(t,e)],Cs.prototype),{dispose:()=>{ei.getInstance().clearData(Cs.prototype)}})};this.html5DragSource=xi.createDragSource(this.header,i),this.pointerDragSource=ti.createDragSource(this.header,i);const r={acceptedTargetZones:["top","bottom"],overlayModel:{activationSize:{type:"percentage",value:50}},canDisplayOverlay:(n,o)=>{const a=ls();if(a&&a.paneId!==this.id&&a.viewId===this.accessor.id)return!0;const l=new Q_(n,o,ls,this);return this._onUnhandledDragOver.fire(l),l.isAccepted}};this.target=xi.createDropTarget(this.element,r),this.pointerTarget=ti.createDropTarget(this.element,r),this.addDisposables(this._onDidDrop,this.html5DragSource,this.pointerDragSource,this.target,this.pointerTarget,this.target.onDrop(n=>{this.onDrop(n)}),this.pointerTarget.onDrop(n=>{this.onDrop(n)}))}onDrop(e){const t=ls();if(t?.viewId!==this.accessor.id){this._onDidDrop.fire(re(re({},e),{},{panel:this,api:new Is(this.accessor),getData:ls}));return}const i=this._params.containerApi,s=t.paneId,r=i.getPanel(s);if(!r){this._onDidDrop.fire(re(re({},e),{},{panel:this,getData:ls,api:new Is(this.accessor)}));return}const n=i.panels,o=n.indexOf(r);let a=i.panels.indexOf(this);(e.position==="left"||e.position==="top")&&(a=Math.max(0,a-1)),(e.position==="right"||e.position==="bottom")&&(o>a&&a++,a=Math.min(n.length-1,a)),i.movePanel(o,a)}};let sb=0;const rb=()=>`dv-tabpanel-${sb++}`;var nb=class extends se{get element(){return this._element}constructor(e,t){var i,s,r,n,o,a,l;super(),this.accessor=e,this.group=t,this.disposable=new Me,this._onDidFocus=new G,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new G,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-content-container",this._element.tabIndex=-1,this._element.id=rb(),this._element.setAttribute("role","tabpanel"),this.addDisposables(this._onDidFocus,this._onDidBlur);const h=()=>{var u;return(u=t.dropTargetContainer)===null||u===void 0?void 0:u.model},c=(u,p)=>this.group.canDisplayContentOverlay(u,p);this.dropTarget=new Yr(this.element,{getOverlayOutline:()=>{var u;return((u=e.options.theme)===null||u===void 0?void 0:u.dndPanelOverlay)==="group"?this.element.parentElement:null},className:"dv-drop-target-content",acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:c,getOverrideTarget:h,overlayModel:(i=(s=this.accessor).resolveDropOverlayModel)===null||i===void 0?void 0:i.call(s,"content"),getPositionResolver:()=>{var u;return(u=e.getDropPositionResolver)===null||u===void 0?void 0:u.call(e)}}),this.pointerDropTarget=ti.createDropTarget(this.element,{acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:c,getOverlayOutline:()=>{var u;return((u=e.options.theme)===null||u===void 0?void 0:u.dndPanelOverlay)==="group"?this.element.parentElement:null},className:"dv-drop-target-content",getOverrideTarget:h,overlayModel:(r=(n=this.accessor).resolveDropOverlayModel)===null||r===void 0?void 0:r.call(n,"content"),getPositionResolver:()=>{var u;return(u=e.getDropPositionResolver)===null||u===void 0?void 0:u.call(e)}}),this.addDisposables(this.dropTarget,this.pointerDropTarget,(o=(a=(l=this.accessor).onDidOptionsChange)===null||a===void 0?void 0:a.call(l,()=>{var u,p,f;const m=(u=(p=(f=this.accessor).resolveDropOverlayModel)===null||p===void 0?void 0:p.call(f,"content"))!==null&&u!==void 0?u:{};this.dropTarget.setOverlayModel(m),this.pointerDropTarget.setOverlayModel(m)}))!==null&&o!==void 0?o:Se.NONE)}show(){this.element.style.display=""}hide(){this.element.style.display="none"}setLabelledBy(e){e?this._element.setAttribute("aria-labelledby",e):this._element.removeAttribute("aria-labelledby")}renderPanel(e,t){var i,s;const r=((i=t?.asActive)!==null&&i!==void 0?i:!0)||this.panel&&this.group.isPanelActive(this.panel);if(((s=this.panel)===null||s===void 0?void 0:s.view.content.element.parentElement)===this._element){var n,o;this.panel.view.content.element.remove(),(n=(o=this.panel.view.content).onHide)===null||n===void 0||n.call(o)}this.panel=e;let a;switch(e.api.renderer){case"onlyWhenVisible":if(this.group.renderContainer.detatch(e),this.panel&&r){var l,h;this._element.appendChild(this.panel.view.content.element),(l=(h=this.panel.view.content).onShow)===null||l===void 0||l.call(h)}a=this._element;break;case"always":e.view.content.element.parentElement===this._element&&e.view.content.element.remove(),a=this.group.renderContainer.attach({panel:e,referenceContainer:this});break;default:throw new Error(`dockview: invalid renderer type '${e.api.renderer}'`)}if(r){const c=Mc(a);this.focusTracker=c;const u=new se;u.addDisposables(c,c.onDidFocus(()=>this._onDidFocus.fire()),c.onDidBlur(()=>this._onDidBlur.fire())),this.disposable.value=u}}openPanel(e){this.panel!==e&&this.renderPanel(e)}layout(e,t){}closePanel(){if(this.panel&&this.panel.api.renderer==="onlyWhenVisible"){var e,t;this.panel.view.content.element.remove(),(e=(t=this.panel.view.content).onHide)===null||e===void 0||e.call(t)}this.panel=void 0}dispose(){this.disposable.dispose(),super.dispose()}refreshFocusState(){var e;!((e=this.focusTracker)===null||e===void 0)&&e.refreshState&&this.focusTracker.refreshState()}};const Xr=e=>{const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttributeNS(null,"height",e.height),t.setAttributeNS(null,"width",e.width),t.setAttributeNS(null,"viewBox",e.viewbox),t.setAttributeNS(null,"aria-hidden","false"),t.setAttributeNS(null,"focusable","false"),t.classList.add("dv-svg");const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttributeNS(null,"d",e.path),t.appendChild(i),t},ob=()=>Xr({width:"11",height:"11",viewbox:"0 0 28 28",path:"M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z"}),ru=()=>Xr({width:"11",height:"11",viewbox:"0 0 24 24",path:"M16 9V4h1c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3z"}),ab=()=>Xr({width:"11",height:"11",viewbox:"0 0 24 15",path:"M12 14.15L0 2.15L2.15 0L12 9.9L21.85 0.0499992L24 2.2L12 14.15Z"}),nu=()=>Xr({width:"11",height:"11",viewbox:"0 0 15 25",path:"M2.15 24.1L0 21.95L9.9 12.05L0 2.15L2.15 0L14.2 12.05L2.15 24.1Z"}),lb=500,hb=8;var La=class extends se{constructor(e,t){super(),this.element=e,this.options=t,this._startX=0,this._startY=0,this.addDisposables(Z(this.element,"pointerdown",i=>{this._onPointerDown(i)}))}_onPointerDown(e){var t,i,s,r,n;if((!((t=this.options.touchOnly)!==null&&t!==void 0)||t)&&e.pointerType!=="touch"&&e.pointerType!=="pen")return;this._cancelPending(),this._pointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY;const o=(i=this.options.delay)!==null&&i!==void 0?i:lb,a=(s=this.options.tolerance)!==null&&s!==void 0?s:hb,l=(r=(n=this.element.ownerDocument)===null||n===void 0?void 0:n.defaultView)!==null&&r!==void 0?r:globalThis.window;this._timer=setTimeout(()=>{this._timer=void 0,this._cancelPending(),this._installContextMenuGuard(l),this._installClickGuard(l),this.options.onLongPress(e)},o),this._moveListener=Z(l,"pointermove",h=>{if(h.pointerId!==this._pointerId)return;const c=h.clientX-this._startX,u=h.clientY-this._startY;Math.hypot(c,u)>a&&this._cancelPending()}),this._upListener=Z(l,"pointerup",h=>{h.pointerId===this._pointerId&&this._cancelPending()}),this._cancelListener=Z(l,"pointercancel",h=>{h.pointerId===this._pointerId&&this._cancelPending()})}_installContextMenuGuard(e){let t;const i=setTimeout(()=>t?.dispose(),500);t=Z(e,"contextmenu",s=>{s.preventDefault(),clearTimeout(i),t?.dispose()},{capture:!0})}_installClickGuard(e){let t;const i=setTimeout(()=>t?.dispose(),500);t=Z(e,"click",s=>{const r=s.target;r&&this.element.contains(r)&&(s.preventDefault(),s.stopPropagation()),clearTimeout(i),t?.dispose()},{capture:!0})}_cancelPending(){var e,t,i;this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0),this._pointerId=void 0,(e=this._moveListener)===null||e===void 0||e.dispose(),(t=this._upListener)===null||t===void 0||t.dispose(),(i=this._cancelListener)===null||i===void 0||i.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}dispose(){this._cancelPending(),super.dispose()}};function Tt(e){if(e.disableDnd)return{html5:!1,pointer:!1,pointerHandlesMouse:!1};switch(e.dndStrategy){case"pointer":return{html5:!1,pointer:!0,pointerHandlesMouse:!0};case"html5":return{html5:!0,pointer:!1,pointerHandlesMouse:!1};default:return db()?{html5:!1,pointer:!0,pointerHandlesMouse:!0}:{html5:!0,pointer:!0,pointerHandlesMouse:!1}}}function db(){if(globalThis.window===void 0||!globalThis.matchMedia)return!1;const e=globalThis.matchMedia("(pointer: coarse)").matches,t=globalThis.matchMedia("(pointer: fine)").matches;return e&&!t}let cb=0;const ub=()=>`dv-tab-${cb++}`;var pb=class extends se{get element(){return this._element}constructor(e,t,i){var s,r,n,o,a,l,h,c;super(),this.panel=e,this.accessor=t,this.group=i,this.content=void 0,this.panelTransfer=ei.getInstance(),this._direction="horizontal",this._pinIndicator=void 0,this._onPointDown=new G,this.onPointerDown=this._onPointDown.event,this._onTabClick=new G,this.onTabClick=this._onTabClick.event,this._onDropped=new G,this.onDrop=this._onDropped.event,this._onDragStart=new G,this.onDragStart=this._onDragStart.event,this._onDragEnd=new G,this.onDragEnd=this._onDragEnd.event;const u=Tt(this.accessor.options);this._element=document.createElement("div"),this._element.className="dv-tab",this._element.tabIndex=-1,this._element.draggable=u.html5,this._element.id=ub(),this._element.setAttribute("role","tab"),this._element.setAttribute("aria-selected","false"),this._element.setAttribute("aria-label",(s=this.panel.title)!==null&&s!==void 0?s:this.panel.id),this._element.dataset.tabPanelId=this.panel.id;const p=(r=this.group)===null||r===void 0||(r=r.model)===null||r===void 0?void 0:r.contentContainerId;p&&this._element.setAttribute("aria-controls",p),K(this.element,"dv-inactive-tab",!0),this._updatePinnedClasses();const f=(g,_)=>{if(this.group.locked)return!1;const E=Te();if(this.accessor.id===E?.viewId){var C;return((C=this.accessor.options.theme)===null||C===void 0?void 0:C.tabAnimation)!=="smooth"}return this.group.model.canDisplayOverlay(g,_,"tab")};this.dropTarget=xi.createDropTarget(this._element,{acceptedTargetZones:["left","right"],overlayModel:this._buildOverlayModel(),canDisplayOverlay:f,getOverrideTarget:()=>{var g;return(g=i.model.dropTargetContainer)===null||g===void 0?void 0:g.model}}),this.pointerDropTarget=ti.createDropTarget(this._element,{acceptedTargetZones:["left","right"],overlayModel:this._buildOverlayModel(),canDisplayOverlay:f,getOverrideTarget:()=>{var g;return(g=i.model.dropTargetContainer)===null||g===void 0?void 0:g.model}});const m={getData:()=>(this.panelTransfer.setData([new St(this.accessor.id,this.group.id,this.panel.id)],St.prototype),{dispose:()=>{this.panelTransfer.clearData(St.prototype)}}),createGhost:()=>({element:this._buildGhostElement(),offsetX:30,offsetY:-10}),onDragStart:g=>{var _;this._onDragStart.fire(g),!(g instanceof PointerEvent)&&((_=this.accessor.options.theme)===null||_===void 0?void 0:_.tabAnimation)==="smooth"&&requestAnimationFrame(()=>{K(this.element,"dv-tab--dragging",!0)})},onDragEnd:g=>{this._onDragEnd.fire(g)}};this.html5DragSource=xi.createDragSource(this._element,re(re({},m),{},{disabled:!u.html5})),this.pointerDragSource=ti.createDragSource(this._element,re(re({},m),{},{disabled:!u.pointer,touchOnly:!u.pointerHandlesMouse,isCancelled:()=>!Tt(this.accessor.options).pointer})),this.onWillShowOverlay=xt.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this._onPointDown,this._onTabClick,this._onDropped,this._onDragStart,this._onDragEnd,this.accessor.onDidOptionsChange(()=>{const g=this._buildOverlayModel();this.dropTarget.setOverlayModel(g),this.pointerDropTarget.setOverlayModel(g),this._updatePinnedClasses()}),(n=(o=this.panel.api)===null||o===void 0||(a=o.onDidChangePinned)===null||a===void 0?void 0:a.call(o,()=>{this._updatePinnedClasses()}))!==null&&n!==void 0?n:{dispose:()=>{}},(l=(h=this.panel.api)===null||h===void 0||(c=h.onDidTitleChange)===null||c===void 0?void 0:c.call(h,g=>{var _;this._element.setAttribute("aria-label",(_=g.title)!==null&&_!==void 0?_:this.panel.id)}))!==null&&l!==void 0?l:{dispose:()=>{}},Z(this._element,"dragend",()=>{K(this.element,"dv-tab--dragging",!1)}),this.html5DragSource,Z(this._element,"pointerdown",g=>{this._onPointDown.fire(g)}),Z(this._element,"click",g=>{this._onTabClick.fire(g)}),Z(this._element,"contextmenu",g=>{var _;(_=this.accessor.contextMenuService)===null||_===void 0||_.show(this.panel,this.group,g)}),new La(this._element,{onLongPress:g=>{var _;this.pointerDragSource.cancelPending(),(_=this.accessor.contextMenuService)===null||_===void 0||_.show(this.panel,this.group,g)}}),this.dropTarget.onDrop(g=>{this._onDropped.fire(g)}),this.pointerDropTarget.onDrop(g=>{this._onDropped.fire(g)}),this.dropTarget,this.pointerDropTarget,this.pointerDragSource)}_updatePinnedClasses(){var e,t,i,s;const r=(e=(t=this.panel.api)===null||t===void 0?void 0:t.isPinned)!==null&&e!==void 0?e:!1,n=r&&((i=this.accessor.options.pinnedTabs)===null||i===void 0?void 0:i.compact)===!0;K(this.element,"dv-tab--pinned",r),K(this.element,"dv-tab--pinned-compact",n);const o=r&&!(!((s=this.panel.api)===null||s===void 0)&&s.tabComponent);if(o&&!this._pinIndicator){const a=document.createElement("div");a.className="dv-tab-pin",a.appendChild(ru()),this._element.insertBefore(a,this._element.firstChild),this._pinIndicator=a}else!o&&this._pinIndicator&&(this._pinIndicator.remove(),this._pinIndicator=void 0)}setActive(e){K(this.element,"dv-active-tab",e),K(this.element,"dv-inactive-tab",!e),this._element.setAttribute("aria-selected",e?"true":"false"),this._element.tabIndex=e?0:-1}setContent(e){this.content&&this.content.element.remove(),this.content=e,this._element.appendChild(this.content.element)}_buildOverlayModel(){var e,t,i;const s=(e=(t=this.accessor).resolveDropOverlayModel)===null||e===void 0?void 0:e.call(t,"tab",this.group);if(s)return s;const r=((i=this.accessor.options.theme)===null||i===void 0?void 0:i.dndTabIndicator)==="line"?Number.POSITIVE_INFINITY:0;return{activationSize:{value:50,type:"percentage"},smallWidthBoundary:r,smallHeightBoundary:r}}setDirection(e){this._direction=e;const t=e==="vertical"?["top","bottom"]:["left","right"];this.dropTarget.setTargetZones(t),this.pointerDropTarget.setTargetZones(t)}updateDragAndDropState(){const e=Tt(this.accessor.options);this._element.draggable=e.html5,this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}_buildGhostElement(){const e=getComputedStyle(this.element),t=this.element.cloneNode(!0),i=this._direction==="vertical",s=new Set(["writing-mode","inline-size","block-size","min-inline-size","min-block-size","max-inline-size","max-block-size","margin-inline","margin-inline-start","margin-inline-end","margin-block","margin-block-start","margin-block-end","padding-inline","padding-inline-start","padding-inline-end","padding-block","padding-block-start","padding-block-end"]);return Array.from(e).forEach(r=>{i&&s.has(r)||t.style.setProperty(r,e.getPropertyValue(r),e.getPropertyPriority(r))}),i&&(t.style.setProperty("writing-mode","horizontal-tb"),t.style.setProperty("width",e.height),t.style.setProperty("height",e.width)),t.style.position="absolute",t.classList.add("dv-tab-ghost-drag"),t}},As=class{get kind(){return this.options.kind}get nativeEvent(){return this.event.nativeEvent}get position(){return this.event.position}get edge(){return this.event.edge}get edgeGroup(){return this.event.edgeGroup}get defaultPrevented(){return this.event.defaultPrevented}get panel(){return this.options.panel}get api(){return this.options.api}get group(){return this.options.group}preventDefault(){this.event.preventDefault()}getData(){return this.options.getData()}constructor(e,t){this.event=e,this.options=t}},ou=class extends se{get group(){return this.groupAccessor()}constructor(e){var t,i;super(),this.panelTransfer=ei.getInstance(),this._onDragStart=new G,this.onDragStart=this._onDragStart.event,this._element=e.element,this.accessor=e.accessor;const s=e.group;this.groupAccessor=typeof s=="function"?s:()=>s,this.isFloatingMoveHandle=(t=e.isFloatingMoveHandle)!==null&&t!==void 0?t:(()=>!0);const r=Tt(this.accessor.options);this._element.draggable=r.html5,K(this._element,"dv-draggable",r.html5||r.pointer),this.addDisposables(this._onDragStart);const n=()=>{const p=document.createElement("div"),f=globalThis.getComputedStyle(this._element),m=f.getPropertyValue("--dv-activegroup-visiblepanel-tab-background-color"),g=f.getPropertyValue("--dv-activegroup-visiblepanel-tab-color");return p.style.backgroundColor=m,p.style.color=g,p.style.padding="2px 8px",p.style.height="24px",p.style.fontSize="11px",p.style.lineHeight="20px",p.style.borderRadius="12px",p.style.whiteSpace="nowrap",p.style.boxSizing="border-box",p.style.display="inline-block",p.textContent=`Multiple Panels (${this.group.size})`,p},a={getData:()=>(this.panelTransfer.setData([new St(this.accessor.id,this.group.id,null)],St.prototype),{dispose:()=>{this.panelTransfer.clearData(St.prototype)}}),createGhost:()=>{var p,f;const m=(p=(f=this.accessor).buildGroupDragGhost)===null||p===void 0?void 0:p.call(f,this.group);return m||{element:n(),offsetX:30,offsetY:-10}},onDragStart:p=>{this._onDragStart.fire(p)}};this.html5DragSource=xi.createDragSource(this._element,re(re({},a),{},{disabled:!r.html5,isCancelled:p=>!!(this.group.api.location.type==="floating"&&this.isFloatingMoveHandle()&&!p.shiftKey||this.group.api.location.type==="edge"&&this.group.size===0)}));const l=()=>{var p;return((p=this.group)===null||p===void 0||(p=p.api)===null||p===void 0||(p=p.location)===null||p===void 0?void 0:p.type)==="floating"&&this.isFloatingMoveHandle()};this.pointerDragSource=ti.createDragSource(this._element,re(re({},a),{},{disabled:!r.pointer,touchOnly:!r.pointerHandlesMouse,touchInitiationDelay:()=>l()?500:250,pressTolerance:()=>l()?1/0:8,isCancelled:()=>!Tt(this.accessor.options).pointer||this.group.api.location.type==="edge"&&this.group.size===0,onDragStart:p=>{var f;(f=this.getFloatingOverlay())===null||f===void 0||f.cancelPendingDrag(),this._onDragStart.fire(p)}}));const h=new Me,c=()=>{const p=this.getFloatingOverlay();h.value=p?p.onDidStartMoving(()=>{this.pointerDragSource.cancelPending()}):Se.NONE};c(),this.addDisposables(h);const u=(i=this.group)===null||i===void 0||(i=i.api)===null||i===void 0?void 0:i.onDidLocationChange;u&&this.addDisposables(u(c)),this.addDisposables(this.html5DragSource,this.pointerDragSource)}updateDragAndDropState(){const e=Tt(this.accessor.options);this._element.draggable=e.html5,K(this._element,"dv-draggable",e.html5||e.pointer),this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}getFloatingOverlay(){var e;if(this.group)return(e=this.accessor.floatingGroups)===null||e===void 0||(e=e.find(t=>t.group===this.group))===null||e===void 0?void 0:e.overlay}},fb=class extends se{get element(){return this._element}constructor(e,t){var i,s,r,n,o,a,l;super(),this.accessor=e,this.group=t,this._onDrop=new G,this.onDrop=this._onDrop.event,this._onDragStart=new G,this.onDragStart=this._onDragStart.event,this._element=document.createElement("div"),this._element.className="dv-void-container",this.addDisposables(this._onDrop,this._onDragStart,Z(this._element,"pointerdown",()=>{this.accessor.doSetGroupActive(this.group)}),Z(this._element,"pointerdown",c=>{c.shiftKey&&Gc(c)},!0)),this.dragSource=new ou({element:this._element,accessor:this.accessor,group:this.group,isFloatingMoveHandle:()=>!this._element.closest(".dv-resize-container-with-titlebar")});const h=(c,u)=>{if(this.group.api.locked)return!1;const p=Te();return this.accessor.id===p?.viewId?!0:t.model.canDisplayOverlay(c,u,"header_space")};this.dropTarget=xi.createDropTarget(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:h,getOverrideTarget:()=>{var c;return(c=t.model.dropTargetContainer)===null||c===void 0?void 0:c.model},overlayModel:(i=(s=this.accessor).resolveDropOverlayModel)===null||i===void 0?void 0:i.call(s,"header_space",this.group)}),this.pointerDropTarget=ti.createDropTarget(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:h,getOverrideTarget:()=>{var c;return(c=t.model.dropTargetContainer)===null||c===void 0?void 0:c.model},overlayModel:(r=(n=this.accessor).resolveDropOverlayModel)===null||r===void 0?void 0:r.call(n,"header_space",this.group)}),this.onWillShowOverlay=xt.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this.dragSource,this.dragSource.onDragStart(c=>{this._onDragStart.fire(c)}),this.dropTarget.onDrop(c=>{this._onDrop.fire(c)}),this.pointerDropTarget.onDrop(c=>{this._onDrop.fire(c)}),this.dropTarget,this.pointerDropTarget,(o=(a=(l=this.accessor).onDidOptionsChange)===null||a===void 0?void 0:a.call(l,()=>{var c,u,p;const f=(c=(u=(p=this.accessor).resolveDropOverlayModel)===null||u===void 0?void 0:u.call(p,"header_space",this.group))!==null&&c!==void 0?c:{};this.dropTarget.setOverlayModel(f),this.pointerDropTarget.setOverlayModel(f)}))!==null&&o!==void 0?o:Se.NONE)}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}},au=class lu extends se{get element(){return this._element}get orientation(){return this._orientation}set orientation(t){this._orientation!==t&&(this._scrollOffset=0,this._orientation=t,It(this._scrollbar,"dv-scrollbar-vertical","dv-scrollbar-horizontal"),t==="vertical"?At(this._scrollbar,"dv-scrollbar-vertical"):At(this._scrollbar,"dv-scrollbar-horizontal"))}constructor(t){super(),this.scrollableElement=t,this._scrollOffset=0,this._orientation="horizontal",this._element=document.createElement("div"),this._element.className="dv-scrollable",this._scrollbar=document.createElement("div"),this._scrollbar.className="dv-scrollbar dv-scrollbar-horizontal",this.element.appendChild(t),this.element.appendChild(this._scrollbar),this.addDisposables(Z(this.element,"wheel",i=>{this._scrollOffset+=i.deltaY*lu.MouseWheelSpeed,this.scheduleStyleUpdate()}),Z(this._scrollbar,"pointerdown",i=>{var s;i.preventDefault();const r=(s=this._scrollbar.ownerDocument)!==null&&s!==void 0?s:document;K(this.element,"dv-scrollable-scrolling",!0);const n=this._orientation==="horizontal"?i.clientX:i.clientY,o=this._scrollOffset,a=h=>{const c=this._orientation==="horizontal"?h.clientX-n:h.clientY-n,u=(this._orientation==="horizontal"?this.element.clientWidth:this.element.clientHeight)/(this._orientation==="horizontal"?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight);this._scrollOffset=o+c/u,this.scheduleStyleUpdate()},l=()=>{K(this.element,"dv-scrollable-scrolling",!1),r.removeEventListener("pointermove",a),r.removeEventListener("pointerup",l),r.removeEventListener("pointercancel",l)};r.addEventListener("pointermove",a),r.addEventListener("pointerup",l),r.addEventListener("pointercancel",l)}),Z(this.element,"scroll",()=>{this.scheduleStyleUpdate()}),Z(this.scrollableElement,"scroll",()=>{this._scrollOffset=this._orientation==="horizontal"?this.scrollableElement.scrollLeft:this.scrollableElement.scrollTop,this.scheduleStyleUpdate()}),ji(this.element,()=>{K(this.element,"dv-scrollable-resizing",!0),this._animationTimer&&clearTimeout(this._animationTimer),this._animationTimer=setTimeout(()=>{clearTimeout(this._animationTimer),K(this.element,"dv-scrollable-resizing",!1)},500),this.scheduleStyleUpdate()}),Se.from(()=>{this._pendingStyleFrame!==void 0&&(cancelAnimationFrame(this._pendingStyleFrame),this._pendingStyleFrame=void 0)}))}scheduleStyleUpdate(){this._pendingStyleFrame===void 0&&(this._pendingStyleFrame=requestAnimationFrame(()=>{this._pendingStyleFrame=void 0,this.calculateScrollbarStyles()}))}calculateScrollbarStyles(){const t=this._orientation==="horizontal"?this.element.clientWidth:this.element.clientHeight,i=this._orientation==="horizontal"?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight;if(i>t){const s=t*(t/i);this._orientation==="horizontal"?(this._scrollbar.style.width=`${s}px`,this._scrollbar.style.height=""):(this._scrollbar.style.height=`${s}px`,this._scrollbar.style.width=""),this._scrollOffset=Ee(this._scrollOffset,0,i-t),this._orientation==="horizontal"?this.scrollableElement.scrollLeft=this._scrollOffset:this.scrollableElement.scrollTop=this._scrollOffset;const r=this._scrollOffset/(i-t);this._orientation==="horizontal"?(this._scrollbar.style.left=`${(t-s)*r}px`,this._scrollbar.style.top=""):(this._scrollbar.style.top=`${(t-s)*r}px`,this._scrollbar.style.left="")}else this._orientation==="horizontal"?(this._scrollbar.style.width="0px",this._scrollbar.style.left="0px"):(this._scrollbar.style.height="0px",this._scrollbar.style.top="0px"),this._scrollOffset=0}};au.MouseWheelSpeed=1;const hu="dv-tabs-container--wrap";function mb(e,t){return typeof e=="boolean"?e:!!e?.[t]}function lo(e){return typeof e=="boolean"?e:e?Object.values(e).some(Boolean):!1}var du=class extends Lc{constructor(e,t,i,s,r){super(),this.nativeEvent=e,this.target=t,this.position=i,this.getData=s,this.group=r}};const ho=Object.keys({disableAutoResizing:void 0,hideBorders:void 0,singleTabMode:void 0,disableFloatingGroups:void 0,floatingGroupBounds:void 0,transformFloatingGroupDrag:void 0,smartGuides:void 0,floatingGroupDragHandle:void 0,popoutUrl:void 0,nonce:void 0,defaultRenderer:void 0,defaultHeaderPosition:void 0,debug:void 0,locked:void 0,disableDnd:void 0,dndStrategy:void 0,className:void 0,noPanelsOverlay:void 0,dndEdges:void 0,dropPositionResolver:void 0,dndCompass:void 0,theme:void 0,disableTabsOverflowList:void 0,overflow:void 0,scrollbars:void 0,getTabContextMenuItems:void 0,getTabGroupChipContextMenuItems:void 0,createTabGroupChipComponent:void 0,createGroupDragGhostComponent:void 0,dropOverlayModel:void 0,announcements:void 0,getAnnouncement:void 0,announcer:void 0,messages:void 0,keyboardNavigation:void 0,layoutHistory:void 0,autoHideEdgeGroups:void 0,dockToEdgeGroups:void 0,edgeGroupPeek:void 0,tabGroupColors:void 0,tabGroupAccent:void 0,pinnedTabs:void 0});function gb(e){return!!e.referencePanel}function vb(e){return!!e.referenceGroup}function _b(e){return!!e.referencePanel}function bb(e){return!!e.referenceGroup}const Na=[{id:"grey",value:"var(--dv-tab-group-color-grey)",label:"Grey"},{id:"blue",value:"var(--dv-tab-group-color-blue)",label:"Blue"},{id:"red",value:"var(--dv-tab-group-color-red)",label:"Red"},{id:"yellow",value:"var(--dv-tab-group-color-yellow)",label:"Yellow"},{id:"green",value:"var(--dv-tab-group-color-green)",label:"Green"},{id:"pink",value:"var(--dv-tab-group-color-pink)",label:"Pink"},{id:"purple",value:"var(--dv-tab-group-color-purple)",label:"Purple"},{id:"cyan",value:"var(--dv-tab-group-color-cyan)",label:"Cyan"},{id:"orange",value:"var(--dv-tab-group-color-orange)",label:"Orange"}];var cu=class{constructor(e,t=!0){this._entries=e.slice(),this._byId=new Map(e.map(i=>[i.id,i])),this._enabled=t}get enabled(){return this._enabled}set enabled(e){this._enabled=e}setEntries(e){this._entries=e.slice(),this._byId=new Map(e.map(t=>[t.id,t]))}entries(){return this._entries}has(e){return this._byId.has(e)}get(e){return this._byId.get(e)}defaultId(){var e;return(e=this._entries[0])===null||e===void 0?void 0:e.id}resolveValue(e){if(!this._enabled||!e)return;const t=this._byId.get(e);return t?t.value:e}};let gn;function uu(){var e;return(e=gn)!==null&&e!==void 0||(gn=new cu(Na,!0)),gn}function Ma(e,t,i){const s=(i??uu()).resolveValue(t);s===void 0?e.style.removeProperty("--dv-tab-group-color"):e.style.setProperty("--dv-tab-group-color",s)}function Oa(e,t){return(t??uu()).resolveValue(e)}var Kl=class extends se{get element(){return this._element}constructor(e){super(),this._palette=e,this._onClick=new G,this.onClick=this._onClick.event,this._onContextMenu=new G,this.onContextMenu=this._onContextMenu.event,this._element=document.createElement("div"),this._element.className="dv-tab-group-chip",this._element.tabIndex=0,this._label=document.createElement("span"),this._label.className="dv-tab-group-chip-label",this._element.appendChild(this._label),this.addDisposables(this._onClick,this._onContextMenu,new La(this._element,{onLongPress:t=>{this._onContextMenu.fire(t)}}),Z(this._element,"click",t=>{this._onClick.fire(t)}),Z(this._element,"contextmenu",t=>{this._onContextMenu.fire(t)}))}init(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed),this.addDisposables(e.tabGroup.onDidChange(()=>{this._tabGroup&&(this.updateColor(this._tabGroup.color),this.updateLabel(this._tabGroup.label))}),e.tabGroup.onDidCollapseChange(t=>{this.updateCollapsed(t)}),this._onClick.event(()=>{var t;(t=this._tabGroup)===null||t===void 0||t.toggle()}))}update(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed)}updateColor(e){var t;Ma(this._element,e,this._palette),K(this._element,"dv-tab-group-chip--accent-off",((t=this._palette)===null||t===void 0?void 0:t.enabled)===!1)}updateLabel(e){this._label.textContent=e,K(this._label,"dv-tab-group-chip-label--empty",!e)}updateCollapsed(e){K(this._element,"dv-tab-group-chip--collapsed",e)}};const wb="dv-tab-group-chip-continuation",ql=8;var pu=class{get underlines(){return this._underlines}constructor(e){this._ctx=e,this._underlines=new Map,this._continuationMarkers=new Map,this._rafId=null}positionUnderlines(){requestAnimationFrame(()=>{this._positionUnderlinesSync()})}trackUnderlines(){this._rafId!==null&&cancelAnimationFrame(this._rafId);const e=performance.now(),t=250,i=()=>{this._positionUnderlinesSync(),performance.now()-e<t?this._rafId=requestAnimationFrame(i):this._rafId=null};this._rafId=requestAnimationFrame(i)}syncUnderlineElements(e){for(const t of e)if(!this._underlines.has(t)){const i=document.createElement("div");i.className="dv-tab-group-underline",this._ctx.tabsList.appendChild(i),this._underlines.set(t,i)}for(const[t,i]of this._underlines)e.has(t)||(i.remove(),this._underlines.delete(t),this._clearContinuationMarkers(t))}getUnderline(e){return this._underlines.get(e)}dispose(){this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null);for(const[,e]of this._underlines)e.remove();this._underlines.clear(),this._clearContinuationMarkers()}_syncContinuationMarkers(e,t){let i=this._continuationMarkers.get(e);for(i||(i=[],this._continuationMarkers.set(e,i));i.length<t;){const s=document.createElement("div");s.className=wb,this._ctx.tabsList.appendChild(s),i.push(s)}for(;i.length>t;){const s=i.pop();s?.remove()}return i}_clearContinuationMarkers(e){if(e===void 0){for(const[,i]of this._continuationMarkers)for(const s of i)s.remove();this._continuationMarkers.clear();return}const t=this._continuationMarkers.get(e);if(t){for(const i of t)i.remove();this._continuationMarkers.delete(e)}}_positionUnderlinesSync(){const e=this._ctx.tabsList.getBoundingClientRect(),t=this._ctx.getTabGroups(),i=this._ctx.getDirection()==="vertical",s=this._ctx.tabsList.classList.contains(hu);s||this._clearContinuationMarkers();const r=i?e.width:e.height,n=this._ctx.getActivePanelId(),o=this._ctx.getTabMap();for(const a of t){const l=this._underlines.get(a.id);if(!l)continue;const h=a.panelIds;if(h.length===0){l.style.display="none";continue}if(l.style.display="",s){this._positionWrappedUnderline(l,a,e,o,i);continue}const c=this._ctx.getChipElement(a.id);let u;if(c){const E=c.getBoundingClientRect(),C=getComputedStyle(c),T=i?Number.parseFloat(C.marginTop)||0:Number.parseFloat(C.marginLeft)||0;u=i?E.top-e.top-T:E.left-e.left-T}else{const E=h[0],C=o.get(E);if(C){const T=C.value.element.getBoundingClientRect();u=i?T.top-e.top:T.left-e.left}else u=0}const p=h[h.length-1],f=o.get(p);if(!f){i?(l.style.top=`${u}px`,l.style.height="0px",l.style.left="",l.style.width=""):(l.style.left=`${u}px`,l.style.width="0px",l.style.top="",l.style.height="");continue}const m=f.value.element.getBoundingClientRect();let g=i?m.bottom-e.top:m.right-e.left,_=g-u;if((a.collapsed||a.panelIds.some(E=>{const C=o.get(E);return C?.value.element.classList.contains("dv-tab--group-expanding")}))&&c){const E=c.getBoundingClientRect(),C=i?E.top+E.height/2-e.top:E.left+E.width/2-e.left;let T=0,x=0;for(const k of a.panelIds){const N=o.get(k);if(!N)continue;const O=N.value.element;i?(T+=O.getBoundingClientRect().height,x+=O.scrollHeight):(T+=O.getBoundingClientRect().width,x+=O.scrollWidth)}const A=x>0?Math.min(1,T/x):0;u=C+(u-C)*A,g=C+(g-C)*A,_=Math.max(0,g-u)}i?(l.style.top=`${u}px`,l.style.height=`${Math.max(0,_)}px`,l.style.left="",l.style.width="",l.style.bottom=""):(l.style.left=`${u}px`,l.style.width=`${Math.max(0,_)}px`,l.style.top="",l.style.height="",l.style.bottom=""),this.applyShape(l,a,u,_,r,n,e,i)}}_positionWrappedUnderline(e,t,i,s,r){const o=Oa(t.color,this._ctx.getColorPalette());if(o===void 0){e.style.display="none",this._clearContinuationMarkers(t.id);return}const{runs:a,firstRun:l}=this._computeWrappedRuns(t,i,s,r);if(a.length===0){e.style.display="none",this._clearContinuationMarkers(t.id);return}this._positionContinuationMarkers(t.id,a,l,o,r);const h=Math.min(...a.map(T=>T.left)),c=Math.max(...a.map(T=>T.right)),u=Math.min(...a.map(T=>T.top)),p=Math.max(...a.map(T=>T.bottom)),f=r?Math.max(0,c-h):i.width,m=r?i.height:Math.max(0,p-u);e.style.left=r?`${h}px`:"0px",e.style.top=r?"0px":`${u}px`,e.style.bottom="auto",e.style.width=`${f}px`,e.style.height=`${m}px`,e.style.backgroundColor="";const{svg:g,path:_}=this.ensureSvgPath(e);g.setAttribute("width",String(f)),g.setAttribute("height",String(m)),_.setAttribute("stroke",o),_.setAttribute("stroke-width",String(2));const E=this._ctx.getHeaderPosition(),C=r?E==="right":E==="bottom";_.setAttribute("d",this._wrappedPathData(a,r,C,h,u,2))}_computeWrappedRuns(e,t,i,s){const r=[];let n;for(const a of e.panelIds){var o;const l=i.get(a);if(!l)continue;const h=l.value.element.getBoundingClientRect();if(h.width===0&&h.height===0)continue;const c=h.top-t.top,u=h.bottom-t.top,p=h.left-t.left,f=h.right-t.left,m=s?p:c;let g=r.find(_=>Math.abs((s?_.left:_.top)-m)<=2);g?(g.top=Math.min(g.top,c),g.bottom=Math.max(g.bottom,u),g.left=Math.min(g.left,p),g.right=Math.max(g.right,f)):(g={top:c,bottom:u,left:p,right:f},r.push(g)),(o=n)!==null&&o!==void 0||(n=g)}return{runs:r,firstRun:n}}_wrappedPathData(e,t,i,s,r,n){let o="";for(const a of e)if(t){const l=i?a.right-s-n/2:a.left-s+n/2;o+=`M ${l},${a.top} L ${l},${a.bottom} `}else{const l=i?a.top-r+n/2:a.bottom-r-n/2;o+=`M ${a.left},${l} L ${a.right},${l} `}return o.trim()}_positionContinuationMarkers(e,t,i,s,r){const n=t.filter(a=>a!==i),o=this._syncContinuationMarkers(e,n.length);n.forEach((a,l)=>{const h=o[l];if(h.style.backgroundColor=s,r){const c=(a.left+a.right)/2;h.style.left=`${c-ql/2}px`,h.style.top=`${a.top}px`}else{const c=(a.top+a.bottom)/2;h.style.left=`${a.left}px`,h.style.top=`${c-ql/2}px`}})}ensureSvgPath(e){const t=e.firstElementChild;if(t?.tagName==="svg")return{svg:t,path:t.firstElementChild};e.replaceChildren();const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.style.display="block";const s=document.createElementNS("http://www.w3.org/2000/svg","path");return s.setAttribute("fill","none"),i.appendChild(s),e.appendChild(i),{svg:i,path:s}}},yb=class extends pu{_applyStraightLine(e,t,i,s,r,n,o){const a=o?r:s,l=o?s:r;e.setAttribute("width",String(a)),e.setAttribute("height",String(l)),i.style.width=`${a}px`,i.style.height=`${l}px`,t.setAttribute("d",o?`M ${n},0 L ${n},${s}`:`M 0,${n} L ${s},${n}`)}applyShape(e,t,i,s,r,n,o,a){const h=r,c=s,u=Oa(t.color,this._ctx.getColorPalette());if(c<=0||h<=0||u===void 0){e.style.display="none";return}e.style.display="";let p;n&&t.panelIds.includes(n)&&(p=this._ctx.getTabMap().get(n));const{svg:f,path:m}=this.ensureSvgPath(e);m.setAttribute("stroke",u),m.setAttribute("stroke-width",String(2));const g=2,_=this._ctx.getHeaderPosition(),E=!a&&_==="bottom",C=a&&_==="right";let T,x;if(a?(T=C?h-g:g,x=C?g:h-g):(T=E?g:h-g,x=E?h-g:g),!p){this._applyStraightLine(f,m,e,c,h,T,a);return}const A=p.value.element.getBoundingClientRect();let k,N;if(a?(k=Math.max(0,A.top-o.top-i),N=Math.min(c,A.bottom-o.top-i)):(k=Math.max(0,A.left-o.left-i),N=Math.min(c,A.right-o.left-i)),N<=k){this._applyStraightLine(f,m,e,c,h,T,a);return}const O=6,z=x>T?1:-1;if(a){const R=h,I=c;f.setAttribute("width",String(R)),f.setAttribute("height",String(I)),e.style.width=`${R}px`,e.style.height=`${I}px`;const w=[`M ${T},0`,`L ${T},${k-O}`,`Q ${T},${k} ${T+z*O},${k}`,`L ${x-z*O},${k}`,`Q ${x},${k} ${x},${k+O}`,`L ${x},${N-O}`,`Q ${x},${N} ${x-z*O},${N}`,`L ${T+z*O},${N}`,`Q ${T},${N} ${T},${N+O}`,`L ${T},${I}`].join(" ");m.setAttribute("d",w)}else{const R=c,I=h;f.setAttribute("width",String(R)),f.setAttribute("height",String(I)),e.style.width=`${R}px`,e.style.height=`${I}px`;const w=[`M 0,${T}`,`L ${k-O},${T}`,`Q ${k},${T} ${k},${T+z*O}`,`L ${k},${x-z*O}`,`Q ${k},${x} ${k+O},${x}`,`L ${N-O},${x}`,`Q ${N},${x} ${N},${x-z*O}`,`L ${N},${T+z*O}`,`Q ${N},${T} ${N+O},${T}`,`L ${R},${T}`].join(" ");m.setAttribute("d",w)}}},Sb=class extends pu{applyShape(e,t,i,s,r,n,o,a){const h=Oa(t.color,this._ctx.getColorPalette());if(s<=0||h===void 0){e.style.display="none";return}e.style.display="",e.firstElementChild&&e.replaceChildren(),e.style.backgroundColor=h,a?(e.style.width="2px",e.style.height=`${s}px`):(e.style.width=`${s}px`,e.style.height="2px")}};const xb=new Map;var Cb=class{get chipRenderers(){return this._chipRenderers}get groupUnderlines(){var e,t;return(e=(t=this._indicator)===null||t===void 0?void 0:t.underlines)!==null&&e!==void 0?e:xb}get skipNextCollapseAnimation(){return this._skipNextCollapseAnimation}set skipNextCollapseAnimation(e){this._skipNextCollapseAnimation=e}constructor(e,t){this._ctx=e,this._callbacks=t,this._chipRenderers=new Map,this._indicator=null,this._skipNextCollapseAnimation=!1,this._pendingTransitionCleanups=new Map}update(){const e=this._ctx.group.model.getTabGroups(),t=new Set;for(const s of e)t.add(s.id),this._ensureChipForGroup(s),this._positionChipForGroup(s);for(const[s,r]of this._chipRenderers)if(!t.has(s)){var i;r.chip.element.remove(),r.chip.dispose(),(i=r.dragSourcesDisposable)===null||i===void 0||i.dispose(),r.disposable.dispose(),this._chipRenderers.delete(s)}this._updateTabGroupClasses()}refreshAccents(){for(const i of this._ctx.group.model.getTabGroups()){var e,t;const s=this._chipRenderers.get(i.id);s==null||(t=(e=s.chip).update)===null||t===void 0||t.call(e,{tabGroup:i})}this._updateTabGroupClasses()}positionAllChips(){if(this._chipRenderers.size!==0)for(const e of this._ctx.group.model.getTabGroups())this._positionChipForGroup(e)}updateDirection(){const e=this._ctx.getDirection()==="vertical";for(const[,t]of this._chipRenderers)t.dropTarget.setTargetZones(e?["top"]:["left"])}snapshotChipWidths(){const e=new Map;for(const[t,i]of this._chipRenderers)e.set(t,i.chip.element.getBoundingClientRect().width);return e}positionUnderlines(){var e;(e=this._indicator)===null||e===void 0||e.positionUnderlines()}trackUnderlines(){var e;(e=this._indicator)===null||e===void 0||e.trackUnderlines()}setGroupDragImage(e,t,i){if(!e.dataTransfer)return;const s=this._ctx.getDirection()==="vertical",r=this._ctx.tabsList.cloneNode(!0);s?(r.classList.remove("dv-tabs-container-vertical","dv-vertical"),r.classList.add("dv-horizontal"),r.style.writingMode="horizontal-tb",r.style.height=`${this._ctx.tabsList.offsetWidth}px`):r.style.height=`${this._ctx.tabsList.offsetHeight}px`,r.style.width="auto",r.style.overflow="visible",r.style.pointerEvents="none";const n=Array.from(r.children),o=Array.from(this._ctx.tabsList.children);for(let f=n.length-1;f>=0;f--)o[f]!==i&&n[f].remove();const a=document.createElement("div");a.className="dv-groupview dv-active-group",a.style.position="fixed",a.style.top="-10000px",a.style.left="0px",a.style.height="auto",a.style.width="auto",a.style.pointerEvents="none";const l=document.createElement("div");l.className="dv-tabs-and-actions-container",l.style.height="auto",l.style.width="auto",a.appendChild(l),l.appendChild(r),this._ctx.accessor.element.appendChild(a);const h=r.querySelector(".dv-tab-group-chip"),c=i.getBoundingClientRect(),u=e.clientX-c.left,p=e.clientY-c.top;if(h){const f=h.getBoundingClientRect(),m=a.getBoundingClientRect(),g=f.left-m.left+u,_=f.top-m.top+p;e.dataTransfer.setDragImage(a,g,_)}else e.dataTransfer.setDragImage(a,u,p);requestAnimationFrame(()=>{a.remove()})}cleanupTransition(e){var t;(t=this._pendingTransitionCleanups.get(e))===null||t===void 0||t(),this._pendingTransitionCleanups.delete(e)}updateDragAndDropState(){const e=Tt(this._ctx.accessor.options);for(const r of this._chipRenderers.values()){var t,i,s;r.chip.element.draggable=e.html5,(t=r.html5DragSource)===null||t===void 0||t.setDisabled(!e.html5),(i=r.pointerDragSource)===null||i===void 0||i.setDisabled(!e.pointer),(s=r.pointerDragSource)===null||s===void 0||s.setTouchOnly(!e.pointerHandlesMouse)}}disposeChipDrag(e){var t;const i=this._chipRenderers.get(e);i&&((t=i.dragSourcesDisposable)===null||t===void 0||t.dispose(),i.html5DragSource=void 0,i.pointerDragSource=void 0,i.dragSourcesDisposable=void 0)}_buildChipGhostElement(e){const t=getComputedStyle(e),i=e.cloneNode(!0);return Array.from(t).forEach(s=>{i.style.setProperty(s,t.getPropertyValue(s),t.getPropertyPriority(s))}),i.style.position="absolute",i}disposeAll(){var e;(e=this._indicator)===null||e===void 0||e.dispose(),this._indicator=null;for(const[,i]of this._pendingTransitionCleanups)i();this._pendingTransitionCleanups.clear();for(const[,i]of this._chipRenderers){var t;i.chip.element.remove(),i.chip.dispose(),(t=i.dragSourcesDisposable)===null||t===void 0||t.dispose(),i.disposable.dispose()}this._chipRenderers.clear()}_ensureIndicator(){var e,t,i;const s=((e=(t=this._ctx.accessor.options.theme)===null||t===void 0?void 0:t.tabGroupIndicator)!==null&&e!==void 0?e:"wrap")==="none"?Sb:yb;this._indicator&&!(this._indicator instanceof s)&&(this._indicator.dispose(),this._indicator=null),(i=this._indicator)!==null&&i!==void 0||(this._indicator=new s({tabsList:this._ctx.tabsList,getTabGroups:()=>this._ctx.group.model.getTabGroups(),getActivePanelId:()=>{var r;return(r=this._ctx.group.activePanel)===null||r===void 0?void 0:r.id},getTabMap:()=>this._ctx.getTabMap(),getChipElement:r=>{var n;return(n=this._chipRenderers.get(r))===null||n===void 0?void 0:n.chip.element},getDirection:()=>this._ctx.getDirection(),getHeaderPosition:()=>this._ctx.group.model.headerPosition,getColorPalette:()=>this._ctx.accessor.tabGroupColorPalette}))}_createChipDragSources(e,t){const i=Tt(this._ctx.accessor.options);e.element.draggable=i.html5;const s=ei.getInstance(),r=()=>(s.setData([new St(this._ctx.accessor.id,this._ctx.group.id,null,t.id)],St.prototype),{dispose:()=>{s.clearData(St.prototype)}}),n=xi.createDragSource(e.element,{getData:r,disabled:!i.html5,isCancelled:()=>!Tt(this._ctx.accessor.options).html5,onDragStart:l=>{"dataTransfer"in l&&l.dataTransfer&&this.setGroupDragImage(l,t,e.element),this._callbacks.onChipDragStart(t,e,l)},onDragEnd:l=>{var h,c;(h=(c=this._callbacks).onChipDragEnd)===null||h===void 0||h.call(c,t,e,l)}}),o=()=>{s.clearData(St.prototype)};e.element.addEventListener("dragend",o,{once:!0});const a=ti.createDragSource(e.element,{getData:r,disabled:!i.pointer,touchOnly:!i.pointerHandlesMouse,isCancelled:()=>!Tt(this._ctx.accessor.options).pointer,createGhost:()=>({element:this._buildChipGhostElement(e.element),offsetX:8,offsetY:8}),onDragStart:l=>{this._callbacks.onChipDragStart(t,e,l)}});return{html5DragSource:n,pointerDragSource:a,disposable:{dispose:()=>{n.dispose(),a.dispose(),e.element.removeEventListener("dragend",o)}}}}_ensureChipForGroup(e){const t=this._chipRenderers.get(e.id);if(t){if(!t.html5DragSource){const c=this._createChipDragSources(t.chip,e);t.html5DragSource=c.html5DragSource,t.pointerDragSource=c.pointerDragSource,t.dragSourcesDisposable=c.disposable}return}const i=this._ctx.accessor.options.createTabGroupChipComponent,s=i?i(e):new Kl(this._ctx.accessor.tabGroupColorPalette);s.init({tabGroup:e,api:this._ctx.accessor.api});const r=this._createChipDragSources(s,e),n=[e.onDidChange(()=>{var c;(c=s.update)===null||c===void 0||c.call(s,{tabGroup:e}),this._updateTabGroupClasses()}),e.onDidPanelChange(()=>{this._positionChipForGroup(e),this._updateTabGroupClasses()}),e.onDidCollapseChange(()=>{this._updateTabGroupClasses()})],o=c=>{var u;(u=this._chipRenderers.get(e.id))===null||u===void 0||(u=u.pointerDragSource)===null||u===void 0||u.cancelPending(),this._callbacks.onChipContextMenu(e,c)};s instanceof Kl?n.push(s.onContextMenu(o)):n.push(new La(s.element,{onLongPress:o}),Z(s.element,"contextmenu",o));const a=this._ctx.getDirection()==="vertical",l=new Yr(s.element,{acceptedTargetZones:a?["top"]:["left"],overlayModel:{activationSize:{value:100,type:"percentage"}},canDisplayOverlay:(c,u)=>{if(this._ctx.group.locked||this._ctx.accessor.options.disableDnd)return!1;const p=Te();if(this._ctx.accessor.id===p?.viewId){var f;return((f=this._ctx.accessor.options.theme)===null||f===void 0?void 0:f.tabAnimation)!=="smooth"}return this._ctx.group.model.canDisplayOverlay(c,u,"tab")}});n.push(l,l.onDrop(c=>{this._callbacks.onChipDrop(e,c)}));const h=new se(...n);this._chipRenderers.set(e.id,{chip:s,html5DragSource:r.html5DragSource,pointerDragSource:r.pointerDragSource,dragSourcesDisposable:r.disposable,disposable:h,dropTarget:l}),e.collapsed&&(this._skipNextCollapseAnimation=!0)}_positionChipForGroup(e){const t=this._chipRenderers.get(e.id);if(!t)return;const i=t.chip.element,s=e.panelIds;if(s.length===0){i.remove();return}const r=s[0],n=this._ctx.getTabMap().get(r);if(!n){i.remove();return}const o=n.value.element;i.nextSibling!==o&&this._ctx.tabsList.insertBefore(i,o)}_updateTabGroupClasses(){const e=this._ctx.group.model.getTabGroups(),t=this._ctx.getTabs(),i=this._ctx.getTabMap();let s=!1;const r=new Map;for(const a of e)for(const l of a.panelIds)r.set(l,a);for(const a of t){const l=a.value,h=l.panel.id,c=r.get(h),u=!!c;if(K(l.element,"dv-tab--grouped",u),c){const p=c.panelIds,f=p[0]===h,m=p[p.length-1]===h;K(l.element,"dv-tab--group-first",f),K(l.element,"dv-tab--group-last",m),Ma(l.element,c.color,this._ctx.accessor.tabGroupColorPalette);const g=l.element.classList.contains("dv-tab--group-collapsed");if(!c.collapsed&&g){var n;s=!0,l.element.classList.remove("dv-tab--group-collapsed"),l.element.classList.add("dv-tab--group-expanding"),(n=this._pendingTransitionCleanups.get(h))===null||n===void 0||n();const _=()=>{l.element.classList.remove("dv-tab--group-expanding"),l.element.style.removeProperty("width"),l.element.removeEventListener("transitionend",_),clearTimeout(E),this._pendingTransitionCleanups.delete(h)},E=setTimeout(_,300);this._pendingTransitionCleanups.set(h,_),l.element.addEventListener("transitionend",_)}}else K(l.element,"dv-tab--group-first",!1),K(l.element,"dv-tab--group-last",!1),l.element.classList.remove("dv-tab--group-collapsed","dv-tab--group-expanding"),l.element.style.removeProperty("width"),l.element.style.removeProperty("--dv-tab-group-color")}const o=new Set;for(const a of e)if(o.add(a.id),a.collapsed&&a.panelIds.some(l=>{const h=i.get(l);return h&&!h.value.element.classList.contains("dv-tab--group-collapsed")}))if(this._skipNextCollapseAnimation){const l=[];for(const h of a.panelIds){const c=i.get(h);c&&(c.value.element.style.transition="none",c.value.element.classList.add("dv-tab--group-collapsed"),l.push(c.value.element))}if(l.length>0){l[0].offsetHeight;for(const h of l)h.style.removeProperty("transition")}}else{s=!0;const l=this._ctx.getDirection()==="vertical";for(const h of a.panelIds){const c=i.get(h);if(c&&!c.value.element.classList.contains("dv-tab--group-collapsed")){const u=c.value.element.getBoundingClientRect();l?c.value.element.style.height=`${u.height}px`:c.value.element.style.width=`${u.width}px`,c.value.element.offsetHeight,c.value.element.classList.add("dv-tab--group-collapsed")}}}this._skipNextCollapseAnimation=!1,this._ensureIndicator(),this._indicator&&(this._indicator.syncUnderlineElements(o),s?this._indicator.trackUnderlines():this._indicator.positionUnderlines())}},Db=class extends se{get _tabs(){return this.host.tabItems}get _tabMap(){return this.host.tabMap}get _tabsList(){return this.host.tabsList}get _direction(){return this.host.direction}get group(){return this.host.groupPanel}get accessor(){return this.host.component}get _tabGroupManager(){return this.host.tabGroupManager}get _wrapMode(){return this._tabsList.classList.contains(hu)}get animState(){return this._animState}set animState(e){this._animState=e}get pendingCollapse(){return this._pendingCollapse}set pendingCollapse(e){this._pendingCollapse=e}set voidContainerElement(e){this._voidContainer=e}constructor(e){super(),this.host=e,this._animState=null,this._pendingMarginCleanups=new Map,this._pendingCollapse=!1,this._flipTransitionCleanup=null,this._voidContainer=null,this._extendedDropZone=null,this._pointerInsideTabsList=!1,this._wrapIndicatorEl=null,this.addDisposables({dispose:()=>{var t;(t=this._flipTransitionCleanup)===null||t===void 0||t.call(this)}})}setExtendedDropZone(e){this._extendedDropZone=e}setExternalInsertionIndex(e){this._animState&&e!==this._animState.currentInsertionIndex&&(this._animState.currentInsertionIndex=e,this.applyDragOverTransforms())}clearExternalAnimState(){this._animState&&(this.resetTabTransforms(),this._animState.sourceIndex===-1?this._animState=null:this._animState.currentInsertionIndex=null)}snapshotTabPositions(){const e=new Map;for(const t of this._tabs)e.set(t.value.panel.id,t.value.element.getBoundingClientRect());return e}getAverageTabWidth(){if(this._tabs.length===0)return 0;const e=this._direction==="vertical";let t=0;for(const i of this._tabs){const s=i.value.element.getBoundingClientRect();t+=e?s.height:s.width}return t/this._tabs.length}handlePointerDragMove(e,t){var i;const s=((i=this._tabsList.ownerDocument)!==null&&i!==void 0?i:document).elementFromPoint(e,t);if(!(s&&(this._tabsList.contains(s)||this._extendedDropZone&&this._extendedDropZone.contains(s)))){this._pointerInsideTabsList&&(this._pointerInsideTabsList=!1,this.processDragLeave(s));return}this._pointerInsideTabsList=!0,this.processDragOver(e,t)}handlePointerDragEnd(e){e&&this._animState&&this._animState.sourceIndex!==-1&&!this._animState.sourceTabGroupId&&this._animState.currentInsertionIndex!==null&&this.isPointInsideTabsList(e.clientX,e.clientY)&&this.commitPointerReorder(e.pointerEvent),this._pointerInsideTabsList=!1,this.resetDragAnimation()}isPointInsideTabsList(e,t){var i;const s=((i=this._tabsList.ownerDocument)!==null&&i!==void 0?i:document).elementFromPoint(e,t);return!!s&&this._tabsList.contains(s)}commitPointerReorder(e){const t=this._animState;if(t?.currentInsertionIndex==null)return;const i=t.currentInsertionIndex,s=t.sourceIndex,r=i-(s!==-1&&s<i?1:0);this._animState=null,this.clearWrapDropIndicator(),this.uncollapseSourceTab(t.sourceTabId),r!==s&&this.host.fireDrop({event:e,index:r,targetTabGroupId:null})}processDragOver(e,t){if(this.accessor.options.disableDnd||(this._dropStaleAnimState(),!this._animState&&!this._initAnimStateForExternalDrag()))return!1;if(this._animState.sourceIndex!==-1){var i;(i=this.group.model.dropTargetContainer)===null||i===void 0||(i=i.model)===null||i===void 0||i.clear()}return this.handleDragOver({clientX:e,clientY:t}),!0}_dropStaleAnimState(){if(!this._animState)return;const e=Te();e?.tabGroupId&&e.groupId!==this.group.id&&this._animState.sourceTabGroupId!==e.tabGroupId&&(this._animState=null)}_initAnimStateForExternalDrag(){var e;const t=Te();if(((e=this.accessor.options.theme)===null||e===void 0?void 0:e.tabAnimation)==="default"&&!t?.tabGroupId||!t||!(t.panelId||t.tabGroupId)||t.groupId===this.group.id)return!1;const i=this.getAverageTabWidth();return this._animState=t.tabGroupId?this._makeGroupDragAnimState(t,i):this._makeTabDragAnimState(t,i),!0}_makeGroupDragAnimState(e,t){var i;const s=this.accessor.getPanel(e.groupId),r=s?.model.getTabGroups().find(o=>o.id===e.tabGroupId),n=t*((i=r?.panelIds.length)!==null&&i!==void 0?i:1)+t;return{sourceTabId:"",sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.tabGroupId,sourceGroupPanelIds:r?new Set(r.panelIds):new Set,sourceChipWidth:t,cursorOffsetFromDragLeft:n/2,sourceGapWidth:n,containerLeft:this._tabsList.getBoundingClientRect().left}}_makeTabDragAnimState(e,t){return{sourceTabId:e.panelId,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:t/2,sourceGapWidth:t,containerLeft:this._tabsList.getBoundingClientRect().left}}processDragLeave(e){var t;if(this._animState&&!(e&&this._tabsList.contains(e))){if(e&&(!((t=this._extendedDropZone)===null||t===void 0)&&t.contains(e))){this.resetTabTransforms(),this._animState.currentInsertionIndex=null;return}if(!(this._voidContainer&&e&&(e===this._voidContainer||this._voidContainer.contains(e))))if(this.resetTabTransforms(),this._animState.sourceIndex===-1){var i;(i=this.group.model.dropTargetContainer)===null||i===void 0||(i=i.model)===null||i===void 0||i.clear(),this._animState=null}else this._animState.currentInsertionIndex=null}}handleDragOver(e){var t;if(!this._animState)return;if(this._wrapMode&&!this._animState.sourceTabGroupId){var i;this.handleWrappedDragOver(e.clientX,(i=e.clientY)!==null&&i!==void 0?i:0);return}const s=e.clientX,r=this._buildFirstPanelToGroupMap();let n=this._computeDragOverInsertionIndex(s,r),o=null;if(n!==null&&this._tabGroupManager.chipRenderers.size>0){const a=this._resolveInsertionAgainstTabGroups(s,n,r);n=a.insertionIndex,o=a.targetTabGroupId}n===this._animState.currentInsertionIndex&&o===this._animState.targetTabGroupId||(this._animState.currentInsertionIndex=n,this._animState.targetTabGroupId=o,((t=this.accessor.options.theme)===null||t===void 0?void 0:t.tabAnimation)==="smooth"&&this.applyDragOverTransforms())}_buildFirstPanelToGroupMap(){const e=new Map;if(this._tabGroupManager.chipRenderers.size===0)return e;for(const t of this.group.model.getTabGroups())t.id!==this._animState.sourceTabGroupId&&t.panelIds.length>0&&e.set(t.panelIds[0],t.id);return e}_computeDragOverInsertionIndex(e,t){const i=this._animState,s=i.sourceGroupPanelIds,r=e-i.cursorOffsetFromDragLeft-i.containerLeft;let n=0,o=null;for(let c=0;c<this._tabs.length;c++){const u=this._tabs[c].value;if(u.panel.id===i.sourceTabId||s?.has(u.panel.id))continue;const p=t.get(u.panel.id);if(p){var a;const g=(a=i.chipPositions.get(p))!==null&&a!==void 0?a:0;if(n+g>r){var l;(l=o)!==null&&l!==void 0||(o=c);break}n+=g}const f=i.tabPositions.get(u.panel.id),m=f?f.width:u.element.getBoundingClientRect().width;if(n+m/2<=r)n+=m,o=c+1;else{var h;(h=o)!==null&&h!==void 0||(o=c);break}}return o}_accumulatedWidthUpTo(e,t){const i=this._animState,s=i.sourceGroupPanelIds;let r=0;for(let o=0;o<this._tabs.length;o++){const a=this._tabs[o].value;if(a.panel.id===i.sourceTabId||s?.has(a.panel.id))continue;if(o>=e)break;const l=t.get(a.panel.id);if(l){var n;r+=(n=i.chipPositions.get(l))!==null&&n!==void 0?n:0}const h=i.tabPositions.get(a.panel.id);r+=h?h.width:a.element.getBoundingClientRect().width}return r}_resolveInsertionAgainstTabGroups(e,t,i){const s=!!this._animState.sourceTabGroupId,r=this._accumulatedWidthUpTo(t,i);for(const n of this.group.model.getTabGroups()){const o=this._evaluateTabGroupForInsertion(n,e,t,r,s);if(o)return o}return{insertionIndex:t,targetTabGroupId:null}}_evaluateTabGroupForInsertion(e,t,i,s,r){const n=this._resolveGroupRange(e);if(!n)return null;const{firstIdx:o,lastIdx:a}=n,l=i>=o&&i<=a,h=!l&&i===o-1;return!l&&!h?null:r?this._resolveGroupDragTarget(i,o,a,l):this._resolveTabDragTarget(e,t,i,s,o,h)}_resolveGroupRange(e){const t=this._animState,i=t.sourceGroupPanelIds,s=e.panelIds.filter(o=>o!==t.sourceTabId&&!i?.has(o));if(s.length===0)return null;const r=this._tabs.findIndex(o=>o.value.panel.id===s[0]),n=this._tabs.findIndex(o=>o.value.panel.id===s[s.length-1]);return r===-1||n===-1?null:{firstIdx:r,lastIdx:n}}_resolveGroupDragTarget(e,t,i,s){return s?{insertionIndex:e<(t+i+1)/2?t:i+1,targetTabGroupId:null}:{insertionIndex:e,targetTabGroupId:null}}_resolveTabDragTarget(e,t,i,s,r,n){var o;const a=this._animState,l=(o=a.chipPositions.get(e.id))!==null&&o!==void 0?o:0;if(n)return this._onlySourceBetween(i,r)?t>=(e.collapsed?a.containerLeft+s+l/2:a.containerLeft+s+l)?{insertionIndex:r,targetTabGroupId:e.id}:{insertionIndex:i,targetTabGroupId:null}:null;const h=a.containerLeft+s+l;return i===r?{insertionIndex:i,targetTabGroupId:t>=h?e.id:null}:{insertionIndex:i,targetTabGroupId:e.id}}_onlySourceBetween(e,t){const i=this._animState;for(let r=e;r<t;r++){var s;const n=this._tabs[r].value.panel.id;if(n!==i.sourceTabId&&!(!((s=i.sourceGroupPanelIds)===null||s===void 0)&&s.has(n)))return!1}return!0}handleWrappedDragOver(e,t){if(!this._animState)return;const i=this.computeWrappedInsertionIndex(e,t);i===this._animState.currentInsertionIndex&&this._animState.targetTabGroupId===null||(this._animState.currentInsertionIndex=i,this._animState.targetTabGroupId=null,this.updateWrapDropIndicator(i))}computeWrappedInsertionIndex(e,t){var i;const s=this._direction==="vertical",r=this._wrappedDragEntries();if(r.length===0)return this._tabs.length;const n=s?e:t,o=s?t:e,a=f=>s?f.left:f.top,l=f=>s?f.right:f.bottom,h=f=>s?f.top:f.left,c=f=>s?f.height:f.width,u=this._bucketWrappedLines(r,a,l),p=[...((i=u.find(f=>n>=f.start&&n<=f.end))!==null&&i!==void 0?i:this._nearestWrappedLine(u,n)).items].sort((f,m)=>h(f.rect)-h(m.rect));for(const f of p)if(o<h(f.rect)+c(f.rect)/2)return f.index;return p[p.length-1].index+1}_wrappedDragEntries(){var e,t;const i=(e=this._animState)===null||e===void 0?void 0:e.sourceTabId,s=(t=this._animState)===null||t===void 0?void 0:t.sourceGroupPanelIds,r=[];for(let n=0;n<this._tabs.length;n++){const o=this._tabs[n].value;o.panel.id!==i&&(s?.has(o.panel.id)||r.push({index:n,rect:o.element.getBoundingClientRect()}))}return r}_bucketWrappedLines(e,t,i){const s=[];for(const r of e){const n=t(r.rect),o=s.find(a=>Math.abs(a.start-n)<=2);o?(o.items.push(r),o.end=Math.max(o.end,i(r.rect))):s.push({start:n,end:i(r.rect),items:[r]})}return s.sort((r,n)=>r.start-n.start),s}_nearestWrappedLine(e,t){const i=s=>t<s.start?s.start-t:t-s.end;return e.reduce((s,r)=>i(r)<i(s)?r:s,e[0])}updateWrapDropIndicator(e){var t;this.clearWrapDropIndicator();const i=this._tabs.length;if(i===0)return;const s=(t=this._animState)===null||t===void 0?void 0:t.sourceTabId;if(e<i){const r=this._tabs[e].value.element;if(this._tabs[e].value.panel.id===s)return;r.classList.add("dv-tab--reorder-before"),this._wrapIndicatorEl=r}else{const r=this._tabs[i-1].value.element;r.classList.add("dv-tab--reorder-after"),this._wrapIndicatorEl=r}}clearWrapDropIndicator(){var e;(e=this._wrapIndicatorEl)===null||e===void 0||e.classList.remove("dv-tab--reorder-before","dv-tab--reorder-after"),this._wrapIndicatorEl=null}_removeClassInstantlyBatch(e,t){const i=[];for(const s of e)s.classList.contains(t)&&(s.style.transition="none",K(s,t,!1),i.push(s));if(i.length>0){i[0].getBoundingClientRect();for(const s of i)s.style.removeProperty("transition")}}uncollapseSourceTab(e){const t=this._tabMap.get(e);t&&this._removeClassInstantlyBatch([t.value.element],"dv-tab--dragging")}applyDragOverTransforms(e=!1){var t;if(this._wrapMode)return;if(((t=this._animState)===null||t===void 0?void 0:t.currentInsertionIndex)==null){this.resetTabTransforms();return}if(this._pendingCollapse)return;const i=this._animState.currentInsertionIndex,s=this._computeGapWidth(),r=this._computeChipToShift(i);this._applyGapMargins(i,s,r,e)}_computeGapWidth(){const e=this._animState;if(e.sourceTabGroupId&&e.sourceGroupPanelIds)return e.sourceGapWidth;const t=e.tabPositions.get(e.sourceTabId);return t?t.width:this.getAverageTabWidth()}_computeChipToShift(e){if(this._tabGroupManager.chipRenderers.size===0)return null;for(const t of this.group.model.getTabGroups()){const i=this._chipToShiftForGroup(t,e);if(i!==void 0)return i}return null}_chipToShiftForGroup(e,t){const i=this._animState;if(e.id===i.sourceTabGroupId||e.panelIds.includes(i.sourceTabId))return;const s=e.panelIds.filter(n=>{var o;return n!==i.sourceTabId&&!(!((o=i.sourceGroupPanelIds)===null||o===void 0)&&o.has(n))});if(s.length===0)return;const r=this._tabs.findIndex(n=>n.value.panel.id===s[0]);if((!i.targetTabGroupId||i.targetTabGroupId===e.id&&e.collapsed)&&!(r<t)){if(this._onlySourceBetween(t,r)){const n=this._tabGroupManager.chipRenderers.get(e.id);if(n)return n.chip.element}return null}}_applyGapMargins(e,t,i,s){const r=this._animState,n=r.sourceGroupPanelIds;let o=!1;for(const[a,l]of this._tabGroupManager.chipRenderers)a!==r.sourceTabGroupId&&this._clearMargin(l.chip.element,s);i&&(this._setMargin(i,`${t}px`,s),o=!0);for(let a=0;a<this._tabs.length;a++){const l=this._tabs[a].value;l.panel.id!==r.sourceTabId&&(n?.has(l.panel.id)||(!o&&a>=e?(this._setMargin(l.element,`${t}px`,s),o=!0):this._clearMargin(l.element,s)))}this._tabGroupManager.trackUnderlines()}_shiftingClass(e){return e.classList.contains("dv-tab-group-chip")?"dv-tab-group-chip--shifting":"dv-tab--shifting"}_setMargin(e,t,i){i?(e.style.transition="none",e.style.marginLeft=t,e.getBoundingClientRect(),e.style.removeProperty("transition")):e.style.marginLeft=t,K(e,this._shiftingClass(e),!0)}_clearMargin(e,t){const i=this._shiftingClass(e),s=this._pendingMarginCleanups.get(e);if(s&&s(),t||!e.style.marginLeft)e.style.removeProperty("margin-left"),K(e,i,!1);else{e.style.marginLeft="0px",K(e,i,!0);const r=()=>{e.style.removeProperty("margin-left"),K(e,i,!1),e.removeEventListener("transitionend",r),clearTimeout(n),this._pendingMarginCleanups.delete(e)},n=setTimeout(r,300);this._pendingMarginCleanups.set(e,r),e.addEventListener("transitionend",r)}}resetTabTransforms(){this.clearWrapDropIndicator();for(const[,e]of this._pendingMarginCleanups)e();this._pendingMarginCleanups.clear();for(const e of this._tabs)e.value.element.style.removeProperty("margin-left"),e.value.element.style.removeProperty("margin-right"),e.value.element.style.removeProperty("margin-top"),e.value.element.style.removeProperty("margin-bottom"),e.value.element.style.removeProperty("transform"),K(e.value.element,"dv-tab--shifting",!1);for(const[,e]of this._tabGroupManager.chipRenderers)e.chip.element.style.removeProperty("margin-left"),K(e.chip.element,"dv-tab-group-chip--shifting",!1);this._tabGroupManager.positionUnderlines()}commitGroupMove(e,t){const i=Te();if(this._tabGroupManager.disposeChipDrag(e),this.group.model.getTabGroups().some(n=>n.id===e)){var s;if(((s=this.accessor.options.theme)===null||s===void 0?void 0:s.tabAnimation)==="smooth"){this._clearGroupDragClasses(e);const n=this.snapshotTabPositions();this.resetTabTransforms(),this.group.model.moveTabGroup(e,t),this.runFlipAnimation(n,"",!1)}else this._tabGroupManager.skipNextCollapseAnimation=!0,this.group.model.moveTabGroup(e,t)}else if(i){var r;this.resetTabTransforms(),this.accessor.moveGroupOrPanel({from:{groupId:i.groupId,tabGroupId:(r=i.tabGroupId)!==null&&r!==void 0?r:e},to:{group:this.group,position:"center",index:t}})}}_clearGroupDragClasses(e){const t=this._tabGroupManager.chipRenderers.get(e);t&&this._removeClassInstantlyBatch([t.chip.element],"dv-tab-group-chip--dragging"),this._removeClassInstantlyBatch(this._tabs.map(s=>s.value.element),"dv-tab--dragging");const i=this._tabGroupManager.groupUnderlines.get(e);i&&i.style.removeProperty("display"),this._tabGroupManager.skipNextCollapseAnimation=!0}resetDragAnimation(){if(this._pendingCollapse=!1,this._animState){this.resetTabTransforms(),this._animState.sourceTabGroupId?this._clearGroupDragClasses(this._animState.sourceTabGroupId):this._removeClassInstantlyBatch(this._tabs.map(e=>e.value.element),"dv-tab--dragging"),this._animState=null;for(const[,e]of this._tabGroupManager.groupUnderlines)e.style.removeProperty("display")}}runFlipAnimation(e,t,i=!1,s){if(this._wrapMode)return;let r=!1;for(let n=0;n<this._tabs.length;n++)this._applyFlipTransform(this._tabs[n],n,t,i,e,s)&&(r=!0);r&&this._scheduleFlipReset()}_applyFlipTransform(e,t,i,s,r,n){const o=this._direction==="vertical",a=e.value.panel.id;if(a===i){if(!s)return!1;const u=e.value.element.getBoundingClientRect();return e.value.element.style.transform=o?`translateY(${u.height}px)`:`translateX(${u.width}px)`,K(e.value.element,"dv-tab--shifting",!0),!0}if(n!==void 0&&(t<n.from||t>n.to))return!1;const l=r.get(a);if(!l)return!1;const h=e.value.element.getBoundingClientRect(),c=o?l.top-h.top:l.left-h.left;return Math.abs(c)<1?!1:(e.value.element.style.transform=o?`translateY(${c}px)`:`translateX(${c}px)`,K(e.value.element,"dv-tab--shifting",!0),!0)}_scheduleFlipReset(){requestAnimationFrame(()=>{var e;for(const s of this._tabs)s.value.element.style.transform&&(s.value.element.style.transform="");this._tabGroupManager.trackUnderlines(),(e=this._flipTransitionCleanup)===null||e===void 0||e.call(this);const t=s=>{if(s.propertyName==="transform"){i();for(const r of this._tabs)K(r.value.element,"dv-tab--shifting",!1);this._tabGroupManager.positionUnderlines()}},i=()=>{this._tabsList.removeEventListener("transitionend",t),this._flipTransitionCleanup=null};this._flipTransitionCleanup=i,this._tabsList.addEventListener("transitionend",t)})}},kb=class extends se{get _animState(){return this._reorder.animState}set _animState(e){this._reorder.animState=e}get _pendingCollapse(){return this._reorder.pendingCollapse}set _pendingCollapse(e){this._reorder.pendingCollapse=e}get tabItems(){return this._tabs}get tabMap(){return this._tabMap}get tabsList(){return this._tabsList}get groupPanel(){return this.group}get component(){return this.accessor}get tabGroupManager(){return this._tabGroupManager}fireDrop(e){this._onDrop.fire(e)}setOverflowExclude(e){this._overflowExclude=e,this.refreshOverflow()}setForcedOverflow(e){this._forcedOverflow=e,this.refreshOverflow()}refreshOverflow(){this._showTabsOverflowControl&&this.toggleDropdown({reset:!1}),this._applyPinnedSticky()}setPinnedSticky(e){this._pinnedSticky!==e&&(this._pinnedSticky=e,this._applyPinnedSticky())}_applyPinnedSticky(){const e=this._pinnedSticky?this._tabs.filter(i=>this._overflowExclude(i.value.panel.id)):[];if(e.length===0&&!this._hasPinnedStickyStyling)return;for(const i of this._tabs){const s=i.value.element;s.classList.contains("dv-tab--pinned-sticky")&&(s.classList.remove("dv-tab--pinned-sticky"),s.style.removeProperty("--dv-pinned-sticky-left"))}if(e.length===0){this._hasPinnedStickyStyling=!1;return}const t=e.map(i=>i.value.element.offsetLeft);e.forEach((i,s)=>{const r=i.value.element;r.classList.add("dv-tab--pinned-sticky"),r.style.setProperty("--dv-pinned-sticky-left",`${t[s]}px`)}),this._hasPinnedStickyStyling=!0}get showTabsOverflowControl(){return this._showTabsOverflowControl}set showTabsOverflowControl(e){if(this._showTabsOverflowControl!=e)if(this._showTabsOverflowControl=e,e){const t=new p_(this._tabsList);this._observerDisposable.value=new se(t,t.onDidChange(i=>{const s=i.hasScrollX||i.hasScrollY;this.toggleDropdown({reset:!s}),this._applyPinnedSticky(),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}),Z(this._tabsList,"scroll",()=>{this.toggleDropdown({reset:!1}),this._applyPinnedSticky(),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}))}else this._observerDisposable.value=Se.NONE}get element(){return this._element}get tabsListElement(){return this._tabsList}set voidContainer(e){var t;(t=this._voidContainerListeners)===null||t===void 0||t.dispose(),this._voidContainerListeners=null,this._reorder.voidContainerElement=e,e&&(this._voidContainerListeners=new se(Z(e,"dragover",i=>{this._animState&&i.preventDefault()}),Z(e,"drop",i=>{var s;!((s=this._animState)===null||s===void 0)&&s.sourceTabGroupId&&this._animState.currentInsertionIndex!==null&&(i.preventDefault(),i.stopPropagation(),this.handleVoidDrop())})))}handleVoidDrop(){var e,t;if(!(!((e=this._animState)===null||e===void 0)&&e.sourceTabGroupId))return!1;const i=this._animState.sourceTabGroupId,s=(t=this._animState.currentInsertionIndex)!==null&&t!==void 0?t:this._tabs.length;return this._animState=null,this._commitGroupMove(i,s),!0}get panels(){return this._tabs.map(e=>e.value.panel.id)}get size(){return this._tabs.length}get tabs(){return this._tabs.map(e=>e.value)}get direction(){return this._direction}set direction(e){if(this._direction!==e){this._direction=e,this._tabsList.setAttribute("aria-orientation",e==="vertical"?"vertical":"horizontal"),this._scrollbar&&(this._scrollbar.orientation=e),It(this._tabsList,"dv-horizontal","dv-vertical"),e==="vertical"?At(this._tabsList,"dv-tabs-container-vertical","dv-vertical"):(It(this._tabsList,"dv-tabs-container-vertical"),At(this._tabsList,"dv-horizontal"));for(const t of this._tabs)t.value.setDirection(e);this._tabGroupManager.updateDirection()}}constructor(e,t,i){super(),this.group=e,this.accessor=t,this._observerDisposable=new Me,this._pointerActivation=new Me,this._scrollbar=null,this._tabs=[],this._tabMap=new Map,this.selectedIndex=-1,this._showTabsOverflowControl=!1,this._overflowExclude=()=>!1,this._forcedOverflow=()=>!1,this._pinnedSticky=!1,this._hasPinnedStickyStyling=!1,this._direction="horizontal",this._voidContainerListeners=null,this._onTabDragStart=new G,this.onTabDragStart=this._onTabDragStart.event,this._onDrop=new G,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new G,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onOverflowTabsChange=new G,this.onOverflowTabsChange=this._onOverflowTabsChange.event,this._tabsList=document.createElement("div"),this._tabsList.className="dv-tabs-container",this._tabsList.setAttribute("role","tablist"),this._tabsList.setAttribute("aria-orientation",this._direction==="vertical"?"vertical":"horizontal"),this.showTabsOverflowControl=i.showTabsOverflowControl,t.options.scrollbars==="native"?this._element=this._tabsList:(this._scrollbar=new au(this._tabsList),this._scrollbar.orientation=this.direction,this._element=this._scrollbar.element,this.addDisposables(this._scrollbar)),this._tabGroupManager=new Cb({group:this.group,accessor:this.accessor,tabsList:this._tabsList,getTabs:()=>this._tabs,getTabMap:()=>this._tabMap,getDirection:()=>this._direction},{onChipContextMenu:(s,r)=>{var n;(n=this.accessor.contextMenuService)===null||n===void 0||n.showForChip(s,this.group,r)},onChipDragStart:(s,r,n)=>{this._handleChipDragStart(s,r,n)},onChipDragEnd:()=>{this._reorder.resetDragAnimation()},onChipDrop:(s,r)=>{this._handleChipDrop(s,r)}}),this._reorder=new Db(this),this.addDisposables(this._onOverflowTabsChange,this._observerDisposable,this._pointerActivation,this._onWillShowOverlay,this._onDrop,this._onTabDragStart,this._reorder,Tr.getInstance().onDragEnd(s=>{this._reorder.handlePointerDragEnd(s)}),Tr.getInstance().onDragMove(s=>{this._reorder.handlePointerDragMove(s.clientX,s.clientY)}),Z(this.element,"pointerdown",s=>{s.defaultPrevented||s.button===0&&this.accessor.doSetGroupActive(this.group)}),Z(this._tabsList,"wheel",s=>{const r=this._direction==="vertical",n=r?s.deltaY||s.deltaX:s.deltaX||s.deltaY;if(n===0)return;const o=r?this._tabsList.scrollHeight-this._tabsList.clientHeight:this._tabsList.scrollWidth-this._tabsList.clientWidth;if(o<=0)return;const a=r?this._tabsList.scrollTop:this._tabsList.scrollLeft;n<0&&a<=0||n>0&&a>=o||(s.preventDefault(),s.stopPropagation(),r?this._tabsList.scrollTop=a+n:this._tabsList.scrollLeft=a+n)},{passive:!1}),Z(this._tabsList,"keydown",s=>{this._onKeyDown(s)}),Z(this._tabsList,"dragover",s=>{this._reorder.processDragOver(s.clientX,s.clientY)&&s.preventDefault()},!0),Z(this._tabsList,"dragleave",s=>{this._reorder.processDragLeave(s.relatedTarget)},!0),Z(this._tabsList,"dragend",()=>{this._reorder.resetDragAnimation()}),Z(this._tabsList,"drop",s=>{var r,n,o;if(((r=this._animState)===null||r===void 0?void 0:r.currentInsertionIndex)==null||((n=this.accessor.options.theme)===null||n===void 0?void 0:n.tabAnimation)!=="smooth"&&!this._animState.sourceTabGroupId)return;s.stopPropagation(),s.preventDefault(),(o=this.group.model.dropTargetContainer)===null||o===void 0||(o=o.model)===null||o===void 0||o.clear();const a=this._animState;if(this._animState=null,this._pendingCollapse=!1,a.sourceTabGroupId){this._commitGroupMove(a.sourceTabGroupId,a.currentInsertionIndex);return}const l=a.currentInsertionIndex,h=a.sourceIndex,c=l-(h!==-1&&h<l?1:0),u=this.group.model.getTabGroupForPanel(a.sourceTabId);if(c===h&&!a.targetTabGroupId&&!u){this._reorder.uncollapseSourceTab(a.sourceTabId),this.resetTabTransforms();return}this._reorder.uncollapseSourceTab(a.sourceTabId);const p=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:s,index:c,targetTabGroupId:a.targetTabGroupId}),this.runFlipAnimation(p,a.sourceTabId,a.sourceIndex===-1,{from:Math.min(h,c),to:Math.max(h,c)})},!0),Se.from(()=>{var s;(s=this._voidContainerListeners)===null||s===void 0||s.dispose(),this._reorder.resetDragAnimation(),this._tabGroupManager.disposeAll();for(const{value:r,disposable:n}of this._tabs)n.dispose(),r.dispose();this._tabs=[],this._tabMap.clear()}))}indexOf(e){return this._tabs.findIndex(t=>t.value.panel.id===e)}getTabId(e){var t;return(t=this._tabMap.get(e))===null||t===void 0?void 0:t.value.element.id}getPanelForTab(e){for(const{value:t}of this._tabs)if(t.element===e||t.element.contains(e))return t.panel}isActive(e){return this.selectedIndex>-1&&this._tabs[this.selectedIndex].value===e}_onKeyDown(e){const t=this._tabs.findIndex(o=>o.value.element===e.target);if(t===-1)return;const i=this._direction==="vertical",s=i?"ArrowDown":"ArrowRight",r=i?"ArrowUp":"ArrowLeft",n=this._tabs.length-1;switch(e.key){case s:e.preventDefault(),this._focusTab(Math.min(t+1,n));break;case r:e.preventDefault(),this._focusTab(Math.max(t-1,0));break;case"Home":e.preventDefault(),this._focusTab(0);break;case"End":e.preventDefault(),this._focusTab(n);break;case"Enter":case" ":e.preventDefault(),this.accessor.withOrigin("user",()=>this._tabs[t].value.panel.api.setActive());break;case"Delete":case"Backspace":e.preventDefault(),this._closeTab(t);break}}_closeTab(e){var t,i,s,r,n;const o=(t=this._tabs[e])===null||t===void 0?void 0:t.value;if(!o)return;const a=(i=(s=(r=this._tabs[e+1])===null||r===void 0?void 0:r.value)!==null&&s!==void 0?s:(n=this._tabs[e-1])===null||n===void 0?void 0:n.value)===null||i===void 0?void 0:i.panel.id;if(o.panel.api.close(),a!==void 0){const l=this._tabs.findIndex(h=>h.value.panel.id===a);l>-1&&this._focusTab(l)}}_focusTab(e){for(let t=0;t<this._tabs.length;t++)this._tabs[t].value.element.tabIndex=t===e?0:-1;this._tabs[e].value.element.focus()}focusActiveTab(){var e;if(this._tabs.length===0)return;const t=(e=this.group.activePanel)===null||e===void 0?void 0:e.id,i=t?this._tabs.findIndex(s=>s.value.panel.id===t):-1;this._focusTab(i>-1?i:0)}setActivePanel(e){const t=this._direction==="vertical";for(const i of this._tabs){const s=e.id===i.value.panel.id;i.value.setActive(s),s&&this._scrollTabIntoView(i.value.element,t)}this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}_scrollTabIntoView(e,t){const i=e.parentElement;if(!i)return;const s=t?e.offsetTop:e.offsetLeft,r=t?e.offsetHeight:e.offsetWidth,n=t?i.scrollTop:i.scrollLeft,o=t?i.clientHeight:i.clientWidth;(s<n||s+r>n+o)&&(t?i.scrollTop=s:i.scrollLeft=s)}_activateOnPointerDown(e){if(!Tt(this.accessor.options).html5){this.group.model.openPanel(e);return}const t=requestAnimationFrame(()=>{this._tabMap.has(e.id)&&this.group.model.openPanel(e)});this._pointerActivation.value={dispose:()=>cancelAnimationFrame(t)}}openPanel(e,t=this._tabs.length){if(this._tabMap.has(e.id))return;const i=new pb(e,this.accessor,this.group);i.setContent(e.view.tab),this._direction!=="horizontal"&&i.setDirection(this._direction);const s={value:i,disposable:new se(i.onDragStart(r=>{var n;if(this._onTabDragStart.fire({nativeEvent:r,panel:e}),((n=this.accessor.options.theme)===null||n===void 0?void 0:n.tabAnimation)==="smooth"){const o=i.element.getBoundingClientRect().width,a=this._tabs.findIndex(l=>l.value===i);this._animState={sourceTabId:e.id,sourceIndex:a,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:o/2,sourceGapWidth:o,containerLeft:this._tabsList.getBoundingClientRect().left},this._pendingCollapse=!0,requestAnimationFrame(()=>{var l,h;this._pendingCollapse=!1,this._animState&&(this._tabsList.classList.contains("dv-tabs-container--wrap")||(i.element.style.transition="none",K(i.element,"dv-tab--dragging",!0),i.element.offsetHeight),(h=(l=this._animState).currentInsertionIndex)!==null&&h!==void 0||(l.currentInsertionIndex=a),this.applyDragOverTransforms(!0),i.element.style.removeProperty("transition"))})}}),i.onTabClick(r=>{r.defaultPrevented||this.group.api.location.type==="edge"&&(this.group.activePanel===e?this.group.api.isCollapsed()?this.group.api.expand():this.group.api.collapse():(this.group.model.openPanel(e),this.group.api.isCollapsed()&&this.group.api.expand()))}),i.onPointerDown(r=>{if(r.defaultPrevented)return;const n=!this.accessor.options.disableFloatingGroups,o=this.group.api.location.type==="floating"&&this.size===1;if(n&&!o&&r.shiftKey){r.preventDefault();const a=this.accessor.getGroupPanel(i.panel.id),{top:l,left:h}=i.element.getBoundingClientRect(),{top:c,left:u}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(a,{x:h-u,y:l-c,inDragMode:!0});return}r.button===0&&this.group.api.location.type!=="edge"&&this.group.activePanel!==e&&this._activateOnPointerDown(e)}),i.onDrop(r=>{const n=this._animState;this._animState=null,this._pendingCollapse=!1;const o=this._tabs.findIndex(u=>u.value===i);if(n){var a;const u=r.position==="right"?o+1:o;if(n.sourceTabGroupId){var l;this._commitGroupMove(n.sourceTabGroupId,(l=n.currentInsertionIndex)!==null&&l!==void 0?l:u);return}this._reorder.uncollapseSourceTab(n.sourceTabId);const p=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:r.nativeEvent,index:u,targetTabGroupId:n.targetTabGroupId}),((a=this.accessor.options.theme)===null||a===void 0?void 0:a.tabAnimation)==="smooth"&&this.runFlipAnimation(p,n.sourceTabId,n.sourceIndex===-1,n.sourceIndex===-1?void 0:{from:Math.min(n.sourceIndex,u),to:Math.max(n.sourceIndex,u)})}else{var h,c;const u=this._direction==="vertical"?"bottom":"right",p=r.position===u?o+1:o,f=Te(),m=f?this._tabs.findIndex(E=>E.value.panel.id===f.panelId):-1,g=p-(m!==-1&&m<p?1:0),_=(h=(c=this.group.model.getTabGroupForPanel(i.panel.id))===null||c===void 0?void 0:c.id)!==null&&h!==void 0?h:null;this._onDrop.fire({event:r.nativeEvent,index:g,targetTabGroupId:_})}}),i.onWillShowOverlay(r=>{this._onWillShowOverlay.fire(new As(r,{kind:"tab",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:Te}))}))};this.addTab(s,t),this._tabGroupManager.positionAllChips(),this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}delete(e){var t;((t=this._animState)===null||t===void 0?void 0:t.sourceTabId)===e&&(this.resetTabTransforms(),this._animState=null),this._tabGroupManager.cleanupTransition(e);const i=this.indexOf(e),s=this._tabs.splice(i,1)[0];if(this._tabMap.delete(e),s){const{value:r,disposable:n}=s;n.dispose(),r.dispose(),r.element.remove()}this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}addTab(e,t=this._tabs.length){if(t<0||t>this._tabs.length)throw new Error("invalid location");const i=t<this._tabs.length?this._tabs[t].value.element:null;this._tabsList.insertBefore(e.value.element,i),this._tabs=[...this._tabs.slice(0,t),e,...this._tabs.slice(t)],this._tabMap.set(e.value.panel.id,e),this.selectedIndex<0&&(this.selectedIndex=t)}toggleDropdown(e){const t=this._tabs.some(o=>!this._overflowExclude(o.value.panel.id)&&this._forcedOverflow(o.value.panel.id));if(e.reset&&!t){this._onOverflowTabsChange.fire({tabs:[],tabGroups:[],pinnedTabs:[],reset:!0});return}const i=this._tabs.filter(o=>!this._overflowExclude(o.value.panel.id)&&(this._forcedOverflow(o.value.panel.id)||!e.reset&&!fn(o.value.element,this._tabsList))).map(o=>o.value.panel.id),s=e.reset?[]:this._tabs.filter(o=>this._overflowExclude(o.value.panel.id)&&o.value.element.getBoundingClientRect().width>0&&!fn(o.value.element,this._tabsList)).map(o=>o.value.panel.id),r=new Set(i),n=[];for(const o of this.group.model.getTabGroups()){const a=this._tabGroupManager.chipRenderers.get(o.id),l=a&&!fn(a.chip.element,this._tabsList),h=o.panelIds.length>0&&o.panelIds.every(c=>r.has(c));if((l||h)&&(n.push(o.id),o.collapsed))for(const c of o.panelIds)r.has(c)||(r.add(c),i.push(c))}this._onOverflowTabsChange.fire({tabs:i,tabGroups:n,pinnedTabs:s,reset:!1})}updateDragAndDropState(){for(const e of this._tabs)e.value.updateDragAndDropState();this._tabGroupManager.updateDragAndDropState()}updateTabGroups(){this._tabGroupManager.update()}refreshTabGroupAccent(){this._tabGroupManager.refreshAccents()}_handleChipDragStart(e,t,i){var s;const r=e.panelIds[0],n=r?this._tabs.findIndex(h=>h.value.panel.id===r):-1,o=t.element.getBoundingClientRect();let a=o.width;for(const h of e.panelIds){const c=this._tabMap.get(h);c&&(a+=c.value.element.getBoundingClientRect().width)}if(this._animState={sourceTabId:"",sourceIndex:n,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.id,sourceGroupPanelIds:new Set(e.panelIds),sourceChipWidth:o.width,cursorOffsetFromDragLeft:i.clientX-o.left,sourceGapWidth:a,containerLeft:this._tabsList.getBoundingClientRect().left},((s=this.accessor.options.theme)===null||s===void 0?void 0:s.tabAnimation)!=="smooth")return;const l=new Set(e.panelIds);this._pendingCollapse=!0,requestAnimationFrame(()=>{var h,c;if(this._pendingCollapse=!1,!this._animState)return;for(const f of this._tabs)l.has(f.value.panel.id)&&(f.value.element.style.transition="none",K(f.value.element,"dv-tab--dragging",!0));const u=this._tabGroupManager.chipRenderers.get(e.id);u&&(u.chip.element.style.transition="none",K(u.chip.element,"dv-tab-group-chip--dragging",!0)),this._tabsList.offsetHeight;const p=this._tabGroupManager.groupUnderlines.get(e.id);p&&(p.style.display="none"),(c=(h=this._animState).currentInsertionIndex)!==null&&c!==void 0||(h.currentInsertionIndex=n),this.applyDragOverTransforms(!0);for(const f of this._tabs)l.has(f.value.panel.id)&&f.value.element.style.removeProperty("transition");u&&u.chip.element.style.removeProperty("transition")})}_handleChipDrop(e,t){const i=e.panelIds[0];if(!i)return;const s=this._tabs.findIndex(a=>a.value.panel.id===i);if(s===-1)return;const r=Te(),n=r?.groupId===this.group.id&&r?.panelId?this._tabs.findIndex(a=>a.value.panel.id===r.panelId):-1,o=s-(n!==-1&&n<s?1:0);this._onDrop.fire({event:t.nativeEvent,index:o,targetTabGroupId:null})}setExtendedDropZone(e){this._reorder.setExtendedDropZone(e)}setExternalInsertionIndex(e){this._reorder.setExternalInsertionIndex(e)}clearExternalAnimState(){this._reorder.clearExternalAnimState()}snapshotTabPositions(){return this._reorder.snapshotTabPositions()}handleDragOver(e){this._reorder.handleDragOver(e)}applyDragOverTransforms(e=!1){this._reorder.applyDragOverTransforms(e)}resetTabTransforms(){this._reorder.resetTabTransforms()}_commitGroupMove(e,t){this._reorder.commitGroupMove(e,t)}runFlipAnimation(e,t,i=!1,s){this._reorder.runFlipAnimation(e,t,i,s)}};function Pb(){const e=document.createElement("div");e.className="dv-tabs-overflow-dropdown-default";const t=document.createElement("span");t.textContent="";const i=nu();return e.appendChild(i),e.appendChild(t),{element:e,update:s=>{t.textContent=`${s.tabs}`}}}var Eb=class extends se{get onTabDragStart(){return this.tabs.onTabDragStart}get panels(){return this.tabs.panels}get size(){return this.tabs.size}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.element.style.display=e?"none":""}get direction(){return this._direction}set direction(e){this._direction=e,e==="vertical"?(At(this._element,"dv-groupview-header-vertical"),At(this.rightActionsContainer,"dv-right-actions-container-vertical"),this.tabs.direction=e):(It(this._element,"dv-groupview-header-vertical"),It(this.rightActionsContainer,"dv-right-actions-container-vertical"),this.tabs.direction=e)}get element(){return this._element}get tabsListElement(){return this.tabs.tabsListElement}constructor(e,t){super(),this.accessor=e,this.group=t,this._hidden=!1,this._direction="horizontal",this._dropIndexResolver=(i,s)=>s,this._pinnedRow=void 0,this.dropdownPart=null,this._overflowTabs=[],this._overflowTabGroups=[],this._overflowPinnedTabs=[],this._dropdownDisposable=new Me,this._onDrop=new G,this.onDrop=this._onDrop.event,this._onGroupDragStart=new G,this.onGroupDragStart=this._onGroupDragStart.event,this._onWillShowOverlay=new G,this.onWillShowOverlay=this._onWillShowOverlay.event,this._element=document.createElement("div"),this._element.className="dv-tabs-and-actions-container",K(this._element,"dv-full-width-single-tab",this.accessor.options.singleTabMode==="fullwidth"),this.rightActionsContainer=document.createElement("div"),this.rightActionsContainer.className="dv-right-actions-container",this.leftActionsContainer=document.createElement("div"),this.leftActionsContainer.className="dv-left-actions-container",this.preActionsContainer=document.createElement("div"),this.preActionsContainer.className="dv-pre-actions-container",this.tabs=new kb(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new fb(this.accessor,this.group),this.tabs.voidContainer=this.voidContainer.element,this._element.appendChild(this.preActionsContainer),this._element.appendChild(this.tabs.element),this._element.appendChild(this.leftActionsContainer),this._element.appendChild(this.voidContainer.element),this._element.appendChild(this.rightActionsContainer),this.tabs.setExtendedDropZone(this._element),this.addDisposables(this.tabs.onDrop(i=>this._onDrop.fire(i)),this.tabs.onWillShowOverlay(i=>this._onWillShowOverlay.fire(i)),e.onDidOptionsChange(()=>{this.tabs.showTabsOverflowControl=!e.options.disableTabsOverflowList}),this.tabs.onOverflowTabsChange(i=>{this.toggleDropdown(i)}),this.tabs,this._onWillShowOverlay,this._onDrop,this._onGroupDragStart,this.voidContainer,this.voidContainer.onDragStart(i=>{this._onGroupDragStart.fire({nativeEvent:i,group:this.group})}),this.voidContainer.onDrop(i=>{this.tabs.handleVoidDrop()||this._onDrop.fire({event:i.nativeEvent,index:this.tabs.size})}),this.voidContainer.onWillShowOverlay(i=>{this._onWillShowOverlay.fire(new As(i,{kind:"header_space",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:Te}))}),Z(this.leftActionsContainer,"dragleave",i=>{const s=i.relatedTarget;!this.leftActionsContainer.contains(s)&&!this._element.contains(s)&&this.tabs.clearExternalAnimState()}),Z(this.voidContainer.element,"dragleave",i=>{const s=i.relatedTarget;this.voidContainer.element.contains(s)||(this._element.contains(s)?this.tabs.setExternalInsertionIndex(null):this.tabs.clearExternalAnimState())}),Z(this.voidContainer.element,"pointerdown",i=>{if(!i.defaultPrevented&&!this.accessor.options.disableFloatingGroups&&i.shiftKey&&this.group.api.location.type!=="floating"&&this.group.api.location.type!=="edge"){i.preventDefault();const{top:s,left:r}=this.element.getBoundingClientRect(),{top:n,left:o}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(this.group,{x:r-o+20,y:s-n+20,inDragMode:!0})}}))}show(){this.hidden||(this.element.style.display="")}hide(){this._element.style.display="none"}setRightActionsElement(e){this.rightActions!==e&&(this.rightActions&&(this.rightActions.remove(),this.rightActions=void 0),e&&(this.rightActionsContainer.appendChild(e),this.rightActions=e))}setLeftActionsElement(e){this.leftActions!==e&&(this.leftActions&&(this.leftActions.remove(),this.leftActions=void 0),e&&(this.leftActionsContainer.appendChild(e),this.leftActions=e))}setPrefixActionsElement(e){this.preActions!==e&&(this.preActions&&(this.preActions.remove(),this.preActions=void 0),e&&(this.preActionsContainer.appendChild(e),this.preActions=e))}isActive(e){return this.tabs.isActive(e)}indexOf(e){return this.tabs.indexOf(e)}getTabId(e){return this.tabs.getTabId(e)}getPanelForTab(e){return this.tabs.getPanelForTab(e)}setActive(e){}delete(e){this.tabs.delete(e),this.updateClassnames()}setActivePanel(e){this.tabs.setActivePanel(e)}focusActiveTab(){this.tabs.focusActiveTab()}openPanel(e,t=this.tabs.size){this.tabs.openPanel(e,t),this.updateClassnames()}closePanel(e){this.delete(e.id)}setOverflowExclude(e){this.tabs.setOverflowExclude(e)}setForcedOverflow(e){this.tabs.setForcedOverflow(e)}setPinnedSticky(e){this.tabs.setPinnedSticky(e)}refreshOverflow(){this.tabs.refreshOverflow()}setPinnedRow(e){this._pinnedRow!==e&&(this._pinnedRow&&this._pinnedRow.remove(),this._pinnedRow=e,e&&(e.classList.add("dv-pinned-row"),this._element.insertBefore(e,this._element.firstChild)),K(this._element,"dv-tabs-and-actions-container--pinned-row",!!e))}setDropIndexResolver(e){this._dropIndexResolver=e}resolveDropIndex(e,t){return this._dropIndexResolver(e,t)}updateClassnames(){K(this._element,"dv-single-tab",this.size===1)}toggleDropdown(e){const t=e.reset?[]:e.tabs,i=e.reset?[]:e.tabGroups,s=e.reset?[]:e.pinnedTabs;this._overflowTabs=t,this._overflowTabGroups=i,this._overflowPinnedTabs=s;const r=this._overflowTabs.length+this._overflowPinnedTabs.length;if(r>0&&this.dropdownPart){this.dropdownPart.update({tabs:r});return}if(r===0){this._dropdownDisposable.dispose();return}const n=document.createElement("div");n.className="dv-tabs-overflow-dropdown-root";const o=Pb();o.update({tabs:r}),this.dropdownPart=o,n.appendChild(o.element),this.rightActionsContainer.prepend(n),this._dropdownDisposable.value=new se(Se.from(()=>{var a,l;n.remove(),(a=this.dropdownPart)===null||a===void 0||(l=a.dispose)===null||l===void 0||l.call(a),this.dropdownPart=null}),Z(n,"pointerdown",a=>{a.preventDefault()},{capture:!0}),Z(n,"click",a=>{const l=S_(n),h={x:a.clientX,y:a.clientY,zIndex:l?.style.zIndex?`calc(${l.style.zIndex} * 2)`:void 0},c=this.createOverflowRenderContext(n,h),u=this.accessor.advancedOverflowService;u?u.renderOverflow({group:this.group,overflowTabs:[...this._overflowTabs],overflowTabGroups:[...this._overflowTabGroups],pinnedOverflowTabs:[...this._overflowPinnedTabs],context:c}):c.open(this.renderFreeOverflowList(c))}))}createOverflowRenderContext(e,t){const i=new Set(this._overflowTabGroups),s=this.group.model.getTabGroups(),r=new Map,n=new Map;for(const l of s)if(n.set(l.id,l),i.has(l.id))for(const h of l.panelIds)r.set(h,l);const o=()=>this.accessor.getPopupServiceForGroup(this.group),a=l=>{const h=document.createElement("div");h.className="dv-tabs-overflow-group-header";const c=document.createElement("span");c.className="dv-tabs-overflow-group-color",Ma(c,l.color,this.accessor.tabGroupColorPalette),h.appendChild(c);const u=document.createElement("span");if(u.className="dv-tabs-overflow-group-label",u.textContent=l.label||l.id,h.appendChild(u),l.collapsed){const p=document.createElement("span");p.className="dv-tabs-overflow-group-collapsed-badge",p.textContent=`${l.panelIds.length}`,h.appendChild(p)}return h.addEventListener("click",()=>{o().close(),l.collapsed&&l.expand();const p=l.panelIds[0];if(p){const f=this.group.panels.find(m=>m.id===p);this.accessor.withOrigin("user",()=>f?.api.setActive())}}),h};return{overflowGroupIdForPanel:l=>{var h;return(h=r.get(l))===null||h===void 0?void 0:h.id},buildGroupHeader:l=>{const h=n.get(l);if(!(!h||!i.has(h.id)))return a(h)},buildPinnedHeader:()=>{const l=document.createElement("div");l.className="dv-tabs-overflow-group-header dv-tabs-overflow-pinned-header";const h=ru();h.classList.add("dv-tabs-overflow-pinned-icon"),l.appendChild(h);const c=document.createElement("span");return c.className="dv-tabs-overflow-group-label",c.textContent="Pinned",l.appendChild(c),l},buildRow:l=>{const h=this.group.panels.find(g=>g.id===l);if(!h)return;const c=this.tabs.tabs.find(g=>g.panel.id===l),u=r.get(l),p=h.view.createTabRenderer("headerOverflow").element,f=document.createElement("div");K(f,"dv-tab",!0),K(f,"dv-active-tab",h.api.isActive),K(f,"dv-inactive-tab",!h.api.isActive),u&&K(f,"dv-tab--grouped",!0);const m=()=>{u?.collapsed&&u.expand(),c?.element.scrollIntoView({block:"nearest",inline:"nearest"}),this.accessor.withOrigin("user",()=>h.api.setActive())};return f.addEventListener("click",g=>{o().close(),!g.defaultPrevented&&m()}),f.appendChild(p),{element:f,panel:h,activate:()=>{o().close(),m()}}},open:l=>{o().openPopover(l,t)},close:()=>o().close(),focusTrigger:()=>{e.tabIndex=-1,e.focus()}}}renderFreeOverflowList(e){const t=document.createElement("div");t.style.overflow="auto",t.className="dv-tabs-overflow-container";const i=this._overflowPinnedTabs.map(r=>e.buildRow(r)).filter(r=>r!=null);if(i.length>0){t.appendChild(e.buildPinnedHeader());for(const r of i)t.appendChild(r.element)}const s=new Set;for(const r of this.tabs.tabs.filter(n=>this._overflowTabs.includes(n.panel.id))){const n=e.overflowGroupIdForPanel(r.panel.id);if(n&&!s.has(n)){s.add(n);const a=e.buildGroupHeader(n);a&&t.appendChild(a)}const o=e.buildRow(r.panel.id);o&&t.appendChild(o.element)}return t}updateDragAndDropState(){this.tabs.updateDragAndDropState(),this.voidContainer.updateDragAndDropState()}updateTabGroups(){this.tabs.updateTabGroups()}refreshTabGroupAccent(){this.tabs.refreshTabGroupAccent()}},Tb=class extends se{get label(){return this._label}get color(){return this._color}get componentParams(){return this._componentParams}setLabel(e){this.isDisposed||this._label===e||(this._label=e,this._onDidChange.fire())}setColor(e){if(this.isDisposed)return;const t=e===""?void 0:e;this._color!==t&&(this._color=t,this._onDidChange.fire())}setComponentParams(e){this.isDisposed||(this._componentParams=e,this._onDidChange.fire())}get collapsed(){return this._collapsed}get panelIds(){return this._panelIds}get size(){return this._panelIds.length}get isEmpty(){return this._panelIds.length===0}constructor(e,t){var i,s;super(),this.id=e,this._collapsed=!1,this._panelIds=[],this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._onDidPanelChange=new G,this.onDidPanelChange=this._onDidPanelChange.event,this._onDidCollapseChange=new G,this.onDidCollapseChange=this._onDidCollapseChange.event,this._onDidDestroy=new G,this.onDidDestroy=this._onDidDestroy.event,this._label=(i=t?.label)!==null&&i!==void 0?i:"",this._color=t?.color===""?void 0:t?.color,this._collapsed=(s=t?.collapsed)!==null&&s!==void 0?s:!1,this._componentParams=t?.componentParams,this.addDisposables(this._onDidChange,this._onDidPanelChange,this._onDidCollapseChange,this._onDidDestroy)}addPanel(e,t){if(this.isDisposed||this._panelIds.includes(e))return;const i=t===void 0?this._panelIds.length:Math.max(0,Math.min(t,this._panelIds.length));this._panelIds.splice(i,0,e),this._onDidPanelChange.fire({panelId:e,type:"add"})}removePanel(e){if(this.isDisposed)return!1;const t=this._panelIds.indexOf(e);return t===-1?!1:(this._panelIds.splice(t,1),this._onDidPanelChange.fire({panelId:e,type:"remove"}),!0)}indexOfPanel(e){return this._panelIds.indexOf(e)}containsPanel(e){return this._panelIds.includes(e)}collapse(){this.isDisposed||this._collapsed||(this._collapsed=!0,this._onDidCollapseChange.fire(!0))}expand(){this.isDisposed||!this._collapsed||(this._collapsed=!1,this._onDidCollapseChange.fire(!1))}toggle(){this._collapsed?this.expand():this.collapse()}toJSON(){const e={id:this.id,collapsed:this._collapsed,panelIds:[...this._panelIds]};return this._label&&(e.label=this._label),this._color!==void 0&&(e.color=this._color),this._componentParams!==void 0&&(e.componentParams=this._componentParams),e}dispose(){this._onDidDestroy.fire(),super.dispose()}},Ga=class extends Ea{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get panel(){return this.options.panel}get group(){return this.options.group}get api(){return this.options.api}constructor(e){super(),this.options=e}getData(){return this.options.getData()}},fu=class extends Ga{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}},Ib=class extends se{get tabGroups(){return this._tabGroups}get element(){throw new Error("dockview: not supported")}get activePanel(){return this._activePanel}get contentContainerId(){return this.contentContainer.element.id}get contentDropTarget(){return this.contentContainer.dropTarget}get locked(){return this._locked}set locked(e){this._locked=e,K(this.container,"dv-locked-groupview",e==="no-drop-target"||e)}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return this._panels.length===0}get hasWatermark(){return!!(this.watermark&&this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get tabsListElement(){return this.tabsContainer.tabsListElement}getPanelForTab(e){return this.tabsContainer.getPanelForTab(e)}get isContentFocused(){return document.activeElement?Zn(document.activeElement,this.contentContainer.element):!1}get headerPosition(){var e;return(e=this._headerPosition)!==null&&e!==void 0?e:"top"}set headerPosition(e){var t;this._headerPosition=e,this.invalidateHeaderSize(),It(this.container,"dv-groupview-header-top","dv-groupview-header-bottom","dv-groupview-header-left","dv-groupview-header-right"),At(this.container,`dv-groupview-header-${e}`);const i=e==="top"||e==="bottom"?"horizontal":"vertical",s=this._headerDirection;if(this._headerDirection=i,this.tabsContainer.direction=i,this.header.direction=i,!((t=this._activePanel)===null||t===void 0)&&t.layout){const{width:n,height:o}=this.contentDimensions();this._activePanel.layout(n,o)}if(this.updateHeaderActions(),s!==void 0&&s!==i){var r;(r=this.groupPanel)===null||r===void 0||r.api._onDidHeaderDirectionChange.fire({direction:i,position:e})}}get location(){return this._location}set location(e){this._location=e,K(this.container,"dv-groupview-floating",!1),K(this.container,"dv-groupview-popout",!1),K(this.container,"dv-groupview-edge",!1);const t=i=>{this.contentContainer.dropTarget.setTargetZones(i),this.contentContainer.pointerDropTarget.setTargetZones(i)};switch(e.type){case"grid":t(["top","bottom","left","right","center"]);break;case"floating":t(["top","bottom","left","right","center"]),K(this.container,"dv-groupview-floating",!0);break;case"popout":t(["top","bottom","left","right","center"]),K(this.container,"dv-groupview-popout",!0);break;case"edge":t(["center"]),K(this.container,"dv-groupview-edge",!0);break}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,i,s,r){var n,o;super(),this.container=e,this.accessor=t,this.id=i,this.options=s,this.groupPanel=r,this._isGroupActive=!1,this._locked=!1,this._location={type:"grid"},this.mostRecentlyUsed=[],this._overwriteRenderContainer=null,this._overwriteDropTargetContainer=null,this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._panelDisposables=new Map,this._tabGroupDisposables=new Map,this._pendingMicrotaskDisposables=new Set,this._onMove=new G,this.onMove=this._onMove.event,this._onDidDrop=new G,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new G,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new G,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onTabDragStart=new G,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new G,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new G,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPanelTitleChange=new G,this.onDidPanelTitleChange=this._onDidPanelTitleChange.event,this._onDidPanelParametersChange=new G,this.onDidPanelParametersChange=this._onDidPanelParametersChange.event,this._onDidRemovePanel=new G,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new G,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onUnhandledDragOver=new G,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this._tabGroups=[],this._tabGroupMap=new Map,this._panelToTabGroup=new Map,this._tabGroupIdCounter=0,this._pendingTabGroupUpdate=!1,this._onDidCreateTabGroup=new G,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new G,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new G,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new G,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new G,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new G,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,K(this.container,"dv-groupview",!0),this.container.setAttribute("role","region"),this._api=new Aa(this.accessor),this.tabsContainer=new Eb(this.accessor,this.groupPanel),this.contentContainer=new nb(this.accessor,this),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!s.hideHeader,this.locked=(n=s.locked)!==null&&n!==void 0?n:!1,this.headerPosition=(o=s.headerPosition)!==null&&o!==void 0?o:t.defaultHeaderPosition,this.addDisposables(ji(this.tabsContainer.element,()=>{if(this.isDisposed)return;const a=this.measureHeaderSize();a!==this._cachedHeaderSize&&(this._cachedHeaderSize=a,this.layout(this._width,this._height))}),this._onDidPanelTitleChange.event(()=>this.updateAccessibleLabel()),this._onTabDragStart,this._onGroupDragStart,this._onWillShowOverlay,this.tabsContainer.onTabDragStart(a=>{this._onTabDragStart.fire(a)}),this.tabsContainer.onGroupDragStart(a=>{this._onGroupDragStart.fire(a)}),this.tabsContainer.onDrop(a=>{var l;const h=Te(),c=(l=h?.panelId)!==null&&l!==void 0?l:null,u=c?this.tabsContainer.resolveDropIndex(c,a.index):a.index;if(this.handleDropEvent("header",a.event,"center",u),c&&a.targetTabGroupId){const p=this._tabGroupMap.get(a.targetTabGroupId);let f;if(p){const m=this._panels.findIndex(g=>g.id===c);if(m!==-1){f=0;for(const g of p.panelIds)this._panels.findIndex(_=>_.id===g)<m&&f++}}this.addPanelToTabGroup(a.targetTabGroupId,c,f)}else c&&a.targetTabGroupId===null&&this.removePanelFromTabGroup(c)}),this.contentContainer.onDidFocus(()=>{this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.onDidBlur(()=>{}),this.contentContainer.dropTarget.onDrop(a=>{this.handleDropEvent("content",a.nativeEvent,a.position,void 0,a.edge)}),this.contentContainer.pointerDropTarget.onDrop(a=>{this.handleDropEvent("content",a.nativeEvent,a.position,void 0,a.edge)}),this.tabsContainer.onWillShowOverlay(a=>{this._onWillShowOverlay.fire(a)}),this.contentContainer.dropTarget.onWillShowOverlay(a=>{this._onWillShowOverlay.fire(new As(a,{kind:"content",panel:this.activePanel,api:this._api,group:this.groupPanel,getData:Te}))}),this.contentContainer.pointerDropTarget.onWillShowOverlay(a=>{this._onWillShowOverlay.fire(new As(a,{kind:"content",panel:this.activePanel,api:this._api,group:this.groupPanel,getData:Te}))}),this._onMove,this._onDidChange,this._onDidDrop,this._onWillDrop,this._onDidAddPanel,this._onDidRemovePanel,this._onDidActivePanelChange,this._onUnhandledDragOver,this._onDidPanelTitleChange,this._onDidPanelParametersChange,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,this._onDidCreateTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidDestroyTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidAddPanelToTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidRemovePanelFromTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupChange.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupCollapsedChange.event(()=>{this._scheduleTabGroupUpdate()}))}_scheduleTabGroupUpdate(){this._pendingTabGroupUpdate||(this._pendingTabGroupUpdate=!0,queueMicrotask(()=>{this._pendingTabGroupUpdate=!1,this.isDisposed||this.tabsContainer.updateTabGroups()}))}_bracketTabGroupMutation(e){return this.accessor.mutation?this.accessor.mutation("tab-group",e):e()}createTabGroup(e){return this._bracketTabGroupMutation(()=>this._doCreateTabGroup(e))}_doCreateTabGroup(e){var t;const i=(t=e?.id)!==null&&t!==void 0?t:`tg-${this.id}-${this._tabGroupIdCounter++}`,s=new Tb(i,{label:e?.label,color:e?.color,collapsed:e?.collapsed,componentParams:e?.componentParams});return this._tabGroups.push(s),this._tabGroupMap.set(i,s),this._tabGroupDisposables.set(i,new se(s.onDidChange(()=>{this._onDidTabGroupChange.fire({tabGroup:s})}),s.onDidCollapseChange(r=>{r?this._handleGroupCollapse(s):this._handleGroupExpand(s),this._onDidTabGroupCollapsedChange.fire({tabGroup:s})}),s.onDidDestroy(()=>{this._removeTabGroupInternal(s)}))),this._onDidCreateTabGroup.fire({tabGroup:s}),s}dissolveTabGroup(e){const t=this._tabGroupMap.get(e);t&&this._bracketTabGroupMutation(()=>{const i=[...t.panelIds];for(const s of i)t.removePanel(s),this._panelToTabGroup.delete(s),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:s});t.dispose()})}addPanelToTabGroup(e,t,i){const s=this._tabGroupMap.get(e);if(!s||!this._panels.some(n=>n.id===t))return;const r=this.getTabGroupForPanel(t);r?.id!==e&&this._bracketTabGroupMutation(()=>{r&&this.removePanelFromTabGroup(t),s.addPanel(t,i),this._panelToTabGroup.set(t,s),this._enforceContiguity(s,t),this._onDidAddPanelToTabGroup.fire({tabGroup:s,panelId:t})})}movePanelWithinGroup(e,t,i){const s=this._tabGroupMap.get(e);s?.containsPanel(t)&&(s.removePanel(t),s.addPanel(t,i),this._enforceContiguity(s,t),this.tabsContainer.updateTabGroups())}movePanelBetweenGroups(e,t,i){const s=this._findTabGroupForPanel(e),r=this._tabGroupMap.get(t);r&&(s&&(s.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:s,panelId:e}),s.isEmpty&&s.dispose()),r.addPanel(e,i),this._panelToTabGroup.set(e,r),this._enforceContiguity(r,e),this._onDidAddPanelToTabGroup.fire({tabGroup:r,panelId:e}))}moveTabGroup(e,t){const i=this._tabGroupMap.get(e);if(!i||i.panelIds.length===0)return;const s=new Set(i.panelIds),r=i.panelIds.map(l=>this._panels.find(h=>h.id===l)).filter(l=>l!==void 0);if(r.length===0)return;let n=0;for(let l=0;l<Math.min(t,this._panels.length);l++)s.has(this._panels[l].id)&&n++;for(const l of r){const h=this._panels.indexOf(l);h!==-1&&this._panels.splice(h,1)}const o=t-n,a=Math.max(0,Math.min(o,this._panels.length));this._panels.splice(a,0,...r);for(const l of this._panels)this.tabsContainer.delete(l.id);for(let l=0;l<this._panels.length;l++)this.tabsContainer.openPanel(this._panels[l],l);this.tabsContainer.updateTabGroups()}_enforceContiguity(e,t){const i=this._panels.find(a=>a.id===t);if(!i)return;const s=e.indexOfPanel(t),r=this._computeGlobalIndex(e,s),n=this._panels.indexOf(i);if(n===r)return;this._panels.splice(n,1);const o=r>n?r-1:r;this._panels.splice(o,0,i),this.tabsContainer.delete(t),this.tabsContainer.openPanel(i,o)}_computeGlobalIndex(e,t){const i=e.panelIds;if(i.length<=1){const s=this._panels.find(r=>r.id===i[0]);return s?this._panels.indexOf(s):this._panels.length}for(let s=0;s<i.length;s++){if(s===t)continue;const r=this._panels.find(n=>n.id===i[s]);if(r){const n=this._panels.indexOf(r);return Math.max(0,n+(t-s))}}return this._panels.length}removePanelFromTabGroup(e){const t=this._findTabGroupForPanel(e);t&&this._bracketTabGroupMutation(()=>{t.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:e}),t.isEmpty&&t.dispose()})}getTabGroups(){return this._tabGroups}updateTabGroups(){this.tabsContainer.updateTabGroups()}refreshTabGroupAccent(){this.tabsContainer.refreshTabGroupAccent()}refreshWatermark(){if(this.watermark){var e,t;this.watermark.element.remove(),(e=(t=this.watermark).dispose)===null||e===void 0||e.call(t),this.watermark=void 0}this.updateContainer()}getTabGroupForPanel(e){return this._findTabGroupForPanel(e)}_findTabGroupForPanel(e){return this._panelToTabGroup.get(e)}_removeTabGroupInternal(e){const t=this._tabGroups.indexOf(e);if(t!==-1){this._tabGroups.splice(t,1),this._tabGroupMap.delete(e.id);for(const s of e.panelIds)this._panelToTabGroup.delete(s);this._onDidDestroyTabGroup.fire({tabGroup:e});const i=this._tabGroupDisposables.get(e.id);this._tabGroupDisposables.delete(e.id),i&&(this._pendingMicrotaskDisposables.add(i),queueMicrotask(()=>{this._pendingMicrotaskDisposables.delete(i),i.dispose()}))}}_handleGroupCollapse(e){if(!this._activePanel||!e.containsPanel(this._activePanel.id))return;const t=this._panels.indexOf(this._activePanel);for(let i=t+1;i<this._panels.length;i++){const s=this._panels[i],r=this._findTabGroupForPanel(s.id);if(!r?.collapsed){this.doSetActivePanel(s),this.updateContainer();return}}for(let i=t-1;i>=0;i--){const s=this._panels[i],r=this._findTabGroupForPanel(s.id);if(!r?.collapsed){this.doSetActivePanel(s),this.updateContainer();return}}this.contentContainer.closePanel(),this.doSetActivePanel(void 0),this.updateContainer()}_handleGroupExpand(e){if(this._activePanel)return;const t=e.panelIds[0];if(t){const i=this._panels.find(s=>s.id===t);i&&(this.doSetActivePanel(i),this.updateContainer())}}restoreTabGroups(e){for(const t of e){const i=/-(\d+)$/.exec(t.id);if(i){const s=Number.parseInt(i[1],10)+1;s>this._tabGroupIdCounter&&(this._tabGroupIdCounter=s)}}for(const t of e){const i=this.createTabGroup({id:t.id,label:t.label,color:t.color,componentParams:t.componentParams}),s=this._tabGroupMap.get(i.id);for(const r of t.panelIds)this._panels.some(n=>n.id===r)&&(i.addPanel(r),this._panelToTabGroup.set(r,s),this._enforceContiguity(s,r));t.collapsed&&i.collapse(),i.isEmpty&&i.dispose()}}focusContent(){this.contentContainer.element.focus()}focusActiveTab(){this.tabsContainer.focusActiveTab()}set renderContainer(e){if(this.panels.forEach(t=>{this.renderContainer.detatch(t)}),this._overwriteRenderContainer=e,this.panels.forEach(t=>{this.rerender(t)}),this._activePanel){this.contentContainer.renderPanel(this._activePanel,{asActive:!0});const{width:t,height:i}=this.contentDimensions();this._activePanel.layout(t,i)}}get renderContainer(){var e;return(e=this._overwriteRenderContainer)!==null&&e!==void 0?e:this.accessor.overlayRenderContainer}set dropTargetContainer(e){this._overwriteDropTargetContainer=e}get dropTargetContainer(){var e;return this._location.type==="floating"&&this.accessor.rootDropTargetContainer.disabled?this.accessor.floatingDropTargetContainer:(e=this._overwriteDropTargetContainer)!==null&&e!==void 0?e:this.accessor.rootDropTargetContainer}initialize(){this.options.panels&&this.options.panels.forEach(e=>{this.doAddPanel(e)}),this.options.activePanel&&this.openPanel(this.options.activePanel),this.setActive(this.isActive,!0),this.updateContainer(),this.updateHeaderActions()}updateHeaderActions(){var e;(e=this.accessor.headerActionsService)===null||e===void 0||e.refresh(this.groupPanel)}attachHeaderAction(e,t){switch(e){case"left":this.tabsContainer.setLeftActionsElement(t);break;case"right":this.tabsContainer.setRightActionsElement(t);break;case"prefix":this.tabsContainer.setPrefixActionsElement(t);break}}rerender(e){this.contentContainer.renderPanel(e,{asActive:!1})}indexOf(e){return this.tabsContainer.indexOf(e.id)}toJSON(){var e;const t={views:this.tabsContainer.panels,activeView:(e=this._activePanel)===null||e===void 0?void 0:e.id,id:this.id};return this.locked!==!1&&(t.locked=this.locked),this.header.hidden&&(t.hideHeader=!0),this.headerPosition!=="top"&&(t.headerPosition=this.headerPosition),this._tabGroups.length>0&&(t.tabGroups=this._tabGroups.map(i=>i.toJSON())),t}moveToNext(e){var t,i,s;(t=e)!==null&&t!==void 0||(e={}),(s=(i=e).panel)!==null&&s!==void 0||(i.panel=this.activePanel);const r=e.panel?this.panels.indexOf(e.panel):-1;let n;if(r<this.panels.length-1)n=r+1;else{if(e.suppressRoll)return;n=0}this.openPanel(this.panels[n])}moveToPrevious(e){var t,i,s;if((t=e)!==null&&t!==void 0||(e={}),(s=(i=e).panel)!==null&&s!==void 0||(i.panel=this.activePanel),!e.panel)return;const r=this.panels.indexOf(e.panel);let n;if(r>0)n=r-1;else{if(e.suppressRoll)return;n=this.panels.length-1}this.openPanel(this.panels[n])}containsPanel(e){return this.panels.includes(e)}init(e){}update(e){}focus(){var e;(e=this._activePanel)===null||e===void 0||e.focus()}openPanel(e,t={}){(typeof t.index!="number"||t.index>this.panels.length)&&(t.index=this.panels.length);const i=!!t.skipSetActive;if(e.updateParentGroup(this.groupPanel,{skipSetActive:t.skipSetActive}),this.doAddPanel(e,t.index,{skipSetActive:i}),this.invalidateHeaderSize(),this._activePanel===e){this.contentContainer.renderPanel(e,{asActive:!0});return}i||this.doSetActivePanel(e),t.skipSetGroupActive||this.accessor.doSetGroupActive(this.groupPanel),t.skipSetActive||this.updateContainer()}removePanel(e,t){const i=typeof e=="string"?e:e.id,s=this._panels.find(r=>r.id===i);if(!s)throw new Error("invalid operation");return this._removePanel(s,t)}closeAllPanels(){if(this.panels.length>0){const e=[...this.panels];for(const t of e)this.doClose(t)}else this.accessor.removeGroup(this.groupPanel)}closePanel(e){this.doClose(e)}doClose(e){const t=this.panels.length===1&&this.accessor.groups.length===1;this.accessor.removePanel(e,t&&this.accessor.options.noPanelsOverlay==="emptyGroup"?{removeEmptyGroup:!1}:void 0)}isPanelActive(e){return this._activePanel===e}updateActions(e){this.tabsContainer.setRightActionsElement(e)}setActive(e,t=!1){if(!(!t&&this.isActive===e)){if(this._isGroupActive=e,K(this.container,"dv-active-group",e),K(this.container,"dv-inactive-group",!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0){const i=this._panels.find(s=>{const r=this._findTabGroupForPanel(s.id);return!r?.collapsed});i&&this.doSetActivePanel(i)}this.updateContainer()}}layout(e,t){var i;this._width=e,this._height=t;const{width:s,height:r}=this.contentDimensions();this.contentContainer.layout(s,r),!((i=this._activePanel)===null||i===void 0)&&i.layout&&this._activePanel.layout(s,r)}relayout(){this.invalidateHeaderSize(),this.layout(this._width,this._height)}measureHeaderSize(){const e=this.tabsContainer.element;return this.headerPosition==="top"||this.headerPosition==="bottom"?e.offsetHeight:e.offsetWidth}invalidateHeaderSize(){this._cachedHeaderSize=void 0}contentDimensions(){var e;const t=this.headerPosition==="top"||this.headerPosition==="bottom",i=(e=this._cachedHeaderSize)!==null&&e!==void 0?e:this._cachedHeaderSize=this.measureHeaderSize();return{width:t?this._width:Math.max(0,this._width-i),height:t?Math.max(0,this._height-i):this._height}}_removePanel(e,t){const i=this._activePanel===e;if(this.doRemovePanel(e),this.invalidateHeaderSize(),i&&this.panels.length>0){const s=this.mostRecentlyUsed[0];this.openPanel(s,{skipSetActive:t?.skipSetActive,skipSetGroupActive:t?.skipSetActiveGroup})}return this._activePanel&&this.panels.length===0&&this.doSetActivePanel(void 0),t?.skipSetActive||this.updateContainer(),e}doRemovePanel(e){const t=this.panels.indexOf(e);if(this._activePanel===e&&this.contentContainer.closePanel(),this.tabsContainer.delete(e.id),this._panels.splice(t,1),this.mostRecentlyUsed.includes(e)){const s=this.mostRecentlyUsed.indexOf(e);this.mostRecentlyUsed.splice(s,1)}const i=this._panelDisposables.get(e.id);i&&(i.dispose(),this._panelDisposables.delete(e.id)),this.removePanelFromTabGroup(e.id),this._onDidRemovePanel.fire({panel:e})}doAddPanel(e,t=this.panels.length,i){const s=this._panels.indexOf(e)>-1;this.tabsContainer.show(),this.contentContainer.show(),this.tabsContainer.openPanel(e,t),i?.skipSetActive?e.api.renderer==="always"&&this.contentContainer.renderPanel(e,{asActive:!1}):this.contentContainer.openPanel(e),!s&&(this.updateMru(e),this.panels.splice(t,0,e),this._panelDisposables.set(e.id,new se(e.api.onDidTitleChange(r=>this._onDidPanelTitleChange.fire(r)),e.api.onDidParametersChange(r=>this._onDidPanelParametersChange.fire(r)))),this._onDidAddPanel.fire({panel:e}))}doSetActivePanel(e){if(this._activePanel!==e){if(this._activePanel=e,e){var t,i,s;this.tabsContainer.setActivePanel(e),this.contentContainer.setLabelledBy(this.tabsContainer.getTabId(e.id)),this.contentContainer.openPanel(e);const{width:r,height:n}=this.contentDimensions();e.layout(r,n),this.updateMru(e),this.contentContainer.refreshFocusState(),this._onDidActivePanelChange.fire({panel:e,origin:(t=(i=(s=this.accessor).currentOrigin)===null||i===void 0?void 0:i.call(s))!==null&&t!==void 0?t:"user"})}this.updateAccessibleLabel()}}updateAccessibleLabel(){var e;const t=(e=this._activePanel)===null||e===void 0?void 0:e.title;t?this.container.setAttribute("aria-label",t):this.container.removeAttribute("aria-label")}updateMru(e){this.mostRecentlyUsed.includes(e)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(e),1),this.mostRecentlyUsed=[e,...this.mostRecentlyUsed]}updateContainer(){this.panels.forEach(s=>s.runEvents());const e=this.isEmpty||!this._activePanel;if(e&&!this.watermark){const s=this.accessor.createWatermarkComponent();s.init({containerApi:this._api,group:this.groupPanel}),this.watermark=s,Z(this.watermark.element,"pointerdown",()=>{this.isActive||this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.element.appendChild(this.watermark.element)}if(!e&&this.watermark){var t,i;this.watermark.element.remove(),(t=(i=this.watermark).dispose)===null||t===void 0||t.call(i),this.watermark=void 0}}canDisplayOverlay(e,t,i){const s=new du(e,i,t,Te,this.accessor.getPanel(this.id));return this._onUnhandledDragOver.fire(s),s.isAccepted}canDisplayContentOverlay(e,t){if(this.locked==="no-drop-target"||this.locked&&t==="center")return!1;const i=Te();return!i&&e.shiftKey&&this.location.type!=="floating"?!1:i?.viewId===this.accessor.id?!0:this.canDisplayOverlay(e,t,"content")}handleDropEvent(e,t,i,s,r){if(this.locked==="no-drop-target")return;if(e==="content"&&r){this.accessor.dockToLayoutEdge(t,i);return}function n(){switch(e){case"header":return typeof s=="number"?"tab":"header_space";case"content":return"content"}}const o=typeof s=="number"?this.panels[s]:void 0,a=new fu({nativeEvent:t,position:i,panel:o,getData:()=>Te(),kind:n(),group:this.groupPanel,api:this._api});if(this._onWillDrop.fire(a),a.defaultPrevented)return;const l=Te();if(l?.viewId===this.accessor.id){if(e==="content"&&l.groupId===this.id&&(i==="center"||l.panelId===null&&!l.tabGroupId)||e==="header"&&l.groupId===this.id&&l.panelId===null&&!l.tabGroupId)return;if(l.panelId===null){const{groupId:u}=l;this._onMove.fire({target:i,groupId:u,index:s,tabGroupId:l.tabGroupId});return}if(this.tabsContainer.indexOf(l.panelId)!==-1&&this.tabsContainer.size===1)return;const{groupId:h,panelId:c}=l;if(this.id===h&&!i&&this.tabsContainer.indexOf(c)===s)return;this._onMove.fire({target:i,groupId:l.groupId,itemId:l.panelId,index:s})}else this._onDidDrop.fire(new Ga({nativeEvent:t,position:i,panel:o,getData:()=>Te(),group:this.groupPanel,api:this._api}))}updateDragAndDropState(){this.tabsContainer.updateDragAndDropState()}dispose(){var e,t,i;super.dispose(),(e=this.watermark)===null||e===void 0||e.element.remove(),(t=this.watermark)===null||t===void 0||(i=t.dispose)===null||i===void 0||i.call(t),this.watermark=void 0;for(const s of[...this._tabGroups])s.dispose();for(const s of this._tabGroupDisposables.values())s.dispose();this._tabGroupDisposables.clear();for(const s of this._pendingMicrotaskDisposables)s.dispose();this._pendingMicrotaskDisposables.clear();for(const s of this.panels)s.dispose();this.tabsContainer.dispose(),this.contentContainer.dispose()}},za=class extends iu{constructor(e,t,i){super(e,t),this._onDidConstraintsChangeInternal=new G,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new G,this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new G,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange),i&&this.initialize(i)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}},mu=class extends Ra{get priority(){return this._priority}get snap(){return this._snap}get minimumWidth(){return this.__minimumWidth()}get minimumHeight(){return this.__minimumHeight()}get maximumHeight(){return this.__maximumHeight()}get maximumWidth(){return this.__maximumWidth()}__minimumWidth(){const e=typeof this._minimumWidth=="function"?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}__maximumWidth(){const e=typeof this._maximumWidth=="function"?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}__minimumHeight(){const e=typeof this._minimumHeight=="function"?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}__maximumHeight(){const e=typeof this._maximumHeight=="function"?this._maximumHeight():this._maximumHeight;return e!==this._evaluatedMaximumHeight&&(this._evaluatedMaximumHeight=e,this.updateConstraints()),e}get isActive(){return this.api.isActive}get isVisible(){return this.api.isVisible}constructor(e,t,i,s){super(e,t,s??new za(e,t)),this._evaluatedMinimumWidth=0,this._evaluatedMaximumWidth=Number.MAX_SAFE_INTEGER,this._evaluatedMinimumHeight=0,this._evaluatedMaximumHeight=Number.MAX_SAFE_INTEGER,this._minimumWidth=0,this._minimumHeight=0,this._maximumWidth=Number.MAX_SAFE_INTEGER,this._maximumHeight=Number.MAX_SAFE_INTEGER,this._snap=!1,this._onDidChange=new G,this.onDidChange=this._onDidChange.event,typeof i?.minimumWidth=="number"&&(this._minimumWidth=i.minimumWidth),typeof i?.maximumWidth=="number"&&(this._maximumWidth=i.maximumWidth),typeof i?.minimumHeight=="number"&&(this._minimumHeight=i.minimumHeight),typeof i?.maximumHeight=="number"&&(this._maximumHeight=i.maximumHeight),this.api.initialize(this),this.addDisposables(this.api.onWillVisibilityChange(r=>{const{isVisible:n}=r,{accessor:o}=this._params;o.setVisible(this,n)}),this.api.onActiveChange(()=>{const{accessor:r}=this._params;r.doSetGroupActive(this)}),this.api.onDidConstraintsChangeInternal(r=>{(typeof r.minimumWidth=="number"||typeof r.minimumWidth=="function")&&(this._minimumWidth=r.minimumWidth),(typeof r.minimumHeight=="number"||typeof r.minimumHeight=="function")&&(this._minimumHeight=r.minimumHeight),(typeof r.maximumWidth=="number"||typeof r.maximumWidth=="function")&&(this._maximumWidth=r.maximumWidth),(typeof r.maximumHeight=="number"||typeof r.maximumHeight=="function")&&(this._maximumHeight=r.maximumHeight),this._onDidChange.fire(void 0)}),this.api.onDidSizeChange(r=>{this._onDidChange.fire({height:r.height,width:r.width})}),this._onDidChange)}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}init(e){e.maximumHeight&&(this._maximumHeight=e.maximumHeight),e.minimumHeight&&(this._minimumHeight=e.minimumHeight),e.maximumWidth&&(this._maximumWidth=e.maximumWidth),e.minimumWidth&&(this._minimumWidth=e.minimumWidth),this._priority=e.priority,this._snap=!!e.snap,super.init(e),typeof e.isVisible=="boolean"&&this.setVisible(e.isVisible)}updateConstraints(){this.api._onDidConstraintsChange.fire({minimumWidth:this._evaluatedMinimumWidth,maximumWidth:this._evaluatedMaximumWidth,minimumHeight:this._evaluatedMinimumHeight,maximumHeight:this._evaluatedMaximumHeight})}toJSON(){const e=super.toJSON(),t=s=>s===Number.MAX_SAFE_INTEGER?void 0:s,i=s=>s<=0?void 0:s;return re(re({},e),{},{minimumHeight:i(this.minimumHeight),maximumHeight:t(this.maximumHeight),minimumWidth:i(this.minimumWidth),maximumWidth:t(this.maximumWidth),snap:this.snap,priority:this.priority})}};const Ut="dockview: DockviewGroupPanelApiImpl not initialized";var Ab=class extends za{get location(){if(!this._group)throw new Error(Ut);return this._group.model.location}get boundingBox(){if(!this._group||this._group.model.location.type==="popout")return;const e=this.accessor.element.getBoundingClientRect(),t=this._group.element.getBoundingClientRect();return{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}}get locked(){if(!this._group)throw new Error(Ut);return this._group.locked}set locked(e){if(!this._group)throw new Error(Ut);this._group.locked=e}constructor(e,t){super(e,"__dockviewgroup__"),this.accessor=t,this._onDidLocationChange=new G,this.onDidLocationChange=this._onDidLocationChange.event,this._onDidActivePanelChange=new G,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidCollapsedChange=new G,this.onDidCollapsedChange=this._onDidCollapsedChange.event,this._onDidPeekChange=new G,this.onDidPeekChange=this._onDidPeekChange.event,this._onDidHeaderDirectionChange=new G,this.onDidHeaderDirectionChange=this._onDidHeaderDirectionChange.event,this.addDisposables(this._onDidLocationChange,this._onDidActivePanelChange,this._onDidCollapsedChange,this._onDidPeekChange,this._onDidHeaderDirectionChange,this._onDidVisibilityChange.event(i=>{i.isVisible&&this._pendingSize&&(super.setSize(this._pendingSize),this._pendingSize=void 0)}))}setSize(e){this._pendingSize=re({},e),super.setSize(e)}close(){if(this._group)return this.accessor.removeGroup(this._group)}getWindow(){return this.location.type==="popout"?this.location.getWindow():globalThis.window}setHeaderPosition(e){if(!this._group)throw new Error(Ut);this._group.model.headerPosition=e}getHeaderPosition(){if(!this._group)throw new Error(Ut);return this._group.model.headerPosition}moveTo(e){if(!this._group)throw new Error(Ut);this.accessor.withOrigin("api",()=>{var t,i,s,r;const n=(t=e.group)!==null&&t!==void 0?t:this.accessor.addGroup({direction:j_((i=e.position)!==null&&i!==void 0?i:"right"),skipSetActive:(s=e.skipSetActive)!==null&&s!==void 0?s:!1});this.accessor.moveGroupOrPanel({from:{groupId:this._group.id},to:{group:n,position:e.group&&(r=e.position)!==null&&r!==void 0?r:"center",index:e.index},skipSetActive:e.skipSetActive})})}maximize(){if(!this._group)throw new Error(Ut);this.location.type==="grid"&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw new Error(Ut);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw new Error(Ut);this.isMaximized()&&this.accessor.exitMaximizedGroup()}collapse(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!0)}expand(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!1)}isCollapsed(){return this._group?this.accessor.isEdgeGroupCollapsed(this._group):!1}isPeeking(){return this._group?this.accessor.isEdgeGroupPeeking(this._group):!1}setAutoHide(e){this._group&&this.accessor.setEdgeGroupAutoHide(this._group,e)}isAutoHide(){return this._group?this.accessor.isEdgeGroupAutoHide(this._group):!1}initialize(e){this._group=e}};const Rb=100,Lb=100;var er=class extends mu{get minimumWidth(){var e;if(typeof this._explicitConstraints.minimumWidth=="number")return this._explicitConstraints.minimumWidth;const t=(e=this.activePanel)===null||e===void 0?void 0:e.minimumWidth;return typeof t=="number"?t:super.__minimumWidth()}get minimumHeight(){var e;if(typeof this._explicitConstraints.minimumHeight=="number")return this._explicitConstraints.minimumHeight;const t=(e=this.activePanel)===null||e===void 0?void 0:e.minimumHeight;return typeof t=="number"?t:super.__minimumHeight()}get maximumWidth(){var e;if(typeof this._explicitConstraints.maximumWidth=="number")return this._explicitConstraints.maximumWidth;const t=(e=this.activePanel)===null||e===void 0?void 0:e.maximumWidth;return typeof t=="number"?t:super.__maximumWidth()}get maximumHeight(){var e;if(typeof this._explicitConstraints.maximumHeight=="number")return this._explicitConstraints.maximumHeight;const t=(e=this.activePanel)===null||e===void 0?void 0:e.maximumHeight;return typeof t=="number"?t:super.__maximumHeight()}get panels(){return this._model.panels}get activePanel(){return this._model.activePanel}get size(){return this._model.size}get model(){return this._model}get locked(){return this._model.locked}set locked(e){this._model.locked=e}get header(){return this._model.header}constructor(e,t,i){var s,r,n,o,a,l;super(t,"groupview_default",{minimumHeight:(s=(r=i.constraints)===null||r===void 0?void 0:r.minimumHeight)!==null&&s!==void 0?s:Lb,minimumWidth:(n=(o=i.constraints)===null||o===void 0?void 0:o.minimumWidth)!==null&&n!==void 0?n:Rb,maximumHeight:(a=i.constraints)===null||a===void 0?void 0:a.maximumHeight,maximumWidth:(l=i.constraints)===null||l===void 0?void 0:l.maximumWidth},new Ab(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new Ib(this.element,e,t,i,this),this.addDisposables(this.model.onDidActivePanelChange(h=>{this.api._onDidActivePanelChange.fire(h)}),this.api.onDidConstraintsChangeInternal(h=>{h.minimumWidth!==void 0&&(this._explicitConstraints.minimumWidth=typeof h.minimumWidth=="function"?h.minimumWidth():h.minimumWidth),h.minimumHeight!==void 0&&(this._explicitConstraints.minimumHeight=typeof h.minimumHeight=="function"?h.minimumHeight():h.minimumHeight),h.maximumWidth!==void 0&&(this._explicitConstraints.maximumWidth=typeof h.maximumWidth=="function"?h.maximumWidth():h.maximumWidth),h.maximumHeight!==void 0&&(this._explicitConstraints.maximumHeight=typeof h.maximumHeight=="function"?h.maximumHeight():h.maximumHeight)}))}focus(){this.api.isActive||this.api.setActive(),super.focus()}initialize(){this._model.initialize()}setActive(e){super.setActive(e),this.model.setActive(e)}layout(e,t){super.layout(e,t),this.model.layout(e,t)}relayout(){this.model.relayout()}getComponent(){return this._model}toJSON(){return this.model.toJSON()}};const Nb={name:"dark",className:"dockview-theme-dark",colorScheme:"dark"},Mb={name:"light",className:"dockview-theme-light",colorScheme:"light"},Ob={className:"dockview-theme-abyss",tabGroupIndicator:"none"};var Gb=class extends za{get location(){return this.group.api.location}get title(){return this.panel.title}get isPinned(){return this.panel.isPinned}get isGroupActive(){return this.group.isActive}get renderer(){return this.panel.renderer}set group(e){const t=this._group;this._group!==e&&(this._group=e,this._onDidGroupChange.fire({}),this.setupGroupEventListeners(t),this.fireLocationChange())}get group(){return this._group}get tabComponent(){return this._tabComponent}constructor(e,t,i,s,r){super(e.id,s),this.panel=e,this.accessor=i,this._onDidTitleChange=new G,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidChangePinned=new G,this.onDidChangePinned=this._onDidChangePinned.event,this._onDidActiveGroupChange=new G,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new G,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new G,this.onDidRendererChange=this._onDidRendererChange.event,this._onDidLocationChange=new G,this.onDidLocationChange=this._onDidLocationChange.event,this.groupEventsDisposable=new Me,this._tabComponent=r,this.initialize(e),this._group=t,this.setupGroupEventListeners(),this.addDisposables(this.groupEventsDisposable,this._onDidRendererChange,this._onDidTitleChange,this._onDidChangePinned,this._onDidGroupChange,this._onDidActiveGroupChange,this._onDidLocationChange)}getWindow(){return this.group.api.getWindow()}setActive(){this.accessor.withOrigin("api",()=>super.setActive())}moveTo(e){this.accessor.withOrigin("api",()=>{var t,i;return this.accessor.moveGroupOrPanel({from:{groupId:this._group.id,panelId:this.panel.id},to:{group:(t=e.group)!==null&&t!==void 0?t:this._group,position:e.group&&(i=e.position)!==null&&i!==void 0?i:"center",index:e.index},skipSetActive:e.skipSetActive})})}setTitle(e){this.panel.setTitle(e)}setPinned(e){this.accessor.setPanelPinned(this.panel,e)}setRenderer(e){this.panel.setRenderer(e)}close(){this.group.model.closePanel(this.panel)}maximize(){this.group.api.maximize()}isMaximized(){return this.group.api.isMaximized()}exitMaximized(){this.group.api.exitMaximized()}fireLocationChange(){this.accessor.deferLocationChange(this,()=>{this.isDisposed||this._onDidLocationChange.fire({location:this.location})})}setupGroupEventListeners(e){var t;let i=(t=e?.isActive)!==null&&t!==void 0?t:!1;this.groupEventsDisposable.value=new se(this.group.api.onDidVisibilityChange(s=>{const r=!s.isVisible&&this.isVisible,n=s.isVisible&&!this.isVisible,o=this.group.model.isPanelActive(this.panel);(r||n&&o)&&this._onDidVisibilityChange.fire(s)}),this.group.api.onDidLocationChange(()=>{this.group===this.panel.group&&this.fireLocationChange()}),this.group.api.onDidActiveChange(()=>{this.group===this.panel.group&&i!==this.isGroupActive&&(i=this.isGroupActive,this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}))}))}},qi=class extends se{get params(){return this._params}get title(){return this._title}get isPinned(){return this._pinned}get group(){return this._group}get renderer(){var e;return(e=this._renderer)!==null&&e!==void 0?e:this.accessor.renderer}get minimumWidth(){return this._minimumWidth}get minimumHeight(){return this._minimumHeight}get maximumWidth(){return this._maximumWidth}get maximumHeight(){return this._maximumHeight}constructor(e,t,i,s,r,n,o,a){super(),this.id=e,this.accessor=s,this.containerApi=r,this.view=o,this._pinned=!1,this._renderer=a.renderer,this._group=n,this._minimumWidth=a.minimumWidth,this._minimumHeight=a.minimumHeight,this._maximumWidth=a.maximumWidth,this._maximumHeight=a.maximumHeight,this.api=new Gb(this,this._group,s,t,i),this.addDisposables(this.api.onActiveChange(()=>{s.setActivePanel(this)}),this.api.onDidSizeChange(l=>{this.group.api.setSize(l)}),this.api.onDidRendererChange(()=>{this.group.model.rerender(this)}))}init(e){this._params=e.params,this.view.init(re(re({},e),{},{api:this.api,containerApi:this.containerApi})),this.setTitle(e.title)}focus(){const e=new tu;this.api._onWillFocus.fire(e),!e.defaultPrevented&&(this.api.isActive||this.api.setActive())}toJSON(){return{id:this.id,contentComponent:this.view.contentComponent,tabComponent:this.view.tabComponent,params:Object.keys(this._params||{}).length>0?this._params:void 0,title:this.title,renderer:this._renderer,minimumHeight:this._minimumHeight,maximumHeight:this._maximumHeight,minimumWidth:this._minimumWidth,maximumWidth:this._maximumWidth,pinned:this._pinned?!0:void 0}}setTitle(e){e!==this.title&&(this._title=e,this.view.setTitle(e),this.api._onDidTitleChange.fire({title:e}))}setPinned(e){this._pinned!==e&&(this._pinned=e,this.api._onDidChangePinned.fire({isPinned:e}))}setRenderer(e){e!==this.renderer&&(this._renderer=e,this.api._onDidRendererChange.fire({renderer:e}))}update(e){this._params=re(re({},this._params),e.params);for(const t of Object.keys(e.params))e.params[t]===void 0&&delete this._params[t];this.view.update({params:this._params})}updateFromStateModel(e){var t,i,s,r,n;this._maximumHeight=e.maximumHeight,this._minimumHeight=e.minimumHeight,this._maximumWidth=e.maximumWidth,this._minimumWidth=e.minimumWidth,this._params=(t=e.params)!==null&&t!==void 0?t:{},this.view.update({params:this._params}),this.setTitle((i=e.title)!==null&&i!==void 0?i:this.id),this.setRenderer((s=e.renderer)!==null&&s!==void 0?s:this.accessor.renderer),this.setPinned(((r=e.pinned)!==null&&r!==void 0?r:!1)&&!!(!((n=this.accessor.options.pinnedTabs)===null||n===void 0)&&n.enabled))}updateParentGroup(e,t){this._group=e,this.api.group=this._group;const i=this._group.model.isPanelActive(this),s=this.group.api.isActive&&i;t?.skipSetActive||this.api.isActive!==s&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&i}),this.api.isVisible!==i&&this.api._onDidVisibilityChange.fire({isVisible:i})}runEvents(){const e=this._group.model.isPanelActive(this),t=this.group.api.isActive&&e;this.api.isActive!==t&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&e}),this.api.isVisible!==e&&this.api._onDidVisibilityChange.fire({isVisible:e})}layout(e,t){this.api._onDidDimensionChange.fire({width:e,height:t}),this.view.layout(e,t)}dispose(){this.api.dispose(),this.view.dispose()}},Yl=class extends se{get element(){return this._element}constructor(){super(),this._messages=Er,this._element=document.createElement("div"),this._element.className="dv-default-tab",this._content=document.createElement("div"),this._content.className="dv-default-tab-content",this.action=document.createElement("div"),this.action.className="dv-default-tab-action",this.action.setAttribute("role","button"),this.action.setAttribute("tabindex","-1");const e=ob();e.setAttribute("aria-hidden","true"),this.action.appendChild(e),this._element.appendChild(this._content),this._element.appendChild(this.action),this.render()}init(e){var t;this._title=e.title,this._messages=(t=e.containerApi.messages)!==null&&t!==void 0?t:Er,this.addDisposables(e.api.onDidTitleChange(i=>{this._title=i.title,this.render()}),Z(this.action,"pointerdown",i=>{i.preventDefault()}),Z(this.action,"click",i=>{i.defaultPrevented||(i.preventDefault(),e.api.close())})),this.render()}render(){if(this._content.textContent!==this._title){var e;this._content.textContent=(e=this._title)!==null&&e!==void 0?e:""}this.action.setAttribute("aria-label",this._title?this._messages.closeTab(this._title):this._messages.closeTabPlain())}},gu=class{get content(){return this._content}get tab(){return this._tab}constructor(e,t,i,s){this.accessor=e,this.id=t,this.contentComponent=i,this.tabComponent=s,this._content=this.createContentComponent(this.id,i),this._tab=this.createTabComponent(this.id,s)}createTabRenderer(e){const t=this.createTabComponent(this.id,this.tabComponent);if(this._params&&t.init(re(re({},this._params),{},{tabLocation:e})),this._updateEvent){var i;(i=t.update)===null||i===void 0||i.call(t,this._updateEvent)}return t}init(e){this._params=e,this.content.init(e),this.tab.init(re(re({},e),{},{tabLocation:"header"}))}setTitle(e){this._params&&(this._params.title=e)}layout(e,t){var i,s;(i=(s=this.content).layout)===null||i===void 0||i.call(s,e,t)}update(e){var t,i,s,r;this._updateEvent=e,(t=(i=this.content).update)===null||t===void 0||t.call(i,e),(s=(r=this.tab).update)===null||s===void 0||s.call(r,e)}dispose(){var e,t,i,s;(e=(t=this.content).dispose)===null||e===void 0||e.call(t),(i=(s=this.tab).dispose)===null||i===void 0||i.call(s)}createContentComponent(e,t){return this.accessor.options.createComponent({id:e,name:t})}createTabComponent(e,t){const i=t??this.accessor.options.defaultTabComponent;if(i){if(this.accessor.options.createTabComponent){const s=this.accessor.options.createTabComponent({id:e,name:i});return s||new Yl}console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new Yl}},zb=class{constructor(e){this.accessor=e}fromJSON(e,t){var i,s,r;const n=e.id,o=e.params,a=e.title,l=e.view,h=l?l.content.id:(i=e.contentComponent)!==null&&i!==void 0?i:"unknown",c=l?(s=l.tab)===null||s===void 0?void 0:s.id:e.tabComponent,u=new gu(this.accessor,n,h,c),p=new qi(n,h,c,this.accessor,new Aa(this.accessor),t,u,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return p.init({title:a??n,params:o??{}}),e.pinned&&(!((r=this.accessor.options.pinnedTabs)===null||r===void 0)&&r.enabled)&&p.setPinned(!0),p}},Bb=class extends se{get element(){return this._element}constructor(){super(),this._element=document.createElement("div"),this._element.className="dv-watermark"}init(t){}},jb=class{constructor(){this._orderedList=[]}push(e){this._orderedList=[...this._orderedList.filter(t=>t!==e),e],this.update()}destroy(e){this._orderedList=this._orderedList.filter(t=>t!==e),this.update()}update(){for(let e=0;e<this._orderedList.length;e++)this._orderedList[e].setAttribute("aria-level",`${e}`),this._orderedList[e].style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2})`}};const tr=new jb;var Ba=class Ei extends se{set minimumInViewportWidth(t){this.options.minimumInViewportWidth=t}set minimumInViewportHeight(t){this.options.minimumInViewportHeight=t}get element(){return this._element}get isVisible(){return this._isVisible}get headerHeight(){var t,i;return(t=(i=this.options.header)===null||i===void 0?void 0:i.offsetHeight)!==null&&t!==void 0?t:0}constructor(t){super(),this.options=t,this._element=document.createElement("div"),this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new G,this.onDidChangeEnd=this._onDidChangeEnd.event,this._onDidStartMoving=new G,this.onDidStartMoving=this._onDidStartMoving.event,this._dragMove=new Me,this._dragCancelled=!1,this.addDisposables(this._onDidChange,this._onDidChangeEnd,this._onDidStartMoving,this._dragMove),this._element.className="dv-resize-container",this._element.setAttribute("role","dialog"),this._element.setAttribute("aria-modal","false"),this._isVisible=!0,this.setupResize("top"),this.setupResize("bottom"),this.setupResize("left"),this.setupResize("right"),this.setupResize("topleft"),this.setupResize("topright"),this.setupResize("bottomleft"),this.setupResize("bottomright"),this.options.header&&(K(this._element,"dv-resize-container-with-titlebar",!0),this._element.appendChild(this.options.header)),this._element.appendChild(this.options.content),this.options.container.appendChild(this._element),this.setBounds(re(re(re(re({height:this.options.height,width:this.options.width},"top"in this.options&&{top:this.options.top}),"bottom"in this.options&&{bottom:this.options.bottom}),"left"in this.options&&{left:this.options.left}),"right"in this.options&&{right:this.options.right})),tr.push(this._element)}setVisible(t){t!==this.isVisible&&(this._isVisible=t,K(this.element,"dv-hidden",!this.isVisible))}bringToFront(){tr.push(this._element)}setBounds(t={}){typeof t.height=="number"&&(this._element.style.height=`${t.height}px`),typeof t.width=="number"&&(this._element.style.width=`${t.width}px`),"top"in t&&typeof t.top=="number"&&(this._element.style.top=`${t.top}px`,this._element.style.bottom="auto",this.verticalAlignment="top"),"bottom"in t&&typeof t.bottom=="number"&&(this._element.style.bottom=`${t.bottom}px`,this._element.style.top="auto",this.verticalAlignment="bottom"),"left"in t&&typeof t.left=="number"&&(this._element.style.left=`${t.left}px`,this._element.style.right="auto",this.horiziontalAlignment="left"),"right"in t&&typeof t.right=="number"&&(this._element.style.right=`${t.right}px`,this._element.style.left="auto",this.horiziontalAlignment="right");const i=this.options.container.getBoundingClientRect(),s=this._element.getBoundingClientRect(),r=Math.max(0,this.getMinimumWidth(s.width)),n=Math.max(0,this.getMinimumHeight(s.height));if(this.verticalAlignment==="top"){const o=Ee(s.top-i.top,-n,Math.max(0,i.height-s.height+n));this._element.style.top=`${o}px`,this._element.style.bottom="auto"}if(this.verticalAlignment==="bottom"){const o=Ee(i.bottom-s.bottom,-n,Math.max(0,i.height-s.height+n));this._element.style.bottom=`${o}px`,this._element.style.top="auto"}if(this.horiziontalAlignment==="left"){const o=Ee(s.left-i.left,-r,Math.max(0,i.width-s.width+r));this._element.style.left=`${o}px`,this._element.style.right="auto"}if(this.horiziontalAlignment==="right"){const o=Ee(i.right-s.right,-r,Math.max(0,i.width-s.width+r));this._element.style.right=`${o}px`,this._element.style.left="auto"}this._onDidChange.fire()}toJSON(){const t=this.options.container.getBoundingClientRect(),i=this._element.getBoundingClientRect(),s={};return this.verticalAlignment==="top"?s.top=Number.parseFloat(this._element.style.top):this.verticalAlignment==="bottom"?s.bottom=Number.parseFloat(this._element.style.bottom):s.top=i.top-t.top,this.horiziontalAlignment==="left"?s.left=Number.parseFloat(this._element.style.left):this.horiziontalAlignment==="right"?s.right=Number.parseFloat(this._element.style.right):s.left=i.left-t.left,s.width=i.width,s.height=i.height,s}cancelPendingDrag(){this._dragMove.value&&(this._dragCancelled=!0,K(this._element,"dv-resize-container-dragging",!1),this._dragMove.value=Se.NONE)}setupDrag(t,i){const s=(r,n)=>{var o,a,l;let h=null,c=!1;this._dragCancelled=!1;const u=this.options.transformDragPosition?(o=(a=(l=this.options).getSiblingBoxes)===null||a===void 0?void 0:a.call(l))!==null&&o!==void 0?o:[]:[],p=Es();if(r&&typeof n=="number"&&typeof r.setPointerCapture=="function")try{r.setPointerCapture(n)}catch{}const f=()=>{K(this._element,"dv-resize-container-dragging",!1),this._dragMove.value=Se.NONE,this._onDidChangeEnd.fire()};this._dragMove.value=new se({dispose:()=>{if(p.release(),r&&typeof n=="number"&&typeof r.releasePointerCapture=="function")try{r.releasePointerCapture(n)}catch{}}},Z(globalThis.window,"pointermove",m=>{var g;if(this._dragCancelled)return;const _=this.options.container.getBoundingClientRect(),E=m.clientX-_.left,C=m.clientY-_.top;K(this._element,"dv-resize-container-dragging",!0);const T=this._element.getBoundingClientRect();(g=h)!==null&&g!==void 0||(h={x:m.clientX-T.left,y:m.clientY-T.top});const x=Math.max(0,this.getMinimumWidth(T.width)),A=Math.max(0,this.getMinimumHeight(T.height));let k=C-h.y,N=E-h.x;if(this.options.transformDragPosition){const D=this.options.transformDragPosition({proposed:{top:k,left:N,width:T.width,height:T.height},container:{width:_.width,height:_.height},others:u,modifiers:{altKey:m.altKey,ctrlKey:m.ctrlKey,metaKey:m.metaKey,shiftKey:m.shiftKey}});D&&(k=D.top,N=D.left)}const O=Math.max(0,_.height-T.height+A),z=Math.max(0,_.width-T.width+x),R=Ee(k,-A,O),I=Ee(_.height-T.height-k,-A,O),w=Ee(N,-x,z),v=Ee(_.width-T.width-N,-x,z),S={};R<=I?S.top=R:S.bottom=I,w<=v?S.left=w:S.right=v,this.setBounds(S),c||(c=!0,this._onDidStartMoving.fire())}),Z(globalThis.window,"pointerup",f),Z(globalThis.window,"pointercancel",f))};this.addDisposables(Z(t,"pointerdown",r=>{if(r.defaultPrevented){r.preventDefault();return}Wl(r)||s(t,r.pointerId)}),Z(this.options.content,"pointerdown",r=>{r.defaultPrevented||Wl(r)||r.shiftKey&&s(this.options.content,r.pointerId)}),Z(this.options.content,"pointerdown",()=>{tr.push(this._element)},!0)),i?.inDragMode&&s()}setupResize(t){const i=document.createElement("div");i.className=`dv-resize-handle-${t}`,this._element.appendChild(i);const s=new Me;this.addDisposables(s,Z(i,"pointerdown",r=>{r.preventDefault();let n=null;const o=Es(),a=r.pointerId;if(typeof i.setPointerCapture=="function")try{i.setPointerCapture(a)}catch{}const l=()=>{s.dispose(),this._onDidChangeEnd.fire()};s.value=new se(Z(globalThis.window,"pointermove",h=>{var c;const u=this.options.container.getBoundingClientRect(),p=this._element.getBoundingClientRect(),f=h.clientY-u.top,m=h.clientX-u.left;(c=n)!==null&&c!==void 0||(n={originalY:f,originalHeight:p.height,originalX:m,originalWidth:p.width});let g,_,E,C,T,x;const A=()=>{const R=n.originalY+n.originalHeight>u.height?Math.max(0,u.height-Ei.MINIMUM_HEIGHT):Math.max(0,n.originalY+n.originalHeight-Ei.MINIMUM_HEIGHT);g=Ee(f,0,R),E=n.originalY+n.originalHeight-g,_=u.height-g-E},k=()=>{g=n.originalY-n.originalHeight;const R=g<0&&typeof this.options.minimumInViewportHeight=="number"?-g+this.options.minimumInViewportHeight:Ei.MINIMUM_HEIGHT,I=u.height-Math.max(0,g);E=Ee(f-g,R,I),_=u.height-g-E},N=()=>{const R=n.originalX+n.originalWidth>u.width?Math.max(0,u.width-Ei.MINIMUM_WIDTH):Math.max(0,n.originalX+n.originalWidth-Ei.MINIMUM_WIDTH);C=Ee(m,0,R),x=n.originalX+n.originalWidth-C,T=u.width-C-x},O=()=>{C=n.originalX-n.originalWidth;const R=C<0&&typeof this.options.minimumInViewportWidth=="number"?-C+this.options.minimumInViewportWidth:Ei.MINIMUM_WIDTH,I=u.width-Math.max(0,C);x=Ee(m-C,R,I),T=u.width-C-x};switch(t){case"top":A();break;case"bottom":k();break;case"left":N();break;case"right":O();break;case"topleft":A(),N();break;case"topright":A(),O();break;case"bottomleft":k(),N();break;case"bottomright":k(),O();break}const z={};g<=_?z.top=g:z.bottom=_,C<=T?z.left=C:z.right=T,z.height=E,z.width=x,this.setBounds(z)}),{dispose:()=>{if(o.release(),typeof i.releasePointerCapture=="function")try{i.releasePointerCapture(a)}catch{}}},Z(globalThis.window,"pointerup",l),Z(globalThis.window,"pointercancel",l))}))}getMinimumWidth(t){return typeof this.options.minimumInViewportWidth=="number"?t-this.options.minimumInViewportWidth:0}getMinimumHeight(t){return typeof this.options.minimumInViewportHeight=="number"?t-this.options.minimumInViewportHeight:0}dispose(){tr.destroy(this._element),this._element.remove(),super.dispose()}};Ba.MINIMUM_HEIGHT=20;Ba.MINIMUM_WIDTH=20;var $b=class extends se{get element(){return this._element}get group(){return this._group}setGroup(e){this._group=e}constructor(e,t){super(),this.accessor=e,this._onDragStart=new G,this.onDragStart=this._onDragStart.event,this._group=t,this._element=document.createElement("div"),this._element.className="dv-floating-titlebar",this.addDisposables(this._onDragStart,Z(this._element,"pointerdown",()=>{this.accessor.doSetGroupActive(this._group)}),Z(this._element,"pointerdown",i=>{i.shiftKey&&Gc(i)},!0)),this.dragSource=new ou({element:this._element,accessor:this.accessor,group:()=>this._group}),this.addDisposables(this.dragSource,this.dragSource.onDragStart(i=>{this._onDragStart.fire(i)}))}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}};function ii(e){return{moduleName:e.name,options:e.options,services:{[e.serviceKey]:e.create},init:e.init?(t,i)=>e.init(t,i[e.serviceKey]):void 0,dependsOn:e.dependsOn}}const Wb=new Set(["AdvancedOverflow","AutoEdgeGroup","AutoHideEdgeGroup","ContextMenu","DndCompass","KeyboardDocking","KeyboardNavigation","LayoutHistory","License","MultiRowTabs","PinnedTabs","SmartGuides"]),Xl=new Set;function vu(e,t){const i=t===void 0?[]:[].concat(t),s=i.map(o=>`\`${o}\``).join(", "),r=i.length>1?"require":"requires",n=i.length?`${s} ${r} the "${e}" module`:`The "${e}" module is required`;return Wb.has(e)?`dockview: ${n}, which ships in dockview-enterprise.
|
|
4
|
+
|
|
5
|
+
npm install dockview-enterprise
|
|
6
|
+
import 'dockview-enterprise'; // self-registers every enterprise module
|
|
7
|
+
`:`dockview: ${n}, but it is not registered.`}function _u(e,t){const i=`${e}|${(t===void 0?[]:[].concat(t)).join("|")}`;Xl.has(i)||(Xl.add(i),console.error(vu(e,t)))}function ct(e,t,i){if(e!==void 0)return e;_u(t,i)}var Hb=class{constructor(){this._modules=new Map,this._services={},this._initDisposables=[]}get services(){return this._services}register(e){if(!this._modules.has(e.moduleName)){if(e.dependsOn)for(const t of e.dependsOn)this.register(t);this._modules.set(e.moduleName,e)}}initialize(e){for(const t of this._modules.values())if(t.services)for(const[i,s]of Object.entries(t.services))this._services[i]=s(e)}postConstruct(e){for(const t of this._modules.values())t.init&&this._initDisposables.push(t.init(e,this._services))}has(e){return this._modules.has(e)}dispose(){for(const e of this._initDisposables)e.dispose();this._initDisposables.length=0;for(const e of Object.values(this._services))e!==void 0&&typeof e.dispose=="function"&&e.dispose()}};const Fb=[];function Vb(){return[...Fb]}const Ub=[{optionKey:"smartGuides",reason:"smartGuides",moduleName:"SmartGuides",when:e=>!!e.smartGuides&&e.smartGuides.enabled!==!1},{optionKey:"layoutHistory",reason:"layoutHistory.enabled: true",moduleName:"LayoutHistory",when:e=>{var t;return((t=e.layoutHistory)===null||t===void 0?void 0:t.enabled)===!0}},{optionKey:"pinnedTabs",reason:"pinnedTabs.enabled: true",moduleName:"PinnedTabs",when:e=>{var t;return((t=e.pinnedTabs)===null||t===void 0?void 0:t.enabled)===!0}},{optionKey:"overflow",reason:"overflow.mode: 'wrap'",moduleName:"MultiRowTabs",when:e=>{var t;return((t=e.overflow)===null||t===void 0?void 0:t.mode)==="wrap"}},{optionKey:"overflow",reason:"overflow.maxRows",moduleName:"MultiRowTabs",when:e=>{var t;return((t=e.overflow)===null||t===void 0?void 0:t.maxRows)!=null}},{optionKey:"overflow",reason:"overflow.search",moduleName:"AdvancedOverflow",when:e=>{var t;return!!(!((t=e.overflow)===null||t===void 0)&&t.search)}},{optionKey:"overflow",reason:"overflow.mru",moduleName:"AdvancedOverflow",when:e=>{var t;return!!(!((t=e.overflow)===null||t===void 0)&&t.mru)}},{optionKey:"autoHideEdgeGroups",reason:"autoHideEdgeGroups",moduleName:"AutoHideEdgeGroup",when:e=>lo(e.autoHideEdgeGroups)},{optionKey:"dockToEdgeGroups",reason:"dockToEdgeGroups",moduleName:"AutoEdgeGroup",when:e=>lo(e.dockToEdgeGroups)},{optionKey:"getTabContextMenuItems",reason:"getTabContextMenuItems",moduleName:"ContextMenu",when:e=>e.getTabContextMenuItems!=null},{optionKey:"getTabGroupChipContextMenuItems",reason:"getTabGroupChipContextMenuItems",moduleName:"ContextMenu",when:e=>e.getTabGroupChipContextMenuItems!=null},{optionKey:"dndCompass",reason:"dndCompass",moduleName:"DndCompass",when:e=>!!e.dndCompass},{optionKey:"keyboardNavigation",reason:"keyboardNavigation",moduleName:"KeyboardNavigation",when:e=>!!e.keyboardNavigation}];function Kb(e,t){const i=new Map;for(const s of Ub){if(!s.when(e)||t(s.moduleName))continue;const r=i.get(s.moduleName);r?r.push(s.reason):i.set(s.moduleName,[s.reason])}for(const[s,r]of i)_u(s,r)}const ai={left:100,top:100,width:300,height:300};var qb=class extends se{get group(){return this._group}setTitleBar(e){this._titleBar=e}setAnchorGroup(e){var t;this._group=e,(t=this._titleBar)===null||t===void 0||t.setGroup(e)}constructor(e,t,i){super(),this.overlay=t,this.gridview=i,this._group=e,this.addDisposables(t,{dispose:()=>this.gridview.dispose()})}position(e){this.overlay.setBounds(e)}},Yb=class{get floatingGroups(){return this._floatingGroups}constructor(e){this._floatingGroups=[],this._host=e}add(e,t,i){const s=new qb(e,t,i),r=new se(e.api.onDidActiveChange(o=>{o.isActive&&t.bringToFront()}),(()=>{let o=-1,a=-1;return ji(i.element,l=>{const h=Math.round(l.contentRect.width),c=Math.round(l.contentRect.height);h===o&&c===a||(o=h,a=c,i.layout(h,c))})})()),n=()=>{var o;const a=(o=e.activePanel)===null||o===void 0?void 0:o.title;a?t.element.setAttribute("aria-label",a):t.element.removeAttribute("aria-label")};return n(),s.addDisposables(e.api.onDidActivePanelChange(()=>n()),t.onDidChange(()=>{i.layout(i.width,i.height)}),t.onDidChangeEnd(()=>{this._host.fireLayoutChange()}),e.onDidChange(o=>{t.setBounds({height:typeof o?.height=="number"?o.height+t.headerHeight:o?.height,width:o?.width})}),{dispose:()=>{r.dispose(),$c(this._floatingGroups,s),e.model.location={type:"grid"}}}),this._floatingGroups.push(s),s}findByGroup(e){return this._floatingGroups.find(t=>t.group===e||t.gridview.element.contains(e.element))}serialize(){return this._floatingGroups.map(e=>{const t=e.gridview.serialize(),i=e.overlay.toJSON(),s=t.root;return s.type==="branch"&&s.data.length===1&&s.data[0].type==="leaf"?{data:s.data[0].data,position:i}:{grid:t,position:i}})}constrainBounds(){for(const e of this._floatingGroups)e.overlay.setBounds()}updateBounds(e){if("floatingGroupBounds"in e)for(const s of this._floatingGroups){switch(e.floatingGroupBounds){case"boundedWithinViewport":s.overlay.minimumInViewportHeight=void 0,s.overlay.minimumInViewportWidth=void 0;break;case void 0:s.overlay.minimumInViewportHeight=100,s.overlay.minimumInViewportWidth=100;break;default:var t,i;s.overlay.minimumInViewportHeight=(t=e.floatingGroupBounds)===null||t===void 0?void 0:t.minimumHeightWithinViewport,s.overlay.minimumInViewportWidth=(i=e.floatingGroupBounds)===null||i===void 0?void 0:i.minimumWidthWithinViewport}s.overlay.setBounds()}}disposeAll(){for(const e of[...this._floatingGroups])e.dispose()}dispose(){this.disposeAll()}};const Xb=ii({name:"FloatingGroup",serviceKey:"floatingGroupService",create:e=>new Yb(e)});var Jb=class{constructor(e){this._entries=[],this._restorationCleanups=new Set,this._restorationPromise=Promise.resolve(),this._onDidRemove=new G,this.onDidRemove=this._onDidRemove.event,this._host=e}get entries(){return this._entries}get restorationPromise(){return this._restorationPromise}add(e){this._entries.push(e)}remove(e){$c(this._entries,e)&&!this._host.isDisposed&&this._onDidRemove.fire(e)}findByGroup(e){return this._entries.find(t=>t.popoutGroup===e||t.gridview.element.contains(e.element))}findReferenceGroupId(e){var t;return(t=this._entries.find(i=>i.popoutGroup===e))===null||t===void 0?void 0:t.referenceGroup}observeGridviewSize(e,t,i){var s;const r=(s=e.window)===null||s===void 0?void 0:s.ResizeObserver;if(!r)return;let n=-1,o=-1;const a=()=>{const h=e.window;if(this._host.isDisposed||!h||h.closed)return;const c=Math.round(t.element.clientWidth),u=Math.round(t.element.clientHeight);c===n&&u===o||(n=c,o=u,c>0&&u>0&&t.layout(c,u),i.updateAllPositions())},l=new r(()=>{var h;const c=(h=e.window)===null||h===void 0?void 0:h.requestAnimationFrame;c?c.call(e.window,a):a()});return l.observe(t.element),{dispose:()=>l.disconnect()}}scheduleRestoration(e,t,i){return new Promise(s=>{const r=()=>{this._restorationCleanups.delete(r),clearTimeout(n),i?.(),s()},n=setTimeout(()=>{if(this._restorationCleanups.delete(r),this._host.isDisposed){s();return}t(),s()},e);this._restorationCleanups.add(r)})}finishRestoration(e){this._restorationPromise=Promise.all(e).then(()=>{})}cancelPendingRestorations(){for(const e of[...this._restorationCleanups])e();this._restorationCleanups.clear()}serialize(){return this._entries.map(e=>{const t=e.gridview.serialize(),i=t.root,s=e.popoutGroup.api.location.type==="popout"?e.popoutGroup.api.location.popoutUrl:void 0,r={gridReferenceGroup:e.referenceGroup,position:e.window.dimensions(),url:s};return i.type==="branch"&&i.data.length===1&&i.data[0].type==="leaf"?re(re({},r),{},{data:i.data[0].data}):re(re({},r),{},{grid:t})})}disposeAll(){for(const e of[...this._entries])e.disposable.dispose()}dispose(){this.cancelPendingRestorations(),this.disposeAll(),this._onDidRemove.dispose()}};const Zb=ii({name:"PopoutWindow",serviceKey:"popoutWindowService",create:e=>new Jb(e)});var Qb=class{constructor(e){this._watermark=null,this._host=e}update(){if(this._host.hasVisibleGridGroup()){this._unmount();return}if(this._watermark)return;this._watermark=this._host.createWatermarkComponent(),this._watermark.init({containerApi:this._host.api});const e=document.createElement("div");e.className="dv-watermark-container",g_(e,"watermark-component"),e.appendChild(this._watermark.element),this._host.mountElement.appendChild(e)}refresh(){this._unmount(),this.update()}_unmount(){var e,t;this._watermark&&(this._watermark.element.parentElement.remove(),(e=(t=this._watermark).dispose)===null||e===void 0||e.call(t),this._watermark=null)}dispose(){this._unmount()}};const ew=ii({name:"Watermark",serviceKey:"watermarkService",create:e=>new Qb(e),init:(e,t)=>(t.update(),new se(xt.any(e.onDidAdd,e.onDidRemove)(()=>{t.update()}),e.onDidViewVisibilityChangeMicroTaskQueue(()=>{t.update()})))});var tw=class{constructor(){this._edgeGroups=new Map,this._edgeGroupDisposables=new Map,this._autoHide=new WeakMap,this._autoReveal=new WeakMap}add(e,t,i){this._edgeGroups.set(e,t),this._edgeGroupDisposables.set(e,i)}remove(e){var t;(t=this._edgeGroupDisposables.get(e))===null||t===void 0||t.dispose(),this._edgeGroupDisposables.delete(e),this._edgeGroups.delete(e)}get(e){return this._edgeGroups.get(e)}has(e){return this._edgeGroups.has(e)}hasAny(){return this._edgeGroups.size>0}entries(){return this._edgeGroups.entries()}includes(e){for(const t of this._edgeGroups.values())if(t===e)return!0;return!1}findPositionOf(e){for(const[t,i]of this._edgeGroups)if(i===e)return t}setAutoHide(e,t){t===void 0?this._autoHide.delete(e):this._autoHide.set(e,t)}isAutoHide(e){return this._autoHide.get(e)}setAutoReveal(e,t){this._autoReveal.set(e,t)}isAutoReveal(e){var t;return(t=this._autoReveal.get(e))!==null&&t!==void 0?t:!1}disposeAll(){for(const e of this._edgeGroupDisposables.values())e.dispose();this._edgeGroupDisposables.clear(),this._edgeGroups.clear()}dispose(){this.disposeAll()}};const iw=ii({name:"EdgeGroup",serviceKey:"edgeGroupService",create:()=>new tw}),sw={activationSize:{type:"pixels",value:10},size:{type:"pixels",value:20}},rw={activationSize:{type:"pixels",value:32},size:{type:"pixels",value:20}};function Jl(e,t){return typeof e.dndEdges=="object"&&e.dndEdges!==null?e.dndEdges:t&&lo(e.dockToEdgeGroups)?rw:sw}var nw=class{constructor(e){this._host=e;const t=(s,r)=>{const n=Te();return n?n.viewId!==e.id?!1:r==="center"?e.isGridEmpty():!0:r==="center"&&!e.isGridEmpty()?!1:e.dispatchUnhandledDragOver(s,r)},i=Jl(e.options,!1);this._html5Target=xi.createDropTarget(e.element,{className:"dv-drop-target-edge",canDisplayOverlay:t,acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:i,getOverrideTarget:()=>e.rootDropTargetOverrideTarget(),getPositionResolver:()=>e.options.dropPositionResolver}),this._pointerTarget=ti.createDropTarget(e.element,{className:"dv-drop-target-edge",canDisplayOverlay:t,acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:i,getOverrideTarget:()=>e.rootDropTargetOverrideTarget(),getPositionResolver:()=>e.options.dropPositionResolver}),this.onWillShowOverlay=xt.any(this._html5Target.onWillShowOverlay,this._pointerTarget.onWillShowOverlay),this.onDrop=xt.any(this._html5Target.onDrop,this._pointerTarget.onDrop),this.setOptions(e.options)}setOptions(e){if("dndEdges"in e){const t=typeof e.dndEdges=="boolean"&&e.dndEdges===!1;this._html5Target.disabled=t,this._pointerTarget.disabled=t}if("dndEdges"in e||"dockToEdgeGroups"in e){const t=Jl({dndEdges:"dndEdges"in e?e.dndEdges:this._host.options.dndEdges,dockToEdgeGroups:"dockToEdgeGroups"in e?e.dockToEdgeGroups:this._host.options.dockToEdgeGroups},this._host.hasEdgeDragReveal);this._html5Target.setOverlayModel(t),this._pointerTarget.setOverlayModel(t)}}dispose(){this._html5Target.dispose(),this._pointerTarget.dispose()}};const ow=ii({name:"RootDropTarget",serviceKey:"rootDropTargetService",create:e=>new nw(e),init:(e,t)=>(t.setOptions(e.options),Se.NONE)}),aw={left:"createLeftHeaderActionComponent",right:"createRightHeaderActionComponent",prefix:"createPrefixHeaderActionComponent"};var lw=class{constructor(e){this._perGroup=new Map,this._host=e}refresh(e){if(!e?.model)return;const t=this._ensureState(e);this._refreshSlot("left",e,t.left),this._refreshSlot("right",e,t.right),this._refreshSlot("prefix",e,t.prefix)}refreshAll(){for(const e of this._host.groups)this.refresh(e)}disposeGroup(e){const t=this._perGroup.get(e);t&&(t.left.dispose(),t.right.dispose(),t.prefix.dispose(),this._perGroup.delete(e))}dispose(){for(const e of[...this._perGroup.keys()])this.disposeGroup(e)}_ensureState(e){let t=this._perGroup.get(e);return t||(t={left:new Me,right:new Me,prefix:new Me},this._perGroup.set(e,t)),t}_refreshSlot(e,t,i){const s=this._host.options[aw[e]];if(s){const r=s(t);i.value=r,r.init({containerApi:this._host.api,api:t.api,group:t}),t.model.attachHeaderAction(e,r.element)}else i.dispose(),t.model.attachHeaderAction(e,void 0)}};const hw=ii({name:"HeaderActions",serviceKey:"headerActionsService",create:e=>new lw(e),init:(e,t)=>new se(e.onDidRemoveGroup(i=>{t.disposeGroup(i)}))}),Zl=e=>e==="load"||e==="clear";function ir(e,t){const i=e.createElement("div");return i.className=t==="assertive"?"dv-live-region-assertive":"dv-live-region",i.setAttribute("role",t==="assertive"?"alert":"status"),i.setAttribute("aria-live",t),i.setAttribute("aria-atomic","true"),Object.assign(i.style,{position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:"0"}),i}var dw=class extends se{constructor(e){var t;super(),this._regions=new Map,this._suppressDepth=0,this._locationSubs=new Map,this._host=e;const i=e.element.ownerDocument;this._mainWindow=(t=i.defaultView)!==null&&t!==void 0?t:window;const s={polite:ir(i,"polite"),assertive:ir(i,"assertive")};e.element.appendChild(s.polite),e.element.appendChild(s.assertive),this._regions.set(this._mainWindow,s),this._syncPopoutRegions(),this.addDisposables({dispose:()=>this._disposeRegions()},e.onDidChangePopouts(()=>this._syncPopoutRegions()),e.onDidAddPanel(r=>this._announce(r,"open")),e.onDidRemovePanel(r=>this._announce(r,"close")),e.onWillMutateLayout(r=>{Zl(r.kind)&&this._suppressDepth++}),e.onDidMutateLayout(r=>{Zl(r.kind)&&(this._suppressDepth=Math.max(0,this._suppressDepth-1))}),e.onDidMaximizedGroupChange(r=>{const n=r.group.activePanel;n&&this._announce(n,r.isMaximized?"maximize":"restore")}),e.onDidAddGroup(r=>this._trackLocation(r)),e.onDidRemoveGroup(r=>{var n;(n=this._locationSubs.get(r.id))===null||n===void 0||n.dispose(),this._locationSubs.delete(r.id)}),{dispose:()=>{this._locationSubs.forEach(r=>r.dispose()),this._locationSubs.clear()}})}_syncPopoutRegions(){const e=this._host.element.ownerDocument,t=new Set([this._mainWindow]);for(const s of this._host.getPopoutWindows()){var i;if(s.document===e||(t.add(s),this._regions.has(s)))continue;const r=s.document,n=(i=r.body)!==null&&i!==void 0?i:r.documentElement,o={polite:ir(r,"polite"),assertive:ir(r,"assertive")};n.appendChild(o.polite),n.appendChild(o.assertive),this._regions.set(s,o)}for(const[s,r]of this._regions)t.has(s)||(r.polite.remove(),r.assertive.remove(),this._regions.delete(s))}_disposeRegions(){for(const e of this._regions.values())e.polite.remove(),e.assertive.remove();this._regions.clear()}_focusedRegions(){for(const[e,t]of this._regions)if(e!==this._mainWindow)try{if(e.document.hasFocus())return t}catch{}return this._regions.get(this._mainWindow)}_trackLocation(e){let t=e.api.location.type;const i=e.api.onDidLocationChange(s=>{const r=s.location.type;if(r===t)return;t=r;const n=e.activePanel;if(!n)return;let o;switch(r){case"floating":o="float";break;case"popout":o="popout";break;default:o="dock";break}this._announce(n,o)});this._locationSubs.set(e.id,i)}announce(e,t="polite"){if(this._host.options.announcements===!1||this._suppressDepth>0||!e)return;const i=this._host.options.announcer;if(i){i({message:e,politeness:t});return}const s=this._focusedRegions(),r=t==="assertive"?s.assertive:s.polite;r.textContent="",r.textContent=e}_announce(e,t){var i,s;const r=(i=(s=this._host.options).getAnnouncement)===null||i===void 0?void 0:i.call(s,{kind:t,panel:e});r===null||r===""||this.announce(r??this._defaultMessage(e,t))}_defaultMessage(e,t){var i;const s=Vc(this._host.options.messages),r=(i=e.title)!==null&&i!==void 0?i:e.id;switch(t){case"open":return s.panelOpened(r);case"close":return s.panelClosed(r);case"maximize":return s.groupMaximized(r);case"restore":return s.groupRestored(r);case"float":return s.groupFloated(r);case"dock":return s.groupDocked(r);case"popout":return s.groupPoppedOut(r)}}};const cw=ii({name:"LiveRegion",serviceKey:"liveRegionService",create:e=>new dw(e)}),uw=30,pw=-10;var fw=class{constructor(e){this.host=e}dispatchWillDragPanel(e){this.host.fireWillDragPanel(e)}dispatchWillDragGroup(e){this.host.fireWillDragGroup(e)}dispatchWillDrop(e){this.host.fireWillDrop(e)}dispatchWillShowOverlay(e){this.host.fireWillShowOverlay(e)}buildGroupDragGhost(e){const t=this.host.options.createGroupDragGhostComponent;if(!t)return;const i=t(e);return i.init({group:e,api:this.host.api}),{element:i.element,offsetX:uw,offsetY:pw,dispose:i.dispose?()=>{var s;return(s=i.dispose)===null||s===void 0?void 0:s.call(i)}:void 0}}resolveOverlayModel(e,t){var i,s;return(i=(s=this.host.options).dropOverlayModel)===null||i===void 0?void 0:i.call(s,{location:e,group:t})}showPreviewOverlay(e,t){const i=e.model.contentDropTarget;return i.showOverlay(t),Se.from(()=>i.clearOverlay())}dispose(){}};const mw=ii({name:"AdvancedDnD",serviceKey:"advancedDnDService",create:e=>new fw(e)});var gw=class{constructor(e){this._host=e}attachToGroup(e){return new se(e.model.onDidCreateTabGroup(t=>{this._host.fireDidCreateTabGroup(t)}),e.model.onDidDestroyTabGroup(t=>{this._host.fireDidDestroyTabGroup(t)}),e.model.onDidAddPanelToTabGroup(t=>{this._host.fireDidAddPanelToTabGroup(t)}),e.model.onDidRemovePanelFromTabGroup(t=>{this._host.fireDidRemovePanelFromTabGroup(t)}),e.model.onDidTabGroupChange(t=>{this._host.fireDidTabGroupChange(t)}),e.model.onDidTabGroupCollapsedChange(t=>{this._host.fireDidTabGroupCollapsedChange(t)}))}dispose(){}};const vw=ii({name:"TabGroupChips",serviceKey:"tabGroupChipsService",create:e=>new gw(e),init:(e,t)=>{const i=new Map;return new se(e.onDidAddGroup(s=>{i.set(s,t.attachToGroup(s))}),e.onDidRemoveGroup(s=>{var r;(r=i.get(s))===null||r===void 0||r.dispose(),i.delete(s)}),{dispose:()=>{for(const s of i.values())s.dispose();i.clear()}})}}),_w=[Xb,Zb,ew,iw,ow,hw,cw,mw,vw];var bw=class{constructor(){this.cache=new WeakMap,this.currentFrameId=0,this.rafId=null}getPosition(e){const t=this.cache.get(e);if(t?.frameId===this.currentFrameId)return t.rect;this.scheduleFrameUpdate();const i=Qn(e);return this.cache.set(e,{rect:i,frameId:this.currentFrameId}),i}invalidate(){this.currentFrameId++}scheduleFrameUpdate(){this.rafId||(this.rafId=requestAnimationFrame(()=>{this.currentFrameId++,this.rafId=null}))}};const Ql=-1;function ww(){const e=document.createElement("div");return e.tabIndex=-1,e}var eh=class extends se{constructor(e,t){super(),this.element=e,this.accessor=t,this.map={},this._disposed=!1,this._generation=0,this.positionCache=new bw,this.addDisposables(Se.from(()=>{for(const i of Object.values(this.map))i.disposable.dispose(),i.destroy.dispose(),this.cancelPendingUpdate(i);this._disposed=!0}))}updateAllPositions(){if(!this._disposed){this.positionCache.invalidate();for(const e of Object.values(this.map))e.panel.api.isVisible&&e.resize&&e.resize()}}repositionPanelOverlay(e,t=!1,i){var s;if(this._disposed)return;const r=this.map[e];r&&(r.forceVisible=t,r.clip=i,this.positionCache.invalidate(),(s=r.resize)===null||s===void 0||s.call(r))}cancelPendingUpdate(e){e.pendingUpdate!==void 0&&(cancelAnimationFrame(e.pendingUpdate),e.pendingUpdate=void 0)}detatch(e){if(this.map[e.api.id]){const t=this.map[e.api.id];return t.disposable.dispose(),t.destroy.dispose(),this.cancelPendingUpdate(t),delete this.map[e.api.id],!0}return!1}attach(e){const{panel:t,referenceContainer:i}=e;if(!this.map[t.api.id]){const p=ww();p.className="dv-render-overlay",p.style.visibility="hidden",this.map[t.api.id]={panel:t,disposable:Se.NONE,destroy:Se.NONE,element:p,retainPreviousGeometry:!1,positioned:!1,generation:++this._generation}}const s=this.map[t.api.id];s.referenceContainer!==i&&(s.generation=++this._generation,this.cancelPendingUpdate(s),s.referenceContainer=i,s.retainPreviousGeometry=s.positioned);const r=s.generation,n=s.element,o=t.view.content.element;o.parentElement!==n&&n.appendChild(o),n.parentElement!==this.element&&this.element.appendChild(n);const a=()=>{const p=t.api.id,f=this.map[p];if(f?.generation!==r||f.pendingUpdate!==void 0)return;f.pendingUpdate=Ql;const m=requestAnimationFrame(()=>{var g;const _=this.map[p];if(_&&(_.pendingUpdate=void 0),this.isDisposed||_?.generation!==r)return;const E=(g=_.forceVisible)!==null&&g!==void 0?g:!1,C=_.clip,T=this.positionCache.getPosition(i.element),x=this.positionCache.getPosition(this.element),A=T.left-x.left,k=T.top-x.top,N=T.width,O=T.height;if(_.retainPreviousGeometry&&(N===0||O===0)){!t.api.isVisible&&!E&&(n.style.visibility="hidden",n.style.pointerEvents="none");return}if(_.retainPreviousGeometry=!1,_.positioned=!0,n.style.left=`${A}px`,n.style.top=`${k}px`,n.style.width=`${N}px`,n.style.height=`${O}px`,t.api.isVisible||E?(n.style.visibility="",n.style.pointerEvents=""):(n.style.visibility="hidden",n.style.pointerEvents="none"),E?n.style.zIndex="1000":t.api.location.type!=="floating"&&(n.style.zIndex=""),C){var z,R;const I=this.element.ownerDocument.defaultView,w=(z=I?.scrollX)!==null&&z!==void 0?z:0,v=(R=I?.scrollY)!==null&&R!==void 0?R:0,S=C.top+v,D=C.left+w,y=Math.max(0,S-T.top),L=Math.max(0,D-T.left),M=Math.max(0,T.left+N-(C.right+w)),H=Math.max(0,T.top+O-(C.bottom+v));n.style.clipPath=`inset(${y}px ${M}px ${H}px ${L}px)`}else n.style.clipPath="";K(n,"dv-render-overlay-float",t.group.api.location.type==="floating")});f.pendingUpdate===Ql&&(f.pendingUpdate=m)},l=()=>{if(t.api.isVisible){var p;this.positionCache.invalidate(),a(),!((p=this.map[t.api.id])===null||p===void 0)&&p.retainPreviousGeometry&&(n.style.visibility=""),n.style.pointerEvents=""}else n.style.visibility="hidden",n.style.pointerEvents="none"},h=new Me,c=()=>{t.api.location.type==="floating"?queueMicrotask(()=>{const p=this.accessor.getFloatingWindowForGroup(t.api.group);if(!p)return;const f=p.overlay.element,m=()=>{const _=Number(f.getAttribute("aria-level"));n.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${_*2+1})`},g=new MutationObserver(()=>{m()});h.value=Se.from(()=>g.disconnect()),g.observe(f,{attributeFilter:["aria-level"],attributes:!0}),m()}):n.style.zIndex=""},u=new se(h,new qc(n,{onDragEnd:p=>{i.dropTarget.dnd.onDragEnd(p)},onDragEnter:p=>{i.dropTarget.dnd.onDragEnter(p)},onDragLeave:p=>{i.dropTarget.dnd.onDragLeave(p)},onDrop:p=>{i.dropTarget.dnd.onDrop(p)},onDragOver:p=>{i.dropTarget.dnd.onDragOver(p)}}),t.api.onDidVisibilityChange(()=>{l()}),t.api.onDidDimensionsChange(()=>{t.api.isVisible&&a()}),t.api.onDidLocationChange(()=>{c()}));return this.map[t.api.id].destroy=Se.from(()=>{o.parentElement===n&&o.remove(),n.remove()}),c(),queueMicrotask(()=>{this.isDisposed||l()}),this.map[t.api.id].disposable.dispose(),this.map[t.api.id].disposable=u,this.map[t.api.id].resize=a,n}};function th(e,t,i,s,r,n,o){try{var a=e[n](o),l=a.value}catch(h){i(h);return}a.done?t(l):Promise.resolve(l).then(s,r)}function bu(e){return function(){var t=this,i=arguments;return new Promise(function(s,r){var n=e.apply(t,i);function o(l){th(n,s,r,o,a,"next",l)}function a(l){th(n,s,r,o,a,"throw",l)}o(void 0)})}}function yw(e){let t;try{t=new URL(e,globalThis.location.href)}catch{throw new Error(`dockview: invalid popout URL: ${e}`)}if(!(t.protocol==="http:"||t.protocol==="https:")||t.origin!==globalThis.location.origin)throw new Error(`dockview: popout URL must be same-origin http(s); got: ${e}`)}var Sw=class extends se{get window(){var e,t;return(e=(t=this._window)===null||t===void 0?void 0:t.value)!==null&&e!==void 0?e:null}constructor(e,t,i){super(),this.target=e,this.className=t,this.options=i,this._onWillClose=new G,this.onWillClose=this._onWillClose.event,this._onDidClose=new G,this.onDidClose=this._onDidClose.event,this._window=null,this.addDisposables(this._onWillClose,this._onDidClose,{dispose:()=>{this.close()}})}dimensions(){if(!this._window)return null;const e=this._window.value.screenX;return{top:this._window.value.screenY,left:e,width:this._window.value.innerWidth,height:this._window.value.innerHeight}}close(){if(this._window){var e,t;this._onWillClose.fire(),(e=(t=this.options).onWillClose)===null||e===void 0||e.call(t,{id:this.target,window:this._window.value}),this._window.disposable.dispose(),this._window=null,this._onDidClose.fire()}}open(){var e=this;return bu(function*(){var t,i;if(e._window)throw new Error("instance of popout window is already open");const s=`${e.options.url}`;yw(s);const r=Object.entries({top:e.options.top,left:e.options.left,width:e.options.width,height:e.options.height}).map(([l,h])=>`${l}=${h}`).join(","),n=window.open(s,e.target,r);if(!n)return null;const o=new se;e._window={value:n,disposable:o},o.addDisposables(Se.from(()=>{n.close()}),Z(globalThis.window,"beforeunload",()=>{e.close()}));const a=e.createPopoutWindowContainer();return e.className&&a.classList.add(e.className),(t=(i=e.options).onDidOpen)===null||t===void 0||t.call(i,{id:e.target,window:n}),new Promise((l,h)=>{n.addEventListener("unload",()=>{}),o.addDisposables(e.onWillClose(()=>l(null))),n.addEventListener("load",()=>{try{const c=n.document;c.title=document.title,c.body.appendChild(a),m_(c,globalThis.document.styleSheets,{nonce:e.options.nonce}),Z(n,"beforeunload",()=>{e.close()}),l(a)}catch(c){h(c)}})})})()}createPopoutWindowContainer(){const e=document.createElement("div");return e.classList.add("dv-popout-window"),e.id="dv-popout-window",e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.top="0px",e.style.left="0px",e}},xw=class extends se{constructor(e){super(),this.accessor=e,this.init()}init(){const e=new Set,t=new Set;this.addDisposables(this.accessor.onDidAddPanel(i=>{if(e.has(i.api.id))throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${i.api.id} but panel already exists`);e.add(i.api.id)}),this.accessor.onDidRemovePanel(i=>{if(e.has(i.api.id))e.delete(i.api.id);else throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${i.api.id} but panel does not exists`)}),this.accessor.onDidAddGroup(i=>{if(t.has(i.api.id))throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${i.api.id} but group already exists`);t.add(i.api.id)}),this.accessor.onDidRemoveGroup(i=>{if(t.has(i.api.id))t.delete(i.api.id);else throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${i.api.id} but group does not exists`)}))}};function Cw(e){if(!e.matchMedia)return!1;const t=e.matchMedia("(pointer: coarse)").matches,i=e.matchMedia("(pointer: fine)").matches;return t&&!i}function Dw(e){var t,i,s,r,n,o,a;const l=(t=e.window)!==null&&t!==void 0?t:window,h=(i=e.capture)!==null&&i!==void 0?i:!1,c=(s=e.escape)!==null&&s!==void 0?s:!0,u=(r=e.keys)!==null&&r!==void 0?r:[],p=(n=e.outsidePointerDown)!==null&&n!==void 0?n:!0,f=(o=e.pointerDownGraceMs)!==null&&o!==void 0?o:0,m=(a=e.now)!==null&&a!==void 0?a:Date.now,g=m(),_=new se,E=C=>{var T,x;if(e.isInside)return e.isInside(C);const A=C.target;return A instanceof Node?((T=(x=e.elements)===null||x===void 0?void 0:x.call(e))!==null&&T!==void 0?T:[]).some(k=>k.contains(A)):!1};if((c||u.length>0)&&_.addDisposables(Z(l,"keydown",C=>{(c&&C.key==="Escape"||u.includes(C.key))&&e.onDismiss()},h)),(p||e.onInsidePointerDown)&&_.addDisposables(Z(l,"pointerdown",C=>{if(E(C)){var T;(T=e.onInsidePointerDown)===null||T===void 0||T.call(e,C);return}!p||m()-g<f||e.onDismiss()},h)),e.resize&&_.addDisposables(Z(l,"resize",()=>{Cw(l)||e.onDismiss()})),e.focusOut){const C=x=>{var A,k;return e.isFocusInside?e.isFocusInside(x):((A=(k=e.elements)===null||k===void 0?void 0:k.call(e))!==null&&A!==void 0?A:[]).some(N=>N.contains(x))},T=x=>{const A=x.target;A instanceof Element&&!C(A)&&e.onDismiss()};l.addEventListener("focusin",T,h),_.addDisposables({dispose:()=>l.removeEventListener("focusin",T,h)})}return _}var ih=class extends se{constructor(e,t=globalThis.window){super(),this._active=null,this._activeDisposable=new Me,this._root=e,this._window=t,this._element=t.document.createElement("div"),this._element.className="dv-popover-anchor",this._element.style.position="relative",this._root.prepend(this._element),this.addDisposables(Se.from(()=>{this.close()}),this._activeDisposable)}updateRoot(e){e.prepend(this._element),this._root=e}openPopover(e,t){var i;this.close();const s=this._window.document.createElement("div");s.style.position="absolute",s.style.zIndex=(i=t.zIndex)!==null&&i!==void 0?i:"var(--dv-overlay-z-index)",s.appendChild(e);const r=this._element.getBoundingClientRect(),n=r.left,o=r.top;s.style.top=`${t.y-o}px`,s.style.left=`${t.x-n}px`,this._element.appendChild(s),this._active=s;const a=200;this._activeDisposable.value=Dw({window:this._window,onDismiss:()=>this.close(),elements:()=>this._active?[this._active]:[],keys:["Enter"],pointerDownGraceMs:a,resize:!0}),this._window.requestAnimationFrame(()=>{y_(s,this._root)})}close(){this._active&&(this._active.remove(),this._activeDisposable.dispose(),this._active=null)}},vn=class extends se{get disabled(){return this._disabled}set disabled(e){this.disabled!==e&&(this._disabled=e,e&&this._clearNow())}_cancelPendingClear(){this._pendingClear!==void 0&&(clearTimeout(this._pendingClear),this._pendingClear=void 0)}_clearNow(){this._cancelPendingClear(),this._model&&this._model.root.remove(),this._model=void 0}get model(){if(!this.disabled)return{clear:()=>{this._clearNow()},scheduleClear:()=>{this._pendingClear!==void 0||!this._model||(this._pendingClear=setTimeout(()=>{this._pendingClear=void 0,this._clearNow()},0))},exists:()=>!!this._model,getElements:(e,t)=>{this._cancelPendingClear();const i=this._outline!==t;if(this._outline=t,this._model)return this._model.changed=i,this._model;const s=this.createContainer(),r=this.createAnchor();if(this._model={root:s,overlay:r,changed:i},s.appendChild(r),this.element.appendChild(s),e?.target instanceof HTMLElement){const n=e.target.getBoundingClientRect(),o=this.element.getBoundingClientRect();r.style.left=`${n.left-o.left}px`,r.style.top=`${n.top-o.top}px`}return this._model}}}constructor(e,t){super(),this.element=e,this._disabled=!1,this._disabled=t.disabled,this.addDisposables(Se.from(()=>{var i;(i=this.model)===null||i===void 0||i.clear()}))}createContainer(){const e=document.createElement("div");return e.className="dv-drop-target-container",e}createAnchor(){const e=document.createElement("div");return e.className="dv-drop-target-anchor",e.style.visibility="hidden",e}},kw=class{get _effectiveBaseCollapsed(){var e;return(e=this._measuredTabSize)!==null&&e!==void 0?e:this._baseCollapsedSize}get minimumSize(){return this._isCollapsed?this.collapsedSize:this._baseMinimumSize!==void 0?this._baseMinimumSize+this._gapAdd:this._effectiveBaseCollapsed+50+this._gapAdd}get maximumSize(){return this._isCollapsed?this.collapsedSize:this._expandedMaximumSize}get element(){return this._group.element}get isCollapsed(){return this._isCollapsed}get lastExpandedSize(){return this._lastExpandedSize}get collapsedSize(){return this._effectiveBaseCollapsed+this._gapAdd}get configuredMinimumSize(){return this._baseMinimumSize}get configuredMaximumSize(){return this._expandedMaximumSize}get configuredCollapsedSize(){return this._baseCollapsedSize}constructor(e,t,i,s=0){var r,n,o;this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this.snap=!1,this.priority="low",this._isCollapsed=!1,this._tabSizeDisposables=new se,this._group=t,this._orientation=i,t.element.classList.add("dv-edge-group"),t.element.dataset.testid=`dv-edge-group-${e.id}`,this._baseCollapsedSize=(r=e.collapsedSize)!==null&&r!==void 0?r:35,this._baseMinimumSize=e.minimumSize,this._gapAdd=s,this._expandedMaximumSize=(n=e.maximumSize)!==null&&n!==void 0?n:Number.POSITIVE_INFINITY,this._lastExpandedSize=(o=e.initialSize)!==null&&o!==void 0?o:200,e.collapsed&&(this._isCollapsed=!0,t.element.classList.add("dv-edge-collapsed")),this._observeTabStrip()}_observeTabStrip(){const e=this._group.element.querySelector(".dv-tabs-and-actions-container");e&&this._tabSizeDisposables.addDisposables(ji(e,()=>{this._applyMeasuredTabSize(this._orientation==="vertical"?e.offsetHeight:e.offsetWidth)}))}_applyMeasuredTabSize(e){e<=0||e===this._measuredTabSize||(this._measuredTabSize=e,this._isCollapsed&&this._onDidChange.fire({size:this.collapsedSize}))}layout(e,t){this._isCollapsed||(this._lastExpandedSize=e),this._orientation==="horizontal"?this._group.layout(e,t):this._group.layout(t,e)}setCollapsed(e){this._isCollapsed!==e&&(this._isCollapsed=e,this._group.element.classList.toggle("dv-edge-collapsed",e))}setVisible(e){}restoreExpandedSize(e){this._lastExpandedSize=e}updateSizing(e,t,i){this._baseCollapsedSize=e,this._baseMinimumSize=t,this._gapAdd=i}dispose(){this._tabSizeDisposables.dispose(),this._onDidChange.dispose()}},Pw=class{get element(){return this._dockviewElement}constructor(e,t){this._dockviewElement=e,this._layoutDockview=t,this.priority="high",this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this._onDidChange=new G,this.onDidChange=this._onDidChange.event}layout(e,t){this._layoutDockview(t,e)}setVisible(e){}dispose(){this._onDidChange.dispose()}},Ew=class{get element(){return this._element}constructor(e,t=0){this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this.priority="high",this._element=document.createElement("div"),this._element.className="dv-shell-middle-column",this._element.style.height="100%",this._element.style.width="100%",this._splitview=new Oi(this._element,{orientation:"VERTICAL",proportionalLayout:!1,margin:t}),this._centerIndex=0,this._splitview.addView(e,{type:"distribute"},0)}addTopView(e,t){this._splitview.addView(e,t,0),this._topIndex=0,this._centerIndex+=1,this._bottomIndex!==void 0&&(this._bottomIndex+=1)}addBottomView(e,t){const i=this._splitview.length;this._splitview.addView(e,t,i),this._bottomIndex=i}removeView(e){const t=e==="top"?this._topIndex:this._bottomIndex;t!==void 0&&(this._splitview.removeView(t),e==="top"?(this._topIndex=void 0,this._centerIndex-=1,this._bottomIndex!==void 0&&(this._bottomIndex-=1)):this._bottomIndex=void 0)}layout(e,t){this._splitview.layout(t,e)}setVisible(e){}setViewVisible(e,t){const i=e==="top"?this._topIndex:this._bottomIndex;i!==void 0&&this._splitview.setViewVisible(i,t)}isViewVisible(e){const t=e==="top"?this._topIndex:this._bottomIndex;return t!==void 0?this._splitview.isViewVisible(t):!1}getViewSize(e){const t=e==="top"?this._topIndex:this._bottomIndex;return t!==void 0?this._splitview.getViewSize(t):0}getViewCachedVisibleSize(e){const t=e==="top"?this._topIndex:this._bottomIndex;if(t!==void 0)return this._splitview.getViewCachedVisibleSize(t)}resizeView(e,t){const i=e==="top"?this._topIndex:this._bottomIndex;i!==void 0&&this._splitview.resizeView(i,t)}updateMargin(e){this._splitview.margin=e}dispose(){this._onDidChange.dispose(),this._splitview.dispose()}},Tw=class{constructor(e,t,i,s=0,r=35){this._disposables=new se,this._viewConfigs=new Map,this._currentWidth=0,this._currentHeight=0,this._gap=s,this._defaultCollapsedSize=r,this._shellElement=document.createElement("div"),this._shellElement.className="dv-shell",this._shellElement.style.height="100%",this._shellElement.style.width="100%",this._shellElement.style.position="relative",e.appendChild(this._shellElement);const n=new Pw(t,i);this._middleColumn=new Ew(n,s),this._outerSplitview=new Oi(this._shellElement,{orientation:"HORIZONTAL",proportionalLayout:!1,margin:s}),this._middleIndex=0,this._outerSplitview.addView(this._middleColumn,{type:"distribute"},0),this._disposables.addDisposables(ji(this._shellElement,o=>{if(!this._shellElement.offsetParent||!zc(this._shellElement))return;const a=Math.round(o.contentRect.width),l=Math.round(o.contentRect.height);a===this._currentWidth&&l===this._currentHeight||(this._currentWidth=a,this._currentHeight=l,this.layout(a,l))}),this._outerSplitview,this._middleColumn,n)}get element(){return this._shellElement}addEdgeView(e,t,i){if(this.hasEdgeGroup(e))throw new Error(`dockview: edge group already registered at position '${e}'`);this._viewConfigs.set(e,t);const s=1+(this._viewConfigs.has("left")?1:0)+(this._viewConfigs.has("right")?1:0),r=1+(this._viewConfigs.has("top")?1:0)+(this._viewConfigs.has("bottom")?1:0),n=s>1?this._gap*(s-1)/s:0,o=r>1?this._gap*(r-1)/r:0,a=e==="left"||e==="right",l=a?n:o,h=a?"horizontal":"vertical",c=new kw(re({collapsedSize:this._defaultCollapsedSize},t),i,h,l),u=c.isCollapsed?c.collapsedSize:c.lastExpandedSize;switch(e){case"left":this._outerSplitview.addView(c,u,0),this._leftIndex=0,this._middleIndex+=1,this._rightIndex!==void 0&&(this._rightIndex+=1),this._leftView=c;break;case"right":{const p=this._outerSplitview.length;this._outerSplitview.addView(c,u,p),this._rightIndex=p,this._rightView=c}break;case"top":this._middleColumn.addTopView(c,u),this._topView=c;break;case"bottom":this._middleColumn.addBottomView(c,u),this._bottomView=c;break}return this._disposables.addDisposables(c),this.updateTheme(this._gap,this._defaultCollapsedSize),c}layout(e,t){this._outerSplitview.layout(e,t)}updateTheme(e,t){var i,s,r,n;this._gap=e,this._defaultCollapsedSize=t;const o=1+(this._viewConfigs.has("left")?1:0)+(this._viewConfigs.has("right")?1:0),a=1+(this._viewConfigs.has("top")?1:0)+(this._viewConfigs.has("bottom")?1:0),l=o>1?e*(o-1)/o:0,h=a>1?e*(a-1)/a:0;this._outerSplitview.margin=e,this._middleColumn.updateMargin(e);const c=(g,_,E)=>{var C;const T=(C=_.collapsedSize)!==null&&C!==void 0?C:t;g.updateSizing(T,_.minimumSize,E)},u=this._viewConfigs.get("top");this._topView&&u&&c(this._topView,u,h);const p=this._viewConfigs.get("bottom");this._bottomView&&p&&c(this._bottomView,p,h);const f=this._viewConfigs.get("left");this._leftView&&f&&c(this._leftView,f,l);const m=this._viewConfigs.get("right");this._rightView&&m&&c(this._rightView,m,l),!((i=this._leftView)===null||i===void 0)&&i.isCollapsed&&this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,this._leftView.collapsedSize),!((s=this._rightView)===null||s===void 0)&&s.isCollapsed&&this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,this._rightView.collapsedSize),!((r=this._topView)===null||r===void 0)&&r.isCollapsed&&this._middleColumn.resizeView("top",this._topView.collapsedSize),!((n=this._bottomView)===null||n===void 0)&&n.isCollapsed&&this._middleColumn.resizeView("bottom",this._bottomView.collapsedSize),this._currentWidth>0&&this._currentHeight>0&&this.layout(this._currentWidth,this._currentHeight)}removeEdgeView(e){const t=this._getView(e);if(t){switch(e){case"left":this._outerSplitview.removeView(this._leftIndex),this._leftIndex=void 0,this._leftView=void 0,this._middleIndex-=1,this._rightIndex!==void 0&&(this._rightIndex-=1);break;case"right":this._outerSplitview.removeView(this._rightIndex),this._rightIndex=void 0,this._rightView=void 0;break;case"top":this._middleColumn.removeView("top"),this._topView=void 0;break;case"bottom":this._middleColumn.removeView("bottom"),this._bottomView=void 0;break}this._disposables.removeDisposable(t),t.dispose(),this._viewConfigs.delete(e),this.updateTheme(this._gap,this._defaultCollapsedSize)}}hasEdgeGroup(e){switch(e){case"top":return this._topView!==void 0;case"bottom":return this._bottomView!==void 0;case"left":return this._leftView!==void 0;case"right":return this._rightView!==void 0}}setEdgeGroupVisible(e,t){switch(e){case"left":this._leftIndex!==void 0&&this._outerSplitview.setViewVisible(this._leftIndex,t);break;case"right":this._rightIndex!==void 0&&this._outerSplitview.setViewVisible(this._rightIndex,t);break;case"top":case"bottom":this._middleColumn.setViewVisible(e,t);break}}isEdgeGroupVisible(e){switch(e){case"left":return this._leftIndex!==void 0?this._outerSplitview.isViewVisible(this._leftIndex):!1;case"right":return this._rightIndex!==void 0?this._outerSplitview.isViewVisible(this._rightIndex):!1;case"top":case"bottom":return this._middleColumn.isViewVisible(e)}}setEdgeGroupCollapsed(e,t){const i=this._getView(e);if(!i)return;i.setCollapsed(t);const s=t?i.collapsedSize:i.lastExpandedSize;switch(e){case"left":this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,s);break;case"right":this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,s);break;case"top":case"bottom":this._middleColumn.resizeView(e,s);break}}isEdgeGroupCollapsed(e){var t,i;return(t=(i=this._getView(e))===null||i===void 0?void 0:i.isCollapsed)!==null&&t!==void 0?t:!1}getEdgeGroupExpandedSize(e){var t,i;return(t=(i=this._getView(e))===null||i===void 0?void 0:i.lastExpandedSize)!==null&&t!==void 0?t:0}_getView(e){switch(e){case"top":return this._topView;case"bottom":return this._bottomView;case"left":return this._leftView;case"right":return this._rightView}}toJSON(){const e={},t=s=>({minimumSize:s.configuredMinimumSize,maximumSize:Number.isFinite(s.configuredMaximumSize)?s.configuredMaximumSize:void 0,collapsedSize:s.configuredCollapsedSize}),i=(s,r,n,o)=>s.isCollapsed?s.lastExpandedSize:r?n:o??s.lastExpandedSize;if(this._leftView&&this._leftIndex!==void 0){const s=this._outerSplitview.isViewVisible(this._leftIndex);e.left=re({size:i(this._leftView,s,this._outerSplitview.getViewSize(this._leftIndex),this._outerSplitview.getViewCachedVisibleSize(this._leftIndex)),visible:s,collapsed:this._leftView.isCollapsed||void 0},t(this._leftView))}if(this._rightView&&this._rightIndex!==void 0){const s=this._outerSplitview.isViewVisible(this._rightIndex);e.right=re({size:i(this._rightView,s,this._outerSplitview.getViewSize(this._rightIndex),this._outerSplitview.getViewCachedVisibleSize(this._rightIndex)),visible:s,collapsed:this._rightView.isCollapsed||void 0},t(this._rightView))}if(this._topView){const s=this._middleColumn.isViewVisible("top");e.top=re({size:i(this._topView,s,this._middleColumn.getViewSize("top"),this._middleColumn.getViewCachedVisibleSize("top")),visible:s,collapsed:this._topView.isCollapsed||void 0},t(this._topView))}if(this._bottomView){const s=this._middleColumn.isViewVisible("bottom");e.bottom=re({size:i(this._bottomView,s,this._middleColumn.getViewSize("bottom"),this._middleColumn.getViewCachedVisibleSize("bottom")),visible:s,collapsed:this._bottomView.isCollapsed||void 0},t(this._bottomView))}return e}fromJSON(e){if(e.left&&this._leftIndex!==void 0){var t,i,s,r,n;(t=this._leftView)===null||t===void 0||t.restoreExpandedSize(e.left.size),(i=this._leftView)===null||i===void 0||i.setCollapsed((s=e.left.collapsed)!==null&&s!==void 0?s:!1),this._outerSplitview.resizeView(this._leftIndex,e.left.collapsed&&(r=(n=this._leftView)===null||n===void 0?void 0:n.collapsedSize)!==null&&r!==void 0?r:e.left.size),e.left.visible||this._outerSplitview.setViewVisible(this._leftIndex,!1)}if(e.right&&this._rightIndex!==void 0){var o,a,l,h,c;(o=this._rightView)===null||o===void 0||o.restoreExpandedSize(e.right.size),(a=this._rightView)===null||a===void 0||a.setCollapsed((l=e.right.collapsed)!==null&&l!==void 0?l:!1),this._outerSplitview.resizeView(this._rightIndex,e.right.collapsed&&(h=(c=this._rightView)===null||c===void 0?void 0:c.collapsedSize)!==null&&h!==void 0?h:e.right.size),e.right.visible||this._outerSplitview.setViewVisible(this._rightIndex,!1)}if(e.top){var u,p,f,m,g;(u=this._topView)===null||u===void 0||u.restoreExpandedSize(e.top.size),(p=this._topView)===null||p===void 0||p.setCollapsed((f=e.top.collapsed)!==null&&f!==void 0?f:!1),this._middleColumn.resizeView("top",e.top.collapsed&&(m=(g=this._topView)===null||g===void 0?void 0:g.collapsedSize)!==null&&m!==void 0?m:e.top.size),e.top.visible||this._middleColumn.setViewVisible("top",!1)}if(e.bottom){var _,E,C,T,x;(_=this._bottomView)===null||_===void 0||_.restoreExpandedSize(e.bottom.size),(E=this._bottomView)===null||E===void 0||E.setCollapsed((C=e.bottom.collapsed)!==null&&C!==void 0?C:!1),this._middleColumn.resizeView("bottom",e.bottom.collapsed&&(T=(x=this._bottomView)===null||x===void 0?void 0:x.collapsedSize)!==null&&T!==void 0?T:e.bottom.size),e.bottom.visible||this._middleColumn.setViewVisible("bottom",!1)}}dispose(){this._disposables.dispose(),this._shellElement.remove()}};function Iw(e){var t;return new cu((t=e.tabGroupColors)!==null&&t!==void 0?t:Na,e.tabGroupAccent!=="off")}function sr(e){const t=e.from.activePanel;[...e.from.panels].map(i=>{const s=e.from.model.removePanel(i);return e.from.model.renderContainer.detatch(i),s}).forEach(i=>{e.to.model.openPanel(i,{skipSetActive:t!==i,skipSetGroupActive:!0})})}const co=()=>({dispose:()=>{}}),Aw=co;var Rw=class extends Fc{fireDidCreateTabGroup(e){this._onDidCreateTabGroup.fire(e)}fireDidDestroyTabGroup(e){this._onDidDestroyTabGroup.fire(e)}fireDidAddPanelToTabGroup(e){this._onDidAddPanelToTabGroup.fire(e)}fireDidRemovePanelFromTabGroup(e){this._onDidRemovePanelFromTabGroup.fire(e)}fireDidTabGroupChange(e){this._onDidTabGroupChange.fire(e)}fireDidTabGroupCollapsedChange(e){this._onDidTabGroupCollapsedChange.fire(e)}get orientation(){return this.gridview.orientation}get totalPanels(){return this.panels.length}get panels(){return this.groups.flatMap(e=>e.panels)}get options(){return this._options}get tabGroupColorPalette(){return this._tabGroupColorPalette}get activePanel(){const e=this.activeGroup;if(e)return e.activePanel}get renderer(){var e;return(e=this.options.defaultRenderer)!==null&&e!==void 0?e:"onlyWhenVisible"}get defaultHeaderPosition(){var e;return(e=this.options.defaultHeaderPosition)!==null&&e!==void 0?e:"top"}get api(){return this._api}get floatingGroups(){var e,t;return(e=(t=this._moduleRegistry)===null||t===void 0||(t=t.services.floatingGroupService)===null||t===void 0?void 0:t.floatingGroups)!==null&&e!==void 0?e:[]}getFloatingWindowForGroup(e){var t;return(t=this._floatingGroupService)===null||t===void 0?void 0:t.findByGroup(e)}_gatherFloatingGroupBoxes(e){return this.getFloatingGroupSnapshots(e).map(t=>t.box)}getFloatingContainer(){var e;return(e=this._floatingOverlayHost)!==null&&e!==void 0?e:this.gridview.element}getFloatingGroupSnapshots(e){const t=this.getFloatingContainer().getBoundingClientRect();return this.floatingGroups.filter(i=>i.group!==e).map(i=>{const s=i.overlay.element.getBoundingClientRect();return{group:i.group,box:{left:s.left-t.left,top:s.top-t.top,width:s.width,height:s.height}}})}mergeFloatInto(e,t,i){e===t||!this.getPanel(t.id)||this.moveGroupOrPanel({from:{groupId:e.id},to:{group:t,position:i}})}getGridSplitterRects(){const e=this.getFloatingContainer().getBoundingClientRect(),t=[];return this.gridview.element.querySelectorAll(".dv-sash").forEach(i=>{const s=i.getBoundingClientRect();t.push({left:s.left-e.left,top:s.top-e.top,width:s.width,height:s.height})}),t}get _smartGuidesService(){return this._moduleRegistry.services.smartGuidesService}get smartGuidesEnabled(){var e,t;return(e=(t=this._smartGuidesService)===null||t===void 0?void 0:t.enabled)!==null&&e!==void 0?e:!1}setSmartGuidesEnabled(e){var t;(t=ct(this._smartGuidesService,"SmartGuides","api.setSmartGuidesEnabled"))===null||t===void 0||t.setEnabled(e)}updateSmartGuidesOptions(e){var t;(t=ct(this._smartGuidesService,"SmartGuides","api.updateSmartGuidesOptions"))===null||t===void 0||t.updateOptions(e)}get onDidSnapFloat(){var e,t;return(e=(t=this._smartGuidesService)===null||t===void 0?void 0:t.onDidSnapFloat)!==null&&e!==void 0?e:co}get onDidSnapTogether(){var e,t;return(e=(t=this._smartGuidesService)===null||t===void 0?void 0:t.onDidSnapTogether)!==null&&e!==void 0?e:co}_buildFloatingDragTransform(e,t){const i=this.options.transformFloatingGroupDrag,s=!t;if(!(!i&&!(s&&this._smartGuidesService)))return r=>{var n,o;const a=i?.({group:e,proposed:r.proposed,container:r.container,others:r.others,modifiers:r.modifiers}),l=a?re(re({},r.proposed),a):r.proposed,h=s?(n=this._smartGuidesService)===null||n===void 0?void 0:n.transformFloatingGroupDrag({group:e,proposed:l,container:r.container,others:r.others,modifiers:r.modifiers}):void 0;return(o=h??a)!==null&&o!==void 0?o:void 0}}get _floatingGroupService(){return this._moduleRegistry.services.floatingGroupService}get _popoutWindowService(){return this._moduleRegistry.services.popoutWindowService}get _watermarkService(){return this._moduleRegistry.services.watermarkService}get _edgeGroupService(){return this._moduleRegistry.services.edgeGroupService}get _rootDropTargetService(){return this._moduleRegistry.services.rootDropTargetService}get _advancedDnDService(){return this._moduleRegistry.services.advancedDnDService}get _dndCompassService(){return this._moduleRegistry.services.dndCompassService}canDropOnGroup(e,t,i){return e.model.canDisplayContentOverlay(i,t)}getDropOverlayElement(e){var t,i;const s=e.element.querySelector(".dv-content-container");if(s)return((t=this.options.theme)===null||t===void 0?void 0:t.dndPanelOverlay)==="group"&&(i=s.parentElement)!==null&&i!==void 0?i:s}getTabsListElement(e){return e.model.header.hidden?void 0:e.model.tabsListElement}relayoutGroup(e){e.relayout()}setForcedOverflow(e,t){e.model.header.setForcedOverflow(t)}getLayoutElement(){return this.gridview.element}getDropPositionResolver(){var e;if(this.options.dropPositionResolver)return this.options.dropPositionResolver;const t=(e=this._dndCompassService)===null||e===void 0?void 0:e.resolver,i=this._moduleRegistry.services.autoEdgeGroupService;return t&&i?{resolve:s=>{var r;return(r=i.resolveEdge(s))!==null&&r!==void 0?r:t.resolve(s)}}:t??i?.resolver}dockToLayoutEdge(e,t){const i=new fu({nativeEvent:e,position:t,panel:void 0,api:this._api,group:void 0,getData:Te,kind:"edge"});if(this._onWillDrop.fire(i),i.defaultPrevented)return;const s=Te();if(s){var r;this.moveGroupOrPanel({from:{groupId:s.groupId,panelId:(r=s.panelId)!==null&&r!==void 0?r:void 0},to:{group:this.orthogonalize(t),position:"center"}})}else this._onDidDrop.fire(new Ga({nativeEvent:e,position:t,panel:void 0,api:this._api,group:void 0,getData:Te}))}get headerActionsService(){return this._moduleRegistry.services.headerActionsService}get _layoutHistoryService(){return this._moduleRegistry.services.layoutHistoryService}undo(){var e;(e=ct(this._layoutHistoryService,"LayoutHistory","api.undo"))===null||e===void 0||e.undo()}redo(){var e;(e=ct(this._layoutHistoryService,"LayoutHistory","api.redo"))===null||e===void 0||e.redo()}get canUndo(){var e,t;return(e=(t=this._layoutHistoryService)===null||t===void 0?void 0:t.canUndo)!==null&&e!==void 0?e:!1}get canRedo(){var e,t;return(e=(t=this._layoutHistoryService)===null||t===void 0?void 0:t.canRedo)!==null&&e!==void 0?e:!1}clearHistory(){var e;(e=this._layoutHistoryService)===null||e===void 0||e.clear()}get onDidChangeHistory(){var e,t;return(e=(t=this._layoutHistoryService)===null||t===void 0?void 0:t.onDidChangeHistory)!==null&&e!==void 0?e:Aw}get hasEdgeDragReveal(){return!!this._moduleRegistry.services.autoEdgeGroupService}isGridEmpty(){return this.gridview.length===0}rootDropTargetOverrideTarget(){var e;return(e=this.rootDropTargetContainer)===null||e===void 0?void 0:e.model}dispatchUnhandledDragOver(e,t){const i=new du(e,"edge",t,Te);return this._onUnhandledDragOver.fire(i),i.isAccepted}fireWillDragPanel(e){this._onWillDragPanel.fire(e)}fireWillDragGroup(e){this._onWillDragGroup.fire(e)}fireWillDrop(e){this._onWillDrop.fire(e)}fireWillShowOverlay(e){this._onWillShowOverlay.fire(e)}buildGroupDragGhost(e){var t;return(t=this._advancedDnDService)===null||t===void 0?void 0:t.buildGroupDragGhost(e)}resolveDropOverlayModel(e,t){var i;return(i=this._advancedDnDService)===null||i===void 0?void 0:i.resolveOverlayModel(e,t)}get rootElement(){var e,t;return(e=(t=this._shellManager)===null||t===void 0?void 0:t.element)!==null&&e!==void 0?e:this.element}ownsElement(e){if(this.rootElement.contains(e))return!0;const t=this.rootElement.ownerDocument,i=e.ownerDocument;return!i||i===t?!1:this.getPopoutWindows().some(s=>s.document===i)}adjacentGroup(e,t){var i;if(e.api.location.type!=="grid")return;const s=Ce(e.element);return(i=t?this.gridview.previous(s):this.gridview.next(s))===null||i===void 0?void 0:i.view}adjacentGroupInDirection(e,t){if(e.api.location.type!=="grid")return;const i=e.element.getBoundingClientRect(),s=i.left+i.width/2,r=i.top+i.height/2;let n,o=Number.POSITIVE_INFINITY;for(const a of this.groups){if(a===e||a.api.location.type!=="grid")continue;const l=a.element.getBoundingClientRect(),h=l.left+l.width/2-s,c=l.top+l.height/2-r;let u;switch(t){case"left":u=h<0&&Math.abs(h)>=Math.abs(c);break;case"right":u=h>0&&Math.abs(h)>=Math.abs(c);break;case"up":u=c<0&&Math.abs(c)>=Math.abs(h);break;default:u=c>0&&Math.abs(c)>=Math.abs(h);break}if(!u)continue;const p=h*h+c*c;p<o&&(o=p,n=a)}return n}showDropPreview(e,t){var i,s;return(i=(s=this._advancedDnDService)===null||s===void 0?void 0:s.showPreviewOverlay(e,t))!==null&&i!==void 0?i:Se.NONE}announce(e){var t;(t=this._moduleRegistry.services.liveRegionService)===null||t===void 0||t.announce(e)}dockPanel(e,t,i){this.moveGroupOrPanel({from:{groupId:e.group.id,panelId:e.id},to:{group:t,position:i}})}floatPanel(e){this.addFloatingGroup(e)}get contextMenuService(){return this._moduleRegistry.services.contextMenuService}get pinnedTabsService(){return this._moduleRegistry.services.pinnedTabsService}get advancedOverflowService(){return this._moduleRegistry.services.advancedOverflowService}setPanelPinned(e,t){var i;e.isPinned!==t&&!((i=this.options.pinnedTabs)===null||i===void 0)&&i.enabled&&this.pinnedTabsService&&(e.setPinned(t),this._onDidPanelPinnedChange.fire({panel:e,isPinned:t}))}get mountElement(){return this.gridview.element}hasVisibleGridGroup(){return this.groups.some(e=>e.api.location.type==="grid"&&e.api.isVisible)}fireLayoutChange(){this._bufferOnDidLayoutChange.fire()}get popoutRestorationPromise(){var e,t;return(e=(t=this._popoutWindowService)===null||t===void 0?void 0:t.restorationPromise)!==null&&e!==void 0?e:Promise.resolve()}constructor(e,t){var i,s,r,n,o;super(e,{proportionalLayout:!0,orientation:"HORIZONTAL",styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:t.disableAutoResizing,locked:t.locked,margin:(i=(s=t.theme)===null||s===void 0?void 0:s.gap)!==null&&i!==void 0?i:0,className:t.className}),this.nextGroupId=Ta(),this._deserializer=new zb(this),this._moduleRegistry=new Hb,this._onWillDragPanel=new G,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new G,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new G,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new G,this.onWillDrop=this._onWillDrop.event,this._mutationDepth=0,this._pendingLocationChanges=new Map,this._origin="user",this._originDepth=0,this._onWillMutateLayout=new G,this.onWillMutateLayout=this._onWillMutateLayout.event,this._onDidMutateLayout=new G,this.onDidMutateLayout=this._onDidMutateLayout.event,this._onWillShowOverlay=new G,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onUnhandledDragOver=new G,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this._onDidRemovePanel=new G,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new G,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPopoutGroupSizeChange=new G,this.onDidPopoutGroupSizeChange=this._onDidPopoutGroupSizeChange.event,this._onDidPopoutGroupPositionChange=new G,this.onDidPopoutGroupPositionChange=this._onDidPopoutGroupPositionChange.event,this._onDidAddPopoutGroup=new G,this.onDidAddPopoutGroup=this._onDidAddPopoutGroup.event,this._onDidRemovePopoutGroup=new G,this.onDidRemovePopoutGroup=this._onDidRemovePopoutGroup.event,this._onDidChangePopouts=new G,this.onDidChangePopouts=this._onDidChangePopouts.event,this._onDidOpenPopoutWindowFail=new G,this.onDidOpenPopoutWindowFail=this._onDidOpenPopoutWindowFail.event,this._onDidStartFloatingGroupDrag=new G,this.onDidStartFloatingGroupDrag=this._onDidStartFloatingGroupDrag.event,this._onDidEndFloatingGroupDrag=new G,this.onDidEndFloatingGroupDrag=this._onDidEndFloatingGroupDrag.event,this._onDidLayoutFromJSON=new G,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new G({replay:!0}),this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidPanelPinnedChange=new G,this.onDidPanelPinnedChange=this._onDidPanelPinnedChange.event,this._onDidMovePanel=new G,this.onDidMovePanel=this._onDidMovePanel.event,this._onDidCreateTabGroup=new G,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new G,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new G,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new G,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new G,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new G,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,this._onDidMaximizedGroupChange=new G,this.onDidMaximizedGroupChange=this._onDidMaximizedGroupChange.event,this._inShellLayout=!1,this._onDidRemoveGroup=new G,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidEdgeGroupAutoHideChange=new G,this.onDidEdgeGroupAutoHideChange=this._onDidEdgeGroupAutoHideChange.event,this._onDidAddGroup=new G,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidOptionsChange=new G,this.onDidOptionsChange=this._onDidOptionsChange.event,this._onDidActiveGroupChange=new G,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._peekingGroups=new Set,this._moving=!1,this._options=t,this._tabGroupColorPalette=Iw(t);const a=t.modules,l=a??[..._w,...Vb()];for(const u of l)this._moduleRegistry.register(u);this._moduleRegistry.initialize(this),this.reportMissingOptionModules(t);const h=this._popoutWindowService;h&&this.addDisposables(h.onDidRemove(u=>{this._onDidRemovePopoutGroup.fire({id:u.popoutGroup.id,group:u.popoutGroup,window:u.getWindow()})})),this.popupService=new ih(this.element),this._api=new Aa(this),this.disableResizing=!0,this.element.remove(),this._shellManager=new Tw(e,this.element,(u,p)=>this._layoutFromShell(u,p),(r=(n=t.theme)===null||n===void 0?void 0:n.gap)!==null&&r!==void 0?r:0,(o=t.theme)===null||o===void 0?void 0:o.edgeGroupCollapsedSize),this.popupService.updateRoot(this._shellManager.element),this._shellThemeClassnames=new qr(this._shellManager.element),this.rootDropTargetContainer=new vn(this._shellManager.element,{disabled:!0}),this.floatingDropTargetContainer=new vn(this._shellManager.element,{disabled:!1}),this.overlayRenderContainer=new eh(this._shellManager.element,this),this._floatingOverlayHost=document.createElement("div"),this._floatingOverlayHost.className="dv-floating-overlay-host",this._shellManager.element.appendChild(this._floatingOverlayHost),K(this.gridview.element,"dv-dockview",!0),K(this.element,"dv-debug",!!t.debug),this.updateTheme(),t.debug&&this.addDisposables(new xw(this)),this.addDisposables(Se.from(()=>this._pendingLocationChanges.clear()),this.rootDropTargetContainer,this.floatingDropTargetContainer,Z(this._shellManager.element,"dragend",()=>{var u,p;(u=this.rootDropTargetContainer.model)===null||u===void 0||u.clear(),(p=this.floatingDropTargetContainer.model)===null||p===void 0||p.clear()},!0),this.overlayRenderContainer,this._onWillDragPanel,this._onWillDragGroup,this._onWillShowOverlay,this._onDidActivePanelChange,this._onDidPanelPinnedChange,this._onDidAddPanel,this._onDidRemovePanel,this._onDidLayoutFromJSON,this._onDidDrop,this._onWillDrop,this._onWillMutateLayout,this._onDidMutateLayout,this._onDidMovePanel,this._onDidMovePanel.event(()=>{this.debouncedUpdateAllPositions()}),this._onDidAddGroup,this._onDidRemoveGroup,this._onDidEdgeGroupAutoHideChange,this._onDidActiveGroupChange,this._onUnhandledDragOver,this._onDidMaximizedGroupChange,this._onDidPopoutGroupSizeChange,this._onDidPopoutGroupPositionChange,this._onDidAddPopoutGroup,this._onDidRemovePopoutGroup,this._onDidChangePopouts,this._onDidAddPopoutGroup.event(()=>this._onDidChangePopouts.fire()),this._onDidRemovePopoutGroup.event(()=>this._onDidChangePopouts.fire()),this._onDidOpenPopoutWindowFail,this._onDidStartFloatingGroupDrag,this._onDidEndFloatingGroupDrag,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,xt.any(this.onDidPopoutGroupSizeChange,this.onDidPopoutGroupPositionChange,this.onDidCreateTabGroup,this.onDidDestroyTabGroup,this.onDidAddPanelToTabGroup,this.onDidRemovePanelFromTabGroup,this.onDidTabGroupChange,this.onDidTabGroupCollapsedChange)(()=>{this.fireLayoutChange()}),this._onDidOptionsChange,this.onDidAdd(u=>{this._moving||this._onDidAddGroup.fire(u)}),this.onDidRemove(u=>{this._moving||this._onDidRemoveGroup.fire(u)}),this.onDidActiveChange(u=>{this._moving||this._onDidActiveGroupChange.fire(u)}),this.onDidMaximizedChange(u=>{this._onDidMaximizedGroupChange.fire({group:u.panel,isMaximized:u.isMaximized})}),xt.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidAddGroup,this.onDidRemove,this.onDidRemoveGroup,this.onDidMovePanel,this.onDidActivePanelChange)(()=>{this._bufferOnDidLayoutChange.fire()}),Se.from(()=>{var u;this._moduleRegistry.dispose(),(u=this._shellManager)===null||u===void 0||u.dispose()}));const c=this._rootDropTargetService;c&&this.addDisposables(c.onWillShowOverlay(u=>{this.gridview.length>0&&u.position==="center"||this._onWillShowOverlay.fire(new As(u,{kind:"edge",panel:void 0,api:this._api,group:void 0,getData:Te}))}),c.onDrop(u=>this.dockToLayoutEdge(u.nativeEvent,u.position))),this._moduleRegistry.postConstruct(this)}setVisible(e,t){switch(e.api.location.type){case"grid":super.setVisible(e,t);break;case"floating":{const i=this.floatingGroups.find(s=>s.group===e);i&&(i.overlay.setVisible(t),e.api._onDidVisibilityChange.fire({isVisible:t}));break}case"popout":console.warn("dockview: You cannot hide a group that is in a popout window");break}}getPopupServiceForGroup(e){var t,i;return(t=(i=this._popoutWindowService)===null||i===void 0||(i=i.findByGroup(e))===null||i===void 0?void 0:i.popupService)!==null&&t!==void 0?t:this.popupService}addPopoutGroup(e,t){return this.mutationAsync("popout",()=>this._doAddPopoutGroup(e,t))}getPopouts(){var e,t;return(e=(t=this._popoutWindowService)===null||t===void 0?void 0:t.entries.map(i=>({id:i.popoutGroup.id,group:i.popoutGroup,window:i.getWindow()})))!==null&&e!==void 0?e:[]}getPopoutWindows(){return this.getPopouts().map(e=>e.window)}_doAddPopoutGroup(e,t){var i,s,r,n,o;const a=ct(this._popoutWindowService,"PopoutWindow","api.addPopoutGroup");if(!a||e instanceof er&&e.model.location.type==="edge")return Promise.resolve(!1);if(e instanceof qi&&e.group.size===1)return this.addPopoutGroup(e.group,t);const l=__(this.gridview.element),h=this.element;function c(){var _,E;if(t?.position)return t.position;const C=(e instanceof er?e.element:(_=(E=e.group)===null||E===void 0?void 0:E.element)!==null&&_!==void 0?_:h).getBoundingClientRect();return{left:window.screenX+C.left,top:window.screenY+C.top,width:C.width,height:C.height}}const u=c(),p=(i=t==null||(s=t.overridePopoutGroup)===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:this.getNextGroupId(),f=(r=t?.popoutUrl)!==null&&r!==void 0?r:(n=this.options)===null||n===void 0?void 0:n.popoutUrl,m=new Sw(`${this.id}-${p}`,l??"",{url:f??"/popout.html",left:u.left,top:u.top,width:u.width,height:u.height,onDidOpen:t?.onDidOpen,onWillClose:t?.onWillClose,nonce:(o=this.options)===null||o===void 0?void 0:o.nonce}),g=new se(m,m.onDidClose(()=>{g.dispose()}));return m.open().then(_=>{var E,C;if(m.isDisposed)return!1;const T=(E=t?.referenceGroup)!==null&&E!==void 0?E:e instanceof qi?e.group:e,x=e.api.location.type,A=T.element.parentElement!==null;let k;if(t?.overridePopoutGridview){var N;k=(N=t.overridePopoutGroup)!==null&&N!==void 0?N:T}else A?t?.overridePopoutGroup?k=t.overridePopoutGroup:(k=this.createGroup({id:p}),_&&this._onDidAddGroup.fire(k)):k=T;if(_===null)return this.handleBlockedPopout({group:k,referenceGroup:T,options:t,popoutWindowDisposable:g}),!1;const O=document.createElement("div");O.className="dv-overlay-render-container";const z=new eh(O,this);k.model.renderContainer=z;const R=(C=t?.overridePopoutGridview)!==null&&C!==void 0?C:this.createNestedGridview();t?.overridePopoutGridview||R.addView(k,nt.Distribute,[0]),R.element.style.width="100%",R.element.style.height="100%",R.layout(m.window.innerWidth,m.window.innerHeight);let I=!1;const w=()=>{I||(I=!0,R.dispose())};let v,S=[];if(!t?.overridePopoutGroup&&!t?.overridePopoutGridview&&A)if(e instanceof qi){const ne=e.group;this.movingLock(()=>{const W=T.model.removePanel(e);k.model.openPanel(W)}),S=[{panel:e,from:ne}]}else switch(this.movingLock(()=>sr({from:T,to:k})),S=k.panels.map(ne=>({panel:ne,from:T})),x){case"grid":T.api.setVisible(!1);break;case"floating":case"popout":var D;v=(D=this.floatingGroups.find(ne=>ne.group.api.id===e.api.id))===null||D===void 0?void 0:D.overlay.toJSON(),this.removeGroup(T);break}_.classList.add("dv-dockview"),_.style.overflow="hidden",_.appendChild(O),_.appendChild(R.element);const y=document.createElement("div"),L=new vn(y,{disabled:this.rootDropTargetContainer.disabled});_.appendChild(y),k.model.dropTargetContainer=L;const M=new ih(_,m.window);if(g.addDisposables(M),k.model.location={type:"popout",getWindow:()=>m.window,popoutUrl:f},t?.overridePopoutGridview){const ne=this.groups.filter(W=>R.element.contains(W.element));for(const W of ne)W.model.renderContainer=z,W.model.dropTargetContainer=L,W.model.location={type:"popout",getWindow:()=>m.window,popoutUrl:f}}A&&e.api.location.type==="grid"&&e.api.setVisible(!1),this.doSetGroupAndPanelActive(k);const H=a.observeGridviewSize(m,R,z);H&&g.addDisposables(H);const j=new Me;g.addDisposables(j);const J=ne=>{j.value=new se(ne.api.onDidActiveChange(W=>{if(W.isActive){var ge;(ge=m.window)===null||ge===void 0||ge.focus()}}),ne.api.onWillFocus(()=>{var W;(W=m.window)===null||W===void 0||W.focus()}))};J(k);const te={},ie=A&&T&&this.getPanel(T.id),le={window:m,popoutGroup:k,gridview:R,overlayRenderContainer:z,dropTargetContainer:L,getWindow:()=>m.window,popoutUrl:f,referenceGroup:ie?T.id:void 0,popupService:M,setAnchorGroup:ne=>{le.popoutGroup=ne,J(ne)},disposable:{dispose:()=>(g.dispose(),te.returnedGroup)}},me=b_(m.window);g.addDisposables(me,w_(m.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:m.window.innerWidth,height:m.window.innerHeight,group:le.popoutGroup})}),me.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:m.window.screenX,screenY:m.window.screenY,group:le.popoutGroup})}),Z(m.window,"resize",()=>{R.layout(m.window.innerWidth,m.window.innerHeight)}),z,Se.from(()=>this.disposePopoutWindow({group:k,referenceGroup:T,popoutGridview:R,isGroupAddedToDom:A,floatingBox:v,disposePopoutGridview:w,closeResult:te}))),a.add(le),this._onDidAddPopoutGroup.fire({id:le.popoutGroup.id,group:le.popoutGroup,window:le.getWindow()});for(const{panel:ne,from:W}of S)this.fireDidMovePanel(ne,W);return!0}).catch(_=>(console.error("dockview: failed to create popout.",_),!1))}handleBlockedPopout(e){const{group:t,referenceGroup:i,options:s,popoutWindowDisposable:r}=e;if(console.error("dockview: failed to create popout. perhaps you need to allow pop-ups for this website"),r.dispose(),this._onDidOpenPopoutWindowFail.fire(),s?.overridePopoutGridview){const n=s.overridePopoutGridview,o=this.groups.filter(a=>n.element.contains(a.element));for(const a of o)this.movingLock(()=>{n.remove(a),this.redockGroupToMainGrid(a)});n.dispose(),i&&!i.api.isVisible&&i.api.setVisible(!0);return}t===i?this.gridview.element.contains(t.element)||(this.movingLock(()=>this.doAddGroup(t,[0])),t.model.location={type:"grid"}):(this.movingLock(()=>sr({from:t,to:i})),t.model.size===0&&this._groups.has(t.id)&&(t.dispose(),this._groups.delete(t.id),this._onDidRemoveGroup.fire(t))),i.api.isVisible||i.api.setVisible(!0)}redockGroupToMainGrid(e){e.model.renderContainer=this.overlayRenderContainer,e.model.dropTargetContainer=this.rootDropTargetContainer,e.model.location={type:"grid"},this.doAddGroup(e,[0])}disposePopoutWindow(e){var t;const{group:i,referenceGroup:s,popoutGridview:r,isGroupAddedToDom:n,floatingBox:o,disposePopoutGridview:a,closeResult:l}=e;if(this.isDisposed){a();return}const h=!!(!((t=this._popoutWindowService)===null||t===void 0)&&t.entries.find(m=>m.gridview===r)),c=this.groups.filter(m=>r.element.contains(m.element)),u=c.includes(i),p=u&&c.length===1,f=[];if(h){for(const m of c)if(m!==i){this.movingLock(()=>{this.doRemoveGroup(m,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),this.redockGroupToMainGrid(m)});for(const g of m.panels)f.push({panel:g,from:m})}}if(u&&n&&this.getPanel(s.id)){const m=[...i.panels];this.movingLock(()=>sr({from:i,to:s}));for(const g of m)f.push({panel:g,from:i});s.api.isVisible||s.api.setVisible(!0),this.getPanel(i.id)&&this.doRemoveGroup(i,{skipPopoutAssociated:!0})}else if(u&&this.getPanel(i.id)){if(i.model.renderContainer=this.overlayRenderContainer,i.model.dropTargetContainer=this.rootDropTargetContainer,l.returnedGroup=i,!h){a();return}if(o&&p)this.addFloatingGroup(i,{height:o.height,width:o.width,position:o});else{this.doRemoveGroup(i,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),i.model.location={type:"grid"},this.movingLock(()=>{this.doAddGroup(i,[0])});for(const m of i.panels)f.push({panel:m,from:i})}this.doSetGroupAndPanelActive(i)}a();for(const{panel:m,from:g}of f)this.fireDidMovePanel(m,g)}addFloatingGroup(e,t){this.mutation("float",()=>this._doAddFloatingGroup(e,t))}_doAddFloatingGroup(e,t){if(!ct(this._floatingGroupService,"FloatingGroup","api.addFloatingGroup")||e instanceof er&&e.model.location.type==="edge")return;let i,s=[];if(e instanceof qi){const l=e.group;i=this.createGroup(),this._onDidAddGroup.fire(i),this.movingLock(()=>this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0,skipSetActiveGroup:!0})),this.movingLock(()=>i.model.openPanel(e,{skipSetGroupActive:!0})),s=[{panel:e,from:l}]}else{var r;i=e;const l=(r=this._popoutWindowService)===null||r===void 0?void 0:r.findReferenceGroupId(i),h=l?this.getPanel(l):void 0;typeof t?.skipRemoveGroup=="boolean"&&t.skipRemoveGroup||(h?(this.movingLock(()=>sr({from:e,to:h})),this.doRemoveGroup(e,{skipPopoutReturn:!0,skipPopoutAssociated:!0}),this.doRemoveGroup(h,{skipDispose:!0}),i=h,s=i.panels.map(c=>({panel:c,from:e}))):(this.doRemoveGroup(e,{skipDispose:!0,skipPopoutReturn:!0,skipPopoutAssociated:!1}),s=i.panels.map(c=>({panel:c,from:i}))))}function n(){if(t?.position){const l={};return"left"in t.position?l.left=Math.max(t.position.left,0):"right"in t.position?l.right=Math.max(t.position.right,0):l.left=ai.left,"top"in t.position?l.top=Math.max(t.position.top,0):"bottom"in t.position?l.bottom=Math.max(t.position.bottom,0):l.top=ai.top,typeof t.width=="number"?l.width=Math.max(t.width,0):l.width=ai.width,typeof t.height=="number"?l.height=Math.max(t.height,0):l.height=ai.height,l}return{left:typeof t?.x=="number"?Math.max(t.x,0):ai.left,top:typeof t?.y=="number"?Math.max(t.y,0):ai.top,width:typeof t?.width=="number"?Math.max(t.width,0):ai.width,height:typeof t?.height=="number"?Math.max(t.height,0):ai.height}}const o=n(),a=this.createNestedGridview();a.addView(i,nt.Distribute,[0]),this.mountFloatingWindow(a,i,[i],o,{dragHandle:t?.dragHandle,inDragMode:t?.inDragMode,skipActiveGroup:t?.skipActiveGroup,disableSmartGuides:t?.disableSmartGuides});for(const{panel:l,from:h}of s)this.fireDidMovePanel(l,h)}createNestedGridview(e="HORIZONTAL"){var t,i;return new Hc(!0,this.options.hideBorders?{separatorBorder:"transparent"}:void 0,e,!1,(t=(i=this.options.theme)===null||i===void 0?void 0:i.gap)!==null&&t!==void 0?t:0)}mountFloatingWindow(e,t,i,s,r){var n,o,a,l,h,c,u,p,f;const m=ct(this._floatingGroupService,"FloatingGroup","api.addFloatingGroup");if(!m)return;const g=((n=(o=r?.dragHandle)!==null&&o!==void 0?o:this.options.floatingGroupDragHandle)!==null&&n!==void 0?n:"titlebar")==="titlebar"?new $b(this,t):void 0,_=new Ba(re(re({container:(a=this._floatingOverlayHost)!==null&&a!==void 0?a:this.gridview.element,content:e.element,header:g?.element},s),{},{minimumInViewportWidth:this.options.floatingGroupBounds==="boundedWithinViewport"?void 0:(l=(h=this.options.floatingGroupBounds)===null||h===void 0?void 0:h.minimumWidthWithinViewport)!==null&&l!==void 0?l:100,minimumInViewportHeight:this.options.floatingGroupBounds==="boundedWithinViewport"?void 0:(c=(u=this.options.floatingGroupBounds)===null||u===void 0?void 0:u.minimumHeightWithinViewport)!==null&&c!==void 0?c:100,transformDragPosition:this._buildFloatingDragTransform(t,(p=r?.disableSmartGuides)!==null&&p!==void 0?p:!1),getSiblingBoxes:()=>this._gatherFloatingGroupBoxes(t)})),E=(f=g?.element)!==null&&f!==void 0?f:t.element.querySelector(".dv-void-container");if(!E)throw new Error("dockview: failed to find drag handle");_.setupDrag(E,{inDragMode:typeof r?.inDragMode=="boolean"?r.inDragMode:!1});const C=m.add(t,_,e);C.addDisposables(_.onDidStartMoving(()=>this._onDidStartFloatingGroupDrag.fire(t)),_.onDidChangeEnd(()=>this._onDidEndFloatingGroupDrag.fire(t))),g&&(C.setTitleBar(g),C.addDisposables(g,Se.from(()=>C.setTitleBar(void 0)),g.onDragStart(T=>{this._onWillDragGroup.fire({nativeEvent:T,group:C.group})})));for(const T of i)T.model.location={type:"floating"};r?.skipActiveGroup||this.doSetGroupAndPanelActive(t)}orthogonalize(e,t){switch(this.gridview.normalize(),e){case"top":case"bottom":this.gridview.orientation==="HORIZONTAL"&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case"left":case"right":this.gridview.orientation==="VERTICAL"&&this.gridview.insertOrthogonalSplitviewAtRoot();break}switch(e){case"top":case"left":case"center":return this.createGroupAtLocation([0],void 0,t);case"bottom":case"right":return this.createGroupAtLocation([this.gridview.length],void 0,t);default:throw new Error(`dockview: unsupported position ${e}`)}}updateOptions(e){var t,i;super.updateOptions(e),this.reportMissingOptionModules(e),(t=this._floatingGroupService)===null||t===void 0||t.updateBounds(e),(i=this._rootDropTargetService)===null||i===void 0||i.setOptions(e);const s=this.options.disableDnd,r=this.options.dndStrategy;this._options=re(re({},this.options),e);const n=this.options.disableDnd,o=this.options.dndStrategy;if((s!==n||r!==o)&&this.updateDragAndDropState(),"theme"in e&&this.updateTheme(),"createRightHeaderActionComponent"in e||"createLeftHeaderActionComponent"in e||"createPrefixHeaderActionComponent"in e){var a;(a=this.headerActionsService)===null||a===void 0||a.refreshAll()}if("createWatermarkComponent"in e){var l;(l=this._watermarkService)===null||l===void 0||l.refresh();for(const c of this.groups)c.model.refreshWatermark()}if("tabGroupColors"in e||"tabGroupAccent"in e){var h;this._tabGroupColorPalette.setEntries((h=this._options.tabGroupColors)!==null&&h!==void 0?h:Na),this._tabGroupColorPalette.enabled=this._options.tabGroupAccent!=="off";for(const c of this.groups)c.model.refreshTabGroupAccent()}this._onDidOptionsChange.fire(),this._layoutFromShell(this.gridview.width,this.gridview.height)}reportMissingOptionModules(e){Kb(e,t=>this._moduleRegistry.has(t))}layout(e,t,i){var s;this._shellManager&&!this._inShellLayout?this._shellManager.layout(e,t):super.layout(e,t,i),this._syncFloatingOverlayHost(),(s=this._moduleRegistry)===null||s===void 0||(s=s.services.floatingGroupService)===null||s===void 0||s.constrainBounds()}_syncFloatingOverlayHost(){if(!this._floatingOverlayHost||!this._shellManager)return;const e=this._shellManager.element.getBoundingClientRect(),t=this.element.getBoundingClientRect(),i=this._floatingOverlayHost;i.style.left=`${t.left-e.left}px`,i.style.top=`${t.top-e.top}px`,i.style.width=`${t.width}px`,i.style.height=`${t.height}px`}_layoutFromShell(e,t){this._inShellLayout=!0,this.layout(e,t,!0),this._inShellLayout=!1}forceRelayout(){this._shellManager?this._layoutFromShell(this.width,this.height):super.forceRelayout()}addEdgeGroup(e,t){const i=this._edgeGroupService;if(!i)throw new Error(vu("EdgeGroup","api.addEdgeGroup"));if(i.has(e))throw new Error(`dockview: edge group already exists at position '${e}'`);return this.mutation("add",()=>{const s=this.createGroup({id:t.id});s.model.location={type:"edge",position:e},s.model.headerPosition=e;const r=s.model.onDidRemovePanel(()=>{s.model.isEmpty&&(i.isAutoReveal(s)?queueMicrotask(()=>{var n;s.model.isEmpty&&(!((n=this._edgeGroupService)===null||n===void 0)&&n.includes(s))&&this.removeEdgeGroup(e)}):this.setEdgeGroupCollapsed(s,!0))});return i.add(e,s,r),t.autoHide!==void 0&&i.setAutoHide(s,t.autoHide),t.autoReveal!==void 0&&i.setAutoReveal(s,t.autoReveal),this._onDidAddGroup.fire(s),this._shellManager.addEdgeView(e,t,s),s.api})}revealEdgeGroupWithData(e,t,i){const s=this._edgeGroupService;s&&this.mutation("add",()=>{var r;let n=s.get(e);n||(this.addEdgeGroup(e,{id:this.getNextGroupId(),autoReveal:!0,autoHide:i?.autoHide,collapsed:!0}),n=s.get(e)),n&&this.moveGroupOrPanel({from:{groupId:t.groupId,panelId:(r=t.panelId)!==null&&r!==void 0?r:void 0},to:{group:n,position:"center"}})})}getEdgeGroup(e){var t;return(t=this._edgeGroupService)===null||t===void 0||(t=t.get(e))===null||t===void 0?void 0:t.api}getEdgeGroupPanel(e){var t;return(t=this._edgeGroupService)===null||t===void 0?void 0:t.get(e)}pinEdgeGroup(e){var t;(t=ct(this._moduleRegistry.services.autoHideEdgeGroupService,"AutoHideEdgeGroup","api.pinEdgeGroup"))===null||t===void 0||t.pin(e)}autoHideEdgeGroup(e){var t;(t=ct(this._moduleRegistry.services.autoHideEdgeGroupService,"AutoHideEdgeGroup","api.autoHideEdgeGroup"))===null||t===void 0||t.autoHide(e)}peekEdgeGroup(e,t){var i;(i=ct(this._moduleRegistry.services.autoHideEdgeGroupService,"AutoHideEdgeGroup","api.peekEdgeGroup"))===null||i===void 0||i.peek(e,t)}get overlayRoot(){return this.rootElement}getDropZoneRect(){return this.element.getBoundingClientRect()}getEdgeGroupExpandedSize(e){var t,i;return(t=(i=this._shellManager)===null||i===void 0?void 0:i.getEdgeGroupExpandedSize(e))!==null&&t!==void 0?t:0}repositionPanelOverlay(e,t,i){this.overlayRenderContainer.repositionPanelOverlay(e.api.id,t,i)}setEdgeGroupVisible(e,t){this._shellManager.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this._shellManager.isEdgeGroupVisible(e)}removeEdgeGroup(e){const t=ct(this._edgeGroupService,"EdgeGroup","api.removeEdgeGroup");if(!t)return;const i=t.get(e);if(!i)throw new Error(`dockview: no edge group exists at position '${e}'`);this.mutation("remove",()=>{for(const s of[...i.panels])this.removePanel(s,{removeEmptyGroup:!1,skipDispose:!1});this._shellManager.removeEdgeView(e),t.remove(e),i.dispose(),this._groups.delete(i.id),this._onDidRemoveGroup.fire(i)})}setEdgeGroupCollapsed(e,t){var i;const s=(i=this._edgeGroupService)===null||i===void 0?void 0:i.findPositionOf(e);s&&this._shellManager.isEdgeGroupCollapsed(s)!==t&&(this._shellManager.setEdgeGroupCollapsed(s,t),e.api._onDidCollapsedChange.fire({isCollapsed:t}))}isEdgeGroupCollapsed(e){var t;const i=(t=this._edgeGroupService)===null||t===void 0?void 0:t.findPositionOf(e);return i?this._shellManager.isEdgeGroupCollapsed(i):!1}isEdgeGroupPeeking(e){return this._peekingGroups.has(e)}setEdgeGroupPeeking(e,t){this._peekingGroups.has(e)!==t&&(t?this._peekingGroups.add(e):this._peekingGroups.delete(e),e.api._onDidPeekChange.fire({isPeeking:t}))}isEdgeGroupAutoHide(e){var t,i;const s=(t=this._edgeGroupService)===null||t===void 0?void 0:t.isAutoHide(e);if(s!==void 0)return s;const r=(i=this._edgeGroupService)===null||i===void 0?void 0:i.findPositionOf(e);return r===void 0?!1:mb(this.options.autoHideEdgeGroups,r)}setEdgeGroupAutoHide(e,t){const i=this._edgeGroupService;i?.includes(e)&&(i.setAutoHide(e,t),this._onDidEdgeGroupAutoHideChange.fire(e))}updateDragAndDropState(){for(const e of this.groups)e.model.updateDragAndDropState()}focus(){var e;(e=this.activeGroup)===null||e===void 0||e.focus()}getGroupPanel(e){return this.panels.find(t=>t.id===e)}setActivePanel(e){e.group.model.openPanel(e),this.doSetGroupAndPanelActive(e.group)}activateNext(e={}){var t;if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[e.group.panels.length-1]){e.group.model.moveToNext({suppressRoll:!0});return}const i=Ce(e.group.element),s=(t=this.gridview.next(i))===null||t===void 0?void 0:t.view;this.doSetGroupAndPanelActive(s)}activatePrevious(e={}){var t;if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[0]){e.group.model.moveToPrevious({suppressRoll:!0});return}const i=Ce(e.group.element),s=(t=this.gridview.previous(i))===null||t===void 0?void 0:t.view;s&&this.doSetGroupAndPanelActive(s)}toJSON(){var e,t,i,s,r;const n=this.gridview.serialize(),o=this.panels.reduce((u,p)=>(u[p.id]=p.toJSON(),u),{}),a=(e=(t=this._floatingGroupService)===null||t===void 0?void 0:t.serialize())!==null&&e!==void 0?e:[],l=(i=(s=this._popoutWindowService)===null||s===void 0?void 0:s.serialize())!==null&&i!==void 0?i:[],h={grid:n,panels:o,activeGroup:(r=this.activeGroup)===null||r===void 0?void 0:r.id};a.length>0&&(h.floatingGroups=a),l.length>0&&(h.popoutGroups=l);const c=this._serializeEdgeGroups();return c&&(h.edgeGroups=c),h}_serializeEdgeGroups(){var e;if(!(!((e=this._edgeGroupService)===null||e===void 0)&&e.hasAny()))return;const t=this._shellManager.toJSON();for(const[i,s]of this._edgeGroupService.entries()){const r=t[i];if(!r)continue;if(this._edgeGroupService.isAutoReveal(s)&&s.model.isEmpty){delete t[i];continue}r.group=s.toJSON(),this._edgeGroupService.isAutoReveal(s)&&(r.autoReveal=!0);const n=this._edgeGroupService.isAutoHide(s);n!==void 0&&(r.autoHide=n)}return t}fromJSON(e,t){this.mutation("load",()=>this._doFromJSON(e,t))}_doFromJSON(e,t){var i,s;if((i=this._popoutWindowService)===null||i===void 0||i.cancelPendingRestorations(),typeof e!="object"||e===null)throw new Error("dockview: serialized layout must be a non-null object");if(!e.grid||((s=e.grid.root)===null||s===void 0?void 0:s.type)!=="branch"||!Array.isArray(e.grid.root.data))throw new Error("dockview: root must be of type branch");const r=new Map,n=new Map,o=[],a=[],l=()=>{for(const T of a)try{T.dispose()}catch(x){console.error("dockview: failed to dispose a temporary group created for reuseExistingPanels",x)}a.length=0};if(t?.reuseExistingPanels){const T=Object.keys(e.panels);let x;const A=()=>{const k=this.createGroup(),N=this._groups.get(k.api.id);return this._groups.delete(k.api.id),a.push(Se.from(()=>{this.movingLock(()=>{for(const O of k.panels.slice())k.model.removePanel(O)}),N?.disposable.dispose(),k.dispose()})),k};try{for(const k of this.panels)if(T.includes(k.api.id)){r.set(k.api.id,k);let N;if(k.api.renderer==="always"&&k.api.isVisible)N=A();else{var h;(h=x)!==null&&h!==void 0||(x=A()),N=x}n.set(k.api.id,N),o.push({panel:k,temporaryGroup:N})}this.movingLock(()=>{o.forEach(({panel:k,temporaryGroup:N})=>{this.moveGroupOrPanel({from:{groupId:k.api.group.api.id,panelId:k.api.id},to:{group:N,position:"center"},keepEmptyGroups:!0})})}),this.clear()}catch(k){throw l(),k}}else this.clear();const{grid:c,panels:u,activeGroup:p}=e;try{var f,m,g,_,E;const T=this.width,x=this.height,A=N=>{const{id:O,locked:z,hideHeader:R,headerPosition:I,views:w,activeView:v}=N;if(typeof O!="string")throw new TypeError("dockview: group id must be of type string");const S=this.createGroup({id:O,locked:!!z,hideHeader:!!R,headerPosition:I});this._onDidAddGroup.fire(S);const D=[],y=w.filter(L=>u[L]);for(const L of y){const M=r.get(L),H=n.get(L);if(H&&M)this.movingLock(()=>{H.model.removePanel(M)}),D.push(M),M.updateFromStateModel(u[L]);else{const j=this._deserializer.fromJSON(u[L],S);D.push(j)}}for(const L of D){const M=typeof v=="string"&&v===L.id;r.has(L.api.id)?this.movingLock(()=>{S.model.openPanel(L,{skipSetActive:!M,skipSetGroupActive:!0})}):S.model.openPanel(L,{skipSetActive:!M,skipSetGroupActive:!0})}return N.tabGroups&&N.tabGroups.length>0&&S.model.restoreTabGroups(N.tabGroups),!S.activePanel&&S.panels.length>0&&S.model.openPanel(S.panels[S.panels.length-1],{skipSetGroupActive:!0}),S};this.gridview.deserialize(c,{fromJSON:N=>A(N.data)}),this._layoutFromShell(T,x),e.edgeGroups&&this.deserializeEdgeGroups(e.edgeGroups,u,r,n),this.deserializeFloatingWindows((f=e.floatingGroups)!==null&&f!==void 0?f:[],A);const k=this.deserializePopoutWindows((m=e.popoutGroups)!==null&&m!==void 0?m:[],A);if((g=this._popoutWindowService)===null||g===void 0||g.finishRestoration(k),(_=this._floatingGroupService)===null||_===void 0||_.constrainBounds(),typeof p=="string"){const N=this.getPanel(p);N&&this.doSetGroupAndPanelActive(N)}(E=this._watermarkService)===null||E===void 0||E.update()}catch(T){var C;console.error("dockview: failed to deserialize layout. Reverting changes",T);for(const x of this.groups)for(const A of x.panels)this.removePanel(A,{removeEmptyGroup:!1,skipDispose:!1});for(const x of this.groups)x.dispose(),this._groups.delete(x.id),this._onDidRemoveGroup.fire(x);throw(C=this._floatingGroupService)===null||C===void 0||C.disposeAll(),this.clear(),T}finally{l()}this.debouncedUpdateAllPositions(),this._onDidLayoutFromJSON.fire()}deserializeNestedGridview(e,t){const i=this.createNestedGridview(e.orientation),s=[];return i.deserialize(e,{fromJSON:r=>{const n=t(r.data);return s.push(n),n}}),{gridview:i,members:s}}deserializeEdgeGroups(e,t,i,s){const r=ct(this._edgeGroupService,"EdgeGroup","fromJSON edge restoration");if(r){for(const o of["top","bottom","left","right"]){const a=e[o];if(a&&!r.has(o)){var n;const l=a.group,h=(n=l?.id)!==null&&n!==void 0?n:`${o}-group`;this.addEdgeGroup(o,{id:h,autoReveal:a.autoReveal,autoHide:a.autoHide,minimumSize:a.minimumSize,maximumSize:a.maximumSize,collapsedSize:a.collapsedSize})}}for(const[o,a]of r.entries()){const l=e[o],h=l?.group;if(h){const{views:c,activeView:u}=h,p=[];for(const f of c){if(!t[f])continue;const m=i.get(f),g=s.get(f);if(g&&m)this.movingLock(()=>{g.model.removePanel(m)}),p.push(m),m.updateFromStateModel(t[f]);else{const _=this._deserializer.fromJSON(t[f],a);p.push(_)}}for(const f of p){const m=u===f.id;i.has(f.api.id)?this.movingLock(()=>{a.model.openPanel(f,{skipSetActive:!m,skipSetGroupActive:!0})}):a.model.openPanel(f,{skipSetActive:!m,skipSetGroupActive:!0})}h.tabGroups&&h.tabGroups.length>0&&a.model.restoreTabGroups(h.tabGroups),!a.activePanel&&a.panels.length>0&&a.model.openPanel(a.panels[a.panels.length-1],{skipSetGroupActive:!0})}}this._shellManager.fromJSON(e)}}deserializeFloatingWindows(e,t){for(const i of e){const{data:s,grid:r,position:n}=i;if(r){const{gridview:o,members:a}=this.deserializeNestedGridview(r,t);if(a.length===0)continue;this.mountFloatingWindow(o,a[0],a,n,{inDragMode:!1})}else if(s){const o=t(s);this.addFloatingGroup(o,{position:n,width:n.width,height:n.height,skipRemoveGroup:!0,inDragMode:!1})}}}deserializePopoutWindows(e,t){const i=e.length>0?ct(this._popoutWindowService,"PopoutWindow","fromJSON popout restoration"):this._popoutWindowService;return i?e.flatMap((s,r)=>{const{data:n,grid:o,position:a,gridReferenceGroup:l,url:h}=s;let c,u=[];if(o){const f=this.deserializeNestedGridview(o,t);if(c=f.gridview,u=f.members,u.length===0)return c.dispose(),[]}const p=o?u[0]:t(n);return i.scheduleRestoration(r*100,()=>{this.addPopoutGroup(p,{position:a??void 0,overridePopoutGroup:l?p:void 0,overridePopoutGridview:c,referenceGroup:l?this.getPanel(l):void 0,popoutUrl:h})},()=>{for(const f of u.length>0?u:[p])if(!this.isDisposed&&this._groups.has(f.id)&&f.element.parentElement===null){for(const m of[...f.panels])this.removePanel(m,{removeEmptyGroup:!1});f.dispose(),this._groups.delete(f.id),this._onDidRemoveGroup.fire(f)}})}):[]}clear(){this.mutation("clear",()=>this._doClear())}_doClear(){const e=Array.from(this._groups.values()).map(s=>s.value),t=!!this.activeGroup;for(const s of e){var i;if(!((i=this._edgeGroupService)===null||i===void 0)&&i.includes(s)){const r=[...s.panels];for(const n of r)this.removePanel(n,{removeEmptyGroup:!1});continue}this.removeGroup(s,{skipActive:!0})}t&&this.doSetGroupAndPanelActive(void 0),this.gridview.clear()}closeAllGroups(){this.mutation("remove",()=>{for(const e of this._groups.entries()){const[t,i]=e;i.value.model.closeAllPanels()}})}addPanel(e){return this.mutation("add",()=>this._doAddPanel(e))}_doAddPanel(e){if(this.panels.some(c=>c.id===e.id))throw new Error(`dockview: panel with id ${e.id} already exists`);let t;if(e.position&&e.floating)throw new Error("dockview: you can only provide one of: position, floating as arguments to .addPanel(...)");const i={width:e.initialWidth,height:e.initialHeight};let s;const r=c=>!!e.inactive&&c.model.size>0;if(e.position)if(gb(e.position)){const c=typeof e.position.referencePanel=="string"?this.getGroupPanel(e.position.referencePanel):e.position.referencePanel;if(s=e.position.index,!c){var n;const u=typeof e.position.referencePanel=="string"?e.position.referencePanel:(n=e.position.referencePanel)===null||n===void 0?void 0:n.id;throw new Error(`dockview: referencePanel '${u}' does not exist`)}t=this.findGroup(c)}else if(vb(e.position)){var o;if(t=typeof e.position.referenceGroup=="string"?(o=this._groups.get(e.position.referenceGroup))===null||o===void 0?void 0:o.value:e.position.referenceGroup,s=e.position.index,!t){var a;const c=typeof e.position.referenceGroup=="string"?e.position.referenceGroup:(a=e.position.referenceGroup)===null||a===void 0?void 0:a.id;throw new Error(`dockview: referenceGroup '${c}' does not exist`)}}else{const c=this.orthogonalize(Ul(e.position.direction)),u=this.createPanel(e,c);return c.model.openPanel(u,{skipSetActive:r(c),skipSetGroupActive:e.inactive,index:s}),e.inactive||this.doSetGroupAndPanelActive(c),c.api.setSize({height:i?.height,width:i?.width}),u}else t=this.activeGroup;let l;if(t){var h;const c=Pr(((h=e.position)===null||h===void 0?void 0:h.direction)||"within");if(e.floating){const u=this.createGroup();this._onDidAddGroup.fire(u);const p=typeof e.floating=="object"&&e.floating!==null?e.floating:{};this.addFloatingGroup(u,re(re({},p),{},{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),l=this.createPanel(e,u),u.model.openPanel(l,{skipSetActive:r(u),skipSetGroupActive:e.inactive,index:s})}else if(t.api.location.type==="floating"||t.api.location.type==="edge"||c==="center")l=this.createPanel(e,t),t.model.openPanel(l,{skipSetActive:r(t),skipSetGroupActive:e.inactive,index:s}),t.api.setSize({width:i?.width,height:i?.height}),e.inactive||this.doSetGroupAndPanelActive(t);else{const u=Ce(t.element),p=wt(this.gridview.orientation,u,c),f=this.createGroupAtLocation(p,this.orientationAtLocation(p)==="VERTICAL"?i?.height:i?.width);l=this.createPanel(e,f),f.model.openPanel(l,{skipSetActive:r(f),skipSetGroupActive:e.inactive,index:s}),e.inactive||this.doSetGroupAndPanelActive(f)}}else if(e.floating){const c=this.createGroup();this._onDidAddGroup.fire(c);const u=typeof e.floating=="object"&&e.floating!==null?e.floating:{};this.addFloatingGroup(c,re(re({},u),{},{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),l=this.createPanel(e,c),c.model.openPanel(l,{skipSetActive:r(c),skipSetGroupActive:e.inactive,index:s})}else{const c=this.createGroupAtLocation([0],this.gridview.orientation==="VERTICAL"?i?.height:i?.width);l=this.createPanel(e,c),c.model.openPanel(l,{skipSetActive:r(c),skipSetGroupActive:e.inactive,index:s}),e.inactive||this.doSetGroupAndPanelActive(c)}return l}removePanel(e,t){this.mutation("remove",()=>{var i;return this._doRemovePanel(e,{removeEmptyGroup:(i=t?.removeEmptyGroup)!==null&&i!==void 0?i:!0,skipDispose:t?.skipDispose,skipSetActiveGroup:t?.skipSetActiveGroup})})}_doRemovePanel(e,t){const i=e.group;if(!i)throw new Error(`dockview: cannot remove panel ${e.id}. it's missing a group.`);i.model.removePanel(e,{skipSetActiveGroup:t.skipSetActiveGroup}),t.skipDispose||(e.group.model.renderContainer.detatch(e),e.dispose()),i.size===0&&t.removeEmptyGroup&&this.removeGroup(i,{skipActive:t.skipSetActiveGroup})}createWatermarkComponent(){return this.options.createWatermarkComponent?this.options.createWatermarkComponent():new Bb}addGroup(e){return this.mutation("add",()=>this._doAddGroup(e))}_doAddGroup(e){if(e){let r;if(_b(e)){var t;const c=typeof e.referencePanel=="string"?this.panels.find(p=>p.id===e.referencePanel):e.referencePanel,u=typeof e.referencePanel=="string"?e.referencePanel:(t=e.referencePanel)===null||t===void 0?void 0:t.id;if(!c)throw new Error(`dockview: reference panel ${u} does not exist`);if(r=this.findGroup(c),!r)throw new Error(`dockview: reference group for reference panel ${u} does not exist`)}else if(bb(e)){var i;if(r=typeof e.referenceGroup=="string"?(i=this._groups.get(e.referenceGroup))===null||i===void 0?void 0:i.value:e.referenceGroup,!r){var s;const c=typeof e.referenceGroup=="string"?e.referenceGroup:(s=e.referenceGroup)===null||s===void 0?void 0:s.id;throw new Error(`dockview: reference group ${c} does not exist`)}}else{const c=this.orthogonalize(Ul(e.direction),e);return e.skipSetActive||this.doSetGroupAndPanelActive(c),c}const n=Pr(e.direction||"within"),o=Ce(r.element),a=wt(this.gridview.orientation,o,n),l=this.createGroup(e),h=this.getLocationOrientation(a)==="VERTICAL"?e.initialHeight:e.initialWidth;return this.doAddGroup(l,a,h),e.skipSetActive||this.doSetGroupAndPanelActive(l),l}else{const r=this.createGroup(e);return this.doAddGroup(r),this.doSetGroupAndPanelActive(r),r}}getLocationOrientation(e){return e.length%2==0&&this.gridview.orientation==="HORIZONTAL"?"HORIZONTAL":"VERTICAL"}removeGroup(e,t){this.mutation("remove",()=>this.doRemoveGroup(e,t))}detachFromNestedWindow(e){var t,i;const s=(t=this._floatingGroupService)===null||t===void 0?void 0:t.findByGroup(e);if(s){const n=this.nestedWindowMembers(e);return n.length<=1?!1:(s.gridview.remove(e),s.group===e&&s.setAnchorGroup(n.find(o=>o!==e)),!0)}const r=(i=this._popoutWindowService)===null||i===void 0?void 0:i.findByGroup(e);if(r){const n=this.nestedWindowMembers(e);return n.length<=1?!1:(r.gridview.remove(e),r.popoutGroup===e&&r.setAnchorGroup(n.find(o=>o!==e)),!0)}return!1}disposeGroupRecord(e){e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}activateFallbackGroupIfRemoved(e,t){if(!t&&this._activeGroup===e){const i=Array.from(this._groups.values());this.doSetGroupAndPanelActive(i.length>0?i[0].value:void 0)}}doRemoveGroup(e,t){var i;if(!((i=this._edgeGroupService)===null||i===void 0)&&i.includes(e))return e;const s=[...e.panels];if(!t?.skipDispose)for(const c of s){var r;this.removePanel(c,{removeEmptyGroup:!1,skipDispose:(r=t?.skipDispose)!==null&&r!==void 0?r:!1})}const n=this.activePanel;if(e.api.location.type==="floating"){var o;const c=(o=this._floatingGroupService)===null||o===void 0?void 0:o.findByGroup(e);if(!c)throw new Error("dockview: failed to find floating group");return this.detachFromNestedWindow(e)?(t?.skipDispose?e.model.location={type:"grid"}:this.disposeGroupRecord(e),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e):(t?.skipDispose||this.disposeGroupRecord(e),c.dispose(),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e)}if(e.api.location.type==="popout"){var a,l;const c=(a=this._popoutWindowService)===null||a===void 0?void 0:a.findByGroup(e);if(!c)throw new Error("dockview: failed to find popout group");if(this.detachFromNestedWindow(e))return t?.skipDispose?e.model.location={type:"grid"}:this.disposeGroupRecord(e),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e;if(!t?.skipDispose){if(!t?.skipPopoutAssociated){const p=c.referenceGroup?this.getPanel(c.referenceGroup):void 0;p?.panels.length===0&&this.removeGroup(p)}c.popoutGroup.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}(l=this._popoutWindowService)===null||l===void 0||l.remove(c);const u=c.disposable.dispose();return!t?.skipPopoutReturn&&u&&(this.doAddGroup(u,[0]),this.doSetGroupAndPanelActive(u)),this.activateFallbackGroupIfRemoved(e,t?.skipActive),c.popoutGroup}if(!this.gridview.element.contains(e.element)){if(!t?.skipDispose){const c=this._groups.get(e.id);c?.disposable.dispose(),this.disposeGroupRecord(e)}return this.activateFallbackGroupIfRemoved(e,t?.skipActive),e}const h=super.doRemoveGroup(e,t);return t?.skipActive||this.activePanel!==n&&this.fireActivePanelChange(this.activePanel),h}debouncedUpdateAllPositions(){this._updatePositionsFrameId!==void 0&&cancelAnimationFrame(this._updatePositionsFrameId),this._updatePositionsFrameId=requestAnimationFrame(()=>{var e,t;this._updatePositionsFrameId=void 0,this.overlayRenderContainer.updateAllPositions();for(const i of(e=(t=this._popoutWindowService)===null||t===void 0?void 0:t.entries)!==null&&e!==void 0?e:[])i.overlayRenderContainer.updateAllPositions()})}movingLock(e){const t=this._moving;try{return this._moving=!0,e()}finally{this._moving=t}}mutation(e,t){const i=this.openMutation(e);try{return t()}finally{i()}}mutationAsync(e,t){var i=this;return bu(function*(){const s=i.openMutation(e);try{return yield t()}finally{s()}})()}openMutation(e){const t=this._origin;return this._mutationDepth===0&&this._onWillMutateLayout.fire({kind:e,origin:t}),this._mutationDepth++,()=>{this._mutationDepth--,this._mutationDepth===0&&(this.flushLocationChanges(),this._onDidMutateLayout.fire({kind:e,origin:t}))}}deferLocationChange(e,t){if(this._mutationDepth===0){t();return}this._pendingLocationChanges.set(e,t)}flushLocationChanges(){if(this._pendingLocationChanges.size===0)return;const e=Array.from(this._pendingLocationChanges.values());this._pendingLocationChanges.clear();for(const t of e)t()}currentOrigin(){return this._origin}withOrigin(e,t){if(this._originDepth>0||this._mutationDepth>0)return t();const i=this._origin;this._origin=e,this._originDepth++;try{return t()}finally{this._originDepth--,this._origin=i}}fireActivePanelChange(e){this._onDidActivePanelChange.fire({panel:e,origin:this._origin})}fireDidMovePanel(e,t){this._onDidMovePanel.fire({panel:e,from:t,to:e.group})}moveGroupOrPanel(e){this.mutation("move",()=>this._doMoveGroupOrPanel(e))}_doMoveGroupOrPanel(e){var t;const i=e.to.group,s=e.from.groupId,r=e.from.panelId,n=e.to.position,o=e.to.index,a=s?(t=this._groups.get(s))===null||t===void 0?void 0:t.value:void 0;if(!a)throw new Error(`dockview: Failed to find group id ${s}`);if(r===void 0){e.from.tabGroupId?this.moveTabGroupToGroup({sourceGroup:a,tabGroupId:e.from.tabGroupId,destinationGroup:i,destinationTarget:n,destinationIndex:o,skipSetActive:e.skipSetActive,keepEmptyGroups:e.keepEmptyGroups}):this.moveGroup({from:{group:a},to:{group:i,position:n},skipSetActive:e.skipSetActive});return}if(!n||n==="center"){const h=this.movingLock(()=>a.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!h)throw new Error(`dockview: No panel with id ${r}`);!e.keepEmptyGroups&&a.model.size===0&&this.doRemoveGroup(a,{skipActive:!0});const c=i.model.size===0;this.movingLock(()=>{var u;return i.model.openPanel(h,{index:o,skipSetActive:((u=e.skipSetActive)!==null&&u!==void 0?u:!1)&&!c,skipSetGroupActive:!0})}),e.skipSetActive||this.doSetGroupAndPanelActive(i),this.fireDidMovePanel(h,a)}else{const h=this.getGridviewForGroup(i),c=Ce(i.element),u=wt(h.orientation,c,n);if(a.size<2){const[p,f]=Zt(u);if(a.api.location.type==="grid"&&h===this.gridview){const[E,C]=Zt(Ce(a.element));if(jc(E,p)){this.gridview.moveView(E,C,f),this.fireDidMovePanel(this.getGroupPanel(r),a);return}}if(a.api.location.type==="popout"&&this.nestedWindowMembers(a).length<=1){var l;const E=(l=this._popoutWindowService)===null||l===void 0?void 0:l.findByGroup(a);if(!E)return;const C=this.movingLock(()=>E.popoutGroup.model.removePanel(E.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(a,{skipActive:!0});const T=wt(h.orientation,Ce(i.element),n),x=this.createGroupAtLocation(T,void 0,void 0,h);this.movingLock(()=>x.model.openPanel(C,{skipSetActive:!0})),this.doSetGroupAndPanelActive(x),this.fireDidMovePanel(this.getGroupPanel(r),a);return}if(a.api.location.type==="edge"){const E=this.movingLock(()=>a.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!E)throw new Error(`dockview: No panel with id ${r}`);const C=this.createGroupAtLocation(u,void 0,void 0,h);this.movingLock(()=>C.model.openPanel(E,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(C),this.fireDidMovePanel(E,a);return}const m=this.movingLock(()=>this.doRemoveGroup(a,{skipActive:!0,skipDispose:!0})),g=Ce(i.element),_=wt(h.orientation,g,n);this.movingLock(()=>this.doAddGroup(m,_,void 0,h)),this.setGroupLocationForRoot(m,h),this.doSetGroupAndPanelActive(m),this.fireDidMovePanel(this.getGroupPanel(r),a)}else{const p=this.movingLock(()=>a.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!p)throw new Error(`dockview: No panel with id ${r}`);const f=wt(h.orientation,c,n),m=this.createGroupAtLocation(f,void 0,void 0,h);this.movingLock(()=>m.model.openPanel(p,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(m),this.fireDidMovePanel(p,a)}}}moveTabGroupToGroup(e){const{sourceGroup:t,tabGroupId:i,destinationGroup:s,destinationTarget:r,destinationIndex:n}=e,o=t.model.getTabGroups().find(_=>_.id===i);if(!o||o.panelIds.length===0)return;const a=o.label,l=o.color,h=o.collapsed,c=o.componentParams,u=[...o.panelIds],p=r&&r!=="center"?Ce(s.element):void 0,f=this.movingLock(()=>u.map(_=>t.model.removePanel(_,{skipSetActive:!1,skipSetActiveGroup:!0})).filter(_=>_!==void 0));if(f.length===0)return;const m=_=>{this.movingLock(()=>{for(const C of f)_.model.openPanel(C,{index:n,skipSetActive:!0,skipSetGroupActive:!0})});const E=_.model.createTabGroup({label:a,color:l,collapsed:h,componentParams:c});for(const C of f)_.model.addPanelToTabGroup(E.id,C.id);e.skipSetActive||this.doSetGroupAndPanelActive(_);for(const C of f)this.fireDidMovePanel(C,t)};let g;if(!r||r==="center"||!p)g=s;else{const _=wt(this.gridview.orientation,p,r);g=this.createGroupAtLocation(_)}!e.keepEmptyGroups&&t.model.size===0&&t!==g&&this.doRemoveGroup(t,{skipActive:!0}),m(g)}moveGroup(e){this.mutation("move",()=>this._doMoveGroup(e))}maximizeGroup(e){this.mutation("maximize",()=>super.maximizeGroup(e))}exitMaximizedGroup(){this.mutation("maximize",()=>super.exitMaximizedGroup())}_doMoveGroup(e){var t;const i=e.from.group,s=e.to.group,r=e.to.position;let n=i,o;if(r==="center"){const c=i.activePanel,u=i.model.getTabGroups().map(f=>({label:f.label,color:f.color,collapsed:f.collapsed,componentParams:f.componentParams,panelIds:[...f.panelIds]})),p=this.movingLock(()=>[...i.panels].map(f=>i.model.removePanel(f.id,{skipSetActive:!0})));i?.model.size===0&&this.doRemoveGroup(i,{skipActive:!0}),this.movingLock(()=>{for(const f of p)s.model.openPanel(f,{skipSetActive:f!==c,skipSetGroupActive:!0})}),o=p;for(const f of u){const m=s.model.createTabGroup({label:f.label,color:f.color,collapsed:f.collapsed,componentParams:f.componentParams});for(const g of f.panelIds)s.model.addPanelToTabGroup(m.id,g)}e.skipSetActive!==!0?this.doSetGroupAndPanelActive(s):this.activePanel||this.doSetGroupAndPanelActive(s)}else{if(i.api.location.type==="edge"){const c=i.activePanel,u=i.model.getTabGroups().map(f=>({label:f.label,color:f.color,collapsed:f.collapsed,componentParams:f.componentParams,panelIds:[...f.panelIds]})),p=this.movingLock(()=>[...i.panels].map(f=>i.model.removePanel(f.id,{skipSetActive:!0})));n=this.createGroup(),this._onDidAddGroup.fire(n),this.movingLock(()=>{for(const f of p)n.model.openPanel(f,{skipSetActive:f!==c,skipSetGroupActive:!0})});for(const f of u){const m=n.model.createTabGroup({label:f.label,color:f.color,collapsed:f.collapsed,componentParams:f.componentParams});for(const g of f.panelIds)n.model.addPanelToTabGroup(m.id,g)}}else switch(i.api.location.type){case"grid":this.gridview.removeView(Ce(i.element));break;case"floating":{var a;const c=(a=this._floatingGroupService)===null||a===void 0?void 0:a.findByGroup(i);if(!c)throw new Error("dockview: failed to find floating group");this.detachFromNestedWindow(i)||c.dispose();break}case"popout":{var l,h;const c=(l=this._popoutWindowService)===null||l===void 0?void 0:l.findByGroup(i);if(!c)throw new Error("dockview: failed to find popout group");if(this.detachFromNestedWindow(i))break;if((h=this._popoutWindowService)===null||h===void 0||h.remove(c),c.referenceGroup){const u=this.getPanel(c.referenceGroup);u&&!u.api.isVisible&&this.doRemoveGroup(u,{skipActive:!0})}c.window.dispose();break}}if(s.api.location.type==="grid"||s.api.location.type==="floating"||s.api.location.type==="popout"){const c=this.getGridviewForGroup(s),u=Ce(s.element),p=wt(c.orientation,u,r);let f;switch(c.orientation){case"VERTICAL":f=u.length%2==0?i.api.width:i.api.height;break;case"HORIZONTAL":f=u.length%2==0?i.api.height:i.api.width;break}c.addView(n,f,p),this.setGroupLocationForRoot(n,c)}}if(((t=o)!==null&&t!==void 0?t:n.panels).forEach(c=>{this.fireDidMovePanel(c,i)}),this.debouncedUpdateAllPositions(),e.skipSetActive===!1){const c=s??i;this.doSetGroupAndPanelActive(c)}else n!==i&&e.skipSetActive!==!0&&this.doSetGroupAndPanelActive(n)}doSetGroupActive(e){var t;super.doSetGroupActive(e);const i=this.activePanel;!this._moving&&i!==((t=this._onDidActivePanelChange.value)===null||t===void 0?void 0:t.panel)&&this.fireActivePanelChange(i)}doSetGroupAndPanelActive(e){var t;super.doSetGroupActive(e);const i=this.activePanel;e&&this.hasMaximizedGroup()&&!this.isMaximizedGroup(e)&&this.exitMaximizedGroup(),!this._moving&&i!==((t=this._onDidActivePanelChange.value)===null||t===void 0?void 0:t.panel)&&this.fireActivePanelChange(i)}getNextGroupId(){let e=this.nextGroupId.next();for(;this._groups.has(e);)e=this.nextGroupId.next();return e}createGroup(e){var t;(t=e)!==null&&t!==void 0||(e={});let i=e?.id;if(i&&this._groups.has(e.id)&&(console.warn(`dockview: Duplicate group id ${e?.id}. reassigning group id to avoid errors`),i=void 0),!i)for(i=this.nextGroupId.next();this._groups.has(i);)i=this.nextGroupId.next();const s=new er(this,i,e);if(s.init({params:{},accessor:this}),!this._groups.has(s.id)){const r=new se(s.model.onTabDragStart(n=>{var o;(o=this._advancedDnDService)===null||o===void 0||o.dispatchWillDragPanel(n)}),s.model.onGroupDragStart(n=>{var o;(o=this._advancedDnDService)===null||o===void 0||o.dispatchWillDragGroup(n)}),s.model.onMove(n=>{const{groupId:o,itemId:a,target:l,index:h,tabGroupId:c}=n;this.moveGroupOrPanel({from:{groupId:o,panelId:a,tabGroupId:c},to:{group:s,position:l,index:h}})}),s.model.onDidDrop(n=>{this._onDidDrop.fire(n)}),s.model.onWillDrop(n=>{var o;(o=this._advancedDnDService)===null||o===void 0||o.dispatchWillDrop(n)}),s.model.onWillShowOverlay(n=>{var o;if(this.options.disableDnd){n.preventDefault();return}(o=this._advancedDnDService)===null||o===void 0||o.dispatchWillShowOverlay(n)}),s.model.onUnhandledDragOver(n=>{this._onUnhandledDragOver.fire(n)}),s.model.onDidAddPanel(n=>{this._moving||this._onDidAddPanel.fire(n.panel)}),s.model.onDidRemovePanel(n=>{this._moving||this._onDidRemovePanel.fire(n.panel)}),s.model.onDidActivePanelChange(n=>{var o;this._moving||n.panel===this.activePanel&&((o=this._onDidActivePanelChange.value)===null||o===void 0?void 0:o.panel)!==n.panel&&this.fireActivePanelChange(n.panel)}),xt.any(s.model.onDidPanelTitleChange,s.model.onDidPanelParametersChange)(()=>{this._bufferOnDidLayoutChange.fire()}));this._groups.set(s.id,{value:s,disposable:r})}return s.initialize(),s}createPanel(e,t){var i,s,r;const n=e.component,o=(i=e.tabComponent)!==null&&i!==void 0?i:this.options.defaultTabComponent,a=new gu(this,e.id,n,o),l=new qi(e.id,n,o,this,this._api,t,a,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return l.init({title:(s=e.title)!==null&&s!==void 0?s:e.id,params:(r=e?.params)!==null&&r!==void 0?r:{}}),l}createGroupAtLocation(e,t,i,s=this.gridview){const r=this.createGroup(i);return this.doAddGroup(r,e,t,s),this.setGroupLocationForRoot(r,s),r}setGroupLocationForRoot(e,t){var i;const s=(i=this._popoutWindowService)===null||i===void 0?void 0:i.entries.find(r=>r.gridview===t);if(s){e.model.renderContainer!==s.overlayRenderContainer&&(e.model.renderContainer=s.overlayRenderContainer),e.model.dropTargetContainer=s.dropTargetContainer,e.model.location={type:"popout",getWindow:s.getWindow,popoutUrl:s.popoutUrl};return}e.model.renderContainer!==this.overlayRenderContainer&&(e.model.renderContainer=this.overlayRenderContainer),e.model.dropTargetContainer=this.rootDropTargetContainer,e.model.location=t===this.gridview?{type:"grid"}:{type:"floating"}}getGridviewForGroup(e){var t,i;const s=(t=this._floatingGroupService)===null||t===void 0?void 0:t.findByGroup(e);if(s)return s.gridview;const r=(i=this._popoutWindowService)===null||i===void 0?void 0:i.findByGroup(e);return r?r.gridview:this.gridview}nestedWindowMembers(e){const t=this.getGridviewForGroup(e);return t===this.gridview?[]:this.groups.filter(i=>t.element.contains(i.element))}findGroup(e){var t;return(t=Array.from(this._groups.values()).find(i=>i.value.model.containsPanel(e)))===null||t===void 0?void 0:t.value}orientationAtLocation(e){const t=this.gridview.orientation;return e.length%2==1?t:zt(t)}updateTheme(){var e,t,i,s,r,n,o,a;const l=(e=this._options.theme)!==null&&e!==void 0?e:Ob;(t=this._shellThemeClassnames)===null||t===void 0||t.setClassNames(l.className);const h=(i=l.gap)!==null&&i!==void 0?i:0;this.gridview.margin=h;for(const f of this.floatingGroups)f.gridview.margin=h;for(const f of(s=(r=this._popoutWindowService)===null||r===void 0?void 0:r.entries)!==null&&s!==void 0?s:[])f.gridview.margin=h;if((n=this._shellManager)===null||n===void 0||n.updateTheme(h,(o=l.edgeGroupCollapsedSize)!==null&&o!==void 0?o:35),l.dndOverlayBorder===void 0){var c;this.element.style.removeProperty("--dv-drag-over-border"),(c=this._shellManager)===null||c===void 0||c.element.style.removeProperty("--dv-drag-over-border")}else{var u;this.element.style.setProperty("--dv-drag-over-border",l.dndOverlayBorder),(u=this._shellManager)===null||u===void 0||u.element.style.setProperty("--dv-drag-over-border",l.dndOverlayBorder)}l.dndOverlayMounting==="absolute"?this.rootDropTargetContainer.disabled=!1:this.rootDropTargetContainer.disabled=!0;const p=((a=l.tabGroupIndicator)!==null&&a!==void 0?a:"wrap")==="none";K(this.element,"dv-tab-group-indicator-none",p),this._shellManager&&K(this._shellManager.element,"dv-tab-group-indicator-none",p);for(const f of this.groups)f.model.updateTabGroups()}},Lw=class extends Fc{get orientation(){return this.gridview.orientation}set orientation(e){this.gridview.orientation=e}get options(){return this._options}get deserializer(){return this._deserializer}set deserializer(e){this._deserializer=e}constructor(e,t){var i;super(e,{proportionalLayout:(i=t.proportionalLayout)!==null&&i!==void 0?i:!0,orientation:t.orientation,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:t.disableAutoResizing,className:t.className}),this._onDidLayoutfromJSON=new G,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidRemoveGroup=new G,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new G,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new G,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._options=t,this.addDisposables(this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this.onDidAdd(s=>{this._onDidAddGroup.fire(s)}),this.onDidRemove(s=>{this._onDidRemoveGroup.fire(s)}),this.onDidActiveChange(s=>{this._onDidActiveGroupChange.fire(s)}))}updateOptions(e){super.updateOptions(e);const t=typeof e.orientation=="string"&&this.gridview.orientation!==e.orientation;this._options=re(re({},this.options),e),t&&(this.gridview.orientation=e.orientation),this.layout(this.gridview.width,this.gridview.height,!0)}removePanel(e){this.removeGroup(e)}toJSON(){var e;return{grid:this.gridview.serialize(),activePanel:(e=this.activeGroup)===null||e===void 0?void 0:e.id}}setVisible(e,t){this.gridview.setViewVisible(Ce(e.element),t)}setActive(e){this._groups.forEach((t,i)=>{t.value.setActive(e===t.value)})}focus(){var e;(e=this.activeGroup)===null||e===void 0||e.focus()}fromJSON(e){this.clear();const{grid:t,activePanel:i}=e;try{const s=[],r=this.width,n=this.height;if(this.gridview.deserialize(t,{fromJSON:o=>{const{data:a}=o,l=this.options.createComponent({id:a.id,name:a.component});return s.push(()=>l.init({params:a.params,minimumWidth:a.minimumWidth,maximumWidth:a.maximumWidth,minimumHeight:a.minimumHeight,maximumHeight:a.maximumHeight,priority:a.priority,snap:!!a.snap,accessor:this,isVisible:o.visible})),this._onDidAddGroup.fire(l),this.registerPanel(l),l}}),this.layout(r,n,!0),s.forEach(o=>o()),typeof i=="string"){const o=this.getPanel(i);o&&this.doSetGroupActive(o)}}catch(s){for(const r of this.groups)r.dispose(),this._groups.delete(r.id),this._onDidRemoveGroup.fire(r);throw this.clear(),s}this._onDidLayoutfromJSON.fire()}clear(){const e=this.activeGroup,t=Array.from(this._groups.values());for(const i of t)i.disposable.dispose(),this.doRemoveGroup(i.value,{skipActive:!0});e&&this.doSetGroupActive(void 0),this.gridview.clear()}movePanel(e,t){var i;const s=(i=this._groups.get(t.reference))===null||i===void 0?void 0:i.value;if(!s)throw new Error(`reference group ${t.reference} does not exist`);const r=Pr(t.direction);if(r==="center")throw new Error(`${r} not supported as an option`);const n=Ce(s.element),o=wt(this.gridview.orientation,n,r),a=this.gridview.remove(e);this.doAddGroup(a,o,t.size)}addPanel(e){var t,i,s;let r=(t=e.location)!==null&&t!==void 0?t:[0];if(!((i=e.position)===null||i===void 0)&&i.referencePanel){var n;const a=(n=this._groups.get(e.position.referencePanel))===null||n===void 0?void 0:n.value;if(!a)throw new Error(`reference group ${e.position.referencePanel} does not exist`);const l=Pr(e.position.direction);if(l==="center")throw new Error(`${l} not supported as an option`);{const h=Ce(a.element);r=wt(this.gridview.orientation,h,l)}}const o=this.options.createComponent({id:e.id,name:e.component});return o.init({params:(s=e.params)!==null&&s!==void 0?s:{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.doAddGroup(o,r,e.size),this.registerPanel(o),this.doSetGroupActive(o),o}registerPanel(e){const t=new se(e.api.onDidFocusChange(i=>{i.isFocused&&this._groups.forEach(s=>{const r=s.value;r.setActive(r===e)})}));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,i){const s=this.getPanel(t);if(!s)throw new Error("invalid operation");const r=Ce(e.element),[n,o]=Zt(wt(this.gridview.orientation,r,i)),[a,l]=Zt(Ce(s.element));if(jc(a,n)){this.gridview.moveView(a,l,o);return}const h=this.doRemoveGroup(s,{skipActive:!0,skipDispose:!0}),c=Ce(e.element),u=wt(this.gridview.orientation,c,i);this.doAddGroup(h,u)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}},Nw=class extends Ia{get panels(){return this.splitview.getViews()}get options(){return this._options}get length(){return this._panels.size}get orientation(){return this.splitview.orientation}get splitview(){return this._splitview}set splitview(e){this._splitview&&this._splitview.dispose(),this._splitview=e,this._splitviewChangeDisposable.value=new se(this._splitview.onDidSashEnd(()=>{this._onDidLayoutChange.fire(void 0)}),this._splitview.onDidAddView(t=>this._onDidAddView.fire(t)),this._splitview.onDidRemoveView(t=>this._onDidRemoveView.fire(t)))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation==="HORIZONTAL"?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation==="HORIZONTAL"?this.splitview.size:this.splitview.orthogonalSize}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._splitviewChangeDisposable=new Me,this._panels=new Map,this._onDidLayoutfromJSON=new G,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new G,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new G,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new G,this.onDidLayoutChange=this._onDidLayoutChange.event,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new qr(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this._options=t,this.splitview=new Oi(this.element,t),this.addDisposables(this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange)}updateOptions(e){if("className"in e){var t;this._classNames.setClassNames((t=e.className)!==null&&t!==void 0?t:"")}if("disableResizing"in e){var i;this.disableResizing=(i=e.disableAutoResizing)!==null&&i!==void 0?i:!1}typeof e.orientation=="string"&&(this.splitview.orientation=e.orientation),this._options=re(re({},this.options),e),this.splitview.layout(this.splitview.size,this.splitview.orthogonalSize)}focus(){var e;(e=this._activePanel)===null||e===void 0||e.focus()}movePanel(e,t){this.splitview.moveView(e,t)}setVisible(e,t){const i=this.panels.indexOf(e);this.splitview.setViewVisible(i,t)}setActive(e,t){this._activePanel=e,this.panels.filter(i=>i!==e).forEach(i=>{i.api._onDidActiveChange.fire({isActive:!1}),t||i.focus()}),e.api._onDidActiveChange.fire({isActive:!0}),t||e.focus()}removePanel(e,t){const i=this._panels.get(e.id);if(!i)throw new Error(`unknown splitview panel ${e.id}`);i.dispose(),this._panels.delete(e.id);const s=this.panels.indexOf(e);this.splitview.removeView(s,t).dispose();const r=this.panels;r.length>0&&this.setActive(r[r.length-1])}getPanel(e){return this.panels.find(t=>t.id===e)}addPanel(e){var t;if(this._panels.has(e.id))throw new Error(`panel ${e.id} already exists`);const i=this.options.createComponent({id:e.id,name:e.component});i.orientation=this.splitview.orientation,i.init({params:(t=e.params)!==null&&t!==void 0?t:{},minimumSize:e.minimumSize,maximumSize:e.maximumSize,snap:e.snap,priority:e.priority,accessor:this});const s=typeof e.size=="number"?e.size:nt.Distribute,r=typeof e.index=="number"?e.index:void 0;return this.splitview.addView(i,s,r),this.doAddView(i),this.setActive(i),i}layout(e,t){const[i,s]=this.splitview.orientation==="HORIZONTAL"?[e,t]:[t,e];this.splitview.layout(i,s)}doAddView(e){const t=e.api.onDidFocusChange(i=>{i.isFocused&&this.setActive(e,!0)});this._panels.set(e.id,t)}toJSON(){var e;return{views:this.splitview.getViews().map((t,i)=>({size:this.splitview.getViewSize(i),data:t.toJSON(),snap:!!t.snap,priority:t.priority})),activeView:(e=this._activePanel)===null||e===void 0?void 0:e.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){this.clear();const{views:t,orientation:i,size:s,activeView:r}=e,n=[],o=this.width,a=this.height;if(this.splitview=new Oi(this.element,{orientation:i,proportionalLayout:this.options.proportionalLayout,descriptor:{size:s,views:t.map(l=>{const h=l.data;if(this._panels.has(h.id))throw new Error(`panel ${h.id} already exists`);const c=this.options.createComponent({id:h.id,name:h.component});return n.push(()=>{var u;c.init({params:(u=h.params)!==null&&u!==void 0?u:{},minimumSize:h.minimumSize,maximumSize:h.maximumSize,snap:l.snap,priority:l.priority,accessor:this})}),c.orientation=i,this.doAddView(c),setTimeout(()=>{this._onDidAddView.fire(c)},0),{size:l.size,view:c}})}}),this.layout(o,a),n.forEach(l=>l()),typeof r=="string"){const l=this.getPanel(r);l&&this.setActive(l)}this._onDidLayoutfromJSON.fire()}clear(){for(const e of this._panels.values())e.dispose();for(this._panels.clear();this.splitview.length>0;)this.splitview.removeView(0,nt.Distribute,!0).dispose()}dispose(){for(const t of this._panels.values())t.dispose();this._panels.clear();const e=this.splitview.getViews();this._splitviewChangeDisposable.dispose(),this.splitview.dispose();for(const t of e)t.dispose();this.element.remove(),super.dispose()}},sh=class extends se{get element(){return this._element}constructor(){super(),this._expandedIcon=ab(),this._collapsedIcon=nu(),this.disposable=new Me,this.apiRef={api:null},this._element=document.createElement("div"),this.element.className="dv-default-header",this._content=document.createElement("span"),this._expander=document.createElement("div"),this._expander.className="dv-pane-header-icon",this.element.appendChild(this._expander),this.element.appendChild(this._content),this.addDisposables(Z(this._element,"click",()=>{var e;(e=this.apiRef.api)===null||e===void 0||e.setExpanded(!this.apiRef.api.isExpanded)}))}init(e){this.apiRef.api=e.api,this._content.textContent=e.title,this.updateIcon(),this.disposable.value=e.api.onDidExpansionChange(()=>{this.updateIcon()})}updateIcon(){var e;const t=!!(!((e=this.apiRef.api)===null||e===void 0)&&e.isExpanded);K(this._expander,"collapsed",!t),t?(this._expander.contains(this._collapsedIcon)&&this._collapsedIcon.remove(),this._expander.contains(this._expandedIcon)||this._expander.appendChild(this._expandedIcon)):(this._expander.contains(this._expandedIcon)&&this._expandedIcon.remove(),this._expander.contains(this._collapsedIcon)||this._expander.appendChild(this._collapsedIcon))}update(e){}dispose(){this.disposable.dispose(),super.dispose()}};const Mw=Ta(),rh=22,nh=0,oh=Number.MAX_SAFE_INTEGER;var ah=class extends ib{constructor(e){super({accessor:e.accessor,id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,disableDnd:e.disableDnd,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this.options=e}getBodyComponent(){return this.options.body}getHeaderComponent(){return this.options.header}},Ow=class extends Ia{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new se(this._paneview.onDidChange(()=>{this._onDidLayoutChange.fire(void 0)}),this._paneview.onDidAddView(t=>this._onDidAddView.fire(t)),this._paneview.onDidRemoveView(t=>this._onDidRemoveView.fire(t)))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation==="HORIZONTAL"?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation==="HORIZONTAL"?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._id=Mw.next(),this._disposable=new Me,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new G,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new G,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new G,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new G,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new G,this.onDidRemoveView=this._onDidRemoveView.event,this._onUnhandledDragOver=new G,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this.element.style.height="100%",this.element.style.width="100%",this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView,this._onUnhandledDragOver),this._classNames=new qr(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this._options=t,this.paneview=new Fl(this.element,{orientation:"VERTICAL"}),this.addDisposables(this._disposable)}setVisible(e,t){const i=this.panels.indexOf(e);this.paneview.setViewVisible(i,t)}focus(){}updateOptions(e){if("className"in e){var t;this._classNames.setClassNames((t=e.className)!==null&&t!==void 0?t:"")}if("disableAutoResizing"in e){var i;this.disableResizing=(i=e.disableAutoResizing)!==null&&i!==void 0?i:!1}this._options=re(re({},this.options),e)}addPanel(e){var t,i,s;const r=this.options.createComponent({id:e.id,name:e.component});let n;e.headerComponent&&this.options.createHeaderComponent&&(n=this.options.createHeaderComponent({id:e.id,name:e.headerComponent})),(t=n)!==null&&t!==void 0||(n=new sh);const o=new ah({id:e.id,component:e.component,headerComponent:e.headerComponent,header:n,body:r,orientation:"VERTICAL",isExpanded:!!e.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:(i=e.headerSize)!==null&&i!==void 0?i:rh,minimumBodySize:nh,maximumBodySize:oh});this.doAddPanel(o);const a=typeof e.size=="number"?e.size:nt.Distribute,l=typeof e.index=="number"?e.index:void 0;return o.init({params:(s=e.params)!==null&&s!==void 0?s:{},minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize,isExpanded:e.isExpanded,title:e.title,containerApi:new Is(this),accessor:this}),this.paneview.addPane(o,a,l),o.orientation=this.paneview.orientation,o}removePanel(e){const t=this.panels.indexOf(e);this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find(t=>t.id===e)}layout(e,t){const[i,s]=this.paneview.orientation==="HORIZONTAL"?[e,t]:[t,e];this.paneview.layout(i,s)}toJSON(){const e=i=>i===Number.MAX_SAFE_INTEGER||i===Number.POSITIVE_INFINITY?void 0:i,t=i=>i<=0?void 0:i;return{views:this.paneview.getPanes().map((i,s)=>{const r=this.paneview.getViewCachedVisibleSize(s),n=typeof r=="number";return re({size:n?r:this.paneview.getViewSize(s),data:i.toJSON(),minimumSize:t(i.minimumBodySize),maximumSize:e(i.maximumBodySize),headerSize:i.headerSize,expanded:i.isExpanded()},n?{visible:!1}:{})}),size:this.paneview.size}}fromJSON(e){this.clear();const{views:t,size:i}=e,s=[],r=this.width,n=this.height;this.paneview=new Fl(this.element,{orientation:"VERTICAL",descriptor:{size:i,views:t.map(o=>{var a,l,h,c;const u=o.data,p=this.options.createComponent({id:u.id,name:u.component});let f;u.headerComponent&&this.options.createHeaderComponent&&(f=this.options.createHeaderComponent({id:u.id,name:u.headerComponent})),(a=f)!==null&&a!==void 0||(f=new sh);const m=new ah({id:u.id,component:u.component,headerComponent:u.headerComponent,header:f,body:p,orientation:"VERTICAL",isExpanded:!!o.expanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:(l=o.headerSize)!==null&&l!==void 0?l:rh,minimumBodySize:(h=o.minimumSize)!==null&&h!==void 0?h:nh,maximumBodySize:(c=o.maximumSize)!==null&&c!==void 0?c:oh});return this.doAddPanel(m),s.push(()=>{var g;m.init({params:(g=u.params)!==null&&g!==void 0?g:{},minimumBodySize:o.minimumSize,maximumBodySize:o.maximumSize,title:u.title,isExpanded:!!o.expanded,containerApi:new Is(this),accessor:this}),m.orientation=this.paneview.orientation}),setTimeout(()=>{this._onDidAddView.fire(m)},0),{size:o.size,view:m,visible:o.visible}})}}),this.layout(r,n),s.forEach(o=>o()),this._onDidLayoutfromJSON.fire()}clear(){for(const[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.paneview.dispose()}doAddPanel(e){const t=new se(e.onDidDrop(i=>{this._onDidDrop.fire(i)}),e.onUnhandledDragOver(i=>{this._onUnhandledDragOver.fire(i)}));this._viewDisposables.set(e.id,t)}doRemovePanel(e){const t=this._viewDisposables.get(e.id);t&&(t.dispose(),this._viewDisposables.delete(e.id))}dispose(){super.dispose();for(const[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.element.remove(),this.paneview.dispose()}},Gw=class extends Ra{get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){const e=typeof this._minimumSize=="function"?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){const e=typeof this._maximumSize=="function"?this._maximumSize():this._maximumSize;return e!==this._evaluatedMaximumSize&&(this._evaluatedMaximumSize=e,this.updateConstraints()),e}get snap(){return this._snap}constructor(e,t){super(e,t,new su(e,t)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new G,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,this.api.onWillVisibilityChange(i=>{const{isVisible:s}=i,{accessor:r}=this._params;r.setVisible(this,s)}),this.api.onActiveChange(()=>{const{accessor:i}=this._params;i.setActive(this)}),this.api.onDidConstraintsChangeInternal(i=>{(typeof i.minimumSize=="number"||typeof i.minimumSize=="function")&&(this._minimumSize=i.minimumSize),(typeof i.maximumSize=="number"||typeof i.maximumSize=="function")&&(this._maximumSize=i.maximumSize),this.updateConstraints()}),this.api.onDidSizeChange(i=>{this._onDidChange.fire({size:i.size})}))}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(e,t){const[i,s]=this.orientation==="HORIZONTAL"?[e,t]:[t,e];super.layout(i,s)}init(e){super.init(e),this._priority=e.priority,e.minimumSize&&(this._minimumSize=e.minimumSize),e.maximumSize&&(this._maximumSize=e.maximumSize),e.snap&&(this._snap=e.snap)}toJSON(){const e=i=>i===Number.MAX_SAFE_INTEGER||i===Number.POSITIVE_INFINITY?void 0:i,t=i=>i<=0?void 0:i;return re(re({},super.toJSON()),{},{minimumSize:t(this.minimumSize),maximumSize:e(this.maximumSize)})}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}};function zw(e,t){return new Rw(e,t).api}function Bw(e,t){return new Uc(new Nw(e,t))}function jw(e,t){return new Kc(new Lw(e,t))}function $w(e,t){return new Is(new Ow(e,t))}function Rs(e){"@babel/helpers - typeof";return Rs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Rs(e)}function Ww(e,t){if(Rs(e)!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var s=i.call(e,t);if(Rs(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Hw(e){var t=Ww(e,"string");return Rs(t)=="symbol"?t:t+""}function Fw(e,t,i){return(t=Hw(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function lh(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),i.push.apply(i,s)}return i}function dt(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?lh(Object(i),!0).forEach(function(s){Fw(e,s,i[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):lh(Object(i)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(i,s))})}return e}const wu=(e,t)=>{const[,i]=oe.useState(0),s=oe.useRef(e.componentProps);return oe.useImperativeHandle(t,()=>({update:r=>{s.current=dt(dt({},s.current),r),i(n=>n+1)}}),[]),oe.createElement(e.component,s.current)};wu.displayName="DockviewReactJsBridge";const Vw=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),Uw=oe.createContext({});var Ht=class{constructor(e,t,i,s,r){this.parent=e,this.portalStore=t,this.component=i,this.parameters=s,this.context=r,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw new Error("invalid operation: resource is already disposed");this.componentInstance?this.componentInstance.update(e):this._initialProps=dt(dt({},this._initialProps),e)}createPortal(){if(this.disposed)throw new Error("invalid operation: resource is already disposed");if(!Kw(this.component))throw new Error("Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components");const e=oe.createElement(oe.forwardRef(wu),{component:this.component,componentProps:this.parameters,ref:s=>{this.componentInstance=s,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?oe.createElement(Uw.Provider,{value:this.context},e):e,i=mf.createPortal(t,this.parent,Vw.next());this.ref={portal:i,disposable:this.portalStore.addPortal(i)}}dispose(){var e;(e=this.ref)===null||e===void 0||e.disposable.dispose(),this.disposed=!0}};const Jr=()=>{const[e,t]=oe.useState([]);return oe.useDebugValue(`Portal count: ${e.length}`),[e,oe.useCallback(i=>{t(r=>[...r,i]);let s=!1;return Se.from(()=>{if(s)throw new Error("invalid operation: resource already disposed");s=!0,t(r=>r.filter(n=>n!==i))})},[])]};function Kw(e){return typeof e=="function"||!!e?.$$typeof}var hh=class{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._onDidFocus=new G,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new G,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new Ht(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;(t=this.part)===null||t===void 0||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),(e=this.part)===null||e===void 0||e.dispose()}},dh=class{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new Ht(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;(t=this.part)===null||t===void 0||t.update({params:e.params})}layout(e,t){}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}},ch=class{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new Ht(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t,i,s;this.parameters&&(this.parameters.params=e.params),(t=this.part)===null||t===void 0||t.update({params:(i=(s=this.parameters)===null||s===void 0?void 0:s.params)!==null&&i!==void 0?i:{}})}layout(e,t){}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}},qw=class{get element(){return this._element}get part(){return this._part}constructor(e,t,i){this.component=e,this.reactPortalStore=t,this._group=i,this.mutableDisposable=new Me,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.mutableDisposable.value=new se(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),e.api.onDidActiveChange(()=>{this.updateGroupActive()}),e.api.onDidLocationChange(t=>{this.updateLocation(t.location)})),this._part=new Ht(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group,headerPosition:this._group.model.headerPosition,location:e.api.location})}dispose(){var e;this.mutableDisposable.dispose(),(e=this._part)===null||e===void 0||e.dispose()}update(e){var t;(t=this._part)===null||t===void 0||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}updateLocation(e){this.update({params:{location:e}})}},Yw=class{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new Ht(this._element,this.reactPortalStore,this.component,e)}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}},uh=class{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new Ht(this._element,this.reactPortalStore,this.component,{tabGroup:e.tabGroup,api:e.api})}update(e){var t;(t=this.part)===null||t===void 0||t.update({tabGroup:e.tabGroup})}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}},ph=class{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new Ht(this._element,this.reactPortalStore,this.component,{group:e.group,api:e.api})}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}};function Hi(e,t){return e?i=>new qw(e,t,i):void 0}const rr="props.defaultTabComponent";function Xw(e){return ho.reduce((t,i)=>(i in e&&(t[i]=e[i]),t),{})}const yu=oe.forwardRef((e,t)=>{const i=oe.useRef(null),s=oe.useRef(void 0),[r,n]=Jr();oe.useImperativeHandle(t,()=>i.current,[]);const o=oe.useRef({});return oe.useEffect(()=>{const a={};ho.forEach(l=>{const h=l,c=e[h];h in e&&c!==o.current[h]&&(a[h]=c)}),s.current&&s.current.updateOptions(a),o.current=e},ho.map(a=>e[a])),oe.useEffect(()=>{if(!i.current)return;const a=dt({},e.tabComponents);e.defaultTabComponent&&(a[rr]=e.defaultTabComponent);const l={createLeftHeaderActionComponent:Hi(e.leftHeaderActionsComponent,{addPortal:n}),createRightHeaderActionComponent:Hi(e.rightHeaderActionsComponent,{addPortal:n}),createPrefixHeaderActionComponent:Hi(e.prefixHeaderActionsComponent,{addPortal:n}),createComponent:f=>new hh(f.id,e.components[f.name],{addPortal:n}),createTabComponent(f){return new dh(f.id,a[f.name],{addPortal:n})},createWatermarkComponent:e.watermarkComponent?()=>new ch("watermark",e.watermarkComponent,{addPortal:n}):void 0,defaultTabComponent:e.defaultTabComponent?rr:void 0,createContextMenuItemComponent:f=>{if(f.component)return new Yw(f.id,f.component,{addPortal:n})}},h=Xw(e);if(e.tabGroupChipComponent){const f=e.tabGroupChipComponent;h.createTabGroupChipComponent=()=>new uh(f,{addPortal:n})}if(e.groupDragGhostComponent){const f=e.groupDragGhostComponent;h.createGroupDragGhostComponent=()=>new ph(f,{addPortal:n})}const c=zw(i.current,dt(dt({},h),l)),{clientWidth:u,clientHeight:p}=i.current;return c.layout(u,p),e.onReady&&e.onReady({api:c}),s.current=c,()=>{s.current=void 0,c.dispose()}},[]),oe.useEffect(()=>{if(!s.current)return()=>{};const a=s.current.onDidDrop(l=>{e.onDidDrop&&e.onDidDrop(l)});return()=>{a.dispose()}},[e.onDidDrop]),oe.useEffect(()=>{if(!s.current)return()=>{};const a=s.current.onWillDrop(l=>{e.onWillDrop&&e.onWillDrop(l)});return()=>{a.dispose()}},[e.onWillDrop]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createTabGroupChipComponent:e.tabGroupChipComponent?()=>new uh(e.tabGroupChipComponent,{addPortal:n}):void 0})},[e.tabGroupChipComponent]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createGroupDragGhostComponent:e.groupDragGhostComponent?()=>new ph(e.groupDragGhostComponent,{addPortal:n}):void 0})},[e.groupDragGhostComponent]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createComponent:a=>new hh(a.id,e.components[a.name],{addPortal:n})})},[e.components]),oe.useEffect(()=>{if(!s.current)return;const a=dt({},e.tabComponents);e.defaultTabComponent&&(a[rr]=e.defaultTabComponent),s.current.updateOptions({defaultTabComponent:e.defaultTabComponent?rr:void 0,createTabComponent(l){return new dh(l.id,a[l.name],{addPortal:n})}})},[e.tabComponents,e.defaultTabComponent]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createWatermarkComponent:e.watermarkComponent?()=>new ch("watermark",e.watermarkComponent,{addPortal:n}):void 0})},[e.watermarkComponent]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createRightHeaderActionComponent:Hi(e.rightHeaderActionsComponent,{addPortal:n})})},[e.rightHeaderActionsComponent]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createLeftHeaderActionComponent:Hi(e.leftHeaderActionsComponent,{addPortal:n})})},[e.leftHeaderActionsComponent]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createPrefixHeaderActionComponent:Hi(e.prefixHeaderActionsComponent,{addPortal:n})})},[e.prefixHeaderActionsComponent]),oe.createElement("div",{style:{height:"100%",width:"100%"},ref:i},r)});yu.displayName="DockviewComponent";var fh=class extends Gw{constructor(e,t,i,s){super(e,t),this.reactComponent=i,this.reactPortalStore=s}getComponent(){var e,t;return new Ht(this.element,this.reactPortalStore,this.reactComponent,{params:(e=(t=this._params)===null||t===void 0?void 0:t.params)!==null&&e!==void 0?e:{},api:this.api,containerApi:new Uc(this._params.accessor)})}};function Jw(e){return eo.reduce((t,i)=>(i in e&&(t[i]=e[i]),t),{})}const Zw=oe.forwardRef((e,t)=>{const i=oe.useRef(null),s=oe.useRef(void 0),[r,n]=Jr();oe.useImperativeHandle(t,()=>i.current,[]);const o=oe.useRef({});return oe.useEffect(()=>{const a={};eo.forEach(l=>{const h=l,c=e[h];h in e&&c!==o.current[h]&&(a[h]=c)}),s.current&&s.current.updateOptions(a),o.current=e},eo.map(a=>e[a])),oe.useEffect(()=>{if(!i.current)return()=>{};const a=Bw(i.current,dt(dt({},Jw(e)),{createComponent:c=>new fh(c.id,c.name,e.components[c.name],{addPortal:n})})),{clientWidth:l,clientHeight:h}=i.current;return a.layout(l,h),e.onReady&&e.onReady({api:a}),s.current=a,()=>{s.current=void 0,a.dispose()}},[]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createComponent:a=>new fh(a.id,a.name,e.components[a.name],{addPortal:n})})},[e.components]),oe.createElement("div",{style:{height:"100%",width:"100%"},ref:i},r)});Zw.displayName="SplitviewComponent";var mh=class extends mu{constructor(e,t,i,s){super(e,t),this.reactComponent=i,this.reactPortalStore=s}getComponent(){var e,t;return new Ht(this.element,this.reactPortalStore,this.reactComponent,{params:(e=(t=this._params)===null||t===void 0?void 0:t.params)!==null&&e!==void 0?e:{},api:this.api,containerApi:new Kc(this._params.accessor)})}};function Qw(e){return no.reduce((t,i)=>(i in e&&(t[i]=e[i]),t),{})}const e0=oe.forwardRef((e,t)=>{const i=oe.useRef(null),s=oe.useRef(void 0),[r,n]=Jr();oe.useImperativeHandle(t,()=>i.current,[]);const o=oe.useRef({});return oe.useEffect(()=>{const a={};no.forEach(l=>{const h=l,c=e[h];h in e&&c!==o.current[h]&&(a[h]=c)}),s.current&&s.current.updateOptions(a),o.current=e},no.map(a=>e[a])),oe.useEffect(()=>{if(!i.current)return()=>{};const a=jw(i.current,dt(dt({},Qw(e)),{createComponent:c=>new mh(c.id,c.name,e.components[c.name],{addPortal:n})})),{clientWidth:l,clientHeight:h}=i.current;return a.layout(l,h),e.onReady&&e.onReady({api:a}),s.current=a,()=>{s.current=void 0,a.dispose()}},[]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createComponent:a=>new mh(a.id,a.name,e.components[a.name],{addPortal:n})})},[e.components]),oe.createElement("div",{style:{height:"100%",width:"100%"},ref:i},r)});e0.displayName="GridviewComponent";var nr=class{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new Ht(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;(t=this.part)===null||t===void 0||t.update(e.params)}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}};function t0(e){return ao.reduce((t,i)=>(i in e&&(t[i]=e[i]),t),{})}const i0=oe.forwardRef((e,t)=>{const i=oe.useRef(null),s=oe.useRef(void 0),[r,n]=Jr();oe.useImperativeHandle(t,()=>i.current,[]);const o=oe.useRef({});return oe.useEffect(()=>{const a={};ao.forEach(l=>{const h=l,c=e[h];h in e&&c!==o.current[h]&&(a[h]=c)}),s.current&&s.current.updateOptions(a),o.current=e},ao.map(a=>e[a])),oe.useEffect(()=>{var a;if(!i.current)return()=>{};const l=(a=e.headerComponents)!==null&&a!==void 0?a:{},h=$w(i.current,dt(dt({},t0(e)),{createComponent:p=>new nr(p.id,e.components[p.name],{addPortal:n}),createHeaderComponent:p=>new nr(p.id,l[p.name],{addPortal:n})})),{clientWidth:c,clientHeight:u}=i.current;return h.layout(c,u),e.onReady&&e.onReady({api:h}),s.current=h,()=>{s.current=void 0,h.dispose()}},[]),oe.useEffect(()=>{s.current&&s.current.updateOptions({createComponent:a=>new nr(a.id,e.components[a.name],{addPortal:n})})},[e.components]),oe.useEffect(()=>{var a;if(!s.current)return;const l=(a=e.headerComponents)!==null&&a!==void 0?a:{};s.current.updateOptions({createHeaderComponent:h=>new nr(h.id,l[h.name],{addPortal:n})})},[e.headerComponents]),oe.useEffect(()=>{if(!s.current)return()=>{};const a=s.current.onDidDrop(l=>{e.onDidDrop&&e.onDidDrop(l)});return()=>{a.dispose()}},[e.onDidDrop]),oe.createElement("div",{style:{height:"100%",width:"100%"},ref:i},r)});i0.displayName="PaneviewComponent";function s0(e,t){const i=t.trim();if(i.length===0||i.length>512||i.startsWith("/")||i.startsWith("\\")||i.includes("\\")||i.includes("\0")||i.includes("?")||i.includes("#")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(i))return null;const s=Cl(e)&&e!=="."?e:e.split("/").pop()??"",r=s.lastIndexOf("/"),n=r===-1?"":s.slice(0,r),o=n?`${n}/${i}`:i,a=[];for(const h of o.split("/"))if(!(h===""||h===".")){if(h===".."){if(a.length===0)return null;a.pop();continue}a.push(h)}const l=a.join("/");return!l||!Cl(l)?null:l}function gh(e,t){const i=new RegExp(`\\b${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s"'=<>]+))`,"i").exec(e);return i?i[1]??i[2]??i[3]??"":null}function r0(e,t,i){return e.replace(new RegExp(`\\b${t}\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s"'=<>]+)`,"i"),`${t}="${i}"`)}function n0(e){return e?.trim().toLowerCase().split(/\s+/).includes("stylesheet")??!1}function o0(e){try{return new TextDecoder().decode(Uint8Array.from(atob(e),t=>t.charCodeAt(0)))}catch{return null}}function a0(e,t){const i=[],s=(r,n,o,a)=>{const l=n[1]??"";if(!a(l))return;const h=gh(l,o);if(h===null)return;const c=s0(t,h);c&&i.push({start:n.index,end:n.index+n[0].length,kind:r,rel:c,attrs:l,full:n[0]})};for(const r of e.matchAll(/<script\b([^>]*)>[\s\S]*?<\/script>/gi))s("script",r,"src",()=>!0);for(const r of e.matchAll(/<link\b([^>]*?)\/?>/gi))s("style",r,"href",n=>n0(gh(n,"rel")));for(const r of e.matchAll(/<img\b([^>]*?)\/?>/gi))s("img",r,"src",()=>!0);return i.sort((r,n)=>r.start-n.start),i}async function l0(e,t,i){const s=a0(e,t),r=new Map;await Promise.all([...new Set(s.map(a=>a.rel))].map(async a=>{r.set(a,await i(a))}));let n=0,o="";for(const a of s){o+=e.slice(n,a.start),n=a.end;const l=r.get(a.rel);if(!l){o+=a.full;continue}if(a.kind==="img"){const c=l.mime||"application/octet-stream";o+=`<img${r0(a.attrs,"src",`data:${c};base64,${l.base64}`)}>`;continue}const h=o0(l.base64);if(h===null){o+=a.full;continue}o+=a.kind==="script"?`<script>${h.replace(/<\/script/gi,"<\\/script")}<\/script>`:`<style>${h.replace(/<\/style/gi,"<\\/style")}</style>`}return o+e.slice(n)}const h0="plugin-view.html";function vh(){return document.documentElement.classList.contains("dark")?"dark":"light"}function d0({pluginId:e,viewId:t,sessionId:i}){const{t:s}=he(),r=Os().find(n=>n.pluginId===e&&n.id===t);return r?d.jsx(Zr,{pluginId:e,entry:r.entry,title:r.title,sessionId:i}):d.jsx("div",{className:"flex h-full items-center justify-center p-6 text-sm text-muted-foreground",children:s("Plugin is not enabled")})}function Zr({pluginId:e,entry:t,title:i,sessionId:s,file:r}){const n=b.useRef(null),[o,a]=b.useState(null),l=b.useRef(s);l.current=s;const h=ue(_=>s?_.conversations[s]?.projectId??null:null),c=b.useRef(h);c.current=h;const u=b.useRef(r);u.current=r;const p=b.useRef(null),f=b.useRef(null);b.useEffect(()=>{const _=n.current;if(!_)return;a(null);let E=!1,C=null;const T=()=>{try{C?.port1.postMessage(_f(vh()))}catch{}},x=new MutationObserver(T);x.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const A=window.electronAPI.extensionPlugins.onViewEvent(O=>{if(!(O.pluginId!==e||typeof O.name!="string"))try{C?.port1.postMessage(gf(O.name,O.data))}catch{}}),k=Sf(async(O,z)=>{const R=await window.electronAPI.extensionPlugins.call({pluginId:e,method:"renderer.call",payload:{method:O,args:z},sessionId:l.current});if(!R.ok)throw new Error(R.error);return R.value}),N=async O=>{if(O.source!==_.contentWindow||O.data?.type!=="enso-view-ready")return;C?.port1.close();const z=new MessageChannel;C=z,p.current=z,z.port1.onmessage=S=>{const D=bf(S.data);if(D){window.electronAPI.extensionPlugins.viewStateSet(e,D);return}const y=wf(S.data);if(y!==null){f.current=y,u.current?.onEdit(y);return}k(S.data).then(L=>{L&&!E&&C===z&&z.port1.postMessage(L)})};const[R,I]=await Promise.all([window.electronAPI.extensionPlugins.asset(e,t),window.electronAPI.extensionPlugins.viewStateGet(e)]);if(E||C!==z)return;if(!R.ok){a(R.error);return}const w=await l0(yf(R.base64),t,async S=>{const D=await window.electronAPI.extensionPlugins.asset(e,S);return D.ok?{mime:D.mime,base64:D.base64}:null});if(E||C!==z)return;const v=u.current;_.contentWindow?.postMessage({type:"enso-view-init",html:w,theme:vh(),storage:I.ok?I.state:{},session:vl(l.current,c.current),...v?{file:{rel:v.rel,text:v.text}}:{}},"*",[z.port2])};return window.addEventListener("message",N),_.src=new URL(h0,document.baseURI).href,()=>{E=!0,x.disconnect(),A(),window.removeEventListener("message",N),C?.port1.close(),p.current=null,_.removeAttribute("src")}},[e,t]),b.useEffect(()=>{try{p.current?.port1.postMessage(vl(s,h))}catch{}},[s,h]);const m=r?.rel,g=r?.text;return b.useEffect(()=>{if(!(m===void 0||g===void 0)){if(f.current===g){f.current=null;return}try{p.current?.port1.postMessage(vf(m,g))}catch{}}},[m,g]),d.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[o&&d.jsx("div",{className:"shrink-0 px-3 py-2 text-xs text-destructive",children:o}),d.jsx("iframe",{ref:n,title:i,className:"min-h-0 w-full flex-1 border-0 bg-background"})]})}const c0=/^(\d{4})-(\d{2})-(\d{2})$/u;function _h(e){return e<10?`0${e}`:String(e)}function Ds(e){const t=new Date(e);return`${t.getFullYear()}-${_h(t.getMonth()+1)}-${_h(t.getDate())}`}function u0(e){if(typeof e!="string")return null;const t=c0.exec(e.trim());if(!t)return null;const i=Number(t[1]),s=Number(t[2]),r=Number(t[3]),n=new Date(i,s-1,r);return n.getFullYear()!==i||n.getMonth()!==s-1||n.getDate()!==r?null:`${t[1]}-${t[2]}-${t[3]}`}function p0(e){const t=u0(e);if(!t)return Number.NaN;const[i,s,r]=t.split("-").map(Number);return new Date(i,s-1,r).getTime()}function bh(e,t){const i=p0(e);if(Number.isNaN(i))return e;const s=new Date(i);return Ds(new Date(s.getFullYear(),s.getMonth(),s.getDate()+t).getTime())}const f0=[{name:"status",zh:"进行中的会话,以及需要你处理的",en:"Running sessions and what needs you"},{name:"board",zh:"今天的看板;可带日期,如 /board 2026-05-20 或 yesterday",en:"Today's board; optional date"},{name:"feed",zh:"最近的动态,底部可翻更早",en:"Recent activity, with an older button"},{name:"todo",zh:"未完成的待办",en:"Open todos"},{name:"schedules",zh:"定时任务与下次运行时间",en:"Scheduled tasks and next run"},{name:"following",zh:"手机关注的任务;/following clear 全清",en:"Tasks followed from the phone; /following clear drops all"},{name:"last",zh:"回看秘书会话最近一轮;/last 3 看最近三轮",en:"Replay the last round; /last 3 for three"},{name:"sync",zh:"把所有回复同步到手机;/sync off 关掉",en:"Mirror every reply here; /sync off stops it"},{name:"memory",zh:"秘书记得的标题(默认关闭)",en:"Memory titles (off by default)",gated:!0},{name:"help",zh:"列出所有命令",en:"List every command"}];function m0(e){return e.result==="interrupted"?"interrupted":e.state==="error"?"failed":e.state==="waiting"?"waiting":e.stalled?"stalled":e.state==="running"?"running":e.backgroundRunning?"background":e.backgroundPersistent?"persistent":e.continuing?"continuing":"idle"}const g0="1",Fi="inline-flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1.5 text-[12.5px] transition-colors hover:bg-muted disabled:opacity-50",wh={network:"Cannot reach api.telegram.org. Check the proxy.",unauthorized:"Telegram rejected this token",api:"Telegram returned an error","token-required":"Paste a bot token first","not-group":"This chat is not a group","invalid-chat-id":"Group chat IDs are numbers, e.g. -1001234567890","invalid-topic":"Pick at least one topic","route-conflict":"Another secretary already has this group or one of these topics"};function v0({checked:e,disabled:t,label:i,onClick:s,enso:r}){return d.jsxs("button",{type:"button",role:"checkbox","aria-checked":e,"data-enso":r,disabled:t,onClick:s,className:"flex items-center gap-1.5 text-left text-[12px] disabled:opacity-50",children:[d.jsx("span",{className:Y("flex size-3.5 shrink-0 items-center justify-center rounded border border-border",e&&"border-foreground bg-foreground text-background"),children:e&&d.jsx(bi,{className:"size-2.5"})}),i]})}function yh({checked:e,disabled:t,label:i,onClick:s,enso:r}){return d.jsx("button",{type:"button",role:"radio","aria-checked":e,"data-enso":r,disabled:t,onClick:s,className:Y("rounded-md px-2 py-0.5 text-[11.5px] transition-colors disabled:opacity-50",e?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"),children:i})}function _0({group:e,secretaryId:t,busy:i,onRemove:s,onSaved:r}){const{t:n}=he(),[o,a]=b.useState(!1),[l,h]=b.useState({state:"idle"}),[c,u]=b.useState(e.topics.map(R=>R.id)),[p,f]=b.useState(!1),[m,g]=b.useState(null),_=R=>R.id===g0?n("General (default topic)"):R.title??n("Topic #{{id}}",{id:R.id}),E=(R,I)=>{const w=n(wh[R]??wh.api),v=R==="api"?` ${n("Make sure the bot is in this group.")}`:"";return`${w}${I?`: ${I}`:""}${v}`},C=()=>{h({state:"loading"}),window.electronAPI.secretary.contactTelegramTopics(e.id,t).then(R=>h(R.ok?{state:"ready",forum:R.forum,topics:R.topics}:{state:"error",error:R.error,...R.detail?{detail:R.detail}:{}}),()=>h({state:"error",error:"api"}))},T=()=>{u(e.topics.map(R=>R.id)),g(null),a(!0),C()},x=R=>{f(!0),g(null),window.electronAPI.secretary.contactSettings({telegramGroupScope:{chatId:e.id,scope:R}},t).then(I=>{I.ok?(a(!1),r()):g(I.error)},()=>g("api")).finally(()=>f(!1))},A=()=>{o&&a(!1),e.all||x("all")},k=e.title??e.id,N=l.state==="ready"?[...l.topics,...e.topics.filter(R=>!l.topics.some(I=>I.id===R.id))]:[],O=i||p,z=o||!e.all;return d.jsxs("li",{"data-enso":"secretary-contact-group",className:"flex flex-col gap-1.5",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{"data-enso":"secretary-contact-group-name",className:"min-w-0 flex-1 truncate text-[12px]",children:e.title?d.jsxs(d.Fragment,{children:[e.title," ",d.jsx("span",{className:"font-mono text-[11px] text-muted-foreground",children:e.id})]}):d.jsx("span",{className:"font-mono text-[11.5px]",children:e.id})}),d.jsxs("div",{role:"radiogroup","aria-label":n("What {{name}} hands to this secretary",{name:k}),className:"inline-flex shrink-0 rounded-lg border border-border p-0.5",children:[d.jsx(yh,{enso:"secretary-contact-scope-all",checked:!z,disabled:O,label:n("Whole group"),onClick:A}),d.jsx(yh,{enso:"secretary-contact-scope-topics",checked:z,disabled:O,label:n("Pick topics"),onClick:()=>{o||T()}})]}),d.jsx("button",{type:"button","data-enso":"secretary-contact-group-remove",disabled:i,"aria-label":n("Remove {{name}}",{name:k}),className:Fi,onClick:s,children:d.jsx(Gs,{className:"size-3.5"})})]}),!e.all&&!o&&d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("span",{"data-enso":"secretary-contact-group-scope",className:"min-w-0 flex-1 truncate text-[11.5px] text-muted-foreground",children:n("Topics: {{names}}",{names:e.topics.map(_).join(", ")})}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-group-topics",disabled:i,className:Fi,onClick:T,children:[d.jsx(wv,{className:"size-3.5"}),n("Change topics")]})]}),m&&!o&&d.jsx("p",{className:"text-[11.5px] text-destructive",children:E(m)}),o&&d.jsxs("div",{"data-enso":"secretary-contact-group-picker",className:"flex flex-col gap-1.5 rounded-lg bg-muted/40 px-2.5 py-2",children:[l.state==="loading"&&d.jsxs("p",{className:"flex items-center gap-1.5 text-[11.5px] text-muted-foreground",children:[d.jsx(Wr,{className:"size-3.5 animate-spin"}),n("Loading topics…")]}),l.state==="error"&&d.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[d.jsx("p",{"data-enso":"secretary-contact-topics-error",className:"min-w-0 flex-1 text-[11.5px] text-destructive",children:n("Could not load topics: {{reason}}",{reason:E(l.error,l.detail)})}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-topics-retry",className:Fi,onClick:C,children:[d.jsx(_i,{className:"size-3.5"}),n("Retry")]})]}),l.state==="ready"&&(l.forum?d.jsxs(d.Fragment,{children:[N.map(R=>d.jsx(v0,{enso:"secretary-contact-topic",checked:c.includes(R.id),disabled:O||!!R.owner&&!c.includes(R.id),label:R.owner?`${_(R)} · ${n("taken by {{owner}}",{owner:R.owner})}`:_(R),onClick:()=>u(I=>I.includes(R.id)?I.filter(w=>w!==R.id):[...I,R.id])},R.id)),d.jsx("p",{className:"text-[11px] text-subtle-foreground",children:n("Only topics the bot has seen are listed. If one is missing, send a message in that topic, then refresh. Topics you leave unchecked are ignored.")})]}):d.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:n("This group has no topics, so it can only be bound as a whole.")})),m&&d.jsx("p",{className:"text-[11.5px] text-destructive",children:E(m)}),d.jsxs("div",{className:"flex gap-1.5",children:[l.state==="ready"&&l.forum&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button","data-enso":"secretary-contact-scope-save",disabled:O||c.length===0,className:Fi,onClick:()=>x(c),children:[d.jsx(bi,{className:"size-3.5"}),n("Save")]}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-topics-refresh",disabled:O,className:Fi,onClick:C,children:[d.jsx(_i,{className:"size-3.5"}),n("Refresh")]})]}),d.jsx("button",{type:"button","data-enso":"secretary-contact-topics-cancel",disabled:p,className:Fi,onClick:()=>a(!1),children:n("Cancel")})]})]})]})}const b0="rounded-xl border border-border px-3 py-2.5",_n="inline-flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1.5 text-[12.5px] transition-colors hover:bg-muted disabled:opacity-50";function w0(e){return e?.find(t=>!t.self&&t.privateChat)?.name??null}const y0={"private-owned":'Your private chat with this bot already belongs to secretary "{{owner}}". One person has only one private chat with a bot, so bind this secretary to a group or forum topic below, or give it a different bot.',"route-conflict":'That group or topic already belongs to secretary "{{owner}}". Send the code in another group or topic.',expired:"The code expired. Generate a new one.","missing-code":"The bot got /start without the code. Open the bot with the button or QR code (the link carries the code), or send /start {{code}} yourself."};function S0({bind:e}){const{t}=he(),i=e.rejected;return i?d.jsxs("p",{"data-enso":"secretary-contact-bind-rejected","data-reason":i.reason,className:"mt-2 flex gap-1.5 rounded-lg bg-warning/10 px-2.5 py-2 text-[11.5px] text-warning",children:[d.jsx(Cf,{className:"mt-px size-3.5 shrink-0"}),d.jsx("span",{children:t(y0[i.reason],{owner:i.owner??"",code:e.code})})]}):null}function x0({bind:e,bot:t,now:i,busy:s,onNewCode:r,onCopied:n}){const{t:o}=he(),a=e?e.expiresAt<=i:!1,l=e?Math.max(0,Math.ceil((e.expiresAt-i)/6e4)):0,h=e?.topicCommand??(t?`/bind@${t} ${o("<code>")}`:null);return d.jsxs("ol",{"data-enso":"secretary-contact-bind-places",className:"mt-1.5 flex flex-col gap-1.5",children:[d.jsxs("li",{className:"flex flex-col gap-1 text-[11.5px] text-muted-foreground",children:[d.jsxs("span",{children:[d.jsx("span",{className:"font-medium text-foreground",children:"1."})," ",o("Add the bot to the group: tap the button, or add @{{bot}} as a member in Telegram. For a forum group, turn on Topics first.",{bot:t??"bot"})]}),e?.groupLink&&d.jsxs("a",{"data-enso":"secretary-contact-group-link",href:e.groupLink,target:"_blank",rel:"noreferrer",className:`${_n} self-start text-foreground`,children:[d.jsx(Kn,{className:"size-3.5"}),o("Add the bot to a group")]})]}),d.jsxs("li",{className:"flex flex-col gap-1 text-[11.5px] text-muted-foreground",children:[d.jsxs("span",{children:[d.jsx("span",{className:"font-medium text-foreground",children:"2."})," ",o("Send this in the group to hand the whole group to this secretary, or inside a forum topic to hand over only that topic:")]}),h?d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("code",{"data-enso":"secretary-contact-topic-command",className:"min-w-0 flex-1 truncate rounded bg-muted px-1.5 py-1 font-mono text-[11.5px] text-foreground",children:h}),e&&!a&&d.jsx("button",{type:"button","data-enso":"secretary-contact-copy-topic-command",className:_n,"aria-label":o("Copy"),onClick:()=>{navigator.clipboard.writeText(e.topicCommand??""),n()},children:d.jsx(Fd,{className:"size-3.5"})})]}):d.jsx("span",{className:"text-subtle-foreground",children:o("Verify a bot above first; the binding code shows up here.")}),e&&d.jsxs("span",{"data-enso":"secretary-contact-groups-code",className:a?"text-warning":"text-subtle-foreground",children:[o("Binding code of this secretary: {{code}}",{code:e.code})," ·"," ",a?o("This code has expired"):o("Valid for {{minutes}} more minutes",{minutes:l})]}),t&&(!e||a)&&d.jsxs("button",{type:"button","data-enso":"secretary-contact-groups-new-code",disabled:s,className:`${_n} self-start text-foreground`,onClick:r,children:[d.jsx(xf,{className:"size-3.5"}),o(e?"New code":"Get a binding code")]})]}),d.jsxs("li",{className:"text-[11.5px] text-muted-foreground",children:[d.jsx("span",{className:"font-medium text-foreground",children:"3."})," ",o("Bound groups show up in the list of this section, where you can switch between the whole group and picked topics.")]})]})}function C0({shared:e}){const{t}=he(),i=(e??[]).filter(s=>!s.self).flatMap(s=>s.groups.map(r=>({owner:s.name,group:r})));return i.length===0?null:d.jsxs("div",{className:"mt-2",children:[d.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:t("Claimed by other secretaries on this bot (read only):")}),d.jsx("ul",{className:"mt-1 flex flex-col gap-0.5",children:i.map(({owner:s,group:r})=>d.jsxs("li",{"data-enso":"secretary-contact-group-other",className:"flex items-center gap-1.5 text-[12px] text-muted-foreground",children:[d.jsx(Sc,{className:"size-3 shrink-0"}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:D0(r,t)}),d.jsx("span",{className:"shrink-0 text-[11px]",children:t("belongs to {{owner}}",{owner:s})})]},`${s}:${r.id}`))})]})}function D0(e,t){const i=e.title??e.id;if(e.all)return`${i} · ${t("Whole group")}`;const s=e.topics.map(r=>r.id==="1"?t("General (default topic)"):r.title??t("Topic #{{id}}",{id:r.id})).join(", ");return`${i} · ${t("Topics: {{names}}",{names:s})}`}function k0({shared:e,bot:t}){const{t:i}=he();return d.jsxs("div",{"data-enso":"secretary-contact-shared",className:b0,children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-medium text-muted-foreground",children:[d.jsx(Df,{className:"size-3.5"}),i("@{{bot}} is shared by {{count}} secretaries",{bot:t??"",count:e.length})]}),d.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:i("Each private chat, group or forum topic belongs to one secretary. A topic bound on its own wins over the whole group. Places nobody bound get no reply.")}),d.jsx("ul",{className:"mt-1.5 flex flex-col gap-1.5",children:e.map(s=>{const r=[...s.privateChat?[i("Private chat with @{{name}}",{name:s.privateChat.username??String(s.privateChat.id)})]:[],...s.groups.length>0?[i("Groups and topics: {{count}}",{count:s.groups.length})]:[]];return d.jsxs("li",{"data-enso":"secretary-contact-shared-user","data-self":s.self||void 0,className:"text-[12px]",children:[d.jsx("span",{className:"font-medium",children:s.name}),s.self&&d.jsxs("span",{className:"ml-1 text-[11px] text-muted-foreground",children:["(",i("this secretary"),")"]}),!s.enabled&&d.jsxs("span",{className:"ml-1 text-[11px] text-subtle-foreground",children:["· ",i("Telegram off")]}),r.length===0?d.jsx("p",{className:"text-[11.5px] text-subtle-foreground",children:i("Nothing bound yet")}):d.jsx("ul",{className:"text-[11.5px] text-muted-foreground",children:r.map(n=>d.jsxs("li",{className:"truncate",children:["· ",n]},n))})]},s.secretaryId)})})]})}const P0="https://t.me/BotFather",E0={"token-invalid":"That does not look like a bot token",network:"Cannot reach api.telegram.org. Check the proxy.",unauthorized:"Telegram rejected this token",api:"Telegram returned an error","token-required":"Paste a bot token first","not-bound":"Not bound yet","not-found":"That task is already gone","no-secretary":"No secretary conversation is available","deliver-failed":"Could not reach the secretary session","invalid-chat-id":"Group chat IDs are numbers, e.g. -1001234567890","invalid sender":"Not allowed from this window"},li="rounded-xl border border-border px-3 py-2.5",gt="inline-flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1.5 text-[12.5px] transition-colors hover:bg-muted disabled:opacity-50",bn="inline-flex items-center gap-1.5 rounded-lg bg-foreground px-2.5 py-1.5 text-[12.5px] font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-50";function wn({index:e,label:t}){return d.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-medium text-muted-foreground",children:[d.jsx("span",{className:"flex size-4 items-center justify-center rounded-full bg-muted text-[10px] tabular-nums",children:e}),t]})}const T0={unconfigured:"Not set up",pending:"Waiting to bind",connected:"Connected",error:"Error"},I0={unconfigured:"bg-muted text-muted-foreground",pending:"bg-warning/15 text-warning",connected:"bg-success/15 text-success",error:"bg-destructive/15 text-destructive"},Su="enso.secretary.contact.collapsed";function A0(){try{const e=JSON.parse(window.localStorage.getItem(Su)??"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>t===!0))}catch{return{}}}function R0(e){try{window.localStorage.setItem(Su,JSON.stringify(e))}catch{}}const L0="enso.telegram";function or({label:e,hint:t,checked:i,disabled:s,dataEnso:r,onChange:n}){return d.jsxs("label",{className:"flex items-start gap-2",children:[d.jsx("input",{type:"checkbox","data-enso":r,className:"mt-0.5",checked:i,disabled:s,onChange:o=>n(o.target.checked)}),d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsx("span",{className:"block text-[12.5px]",children:e}),d.jsx("span",{className:"mt-0.5 block text-[11.5px] text-muted-foreground",children:t})]})]})}function N0({channel:e,collapsed:t,busy:i,onToggle:s,onPrefs:r,children:n}){const{t:o}=he(),a=e.id==="telegram",{prefs:l,caps:h}=e,c=[!h.buttons&&o("No buttons: questions and cards arrive as numbered text."),!h.edit&&o("Cannot edit sent messages: answered questions are not marked there."),!h.typing&&o("No typing indicator.")].filter(u=>typeof u=="string");return d.jsxs("div",{"data-enso":"secretary-contact-channel","data-channel":e.id,className:"rounded-xl border border-border",children:[d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[d.jsxs("button",{type:"button","data-enso":"secretary-contact-channel-toggle","aria-expanded":!t,className:"flex min-w-0 flex-1 items-center gap-2 text-left",onClick:s,children:[t?d.jsx(zs,{className:"size-3.5 shrink-0 text-muted-foreground"}):d.jsx(Bi,{className:"size-3.5 shrink-0 text-muted-foreground"}),e.pluginId?d.jsx(da,{pluginId:e.pluginId,icon:e.icon,className:"size-4"}):d.jsx(ya,{className:"size-4 shrink-0"}),d.jsx("span",{className:"truncate text-[13px] font-medium",children:e.title}),d.jsx("span",{className:"shrink-0 rounded bg-muted px-1 text-[10.5px] text-muted-foreground",children:e.builtin?o("Built-in"):o("Plugin")}),d.jsx("span",{"data-enso":"secretary-contact-channel-status",className:Y("shrink-0 rounded px-1 text-[10.5px]",I0[e.status]),children:o(T0[e.status])})]}),d.jsx(Vd,{"data-enso":"secretary-contact-channel-enabled",checked:l.enabled,disabled:i,"aria-label":o("Enable {{name}}",{name:e.title}),onCheckedChange:u=>r({enabled:u})})]}),!t&&d.jsxs("div",{className:"flex flex-col gap-2 border-t border-border px-3 py-2.5",children:[e.detail&&e.status==="error"&&d.jsx("p",{className:"text-[11.5px] text-destructive",children:e.detail}),d.jsx(or,{dataEnso:"secretary-contact-push",label:o("Push to this channel"),hint:o("Milestones, questions from the secretary, cards and approval notices go out here."),checked:l.push,disabled:i,onChange:u=>r({push:u})}),d.jsx(or,{dataEnso:a?"secretary-contact-allow-dispatch":"secretary-contact-card-confirm",label:o(a?"Allow confirming cards from Telegram":"Confirm cards from the phone"),hint:a?o("On by default. A tap on your phone can confirm settings, skill, tool, takeover and cleanup cards. Those cards change which projects the secretary sees, what it may take over, which skills and tools it installs and what it cleans up. Approvals are never handled from Telegram."):h.buttons?o("Off by default. Approvals are never handled from the phone."):o('Off by default. Reply "confirm 1" to confirm a card. Approvals are never handled from the phone.'),checked:l.cardConfirm,disabled:i,onChange:u=>r({cardConfirm:u})}),d.jsx(or,{dataEnso:"secretary-contact-mirror",label:o("Mirror every reply"),hint:o("Off by default. Every reply in the secretary conversation is sent here, not just milestones."),checked:l.syncMirror,disabled:i,onChange:u=>r({syncMirror:u})}),d.jsx(or,{dataEnso:a?"secretary-contact-allow-memory":"secretary-contact-memory",label:o(a?"Allow viewing memory titles on Telegram":"Allow viewing memory titles"),hint:o("Off by default. /memory lists titles only, never the memory text."),checked:l.memory,disabled:i,onChange:u=>r({memory:u})}),c.length>0&&d.jsx("ul",{"data-enso":"secretary-contact-limits",className:"flex flex-col gap-0.5 text-[11.5px] text-subtle-foreground",children:c.map(u=>d.jsxs("li",{children:["· ",u]},u))}),n]})]})}function M0({secretaryId:e}={}){const{t}=he(),[i,s]=b.useState(null),[r,n]=b.useState(""),[o,a]=b.useState(!1),[l,h]=b.useState(null),[c,u]=b.useState(null),[p,f]=b.useState(null),[m,g]=b.useState(A0),[_,E]=b.useState([]),[C,T]=b.useState(""),[x,A]=b.useState(()=>Date.now());b.useEffect(()=>{const W=window.electronAPI.extensionPlugins,ge=()=>{W.list().then(E).catch(()=>E([]))};return ge(),W.onChanged(ge)},[]);const k=W=>{g(ge=>{const X={...ge};return X[W]?delete X[W]:X[W]=!0,R0(X),X})},N=b.useCallback(()=>{window.electronAPI.secretary.contactState(e).then(s)},[e]);b.useEffect(()=>(N(),window.electronAPI.secretary.onContactChanged(W=>{e&&W.secretaryId&&W.secretaryId!==e||s(W)})),[N,e]);const O=i?.telegram.bind?.expiresAt;b.useEffect(()=>{if(O===void 0)return;A(Date.now());const W=window.setInterval(()=>A(Date.now()),15e3);return()=>window.clearInterval(W)},[O]);const z=i?.telegram.bind?.link;b.useEffect(()=>{if(!z){f(null);return}let W=!0;return zg.toDataURL(z,{width:320,margin:1}).then(ge=>{W&&f(ge)}).catch(()=>f(null)),()=>{W=!1}},[z]);const R=W=>{a(!0),h(null),u(null),W().then(ge=>{ge.ok||h(ge.error??"api")}).finally(()=>{a(!1),N()})};if(!i)return null;const I=i.telegram,w=i.channels??[],v=_.some(W=>W.id===L0&&W.state==="enabled"),S=(W,ge)=>R(()=>window.electronAPI.secretary.contactSettings({channelId:W,prefs:ge},e)),D=I.poll.state==="error"||I.poll.state==="backoff",y=I.poll.state!=="stopped"&&I.poll.state!=="error",L=l==="network"&&y?null:l,M=I.groups??[],H=C.trim(),j=(W,ge)=>R(()=>window.electronAPI.secretary.contactSettings({telegramGroup:{action:W,chatId:ge}},e).then(X=>(X.ok&&W==="add"&&T(""),X))),J=I.bind?Math.max(0,Math.ceil((I.bind.expiresAt-x)/6e4)):0,te=I.bind?I.bind.expiresAt<=x:!1,ie=I.chat?null:w0(I.shared),le=d.jsx(x0,{bind:I.bind,bot:I.bot?.username,now:x,busy:o,onNewCode:()=>R(()=>window.electronAPI.secretary.contactBind(void 0,e)),onCopied:()=>u(t("Copied"))}),me=d.jsxs("div",{"data-enso":"secretary-contact-groups",className:li,children:[d.jsx("div",{className:"text-[12px] font-medium text-muted-foreground",children:t("Groups and topics")}),d.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:t("Only groups on this list reach the secretary, and only messages from the bound account count. Messages from anyone else in the group are not received.")}),M.length===0?d.jsxs(d.Fragment,{children:[le,d.jsx("p",{className:"mt-1.5 text-[11.5px] text-subtle-foreground",children:t("No groups yet: group messages are not received.")})]}):d.jsxs(d.Fragment,{children:[d.jsx("ul",{className:"mt-1.5 flex flex-col gap-1",children:M.map(W=>d.jsx(_0,{group:W,secretaryId:e,busy:o,onRemove:()=>j("remove",W.id),onSaved:N},W.id))}),d.jsx("p",{className:"mt-2.5 text-[11.5px] font-medium text-muted-foreground",children:t("Bind another group or topic")}),le]}),d.jsx(C0,{shared:I.shared}),d.jsx("p",{className:"mt-2 text-[11px] text-subtle-foreground",children:t("Or add a group by its chat ID:")}),d.jsxs("form",{className:"mt-1 flex gap-1.5",onSubmit:W=>{if(W.preventDefault(),!!H){if(M.some(ge=>ge.id===H)){T("");return}j("add",H)}},children:[d.jsx("input",{"data-enso":"secretary-contact-group-input",value:C,spellCheck:!1,autoComplete:"off",placeholder:t("Group chat ID, e.g. -1001234567890"),onChange:W=>T(W.target.value),className:"min-w-0 flex-1 rounded-lg border border-border bg-transparent px-2.5 py-1.5 font-mono text-[12px] outline-none focus:border-foreground/40"}),d.jsxs("button",{type:"submit","data-enso":"secretary-contact-group-add",disabled:o||!H,className:gt,children:[d.jsx(Zi,{className:"size-3.5"}),t("Add group")]})]})]}),ne=d.jsxs(d.Fragment,{children:[v&&d.jsx("p",{"data-enso":"secretary-contact-token-conflict",className:"text-[11.5px] text-warning",children:t("The Telegram remote plugin (enso.telegram) is enabled. Do not give both the same bot token: only one place can poll a bot, so they would steal each other's messages.")}),I.status==="bound"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{"data-enso":"secretary-contact-bound",className:li,children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full bg-success/15 text-success",children:d.jsx(bi,{className:"size-3.5"})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"truncate text-[13px] font-medium",children:I.chat?t("Bound to @{{username}}",{username:I.chat.username??String(I.chat.id)}):t("Bound to groups and topics")}),d.jsxs("p",{className:"truncate text-[11.5px] text-muted-foreground",children:[t("Bot @{{bot}}",{bot:I.bot?.username??""}),I.tokenHint?` · ${I.tokenHint}`:""]})]})]}),d.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[d.jsxs("button",{type:"button","data-enso":"secretary-contact-test",disabled:o,className:gt,onClick:()=>R(()=>window.electronAPI.secretary.contactTest(e).then(W=>(W.ok&&u(t("Test message sent")),W))),children:[d.jsx(ya,{className:"size-3.5"}),t("Send a test message")]}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-unbind",disabled:o,className:gt,onClick:()=>R(()=>window.electronAPI.secretary.contactUnbind(e)),children:[d.jsx(Tv,{className:"size-3.5"}),t("Unbind")]}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-replace",disabled:o,className:gt,onClick:()=>R(()=>window.electronAPI.secretary.contactForgetBot(e)),children:[d.jsx(_i,{className:"size-3.5"}),t("Change bot")]})]})]}),me,d.jsx("div",{"data-enso":"secretary-contact-sync",className:Y(li,I.syncMirror&&"border-warning/50 bg-warning/5"),children:I.syncMirror?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-[12.5px] font-medium text-warning",children:[d.jsx(Dv,{className:"size-3.5 shrink-0"}),t("Mirroring every conversation to Telegram")]}),d.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:t("Every reply in the secretary conversation is sent to your phone, not just milestones. Silent turns arrive as a one-line summary. Telegram messages are not end-to-end encrypted and stay on Telegram servers. Send /sync off in Telegram to stop.")})]}):d.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:t("Only milestones go to Telegram. Send /sync in Telegram to mirror every reply; /last replays the latest round.")})}),d.jsxs("div",{"data-enso":"secretary-contact-commands",className:li,children:[d.jsx("div",{className:"text-[12px] font-medium text-muted-foreground",children:t("Commands you can send")}),d.jsx("ul",{className:"mt-1 flex flex-col gap-0.5",children:f0.filter(W=>!W.gated||I.allowMemory).map(W=>d.jsxs("li",{className:"text-[12px]",children:[d.jsxs("code",{className:"rounded bg-muted px-1 text-[11.5px]",children:["/",W.name]})," ",d.jsx("span",{className:"text-muted-foreground",children:t(W.en)})]},W.name))}),d.jsx("p",{className:"mt-1.5 text-[11.5px] text-muted-foreground",children:t("Telegram messages are not end-to-end encrypted and stay on Telegram servers. /status, /board and /feed show titles and short summaries; /last and /sync send conversation text. Memory text and tool output never leave the app.")})]}),!I.secure&&d.jsx("p",{className:"px-1 text-[11.5px] text-warning",children:t("No system keychain available: the bot token is stored unencrypted on this machine.")})]}),I.status==="awaiting-start"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{"data-enso":"secretary-contact-verified",className:li,children:[d.jsx(wn,{index:2,label:t("Bot verified")}),d.jsxs("p",{className:"mt-1 text-[13px] font-medium",children:[I.bot?.name," ",d.jsxs("span",{className:"text-muted-foreground",children:["@",I.bot?.username]})]})]}),d.jsxs("div",{"data-enso":"secretary-contact-code",className:li,children:[d.jsx(wn,{index:3,label:t("Open the bot and press Start")}),d.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[p&&d.jsx("img",{"data-enso":"secretary-contact-qr",src:p,alt:t("Binding QR code"),className:"size-28 shrink-0 rounded-lg bg-white p-1"}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:t("Binding code")}),d.jsx("p",{"data-enso":"secretary-contact-code-value",className:"font-mono text-[22px] tracking-[0.2em] tabular-nums",children:I.bind?.code}),te?d.jsx("p",{"data-enso":"secretary-contact-code-expired",className:"mt-1 text-[11.5px] text-warning",children:t("This code has expired")}):d.jsx("p",{className:"mt-1 text-[11.5px] text-subtle-foreground",children:t("Valid for {{minutes}} more minutes",{minutes:J})})]})]}),d.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[d.jsxs("a",{"data-enso":"secretary-contact-open-bot",href:I.bind?.link,target:"_blank",rel:"noreferrer",className:bn,children:[d.jsx(Kn,{className:"size-3.5"}),t("Open @{{bot}}",{bot:I.bot?.username??""})]}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-copy",className:gt,onClick:()=>{navigator.clipboard.writeText(I.bind?.link??""),u(t("Link copied"))},children:[d.jsx(Fd,{className:"size-3.5"}),t("Copy link")]}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-regenerate",disabled:o,className:te?bn:gt,onClick:()=>R(()=>window.electronAPI.secretary.contactBind(void 0,e)),children:[d.jsx(_i,{className:"size-3.5"}),t("New code")]}),d.jsx("button",{type:"button","data-enso":"secretary-contact-cancel",disabled:o,className:gt,onClick:()=>R(()=>window.electronAPI.secretary.contactCancel(e)),children:t("Cancel")})]}),I.bind&&d.jsx(S0,{bind:I.bind}),ie&&I.bind?.rejected?.reason!=="private-owned"&&d.jsx("p",{"data-enso":"secretary-contact-private-owned",className:"mt-2 text-[11.5px] text-warning",children:t('Your private chat with this bot already belongs to secretary "{{owner}}". Bind this secretary to a group or forum topic instead.',{owner:ie})}),d.jsx("p",{className:"mt-2 text-[11.5px] text-subtle-foreground",children:t("The code works once. Press Start in a private chat with the bot, or send it in a group or forum topic to bind that place to this secretary instead.")})]}),me]}),I.shared&&I.status!=="unbound"&&d.jsx(k0,{shared:I.shared,bot:I.bot?.username}),I.status==="unbound"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{"data-enso":"secretary-contact-step1",className:li,children:[d.jsx(wn,{index:1,label:t("Create a bot with @BotFather")}),d.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:t("Send /newbot, pick a name, and copy the token it gives you.")}),d.jsxs("a",{"data-enso":"secretary-contact-botfather",href:P0,target:"_blank",rel:"noreferrer",className:Y(gt,"mt-2"),children:[d.jsx(Kn,{className:"size-3.5"}),t("Open @BotFather")]}),d.jsx("input",{"data-enso":"secretary-contact-token",type:"password",value:r,spellCheck:!1,autoComplete:"off",placeholder:t("Paste the bot token"),onChange:W=>n(W.target.value),className:"mt-2 w-full rounded-lg border border-border bg-transparent px-2.5 py-1.5 font-mono text-[12px] outline-none focus:border-foreground/40"}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-verify",disabled:o||r.trim().length===0,className:Y(bn,"mt-2"),onClick:()=>R(()=>window.electronAPI.secretary.contactBind(r.trim(),e)),children:[o?d.jsx(Wr,{className:"size-3.5 animate-spin"}):d.jsx(bi,{className:"size-3.5"}),t("Verify and continue")]}),I.bot&&d.jsxs("button",{type:"button","data-enso":"secretary-contact-reconnect",disabled:o,className:Y(gt,"mt-1.5"),onClick:()=>R(()=>window.electronAPI.secretary.contactBind(void 0,e)),children:[d.jsx(_i,{className:"size-3.5"}),t("Bind again with @{{bot}}",{bot:I.bot.username})]})]}),d.jsx("p",{className:"px-1 text-[11.5px] text-subtle-foreground",children:t("The token is stored with the system keychain and never written to logs.")}),me]})]});return d.jsxs("div",{"data-enso":"secretary-contact",className:"flex flex-col gap-2 px-3 py-3",children:[d.jsx("p",{className:"px-1 text-[11.5px] text-muted-foreground",children:t("Reach the secretary from your phone. Milestones go out; your replies come back.")}),d.jsxs("div",{"data-enso":"secretary-contact-master",className:"flex items-center justify-between gap-2 rounded-xl border border-border px-3 py-2",children:[d.jsx("span",{className:"text-[13px] font-medium",children:t("Enable contacts")}),d.jsx(Vd,{"data-enso":"secretary-contact-enabled",checked:i.enabled,disabled:o,"aria-label":t("Enable contacts"),onCheckedChange:W=>R(()=>window.electronAPI.secretary.contactSettings({enabled:W},e))})]}),i.enabled?d.jsxs(d.Fragment,{children:[(L||D)&&d.jsxs("div",{"data-enso":"secretary-contact-error",className:"flex items-start gap-1.5 rounded-lg border border-destructive/40 bg-destructive/5 px-2.5 py-2 text-[12px] text-destructive",children:[d.jsx(ha,{className:"mt-0.5 size-3.5 shrink-0"}),d.jsx("span",{className:"min-w-0 flex-1",children:t(L?E0[L]??"Telegram returned an error":"Cannot reach api.telegram.org. Check the proxy.")})]}),c&&d.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border border-success/40 bg-success/5 px-2.5 py-2 text-[12px] text-success",children:[d.jsx(bi,{className:"size-3.5 shrink-0"}),d.jsx("span",{children:c})]}),w.map(W=>d.jsx(N0,{channel:W,collapsed:m[W.id]===!0,busy:o,onToggle:()=>k(W.id),onPrefs:ge=>S(W.id,ge),children:W.id==="telegram"?ne:W.pluginId&&W.settingsView?d.jsx("div",{"data-enso":"secretary-contact-plugin-view",className:"h-72 overflow-hidden rounded-lg border border-border",children:d.jsx(Zr,{pluginId:W.pluginId,entry:W.settingsView,title:W.title,sessionId:null})}):null},W.id)),d.jsxs("div",{"data-enso":"secretary-contact-following",className:li,children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("div",{className:"text-[12.5px] font-medium",children:t("Followed from the phone: {{count}}",{count:I.following.length})}),I.following.length>0&&d.jsx("button",{type:"button","data-enso":"secretary-contact-following-clear",disabled:o,className:gt,onClick:()=>R(()=>window.electronAPI.secretary.contactFollowing({action:"clear"},e)),children:t("Clear all")})]}),d.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:t("What you dispatch or schedule from the phone keeps reporting here until it finishes or fails once, even with /sync off.")}),I.following.length>0&&d.jsx("ul",{className:"mt-1.5 flex flex-col gap-1",children:I.following.map(W=>d.jsxs("li",{className:"flex items-start justify-between gap-2",children:[d.jsxs("span",{className:"min-w-0 flex-1 text-[12px]",children:[d.jsxs("span",{className:"text-muted-foreground",children:[W.kind==="schedule"?t("Scheduled"):t("Session")," ·"," "]}),W.summary]}),d.jsx("button",{type:"button","data-enso":"secretary-contact-following-cancel",disabled:o,className:gt,onClick:()=>R(()=>window.electronAPI.secretary.contactFollowing({action:"cancel",id:W.id},e)),children:t("Drop")})]},W.id))})]}),d.jsxs("button",{type:"button","data-enso":"secretary-contact-market",className:Y(gt,"self-start"),onClick:()=>{window.electronAPI.window.openSettings({category:"plugins",rowId:"plugins.enso",marketQuery:"contact"})},children:[d.jsx(Ud,{className:"size-3.5"}),t("Find more contact channels in the plugin market")]})]}):d.jsx("p",{className:"px-1 text-[11.5px] text-subtle-foreground",children:t("Contacts are off: nothing is sent or received on any channel.")})]})}const O0=[{key:"running",title:"In progress",dot:"#3b82f6"},{key:"stopped",title:"Stopped",dot:"#64748b",stamp:"Stopped"},{key:"needsYou",title:"Needed you",dot:"#f59e0b",stamp:"Needed you"},{key:"done",title:"What got done",dot:"#10b981",stamp:"Completed"},{key:"failed",title:"Failed or interrupted",dot:"#ef4444",stamp:"Failed"},{key:"todos",title:"To-dos",dot:"#a855f7"},{key:"changes",title:"Settings and capabilities",dot:"#06b6d4"}],G0="flex-none rounded-lg p-1 pb-1.5 bg-[color-mix(in_oklch,var(--muted)_55%,transparent)] shadow-[inset_0_0_0_1px_color-mix(in_oklch,var(--border)_60%,transparent)] @[560px]:w-[260px]",z0="rounded-md border border-border bg-card px-2.5 py-2 shadow-[0_1px_2px_0_rgb(0_0_0/0.05)] transition-[border-color,box-shadow] duration-200 hover:border-foreground/15 hover:shadow-[0_1px_3px_0_rgb(0_0_0/0.08)]",pi="inline-flex h-[18px] max-w-full items-center gap-1 rounded-full bg-foreground/[0.06] px-1.5 font-medium",Sh=Y(pi,"relative shrink-0 text-[11px] leading-none text-muted-foreground transition-colors before:absolute before:inset-x-0 before:-inset-y-1 before:content-[''] hover:bg-foreground/10 hover:text-foreground"),Ir="flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground";function hs(e,t,i){const s=Hr(e,i);if(Ds(e)===t)return s;const r=new Date(e);return`${r.getMonth()+1}/${r.getDate()} ${s}`}function B0({conversationId:e,task:t}){const{t:i}=he(),s=Xm(),r=Jm(t);return d.jsxs("div",{"data-enso":"secretary-daily-leftover-task",className:"flex min-w-0 items-center gap-1.5 py-0.5",children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"truncate font-mono text-[11px] text-foreground/80",title:t.command,children:t.command}),r==="idle"?d.jsx("div",{className:"text-[10.5px] text-warning",children:Zm(t,s,i)}):r==="kept"?d.jsx(Qm,{task:t,className:"text-[10.5px]"}):d.jsx("div",{className:"text-[10.5px] text-muted-foreground tabular-nums",children:i("Running for {{duration}}",{duration:eg(s-t.startedAt)})})]}),r==="idle"&&d.jsx("button",{type:"button",onClick:()=>tg(e,t.taskId,""),className:"shrink-0 rounded-[5px] px-1 text-[11px] text-muted-foreground transition-colors hover:bg-foreground/5 hover:text-foreground",children:i("Keep")}),d.jsx("button",{type:"button","data-enso":"secretary-daily-stop-task",onClick:()=>ig(e,t.taskId),className:"shrink-0 rounded-[5px] px-1 text-[11px] text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",children:i("Stop")})]})}function j0({item:e,column:t,day:i}){const{t:s,locale:r}=he(),[n,o]=b.useState(!1),[a,l]=b.useState(!1),h=e.summary??e.detail,c=e.detail??e.summary,u=e.doneAt!==void 0,p=[e.dispatchedAt!==void 0?`${s("Dispatched")} ${hs(e.dispatchedAt,i,r)}`:"",e.addedAt!==void 0?`${s("Added")} ${hs(e.addedAt,i,r)}`:"",e.doneAt!==void 0?`${s("Done")} ${hs(e.doneAt,i,r)}`:"",t.stamp?`${s(t.stamp)} ${hs(e.at,i,r)}`:""].filter(Boolean),f=e.tracked&&e.manual&&t.key==="done"?"undo":null,m=e.tracked&&(t.key==="running"||t.key==="stopped"),g=t.key==="done"&&e.conversationId?{title:e.title,...c?{fallback:c}:{}}:void 0,_=()=>{e.conversationId&&xa(e.conversationId,g)},E=ue(k=>e.conversationId?k.conversations[e.conversationId]?.backgroundTasks:void 0),C=e.leftover?(E??[]).filter(k=>k.status==="running"):[],T=C.filter(Ym).length,x=e.leftover!==void 0&&E!==void 0&&C.length===0,A=e.leftover&&e.conversationId&&!x&&(C.length===0||T>0)?e.conversationId:null;return d.jsxs("div",{"data-enso":"secretary-daily-card","data-item":e.id,"data-done":u?"true":void 0,className:Y(z0,"group/row relative"),children:[A&&d.jsx(Bs,{className:"from-card",children:d.jsx("button",{type:"button","data-enso":"secretary-daily-stop-leftover",title:s("Stop suspected idle leftover tasks"),"aria-label":s("Stop suspected idle leftover tasks"),disabled:a,onClick:()=>{l(!0),window.electronAPI.secretary.stopTasks(A).finally(()=>l(!1))},className:Y(Ir,"w-auto px-1 text-[11px] hover:bg-destructive/10 hover:text-destructive"),children:s("Stop")})}),(f||m)&&d.jsxs("div",{"data-enso":"secretary-daily-actions",className:"mb-1.5 flex flex-wrap items-center justify-start gap-1",children:[(f||m)&&d.jsxs("button",{type:"button","data-enso":m?"secretary-daily-mark-done":"secretary-daily-mark-undo",title:s(m?"Mark done":"Undo mark done"),"aria-label":s(m?"Mark done":"Undo mark done"),onClick:()=>{e.conversationId&&window.electronAPI.secretary.markResult(e.conversationId,m?"done":"undo")},className:Sh,children:[m?d.jsx(bi,{className:"size-[11px]"}):d.jsx(Sa,{className:"size-[11px]"}),d.jsx("span",{children:s(m?"Mark done":"Undo mark done")})]}),m&&d.jsxs("button",{type:"button","data-enso":"secretary-daily-dismiss",title:s("Move off the board"),"aria-label":s("Move off the board"),onClick:()=>{e.conversationId&&window.electronAPI.secretary.markResult(e.conversationId,"dismiss")},className:Sh,children:[d.jsx(Gs,{className:"size-[11px]"}),d.jsx("span",{children:s("Move off the board")})]})]}),d.jsxs("button",{type:"button","data-enso":"secretary-daily-expand",...g?{"aria-haspopup":"dialog"}:{"aria-expanded":n},onClick:g?_:()=>o(k=>!k),className:"block w-full text-left",children:[d.jsx("span",{className:Y("block text-[12.5px] font-medium leading-[1.45] break-words",u&&"text-muted-foreground line-through"),children:e.title}),h&&d.jsx("span",{className:Y("mt-[3px] block whitespace-pre-wrap break-words text-[12px] text-muted-foreground",n?void 0:"line-clamp-3"),children:n?c:h})]}),C.length>0&&e.conversationId&&d.jsx("div",{"data-enso":"secretary-daily-leftover-tasks",className:"mt-[7px] rounded-[5px] bg-foreground/[0.04] px-1.5 py-1",children:C.map(k=>d.jsx(B0,{conversationId:e.conversationId,task:k},k.taskId))}),d.jsxs("div",{className:"mt-[7px] flex flex-wrap items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.projectName&&d.jsx("span",{className:pi,children:e.projectName}),e.label&&d.jsx("span",{className:pi,children:s(e.label)}),e.leftover&&!x&&d.jsx("span",{"data-enso":"secretary-daily-leftover",className:Y(pi,(C.length===0||T>0)&&"text-warning"),children:C.length>0&&T===0?s("Done ({{count}} kept tasks)",{count:C.length}):s("Done ({{count}} leftover tasks)",{count:C.length||e.leftover.count})}),e.persistent&&d.jsx("span",{"data-enso":"secretary-daily-persistent",className:Y(pi,"text-warning"),children:s("Service running")}),e.branch&&d.jsx("span",{"data-enso":"secretary-daily-branch",className:Y(pi,"font-mono"),children:e.branch}),e.commit&&d.jsx("span",{"data-enso":"secretary-daily-commit",className:Y(pi,"font-mono"),children:e.commit}),e.conversationId&&d.jsxs("button",{type:"button","data-enso":"secretary-daily-open",title:s("Open session"),"aria-label":s("Open session"),onClick:_,className:Y(pi,"cursor-pointer text-foreground transition-colors hover:bg-brand/15 hover:text-brand"),children:[d.jsx(Bg,{className:"size-[11px] shrink-0"}),d.jsx("span",{className:"truncate",children:s("Session")})]}),d.jsx("span",{"data-enso":"secretary-daily-times",className:"tabular-nums",children:p.length>0?p.join(" · "):hs(e.at,i,r)})]})]})}function $0({column:e,items:t,folded:i,onToggleFold:s,day:r}){const{t:n}=he();return d.jsxs("section",{"data-enso":"secretary-daily-column","data-group":e.key,className:G0,children:[d.jsxs("div",{className:"flex min-h-[30px] items-center gap-1 pt-0.5 pb-1.5",children:[d.jsx("button",{type:"button","data-enso":"secretary-daily-fold","aria-expanded":!i,"aria-label":n(i?"Expand":"Collapse"),onClick:s,className:Y(Ir,"size-6"),children:d.jsx(Bi,{className:Y("size-3.5 transition-transform duration-300",i&&"-rotate-90")})}),d.jsx("span",{"aria-hidden":!0,className:"mx-0.5 size-[7px] shrink-0 rounded-full",style:{background:e.dot,boxShadow:`0 0 0 3px color-mix(in oklch, ${e.dot} 18%, transparent)`}}),d.jsx("span",{className:"min-w-0 truncate px-1.5 py-0.5 text-[12.5px] font-semibold",children:n(e.title)}),d.jsx("span",{"data-enso":"secretary-daily-count","data-key":e.key,className:"rounded-full bg-foreground/[0.06] px-1.5 py-0.5 font-mono text-[11px] leading-none tabular-nums text-muted-foreground",children:t.length})]}),!i&&d.jsxs("div",{className:"flex min-h-1.5 flex-col gap-1.5",children:[t.map(o=>d.jsx(j0,{item:o,column:e,day:r},o.id)),t.length===0&&d.jsxs("div",{"data-enso":"secretary-daily-empty-column",className:"flex flex-col items-center gap-1 px-2 pt-3.5 pb-2 text-center text-[11.5px] text-subtle-foreground",children:[d.jsx(qm,{className:"size-5 opacity-60"}),n("No cards yet")]})]})]})}function W0({secretaryId:e}={}){const{t}=he(),[i,s]=b.useState(()=>Ds(Date.now())),[r,n]=b.useState(null),[o,a]=b.useState(()=>new Set),l=Ds(Date.now()),h=b.useCallback(g=>{window.electronAPI.secretary.daily(g,e).then(_=>{_.ok&&n(_.daily)}).catch(()=>{})},[e]);b.useEffect(()=>{h(i)},[i,h]),b.useEffect(()=>{if(i===Ds(Date.now()))return window.electronAPI.secretary.onStateChanged(()=>h(i))},[i,h]);const c=g=>r?.groups.find(_=>_.key===g)?.items??[],u=(r?.groups??[]).reduce((g,_)=>g+_.items.length,0),p=c("done").length,f=r?.counts.dispatched??0,m=g=>a(_=>{const E=new Set(_);return E.has(g)?E.delete(g):E.add(g),E});return d.jsxs("div",{"data-enso":"secretary-daily",className:"@container flex flex-col gap-2 px-3 py-2",children:[d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{type:"button","data-enso":"secretary-daily-prev",title:t("Previous day"),"aria-label":t("Previous day"),onClick:()=>s(g=>bh(g,-1)),className:Ir,children:d.jsx(Kd,{className:"h-3.5 w-3.5"})}),d.jsx("input",{type:"date","data-enso":"secretary-daily-date","aria-label":t("Daily board"),value:i,max:l,onChange:g=>{const _=g.target.value;_&&s(_)},className:"min-w-0 flex-1 rounded-[6px] border border-border bg-transparent px-1.5 py-0.5 text-[12.5px] tabular-nums outline-none focus:border-foreground/30"}),d.jsx("button",{type:"button","data-enso":"secretary-daily-next",title:t("Next day"),"aria-label":t("Next day"),disabled:i>=l,onClick:()=>s(g=>bh(g,1)),className:Y(Ir,"disabled:opacity-40 disabled:hover:bg-transparent"),children:d.jsx(zs,{className:"h-3.5 w-3.5"})}),d.jsxs("span",{"data-enso":"secretary-daily-stat",title:`${t("Dispatched")} / ${t("What got done")} / ${t("All")}`,className:"shrink-0 whitespace-nowrap font-mono text-[11.5px] tabular-nums text-muted-foreground",children:[t("Dispatched")," ",f," · ",p,"/",u]}),d.jsx("button",{type:"button","data-enso":"secretary-daily-today",disabled:i===l,onClick:()=>s(l),className:"shrink-0 rounded-md border border-border px-2 py-0.5 text-[11.5px] whitespace-nowrap transition-colors hover:bg-muted disabled:opacity-40 disabled:hover:bg-transparent",children:t("Today")})]}),d.jsx("div",{"data-enso":"secretary-daily-board",className:"flex flex-col gap-2.5 @[560px]:flex-row @[560px]:items-start @[560px]:overflow-x-auto @[560px]:pb-1",children:O0.map(g=>d.jsx($0,{column:g,items:c(g.key),folded:o.has(g.key),onToggleFold:()=>m(g.key),day:i},g.key))}),r?.earliest&&d.jsx("p",{"data-enso":"secretary-daily-earliest",className:"px-1.5 pt-1 text-[11px] text-subtle-foreground",children:t("Look back to {{day}}",{day:r.earliest})})]})}function H0(e){return`proj:${e}`}const xh=50,F0=10;function V0({item:e,onOpen:t,onEdit:i,onDelete:s,trailing:r,children:n}){return d.jsxs("div",{"data-enso":"secretary-memory-row","data-memory-id":e.id,className:"flex flex-col",children:[d.jsxs("div",{className:Y(Kr,"w-full rounded-lg px-1.5 py-2"),children:[d.jsxs("button",{type:"button","data-enso":"secretary-memory-open",onClick:()=>t(e.id),className:"block w-full min-w-0 text-left",children:[d.jsxs("span",{className:"flex w-full min-w-0 items-baseline gap-1.5",children:[d.jsx("span",{className:"min-w-0 truncate text-[13px]",children:e.title}),d.jsx("span",{className:"shrink-0 text-[11.5px] text-subtle-foreground",children:r})]}),e.contentSummary&&d.jsx("span",{className:"mt-0.5 line-clamp-2 block text-[12px] text-muted-foreground",children:e.contentSummary})]}),d.jsx(Wg,{id:e.id,onEdit:i,onDelete:s})]}),n]})}function U0({secretaryId:e}={}){const{t,locale:i}=he(),s=Et(C=>e?C.states[e]:C.secretary),r=s?.projectId??null,n=s?.profile?.name.trim()||t("Secretary"),o=r?H0(r):null,[a,l]=b.useState([]),[h,c]=b.useState([]),[u,p]=b.useState(null),[f,m]=b.useState(null),[g,_]=b.useState(null);b.useEffect(()=>{if(!o)return;let C=!0;const T=()=>{window.electronAPI.memory.list({spaceId:o,limit:xh,offset:0}).then(A=>C&&l(A.items)),window.electronAPI.memory.list({limit:xh,offset:0}).then(A=>{C&&c(A.items.filter(k=>k.spaceId!==o).slice(0,F0))})};T();const x=window.electronAPI.memory.onChanged(T);return()=>{C=!1,x()}},[o]);const E=(C,T,x)=>d.jsx(V0,{item:C,trailing:T,onOpen:A=>p(u===A?null:A),onEdit:m,onDelete:A=>_([A]),children:u===C.id&&d.jsx(K0,{id:C.id,readOnly:x,onClose:()=>p(null)})},C.id);return d.jsxs("div",{"data-enso":"secretary-memory",className:"flex w-full flex-col gap-2 px-3 py-3",children:[d.jsxs("section",{className:"flex w-full flex-col",children:[d.jsxs("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:[t("{{name}} remembers",{name:n}),a.length>0&&d.jsx("span",{className:"ml-1 tabular-nums",children:a.length})]}),a.length===0?d.jsx("p",{className:"px-1.5 py-2 text-[12px] text-muted-foreground",children:t("The secretary has not saved anything yet.")}):a.map(C=>E(C,yi(Date.parse(C.updatedAt),i),!1))]}),h.length>0&&d.jsxs("section",{className:"flex w-full flex-col",children:[d.jsxs("h3",{className:"flex items-center gap-1.5 px-1.5 pb-0.5 text-[12px] text-subtle-foreground",children:[t("From your projects"),d.jsx(Sc,{className:"size-3"})]}),d.jsx("p",{className:"px-1.5 pb-1 text-[11.5px] text-subtle-foreground",children:t("{{name}} can read these but not change them",{name:n})}),h.map(C=>E(C,C.spaceLabel,!0))]}),d.jsx(jg,{memoryId:f,onClose:()=>m(null)}),d.jsx($g,{ids:g,onClose:()=>_(null),onDeleted:C=>{u&&C.includes(u)&&p(null)}})]})}function K0({id:e,readOnly:t,onClose:i}){const{t:s}=he(),[r,n]=b.useState(null),[o,a]=b.useState(!1);b.useEffect(()=>{let h=!0;return window.electronAPI.memory.detail(e).then(c=>{h&&c&&n(c)}),()=>{h=!1}},[e]);const l=()=>{a(!0),window.electronAPI.memory.archive(e).finally(()=>{a(!1),i()})};return d.jsxs("div",{"data-enso":"secretary-memory-detail",className:"mx-1.5 mb-1 rounded-lg border border-border px-2.5 py-2",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] text-muted-foreground",children:r?.spaceLabel??""}),!t&&d.jsx("button",{type:"button",disabled:o,onClick:l,className:"rounded-md px-2 py-0.5 text-[12px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50",children:s("Archive")}),d.jsx("button",{type:"button",onClick:i,className:"rounded-md px-2 py-0.5 text-[12px] text-muted-foreground hover:bg-muted hover:text-foreground",children:s("Close")})]}),d.jsx("pre",{className:"mt-1 max-h-64 overflow-auto text-[12px] whitespace-pre-wrap text-muted-foreground",children:r?.content})]})}const uo="shrink-0 rounded px-1 py-px text-[10px]",q0={failed:{label:"Failed",className:"bg-destructive/15 text-destructive"},waiting:{label:"Waiting for you",className:"bg-warning/15 text-warning"},running:{label:"Running",className:"bg-success/15 text-success"},background:{label:"Waiting on a background task",className:"bg-warning/15 text-warning"},persistent:{label:"Service running",className:"bg-warning/15 text-warning"},continuing:{label:"Continuing",className:"bg-success/15 text-success"},interrupted:{label:"Interrupted",className:"bg-warning/15 text-warning"},stalled:{label:"Stalled, no activity",className:"bg-destructive/15 text-destructive"},idle:{label:"Idle",className:"bg-muted text-muted-foreground"}};function Y0(e){return q0[m0({...e,stalled:e.stalled!==void 0})]}function X0({card:e}){const{t,locale:i}=he(),s=Ue(l=>l.providers)??[],[r,n]=b.useState(!1),o=Y0(e),a=sg(s,e.model);return d.jsxs("div",{"data-enso":"secretary-running-row","data-conversation":e.conversationId,"data-open":r?"true":"false",className:Y(Kr,"flex items-start gap-2 rounded-lg px-1.5 py-1.5"),children:[d.jsxs("button",{type:"button","data-enso":"secretary-running-expand","aria-expanded":r,onClick:()=>n(l=>!l),className:"min-w-0 flex-1 text-left",children:[d.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[d.jsx("span",{"data-enso":"secretary-running-badge",className:Y(uo,o.className),children:t(o.label)}),e.takeover&&d.jsx("span",{"data-enso":"secretary-running-takeover",className:Y(uo,"bg-primary/10 text-primary"),children:t("Taken over")}),d.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px]",children:e.title||t("Unnamed")})]}),d.jsxs("span",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-[11.5px] text-muted-foreground",children:[d.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 text-[11px]",children:e.projectName}),d.jsx("span",{className:"shrink-0 tabular-nums",children:yi(e.stateSince,i)})]}),(e.branch||e.baseRef)&&d.jsxs("span",{"data-enso":"secretary-running-base",className:"mt-0.5 block truncate text-[11.5px] text-subtle-foreground",children:[e.branch??"",e.baseRef?` · ${t("from {{ref}}",{ref:e.baseRef})}`:""]}),a&&d.jsx("span",{"data-enso":"secretary-running-model",className:"mt-0.5 block truncate text-[11.5px] text-subtle-foreground",children:t("Model: {{model}}",{model:a})}),e.lastText&&d.jsx("span",{className:Y("mt-0.5 block text-[12px] text-muted-foreground",r?"whitespace-pre-wrap break-words":"truncate"),children:e.lastText}),r&&d.jsx("span",{className:"mt-1 block text-[11.5px] text-subtle-foreground",children:t("Started {{time}}",{time:yi(e.startedAt,i)})})]}),d.jsx(Bs,{className:"pr-7",children:d.jsx("button",{type:"button","data-enso":"secretary-running-mark-done",title:t("Mark done"),"aria-label":t("Mark done"),onClick:l=>{l.stopPropagation(),window.electronAPI.secretary.markResult(e.conversationId,"done")},className:"flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-success/10 hover:text-success",children:d.jsx(bi,{className:"h-3.5 w-3.5"})})}),d.jsx("button",{type:"button","data-enso":"secretary-running-open",title:t("Open session"),"aria-label":t("Open session"),onClick:l=>{l.stopPropagation(),xa(e.conversationId)},className:"relative flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:d.jsx(pc,{className:"h-3.5 w-3.5"})})]})}function J0({pending:e}){const{t,locale:i}=he(),s=e.draft.title?.trim()||e.draft.prompt.split(`
|
|
8
|
+
`)[0]?.trim()||"";return d.jsx("div",{"data-enso":"secretary-running-pending","data-pending":e.id,className:"flex items-start gap-2 rounded-lg px-1.5 py-1.5",children:d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[d.jsx("span",{"data-enso":"secretary-running-badge",className:Y(uo,"bg-warning/15 text-warning"),children:t("Waiting for dependencies")}),d.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px]",children:s||t("Unnamed")})]}),d.jsxs("span",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-[11.5px] text-muted-foreground",children:[d.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 text-[11px]",children:e.projectId}),d.jsx("span",{className:"shrink-0 tabular-nums",children:yi(e.updatedAt,i)})]}),d.jsx("span",{"data-enso":"secretary-running-after",className:"mt-0.5 block truncate text-[11.5px] text-subtle-foreground",children:t("After {{ids}}",{ids:e.after.join(", ")})})]})})}function Z0({secretaryId:e}={}){const{t}=he(),i=Et(s=>(e?s.states[e]??(s.focusedId===e?s.secretary:void 0):s.secretary)?.board.running??[]);return d.jsxs("section",{"data-enso":"secretary-running",className:"flex flex-col px-3 pt-2",children:[d.jsxs("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:[t("In progress"),d.jsx("span",{className:"ml-1 tabular-nums",children:i.length})]}),i.length===0?d.jsx("p",{"data-enso":"secretary-running-empty",className:"px-1.5 py-1 text-[12px] text-muted-foreground",children:t("Nothing running")}):i.map(s=>s.kind==="session"?d.jsx(X0,{card:s},s.conversationId):s.kind==="pending"?d.jsx(J0,{pending:s.pending},s.pending.id):null)]})}function Q0(e){return e.system==="daily-brief"?d.jsx(Pv,{className:"size-3.5"}):e.system?d.jsx(rg,{className:"size-3.5"}):e.at?d.jsx(ng,{className:"size-3.5"}):d.jsx(og,{className:"size-3.5"})}const Ch=(e,t)=>`${yi(e,t)} ${Hr(e,t)}`;function ey(e,t,i){const s=[];return e.system==="daily-brief"?s.push(t("Every day at {{time}}",{time:Hr(e.nextRunAt??Date.now(),i)})):(s.push(e.system?t("From a to-do"):e.at?t("One-off"):t("Repeats")),e.nextRunAt!==void 0&&s.push(Ch(e.nextRunAt,i))),e.lastFiredAt!==void 0&&s.push(t("Last run {{time}}",{time:Ch(e.lastFiredAt,i)})),s.join(" · ")}function Dh({schedule:e,onRemove:t}){const{t:i,locale:s}=he();return d.jsxs("div",{"data-enso":"secretary-schedule","data-system":e.system!==void 0||void 0,className:Y(Kr,"flex items-start gap-2.5 rounded-lg px-1.5 py-2"),children:[d.jsx("span",{className:"mt-0.5 flex size-4 shrink-0 items-center justify-center text-subtle-foreground",children:Q0(e)}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"truncate text-[13px]",children:e.name}),d.jsx("p",{className:"mt-0.5 text-[11.5px] text-muted-foreground",children:ey(e,i,s)})]}),t&&d.jsx(Bs,{children:d.jsx("button",{type:"button",title:i("Delete"),"aria-label":i("Delete"),onClick:()=>t(e.id),className:"flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-muted hover:text-destructive",children:d.jsx(ca,{className:"size-3.5"})})})]})}function ty({schedules:e,name:t,onReload:i,secretaryId:s}){const{t:r}=he(),n=e.filter(l=>l.system!==void 0),o=e.filter(l=>l.system===void 0),a=l=>{window.electronAPI.secretary.removeSchedule(l,s).then(i)};return d.jsxs("div",{"data-enso":"secretary-schedules",className:"flex flex-col gap-1 px-3 py-3",children:[n.length>0&&d.jsxs("section",{className:"flex flex-col",children:[d.jsx("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:r("System")}),n.map(l=>d.jsx(Dh,{schedule:l},l.id))]}),o.length>0&&d.jsxs("section",{className:"flex flex-col",children:[d.jsx("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:r("Scheduled by {{name}}",{name:t})}),o.map(l=>d.jsx(Dh,{schedule:l,onRemove:a},l.id))]}),d.jsx("p",{className:"px-1.5 pt-2 text-[11.5px] text-subtle-foreground",children:r("To add a schedule, just tell {{name}}",{name:t})})]})}const iy="w-full border-b border-border/60 px-3 py-2 text-left last:border-b-0";function sy({secretaryId:e}={}){const{t}=he(),[i,s]=b.useState([]),[r,n]=b.useState(null),[o,a]=b.useState(null),[l,h]=b.useState(null),[c,u]=b.useState(null),[p,f]=b.useState(!1),m=Ue(k=>k.skills),g=Et(k=>e?k.states[e]?.profile:k.secretary.profile),_=`${(g?.skillIds??[]).join(",")}|${(g?.disabledSkillNames??[]).join(",")}`,E=b.useCallback(async()=>{const k=await window.electronAPI.secretary.listSkills(e);k.ok?(s(k.skills),n(null)):n(k.error)},[e]);b.useEffect(()=>{E()},[E,_,m]);const C=async k=>{if(o===k.id){a(null),h(null);return}if(a(k.id),h(k.body??null),k.body!==void 0)return;const N=await window.electronAPI.secretary.readSkill({id:k.id,source:k.source},e);h(N.ok?N.body:null)},T=async k=>{f(!0);const N=await window.electronAPI.secretary.setSkillEnabled({id:k.id,source:k.source,enabled:!k.enabled},e);if(f(!1),!N.ok){n(N.error);return}await E()},x=async k=>{f(!0);const N=await window.electronAPI.secretary.removeSkill(k.id,e);if(f(!1),u(null),!N.ok){n(N.error);return}o===k.id&&(a(null),h(null)),await E()};if(r)return d.jsx("p",{className:"px-3 py-3 text-xs text-destructive",children:r});if(i.length===0)return d.jsx("p",{"data-enso":"secretary-skills-empty",className:"px-3 py-3 text-xs text-muted-foreground",children:t("The secretary has no skills yet. Ask it to propose one.")});const A=[{key:"own",title:t("Own skills"),items:i.filter(k=>k.source==="own")},{key:"global",title:t("Shared global skills"),items:i.filter(k=>k.source==="global")}];return d.jsx("div",{"data-enso":"secretary-skills",className:"flex flex-col gap-3 px-3 py-3",children:A.map(k=>d.jsxs("section",{"data-enso":"secretary-skill-group","data-group":k.key,children:[d.jsxs("p",{className:"mb-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase",children:[k.title,d.jsx("span",{className:"ml-1 tabular-nums",children:k.items.length})]}),k.items.length===0?d.jsx("p",{className:"text-[11.5px] text-subtle-foreground",children:t("Nothing here yet")}):d.jsx("div",{className:"rounded-md border",children:k.items.map(N=>d.jsxs("div",{"data-enso":"secretary-skill-row","data-source":N.source,"data-enabled":N.enabled?"true":"false",className:iy,children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("button",{type:"button","data-enso":"secretary-skill-expand",onClick:()=>{C(N)},className:"flex min-w-0 flex-1 items-center gap-1 text-left",children:[d.jsx(zs,{className:Y("size-3 shrink-0 text-muted-foreground transition-transform",o===N.id&&"rotate-90")}),d.jsx("span",{className:"truncate font-mono text-[12.5px]",children:N.name}),d.jsx("span",{className:Y("shrink-0 rounded px-1 text-[10px]",N.enabled?"bg-muted text-muted-foreground":"bg-warning/10 text-warning"),children:N.enabled?t("Enabled"):t("Disabled")})]}),d.jsx("button",{type:"button","data-enso":"secretary-skill-toggle",disabled:p,onClick:()=>{T(N)},className:"shrink-0 rounded px-1.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:N.enabled?t("Disable"):t("Enable")}),N.source==="own"&&d.jsx("button",{type:"button","data-enso":"secretary-skill-delete",disabled:p,onClick:()=>u(N.id),"aria-label":t("Delete"),className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-destructive",children:d.jsx(ca,{className:"size-3.5"})})]}),N.description&&d.jsx("p",{className:"mt-0.5 truncate text-[11.5px] text-muted-foreground",children:N.description}),c===N.id&&d.jsxs("div",{"data-enso":"secretary-skill-confirm",className:"mt-1.5 flex items-center gap-2 rounded bg-destructive/5 px-2 py-1.5",children:[d.jsx("span",{className:"min-w-0 flex-1 text-[11.5px]",children:t("Delete this skill?")}),d.jsx("button",{type:"button","data-enso":"secretary-skill-confirm-delete",disabled:p,onClick:()=>{x(N)},className:"rounded bg-destructive px-2 py-0.5 text-[11px] text-destructive-foreground",children:t("Delete")}),d.jsx("button",{type:"button","data-enso":"secretary-skill-confirm-cancel",onClick:()=>u(null),className:"rounded px-2 py-0.5 text-[11px] text-muted-foreground hover:bg-muted",children:t("Cancel")})]}),o===N.id&&d.jsxs("div",{"data-enso":"secretary-skill-body",className:"mt-1.5 rounded border border-dashed border-border bg-muted/20 px-2 py-1.5",children:[d.jsx("p",{className:"mb-1 text-[10.5px] text-subtle-foreground",children:t("Shown for you only: this content is not an instruction to the secretary.")}),l===null?d.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:t("Unavailable")}):d.jsx("div",{className:"max-h-72 overflow-auto text-[12px]",children:d.jsx(kf,{text:l})})]})]},`${N.source}:${N.id}`))})]},k.key))})}const ry=new Set(["goal-complete","turn-ended"]);function ny(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function oy(e){const t=new Date(e).getHours();return t<12?"Good morning":t<18?"Good afternoon":"Good evening"}function ay(e,t){const i=[...e.needsYou,...e.running,...e.done].filter(n=>n.kind==="session"),s=ny(t),r=i.filter(n=>(n.resultAt??0)>=s);return{greeting:oy(t),today:{dispatched:i.filter(n=>n.startedAt>=s).length,completed:r.filter(n=>n.result!==void 0&&ry.has(n.result)).length,failed:r.filter(n=>n.result==="failed").length},counts:{needsYou:e.needsYou.length,running:e.running.length,todos:e.todos.filter(n=>(n.phase??"todo")==="todo").length},events:Bv(e)}}const ly=8;function hy(e){const[t,i]=b.useState([]),[s,r]=b.useState(0),[n,o]=b.useState(!0),[a,l]=b.useState(!1),[h,c]=b.useState(!1),[u,p]=b.useState(null),f=b.useRef(null),m=b.useRef(t),g=b.useRef([]),_=b.useRef(void 0),E=b.useRef(!1),C=b.useRef(!1),T=b.useRef(!1),x=b.useRef(0);m.current=t;const A=b.useCallback(I=>{f.current=I,p(I)},[]),k=b.useCallback(()=>f.current?.closest('[data-enso="secretary-panel-scroll"]'),[]),N=b.useCallback(()=>{const I=k();return I?(I.scrollTop||0)<=ly:!0},[k]),O=b.useCallback(async()=>{const I=++x.current,w=new Set(m.current.map(H=>H.id)),v=[];let S,D=!1;for(let H=0;H<20;H+=1){const j=await window.electronAPI.secretary.feed({...S?{before:S}:{},limit:Pl},e);if(I!==x.current)return;if(!j.ok){T.current||o(!1);return}v.push(...j.events),D=j.hasMore;const J=j.events.some(ie=>w.has(ie.id));if(w.size===0||J||!D||j.events.length===0)break;const te=j.events.at(-1);if(!te)break;S={at:te.at,id:te.id}}if(I!==x.current)return;const y=N(),L=m.current.length===0,M=pn(m.current,v,y);if(g.current=y?[]:M.pending,r(g.current.length),i(H=>pn(H,v,y).events),L){const H=v.at(-1);H&&(_.current={at:H.at,id:H.id}),C.current=!D,l(!D)}T.current||(T.current=!0,c(!0),o(!1))},[N,e]),z=b.useCallback(async()=>{const I=_.current;if(!(!I||E.current||C.current)){E.current=!0,o(!0);try{const w=await window.electronAPI.secretary.feed({before:I,limit:Pl},e);if(!w.ok)return;i(S=>jv(S,w.events));const v=w.events.at(-1);v&&(_.current={at:v.at,id:v.id}),C.current=!w.hasMore,l(!w.hasMore)}finally{E.current=!1,o(!1)}}},[e]);return b.useEffect(()=>{let I=!0;const w=()=>{I&&O()};w();const v=window.electronAPI.secretary.onStateChanged(w);return()=>{I=!1,v()}},[O]),b.useEffect(()=>{const I=u,w=k();if(!I||!w||!h||a||typeof IntersectionObserver!="function")return;const v=()=>{const D=w.getBoundingClientRect(),y=I.getBoundingClientRect();D.height>0&&y.top<=D.bottom+80&&z()},S=new IntersectionObserver(D=>{D.some(y=>y.isIntersecting)&&z()},{root:w,rootMargin:"80px"});return S.observe(I),w.addEventListener("scroll",v,{passive:!0}),()=>{S.disconnect(),w.removeEventListener("scroll",v)}},[a,z,h,k,u]),{events:t,freshCount:s,loading:n,exhausted:a,sentinelRef:A,reveal:()=>{const I=g.current;if(I.length===0)return;i(v=>pn(v,I,!0).events),g.current=[],r(0);const w=k();w&&(w.scrollTop=0)}}}function Ai(e,t){window.electronAPI.secretary.mutateTodo(e,t)}function dy(e,t,i){return new Date(e).toDateString()===new Date(i).toDateString()?Hr(e,t):yi(e,t,i)}const cy={ok:"border-success bg-success",warn:"border-warning bg-warning",bad:"border-destructive bg-destructive",run:"border-success bg-background",idle:"border-subtle-foreground bg-background"},Yi="flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",uy={running:"Running",waiting:"Waiting for you",idle:"Idle",error:"Failed","not-started":"Not started",gone:"The session was deleted"},py={failed:"The session failed",stopped:"The session was stopped",deleted:"The session was deleted"};function yn({value:e,label:t,warn:i}){return d.jsxs("div",{"data-enso":"secretary-stat","data-warn":i||void 0,className:Y("rounded-[10px] border px-2.5 py-2",i?"border-warning/40 bg-warning/5":"border-border"),children:[d.jsx("div",{className:"text-[18px] font-semibold tabular-nums",children:e}),d.jsx("div",{className:"text-[11.5px] text-muted-foreground",children:t})]})}function fy({pending:e}){const{t}=he(),i=e.draft.title?.trim()||e.draft.prompt.split(`
|
|
9
|
+
`)[0]?.trim()||"";return d.jsxs("div",{"data-enso":"secretary-pending-problem","data-problem":e.problem??"dispatch-failed",className:"rounded-xl border border-warning/40 bg-warning/5 px-3 py-2.5",children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-[11.5px] font-medium text-warning",children:[d.jsx(ha,{className:"size-3.5 shrink-0"}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:t(my[e.problem??"dispatch-failed"])})]}),d.jsx("p",{className:"mt-1 text-[13px] font-medium",children:i}),d.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:t("Waited for {{ids}}",{ids:e.after.join(", ")})})]})}const my={"dependency-failed":"A dependency failed","dependency-stopped":"A dependency was stopped","dependency-deleted":"A dependency was deleted","dispatch-failed":"The dispatch could not start",cancelled:"The dispatch was cancelled"};function gy({card:e}){const{t,locale:i}=he(),s=fc(),r=ue(u=>u.conversations[e.conversationId]?.pendingApprovals),n=ue(u=>u.conversations[e.conversationId]?.pendingAsks),[o,a]=b.useState(!1),l=()=>{a(!0),window.electronAPI.agent.abort(e.conversationId).finally(()=>a(!1))},h=e.state!=="waiting"&&e.result!==void 0&&Av.has(e.result),c=Cc(e);return d.jsxs("div",{"data-enso":"secretary-card","data-kind":"session","data-state":e.state,className:"rounded-xl border border-warning/40 bg-warning/5 px-3 py-2.5",children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-[11.5px] font-medium text-warning",children:[s&&d.jsx(qd,{name:s.name,color:s.color,image:s.image,enso:"secretary-card-avatar",className:"size-4 rounded-[5px] text-[9px]"}),d.jsx(ha,{className:"size-3.5 shrink-0"}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:t(c.label)}),d.jsx("span",{className:"shrink-0 font-normal text-subtle-foreground",children:yi(c.at,i)})]}),d.jsx("p",{className:"mt-1 text-[13px] font-medium",children:e.title}),d.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 text-[12px] text-muted-foreground",children:[d.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 text-[11px]",children:e.projectName}),e.lastText&&d.jsx("span",{className:"line-clamp-1",children:e.lastText})]}),r&&r.length>0&&d.jsx("div",{className:"mt-2",children:d.jsx(mc,{approvals:r,onRespond:(u,p)=>{window.electronAPI.agent.respondApproval(e.conversationId,u,p)}})}),n&&n.length>0&&d.jsx("div",{className:"mt-2",children:d.jsx(gc,{asks:n,autoFocus:!1,onAnswer:(u,p)=>{window.electronAPI.agent.respondAsk(e.conversationId,u,p)}})}),d.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[d.jsx("button",{type:"button","data-enso":"secretary-card-open",onClick:()=>vc(e.conversationId),className:"rounded-md bg-primary px-2.5 py-1 text-[12px] text-primary-foreground transition-colors hover:bg-primary/90",children:t("Open session")}),h&&d.jsx("button",{type:"button","data-enso":"secretary-dismiss-result",onClick:()=>{window.electronAPI.secretary.dismissResult(e.conversationId)},className:"rounded-md px-2.5 py-1 text-[12px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:t("Got it")}),e.state==="running"&&d.jsx("button",{type:"button",disabled:o,onClick:l,className:"rounded-md px-2.5 py-1 text-[12px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50",children:t("Stop")})]})]})}function Sn({todo:e,secretaryId:t}){const{t:i,locale:s}=he(),[r,n]=b.useState(null),o=e.phase??"todo",a=!!e.conversationId;return r!==null?d.jsx("div",{className:"rounded-lg border border-border px-2.5 py-1.5",children:d.jsx("input",{autoFocus:!0,value:r,onChange:l=>n(l.target.value),onKeyDown:l=>{if(l.key==="Escape"&&n(null),l.key!=="Enter")return;const h=r.trim();h&&Ai({action:"update",todoId:e.id,text:h},t),n(null)},className:"w-full bg-transparent text-[13px] outline-none"})}):d.jsxs("div",{"data-enso":"secretary-todo","data-phase":o,"data-session":e.conversationId,draggable:o!=="todo",onDragStart:l=>{l.dataTransfer.setData("text/plain",e.id),l.dataTransfer.effectAllowed="move"},className:Y(Kr,"flex items-start gap-2.5 rounded-lg px-1.5 py-1.5"),children:[d.jsx("button",{type:"button","data-enso":"secretary-todo-done","aria-label":i("Mark done"),onClick:()=>Ai({action:"update",todoId:e.id,done:!0},t),className:"mt-[3px] size-3.5 shrink-0 rounded-full border-[1.5px] border-foreground/30 transition-colors hover:border-success hover:bg-success/20"}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"text-[13px]",children:e.text}),o!=="todo"&&d.jsxs("button",{type:"button","data-enso":"secretary-todo-session",disabled:!a,onClick:()=>{e.conversationId&&xa(e.conversationId)},className:"mt-0.5 block max-w-full truncate text-left text-[12px] text-muted-foreground hover:text-foreground disabled:cursor-default",children:[e.sessionTitle||i("Open session"),e.sessionState?` · ${i(uy[e.sessionState])}`:""]}),o==="problem"&&e.problem&&d.jsx("p",{"data-enso":"secretary-todo-problem",className:"mt-0.5 text-[11.5px] text-destructive",children:i(py[e.problem])}),e.dueAt!==void 0&&d.jsx("p",{className:"mt-0.5 text-[11.5px] text-subtle-foreground",children:yi(e.dueAt,s)})]}),d.jsxs(Bs,{children:[o==="todo"?d.jsx("button",{type:"button","data-enso":"secretary-todo-dispatch",title:i("Dispatch"),"aria-label":i("Dispatch"),onClick:()=>Ai({action:"dispatch",todoId:e.id},t),className:Yi,children:d.jsx(ya,{className:"h-3.5 w-3.5"})}):d.jsx("button",{type:"button","data-enso":"secretary-todo-reopen",title:i("Back to to-do"),"aria-label":i("Back to to-do"),onClick:()=>Ai({action:"reopen",todoId:e.id},t),className:Yi,children:d.jsx(Sa,{className:"h-3.5 w-3.5"})}),d.jsx("button",{type:"button",title:i("Edit"),"aria-label":i("Edit"),onClick:()=>n(e.text),className:Yi,children:d.jsx(Pf,{className:"h-3.5 w-3.5"})}),d.jsx("button",{type:"button",title:i("Delete"),"aria-label":i("Delete"),onClick:()=>Ai({action:"remove",todoId:e.id},t),className:Yi,children:d.jsx(ca,{className:"h-3.5 w-3.5"})})]})]})}function kh({onClose:e,secretaryId:t}){const{t:i}=he(),[s,r]=b.useState(""),n=()=>{const o=s.trim();o&&Ai({action:"add",text:o},t),e()};return d.jsx("div",{className:"rounded-lg border border-border px-2.5 py-1.5",children:d.jsx("input",{autoFocus:!0,value:s,placeholder:i("Add a to-do"),onChange:o=>r(o.target.value),onBlur:n,onKeyDown:o=>{o.key==="Escape"&&e(),o.key==="Enter"&&n()},className:"w-full bg-transparent text-[13px] outline-none"})})}function vy({onAdd:e}){const{t}=he();return d.jsxs("button",{type:"button",onClick:e,className:"flex items-center gap-2.5 rounded-lg px-1.5 py-1.5 text-[13px] text-subtle-foreground transition-colors hover:bg-foreground/5 hover:text-muted-foreground",children:[d.jsx(Zi,{className:"size-3.5 shrink-0"}),t("Add a to-do")]})}function _y({event:e}){const{t,locale:i}=he(),s=fc(),[r,n]=b.useState(!1),[o,a]=b.useState(!1),l=e.conversationId,h=l?()=>vc(l):void 0,c=l?()=>{n(!0),window.electronAPI.agent.abort(l).finally(()=>n(!1))}:void 0;return d.jsxs("div",{"data-enso":"secretary-feed-event","data-id":e.id,"data-tone":e.tone,className:"group/row relative flex items-start gap-2 py-1 pl-4",children:[d.jsx("span",{"aria-hidden":!0,className:Y("absolute top-[9px] left-0 size-2 -translate-x-1/2 rounded-full border-[1.5px]",cy[e.tone])}),s&&d.jsx(qd,{name:s.name,color:s.color,image:s.image,enso:"secretary-feed-avatar",className:"mt-0.5 size-4 shrink-0 rounded-[5px] text-[9px]"}),d.jsxs("button",{type:"button","data-enso":"secretary-feed-expand","aria-expanded":o,onClick:()=>a(u=>!u),className:"min-w-0 flex-1 text-left",children:[d.jsxs("span",{className:"block text-[11px] text-subtle-foreground",children:[dy(e.at,i,Date.now()),e.projectName?` · ${e.projectName}`:""]}),d.jsx("span",{className:"mt-0.5 block truncate text-[13px]",children:e.title}),d.jsx("span",{className:Y("mt-0.5 block text-[12px] text-muted-foreground",o?"whitespace-pre-wrap break-words":"line-clamp-2"),children:e.detail?`${t(e.label)} · ${e.detail}`:t(e.label)})]}),e.running&&c&&d.jsx(Bs,{className:"from-background pr-7",children:d.jsx("button",{type:"button","data-enso":"secretary-feed-stop",title:t("Stop"),"aria-label":t("Stop"),disabled:r,onClick:u=>{u.stopPropagation(),c()},className:Y(Yi,"hover:bg-destructive/10 hover:text-destructive"),children:d.jsx(Yd,{className:"h-3.5 w-3.5"})})}),h&&d.jsx("button",{type:"button","data-enso":"secretary-feed-open",title:t("Open session"),"aria-label":t("Open session"),onClick:u=>{u.stopPropagation(),h()},className:Y(Yi,"relative"),children:d.jsx(pc,{className:"h-3.5 w-3.5"})})]})}function by({name:e,onAdd:t}){const{t:i}=he();return d.jsxs("div",{"data-enso":"secretary-empty",className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 py-14 text-center",children:[d.jsx("span",{className:"flex size-11 items-center justify-center rounded-[14px] bg-muted text-subtle-foreground",children:d.jsx(cv,{className:"size-5"})}),d.jsx("p",{className:"text-[13.5px] font-medium",children:i("Nothing on your plate")}),d.jsx("p",{className:"text-[12px] text-muted-foreground",children:i("Ask {{name}} for work in the chat, or note a to-do first",{name:e})}),d.jsxs("button",{type:"button",onClick:t,className:"mt-2 flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-[12px] transition-colors hover:bg-muted",children:[d.jsx(Zi,{className:"size-3.5"}),i("Add a to-do")]})]})}function wy({name:e,secretaryId:t}){const{t:i}=he(),s=Et(w=>t?w.states[t]?.board??w.secretary.board:w.secretary.board),r=Et(w=>w.secretaries),[n,o]=b.useState("own"),[a,l]=b.useState("all"),[h,c]=b.useState(null);b.useEffect(()=>{if(n!=="all")return;let w=!0;return window.electronAPI.secretary.overview().then(v=>{w&&v.ok&&c(v.boards)}),()=>{w=!1}},[n]);const u=b.useMemo(()=>{if(n!=="all"||!h)return s;const w=a==="all"?h:h.filter(v=>v.secretaryId===a);return{needsYou:w.flatMap(v=>v.board.needsYou),running:w.flatMap(v=>v.board.running),todos:w.flatMap(v=>v.board.todos),done:w.flatMap(v=>v.board.done)}},[n,h,a,s]),p=Et(w=>w.focusProposal),[f,m]=b.useState(!1),[g,_]=b.useState(null),E=ay(u,Date.now()),C=hy(t),T=u.needsYou.length+u.running.length+u.todos.length+u.done.length===0;if(b.useEffect(()=>{if(!p)return;_(p.proposalId),document.querySelector(`[data-enso=secretary-proposal-focus][data-proposal-id="${p.proposalId}"]`)?.scrollIntoView({block:"center",behavior:"smooth"});const v=setTimeout(()=>{_(null),Et.getState().clearFocusProposal()},2400);return()=>clearTimeout(v)},[p]),T)return f?d.jsx("div",{className:"px-3 py-3",children:d.jsx(kh,{onClose:()=>m(!1),secretaryId:t})}):d.jsx(by,{name:e,onAdd:()=>m(!0)});const{dispatched:x,completed:A,failed:k}=E.today,N=x+A+k===0?i("Nothing dispatched today"):i("Today {{dispatched}} dispatched, {{completed}} completed, {{failed}} failed",{dispatched:x,completed:A,failed:k}),O=u.todos.filter(w=>w.phase==="active"),z=u.todos.filter(w=>w.phase==="problem"),R=u.todos.filter(w=>(w.phase??"todo")==="todo"),I=new Set([...O,...z].map(w=>w.id));return d.jsxs("div",{"data-enso":"secretary-workbench",className:"flex flex-col gap-3 px-3 py-3",children:[r.length>1&&d.jsxs("div",{className:"flex items-center gap-1.5",children:[["own","all"].map(w=>d.jsx("button",{type:"button","data-enso":"secretary-board-scope-option","data-scope":w,"aria-pressed":n===w,onClick:()=>o(w),className:Y("rounded-md px-2 py-0.5 text-[12px] transition-colors",n===w?"bg-foreground/10 font-medium text-foreground":"text-muted-foreground hover:bg-foreground/5"),children:w==="own"?e:i("All secretaries")},w)),n==="all"&&d.jsxs("select",{"data-enso":"secretary-board-filter",value:a,onChange:w=>l(w.target.value),className:"ml-auto rounded-md bg-transparent text-[12px] text-muted-foreground",children:[d.jsx("option",{value:"all",children:i("All secretaries")}),r.map(w=>d.jsx("option",{value:w.id,children:w.name??i("Secretary")},w.id))]})]}),d.jsxs("div",{children:[d.jsx("p",{className:"text-[15px] font-semibold",children:i(E.greeting)}),d.jsx("p",{className:"mt-0.5 text-[12.5px] text-muted-foreground",children:N})]}),d.jsxs("div",{className:"grid grid-cols-3 gap-1.5",children:[d.jsx(yn,{value:E.counts.needsYou,label:i("Waiting on you"),warn:E.counts.needsYou>0}),d.jsx(yn,{value:E.counts.running,label:i("In progress")}),d.jsx(yn,{value:E.counts.todos,label:i("To do")})]}),u.needsYou.length>0&&d.jsx("section",{"data-enso":"secretary-needs-you",className:"flex flex-col gap-1.5",children:u.needsYou.map(w=>w.kind==="proposal"?d.jsx("div",{"data-enso":"secretary-proposal-focus","data-proposal-id":w.proposal.id,className:Y("rounded-lg transition-shadow",g===w.proposal.id&&"ring-2 ring-warning"),children:d.jsx(ag,{proposalId:w.proposal.id,prominent:!0})},w.proposal.id):w.kind==="pending"?d.jsx(fy,{pending:w.pending},w.pending.id):d.jsx(gy,{card:w},w.conversationId))}),O.length>0&&d.jsx(Ph,{title:i("In progress"),count:O.length,marker:"secretary-active",children:O.map(w=>d.jsx(Sn,{todo:w,secretaryId:t},w.id))}),z.length>0&&d.jsx(Ph,{title:i("Problem"),count:z.length,marker:"secretary-problem",children:z.map(w=>d.jsx(Sn,{todo:w,secretaryId:t},w.id))}),d.jsxs("section",{"data-enso":"secretary-todos",className:"flex flex-col",onDragOver:w=>{[...w.dataTransfer.types].includes("text/plain")&&w.preventDefault()},onDrop:w=>{w.preventDefault();const v=w.dataTransfer.getData("text/plain");I.has(v)&&Ai({action:"reopen",todoId:v},t)},children:[d.jsxs("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:[i("To do"),R.length>0&&d.jsx("span",{className:"ml-1 tabular-nums",children:R.length})]}),R.map(w=>d.jsx(Sn,{todo:w,secretaryId:t},w.id)),f?d.jsx(kh,{onClose:()=>m(!1),secretaryId:t}):d.jsx(vy,{onAdd:()=>m(!0)})]}),d.jsxs("section",{"data-enso":"secretary-feed",className:"flex flex-col",children:[d.jsx("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:i("Recent activity")}),C.freshCount>0&&d.jsx("button",{type:"button","data-enso":"secretary-feed-fresh","data-count":C.freshCount,onClick:C.reveal,className:"sticky top-0 z-10 mx-1.5 h-7 -mb-7 rounded-md bg-muted px-2 text-[12px] text-foreground",children:i("{{count}} new updates",{count:C.freshCount})}),d.jsxs("div",{className:"ml-1.5 flex flex-col border-l border-border",children:[C.events.map(w=>d.jsx(_y,{event:w},w.id)),d.jsx("div",{ref:C.sentinelRef,"data-enso":"secretary-feed-sentinel",className:"h-px"})]}),C.loading&&d.jsx("p",{"data-enso":"secretary-feed-loading",className:"px-1.5 py-1 text-[12px] text-subtle-foreground",children:i("Loading…")}),C.exhausted&&!C.loading&&C.events.length>0&&d.jsx("p",{"data-enso":"secretary-feed-end",className:"px-1.5 py-1 text-[12px] text-subtle-foreground",children:i("No earlier activity")})]})]})}function Ph({title:e,count:t,marker:i,children:s}){return d.jsxs("section",{"data-enso":i,className:"flex flex-col",children:[d.jsxs("h3",{className:"px-1.5 pb-1 text-[12px] text-subtle-foreground",children:[e,d.jsx("span",{className:"ml-1 tabular-nums",children:t})]}),s]})}const yy=[{key:"workbench",label:"Workbench"},{key:"daily",label:"Daily board"},{key:"memory",label:"Memory"},{key:"schedules",label:"Schedules"},{key:"contact",label:"Contacts"},{key:"skills",label:"Skills"}];function Sy({projectId:e}={}){const{t}=he(),i=lg(e)??void 0,s=Et(m=>i?m.states[i]??(m.focusedId===i?m.secretary:void 0)??m.secretary:m.secretary),r=Et(m=>m.focusProposal),[n,o]=b.useState("workbench"),[a,l]=b.useState(!1),[h,c]=b.useState([]),u=b.useCallback(()=>{window.electronAPI.secretary.listSchedules(i).then(m=>{m.ok&&c(m.schedules)})},[i]);b.useEffect(()=>(u(),window.electronAPI.secretary.onStateChanged(u)),[u]),b.useEffect(()=>{r&&o("workbench")},[r]);const p=hg(s,t);if(!p)return null;const f={workbench:p.needsYou,daily:0,memory:0,schedules:h.length,contact:0,skills:0};return d.jsxs("div",{"data-enso":"secretary-panel",className:"flex h-full min-h-0 flex-col",children:[d.jsxs("div",{className:"flex items-center gap-2.5 px-3 pt-3",children:[d.jsx(Ef,{name:p.name,color:p.color,image:p.image,needsYou:p.needsYou,running:p.running,size:"sm"}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"truncate text-[13.5px] font-semibold",children:p.name}),d.jsx("p",{"data-enso":"secretary-summary",className:"flex min-w-0 items-center truncate text-[11.5px] text-muted-foreground",children:d.jsx(dg,{view:p,runningExpanded:a,onToggleRunning:()=>l(m=>!m)})})]}),d.jsx("button",{type:"button","data-enso":"secretary-panel-settings",onClick:()=>If(i),title:t("Secretary settings"),"aria-label":t("Secretary settings"),className:"flex size-6 shrink-0 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:d.jsx(Tf,{className:"size-4"})})]}),d.jsx("div",{className:"mt-2 flex shrink-0 gap-0.5 border-b border-border px-1.5",children:yy.map(({key:m,label:g})=>d.jsxs("button",{type:"button","data-enso":"secretary-panel-tab","data-tab":m,"data-active":n===m||void 0,onClick:()=>o(m),className:Y("relative px-2 pt-1 pb-1.5 text-[12.5px] transition-colors",n===m?"font-medium text-foreground":"text-subtle-foreground hover:text-foreground"),children:[t(g),f[m]>0&&d.jsx("span",{className:Y("ml-1 text-[11px] tabular-nums",m==="workbench"?"text-warning":"text-subtle-foreground"),children:f[m]}),n===m&&d.jsx("span",{className:"absolute inset-x-1.5 -bottom-px h-0.5 rounded-full bg-foreground"})]},m))}),d.jsxs("div",{"data-enso":"secretary-panel-scroll",className:"relative flex min-h-0 flex-1 flex-col overflow-y-auto",children:[a&&d.jsx(Z0,{secretaryId:i}),n==="workbench"&&d.jsx(wy,{name:p.name,secretaryId:i}),n==="daily"&&d.jsx(W0,{secretaryId:i}),n==="memory"&&d.jsx(U0,{secretaryId:i}),n==="contact"&&d.jsx(M0,{secretaryId:i}),n==="skills"&&d.jsx(sy,{secretaryId:i}),n==="schedules"&&d.jsx(ty,{schedules:h,name:p.name,onReload:u,secretaryId:i})]})]})}function xy({conversationId:e,panelApi:t}){const{t:i}=he(),s=t.id.startsWith("btw:")?t.id.slice(4):t.id,r=Af(),n=Ue(y=>y.virtualModels),o=Ue(y=>y.defaultModel),a=Ue(y=>y.projects),l=Ue(y=>y.projectGroups),h=Xd(y=>y.snapshot),c=Rf(),[u,p]=b.useState("contextual"),[f,m]=b.useState(!1),[g]=b.useState(()=>cg(ue.getState().conversations[e]?.messages??[])),_=ue(Lf(y=>y.conversations[s]??null)),E=_?.title,C=_?.projectId,T=b.useMemo(()=>a.find(y=>y.id===C),[C,a]),x=b.useMemo(()=>Jd(T,l),[T,l]),A=b.useMemo(()=>Zd({defaultModel:o,...x,lastProviderId:_?.lastProviderId,lastModelId:_?.lastModelId,providers:r,credentials:Qd(h),virtualModels:n}),[n,_?.lastModelId,_?.lastProviderId,x,o,h,r]),k=A.source==="none"?void 0:c.find(y=>y.id===A.providerId),N=A.source==="none"?"":A.modelId,O=A.source==="none"?"":Nf(A)?A.providerId:k?.id??"",z=b.useMemo(()=>ug(_?.messages??[]),[_?.messages]),R=b.useRef(null),I=_?.status==="running",w=f||(_?Mf({started:_.started,sessionFile:_.sessionFile,messages:_.messages,spawning:_.spawning,status:_.status,historyLoadAttempted:_.historyLoadAttempted}):!0),v=b.useMemo(()=>{const y={name:"/compact",description:i("Compact the context now (/compact [summary focus])")},L=new Set([y.name]);return[y,...(_?.commands??[]).filter(M=>!L.has(M.name))]},[_?.commands,i]);b.useEffect(()=>{const y=ue.getState().conversations[e],L=Ue.getState();ue.getState().ensureBtwConversation({id:s,projectId:y?.projectId??"",btwParentId:e,rolePrompt:Sl("contextual",g),lastProviderId:y?.lastProviderId??L.defaultModel?.providerId,lastModelId:y?.lastModelId??L.defaultModel?.modelId,reasoningEnabled:y?.reasoningEnabled??L.defaultReasoningEnabled,thinkingLevel:y?.thinkingLevel??L.defaultThinkingLevel,approvalMode:y?.approvalMode??"full",presetId:y?.presetId})},[e,s,g]),b.useEffect(()=>{E&&t.setTitle(E)},[t,E]);const S=y=>{y===u||f||(m(!0),(async()=>(ue.getState().abort(s),await ue.getState().resetBtwSession(s,Sl(y,g)),p(y),t.setTitle(i("Btw")),m(!1)))())},D=()=>{const y=wg(z);if(y){if(!_c(y)){kr({type:"warning",title:i("No Composer for this selection")});return}Da()}};return d.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[d.jsxs("div",{className:"flex h-[36px] shrink-0 items-center gap-1 border-b px-2",children:[d.jsx(Eh,{label:i("Contextual"),active:u==="contextual",onClick:()=>S("contextual")}),d.jsx(Eh,{label:i("Tangent"),active:u==="tangent",onClick:()=>S("tangent")}),d.jsx("button",{type:"button",className:"ml-auto rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40",disabled:!z,onClick:D,children:i("Insert into chat")})]}),_?d.jsx(pg,{conversationId:s,cwd:T?.path,emptyTitle:i("Btw"),timelineRef:R}):d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-2 text-center text-muted-foreground",children:[d.jsx(Ca,{className:"h-5 w-5"}),d.jsx("p",{className:"text-xs",children:i("Ask a side question without sending it to the main agent.")})]}),d.jsx("div",{className:"@container pt-1",children:d.jsxs("div",{className:fg,children:[_?.retry?d.jsx(mg,{retry:_.retry,onCancel:()=>{window.electronAPI.agent.abortRetry(s)}}):null,d.jsx(Of.Provider,{value:C?{conversationId:s,projectId:C,...T?.path?{cwd:T.path}:{}}:null,children:d.jsx(gg,{sessionId:s,tasks:_?.backgroundTasks??[],subagents:_?.subagents??[]},s)}),d.jsx(mc,{approvals:_?.pendingApprovals??[],allowSession:!0,onRespond:(y,L)=>{window.electronAPI.agent.respondApproval(s,y,L)}}),d.jsx(gc,{asks:_?.pendingAsks??[],onAnswer:(y,L)=>{window.electronAPI.agent.respondAsk(s,y,L)}}),d.jsx(vg,{conversationId:s,queued:_?.queuedMessages??[]}),d.jsx(_g,{isolated:!0,cwd:T?.path,commands:v,running:I,busy:w,locked:(_?.pendingApprovals??[]).length>0,focusKey:s,injectedDraft:_?.draftText,injectedImages:_?.draftImages,injectedDraftAppend:_?.draftAppend,onDraftConsumed:()=>ue.getState().clearDraft(s),queuedCount:_?.queuedMessages?.length??0,onSteerQueued:()=>ue.getState().steerQueued(s),autoFocus:!1,placeholder:i("Ask aside…"),toolbar:d.jsx(Gf,{providers:c,recordRecent:!0,activeAccount:zf(r,_??void 0),virtualModels:n,providerId:O,modelId:N,reasoningEnabled:_?.reasoningEnabled??!1,thinkingLevel:_?.thinkingLevel??"medium",onSelect:(y,L)=>ue.getState().setModel(s,y,L),onReasoningChange:y=>ue.getState().setReasoning(s,y),onThinkingChange:y=>ue.getState().setThinking(s,y),side:"top"}),onSend:y=>!O||!N||!T?!1:(R.current?.scrollToBottom(),ue.getState().send(y.text,{providerId:O,modelId:N,cwd:T.path},y.images,s),!0),onAbort:()=>{ue.getState().abort(s)}}),d.jsx(bg,{conversationId:s,cwd:T?.path})]})})]})}function Eh({label:e,active:t,onClick:i}){return d.jsx("button",{type:"button",className:Y("rounded-md px-2 py-1 text-xs transition-colors",t?"bg-muted font-medium":"text-muted-foreground hover:bg-muted/50"),onClick:i,children:e})}function Cy(){ec()||window.electronAPI.browser.restoreTabs()}function xu(e,t,i,s={}){const r=new Set,n=e.map(o=>{const a=`diff:${o.path}`;r.add(a);const l=t.has(a),h=i.get(a),c=s.ignoreLineEndings?o.oldText.replace(/\r\n/g,`
|
|
10
|
+
`):o.oldText,u=s.ignoreLineEndings?o.newText.replace(/\r\n/g,`
|
|
11
|
+
`):o.newText,p=!h||h.oldText!==c||h.newText!==u,f=p||!h?tv({name:o.path,contents:c},{name:o.path,contents:u}):h.fileDiff;(p||!h)&&(f.cacheKey=yg(o.path,c,u));const m=h?p||h.collapsed!==l?h.version+1:h.version:0;return i.set(a,{oldText:c,newText:u,collapsed:l,version:m,fileDiff:f}),{id:a,type:"diff",fileDiff:f,version:m,collapsed:l}});for(const o of i.keys())r.has(o)||i.delete(o);return n}const Dy={theme:pa,diffStyle:"split",lineDiffType:"word",preferredHighlighter:"shiki-js",overflow:"scroll",stickyHeaders:!0},ky={height:"100%",overflow:"auto"},Py=new Set;function Cu({result:e,loading:t}){const{t:i}=he(),s=ua(Dy),[r,n]=b.useState(!1),[o,a]=b.useState(!1),l=b.useRef(new Map);b.useEffect(()=>{let u=!0;return fa().then(()=>{u&&n(!0)},()=>{u&&a(!0)}),()=>{u=!1}},[]);const h=b.useMemo(()=>xu(e?.ok?[e]:[],Py,l.current,{ignoreLineEndings:!0}),[e]),c=t?i("Loading..."):o?i("Could not load the diff viewer."):e?e.ok?r?e.oldText===e.newText?i("No text changes to display."):h[0]?.fileDiff.hunks.length===0?i("Only line endings changed."):null:i("Loading..."):i(e.error):i("Select a file to view its diff.");return d.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:c?d.jsx("div",{className:"flex h-full items-center justify-center px-4 py-8 text-center text-xs text-muted-foreground",role:"status",children:c}):d.jsx(Tc,{className:"min-h-0 w-full flex-1",items:h,style:ky,options:s})})}function Du({tree:e,onToggle:t}){const{t:i}=he(),s=i(e?"List view":"Tree view");return d.jsx(Ne,{variant:"ghost",size:"icon-xs",title:s,"aria-label":s,onClick:t,children:e?d.jsx(Sg,{className:"size-3.5"}):d.jsx(Sv,{className:"size-3.5"})})}function ku({files:e,tree:t,children:i}){const s=b.useId(),[r,n]=b.useState(()=>new Set),o=b.useMemo(()=>{const l={name:"",path:"",directories:new Map,files:[]};if(!t)return l;for(const h of e){const c=h.path.split("/");let u=l;for(const p of c.slice(0,-1)){let f=u.directories.get(p);f||(f={name:p,path:u.path?`${u.path}/${p}`:p,directories:new Map,files:[]},u.directories.set(p,f)),u=f}u.files.push(h)}return l},[e,t]),a=l=>d.jsxs(d.Fragment,{children:[[...l.directories.values()].sort((h,c)=>h.name.localeCompare(c.name)).map(h=>{const c=!r.has(h.path),u=`${s}-${encodeURIComponent(h.path)}`;return d.jsxs("div",{children:[d.jsxs("button",{type:"button",title:h.path,"aria-expanded":c,"aria-controls":c?u:void 0,className:"flex w-full min-w-0 items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring",onClick:()=>n(p=>{const f=new Set(p);return f.has(h.path)?f.delete(h.path):f.add(h.path),f}),children:[d.jsx(Bi,{"aria-hidden":"true",className:Y("size-3 shrink-0 text-muted-foreground",!c&&"-rotate-90")}),c?d.jsx(ma,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}):d.jsx(xg,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),d.jsx("span",{className:"truncate",children:h.name})]}),c&&d.jsx("div",{id:u,className:"ml-3 min-w-0 border-l pl-1",children:a(h)})]},`directory:${h.path}`)}),l.files.slice().sort((h,c)=>h.path.localeCompare(c.path)).map(h=>d.jsx(b.Fragment,{children:i(h)},`file:${h.path}`))]});return t?a(o):e.map(l=>d.jsx(b.Fragment,{children:i(l)},l.path))}const Ey={added:{label:"A",color:"text-success"},modified:{label:"M",color:"text-info"},deleted:{label:"D",color:"text-destructive"},untracked:{label:"?",color:"text-success"},conflicted:{label:"!",color:"text-warning"}};function Pu({file:e,selected:t,onSelect:i,actions:s,showDirectory:r=!0}){const{t:n}=he(),o=e.path.lastIndexOf("/"),a=e.path.slice(o+1),l=e.path.slice(0,Math.max(0,o)),h=Ey[e.status];return d.jsxs("div",{className:Y("group flex min-w-0 items-center rounded-md pr-1 hover:bg-muted/50",t&&"bg-brand/10 dark:bg-brand/15"),children:[d.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring",title:e.path,"aria-pressed":t,onClick:i,children:[d.jsx(tc,{"aria-hidden":"true",className:Y("size-3.5 shrink-0",h.color)}),d.jsx("span",{className:Y("truncate",!r&&"flex-1"),children:a}),r&&d.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] text-muted-foreground",children:l}),d.jsxs("span",{className:Y("shrink-0 font-mono text-[11px]",h.color),title:n(e.status),children:[d.jsx("span",{"aria-hidden":"true",children:h.label}),d.jsx("span",{className:"sr-only",children:n(e.status)})]})]}),s&&d.jsx("div",{className:"flex shrink-0 items-center opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100",children:s})]})}function Eu({title:e,hasSelection:t,navigation:i,actions:s,children:r}){const{t:n}=he(),o=b.useId(),[a,l]=b.useState(!0),h=!t||a;return d.jsx("div",{className:"@container/git flex min-h-0 min-w-0 flex-1 flex-col",children:d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden @min-[720px]/git:flex-row",children:[d.jsxs("div",{className:Y("flex min-h-0 min-w-0 flex-col overflow-hidden border-b @min-[720px]/git:h-full @min-[720px]/git:max-h-none @min-[720px]/git:flex-none @min-[720px]/git:border-r @min-[720px]/git:border-b-0",h?"flex-1 @min-[720px]/git:w-[280px]":"shrink-0 @min-[720px]/git:w-8",h&&t&&"max-h-[45%] basis-[45%] shrink-0"),children:[d.jsxs("div",{className:"flex shrink-0 items-center",children:[d.jsxs("button",{type:"button",className:"flex min-h-7 min-w-0 flex-1 items-center gap-1.5 px-2 py-1 text-left text-[11px] font-medium text-muted-foreground hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring","aria-expanded":h,"aria-controls":o,disabled:!t,title:n(h?"Collapse list":"Expand list"),onClick:()=>l(!h),children:[d.jsx(Bi,{className:Y("size-3.5 shrink-0",!h&&"-rotate-90")}),d.jsx("span",{className:Y("truncate",!h&&"@min-[720px]/git:hidden"),children:e})]}),h&&s&&d.jsx("div",{className:"mr-1 flex shrink-0 items-center",children:s})]}),d.jsx("div",{id:o,className:Y("flex min-h-0 flex-1 flex-col overflow-hidden",!h&&"hidden"),children:i})]}),d.jsx("div",{className:Y("min-h-0 min-w-0 flex-1 flex-col overflow-hidden @min-[720px]/git:flex",t?"flex":"hidden"),children:r})]})})}function Ty({request:e,head:t,tree:i,onToggleTree:s}){const{t:r}=he(),n=b.useId(),[o,a]=b.useState([]),[l,h]=b.useState(0),[c,u]=b.useState(0),[p,f]=b.useState(!1),[m,g]=b.useState(!0),[_,E]=b.useState(null),[C,T]=b.useState(null),[x,A]=b.useState([]),[k,N]=b.useState(!1),[O,z]=b.useState(null),[R,I]=b.useState(null),[w,v]=b.useState(null),[S,D]=b.useState(!1);return b.useEffect(()=>{let y=!0;return g(!0),E(null),window.electronAPI.git.history({...e,head:t??void 0,skip:l,limit:20}).then(L=>{y&&(L.ok?(a(M=>l===0?L.commits:[...M,...L.commits]),f(L.hasMore)):E(L.error))}).catch(()=>{y&&E("Could not load Git history.")}).finally(()=>{y&&g(!1)}),()=>{y=!1}},[e,t,l,c]),b.useEffect(()=>{if(!C)return;let y=!0;return N(!0),z(null),window.electronAPI.git.commitFiles({...e,hash:C.hash}).then(L=>{y&&(L.ok?A(L.files):z(L.error))}).catch(()=>{y&&z("Could not load the changed files.")}).finally(()=>{y&&N(!1)}),()=>{y=!1}},[e,C]),b.useEffect(()=>{if(!R||!C)return;let y=!0;return D(!0),window.electronAPI.git.commitDiff({...e,hash:C.hash,path:R}).then(L=>{y&&v(L)}).catch(()=>{y&&v({ok:!1,error:"Could not load the diff."})}).finally(()=>{y&&D(!1)}),()=>{y=!1}},[e,C,R]),d.jsxs(Eu,{title:r("History"),hasSelection:R!==null,actions:d.jsx(Du,{tree:i,onToggle:s}),navigation:d.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-1 pb-1",children:[o.map(y=>{const L=C?.hash===y.hash;return d.jsxs("div",{children:[d.jsxs("button",{type:"button","aria-expanded":L,"aria-controls":L?`${n}-${y.hash}`:void 0,className:Y("flex w-full min-w-0 items-start gap-1.5 rounded-md px-2 py-1.5 text-left hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring",L&&"bg-brand/10 dark:bg-brand/15"),title:`${y.subject}
|
|
12
|
+
${y.hash}
|
|
13
|
+
${y.author} · ${y.date}`,onClick:()=>{T(L?null:y),A([]),N(!L),z(null),I(null),v(null),D(!1)},children:[d.jsx(Bi,{"aria-hidden":"true",className:Y("mt-0.5 size-3.5 shrink-0 text-muted-foreground",!L&&"-rotate-90")}),d.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[d.jsx("span",{className:"truncate text-xs",children:y.subject}),d.jsxs("span",{className:"flex min-w-0 gap-2 text-[11px] text-muted-foreground",children:[d.jsx("span",{className:"shrink-0 font-mono",children:y.hash.slice(0,7)}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:y.author}),d.jsx("time",{className:"shrink-0",dateTime:y.date,children:new Date(y.date).toLocaleDateString()})]})]})]}),L&&d.jsx("div",{id:`${n}-${y.hash}`,className:"my-1 ml-3 border-l pl-1",children:k?d.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:r("Loading...")}):O?d.jsx("p",{role:"alert",className:"px-2 py-3 text-xs text-destructive",children:r(O)}):x.length===0?d.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:r("No file changes in this commit.")}):d.jsx(ku,{files:x,tree:i,children:M=>d.jsx(Pu,{file:M,showDirectory:!i,selected:R===M.path,onSelect:()=>{R!==M.path&&(I(M.path),v(null),D(!0))}})},y.hash)})]},y.hash)}),m&&d.jsx("div",{className:"flex justify-center p-3",children:d.jsx(Wr,{className:"size-4 animate-spin","aria-label":r("Loading...")})}),_&&d.jsx("p",{role:"alert",className:"px-2 py-3 text-xs text-destructive",children:r(_)}),!m&&!_&&o.length===0&&d.jsx("p",{className:"m-1 rounded-md border border-dashed px-2 py-5 text-center text-xs text-muted-foreground",children:r("No commits yet.")}),p&&!m&&!_&&d.jsx(Ne,{variant:"ghost",size:"xs",className:"w-full",onClick:()=>h(o.length),children:r("Load more commits")}),_&&d.jsx(Ne,{variant:"ghost",size:"xs",className:"w-full",onClick:()=>u(y=>y+1),children:r("Retry")})]}),children:[C&&R&&d.jsxs("div",{className:"shrink-0 truncate border-b px-3 py-1 text-[11px] text-muted-foreground",title:`${C.subject} · ${R}`,children:[C.hash.slice(0,7)," · ",R]}),d.jsx(Cu,{result:w,loading:S})]})}function Iy({conversationId:e,projectId:t,disabled:i,unavailable:s,editWriteKey:r}){const{t:n}=he(),{visible:o}=Cg(),a=b.useMemo(()=>({conversationId:e,projectId:t}),[e,t]),[l,h]=b.useState(null),[c,u]=b.useState(!0),[p,f]=b.useState(null),[m,g]=b.useState(null),[_,E]=b.useState(null),[C,T]=b.useState("changes"),[x,A]=b.useState(!0),[k,N]=b.useState(""),[O,z]=b.useState(""),R=b.useRef(null),[I,w]=b.useState(null),[v,S]=b.useState(null),[D,y]=b.useState(null),[L,M]=b.useState(!1),[H,j]=b.useState(0),J=b.useRef(!1),te=b.useRef(!1),ie=b.useRef(0),le=b.useRef(0),me=b.useCallback(async(Q=!1)=>{if(!o||i||s||te.current||le.current!==0&&!Q)return;const de=++ie.current;le.current=de,Q&&u(!0);try{const Ge=await window.electronAPI.git.status(a);if(!J.current||de!==ie.current)return;Ge.ok?(h(Ge),f(null)):(h(null),f(Ge.error))}catch{J.current&&de===ie.current&&(h(null),f("Could not read Git status."))}finally{le.current===de&&(le.current=0),J.current&&de===ie.current&&u(!1)}},[o,i,s,a]);b.useEffect(()=>{J.current=!0;const Q=()=>{me()},de=window.setInterval(()=>{document.visibilityState==="visible"&&document.hasFocus()&&me()},5e3);return window.addEventListener("focus",Q),()=>{J.current=!1,ie.current+=1,window.clearInterval(de),window.removeEventListener("focus",Q)}},[me]),b.useEffect(()=>{me(!0)},[me,r]),b.useEffect(()=>{if(!I||!l)return;(I.staged?l.staged:l.unstaged).some(de=>de.path===I.path)||(w(null),y(null),M(!1))},[I,l]),b.useEffect(()=>{if(!o||!I||i||s||_!==null||C!=="changes")return;let Q=!0,de=!1;const Ge=async()=>{if(!de){de=!0;try{const lt=await window.electronAPI.git.fileDiff({...a,...I});Q&&y(lt)}catch{Q&&y({ok:!1,error:"Could not load the diff."})}finally{de=!1,Q&&M(!1)}}};Ge();const Be=()=>{Ge()},ni=window.setInterval(()=>{document.visibilityState==="visible"&&document.hasFocus()&&Ge()},5e3);return window.addEventListener("focus",Be),()=>{Q=!1,window.clearInterval(ni),window.removeEventListener("focus",Be)}},[o,a,I,H,i,s,C,_]);const ne=async(Q,de,Ge)=>{if(!(te.current||i||s||c||!l)){te.current=!0,ie.current+=1,E(Q),g(null);try{const Be=await de();if(!J.current)return;Be.ok?Ge?.():g(Be.error)}catch{J.current&&g("Could not complete the Git operation.")}finally{te.current=!1,J.current&&(E(null),j(Be=>Be+1),me(!0),ue.getState().refreshWorktreeStatuses().catch(()=>{}))}}},W=i||s||c||_!==null||!l,ge=!W&&!!k.trim()&&!!l?.staged.length,X=(Q,de)=>{I?.path===Q.path&&I.staged===de||(y(null),M(!0),w({path:Q.path,staged:de}))},ve=[{id:"staged",staged:!0,title:n("Staged changes"),files:l?.staged??[]},{id:"unstaged",staged:!1,title:n("Unstaged changes"),files:l?.unstaged.filter(Q=>Q.status!=="untracked")??[]},{id:"untracked",staged:!1,title:n("Untracked changes"),files:l?.unstaged.filter(Q=>Q.status==="untracked")??[]}],ye=O.trim().toLowerCase(),ke=ve.map(Q=>({...Q,files:Q.files.filter(de=>de.path.toLowerCase().includes(ye))})),we=ke.reduce((Q,de)=>Q+de.files.length,0),it=()=>{ge&&ne("Commit",()=>window.electronAPI.git.commit({...a,message:k}),()=>N(""))};return d.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-col",children:[d.jsxs("div",{className:"flex h-[36px] shrink-0 items-center gap-1 border-b px-2",children:[l&&!i&&!s&&!p&&d.jsxs("div",{className:"flex shrink-0 items-center gap-1",role:"tablist","aria-label":n("Git views"),children:[d.jsxs(Ne,{role:"tab","aria-selected":C==="changes",variant:C==="changes"?"secondary":"ghost",size:"xs",onClick:()=>T("changes"),children:[d.jsx(mv,{className:"size-3.5"}),n("Changes")]}),d.jsxs(Ne,{role:"tab","aria-selected":C==="history",variant:C==="history"?"secondary":"ghost",size:"xs",onClick:()=>T("history"),children:[d.jsx(Bf,{className:"size-3.5"}),n("History")]})]}),d.jsx(Dg,{className:"size-3.5 shrink-0 text-muted-foreground"}),d.jsx("span",{className:"min-w-0 flex-1 truncate text-xs",title:l?.branch??void 0,children:l?.branch??n(l?"Detached HEAD":"Git")}),l?.upstream&&d.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",title:l.upstream,children:["↓",l.behind," ↑",l.ahead]}),l&&!l.upstream&&d.jsx("span",{className:"max-w-20 truncate text-[11px] text-muted-foreground",title:n("No upstream branch configured."),children:n("No upstream")}),d.jsx(Di,{title:n("Fetch"),disabled:W,onClick:()=>{ne("Fetch",()=>window.electronAPI.git.fetch(a))},children:d.jsx(jf,{className:"size-3.5"})}),d.jsx(Di,{title:n("Pull"),disabled:W||!l?.upstream,onClick:()=>{ne("Pull",()=>window.electronAPI.git.pull(a))},children:d.jsx($f,{className:"size-3.5"})}),d.jsx(Di,{title:n("Push"),disabled:W||!l?.upstream,onClick:()=>{ne("Push",()=>window.electronAPI.git.push(a))},children:d.jsx(Wf,{className:"size-3.5"})}),d.jsx(Di,{title:n("Refresh"),disabled:i||s||_!==null||c,onClick:()=>{j(Q=>Q+1),me(!0)},children:d.jsx(_i,{className:Y("size-3.5",c&&!s&&!i&&"animate-spin")})})]}),_&&d.jsxs("p",{role:"status",className:"flex shrink-0 items-center gap-2 px-3 py-1 text-xs text-muted-foreground",children:[d.jsx(Wr,{className:"size-3 animate-spin"}),n(_),"…"]}),m&&d.jsx("p",{role:"alert",className:"max-h-24 shrink-0 overflow-auto whitespace-pre-wrap break-words border-b px-3 py-2 text-xs text-destructive",children:n(m)}),s||i||p||!l?d.jsx("div",{role:"status",className:"m-3 flex min-h-0 flex-1 items-center justify-center rounded-md border border-dashed p-4 text-center text-xs text-muted-foreground",children:n(s?"Git diff is not available for this workspace.":i?"Workspace is changing. Please wait.":p??"Loading...")}):C==="history"?d.jsx(Ty,{request:a,head:l.head,tree:x,onToggleTree:()=>A(Q=>!Q)},`${l.head}:${H}`):d.jsxs(Eu,{title:n("Changed files"),hasSelection:I!==null,actions:d.jsx(Du,{tree:x,onToggle:()=>A(Q=>!Q)}),navigation:d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"shrink-0 px-2 pb-1.5",children:d.jsxs(Hf,{className:"text-xs",children:[d.jsx(Ff,{ref:R,size:"sm",type:"search",value:O,onChange:Q=>z(Q.target.value),placeholder:n("Filter changed files…"),"aria-label":n("Filter changed files…")}),O.length>0&&d.jsx(Vf,{align:"inline-end",children:d.jsx(Ne,{type:"button",variant:"ghost",size:"icon-xs",title:n("Clear"),"aria-label":n("Clear"),onClick:()=>{z(""),R.current?.focus()},children:d.jsx(Gs,{className:"size-3.5"})})})]})}),d.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-1 pb-1",children:[ke.map(Q=>Q.files.length===0?null:d.jsxs("section",{className:"mb-2 last:mb-0",children:[d.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 text-[11px] font-medium text-muted-foreground",children:[d.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[Q.title," ",d.jsx("span",{className:"ml-1 font-normal",children:Q.files.length})]}),d.jsx(Di,{title:n(Q.staged?"Unstage all":"Stage all"),disabled:W,onClick:()=>{ne(Q.staged?"Unstage":"Stage",()=>window.electronAPI.git[Q.staged?"unstage":"stage"]({...a,paths:Q.files.map(de=>de.path)}))},children:Q.staged?d.jsx(_l,{className:"size-3.5"}):d.jsx(Zi,{className:"size-3.5"})})]}),d.jsx(ku,{files:Q.files,tree:x,children:de=>d.jsx(Pu,{file:de,showDirectory:!x,selected:I?.path===de.path&&I.staged===Q.staged,onSelect:()=>X(de,Q.staged),actions:d.jsxs(d.Fragment,{children:[!Q.staged&&d.jsx(Di,{title:n(de.status==="untracked"?"Delete untracked file":"Discard changes"),disabled:W||de.status==="conflicted",onClick:()=>S(de),children:d.jsx(Sa,{className:"size-3.5"})}),d.jsx(Di,{title:n(Q.staged?"Unstage":"Stage"),disabled:W,onClick:()=>{ne(Q.staged?"Unstage":"Stage",()=>window.electronAPI.git[Q.staged?"unstage":"stage"]({...a,paths:[de.path]}))},children:Q.staged?d.jsx(_l,{className:"size-3.5"}):d.jsx(Zi,{className:"size-3.5"})})]})})},ye)]},Q.id)),we===0&&d.jsx("p",{className:"m-1 rounded-md border border-dashed px-2 py-5 text-center text-xs text-muted-foreground",children:n(l.staged.length+l.unstaged.length===0?"Working tree clean.":"No matching files.")})]}),d.jsxs("div",{className:"flex shrink-0 items-end gap-1.5 border-t p-2",children:[d.jsx(Uf,{size:"sm",rows:3,value:k,"aria-label":n("Commit message"),placeholder:n("Enter commit message…"),className:"min-w-0 flex-1 text-xs [&_textarea]:max-h-[calc(6lh+0.5rem)] [&_textarea]:min-h-[calc(3lh+0.5rem)] [&_textarea]:resize-none [&_textarea]:overflow-auto",disabled:_!==null,onChange:Q=>N(Q.target.value),onKeyDown:Q=>{(Q.ctrlKey||Q.metaKey)&&Q.key==="Enter"&&!Q.nativeEvent.isComposing&&(Q.preventDefault(),it())}}),d.jsxs(Ne,{size:"xs",className:"mb-0.5 shrink-0",title:n("{{count}} staged files",{count:l.staged.length}),"aria-label":n("Commit"),disabled:!ge,onClick:it,children:[d.jsx(vv,{className:"size-3.5"}),n("Commit"),l.staged.length>0&&d.jsx("span",{className:"font-mono text-[11px]",children:l.staged.length})]})]})]}),children:[I&&d.jsxs("div",{className:"shrink-0 truncate border-b px-3 py-1 text-[11px] text-muted-foreground",title:I.path,children:[n(I.staged?"Staged changes":"Unstaged changes")," · ",I.path]}),d.jsx(Cu,{result:D,loading:I!==null&&L})]}),d.jsx(qn,{open:v!==null&&!W,onOpenChange:Q=>{Q||S(null)},title:n(v?.status==="untracked"?"Delete untracked file":"Discard changes"),description:v?.status==="untracked"?n("Delete untracked file {{path}} permanently?",{path:v.path}):n("Restore {{path}} to its staged version? Unstaged changes will be lost.",{path:v?.path??""}),confirmLabel:n(v?.status==="untracked"?"Delete":"Discard"),onConfirm:()=>{v&&ne("Discard",()=>window.electronAPI.git.discard({...a,paths:[v.path],confirmUntracked:v.status==="untracked"}))}})]})}function Di({title:e,disabled:t,onClick:i,children:s}){return d.jsx(Ne,{variant:"ghost",size:"icon-xs",title:e,"aria-label":e,disabled:t,onClick:i,children:s})}const Tu=28,Ay={theme:pa,diffStyle:"split",lineDiffType:"word",preferredHighlighter:"shiki-js",overflow:"scroll",stickyHeaders:!0,itemMetrics:{diffHeaderHeight:Tu}},Ry={height:"max-content",overflow:"auto"},Ly={files:[],snapshots:{}},Th=[];function Ny({conversationId:e,projectId:t}){const{t:i}=he(),s=ua(Ay),r=De(j=>j.changesModeByConversation[e])??"all",n=De(j=>j.setChangesMode),o=b.useRef(null),a=b.useRef(null),l=b.useRef(!1);b.useLayoutEffect(()=>{const j=o.current,J=a.current,te=j?.querySelector('[aria-selected="true"]');!j||!J||!te||(l.current||(J.style.transition="none"),J.style.transform=`translate(${te.offsetLeft}px, ${te.offsetTop}px)`,J.style.width=`${te.offsetWidth}px`,J.style.height=`${te.offsetHeight}px`,l.current||(J.offsetWidth,J.style.transition="",l.current=!0))},[r]);const h=De(j=>j.snapshotsByConversation[e]),c=De(j=>j.saveSnapshots),u=De(j=>j.loadSnapshots),p=ue(j=>ic(j.conversations[e]?.messages??Th)),f=ue(j=>j.workspaceRevisionByConversation[e]??0),m=ue(j=>!!j.conversations[e]?.workspaceMigrating),g=Ue(j=>j.projects.find(J=>J.id===t)),_=ue(j=>g?.kind==="secretary"?void 0:g?.kind==="scratch"?sc({kind:"scratch",canonicalPath:g.path,conversationId:e})??void 0:j.conversations[e]?.worktree?.path??g?.path),E=ue(j=>j.conversations[e]?.status==="running"),C=b.useRef([]),T=b.useMemo(()=>{const j=ue.getState().conversations[e],te=Yn(j?.messages??Th,E,j?.customEntries??[],_).flatMap(ie=>ie.kind!=="tool"?[]:ie.name==="apply_patch"?(ie.fileChanges??[]).map(le=>({path:le.path,edits:null,writeContent:null,fileChange:le})):ie.state!=="ok"||ie.name!=="edit"&&ie.name!=="write"?[]:ie.summary?ie.name==="edit"&&!(ie.edits&&ie.edits.length>0)?[]:ie.name==="write"&&ie.writeContent==null?[]:[{path:ie.summary,edits:ie.edits,writeContent:ie.writeContent}]:[]);return iv(C.current,te)?C.current:(C.current=te,te)},[e,p,_,E]),[x,A]=b.useState(!1),[k,N]=b.useState({});b.useEffect(()=>{let j=!0;return fa().then(()=>{j&&A(!0)}),()=>{j=!1}},[]),b.useEffect(()=>{r==="all"&&u(e)},[e,u,r]),b.useEffect(()=>{if(r!=="all"||m)return;const j=[...new Set(T.map(te=>te.path))];let J=!0;return Promise.all(j.map(async te=>{const ie=Kf(te,_),le=ie?await window.electronAPI.files.read({conversationId:e,projectId:t,rel:ie}):qf(te)?await window.electronAPI.files.read({conversationId:e,projectId:t,path:te}):null;return[te,le]})).then(te=>{if(!J)return;const ie=Object.fromEntries(te);N(le=>sv(le,ie)?le:ie)}),()=>{J=!1}},[e,r,t,_,T,m,f]);const O=b.useMemo(()=>h?rv({tools:T,snapshots:h,currentByPath:k}):Ly,[T,h,k]);b.useEffect(()=>{if(r!=="all"||!h)return;const j=O.snapshots,J=Object.keys(j);J.length===Object.keys(h).length&&J.every(te=>h[te]===j[te])||c(e,j)},[O.snapshots,e,r,c,h]);const z=O.files,R=O.incompletePaths??[],[I,w]=b.useState(()=>new Set),v=b.useCallback(j=>{w(J=>{const te=new Set(J);return te.delete(j)||te.add(j),te})},[]),S=b.useRef(new Map),D=b.useMemo(()=>xu(z,I,S.current),[z,I]),y=D.length>0&&D.every(j=>j.collapsed),L=()=>w(y?new Set:new Set(D.map(j=>j.id))),M=b.useCallback(j=>d.jsx(My,{item:j,onToggle:()=>v(j.id)}),[v]),H=!x||!h;return d.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[d.jsxs("div",{className:"flex h-[36px] shrink-0 items-center gap-1 border-b px-2",children:[d.jsxs("div",{ref:o,role:"tablist",className:"t-tabs",children:[d.jsx("span",{ref:a,"aria-hidden":"true",className:"t-tabs-pill"}),d.jsx(Ih,{active:r==="all",onClick:()=>n(e,"all"),children:i("Session")}),d.jsx(Ih,{active:r==="git",onClick:()=>n(e,"git"),children:i("Git")})]}),r==="all"&&D.length>0&&d.jsx("button",{type:"button",onClick:L,title:i(y?"Expand all":"Collapse all"),className:"ml-auto inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-muted/50 hover:text-foreground",children:y?d.jsx(Yf,{className:"h-3.5 w-3.5"}):d.jsx(hv,{className:"h-3.5 w-3.5"})})]}),d.jsx("div",{className:"min-h-0 flex-1",children:r==="git"?d.jsx(Iy,{conversationId:e,projectId:t,disabled:m,unavailable:g?.kind==="ssh",editWriteKey:p},`${e}:${_}:${f}`):H||z.length===0&&R.length===0?d.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-sm text-muted-foreground",children:i(H?"Loading...":"No file changes in this conversation yet.")}):d.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[R.map(j=>d.jsxs("div",{className:"m-2 flex shrink-0 items-start gap-2 rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground",children:[d.jsx(Xf,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),d.jsxs("div",{className:"min-w-0",children:[d.jsx("div",{className:"truncate font-mono text-foreground",title:j,children:j}),d.jsx("div",{children:i("Diff unavailable because the original snapshot was truncated.")})]})]},j)),z.length>0&&d.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:d.jsx(Tc,{className:"min-h-0 w-full",items:D,style:Ry,options:s,renderCustomHeader:M})})]})})]})}function My({item:e,onToggle:t}){const i=e.type==="diff"?e.fileDiff:null;let s=0,r=0;for(const o of i?.hunks??[])s+=o.additionLines,r+=o.deletionLines;const n=i?.name??(e.type==="file"?e.file.name:"");return d.jsxs("button",{type:"button",onClick:t,style:{height:Tu},className:"flex w-full min-w-0 items-center gap-1.5 px-2 text-left font-mono text-xs hover:bg-muted/50",children:[e.collapsed?d.jsx(zs,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):d.jsx(Bi,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),d.jsx("span",{className:"min-w-0 flex-1 truncate",title:n,children:n}),r>0&&d.jsxs("span",{className:"shrink-0 text-red-500",children:["-",r]}),s>0&&d.jsxs("span",{className:"shrink-0 text-green-600",children:["+",s]})]})}function Ih({active:e,onClick:t,children:i}){return d.jsx("button",{type:"button",role:"tab",onClick:t,"aria-selected":e,className:Y("t-tab rounded-md px-2 py-1 text-xs transition-colors",e?"font-medium":"text-muted-foreground hover:bg-muted/50"),children:i})}const Oy=/\.(png|jpe?g|gif|webp|bmp|svg|ico|avif)$/i;function Ah(e){return Oy.test(e)}const Gy=4*1024*1024,zy={backgroundImage:"repeating-conic-gradient(rgb(128 128 128 / 0.18) 0% 25%, transparent 0% 50%)",backgroundSize:"16px 16px"};function By({rel:e,version:t,resolveImage:i,onOpenSource:s}){const{t:r}=he(),[n,o]=b.useState({status:"loading"}),[a,l]=b.useState(!0),[h,c]=b.useState(!1);return b.useEffect(()=>{let u=!0;return i(e).then(p=>{u&&o(f=>p.ok?f.status==="ready"&&f.dataUrl===p.dataUrl?f:{status:"ready",dataUrl:p.dataUrl}:{status:"error",tooLarge:p.error==="too-large"})},()=>{u&&o({status:"error",tooLarge:!1})}),()=>{u=!1}},[e,t,i]),n.status==="loading"?d.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:r("Loading...")}):n.status==="error"?d.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:[d.jsx("span",{children:n.tooLarge?r("The image is too large to preview."):r("Unable to preview this image.")}),d.jsx(Ne,{type:"button",variant:"outline",size:"sm",onClick:s,children:r("Open in code editor")})]}):n.dataUrl.length>Gy&&!h?d.jsx("div",{className:"flex h-full items-center justify-center px-6",children:d.jsx(Ne,{type:"button",variant:"outline",size:"sm",onClick:()=>c(!0),children:r("Image is too large. Click to load.")})}):d.jsxs("div",{className:"relative h-full",children:[d.jsx("div",{className:"absolute top-2 right-2 z-10",children:d.jsxs(Ne,{type:"button",variant:"outline",size:"sm","aria-label":r(a?"Actual size":"Fit to window"),onClick:()=>l(u=>!u),children:[a?d.jsx(rc,{className:"h-3.5 w-3.5"}):d.jsx(nc,{className:"h-3.5 w-3.5"}),r(a?"Actual size":"Fit to window")]})}),d.jsx("div",{className:"h-full overflow-auto p-4",style:zy,children:d.jsx("button",{type:"button",className:Y(a?"flex h-full w-full cursor-zoom-in items-center justify-center":"m-auto block w-max cursor-zoom-out"),onClick:()=>l(u=>!u),children:d.jsx("img",{src:n.dataUrl,alt:e,"data-fit":a?"contain":"actual",className:a?"max-h-full max-w-full object-contain":"max-w-none"})})})]})}function jy({conversationId:e,projectId:t,onOpenFile:i,onClose:s,menu:r}){const{t:n}=he(),o=b.useRef(0),[a,l]=b.useState(""),[h,c]=b.useState("names"),[u,p]=b.useState(null),[f,m]=b.useState(!1);return b.useEffect(()=>{if(!a.trim()){o.current+=1,p(null),m(!1);return}const _=++o.current;m(!0);const E=setTimeout(()=>{window.electronAPI.workspaceFiles.search({conversationId:e,projectId:t,query:a,mode:h}).then(C=>{_===o.current&&(p(C),m(!1))})},150);return()=>clearTimeout(E)},[e,h,t,a]),d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[d.jsxs("div",{className:"flex flex-col gap-1 px-1 pb-1",children:[d.jsx(oc,{size:"sm",autoFocus:!0,value:a,onChange:g=>l(g.target.value),onKeyDown:g=>{g.key==="Escape"&&s()},placeholder:n(h==="names"?"Search file names":"Search file contents"),"aria-label":n("Search")}),d.jsxs("div",{className:"flex gap-0.5",children:[d.jsx(Lh,{active:h==="names",onClick:()=>c("names"),label:n("File name"),icon:Hg}),d.jsx(Lh,{active:h==="content",onClick:()=>c("content"),label:n("Content"),icon:tc})]})]}),d.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-1 pb-1",children:a.trim()?f&&!u?d.jsx("p",{className:"px-1 py-2 text-muted-foreground text-xs",children:n("Searching…")}):u&&!u.ok?d.jsx("p",{className:"px-1 py-2 text-muted-foreground text-xs",children:n(Wy(u.error))}):u?.ok&&u.hits.length===0?d.jsx("p",{className:"px-1 py-2 text-muted-foreground text-xs",children:n("No results")}):u?.ok&&u.mode==="names"?u.hits.map(g=>{const _=Vr(g.name,!1);return d.jsx(Rh,{rel:g.relativePath,name:g.name,menu:r,onOpenFile:i,children:d.jsxs("button",{type:"button","data-search-hit":g.relativePath,className:"flex w-full items-start gap-1 rounded-sm px-1 py-0.5 text-left hover:bg-muted",onClick:()=>i(g.relativePath),children:[d.jsx(_,{className:Y("mt-0.5 size-3.5 shrink-0",Ur(g.name,!1))}),d.jsxs("span",{className:"min-w-0",children:[d.jsx("span",{className:"block truncate text-xs",children:g.name}),d.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:g.relativePath})]})]})},g.relativePath)}):u?.ok&&u.mode==="content"?u.hits.map(g=>{const _=g.relativePath.split("/").pop()||g.relativePath;return d.jsx(Rh,{rel:g.relativePath,name:_,menu:r,onOpenFile:i,children:$y(g,i)},Iu(g))}):null:d.jsx("p",{className:"px-1 py-2 text-muted-foreground text-xs",children:n("Type to search this workspace.")})})]})}function Iu(e){return`${e.relativePath}:${e.line}:${e.column}`}function $y(e,t){const i=e.relativePath.split("/").pop()||e.relativePath,s=Vr(i,!1);return d.jsxs("button",{type:"button","data-search-hit":Iu(e),className:"flex w-full items-start gap-1 rounded-sm px-1 py-0.5 text-left hover:bg-muted",onClick:()=>t(e.relativePath),children:[d.jsx(s,{className:Y("mt-0.5 size-3.5 shrink-0",Ur(i,!1))}),d.jsxs("span",{className:"min-w-0",children:[d.jsxs("span",{className:"block truncate text-xs",children:[i,d.jsxs("span",{className:"text-muted-foreground",children:[":",e.line]})]}),d.jsx("span",{className:"block truncate font-mono text-[10px] text-muted-foreground",children:e.content.trim()})]})]})}function Rh({rel:e,name:t,menu:i,onOpenFile:s,children:r}){return d.jsx(Fr,{target:{kind:"file",rel:e,name:t},local:i.local,onNewFile:i.onNewFile,onNewFolder:i.onNewFolder,onView:s,onPreview:i.onPreview,onBrowser:i.onBrowser,onCopyPath:i.onCopyPath,onCopyRel:i.onCopyRel,onCopyFile:i.onCopyFile,onReveal:i.onReveal,onRename:i.onRename,onDelete:i.onDelete,onSend:i.onSend,children:r})}function Wy(e){switch(e){case"unsupported":return"Search is not available for SSH workspaces.";case"rg-missing":return"Search needs ripgrep (rg). Install it and make sure it is on PATH.";case"timeout":return"Search timed out. Try a more specific query or a smaller folder.";default:return"Could not complete the file action."}}function Lh({active:e,onClick:t,label:i,icon:s}){return d.jsxs(Ne,{type:"button",variant:"ghost",size:"sm",className:Y("h-6 flex-1 px-1 text-xs",e&&"bg-muted"),"aria-pressed":e,onClick:t,children:[d.jsx(s,{className:"size-3.5"}),i]})}const Hy=/^data:image\/(png|jpe?g|gif|webp|bmp|x-icon|svg\+xml);/i;function Fy(){return{...Ys,attributes:{...Ys.attributes,source:[]},protocols:{...Ys.protocols,src:[...Ys.protocols?.src??[],"data"]}}}function Vy(){return e=>{Jf(e,"element",t=>{if(t.tagName!=="img")return;const i=t.properties?.src;typeof i!="string"||!i.startsWith("data:")||Hy.test(i)||delete t.properties.src})}}const Uy=[sm],Ky=Fy(),qy=[tm,[im,Ky],Vy],Yy=({children:e,node:t,...i})=>d.jsx("p",{className:"my-1.5 leading-relaxed first:mt-0 last:mb-0",...i,children:e}),Xy=({children:e,node:t,...i})=>d.jsx("h1",{className:"mt-3 mb-1.5 text-base font-semibold",...i,children:e}),Jy=({children:e,node:t,...i})=>d.jsx("h2",{className:"mt-3 mb-1.5 text-base font-semibold",...i,children:e}),Zy=({children:e,node:t,...i})=>d.jsx("h3",{className:"mt-2 mb-1 text-sm font-semibold",...i,children:e}),Qy=({children:e,node:t,...i})=>d.jsx("ul",{className:"my-1.5 list-disc pl-5 space-y-0.5",...i,children:e}),eS=({children:e,node:t,...i})=>d.jsx("ol",{className:"my-1.5 list-decimal pl-5 space-y-0.5",...i,children:e}),tS=({children:e,node:t,...i})=>d.jsx("th",{className:"whitespace-nowrap border-b border-border px-2 py-1 text-left font-medium",...i,children:e}),iS=({children:e,node:t,...i})=>d.jsx("td",{className:"whitespace-nowrap border-b border-border/50 px-2 py-1",...i,children:e}),sS={p:Yy,h1:Xy,h2:Jy,h3:Zy,ul:Qy,ol:eS,th:tS,td:iS};function rS({text:e,baseDirRel:t,resolveImage:i,resolveRemoteImage:s}){const r=b.useRef(new Map),n=b.useMemo(()=>({...Zf,...sS,img:({node:l,src:h,alt:c,...u})=>d.jsx(nS,{src:typeof h=="string"?h:void 0,alt:c,rest:u,baseDirRel:t,resolveImage:i,resolveRemoteImage:s,cache:r.current})}),[t,i,s]),o=b.useMemo(()=>({text:e,streaming:!1,searchQuery:"",activeNth:-1}),[e]);return d.jsx(Qf.Provider,{value:o,children:d.jsx("div",{style:rm(nm),children:d.jsx(em,{remarkPlugins:Uy,rehypePlugins:qy,components:n,urlTransform:a=>a,children:e})})})}function nS({src:e,alt:t,rest:i,baseDirRel:s,resolveImage:r,resolveRemoteImage:n,cache:o}){const a=e?om(e):"unsupported",l=a==="local"&&e?`local:${bl(s,e)??""}`:e,[h,c]=b.useState(()=>a==="data"?e??null:l?o.get(l)??null:null);return b.useEffect(()=>{if(!e||a==="unsupported"){c(null);return}if(a==="data"){c(e);return}const u=l?o.get(l):void 0;if(u){c(u);return}let p=!0;return(a==="local"?(()=>{const m=bl(s,e);return m?r(m):Promise.resolve(null)})():n(am(e))).then(m=>{p&&(m&&l&&o.set(l,m),c(m))}),()=>{p=!1}},[e,a,s,r,n,o,l]),h?d.jsx("img",{...i,src:h,alt:t,className:"max-w-full rounded",loading:"lazy"}):null}function Au(e){const t=e.trim();if(!t||t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t))return null;const i=t.split(/[/\\]/).filter(s=>s&&s!==".");return i.length===0||i.includes("..")?null:i.join("/")}function ar(e){const t=Au(e);if(!t)return[];const i=t.split("/");if(i.length<=1)return[];const s=[];let r="";for(let n=0;n<i.length-1;n++)r=r?`${r}/${i[n]}`:i[n],s.push(r);return s}function oS(e,t,i=!0){if(!i)return{refreshRels:[],nextSeen:null};const s=[],r=o=>{for(const a of o){if(a.kind==="tool-group"){r(a.children);continue}a.kind!=="tool"||a.state!=="ok"||a.name!=="write"||a.output===null&&a.durationMs===null||a.summary&&s.push({key:a.key,rel:Au(a.summary)})}};r(e);const n=new Set(s.map(o=>o.key));return t===null?{refreshRels:[],nextSeen:n}:{refreshRels:s.filter(o=>!t.has(o.key)&&o.rel).map(o=>o.rel),nextSeen:n}}const ja="\0preview";function Ru(e){return`${e}${ja}`}function Lu(e){return e.endsWith(ja)}function Ri(e){return Lu(e)?e.slice(0,-ja.length):e}function aS(e,t){return e===t||e.startsWith(`${t}/`)}function po(e,t){return aS(Ri(e),t)}function lS(e,t){const i=e.trim();return!i||i===t?"cancel":"commit"}function lr(e,t,i){const s=Lu(e),r=Ri(e);let n=null;return r===t?n=i:r.startsWith(`${t}/`)&&(n=i+r.slice(t.length)),n==null?null:s?Ru(n):n}function hS(e){return e==="preview"?"source":"preview"}function dS(e,t){const i=Ri(e),s=[{id:"copy-path",rel:i,mode:"absolute"}];return t&&s.push({id:"reveal",rel:i}),s}function ds(e,t,i){return e.some(s=>s.epoch>i&&po(t,s.rel))}async function cS(e,t){const{revision:i,migrating:s}=t();if(s)return null;const r=await e(),n=t();return n.migrating||n.revision!==i?null:r}function Nh(e,t){return t===null?{...e,conflict:!0}:e.dirty?t!==e.contents&&t!==e.draft?{...e,conflict:!0}:e:t===e.draft&&!e.tooLarge?e:{...e,contents:t,draft:t,version:e.version+1,conflict:!1,tooLarge:!1}}function fo(e,t,i,s){const r=e.indexOf(t);if(r<0)return[];switch(i){case"self":return[t];case"others":return e.filter(n=>n!==t);case"right":return e.slice(r+1);case"saved":return e.filter(n=>!0);case"all":return[...e]}}const uS={theme:pa,disableFileHeader:!0,overflow:"scroll",preferredHighlighter:"shiki-js"};function pS(e){return new Fg(e)}function fS(e,t){return e?`${e}/${t}`:t}function Vi(e){return e.split("/").pop()||e}function mS(e){const t=e.lastIndexOf("/");return t<0?"":e.slice(0,t)}const xn=[];function gS({conversationId:e,projectId:t}){const{t:i}=he(),s=ua(uS),r=kg("files"),n=b.useMemo(()=>({conversationId:e,projectId:t}),[e,t]),o=ue(P=>P.workspaceRevisionByConversation[e]??0),a=ue(P=>!!P.conversations[e]?.workspaceMigrating),l=b.useCallback(P=>cS(()=>window.electronAPI.workspaceFiles.read({...n,rel:P}),()=>{const B=ue.getState();return{revision:B.workspaceRevisionByConversation[e]??0,migrating:!!B.conversations[e]?.workspaceMigrating}}),[e,n]),[h,c]=b.useState(!1),[u,p]=b.useState([]),[f,m]=b.useState(null),g=Pg(),_=b.useRef(g);_.current=g;const E=ga(),[C,T]=b.useState(!0),x=b.useRef(null),[A,k]=b.useState(0);b.useEffect(()=>{const P=x.current;if(!P||typeof ResizeObserver>"u")return;const B=new ResizeObserver(F=>{const V=F.at(-1)?.contentRect.width;V!==void 0&&k(Math.round(V))});return B.observe(P),()=>B.disconnect()},[]);const N=De(P=>lm(P.filesTreeWidth,A)),O=De(P=>P.nudgeFilesTreeWidth),z=De(P=>P.resetFilesTreeWidth),R=b.useCallback(P=>O(P,A),[O,A]),I=b.useCallback(P=>{m(P),T(!1)},[]);b.useEffect(()=>{f||T(!0)},[f]);const[w,v]=b.useState(0),[S,D]=b.useState(()=>new Set),[y,L]=b.useState(!1),[M,H]=b.useState(null),[j,J]=b.useState(null),[te,ie]=b.useState(null),le=Ue(P=>P.projects.find(B=>B.id===t)),me=le?.kind!=="ssh"&&!window.electronAPI.remote,ne=b.useRef(u);ne.current=u;const W=b.useRef(f);W.current=f;const ge=b.useRef(null),X=b.useRef(null),ve=b.useRef(null),ye=b.useRef(0),ke=b.useRef([]),we=b.useCallback(P=>{ye.current+=1,ke.current.push({epoch:ye.current,rel:P}),ke.current.length>200&&ke.current.splice(0,100)},[]);b.useEffect(()=>{const P=ve.current;if(!P||!f)return;P.querySelector(`[data-file-tab="${CSS.escape(f)}"]`)?.scrollIntoView({inline:"nearest",block:"nearest"})},[f]),b.useEffect(()=>{let P=!0;return fa().then(()=>{P&&c(!0)}),()=>{P=!1}},[]);const it=b.useCallback((P,B)=>{p(F=>F.map(V=>V.rel===P?Nh(V,B):V))},[]),Q=b.useCallback(P=>{p(B=>B.map(F=>F.rel===P?{...F,version:F.version+1}:F))},[]),de=b.useCallback(P=>{kr({title:i(P==="exists"?"A file or folder with that name already exists.":P==="invalid-name"?"Invalid name.":"Could not complete the file action.")})},[i]),Ge=b.useCallback(async(P,B)=>{if(ne.current.find(ae=>ae.rel===P)){B&&p(ae=>ae.map(pe=>pe.rel===P?{...pe,viewMode:B,viewer:void 0}:pe)),I(P);return}if(Ah(P)&&B!=="source"&&!Xs(P,_.current).some(ae=>ae.default)){p(ae=>[...ae,{rel:P,contents:"",draft:"",version:0,dirty:!1,conflict:!1,image:!0}]),I(P),window.electronAPI.workspaceFiles.watchStart({...n,rel:P});return}const V=ye.current,U=await l(P);if(!(!U||ds(ke.current,P,V))){if(!U.ok){if(U.error!=="too-large"){de(U.error);return}p(ae=>[...ae,{rel:P,contents:"",draft:"",version:0,dirty:!1,conflict:!1,tooLarge:!0}]),I(P);return}p(ae=>[...ae,{rel:P,contents:U.content,draft:U.content,version:0,dirty:!1,conflict:!1,viewMode:B,viewer:B?void 0:(()=>{const pe=Xs(P,_.current).find(kt=>kt.default);return pe?os(pe):void 0})()}]),I(P),window.electronAPI.workspaceFiles.watchStart({...n,rel:P})}},[de,l,n,I]),[Be,ni]=b.useState(null),lt=b.useCallback(P=>{const B=ne.current,F=B.filter(V=>!P(V.rel));for(const V of B)P(V.rel)&&window.electronAPI.workspaceFiles.watchStop({...n,rel:V.rel});p(F),m(V=>V&&F.some(U=>U.rel===V)?V:F.at(-1)?.rel??null)},[n]),nn=b.useCallback(P=>{lt(B=>B===P)},[lt]),Fs=b.useCallback(P=>{if(ne.current.find(F=>F.rel===P)?.dirty){ni({kind:"one",rel:P});return}nn(P)},[nn]);b.useEffect(()=>hm(e,()=>{const P=W.current;return!P||ne.current.length===0?!1:(Fs(P),!0)}),[e,Fs]),b.useEffect(()=>()=>{for(const P of ne.current)window.electronAPI.workspaceFiles.watchStop({...n,rel:P.rel})},[n]),b.useEffect(()=>{let P=!0;const B=window.electronAPI.workspaceFiles.onChange(F=>{if(F.conversationId!==e)return;const V=ne.current.find(U=>U.rel===F.rel);if(V){if(V.image){Q(F.rel);return}l(F.rel).then(U=>{P&&U?.ok&&it(F.rel,U.content)})}});return()=>{P=!1,B()}},[it,Q,e,l]);const Vs=ue(P=>P.conversations[e]?.status==="running"),Us=ue(P=>le?.kind==="secretary"?void 0:le?.kind==="scratch"?sc({kind:"scratch",canonicalPath:le.path,conversationId:e})??void 0:P.conversations[e]?.worktree?.path??le?.path),on=ue(P=>P.conversations[e]?.historyBaseIndex),hl=ue(P=>ic(P.conversations[e]?.messages??xn)),an=b.useMemo(()=>{const P=ue.getState().conversations[e];return Yn(P?.messages??xn,Vs,P?.customEntries??[],Us).flatMap(B=>B.kind!=="tool"||B.state!=="ok"?[]:B.name!=="edit"&&B.name!=="write"?[]:B.summary?[B.summary]:[]).join(`
|
|
14
|
+
`)},[e,hl,Us,Vs]);b.useEffect(()=>{let P=!0;const B=new Set(an?an.split(`
|
|
15
|
+
`):[]);for(const F of B){const V=ne.current.find(U=>U.rel===F);if(V){if(V.image){Q(F);continue}l(F).then(U=>{P&&U?.ok&&it(F,U.content)})}}return()=>{P=!1}},[it,Q,l,an]);const ln=b.useRef(null),dl=b.useRef(e),cl=b.useRef(on),Ft=b.useCallback(()=>v(P=>P+1),[]);b.useEffect(()=>{if(o===0||a)return;let P=!0;Ft();for(const B of ne.current){if(B.image){Q(B.rel);continue}const F=Ri(B.rel),V=ye.current;l(F).then(U=>{!P||!U||ds(ke.current,F,V)||p(ae=>ae.map(pe=>pe.rel===B.rel?Nh(pe,U.ok?U.content:null):pe))})}return()=>{P=!1}},[Q,Ft,l,a,o]);const Ks=b.useCallback(P=>{P&&D(B=>{if(B.has(P))return B;const F=new Set(B);return F.add(P),F})},[]),rs=b.useCallback(P=>{P.length!==0&&D(B=>{let F=!1;const V=new Set(B);for(const U of P)!U||V.has(U)||(V.add(U),F=!0);return F?V:B})},[]);b.useEffect(()=>{const P=ue.getState().conversations[e],B=on;(dl.current!==e||cl.current!==B)&&(dl.current=e,cl.current=B,ln.current=null);const F=Yn(P?.messages??xn,Vs,P?.customEntries??[],Us),{refreshRels:V,nextSeen:U}=oS(F,ln.current,dm(P?.messages??[]));ln.current=U,V.length!==0&&(rs(V.flatMap(ar)),Ft())},[Ft,e,hl,rs,on,Us,Vs]);const Zp=b.useCallback(P=>{D(B=>{const F=new Set(B);return F.has(P)?F.delete(P):F.add(P),F})},[]),hn=b.useCallback(P=>{Ks(P),H({parent:P,kind:"file"})},[Ks]),dn=b.useCallback(P=>{Ks(P),H({parent:P,kind:"dir"})},[Ks]),qs=b.useCallback(async(P,B=!1)=>{if(B){await Ge(P,"preview");return}const F=Ru(P);if(ne.current.find(pe=>pe.rel===F)){I(F);return}const U=ye.current,ae=await l(P);if(!(!ae||ds(ke.current,P,U))){if(!ae.ok){de(ae.error);return}p(pe=>[...pe,{rel:F,contents:ae.content,draft:ae.content,version:0,dirty:!1,conflict:!1,preview:!0}]),I(F)}},[de,l,Ge,I]);b.useEffect(()=>cm(e,(P,B,F)=>{ge.current=B?{rel:P,line:B}:null;const V=X.current,U=ne.current.find(ae=>ae.rel===P);if(B&&V?.rel===P&&W.current===P&&U?.viewMode!=="preview"&&!U?.viewer){ge.current=null,V.editor.focus({lineNumber:B});return}F==="markdown"&&!B?qs(P,!0):Ge(P,!B&&(Ah(P)||Xs(P,_.current).some(ae=>ae.default))?void 0:"source")}),[e,Ge,qs]);const Qp=b.useCallback(P=>window.electronAPI.workspaceFiles.readImage({...n,rel:P}).then(B=>B.ok?B.dataUrl:null),[n]),ef=b.useCallback(P=>window.electronAPI.workspaceFiles.readImage({...n,rel:P}),[n]),tf=b.useCallback(P=>window.electronAPI.workspaceFiles.fetchRemoteImage({...n,url:P}).then(B=>B.ok?B.dataUrl:null),[n]),sf=b.useCallback(async P=>{const B=ye.current,F=await l(P);if(!(!F||ds(ke.current,P,B))){if(!F.ok&&F.error!=="too-large"){de(F.error);return}p(V=>V.map(U=>U.rel!==P?U:F.ok?{...U,image:void 0,contents:F.content,draft:F.content,version:U.version+1}:{...U,image:void 0,tooLarge:!0}))}},[de,l]),ul=b.useCallback(async P=>{const B=await window.electronAPI.workspaceFiles.absPath({...n,rel:P});if(!B.ok||!B.local||!B.fileUrl){de(B.ok?"unsupported":B.error);return}const F=`browser:file:${e}:${P}`;ac({conversationId:e,tabId:F,title:Vi(P)});const V=await window.electronAPI.browser.navigate(F,e,B.fileUrl);V.ok||de(V.error)},[e,de,n]),pl=b.useCallback(async P=>{if(ue.getState().conversations[e]?.workspaceMigrating){kr({type:"error",title:i("Wait for the workspace operation to finish before saving.")});return}const B=ne.current.find(ae=>ae.rel===P);if(!B||B.preview||!B.dirty)return;const F=B.draft,V=ye.current,U=await window.electronAPI.workspaceFiles.write({...n,rel:P,content:F});if(!ds(ke.current,P,V)){if(!U.ok){de(U.error);return}p(ae=>ae.map(pe=>pe.rel===P?{...pe,contents:F,dirty:pe.draft!==F,conflict:!1}:pe))}},[e,de,n,i]),rf=b.useCallback(P=>{p(B=>B.map(F=>F.rel===P?{...F,viewMode:hS(F.viewMode)}:F))},[]),fl=b.useCallback((P,B)=>{p(F=>F.map(V=>V.rel===P?{...V,viewer:B}:V))},[]),nf=b.useCallback((P,B)=>{p(F=>F.map(V=>V.rel===P?{...V,draft:B,dirty:B!==V.contents}:V))},[]);b.useEffect(()=>{if(!r)return;const P=B=>{!(pm?B.metaKey:B.ctrlKey)||B.key.toLowerCase()!=="s"||f&&(B.preventDefault(),pl(f))};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[f,pl,r]);const fe=u.find(P=>P.rel===f)??null,cn=fe&&!fe.preview&&!fe.tooLarge&&!fe.image?Xs(fe.rel,g):[],Wi=fe?.viewer?cn.find(P=>os(P)===fe.viewer):void 0,of=b.useMemo(()=>({enabledSelectionAction:!0,renderSelectionAction(P){const B=document.createElement("button");return B.type="button",B.style.cssText="appearance:none;border:0;margin:0;background:transparent;padding:2px 8px;font:inherit;font-size:12px;font-weight:500;line-height:20px;cursor:pointer;color:inherit;border-radius:6px",B.textContent=i("Send to conversation"),B.addEventListener("mouseenter",()=>{B.style.background="color-mix(in lab, currentColor 8%, transparent)"}),B.addEventListener("mouseleave",()=>{B.style.background="transparent"}),B.addEventListener("mousedown",F=>F.preventDefault()),B.addEventListener("click",()=>{const F=P.getSelectionText().trim(),V=f;if(!F||!V){P.close();return}const U=P.selection.start.line+1;let ae=P.selection.end.line+1;P.selection.end.character===0&&ae>U&&(ae-=1);const pe=U===ae?`L${U}`:`L${U}-L${ae}`;Jn({kind:"file",id:`${V}#${pe}`,label:`${Vi(V)}#${pe}`,relativePath:`${V}#${pe}`}),Da(),P.close()}),B},onChange(P){const B=f;if(!B)return;const F=P.contents;p(V=>V.map(U=>U.rel===B?{...U,draft:F,dirty:F!==U.contents}:U))},onAttach(P){if(!f)return;X.current={rel:f,editor:P};const B=ge.current;B?.rel===f&&(ge.current=null,P.focus({lineNumber:B.line}))}}),[f,i]),ml=b.useCallback(async(P,B)=>{const F=await window.electronAPI.workspaceFiles.rename({...n,rel:P,name:B});if(!F.ok)return de(F.error),!1;J(null);const V=F.rel;if(V){we(P);for(const U of ne.current){if(U.preview||U.tooLarge)continue;const ae=lr(U.rel,P,V);ae!=null&&(window.electronAPI.workspaceFiles.watchStop({...n,rel:U.rel}),window.electronAPI.workspaceFiles.watchStart({...n,rel:ae}))}p(U=>U.map(ae=>{const pe=lr(ae.rel,P,V);return pe==null?ae:{...ae,rel:pe}})),m(U=>U==null?U:lr(U,P,V)??U),D(U=>{let ae=!1;const pe=new Set;for(const kt of U){const gl=lr(kt,P,V)??kt;gl!==kt&&(ae=!0),pe.add(gl)}return ae?pe:U})}return Ft(),!0},[Ft,de,we,n]);return d.jsxs(Xg,{createEditor:pS,children:[d.jsxs("div",{ref:x,className:"flex h-full min-h-0 bg-background",children:[d.jsxs("div",{className:Y("flex shrink-0 flex-col overflow-hidden text-sm",E&&(C?"w-full":"hidden")),style:E?void 0:{width:N},children:[d.jsxs("div",{className:"flex justify-end gap-0.5 px-1 py-0.5",children:[d.jsx(Ne,{variant:"ghost",size:"icon-sm",onClick:()=>L(P=>!P),"aria-label":i("Search"),"aria-pressed":y,children:d.jsx(Ud,{})}),d.jsx(Ne,{variant:"ghost",size:"icon-sm",onClick:Ft,"aria-label":i("Refresh"),children:d.jsx(_i,{})})]}),y?d.jsx(jy,{conversationId:e,projectId:t,onOpenFile:P=>{Ge(P)},onClose:()=>L(!1),menu:{local:me,onPreview:P=>{qs(P)},onBrowser:P=>{ul(P)},onCopyPath:P=>{window.electronAPI.workspaceFiles.copyPath({...n,rel:P,mode:"absolute"})},onCopyRel:P=>{window.electronAPI.workspaceFiles.copyPath({...n,rel:P,mode:"relative"})},onCopyFile:P=>{window.electronAPI.workspaceFiles.copyFile({...n,rel:P}).then(B=>{B.ok||de(B.error)})},onReveal:P=>{window.electronAPI.workspaceFiles.reveal({...n,rel:P})},onNewFile:P=>{L(!1),rs(ar(P)),hn(P)},onNewFolder:P=>{L(!1),rs(ar(P)),dn(P)},onRename:(P,B)=>{L(!1),rs(ar(P)),J({rel:P,name:B,at:"tree"})},onDelete:(P,B)=>ie({rel:P,name:B}),onSend:(P,B)=>{Jn({kind:"file",id:P,label:B,relativePath:P})}}}):d.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d.jsx(Fr,{target:{kind:"blank"},local:me,onNewFile:hn,onNewFolder:dn,onCopyPath:()=>{},onCopyRel:()=>{},children:d.jsx("div",{className:"min-h-full",children:d.jsx(Nu,{rel:"",depth:0,conversationId:e,projectId:t,treeEpoch:w,draft:M,renaming:j,local:me,expandedDirs:S,onToggleDir:Zp,onOpen:Ge,onPreview:qs,onBrowser:ul,onCopyPath:P=>{window.electronAPI.workspaceFiles.copyPath({...n,rel:P,mode:"absolute"})},onCopyRel:P=>{window.electronAPI.workspaceFiles.copyPath({...n,rel:P,mode:"relative"})},onCopyFile:P=>{window.electronAPI.workspaceFiles.copyFile({...n,rel:P}).then(B=>{B.ok||de(B.error)})},onReveal:P=>{window.electronAPI.workspaceFiles.reveal({...n,rel:P})},onNewFile:hn,onNewFolder:dn,onRenameStart:(P,B)=>J({rel:P,name:B,at:"tree"}),onDelete:(P,B)=>ie({rel:P,name:B}),onDraftCancel:()=>H(null),onRenameCancel:()=>J(null),onDraftCommit:async(P,B,F)=>{const U=await(B==="dir"?window.electronAPI.workspaceFiles.mkdir:window.electronAPI.workspaceFiles.createFile)({...n,rel:P||void 0,name:F});return U.ok?(H(null),Ft(),B==="file"&&U.rel&&Ge(U.rel),!0):(de(U.error),!1)},onRenameCommit:ml})})})})]}),!E&&d.jsx(Eg,{onResize:R,onReset:z}),d.jsxs("div",{className:Y("flex min-w-0 flex-1 flex-col",E&&C&&"hidden"),children:[u.length>0&&d.jsxs("div",{ref:ve,className:"flex h-[36px] shrink-0 items-center gap-1 overflow-x-auto border-b px-2",children:[E&&d.jsx("button",{type:"button",className:"flex shrink-0 items-center rounded-md px-1 text-muted-foreground hover:bg-muted/50",onClick:()=>T(!0),"aria-label":i("Files"),title:i("Files"),children:d.jsx(Kd,{className:"h-4 w-4"})}),u.map(P=>{const B=j?.rel===P.rel&&j.at==="tab"&&!P.preview,F=d.jsxs("button",{type:"button","data-file-tab":P.rel,className:Y("flex items-center gap-1.5 rounded-md px-2 py-1 text-xs",P.rel===f?"bg-muted font-medium":"text-muted-foreground hover:bg-muted/50"),onClick:()=>{B||m(P.rel)},onDoubleClick:V=>{P.preview||(V.preventDefault(),V.stopPropagation(),J({rel:P.rel,name:Vi(P.rel),at:"tab"}))},children:[B?d.jsx(Ar,{depth:0,kind:"file",variant:"tab",initial:j.name,onCancel:()=>J(null),onCommit:V=>ml(P.rel,V)}):d.jsxs("span",{className:"max-w-36 truncate",children:[Vi(P.preview?Ri(P.rel):P.rel),P.preview?` ${i("Preview")}`:"",P.dirty?"*":""]}),d.jsx("button",{type:"button",className:"text-muted-foreground hover:text-destructive",onClick:V=>{V.stopPropagation(),Fs(P.rel)},children:"×"})]});return d.jsxs(va,{children:[d.jsx(_a,{render:F}),d.jsxs(ba,{className:"min-w-40",children:[dS(P.rel,me).map(V=>V.id==="copy-path"?d.jsx(et,{onClick:()=>{window.electronAPI.workspaceFiles.copyPath({...n,rel:V.rel,mode:V.mode})},children:i("Copy Path")},V.id):d.jsx(et,{onClick:()=>{window.electronAPI.workspaceFiles.reveal({...n,rel:V.rel})},children:i(um())},V.id)),d.jsx(lc,{}),!P.preview&&d.jsx(et,{onClick:()=>J({rel:P.rel,name:Vi(P.rel),at:"tab"}),children:i("Rename")}),d.jsx(et,{onClick:()=>Fs(P.rel),children:i("Close")}),d.jsx(et,{onClick:()=>{const V=ne.current,U=P.rel,ae=V.some(pe=>pe.rel!==U&&pe.dirty);lt(pe=>pe!==U&&!V.find(kt=>kt.rel===pe)?.dirty),ae&&ni({kind:"others",rel:U})},children:i("Close others")}),d.jsx(et,{onClick:()=>{const V=ne.current,U=fo(V.map(pe=>pe.rel),P.rel,"right"),ae=U.some(pe=>V.find(kt=>kt.rel===pe)?.dirty);lt(pe=>U.includes(pe)&&!V.find(kt=>kt.rel===pe)?.dirty),ae&&ni({kind:"right",rel:P.rel})},children:i("Close tabs to the right")}),d.jsx(et,{onClick:()=>{const V=ne.current;lt(U=>!V.find(ae=>ae.rel===U)?.dirty)},children:i("Close saved")}),d.jsx(et,{onClick:()=>{const V=ne.current,U=V.some(ae=>ae.dirty);lt(ae=>!V.find(pe=>pe.rel===ae)?.dirty),U&&ni({kind:"all"})},children:i("Close all")}),d.jsx(et,{onClick:()=>lt(V=>V!==P.rel),children:i("Force close others")}),d.jsx(et,{onClick:()=>lt(()=>!0),children:i("Force close all")})]})]},P.rel)})]}),fe?.conflict&&d.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b px-2 py-1 text-[11px]",children:[d.jsx("span",{children:i("This file changed on disk.")}),d.jsx("button",{type:"button",className:"underline",disabled:a,onClick:()=>{l(Ri(fe.rel)).then(P=>{P?.ok&&p(B=>B.map(F=>F.rel===fe.rel?{...F,contents:P.content,draft:P.content,version:F.version+1,dirty:!1,conflict:!1}:F))})},children:i("Reload")})]}),d.jsxs("div",{className:"relative min-h-0 flex-1",children:[fe&&!fe.preview&&!fe.tooLarge&&(un(fe.rel)||cn.length>0)&&d.jsx("div",{className:"absolute top-2 right-2 z-10 flex gap-1",children:Wi?d.jsxs(Ne,{type:"button",variant:"outline",size:"sm","aria-label":i("View Source"),onClick:()=>fl(fe.rel,void 0),children:[d.jsx(xl,{className:"h-3.5 w-3.5"}),i("View Source")]}):d.jsxs(d.Fragment,{children:[cn.map(P=>d.jsxs(Ne,{type:"button",variant:"outline",size:"sm","aria-label":P.title,title:P.pluginName,onClick:()=>fl(fe.rel,os(P)),children:[d.jsx(wl,{className:"h-3.5 w-3.5"}),P.title]},os(P))),un(fe.rel)&&d.jsxs(Ne,{type:"button",variant:"outline",size:"sm","aria-label":fe.viewMode==="preview"?i("View Source"):i("Preview"),onClick:()=>rf(fe.rel),children:[fe.viewMode==="preview"?d.jsx(xl,{className:"h-3.5 w-3.5"}):d.jsx(wl,{className:"h-3.5 w-3.5"}),fe.viewMode==="preview"?i("View Source"):i("Preview")]})]})}),!h||!fe?d.jsx("div",{className:"flex h-full items-center justify-center px-3 text-center text-sm text-muted-foreground",children:i(h?"Open a file from the tree.":"Loading...")}):fe.tooLarge?d.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground",children:i("This file is too large to open in the editor.")}):fe.image?d.jsx(By,{rel:fe.rel,version:fe.version,resolveImage:ef,onOpenSource:()=>{sf(fe.rel)}},fe.rel):Wi?d.jsx(Zr,{pluginId:Wi.pluginId,entry:Wi.entry,title:Wi.title,sessionId:e,file:{rel:fe.rel,text:fe.draft,onEdit:P=>nf(fe.rel,P)}},`${fe.rel}:${os(Wi)}`):fe.preview||fe.viewMode==="preview"&&un(fe.rel)?d.jsx("div",{className:"h-full overflow-auto px-3 py-2 text-sm",children:d.jsx(rS,{text:fe.preview?fe.contents:fe.draft,baseDirRel:mS(Ri(fe.rel)),resolveImage:Qp,resolveRemoteImage:tf})}):d.jsx(Jg,{style:{height:"100%",overflow:"auto"},children:d.jsx(av,{file:{name:Vi(fe.rel),contents:fe.draft},disableWorkerPool:!0,edit:!0,editorOptions:of,options:s},`${fe.rel}:${fe.version}`)})]})]})]}),d.jsx(qn,{open:Be!==null,onOpenChange:P=>{P||ni(null)},title:i("Unsaved changes"),description:Be?.kind==="one"?i("This file has unsaved changes. Close anyway?"):i("Some files have unsaved changes. Close anyway?"),confirmLabel:i("Close"),onConfirm:()=>{if(Be){if(Be.kind==="one"&&Be.rel)nn(Be.rel);else if(Be.kind==="others"&&Be.rel){const P=Be.rel;lt(B=>B!==P)}else if(Be.kind==="right"&&Be.rel){const P=Be.rel,B=new Set(fo(ne.current.map(F=>F.rel),P,"right"));lt(F=>B.has(F))}else lt(()=>!0);ni(null)}}}),d.jsx(qn,{open:te!==null,onOpenChange:P=>{P||ie(null)},title:i("Delete"),description:i("Delete {{name}} permanently?",{name:te?.name??""}),confirmLabel:i("Delete"),onConfirm:()=>{if(!te)return;const{rel:P}=te;window.electronAPI.workspaceFiles.remove({...n,rel:P}).then(B=>{if(!B.ok){de(B.error);return}we(P),lt(F=>po(F,P)),D(F=>{let V=!1;const U=new Set;for(const ae of F){if(po(ae,P)){V=!0;continue}U.add(ae)}return V?U:F}),ie(null),Ft()})}})]})}function Ar({depth:e,kind:t,initial:i,onCancel:s,onCommit:r,variant:n="tree"}){const[o,a]=b.useState(i),l=b.useRef(null),h=b.useRef(!0),c=b.useRef(!1);b.useEffect(()=>{const p=window.setTimeout(()=>{const m=l.current;m&&(m.focus(),m.select())},0),f=window.setTimeout(()=>{h.current=!1},50);return()=>{window.clearTimeout(p),window.clearTimeout(f)}},[]);const u=p=>{if(!c.current){if(p==="commit"&&lS(o,i)==="commit"){c.current=!0,r(o.trim()).then(f=>{f||(c.current=!1,l.current?.focus())});return}c.current=!0,s()}};return d.jsx("input",{ref:l,className:n==="tab"?"max-w-36 rounded-sm border bg-background px-1 py-0 text-xs outline-none":"mx-1 my-0.5 w-[calc(100%-0.5rem)] rounded-sm border bg-background px-1 py-0.5 text-sm outline-none",style:n==="tree"?{marginLeft:8+e*12}:void 0,value:o,onChange:p=>a(p.target.value),onPointerDown:p=>p.stopPropagation(),onClick:p=>p.stopPropagation(),onBlur:()=>{if(h.current){l.current?.focus();return}u("commit")},onKeyDown:p=>{p.nativeEvent.isComposing||(p.key==="Escape"&&(p.preventDefault(),u("cancel")),p.key==="Enter"&&(p.preventDefault(),u("commit")))},"aria-label":t==="dir"?"New Folder":"New File"})}function Nu({rel:e,depth:t,conversationId:i,projectId:s,treeEpoch:r,...n}){const[o,a]=b.useState(null);if(b.useEffect(()=>{let h=!0;return window.electronAPI.workspaceFiles.listDir({conversationId:i,projectId:s,rel:e||void 0}).then(c=>{h&&a(c.ok?c.entries:[])}),()=>{h=!1}},[i,s,e,r]),!o)return d.jsx("div",{className:"px-2 py-1 text-muted-foreground",children:"…"});const l=n.draft?.parent===e;return d.jsxs("div",{children:[o.map(h=>{const c=fS(e,h.name),u=n.expandedDirs.has(c);if(h.kind==="dir"){const f=n.renaming?.rel===c&&n.renaming.at==="tree"?d.jsx(Ar,{depth:t,kind:"dir",initial:h.name,onCancel:n.onRenameCancel,onCommit:m=>n.onRenameCommit(c,m)}):d.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 px-2 py-1 text-left hover:bg-muted/60",style:{paddingLeft:8+t*12},onClick:()=>n.onToggleDir(c),children:[d.jsx(zs,{className:Y("h-3.5 w-3.5 shrink-0",u&&"rotate-90")}),(()=>{const m=Vr(h.name,!0,u);return d.jsx(m,{className:Y("h-4 w-4 shrink-0",Ur(h.name,!0))})})(),d.jsx("span",{className:"truncate",children:h.name})]});return d.jsxs("div",{children:[d.jsx(Fr,{target:{kind:"dir",rel:c,name:h.name},local:n.local,onNewFile:n.onNewFile,onNewFolder:n.onNewFolder,onCopyPath:n.onCopyPath,onCopyRel:n.onCopyRel,onReveal:n.onReveal,onRename:n.onRenameStart,onDelete:n.onDelete,children:f}),u&&d.jsx(Nu,{rel:c,depth:t+1,conversationId:i,projectId:s,treeEpoch:r,...n})]},c)}return d.jsx(vS,{rel:c,name:h.name,depth:t,renaming:n.renaming?.rel===c&&n.renaming.at==="tree",handlers:n},c)}),l&&n.draft&&d.jsx(Ar,{depth:t,kind:n.draft.kind,initial:"",onCancel:n.onDraftCancel,onCommit:h=>n.onDraftCommit(e,n.draft.kind,h)})]})}function vS({rel:e,name:t,depth:i,renaming:s,handlers:r}){const{setNodeRef:n,listeners:o,isDragging:a}=Tg({id:`workspace-file:${e}`,data:{type:"workspace-file",relativePath:e,name:t}}),l=s?d.jsx(Ar,{depth:i,kind:"file",initial:t,onCancel:r.onRenameCancel,onCommit:h=>r.onRenameCommit(e,h)}):d.jsxs("button",{type:"button",ref:n,...o,style:{paddingLeft:20+i*12,opacity:a?.4:void 0},className:"flex w-full cursor-default items-center gap-1.5 px-2 py-1 text-left hover:bg-muted/60",onClick:()=>r.onOpen(e),children:[(()=>{const h=Vr(t,!1);return d.jsx(h,{className:Y("h-4 w-4 shrink-0",Ur(t,!1))})})(),d.jsx("span",{className:"truncate",children:t})]});return d.jsx(Fr,{target:{kind:"file",rel:e,name:t},local:r.local,onNewFile:r.onNewFile,onNewFolder:r.onNewFolder,onView:r.onOpen,onPreview:r.onPreview,onBrowser:r.onBrowser,onCopyPath:r.onCopyPath,onCopyRel:r.onCopyRel,onCopyFile:r.onCopyFile,onReveal:r.onReveal,onRename:r.onRenameStart,onDelete:r.onDelete,onSend:(h,c)=>{Jn({kind:"file",id:h,label:c,relativePath:h})},children:l})}const mo=new Set,go=new Set;function ki(){for(const e of go)e()}function _S({panelId:e,conversationId:t,api:i,containerApi:s}){const r=b.useRef(null);return b.useEffect(()=>{const n=r.current;if(!n)return;const o={panelId:e,conversationId:t,el:n,api:i};mo.add(o),ki();const a=new ResizeObserver(ki);a.observe(n);const l=[i.onDidVisibilityChange(ki),i.onDidActiveChange(ki),i.onDidDimensionsChange(ki),s.onDidLayoutChange(ki)];return()=>{mo.delete(o),a.disconnect();for(const h of l)h.dispose();ki()}},[e,t,i,s]),d.jsx("div",{ref:r,"data-global-plugin-slot":e,className:"h-full w-full"})}function bS(e,t){return e===t||!!e&&!!t&&e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function Mh(e,t){if(t){for(const i of mo)if(!(i.panelId!==e||i.conversationId!==t)&&i.el.isConnected&&i.api.isVisible)return i}}function wS(){const e=ue(p=>p.activeId),t=wa(e),i=De(p=>p.liveGlobalTabs),s=Os(),r=b.useRef(null),[n,o]=b.useState({}),[a,l]=b.useState({}),[h,c]=b.useState(!1);b.useEffect(()=>{const p=m=>{m.target instanceof Element&&m.target.closest(".dv-dockview")&&c(!0)},f=()=>c(!1);return document.addEventListener("dragstart",p,!0),document.addEventListener("dragend",f,!0),document.addEventListener("drop",f,!0),()=>{document.removeEventListener("dragstart",p,!0),document.removeEventListener("dragend",f,!0),document.removeEventListener("drop",f,!0)}},[]);const u=b.useCallback(()=>{const p=r.current;if(!p)return;const f=p.getBoundingClientRect(),m={};for(const _ of i){const C=(t?Mh(_,e):void 0)?.el.getBoundingClientRect();m[_]=C&&C.width>0&&C.height>0?{left:C.left-f.left,top:C.top-f.top,width:C.width,height:C.height}:null}o(_=>{let E=!1;const C={..._};for(const[T,x]of Object.entries(m))x&&!bS(_[T],x)&&(C[T]=x,E=!0);return E?C:_});const g=Object.fromEntries(Object.entries(m).map(([_,E])=>[_,E!==null]));l(_=>{const E=new Set([...Object.keys(_),...Object.keys(g)]);for(const C of E)if(_[C]!==g[C])return g;return _})},[e,i,t]);return b.useLayoutEffect(u,[u]),b.useEffect(()=>{let p=0;const f=()=>{p||(p=requestAnimationFrame(()=>{p=0,u()}))};go.add(f);const m=new ResizeObserver(f);r.current&&m.observe(r.current),window.addEventListener("resize",f);const g=()=>{const _=document.activeElement;if(!_||!r.current?.contains(_))return;const E=_.closest("[data-global-plugin]")?.dataset.globalPlugin;E&&Mh(E,ue.getState().activeId)?.api.setActive()};return window.addEventListener("blur",g),()=>{p&&cancelAnimationFrame(p),go.delete(f),m.disconnect(),window.removeEventListener("resize",f),window.removeEventListener("blur",g)}},[u]),d.jsx("div",{ref:r,className:"enso-global-plugin-layer pointer-events-none absolute inset-0",children:i.map(p=>{const f=s.find(_=>fm(_)===p);if(!f)return null;const m=n[p],g={position:"absolute",left:m?.left??0,top:m?.top??0,width:m?.width??"100%",height:m?.height??"100%",visibility:a[p]&&!h?"visible":"hidden"};return d.jsx("div",{"data-global-plugin":p,style:g,children:d.jsx(Zr,{pluginId:f.pluginId,entry:f.entry,title:f.title,sessionId:e})},p)})})}function Oh(e){return e.closest(".dv-tabs-overflow-container")}function Gh(e){const t=new Map;for(const i of e.children){if(!i.classList.contains("dv-tab"))continue;const s=i.querySelector("[data-panel-id]")?.getAttribute("data-panel-id");s&&t.set(s,i)}return t}function yS(e){for(const t of e.children)if(t.classList.contains("dv-tab"))return!0;return!1}function SS(e){const t=e.closest(".dv-popover-anchor"),i=e.parentElement;if(t&&i&&i.parentElement===t){i.remove();return}e.remove()}function zh(e,t){for(const i of t)i.parentElement===e&&i.remove();yS(e)||SS(e)}function Mu(e){return e.startsWith("pinned-terminal:")||/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(e)}function Ou(e){const t=e.indexOf(":",7);return e.startsWith("plugin:")&&t>7&&t<e.length-1}function xS(e){if(e==="changes"||e==="files"||e==="workflow")return e;if(e==="browser"||e.startsWith("browser:"))return"browser";if(e.startsWith("btw:"))return"btw";if(Ou(e))return e;if(Mu(e))return"terminal"}function Cn(e,t){return e.some(t)}function CS(e){if(!Array.isArray(e.pinnedTabs))return[];const t=[...e.openPanelIds],i=[];for(const s of e.pinnedTabs)if(s==="terminal"&&!e.secretary){if(Cn(t,Mu))continue;i.push({kind:"terminal"}),t.push("pinned-terminal:planned")}else if(s==="changes"&&!e.secretary){if(t.includes("changes"))continue;i.push({kind:"changes"}),t.push("changes")}else if(s==="files"&&!e.secretary){if(t.includes("files"))continue;i.push({kind:"files"}),t.push("files")}else if(s==="browser"){if(Cn(t,r=>r==="browser"||r.startsWith("browser:")))continue;i.push({kind:"browser"}),t.push("browser:planned")}else if(s==="btw"&&!e.secretary){if(Cn(t,r=>r.startsWith("btw:")))continue;i.push({kind:"btw"}),t.push("btw:planned")}else if(s==="workflow"&&e.workflowAvailable&&!e.secretary){if(t.includes("workflow"))continue;i.push({kind:"workflow"}),t.push("workflow")}else if(typeof s=="string"&&s.startsWith("plugin:")){const r=e.pluginViews.find(n=>`plugin:${n.pluginId}:${n.id}`===s);if(!r||e.secretary&&!e.secretaryPluginIds?.includes(r.pluginId)||t.includes(s))continue;i.push({kind:"plugin",pluginId:r.pluginId,viewId:r.id}),t.push(s)}return i}function Rr(e,t,i,s){const r=e.getPanel("secretary");if(r){r.focus();return}e.addPanel({id:"secretary",component:"secretary",title:s,params:{conversationId:t,projectId:i}})}function DS(){let e=!1;return({secretary:t,open:i,active:s,ready:r})=>i?e||!t||!s||!r?!1:(e=!0,!0):(e=!1,!1)}const Bh="plugin:";function kS(e,t){const i=new Set(t??[]);return e.filter(s=>i.has(s.pluginId))}function PS(e,t,i=new Set){if(!t)return[];const s=new Set(t);return e.filter(r=>{if(!r.startsWith(Bh)||i.has(r))return!1;const n=r.slice(Bh.length).split(":")[0]??"";return!s.has(n)})}function ES({checked:e,onClick:t}){const{t:i}=he();return d.jsxs(et,{"data-enso":"side-tab-show-everywhere",role:"menuitemcheckbox","aria-checked":e,onClick:t,children:[d.jsx("span",{className:"min-w-0 flex-1",children:i("Show in all sessions")}),e?d.jsx(bi,{className:"size-3.5 text-primary"}):null]})}function TS({title:e,global:t}){const{t:i}=he(),s=i("Show in all sessions");return d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"min-w-0 max-w-32 truncate",children:e}),t?d.jsx("span",{"data-enso":"side-tab-global",role:"img","aria-label":s,title:s,className:"shrink-0 text-primary",children:d.jsx(pv,{className:"h-3 w-3"})}):null]})}var IS=2,AS=1,RS=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._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 t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),r=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,l=o.right+o.left,h=s-a,c=r-l-t;return{cols:Math.max(IS,Math.floor(c/e.css.cell.width)),rows:Math.max(AS,Math.floor(h/e.css.cell.height))}}};var LS=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?jh.isErrorNoTelemetry(t)?new jh(t.message+`
|
|
16
|
+
|
|
17
|
+
`+t.stack):new Error(t.message+`
|
|
18
|
+
|
|
19
|
+
`+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(i=>{i(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},NS=new LS;function Dn(e){MS(e)||NS.onUnexpectedError(e)}var vo="Canceled";function MS(e){return e instanceof OS?!0:e instanceof Error&&e.name===vo&&e.message===vo}var OS=class extends Error{constructor(){super(vo),this.name=this.message}},jh=class _o extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof _o)return t;let i=new _o;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},GS;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(GS||={});function zS(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var Gu;(e=>{function t(x){return x&&typeof x=="object"&&typeof x[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(x){yield x}e.single=r;function n(x){return t(x)?x:r(x)}e.wrap=n;function o(x){return x||i}e.from=o;function*a(x){for(let A=x.length-1;A>=0;A--)yield x[A]}e.reverse=a;function l(x){return!x||x[Symbol.iterator]().next().done===!0}e.isEmpty=l;function h(x){return x[Symbol.iterator]().next().value}e.first=h;function c(x,A){let k=0;for(let N of x)if(A(N,k++))return!0;return!1}e.some=c;function u(x,A){for(let k of x)if(A(k))return k}e.find=u;function*p(x,A){for(let k of x)A(k)&&(yield k)}e.filter=p;function*f(x,A){let k=0;for(let N of x)yield A(N,k++)}e.map=f;function*m(x,A){let k=0;for(let N of x)yield*A(N,k++)}e.flatMap=m;function*g(...x){for(let A of x)yield*A}e.concat=g;function _(x,A,k){let N=k;for(let O of x)N=A(N,O);return N}e.reduce=_;function*E(x,A,k=x.length){for(A<0&&(A+=x.length),k<0?k+=x.length:k>x.length&&(k=x.length);A<k;A++)yield x[A]}e.slice=E;function C(x,A=Number.POSITIVE_INFINITY){let k=[];if(A===0)return[k,x];let N=x[Symbol.iterator]();for(let O=0;O<A;O++){let z=N.next();if(z.done)return[k,e.empty()];k.push(z.value)}return[k,{[Symbol.iterator](){return N}}]}e.consume=C;async function T(x){let A=[];for await(let k of x)A.push(k);return Promise.resolve(A)}e.asyncToArray=T})(Gu||={});function ks(e){if(Gu.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function zu(...e){return es(()=>ks(e))}function es(e){return{dispose:zS(()=>{e()})}}var Bu=class ju{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ks(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?ju.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Bu.DISABLE_DISPOSED_WARNING=!1;var $a=Bu,Ci=class{constructor(){this._store=new $a,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Ci.None=Object.freeze({dispose(){}});var Lr=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},BS=globalThis.performance&&typeof globalThis.performance.now=="function",jS=class $u{static create(t){return new $u(t)}constructor(t){this._now=BS&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Wa;(e=>{e.None=()=>Ci.None;function t(w,v){return u(w,()=>{},0,void 0,!0,void 0,v)}e.defer=t;function i(w){return(v,S=null,D)=>{let y=!1,L;return L=w(M=>{if(!y)return L?L.dispose():y=!0,v.call(S,M)},null,D),y&&L.dispose(),L}}e.once=i;function s(w,v,S){return h((D,y=null,L)=>w(M=>D.call(y,v(M)),null,L),S)}e.map=s;function r(w,v,S){return h((D,y=null,L)=>w(M=>{v(M),D.call(y,M)},null,L),S)}e.forEach=r;function n(w,v,S){return h((D,y=null,L)=>w(M=>v(M)&&D.call(y,M),null,L),S)}e.filter=n;function o(w){return w}e.signal=o;function a(...w){return(v,S=null,D)=>{let y=zu(...w.map(L=>L(M=>v.call(S,M))));return c(y,D)}}e.any=a;function l(w,v,S,D){let y=S;return s(w,L=>(y=v(y,L),y),D)}e.reduce=l;function h(w,v){let S,D={onWillAddFirstListener(){S=w(y.fire,y)},onDidRemoveLastListener(){S?.dispose()}},y=new Gt(D);return v?.add(y),y.event}function c(w,v){return v instanceof Array?v.push(w):v&&v.add(w),w}function u(w,v,S=100,D=!1,y=!1,L,M){let H,j,J,te=0,ie,le={leakWarningThreshold:L,onWillAddFirstListener(){H=w(ne=>{te++,j=v(j,ne),D&&!J&&(me.fire(j),j=void 0),ie=()=>{let W=j;j=void 0,J=void 0,(!D||te>1)&&me.fire(W),te=0},typeof S=="number"?(clearTimeout(J),J=setTimeout(ie,S)):J===void 0&&(J=0,queueMicrotask(ie))})},onWillRemoveListener(){y&&te>0&&ie?.()},onDidRemoveLastListener(){ie=void 0,H.dispose()}},me=new Gt(le);return M?.add(me),me.event}e.debounce=u;function p(w,v=0,S){return e.debounce(w,(D,y)=>D?(D.push(y),D):[y],v,void 0,!0,void 0,S)}e.accumulate=p;function f(w,v=(D,y)=>D===y,S){let D=!0,y;return n(w,L=>{let M=D||!v(L,y);return D=!1,y=L,M},S)}e.latch=f;function m(w,v,S){return[e.filter(w,v,S),e.filter(w,D=>!v(D),S)]}e.split=m;function g(w,v=!1,S=[],D){let y=S.slice(),L=w(j=>{y?y.push(j):H.fire(j)});D&&D.add(L);let M=()=>{y?.forEach(j=>H.fire(j)),y=null},H=new Gt({onWillAddFirstListener(){L||(L=w(j=>H.fire(j)),D&&D.add(L))},onDidAddFirstListener(){y&&(v?setTimeout(M):M())},onDidRemoveLastListener(){L&&L.dispose(),L=null}});return D&&D.add(H),H.event}e.buffer=g;function _(w,v){return(S,D,y)=>{let L=v(new C);return w(function(M){let H=L.evaluate(M);H!==E&&S.call(D,H)},void 0,y)}}e.chain=_;let E=Symbol("HaltChainable");class C{constructor(){this.steps=[]}map(v){return this.steps.push(v),this}forEach(v){return this.steps.push(S=>(v(S),S)),this}filter(v){return this.steps.push(S=>v(S)?S:E),this}reduce(v,S){let D=S;return this.steps.push(y=>(D=v(D,y),D)),this}latch(v=(S,D)=>S===D){let S=!0,D;return this.steps.push(y=>{let L=S||!v(y,D);return S=!1,D=y,L?y:E}),this}evaluate(v){for(let S of this.steps)if(v=S(v),v===E)break;return v}}function T(w,v,S=D=>D){let D=(...H)=>M.fire(S(...H)),y=()=>w.on(v,D),L=()=>w.removeListener(v,D),M=new Gt({onWillAddFirstListener:y,onDidRemoveLastListener:L});return M.event}e.fromNodeEventEmitter=T;function x(w,v,S=D=>D){let D=(...H)=>M.fire(S(...H)),y=()=>w.addEventListener(v,D),L=()=>w.removeEventListener(v,D),M=new Gt({onWillAddFirstListener:y,onDidRemoveLastListener:L});return M.event}e.fromDOMEventEmitter=x;function A(w){return new Promise(v=>i(w)(v))}e.toPromise=A;function k(w){let v=new Gt;return w.then(S=>{v.fire(S)},()=>{v.fire(void 0)}).finally(()=>{v.dispose()}),v.event}e.fromPromise=k;function N(w,v){return w(S=>v.fire(S))}e.forward=N;function O(w,v,S){return v(S),w(D=>v(D))}e.runAndSubscribe=O;class z{constructor(v,S){this._observable=v,this._counter=0,this._hasChanged=!1;let D={onWillAddFirstListener:()=>{v.addObserver(this)},onDidRemoveLastListener:()=>{v.removeObserver(this)}};this.emitter=new Gt(D),S&&S.add(this.emitter)}beginUpdate(v){this._counter++}handlePossibleChange(v){}handleChange(v,S){this._hasChanged=!0}endUpdate(v){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function R(w,v){return new z(w,v).emitter.event}e.fromObservable=R;function I(w){return(v,S,D)=>{let y=0,L=!1,M={beginUpdate(){y++},endUpdate(){y--,y===0&&(w.reportChanges(),L&&(L=!1,v.call(S)))},handlePossibleChange(){},handleChange(){L=!0}};w.addObserver(M),w.reportChanges();let H={dispose(){w.removeObserver(M)}};return D instanceof $a?D.add(H):Array.isArray(D)&&D.push(H),H}}e.fromObservableLight=I})(Wa||={});var bo=class wo{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${wo._idPool++}`,wo.all.add(this)}start(t){this._stopWatch=new jS,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};bo.all=new Set,bo._idPool=0;var $S=bo,WS=-1,Wu=class Hu{constructor(t,i,s=(Hu._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let l=new VS(a,n);this._errorHandler(l)}return()=>{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,r]of this._stacks)(!t||i<r)&&(t=[s,r],i=r);return t}};Wu._idPool=1;var HS=Wu,FS=class Fu{constructor(t){this.value=t}static create(){let t=new Error;return new Fu(t.stack??"")}print(){console.warn(this.value.split(`
|
|
20
|
+
`).slice(2).join(`
|
|
21
|
+
`))}},VS=class extends Error{constructor(t,i){super(t),this.name="ListenerLeakError",this.stack=i}},US=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},KS=0,kn=class{constructor(t){this.value=t,this.id=KS++}},qS=2,YS,Gt=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new HS(t?.onListenerError??Dn,this._options?.leakWarningThreshold??WS):void 0,this._perfMon=this._options?._profName?new $S(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,i,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],h=new US(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||Dn)(h),Ci.None}if(this._disposed)return Ci.None;i&&(t=t.bind(i));let r=new kn(t),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=FS.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof kn?(this._deliveryQueue??=new XS,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=es(()=>{n?.(),this._removeListener(r)});return s instanceof $a?s.add(o):Array.isArray(s)&&s.push(o),o},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let i=this._listeners,s=i.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let r=this._deliveryQueue.current===this;if(this._size*qS<=i.length){let n=0;for(let o=0;o<i.length;o++)i[o]?i[n++]=i[o]:r&&(this._deliveryQueue.end--,n<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=n}}_deliver(t,i){if(!t)return;let s=this._options?.onListenerError||Dn;if(!s){t.value(i);return}try{t.value(i)}catch(r){s(r)}}_deliverQueue(t){let i=t.current._listeners;for(;t.i<t.end;)this._deliver(i[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof kn)this._deliver(this._listeners,t);else{let i=this._deliveryQueue;i.enqueue(this,t,this._listeners.length),this._deliverQueue(i)}this._perfMon?.stop()}hasListeners(){return this._size>0}},XS=class{constructor(){this.i=-1,this.end=0}enqueue(t,i,s){this.i=0,this.end=s,this.current=t,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Vu=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),JS;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof ZS?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Wa.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Vu})})(JS||={});var ZS=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Vu:(this._emitter||(this._emitter=new Gt),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Xi="en",Pn=!1,hr,vr=Xi,$h=Xi,QS,Xt,Ni=globalThis,ft;typeof Ni.vscode<"u"&&typeof Ni.vscode.process<"u"?ft=Ni.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(ft=process);var ex=typeof ft?.versions?.electron=="string",tx=ex&&ft?.type==="renderer";if(typeof ft=="object"){ft.platform,ft.platform,Pn=ft.platform==="linux",Pn&&ft.env.SNAP&&ft.env.SNAP_REVISION,ft.env.CI||ft.env.BUILD_ARTIFACTSTAGINGDIRECTORY,hr=Xi,vr=Xi;let e=ft.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);hr=t.userLocale,$h=t.osLocale,vr=t.resolvedLanguage||Xi,QS=t.languagePack?.translationsConfigFile}catch{}}else typeof navigator=="object"&&!tx?(Xt=navigator.userAgent,Xt.indexOf("Windows")>=0,Xt.indexOf("Macintosh")>=0,(Xt.indexOf("Macintosh")>=0||Xt.indexOf("iPad")>=0||Xt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Pn=Xt.indexOf("Linux")>=0,Xt?.indexOf("Mobi")>=0,vr=globalThis._VSCODE_NLS_LANGUAGE||Xi,hr=navigator.language.toLowerCase(),$h=hr):console.error("Unable to resolve platform.");var $t=Xt,hi=vr,ix;(e=>{function t(){return hi}e.value=t;function i(){return hi.length===2?hi==="en":hi.length>=3?hi[0]==="e"&&hi[1]==="n"&&hi[2]==="-":!1}e.isDefaultVariant=i;function s(){return hi==="en"}e.isDefault=s})(ix||={});var sx=typeof Ni.postMessage=="function"&&!Ni.importScripts;(()=>{if(sx){let e=[];Ni.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),Ni.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var rx=!!($t&&$t.indexOf("Chrome")>=0);$t&&$t.indexOf("Firefox")>=0;!rx&&$t&&$t.indexOf("Safari")>=0;$t&&$t.indexOf("Edg/")>=0;$t&&$t.indexOf("Android")>=0;function Uu(e,t=0,i){let s=setTimeout(()=>{e()},t);return es(()=>{clearTimeout(s)})}var nx;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})(nx||={});var Wh=class _t{static fromArray(t){return new _t(i=>{i.emitMany(t)})}static fromPromise(t){return new _t(async i=>{i.emitMany(await t)})}static fromPromises(t){return new _t(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new _t(async i=>{await Promise.all(t.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new Gt,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Wa.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,i){return new _t(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return _t.map(this,t)}static filter(t,i){return new _t(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return _t.filter(this,t)}static coalesce(t){return _t.filter(t,i=>!!i)}coalesce(){return _t.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return _t.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Wh.EMPTY=Wh.fromArray([]);var ox=class extends Ci{constructor(t){super(),this._terminal=t,this._linesCacheTimeout=this._register(new Lr),this._linesCacheDisposables=this._register(new Lr),this._register(es(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=zu(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=Uu(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(t){return this._linesCache?.[t]}setLineInCache(t,i){this._linesCache&&(this._linesCache[t]=i)}translateBufferLineToStringWithWrap(t,i){let s=[],r=[0],n=this._terminal.buffer.active.getLine(t);for(;n;){let o=this._terminal.buffer.active.getLine(t+1),a=o?o.isWrapped:!1,l=n.translateToString(!a&&i);if(a&&o){let h=n.getCell(n.length-1);h&&h.getCode()===0&&h.getWidth()===1&&o.getCell(0)?.getWidth()===2&&(l=l.slice(0,-1))}if(s.push(l),a)r.push(r[r.length-1]+l.length);else break;t++,n=o}return[s.join(""),r]}},ax=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(t){this._cachedSearchTerm=t}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(t){this._lastSearchOptions=t}isValidSearchTerm(t){return!!(t&&t.length>0)}didOptionsChange(t){return this._lastSearchOptions?t?this._lastSearchOptions.caseSensitive!==t.caseSensitive||this._lastSearchOptions.regex!==t.regex||this._lastSearchOptions.wholeWord!==t.wholeWord:!1:!0}shouldUpdateHighlighting(t,i){return i?.decorations?this._cachedSearchTerm===void 0||t!==this._cachedSearchTerm||this.didOptionsChange(i):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},lx=class{constructor(t,i){this._terminal=t,this._lineCache=i}find(t,i,s,r){if(!t||t.length===0){this._terminal.clearSelection();return}if(s>this._terminal.cols)throw new Error(`Invalid col: ${s} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let n={startRow:i,startCol:s},o=this._findInLine(t,n,r);if(!o)for(let a=i+1;a<this._terminal.buffer.active.baseY+this._terminal.rows&&(n.startRow=a,n.startCol=0,o=this._findInLine(t,n,r),!o);a++);return o}findNextWithSelection(t,i,s){if(!t||t.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let n=0,o=0;r&&(s===t?(n=r.end.x,o=r.end.y):(n=r.start.x,o=r.start.y)),this._lineCache.initLinesCache();let a={startRow:o,startCol:n},l=this._findInLine(t,a,i);if(!l)for(let h=o+1;h<this._terminal.buffer.active.baseY+this._terminal.rows&&(a.startRow=h,a.startCol=0,l=this._findInLine(t,a,i),!l);h++);if(!l&&o!==0)for(let h=0;h<o&&(a.startRow=h,a.startCol=0,l=this._findInLine(t,a,i),!l);h++);return!l&&r&&(a.startRow=r.start.y,a.startCol=0,l=this._findInLine(t,a,i)),l}findPreviousWithSelection(t,i,s){if(!t||t.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let n=this._terminal.buffer.active.baseY+this._terminal.rows-1,o=this._terminal.cols,a=!0;this._lineCache.initLinesCache();let l={startRow:n,startCol:o},h;if(r&&(l.startRow=n=r.start.y,l.startCol=o=r.start.x,s!==t&&(h=this._findInLine(t,l,i,!1),h||(l.startRow=n=r.end.y,l.startCol=o=r.end.x))),h||(h=this._findInLine(t,l,i,a)),!h){l.startCol=Math.max(l.startCol,this._terminal.cols);for(let c=n-1;c>=0&&(l.startRow=c,h=this._findInLine(t,l,i,a),!h);c--);}if(!h&&n!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let c=this._terminal.buffer.active.baseY+this._terminal.rows-1;c>=n&&(l.startRow=c,h=this._findInLine(t,l,i,a),!h);c--);return h}_isWholeWord(t,i,s){return(t===0||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(i[t-1]))&&(t+s.length===i.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(i[t+s.length]))}_findInLine(t,i,s={},r=!1){let n=i.startRow,o=i.startCol;if(this._terminal.buffer.active.getLine(n)?.isWrapped){if(r){i.startCol+=this._terminal.cols;return}return i.startRow--,i.startCol+=this._terminal.cols,this._findInLine(t,i,s)}let a=this._lineCache.getLineFromCache(n);a||(a=this._lineCache.translateBufferLineToStringWithWrap(n,!0),this._lineCache.setLineInCache(n,a));let[l,h]=a,c=this._bufferColsToStringOffset(n,o),u=t,p=l;s.regex||(u=s.caseSensitive?t:t.toLowerCase(),p=s.caseSensitive?l:l.toLowerCase());let f=-1;if(s.regex){let m=RegExp(u,s.caseSensitive?"g":"gi"),g;if(r)for(;g=m.exec(p.slice(0,c));)f=m.lastIndex-g[0].length,t=g[0],m.lastIndex-=t.length-1;else g=m.exec(p.slice(c)),g&&g[0].length>0&&(f=c+(m.lastIndex-g[0].length),t=g[0])}else r?c-u.length>=0&&(f=p.lastIndexOf(u,c-u.length)):f=p.indexOf(u,c);if(f>=0){if(s.wholeWord&&!this._isWholeWord(f,p,t))return;let m=0;for(;m<h.length-1&&f>=h[m+1];)m++;let g=m;for(;g<h.length-1&&f+t.length>=h[g+1];)g++;let _=f-h[m],E=f+t.length-h[g],C=this._stringLengthToBufferSize(n+m,_),T=this._stringLengthToBufferSize(n+g,E)-C+this._terminal.cols*(g-m);return{term:t,col:C,row:n+m,size:T}}}_stringLengthToBufferSize(t,i){let s=this._terminal.buffer.active.getLine(t);if(!s)return 0;for(let r=0;r<i;r++){let n=s.getCell(r);if(!n)break;let o=n.getChars();o.length>1&&(i-=o.length-1);let a=s.getCell(r+1);a&&a.getWidth()===0&&i++}return i}_bufferColsToStringOffset(t,i){let s=t,r=0,n=this._terminal.buffer.active.getLine(s);for(;i>0&&n;){for(let o=0;o<i&&o<this._terminal.cols;o++){let a=n.getCell(o);if(!a)break;a.getWidth()&&(r+=a.getCode()===0?1:a.getChars().length)}if(s++,n=this._terminal.buffer.active.getLine(s),n&&!n.isWrapped)break;i-=this._terminal.cols}return r}},hx=class extends Ci{constructor(t){super(),this._terminal=t,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(es(()=>this.clearHighlightDecorations()))}createHighlightDecorations(t,i){this.clearHighlightDecorations();for(let s of t){let r=this._createResultDecorations(s,i,!1);if(r)for(let n of r)this._storeDecoration(n,s)}}createActiveDecoration(t,i){let s=this._createResultDecorations(t,i,!0);if(s)return{decorations:s,match:t,dispose(){ks(s)}}}clearHighlightDecorations(){ks(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(t,i){this._highlightedLines.add(t.marker.line),this._highlightDecorations.push({decoration:t,match:i,dispose(){t.dispose()}})}_applyStyles(t,i,s){t.classList.contains("xterm-find-result-decoration")||(t.classList.add("xterm-find-result-decoration"),i&&(t.style.outline=`1px solid ${i}`)),s&&t.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(t,i,s){let r=[],n=t.col,o=t.size,a=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+t.row;for(;o>0;){let h=Math.min(this._terminal.cols-n,o);r.push([a,n,h]),n=0,o-=h,a++}let l=[];for(let h of r){let c=this._terminal.registerMarker(h[0]),u=this._terminal.registerDecoration({marker:c,x:h[1],width:h[2],backgroundColor:s?i.activeMatchBackground:i.matchBackground,overviewRulerOptions:this._highlightedLines.has(c.line)?void 0:{color:s?i.activeMatchColorOverviewRuler:i.matchOverviewRuler,position:"center"}});if(u){let p=[];p.push(c),p.push(u.onRender(f=>this._applyStyles(f,s?i.activeMatchBorder:i.matchBorder,!1))),p.push(u.onDispose(()=>ks(p))),l.push(u)}}return l.length===0?void 0:l}},dx=class extends Ci{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Gt)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(t){this._selectedDecoration=t}updateResults(t,i){this._searchResults=t.slice(0,i)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(t){for(let i=0;i<this._searchResults.length;i++){let s=this._searchResults[i];if(s.row===t.row&&s.col===t.col&&s.size===t.size)return i}return-1}fireResultsChanged(t){if(!t)return;let i=-1;this._selectedDecoration&&(i=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:i,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},cx=class extends Ci{constructor(t){super(),this._highlightTimeout=this._register(new Lr),this._lineCache=this._register(new Lr),this._state=new ax,this._resultTracker=this._register(new dx),this._highlightLimit=t?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(t){this._terminal=t,this._lineCache.value=new ox(t),this._engine=new lx(t,this._lineCache.value),this._decorationManager=new hx(t),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(es(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=Uu(()=>{let t=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(t,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(t){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),t||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(t,i,s){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=i,this._state.shouldUpdateHighlighting(t,i)&&this._highlightAllMatches(t,i);let r=this._findNextAndSelect(t,i,s);return this._fireResults(i),this._state.cachedSearchTerm=t,r}_highlightAllMatches(t,i){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(t)){this.clearDecorations();return}this.clearDecorations(!0);let s=[],r,n=this._engine.find(t,0,0,i);for(;n&&(r?.row!==n.row||r?.col!==n.col)&&!(s.length>=this._highlightLimit);)r=n,s.push(r),n=this._engine.find(t,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,i);this._resultTracker.updateResults(s,this._highlightLimit),i.decorations&&this._decorationManager.createHighlightDecorations(s,i.decorations)}_findNextAndSelect(t,i,s){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(t,i,this._state.cachedSearchTerm);return this._selectResult(r,i?.decorations,s?.noScroll)}findPrevious(t,i,s){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=i,this._state.shouldUpdateHighlighting(t,i)&&this._highlightAllMatches(t,i);let r=this._findPreviousAndSelect(t,i,s);return this._fireResults(i),this._state.cachedSearchTerm=t,r}_fireResults(t){this._resultTracker.fireResultsChanged(!!t?.decorations)}_findPreviousAndSelect(t,i,s){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(t,i,this._state.cachedSearchTerm);return this._selectResult(r,i?.decorations,s?.noScroll)}_selectResult(t,i,s){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!t)return this._terminal.clearSelection(),!1;if(this._terminal.select(t.col,t.row,t.size),i){let r=this._decorationManager.createActiveDecoration(t,i);r&&(this._resultTracker.selectedDecoration=r)}if(!s&&(t.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||t.row<this._terminal.buffer.active.viewportY)){let r=t.row-this._terminal.buffer.active.viewportY;r-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(r)}return!0}};var En=[[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]],ux=[[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]],We;function px(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return!0;return!1}var fx=class{constructor(){if(this.version="6",!We){We=new Uint8Array(65536),We.fill(1),We[0]=0,We.fill(0,1,32),We.fill(0,127,160),We.fill(2,4352,4448),We[9001]=2,We[9002]=2,We.fill(2,11904,42192),We[12351]=1,We.fill(2,44032,55204),We.fill(2,63744,64256),We.fill(2,65040,65050),We.fill(2,65072,65136),We.fill(2,65280,65377),We.fill(2,65504,65511);for(let t=0;t<En.length;++t)We.fill(0,En[t][0],En[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?We[t]:px(t,ux)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,i){let s=this.wcwidth(t),r=s===0&&i!==0;if(r){let n=Mr.extractWidth(i);n===0?r=!1:n>s&&(s=n)}return Mr.createPropertyValue(0,s,r)}},mx=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Hh.isErrorNoTelemetry(t)?new Hh(t.message+`
|
|
22
|
+
|
|
23
|
+
`+t.stack):new Error(t.message+`
|
|
24
|
+
|
|
25
|
+
`+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(i=>{i(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},gx=new mx;function Tn(e){vx(e)||gx.onUnexpectedError(e)}var yo="Canceled";function vx(e){return e instanceof _x?!0:e instanceof Error&&e.name===yo&&e.message===yo}var _x=class extends Error{constructor(){super(yo),this.name=this.message}},Hh=class So extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof So)return t;let i=new So;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}};function bx(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var wx;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(wx||={});var Ku;(e=>{function t(x){return x&&typeof x=="object"&&typeof x[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(x){yield x}e.single=r;function n(x){return t(x)?x:r(x)}e.wrap=n;function o(x){return x||i}e.from=o;function*a(x){for(let A=x.length-1;A>=0;A--)yield x[A]}e.reverse=a;function l(x){return!x||x[Symbol.iterator]().next().done===!0}e.isEmpty=l;function h(x){return x[Symbol.iterator]().next().value}e.first=h;function c(x,A){let k=0;for(let N of x)if(A(N,k++))return!0;return!1}e.some=c;function u(x,A){for(let k of x)if(A(k))return k}e.find=u;function*p(x,A){for(let k of x)A(k)&&(yield k)}e.filter=p;function*f(x,A){let k=0;for(let N of x)yield A(N,k++)}e.map=f;function*m(x,A){let k=0;for(let N of x)yield*A(N,k++)}e.flatMap=m;function*g(...x){for(let A of x)yield*A}e.concat=g;function _(x,A,k){let N=k;for(let O of x)N=A(N,O);return N}e.reduce=_;function*E(x,A,k=x.length){for(A<0&&(A+=x.length),k<0?k+=x.length:k>x.length&&(k=x.length);A<k;A++)yield x[A]}e.slice=E;function C(x,A=Number.POSITIVE_INFINITY){let k=[];if(A===0)return[k,x];let N=x[Symbol.iterator]();for(let O=0;O<A;O++){let z=N.next();if(z.done)return[k,e.empty()];k.push(z.value)}return[k,{[Symbol.iterator](){return N}}]}e.consume=C;async function T(x){let A=[];for await(let k of x)A.push(k);return Promise.resolve(A)}e.asyncToArray=T})(Ku||={});function qu(e){if(Ku.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function yx(...e){return Yu(()=>qu(e))}function Yu(e){return{dispose:bx(()=>{e()})}}var Xu=class Ju{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{qu(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Ju.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Xu.DISABLE_DISPOSED_WARNING=!1;var Ha=Xu,Nr=class{constructor(){this._store=new Ha,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Nr.None=Object.freeze({dispose(){}});var Sx=globalThis.performance&&typeof globalThis.performance.now=="function",xx=class Zu{static create(t){return new Zu(t)}constructor(t){this._now=Sx&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Cx;(e=>{e.None=()=>Nr.None;function t(w,v){return u(w,()=>{},0,void 0,!0,void 0,v)}e.defer=t;function i(w){return(v,S=null,D)=>{let y=!1,L;return L=w(M=>{if(!y)return L?L.dispose():y=!0,v.call(S,M)},null,D),y&&L.dispose(),L}}e.once=i;function s(w,v,S){return h((D,y=null,L)=>w(M=>D.call(y,v(M)),null,L),S)}e.map=s;function r(w,v,S){return h((D,y=null,L)=>w(M=>{v(M),D.call(y,M)},null,L),S)}e.forEach=r;function n(w,v,S){return h((D,y=null,L)=>w(M=>v(M)&&D.call(y,M),null,L),S)}e.filter=n;function o(w){return w}e.signal=o;function a(...w){return(v,S=null,D)=>{let y=yx(...w.map(L=>L(M=>v.call(S,M))));return c(y,D)}}e.any=a;function l(w,v,S,D){let y=S;return s(w,L=>(y=v(y,L),y),D)}e.reduce=l;function h(w,v){let S,D={onWillAddFirstListener(){S=w(y.fire,y)},onDidRemoveLastListener(){S?.dispose()}},y=new fi(D);return v?.add(y),y.event}function c(w,v){return v instanceof Array?v.push(w):v&&v.add(w),w}function u(w,v,S=100,D=!1,y=!1,L,M){let H,j,J,te=0,ie,le={leakWarningThreshold:L,onWillAddFirstListener(){H=w(ne=>{te++,j=v(j,ne),D&&!J&&(me.fire(j),j=void 0),ie=()=>{let W=j;j=void 0,J=void 0,(!D||te>1)&&me.fire(W),te=0},typeof S=="number"?(clearTimeout(J),J=setTimeout(ie,S)):J===void 0&&(J=0,queueMicrotask(ie))})},onWillRemoveListener(){y&&te>0&&ie?.()},onDidRemoveLastListener(){ie=void 0,H.dispose()}},me=new fi(le);return M?.add(me),me.event}e.debounce=u;function p(w,v=0,S){return e.debounce(w,(D,y)=>D?(D.push(y),D):[y],v,void 0,!0,void 0,S)}e.accumulate=p;function f(w,v=(D,y)=>D===y,S){let D=!0,y;return n(w,L=>{let M=D||!v(L,y);return D=!1,y=L,M},S)}e.latch=f;function m(w,v,S){return[e.filter(w,v,S),e.filter(w,D=>!v(D),S)]}e.split=m;function g(w,v=!1,S=[],D){let y=S.slice(),L=w(j=>{y?y.push(j):H.fire(j)});D&&D.add(L);let M=()=>{y?.forEach(j=>H.fire(j)),y=null},H=new fi({onWillAddFirstListener(){L||(L=w(j=>H.fire(j)),D&&D.add(L))},onDidAddFirstListener(){y&&(v?setTimeout(M):M())},onDidRemoveLastListener(){L&&L.dispose(),L=null}});return D&&D.add(H),H.event}e.buffer=g;function _(w,v){return(S,D,y)=>{let L=v(new C);return w(function(M){let H=L.evaluate(M);H!==E&&S.call(D,H)},void 0,y)}}e.chain=_;let E=Symbol("HaltChainable");class C{constructor(){this.steps=[]}map(v){return this.steps.push(v),this}forEach(v){return this.steps.push(S=>(v(S),S)),this}filter(v){return this.steps.push(S=>v(S)?S:E),this}reduce(v,S){let D=S;return this.steps.push(y=>(D=v(D,y),D)),this}latch(v=(S,D)=>S===D){let S=!0,D;return this.steps.push(y=>{let L=S||!v(y,D);return S=!1,D=y,L?y:E}),this}evaluate(v){for(let S of this.steps)if(v=S(v),v===E)break;return v}}function T(w,v,S=D=>D){let D=(...H)=>M.fire(S(...H)),y=()=>w.on(v,D),L=()=>w.removeListener(v,D),M=new fi({onWillAddFirstListener:y,onDidRemoveLastListener:L});return M.event}e.fromNodeEventEmitter=T;function x(w,v,S=D=>D){let D=(...H)=>M.fire(S(...H)),y=()=>w.addEventListener(v,D),L=()=>w.removeEventListener(v,D),M=new fi({onWillAddFirstListener:y,onDidRemoveLastListener:L});return M.event}e.fromDOMEventEmitter=x;function A(w){return new Promise(v=>i(w)(v))}e.toPromise=A;function k(w){let v=new fi;return w.then(S=>{v.fire(S)},()=>{v.fire(void 0)}).finally(()=>{v.dispose()}),v.event}e.fromPromise=k;function N(w,v){return w(S=>v.fire(S))}e.forward=N;function O(w,v,S){return v(S),w(D=>v(D))}e.runAndSubscribe=O;class z{constructor(v,S){this._observable=v,this._counter=0,this._hasChanged=!1;let D={onWillAddFirstListener:()=>{v.addObserver(this)},onDidRemoveLastListener:()=>{v.removeObserver(this)}};this.emitter=new fi(D),S&&S.add(this.emitter)}beginUpdate(v){this._counter++}handlePossibleChange(v){}handleChange(v,S){this._hasChanged=!0}endUpdate(v){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function R(w,v){return new z(w,v).emitter.event}e.fromObservable=R;function I(w){return(v,S,D)=>{let y=0,L=!1,M={beginUpdate(){y++},endUpdate(){y--,y===0&&(w.reportChanges(),L&&(L=!1,v.call(S)))},handlePossibleChange(){},handleChange(){L=!0}};w.addObserver(M),w.reportChanges();let H={dispose(){w.removeObserver(M)}};return D instanceof Ha?D.add(H):Array.isArray(D)&&D.push(H),H}}e.fromObservableLight=I})(Cx||={});var xo=class Co{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Co._idPool++}`,Co.all.add(this)}start(t){this._stopWatch=new xx,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};xo.all=new Set,xo._idPool=0;var Dx=xo,kx=-1,Qu=class ep{constructor(t,i,s=(ep._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let l=new Tx(a,n);this._errorHandler(l)}return()=>{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,r]of this._stacks)(!t||i<r)&&(t=[s,r],i=r);return t}};Qu._idPool=1;var Px=Qu,Ex=class tp{constructor(t){this.value=t}static create(){let t=new Error;return new tp(t.stack??"")}print(){console.warn(this.value.split(`
|
|
26
|
+
`).slice(2).join(`
|
|
27
|
+
`))}},Tx=class extends Error{constructor(t,i){super(t),this.name="ListenerLeakError",this.stack=i}},Ix=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},Ax=0,In=class{constructor(e){this.value=e,this.id=Ax++}},Rx=2,Lx,fi=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new Px(t?.onListenerError??Tn,this._options?.leakWarningThreshold??kx):void 0,this._perfMon=this._options?._profName?new Dx(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,i,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],h=new Ix(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||Tn)(h),Nr.None}if(this._disposed)return Nr.None;i&&(t=t.bind(i));let r=new In(t),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Ex.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof In?(this._deliveryQueue??=new Nx,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=Yu(()=>{n?.(),this._removeListener(r)});return s instanceof Ha?s.add(o):Array.isArray(s)&&s.push(o),o},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let i=this._listeners,s=i.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Rx<=i.length){let n=0;for(let o=0;o<i.length;o++)i[o]?i[n++]=i[o]:r&&(this._deliveryQueue.end--,n<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=n}}_deliver(t,i){if(!t)return;let s=this._options?.onListenerError||Tn;if(!s){t.value(i);return}try{t.value(i)}catch(r){s(r)}}_deliverQueue(t){let i=t.current._listeners;for(;t.i<t.end;)this._deliver(i[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof In)this._deliver(this._listeners,t);else{let i=this._deliveryQueue;i.enqueue(this,t,this._listeners.length),this._deliverQueue(i)}this._perfMon?.stop()}hasListeners(){return this._size>0}},Nx=class{constructor(){this.i=-1,this.end=0}enqueue(t,i,s){this.i=0,this.end=s,this.current=t,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Mr=class _r{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new fi,this.onChange=this._onChange.event;let t=new fx;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let h=t.charCodeAt(n);56320<=h&&h<=57343?o=(o-55296)*1024+h-56320+65536:i+=this.wcwidth(h)}let a=this.charProperties(o,s),l=_r.extractWidth(a);_r.extractShouldJoin(a)&&(l-=_r.extractWidth(s)),i+=l,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},An=[[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1541],[1552,1562],[1564,1564],[1611,1631],[1648,1648],[1750,1757],[1759,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2259,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2902,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6158],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6832,6846],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7616,7673],[7675,7679],[8203,8207],[8234,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12333],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43493,43493],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43756,43757],[43766,43766],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[65529,65531]],Mx=[[66045,66045],[66272,66272],[66422,66426],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69446,69456],[69633,69633],[69688,69702],[69759,69761],[69811,69814],[69817,69818],[69821,69821],[69837,69837],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[78896,78904],[92912,92916],[92976,92982],[94031,94031],[94095,94098],[113821,113822],[113824,113827],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[123184,123190],[123628,123631],[125136,125142],[125252,125258],[917505,917505],[917536,917631],[917760,917999]],Rn=[[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,11929],[11931,12019],[12032,12245],[12272,12283],[12288,12329],[12334,12350],[12353,12438],[12443,12543],[12549,12591],[12593,12686],[12688,12730],[12736,12771],[12784,12830],[12832,12871],[12880,19903],[19968,42124],[42128,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65106],[65108,65126],[65128,65131],[65281,65376],[65504,65510]],Ox=[[94176,94179],[94208,100343],[100352,101106],[110592,110878],[110928,110930],[110948,110951],[110960,111355],[126980,126980],[127183,127183],[127374,127374],[127377,127386],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128725],[128747,128748],[128756,128762],[128992,129003],[129293,129393],[129395,129398],[129402,129442],[129445,129450],[129454,129482],[129485,129535],[129648,129651],[129656,129658],[129664,129666],[129680,129685],[131072,196605],[196608,262141]],Kt;function Fh(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return!0;return!1}var Gx=class{constructor(){if(this.version="11",!Kt){Kt=new Uint8Array(65536),Kt.fill(1),Kt[0]=0,Kt.fill(0,1,32),Kt.fill(0,127,160);for(let t=0;t<An.length;++t)Kt.fill(0,An[t][0],An[t][1]+1);for(let t=0;t<Rn.length;++t)Kt.fill(2,Rn[t][0],Rn[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?Kt[t]:Fh(t,Mx)?0:Fh(t,Ox)?2:1}charProperties(t,i){let s=this.wcwidth(t),r=s===0&&i!==0;if(r){let n=Mr.extractWidth(i);n===0?r=!1:n>s&&(s=n)}return Mr.createPropertyValue(0,s,r)}},zx=class{activate(e){e.unicode.register(new Gx)}dispose(){}};var Bx=class{constructor(t,i,s,r={}){this._terminal=t,this._regex=i,this._handler=s,this._options=r}provideLinks(t,i){let s=$x.computeLink(t,this._regex,this._terminal,this._handler);i(this._addCallbacks(s))}_addCallbacks(t){return t.map(i=>(i.leave=this._options.leave,i.hover=(s,r)=>{if(this._options.hover){let{range:n}=i;this._options.hover(s,r,n)}},i))}};function jx(e){try{let t=new URL(e),i=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(i.toLocaleLowerCase())}catch{return!1}}var $x=class br{static computeLink(t,i,s,r){let n=new RegExp(i.source,(i.flags||"")+"g"),[o,a]=br._getWindowedLineStrings(t-1,s),l=o.join(""),h,c=[];for(;h=n.exec(l);){let u=h[0];if(!jx(u))continue;let[p,f]=br._mapStrIdx(s,a,0,h.index),[m,g]=br._mapStrIdx(s,p,f,u.length);if(p===-1||f===-1||m===-1||g===-1)continue;let _={start:{x:f+1,y:p+1},end:{x:g,y:m+1}};c.push({range:_,text:u,activate:r})}return c}static _getWindowedLineStrings(t,i){let s,r=t,n=t,o=0,a="",l=[];if(s=i.buffer.active.getLine(t)){let h=s.translateToString(!0);if(s.isWrapped&&h[0]!==" "){for(o=0;(s=i.buffer.active.getLine(--r))&&o<2048&&(a=s.translateToString(!0),o+=a.length,l.push(a),!(!s.isWrapped||a.indexOf(" ")!==-1)););l.reverse()}for(l.push(h),o=0;(s=i.buffer.active.getLine(++n))&&s.isWrapped&&o<2048&&(a=s.translateToString(!0),o+=a.length,l.push(a),a.indexOf(" ")===-1););}return[l,r]}static _mapStrIdx(t,i,s,r){let n=t.buffer.active,o=n.getNullCell(),a=s;for(;r;){let l=n.getLine(i);if(!l)return[-1,-1];for(let h=a;h<l.length;++h){l.getCell(h,o);let c=o.getChars();if(o.getWidth()&&(r-=c.length||1,h===l.length-1&&c==="")){let u=n.getLine(i+1);u&&u.isWrapped&&(u.getCell(0,o),o.getWidth()===2&&(r+=1))}if(r<0)return[i,h]}i++,a=0}return[i,a]}},Wx=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Hx(e,t){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var Fx=class{constructor(t=Hx,i={}){this._handler=t,this._options=i}activate(t){this._terminal=t;let i=this._options,s=i.urlRegex||Wx;this._linkProvider=this._terminal.registerLinkProvider(new Bx(this._terminal,s,this._handler,i))}dispose(){this._linkProvider?.dispose()}};var ip=Object.defineProperty,Vx=Object.getOwnPropertyDescriptor,Ux=(e,t)=>{for(var i in t)ip(e,i,{get:t[i],enumerable:!0})},Oe=(e,t,i,s)=>{for(var r=s>1?void 0:s?Vx(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&ip(t,i,r),r},ee=(e,t)=>(i,s)=>t(i,s,e),Vh="Terminal input",Do={get:()=>Vh,set:e=>Vh=e},Uh="Too much output to announce, navigate to rows manually to read",ko={get:()=>Uh,set:e=>Uh=e};function Kx(e){return e.replace(/\r?\n/g,"\r")}function qx(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Yx(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Xx(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");sp(r,t,i,s)}}function sp(e,t,i,s){e=Kx(e),e=qx(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function rp(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function Kh(e,t,i,s,r){rp(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function gi(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Qr(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var Jx=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},Zx=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,a,l=0,h=0;if(this.interim[0]){let p=!1,f=this.interim[0];f&=(f&224)===192?31:(f&240)===224?15:7;let m=0,g;for(;(g=this.interim[++m]&63)&&m<4;)f<<=6,f|=g;let _=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,E=_-m;for(;h<E;){if(h>=i)return 0;if(g=e[h++],(g&192)!==128){h--,p=!0;break}else this.interim[m++]=g,f<<=6,f|=g&63}p||(_===2?f<128?h--:t[s++]=f:_===3?f<2048||f>=55296&&f<=57343||f===65279||(t[s++]=f):f<65536||f>1114111||(t[s++]=f)),this.interim.fill(0)}let c=i-4,u=h;for(;u<i;){for(;u<c&&!((r=e[u])&128)&&!((n=e[u+1])&128)&&!((o=e[u+2])&128)&&!((a=e[u+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=a,u+=4;if(r=e[u++],r<128)t[s++]=r;else if((r&224)===192){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(l=(r&31)<<6|n&63,l<128){u--;continue}t[s++]=l}else if((r&240)===224){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[u++],(o&192)!==128){u--;continue}if(l=(r&15)<<12|(n&63)<<6|o&63,l<2048||l>=55296&&l<=57343||l===65279)continue;t[s++]=l}else if((r&248)===240){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[u++],(o&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[u++],(a&192)!==128){u--;continue}if(l=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,l<65536||l>1114111)continue;t[s++]=l}}return s}},np="",vi=" ",js=class op{constructor(){this.fg=0,this.bg=0,this.extended=new Or}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new op;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Or=class ap{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new ap(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ct=class lp extends js{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Or,this.combinedData=""}static fromCharData(t){let i=new lp;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?gi(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},qh="di$target",Po="di$dependencies",Ln=new Map;function Qx(e){return e[Po]||[]}function Ze(e){if(Ln.has(e))return Ln.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");eC(t,i,r)};return t._id=e,Ln.set(e,t),t}function eC(e,t,i){t[qh]===t?t[Po].push({id:e,index:i}):(t[Po]=[{id:e,index:i}],t[qh]=t)}var ot=Ze("BufferService"),hp=Ze("CoreMouseService"),$i=Ze("CoreService"),tC=Ze("CharsetService"),Fa=Ze("InstantiationService"),dp=Ze("LogService"),at=Ze("OptionsService"),cp=Ze("OscLinkService"),iC=Ze("UnicodeService"),$s=Ze("DecorationService"),Eo=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new Ct,o=i.getTrimmedLength(),a=-1,l=-1,h=!1;for(let c=0;c<o;c++)if(!(l===-1&&!i.hasContent(c))){if(i.loadCell(c,n),n.hasExtendedAttrs()&&n.extended.urlId)if(l===-1){l=c,a=n.extended.urlId;continue}else h=n.extended.urlId!==a;else l!==-1&&(h=!0);if(h||l!==-1&&c===o-1){let u=this._oscLinkService.getLinkData(a)?.uri;if(u){let p={start:{x:l+1,y:e},end:{x:c+(!h&&c===o-1?1:0),y:e}},f=!1;if(!r?.allowNonHttpProtocols)try{let m=new URL(u);["http:","https:"].includes(m.protocol)||(f=!0)}catch{f=!0}f||s.push({text:u,range:p,activate:(m,g)=>r?r.activate(m,g,p):sC(m,g),hover:(m,g)=>r?.hover?.(m,g,p),leave:(m,g)=>r?.leave?.(m,g,p)})}h=!1,n.hasExtendedAttrs()&&n.extended.urlId?(l=c,a=n.extended.urlId):(l=-1,a=-1)}}t(s)}};Eo=Oe([ee(0,ot),ee(1,at),ee(2,cp)],Eo);function sC(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
28
|
+
|
|
29
|
+
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var en=Ze("CharSizeService"),si=Ze("CoreBrowserService"),Va=Ze("MouseService"),ri=Ze("RenderService"),rC=Ze("SelectionService"),up=Ze("CharacterJoinerService"),ts=Ze("ThemeService"),pp=Ze("LinkProviderService"),nC=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Yh.isErrorNoTelemetry(e)?new Yh(e.message+`
|
|
30
|
+
|
|
31
|
+
`+e.stack):new Error(e.message+`
|
|
32
|
+
|
|
33
|
+
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},oC=new nC;function wr(e){aC(e)||oC.onUnexpectedError(e)}var To="Canceled";function aC(e){return e instanceof lC?!0:e instanceof Error&&e.name===To&&e.message===To}var lC=class extends Error{constructor(){super(To),this.name=this.message}};function hC(e){return new Error(`Illegal argument: ${e}`)}var Yh=class Io extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Io)return t;let i=new Io;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Ao=class fp extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,fp.prototype)}};function ut(e,t=0){return e[e.length-(1+t)]}var dC;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(dC||={});function cC(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var mp;(e=>{function t(x){return x&&typeof x=="object"&&typeof x[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(x){yield x}e.single=r;function n(x){return t(x)?x:r(x)}e.wrap=n;function o(x){return x||i}e.from=o;function*a(x){for(let A=x.length-1;A>=0;A--)yield x[A]}e.reverse=a;function l(x){return!x||x[Symbol.iterator]().next().done===!0}e.isEmpty=l;function h(x){return x[Symbol.iterator]().next().value}e.first=h;function c(x,A){let k=0;for(let N of x)if(A(N,k++))return!0;return!1}e.some=c;function u(x,A){for(let k of x)if(A(k))return k}e.find=u;function*p(x,A){for(let k of x)A(k)&&(yield k)}e.filter=p;function*f(x,A){let k=0;for(let N of x)yield A(N,k++)}e.map=f;function*m(x,A){let k=0;for(let N of x)yield*A(N,k++)}e.flatMap=m;function*g(...x){for(let A of x)yield*A}e.concat=g;function _(x,A,k){let N=k;for(let O of x)N=A(N,O);return N}e.reduce=_;function*E(x,A,k=x.length){for(A<0&&(A+=x.length),k<0?k+=x.length:k>x.length&&(k=x.length);A<k;A++)yield x[A]}e.slice=E;function C(x,A=Number.POSITIVE_INFINITY){let k=[];if(A===0)return[k,x];let N=x[Symbol.iterator]();for(let O=0;O<A;O++){let z=N.next();if(z.done)return[k,e.empty()];k.push(z.value)}return[k,{[Symbol.iterator](){return N}}]}e.consume=C;async function T(x){let A=[];for await(let k of x)A.push(k);return Promise.resolve(A)}e.asyncToArray=T})(mp||={});function Gi(e){if(mp.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function uC(...e){return Ie(()=>Gi(e))}function Ie(e){return{dispose:cC(()=>{e()})}}var gp=class vp{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Gi(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?vp.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};gp.DISABLE_DISPOSED_WARNING=!1;var wi=gp,be=class{constructor(){this._store=new wi,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};be.None=Object.freeze({dispose(){}});var Qi=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Qt=typeof window=="object"?window:globalThis,Ro=class Lo{constructor(t){this.element=t,this.next=Lo.Undefined,this.prev=Lo.Undefined}};Ro.Undefined=new Ro(void 0);var Ae=Ro,Xh=class{constructor(){this._first=Ae.Undefined,this._last=Ae.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Ae.Undefined}clear(){let e=this._first;for(;e!==Ae.Undefined;){let t=e.next;e.prev=Ae.Undefined,e.next=Ae.Undefined,e=t}this._first=Ae.Undefined,this._last=Ae.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new Ae(e);if(this._first===Ae.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i}else{let r=this._first;this._first=i,i.next=r,r.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==Ae.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Ae.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Ae.Undefined&&e.next!==Ae.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Ae.Undefined&&e.next===Ae.Undefined?(this._first=Ae.Undefined,this._last=Ae.Undefined):e.next===Ae.Undefined?(this._last=this._last.prev,this._last.next=Ae.Undefined):e.prev===Ae.Undefined&&(this._first=this._first.next,this._first.prev=Ae.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Ae.Undefined;)yield e.element,e=e.next}},pC=globalThis.performance&&typeof globalThis.performance.now=="function",fC=class _p{static create(t){return new _p(t)}constructor(t){this._now=pC&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},tt;(e=>{e.None=()=>be.None;function t(w,v){return u(w,()=>{},0,void 0,!0,void 0,v)}e.defer=t;function i(w){return(v,S=null,D)=>{let y=!1,L;return L=w(M=>{if(!y)return L?L.dispose():y=!0,v.call(S,M)},null,D),y&&L.dispose(),L}}e.once=i;function s(w,v,S){return h((D,y=null,L)=>w(M=>D.call(y,v(M)),null,L),S)}e.map=s;function r(w,v,S){return h((D,y=null,L)=>w(M=>{v(M),D.call(y,M)},null,L),S)}e.forEach=r;function n(w,v,S){return h((D,y=null,L)=>w(M=>v(M)&&D.call(y,M),null,L),S)}e.filter=n;function o(w){return w}e.signal=o;function a(...w){return(v,S=null,D)=>{let y=uC(...w.map(L=>L(M=>v.call(S,M))));return c(y,D)}}e.any=a;function l(w,v,S,D){let y=S;return s(w,L=>(y=v(y,L),y),D)}e.reduce=l;function h(w,v){let S,D={onWillAddFirstListener(){S=w(y.fire,y)},onDidRemoveLastListener(){S?.dispose()}},y=new q(D);return v?.add(y),y.event}function c(w,v){return v instanceof Array?v.push(w):v&&v.add(w),w}function u(w,v,S=100,D=!1,y=!1,L,M){let H,j,J,te=0,ie,le={leakWarningThreshold:L,onWillAddFirstListener(){H=w(ne=>{te++,j=v(j,ne),D&&!J&&(me.fire(j),j=void 0),ie=()=>{let W=j;j=void 0,J=void 0,(!D||te>1)&&me.fire(W),te=0},typeof S=="number"?(clearTimeout(J),J=setTimeout(ie,S)):J===void 0&&(J=0,queueMicrotask(ie))})},onWillRemoveListener(){y&&te>0&&ie?.()},onDidRemoveLastListener(){ie=void 0,H.dispose()}},me=new q(le);return M?.add(me),me.event}e.debounce=u;function p(w,v=0,S){return e.debounce(w,(D,y)=>D?(D.push(y),D):[y],v,void 0,!0,void 0,S)}e.accumulate=p;function f(w,v=(D,y)=>D===y,S){let D=!0,y;return n(w,L=>{let M=D||!v(L,y);return D=!1,y=L,M},S)}e.latch=f;function m(w,v,S){return[e.filter(w,v,S),e.filter(w,D=>!v(D),S)]}e.split=m;function g(w,v=!1,S=[],D){let y=S.slice(),L=w(j=>{y?y.push(j):H.fire(j)});D&&D.add(L);let M=()=>{y?.forEach(j=>H.fire(j)),y=null},H=new q({onWillAddFirstListener(){L||(L=w(j=>H.fire(j)),D&&D.add(L))},onDidAddFirstListener(){y&&(v?setTimeout(M):M())},onDidRemoveLastListener(){L&&L.dispose(),L=null}});return D&&D.add(H),H.event}e.buffer=g;function _(w,v){return(S,D,y)=>{let L=v(new C);return w(function(M){let H=L.evaluate(M);H!==E&&S.call(D,H)},void 0,y)}}e.chain=_;let E=Symbol("HaltChainable");class C{constructor(){this.steps=[]}map(v){return this.steps.push(v),this}forEach(v){return this.steps.push(S=>(v(S),S)),this}filter(v){return this.steps.push(S=>v(S)?S:E),this}reduce(v,S){let D=S;return this.steps.push(y=>(D=v(D,y),D)),this}latch(v=(S,D)=>S===D){let S=!0,D;return this.steps.push(y=>{let L=S||!v(y,D);return S=!1,D=y,L?y:E}),this}evaluate(v){for(let S of this.steps)if(v=S(v),v===E)break;return v}}function T(w,v,S=D=>D){let D=(...H)=>M.fire(S(...H)),y=()=>w.on(v,D),L=()=>w.removeListener(v,D),M=new q({onWillAddFirstListener:y,onDidRemoveLastListener:L});return M.event}e.fromNodeEventEmitter=T;function x(w,v,S=D=>D){let D=(...H)=>M.fire(S(...H)),y=()=>w.addEventListener(v,D),L=()=>w.removeEventListener(v,D),M=new q({onWillAddFirstListener:y,onDidRemoveLastListener:L});return M.event}e.fromDOMEventEmitter=x;function A(w){return new Promise(v=>i(w)(v))}e.toPromise=A;function k(w){let v=new q;return w.then(S=>{v.fire(S)},()=>{v.fire(void 0)}).finally(()=>{v.dispose()}),v.event}e.fromPromise=k;function N(w,v){return w(S=>v.fire(S))}e.forward=N;function O(w,v,S){return v(S),w(D=>v(D))}e.runAndSubscribe=O;class z{constructor(v,S){this._observable=v,this._counter=0,this._hasChanged=!1;let D={onWillAddFirstListener:()=>{v.addObserver(this)},onDidRemoveLastListener:()=>{v.removeObserver(this)}};this.emitter=new q(D),S&&S.add(this.emitter)}beginUpdate(v){this._counter++}handlePossibleChange(v){}handleChange(v,S){this._hasChanged=!0}endUpdate(v){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function R(w,v){return new z(w,v).emitter.event}e.fromObservable=R;function I(w){return(v,S,D)=>{let y=0,L=!1,M={beginUpdate(){y++},endUpdate(){y--,y===0&&(w.reportChanges(),L&&(L=!1,v.call(S)))},handlePossibleChange(){},handleChange(){L=!0}};w.addObserver(M),w.reportChanges();let H={dispose(){w.removeObserver(M)}};return D instanceof wi?D.add(H):Array.isArray(D)&&D.push(H),H}}e.fromObservableLight=I})(tt||={});var No=class Mo{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Mo._idPool++}`,Mo.all.add(this)}start(t){this._stopWatch=new fC,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};No.all=new Set,No._idPool=0;var mC=No,gC=-1,bp=class wp{constructor(t,i,s=(wp._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let l=new bC(a,n);this._errorHandler(l)}return()=>{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,r]of this._stacks)(!t||i<r)&&(t=[s,r],i=r);return t}};bp._idPool=1;var vC=bp,_C=class yp{constructor(t){this.value=t}static create(){let t=new Error;return new yp(t.stack??"")}print(){console.warn(this.value.split(`
|
|
34
|
+
`).slice(2).join(`
|
|
35
|
+
`))}},bC=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},wC=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},yC=0,Nn=class{constructor(e){this.value=e,this.id=yC++}},SC=2,xC,q=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new vC(e?.onListenerError??wr,this._options?.leakWarningThreshold??gC):void 0,this._perfMon=this._options?._profName?new mC(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,i)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let o=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(o);let a=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],l=new wC(`${o}. HINT: Stack shows most frequent listener (${a[1]}-times)`,a[0]);return(this._options?.onListenerError||wr)(l),be.None}if(this._disposed)return be.None;t&&(e=e.bind(t));let s=new Nn(e),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=_C.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Nn?(this._deliveryQueue??=new CC,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let n=Ie(()=>{r?.(),this._removeListener(s)});return i instanceof wi?i.add(n):Array.isArray(i)&&i.push(n),n},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*SC<=t.length){let r=0;for(let n=0;n<t.length;n++)t[n]?t[r++]=t[n]:s&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=r}}_deliver(e,t){if(!e)return;let i=this._options?.onListenerError||wr;if(!i){e.value(t);return}try{e.value(t)}catch(s){i(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Nn)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},CC=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Oo=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new q,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Oo.INSTANCE=new Oo;var Ua=Oo;function DC(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Ua.INSTANCE.onDidChangeZoomLevel;function kC(e){return Ua.INSTANCE.getZoomFactor(e)}Ua.INSTANCE.onDidChangeFullscreen;var is=typeof navigator=="object"?navigator.userAgent:"",Go=is.indexOf("Firefox")>=0,PC=is.indexOf("AppleWebKit")>=0,Ka=is.indexOf("Chrome")>=0,EC=!Ka&&is.indexOf("Safari")>=0;is.indexOf("Electron/")>=0;is.indexOf("Android")>=0;var Mn=!1;if(typeof Qt.matchMedia=="function"){let e=Qt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Qt.matchMedia("(display-mode: fullscreen)");Mn=e.matches,DC(Qt,e,({matches:i})=>{Mn&&t.matches||(Mn=i)})}var Ji="en",zo=!1,Bo=!1,yr=!1,Sp=!1,dr,Sr=Ji,Jh=Ji,TC,Jt,Mi=globalThis,mt;typeof Mi.vscode<"u"&&typeof Mi.vscode.process<"u"?mt=Mi.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(mt=process);var IC=typeof mt?.versions?.electron=="string",AC=IC&&mt?.type==="renderer";if(typeof mt=="object"){zo=mt.platform==="win32",Bo=mt.platform==="darwin",yr=mt.platform==="linux",yr&&mt.env.SNAP&&mt.env.SNAP_REVISION,mt.env.CI||mt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,dr=Ji,Sr=Ji;let e=mt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);dr=t.userLocale,Jh=t.osLocale,Sr=t.resolvedLanguage||Ji,TC=t.languagePack?.translationsConfigFile}catch{}Sp=!0}else typeof navigator=="object"&&!AC?(Jt=navigator.userAgent,zo=Jt.indexOf("Windows")>=0,Bo=Jt.indexOf("Macintosh")>=0,(Jt.indexOf("Macintosh")>=0||Jt.indexOf("iPad")>=0||Jt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,yr=Jt.indexOf("Linux")>=0,Jt?.indexOf("Mobi")>=0,Sr=globalThis._VSCODE_NLS_LANGUAGE||Ji,dr=navigator.language.toLowerCase(),Jh=dr):console.error("Unable to resolve platform.");var xp=zo,jt=Bo,RC=yr,Zh=Sp,Wt=Jt,di=Sr,LC;(e=>{function t(){return di}e.value=t;function i(){return di.length===2?di==="en":di.length>=3?di[0]==="e"&&di[1]==="n"&&di[2]==="-":!1}e.isDefaultVariant=i;function s(){return di==="en"}e.isDefault=s})(LC||={});var NC=typeof Mi.postMessage=="function"&&!Mi.importScripts;(()=>{if(NC){let e=[];Mi.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),Mi.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var MC=!!(Wt&&Wt.indexOf("Chrome")>=0);Wt&&Wt.indexOf("Firefox")>=0;!MC&&Wt&&Wt.indexOf("Safari")>=0;Wt&&Wt.indexOf("Edg/")>=0;Wt&&Wt.indexOf("Android")>=0;var Ui=typeof navigator=="object"?navigator:{};Zh||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ui&&Ui.clipboard&&Ui.clipboard.writeText,Zh||Ui&&Ui.clipboard&&Ui.clipboard.readText;var qa=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},On=new qa,Qh=new qa,ed=new qa,OC=new Array(230),Cp;(e=>{function t(a){return On.keyCodeToStr(a)}e.toString=t;function i(a){return On.strToKeyCode(a)}e.fromString=i;function s(a){return Qh.keyCodeToStr(a)}e.toUserSettingsUS=s;function r(a){return ed.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function n(a){return Qh.strToKeyCode(a)||ed.strToKeyCode(a)}e.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return On.keyCodeToStr(a)}e.toElectronAccelerator=o})(Cp||={});var GC=class Dp{constructor(t,i,s,r,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof Dp&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new zC([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},zC=class{constructor(e){if(e.length===0)throw hC("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function BC(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Cp.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(Go)switch(t){case 59:return 85;case 60:if(RC)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(jt)return 57;break}else if(PC&&(jt&&t===93||!jt&&t===92))return 57;return OC[t]||0}var jC=jt?256:2048,$C=512,WC=1024,HC=jt?2048:256,td=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.("AltGraph"),this.keyCode=BC(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=jC),this.altKey&&(t|=$C),this.shiftKey&&(t|=WC),this.metaKey&&(t|=HC),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new GC(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},id=new WeakMap;function FC(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var VC=class{static getSameOriginWindowChain(e){let t=id.get(e);if(!t){t=[],id.set(e,t);let i=e,s;do s=FC(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,r=this.getSameOriginWindowChain(e);for(let n of r){let o=n.window.deref();if(i+=o?.scrollY??0,s+=o?.scrollX??0,o===t||!n.iframeElement)break;let a=n.iframeElement.getBoundingClientRect();i+=a.top,s+=a.left}return{top:i,left:s}}},cr=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=VC.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},sd=class{constructor(e,t=0,i=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(Ka){let r=navigator.userAgent.match(/Chrome\/(\d+)/);s=(r?parseInt(r[1]):123)<=122}if(e){let r=e,n=e,o=e.view?.devicePixelRatio||1;if(typeof r.wheelDeltaY<"u")s?this.deltaY=r.wheelDeltaY/(120*o):this.deltaY=r.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<"u"&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type==="wheel"){let a=e;a.deltaMode===a.DOM_DELTA_LINE?Go&&!jt?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof r.wheelDeltaX<"u")EC&&xp?this.deltaX=-(r.wheelDeltaX/120):s?this.deltaX=r.wheelDeltaX/(120*o):this.deltaX=r.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<"u"&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let a=e;a.deltaMode===a.DOM_DELTA_LINE?Go&&!jt?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*o):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},kp=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),UC;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof KC?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:tt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:kp})})(UC||={});var KC=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?kp:(this._emitter||(this._emitter=new q),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Ya=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Ao("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Ao("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},qC=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new Ao("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=Ie(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},YC;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})(YC||={});var rd=class bt{static fromArray(t){return new bt(i=>{i.emitMany(t)})}static fromPromise(t){return new bt(async i=>{i.emitMany(await t)})}static fromPromises(t){return new bt(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new bt(async i=>{await Promise.all(t.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new q,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await tt.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,i){return new bt(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return bt.map(this,t)}static filter(t,i){return new bt(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return bt.filter(this,t)}static coalesce(t){return bt.filter(t,i=>!!i)}coalesce(){return bt.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return bt.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};rd.EMPTY=rd.fromArray([]);var{getWindow:Bt,getWindowId:XC,onDidRegisterWindow:JC}=(function(){let e=new Map,t={window:Qt,disposables:new wi};e.set(Qt.vscodeWindowId,t);let i=new q,s=new q,r=new q;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return be.None;let a=new wi,l={window:o,disposables:a.add(new wi)};return e.set(o.vscodeWindowId,l),a.add(Ie(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),a.add(ce(o,qe.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(l),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){let a=o;if(a?.ownerDocument?.defaultView)return a.ownerDocument.defaultView.window;let l=o;return l?.view?l.view.window:Qt},getDocument(o){return Bt(o).document}}})(),ZC=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function ce(e,t,i,s){return new ZC(e,t,i,s)}var nd=function(e,t,i,s){return ce(e,t,i,s)},Xa,QC=class extends qC{constructor(e){super(),this.defaultTarget=e&&Bt(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},od=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){wr(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),s.set(n,!0);o.length>0;)o.sort(od.sort),o.shift().execute();s.set(n,!1)};Xa=(n,o,a=0)=>{let l=XC(n),h=new od(o,a),c=e.get(l);return c||(c=[],e.set(l,c)),c.push(h),i.get(l)||(i.set(l,!0),n.requestAnimationFrame(()=>r(l))),h}})();function e1(e){let t=e.getBoundingClientRect(),i=Bt(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var qe={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},t1=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=ht(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=ht(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=ht(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=ht(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=ht(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=ht(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=ht(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=ht(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=ht(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=ht(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=ht(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=ht(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=ht(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=ht(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function ht(e){return typeof e=="number"?`${e}px`:e}function Ps(e){return new t1(e)}var Pp=class{constructor(){this._hooks=new wi,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(Ie(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=Bt(e)}this._hooks.add(ce(n,qe.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(ce(n,qe.POINTER_UP,o=>this.stopMonitoring(!0)))}};function i1(e,t,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var Ot;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Ot||={});var bs=class st extends be{constructor(){super(),this.dispatched=!1,this.targets=new Xh,this.ignoreTargets=new Xh,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(tt.runAndSubscribe(JC,({window:t,disposables:i})=>{i.add(ce(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(ce(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(ce(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Qt,disposables:this._store}))}static addTarget(t){if(!st.isTouchDevice())return be.None;st.INSTANCE||(st.INSTANCE=new st);let i=st.INSTANCE.targets.push(t);return Ie(i)}static ignoreTarget(t){if(!st.isTouchDevice())return be.None;st.INSTANCE||(st.INSTANCE=new st);let i=st.INSTANCE.ignoreTargets.push(t);return Ie(i)}static isTouchDevice(){return"ontouchstart"in Qt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=t.targetTouches.length;s<r;s++){let n=t.targetTouches.item(s);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:i,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[i],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(Ot.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let a=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],h=Date.now()-l.initialTimeStamp;if(h<st.HOLD_DELAY&&Math.abs(l.initialPageX-ut(l.rollingPageX))<30&&Math.abs(l.initialPageY-ut(l.rollingPageY))<30){let c=this.newGestureEvent(Ot.Tap,l.initialTarget);c.pageX=ut(l.rollingPageX),c.pageY=ut(l.rollingPageY),this.dispatchEvent(c)}else if(h>=st.HOLD_DELAY&&Math.abs(l.initialPageX-ut(l.rollingPageX))<30&&Math.abs(l.initialPageY-ut(l.rollingPageY))<30){let c=this.newGestureEvent(Ot.Contextmenu,l.initialTarget);c.pageX=ut(l.rollingPageX),c.pageY=ut(l.rollingPageY),this.dispatchEvent(c)}else if(r===1){let c=ut(l.rollingPageX),u=ut(l.rollingPageY),p=ut(l.rollingTimestamps)-l.rollingTimestamps[0],f=c-l.rollingPageX[0],m=u-l.rollingPageY[0],g=[...this.targets].filter(_=>l.initialTarget instanceof Node&&_.contains(l.initialTarget));this.inertia(t,g,s,Math.abs(f)/p,f>0?1:-1,c,Math.abs(m)/p,m>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(Ot.End,l.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===Ot.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>st.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Ot.Change||t.type===Ot.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,a,l,h){this.handle=Xa(t,()=>{let c=Date.now(),u=c-s,p=0,f=0,m=!0;r+=st.SCROLL_FRICTION*u,a+=st.SCROLL_FRICTION*u,r>0&&(m=!1,p=n*r*u),a>0&&(m=!1,f=l*a*u);let g=this.newGestureEvent(Ot.Change);g.translationX=p,g.translationY=f,i.forEach(_=>_.dispatchEvent(g)),m||this.inertia(t,i,c,r,n,o+p,a,l,h+f)})}onTouchMove(t){let i=Date.now();for(let s=0,r=t.changedTouches.length;s<r;s++){let n=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],a=this.newGestureEvent(Ot.Change,o.initialTarget);a.translationX=n.pageX-ut(o.rollingPageX),a.translationY=n.pageY-ut(o.rollingPageY),a.pageX=n.pageX,a.pageY=n.pageY,this.dispatchEvent(a),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};bs.SCROLL_FRICTION=-.005,bs.HOLD_DELAY=700,bs.CLEAR_TAP_COUNT_TIME=400,Oe([i1],bs,"isTouchDevice",1);var s1=bs,Ja=class extends be{onclick(e,t){this._register(ce(e,qe.CLICK,i=>t(new cr(Bt(e),i))))}onmousedown(e,t){this._register(ce(e,qe.MOUSE_DOWN,i=>t(new cr(Bt(e),i))))}onmouseover(e,t){this._register(ce(e,qe.MOUSE_OVER,i=>t(new cr(Bt(e),i))))}onmouseleave(e,t){this._register(ce(e,qe.MOUSE_LEAVE,i=>t(new cr(Bt(e),i))))}onkeydown(e,t){this._register(ce(e,qe.KEY_DOWN,i=>t(new td(i))))}onkeyup(e,t){this._register(ce(e,qe.KEY_UP,i=>t(new td(i))))}oninput(e,t){this._register(ce(e,qe.INPUT,t))}onblur(e,t){this._register(ce(e,qe.BLUR,t))}onfocus(e,t){this._register(ce(e,qe.FOCUS,t))}onchange(e,t){this._register(ce(e,qe.CHANGE,t))}ignoreGesture(e){return s1.ignoreTarget(e)}},ad=11,r1=class extends Ja{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=ad+"px",this.domNode.style.height=ad+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Pp),this._register(nd(this.bgDomNode,qe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(nd(this.domNode,qe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new QC),this._pointerdownScheduleRepeatTimer=this._register(new Ya)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Bt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},n1=class jo{constructor(t,i,s,r,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new jo(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new jo(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let s=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,l=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:l}}},o1=class extends be{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new n1(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new hd(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=hd.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},ld=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Gn(e,t){let i=t-e;return function(s){return e+i*h1(s)}}function a1(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var hd=class $o{constructor(t,i,s,r){this.from=t,this.to=i,this.duration=r,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let r,n;return t<i?(r=t+.75*s,n=i-.75*s):(r=t-.75*s,n=i+.75*s),a1(Gn(t,r),Gn(n,i),.33)}return Gn(t,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),r=this.scrollTop(i);return new ld(s,r,!1)}return new ld(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return $o.start(t,i,s)}static start(t,i,s){s=s+10;let r=Date.now()-10;return new $o(t,i,r,s)}};function l1(e){return Math.pow(e,3)}function h1(e){return 1-l1(1-e)}var d1=class extends be{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Ya)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},c1=140,Ep=class extends Ja{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new d1(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Pp),this._shouldRender=!0,this.domNode=Ps(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(ce(this.domNode.domNode,qe.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new r1(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=Ps(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ce(this.slider.domNode,qe.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let r=e1(this.domNode.domNode);t=e.pageX-r.left,i=e.pageY-r.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-i);if(xp&&o>c1){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(a))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Tp=class Wo{constructor(t,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Wo(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,r,n){let o=Math.max(0,s-t),a=Math.max(0,o-2*i),l=r>0&&r>s;if(!l)return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*a/r))),c=(a-h)/(r-s),u=n*c;return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(h),computedSliderRatio:c,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=Wo._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},u1=class extends Ep{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Tp(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,r.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},p1=class extends Ep{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Tp(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,r.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},f1=500,dd=50,m1=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},Ho=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,i=0,s=1,r=this._rear;do{let n=r===this._front?t:Math.pow(2,-s);if(t-=n,i+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Ka){let i=Bt(t.browserEvent),s=kC(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let r=null,n=new m1(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,r)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),l=Math.max(Math.min(r,o),1),h=Math.max(Math.min(n,a),1),c=Math.max(r,o),u=Math.max(n,a);c%l===0&&u%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Ho.INSTANCE=new Ho;var g1=Ho,v1=class extends Ja{constructor(e,t,i){super(),this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new q),this.onWillScroll=this._onWillScroll.event,this._options=b1(t),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new p1(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new u1(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Ps(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ps(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ps(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Ya),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Gi(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,jt&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new sd(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Gi(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new sd(i))};this._mouseWheelToDispose.push(ce(this._listenOnDomNode,qe.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=g1.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,n=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&n+r===0?n=r=0:Math.abs(r)>=Math.abs(n)?n=0:r=0),this._options.flipAxes&&([r,n]=[n,r]);let o=!jt&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||o)&&!n&&(n=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(n=n*this._options.fastScrollSensitivity,r=r*this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),l={};if(r){let h=dd*r,c=a.scrollTop-(h<0?Math.floor(h):Math.ceil(h));this._verticalScrollbar.writeScrollPosition(l,c)}if(n){let h=dd*n,c=a.scrollLeft-(h<0?Math.floor(h):Math.ceil(h));this._horizontalScrollbar.writeScrollPosition(l,c)}l=this._scrollable.validateScrollPosition(l),(a.scrollLeft!==l.scrollLeft||a.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),f1)}},_1=class extends v1{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function b1(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,jt&&(t.className+=" mac"),t}var Fo=class extends be{constructor(e,t,i,s,r,n,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let l=this._register(new o1({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Xa(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{l.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new _1(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},l)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(tt.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Ie(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Ie(()=>this._styleElement.remove())),this._register(tt.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
36
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};Fo=Oe([ee(2,ot),ee(3,si),ee(4,hp),ee(5,ts),ee(6,at),ee(7,ri)],Fo);var Vo=class extends be{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=r,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(this._coreBrowserService.onDprChange(()=>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(n=>this._removeDecoration(n))),this._register(Ie(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};Vo=Oe([ee(1,ot),ee(2,si),ee(3,$s),ee(4,ri)],Vo);var w1=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(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Lt={full:0,left:0,center:0,right:0},ci={full:0,left:0,center:0,right:0},cs={full:0,left:0,center:0,right:0},Gr=class extends be{constructor(e,t,i,s,r,n,o,a){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new w1,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(Ie(()=>this._canvas?.remove()));let l=this._canvas.getContext("2d");if(l)this._ctx=l;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),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())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);ci.full=this._canvas.width,ci.left=e,ci.center=t,ci.right=e,this._refreshDrawHeightConstants(),cs.full=1,cs.left=1,cs.center=1+ci.left,cs.right=1+ci.left+ci.center}_refreshDrawHeightConstants(){Lt.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Lt.left=t,Lt.center=t,Lt.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Lt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Lt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Lt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Lt.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._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.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(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(cs[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Lt[e.position||"full"]/2),ci[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Lt[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Gr=Oe([ee(2,ot),ee(3,$s),ee(4,ri),ee(5,at),ee(6,ts),ee(7,si)],Gr);var $;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
37
|
+
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))($||={});var xr;(e=>(e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""))(xr||={});var Ip;(e=>e.ST=`${$.ESC}\\`)(Ip||={});var Uo=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${$.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Uo=Oe([ee(2,ot),ee(3,at),ee(4,$i),ee(5,ri)],Uo);var Ye=0,Xe=0,Je=0,Le=0,cd={css:"#00000000",rgba:0},$e;(e=>{function t(r,n,o,a){return a!==void 0?`#${Pi(r)}${Pi(n)}${Pi(o)}${Pi(a)}`:`#${Pi(r)}${Pi(n)}${Pi(o)}`}e.toCss=t;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function s(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=s})($e||={});var Pe;(e=>{function t(l,h){if(Le=(h.rgba&255)/255,Le===1)return{css:h.css,rgba:h.rgba};let c=h.rgba>>24&255,u=h.rgba>>16&255,p=h.rgba>>8&255,f=l.rgba>>24&255,m=l.rgba>>16&255,g=l.rgba>>8&255;Ye=f+Math.round((c-f)*Le),Xe=m+Math.round((u-m)*Le),Je=g+Math.round((p-g)*Le);let _=$e.toCss(Ye,Xe,Je),E=$e.toRgba(Ye,Xe,Je);return{css:_,rgba:E}}e.blend=t;function i(l){return(l.rgba&255)===255}e.isOpaque=i;function s(l,h,c){let u=Cr.ensureContrastRatio(l.rgba,h.rgba,c);if(u)return $e.toColor(u>>24&255,u>>16&255,u>>8&255)}e.ensureContrastRatio=s;function r(l){let h=(l.rgba|255)>>>0;return[Ye,Xe,Je]=Cr.toChannels(h),{css:$e.toCss(Ye,Xe,Je),rgba:h}}e.opaque=r;function n(l,h){return Le=Math.round(h*255),[Ye,Xe,Je]=Cr.toChannels(l.rgba),{css:$e.toCss(Ye,Xe,Je,Le),rgba:$e.toRgba(Ye,Xe,Je,Le)}}e.opacity=n;function o(l,h){return Le=l.rgba&255,n(l,Le*h/255)}e.multiplyOpacity=o;function a(l){return[l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}e.toColorRGB=a})(Pe||={});var Re;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Ye=parseInt(r.slice(1,2).repeat(2),16),Xe=parseInt(r.slice(2,3).repeat(2),16),Je=parseInt(r.slice(3,4).repeat(2),16),$e.toColor(Ye,Xe,Je);case 5:return Ye=parseInt(r.slice(1,2).repeat(2),16),Xe=parseInt(r.slice(2,3).repeat(2),16),Je=parseInt(r.slice(3,4).repeat(2),16),Le=parseInt(r.slice(4,5).repeat(2),16),$e.toColor(Ye,Xe,Je,Le);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Ye=parseInt(n[1]),Xe=parseInt(n[2]),Je=parseInt(n[3]),Le=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),$e.toColor(Ye,Xe,Je,Le);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ye,Xe,Je,Le]=t.getImageData(0,0,1,1).data,Le!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:$e.toRgba(Ye,Xe,Je,Le),css:r}}e.toColor=s})(Re||={});var rt;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,a=r/255,l=n/255,h=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4);return h*.2126+c*.7152+u*.0722}e.relativeLuminance2=i})(rt||={});var Cr;(e=>{function t(o,a){if(Le=(a&255)/255,Le===1)return a;let l=a>>24&255,h=a>>16&255,c=a>>8&255,u=o>>24&255,p=o>>16&255,f=o>>8&255;return Ye=u+Math.round((l-u)*Le),Xe=p+Math.round((h-p)*Le),Je=f+Math.round((c-f)*Le),$e.toRgba(Ye,Xe,Je)}e.blend=t;function i(o,a,l){let h=rt.relativeLuminance(o>>8),c=rt.relativeLuminance(a>>8);if(qt(h,c)<l){if(c<h){let f=s(o,a,l),m=qt(h,rt.relativeLuminance(f>>8));if(m<l){let g=r(o,a,l),_=qt(h,rt.relativeLuminance(g>>8));return m>_?f:g}return f}let u=r(o,a,l),p=qt(h,rt.relativeLuminance(u>>8));if(p<l){let f=s(o,a,l),m=qt(h,rt.relativeLuminance(f>>8));return p>m?u:f}return u}}e.ensureContrastRatio=i;function s(o,a,l){let h=o>>24&255,c=o>>16&255,u=o>>8&255,p=a>>24&255,f=a>>16&255,m=a>>8&255,g=qt(rt.relativeLuminance2(p,f,m),rt.relativeLuminance2(h,c,u));for(;g<l&&(p>0||f>0||m>0);)p-=Math.max(0,Math.ceil(p*.1)),f-=Math.max(0,Math.ceil(f*.1)),m-=Math.max(0,Math.ceil(m*.1)),g=qt(rt.relativeLuminance2(p,f,m),rt.relativeLuminance2(h,c,u));return(p<<24|f<<16|m<<8|255)>>>0}e.reduceLuminance=s;function r(o,a,l){let h=o>>24&255,c=o>>16&255,u=o>>8&255,p=a>>24&255,f=a>>16&255,m=a>>8&255,g=qt(rt.relativeLuminance2(p,f,m),rt.relativeLuminance2(h,c,u));for(;g<l&&(p<255||f<255||m<255);)p=Math.min(255,p+Math.ceil((255-p)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),g=qt(rt.relativeLuminance2(p,f,m),rt.relativeLuminance2(h,c,u));return(p<<24|f<<16|m<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(Cr||={});function Pi(e){let t=e.toString(16);return t.length<2?"0"+t:t}function qt(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var y1=class extends js{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},zr=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Ct}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let i=[],s=t.translateToString(!0),r=0,n=0,o=0,a=t.getFg(0),l=t.getBg(0);for(let h=0;h<t.getTrimmedLength();h++)if(t.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==l){if(h-r>1){let c=this._getJoinedRanges(s,o,n,t,r);for(let u=0;u<c.length;u++)i.push(c[u])}r=h,o=n,a=this._workCell.fg,l=this._workCell.bg}n+=this._workCell.getChars().length||vi.length}if(this._bufferService.cols-r>1){let h=this._getJoinedRanges(s,o,n,t,r);for(let c=0;c<h.length;c++)i.push(h[c])}return i}_getJoinedRanges(e,t,i,s,r){let n=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let l=this._characterJoiners[a].handler(n);for(let h=0;h<l.length;h++)zr._mergeRanges(o,l[h])}catch(l){console.error(l)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(e,t,i){let s=0,r=!1,n=0,o=e[s];if(o){for(let a=i;a<this._bufferService.cols;a++){let l=t.getWidth(a),h=t.getString(a).length||vi.length;if(l!==0){if(!r&&o[0]<=n&&(o[0]=a,r=!0),o[1]<=n){if(o[1]=a,o=e[++s],!o)break;o[0]<=n?(o[0]=a,r=!0):r=!1}n+=h}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=r[0])return e.splice(s,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};zr=Oe([ee(0,ot)],zr);function S1(e){return 57508<=e&&e<=57558}function x1(e){return 9472<=e&&e<=9631}function C1(e){return S1(e)||x1(e)}function D1(){return{css:{canvas:ur(),cell:ur()},device:{canvas:ur(),cell:ur(),char:{width:0,height:0,left:0,top:0}}}}function ur(){return{width:0,height:0}}var Ko=class{constructor(e,t,i,s,r,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new Ct,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,r,n,o,a,l,h,c){let u=[],p=this._characterJoinerService.getJoinedCharacters(t),f=this._themeService.colors,m=e.getNoBgTrimmedLength();i&&m<n+1&&(m=n+1);let g,_=0,E="",C=0,T=0,x=0,A=0,k=!1,N=0,O=!1,z=0,R=0,I=[],w=h!==-1&&c!==-1;for(let v=0;v<m;v++){e.loadCell(v,this._workCell);let S=this._workCell.getWidth();if(S===0)continue;let D=!1,y=v>=R,L=v,M=this._workCell;if(p.length>0&&v===p[0][0]&&y){let we=p.shift(),it=this._isCellInSelection(we[0],t);for(C=we[0]+1;C<we[1];C++)y&&=it===this._isCellInSelection(C,t);y&&=!i||n<we[0]||n>=we[1],y?(D=!0,M=new y1(this._workCell,e.translateToString(!0,we[0],we[1]),we[1]-we[0]),L=we[1]-1,S=M.getWidth()):R=we[1]}let H=this._isCellInSelection(v,t),j=i&&v===n,J=w&&v>=h&&v<=c,te=!1;this._decorationService.forEachDecorationAtCell(v,t,void 0,we=>{te=!0});let ie=M.getChars()||vi;if(ie===" "&&(M.isUnderline()||M.isOverline())&&(ie=" "),z=S*a-l.get(ie,M.isBold(),M.isItalic()),!g)g=this._document.createElement("span");else if(_&&(H&&O||!H&&!O&&M.bg===T)&&(H&&O&&f.selectionForeground||M.fg===x)&&M.extended.ext===A&&J===k&&z===N&&!j&&!D&&!te&&y){M.isInvisible()?E+=vi:E+=ie,_++;continue}else _&&(g.textContent=E),g=this._document.createElement("span"),_=0,E="";if(T=M.bg,x=M.fg,A=M.extended.ext,k=J,N=z,O=H,D&&n>=v&&n<=L&&(n=v),!this._coreService.isCursorHidden&&j&&this._coreService.isCursorInitialized){if(I.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&I.push("xterm-cursor-blink"),I.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":I.push("xterm-cursor-outline");break;case"block":I.push("xterm-cursor-block");break;case"bar":I.push("xterm-cursor-bar");break;case"underline":I.push("xterm-cursor-underline");break}}if(M.isBold()&&I.push("xterm-bold"),M.isItalic()&&I.push("xterm-italic"),M.isDim()&&I.push("xterm-dim"),M.isInvisible()?E=vi:E=M.getChars()||vi,M.isUnderline()&&(I.push(`xterm-underline-${M.extended.underlineStyle}`),E===" "&&(E=" "),!M.isUnderlineColorDefault()))if(M.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${js.toColorRGB(M.getUnderlineColor()).join(",")})`;else{let we=M.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&M.isBold()&&we<8&&(we+=8),g.style.textDecorationColor=f.ansi[we].css}M.isOverline()&&(I.push("xterm-overline"),E===" "&&(E=" ")),M.isStrikethrough()&&I.push("xterm-strikethrough"),J&&(g.style.textDecoration="underline");let le=M.getFgColor(),me=M.getFgColorMode(),ne=M.getBgColor(),W=M.getBgColorMode(),ge=!!M.isInverse();if(ge){let we=le;le=ne,ne=we;let it=me;me=W,W=it}let X,ve,ye=!1;this._decorationService.forEachDecorationAtCell(v,t,void 0,we=>{we.options.layer!=="top"&&ye||(we.backgroundColorRGB&&(W=50331648,ne=we.backgroundColorRGB.rgba>>8&16777215,X=we.backgroundColorRGB),we.foregroundColorRGB&&(me=50331648,le=we.foregroundColorRGB.rgba>>8&16777215,ve=we.foregroundColorRGB),ye=we.options.layer==="top")}),!ye&&H&&(X=this._coreBrowserService.isFocused?f.selectionBackgroundOpaque:f.selectionInactiveBackgroundOpaque,ne=X.rgba>>8&16777215,W=50331648,ye=!0,f.selectionForeground&&(me=50331648,le=f.selectionForeground.rgba>>8&16777215,ve=f.selectionForeground)),ye&&I.push("xterm-decoration-top");let ke;switch(W){case 16777216:case 33554432:ke=f.ansi[ne],I.push(`xterm-bg-${ne}`);break;case 50331648:ke=$e.toColor(ne>>16,ne>>8&255,ne&255),this._addStyle(g,`background-color:#${ud((ne>>>0).toString(16),"0",6)}`);break;default:ge?(ke=f.foreground,I.push("xterm-bg-257")):ke=f.background}switch(X||M.isDim()&&(X=Pe.multiplyOpacity(ke,.5)),me){case 16777216:case 33554432:M.isBold()&&le<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(le+=8),this._applyMinimumContrast(g,ke,f.ansi[le],M,X,void 0)||I.push(`xterm-fg-${le}`);break;case 50331648:let we=$e.toColor(le>>16&255,le>>8&255,le&255);this._applyMinimumContrast(g,ke,we,M,X,ve)||this._addStyle(g,`color:#${ud(le.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,ke,f.foreground,M,X,ve)||ge&&I.push("xterm-fg-257")}I.length&&(g.className=I.join(" "),I.length=0),!j&&!D&&!te&&y?_++:g.textContent=E,z!==this.defaultSpacing&&(g.style.letterSpacing=`${z}px`),u.push(g),v=L}return g&&_&&(g.textContent=E),u}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||C1(s.getCode()))return!1;let o=this._getContrastCache(s),a;if(!r&&!n&&(a=o.getColor(t.rgba,i.rgba)),a===void 0){let l=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=Pe.ensureContrastRatio(r||t,n||i,l),o.setColor((r||t).rgba,(n||i).rgba,a??null)}return a?(this._addStyle(e,`color:${a.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};Ko=Oe([ee(1,up),ee(2,at),ee(3,si),ee(4,$i),ee(5,$s),ee(6,ts)],Ko);function ud(e,t,i){for(;e.length<i;)e=t+e;return e}var k1=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[i,s,r,n],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),t.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(e,t,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let o=this._measure(e,0);return o>0&&(this._flat[s]=o),o}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},P1=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,a=Math.max(n,0),l=Math.min(o,e.rows-1);if(a>=e.rows||l<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=l,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function E1(){return new P1}var zn="xterm-dom-renderer-owner-",vt="xterm-rows",pr="xterm-fg-",pd="xterm-bg-",us="xterm-focus",fr="xterm-selection",T1=1,qo=class extends be{constructor(e,t,i,s,r,n,o,a,l,h,c,u,p,f){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=l,this._optionsService=h,this._bufferService=c,this._coreService=u,this._coreBrowserService=p,this._themeService=f,this._terminalClass=T1++,this._rowElements=[],this._selectionRenderModel=E1(),this.onRequestRedraw=this._register(new q).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(vt),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(fr),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=D1(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(Ko,document),this._element.classList.add(zn+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(Ie(()=>{this._element.classList.remove(zn+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new k1(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),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/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),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(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${vt} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,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(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${vt} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${vt} .xterm-dim { color: ${Pe.multiplyOpacity(e.foreground,.5).css};}`,t+=`${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;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${vt}.${us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${vt}.${us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${vt}.${us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${vt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${vt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${vt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${vt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${vt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${fr} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${fr} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${fr} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${pr}${n} { color: ${o.css}; }${this._terminalSelector} .${pr}${n}.xterm-dim { color: ${Pe.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${pd}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${pr}257 { color: ${Pe.opaque(e.background).css}; }${this._terminalSelector} .${pr}257.xterm-dim { color: ${Pe.multiplyOpacity(Pe.opaque(e.background),.5).css}; }${this._terminalSelector} .${pd}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(us),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(us),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(i){let l=e[0]>t[0];a.appendChild(this._createSelectionElement(n,l?t[0]:e[0],l?e[0]:t[0],o-n+1))}else{let l=s===n?e[0]:0,h=n===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,l,h));let c=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,c)),n!==o){let u=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,u))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,s=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}px`,r}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(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let l=e;l<=t;l++){let h=l+i.ydisp,c=this._rowElements[l],u=i.lines.get(h);if(!c||!u)break;c.replaceChildren(...this._rowFactory.createRow(u,h,h===s,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${zn}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,l=a.ybase+a.y,h=Math.min(a.x,r-1),c=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,p=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=i;f<=s;++f){let m=f+a.ydisp,g=this._rowElements[f],_=a.lines.get(m);if(!g||!_)break;g.replaceChildren(...this._rowFactory.createRow(_,m,m===l,u,p,h,c,this.dimensions.css.cell.width,this._widthCache,n?f===i?e:0:-1,n?(f===s?t:r)-1:-1))}}};qo=Oe([ee(7,Fa),ee(8,en),ee(9,at),ee(10,ot),ee(11,$i),ee(12,si),ee(13,ts)],qo);var Yo=class extends be{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new A1(this._optionsService))}catch{this._measureStrategy=this._register(new I1(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Yo=Oe([ee(2,at)],Yo);var Ap=class extends be{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},I1=class extends Ap{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,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(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},A1=class extends Ap{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},R1=class extends be{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new L1(this._window)),this._onDprChange=this._register(new q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(tt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ce(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ce(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}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}},L1=class extends be{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Qi),this._onDprChange=this._register(new q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Ie(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ce(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.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._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},N1=class extends be{constructor(){super(),this.linkProviders=[],this._register(Ie(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Za(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}function M1(e,t,i,s,r,n,o,a,l){if(!n)return;let h=Za(e,t,i);if(h)return h[0]=Math.ceil((h[0]+(l?o/2:0))/o),h[1]=Math.ceil(h[1]/a),h[0]=Math.min(Math.max(h[0],1),s+(l?1:0)),h[1]=Math.min(Math.max(h[1],1),r),h}var Xo=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return M1(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=Za(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Xo=Oe([ee(0,ri),ee(1,en)],Xo);var O1=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Rp={};Ux(Rp,{getSafariVersion:()=>z1,isChromeOS:()=>Op,isFirefox:()=>Lp,isIpad:()=>B1,isIphone:()=>j1,isLegacyEdge:()=>G1,isLinux:()=>Qa,isMac:()=>Br,isNode:()=>tn,isSafari:()=>Np,isWindows:()=>Mp});var tn=typeof process<"u"&&"title"in process,Ws=tn?"node":navigator.userAgent,Hs=tn?"node":navigator.platform,Lp=Ws.includes("Firefox"),G1=Ws.includes("Edge"),Np=/^((?!chrome|android).)*safari/i.test(Ws);function z1(){if(!Np)return 0;let e=Ws.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Br=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Hs),B1=Hs==="iPad",j1=Hs==="iPhone",Mp=["Windows","Win16","Win32","WinCE"].includes(Hs),Qa=Hs.indexOf("Linux")>=0,Op=/\bCrOS\b/.test(Ws),Gp=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),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(e){this._idleCallback=void 0;let t=0,i=0,s=e.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),r=e.timeRemaining(),i*1.5>r){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=r}this.clear()}},$1=class extends Gp{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},W1=class extends Gp{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},jr=!tn&&"requestIdleCallback"in window?W1:$1,H1=class{constructor(){this._queue=new jr}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Jo=class extends be{constructor(e,t,i,s,r,n,o,a,l){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new Qi),this._pausedResizeTask=new H1,this._observerDisposable=this._register(new Qi),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 q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new O1((h,c)=>this._renderRows(h,c),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new F1(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Ie(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(l.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=Ie(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.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(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,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(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,i){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,this._renderer.value?.handleSelectionChanged(e,t,i)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Jo=Oe([ee(2,at),ee(3,en),ee(4,$i),ee(5,$s),ee(6,ot),ee(7,si),ee(8,ts)],Jo);var F1=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function V1(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return q1(r,n,e,t,i,s)+sn(n,t,i,s)+Y1(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",Ns(Math.abs(r-e),Ls(o,s));o=n>t?"D":"C";let a=Math.abs(n-t),l=K1(n>t?e:r,i)+(a-1)*i.cols+1+U1(n>t?r:e);return Ns(l,Ls(o,s))}function U1(e,t){return e-1}function K1(e,t){return t.cols-e}function q1(e,t,i,s,r,n){return sn(t,s,r,n).length===0?"":Ns(Bp(e,t,e,t-zi(t,r),!1,r).length,Ls("D",n))}function sn(e,t,i,s){let r=e-zi(e,i),n=t-zi(t,i),o=Math.abs(r-n)-X1(e,t,i);return Ns(o,Ls(zp(e,t),s))}function Y1(e,t,i,s,r,n){let o;sn(t,s,r,n).length>0?o=s-zi(s,r):o=t;let a=s,l=J1(e,t,i,s,r,n);return Ns(Bp(e,o,i,a,l==="C",r).length,Ls(l,n))}function X1(e,t,i){let s=0,r=e-zi(e,i),n=t-zi(t,i);for(let o=0;o<Math.abs(r-n);o++){let a=zp(e,t)==="A"?-1:1;i.buffer.lines.get(r+a*o)?.isWrapped&&s++}return s}function zi(e,t){let i=0,s=t.buffer.lines.get(e),r=s?.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=s?.isWrapped;return i}function J1(e,t,i,s,r,n){let o;return sn(i,s,r,n).length>0?o=s-zi(s,r):o=t,e<i&&o<=s||e>=i&&o<s?"C":"D"}function zp(e,t){return e>t?"A":"B"}function Bp(e,t,i,s,r,n){let o=e,a=t,l="";for(;(o!==i||a!==s)&&a>=0&&a<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(l+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&o<0&&(l+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return l+n.buffer.translateBufferLineToString(a,!1,e,o)}function Ls(e,t){let i=t?"O":"[";return $.ESC+i+e}function Ns(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var Z1=class{constructor(e){this._bufferService=e,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.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()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function fd(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Bn=50,Q1=15,eD=50,tD=500,iD=" ",sD=new RegExp(iD,"g"),Zo=class extends be{constructor(e,t,i,s,r,n,o,a,l){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=l,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ct,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new Z1(this._bufferService),this._activeSelectionMode=0,this._register(Ie(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}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(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],n=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let a=i.translateBufferLineToString(o,!0,r,n);s.push(a)}}else{let r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],r));for(let n=e[1]+1;n<=t[1]-1;n++){let o=i.lines.get(n),a=i.translateBufferLineToString(n,!0);o?.isWrapped?s[s.length-1]+=a:s.push(a)}if(e[1]!==t[1]){let n=i.lines.get(t[1]),o=i.translateBufferLineToString(t[1],!0,0,t[0]);n&&n.isWrapped?s[s.length-1]+=o:s.push(o)}}return s.map(r=>r.replace(sD," ")).join(Mp?`\r
|
|
38
|
+
`:`
|
|
39
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Qa&&e&&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(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let i=this._linkifier.currentLink?.link?.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=fd(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Za(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-Bn),Bn),t/=Bn,t/Math.abs(t)+Math.round(t*(Q1-1)))}shouldForceSelection(e){return Br?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),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(),eD)}_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(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Br&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}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(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[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});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<tD&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=V1(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),l=a,h=e[0]-a,c=0,u=0,p=0,f=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;l<o.length&&o.charAt(l+1)===" ";)l++}else{let _=e[0],E=e[0];n.getWidth(_)===0&&(c++,_--),n.getWidth(E)===2&&(u++,E++);let C=n.getString(E).length;for(C>1&&(f+=C-1,l+=C-1);_>0&&a>0&&!this._isCharWordSeparator(n.loadCell(_-1,this._workCell));){n.loadCell(_-1,this._workCell);let T=this._workCell.getChars().length;this._workCell.getWidth()===0?(c++,_--):T>1&&(p+=T-1,a-=T-1),a--,_--}for(;E<n.length&&l+1<o.length&&!this._isCharWordSeparator(n.loadCell(E+1,this._workCell));){n.loadCell(E+1,this._workCell);let T=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,E++):T>1&&(f+=T-1,l+=T-1),l++,E++}}l++;let m=a+h-c+p,g=Math.min(this._bufferService.cols,l-a+c+u-p-f);if(!(!t&&o.slice(a,l).trim()==="")){if(i&&m===0&&n.getCodePoint(0)!==32){let _=r.lines.get(e[1]-1);if(_&&n.isWrapped&&_.getCodePoint(this._bufferService.cols-1)!==32){let E=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(E){let C=this._bufferService.cols-E.start;m-=C,g+=C}}}if(s&&m+g===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let _=r.lines.get(e[1]+1);if(_?.isWrapped&&_.getCodePoint(0)!==32){let E=this._getWordAt([0,e[1]+1],!1,!1,!0);E&&(g+=E.length)}}return{start:m,length:g}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=fd(i,this._bufferService.cols)}};Zo=Oe([ee(3,ot),ee(4,$i),ee(5,Va),ee(6,at),ee(7,ri),ee(8,si)],Zo);var md=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},gd=class{constructor(){this._color=new md,this._css=new md}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},He=Object.freeze((()=>{let e=[Re.toColor("#2e3436"),Re.toColor("#cc0000"),Re.toColor("#4e9a06"),Re.toColor("#c4a000"),Re.toColor("#3465a4"),Re.toColor("#75507b"),Re.toColor("#06989a"),Re.toColor("#d3d7cf"),Re.toColor("#555753"),Re.toColor("#ef2929"),Re.toColor("#8ae234"),Re.toColor("#fce94f"),Re.toColor("#729fcf"),Re.toColor("#ad7fa8"),Re.toColor("#34e2e2"),Re.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:$e.toCss(s,r,n),rgba:$e.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:$e.toCss(s,s,s),rgba:$e.toRgba(s,s,s)})}return e})()),Ti=Re.toColor("#ffffff"),ws=Re.toColor("#000000"),vd=Re.toColor("#ffffff"),_d=ws,ps={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},rD=Ti,Qo=class extends be{constructor(e){super(),this._optionsService=e,this._contrastCache=new gd,this._halfContrastCache=new gd,this._onChangeColors=this._register(new q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ti,background:ws,cursor:vd,cursorAccent:_d,selectionForeground:void 0,selectionBackgroundTransparent:ps,selectionBackgroundOpaque:Pe.blend(ws,ps),selectionInactiveBackgroundTransparent:ps,selectionInactiveBackgroundOpaque:Pe.blend(ws,ps),scrollbarSliderBackground:Pe.opacity(Ti,.2),scrollbarSliderHoverBackground:Pe.opacity(Ti,.4),scrollbarSliderActiveBackground:Pe.opacity(Ti,.5),overviewRulerBorder:Ti,ansi:He.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)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=xe(e.foreground,Ti),t.background=xe(e.background,ws),t.cursor=Pe.blend(t.background,xe(e.cursor,vd)),t.cursorAccent=Pe.blend(t.background,xe(e.cursorAccent,_d)),t.selectionBackgroundTransparent=xe(e.selectionBackground,ps),t.selectionBackgroundOpaque=Pe.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=xe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Pe.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?xe(e.selectionForeground,cd):void 0,t.selectionForeground===cd&&(t.selectionForeground=void 0),Pe.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Pe.opacity(t.selectionBackgroundTransparent,.3)),Pe.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Pe.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=xe(e.scrollbarSliderBackground,Pe.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=xe(e.scrollbarSliderHoverBackground,Pe.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=xe(e.scrollbarSliderActiveBackground,Pe.opacity(t.foreground,.5)),t.overviewRulerBorder=xe(e.overviewRulerBorder,rD),t.ansi=He.slice(),t.ansi[0]=xe(e.black,He[0]),t.ansi[1]=xe(e.red,He[1]),t.ansi[2]=xe(e.green,He[2]),t.ansi[3]=xe(e.yellow,He[3]),t.ansi[4]=xe(e.blue,He[4]),t.ansi[5]=xe(e.magenta,He[5]),t.ansi[6]=xe(e.cyan,He[6]),t.ansi[7]=xe(e.white,He[7]),t.ansi[8]=xe(e.brightBlack,He[8]),t.ansi[9]=xe(e.brightRed,He[9]),t.ansi[10]=xe(e.brightGreen,He[10]),t.ansi[11]=xe(e.brightYellow,He[11]),t.ansi[12]=xe(e.brightBlue,He[12]),t.ansi[13]=xe(e.brightMagenta,He[13]),t.ansi[14]=xe(e.brightCyan,He[14]),t.ansi[15]=xe(e.brightWhite,He[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=xe(e.extendedAnsi[s],He[s+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){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}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]}}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()}}};Qo=Oe([ee(0,at)],Qo);function xe(e,t){if(e!==void 0)try{return Re.toColor(e)}catch{}return t}var nD=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},oD=class{constructor(){this._services=new nD,this._services.set(Fa,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=Qx(e).sort((n,o)=>n.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},aD={trace:0,debug:1,info:2,warn:3,error:4,off:5},lD="xterm.js: ",ea=class extends be{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=aD[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":lD)+t,...i)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};ea=Oe([ee(0,at)],ea);var bd=class extends be{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new q),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,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(e,t,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},_e=3,je=Object.freeze(new js),mr=0,jn=2,ys=class jp{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*_e);let r=i||Ct.fromCharData([0,np,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let i=this._data[t*_e+0],s=i&2097151;return[this._data[t*_e+1],i&2097152?this._combined[t]:s?gi(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*_e+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*_e+0]=t|2097152|i[2]<<22):this._data[t*_e+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*_e+0]>>22}hasWidth(t){return this._data[t*_e+0]&12582912}getFg(t){return this._data[t*_e+1]}getBg(t){return this._data[t*_e+2]}hasContent(t){return this._data[t*_e+0]&4194303}getCodePoint(t){let i=this._data[t*_e+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*_e+0]&2097152}getString(t){let i=this._data[t*_e+0];return i&2097152?this._combined[t]:i&2097151?gi(i&2097151):""}isProtected(t){return this._data[t*_e+2]&536870912}loadCell(t,i){return mr=t*_e,i.content=this._data[mr+0],i.fg=this._data[mr+1],i.bg=this._data[mr+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*_e+0]=i.content,this._data[t*_e+1]=i.fg,this._data[t*_e+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*_e+0]=i|s<<22,this._data[t*_e+1]=r.fg,this._data[t*_e+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*_e+0];r&2097152?this._combined[t]+=gi(i):r&2097151?(this._combined[t]=gi(r&2097151)+gi(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*_e+0]=r}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let r=new Ct;for(let n=this.length-t-i-1;n>=0;--n)this.setCell(t+i+n,this.loadCell(t+n,r));for(let n=0;n<i;++n)this.setCell(t+n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let r=new Ct;for(let n=0;n<this.length-t-i;++n)this.setCell(t+n,this.loadCell(t+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*jn<this._data.buffer.byteLength;let s=t*_e;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let a=parseInt(r[o],10);a>=t&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let a=parseInt(n[o],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,s*4*jn<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*jn<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new jp(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*_e+0]&4194303)return t+(this._data[t*_e+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*_e+0]&4194303||this._data[t*_e+2]&50331648)return t+(this._data[t*_e+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let l=r-1;l>=0;l--){for(let h=0;h<_e;h++)this._data[(s+l)*_e+h]=o[(i+l)*_e+h];o[(i+l)*_e+2]&268435456&&(this._extendedAttrs[s+l]=t._extendedAttrs[i+l])}else for(let l=0;l<r;l++){for(let h=0;h<_e;h++)this._data[(s+l)*_e+h]=o[(i+l)*_e+h];o[(i+l)*_e+2]&268435456&&(this._extendedAttrs[s+l]=t._extendedAttrs[i+l])}let a=Object.keys(t._combined);for(let l=0;l<a.length;l++){let h=parseInt(a[l],10);h>=i&&(this._combined[h-i+s]=t._combined[h])}}translateToString(t,i,s,r){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*_e+0],a=o&2097151,l=o&2097152?this._combined[i]:a?gi(a):vi;if(n+=l,r)for(let h=0;h<l.length;++h)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function hD(e,t,i,s,r,n){let o=[];for(let a=0;a<e.length-1;a++){let l=a,h=e.get(++l);if(!h.isWrapped)continue;let c=[e.get(a)];for(;l<e.length&&h.isWrapped;)c.push(h),h=e.get(++l);if(!n&&s>=a&&s<l){a+=c.length-1;continue}let u=0,p=Ms(c,u,t),f=1,m=0;for(;f<c.length;){let _=Ms(c,f,t),E=_-m,C=i-p,T=Math.min(E,C);c[u].copyCellsFrom(c[f],m,p,T,!1),p+=T,p===i&&(u++,p=0),m+=T,m===_&&(f++,m=0),p===0&&u!==0&&c[u-1].getWidth(i-1)===2&&(c[u].copyCellsFrom(c[u-1],i-1,p++,1,!1),c[u-1].setCell(i-1,r))}c[u].replaceCells(p,i,r);let g=0;for(let _=c.length-1;_>0&&(_>u||c[_].getTrimmedLength()===0);_--)g++;g>0&&(o.push(a+c.length-g),o.push(g)),a+=c.length-1}return o}function dD(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let a=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}function cD(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function uD(e,t,i){let s=[],r=e.map((l,h)=>Ms(e,h,t)).reduce((l,h)=>l+h),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let l=Ms(e,o,t);n>l&&(n-=l,o++);let h=e[o].getWidth(n-1)===2;h&&n--;let c=h?i-1:i;s.push(c),a+=c}return s}function Ms(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var $p=class Wp{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Wp._nextId++,this._onDispose=this.register(new q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Gi(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};$p._nextId=1;var pD=$p,Ke={},Ii=Ke.B;Ke[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ke.A={"#":"£"};Ke.B=void 0;Ke[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ke.C=Ke[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ke.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ke.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ke.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ke.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ke.E=Ke[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ke.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ke.H=Ke[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ke["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var wd=4294967295,yd=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=je.clone(),this.savedCharset=Ii,this.markers=[],this._nullCell=Ct.fromCharData([0,np,1,0]),this._whitespaceCell=Ct.fromCharData([0,vi,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new jr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new bd(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Or),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Or),this._whitespaceCell}getBlankLine(e,t){return new ys(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>wd?wd:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=je);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new bd(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(je),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);let n=0;if(this._rows<t)for(let o=this._rows;o<t;o++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new ys(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new ys(e,i)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=hD(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(je),i);if(s.length>0){let r=dD(this.lines,s);cD(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(je),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new ys(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(je),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let l=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),l.unshift(a);if(!i){let T=this.ybase+this.y;if(T>=o&&T<o+l.length)continue}let h=l[l.length-1].getTrimmedLength(),c=uD(l,this._cols,e),u=c.length-l.length,p;this.ybase===0&&this.y!==this.lines.length-1?p=Math.max(0,this.y-this.lines.maxLength+u):p=Math.max(0,this.lines.length-this.lines.maxLength+u);let f=[];for(let T=0;T<u;T++){let x=this.getBlankLine(je,!0);f.push(x)}f.length>0&&(r.push({start:o+l.length+n,newLines:f}),n+=f.length),l.push(...f);let m=c.length-1,g=c[m];g===0&&(m--,g=c[m]);let _=l.length-u-1,E=h;for(;_>=0;){let T=Math.min(E,g);if(l[m]===void 0)break;if(l[m].copyCellsFrom(l[_],E-T,g-T,T,!0),g-=T,g===0&&(m--,g=c[m]),E-=T,E===0){_--;let x=Math.max(_,0);E=Ms(l,x,this._cols)}}for(let T=0;T<l.length;T++)c[T]<e&&l[T].setCell(c[T],s);let C=u-p;for(;C-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+t-1)}if(r.length>0){let o=[],a=[];for(let g=0;g<this.lines.length;g++)a.push(this.lines.get(g));let l=this.lines.length,h=l-1,c=0,u=r[c];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let p=0;for(let g=Math.min(this.lines.maxLength-1,l+n-1);g>=0;g--)if(u&&u.start>h+p){for(let _=u.newLines.length-1;_>=0;_--)this.lines.set(g--,u.newLines[_]);g++,o.push({index:h+1,amount:u.newLines.length}),p+=u.newLines.length,u=r[++c]}else this.lines.set(g,a[h--]);let f=0;for(let g=o.length-1;g>=0;g--)o[g].index+=f,this.lines.onInsertEmitter.fire(o[g]),f+=o[g].amount;let m=Math.max(0,l+n-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new pD(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},fD=class extends be{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new q),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 yd(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new yd(!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(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),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(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Hp=2,Fp=1,ta=class extends be{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new q),this.onResize=this._onResize.event,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Hp),this.rows=Math.max(e.rawOptions.rows||0,Fp),this.buffers=this._register(new fD(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};ta=Oe([ee(0,at)],ta);var Ki={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Br,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},mD=["normal","bold","100","200","300","400","500","600","700","800","900"],gD=class extends be{constructor(e){super(),this._onOptionChange=this._register(new q),this.onOptionChange=this._onOptionChange.event;let t={...Ki};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Ie(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Ki))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Ki))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Ki[e]),!vD(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Ki[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=mD.includes(t)?t:Ki[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function vD(e){return e==="block"||e==="underline"||e==="bar"}function Ss(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&Ss(e[s],t-1);return i}var Sd=Object.freeze({insertMode:!1}),xd=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),ia=class extends be{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new q),this.onData=this._onData.event,this._onUserInput=this._register(new q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Ss(Sd),this.decPrivateModes=Ss(xd)}reset(){this.modes=Ss(Sd),this.decPrivateModes=Ss(xd)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};ia=Oe([ee(0,ot),ee(1,dp),ee(2,at)],ia);var Cd={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function $n(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var Wn=String.fromCharCode,Dd={DEFAULT:e=>{let t=[$n(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Wn(t[0])}${Wn(t[1])}${Wn(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${$n(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${$n(e,!0)};${e.x};${e.y}${t}`}},sa=class extends be{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new q),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Cd))this.addProtocol(s,Cd[s]);for(let s of Object.keys(Dd))this.addEncoding(s,Dd[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};sa=Oe([ee(0,ot),ee(1,$i),ee(2,at)],sa);var Hn=[[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]],_D=[[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]],Fe;function bD(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return!0;return!1}var wD=class{constructor(){if(this.version="6",!Fe){Fe=new Uint8Array(65536),Fe.fill(1),Fe[0]=0,Fe.fill(0,1,32),Fe.fill(0,127,160),Fe.fill(2,4352,4448),Fe[9001]=2,Fe[9002]=2,Fe.fill(2,11904,42192),Fe[12351]=1,Fe.fill(2,44032,55204),Fe.fill(2,63744,64256),Fe.fill(2,65040,65050),Fe.fill(2,65072,65136),Fe.fill(2,65280,65377),Fe.fill(2,65504,65511);for(let e=0;e<Hn.length;++e)Fe.fill(0,Hn[e][0],Hn[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Fe[e]:bD(e,_D)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=Li.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return Li.createPropertyValue(0,i,s)}},Li=class Dr{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new q,this.onChange=this._onChange.event;let t=new wD;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let h=t.charCodeAt(n);56320<=h&&h<=57343?o=(o-55296)*1024+h-56320+65536:i+=this.wcwidth(h)}let a=this.charProperties(o,s),l=Dr.extractWidth(a);Dr.extractShouldJoin(a)&&(l-=Dr.extractWidth(s)),i+=l,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},yD=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function kd(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var fs=2147483647,SD=256,Vp=class ra{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>SD)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new ra;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let r=t[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let t=new ra(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,r))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>fs?fs:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>fs?fs:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,fs):t}},ms=[],xD=class{constructor(){this._state=0,this._active=ms,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ms}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ms,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ms,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",Qr(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=ms,this._id=-1,this._state=0}}},pt=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Qr(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},gs=[],CD=class{constructor(){this._handlers=Object.create(null),this._active=gs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=gs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=gs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||gs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",Qr(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=gs,this._ident=0}},xs=new Vp;xs.addParam(0);var Pd=class{constructor(e){this._handler=e,this._data="",this._params=xs,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():xs,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Qr(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=xs,this._data="",this._hitLimit=!1,i));return this._params=xs,this._data="",this._hitLimit=!1,t}},DD=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},yt=160,kD=(function(){let e=new DD(4095),t=Array.apply(null,Array(256)).map((a,l)=>l),i=(a,l)=>t.slice(a,l),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(yt,0,2,0),e.add(yt,8,5,8),e.add(yt,6,0,6),e.add(yt,11,0,11),e.add(yt,13,13,13),e})(),PD=class extends be{constructor(e=kD){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Vp,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Ie(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new xD),this._dcsParser=this._register(new CD),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<e.intermediates.length;++r){let n=e.intermediates.charCodeAt(r);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}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.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,l=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&l>-1){for(;l>=0&&(o=a[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._parseStack.handlerPos=l,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&l>-1){for(;l>=0&&(o=a[l](),o!==!0);l--)if(o instanceof Promise)return this._parseStack.handlerPos=l,o}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=n;a<t;++a){switch(s=e[a],r=this._transitions.table[this.currentState<<8|(s<160?s:yt)],r>>4){case 2:for(let p=a+1;;++p){if(p>=t||(s=e[p])<32||s>126&&s<yt){this._printHandler(e,a,p),a=p-1;break}if(++p>=t||(s=e[p])<32||s>126&&s<yt){this._printHandler(e,a,p),a=p-1;break}if(++p>=t||(s=e[p])<32||s>126&&s<yt){this._printHandler(e,a,p),a=p-1;break}if(++p>=t||(s=e[p])<32||s>126&&s<yt){this._printHandler(e,a,p),a=p-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let l=this._csiHandlers[this._collect<<8|s],h=l?l.length-1:-1;for(;h>=0&&(o=l[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._preserveStack(3,l,h,r,a),o;h<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++a<t&&(s=e[a])>47&&s<60);a--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let c=this._escHandlers[this._collect<<8|s],u=c?c.length-1:-1;for(;u>=0&&(o=c[u](),o!==!0);u--)if(o instanceof Promise)return this._preserveStack(4,c,u,r,a),o;u<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let p=a+1;;++p)if(p>=t||(s=e[p])===24||s===26||s===27||s>127&&s<yt){this._dcsParser.put(e,a,p),a=p-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let p=a+1;;p++)if(p>=t||(s=e[p])<32||s>127&&s<yt){this._oscParser.put(e,a,p),a=p-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},ED=/^([\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})$/,TD=/^[\da-f]+$/;function Ed(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=ED.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),TD.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(t.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function Fn(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function ID(e,t=16){let[i,s,r]=e;return`rgb:${Fn(i,t)}/${Fn(s,t)}/${Fn(r,t)}`}var AD={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ui=131072,Td=10;function Id(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Ad=5e3,Rd=0,RD=class extends be{constructor(e,t,i,s,r,n,o,a,l=new PD){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=l,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Jx,this._utf8Decoder=new Zx,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=je.clone(),this._eraseAttrDataInternal=je.clone(),this._onRequestBell=this._register(new q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new q),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 na(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,c)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:c.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,c,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:c,data:u})}),this._parser.setDcsHandlerFallback((h,c,u)=>{c==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:c,payload:u})}),this._parser.setPrintHandler((h,c,u)=>this.print(h,c,u)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(xr.IND,()=>this.index()),this._parser.setExecuteHandler(xr.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(xr.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new pt(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new pt(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new pt(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new pt(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new pt(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new pt(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new pt(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new pt(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new pt(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new pt(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new pt(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new pt(h=>this.restoreCursorColor(h))),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(let h in Ke)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Pd((h,c)=>this.requestStatusString(h,c)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),Ad))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Ad} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>ui&&(n=this._parseStack.position+ui)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<ui&&(this._parseBuffer=new Uint32Array(Math.min(e.length,ui))),o||this._dirtyRowTracker.clearRange(),e.length>ui)for(let h=n;h<e.length;h+=ui){let c=h+ui<e.length?h+ui:e.length,u=typeof e=="string"?this._stringDecoder.decode(e.substring(h,c),this._parseBuffer):this._utf8Decoder.decode(e.subarray(h,c),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,u))return this._preserveStack(s,r,u,h),this._logSlowResolvingAsync(i),i}else if(!o){let h=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,h))return this._preserveStack(s,r,h,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),l=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);l<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(l,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,i){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,l=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,c=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,c);let p=this._parser.precedingJoinState;for(let f=t;f<i;++f){if(s=e[f],s<127&&n){let E=n[String.fromCharCode(s)];E&&(s=E.charCodeAt(0))}let m=this._unicodeService.charProperties(s,p);r=Li.extractWidth(m);let g=Li.extractShouldJoin(m),_=g?Li.extractWidth(p):0;if(p=m,o&&this._onA11yChar.fire(gi(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-_>a){if(l){let E=u,C=this._activeBuffer.x-_;for(this._activeBuffer.x=_,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),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),_>0&&u instanceof ys&&u.copyCellsFrom(E,C,0,_,!1);C<a;)E.setCellFromCodepoint(C++,0,1,c)}else if(this._activeBuffer.x=a-1,r===2)continue}if(g&&this._activeBuffer.x){let E=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-E,s,r);for(let C=r-_;--C>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,c);continue}if(h&&(u.insertCells(this._activeBuffer.x,r-_,this._activeBuffer.getNullCell(c)),u.getWidth(a-1)===2&&u.setCellFromCodepoint(a-1,0,1,c)),u.setCellFromCodepoint(this._activeBuffer.x++,s,r,c),r>0)for(;--r;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,c)}this._parser.precedingJoinState=p,this._activeBuffer.x<a&&i-t>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,c),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Id(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Pd(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new pt(t))}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(){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&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,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(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+i)?.getTrimmedLength(););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)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(e){let t=e.params[0]||1;for(;t--;)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(je));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=Li.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i),a=0;for(let h=0;h<n.length;){let c=n.codePointAt(h)||0;o[a++]=c,h+=c>65535?2:1}let l=a;for(let h=1;h<i;++h)o.copyWithin(l,0,a),l+=a;return this.print(o,0,l),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent($.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent($.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent($.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent($.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent($.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Ii),this._charsetService.setgCharset(1,Ii),this._charsetService.setgCharset(2,Ii),this._charsetService.setgCharset(3,Ii);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(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){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:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let i;(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(i||={});let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:l}=this._bufferService,{active:h,alt:c}=a,u=this._optionsService.rawOptions,p=(g,_)=>(o.triggerDataEvent(`${$.ESC}[${t?"":"?"}${g};${_}$y`),!0),f=g=>g?1:2,m=e.params[0];return t?m===2?p(m,4):m===4?p(m,f(o.modes.insertMode)):m===12?p(m,3):m===20?p(m,f(u.convertEol)):p(m,0):m===1?p(m,f(s.applicationCursorKeys)):m===3?p(m,u.windowOptions.setWinLines?l===80?2:l===132?1:0:0):m===6?p(m,f(s.origin)):m===7?p(m,f(s.wraparound)):m===8?p(m,3):m===9?p(m,f(r==="X10")):m===12?p(m,f(u.cursorBlink)):m===25?p(m,f(!o.isCursorHidden)):m===45?p(m,f(s.reverseWraparound)):m===66?p(m,f(s.applicationKeypad)):m===67?p(m,4):m===1e3?p(m,f(r==="VT200")):m===1002?p(m,f(r==="DRAG")):m===1003?p(m,f(r==="ANY")):m===1004?p(m,f(s.sendFocus)):m===1005?p(m,4):m===1006?p(m,f(n==="SGR")):m===1015?p(m,4):m===1016?p(m,f(n==="SGR_PIXELS")):m===1048?p(m,1):m===47||m===1047||m===1049?p(m,f(h===c)):m===2004?p(m,f(s.bracketedPasteMode)):m===2026?p(m,f(s.synchronizedOutput)):p(m,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=js.fromColorRGB([i,s,r])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=je.fg,e.bg=je.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=je.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=je.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=je.fg&16777215,s.bg&=-67108864,s.bg|=je.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${t};${i}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=je.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(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Id(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Td&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Td&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){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(e){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(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(Ld(n))if(r==="?")t.push({type:0,index:n});else{let o=Ed(r);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=Ed(i[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);Ld(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){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,Ii),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(AD[e[0]],Ke[e[1]]||Ii),!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){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,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=je.clone(),this._eraseAttrDataInternal=je.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ct;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${$.ESC}${o}${$.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},na=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Rd=e,e=t,t=Rd),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};na=Oe([ee(0,ot)],na);function Ld(e){return 0<=e&&e<256}var LD=5e7,Nd=12,ND=50,MD=class extends be{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new q),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>LD)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let o=a=>performance.now()-i>=Nd?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Nd)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>ND&&(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()}},oa=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let a=t.addMarker(t.ybase+t.y),l={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(l,a)),this._dataByLinkId.set(l.id,l),l.id}let i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};oa=Oe([ee(0,ot)],oa);var Md=!1,OD=class extends be{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Qi),this._onBinary=this._register(new q),this.onBinary=this._onBinary.event,this._onData=this._register(new q),this.onData=this._onData.event,this._onLineFeed=this._register(new q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new q),this._instantiationService=new oD,this.optionsService=this._register(new gD(e)),this._instantiationService.setService(at,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(ta)),this._instantiationService.setService(ot,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ea)),this._instantiationService.setService(dp,this._logService),this.coreService=this._register(this._instantiationService.createInstance(ia)),this._instantiationService.setService($i,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(sa)),this._instantiationService.setService(hp,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Li)),this._instantiationService.setService(iC,this.unicodeService),this._charsetService=this._instantiationService.createInstance(yD),this._instantiationService.setService(tC,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(oa),this._instantiationService.setService(cp,this._oscLinkService),this._inputHandler=this._register(new RD(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(tt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(tt.forward(this._bufferService.onResize,this._onResize)),this._register(tt.forward(this.coreService.onData,this._onData)),this._register(tt.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new MD((t,i)=>this._inputHandler.parse(t,i))),this._register(tt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new q),this._onScroll.event(e=>{this._onScrollApi?.fire(e.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(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Md&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Md=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,Hp),t=Math.max(t,Fp),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(kd.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(kd(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ie(()=>{for(let t of e)t.dispose()})}}},GD={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:["'",'"']};function zD(e,t,i,s){let r={type:0,cancel:!1,key:void 0},n=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?r.key=$.ESC+"OA":r.key=$.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=$.ESC+"OD":r.key=$.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=$.ESC+"OC":r.key=$.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=$.ESC+"OB":r.key=$.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":$.DEL,e.altKey&&(r.key=$.ESC+r.key);break;case 9:if(e.shiftKey){r.key=$.ESC+"[Z";break}r.key=$.HT,r.cancel=!0;break;case 13:r.key=e.altKey?$.ESC+$.CR:$.CR,r.cancel=!0;break;case 27:r.key=$.ESC,e.altKey&&(r.key=$.ESC+$.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=$.ESC+"[1;"+(n+1)+"D":t?r.key=$.ESC+"OD":r.key=$.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=$.ESC+"[1;"+(n+1)+"C":t?r.key=$.ESC+"OC":r.key=$.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=$.ESC+"[1;"+(n+1)+"A":t?r.key=$.ESC+"OA":r.key=$.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=$.ESC+"[1;"+(n+1)+"B":t?r.key=$.ESC+"OB":r.key=$.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=$.ESC+"[2~");break;case 46:n?r.key=$.ESC+"[3;"+(n+1)+"~":r.key=$.ESC+"[3~";break;case 36:n?r.key=$.ESC+"[1;"+(n+1)+"H":t?r.key=$.ESC+"OH":r.key=$.ESC+"[H";break;case 35:n?r.key=$.ESC+"[1;"+(n+1)+"F":t?r.key=$.ESC+"OF":r.key=$.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=$.ESC+"[5;"+(n+1)+"~":r.key=$.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=$.ESC+"[6;"+(n+1)+"~":r.key=$.ESC+"[6~";break;case 112:n?r.key=$.ESC+"[1;"+(n+1)+"P":r.key=$.ESC+"OP";break;case 113:n?r.key=$.ESC+"[1;"+(n+1)+"Q":r.key=$.ESC+"OQ";break;case 114:n?r.key=$.ESC+"[1;"+(n+1)+"R":r.key=$.ESC+"OR";break;case 115:n?r.key=$.ESC+"[1;"+(n+1)+"S":r.key=$.ESC+"OS";break;case 116:n?r.key=$.ESC+"[15;"+(n+1)+"~":r.key=$.ESC+"[15~";break;case 117:n?r.key=$.ESC+"[17;"+(n+1)+"~":r.key=$.ESC+"[17~";break;case 118:n?r.key=$.ESC+"[18;"+(n+1)+"~":r.key=$.ESC+"[18~";break;case 119:n?r.key=$.ESC+"[19;"+(n+1)+"~":r.key=$.ESC+"[19~";break;case 120:n?r.key=$.ESC+"[20;"+(n+1)+"~":r.key=$.ESC+"[20~";break;case 121:n?r.key=$.ESC+"[21;"+(n+1)+"~":r.key=$.ESC+"[21~";break;case 122:n?r.key=$.ESC+"[23;"+(n+1)+"~":r.key=$.ESC+"[23~";break;case 123:n?r.key=$.ESC+"[24;"+(n+1)+"~":r.key=$.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=$.DEL:e.keyCode===219?r.key=$.ESC:e.keyCode===220?r.key=$.FS:e.keyCode===221&&(r.key=$.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let o=GD[e.keyCode]?.[e.shiftKey?1:0];if(o)r.key=$.ESC+o;else if(e.keyCode>=65&&e.keyCode<=90){let a=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(a);e.shiftKey&&(l=l.toUpperCase()),r.key=$.ESC+l}else if(e.keyCode===32)r.key=$.ESC+(e.ctrlKey?$.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let a=e.code.slice(3,4);e.shiftKey||(a=a.toLowerCase()),r.key=$.ESC+a,r.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=$.US),e.key==="@"&&(r.key=$.NUL));break}return r}var ze=0,BD=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new jr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new jr,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((r,n)=>this._getKey(r)-this._getKey(n)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(ze=this._search(t),ze===-1)||this._getKey(this._array[ze])!==t)return!1;do if(this._array[ze]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ze),!0;while(++ze<this._array.length&&this._getKey(this._array[ze])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,n)=>r-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ze=this._search(e),!(ze<0||ze>=this._array.length)&&this._getKey(this._array[ze])===e))do yield this._array[ze];while(++ze<this._array.length&&this._getKey(this._array[ze])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ze=this._search(e),!(ze<0||ze>=this._array.length)&&this._getKey(this._array[ze])===e))do t(this._array[ze]);while(++ze<this._array.length&&this._getKey(this._array[ze])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Vn=0,Od=0,jD=class extends be{constructor(){super(),this._decorations=new BD(e=>e?.marker.line),this._onDecorationRegistered=this._register(new q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ie(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new $D(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,r=>{Vn=r.options.x??0,Od=Vn+(r.options.width??1),e>=Vn&&e<Od&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},$D=class extends wi{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new q),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Re.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Re.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},WD=1e3,HD=class{constructor(e,t=WD){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Gd=20,$r=class extends be{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new HD(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(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
40
|
+
`))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(ce(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ie(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Gd+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
41
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Gd+1&&(this._liveRegion.textContent+=ko.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let n=i.lines.get(i.ydisp+r),o=[],a=n?.translateToString(!0,void 0,void 0,o)||"",l=(i.ydisp+r+1).toString(),h=this._rowElements[r];h&&(a.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=a,this._rowColumns.set(h,o)),h.setAttribute("aria-posinset",l),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==s)return;let o,a;if(t===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let l=this._createAccessibilityTreeNode();this._rowElements.unshift(l),this._rowContainer.insertAdjacentElement("afterbegin",l)}else{let l=this._createAccessibilityTreeNode();this._rowElements.push(l),this._rowContainer.appendChild(l)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(i.node))return;let r=({node:a,offset:l})=>{let h=a instanceof Text?a.parentNode:a,c=parseInt(h?.getAttribute("aria-posinset"),10)-1;if(isNaN(c))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(h);if(!u)return console.warn("columns is null. Race condition?"),null;let p=l<u.length?u[l]:u.slice(-1)[0]+1;return p>=this._terminal.cols&&(++c,p=0),{row:c,column:p}},n=r(t),o=r(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,i=this._rowColumns.get(e)?.slice(-1)?.[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};$r=Oe([ee(1,Fa),ee(2,si),ee(3,ri)],$r);var aa=class extends be{constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Ie(()=>{Gi(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(ce(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ce(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ce(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ce(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s<i.length;s++){let r=i[s];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(s=>{s?.forEach(r=>{r.link.dispose&&r.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[s,r]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(s)&&(i=this._checkLinkProviderResult(s,e,i)):r.provideLinks(e.y,n=>{if(this._isMouseOut)return;let o=n?.map(a=>({link:a}));this._activeProviderReplies?.set(s,o),i=this._checkLinkProviderResult(s,e,i),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let r=t.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[n],a=o.link.range.start.y<e?0:o.link.range.start.x,l=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let h=a;h<=l;h++){if(i.has(h)){r.splice(n--,1);break}i.add(h)}}}}_checkLinkProviderResult(e,t,i){if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),r=!1;for(let n=0;n<e;n++)(!this._activeProviderReplies.has(n)||this._activeProviderReplies.get(n))&&(r=!0);if(!r&&s){let n=s.find(o=>this._linkAtPosition(o.link,t));n&&(i=!0,this._handleNewLink(n))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let n=0;n<this._activeProviderReplies.size;n++){let o=this._activeProviderReplies.get(n)?.find(a=>this._linkAtPosition(a.link,t));if(o){i=!0,this._handleNewLink(o);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&FD(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Gi(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:i=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:i=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};aa=Oe([ee(1,Va),ee(2,ri),ee(3,ot),ee(4,pp)],aa);function FD(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var VD=class extends OD{constructor(e={}){super(e),this._linkifier=this._register(new Qi),this.browser=Rp,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Qi),this._onCursorMove=this._register(new q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new q),this.onKey=this._onKey.event,this._onRender=this._register(new q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new q),this.onBell=this._onBell.event,this._onFocus=this._register(new q),this._onBlur=this._register(new q),this._onA11yCharEmitter=this._register(new q),this._onA11yTabEmitter=this._register(new q),this._onWillOpen=this._register(new q),this._setup(),this._decorationService=this._instantiationService.createInstance(jD),this._instantiationService.setService($s,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(N1),this._instantiationService.setService(pp,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Eo)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(tt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(tt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(tt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(tt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Ie(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}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}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let r=Pe.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${$.ESC}]${s};${ID(r)}${Ip.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=$e.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=$e.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance($r,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ce(this.element,"copy",t=>{this.hasSelection()&&Yx(t,this._selectionService)}));let e=t=>Xx(t,this.textarea,this.coreService,this.optionsService);this._register(ce(this.textarea,"paste",e)),this._register(ce(this.element,"paste",e)),Lp?this._register(ce(this.element,"mousedown",t=>{t.button===2&&Kh(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ce(this.element,"contextmenu",t=>{Kh(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Qa&&this._register(ce(this.element,"auxclick",t=>{t.button===1&&rp(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ce(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(ce(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(ce(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(ce(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ce(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(ce(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ce(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(ce(this.screenElement,"mousemove",r=>this.updateCursorStyle(r))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Do.get()),Op||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._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(R1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(si,this._coreBrowserService),this._register(ce(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(ce(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Yo,this._document,this._helperContainer),this._instantiationService.setService(en,this._charSizeService),this._themeService=this._instantiationService.createInstance(Qo),this._instantiationService.setService(ts,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(zr),this._instantiationService.setService(up,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Jo,this.rows,this.screenElement)),this._instantiationService.setService(ri,this._renderService),this._register(this._renderService.onRenderedViewportChange(r=>this._onRender.fire(r))),this.onResize(r=>this._renderService.resize(r.cols,r.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Uo,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Xo),this._instantiationService.setService(Va,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(aa,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),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._viewport=this._register(this._instantiationService.createInstance(Fo,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(r=>{super.scrollLines(r,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Zo,this.element,this.screenElement,s)),this._instantiationService.setService(rC,this._selectionService),this._register(this._selectionService.onRequestScrollLines(r=>this.scrollLines(r.amount,r.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(r=>this._renderService.handleSelectionChanged(r.start,r.end,r.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(r=>{this.textarea.value=r,this.textarea.focus(),this.textarea.select()})),this._register(tt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Vo,this.screenElement)),this._register(ce(this.element,"mousedown",r=>this._selectionService.handleMouseDown(r))),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($r,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Gr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Gr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(qo,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let a,l;switch(n.overrideType||n.type){case"mousemove":l=32,n.buttons===void 0?(a=3,n.button!==void 0&&(a=n.button<3?n.button:3)):a=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":l=0,a=n.button<3?n.button:3;break;case"mousedown":l=1,a=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let h=n.deltaY;if(h===0||e.coreMouseService.consumeWheelEvent(n,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;l=h<0?0:1,a=4;break;default:return!1}return l===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:l,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),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()),n&8?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ce(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(ce(t,"wheel",n=>{if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(n,!0);let o=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(o,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?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(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){sp(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}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(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=zD(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===$.ETX||i.key===$.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(UD(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){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 e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(je));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent($.ESC+"[I"):this.coreService.triggerDataEvent($.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function UD(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var KD=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},qD=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Ct)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},zd=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,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(e){let t=this._buffer.lines.get(e);if(t)return new qD(t)}getNullCell(){return new Ct}},YD=class extends be{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new q),this.onBufferChange=this._onBufferChange.event,this._normal=new zd(this._core.buffers.normal,"normal"),this._alternate=new zd(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)}},XD=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},JD=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},ZD=["cols","rows"],Nt=0,QD=class extends be{constructor(e){super(),this._core=this._register(new VD(e)),this._addonManager=this._register(new KD),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(e){if(ZD.includes(e))throw new Error(`Option "${e}" 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 XD(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new JD(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 YD(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
42
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Do.get()},set promptLabel(e){Do.set(e)},get tooMuchOutput(){return ko.get()},set tooMuchOutput(e){ko.set(e)}}}_verifyIntegers(...e){for(Nt of e)if(Nt===1/0||isNaN(Nt)||Nt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Nt of e)if(Nt&&(Nt===1/0||isNaN(Nt)||Nt%1!==0||Nt<0))throw new Error("This API only accepts positive integers")}};function Bd(e){const t=e.replace(/[\u0000-\u001f\u007f]/g,"").trim();if(!t)return"";let i=t;const s=t.lastIndexOf(": ");return s>=0&&(i=t.slice(s+2).trim()),!i.includes("/")&&!i.startsWith("~")?i:i.replace(/^~\/?/,"").split("/").filter(Boolean).at(-1)||i}let jd=!1;function ek(){jd||(jd=!0,window.electronAPI.terminal.onData(({termId:e,data:t})=>{Si.get(e)?.term.write(t)}),window.electronAPI.terminal.onExit(({termId:e,exitCode:t})=>{Si.get(e)?.term.write(`\r
|
|
43
|
+
\x1B[2m[process exited: ${t}]\x1B[0m\r
|
|
44
|
+
`)}))}function tk(e,t){ek();const i=Si.get(e);if(i)return i;const s=new QD({cursorBlink:!0,fontFamily:`"Enso Nerd Symbols", ${t.fontFamily}`,fontSize:t.fontSize,...t.fontWeight?{fontWeight:t.fontWeight}:{},...t.fontWeightBold?{fontWeightBold:t.fontWeightBold}:{},theme:t.theme,allowTransparency:!0,allowProposedApi:!0,scrollback:5e3}),r=new RS,n=new cx;s.loadAddon(r),s.loadAddon(n),s.loadAddon(new Fx((h,c)=>{window.open(c,"_blank")}));const o=new zx;s.loadAddon(o),s.unicode.activeVersion="11";const a=document.createElement("div");a.dataset.termId=e,a.style.width="100%",a.style.height="100%",s.onData(h=>{window.electronAPI.terminal.write(e,h)});const l={term:s,fit:r,search:n,host:a,opened:!1};return s.onTitleChange(h=>{const c=Bd(h);c&&l.onTitle?.(c)}),s.parser.registerOscHandler(7,h=>{try{const c=decodeURIComponent(h).replace(/^file:\/\/[^/]*/,""),u=Bd(c);u&&l.onTitle?.(u)}catch{}return!1}),Si.set(e,l),l}function ik(e,t,i){const s=tk(e,i);return s.host.parentElement!==t&&t.appendChild(s.host),!s.opened&&t.isConnected&&t.clientWidth>0&&(s.term.open(s.host),s.opened=!0),s}function sk(e){Si.get(e)?.host.remove()}function rk(e,t,i,s,r){for(const{term:n}of Si.values())n.options.theme=e,n.options.fontFamily=`"Enso Nerd Symbols", ${t}`,n.options.fontSize=i,s&&(n.options.fontWeight=s),r&&(n.options.fontWeightBold=r)}function $d(e,t,i,s){const r=Si.get(e)?.search;return!r||!t?!1:i==="next"?r.findNext(t,s):r.findPrevious(t,s)}function nk(e){Si.get(e)?.search.clearDecorations()}function ok({open:e,onClose:t,onFindNext:i,onFindPrevious:s,onClear:r,theme:n}){const{t:o}=he(),a=b.useRef(null),[l,h]=b.useState(""),[c,u]=b.useState(!1),[p,f]=b.useState(!1),[m,g]=b.useState(!1),[_,E]=b.useState(null);b.useEffect(()=>{e?(a.current?.focus(),a.current?.select()):(r(),E(null))},[e,r]);const C=()=>({caseSensitive:c,wholeWord:p,regex:m}),T=k=>{if(!l){E(null);return}E(k==="next"?i(l,C()):s(l,C()))};if(!e)return null;const x=n?.background??"#1e1e1e",A=n?.foreground??"#d4d4d4";return d.jsxs("div",{className:"absolute top-2 right-2 z-10 flex items-center gap-1 rounded-md border px-2 py-1 shadow-lg",style:{backgroundColor:x,borderColor:`${A}30`},children:[d.jsx("input",{ref:a,value:l,onChange:k=>{const N=k.target.value;h(N),N?E(i(N,C())):(r(),E(null))},onKeyDown:k=>{k.key==="Enter"?(k.preventDefault(),T(k.shiftKey?"prev":"next")):k.key==="Escape"&&(k.preventDefault(),t())},placeholder:o("Search..."),className:Y("w-40 bg-transparent text-sm outline-none placeholder:opacity-50",_===!1&&l&&"text-red-400"),style:{color:A}}),d.jsx("button",{type:"button",onClick:()=>u(k=>!k),className:Y("flex h-6 w-6 items-center justify-center rounded text-xs font-bold",c?"bg-white/20":"opacity-50 hover:opacity-100"),style:{color:A},title:o("Case sensitive"),children:"Aa"}),d.jsx("button",{type:"button",onClick:()=>f(k=>!k),className:Y("flex h-6 w-6 items-center justify-center rounded text-xs font-bold",p?"bg-white/20":"opacity-50 hover:opacity-100"),style:{color:A},title:o("Whole word"),children:"W"}),d.jsx("button",{type:"button",onClick:()=>g(k=>!k),className:Y("flex h-6 w-6 items-center justify-center rounded text-xs font-bold",m?"bg-white/20":"opacity-50 hover:opacity-100"),style:{color:A},title:o("Regular expression"),children:".*"}),d.jsx("div",{className:"mx-1 h-4 w-px",style:{backgroundColor:`${A}30`}}),d.jsx("button",{type:"button",onClick:()=>T("prev"),className:"flex h-6 w-6 items-center justify-center rounded opacity-70 hover:opacity-100",style:{color:A},title:o("Previous match"),children:d.jsx(mm,{className:"h-4 w-4"})}),d.jsx("button",{type:"button",onClick:()=>T("next"),className:"flex h-6 w-6 items-center justify-center rounded opacity-70 hover:opacity-100",style:{color:A},title:o("Next match"),children:d.jsx(Bi,{className:"h-4 w-4"})}),d.jsx("button",{type:"button",onClick:t,className:"flex h-6 w-6 items-center justify-center rounded opacity-70 hover:opacity-100",style:{color:A},title:o("Close"),children:d.jsx(Gs,{className:"h-4 w-4"})})]})}function Wd(e,t){const i=hc(e);return t?vm(i):i}function ak({termId:e,conversationId:t,projectId:i,onTitle:s}){const{t:r}=he(),n=b.useRef(null),o=b.useRef(null),a=b.useRef(""),[l,h]=b.useState(!1),c=b.useRef(t);c.current=t;const u=b.useRef(i);u.current=i;const p=b.useRef(s);p.current=s;const f=Ue(S=>S.terminalTheme),m=Ue(S=>S.terminalFontFamily),g=Ue(S=>S.terminalFontSize),_=Ue(S=>S.terminalFontWeight),E=Ue(S=>S.terminalFontWeightBold),C=gm()!==null,T=b.useRef(C);T.current=C;const[x,A]=b.useState(!1);b.useEffect(()=>{const S=n.current;if(!S)return;let D=!1,y=0,L;const M=()=>{if(D)return;if(!S.isConnected||S.clientWidth===0||S.clientHeight===0){y=requestAnimationFrame(M);return}const j=Ue.getState(),J=ik(e,S,{theme:Wd(j.terminalTheme,T.current),fontFamily:j.terminalFontFamily,fontSize:j.terminalFontSize,fontWeight:j.terminalFontWeight,fontWeightBold:j.terminalFontWeightBold});if(!J.opened){y=requestAnimationFrame(M);return}J.onTitle=ie=>p.current?.(ie);const te=()=>{!S.isConnected||S.clientWidth===0||(J.fit.fit(),window.electronAPI.terminal.resize(e,J.term.cols,J.term.rows))};te(),window.electronAPI.terminal.create({termId:e,conversationId:c.current,projectId:u.current,cols:J.term.cols,rows:J.term.rows}),J.term.focus(),o.current=J.term,L=new ResizeObserver(te),L.observe(S)};document.fonts.load('14px "Enso Nerd Symbols"',"").then(M,j=>{console.warn("Failed to load terminal icon font",j),M()});const H=j=>{(j.metaKey||j.ctrlKey)&&j.key==="f"&&(j.preventDefault(),j.stopPropagation(),A(!0))};return S.addEventListener("keydown",H,!0),()=>{D=!0,cancelAnimationFrame(y),L?.disconnect(),S.removeEventListener("keydown",H,!0),o.current=null,sk(e)}},[e]),b.useEffect(()=>{rk(Wd(f,C),m,g,_,E)},[f,m,g,_,E,C]);const k=b.useCallback((S,D)=>$d(e,S,"next",D),[e]),N=b.useCallback((S,D)=>$d(e,S,"prev",D),[e]),O=b.useCallback(()=>nk(e),[e]),z=()=>{const S=o.current?.getSelection().trim()??"";a.current=S,h(S.length>0)},R=()=>{const S=a.current||o.current?.getSelection().trim()||"";S&&(_c(S),Da(),o.current?.clearSelection(),h(!1))},I=()=>{const S=a.current||o.current?.getSelection().trim()||"";S&&navigator.clipboard.writeText(S)},w=hc(f),v=d.jsx("div",{ref:n,"data-slot":"terminal-pane",className:"relative h-full w-full overflow-hidden p-2",style:{backgroundColor:w?.background,"--terminal-bg":w?.background},onContextMenu:z,children:d.jsx(ok,{open:x,onClose:()=>A(!1),onFindNext:k,onFindPrevious:N,onClear:O,theme:w})});return d.jsxs(va,{children:[d.jsx(_a,{render:v}),d.jsxs(ba,{className:"min-w-40",children:[d.jsx(et,{disabled:!l,onClick:I,children:r("Copy")}),d.jsx(et,{disabled:!l,onClick:R,children:r("Send to conversation")})]})]})}const Up={running:"bg-amber-500",completed:"bg-emerald-500",failed:"bg-destructive",cancelled:"bg-muted-foreground"},lk=[],hk={project:"Project",custom:"Custom",global:"Global",plugin:"Plugin",builtin:"Built-in"};function dk(e,t,i,s){const r=ue.getState(),n=r.conversations[e],o=Ue.getState(),a=o.projects.find(c=>c.id===n?.projectId);if(!n||!a)return!1;const l=Zd({defaultModel:o.defaultModel,...Jd(a,o.projectGroups),lastProviderId:n.lastProviderId,lastModelId:n.lastModelId,providers:ym(),credentials:Qd(Xd.getState().snapshot),virtualModels:o.virtualModels});if(l.source==="none")return kr({type:"warning",title:s("No usable model is available. Configure provider credentials and enable a model first.")}),!1;const h={};for(const c of t.args){const u=i[c.key]?.trim();u&&(h[c.key]=u)}return r.send(Sm({id:t.id,name:t.source==="builtin"?s(t.name):t.name,args:h}),{providerId:l.providerId,modelId:l.modelId,cwd:a.path},void 0,e),!0}function ck({conversationId:e,preset:t,open:i,onToggle:s}){const{t:r}=he(),[n,o]=b.useState({}),a=t.args.some(c=>c.required&&!c.default?.trim()&&!n[c.key]?.trim()),l=t.source==="builtin"?r(t.name):t.name,h=t.source==="builtin"?r(t.description):t.description;return d.jsxs("li",{className:"rounded-md border",children:[d.jsxs("button",{type:"button",className:"w-full px-2 py-1.5 text-left text-xs hover:bg-muted/60",onClick:s,children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:l}),d.jsx("span",{className:"shrink-0 text-muted-foreground",children:r(hk[t.source])})]}),d.jsx("p",{className:"mt-0.5 line-clamp-2 text-muted-foreground",children:h})]}),i?d.jsxs("form",{className:"space-y-2 border-t px-2 py-2",onSubmit:c=>{c.preventDefault(),!(a||!dk(e,t,n,r))&&(o({}),s())},children:[t.args.map(c=>d.jsxs("label",{className:"block text-xs",children:[d.jsxs("span",{className:"text-muted-foreground",children:[t.source==="builtin"?r(c.label):c.label,c.required?" *":""]}),d.jsx(oc,{size:"sm",className:"mt-1",value:n[c.key]??"",placeholder:c.default,onChange:u=>o(p=>({...p,[c.key]:u.target.value}))})]},c.key)),d.jsx("div",{className:"flex justify-end",children:d.jsxs(Ne,{type:"submit",size:"xs",disabled:a,children:[d.jsx(wm,{}),r("Run")]})})]}):null]})}function uk({conversationId:e}){const{t}=he(),[i,s]=b.useState([]),[r,n]=b.useState(null),o=Ue(c=>c.disabledWorkflowPresets),a=ue(c=>c.conversations[e]?.presetId),l=b.useCallback(()=>{let c=!1;return window.electronAPI.assets.listWorkflowPresets(e,a).then(u=>{c||s(u)}).catch(()=>{c||s([])}),()=>{c=!0}},[e,a]);b.useEffect(l,[l]);const h=i.filter(c=>c.source!=="builtin"||!o.includes(c.id));return d.jsxs("section",{children:[d.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[d.jsx("h3",{className:"flex-1 text-xs font-medium text-muted-foreground",children:t("Presets")}),d.jsx(Ne,{type:"button",variant:"ghost",size:"icon-xs","aria-label":t("Manage workflow presets"),title:t("Manage workflow presets"),onClick:()=>{window.electronAPI.window.openSettings({category:"workflows",rowId:"workflows.root"})},children:d.jsx(bm,{})}),d.jsx(Ne,{type:"button",variant:"ghost",size:"icon-xs","aria-label":t("Refresh"),onClick:()=>l(),children:d.jsx(_i,{})})]}),d.jsx("ul",{className:"space-y-1.5",children:h.map(c=>d.jsx(ck,{conversationId:e,preset:c,open:r===c.id,onToggle:()=>n(u=>u===c.id?null:c.id)},`${c.source}:${c.id}`))})]})}function pk(e,t){const i=ue.getState();i.activeId!==e&&i.selectConversation(e),i.selectTab(e,t)}function fk({conversationId:e,member:t}){const{t:i}=he(),s=d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:Y("h-1.5 w-1.5 shrink-0 rounded-full",Up[t.status])}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.label}),d.jsx("span",{className:"text-muted-foreground",children:i(t.status)})]}),t.prompt?d.jsx("p",{className:"mt-0.5 truncate pl-3.5 text-muted-foreground",children:t.prompt}):null,t.result?d.jsx("p",{className:"mt-0.5 line-clamp-3 whitespace-pre-wrap pl-3.5 text-foreground/80",children:t.result}):null]}),r=t.childId;return r?d.jsx("li",{children:d.jsx("button",{type:"button",className:"w-full rounded px-1 py-0.5 text-left text-xs hover:bg-muted/60",onClick:()=>pk(e,r),children:s})}):d.jsx("li",{className:"text-xs",children:s})}function mk({conversationId:e}){const{t}=he(),i=Xn(n=>n.byConversation[e])??lk,s=Xn(n=>n.clearFinished),r=i.some(n=>n.status!=="running");return d.jsx("div",{className:"h-full overflow-auto bg-background p-3",children:d.jsxs("div",{className:"space-y-3",children:[d.jsx(uk,{conversationId:e}),r?d.jsx("div",{className:"flex justify-end",children:d.jsxs(Ne,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground",onClick:()=>s(e),children:[d.jsx(_m,{}),t("Clear finished runs")]})}):null,i.length===0?d.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:t("No workflow runs")}):null,i.map(n=>d.jsxs("section",{className:"rounded-md border px-3 py-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:Y("h-2 w-2 shrink-0 rounded-full",Up[n.status])}),d.jsx("h3",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:n.name}),d.jsx("span",{className:"text-xs text-muted-foreground",children:t(n.status)}),n.status==="running"?d.jsx(Ne,{type:"button",variant:"ghost",size:"icon-xs",className:"text-muted-foreground hover:text-destructive","aria-label":t("Stop"),title:t("Stop"),onClick:()=>{window.electronAPI.agent.stopWorkflow(e,n.runId)},children:d.jsx(Yd,{})}):null]}),d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n.description}),d.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:t("{{count}} agents",{count:n.members.length})}),d.jsx("div",{className:"mt-2 space-y-2",children:Iv(n.members).map((o,a,l)=>{const h=!!o.phase&&o.phase!==l[a-1]?.phase;return d.jsxs("div",{children:[d.jsxs("div",{className:"mb-1 flex items-center gap-2 text-xs",children:[h?d.jsx("span",{className:"font-medium",children:o.phase}):null,o.members.length>1?d.jsx("span",{className:"text-muted-foreground",children:t("Parallel")}):null]}),d.jsx("ul",{className:"space-y-1",children:o.members.map(c=>d.jsx(fk,{conversationId:e,member:c},c.seq))})]},`${o.batch}:${o.phase??""}`)})}),n.error?d.jsx("p",{className:"mt-2 text-xs text-destructive",children:n.error}):null,n.logs.length>0?d.jsx("p",{className:"mt-2 whitespace-pre-wrap text-xs text-muted-foreground",children:n.logs.join(`
|
|
45
|
+
`)}):null]},n.runId))]})})}const ss=b.createContext({}),Kp=b.createContext(!1);function rn({api:e,children:t}){const{conversationId:i}=b.useContext(ss);return i?d.jsx(Gg,{dockConversationId:i,api:e,children:t}):t}function gk(e,t){const[i,s]=b.useState(!t);return b.useEffect(()=>{if(!t)return;const r=()=>{const o=t.element.closest(".dv-dockview")?.getBoundingClientRect(),a=t.element.getBoundingClientRect();s(!!o&&Math.abs(a.top-o.top)<1&&Math.abs(a.right-o.right)<1)};r();const n=e.onDidLayoutChange(r);return()=>n.dispose()},[e,t]),i}function qp(e,t){const i=e.panels.length;return i===0?t:`${t} ${i+1}`}function Yp(e,t,i,s){e.addPanel({id:crypto.randomUUID(),component:"terminal",title:qp(e,s),params:{conversationId:t,projectId:i}})}function el(e,t,i,s){const r=e.getPanel("changes");if(r){r.focus();return}e.addPanel({id:"changes",component:"changes",title:s,params:{conversationId:t,projectId:i}})}function vk(e){return d.jsx(ak,{termId:e.api.id,conversationId:e.params.conversationId,projectId:e.params.projectId,onTitle:t=>e.api.setTitle(t)})}function _k(e){const{conversationId:t,projectId:i}=e.params;return!t||!i?null:d.jsx(rn,{api:e.api,children:d.jsx(Ny,{conversationId:t,projectId:i})})}function tl(e,t,i,s){const r=e.getPanel("files");if(r){r.focus();return}e.addPanel({id:"files",component:"files",title:s,params:{conversationId:t,projectId:i}})}function bk(e){const{conversationId:t,projectId:i}=e.params;return!t||!i?null:d.jsx(rn,{api:e.api,children:d.jsx(gS,{conversationId:t,projectId:i})})}function il(e,t,i,s,r){const n=e.panels.filter(o=>o.id.startsWith("btw:")).length;e.addPanel({id:r??`btw:${crypto.randomUUID()}`,component:"btw",title:n===0?s:`${s} ${n+1}`,params:{conversationId:t,projectId:i}})}function wk(e){const{conversationId:t}=e.params;return t?d.jsx(xy,{conversationId:t,panelApi:e.api}):null}function sl(e,t,i,s,r){const n=r??`browser:${crypto.randomUUID()}`,o=e.getPanel(n);if(o){o.focus();return}e.addPanel({id:n,component:"browser",title:s,params:{conversationId:t,projectId:i}})}function yk(e){const{conversationId:t}=e.params;return t?d.jsx(rn,{api:e.api,children:d.jsx(Mg,{conversationId:t,panelApi:e.api})}):null}function rl(e,t,i,s){const r=e.getPanel("workflow");if(r){r.focus();return}e.addPanel({id:"workflow",component:"workflow",title:s,params:{conversationId:t,projectId:i}})}function Sk(e){return d.jsx(rn,{api:e.api,children:d.jsx(Sy,{projectId:e.params.projectId})})}function nl(e){return Ue(t=>Mm(t,e))}function ol(e){return Ue(t=>t.secretaryEnabled&&Om(t.projects,e))}const xk=[];function al(){return Et(e=>e.secretary.profile?e.secretary.profile.pluginIds??xk:null)}function ll(e,t,i,s,r){const n=`plugin:${s.pluginId}:${s.id}`,o=e.getPanel(n);if(o){o.focus();return}e.addPanel({id:n,component:"plugin",title:s.title,params:{conversationId:t,projectId:i,pluginId:s.pluginId,viewId:s.id},renderer:"always",...r?{position:{referenceGroup:r}}:{}})}function Ck(e){const{conversationId:t,pluginId:i,viewId:s}=e.params,r=b.useContext(ss).conversationId,n=De(o=>o.liveGlobalTabs.includes(e.api.id));return b.useEffect(()=>{e.api.renderer!=="always"&&e.api.setRenderer("always")},[e.api]),!i||!s?null:n&&r?d.jsx(_S,{panelId:e.api.id,conversationId:r,api:e.api,containerApi:e.containerApi}):d.jsx(d0,{pluginId:i,viewId:s,sessionId:t??null})}function Dk(e){const{conversationId:t}=e.params;return t?d.jsx(mk,{conversationId:t}):null}function kk(e,t){const i=e.group.panels.map(n=>n.id),s=new Set(fo(i,e.id,t)),r=[];for(const n of[...e.group.panels])s.has(n.id)&&(n.api.close(),r.push(n.id));return r}const Pk=new Set(["terminal","changes","files","btw"]),la=new Set;function Ek(e){for(const t of la)t(e)}function Tk(e){const{t}=he(),{conversationId:i}=b.useContext(ss),s=b.useRef(null),[r,n]=b.useState(e.api.isActive),[o,a]=b.useState(e.api.title??""),[l,h]=b.useState(e.params.favicon??null),[c,u]=b.useState(!1),p=De(R=>R.pinnedTabs),f=De(R=>R.togglePinnedTab),m=xS(e.api.id),g=m?p.includes(m):!1,_=Os(),E=De(R=>R.globalScopeOverrides),C=De(R=>R.liveGlobalTabs.includes(e.api.id)),T=Ou(e.api.id),x=T?_.some(R=>`plugin:${R.pluginId}:${R.id}`===e.api.id):m!==void 0&&Pk.has(m),A=T?$m(e.api.id,E,_)==="global":g,k=()=>{if(T){i&&Km(e.api.id,i,A?"session":"global");return}m&&(f(m),A||Ek(m))};b.useEffect(()=>{const R=e.api.onDidActiveChange(()=>n(e.api.isActive)),I=e.api.onDidTitleChange(()=>a(e.api.title??"")),w=e.api.onDidParametersChange(v=>{const S=v&&typeof v=="object"&&"favicon"in v?v.favicon??null:e.api.getParameters()?.favicon??null;h(S??null),u(!1)});return()=>{R.dispose(),I.dispose(),w.dispose()}},[e.api]);const N=e.api.id==="browser"||e.api.id.startsWith("browser:"),O=R=>{const I=s.current?Oh(s.current):null,w=I?Gh(I):null,v=kk(e.api,R);!I||!w||zh(I,v.flatMap(S=>{const D=w.get(S);return D?[D]:[]}))},z=d.jsxs("div",{ref:R=>{s.current=R},"data-side-tab":!0,"data-panel-id":e.api.id,"data-active":r||void 0,className:Y("group/tab relative flex min-w-0 items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors",r?"bg-muted font-medium":"text-muted-foreground hover:bg-muted/50"),children:[e.api.id==="changes"?d.jsx(bc,{className:"h-3 w-3 shrink-0"}):e.api.id==="files"?d.jsx(ma,{className:"h-3 w-3 shrink-0"}):e.api.id.startsWith("btw:")?d.jsx(Ca,{className:"h-3 w-3 shrink-0"}):e.api.id==="workflow"?d.jsx(dc,{className:"h-3 w-3 shrink-0"}):e.api.id==="secretary"?d.jsx(yc,{className:"h-3 w-3 shrink-0"}):e.api.id.startsWith("plugin:")?d.jsx(da,{pluginId:e.api.id.split(":")[1]??"",className:"h-3 w-3 shrink-0"}):N&&l&&!c?d.jsx("img",{src:l,alt:"",className:"h-3 w-3 shrink-0",onError:()=>u(!0)}):N?d.jsx(cc,{className:"h-3 w-3 shrink-0"}):d.jsx(uc,{className:"h-3 w-3 shrink-0"}),d.jsx(TS,{title:o,global:T&&A}),m&&!C?d.jsx("button",{type:"button","aria-label":t(g?"Unpin default tab":"Pin as default tab"),"aria-pressed":g,title:t(g?"Unpin default tab":"Pin as default tab"),className:Y("rounded p-0.5 transition-opacity hover:text-foreground",g?"text-primary":"text-muted-foreground opacity-0 group-hover/tab:opacity-100 focus-visible:opacity-100"),onPointerDown:R=>R.stopPropagation(),onClick:R=>{R.preventDefault(),R.stopPropagation(),f(m)},children:d.jsx(Ng,{className:"h-3 w-3"})}):null,d.jsx("button",{type:"button",className:"rounded p-0.5 text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/tab:opacity-100",onPointerDown:R=>R.stopPropagation(),onClick:R=>{R.preventDefault(),R.stopPropagation();const I=Oh(R.currentTarget),w=I?Gh(I).get(e.api.id):void 0;e.api.close(),I&&w&&zh(I,[w])},children:d.jsx(Gs,{className:"h-3 w-3"})})]});return d.jsxs(va,{children:[d.jsx(_a,{render:z}),d.jsxs(ba,{className:"min-w-40",children:[d.jsx(et,{onClick:()=>O("self"),children:t("Close")}),d.jsx(et,{onClick:()=>O("others"),children:t("Close others")}),d.jsx(et,{onClick:()=>O("right"),children:t("Close tabs to the right")}),d.jsx(et,{onClick:()=>O("all"),children:t("Close all")}),x?d.jsxs(d.Fragment,{children:[d.jsx(lc,{}),d.jsx(ES,{checked:A,onClick:k})]}):null]})]})}function Xp({onNewTerminal:e,onNewChanges:t,onNewFiles:i,onNewBrowser:s,onNewBtw:r,onNewWorkflow:n,onNewSecretary:o,secretaryLabel:a,onNewPluginView:l,secretaryPluginIds:h,compact:c}){const{t:u}=he(),p=Os(),f=h===void 0?p:kS(p,h??void 0);return d.jsxs(Fm,{children:[d.jsxs(Vm,{className:Y("flex items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",c?"h-6 w-6 rounded p-1 hover:bg-muted":"h-8 gap-1.5 border border-dashed px-3 text-sm hover:border-solid"),"aria-label":u("New tab"),children:[d.jsx(Zi,{className:"h-4 w-4"}),!c&&d.jsx("span",{children:u("New tab")})]}),d.jsxs(Um,{align:c?"end":"center",className:"min-w-36",children:[e?d.jsxs(oi,{onClick:e,children:[d.jsx(uc,{className:"h-4 w-4"}),u("Terminal")]}):null,t?d.jsxs(oi,{onClick:t,children:[d.jsx(bc,{className:"h-4 w-4"}),u("Changes")]}):null,i?d.jsxs(oi,{onClick:i,children:[d.jsx(ma,{className:"h-4 w-4"}),u("Files")]}):null,d.jsxs(oi,{onClick:s,children:[d.jsx(cc,{className:"h-4 w-4"}),u("Browser")]}),r?d.jsxs(oi,{onClick:r,children:[d.jsx(Ca,{className:"h-4 w-4"}),u("Btw")]}):null,n?d.jsxs(oi,{onClick:n,children:[d.jsx(dc,{className:"h-4 w-4"}),u("Workflow")]}):null,o?d.jsxs(oi,{"data-enso":"secretary-panel-open",onClick:o,children:[d.jsx(yc,{className:"h-4 w-4"}),a??u("Secretary")]}):null,l?f.map(m=>d.jsxs(oi,{onClick:()=>l(m),children:[d.jsx(da,{pluginId:m.pluginId,className:"h-4 w-4"}),m.title]},`${m.pluginId}:${m.id}`)):null]})]})}function Jp({containerApi:e,group:t}){const{t:i}=he(),{conversationId:s,projectId:r}=b.useContext(ss),n=De(C=>C.fullscreen),o=De(C=>C.toggleFullscreen),a=nl(r),l=ol(r),h=al(),c=ka(),u=ga(),p=b.useContext(Kp),f=gk(e,t),m=De(C=>C.toggleOpen),g=Wm()==="windows",_=Et(C=>C.focusProposal),E=b.useRef(0);return b.useEffect(()=>{!_||!l||_.at===E.current||(E.current=_.at,Rr(e,s,r,c))},[_,l,e,s,r,c]),d.jsxs("div",{className:"flex h-full items-center gap-0.5",children:[d.jsx(Xp,{compact:!0,onNewTerminal:l?void 0:()=>{if(t){e.addPanel({id:crypto.randomUUID(),component:"terminal",title:qp(e,i("Terminal")),params:{conversationId:s,projectId:r},position:{referenceGroup:t}});return}Yp(e,s,r,i("Terminal"))},onNewChanges:l?void 0:()=>el(e,s,r,i("Changes")),onNewFiles:l?void 0:()=>tl(e,s,r,i("Files")),onNewBrowser:()=>sl(e,s,r,i("Browser")),onNewBtw:l?void 0:()=>{if(t){const C=e.panels.filter(T=>T.id.startsWith("btw:")).length;e.addPanel({id:`btw:${crypto.randomUUID()}`,component:"btw",title:C===0?i("Btw"):`${i("Btw")} ${C+1}`,params:{conversationId:s,projectId:r},position:{referenceGroup:t}});return}il(e,s,r,i("Btw"))},onNewWorkflow:a&&!l?()=>rl(e,s,r,i("Workflow")):void 0,onNewSecretary:l?()=>Rr(e,s,r,c):void 0,secretaryLabel:c,onNewPluginView:C=>ll(e,s,r,C,t),secretaryPluginIds:l?h:void 0}),d.jsx("button",{type:"button",className:Y("flex h-6 w-6 items-center justify-center rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",u&&"hidden"),onClick:o,"aria-label":i(n?"Exit side panel fullscreen":"Expand side panel"),title:i(n?"Exit side panel fullscreen":"Expand side panel"),children:n?d.jsx(nc,{className:"h-3.5 w-3.5"}):d.jsx(rc,{className:"h-3.5 w-3.5"})}),p&&f&&d.jsx("button",{type:"button",className:"ml-1 flex h-8 w-8 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted",onClick:m,"aria-label":i("Toggle side panel"),title:i("Toggle side panel"),children:d.jsx(Og,{className:"h-4 w-4"})}),p&&f&&g&&d.jsx("span",{"aria-hidden":!0,className:"shrink-0",style:{width:`calc(100vw - env(titlebar-area-width, calc(100vw - ${Hm}px)) - 19px)`}})]})}function Ik(e){const{t}=he(),{conversationId:i,projectId:s}=b.useContext(ss),r=nl(s),n=ol(s),o=al(),a=ka();return d.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[d.jsx("div",{className:"enso-side-dock-header flex shrink-0 items-center justify-end border-b bg-background px-2 py-1",children:d.jsx(Jp,{containerApi:e.containerApi})}),d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-3 bg-background px-6 text-center",children:[d.jsx("p",{className:"text-sm text-muted-foreground",children:t("No tabs yet. Create one to get started.")}),d.jsx(Xp,{onNewTerminal:n?void 0:()=>Yp(e.containerApi,i,s,t("Terminal")),onNewChanges:n?void 0:()=>el(e.containerApi,i,s,t("Changes")),onNewFiles:n?void 0:()=>tl(e.containerApi,i,s,t("Files")),onNewBrowser:()=>sl(e.containerApi,i,s,t("Browser")),onNewBtw:n?void 0:()=>il(e.containerApi,i,s,t("Btw")),onNewWorkflow:r&&!n?()=>rl(e.containerApi,i,s,t("Workflow")):void 0,onNewSecretary:n?()=>Rr(e.containerApi,i,s,a):void 0,secretaryLabel:a,onNewPluginView:l=>ll(e.containerApi,i,s,l),secretaryPluginIds:n?o:void 0})]})]})}function Ak(e){return d.jsx(Jp,{containerApi:e.containerApi,group:e.group})}const Hd={terminal:vk,changes:_k,files:bk,browser:yk,btw:wk,workflow:Dk,secretary:Sk,plugin:Ck};function Rk(){const[e,t]=b.useState(()=>document.documentElement.classList.contains("dark"));return b.useEffect(()=>{const i=new MutationObserver(()=>t(document.documentElement.classList.contains("dark")));return i.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>i.disconnect()},[]),e}function Lk({conversationId:e,hidden:t}){const i=ue(s=>s.conversations[e]?.projectId);return i?d.jsx("div",{className:Y("absolute inset-0",t&&"hidden"),children:d.jsx(Nk,{conversationId:e,projectId:i})}):null}function Nk({conversationId:e,projectId:t}){const{t:i}=he(),s=Rk(),r=nl(t),n=ol(t),o=al(),a=Os(),l=ka(),[h]=b.useState(DS),[c,u]=b.useState(null),p=b.useRef(null),f=ue(z=>z.activeId),m=wa(e),g=De(z=>z.uiByConversation[e]?.open===!0),_=De(z=>z.pinnedTabs),E=De(z=>z.globalTabs),C=De(z=>z.liveGlobalTabs),T=De(z=>z.globalScopeOverrides),x=Rm(),A=b.useRef(!1);b.useLayoutEffect(()=>(p.current&&yl(e,p.current),()=>{p.current&&Lm(e,p.current)}),[e]),b.useEffect(()=>{r||c?.getPanel("workflow")?.api.close()},[c,r]),b.useEffect(()=>{if(!c||!n)return;const z=c.panels.map(I=>I.id),R=new Set([...E,...C]);for(const I of PS(z,o,R))c.getPanel(I)?.api.close()},[c,n,o,E,C]),b.useEffect(()=>{!c||!x||(Nm(e,c,!A.current),A.current=!0)},[e,c,g,E,a,T,x]);const k=(z,R)=>{const I=CS({pinnedTabs:R,openPanelIds:z.panels.map(v=>v.id),secretary:n,workflowAvailable:r,pluginViews:a,secretaryPluginIds:o});let w;for(const v of I)if(v.kind==="terminal"){const S=crypto.randomUUID();z.addPanel({id:S,component:"terminal",title:i("Terminal"),params:{conversationId:e,projectId:t}}),w??=S}else if(v.kind==="changes")el(z,e,t,i("Changes")),w??="changes";else if(v.kind==="files")tl(z,e,t,i("Files")),w??="files";else if(v.kind==="browser"){const S=`browser:${crypto.randomUUID()}`;sl(z,e,t,i("Browser"),S),w??=S}else if(v.kind==="btw"){const S=`btw:${crypto.randomUUID()}`;il(z,e,t,i("Btw"),S),w??=S}else if(v.kind==="workflow")rl(z,e,t,i("Workflow")),w??="workflow";else{const S=a.find(y=>y.pluginId===v.pluginId&&y.id===v.viewId);if(!S)continue;const D=`plugin:${v.pluginId}:${v.viewId}`;ll(z,e,t,S),w??=D}return w},N=b.useRef(k);N.current=k,b.useEffect(()=>{const z=R=>{const I=p.current;if(!I)return;const w=I.activePanel;N.current(I,[R])&&w&&w.api.setActive()};return la.add(z),()=>{la.delete(z)}},[]),b.useEffect(()=>{if(!c||!m||f!==e)return;const z=c.panels.length===0,R=N.current(c,_);z&&R&&c.getPanel(R)?.focus()},[f,e,c,a,_,t,n,o,m,i,r]),b.useEffect(()=>{h({secretary:n,open:m,active:f===e,ready:c!==null})&&c&&Rr(c,e,t,l)},[f,e,c,t,h,n,l,m]);const O=z=>{yl(e,z.api);const R=De.getState().layouts[e],I=Gm(R,new Set(Object.keys(Hd)));let w=!!R&&!I;if(I)try{z.api.fromJSON(I)}catch{w=!0}zm(e,z.api),Bm(e,z.api),z.api.onDidLayoutChange(()=>{const v=z.api.toJSON();w&&Object.keys(v.panels??{}).length===0||(w=!1,De.getState().saveLayout(e,v))}),z.api.onDidRemovePanel(v=>{if(!(v.id==="changes"||v.id==="files"||v.id==="secretary"||v.id.startsWith("plugin:"))){if(v.id==="browser"||v.id.startsWith("browser:")){ec()||window.electronAPI.browser.closeTab(v.id);return}if(v.id.startsWith("btw:")){ue.getState().disposeBtwConversation(v.id.slice(4));return}jm(v.id),window.electronAPI.terminal.dispose(v.id)}}),p.current=z.api,u(z.api)};return d.jsx(ss.Provider,{value:{conversationId:e,projectId:t},children:d.jsx("div",{className:"enso-side-dock h-full",children:d.jsx(yu,{components:Hd,defaultTabComponent:Tk,watermarkComponent:Ik,rightHeaderActionsComponent:Ak,theme:s?Nb:Mb,onReady:O})})})}function wP({width:e,resizing:t=!1,card:i=!1,titleRow:s=!1}){const{t:r}=he(),n=ue(v=>v.activeId),o=wa(n),a=ga(),h=De(v=>v.fullscreen)||a&&o;b.useEffect(()=>xm(),[]),b.useEffect(()=>{const v=window.electronAPI.browser.onReveal(D=>{Cm(D.conversationId)||ac({conversationId:D.conversationId,tabId:D.tabId})}),S=window.electronAPI.browser.onTabClosed(D=>{Dm(D.conversationId,D.tabId)});return Cy(),()=>{v(),S()}},[]),b.useEffect(()=>Xn.subscribe((v,S)=>{for(const[D,y]of Object.entries(v.byConversation)){if(S.byConversation[D]===y)continue;const L=y.find(M=>M.status==="running");L&&km({conversationId:D,runId:L.runId,title:r("Workflow")})}}),[r]),b.useEffect(()=>ue.subscribe((v,S)=>{for(const D of Object.keys(S.conversations))v.conversations[D]||Pm(D)}),[]);const c=ue(v=>v.activeId),[u,p]=b.useState([]),f=ue(v=>u.filter(S=>!!v.conversations[S]).join(`
|
|
46
|
+
`)),[m,g]=b.useState(h),[_,E]=b.useState(0),C=i&&!s?Im:Am,T=Tm(e,_,C),x=b.useRef(null),[A,k]=b.useState({id:c,from:c});c!==A.id&&k({id:c,from:A.id}),h&&!m&&g(!0),b.useEffect(()=>{const v=x.current?.parentElement;if(!v)return;const S=()=>{const y=getComputedStyle(v);E(v.clientWidth-parseFloat(y.paddingLeft)-parseFloat(y.paddingRight))};S();const D=new ResizeObserver(S);return D.observe(v),()=>D.disconnect()},[]),b.useEffect(()=>{A.from!==A.id&&k(v=>v.from===v.id?v:{...v,from:v.id})},[A.from,A.id]);const N=m?void 0:Math.max(0,T-(o&&!i?1:0)),O=c,z=Ig({resizing:t,conversationId:A.id??void 0,previousConversationId:A.from??void 0}),R=h?_||T:o?T:0,I=!!s&&!a;O&&!u.includes(O)&&p(v=>v.includes(O)?v:[...v,O]);const w=f===""?[]:f.split(`
|
|
47
|
+
`);return d.jsxs(d.Fragment,{children:[m&&!a?d.jsx("div",{className:"shrink-0",style:{width:T},"aria-hidden":!0}):null,d.jsxs(Ag.aside,{ref:x,"data-slot":"side-panel",initial:!1,animate:{width:R},style:m?{position:"absolute"}:{position:"relative",maxWidth:`max(0px, calc(100% - ${Em+C}px))`},transition:Rg({skip:z,cover:m,targetW:R}),onAnimationComplete:()=>{h||g(!1)},className:Y("flex min-h-0 flex-col",I&&o?"overflow-clip [overflow-clip-margin:4px]":"overflow-hidden",o&&(I||!m)?"bg-transparent":I?"":"bg-background",m?I?"top-px right-[8px] bottom-[8px]":i?"top-0 right-[8px] bottom-[8px]":"inset-y-0 right-0":"shrink-0",I?Y("no-drag -mt-[44px]",m?"rounded-b-[10px]":"rounded-br-[10px]"):i?Y("rounded-[10px]",o&&"shadow-surface"):o&&"border-l"),"data-enso":"side-panel","data-title-row":I||void 0,children:[o&&(I||!m)?d.jsx(Gk,{titleRow:I,full:m}):null,o&&!m&&N!==void 0?d.jsx("div",{"aria-hidden":!0,className:Y("pointer-events-none absolute right-0 bottom-0 bg-background",s?"top-[44px]":"top-0"),style:{left:N}}):null,d.jsx("div",{className:Y("relative flex h-full min-h-0 flex-col",m&&"w-full",!o&&"invisible"),style:{width:N,clipPath:I?m?Ok:Mk:void 0},children:d.jsxs("div",{className:"relative min-h-0 flex-1",children:[d.jsx(Kp.Provider,{value:I,children:w.map(v=>d.jsx(Lk,{conversationId:v,hidden:v!==O},v))}),d.jsx(wS,{}),w.length===0?d.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-6 text-center text-sm text-muted-foreground",children:r("Select a conversation to use the side panel.")}):null]})})]})]})}const Mk="shape(from 0 0, hline to 100%, vline to 44px, hline to calc(100% - 10px), arc to 100% 54px of 10px cw, vline to calc(100% - 10px), arc to calc(100% - 10px) 100% of 10px cw, hline to 0, close)",Ok="shape(from 0 0, hline to 100%, vline to 44px, hline to calc(100% - 10px), arc to 100% 54px of 10px cw, vline to calc(100% - 10px), arc to calc(100% - 10px) 100% of 10px cw, hline to 10px, arc to 0 calc(100% - 10px) of 10px cw, vline to 54px, arc to 10px 44px of 10px cw, hline to 0, close)";function Gk({titleRow:e,full:t}){const i=b.useRef(null),s=De(r=>r.browserHoles);return b.useLayoutEffect(()=>{const r=i.current;if(!r)return;const{left:n,top:o}=r.getBoundingClientRect(),a=Object.values(s).map(c=>({...c,x:c.x-n,y:c.y-o})),l=Lg(a)??"";r.style.clipPath=l;const h=r.closest('[data-enso="side-panel"]');return h&&(l?h.style.setProperty("--enso-side-panel-holes-clip",l):h.style.removeProperty("--enso-side-panel-holes-clip")),()=>{h?.style.removeProperty("--enso-side-panel-holes-clip")}},[s]),d.jsxs(d.Fragment,{children:[e&&d.jsx("div",{"aria-hidden":!0,className:Y("pointer-events-none absolute inset-x-0 top-[44px] bottom-0 shadow-surface",t?"rounded-[10px]":"rounded-r-[10px]"),style:t?void 0:{clipPath:"inset(-24px -24px -24px 0)"}}),d.jsx("div",{ref:i,"aria-hidden":!0,className:Y("pointer-events-none absolute inset-x-0 bottom-0 bg-background",e?Y("top-[44px]",t?"rounded-[10px]":"rounded-r-[10px]"):"top-0")})]})}export{wP as SidePanel};
|