termdock 1.4.270 → 1.4.272
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{App-c7kz7Ubk.js → App-BWvfhtbg.js} +3 -3
- package/dist/client/assets/App-BWvfhtbg.js.br +0 -0
- package/dist/client/assets/App-BWvfhtbg.js.gz +0 -0
- package/dist/client/assets/{ChangeWalkthroughPanel-Bydnbq0F.js → ChangeWalkthroughPanel-Brob_-qZ.js} +1 -1
- package/dist/client/assets/ChangeWalkthroughPanel-Brob_-qZ.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-Brob_-qZ.js.gz +0 -0
- package/dist/client/assets/{DagPlayground-BOhl81pI.js → DagPlayground-CPoE0Lus.js} +1 -1
- package/dist/client/assets/DagPlayground-CPoE0Lus.js.br +0 -0
- package/dist/client/assets/DagPlayground-CPoE0Lus.js.gz +0 -0
- package/dist/client/assets/{DiffLab-Frkr3MbV.js → DiffLab-r6LLTMqZ.js} +18 -1
- package/dist/client/assets/DiffLab-r6LLTMqZ.js.br +0 -0
- package/dist/client/assets/DiffLab-r6LLTMqZ.js.gz +0 -0
- package/dist/client/assets/DiffReview-D7TKj6lg.js +1 -0
- package/dist/client/assets/DiffReview-D7TKj6lg.js.br +0 -0
- package/dist/client/assets/DiffReview-D7TKj6lg.js.gz +0 -0
- package/dist/client/assets/{DiffReviewLab-BOc71Yev.js → DiffReviewLab-BOEQ47OF.js} +1 -1
- package/dist/client/assets/DiffReviewLab-BOEQ47OF.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-BOEQ47OF.js.gz +0 -0
- package/dist/client/assets/DiffViewer-DKC1Ffqk.js +37 -0
- package/dist/client/assets/DiffViewer-DKC1Ffqk.js.br +0 -0
- package/dist/client/assets/DiffViewer-DKC1Ffqk.js.gz +0 -0
- package/dist/client/assets/{ModelPreview-CH2TQwG6.js → ModelPreview-DtR_DlQF.js} +1 -1
- package/dist/client/assets/ModelPreview-DtR_DlQF.js.br +0 -0
- package/dist/client/assets/ModelPreview-DtR_DlQF.js.gz +0 -0
- package/dist/client/assets/RightSidebar-CFX92G5A.js +1678 -0
- package/dist/client/assets/RightSidebar-CFX92G5A.js.br +0 -0
- package/dist/client/assets/RightSidebar-CFX92G5A.js.gz +0 -0
- package/dist/client/assets/{abnfDiagram-VCTEODGH-Uf4zSEDT.js → abnfDiagram-VCTEODGH-DIGD3wFA.js} +1 -1
- package/dist/client/assets/abnfDiagram-VCTEODGH-DIGD3wFA.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-DIGD3wFA.js.gz +0 -0
- package/dist/client/assets/{app-BB2wwQ0J.js → app-DEekdvjC.js} +4 -4
- package/dist/client/assets/app-DEekdvjC.js.br +0 -0
- package/dist/client/assets/app-DEekdvjC.js.gz +0 -0
- package/dist/client/assets/{arc-DRmqfmwm.js → arc-WdvGCyC3.js} +1 -1
- package/dist/client/assets/arc-WdvGCyC3.js.br +0 -0
- package/dist/client/assets/arc-WdvGCyC3.js.gz +0 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-B-2Al0rh.js → architectureDiagram-5GKGNRK7-oaSMD_ie.js} +1 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-oaSMD_ie.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-oaSMD_ie.js.gz +0 -0
- package/dist/client/assets/{blockDiagram-I7D4REHJ-CH5wQtui.js → blockDiagram-I7D4REHJ-7wrxpvDF.js} +1 -1
- package/dist/client/assets/blockDiagram-I7D4REHJ-7wrxpvDF.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-7wrxpvDF.js.gz +0 -0
- package/dist/client/assets/{c4Diagram-7LVT6UL2-BK-d-9zq.js → c4Diagram-7LVT6UL2-Dq5dk5tv.js} +1 -1
- package/dist/client/assets/{c4Diagram-7LVT6UL2-BK-d-9zq.js.br → c4Diagram-7LVT6UL2-Dq5dk5tv.js.br} +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-Dq5dk5tv.js.gz +0 -0
- package/dist/client/assets/channel-BidJ4fZU.js +1 -0
- package/dist/client/assets/{chunk-2Q5K7J3B-C-ckf1lO.js → chunk-2Q5K7J3B-CmItTA-Q.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-DyVtVLgG.js → chunk-5VM5RSS4-o4sjClsS.js} +1 -1
- package/dist/client/assets/{chunk-F27PBJKO-C-CfcBwS.js → chunk-F27PBJKO-CQPcUkX6.js} +1 -1
- package/dist/client/assets/chunk-F27PBJKO-CQPcUkX6.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-CQPcUkX6.js.gz +0 -0
- package/dist/client/assets/{chunk-IMKFNOWR-eabrbPYb.js → chunk-IMKFNOWR-S04BdLvB.js} +1 -1
- package/dist/client/assets/chunk-IMKFNOWR-S04BdLvB.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-S04BdLvB.js.gz +0 -0
- package/dist/client/assets/{chunk-JWPE2WC7-py5DYe3e.js → chunk-JWPE2WC7-Cukh0P3L.js} +1 -1
- package/dist/client/assets/{chunk-POPQ4Y6H-Bx2PbP9P.js → chunk-POPQ4Y6H-DUPy19KF.js} +1 -1
- package/dist/client/assets/{chunk-SVP7TREG-DdooqOrA.js → chunk-SVP7TREG-DTQfmgZH.js} +1 -1
- package/dist/client/assets/{chunk-SVP7TREG-DdooqOrA.js.br → chunk-SVP7TREG-DTQfmgZH.js.br} +0 -0
- package/dist/client/assets/chunk-SVP7TREG-DTQfmgZH.js.gz +0 -0
- package/dist/client/assets/{chunk-TICWLB2K-Bfo-6Shk.js → chunk-TICWLB2K-DbYAq4a4.js} +1 -1
- package/dist/client/assets/chunk-TICWLB2K-DbYAq4a4.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-DbYAq4a4.js.gz +0 -0
- package/dist/client/assets/{chunk-XXDRQBXY-C8WloQnN.js → chunk-XXDRQBXY-DoDg4EbN.js} +1 -1
- package/dist/client/assets/classDiagram-ZZMXUADV-C5huq_he.js +1 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-C5huq_he.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-Czk8_m7q.js → cose-bilkent-JH36ORCC-CqqVEYDM.js} +1 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-CqqVEYDM.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-CqqVEYDM.js.gz +0 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-BISFEUwD.js → cynefin-OW5HDTMX-BGeSn2jU.js} +1 -1
- package/dist/client/assets/cynefin-OW5HDTMX-BGeSn2jU.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-BGeSn2jU.js.gz +0 -0
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-DI32_4sP.js → cynefinDiagram-5FMLGOSQ-TyI7CaNO.js} +1 -1
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-TyI7CaNO.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-TyI7CaNO.js.gz +0 -0
- package/dist/client/assets/{dagre-GXQ25YYZ-TXkJuzc3.js → dagre-GXQ25YYZ-ZBSentj0.js} +1 -1
- package/dist/client/assets/dagre-GXQ25YYZ-ZBSentj0.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-ZBSentj0.js.gz +0 -0
- package/dist/client/assets/{diagram-S7CK7UJ4-BzxAQEyH.js → diagram-S7CK7UJ4-DVAfVD5f.js} +1 -1
- package/dist/client/assets/diagram-S7CK7UJ4-DVAfVD5f.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-DVAfVD5f.js.gz +0 -0
- package/dist/client/assets/{diagram-UQ7AKVKN-CuMScMHK.js → diagram-UQ7AKVKN-DPhUsBz9.js} +1 -1
- package/dist/client/assets/diagram-UQ7AKVKN-DPhUsBz9.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-DPhUsBz9.js.gz +0 -0
- package/dist/client/assets/{diagram-VSXAHHWV-NKI8trX3.js → diagram-VSXAHHWV-Dan0Hk5t.js} +1 -1
- package/dist/client/assets/diagram-VSXAHHWV-Dan0Hk5t.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-Dan0Hk5t.js.gz +0 -0
- package/dist/client/assets/{diagram-VX7I27RA-C99awHgN.js → diagram-VX7I27RA-CGIN1BLp.js} +1 -1
- package/dist/client/assets/diagram-VX7I27RA-CGIN1BLp.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-CGIN1BLp.js.gz +0 -0
- package/dist/client/assets/{diagram-Z3DM3KII-BsC3OPmH.js → diagram-Z3DM3KII-1g5LjYjt.js} +1 -1
- package/dist/client/assets/diagram-Z3DM3KII-1g5LjYjt.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-1g5LjYjt.js.gz +0 -0
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-C4en7LU4.js → ebnfDiagram-PWID7BFC-D-ywTyLI.js} +1 -1
- package/dist/client/assets/ebnfDiagram-PWID7BFC-D-ywTyLI.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-D-ywTyLI.js.gz +0 -0
- package/dist/client/assets/{erDiagram-RLTQ6QDP-DumCCiK7.js → erDiagram-RLTQ6QDP-DFdoY6bQ.js} +1 -1
- package/dist/client/assets/erDiagram-RLTQ6QDP-DFdoY6bQ.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-DFdoY6bQ.js.gz +0 -0
- package/dist/client/assets/{flowDiagram-HODETNUW-DKT_aPyu.js → flowDiagram-HODETNUW-Bl_7iMXm.js} +1 -1
- package/dist/client/assets/flowDiagram-HODETNUW-Bl_7iMXm.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-Bl_7iMXm.js.gz +0 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-CId-QB6P.js → ganttDiagram-EL5Y4UJY-DIVlmw0R.js} +1 -1
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-DIVlmw0R.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-DIVlmw0R.js.gz +0 -0
- package/dist/client/assets/{gestureArbiter-D-hJxSpi.js → gestureArbiter-o4nUxPFe.js} +1 -1
- package/dist/client/assets/gestureArbiter-o4nUxPFe.js.br +0 -0
- package/dist/client/assets/{gestureArbiter-D-hJxSpi.js.gz → gestureArbiter-o4nUxPFe.js.gz} +0 -0
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-CNyiA6xo.js → gitGraphDiagram-WWUBYQGX-BL1YrvgA.js} +1 -1
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-BL1YrvgA.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-BL1YrvgA.js.gz +0 -0
- package/dist/client/assets/{index-DSUyAohI.css → index-t8Mh8TuP.css} +1 -1
- package/dist/client/assets/index-t8Mh8TuP.css.br +0 -0
- package/dist/client/assets/{index-DSUyAohI.css.gz → index-t8Mh8TuP.css.gz} +0 -0
- package/dist/client/assets/{infoDiagram-27XIBGKW-BZ8TbGVw.js → infoDiagram-27XIBGKW-Ej3wK067.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-O1fthDSH.js → ishikawaDiagram-5VMMS53U-Dvw4laqn.js} +1 -1
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-Dvw4laqn.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-Dvw4laqn.js.gz +0 -0
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-WaGckv1S.js → journeyDiagram-3NMN7TZE-Ch1wfZg2.js} +1 -1
- package/dist/client/assets/journeyDiagram-3NMN7TZE-Ch1wfZg2.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-Ch1wfZg2.js.gz +0 -0
- package/dist/client/assets/{kanban-definition-UXKFOSKX-DNQOxjx3.js → kanban-definition-UXKFOSKX-Dok8nWzO.js} +1 -1
- package/dist/client/assets/kanban-definition-UXKFOSKX-Dok8nWzO.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-Dok8nWzO.js.gz +0 -0
- package/dist/client/assets/{layout-9yDfVyqo.js → layout-DyrafMAo.js} +1 -1
- package/dist/client/assets/layout-DyrafMAo.js.br +0 -0
- package/dist/client/assets/layout-DyrafMAo.js.gz +0 -0
- package/dist/client/assets/{linear-B1BTva8R.js → linear-UhrNtiAK.js} +1 -1
- package/dist/client/assets/linear-UhrNtiAK.js.br +0 -0
- package/dist/client/assets/linear-UhrNtiAK.js.gz +0 -0
- package/dist/client/assets/{mermaid.core-8EsAUUxp.js → mermaid.core-BxYAsCR4.js} +5 -5
- package/dist/client/assets/mermaid.core-BxYAsCR4.js.br +0 -0
- package/dist/client/assets/mermaid.core-BxYAsCR4.js.gz +0 -0
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-Drh-G4UL.js → mindmap-definition-YA3MSWOX-BeYVKByv.js} +1 -1
- package/dist/client/assets/mindmap-definition-YA3MSWOX-BeYVKByv.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-BeYVKByv.js.gz +0 -0
- package/dist/client/assets/{passwordBootstrap-BB0eooUy.js → passwordBootstrap-BfnjY8IU.js} +1 -1
- package/dist/client/assets/passwordBootstrap-BfnjY8IU.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-BfnjY8IU.js.gz +0 -0
- package/dist/client/assets/{pegDiagram-XKGWAZYB-CHTmFjna.js → pegDiagram-XKGWAZYB-BVFz26j_.js} +1 -1
- package/dist/client/assets/pegDiagram-XKGWAZYB-BVFz26j_.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-BVFz26j_.js.gz +0 -0
- package/dist/client/assets/{pieDiagram-E7YTZNPT-BoA5Wz2y.js → pieDiagram-E7YTZNPT-GeYzF2j6.js} +1 -1
- package/dist/client/assets/pieDiagram-E7YTZNPT-GeYzF2j6.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-GeYzF2j6.js.gz +0 -0
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-DuhdCXKc.js → quadrantDiagram-AXDQQJYC-BqJqh9wP.js} +1 -1
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-BqJqh9wP.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-BqJqh9wP.js.gz +0 -0
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-DyCp5vBV.js → railroadDiagram-O6MQD6OU-BTaV2wae.js} +1 -1
- package/dist/client/assets/railroadDiagram-O6MQD6OU-BTaV2wae.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-BTaV2wae.js.gz +0 -0
- package/dist/client/assets/{referenceLongPress-B0KH2_WY.js → referenceLongPress-CDkYd5td.js} +1 -1
- package/dist/client/assets/referenceLongPress-CDkYd5td.js.br +0 -0
- package/dist/client/assets/referenceLongPress-CDkYd5td.js.gz +0 -0
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-CQ-bjC2d.js → requirementDiagram-BXWQKSXE-9nSyrkuv.js} +1 -1
- package/dist/client/assets/requirementDiagram-BXWQKSXE-9nSyrkuv.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-9nSyrkuv.js.gz +0 -0
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-VxI-qQvZ.js → sankeyDiagram-P5KCCOFB-CSGA4OcK.js} +1 -1
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-CSGA4OcK.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-CSGA4OcK.js.gz +0 -0
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-DbNFaelN.js → sequenceDiagram-WJ2MYXX4-BRShDC7Q.js} +1 -1
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BRShDC7Q.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BRShDC7Q.js.gz +0 -0
- package/dist/client/assets/{sizeCapture-INFHLROL-Dz84Ksqq.js → sizeCapture-INFHLROL--16hstFI.js} +1 -1
- package/dist/client/assets/sizeCapture-INFHLROL--16hstFI.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL--16hstFI.js.gz +0 -0
- package/dist/client/assets/{sparkles-D2io1LdN.js → sparkles-DIgp3ajd.js} +1 -1
- package/dist/client/assets/{stateDiagram-D77RDMKH-CvEVfJld.js → stateDiagram-D77RDMKH-4FRC8cMG.js} +1 -1
- package/dist/client/assets/stateDiagram-D77RDMKH-4FRC8cMG.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-4FRC8cMG.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-YdMNw7bs.js +1 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-AYjy2aQa.js → swimlanes-42K2YHIH-BuBzA-6g.js} +1 -1
- package/dist/client/assets/swimlanes-42K2YHIH-BuBzA-6g.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-BuBzA-6g.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-DNQ4xmb_.js +8 -0
- package/dist/client/assets/{timeline-definition-24CTP7MA-K9VDNPEb.js → timeline-definition-24CTP7MA-B1FfKxzp.js} +1 -1
- package/dist/client/assets/timeline-definition-24CTP7MA-B1FfKxzp.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-B1FfKxzp.js.gz +0 -0
- package/dist/client/assets/{triangle-alert-kTNQj7PF.js → triangle-alert-CuEimtyz.js} +1 -1
- package/dist/client/assets/{vennDiagram-4TSXK5OY-DUf8BAt1.js → vennDiagram-4TSXK5OY-BO4ncKBK.js} +1 -1
- package/dist/client/assets/vennDiagram-4TSXK5OY-BO4ncKBK.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-BO4ncKBK.js.gz +0 -0
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-Bp1I8Vy7.js → wardleyDiagram-VM6X3IG4-DIzAM0mZ.js} +1 -1
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-DIzAM0mZ.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-DIzAM0mZ.js.gz +0 -0
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-Dt0OvusF.js → xychartDiagram-S5SC5T6Z-DM7-ElZS.js} +1 -1
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-DM7-ElZS.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-DM7-ElZS.js.gz +0 -0
- package/dist/client/index.html +2 -2
- package/dist/client/index.html.br +0 -0
- package/dist/client/index.html.gz +0 -0
- package/dist/client/sw.js +1 -1
- package/dist/client/sw.js.br +0 -0
- package/dist/client/sw.js.gz +0 -0
- package/dist/server/routes/filesystem.js +55 -6
- package/package.json +1 -1
- package/runtime-manifest.json +3 -3
- package/dist/client/assets/App-c7kz7Ubk.js.br +0 -0
- package/dist/client/assets/App-c7kz7Ubk.js.gz +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-Bydnbq0F.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-Bydnbq0F.js.gz +0 -0
- package/dist/client/assets/DagPlayground-BOhl81pI.js.br +0 -0
- package/dist/client/assets/DagPlayground-BOhl81pI.js.gz +0 -0
- package/dist/client/assets/DiffLab-Frkr3MbV.js.br +0 -0
- package/dist/client/assets/DiffLab-Frkr3MbV.js.gz +0 -0
- package/dist/client/assets/DiffReview-DxgTeEAU.js +0 -1
- package/dist/client/assets/DiffReview-DxgTeEAU.js.br +0 -0
- package/dist/client/assets/DiffReview-DxgTeEAU.js.gz +0 -0
- package/dist/client/assets/DiffReviewLab-BOc71Yev.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-BOc71Yev.js.gz +0 -0
- package/dist/client/assets/DiffViewer-BkIhdRra.js +0 -37
- package/dist/client/assets/DiffViewer-BkIhdRra.js.br +0 -0
- package/dist/client/assets/DiffViewer-BkIhdRra.js.gz +0 -0
- package/dist/client/assets/ModelPreview-CH2TQwG6.js.br +0 -0
- package/dist/client/assets/ModelPreview-CH2TQwG6.js.gz +0 -0
- package/dist/client/assets/RightSidebar-BHWRnOpP.js +0 -1678
- package/dist/client/assets/RightSidebar-BHWRnOpP.js.br +0 -0
- package/dist/client/assets/RightSidebar-BHWRnOpP.js.gz +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-Uf4zSEDT.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-Uf4zSEDT.js.gz +0 -0
- package/dist/client/assets/app-BB2wwQ0J.js.br +0 -0
- package/dist/client/assets/app-BB2wwQ0J.js.gz +0 -0
- package/dist/client/assets/arc-DRmqfmwm.js.br +0 -0
- package/dist/client/assets/arc-DRmqfmwm.js.gz +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-B-2Al0rh.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-B-2Al0rh.js.gz +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-CH5wQtui.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-CH5wQtui.js.gz +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-BK-d-9zq.js.gz +0 -0
- package/dist/client/assets/channel-L5SeZpt8.js +0 -1
- package/dist/client/assets/chunk-F27PBJKO-C-CfcBwS.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-C-CfcBwS.js.gz +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-eabrbPYb.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-eabrbPYb.js.gz +0 -0
- package/dist/client/assets/chunk-SVP7TREG-DdooqOrA.js.gz +0 -0
- package/dist/client/assets/chunk-TICWLB2K-Bfo-6Shk.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-Bfo-6Shk.js.gz +0 -0
- package/dist/client/assets/classDiagram-ZZMXUADV-Dli5JRtZ.js +0 -1
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-Dli5JRtZ.js +0 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-Czk8_m7q.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-Czk8_m7q.js.gz +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-BISFEUwD.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-BISFEUwD.js.gz +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-DI32_4sP.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-DI32_4sP.js.gz +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-TXkJuzc3.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-TXkJuzc3.js.gz +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-BzxAQEyH.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-BzxAQEyH.js.gz +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-CuMScMHK.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-CuMScMHK.js.gz +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-NKI8trX3.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-NKI8trX3.js.gz +0 -0
- package/dist/client/assets/diagram-VX7I27RA-C99awHgN.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-C99awHgN.js.gz +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-BsC3OPmH.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-BsC3OPmH.js.gz +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-C4en7LU4.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-C4en7LU4.js.gz +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-DumCCiK7.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-DumCCiK7.js.gz +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-DKT_aPyu.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-DKT_aPyu.js.gz +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CId-QB6P.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CId-QB6P.js.gz +0 -0
- package/dist/client/assets/gestureArbiter-D-hJxSpi.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-CNyiA6xo.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-CNyiA6xo.js.gz +0 -0
- package/dist/client/assets/index-DSUyAohI.css.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-O1fthDSH.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-O1fthDSH.js.gz +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-WaGckv1S.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-WaGckv1S.js.gz +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-DNQOxjx3.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-DNQOxjx3.js.gz +0 -0
- package/dist/client/assets/layout-9yDfVyqo.js.br +0 -0
- package/dist/client/assets/layout-9yDfVyqo.js.gz +0 -0
- package/dist/client/assets/linear-B1BTva8R.js.br +0 -0
- package/dist/client/assets/linear-B1BTva8R.js.gz +0 -0
- package/dist/client/assets/mermaid.core-8EsAUUxp.js.br +0 -0
- package/dist/client/assets/mermaid.core-8EsAUUxp.js.gz +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-Drh-G4UL.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-Drh-G4UL.js.gz +0 -0
- package/dist/client/assets/passwordBootstrap-BB0eooUy.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-BB0eooUy.js.gz +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-CHTmFjna.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-CHTmFjna.js.gz +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-BoA5Wz2y.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-BoA5Wz2y.js.gz +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-DuhdCXKc.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-DuhdCXKc.js.gz +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-DyCp5vBV.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-DyCp5vBV.js.gz +0 -0
- package/dist/client/assets/referenceLongPress-B0KH2_WY.js.br +0 -0
- package/dist/client/assets/referenceLongPress-B0KH2_WY.js.gz +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-CQ-bjC2d.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-CQ-bjC2d.js.gz +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-VxI-qQvZ.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-VxI-qQvZ.js.gz +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DbNFaelN.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DbNFaelN.js.gz +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-Dz84Ksqq.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-Dz84Ksqq.js.gz +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-CvEVfJld.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-CvEVfJld.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-BAVTwS0M.js +0 -1
- package/dist/client/assets/swimlanes-42K2YHIH-AYjy2aQa.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-AYjy2aQa.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-CGSyaJW_.js +0 -8
- package/dist/client/assets/timeline-definition-24CTP7MA-K9VDNPEb.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-K9VDNPEb.js.gz +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-DUf8BAt1.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-DUf8BAt1.js.gz +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-Bp1I8Vy7.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-Bp1I8Vy7.js.gz +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-Dt0OvusF.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-Dt0OvusF.js.gz +0 -0
|
@@ -0,0 +1,1678 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-DtR_DlQF.js","assets/app-DEekdvjC.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-t8Mh8TuP.css","assets/App-BWvfhtbg.js","assets/gestureArbiter-o4nUxPFe.js","assets/gestureArbiter-C2J0D0kV.css","assets/triangle-alert-CuEimtyz.js","assets/referenceLongPress-CDkYd5td.js","assets/DiffReview-D7TKj6lg.js","assets/sparkles-DIgp3ajd.js","assets/DiffViewer-DKC1Ffqk.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-Brob_-qZ.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-BxYAsCR4.js","assets/purify.es-4eNOHKSq.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a5 as Ar,cL as kt,bh as e,g as oo,cV as $t,bz as ht,a as Fs,aQ as lu,C as Di,c as _s,X as Vt,cI as Fi,b5 as Kh,F as js,ao as Vh,cP as J,b9 as qh,bb as ol,bc as Yh,bd as cu,ba as Rs,aB as Xh,E as Jh,i as Qh,b8 as Zh,bB as em,bD as tm,bE as rm,b0 as nm,bC as ad,z as Rt,f as sm,L as Ct,w as am,b as om,cK as od,a$ as id,ax as ld,at as im,aF as gi,aG as cd,cW as Ps,ak as Cs,aH as lm,cJ as Ua,bt as cm,cu as dd,az as dm,cG as um,c2 as fm,aK as hm,Q as ud,O as mm,au as fd,ay as pm,aD as hd,c4 as gm,s as md,d as Ha,m as pd,x as du,af as bm,_ as Bs,bY as xm,cT as vm,bo as ym,ai as wm}from"./app-DEekdvjC.js";import{b as a,r as Yr}from"./dnd-BCFAPC0L.js";import{q as uu,k as km,r as gd,v as ro,g as Sm,V as jm,P as Rm,o as Cm,i as Nm,M as Em,R as _i,w as fu,x as Mm,S as Xn,D as $m,e as hu,c as Lm,N as mu,A as bd,J as Am,E as za,y as Pm,z as Tm,I as Im,K as Dm,B as xd,O as vd,T as yd,H as wd,f as kd,n as bi,m as Wa,d as Fm,s as _m,l as Bm,h as Om,t as Um,F as Sd,C as Hm,a as zm,G as Wm}from"./App-BWvfhtbg.js";import{a as jd,S as Rd,b as pu,c as Bi,F as Gm}from"./gestureArbiter-o4nUxPFe.js";import{D as Oi,C as Ts,L as gu,f as Km,n as Vm}from"./DiffReview-D7TKj6lg.js";import{T as qm,L as io,M as bu,G as Lr}from"./triangle-alert-CuEimtyz.js";import{S as Os}from"./sparkles-DIgp3ajd.js";import{C as xu,M as vu}from"./ChangeWalkthroughPanel-Brob_-qZ.js";import{r as yu,s as wu,l as ku,a as Cd,h as Ui,u as Ym,g as Hi,b as Su}from"./DiffViewer-DKC1Ffqk.js";import{u as ju,G as Ru}from"./referenceLongPress-CDkYd5td.js";const Xm=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],Jm=Ar("case-sensitive",Xm);const Qm=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Zm=Ar("eye-off",Qm);const ep=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],zi=Ar("eye",ep);const tp=[["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:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Wi=Ar("file-text",tp);const rp=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],np=Ar("image-plus",rp);const sp=[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]],ap=Ar("regex",sp);const op=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],ip=Ar("scan",op);const lp=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],cp=Ar("upload",lp);const dp=[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]],up=Ar("whole-word",dp);function Nd({children:r,actions:n}){const{t:s}=kt(),[l,u]=a.useState(!1),d=a.useId(),h=a.useRef(null);return e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[r,e.jsxs("button",{ref:h,type:"button","aria-expanded":l,"aria-controls":d,onClick:()=>u(m=>!m),className:`ml-auto inline-flex h-8 shrink-0 items-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 ${l?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[e.jsx(oo,{size:14}),s("sidebar.moreActions")]})]}),l&&e.jsx("div",{id:d,role:"region","aria-label":s("sidebar.moreActions"),className:"mt-2 flex flex-wrap items-center gap-2 rounded-xl border border-border/15 bg-surface-2 p-2 [&_button]:min-h-9",onKeyDown:m=>{m.key!=="Escape"||!m.currentTarget.contains(m.target)||(m.stopPropagation(),u(!1),h.current?.focus())},children:n})]})}async function fp(r){let n;try{await Promise.race([r(),new Promise(s=>{n=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(n)}}function hp({active:r,rootPath:n,loading:s,delay:l,lastStartedRoot:u,load:d}){a.useEffect(()=>{if(!r||!n||s||u.current===n)return;const h=window.setTimeout(()=>{u.current=n,d(n)},l);return()=>window.clearTimeout(h)},[r,n,s,l,u,d])}function mp(r,n,s){try{const l=r instanceof HTMLImageElement?r.naturalWidth:r.width,u=r instanceof HTMLImageElement?r.naturalHeight:r.height;if(!l||!u)return Promise.resolve(null);const d=r instanceof HTMLImageElement?1400/Math.max(l,u):Math.min(1,1400/Math.max(l,u)),h=document.createElement("canvas");h.width=Math.max(1,Math.round(l*d)),h.height=Math.max(1,Math.round(u*d));const m=h.getContext("2d");if(!m)return Promise.resolve(null);const g=getComputedStyle(document.documentElement);if(m.fillStyle=g.getPropertyValue("--surface").trim()||"white",m.fillRect(0,0,h.width,h.height),m.drawImage(r,0,0,h.width,h.height),s){const b=Math.max(10,Math.min(16,h.width/35));m.font=`${b}px sans-serif`;const f=[];let S="";for(const y of s.split(" "))S&&m.measureText(`${S} ${y}`).width>h.width-20?(f.push(S),S=y):S=S?`${S} ${y}`:y;S&&f.push(S),m.fillStyle=g.getPropertyValue("--surface").trim()||"white",m.fillRect(0,0,h.width,f.length*(b+4)+12),m.fillStyle=g.getPropertyValue("--foreground").trim()||"black",f.forEach((y,N)=>m.fillText(y,10,8+b+N*(b+4)))}if(n){const b=n.xPercent*h.width/100,f=n.yPercent*h.height/100,S=Math.max(4,Math.min(12,Math.min(h.width,h.height)*.015)),y=S*1.6;m.strokeStyle=g.getPropertyValue("--primary").trim()||"black",m.lineWidth=Math.max(1,S/3),m.beginPath(),m.arc(b,f,S,0,Math.PI*2),m.stroke(),m.beginPath(),m.moveTo(b-y,f),m.lineTo(b+y,f),m.moveTo(b,f-y),m.lineTo(b,f+y),m.stroke()}return new Promise(b=>h.toBlob(b,"image/png"))}catch{return Promise.resolve(null)}}function pp(r,n,s,l){return[r.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
|
|
3
|
+
`)}function hx(r,n,s){const l=n*Math.PI/360,u=Math.min(l,Math.atan(Math.tan(l)*Math.max(s,.05)));return Math.max(r,1e-6)/Math.sin(u)*1.15}async function gp(r,n,s,l){if(!s?.snapshot){l.isCurrent()&&l.insert(r,n);return}const u=new Date().toISOString(),d=new AbortController;let h,m;try{m=await Promise.race([(async()=>{const g=await s.snapshot;if(!(!g||d.signal.aborted||!l.isCurrent()))return l.upload(new File([g],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),d.signal)})(),new Promise(g=>{h=setTimeout(()=>{d.abort(),g(void 0)},3e3)})])}catch{}finally{clearTimeout(h),d.abort()}l.isCurrent()&&l.insert(m?pp(r,"",u,m):r,n)}function bp(r,n){return r===n||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function Ed(r,n){return`${r??""}\0${n}`}function xp(r,n,s){if(!r||r.length===0||!s)return{explained:0,stale:0};const l=Ed(n,s);let u=0,d=0;for(const h of r){const m=[h.filePath,h.newPath,h.oldPath].filter(b=>typeof b=="string"&&b.length>0);(m.some(b=>Ed(h.repoRoot,b)===l)||m.some(b=>bp(b,s)))&&(u+=1)}return{explained:u,stale:d}}function vp({status:r}){if(!r)return null;const n=r.stale>0&&r.explained===0;if(!(r.explained>0||r.stale>0))return null;const l=n?"AI audit explanation is stale":"AI audit explanation available";return e.jsx("span",{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full ${n?"bg-[color:var(--warning)]/15 text-[color:var(--warning)]":"bg-accent/10 text-accent"}`,title:l,"aria-label":l,children:n?e.jsx(qm,{size:10}):e.jsx(Os,{size:10})})}function Gi({changeStatus:r,auditStatus:n,renderChangeBadge:s}){return e.jsxs("span",{className:"inline-flex items-center gap-1",children:[s(r),e.jsx(vp,{status:n})]})}const Cu="termdock:right-sidebar:diff-change-list-mode:v1";function yp(r){return r==="list"||r==="tree"}function wp(){return ht(Cu,yp)??"tree"}function kp(r){for(const l of r){const u=l.hunk;if(u.oldPath&&u.newPath&&u.oldPath!==u.newPath)return"renamed";if(!u.oldPath&&u.newPath)return"added";if(u.oldPath&&!u.newPath)return"deleted"}const n=r.some(l=>l.hunk.additions>0),s=r.some(l=>l.hunk.deletions>0);return n&&!s?"added":!n&&s?"deleted":"modified"}function Sp(r){const n=new Map;for(const l of r){const u=n.get(l.hunk.filePath)??{key:l.hunk.filePath,filePath:l.hunk.filePath,items:[],additions:0,deletions:0,explained:0,stale:0,changeType:"modified"};u.items.push(l),u.additions+=l.hunk.additions,u.deletions+=l.hunk.deletions,l.current&&(u.explained+=1),l.stale&&(u.stale+=1),n.set(l.hunk.filePath,u)}const s=Array.from(n.values()).sort((l,u)=>l.filePath.localeCompare(u.filePath));for(const l of s)l.changeType=kp(l.items);return s}function jp(r){const n=r.filePath.split("/").pop()??r.filePath;return{key:r.key,path:r.filePath,displayName:n,displayDir:r.filePath.includes("/")?r.filePath.slice(0,-n.length-1):"",status:r.changeType,title:r.filePath}}function Rp(r,n){const s=r.filter(d=>d.trim().length>0);if(s.length<=1)return s[0]??"";const l=[],u=new Set;for(const[d,h]of s.entries()){const m=h.split(`
|
|
4
|
+
`),g=m.findIndex(S=>S.startsWith("@@ "));if(g<0){l.push(...m);continue}d===0&&l.push(...m.slice(0,g));const b=n[d];let f=g;for(;f>=0&&f<m.length;){const S=m.findIndex(($,E)=>E>f&&$.startsWith("@@ ")),y=S>=0?S:m.length,N=m.slice(f,y),I=N[0]??"",_=b?I===b:!0,B=I||b||N.join(`
|
|
5
|
+
`);_&&!u.has(B)&&(l.push(...N),u.add(B)),f=S}}return l.join(`
|
|
6
|
+
`)}function Cp({groups:r,onInsertDiffReference:n}){return r.map(s=>{const l=Rp(s.items.map(m=>m.hunk.diff||m.current?.diff||m.stale?.diff||""),s.items.map(m=>m.hunk.hunkHeader)),u=s.items.map(m=>m.current??m.stale).filter(m=>!!m).map(m=>({id:m.id,repoRoot:m.repoRoot,filePath:m.filePath,oldPath:m.oldPath,newPath:m.newPath,hunkHeader:m.hunkHeader,hunkIndex:m.hunkIndex,fingerprint:m.fingerprint,diff:m.diff,explanation:m.explanation,summary:m.summary,workspaceRoot:m.workspaceRoot,generatedBy:m.generatedBy,injectedAt:m.injectedAt})),d=s.filePath.split("/").pop()??s.filePath,h=s.filePath.includes("/")?s.filePath.slice(0,-d.length-1):"";return{key:s.key,path:s.filePath,absolutePath:u[0]?.repoRoot?`${u[0].repoRoot}/${s.filePath}`:s.filePath,status:s.changeType,repoRoot:u[0]?.repoRoot??null,displayName:d,displayDir:h,diffOverride:l,previewReverts:Object.fromEntries(s.items.flatMap(m=>m.hunk.previewRevert?[[m.hunk.hunkHeader,m.hunk.previewRevert]]:[])),auditRecords:u,onInsertDiffReference:n}})}function Np(r,n,s){const l=Array.from(r.querySelectorAll("[data-diff-stream-item]"));if(l.length===0)return null;const d=r.getBoundingClientRect().top+48;let h=null,m=Number.POSITIVE_INFINITY;for(const b of l){const f=b.getBoundingClientRect();if(f.bottom<d)continue;const S=Math.abs(f.top-d);S<m&&(h=b,m=S)}const g=h?.dataset.diffSelectionPath??h?.dataset.diffStreamItem??null;return!g||g===n||s(g),g}function Md({items:r,selectedKey:n,onSelect:s,emptyText:l,mobile:u=!1,backLabel:d="Back",headerTitle:h,headerMeta:m,onClose:g,closeLabel:b="Back",wrap:f=!0,onToggleWrap:S,wrapTitle:y,wrapOnLabel:N="Wrap on",wrapOffLabel:I="Wrap off",desktopLayout:_="split",onInsertDiffReference:B,onReferenceCopied:$,insertedReferenceKey:E,copiedReferenceKey:A,onClearAuditRecord:T,onRefresh:U,localOptions:D,onHunkGitAction:p,error:i,refreshing:O,actionsBusy:C,refreshLabel:K,refreshTitle:de,walkthroughs:ne=[],onWalkthroughNavigate:ve,initialDetailScrollTop:W,onDetailScrollPositionChange:X,scrollToKey:L,scrollToKeyNonce:F,externalSwiperRef:q,onMobileSlideChange:se}){const{t:ie}=kt(),me=a.useMemo(()=>Sp(r),[r]),ge=a.useMemo(()=>new Map(me.map(V=>[V.key,V])),[me]),[Pe,M]=a.useState(()=>wp()),[ee,be]=a.useState(()=>new Set),[Le,Xe]=a.useState({key:null,nonce:0}),Ee=me.find(V=>V.explained>0||V.stale>0)?.key??me[0]?.key??null,Qe=n&&me.some(V=>V.key===n)?n:Ee,Fe=a.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:me.map(jp)}],[me]),R=a.useMemo(()=>Cp({groups:me,onInsertDiffReference:B}),[me,B]),te=a.useRef(Ee),le=a.useRef(s);te.current=Ee,le.current=s,a.useEffect(()=>{!n&&te.current&&le.current(te.current)},[n]);const Me=S?e.jsxs("button",{type:"button",onClick:S,"aria-pressed":f,title:y,className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 text-[11px] font-medium transition active:scale-95 ${f?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:f?N:I})]}):null,je=D?.map(V=>e.jsxs("label",{title:V.disabled?ie("rightSidebar.includeUncommittedCurrentBranchOnly"):V.key,className:"inline-flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx("input",{type:"checkbox",checked:V.checked,disabled:O||C||V.disabled&&!V.checked,onChange:he=>V.onChange(he.target.checked),className:"accent-primary"}),e.jsxs("span",{children:[V.label," · ",ie("rightSidebar.includeUncommitted"),V.disabled&&e.jsx("span",{className:"block text-[10px]",children:ie("rightSidebar.includeUncommittedCurrentBranchOnly")})]})]},V.key)),He=i?e.jsx("div",{role:"alert",className:"w-full text-xs text-destructive",children:i}):null,ce=U?e.jsxs("button",{type:"button",onClick:U,disabled:O||C,title:de??K,"aria-label":de??K,className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-full bg-surface-2 px-2.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:cursor-not-allowed disabled:opacity-60",children:[e.jsx(uu,{size:12,className:O?"animate-spin":""}),K&&e.jsx("span",{children:K})]}):null,Ae=V=>e.jsxs("div",{className:"px-0 py-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[h&&e.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:h}),m&&e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:m})]}),g&&e.jsxs("button",{type:"button",onClick:g,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:[e.jsx(Fs,{size:14}),b]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[V,je,ce,Me,He]})]});if(r.length===0){const V=e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l});return!h&&!g?V:e.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[Ae(null),V]})}const nt=S||U?({slideToList:V})=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",onClick:V,children:[e.jsx(Fs,{size:14}),d]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[je,ce,S&&e.jsxs("button",{type:"button",onClick:S,"aria-pressed":f,title:y,className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${f?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:f?N:I})]})]}),He]}):void 0;return e.jsx(Oi,{mobile:u,preserveScrollOnUpdate:!!D?.length,desktopLayout:_,backLabel:d,groups:Fe,selectedKey:Qe,mode:Pe,onModeChange:V=>{M(V),V!=="ai"&&$t(Cu,V)},compact:u,collapsedDirectoryKeys:ee,onToggleDirectory:V=>{be(he=>{const Be=new Set(he);return Be.has(V)?Be.delete(V):Be.add(V),Be})},onSelectFile:V=>{s(V.key),Xe(he=>({key:V.key,nonce:he.nonce+1}))},renderLeading:V=>{const he=ge.get(V.key);return e.jsx(Gi,{changeStatus:V.status,auditStatus:he,renderChangeBadge:Be=>e.jsx(Ts,{status:Be})})},renderTrailing:V=>{const he=ge.get(V.key);return he?e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",he.additions," -",he.deletions]}):null},renderListHeader:Ae,aiContent:({slideToDetail:V,fullscreen:he,toggleFullscreen:Be})=>ne.length>0&&ve?e.jsx(xu,{walkthroughs:ne,repoRoot:ne[0]?.repoRoot,fullscreen:he,onToggleFullscreen:Be,onNavigate:qe=>{u&&window.requestAnimationFrame(V),ve(qe)}}):e.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:ie("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:nt,externalSwiperRef:q,onMobileSlideChange:se,detailContainerClassName:u?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:W,scrollToKey:L??Le.key,scrollToKeyNonce:L==null?Le.nonce:F,onDetailScroll:V=>{Np(V,Qe,s),X?.(V.scrollTop)},files:R,activePane:!0,wrap:f,renderStreamBadge:(V,he)=>{const Be=ge.get(he.key);return e.jsx(Gi,{changeStatus:V,auditStatus:Be,renderChangeBadge:qe=>e.jsx(Ts,{status:qe})})},onInsertDiffReference:B,onReferenceCopied:$,insertedReferenceKey:E,copiedReferenceKey:A,onClearAuditRecord:T,onHunkGitAction:O?void 0:p,emptyContent:e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l})})}function Ep(r){return r.replace(/\/+$/,"")||"/"}function Mp(r){return[...new Set(Array.from(r,Ep))].sort((n,s)=>n.localeCompare(s))}function $p(r){return r==="event-storm"||r==="reconnected"||r==="directory-rescan"||r==="polling-fallback"}function Lp(r){let n=null;return{applicableEvents:r.filter(l=>{const u=l.type==="rescan-required"&&!$p(l.reason);return u&&l.reason&&!n&&(n=l.reason),!u}),unavailableReason:n}}const Ap=1400,Pp=1200,Nu=44,Tp=.7;function xi(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function Ki(r){return`termdock:right-sidebar:context-draft-height:${r}:v1`}function Ip(r){try{const n=window.localStorage.getItem(Ki(r)),s=n===null?NaN:Number(n);return Number.isFinite(s)&&s>=Nu?s:null}catch{return null}}function $d(r,n){try{n===null?window.localStorage.removeItem(Ki(r)):window.localStorage.setItem(Ki(r),String(n))}catch{}}function Ga(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Dp({value:r,collapsed:n,labels:s,focusRequest:l,insertError:u,autoCollapseAfterSend:d,onChange:h,onCollapsedChange:m,onAutoCollapseAfterSendChange:g,onDisable:b,onClear:f,onInsert:S,onInsertAndSend:y}){const[N,I]=a.useState(null),[_,B]=a.useState(!1),[$,E]=a.useState(()=>Ip(xi())),A=a.useRef($),T=a.useRef(null),U=a.useRef(null),D=a.useRef(r),p=a.useRef(null),i=a.useRef(null),O=!!r.trim(),C=r.trim().split(`
|
|
7
|
+
`)[0]??"",K=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";a.useEffect(()=>()=>{T.current!==null&&window.clearTimeout(T.current),U.current!==null&&window.clearTimeout(U.current)},[]),a.useEffect(()=>{let M=!1;const ee=xi();return lu().then(be=>{if(M)return;const Le=be.contextDraftHeight?.[ee]??null;$d(ee,Le),A.current=Le,E(Le)}).catch(()=>{}),()=>{M=!0}},[]),a.useEffect(()=>{if(l!==void 0&&l>0){const M=p.current;if(!M)return;Ga()||M.focus(),M.setSelectionRange(M.value.length,M.value.length),M.scrollTop=M.scrollHeight}},[l]),a.useEffect(()=>{const M=D.current;D.current=r,!(!n||r.length<=M.length)&&(B(!0),U.current!==null&&window.clearTimeout(U.current),U.current=window.setTimeout(()=>{U.current=null,B(!1)},Pp))},[r,n]),a.useEffect(()=>{if(n)return;const M=p.current;M&&(M.style.height=$!==null?`${$}px`:"")},[r,n,$]),a.useEffect(()=>{if(n)return;const M=p.current;!M||document.activeElement===M||(M.scrollTop=M.scrollHeight)},[r,n]),a.useEffect(()=>{if(n||Ga())return;const M=p.current;!M||document.activeElement===M||(M.focus(),M.setSelectionRange(M.value.length,M.value.length))},[n]);const de=a.useRef(null);a.useLayoutEffect(()=>{if(!Ga())return;const M=window.visualViewport;if(!M)return;const ee=()=>{const be=de.current;if(!be)return;if(M.height>=window.innerHeight*.75){be.style.transform="";return}const Le=be.getBoundingClientRect(),Xe=Math.round(M.height-Le.bottom);be.style.transform=Xe!==0?`translateY(${Xe}px)`:""};return ee(),M.addEventListener("resize",ee),M.addEventListener("scroll",ee),()=>{M.removeEventListener("resize",ee),M.removeEventListener("scroll",ee),de.current&&(de.current.style.transform="")}},[n]);const ne=M=>{I(M),T.current!==null&&window.clearTimeout(T.current),T.current=window.setTimeout(()=>{T.current=null,I(null)},Ap)},ve=M=>{m(!1),Ga()&&window.requestAnimationFrame(()=>{const ee=p.current;if(!ee)return;ee.focus();const be=ee.value.length;ee.setSelectionRange(be,be),window.requestAnimationFrame(()=>{ee.setSelectionRange(be,be)})})},W=()=>{S(),ne("inserted")},X=()=>{O&&(y(),ne("sent"))},L=M=>{if(M.key==="Escape"){M.preventDefault(),m(!0);return}M.key!=="Enter"||!M.metaKey&&!M.ctrlKey||(M.preventDefault(),X())},F=M=>{M.preventDefault()},q=M=>{M.preventDefault();const ee=p.current;ee&&(i.current={startY:M.clientY,startHeight:ee.getBoundingClientRect().height},M.currentTarget.setPointerCapture?.(M.pointerId))},se=M=>{const ee=i.current;if(!ee)return;const be=window.visualViewport?.height??window.innerHeight,Le=Math.round(Math.min(Math.max(ee.startHeight+(ee.startY-M.clientY),Nu),be*Tp));A.current=Le,E(Le)},ie=M=>{const ee=xi();$d(ee,M),Fi({contextDraftHeight:{[ee]:M}}).catch(()=>{})},me=()=>{i.current&&(i.current=null,A.current!==null&&ie(A.current))},ge=()=>{A.current=null,E(null),ie(null)},Pe=r.length>0&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/50",children:s.characterCount(r.length)});return n?e.jsx("section",{ref:de,className:"shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:e.jsxs("div",{className:"flex h-8 items-center gap-1 px-2",children:[e.jsxs("button",{type:"button",onClick:()=>ve(),className:"group flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1 py-1 text-left transition-colors hover:bg-surface/70","aria-expanded":!1,"aria-label":s.expand,title:s.expand,children:[e.jsx(km,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),e.jsx("span",{className:`truncate text-[11px] ${u?"text-destructive":_?"text-primary":O?"text-foreground/80":"text-muted-foreground/50"}`,children:u??(_?s.appended:O?C:s.title)})]}),Pe,e.jsx("button",{type:"button",onClick:X,disabled:!O,className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-30 ${O?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground"}`,"aria-label":s.send,title:s.send,children:N==="sent"?e.jsx(Di,{size:12}):e.jsx(gd,{size:12})})]})}):e.jsxs("section",{ref:de,className:"relative shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:[e.jsx("div",{className:"group absolute left-1/2 top-0 z-10 flex h-3 w-16 -translate-x-1/2 -translate-y-1/2 cursor-ns-resize touch-none items-center justify-center",onPointerDown:q,onPointerMove:se,onPointerUp:me,onPointerCancel:me,onDoubleClick:ge,title:s.resize,"aria-hidden":"true",children:e.jsx("span",{className:"h-1 w-8 rounded-full bg-border/50 transition group-hover:bg-border"})}),e.jsxs("div",{className:"flex h-7 items-center gap-0.5 px-2",children:[e.jsxs("button",{type:"button",onPointerDown:F,onClick:()=>m(!0),className:"group flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1 py-1 text-left transition-colors hover:bg-surface/70","aria-expanded":!0,"aria-label":s.collapse,title:s.collapse,children:[e.jsx(_s,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),e.jsx("span",{className:"truncate text-[10px] font-medium text-foreground/75",children:s.title}),Pe]}),e.jsx("button",{type:"button",role:"switch","aria-checked":d,onPointerDown:F,onClick:()=>g(!d),className:"inline-flex h-6 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:bg-surface/70 hover:text-foreground","aria-label":s.autoCollapseAfterSend,title:s.autoCollapseAfterSend,children:e.jsx("span",{"aria-hidden":"true",className:`relative h-3 w-5 rounded-full transition-colors ${d?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-primary-foreground transition-transform ${d?"translate-x-2.5":"translate-x-0.5"}`})})}),e.jsx("button",{type:"button",onPointerDown:F,onClick:b,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/50 transition hover:bg-surface/70 hover:text-foreground active:scale-95","aria-label":s.disable,title:s.disable,children:e.jsx(Vt,{size:11})})]}),e.jsx("div",{className:"px-2 pb-2",children:e.jsxs("div",{className:"overflow-hidden rounded-lg bg-surface/80 ring-1 ring-border/10 transition focus-within:ring-primary/35",children:[e.jsx("textarea",{ref:p,value:r,onChange:M=>h(M.target.value),onKeyDown:L,placeholder:s.title,rows:1,className:"block min-h-11 w-full resize-none bg-transparent px-2.5 py-2 font-mono text-[12px] leading-relaxed text-foreground placeholder:text-muted-foreground/30 focus:outline-none",autoCapitalize:"sentences",spellCheck:!0,"data-context-draft-input":!0}),e.jsxs("div",{className:"flex items-center gap-0.5 border-t border-border/10 px-1 py-1",children:[e.jsx("button",{type:"button",onPointerDown:F,onClick:f,disabled:!O,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/65 transition hover:bg-surface-2 hover:text-foreground active:scale-95 disabled:opacity-30","aria-label":s.clear,title:s.clear,children:e.jsx(ro,{size:11})}),u?e.jsx("span",{className:"min-w-0 flex-1 truncate px-1 text-[10px] text-destructive",role:"alert",children:u}):e.jsx("span",{className:"flex-1"}),e.jsxs("button",{type:"button",onPointerDown:F,onClick:W,disabled:!O,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-[10px] font-medium text-foreground/75 transition hover:bg-surface-2 hover:text-foreground active:scale-[0.98] disabled:opacity-30",children:[e.jsx(Sm,{size:11}),e.jsx("span",{children:N==="inserted"?s.inserted:s.insert})]}),e.jsxs("button",{type:"button",onPointerDown:F,onClick:X,disabled:!O,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md bg-primary px-2 text-[10px] font-semibold text-primary-foreground transition hover:bg-primary/90 active:scale-[0.98] disabled:opacity-30",title:`${s.insertAndSend} · ${K}`,children:[N==="sent"?e.jsx(Di,{size:11}):e.jsx(gd,{size:11}),e.jsx("span",{children:N==="sent"?s.sent:s.send})]})]})]})})]})}function Fp(r,n){const s=n.trim();if(!s)return r;if(!r.trim())return s;const l=r.endsWith(`
|
|
8
|
+
|
|
9
|
+
`)?"":r.endsWith(`
|
|
10
|
+
`)?`
|
|
11
|
+
`:`
|
|
12
|
+
|
|
13
|
+
`;return`${r}${l}${s}`}function _p(r,n){const s=r.trim();return s?n?`${s}\r`:/\s$/.test(r)?r:`${s} `:""}const Vi="termdock:right-sidebar:html-view-mode-by-file:v1";function Bp(r){return r==="preview"||r==="source"}function Eu(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(Bp)}function Mu(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function Ld(r,n){const s=Mu(r,n);return s?ht(Vi,Eu)?.[s]??"source":"source"}function Op(r,n,s){const l=Mu(r,n);if(!l)return;const u=ht(Vi,Eu)??{};$t(Vi,{...u,[l]:s})}function Up(r){try{return new URL(r,location.href).pathname.startsWith("/api/")}catch{return!1}}const Hp=1500,Ad=256*1024*1024;async function zp(r,n){const s=await fetch(r,{signal:n});if(!s.ok)throw new Error(`Media fallback failed: HTTP ${s.status}`);const l=s.headers.get("content-type")??"",u=s.body?.getReader();if(!u){const m=await s.blob();if(m.size>Ad)throw new Error("Media too large for encrypted fallback");return URL.createObjectURL(m)}const d=[];let h=0;try{for(;;){const{done:m,value:g}=await u.read();if(m)break;if(h+=g.byteLength,h>Ad)throw new Error("Media too large for encrypted fallback");d.push(g)}}catch(m){throw await u.cancel().catch(()=>{}),m}return URL.createObjectURL(new Blob(d,{type:l}))}function go(r,n){const s=Up(r),[l,u]=a.useState(()=>!!navigator.serviceWorker?.controller),[d,h]=a.useState(void 0),m=a.useRef(n);return m.current=n,a.useEffect(()=>{if(!s||l)return;const g=navigator.serviceWorker,b=()=>u(!!g?.controller);return g?.addEventListener("controllerchange",b),b(),()=>g?.removeEventListener("controllerchange",b)},[s,l]),a.useEffect(()=>{if(!s||l){h(void 0);return}let g=!1,b;const f=new AbortController,S=window.setTimeout(()=>{zp(r,f.signal).then(y=>{if(g){URL.revokeObjectURL(y);return}b=y,h(y)}).catch(()=>{g||f.signal.aborted||m.current?.()})},Hp);return()=>{g=!0,window.clearTimeout(S),f.abort(),b&&URL.revokeObjectURL(b)}},[s,l,r]),!s||l?r:d}function vi(r){const n=Number.isFinite(r)&&r>0?Math.floor(r):0,s=Math.floor(n/3600),l=Math.floor(n%3600/60),u=n%60,d=String(l).padStart(2,"0"),h=String(u).padStart(2,"0");return s>0?`${s}:${d}:${h}`:`${d}:${h}`}function Wp(r,n,s){return!Number.isFinite(s)||s<=0||!n.width?0:Math.min(1,Math.max(0,(r-n.left)/n.width))*s}const qr=2,Gp=8,Kp=60,Ka=5,Pd=.05,Vp=900;function qp(r){return!Number.isFinite(r)||r<=0?qr:Math.min(Gp,qr+Math.floor(r/Kp))}const Yp=350,Xp=6,Jp=90;function Qp({url:r,onLoadError:n}){const s=go(r,n),{t:l}=kt(),u=a.useRef(null),d=a.useRef(null),h=a.useRef(null),m=a.useRef(null),g=a.useRef(!1),b=a.useRef(null),f=a.useRef(null),S=a.useRef(0),y=a.useRef(!1),N=a.useRef(!1),I=a.useRef(!1),_=a.useRef(null),B=a.useRef(null),$=a.useRef(!1),E=a.useRef(1),A=a.useRef(!1),[T,U]=a.useState(0),[D,p]=a.useState(0),[i,O]=a.useState(!1),[C,K]=a.useState(!1),[de,ne]=a.useState(null),[ve,W]=a.useState(!1),[X,L]=a.useState(0),[F,q]=a.useState(!1),[se,ie]=a.useState({width:0,height:0}),[me,ge]=a.useState(qr),[Pe,M]=a.useState(1),[ee,be]=a.useState(null),Le=a.useRef(qr),Xe=a.useRef(null),Ee=a.useCallback(()=>{_.current!==null&&(clearTimeout(_.current),_.current=null)},[]),Qe=a.useCallback(()=>{Ee();const H=B.current;if(B.current=null,!$.current)return!1;const ae=h.current;if(ae&&(ae.playbackRate=E.current,H))try{ae.releasePointerCapture?.(H.id)}catch{}return $.current=!1,Le.current=qr,W(!1),!0},[Ee]);a.useEffect(()=>()=>{b.current!==null&&cancelAnimationFrame(b.current),f.current!==null&&clearTimeout(f.current),Xe.current!==null&&clearTimeout(Xe.current),Ee();const H=h.current;H&&$.current&&(H.playbackRate=E.current)},[Ee]),a.useEffect(()=>{const H=d.current;if(!H||typeof ResizeObserver>"u")return;const ae=new ResizeObserver(([ye])=>{ye&&ie({width:ye.contentRect.width,height:ye.contentRect.height})});return ae.observe(H),()=>ae.disconnect()},[]),a.useEffect(()=>{const H=()=>q(document.fullscreenElement===u.current);return document.addEventListener("fullscreenchange",H),()=>document.removeEventListener("fullscreenchange",H)},[]);const Fe=a.useCallback((H,ae=!1)=>{const ye=h.current;if(!ye)return!1;const ze=Number.isFinite(ye.duration)?ye.duration:H,mt=Math.min(Math.max(H,0),ze);if(p(mt),Math.abs(ye.currentTime-mt)<1/120)return!1;const ur=ye.fastSeek;return ae&&typeof ur=="function"?ur.call(ye,mt):ye.currentTime=mt,!0},[]),R=a.useCallback(()=>{b.current===null&&(b.current=requestAnimationFrame(()=>{b.current=null;const H=h.current;if(!H||!y.current||N.current||H.seeking)return;const ae=I.current;I.current=!1,N.current=Fe(S.current,!ae)}))},[Fe]),te=a.useCallback(H=>{const ae=m.current,ye=h.current;if(!ae||!ye)return;const ze=ae.getBoundingClientRect(),mt=Wp(H,ze,ye.duration);S.current=mt,ne(mt),I.current=!1,R(),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,I.current=!0,R()},Jp)},[R]),le=a.useCallback(()=>{b.current!==null&&(cancelAnimationFrame(b.current),b.current=null),f.current!==null&&(clearTimeout(f.current),f.current=null),I.current=!1,N.current=!1,Fe(S.current)},[Fe]),Me=a.useCallback(H=>{const ae=h.current;if(!(!ae||!Number.isFinite(ae.duration)||ae.duration<=0)){g.current=!ae.paused,ae.pause(),y.current=!0,K(!0);try{H.currentTarget.setPointerCapture(H.pointerId)}catch{}te(H.clientX)}},[te]),je=a.useCallback(()=>{y.current=!1,le(),K(!1),ne(null);const H=h.current;H&&g.current&&!H.ended&&H.play().catch(()=>{}),g.current=!1},[le]),He=a.useCallback(()=>{const H=h.current;if(H){if(A.current){A.current=!1;return}H.paused?H.play().catch(()=>{}):H.pause()}},[]),ce=a.useCallback(H=>{const ae=h.current;if(!ae)return;const ye=Math.min(1,Math.max(0,Math.round((ae.volume+H)*100)/100));ae.volume=ye,ye>0&&(ae.muted=!1),M(ye),be(ye),Xe.current!==null&&clearTimeout(Xe.current),Xe.current=setTimeout(()=>{Xe.current=null,be(null)},Vp)},[]),Ae=a.useCallback(H=>{const ae=h.current;if(ae){if(H.key==="ArrowLeft"){H.preventDefault(),Fe(ae.currentTime-(H.shiftKey?Ka*2:Ka));return}if(H.key==="ArrowRight"){H.preventDefault(),Fe(ae.currentTime+(H.shiftKey?Ka*2:Ka));return}if(H.key==="ArrowUp"){H.preventDefault(),ce(Pd);return}if(H.key==="ArrowDown"){H.preventDefault(),ce(-Pd);return}(H.key===" "||H.key==="Spacebar"||H.key==="k"||H.key==="K")&&(H.preventDefault(),ae.paused?ae.play().catch(()=>{}):ae.pause())}},[Fe,ce]),nt=a.useCallback(H=>{const ae=h.current;!ae||ae.paused||H.button!==0||(Ee(),B.current={id:H.pointerId,x:H.clientX,y:H.clientY},_.current=setTimeout(()=>{_.current=null;const ye=B.current;if(E.current=ae.playbackRate,ae.playbackRate=qr,Le.current=qr,ge(qr),$.current=!0,W(!0),ye)try{ae.setPointerCapture?.(ye.id)}catch{}},Yp))},[Ee]),V=a.useCallback(H=>{const ae=B.current;if(!ae||ae.id!==H.pointerId)return;if(!$.current){Math.hypot(H.clientX-ae.x,H.clientY-ae.y)>Xp&&(Ee(),B.current=null);return}const ye=qp(H.clientX-ae.x);if(ye===Le.current)return;Le.current=ye,ge(ye);const ze=h.current;ze&&(ze.playbackRate=ye)},[Ee]),he=a.useCallback(()=>{Qe()&&(A.current=!0)},[Qe]);a.useEffect(()=>(window.addEventListener("pointerup",he),window.addEventListener("pointercancel",he),window.addEventListener("blur",he),()=>{window.removeEventListener("pointerup",he),window.removeEventListener("pointercancel",he),window.removeEventListener("blur",he)}),[he]);const Be=a.useCallback(async()=>{const H=u.current,ae=h.current;if(!(!H||!ae))try{document.fullscreenElement===H?await document.exitFullscreen():H.requestFullscreen?await H.requestFullscreen():ae.webkitEnterFullscreen?.()}catch{ae.webkitEnterFullscreen?.()}},[]),qe=a.useCallback(()=>L(H=>(H+90)%360),[]),qt=a.useCallback(H=>{const ae=h.current;if(!ae||!Number.isFinite(ae.duration))return;const ye=H.shiftKey?10:5;let ze=null;H.key==="ArrowLeft"?ze=ae.currentTime-ye:H.key==="ArrowRight"?ze=ae.currentTime+ye:H.key==="Home"?ze=0:H.key==="End"&&(ze=ae.duration),ze!==null&&(H.preventDefault(),Fe(ze))},[Fe]),Ze=C&&de!==null?de:D,dt=T>0?Math.min(1,Math.max(0,Ze/T)):0,Ft=(X===90||X===270)&&se.width>0&&se.height>0?{width:`${se.height}px`,height:`${se.width}px`}:{width:"100%",height:"100%"};return e.jsxs("div",{ref:u,className:"flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-background fullscreen:h-screen fullscreen:w-screen fullscreen:rounded-none","data-testid":"file-preview-video-player","data-rotation":X,children:[e.jsxs("div",{ref:d,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[e.jsx("video",{ref:h,"data-testid":"file-preview-video",className:`absolute left-1/2 top-1/2 max-w-none object-contain outline-none transition-transform duration-200 focus-visible:ring-2 focus-visible:ring-primary/60${ve?` ${jd}`:""}`,style:{...Ft,transform:`translate(-50%, -50%) rotate(${X}deg)`},src:s,preload:"auto",playsInline:!0,tabIndex:0,...ve?{[Rd]:""}:{},onClick:He,onKeyDown:Ae,onVolumeChange:H=>M(H.currentTarget.volume),onPointerDown:nt,onPointerMove:V,onPointerUp:he,onPointerCancel:he,onContextMenu:H=>{$.current&&H.preventDefault()},onPlay:()=>O(!0),onPause:()=>O(!1),onTimeUpdate:H=>p(H.currentTarget.currentTime),onSeeked:H=>{const ae=H.currentTarget;if(p(ae.currentTime),N.current=!1,!y.current)return;const ye=ae.requestVideoFrameCallback;typeof ye=="function"?ye.call(ae,()=>{y.current&&R()}):requestAnimationFrame(()=>{y.current&&R()})},onLoadedMetadata:H=>U(Number.isFinite(H.currentTarget.duration)?H.currentTarget.duration:0),onDurationChange:H=>U(Number.isFinite(H.currentTarget.duration)?H.currentTarget.duration:0),onError:n,children:l("rightSidebar.videoUnsupported")}),ve&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-3 z-10 -translate-x-1/2 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md",children:l("rightSidebar.videoLongPressSpeed",{rate:String(me)})}),ee!==null&&e.jsxs("div",{className:"pointer-events-none absolute right-3 top-3 z-10 inline-flex items-center gap-1 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md","data-testid":"file-preview-video-volume",children:[e.jsx(jm,{size:13}),l("rightSidebar.videoVolume",{percent:Math.round(Pe*100)})]}),C&&de!==null&&e.jsx("div",{className:"pointer-events-none absolute bottom-1 z-10 -translate-x-1/2 rounded-md bg-surface-elevated px-2 py-1 text-[11px] font-medium text-foreground shadow-md",style:{left:`${dt*100}%`},"data-testid":"file-preview-video-scrub-time",children:vi(de)})]}),e.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${jd}`,[Rd]:"",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:He,"aria-label":l(i?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:l(i?"rightSidebar.videoPause":"rightSidebar.videoPlay"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-play",children:i?e.jsx(Rm,{size:14}):e.jsx(Cm,{size:14})}),e.jsxs("div",{ref:m,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(T),"aria-valuenow":Math.floor(Ze),tabIndex:0,className:"group relative h-5 min-w-0 flex-1 cursor-pointer touch-none py-2","data-testid":"file-preview-video-track",onPointerDown:Me,onPointerMove:H=>{C&&te(H.clientX)},onPointerUp:je,onPointerCancel:je,onKeyDown:qt,children:[e.jsx("div",{className:"h-1 w-full rounded-full bg-surface-elevated"}),e.jsx("div",{className:"absolute inset-y-0 left-0 my-auto h-1 rounded-full bg-primary",style:{width:`${dt*100}%`}}),e.jsx("div",{className:"absolute top-1/2 h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary shadow",style:{left:`${dt*100}%`}})]}),e.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[vi(Ze)," / ",vi(T)]}),e.jsx("button",{type:"button",onClick:qe,"aria-label":l("rightSidebar.videoRotate"),title:l("rightSidebar.videoRotate"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-rotate",children:e.jsx(uu,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{Be()},"aria-label":l(F?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:l(F?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-fullscreen",children:F?e.jsx(Nm,{size:14}):e.jsx(Em,{size:14})})]})})]})}function Zp(r){const n=Math.max(0,Math.min(100,r.xPercent)),s=Math.max(0,Math.min(100,r.yPercent));return{...n<=50?{left:`calc(${n}% + 8px)`}:{right:`calc(${100-n}% + 8px)`},...s<=50?{top:`calc(${s}% + 8px)`}:{bottom:`calc(${100-s}% + 8px)`}}}function bo({anchor:r,children:n,disabled:s=!1,onClick:l,title:u}){return e.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:s,onClick:d=>{d.stopPropagation(),l()},title:u,style:Zp(r),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[e.jsx(io,{size:11}),n]})}function eg(r,n,s,l){if(s.width<=0||s.height<=0||l.width<=0||l.height<=0)return null;const u=Math.min(s.width/l.width,s.height/l.height);if(!Number.isFinite(u)||u<=0)return null;const d=l.width*u,h=l.height*u,m=s.left+(s.width-d)/2,g=s.top+(s.height-h)/2,b=r-m,f=n-g;if(b<0||f<0||b>d||f>h)return null;const S=b/d*100,y=f/h*100;return{x:l.x+l.width*S/100,y:l.y+l.height*y/100,xPercent:S,yPercent:y}}function tg(r,n,s){const l=[`SVG标注: ${r}`,`视图: ${n}`,`SVG坐标: (${s.x.toFixed(2)},${s.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return s.nearestText&&l.push(`最近文字: ${s.nearestText}`),`"${l.join(" / ")}"`}function rg(r){const n=new DOMParser().parseFromString(r,"image/svg+xml"),s=n.documentElement;if(s.nodeName.toLowerCase()!=="svg"||n.querySelector("parsererror"))throw new Error("Invalid SVG document");return n.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(l=>l.remove()),n.querySelectorAll("*").forEach(l=>{for(const u of Array.from(l.attributes)){const d=u.name.toLowerCase(),h=u.value.trim();(d.startsWith("on")||(d==="href"||d.endsWith(":href"))&&h&&!h.startsWith("#"))&&l.removeAttribute(u.name)}}),s.removeAttribute("width"),s.removeAttribute("height"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(s)}function ng(r,n,s){let l=null;for(const u of Array.from(r.querySelectorAll("text"))){const d=(u.textContent??"").replace(/\s+/g," ").trim();if(!d)continue;const h=Number(u.getAttribute("x")),m=Number(u.getAttribute("y"));if(!Number.isFinite(h)||!Number.isFinite(m))continue;const g=Math.hypot(h-n,m-s);(!l||g<l.distance)&&(l={text:d,distance:g})}return l?.text.slice(0,120)}function $u({blobUrl:r,filePath:n,viewLabel:s,onInsertAnnotation:l}){const u=a.useRef(null),d=a.useRef(null),[h,m]=a.useState(null),[g,b]=a.useState(null),[f,S]=a.useState(1),[y,N]=a.useState(!1),[I,_]=a.useState(null),B=a.useRef(new Map),$=a.useRef(null),E=a.useRef(!1),A=a.useRef(null),T=a.useRef(f);T.current=f,a.useEffect(()=>{const L=new AbortController;return m(null),b(null),_(null),S(1),fetch(r,{signal:L.signal}).then(F=>F.text()).then(F=>m(rg(F))).catch(F=>{L.signal.aborted||b(F instanceof Error?F.message:"SVG preview failed")}),()=>L.abort()},[r]),a.useEffect(()=>{if(!y)return;const L=F=>{F.key==="Escape"&&N(!1)};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[y]),a.useLayoutEffect(()=>{const L=d.current,F=L?.querySelector("[data-svg-document] > svg");if(!L||!F)return;let q;try{q=F.getBBox()}catch{return}if(!q.width||!q.height)return;const se=Math.max(2,Math.min(q.width,q.height)*.025);F.setAttribute("viewBox",`${q.x-se} ${q.y-se} ${q.width+2*se} ${q.height+2*se}`),F.style.width=`${f*100}%`,F.style.height=`${f*100}%`,F.style.minWidth=`${f*100}%`,F.style.minHeight=`${f*100}%`,F.style.display="block"},[h,f]);const U=a.useMemo(()=>I?tg(n,s,I):null,[n,I,s]),D=L=>{if(E.current){E.current=!1;return}const F=d.current,q=F?.querySelector("[data-svg-document] > svg"),se=u.current;if(!F||!q||!se)return;const ie=q.viewBox.baseVal,me=eg(L.clientX,L.clientY,q.getBoundingClientRect(),ie);if(!me)return;const ge=se.getBoundingClientRect();_({...me,nearestText:ng(q,me.x,me.y),stageX:L.clientX-ge.left,stageY:L.clientY-ge.top,stageXPercent:(L.clientX-ge.left)/ge.width*100,stageYPercent:(L.clientY-ge.top)/ge.height*100})},p=L=>Math.max(1,Math.min(12,L)),i=(L,F)=>{const q=p(F),se=L.querySelector("[data-svg-document] > svg");if(!se)return q;const ie=`${q*100}%`;return se.style.width=ie,se.style.height=ie,se.style.minWidth=ie,se.style.minHeight=ie,T.current=q,q},O=(L,F,q,se)=>{const ie=T.current,me=L.getBoundingClientRect(),ge=q-me.left,Pe=se-me.top,M=(L.scrollLeft+ge)/ie,ee=(L.scrollTop+Pe)/ie,be=i(L,F);return L.scrollLeft=M*be-ge,L.scrollTop=ee*be-Pe,be},C=()=>{const L=Array.from(B.current.values());return L.length>=2?Math.hypot(L[0].x-L[1].x,L[0].y-L[1].y):0},K=L=>{if(L.pointerType==="mouse"&&L.button!==0)return;const F=d.current;F&&(B.current.set(L.pointerId,{x:L.clientX,y:L.clientY}),F.setPointerCapture?.(L.pointerId),B.current.size>=2?($.current={kind:"pinch",startX:L.clientX,startY:L.clientY,startScrollLeft:F.scrollLeft,startScrollTop:F.scrollTop,startDistance:C(),startZoom:T.current,moved:!1},E.current=!0):T.current>1&&($.current={kind:"pan",startX:L.clientX,startY:L.clientY,startScrollLeft:F.scrollLeft,startScrollTop:F.scrollTop,startZoom:T.current,moved:!1}))},de=L=>{if(!B.current.has(L.pointerId))return;B.current.set(L.pointerId,{x:L.clientX,y:L.clientY});const F=d.current,q=$.current;if(!(!F||!q)){if(B.current.size>=2&&q.kind==="pinch"){const se=C();if(!q.startDistance||!se)return;const ie=p(q.startZoom*se/q.startDistance);if(Math.abs(ie-T.current)<.01)return;const me=Array.from(B.current.values()),ge=(me[0].x+me[1].x)/2,Pe=(me[0].y+me[1].y)/2;q.moved=!0,E.current=!0,O(F,ie,ge,Pe),L.preventDefault();return}if(q.kind==="pan"&&B.current.size===1){const se=L.clientX-q.startX,ie=L.clientY-q.startY;if(!q.moved&&Math.hypot(se,ie)<6)return;q.moved=!0,E.current=!0,F.scrollLeft=q.startScrollLeft-se,F.scrollTop=q.startScrollTop-ie,L.preventDefault()}}},ne=L=>{const F=d.current,q=$.current,se=B.current.size===1&&!q?.moved;B.current.delete(L.pointerId);try{F?.releasePointerCapture?.(L.pointerId)}catch{}if(B.current.size===1&&q?.kind==="pinch"){const ge=Array.from(B.current.values())[0];$.current=F?{kind:"pan",startX:ge.x,startY:ge.y,startScrollLeft:F.scrollLeft,startScrollTop:F.scrollTop,startZoom:T.current,moved:!1}:null;return}if(B.current.size>0||($.current=null,q?.kind==="pinch"&&S(T.current),!se||E.current))return;const ie=Date.now(),me=A.current;me&&ie-me.time<350&&Math.hypot(L.clientX-me.x,L.clientY-me.y)<24?(A.current=null,E.current=!0,S(ge=>ge>1?1:2.5)):A.current={time:ie,x:L.clientX,y:L.clientY}},ve=L=>{if(!L.ctrlKey&&!L.metaKey)return;const F=d.current;if(!F)return;L.preventDefault();const q=O(F,T.current*Math.exp(-L.deltaY*.01),L.clientX,L.clientY);S(q)},W=()=>{S(1),T.current=1,d.current&&(d.current.scrollLeft=0,d.current.scrollTop=0)},X=e.jsxs("div",{className:y?"fixed inset-0 z-modal-panel flex min-h-0 flex-col bg-surface pt-[env(safe-area-inset-top,0px)]":"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{ref:u,className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:d,role:"button",tabIndex:0,onClick:D,onDoubleClick:L=>{L.preventDefault(),S(F=>F>1?1:2.5)},onPointerDown:K,onPointerMove:de,onPointerUp:ne,onPointerCancel:ne,onWheel:ve,onScroll:()=>_(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:g?e.jsx("div",{className:"p-4 text-sm text-destructive",children:g}):h?e.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:h}}):e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),I&&e.jsx("span",{"data-svg-pick-marker":!0,className:"pointer-events-none absolute z-10 h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm",style:{left:I.stageX,top:I.stageY}}),I&&U&&e.jsx(bo,{anchor:{xPercent:I.stageXPercent,yPercent:I.stageYPercent},title:"引用 SVG 标注",onClick:()=>{l?.(U,`svg:${I.x.toFixed(2)}:${I.y.toFixed(2)}`),_(null)},children:"引用 SVG 标注"}),e.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[f>1.001&&e.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:L=>{L.stopPropagation(),W()},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:e.jsx(ip,{size:14})}),e.jsx("button",{type:"button","aria-label":y?"退出全屏 SVG":"全屏 SVG",title:y?"退出全屏 SVG":"全屏 SVG",onClick:L=>{L.stopPropagation(),N(F=>!F)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:y?e.jsx(vu,{size:14}):e.jsx(bu,{size:14})})]})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:I?`SVG (${I.x.toFixed(2)}, ${I.y.toFixed(2)}) · ${I.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return y?Yr.createPortal(X,document.body):X}function no(r){switch(r){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function sg(r,n,s,l){const u=[`电子标注: ${r}`,`视图: ${no(n)}`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(l?.available&&l.xMm!==void 0&&l.yMm!==void 0&&(u.push(`PCB坐标: (${l.xMm.toFixed(2)},${l.yMm.toFixed(2)})mm [KiCad板坐标]`),l.layer&&u.push(`显示层: ${l.layer}`),l.nearest)){const d=[l.nearest.net?`网络 ${l.nearest.net}`:null,`对象层 ${l.nearest.layer}`,`距离 ${l.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");u.push(`最近对象: ${l.nearest.label}${d?`(${d})`:""}`)}return`"${u.join(" / ")}"`}function ag({blobUrl:r,filePath:n,view:s,board:l,onViewChange:u,onInsertAnnotation:d,onRefresh:h,interactive3d:m}){const{t:g}=kt(),b=a.useRef(null),f=a.useRef(null),S=a.useRef(null),[y,N]=a.useState(null),[I,_]=a.useState(!1);a.useEffect(()=>(S.current?.abort(),N(null),_(!1),()=>S.current?.abort()),[r,s]);const B=a.useMemo(()=>y?sg(n,s,y,y.inspection):null,[n,y,s]),$=A=>{const T=b.current,U=f.current;if(!T||!U||!U.naturalWidth||!U.naturalHeight)return;const D=T.getBoundingClientRect(),p=U.getBoundingClientRect(),i=Math.min(p.width/U.naturalWidth,p.height/U.naturalHeight),O=U.naturalWidth*i,C=U.naturalHeight*i,K=p.left+(p.width-O)/2,de=p.top+(p.height-C)/2,ne=A.clientX-K,ve=A.clientY-de;if(ne<0||ve<0||ne>O||ve>C)return;const W={xPercent:Math.max(0,Math.min(100,ne/O*100)),yPercent:Math.max(0,Math.min(100,ve/C*100)),stageXPercent:(A.clientX-D.left)/D.width*100,stageYPercent:(A.clientY-D.top)/D.height*100,inspecting:l&&s!=="pcb-3d"};if(N(W),S.current?.abort(),!W.inspecting)return;const X=new AbortController;S.current=X,Kh(n,s,W.xPercent,W.yPercent,X.signal).then(L=>N(F=>F===W?{...F,inspection:L,inspecting:!1}:F)).catch(()=>{X.signal.aborted||N(L=>L===W?{...L,inspection:{available:!1},inspecting:!1}:L)})},E=l?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:E.map(A=>e.jsx("button",{type:"button",onClick:()=>u(A),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${A===s?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:no(A)},A))}),e.jsx("button",{type:"button",onClick:h,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:g("rightSidebar.edaRefresh"),"aria-label":g("rightSidebar.edaRefresh"),children:e.jsx(_i,{size:13})})]}),l&&m?e.jsx("div",{className:s==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:m}):null,l?s==="pcb-3d"?m?null:e.jsx("div",{className:"min-h-0 flex-1"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:b,role:"button",tabIndex:0,onClick:$,onKeyDown:A=>{A.key!=="Enter"&&A.key!==" "||(A.preventDefault(),N({xPercent:50,yPercent:50,stageXPercent:50,stageYPercent:50}))},className:"relative min-h-0 flex-1 cursor-crosshair overflow-hidden bg-surface p-3 outline-none",title:g("rightSidebar.edaPickHint"),children:[e.jsx("img",{ref:f,src:r,alt:`${n} ${no(s)}`,onLoad:()=>_(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${I?"opacity-100":"opacity-0"}`}),y&&e.jsx("span",{className:"pointer-events-none absolute h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-surface shadow-sm",style:{left:`${y.stageXPercent}%`,top:`${y.stageYPercent}%`}}),y&&B&&e.jsx(bo,{anchor:{xPercent:y.stageXPercent,yPercent:y.stageYPercent},disabled:y.inspecting,title:g("rightSidebar.edaInsertAnnotation"),onClick:()=>{d?.(B,`eda:${s}:${y.xPercent.toFixed(1)}:${y.yPercent.toFixed(1)}`,{snapshot:f.current?mp(f.current,y):Promise.resolve(null)}),N(null)},children:g("rightSidebar.edaInsertAnnotation")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:y?y.inspecting?g("rightSidebar.edaInspecting"):y.inspection?.available?g("rightSidebar.edaPickedBoardPosition",{x:y.inspection.xMm?.toFixed(2)??"—",y:y.inspection.yMm?.toFixed(2)??"—",object:y.inspection.nearest?.label??g("rightSidebar.edaNoNearbyObject")}):g("rightSidebar.edaPickedPosition",{x:y.xPercent.toFixed(1),y:y.yPercent.toFixed(1)}):g("rightSidebar.edaPickHint")})})]}):e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx($u,{blobUrl:r,filePath:n,viewLabel:no(s),onInsertAnnotation:d})})]})}function og(r){const n=[];let s=[],l="",u=!1;for(let d=0;d<r.length;d+=1){const h=r[d];u?h==='"'&&r[d+1]==='"'?(l+='"',d+=1):h==='"'?u=!1:l+=h:h==='"'?u=!0:h===","?(s.push(l),l=""):h===`
|
|
14
|
+
`?(s.push(l.replace(/\r$/,"")),n.push(s),s=[],l=""):l+=h}return(l||s.length>0)&&(s.push(l.replace(/\r$/,"")),n.push(s)),n}function ig(r,n,s,l,u){const d=n[u]||`第${u+1}列`,h=s[u]??"",m=n.map((g,b)=>`${g||`第${b+1}列`}=${s[b]??""}`).join(";");return`"表格标注: ${r} / 数据行: ${l+1} / 列: ${d} / 值: ${h} / 记录: ${m}"`}function lg({content:r,filePath:n,onInsertAnnotation:s}){const{t:l}=kt(),u=a.useMemo(()=>og(r),[r]),d=u[0]??[],h=u.slice(1),m=a.useRef(null),[g,b]=a.useState(null),f=g?h[g.row]:null,S=g&&f?ig(n,d,f,g.row+1,g.column):null;return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[e.jsxs("div",{ref:m,className:"relative min-h-0 flex-1",children:[e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("table",{className:"min-w-full border-separate border-spacing-0 text-left text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 top-0 z-20 border-b border-r border-border/20 bg-surface-elevated px-2 py-2 text-[10px] font-semibold text-muted-foreground",children:"#"}),d.map((y,N)=>e.jsx("th",{className:"sticky top-0 z-10 min-w-28 border-b border-r border-border/20 bg-surface-elevated px-3 py-2 font-semibold text-foreground",children:y||l("rightSidebar.csvUnnamedColumn",{index:N+1})},`${y}:${N}`))]})}),e.jsx("tbody",{children:h.map((y,N)=>e.jsxs("tr",{className:"hover:bg-surface-2",children:[e.jsx("th",{className:"sticky left-0 z-10 border-b border-r border-border/15 bg-surface px-2 py-2 text-right text-[10px] font-normal text-muted-foreground",children:N+1}),d.map((I,_)=>{const B=g?.row===N&&g.column===_;return e.jsx("td",{className:`border-b border-r border-border/15 p-0 ${B?"bg-primary/15":""}`,children:e.jsx("button",{type:"button",onClick:$=>{const E=m.current?.getBoundingClientRect(),A=$.currentTarget.getBoundingClientRect();if(!E?.width||!E.height)return;const T=$.clientX||A.left+A.width/2,U=$.clientY||A.top+A.height/2;b({row:N,column:_,xPercent:(T-E.left)/E.width*100,yPercent:(U-E.top)/E.height*100})},className:"block h-full min-h-9 w-full whitespace-pre-wrap px-3 py-2 text-left text-foreground outline-none hover:bg-primary/10 focus-visible:bg-primary/10",children:y[_]||" "})},`cell:${N}:${_}`)})]},`row:${N}`))})]})}),g&&S&&e.jsx(bo,{anchor:{xPercent:g.xPercent,yPercent:g.yPercent},title:l("rightSidebar.csvInsertAnnotation"),onClick:()=>{s?.(S,`csv:${n}:${g.row+1}:${g.column+1}`),b(null)},children:l("rightSidebar.csvInsertAnnotation")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:g&&f?l("rightSidebar.csvSelectedCell",{row:g.row+1,column:d[g.column]||g.column+1}):l("rightSidebar.csvPickHint",{rows:h.length,columns:d.length})})})]})}function qn(r,n){let s=r;for(const l of n){if(!s||typeof s!="object")return;s=s[l]}return s}function cg(r,n){const s=JSON.parse(r),l=qn(s,["meta","version"]);if(n)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(l??"未知")},{label:"活动层编号",value:String(qn(s,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(qn(s,["board","visible_layers"])??"未知")},{label:"Git 集成",value:qn(s,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const u=qn(s,["net_settings","classes"]),d=Array.isArray(u)?u.find(m=>m&&typeof m=="object"&&m.name==="Default"):void 0,h=qn(s,["board","design_settings","drc_exclusions"]);return[{label:"文件性质",value:"KiCad 工程配置"},{label:"格式版本",value:String(l??"未知")},{label:"网络类数量",value:String(Array.isArray(u)?u.length:0)},{label:"默认间距",value:d?.clearance!==void 0?`${d.clearance} mm`:"未设置"},{label:"默认线宽",value:d?.track_width!==void 0?`${d.track_width} mm`:"未设置"},{label:"默认过孔",value:d?.via_diameter!==void 0?`${d.via_diameter} / ${d.via_drill??"—"} mm(外径/钻孔)`:"未设置"},{label:"DRC 排除项",value:String(Array.isArray(h)?h.length:0)}]}function dg(r,n){return`"KiCad项目标注: ${r} / 项: ${n.label} / 值: ${n.value}"`}function ug({content:r,filePath:n,localState:s,onInsertAnnotation:l}){const{t:u}=kt(),d=a.useRef(null),[h,m]=a.useState(null),g=a.useMemo(()=>{try{return{items:cg(r,s),error:null}}catch(f){return{items:[],error:f instanceof Error?f.message:String(f)}}},[r,s]),b=h===null?null:g.items[h.index];return g.error?e.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-3 font-mono text-xs text-foreground",children:r}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[s&&e.jsx("div",{className:"border-b border-[color:var(--warning)]/20 bg-[color:var(--warning)]/5 px-3 py-2 text-xs text-[color:var(--warning)]",children:u("rightSidebar.kicadLocalStateNotice")}),e.jsxs("div",{ref:d,className:"relative min-h-0 flex-1",children:[e.jsxs("div",{className:"h-full overflow-auto px-3 py-2",children:[e.jsx("div",{className:"divide-y divide-border/15",children:g.items.map((f,S)=>e.jsxs("button",{type:"button",onClick:y=>{const N=d.current?.getBoundingClientRect(),I=y.currentTarget.getBoundingClientRect();if(!N?.width||!N.height)return;const _=y.clientX||I.left+I.width/2,B=y.clientY||I.top+I.height/2;m({index:S,xPercent:(_-N.left)/N.width*100,yPercent:(B-N.top)/N.height*100})},className:`grid w-full grid-cols-[minmax(7rem,0.8fr)_minmax(0,1.4fr)] gap-3 px-2 py-3 text-left transition hover:bg-surface-2 ${h?.index===S?"bg-primary/10":""}`,children:[e.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:f.label}),e.jsx("span",{className:"break-words text-xs text-foreground",children:f.value})]},f.label))}),e.jsxs("details",{className:"mt-3 border-t border-border/15 pt-3",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-semibold text-muted-foreground",children:u("rightSidebar.kicadShowRawJson")}),e.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre p-2 font-mono text-[10px] leading-relaxed text-foreground",children:r})]})]}),b&&h&&e.jsx(bo,{anchor:{xPercent:h.xPercent,yPercent:h.yPercent},title:u("rightSidebar.kicadInsertSetting"),onClick:()=>{l?.(dg(n,b),`kicad-project:${n}:${b.label}`),m(null)},children:u("rightSidebar.kicadInsertSetting")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:b?`${b.label}: ${b.value}`:u("rightSidebar.kicadProjectPickHint")})})]})}const fg=`/** ES Module Shims Wasm @version 2.8.4 */
|
|
15
|
+
(function () {
|
|
16
|
+
|
|
17
|
+
const self_ = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
18
|
+
|
|
19
|
+
let invalidate;
|
|
20
|
+
const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
|
|
21
|
+
const initHotReload = (topLevelLoad, importShim) => {
|
|
22
|
+
let _importHook = importHook,
|
|
23
|
+
_resolveHook = resolveHook,
|
|
24
|
+
_metaHook = metaHook;
|
|
25
|
+
|
|
26
|
+
let defaultResolve;
|
|
27
|
+
let hotResolveHook = (id, parent, _defaultResolve) => {
|
|
28
|
+
if (!defaultResolve) defaultResolve = _defaultResolve;
|
|
29
|
+
const originalParent = stripVersion(parent);
|
|
30
|
+
const url = stripVersion(defaultResolve(id, originalParent));
|
|
31
|
+
const hotState = getHotState(url);
|
|
32
|
+
const parents = hotState.p;
|
|
33
|
+
if (!parents.includes(originalParent)) parents.push(originalParent);
|
|
34
|
+
return toVersioned(url, hotState);
|
|
35
|
+
};
|
|
36
|
+
const hotImportHook = (url, _, __, source, sourceType) => {
|
|
37
|
+
const hotState = getHotState(url);
|
|
38
|
+
hotState.e = typeof source === 'string' ? source : true;
|
|
39
|
+
hotState.t = sourceType;
|
|
40
|
+
};
|
|
41
|
+
const hotMetaHook = (metaObj, url) => (metaObj.hot = new Hot(url));
|
|
42
|
+
|
|
43
|
+
const Hot = class Hot {
|
|
44
|
+
constructor(url) {
|
|
45
|
+
this.data = getHotState((this.url = stripVersion(url))).d;
|
|
46
|
+
}
|
|
47
|
+
accept(deps, cb) {
|
|
48
|
+
if (typeof deps === 'function') {
|
|
49
|
+
cb = deps;
|
|
50
|
+
deps = null;
|
|
51
|
+
}
|
|
52
|
+
const hotState = getHotState(this.url);
|
|
53
|
+
if (!hotState.A) return;
|
|
54
|
+
(hotState.a = hotState.a || []).push([
|
|
55
|
+
typeof deps === 'string' ? defaultResolve(deps, this.url)
|
|
56
|
+
: deps ? deps.map(d => defaultResolve(d, this.url))
|
|
57
|
+
: null,
|
|
58
|
+
cb
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
dispose(cb) {
|
|
62
|
+
getHotState(this.url).u = cb;
|
|
63
|
+
}
|
|
64
|
+
invalidate() {
|
|
65
|
+
const hotState = getHotState(this.url);
|
|
66
|
+
hotState.a = hotState.A = null;
|
|
67
|
+
const seen = [this.url];
|
|
68
|
+
hotState.p.forEach(p => invalidate(p, this.url, seen));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const versionedRegEx = /\\?v=\\d+$/;
|
|
73
|
+
const stripVersion = url => {
|
|
74
|
+
const versionMatch = url.match(versionedRegEx);
|
|
75
|
+
return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const toVersioned = (url, hotState) => {
|
|
79
|
+
const { v } = hotState;
|
|
80
|
+
return url + (v ? '?v=' + v : '');
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
let hotRegistry = {},
|
|
84
|
+
curInvalidationRoots = new Set(),
|
|
85
|
+
curInvalidationInterval;
|
|
86
|
+
const getHotState = url =>
|
|
87
|
+
hotRegistry[url] ||
|
|
88
|
+
(hotRegistry[url] = {
|
|
89
|
+
// version
|
|
90
|
+
v: 0,
|
|
91
|
+
// accept list ([deps, cb] pairs)
|
|
92
|
+
a: null,
|
|
93
|
+
// accepting acceptors
|
|
94
|
+
A: true,
|
|
95
|
+
// unload callback
|
|
96
|
+
u: null,
|
|
97
|
+
// entry point or inline script source
|
|
98
|
+
e: false,
|
|
99
|
+
// hot data
|
|
100
|
+
d: {},
|
|
101
|
+
// parents
|
|
102
|
+
p: [],
|
|
103
|
+
// source type
|
|
104
|
+
t: undefined
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
invalidate = (url, fromUrl, seen = []) => {
|
|
108
|
+
const hotState = hotRegistry[url];
|
|
109
|
+
if (!hotState || seen.includes(url)) return false;
|
|
110
|
+
seen.push(url);
|
|
111
|
+
hotState.A = false;
|
|
112
|
+
if (
|
|
113
|
+
fromUrl &&
|
|
114
|
+
hotState.a &&
|
|
115
|
+
hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
|
|
116
|
+
) {
|
|
117
|
+
curInvalidationRoots.add(fromUrl);
|
|
118
|
+
} else {
|
|
119
|
+
if (hotState.e || hotState.a) curInvalidationRoots.add(url);
|
|
120
|
+
hotState.v++;
|
|
121
|
+
if (!hotState.a) hotState.p.forEach(p => invalidate(p, url, seen));
|
|
122
|
+
}
|
|
123
|
+
if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
|
|
124
|
+
return true;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const handleInvalidations = () => {
|
|
128
|
+
curInvalidationInterval = null;
|
|
129
|
+
const earlyRoots = new Set();
|
|
130
|
+
for (const root of curInvalidationRoots) {
|
|
131
|
+
const hotState = hotRegistry[root];
|
|
132
|
+
topLevelLoad(
|
|
133
|
+
toVersioned(root, hotState),
|
|
134
|
+
baseUrl,
|
|
135
|
+
defaultFetchOpts,
|
|
136
|
+
typeof hotState.e === 'string' ? hotState.e : undefined,
|
|
137
|
+
false,
|
|
138
|
+
undefined,
|
|
139
|
+
hotState.t
|
|
140
|
+
).then(m => {
|
|
141
|
+
if (hotState.a) {
|
|
142
|
+
hotState.a.forEach(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
|
|
143
|
+
// unload should be the latest unload handler from the just loaded module
|
|
144
|
+
if (hotState.u) {
|
|
145
|
+
hotState.u(hotState.d);
|
|
146
|
+
hotState.u = null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
hotState.p.forEach(p => {
|
|
150
|
+
const hotState = hotRegistry[p];
|
|
151
|
+
if (hotState && hotState.a)
|
|
152
|
+
hotState.a.forEach(
|
|
153
|
+
async ([d, c]) =>
|
|
154
|
+
d &&
|
|
155
|
+
!earlyRoots.has(c) &&
|
|
156
|
+
(typeof d === 'string' ?
|
|
157
|
+
d === root && c(m)
|
|
158
|
+
: c(await Promise.all(d.map(d => (earlyRoots.add(c), importShim(toVersioned(d, getHotState(d))))))))
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
}, throwError);
|
|
162
|
+
}
|
|
163
|
+
curInvalidationRoots = new Set();
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
setHooks(
|
|
167
|
+
_importHook ? chain(_importHook, hotImportHook) : hotImportHook,
|
|
168
|
+
_resolveHook ?
|
|
169
|
+
(id, parent, defaultResolve) =>
|
|
170
|
+
hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
|
|
171
|
+
: hotResolveHook,
|
|
172
|
+
_metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const hasDocument = typeof document !== 'undefined';
|
|
177
|
+
|
|
178
|
+
const noop = () => {};
|
|
179
|
+
|
|
180
|
+
const chain = (a, b) =>
|
|
181
|
+
function () {
|
|
182
|
+
a.apply(this, arguments);
|
|
183
|
+
b.apply(this, arguments);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const dynamicImport = (u, _errUrl) => import(u);
|
|
187
|
+
|
|
188
|
+
const defineValue = (obj, prop, value) =>
|
|
189
|
+
Object.defineProperty(obj, prop, { writable: false, configurable: false, value });
|
|
190
|
+
|
|
191
|
+
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
192
|
+
|
|
193
|
+
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
194
|
+
Object.assign(esmsInitOptions, self_.esmsInitOptions || {});
|
|
195
|
+
|
|
196
|
+
const version = "2.8.4";
|
|
197
|
+
|
|
198
|
+
const r$1 = esmsInitOptions.version;
|
|
199
|
+
if (self_.importShim || (r$1 && r$1 !== version)) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// shim mode is determined on initialization, no late shim mode
|
|
204
|
+
const shimMode =
|
|
205
|
+
esmsInitOptions.shimMode ||
|
|
206
|
+
(hasDocument ?
|
|
207
|
+
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
208
|
+
.length > 0
|
|
209
|
+
// Without a document, shim mode is always true as we cannot polyfill
|
|
210
|
+
: true);
|
|
211
|
+
|
|
212
|
+
let importHook,
|
|
213
|
+
resolveHook,
|
|
214
|
+
fetchHook = fetch,
|
|
215
|
+
sourceHook,
|
|
216
|
+
metaHook,
|
|
217
|
+
tsTransform =
|
|
218
|
+
esmsInitOptions.tsTransform ||
|
|
219
|
+
(hasDocument && document.currentScript && document.currentScript.src.replace(/(\\.\\w+)?\\.js$/, '-typescript.js')) ||
|
|
220
|
+
'./es-module-shims-typescript.js';
|
|
221
|
+
|
|
222
|
+
const defaultFetchOpts = { credentials: 'same-origin' };
|
|
223
|
+
|
|
224
|
+
const globalHook = name => (typeof name === 'string' ? self_[name] : name);
|
|
225
|
+
|
|
226
|
+
if (esmsInitOptions.onimport) importHook = globalHook(esmsInitOptions.onimport);
|
|
227
|
+
if (esmsInitOptions.resolve) resolveHook = globalHook(esmsInitOptions.resolve);
|
|
228
|
+
if (esmsInitOptions.fetch) fetchHook = globalHook(esmsInitOptions.fetch);
|
|
229
|
+
if (esmsInitOptions.source) sourceHook = globalHook(esmsInitOptions.source);
|
|
230
|
+
if (esmsInitOptions.meta) metaHook = globalHook(esmsInitOptions.meta);
|
|
231
|
+
|
|
232
|
+
const hasCustomizationHooks = importHook || resolveHook || fetchHook !== fetch || sourceHook || metaHook;
|
|
233
|
+
|
|
234
|
+
const {
|
|
235
|
+
noLoadEventRetriggers,
|
|
236
|
+
enforceIntegrity,
|
|
237
|
+
hotReload,
|
|
238
|
+
hotReloadInterval = 100,
|
|
239
|
+
nativePassthrough = !hasCustomizationHooks && !hotReload
|
|
240
|
+
} = esmsInitOptions;
|
|
241
|
+
|
|
242
|
+
const setHooks = (importHook_, resolveHook_, metaHook_) => (
|
|
243
|
+
(importHook = importHook_),
|
|
244
|
+
(resolveHook = resolveHook_),
|
|
245
|
+
(metaHook = metaHook_)
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
const mapOverrides = esmsInitOptions.mapOverrides;
|
|
249
|
+
|
|
250
|
+
let nonce = esmsInitOptions.nonce;
|
|
251
|
+
if (!nonce && hasDocument) {
|
|
252
|
+
const nonceElement = document.querySelector('script[nonce]');
|
|
253
|
+
if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const onerror = globalHook(esmsInitOptions.onerror || console.error.bind(console));
|
|
257
|
+
|
|
258
|
+
const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
|
|
259
|
+
const disable = Array.isArray(esmsInitOptions.polyfillDisable) ? esmsInitOptions.polyfillDisable : [];
|
|
260
|
+
|
|
261
|
+
const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
|
|
262
|
+
const wasmInstancePhaseEnabled =
|
|
263
|
+
enable.includes('wasm-modules') || enable.includes('wasm-module-instances') || enableAll;
|
|
264
|
+
const wasmSourcePhaseEnabled =
|
|
265
|
+
enable.includes('wasm-modules') || enable.includes('wasm-module-sources') || enableAll;
|
|
266
|
+
const deferPhaseEnabled = enable.includes('import-defer') || enableAll;
|
|
267
|
+
const cssModulesEnabled = !disable.includes('css-modules');
|
|
268
|
+
const jsonModulesEnabled = !disable.includes('json-modules');
|
|
269
|
+
|
|
270
|
+
const onpolyfill =
|
|
271
|
+
esmsInitOptions.onpolyfill ?
|
|
272
|
+
globalHook(esmsInitOptions.onpolyfill)
|
|
273
|
+
: () => {
|
|
274
|
+
console.log(\`%c^^ Module error above is polyfilled and can be ignored ^^\`, 'font-weight:900;color:#391');
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const baseUrl =
|
|
278
|
+
hasDocument ? document.baseURI
|
|
279
|
+
: typeof location !== 'undefined' ?
|
|
280
|
+
\`\${location.protocol}//\${location.host}\${
|
|
281
|
+
location.pathname.includes('/') ?
|
|
282
|
+
location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
|
|
283
|
+
: location.pathname
|
|
284
|
+
}\`
|
|
285
|
+
: 'about:blank';
|
|
286
|
+
|
|
287
|
+
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
|
|
288
|
+
let { skip } = esmsInitOptions;
|
|
289
|
+
if (Array.isArray(skip)) {
|
|
290
|
+
const l = skip.map(s => new URL(s, baseUrl).href);
|
|
291
|
+
skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
|
|
292
|
+
} else if (typeof skip === 'string') {
|
|
293
|
+
const r = new RegExp(skip);
|
|
294
|
+
skip = s => r.test(s);
|
|
295
|
+
} else if (skip instanceof RegExp) {
|
|
296
|
+
skip = s => skip.test(s);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const dispatchError = error => self_.dispatchEvent(Object.assign(new Event('error'), { error }));
|
|
300
|
+
|
|
301
|
+
const throwError = err => {
|
|
302
|
+
(self_.reportError || dispatchError)(err);
|
|
303
|
+
onerror(err);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
const fromParent = parent => (parent ? \` imported from \${parent}\` : '');
|
|
307
|
+
|
|
308
|
+
const backslashRegEx = /\\\\/g;
|
|
309
|
+
|
|
310
|
+
const asURL = url => {
|
|
311
|
+
try {
|
|
312
|
+
if (url.indexOf(':') !== -1) return new URL(url).href;
|
|
313
|
+
} catch (_) {}
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const resolveUrl = (relUrl, parentUrl) =>
|
|
317
|
+
resolveIfNotPlainOrUrl(relUrl, parentUrl) || asURL(relUrl) || resolveIfNotPlainOrUrl('./' + relUrl, parentUrl);
|
|
318
|
+
|
|
319
|
+
const resolveIfNotPlainOrUrl = (relUrl, parentUrl) => {
|
|
320
|
+
const hIdx = parentUrl.indexOf('#'),
|
|
321
|
+
qIdx = parentUrl.indexOf('?');
|
|
322
|
+
if (hIdx + qIdx > -2)
|
|
323
|
+
parentUrl = parentUrl.slice(
|
|
324
|
+
0,
|
|
325
|
+
hIdx === -1 ? qIdx
|
|
326
|
+
: qIdx === -1 || qIdx > hIdx ? hIdx
|
|
327
|
+
: qIdx
|
|
328
|
+
);
|
|
329
|
+
if (relUrl.indexOf('\\\\') !== -1) relUrl = relUrl.replace(backslashRegEx, '/');
|
|
330
|
+
// protocol-relative
|
|
331
|
+
if (relUrl[0] === '/' && relUrl[1] === '/') {
|
|
332
|
+
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
|
|
333
|
+
}
|
|
334
|
+
// relative-url
|
|
335
|
+
else if (
|
|
336
|
+
(relUrl[0] === '.' &&
|
|
337
|
+
(relUrl[1] === '/' ||
|
|
338
|
+
(relUrl[1] === '.' && (relUrl[2] === '/' || (relUrl.length === 2 && (relUrl += '/')))) ||
|
|
339
|
+
(relUrl.length === 1 && (relUrl += '/')))) ||
|
|
340
|
+
relUrl[0] === '/'
|
|
341
|
+
) {
|
|
342
|
+
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
|
|
343
|
+
if (parentProtocol === 'blob:') {
|
|
344
|
+
throw new TypeError(
|
|
345
|
+
\`Failed to resolve module specifier "\${relUrl}". Invalid relative url or base scheme isn't hierarchical.\`
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
// Disabled, but these cases will give inconsistent results for deep backtracking
|
|
349
|
+
//if (parentUrl[parentProtocol.length] !== '/')
|
|
350
|
+
// throw new Error('Cannot resolve');
|
|
351
|
+
// read pathname from parent URL
|
|
352
|
+
// pathname taken to be part after leading "/"
|
|
353
|
+
let pathname;
|
|
354
|
+
if (parentUrl[parentProtocol.length + 1] === '/') {
|
|
355
|
+
// resolving to a :// so we need to read out the auth and host
|
|
356
|
+
if (parentProtocol !== 'file:') {
|
|
357
|
+
pathname = parentUrl.slice(parentProtocol.length + 2);
|
|
358
|
+
pathname = pathname.slice(pathname.indexOf('/') + 1);
|
|
359
|
+
} else {
|
|
360
|
+
pathname = parentUrl.slice(8);
|
|
361
|
+
}
|
|
362
|
+
} else {
|
|
363
|
+
// resolving to :/ so pathname is the /... part
|
|
364
|
+
pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (relUrl[0] === '/') return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
|
|
368
|
+
|
|
369
|
+
// join together and split for removal of .. and . segments
|
|
370
|
+
// looping the string instead of anything fancy for perf reasons
|
|
371
|
+
// '../../../../../z' resolved to 'x/y' is just 'z'
|
|
372
|
+
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
|
|
373
|
+
|
|
374
|
+
const output = [];
|
|
375
|
+
let segmentIndex = -1;
|
|
376
|
+
for (let i = 0; i < segmented.length; i++) {
|
|
377
|
+
// busy reading a segment - only terminate on '/'
|
|
378
|
+
if (segmentIndex !== -1) {
|
|
379
|
+
if (segmented[i] === '/') {
|
|
380
|
+
output.push(segmented.slice(segmentIndex, i + 1));
|
|
381
|
+
segmentIndex = -1;
|
|
382
|
+
}
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
// new segment - check if it is relative
|
|
386
|
+
else if (segmented[i] === '.') {
|
|
387
|
+
// ../ segment
|
|
388
|
+
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
|
|
389
|
+
output.pop();
|
|
390
|
+
i += 2;
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
// ./ segment
|
|
394
|
+
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
|
|
395
|
+
i += 1;
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
// it is the start of a new segment
|
|
400
|
+
while (segmented[i] === '/') i++;
|
|
401
|
+
segmentIndex = i;
|
|
402
|
+
}
|
|
403
|
+
// finish reading out the last segment
|
|
404
|
+
if (segmentIndex !== -1) output.push(segmented.slice(segmentIndex));
|
|
405
|
+
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
const resolveAndComposeImportMap = (json, baseUrl, parentMap) => {
|
|
410
|
+
const outMap = {
|
|
411
|
+
imports: { ...parentMap.imports },
|
|
412
|
+
scopes: { ...parentMap.scopes },
|
|
413
|
+
integrity: { ...parentMap.integrity }
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
if (json.imports) resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
|
417
|
+
|
|
418
|
+
if (json.scopes)
|
|
419
|
+
for (let s in json.scopes) {
|
|
420
|
+
const resolvedScope = resolveUrl(s, baseUrl);
|
|
421
|
+
resolveAndComposePackages(
|
|
422
|
+
json.scopes[s],
|
|
423
|
+
outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}),
|
|
424
|
+
baseUrl,
|
|
425
|
+
parentMap
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (json.integrity) resolveAndComposeIntegrity(json.integrity, outMap.integrity, baseUrl);
|
|
430
|
+
|
|
431
|
+
return outMap;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
const getMatch = (path, matchObj) => {
|
|
435
|
+
if (matchObj[path]) return path;
|
|
436
|
+
let sepIndex = path.length;
|
|
437
|
+
do {
|
|
438
|
+
const segment = path.slice(0, sepIndex + 1);
|
|
439
|
+
if (segment in matchObj) return segment;
|
|
440
|
+
} while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1);
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
const applyPackages = (id, packages) => {
|
|
444
|
+
const pkgName = getMatch(id, packages);
|
|
445
|
+
if (pkgName) {
|
|
446
|
+
const pkg = packages[pkgName];
|
|
447
|
+
if (pkg === null) return;
|
|
448
|
+
return pkg + id.slice(pkgName.length);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
const resolveImportMap = (importMap, resolvedOrPlain, parentUrl) => {
|
|
453
|
+
let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
|
|
454
|
+
while (scopeUrl) {
|
|
455
|
+
const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
|
|
456
|
+
if (packageResolution) return packageResolution;
|
|
457
|
+
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
|
|
458
|
+
}
|
|
459
|
+
return applyPackages(resolvedOrPlain, importMap.imports) || (resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain);
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
const resolveAndComposePackages = (packages, outPackages, baseUrl, parentMap) => {
|
|
463
|
+
for (let p in packages) {
|
|
464
|
+
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
465
|
+
if (
|
|
466
|
+
(!shimMode || !mapOverrides) &&
|
|
467
|
+
outPackages[resolvedLhs] &&
|
|
468
|
+
outPackages[resolvedLhs] !== packages[resolvedLhs]
|
|
469
|
+
) {
|
|
470
|
+
console.warn(
|
|
471
|
+
\`es-module-shims: Rejected map override "\${resolvedLhs}" from \${outPackages[resolvedLhs]} to \${packages[resolvedLhs]}.\`
|
|
472
|
+
);
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
let target = packages[p];
|
|
476
|
+
if (typeof target !== 'string') continue;
|
|
477
|
+
const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
|
|
478
|
+
if (mapped) {
|
|
479
|
+
outPackages[resolvedLhs] = mapped;
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
console.warn(\`es-module-shims: Mapping "\${p}" -> "\${packages[p]}" does not resolve\`);
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
const resolveAndComposeIntegrity = (integrity, outIntegrity, baseUrl) => {
|
|
487
|
+
for (let p in integrity) {
|
|
488
|
+
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
489
|
+
if (
|
|
490
|
+
(!shimMode || !mapOverrides) &&
|
|
491
|
+
outIntegrity[resolvedLhs] &&
|
|
492
|
+
outIntegrity[resolvedLhs] !== integrity[resolvedLhs]
|
|
493
|
+
) {
|
|
494
|
+
console.warn(
|
|
495
|
+
\`es-module-shims: Rejected map integrity override "\${resolvedLhs}" from \${outIntegrity[resolvedLhs]} to \${integrity[resolvedLhs]}.\`
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
outIntegrity[resolvedLhs] = integrity[p];
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
let policy;
|
|
503
|
+
if (
|
|
504
|
+
typeof self !== 'undefined' &&
|
|
505
|
+
(typeof self.trustedTypes !== 'undefined' || typeof self.TrustedTypes !== 'undefined')
|
|
506
|
+
) {
|
|
507
|
+
try {
|
|
508
|
+
policy = (self.trustedTypes || self.TrustedTypes).createPolicy('es-module-shims', {
|
|
509
|
+
createHTML: html => html,
|
|
510
|
+
createScript: script => script
|
|
511
|
+
});
|
|
512
|
+
} catch {}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function maybeTrustedInnerHTML(html) {
|
|
516
|
+
return policy ? policy.createHTML(html) : html;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function maybeTrustedScript(script) {
|
|
520
|
+
return policy ? policy.createScript(script) : script;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// support browsers without dynamic import support (eg Firefox 6x)
|
|
524
|
+
let supportsJsonType = false;
|
|
525
|
+
let supportsCssType = false;
|
|
526
|
+
|
|
527
|
+
const supports = hasDocument && HTMLScriptElement.supports;
|
|
528
|
+
|
|
529
|
+
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
|
530
|
+
let supportsWasmInstancePhase = false;
|
|
531
|
+
let supportsWasmSourcePhase = false;
|
|
532
|
+
let supportsMultipleImportMaps = false;
|
|
533
|
+
|
|
534
|
+
const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
|
|
535
|
+
|
|
536
|
+
let featureDetectionPromise = (async function () {
|
|
537
|
+
// In shim mode, feature detection results are unused — skip the iframe overhead
|
|
538
|
+
if (shimMode) return;
|
|
539
|
+
if (!hasDocument)
|
|
540
|
+
return Promise.all([
|
|
541
|
+
import(createBlob(\`import"\${createBlob('{}', 'text/json')}"with{type:"json"}\`)).then(
|
|
542
|
+
() => (
|
|
543
|
+
(supportsJsonType = true),
|
|
544
|
+
import(createBlob(\`import"\${createBlob('', 'text/css')}"with{type:"css"}\`)).then(
|
|
545
|
+
() => (supportsCssType = true),
|
|
546
|
+
noop
|
|
547
|
+
)
|
|
548
|
+
),
|
|
549
|
+
noop
|
|
550
|
+
),
|
|
551
|
+
wasmInstancePhaseEnabled &&
|
|
552
|
+
import(createBlob(\`import"\${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"\`)).then(
|
|
553
|
+
() => (supportsWasmInstancePhase = true),
|
|
554
|
+
noop
|
|
555
|
+
),
|
|
556
|
+
wasmSourcePhaseEnabled &&
|
|
557
|
+
import(createBlob(\`import source x from"\${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"\`)).then(
|
|
558
|
+
() => (supportsWasmSourcePhase = true),
|
|
559
|
+
noop
|
|
560
|
+
)
|
|
561
|
+
]);
|
|
562
|
+
|
|
563
|
+
const msgTag = \`s\${version}\`;
|
|
564
|
+
return new Promise(resolve => {
|
|
565
|
+
const iframe = document.createElement('iframe');
|
|
566
|
+
iframe.style.display = 'none';
|
|
567
|
+
iframe.setAttribute('nonce', nonce);
|
|
568
|
+
function cb({ data }) {
|
|
569
|
+
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === msgTag;
|
|
570
|
+
if (!isFeatureDetectionMessage) return;
|
|
571
|
+
[
|
|
572
|
+
,
|
|
573
|
+
supportsImportMaps,
|
|
574
|
+
supportsMultipleImportMaps,
|
|
575
|
+
supportsJsonType,
|
|
576
|
+
supportsCssType,
|
|
577
|
+
supportsWasmSourcePhase,
|
|
578
|
+
supportsWasmInstancePhase
|
|
579
|
+
] = data;
|
|
580
|
+
resolve();
|
|
581
|
+
document.head.removeChild(iframe);
|
|
582
|
+
window.removeEventListener('message', cb, false);
|
|
583
|
+
}
|
|
584
|
+
window.addEventListener('message', cb, false);
|
|
585
|
+
// Feature checking with careful avoidance of unnecessary work - all gated on initial import map supports check. CSS gates on JSON feature check, Wasm instance phase gates on wasm source phase check.
|
|
586
|
+
const importMapTest = \`<script nonce=\${nonce || ''}>\${
|
|
587
|
+
policy ? 't=(window.trustedTypes||window.TrustedTypes).createPolicy("es-module-shims",{createScript:s=>s});' : ''
|
|
588
|
+
}b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));c=u=>import(u).then(()=>true,()=>false);i=innerText=>document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"\${nonce}",text:\${
|
|
589
|
+
policy ? 't.createScript(innerText)' : 'innerText'
|
|
590
|
+
}}));i(\\\`{"imports":{"x":"\\\${b('')}"}}\\\`);i(\\\`{"imports":{"y":"\\\${b('')}"}}\\\`);cm=\${
|
|
591
|
+
supportsImportMaps && jsonModulesEnabled ? \`c(b(\\\`import"\\\${b('{}','text/json')}"with{type:"json"}\\\`))\` : 'false'
|
|
592
|
+
};sp=\${
|
|
593
|
+
supportsImportMaps && wasmSourcePhaseEnabled ?
|
|
594
|
+
\`c(b(\\\`import source x from "\\\${b(new Uint8Array(\${JSON.stringify(wasmBytes)}),'application/wasm')\\}"\\\`))\`
|
|
595
|
+
: 'false'
|
|
596
|
+
};Promise.all([\${supportsImportMaps ? 'true' : "c('x')"},\${supportsImportMaps ? "c('y')" : false},cm,\${
|
|
597
|
+
supportsImportMaps && cssModulesEnabled ?
|
|
598
|
+
\`cm.then(s=>s?c(b(\\\`import"\\\${b('','text/css')\\}"with{type:"css"}\\\`)):false)\`
|
|
599
|
+
: 'false'
|
|
600
|
+
},sp,\${
|
|
601
|
+
supportsImportMaps && wasmInstancePhaseEnabled ?
|
|
602
|
+
\`\${wasmSourcePhaseEnabled ? 'sp.then(s=>s?' : ''}c(b(\\\`import"\\\${b(new Uint8Array(\${JSON.stringify(wasmBytes)}),'application/wasm')\\}"\\\`))\${wasmSourcePhaseEnabled ? ':false)' : ''}\`
|
|
603
|
+
: 'false'
|
|
604
|
+
}]).then(a=>parent.postMessage(['\${msgTag}'].concat(a),'*'))<\${''}/script>\`;
|
|
605
|
+
|
|
606
|
+
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
607
|
+
// path to trigger before setting srcdoc, therefore we track the timing
|
|
608
|
+
let readyForOnload = false,
|
|
609
|
+
onloadCalledWhileNotReady = false;
|
|
610
|
+
function doOnload() {
|
|
611
|
+
if (!readyForOnload) {
|
|
612
|
+
onloadCalledWhileNotReady = true;
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
// WeChat browser doesn't support setting srcdoc scripts
|
|
616
|
+
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
|
617
|
+
const doc = iframe.contentDocument;
|
|
618
|
+
if (doc && doc.head.childNodes.length === 0) {
|
|
619
|
+
const s = doc.createElement('script');
|
|
620
|
+
if (nonce) s.setAttribute('nonce', nonce);
|
|
621
|
+
s.innerText = maybeTrustedScript(importMapTest.slice(15 + (nonce ? nonce.length : 0), -9));
|
|
622
|
+
doc.head.appendChild(s);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
iframe.onload = doOnload;
|
|
627
|
+
// WeChat browser requires append before setting srcdoc
|
|
628
|
+
document.head.appendChild(iframe);
|
|
629
|
+
|
|
630
|
+
// setting srcdoc is not supported in React native webviews on iOS
|
|
631
|
+
// setting src to a blob URL results in a navigation event in webviews
|
|
632
|
+
// document.write gives usability warnings
|
|
633
|
+
readyForOnload = true;
|
|
634
|
+
if ('srcdoc' in iframe) iframe.srcdoc = maybeTrustedInnerHTML(importMapTest);
|
|
635
|
+
else iframe.contentDocument.write(importMapTest);
|
|
636
|
+
// retrigger onload for Safari only if necessary
|
|
637
|
+
if (onloadCalledWhileNotReady) doOnload();
|
|
638
|
+
});
|
|
639
|
+
})();
|
|
640
|
+
|
|
641
|
+
/* es-module-lexer (minimal) 2.3.1 */
|
|
642
|
+
let e,a,r,i=2<<19;const s=1===new Uint8Array(new Uint16Array([1]).buffer)[0]?function(e,a){const r=e.length;let i=0;for(;i<r;)a[i]=e.charCodeAt(i++);}:function(e,a){const r=e.length;let i=0;for(;i<r;){const r=e.charCodeAt(i);a[i++]=(255&r)<<8|r>>>8;}},f="etaourceeferromsyncunctionlassvoyiedelecontininstantybreareturdebuggeawaithrwhileforifcatcfinallelsxportport";let c$1,t,n;function parse(k,l="@"){c$1=k,t=l;const u=2*c$1.length+(2<<18);if(u>i||!e){for(;u>i;)i*=2;a=new ArrayBuffer(i),s(f,new Uint16Array(a,16,108)),e=function(e,a,r){"use asm";var i=new e.Int8Array(r),s=new e.Int16Array(r),f=new e.Int32Array(r),c=new e.Uint8Array(r),t=new e.Uint16Array(r),n=1040;function b(e){e=e|0;var a=0,r=0,c=0,t=0,n=0,b=0,k=0,o=0,w=0,g=0,p=0,y=0,m=0,O=0,T=0;y=s[398]|0;a=f[71]|0;f[68]=a;k=a;p=a;o=y;g=0;e:while(1){r=f[72]|0;t=o<<16>>16==y<<16>>16;c=g&e;b=a;while(1){n=b+2|0;if(b>>>0>=r>>>0){a=0;w=100;break e}a=s[n>>1]|0;if(!(M(a)|0)){if(t){switch(a<<16>>16){case 125:case 93:case 41:case 59:case 44:{w=100;break e}default:{}}if(c?se(a)|0:0){w=100;break e}}if(!(se(a)|0))break}b=n;}f[71]=n;a:do{switch(a<<16>>16){case 101:{if((o<<16>>16==0?Q(n)|0:0)?(S(b+4|0,214,10)|0)==0:0){u();w=89;}else w=89;break}case 105:{if(((s[b+4>>1]|0)==109?Q(n)|0:0)?(S(b+6|0,224,8)|0)==0:0){l();w=89;}else w=89;break}case 99:{if((((s[b+4>>1]|0)==108?Q(n)|0:0)?(S(b+6|0,70,6)|0)==0:0)?L(s[b+12>>1]|0)|0:0){i[800]=1;w=89;}else w=89;break}case 40:{b=f[69]|0;w=o&65535;f[b+(w<<3)>>2]=1;s[398]=o+1<<16>>16;f[b+(w<<3)+4>>2]=k;w=89;break}case 91:{b=f[69]|0;w=o&65535;f[b+(w<<3)>>2]=8;s[398]=o+1<<16>>16;f[b+(w<<3)+4>>2]=k;w=89;break}case 93:if(!(o<<16>>16)){ee();break a}else {s[398]=o+-1<<16>>16;w=89;break a}case 44:{r=s[397]|0;if((!(o<<16>>16==0|r<<16>>16==0)?(f[(f[69]|0)+((o&65535)+-1<<3)>>2]|0)==5:0)?(m=f[(f[70]|0)+((r&65535)+-1<<2)>>2]|0,(f[m+4>>2]|0)==0):0){f[m+4>>2]=p+2;f[71]=b+4;v(1)|0;w=f[71]|0;f[m+16>>2]=w;f[71]=w+-2;w=89;}else w=89;break}case 41:{if(!(o<<16>>16)){ee();break a}w=o+-1<<16>>16;s[398]=w;r=s[397]|0;if(r<<16>>16!=0?(f[(f[69]|0)+((w&65535)<<3)>>2]|0)==5:0){c=f[(f[70]|0)+((r&65535)+-1<<2)>>2]|0;if(!(f[c+4>>2]|0))f[c+4>>2]=p+2;f[c+12>>2]=b+4;s[397]=r+-1<<16>>16;w=89;}else w=89;break}case 123:{w=f[62]|0;do{if((s[p>>1]|0)==41&(w|0)!=0?(f[w+12>>2]|0)==(p+2|0):0){r=f[63]|0;f[62]=r;if(!r){f[58]=0;break}else {f[r+32>>2]=0;break}}}while(0);b=f[69]|0;w=o&65535;f[b+(w<<3)>>2]=(i[800]|0)==0?2:6;s[398]=o+1<<16>>16;f[b+(w<<3)+4>>2]=k;i[800]=0;w=89;break}case 125:{if(!(o<<16>>16)){ee();break a}k=f[69]|0;w=o+-1<<16>>16;s[398]=w;if((f[k+((w&65535)<<3)>>2]|0)==4){d();w=89;}else w=89;break}case 34:case 39:{A(a);w=89;break}case 47:switch(s[b+4>>1]|0){case 47:{F();break a}case 42:{x(1);break a}default:{c=s[p>>1]|0;r:do{if(!($(c)|0)){if(!(c<<16>>16==41?K(f[(f[69]|0)+((o&65535)<<3)+4>>2]|0)|0:0))w=62;}else switch(c<<16>>16){case 46:if(((s[p+-2>>1]|0)+-48&65535)<10){w=62;break r}else break r;case 43:if((s[p+-2>>1]|0)==43){w=62;break r}else break r;case 45:if((s[p+-2>>1]|0)==45){w=62;break r}else break r;default:break r}}while(0);r:do{if((w|0)==62){w=0;if(o<<16>>16!=0?(O=f[69]|0,T=(o&65535)+-1|0,c<<16>>16==102?(f[O+(T<<3)>>2]|0)==1:0):0){if(((s[p+-2>>1]|0)==111?C(p+-4|0)|0:0)?B(f[O+(T<<3)+4>>2]|0,178,3)|0:0)break}else w=67;if((w|0)==67?(0,c<<16>>16==125):0){t=f[69]|0;r=o&65535;if(U(f[t+(r<<3)+4>>2]|0)|0)break;if((f[t+(r<<3)>>2]|0)==6)break}if(!(h(p)|0)){switch(c<<16>>16){case 0:break r;case 47:{if(i[799]|0)break r;break}default:{}}w=f[64]|0;if((w|0?p>>>0>=(f[w>>2]|0)>>>0:0)?p>>>0<=(f[w+4>>2]|0)>>>0:0){I();i[799]=0;w=89;break a}t=f[3]|0;r=p;do{if(r>>>0<=t>>>0)break;r=r+-2|0;f[68]=r;c=s[r>>1]|0;}while(!(D(c)|0));if(M(c)|0){do{if(r>>>0<=t>>>0)break;r=r+-2|0;f[68]=r;}while(M(s[r>>1]|0)|0);if(q(r)|0){I();i[799]=0;w=89;break a}}i[799]=1;w=89;break a}}}while(0);I();i[799]=0;w=89;break a}}case 96:{b=f[69]|0;w=o&65535;f[b+(w<<3)+4>>2]=k;s[398]=o+1<<16>>16;f[b+(w<<3)>>2]=3;d();w=89;break}default:w=89;}}while(0);if((w|0)==89){w=0;f[68]=f[71];}if(i[798]|0){a=0;break}r=f[68]|0;a:do{if((r|0)==(p|0))if(g&((s[398]|0)==y<<16>>16&e)){a=s[f[71]>>1]|0;if(se(a)|0)break e;else a=1;}else a=g;else {if(a<<16>>16==47){a=(i[799]|0)==0;break}if(G(a)|0)a=1;else {switch(a<<16>>16){case 96:case 34:case 39:case 41:case 93:case 125:{a=1;break a}default:{}}a=0;}}}while(0);k=r;p=r;o=s[398]|0;g=a;a=f[71]|0;}if((w|0)==100)f[71]=n;return a|0}function k(){var e=0,a=0,r=0,c=0,t=0,b=0,k=0,o=0,w=0;w=n;n=n+10240|0;s[397]=0;s[398]=0;f[68]=f[2];i[799]=0;f[67]=0;i[798]=0;f[69]=w+2048;f[70]=w;i[800]=0;r=(f[3]|0)+-2|0;f[71]=r;e=r+(f[65]<<1)|0;f[72]=e;e:while(1){a=r+2|0;f[71]=a;if(r>>>0>=e>>>0){c=85;break}e=s[a>>1]|0;a:do{switch(e<<16>>16){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((s[398]|0)==0?Q(a)|0:0)?(S(r+4|0,214,10)|0)==0:0){u();c=84;}else c=84;break}case 105:{if(((s[r+4>>1]|0)==109?Q(a)|0:0)?(S(r+6|0,224,8)|0)==0:0){l();c=84;}else c=84;break}case 99:{if((((s[r+4>>1]|0)==108?Q(a)|0:0)?(S(r+6|0,70,6)|0)==0:0)?L(s[r+12>>1]|0)|0:0){i[800]=1;c=84;}else c=84;break}case 40:{r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)>>2]=1;a=f[68]|0;s[398]=c+1<<16>>16;f[r+((c&65535)<<3)+4>>2]=a;c=84;break}case 91:{r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)>>2]=8;a=f[68]|0;s[398]=c+1<<16>>16;f[r+((c&65535)<<3)+4>>2]=a;c=84;break}case 93:{e=s[398]|0;if(!(e<<16>>16)){c=21;break e}s[398]=e+-1<<16>>16;c=84;break}case 44:{e=s[397]|0;if(((e<<16>>16!=0?(t=s[398]|0,t<<16>>16!=0):0)?(f[(f[69]|0)+((t&65535)+-1<<3)>>2]|0)==5:0)?(b=f[(f[70]|0)+((e&65535)+-1<<2)>>2]|0,(f[b+4>>2]|0)==0):0){f[b+4>>2]=(f[68]|0)+2;f[71]=r+4;v(1)|0;c=f[71]|0;f[b+16>>2]=c;f[71]=c+-2;c=84;}else c=84;break}case 41:{e=s[398]|0;if(!(e<<16>>16)){c=29;break e}s[398]=e+-1<<16>>16;a=s[397]|0;if(a<<16>>16!=0?(f[(f[69]|0)+((e+-1&65535)<<3)>>2]|0)==5:0){e=f[(f[70]|0)+((a&65535)+-1<<2)>>2]|0;if(!(f[e+4>>2]|0))f[e+4>>2]=(f[68]|0)+2;f[e+12>>2]=r+4;s[397]=a+-1<<16>>16;c=84;}else c=84;break}case 123:{e=f[68]|0;c=f[62]|0;do{if((s[e>>1]|0)==41&(c|0)!=0?(f[c+12>>2]|0)==(e+2|0):0){a=f[63]|0;f[62]=a;if(!a){f[58]=0;break}else {f[a+32>>2]=0;break}}}while(0);r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)>>2]=(i[800]|0)==0?2:6;s[398]=c+1<<16>>16;f[r+((c&65535)<<3)+4>>2]=e;i[800]=0;c=84;break}case 125:{e=s[398]|0;if(!(e<<16>>16)){c=42;break e}c=f[69]|0;s[398]=e+-1<<16>>16;if((f[c+((e+-1&65535)<<3)>>2]|0)==4){d();c=84;}else c=84;break}case 34:case 39:{A(e);c=84;break}case 47:switch(s[r+4>>1]|0){case 47:{F();break a}case 42:{x(1);break a}default:{e=f[68]|0;a=s[e>>1]|0;r:do{if(!($(a)|0))if(a<<16>>16==41){r=s[398]|0;if(!(K(f[(f[69]|0)+((r&65535)<<3)+4>>2]|0)|0))c=57;}else c=56;else switch(a<<16>>16){case 46:if(((s[e+-2>>1]|0)+-48&65535)<10){c=56;break r}else break r;case 43:if((s[e+-2>>1]|0)==43){c=56;break r}else break r;case 45:if((s[e+-2>>1]|0)==45){c=56;break r}else break r;default:break r}}while(0);if((c|0)==56){r=s[398]|0;c=57;}r:do{if((c|0)==57){c=0;if(r<<16>>16!=0?(k=f[69]|0,o=(r&65535)+-1|0,a<<16>>16==102?(f[k+(o<<3)>>2]|0)==1:0):0){if(((s[e+-2>>1]|0)==111?C(e+-4|0)|0:0)?B(f[k+(o<<3)+4>>2]|0,178,3)|0:0)break}else c=62;if((c|0)==62?(0,a<<16>>16==125):0){c=f[69]|0;r=r&65535;if(U(f[c+(r<<3)+4>>2]|0)|0)break;if((f[c+(r<<3)>>2]|0)==6)break}if(!(h(e)|0)){switch(a<<16>>16){case 0:break r;case 47:{if(i[799]|0)break r;break}default:{}}c=f[64]|0;if((c|0?e>>>0>=(f[c>>2]|0)>>>0:0)?e>>>0<=(f[c+4>>2]|0)>>>0:0){I();i[799]=0;c=84;break a}r=f[3]|0;do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[68]=e;a=s[e>>1]|0;}while(!(D(a)|0));if(M(a)|0){do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[68]=e;}while(M(s[e>>1]|0)|0);if(q(e)|0){I();i[799]=0;c=84;break a}}i[799]=1;c=84;break a}}}while(0);I();i[799]=0;c=84;break a}}case 96:{r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)+4>>2]=f[68];s[398]=c+1<<16>>16;f[r+((c&65535)<<3)>>2]=3;d();c=84;break}default:c=84;}}while(0);if((c|0)==84){c=0;f[68]=f[71];}r=f[71]|0;e=f[72]|0;}if((c|0)==21){ee();e=0;}else if((c|0)==29){ee();e=0;}else if((c|0)==42){ee();e=0;}else if((c|0)==85)e=(i[798]|0)==0?(s[397]|s[398])<<16>>16==0:0;n=w;return e|0}function l(){var e=0,a=0,r=0,c=0,t=0,n=0;n=f[71]|0;f[71]=n+12;e=v(1)|0;r=f[71]|0;e:do{if(e<<16>>16!=46){if(!(e<<16>>16==115&r>>>0>(n+12|0)>>>0)){if(!(e<<16>>16==100&r>>>0>(n+10|0)>>>0)){r=0;t=28;break}if(S(r+2|0,32,8)|0){a=r;e=100;r=0;t=60;break}if(!(L(s[r+10>>1]|0)|0)){a=r;e=100;r=0;t=60;break}f[71]=r+10;e=v(1)|0;if(e<<16>>16==42){e=42;c=2;t=62;break}f[71]=r;r=0;t=28;break}if((S(r+2|0,22,10)|0)==0?L(s[r+12>>1]|0)|0:0){f[71]=r+12;e=v(1)|0;a=f[71]|0;if((a|0)!=(r+12|0)){if(e<<16>>16!=102){r=1;t=28;break}if(S(a+2|0,40,6)|0){e=102;r=1;t=60;break}if(!(D(s[a+8>>1]|0)|0)){e=102;r=1;t=60;break}}f[71]=r;r=0;t=28;}else {a=r;e=115;r=0;t=60;}}else {f[71]=r+2;switch((v(1)|0)<<16>>16){case 109:{e=f[71]|0;if(S(e+2|0,16,6)|0)break e;a=f[68]|0;if(!(N(a)|0)?(s[a>>1]|0)==46:0)break e;g(n,n,e+8|0,2);break e}case 115:{e=f[71]|0;if(S(e+2|0,22,10)|0)break e;a=f[68]|0;if(!(N(a)|0)?(s[a>>1]|0)==46:0)break e;f[71]=e+12;e=v(1)|0;r=1;t=28;break e}case 100:{e=f[71]|0;if(S(e+2|0,32,8)|0)break e;a=f[68]|0;if(!(N(a)|0)?(s[a>>1]|0)==46:0)break e;f[71]=e+10;e=v(1)|0;r=2;t=28;break e}default:break e}}}while(0);e:do{if((t|0)==28){if(e<<16>>16==40){a=f[69]|0;c=s[398]|0;f[a+((c&65535)<<3)>>2]=5;e=f[71]|0;s[398]=c+1<<16>>16;f[a+((c&65535)<<3)+4>>2]=e;if((s[f[68]>>1]|0)==46)break;f[71]=e+2;a=v(1)|0;g(n,f[71]|0,0,e);if(!r)e=f[62]|0;else {e=f[62]|0;f[e+28>>2]=(r|0)==1?5:7;}c=f[70]|0;n=s[397]|0;s[397]=n+1<<16>>16;f[c+((n&65535)<<2)>>2]=e;switch(a<<16>>16){case 39:{A(39);break}case 34:{A(34);break}case 96:{if(!(y()|0))t=37;break}default:t=37;}if((t|0)==37){f[71]=(f[71]|0)+-2;break}e=(f[71]|0)+2|0;f[71]=e;switch((v(1)|0)<<16>>16){case 44:{f[71]=(f[71]|0)+2;v(1)|0;c=f[62]|0;f[c+4>>2]=e;n=f[71]|0;f[c+16>>2]=n;i[c+24>>0]=1;f[71]=n+-2;break e}case 41:{s[398]=(s[398]|0)+-1<<16>>16;n=f[62]|0;f[n+4>>2]=e;f[n+12>>2]=(f[71]|0)+2;i[n+24>>0]=1;s[397]=(s[397]|0)+-1<<16>>16;break e}default:{f[71]=(f[71]|0)+-2;break e}}}if(!((r|0)==0&e<<16>>16==123)){switch(e<<16>>16){case 42:case 39:case 34:{c=r;t=62;break e}default:{}}a=f[71]|0;t=60;break}e=f[71]|0;if(s[398]|0){f[71]=e+-2;break}while(1){if(e>>>0>=(f[72]|0)>>>0)break;e=v(1)|0;if(!(ae(e)|0)){if(e<<16>>16==125){t=50;break}}else A(e);e=(f[71]|0)+2|0;f[71]=e;}if((t|0)==50)f[71]=(f[71]|0)+2;c=(v(1)|0)<<16>>16==102;e=f[71]|0;if(c?S(e+2|0,40,6)|0:0){ee();break}f[71]=e+8;e=v(1)|0;if(ae(e)|0){w(n,e,0);break}else {ee();break}}}while(0);if((t|0)==60)if((a|0)==(n+12|0))f[71]=n+10;else {c=r;t=62;}do{if((t|0)==62){if(!((e<<16>>16==42|(c|0)!=2)&(s[398]|0)==0)){f[71]=(f[71]|0)+-2;break}e=f[72]|0;a=f[71]|0;while(1){if(a>>>0>=e>>>0){t=69;break}r=s[a>>1]|0;if(ae(r)|0){t=67;break}t=a+2|0;f[71]=t;a=t;}if((t|0)==67){w(n,r,c);break}else if((t|0)==69){ee();break}}}while(0);return}function u(){var e=0,a=0,r=0,i=0,c=0,t=0,n=0,k=0,l=0,u=0;k=f[71]|0;l=f[64]|0;f[71]=k+12;a=v(1)|0;e=f[71]|0;if(!((e|0)==(k+12|0)?!(O(a)|0):0))u=3;e:do{if((u|0)==3){a:do{switch(a<<16>>16){case 123:{f[71]=e+2;e=v(1)|0;r=f[71]|0;while(1){if(ae(e)|0){A(e);e=(f[71]|0)+2|0;f[71]=e;}else {H(e)|0;e=f[71]|0;}v(1)|0;e=p(r,e)|0;if(e<<16>>16==44){f[71]=(f[71]|0)+2;e=v(1)|0;}a=r;r=f[71]|0;if(e<<16>>16==125){u=15;break}if((r|0)==(a|0)){u=12;break}if(r>>>0>(f[72]|0)>>>0){u=14;break}}if((u|0)==12){ee();break e}else if((u|0)==14){ee();break e}else if((u|0)==15){f[71]=r+2;u=49;break a}break}case 42:{f[71]=e+2;v(1)|0;u=f[71]|0;p(u,u)|0;u=49;break}case 100:{f[71]=e+14;switch((v(1)|0)<<16>>16){case 97:{a=f[71]|0;if((S(a+2|0,46,8)|0)==0?M(s[a+10>>1]|0)|0:0){f[71]=a+10;v(0)|0;u=21;}break}case 102:{u=21;break}case 99:{a=f[71]|0;if(((S(a+2|0,68,8)|0)==0?(l=s[a+10>>1]|0,L(l)|0|l<<16>>16==123):0)?(f[71]=a+10,r=v(1)|0,r<<16>>16!=123):0){n=r;u=30;}break}default:{}}r:do{if((u|0)==21?(i=f[71]|0,(S(i+2|0,54,14)|0)==0):0){a=s[i+16>>1]|0;if(!(L(a)|0))switch(a<<16>>16){case 40:case 42:break;default:break r}f[71]=i+16;a=v(1)|0;if(a<<16>>16==42){f[71]=(f[71]|0)+2;a=v(1)|0;}if(a<<16>>16!=40){n=a;u=30;}}}while(0);if((u|0)==30?(c=f[71]|0,H(n)|0,t=f[71]|0,t>>>0>c>>>0):0){E(e,e+14|0,c,t);f[71]=(f[71]|0)+-2;break e}E(e,e+14|0,0,0);f[71]=e+12;break e}case 97:{f[71]=e+10;v(0)|0;e=f[71]|0;u=34;break}case 102:{u=34;break}case 99:{if((S(e+2|0,68,8)|0)==0?D(s[e+10>>1]|0)|0:0){f[71]=e+10;u=v(1)|0;l=f[71]|0;H(u)|0;u=f[71]|0;E(l,u,l,u);f[71]=(f[71]|0)+-2;break e}f[71]=e+4;e=e+4|0;u=41;break}case 108:case 118:{u=41;break}default:break e}}while(0);if((u|0)==34){f[71]=e+16;e=v(1)|0;if(e<<16>>16==42){f[71]=(f[71]|0)+2;e=v(1)|0;}l=f[71]|0;H(e)|0;u=f[71]|0;E(l,u,l,u);f[71]=(f[71]|0)+-2;break}else if((u|0)==41){f[71]=e+6;while(1){a=v(1)|0;e=f[71]|0;if(e>>>0>(f[72]|0)>>>0)break;a=P(a)|0;if((f[71]|0)==(e|0))break;if(a<<16>>16==61)a=b(1)|0;e=f[71]|0;if(a<<16>>16!=44)break;f[71]=e+2;}f[71]=e+-2;break}else if((u|0)==49){u=(v(1)|0)<<16>>16==102;e=f[71]|0;if(u?(S(e+2|0,40,6)|0)==0:0){f[71]=e+8;w(k,v(1)|0,0);e=(l|0)==0?236:l+16|0;while(1){e=f[e>>2]|0;if(!e)break e;f[e+12>>2]=0;f[e+8>>2]=0;e=e+16|0;}}f[71]=e+-2;break}}}while(0);return}function o(){var e=0,a=0,r=0,i=0,c=0,t=0,n=0;e=f[71]|0;c=(s[e>>1]|0)==123;f[71]=e+2;e=v(1)|0;t=c?125:93;e:while(1){if((t|0)==(e&65535|0))break;i=f[71]|0;if(i>>>0>(f[72]|0)>>>0)break;if((e<<16>>16==46?(s[i+2>>1]|0)==46:0)?(s[i+4>>1]|0)==46:0){f[71]=i+6;e=P(v(1)|0)|0;}else n=9;a:do{if((n|0)==9){n=0;do{if(c){do{if(e<<16>>16==91){b(0)|0;f[71]=(f[71]|0)+2;a=i;}else {if(ae(e)|0){A(e);f[71]=(f[71]|0)+2;a=i;break}if((e+-48&65535)>=10){H(e)|0;a=f[71]|0;break}e=i;r:while(1){r=e+2|0;a=s[r>>1]|0;i:do{if((a+-48&65535)>=10){switch(a<<16>>16){case 67:case 68:case 70:case 97:case 65:case 99:case 100:case 102:case 46:case 66:case 69:case 79:case 88:case 95:case 98:case 101:case 110:case 111:case 120:break i;case 43:case 45:break;default:break r}switch(s[e>>1]|0){case 69:case 101:break;default:break r}}}while(0);e=r;}f[71]=r;a=i;}}while(0);e=v(1)|0;if(e<<16>>16==58){f[71]=(f[71]|0)+2;e=P(v(1)|0)|0;break}if(a>>>0>i>>>0)E(i,a,i,a);}else if(e<<16>>16==44){f[71]=i+2;e=v(1)|0;break a}else {e=P(e)|0;break}}while(0);if(e<<16>>16==61)e=b(0)|0;if(e<<16>>16!=44)break e;f[71]=(f[71]|0)+2;e=v(1)|0;}}while(0)}return}function h(e){e=e|0;e:do{switch(s[e>>1]|0){case 100:switch(s[e+-2>>1]|0){case 105:{e=B(e+-4|0,76,2)|0;break e}case 108:{e=B(e+-4|0,80,3)|0;break e}default:{e=0;break e}}case 101:switch(s[e+-2>>1]|0){case 115:switch(s[e+-4>>1]|0){case 108:{e=z(e+-6|0,101)|0;break e}case 97:{e=z(e+-6|0,99)|0;break e}default:{e=0;break e}}case 116:{e=B(e+-4|0,86,4)|0;break e}case 117:{e=B(e+-4|0,94,6)|0;break e}default:{e=0;break e}}case 102:{if((s[e+-2>>1]|0)==111?(s[e+-4>>1]|0)==101:0)switch(s[e+-6>>1]|0){case 99:{e=B(e+-8|0,106,6)|0;break e}case 112:{e=B(e+-8|0,118,2)|0;break e}default:{e=0;break e}}else e=0;break}case 107:{e=B(e+-2|0,122,4)|0;break}case 110:{if(z(e+-2|0,105)|0)e=1;else e=B(e+-2|0,130,5)|0;break}case 111:{e=z(e+-2|0,100)|0;break}case 114:{e=B(e+-2|0,140,7)|0;break}case 116:{e=B(e+-2|0,154,4)|0;break}case 119:switch(s[e+-2>>1]|0){case 101:{e=z(e+-4|0,110)|0;break e}case 111:{e=B(e+-4|0,162,3)|0;break e}default:{e=0;break e}}default:e=0;}}while(0);return e|0}function w(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,c=0;i=(f[71]|0)+2|0;switch(a<<16>>16){case 39:{A(39);c=5;break}case 34:{A(34);c=5;break}default:ee();}do{if((c|0)==5){g(e,i,f[71]|0,1);if((r|0)>0)f[(f[62]|0)+28>>2]=(r|0)==1?4:6;f[71]=(f[71]|0)+2;c=(v(0)|0)<<16>>16==119;a=f[71]|0;if(((c?(s[a+2>>1]|0)==105:0)?(s[a+4>>1]|0)==116:0)?(s[a+6>>1]|0)==104:0){f[71]=a+8;if((v(1)|0)<<16>>16!=123){f[71]=a;break}r=f[71]|0;i=r;e:while(1){f[71]=i+2;i=v(1)|0;switch(i<<16>>16){case 39:{A(39);f[71]=(f[71]|0)+2;i=v(1)|0;break}case 34:{A(34);f[71]=(f[71]|0)+2;i=v(1)|0;break}default:i=H(i)|0;}if(i<<16>>16!=58){c=20;break}f[71]=(f[71]|0)+2;switch((v(1)|0)<<16>>16){case 39:{A(39);break}case 34:{A(34);break}default:{c=24;break e}}f[71]=(f[71]|0)+2;switch((v(1)|0)<<16>>16){case 125:{c=28;break e}case 44:break;default:{c=26;break e}}i=(f[71]|0)+2|0;f[71]=i;}if((c|0)==20){f[71]=a;break}else if((c|0)==24){f[71]=a;break}else if((c|0)==26){f[71]=a;break}else if((c|0)==28){c=f[62]|0;f[c+16>>2]=r;f[c+12>>2]=(f[71]|0)+2;break}}f[71]=a+-2;}}while(0);return}function d(){var e=0,a=0,r=0;a=f[72]|0;r=f[71]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){a=10;break}switch(s[e>>1]|0){case 96:{a=7;break e}case 36:{if((s[r+4>>1]|0)==123){a=6;break e}break}case 92:{e=r+4|0;break}default:{}}r=e;}if((a|0)==6){e=r+4|0;f[71]=e;a=f[69]|0;r=s[398]|0;f[a+((r&65535)<<3)>>2]=4;s[398]=r+1<<16>>16;f[a+((r&65535)<<3)+4>>2]=e;}else if((a|0)==7){f[71]=e;a=f[69]|0;r=(s[398]|0)+-1<<16>>16;s[398]=r;if((f[a+((r&65535)<<3)>>2]|0)!=3)ee();}else if((a|0)==10){f[71]=e;ee();}return}function v(e){e=e|0;var a=0,r=0,i=0;r=f[71]|0;e:do{a=s[r>>1]|0;a:do{if(a<<16>>16!=47)if(e)if(L(a)|0)break;else break e;else if(M(a)|0)break;else break e;else switch(s[r+2>>1]|0){case 47:{F();break a}case 42:{x(e);break a}default:{a=47;break e}}}while(0);i=f[71]|0;r=i+2|0;f[71]=r;}while(i>>>0<(f[72]|0)>>>0);return a|0}function A(e){e=e|0;var a=0,r=0,i=0,c=0;c=f[72]|0;a=f[71]|0;while(1){i=a+2|0;if(a>>>0>=c>>>0){a=9;break}r=s[i>>1]|0;if(r<<16>>16==e<<16>>16){a=10;break}if(r<<16>>16==92){r=a+4|0;if((s[r>>1]|0)==13){a=a+6|0;a=(s[a>>1]|0)==10?a:r;}else a=r;}else if(se(r)|0){a=9;break}else a=i;}if((a|0)==9){f[71]=i;ee();}else if((a|0)==10)f[71]=i;return}function C(e){e=e|0;var a=0,r=0;a=s[e>>1]|0;if(L(a)|0)r=3;else switch(a<<16>>16){case 41:case 125:case 93:{r=3;break}default:e=0;}e:do{if((r|0)==3){r=f[3]|0;while(1){if(e>>>0<=r>>>0)break;e=e+-2|0;if(!(L(a)|0))break;a=s[e>>1]|0;}switch(a<<16>>16){case 41:case 125:case 93:{e=1;break e}default:{}}e=(O(a)|0)^1;}}while(0);return e|0}function g(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var c=0,t=0;t=f[66]|0;f[66]=t+36;c=f[62]|0;f[((c|0)==0?232:c+32|0)>>2]=t;f[63]=c;f[62]=t;f[t+8>>2]=e;if(2==(s|0)){e=3;c=r;}else {e=1==(s|0)?1:2;c=1==(s|0)?r+2|0:0;}f[t+12>>2]=c;f[t+28>>2]=e;f[t>>2]=a;f[t+4>>2]=r;f[t+16>>2]=0;f[t+20>>2]=s;i[t+24>>0]=1==(s|0)&1;f[t+32>>2]=0;return}function p(e,a){e=e|0;a=a|0;var r=0,i=0,c=0,t=0;r=f[71]|0;i=s[r>>1]|0;c=(e|0)==(a|0)?0:e;t=(e|0)==(a|0)?0:a;if(i<<16>>16==97){f[71]=r+4;r=v(1)|0;e=f[71]|0;if(ae(r)|0){A(r);a=(f[71]|0)+2|0;f[71]=a;}else {H(r)|0;a=f[71]|0;}i=v(1)|0;r=f[71]|0;}if((r|0)!=(e|0))E(e,a,c,t);return i|0}function y(){var e=0,a=0,r=0,i=0;i=f[71]|0;r=f[72]|0;a=i;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=7;break}switch(s[e>>1]|0){case 96:{a=8;break e}case 92:{e=a+4|0;break}case 36:{if((s[a+4>>1]|0)==123){a=7;break e}break}default:{}}a=e;}if((a|0)==7){f[71]=i;e=0;}else if((a|0)==8){f[71]=e;e=1;}return e|0}function m(){var e=0,a=0,r=0;r=f[72]|0;a=f[71]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=6;break}switch(s[e>>1]|0){case 13:case 10:{a=6;break e}case 93:{a=7;break e}case 92:{e=a+4|0;break}default:{}}a=e;}if((a|0)==6){f[71]=e;ee();e=0;}else if((a|0)==7){f[71]=e;e=93;}return e|0}function I(){var e=0,a=0;e:while(1){e=f[71]|0;f[71]=e+2;if(e>>>0>=(f[72]|0)>>>0){a=7;break}switch(s[e+2>>1]|0){case 13:case 10:{a=7;break e}case 47:break e;case 91:{m()|0;break}case 92:{f[71]=e+4;break}default:{}}}if((a|0)==7)ee();return}function U(e){e=e|0;switch(s[e>>1]|0){case 62:{e=(s[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=B(e+-2|0,188,4)|0;break}case 121:{e=B(e+-2|0,196,6)|0;break}case 101:{e=B(e+-2|0,208,3)|0;break}default:e=0;}return e|0}function x(e){e=e|0;var a=0,r=0,i=0,c=0,t=0;c=(f[71]|0)+2|0;f[71]=c;r=f[72]|0;while(1){a=c+2|0;if(c>>>0>=r>>>0)break;i=s[a>>1]|0;if(!e?se(i)|0:0)break;if(i<<16>>16==42?(s[c+4>>1]|0)==47:0){t=8;break}c=a;}if((t|0)==8){f[71]=a;a=c+4|0;}f[71]=a;return}function S(e,a,r){e=e|0;a=a|0;r=r|0;var s=0,f=0;e:do{if(!r)e=0;else {while(1){s=i[e>>0]|0;f=i[a>>0]|0;if(s<<24>>24!=f<<24>>24)break;r=r+-1|0;if(!r){e=0;break e}else {e=e+1|0;a=a+1|0;}}e=(s&255)-(f&255)|0;}}while(0);return e|0}function O(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:{e=1;break}default:if((e&-8)<<16>>16==40|(e+-58&65535)<6)e=1;else {switch(e<<16>>16){case 91:case 93:case 94:{e=1;break e}default:{}}e=(e+-123&65535)<4;}}}while(0);return e|0}function $(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:break;default:if(!((e+-58&65535)<6|(e+-40&65535)<7&e<<16>>16!=41)){switch(e<<16>>16){case 91:case 94:break e;default:{}}return e<<16>>16!=125&(e+-123&65535)<4|0}}}while(0);return 1}function T(e){e=e|0;var a=0;a=s[e>>1]|0;e:do{if((a+-9&65535)>=5){switch(a<<16>>16){case 160:case 32:{a=1;break e}default:{}}if(O(a)|0)return a<<16>>16!=46|(N(e)|0)|0;else a=0;}else a=1;}while(0);return a|0}function j(e){e=e|0;var a=0,r=0;r=n;n=n+16|0;f[r>>2]=0;f[65]=e;a=f[3]|0;s[a+(e<<1)>>1]=0;f[r>>2]=a+(e<<1)+2;f[66]=a+(e<<1)+2;f[58]=0;f[62]=0;f[60]=0;f[59]=0;f[64]=0;f[61]=0;n=r;return a|0}function B(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,s=0;s=e+(0-r<<1)+2|0;i=f[3]|0;if(s>>>0>=i>>>0?(S(s,a,r<<1)|0)==0:0)if((s|0)==(i|0))i=1;else i=T(e+(0-r<<1)|0)|0;else i=0;return i|0}function E(e,a,r,i){e=e|0;a=a|0;r=r|0;i=i|0;var s=0,c=0;s=f[66]|0;f[66]=s+20;c=f[64]|0;f[((c|0)==0?236:c+16|0)>>2]=s;f[64]=s;f[s>>2]=e;f[s+4>>2]=a;f[s+8>>2]=r;f[s+12>>2]=i;f[s+16>>2]=0;return}function P(e){e=e|0;var a=0;switch(e<<16>>16){case 91:case 123:{o();f[71]=(f[71]|0)+2;break}default:{a=f[71]|0;H(e)|0;e=f[71]|0;if(e>>>0>a>>>0)E(a,e,a,e);}}return v(1)|0}function q(e){e=e|0;switch(s[e>>1]|0){case 107:{e=B(e+-2|0,122,4)|0;break}case 101:{if((s[e+-2>>1]|0)==117)e=B(e+-4|0,94,6)|0;else e=0;break}default:e=0;}return e|0}function z(e,a){e=e|0;a=a|0;var r=0;r=f[3]|0;if(r>>>0<=e>>>0?(s[e>>1]|0)==a<<16>>16:0)if((r|0)==(e|0))r=1;else r=D(s[e+-2>>1]|0)|0;else r=0;return r|0}function D(e){e=e|0;e:do{if((e+-9&65535)<5)e=1;else {switch(e<<16>>16){case 32:case 160:{e=1;break e}default:{}}e=e<<16>>16!=46&(O(e)|0);}}while(0);return e|0}function F(){var e=0,a=0,r=0;e=f[72]|0;r=f[71]|0;e:while(1){a=r+2|0;if(r>>>0>=e>>>0)break;switch(s[a>>1]|0){case 13:case 10:break e;default:r=a;}}f[71]=a;return}function G(e){e=e|0;e:do{if(((e&-33)+-65&65535)<26|(e+-48&65535)<10)e=1;else {switch(e<<16>>16){case 36:case 95:{e=1;break e}default:{}}e=(e&65535)>127;}}while(0);return e|0}function H(e){e=e|0;while(1){if(L(e)|0)break;if(O(e)|0)break;e=(f[71]|0)+2|0;f[71]=e;e=s[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function J(){var e=0;e=f[(f[60]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(f[3]|0)>>1;}return e|0}function K(e){e=e|0;if(!(B(e,168,5)|0)?!(B(e,178,3)|0):0)e=B(e,184,2)|0;else e=1;return e|0}function L(e){e=e|0;switch(e<<16>>16){case 160:case 9:case 10:case 11:case 12:case 13:case 32:{e=1;break}default:e=0;}return e|0}function M(e){e=e|0;switch(e<<16>>16){case 160:case 32:case 12:case 11:case 9:{e=1;break}default:e=0;}return e|0}function N(e){e=e|0;if((s[e>>1]|0)==46?(s[e+-2>>1]|0)==46:0)e=(s[e+-4>>1]|0)==46;else e=0;return e|0}function Q(e){e=e|0;if((f[3]|0)==(e|0))e=1;else e=T(e+-2|0)|0;return e|0}function R(){var e=0;e=f[(f[61]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function V(){var e=0;e=f[(f[60]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function W(){var e=0;e=f[(f[61]|0)+8>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function X(){var e=0;e=f[(f[60]|0)+16>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function Y(){var e=0;e=f[(f[60]|0)+4>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function Z(){var e=0;e=f[60]|0;e=f[((e|0)==0?232:e+32|0)>>2]|0;f[60]=e;return (e|0)!=0|0}function _(){var e=0;e=f[61]|0;e=f[((e|0)==0?236:e+16|0)>>2]|0;f[61]=e;return (e|0)!=0|0}function ee(){i[798]=1;f[67]=(f[71]|0)-(f[3]|0)>>1;f[71]=(f[72]|0)+2;return}function ae(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function re(){return (f[(f[60]|0)+8>>2]|0)-(f[3]|0)>>1|0}function ie(){return (f[(f[61]|0)+4>>2]|0)-(f[3]|0)>>1|0}function se(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function fe(){return (f[f[60]>>2]|0)-(f[3]|0)>>1|0}function ce(){return (f[f[61]>>2]|0)-(f[3]|0)>>1|0}function te(){return c[(f[60]|0)+24>>0]|0|0}function ne(e){e=e|0;f[3]=e;return}function be(){return f[(f[60]|0)+28>>2]|0}function ke(){return f[67]|0}function le(e,a){e=e|0;a=a|0;n=e+a+15&-16;return a}return {su:le,ai:X,e:ke,ee:ie,ele:R,els:W,es:ce,id:J,ie:Y,ip:te,is:fe,it:be,p:k,re:_,ri:Z,sa:j,se:V,ses:ne,ss:re}}("undefined"!=typeof globalThis?globalThis:self,{},a),r=e.su(i-(2<<17),1040);}const h=c$1.length+1;e.ses(r),e.sa(h-1),s(c$1,new Uint16Array(a,r,h)),e.p()||(n=e.e(),o());const w=[],d=[];for(;e.ri();){const a=e.is(),r=e.ie(),i=e.ai(),s=e.id(),f=e.ss(),t=e.se(),n=e.it();let k;e.ip()&&(k=b(-1===s?a:a+1,c$1.charCodeAt(-1===s?a-1:a)));let l=null;w.push({t:n,n:k,s:a,e:r,ss:f,se:t,d:s,a:i,at:l});}for(;e.re();){const a=e.es(),r=e.ee(),i=e.els(),s=e.ele(),f=i<0?void 0:v(i,s),c=v(a,r);d.push({s:a,e:r,ls:i,le:s,n:c,ln:f});}return [w,d];function v(e,a){const r=c$1.charCodeAt(e);return 34===r||39===r?b(e+1,r):c$1.slice(e,a)}}function b(e,a){n=e;let r="",i=n;for(;;){n>=c$1.length&&o();const e=c$1.charCodeAt(n);if(e===a)break;92===e?(r+=c$1.slice(i,n),r+=k(),i=n):(8232===e||8233===e||u(e)&&96!==a&&o(),++n);}return r+=c$1.slice(i,n++),r}function k(){let e=c$1.charCodeAt(++n);switch(++n,e){case 110:return "\\n";case 114:return "\\r";case 120:return String.fromCharCode(l(2));case 117:return function(){const e=c$1.charCodeAt(n);let a;123===e?(++n,a=l(c$1.indexOf("}",n)-n),++n,a>1114111&&o()):a=l(4);return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode(55296+(a>>10),56320+(1023&a)))}();case 116:return "\\t";case 98:return "\\b";case 118:return "\\v";case 102:return "\\f";case 13:10===c$1.charCodeAt(n)&&++n;case 10:return "";case 56:case 57:o();default:if(e>=48&&e<=55){let a=c$1.substr(n-1,3).match(/^[0-7]+/)[0],r=parseInt(a,8);return r>255&&(a=a.slice(0,-1),r=parseInt(a,8)),n+=a.length-1,e=c$1.charCodeAt(n),"0"===a&&56!==e&&57!==e||o(),String.fromCharCode(r)}return u(e)?"":String.fromCharCode(e)}}function l(e){const a=n;let r=0,i=0;for(let a=0;a<e;++a,++n){let e,s=c$1.charCodeAt(n);if(95!==s){if(s>=97)e=s-97+10;else if(s>=65)e=s-65+10;else {if(!(s>=48&&s<=57))break;e=s-48;}if(e>=16)break;i=s,r=16*r+e;}else 95!==i&&0!==a||o(),i=s;}return 95!==i&&n-a===e||o(),r}function u(e){return 13===e||10===e}function o(){throw Object.assign(Error(\`Parse error \${t}:\${c$1.slice(0,n).split("\\n").length}:\${n-c$1.lastIndexOf("\\n",n-1)}\`),{idx:n})}
|
|
643
|
+
|
|
644
|
+
const _resolve = (id, parentUrl = baseUrl) => {
|
|
645
|
+
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id);
|
|
646
|
+
const firstResolved = firstImportMap && resolveImportMap(firstImportMap, urlResolved || id, parentUrl);
|
|
647
|
+
const composedResolved =
|
|
648
|
+
composedImportMap === firstImportMap ? firstResolved : (
|
|
649
|
+
resolveImportMap(composedImportMap, urlResolved || id, parentUrl)
|
|
650
|
+
);
|
|
651
|
+
const resolved = composedResolved || firstResolved || throwUnresolved(id, parentUrl);
|
|
652
|
+
// needsShim, shouldShim per load record to set on parent
|
|
653
|
+
let n = false,
|
|
654
|
+
N = false;
|
|
655
|
+
if (!supportsImportMaps) {
|
|
656
|
+
// bare specifier -> needs shim
|
|
657
|
+
if (!urlResolved) n = true;
|
|
658
|
+
// url mapping -> should shim
|
|
659
|
+
else if (urlResolved !== resolved) N = true;
|
|
660
|
+
} else if (!supportsMultipleImportMaps) {
|
|
661
|
+
// bare specifier and not resolved by first import map -> needs shim
|
|
662
|
+
if (!urlResolved && !firstResolved) n = true;
|
|
663
|
+
// resolution doesn't match first import map -> should shim
|
|
664
|
+
if (firstResolved && resolved !== firstResolved) N = true;
|
|
665
|
+
}
|
|
666
|
+
return { r: resolved, n, N };
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
const resolve = (id, parentUrl) => {
|
|
670
|
+
if (!resolveHook) return _resolve(id, parentUrl);
|
|
671
|
+
const result = resolveHook(id, parentUrl, defaultResolve);
|
|
672
|
+
|
|
673
|
+
return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
// import()
|
|
677
|
+
async function importShim(id, opts, parentUrl) {
|
|
678
|
+
if (typeof opts === 'string') {
|
|
679
|
+
parentUrl = opts;
|
|
680
|
+
opts = undefined;
|
|
681
|
+
}
|
|
682
|
+
await initPromise; // needed for shim check
|
|
683
|
+
if (shimMode || !baselineSupport) {
|
|
684
|
+
if (hasDocument) processScriptsAndPreloads();
|
|
685
|
+
legacyAcceptingImportMaps = false;
|
|
686
|
+
}
|
|
687
|
+
let sourceType = undefined;
|
|
688
|
+
if (typeof opts === 'object') {
|
|
689
|
+
if (opts.lang === 'ts') sourceType = 'ts';
|
|
690
|
+
if (typeof opts.with === 'object' && typeof opts.with.type === 'string') {
|
|
691
|
+
sourceType = opts.with.type;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return topLevelLoad(id, parentUrl || baseUrl, defaultFetchOpts, undefined, undefined, undefined, sourceType);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
// import.source()
|
|
698
|
+
// (opts not currently supported as no use cases yet)
|
|
699
|
+
if (shimMode || wasmSourcePhaseEnabled)
|
|
700
|
+
importShim.source = async (id, opts, parentUrl) => {
|
|
701
|
+
if (typeof opts === 'string') {
|
|
702
|
+
parentUrl = opts;
|
|
703
|
+
opts = undefined;
|
|
704
|
+
}
|
|
705
|
+
await initPromise; // needed for shim check
|
|
706
|
+
if (shimMode || !baselineSupport) {
|
|
707
|
+
if (hasDocument) processScriptsAndPreloads();
|
|
708
|
+
legacyAcceptingImportMaps = false;
|
|
709
|
+
}
|
|
710
|
+
await importMapPromise;
|
|
711
|
+
const url = resolve(id, parentUrl || baseUrl).r;
|
|
712
|
+
const load = getOrCreateLoad(url, defaultFetchOpts, undefined, undefined);
|
|
713
|
+
await load.f;
|
|
714
|
+
return importShim._s[load.r];
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
// import.defer() is just a proxy for import(), since we can't actually defer
|
|
718
|
+
if (shimMode || deferPhaseEnabled) importShim.defer = importShim;
|
|
719
|
+
|
|
720
|
+
if (hotReload) {
|
|
721
|
+
initHotReload(topLevelLoad, importShim);
|
|
722
|
+
importShim.hotReload = hotReload$1;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
const defaultResolve = (id, parentUrl) => {
|
|
726
|
+
return (
|
|
727
|
+
resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
|
|
728
|
+
throwUnresolved(id, parentUrl)
|
|
729
|
+
);
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
const throwUnresolved = (id, parentUrl) => {
|
|
733
|
+
throw Error(\`Unable to resolve specifier '\${id}'\${fromParent(parentUrl)}\`);
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
const metaResolve = function (id, parentUrl = this.url) {
|
|
737
|
+
return resolve(id, \`\${parentUrl}\`).r;
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
importShim.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
|
|
741
|
+
importShim.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
|
|
742
|
+
importShim.addImportMap = importMapIn => {
|
|
743
|
+
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
744
|
+
composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
|
|
745
|
+
};
|
|
746
|
+
importShim.version = version;
|
|
747
|
+
|
|
748
|
+
const registry = (importShim._r = {});
|
|
749
|
+
// Wasm caches
|
|
750
|
+
const sourceCache = (importShim._s = {});
|
|
751
|
+
/* const instanceCache = */ importShim._i = new WeakMap();
|
|
752
|
+
|
|
753
|
+
// Ensure this version is the only version
|
|
754
|
+
defineValue(self_, 'importShim', Object.freeze(importShim));
|
|
755
|
+
const shimModeOptions = { ...esmsInitOptions, shimMode: true };
|
|
756
|
+
if (optionsScript) optionsScript.innerText = maybeTrustedScript(JSON.stringify(shimModeOptions));
|
|
757
|
+
self_.esmsInitOptions = shimModeOptions;
|
|
758
|
+
|
|
759
|
+
const loadAll = async (load, seen) => {
|
|
760
|
+
seen[load.u] = 1;
|
|
761
|
+
await load.L;
|
|
762
|
+
await Promise.all(
|
|
763
|
+
load.d.map(({ l: dep, s: sourcePhase }) => {
|
|
764
|
+
if (dep.b || seen[dep.u]) return;
|
|
765
|
+
if (sourcePhase) return dep.f;
|
|
766
|
+
return loadAll(dep, seen);
|
|
767
|
+
})
|
|
768
|
+
);
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
let importMapSrc = false;
|
|
772
|
+
let multipleImportMaps = false;
|
|
773
|
+
let firstImportMap = null;
|
|
774
|
+
// To support polyfilling multiple import maps, we separately track the composed import map from the first import map
|
|
775
|
+
let composedImportMap = { imports: {}, scopes: {}, integrity: {} };
|
|
776
|
+
let baselineSupport;
|
|
777
|
+
|
|
778
|
+
const initPromise = featureDetectionPromise.then(() => {
|
|
779
|
+
baselineSupport =
|
|
780
|
+
supportsImportMaps &&
|
|
781
|
+
(!jsonModulesEnabled || supportsJsonType) &&
|
|
782
|
+
(!cssModulesEnabled || supportsCssType) &&
|
|
783
|
+
(!wasmInstancePhaseEnabled || supportsWasmInstancePhase) &&
|
|
784
|
+
(!wasmSourcePhaseEnabled || supportsWasmSourcePhase) &&
|
|
785
|
+
!deferPhaseEnabled &&
|
|
786
|
+
(!multipleImportMaps || supportsMultipleImportMaps) &&
|
|
787
|
+
!importMapSrc &&
|
|
788
|
+
!hasCustomizationHooks;
|
|
789
|
+
if (!shimMode && typeof WebAssembly !== 'undefined') {
|
|
790
|
+
if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
|
|
791
|
+
const s = Symbol();
|
|
792
|
+
const brand = m => defineValue(m, s, 'WebAssembly.Module');
|
|
793
|
+
class AbstractModuleSource {
|
|
794
|
+
get [Symbol.toStringTag]() {
|
|
795
|
+
if (this[s]) return this[s];
|
|
796
|
+
throw new TypeError('Not an AbstractModuleSource');
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
const { Module: wasmModule, compile: wasmCompile, compileStreaming: wasmCompileStreaming } = WebAssembly;
|
|
800
|
+
WebAssembly.Module = Object.setPrototypeOf(
|
|
801
|
+
Object.assign(function Module(...args) {
|
|
802
|
+
return brand(new wasmModule(...args));
|
|
803
|
+
}, wasmModule),
|
|
804
|
+
AbstractModuleSource
|
|
805
|
+
);
|
|
806
|
+
WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
|
|
807
|
+
WebAssembly.compile = function compile(...args) {
|
|
808
|
+
return wasmCompile(...args).then(brand);
|
|
809
|
+
};
|
|
810
|
+
WebAssembly.compileStreaming = function compileStreaming(...args) {
|
|
811
|
+
return wasmCompileStreaming(...args).then(brand);
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
if (hasDocument) {
|
|
816
|
+
if (!supportsImportMaps) {
|
|
817
|
+
const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
|
|
818
|
+
HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
|
|
819
|
+
}
|
|
820
|
+
if (shimMode || !baselineSupport) {
|
|
821
|
+
attachMutationObserver();
|
|
822
|
+
if (document.readyState === 'complete') {
|
|
823
|
+
readyStateCompleteCheck();
|
|
824
|
+
} else {
|
|
825
|
+
document.addEventListener('readystatechange', readyListener);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
processScriptsAndPreloads();
|
|
829
|
+
}
|
|
830
|
+
return undefined;
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
const attachMutationObserver = () => {
|
|
834
|
+
const observer = new MutationObserver(mutations => {
|
|
835
|
+
for (const mutation of mutations) {
|
|
836
|
+
if (mutation.type !== 'childList') continue;
|
|
837
|
+
for (const node of mutation.addedNodes) {
|
|
838
|
+
if (node.tagName === 'SCRIPT') {
|
|
839
|
+
if (node.type === (shimMode ? 'module-shim' : 'module') && !node.ep) processScript(node, true);
|
|
840
|
+
if (node.type === (shimMode ? 'importmap-shim' : 'importmap') && !node.ep) processImportMap(node, true);
|
|
841
|
+
} else if (
|
|
842
|
+
node.tagName === 'LINK' &&
|
|
843
|
+
node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload') &&
|
|
844
|
+
!node.ep
|
|
845
|
+
) {
|
|
846
|
+
processPreload(node);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
});
|
|
851
|
+
observer.observe(document, { childList: true });
|
|
852
|
+
observer.observe(document.head, { childList: true });
|
|
853
|
+
processScriptsAndPreloads();
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
let importMapPromise = initPromise;
|
|
857
|
+
let firstPolyfillLoad = true;
|
|
858
|
+
let legacyAcceptingImportMaps = true;
|
|
859
|
+
|
|
860
|
+
async function topLevelLoad(
|
|
861
|
+
url,
|
|
862
|
+
parentUrl,
|
|
863
|
+
fetchOpts,
|
|
864
|
+
source,
|
|
865
|
+
nativelyLoaded,
|
|
866
|
+
lastStaticLoadPromise,
|
|
867
|
+
sourceType
|
|
868
|
+
) {
|
|
869
|
+
await initPromise;
|
|
870
|
+
await importMapPromise;
|
|
871
|
+
url = (await resolve(url, parentUrl)).r;
|
|
872
|
+
|
|
873
|
+
// we mock import('./x.css', { with: { type: 'css' }}) support via an inline static reexport
|
|
874
|
+
// because we can't syntactically pass through to dynamic import with a second argument
|
|
875
|
+
if (sourceType === 'css' || sourceType === 'json') {
|
|
876
|
+
// Direct reexport for hot reloading skipped due to Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=1965620
|
|
877
|
+
source = \`import m from'\${url}'with{type:"\${sourceType}"};export default m;\`;
|
|
878
|
+
url += '?entry';
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl, source, sourceType);
|
|
882
|
+
// early analysis opt-out - no need to even fetch if we have feature support
|
|
883
|
+
if (!shimMode && baselineSupport && nativePassthrough && sourceType !== 'ts') {
|
|
884
|
+
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
|
885
|
+
if (nativelyLoaded) return null;
|
|
886
|
+
await lastStaticLoadPromise;
|
|
887
|
+
return dynamicImport(source ? createBlob(source) : url);
|
|
888
|
+
}
|
|
889
|
+
const load = getOrCreateLoad(url, fetchOpts, undefined, source);
|
|
890
|
+
linkLoad(load, fetchOpts);
|
|
891
|
+
const seen = {};
|
|
892
|
+
await loadAll(load, seen);
|
|
893
|
+
resolveDeps(load, seen);
|
|
894
|
+
await lastStaticLoadPromise;
|
|
895
|
+
if (!shimMode && !load.n) {
|
|
896
|
+
if (nativelyLoaded) {
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
if (source) {
|
|
900
|
+
return await dynamicImport(createBlob(source));
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
904
|
+
onpolyfill();
|
|
905
|
+
firstPolyfillLoad = false;
|
|
906
|
+
}
|
|
907
|
+
const module = await (shimMode || load.n || load.N || !nativePassthrough || (!nativelyLoaded && source) ?
|
|
908
|
+
dynamicImport(load.b, load.u)
|
|
909
|
+
: import(load.u));
|
|
910
|
+
// if the top-level load is a shell, run its update function
|
|
911
|
+
if (load.s) (await dynamicImport(load.s, load.u)).u$_(module);
|
|
912
|
+
revokeObjectURLs(Object.keys(seen));
|
|
913
|
+
return module;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
const revokeObjectURLs = registryKeys => {
|
|
917
|
+
let curIdx = 0;
|
|
918
|
+
const handler = self_.requestIdleCallback || self_.requestAnimationFrame || (fn => setTimeout(fn, 0));
|
|
919
|
+
handler(cleanup);
|
|
920
|
+
function cleanup() {
|
|
921
|
+
for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
|
|
922
|
+
const load = registry[key];
|
|
923
|
+
if (load && load.b && load.b !== load.u) URL.revokeObjectURL(load.b);
|
|
924
|
+
}
|
|
925
|
+
if (curIdx < registryKeys.length) handler(cleanup);
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
|
|
929
|
+
const urlJsString = url => \`'\${url.replace(/'/g, "\\\\'")}'\`;
|
|
930
|
+
|
|
931
|
+
let resolvedSource, lastIndex;
|
|
932
|
+
const pushStringTo = (load, originalIndex, dynamicImportEndStack) => {
|
|
933
|
+
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
934
|
+
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
935
|
+
resolvedSource += \`\${load.S.slice(lastIndex, dynamicImportEnd)}, \${urlJsString(load.r)}\`;
|
|
936
|
+
lastIndex = dynamicImportEnd;
|
|
937
|
+
}
|
|
938
|
+
resolvedSource += load.S.slice(lastIndex, originalIndex);
|
|
939
|
+
lastIndex = originalIndex;
|
|
940
|
+
};
|
|
941
|
+
|
|
942
|
+
const pushSourceURL = (load, commentPrefix, commentStart, dynamicImportEndStack) => {
|
|
943
|
+
const urlStart = commentStart + commentPrefix.length;
|
|
944
|
+
const commentEnd = load.S.indexOf('\\n', urlStart);
|
|
945
|
+
const urlEnd = commentEnd !== -1 ? commentEnd : load.S.length;
|
|
946
|
+
let sourceUrl = load.S.slice(urlStart, urlEnd);
|
|
947
|
+
try {
|
|
948
|
+
sourceUrl = new URL(sourceUrl, load.r).href;
|
|
949
|
+
} catch (e) {}
|
|
950
|
+
pushStringTo(load, urlStart, dynamicImportEndStack);
|
|
951
|
+
resolvedSource += sourceUrl;
|
|
952
|
+
lastIndex = urlEnd;
|
|
953
|
+
};
|
|
954
|
+
|
|
955
|
+
const resolveDeps = (load, seen) => {
|
|
956
|
+
if (load.b || !seen[load.u]) return;
|
|
957
|
+
seen[load.u] = 0;
|
|
958
|
+
|
|
959
|
+
for (const { l: dep, s: sourcePhase } of load.d) {
|
|
960
|
+
if (!sourcePhase) resolveDeps(dep, seen);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
if (!load.n) load.n = load.d.some(dep => dep.l.n);
|
|
964
|
+
if (!load.N) load.N = load.d.some(dep => dep.l.N);
|
|
965
|
+
|
|
966
|
+
// use native loader whenever possible (n = needs shim) via executable subgraph passthrough
|
|
967
|
+
// so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
|
|
968
|
+
if (nativePassthrough && !shimMode && !load.n && !load.N) {
|
|
969
|
+
load.b = load.u;
|
|
970
|
+
load.S = undefined;
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
const [imports, exports] = load.a;
|
|
975
|
+
|
|
976
|
+
// "execution"
|
|
977
|
+
let source = load.S,
|
|
978
|
+
depIndex = 0,
|
|
979
|
+
dynamicImportEndStack = [];
|
|
980
|
+
|
|
981
|
+
// once all deps have loaded we can inline the dependency resolution blobs
|
|
982
|
+
// and define this blob
|
|
983
|
+
resolvedSource = '';
|
|
984
|
+
lastIndex = 0;
|
|
985
|
+
|
|
986
|
+
for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a, at } of imports) {
|
|
987
|
+
// source phase
|
|
988
|
+
if (t === 4) {
|
|
989
|
+
let { l: depLoad } = load.d[depIndex++];
|
|
990
|
+
pushStringTo(load, statementStart, dynamicImportEndStack);
|
|
991
|
+
resolvedSource += \`\${source.slice(statementStart, start - 1).replace('source', '')}/*\${source.slice(start - 1, end + 1)}*/'\${createBlob(\`export default importShim._s[\${urlJsString(depLoad.r)}]\`)}'\`;
|
|
992
|
+
lastIndex = end + 1;
|
|
993
|
+
}
|
|
994
|
+
// dependency source replacements
|
|
995
|
+
else if (dynamicImportIndex === -1) {
|
|
996
|
+
let keepAssertion = false;
|
|
997
|
+
if (a > 0 && !shimMode) {
|
|
998
|
+
// strip assertions only when unsupported in polyfill mode
|
|
999
|
+
// minimal lexer builds do not provide parsed attributes, so sniff the assertion source directly
|
|
1000
|
+
const assertion = source.slice(a, statementEnd - 1);
|
|
1001
|
+
keepAssertion =
|
|
1002
|
+
nativePassthrough &&
|
|
1003
|
+
((supportsJsonType && assertion.includes('json')) || (supportsCssType && assertion.includes('css')));
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
// defer phase stripping
|
|
1007
|
+
if (t === 6) {
|
|
1008
|
+
pushStringTo(load, statementStart, dynamicImportEndStack);
|
|
1009
|
+
resolvedSource += source.slice(statementStart, start - 1).replace('defer', '');
|
|
1010
|
+
lastIndex = start;
|
|
1011
|
+
}
|
|
1012
|
+
let { l: depLoad } = load.d[depIndex++],
|
|
1013
|
+
blobUrl = depLoad.b,
|
|
1014
|
+
cycleShell = !blobUrl;
|
|
1015
|
+
if (cycleShell) {
|
|
1016
|
+
// circular shell creation
|
|
1017
|
+
if (!(blobUrl = depLoad.s)) {
|
|
1018
|
+
blobUrl = depLoad.s = createBlob(
|
|
1019
|
+
\`export function u$_(m){\${depLoad.a[1]
|
|
1020
|
+
.map(({ s, e }, i) => {
|
|
1021
|
+
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
|
|
1022
|
+
return \`e$_\${i}=m\${q ? \`[\` : '.'}\${depLoad.S.slice(s, e)}\${q ? \`]\` : ''}\`;
|
|
1023
|
+
})
|
|
1024
|
+
.join(',')}}\${
|
|
1025
|
+
depLoad.a[1].length ? \`let \${depLoad.a[1].map((_, i) => \`e$_\${i}\`).join(',')};\` : ''
|
|
1026
|
+
}export {\${depLoad.a[1]
|
|
1027
|
+
.map(({ s, e }, i) => \`e$_\${i} as \${depLoad.S.slice(s, e)}\`)
|
|
1028
|
+
.join(',')}}\\n//# sourceURL=\${depLoad.r}?cycle\`
|
|
1029
|
+
);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
pushStringTo(load, start - 1, dynamicImportEndStack);
|
|
1034
|
+
resolvedSource += \`/*\${source.slice(start - 1, end + 1)}*/'\${blobUrl}'\`;
|
|
1035
|
+
|
|
1036
|
+
// circular shell execution
|
|
1037
|
+
if (!cycleShell && depLoad.s) {
|
|
1038
|
+
resolvedSource += \`;import*as m$_\${depIndex} from'\${depLoad.b}';import{u$_ as u$_\${depIndex}}from'\${depLoad.s}';u$_\${depIndex}(m$_\${depIndex})\`;
|
|
1039
|
+
depLoad.s = undefined;
|
|
1040
|
+
}
|
|
1041
|
+
lastIndex = keepAssertion ? end + 1 : statementEnd;
|
|
1042
|
+
}
|
|
1043
|
+
// import.meta
|
|
1044
|
+
else if (dynamicImportIndex === -2) {
|
|
1045
|
+
load.m = { url: load.r, resolve: metaResolve };
|
|
1046
|
+
if (metaHook) metaHook(load.m, load.u);
|
|
1047
|
+
pushStringTo(load, start, dynamicImportEndStack);
|
|
1048
|
+
resolvedSource += \`importShim._r[\${urlJsString(load.u)}].m\`;
|
|
1049
|
+
lastIndex = statementEnd;
|
|
1050
|
+
}
|
|
1051
|
+
// dynamic import
|
|
1052
|
+
else {
|
|
1053
|
+
pushStringTo(load, statementStart + 6, dynamicImportEndStack);
|
|
1054
|
+
resolvedSource += \`Shim\${t === 5 ? '.source' : ''}(\`;
|
|
1055
|
+
dynamicImportEndStack.push(statementEnd - 1);
|
|
1056
|
+
lastIndex = start;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// support progressive cycle binding updates (try statement avoids tdz errors)
|
|
1061
|
+
if (load.s && (imports.length === 0 || imports[imports.length - 1].d === -1))
|
|
1062
|
+
resolvedSource += \`\\n;import{u$_}from'\${load.s}';try{u$_({\${exports
|
|
1063
|
+
.filter(e => e.ln)
|
|
1064
|
+
.map(({ s, e, ln }) => \`\${source.slice(s, e)}:\${ln}\`)
|
|
1065
|
+
.join(',')}})}catch(_){};\\n\`;
|
|
1066
|
+
|
|
1067
|
+
let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
|
|
1068
|
+
let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
|
|
1069
|
+
|
|
1070
|
+
// ignore sourceMap comments before already spliced code
|
|
1071
|
+
if (sourceURLCommentStart < lastIndex) sourceURLCommentStart = -1;
|
|
1072
|
+
if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
|
|
1073
|
+
|
|
1074
|
+
// sourceURL first / only
|
|
1075
|
+
if (
|
|
1076
|
+
sourceURLCommentStart !== -1 &&
|
|
1077
|
+
(sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)
|
|
1078
|
+
) {
|
|
1079
|
+
pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
|
|
1080
|
+
}
|
|
1081
|
+
// sourceMappingURL
|
|
1082
|
+
if (sourceMapURLCommentStart !== -1) {
|
|
1083
|
+
pushSourceURL(load, sourceMapURLCommentPrefix, sourceMapURLCommentStart, dynamicImportEndStack);
|
|
1084
|
+
// sourceURL last
|
|
1085
|
+
if (sourceURLCommentStart !== -1 && sourceURLCommentStart > sourceMapURLCommentStart)
|
|
1086
|
+
pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
pushStringTo(load, source.length, dynamicImportEndStack);
|
|
1090
|
+
|
|
1091
|
+
if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
|
|
1092
|
+
|
|
1093
|
+
load.b = createBlob(resolvedSource);
|
|
1094
|
+
load.S = resolvedSource = undefined;
|
|
1095
|
+
};
|
|
1096
|
+
|
|
1097
|
+
const sourceURLCommentPrefix = '\\n//# sourceURL=';
|
|
1098
|
+
const sourceMapURLCommentPrefix = '\\n//# sourceMappingURL=';
|
|
1099
|
+
const cssUrlRegEx = /url\\(\\s*(?:(["'])((?:\\\\.|[^\\n\\\\"'])+)\\1|((?:\\\\.|[^\\s,"'()\\\\])+))\\s*\\)/g;
|
|
1100
|
+
|
|
1101
|
+
// restrict in-flight fetches to a pool of 100
|
|
1102
|
+
let p = [];
|
|
1103
|
+
let c = 0;
|
|
1104
|
+
const pushFetchPool = () => {
|
|
1105
|
+
if (++c > 100) return new Promise(r => p.push(r));
|
|
1106
|
+
};
|
|
1107
|
+
const popFetchPool = () => {
|
|
1108
|
+
c--;
|
|
1109
|
+
if (p.length) p.shift()();
|
|
1110
|
+
};
|
|
1111
|
+
|
|
1112
|
+
const doFetch = async (url, fetchOpts, parent) => {
|
|
1113
|
+
if (enforceIntegrity && !fetchOpts.integrity) throw Error(\`No integrity for \${url}\${fromParent(parent)}.\`);
|
|
1114
|
+
let res,
|
|
1115
|
+
poolQueue = pushFetchPool();
|
|
1116
|
+
if (poolQueue) await poolQueue;
|
|
1117
|
+
try {
|
|
1118
|
+
res = await fetchHook(url, fetchOpts);
|
|
1119
|
+
} catch (e) {
|
|
1120
|
+
e.message = \`Unable to fetch \${url}\${fromParent(parent)} - see network log for details.\\n\` + e.message;
|
|
1121
|
+
throw e;
|
|
1122
|
+
} finally {
|
|
1123
|
+
popFetchPool();
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
if (!res.ok) {
|
|
1127
|
+
const error = new TypeError(\`\${res.status} \${res.statusText} \${res.url}\${fromParent(parent)}\`);
|
|
1128
|
+
error.response = res;
|
|
1129
|
+
throw error;
|
|
1130
|
+
}
|
|
1131
|
+
return res;
|
|
1132
|
+
};
|
|
1133
|
+
|
|
1134
|
+
let esmsTsTransform;
|
|
1135
|
+
const initTs = async () => {
|
|
1136
|
+
const m = await import(tsTransform);
|
|
1137
|
+
if (!esmsTsTransform) esmsTsTransform = m.transform;
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1140
|
+
async function defaultSourceHook(url, fetchOpts, parent) {
|
|
1141
|
+
let res = await doFetch(url, fetchOpts, parent),
|
|
1142
|
+
contentType,
|
|
1143
|
+
[, json, type, jsts] =
|
|
1144
|
+
(contentType = res.headers.get('content-type') || '').match(
|
|
1145
|
+
/^(?:[^/;]+\\/(?:[^/+;]+\\+)?(json)|(?:text|application)\\/(?:x-)?((java|type)script|wasm|css))(?:;|$)/
|
|
1146
|
+
) || [];
|
|
1147
|
+
if (!(type = json || (jsts ? jsts[0] + 's' : type || (/\\.m?ts(\\?|#|$)/.test(url) && 'ts')))) {
|
|
1148
|
+
throw Error(
|
|
1149
|
+
\`Unsupported Content-Type "\${contentType}" loading \${url}\${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.\`
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
return {
|
|
1153
|
+
url: res.url,
|
|
1154
|
+
source: await (type > 'v' ? WebAssembly.compileStreaming(res) : res.text()),
|
|
1155
|
+
type
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
const hotPrefix = 'var h=import.meta.hot,';
|
|
1160
|
+
const fetchModule = async (reqUrl, fetchOpts, parent) => {
|
|
1161
|
+
const mapIntegrity = composedImportMap.integrity[reqUrl];
|
|
1162
|
+
fetchOpts = mapIntegrity && !fetchOpts.integrity ? { ...fetchOpts, integrity: mapIntegrity } : fetchOpts;
|
|
1163
|
+
let {
|
|
1164
|
+
url = reqUrl,
|
|
1165
|
+
source,
|
|
1166
|
+
type
|
|
1167
|
+
} = (await (sourceHook || defaultSourceHook)(reqUrl, fetchOpts, parent, defaultSourceHook)) || {};
|
|
1168
|
+
if (type === 'wasm') {
|
|
1169
|
+
const exports = WebAssembly.Module.exports((sourceCache[url] = source));
|
|
1170
|
+
const imports = WebAssembly.Module.imports(source);
|
|
1171
|
+
const rStr = urlJsString(url);
|
|
1172
|
+
source = \`import*as $_ns from\${rStr};\`;
|
|
1173
|
+
let i = 0,
|
|
1174
|
+
obj = '';
|
|
1175
|
+
for (const { module, kind } of imports) {
|
|
1176
|
+
const specifier = urlJsString(module);
|
|
1177
|
+
source += \`import*as impt\${i} from\${specifier};\\n\`;
|
|
1178
|
+
obj += \`\${specifier}:\${kind === 'global' ? \`importShim._i.get(impt\${i})||impt\${i++}\` : \`impt\${i++}\`},\`;
|
|
1179
|
+
}
|
|
1180
|
+
source += \`\${hotPrefix}i=await WebAssembly.instantiate(importShim._s[\${rStr}],{\${obj}});importShim._i.set($_ns,i);\`;
|
|
1181
|
+
obj = '';
|
|
1182
|
+
for (const { name, kind } of exports) {
|
|
1183
|
+
source += \`export let \${name}=i.exports['\${name}'];\`;
|
|
1184
|
+
if (kind === 'global') source += \`try{\${name}=\${name}.value}catch(_){\${name}=undefined}\`;
|
|
1185
|
+
obj += \`\${name},\`;
|
|
1186
|
+
}
|
|
1187
|
+
source += \`if(h)h.accept(m=>({\${obj}}=m))\`;
|
|
1188
|
+
} else if (type === 'json') {
|
|
1189
|
+
source = \`\${hotPrefix}j=JSON.parse(\${JSON.stringify(source)});export{j as default};if(h)h.accept(m=>j=m.default)\`;
|
|
1190
|
+
} else if (type === 'css') {
|
|
1191
|
+
source = \`\${hotPrefix}s=h&&h.data.s||new CSSStyleSheet();s.replaceSync(\${JSON.stringify(
|
|
1192
|
+
source.replace(
|
|
1193
|
+
cssUrlRegEx,
|
|
1194
|
+
(_match, quotes = '', relUrl1, relUrl2) => \`url(\${quotes}\${resolveUrl(relUrl1 || relUrl2, url)}\${quotes})\`
|
|
1195
|
+
)
|
|
1196
|
+
)});if(h){h.data.s=s;h.accept(()=>{})}export default s\`;
|
|
1197
|
+
} else if (type === 'ts') {
|
|
1198
|
+
if (!esmsTsTransform) await initTs();
|
|
1199
|
+
const transformed = esmsTsTransform(source, url);
|
|
1200
|
+
// even if the TypeScript is valid JavaScript, unless it was a top-level inline source, it wasn't served with
|
|
1201
|
+
// a valid JS MIME here, so we must still polyfill it
|
|
1202
|
+
source = transformed === undefined ? source : transformed;
|
|
1203
|
+
}
|
|
1204
|
+
return { url, source, type };
|
|
1205
|
+
};
|
|
1206
|
+
|
|
1207
|
+
const getOrCreateLoad = (url, fetchOpts, parent, source) => {
|
|
1208
|
+
if (source && registry[url]) {
|
|
1209
|
+
let i = 0;
|
|
1210
|
+
while (registry[url + '#' + ++i]);
|
|
1211
|
+
url += '#' + i;
|
|
1212
|
+
}
|
|
1213
|
+
let load = registry[url];
|
|
1214
|
+
if (load) return load;
|
|
1215
|
+
registry[url] = load = {
|
|
1216
|
+
// url
|
|
1217
|
+
u: url,
|
|
1218
|
+
// response url
|
|
1219
|
+
r: source ? url : undefined,
|
|
1220
|
+
// fetchPromise
|
|
1221
|
+
f: undefined,
|
|
1222
|
+
// source
|
|
1223
|
+
S: source,
|
|
1224
|
+
// linkPromise
|
|
1225
|
+
L: undefined,
|
|
1226
|
+
// analysis
|
|
1227
|
+
a: undefined,
|
|
1228
|
+
// deps
|
|
1229
|
+
d: undefined,
|
|
1230
|
+
// blobUrl
|
|
1231
|
+
b: undefined,
|
|
1232
|
+
// shellUrl
|
|
1233
|
+
s: undefined,
|
|
1234
|
+
// needsShim: does it fail execution in the current native loader?
|
|
1235
|
+
n: false,
|
|
1236
|
+
// shouldShim: does it need to be loaded by the polyfill loader?
|
|
1237
|
+
N: false,
|
|
1238
|
+
// type
|
|
1239
|
+
t: null,
|
|
1240
|
+
// meta
|
|
1241
|
+
m: null
|
|
1242
|
+
};
|
|
1243
|
+
load.f = (async () => {
|
|
1244
|
+
if (load.S === undefined) {
|
|
1245
|
+
// preload fetch options override fetch options (race)
|
|
1246
|
+
({ url: load.r, source: load.S, type: load.t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
|
|
1247
|
+
if (
|
|
1248
|
+
!load.n &&
|
|
1249
|
+
load.t !== 'js' &&
|
|
1250
|
+
!shimMode &&
|
|
1251
|
+
((load.t === 'css' && !supportsCssType) ||
|
|
1252
|
+
(load.t === 'json' && !supportsJsonType) ||
|
|
1253
|
+
(load.t === 'wasm' && !supportsWasmInstancePhase && !supportsWasmSourcePhase) ||
|
|
1254
|
+
load.t === 'ts')
|
|
1255
|
+
) {
|
|
1256
|
+
load.n = true;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
try {
|
|
1260
|
+
load.a = parse(load.S, load.u);
|
|
1261
|
+
} catch (e) {
|
|
1262
|
+
throwError(e);
|
|
1263
|
+
load.a = [[], [], false];
|
|
1264
|
+
}
|
|
1265
|
+
return load;
|
|
1266
|
+
})();
|
|
1267
|
+
return load;
|
|
1268
|
+
};
|
|
1269
|
+
|
|
1270
|
+
const featErr = feat =>
|
|
1271
|
+
Error(
|
|
1272
|
+
\`\${feat} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["\${feat}"] }<\${''}/script>\`
|
|
1273
|
+
);
|
|
1274
|
+
|
|
1275
|
+
const linkLoad = (load, fetchOpts) => {
|
|
1276
|
+
if (load.L) return;
|
|
1277
|
+
load.L = load.f.then(() => {
|
|
1278
|
+
let childFetchOpts = fetchOpts;
|
|
1279
|
+
load.d = load.a[0]
|
|
1280
|
+
.map(({ n, d, t, a, se }) => {
|
|
1281
|
+
const phaseImport = t >= 4;
|
|
1282
|
+
const sourcePhase = phaseImport && t < 6;
|
|
1283
|
+
if (phaseImport) {
|
|
1284
|
+
if (!shimMode && (sourcePhase ? !wasmSourcePhaseEnabled : !deferPhaseEnabled))
|
|
1285
|
+
throw featErr(sourcePhase ? 'wasm-module-sources' : 'import-defer');
|
|
1286
|
+
if (!sourcePhase || !supportsWasmSourcePhase) load.n = true;
|
|
1287
|
+
}
|
|
1288
|
+
let source = undefined;
|
|
1289
|
+
if (a > 0 && !shimMode && nativePassthrough) {
|
|
1290
|
+
const assertion = load.S.slice(a, se - 1);
|
|
1291
|
+
// no need to fetch JSON/CSS if supported, since it's a leaf node, we'll just strip the assertion syntax
|
|
1292
|
+
if (assertion.includes('json')) {
|
|
1293
|
+
if (supportsJsonType) source = '';
|
|
1294
|
+
else load.n = true;
|
|
1295
|
+
} else if (assertion.includes('css')) {
|
|
1296
|
+
if (supportsCssType) source = '';
|
|
1297
|
+
else load.n = true;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
if (d !== -1 || !n) return;
|
|
1301
|
+
const resolved = resolve(n, load.r || load.u);
|
|
1302
|
+
if (resolved.n || hasCustomizationHooks) load.n = true;
|
|
1303
|
+
if (d >= 0 || resolved.N) load.N = true;
|
|
1304
|
+
if (d !== -1) return;
|
|
1305
|
+
if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
|
|
1306
|
+
if (childFetchOpts.integrity) childFetchOpts = { ...childFetchOpts, integrity: undefined };
|
|
1307
|
+
const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, source), s: sourcePhase };
|
|
1308
|
+
// assertion case -> inline the CSS / JSON URL directly
|
|
1309
|
+
if (source === '') child.l.b = child.l.u;
|
|
1310
|
+
if (!child.s) linkLoad(child.l, fetchOpts);
|
|
1311
|
+
// load, sourcePhase
|
|
1312
|
+
return child;
|
|
1313
|
+
})
|
|
1314
|
+
.filter(l => l);
|
|
1315
|
+
});
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1318
|
+
const processScriptsAndPreloads = () => {
|
|
1319
|
+
for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]')) {
|
|
1320
|
+
if (!link.ep) processPreload(link);
|
|
1321
|
+
}
|
|
1322
|
+
for (const script of document.querySelectorAll('script[type]')) {
|
|
1323
|
+
if (script.type === 'importmap' + (shimMode ? '-shim' : '')) {
|
|
1324
|
+
if (!script.ep) processImportMap(script);
|
|
1325
|
+
} else if (script.type === 'module' + (shimMode ? '-shim' : '')) {
|
|
1326
|
+
legacyAcceptingImportMaps = false;
|
|
1327
|
+
if (!script.ep) processScript(script);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
|
|
1332
|
+
const getFetchOpts = script => {
|
|
1333
|
+
const fetchOpts = {};
|
|
1334
|
+
if (script.integrity) fetchOpts.integrity = script.integrity;
|
|
1335
|
+
if (script.referrerPolicy) fetchOpts.referrerPolicy = script.referrerPolicy;
|
|
1336
|
+
if (script.fetchPriority) fetchOpts.priority = script.fetchPriority;
|
|
1337
|
+
if (script.crossOrigin === 'use-credentials') fetchOpts.credentials = 'include';
|
|
1338
|
+
else if (script.crossOrigin === 'anonymous') fetchOpts.credentials = 'omit';
|
|
1339
|
+
else fetchOpts.credentials = 'same-origin';
|
|
1340
|
+
return fetchOpts;
|
|
1341
|
+
};
|
|
1342
|
+
|
|
1343
|
+
let lastStaticLoadPromise = Promise.resolve();
|
|
1344
|
+
|
|
1345
|
+
let domContentLoaded = false;
|
|
1346
|
+
let domContentLoadedCnt = 1;
|
|
1347
|
+
const domContentLoadedCheck = m => {
|
|
1348
|
+
if (m === undefined) {
|
|
1349
|
+
if (domContentLoaded) return;
|
|
1350
|
+
domContentLoaded = true;
|
|
1351
|
+
domContentLoadedCnt--;
|
|
1352
|
+
}
|
|
1353
|
+
if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselineSupport)) {
|
|
1354
|
+
document.removeEventListener('DOMContentLoaded', domContentLoadedEvent);
|
|
1355
|
+
document.dispatchEvent(new Event('DOMContentLoaded'));
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
let loadCnt = 1;
|
|
1359
|
+
const loadCheck = () => {
|
|
1360
|
+
if (--loadCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselineSupport)) {
|
|
1361
|
+
window.removeEventListener('load', loadEvent);
|
|
1362
|
+
window.dispatchEvent(new Event('load'));
|
|
1363
|
+
}
|
|
1364
|
+
};
|
|
1365
|
+
|
|
1366
|
+
const domContentLoadedEvent = async () => {
|
|
1367
|
+
await initPromise;
|
|
1368
|
+
domContentLoadedCheck();
|
|
1369
|
+
};
|
|
1370
|
+
const loadEvent = async () => {
|
|
1371
|
+
await initPromise;
|
|
1372
|
+
domContentLoadedCheck();
|
|
1373
|
+
loadCheck();
|
|
1374
|
+
};
|
|
1375
|
+
|
|
1376
|
+
// this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
|
|
1377
|
+
if (hasDocument) {
|
|
1378
|
+
document.addEventListener('DOMContentLoaded', domContentLoadedEvent);
|
|
1379
|
+
window.addEventListener('load', loadEvent);
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
const readyListener = async () => {
|
|
1383
|
+
await initPromise;
|
|
1384
|
+
processScriptsAndPreloads();
|
|
1385
|
+
if (document.readyState === 'complete') {
|
|
1386
|
+
readyStateCompleteCheck();
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1389
|
+
|
|
1390
|
+
let readyStateCompleteCnt = 1;
|
|
1391
|
+
const readyStateCompleteCheck = () => {
|
|
1392
|
+
if (--readyStateCompleteCnt === 0) {
|
|
1393
|
+
domContentLoadedCheck();
|
|
1394
|
+
if (!noLoadEventRetriggers && (shimMode || !baselineSupport)) {
|
|
1395
|
+
document.removeEventListener('readystatechange', readyListener);
|
|
1396
|
+
document.dispatchEvent(new Event('readystatechange'));
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1400
|
+
|
|
1401
|
+
const hasNext = script => script.nextSibling || (script.parentNode && hasNext(script.parentNode));
|
|
1402
|
+
const epCheck = (script, ready) =>
|
|
1403
|
+
script.ep ||
|
|
1404
|
+
(!ready && ((!script.src && !script.innerHTML) || !hasNext(script))) ||
|
|
1405
|
+
script.getAttribute('noshim') !== null ||
|
|
1406
|
+
!(script.ep = true);
|
|
1407
|
+
|
|
1408
|
+
const processImportMap = (script, ready = readyStateCompleteCnt > 0) => {
|
|
1409
|
+
if (epCheck(script, ready)) return;
|
|
1410
|
+
// we dont currently support external import maps in polyfill mode to match native
|
|
1411
|
+
if (script.src) {
|
|
1412
|
+
if (!shimMode) return;
|
|
1413
|
+
importMapSrc = true;
|
|
1414
|
+
}
|
|
1415
|
+
importMapPromise = importMapPromise
|
|
1416
|
+
.then(async () => {
|
|
1417
|
+
composedImportMap = resolveAndComposeImportMap(
|
|
1418
|
+
script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML),
|
|
1419
|
+
script.src || baseUrl,
|
|
1420
|
+
composedImportMap
|
|
1421
|
+
);
|
|
1422
|
+
})
|
|
1423
|
+
.catch(e => {
|
|
1424
|
+
if (e instanceof SyntaxError)
|
|
1425
|
+
e = new Error(\`Unable to parse import map \${e.message} in: \${script.src || script.innerHTML}\`);
|
|
1426
|
+
throwError(e);
|
|
1427
|
+
});
|
|
1428
|
+
if (!firstImportMap && legacyAcceptingImportMaps) importMapPromise.then(() => (firstImportMap = composedImportMap));
|
|
1429
|
+
if (!legacyAcceptingImportMaps && !multipleImportMaps) {
|
|
1430
|
+
multipleImportMaps = true;
|
|
1431
|
+
if (!shimMode && baselineSupport && !supportsMultipleImportMaps) {
|
|
1432
|
+
baselineSupport = false;
|
|
1433
|
+
if (hasDocument) attachMutationObserver();
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
legacyAcceptingImportMaps = false;
|
|
1437
|
+
};
|
|
1438
|
+
|
|
1439
|
+
const processScript = (script, ready = readyStateCompleteCnt > 0) => {
|
|
1440
|
+
if (epCheck(script, ready)) return;
|
|
1441
|
+
// does this load block readystate complete
|
|
1442
|
+
const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
|
|
1443
|
+
// does this load block DOMContentLoaded
|
|
1444
|
+
const isDomContentLoadedScript = domContentLoadedCnt > 0;
|
|
1445
|
+
const isLoadScript = loadCnt > 0;
|
|
1446
|
+
if (isLoadScript) loadCnt++;
|
|
1447
|
+
if (isBlockingReadyScript) readyStateCompleteCnt++;
|
|
1448
|
+
if (isDomContentLoadedScript) domContentLoadedCnt++;
|
|
1449
|
+
let loadPromise;
|
|
1450
|
+
const ts = script.lang === 'ts';
|
|
1451
|
+
if (ts && !script.src) {
|
|
1452
|
+
loadPromise = Promise.resolve(esmsTsTransform || initTs())
|
|
1453
|
+
.then(() => {
|
|
1454
|
+
const transformed = esmsTsTransform(script.innerHTML, baseUrl);
|
|
1455
|
+
if (transformed !== undefined) {
|
|
1456
|
+
onpolyfill();
|
|
1457
|
+
firstPolyfillLoad = false;
|
|
1458
|
+
}
|
|
1459
|
+
return topLevelLoad(
|
|
1460
|
+
script.src || baseUrl,
|
|
1461
|
+
baseUrl,
|
|
1462
|
+
getFetchOpts(script),
|
|
1463
|
+
transformed === undefined ? script.innerHTML : transformed,
|
|
1464
|
+
!shimMode && transformed === undefined,
|
|
1465
|
+
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1466
|
+
'ts'
|
|
1467
|
+
);
|
|
1468
|
+
})
|
|
1469
|
+
.catch(throwError);
|
|
1470
|
+
} else {
|
|
1471
|
+
loadPromise = topLevelLoad(
|
|
1472
|
+
script.src || baseUrl,
|
|
1473
|
+
baseUrl,
|
|
1474
|
+
getFetchOpts(script),
|
|
1475
|
+
!script.src ? script.innerHTML : undefined,
|
|
1476
|
+
!shimMode,
|
|
1477
|
+
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1478
|
+
ts ? 'ts' : undefined
|
|
1479
|
+
).catch(throwError);
|
|
1480
|
+
}
|
|
1481
|
+
if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
|
|
1482
|
+
if (isBlockingReadyScript && !ts) {
|
|
1483
|
+
lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
|
|
1484
|
+
}
|
|
1485
|
+
if (isDomContentLoadedScript) loadPromise.then(domContentLoadedCheck);
|
|
1486
|
+
if (isLoadScript) loadPromise.then(loadCheck);
|
|
1487
|
+
};
|
|
1488
|
+
|
|
1489
|
+
const fetchCache = {};
|
|
1490
|
+
const processPreload = link => {
|
|
1491
|
+
link.ep = true;
|
|
1492
|
+
initPromise.then(() => {
|
|
1493
|
+
if (baselineSupport && !shimMode) return;
|
|
1494
|
+
if (fetchCache[link.href]) return;
|
|
1495
|
+
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
|
|
1496
|
+
});
|
|
1497
|
+
};
|
|
1498
|
+
|
|
1499
|
+
})();
|
|
1500
|
+
`,hg=`/* Runs only in the opaque preview frame. All local reads use its directory capability. */
|
|
1501
|
+
function installPreviewRuntime(capability, base, externalOrigins, shimUrl) {
|
|
1502
|
+
const external = new Set(externalOrigins);
|
|
1503
|
+
const report = () => parent.postMessage({ type: 'preview-error', capability }, '*');
|
|
1504
|
+
const nativeFetch = window.fetch.bind(window);
|
|
1505
|
+
const nativeWorker = window.Worker;
|
|
1506
|
+
const externalUrl = value => {
|
|
1507
|
+
const url = new URL(value, base);
|
|
1508
|
+
const origin = url.protocol === 'wss:' ? 'https://' + url.host : url.origin;
|
|
1509
|
+
if (!external.has(origin)) throw new Error('Outside preview network scope');
|
|
1510
|
+
return url;
|
|
1511
|
+
};
|
|
1512
|
+
const bridgeFetch = async (input, init = {}) => {
|
|
1513
|
+
const url = new URL(typeof input === 'string' ? input : input.url || String(input), base);
|
|
1514
|
+
const method = String(init.method || (input && input.method) || 'GET').toUpperCase();
|
|
1515
|
+
if (url.protocol === 'blob:' || url.protocol === 'data:') return nativeFetch(input, init);
|
|
1516
|
+
if (url.origin !== new URL(base).origin) {
|
|
1517
|
+
externalUrl(url.href);
|
|
1518
|
+
return nativeFetch(url.href, { ...init, method, credentials: 'omit', referrerPolicy: 'no-referrer' });
|
|
1519
|
+
}
|
|
1520
|
+
if (!['GET', 'HEAD'].includes(method) || !url.pathname.startsWith(new URL(base).pathname)) throw new Error('Outside preview directory');
|
|
1521
|
+
return new Promise((resolve, reject) => {
|
|
1522
|
+
if (init.signal?.aborted) { reject(init.signal.reason); return; }
|
|
1523
|
+
const channel = new MessageChannel();
|
|
1524
|
+
const finish = () => { clearTimeout(timer); channel.port1.close(); init.signal?.removeEventListener('abort', abort); };
|
|
1525
|
+
const abort = () => { finish(); reject(init.signal.reason); };
|
|
1526
|
+
const timer = setTimeout(() => { finish(); report(); reject(new Error('Preview resource timeout')); }, 15000);
|
|
1527
|
+
init.signal?.addEventListener('abort', abort, { once: true });
|
|
1528
|
+
channel.port1.onmessage = event => {
|
|
1529
|
+
finish();
|
|
1530
|
+
if (event.data.error) { reject(new Error(event.data.error)); return; }
|
|
1531
|
+
const response = new Response(method === 'HEAD' ? null : event.data.data, { status: event.data.status, headers: event.data.headers });
|
|
1532
|
+
Object.defineProperty(response, 'url', { value: url.href }); resolve(response);
|
|
1533
|
+
};
|
|
1534
|
+
parent.postMessage({ type: 'preview-fetch', capability, url: url.href, method }, '*', [channel.port2]);
|
|
1535
|
+
});
|
|
1536
|
+
};
|
|
1537
|
+
Object.defineProperty(window, 'fetch', { configurable: false, writable: false, value: bridgeFetch });
|
|
1538
|
+
window.esmsInitOptions = { shimMode: true, nativePassthrough: false, fetch: bridgeFetch, onerror: report };
|
|
1539
|
+
class PreviewXHR extends EventTarget {
|
|
1540
|
+
readyState = 0; status = 0; statusText = ''; response = null; responseText = ''; responseURL = ''; responseType = ''; timeout = 0;
|
|
1541
|
+
upload = new EventTarget(); withCredentials = false;
|
|
1542
|
+
open(method, url, async = true) {
|
|
1543
|
+
if (!async) throw new Error('Synchronous preview requests are unavailable');
|
|
1544
|
+
this.abort(); this.method = method; this.url = new URL(url, base).href; this.headers = {}; this.readyState = 1; this.emit('readystatechange');
|
|
1545
|
+
}
|
|
1546
|
+
setRequestHeader(name, value) { this.headers[name] = value; }
|
|
1547
|
+
getAllResponseHeaders() { return this.responseHeaders ? [...this.responseHeaders].map(([key, value]) => key + ': ' + value + '\\r\\n').join('') : ''; }
|
|
1548
|
+
getResponseHeader(name) { return this.responseHeaders?.get(name) ?? null; }
|
|
1549
|
+
overrideMimeType(value) { this.mime = value; }
|
|
1550
|
+
emit(type, event = new Event(type)) { this.dispatchEvent(event); this['on' + type]?.call(this, event); }
|
|
1551
|
+
abort() { if (this.controller) { this.controller.abort(); this.controller = null; this.readyState = 0; this.emit('abort'); this.emit('loadend'); } }
|
|
1552
|
+
send(body = null) {
|
|
1553
|
+
const controller = new AbortController(); this.controller = controller;
|
|
1554
|
+
const timer = this.timeout > 0 ? setTimeout(() => { if (this.controller !== controller) return; controller.abort(); this.controller = null; this.emit('timeout'); this.emit('loadend'); }, this.timeout) : null;
|
|
1555
|
+
this.emit('loadstart');
|
|
1556
|
+
bridgeFetch(this.url, { method: this.method, headers: this.headers, body, signal: controller.signal }).then(async response => {
|
|
1557
|
+
this.status = response.status; this.statusText = response.statusText; this.responseURL = response.url; this.responseHeaders = response.headers;
|
|
1558
|
+
this.readyState = 2; this.emit('readystatechange'); this.readyState = 3; this.emit('readystatechange');
|
|
1559
|
+
const bytes = await response.arrayBuffer();
|
|
1560
|
+
if (this.controller !== controller) return;
|
|
1561
|
+
this.responseText = new TextDecoder().decode(bytes);
|
|
1562
|
+
this.response = this.responseType === 'arraybuffer' ? bytes : this.responseType === 'blob' ? new Blob([bytes], { type: this.mime || response.headers.get('content-type') || '' }) : this.responseType === 'json' ? (() => { try { return JSON.parse(this.responseText); } catch { return null; } })() : this.responseType === 'document' ? new DOMParser().parseFromString(this.responseText, 'text/html') : this.responseText;
|
|
1563
|
+
this.readyState = 4; this.emit('readystatechange'); this.emit('progress', new ProgressEvent('progress', { lengthComputable: true, loaded: bytes.byteLength, total: bytes.byteLength })); this.emit('load'); this.emit('loadend'); this.controller = null;
|
|
1564
|
+
}).catch(() => { if (this.controller !== controller) return; this.controller = null; this.status = 0; this.readyState = 4; this.emit('readystatechange'); this.emit('error'); this.emit('loadend'); }).finally(() => clearTimeout(timer));
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
for (const [key, value] of Object.entries({ UNSENT: 0, OPENED: 1, HEADERS_RECEIVED: 2, LOADING: 3, DONE: 4 })) { PreviewXHR[key] = value; PreviewXHR.prototype[key] = value; }
|
|
1568
|
+
Object.defineProperty(window, 'XMLHttpRequest', { configurable: false, writable: false, value: PreviewXHR });
|
|
1569
|
+
for (const name of ['WebSocket', 'EventSource']) {
|
|
1570
|
+
const Native = window[name];
|
|
1571
|
+
if (Native) Object.defineProperty(window, name, { configurable: false, writable: false, value: class extends Native {
|
|
1572
|
+
constructor(url, options) { super(externalUrl(url).href, name === 'EventSource' ? { withCredentials: false } : options); }
|
|
1573
|
+
} });
|
|
1574
|
+
}
|
|
1575
|
+
// A worker receives the same read-only bridge over a private MessagePort. Its
|
|
1576
|
+
// module graph is loaded by the same shim, including computed dynamic imports.
|
|
1577
|
+
class PreviewWorker extends EventTarget {
|
|
1578
|
+
constructor(url, options = {}) {
|
|
1579
|
+
super();
|
|
1580
|
+
const entry = new URL(url, base).href;
|
|
1581
|
+
const workerSource = \`(\${workerBootstrap.toString()})(\${JSON.stringify(entry)},\${JSON.stringify(options.type || 'classic')},\${JSON.stringify(shimUrl)});\`;
|
|
1582
|
+
this.objectUrl = URL.createObjectURL(new Blob([workerSource], { type: 'text/javascript' }));
|
|
1583
|
+
this.worker = new nativeWorker(this.objectUrl, { name: options.name });
|
|
1584
|
+
const channel = new MessageChannel(); this.port = channel.port1;
|
|
1585
|
+
this.port.onmessage = async event => {
|
|
1586
|
+
const { id, url, init } = event.data;
|
|
1587
|
+
try { const response = await bridgeFetch(url, init); const data = await response.arrayBuffer(); this.port.postMessage({ id, status: response.status, headers: [...response.headers], data }, [data]); }
|
|
1588
|
+
catch (error) { this.port.postMessage({ id, error: String(error) }); }
|
|
1589
|
+
};
|
|
1590
|
+
this.worker.postMessage({ previewInit: true, base: entry, importMap: window.importShim?.getImportMap?.() }, [channel.port2]);
|
|
1591
|
+
for (const type of ['message', 'messageerror', 'error']) this.worker.addEventListener(type, event => {
|
|
1592
|
+
const forwarded = type === 'error' ? new ErrorEvent(type, { message: event.message }) : new MessageEvent(type, { data: event.data, ports: event.ports });
|
|
1593
|
+
this.dispatchEvent(forwarded); this['on' + type]?.call(this, forwarded);
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
postMessage(value, transfer) { this.worker.postMessage(value, transfer); }
|
|
1597
|
+
terminate() { this.worker.terminate(); this.port.close(); URL.revokeObjectURL(this.objectUrl); }
|
|
1598
|
+
}
|
|
1599
|
+
function workerBootstrap(entry, type, shim) {
|
|
1600
|
+
const queued = []; let initialized = false, ready = false;
|
|
1601
|
+
const receive = event => {
|
|
1602
|
+
if (!event.data?.previewInit || initialized) { if (!ready) { event.stopImmediatePropagation(); queued.push(event); } return; }
|
|
1603
|
+
initialized = true; event.stopImmediatePropagation();
|
|
1604
|
+
const port = event.ports[0]; const pending = new Map(); let next = 0;
|
|
1605
|
+
port.onmessage = message => { const done = pending.get(message.data.id); if (!done) return; pending.delete(message.data.id); message.data.error ? done.reject(new Error(message.data.error)) : done.resolve(new Response(message.data.data, { status: message.data.status, headers: message.data.headers })); };
|
|
1606
|
+
self.fetch = (url, init = {}) => new Promise((resolve, reject) => { const id = ++next; pending.set(id, { resolve, reject }); port.postMessage({ id, url: new URL(typeof url === 'string' ? url : url.url || String(url), entry).href, init: { method: init.method || 'GET', headers: init.headers } }); });
|
|
1607
|
+
self.esmsInitOptions = { shimMode: true, nativePassthrough: false, fetch: self.fetch };
|
|
1608
|
+
const nativeImport = self.importScripts.bind(self);
|
|
1609
|
+
nativeImport(shim);
|
|
1610
|
+
if (event.data.importMap) self.importShim.addImportMap(event.data.importMap);
|
|
1611
|
+
const load = type === 'module' ? self.importShim(entry) : self.fetch(entry).then(r => r.text()).then(source => { const blob = URL.createObjectURL(new Blob([source], { type: 'text/javascript' })); nativeImport(blob); URL.revokeObjectURL(blob); });
|
|
1612
|
+
load.then(() => { ready = true; removeEventListener('message', receive); for (const message of queued) dispatchEvent(new MessageEvent('message', { data: message.data, ports: message.ports })); }).catch(error => setTimeout(() => { throw error; }));
|
|
1613
|
+
};
|
|
1614
|
+
addEventListener('message', receive);
|
|
1615
|
+
}
|
|
1616
|
+
Object.defineProperty(window, 'Worker', { configurable: false, writable: false, value: PreviewWorker });
|
|
1617
|
+
const navigate = value => {
|
|
1618
|
+
const url = new URL(value, base);
|
|
1619
|
+
if (url.origin === new URL(base).origin && url.pathname.startsWith(new URL(base).pathname)) parent.postMessage({ type: 'preview-navigate', capability, url: url.href }, '*');
|
|
1620
|
+
else { externalUrl(url.href); parent.postMessage({ type: 'preview-external', capability, url: url.href }, '*'); }
|
|
1621
|
+
};
|
|
1622
|
+
Object.defineProperty(window, 'open', { configurable: false, writable: false, value: value => { navigate(value); return null; } });
|
|
1623
|
+
document.addEventListener('click', event => { const anchor = event.target.closest?.('a,area'); const href = anchor?.getAttribute('href'); if (href && !href.startsWith('#')) { event.preventDefault(); navigate(href); } }, true);
|
|
1624
|
+
document.addEventListener('submit', event => {
|
|
1625
|
+
event.preventDefault(); const form = event.target;
|
|
1626
|
+
const url = new URL(form.getAttribute('action') || base, base);
|
|
1627
|
+
if ((form.getAttribute('method') || 'get').toLowerCase() !== 'get') { report(); return; }
|
|
1628
|
+
for (const [key, value] of new FormData(form)) if (typeof value === 'string') url.searchParams.append(key, value);
|
|
1629
|
+
navigate(url.href);
|
|
1630
|
+
}, true);
|
|
1631
|
+
window.addEventListener('securitypolicyviolation', report);
|
|
1632
|
+
window.addEventListener('error', report, true);
|
|
1633
|
+
window.addEventListener('unhandledrejection', report);
|
|
1634
|
+
}
|
|
1635
|
+
`,Va="/api/terminal/fs/preview/",mg=8*1024*1024,pg=32*1024*1024,gg=128,bg="data:,";function Mt(r){throw new Error(r)}function xg(r){return JSON.stringify(r).replace(/</g,"\\u003c")}async function Td(r,n,s){let l="",u=0;for(const d of r.matchAll(n))l+=r.slice(u,d.index)+await s(d),u=d.index+d[0].length;return l+r.slice(u)}async function Lu(r,n){const s=n.origin??location.origin,l=new URL(r,s);(l.origin!==s||!js(l.pathname)?.startsWith(Va))&&Mt("预览地址不是有效的本地文件入口");const u=crypto.randomUUID(),d=`https://termdock-preview.invalid/${u}/`,h=[],m=W=>{!h.includes(W)&&h.length<20&&h.push(W)},g=new Set,b=[],f=new Set,S=new Map,y=new Map;let N=0,I=!1;const _=new Set,B=()=>{I=!0;for(const W of[..._])W();g.clear(),b.length=0};async function $(W){W.ok||Mt(`预览资源读取失败(${W.status})`);const X=W.body?.getReader(),L=[];let F=0;try{if(X)for(;;){const ie=await X.read();if(ie.done)break;F+=ie.value.byteLength,N+=ie.value.byteLength,(F>mg||N>pg)&&Mt("预览资源超出大小限制"),L.push(ie.value)}}catch(ie){throw await X?.cancel().catch(()=>{}),ie}finally{X?.releaseLock()}const q=new Uint8Array(F);let se=0;for(const ie of L)q.set(ie,se),se+=ie.length;return{bytes:q,type:W.headers.get("content-type")??"application/octet-stream",status:W.status}}let E=l,A;for(let W=0;W<4;W++){const X=await n.fetch(E.pathname+E.search,{signal:n.signal,redirect:"manual"});if(![301,302,303,307,308].includes(X.status)){A=X;break}const L=X.headers.get("location");await X.body?.cancel(),L||Mt("预览重定向缺少目标");const F=new URL(L,E);(F.origin!==s||!js(F.pathname)?.startsWith(Va))&&Mt("预览重定向越出文件范围"),E=F}A||Mt("预览重定向次数过多");const T=js(E.pathname),U=T.slice(Va.length).split("/");/^[a-f0-9]{32}$/.test(U[0])||Mt("服务未提供有效的预览资源授权");const D=js(l.pathname).slice(Va.length).split("/");/^[a-f0-9]{32}$/.test(D[0])&&D.shift(),D.join("/").replace(/\/$/,"")!==U.slice(1).join("/").replace(/\/$/,"")&&Mt("预览重定向改变了文件范围");const p=T.endsWith("/")?T:T.slice(0,T.lastIndexOf("/")+1),i=new URL(E.pathname.endsWith("/")?E.pathname:E.pathname.slice(0,E.pathname.lastIndexOf("/")+1),s);function O(W,X){const L=new URL(W,X);return L.origin!==s?null:(js(L.pathname)?.startsWith(p)||Mt("已阻止预览访问目录之外的资源"),L)}function C(W){const X=new URL(W,d);(X.origin!==new URL(d).origin||!X.pathname.startsWith(new URL(d).pathname))&&Mt("已阻止预览访问服务接口或目录之外的资源");const L=X.pathname.slice(new URL(d).pathname.length)+X.search;return O(L,i)??Mt("预览资源无效")}function K(W){const X=W.pathname+W.search,L=S.get(X);if(L)return L;if(I||n.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(S.size>=gg)return Promise.reject(new Error("预览资源数量超出限制"));const F=n.fetch(X,{signal:n.signal,redirect:"manual"}).then($);return S.set(X,F),F}function de(W,X){I&&Mt("预览已关闭");const L=`termdock-resource-${u}-${b.length}`;return b.push({token:L,data:W,type:X}),g.add(L),L}async function ne(W,X,L,F=new Set){if(!W||W.startsWith("#")||/^data:(?:image|font)\//i.test(W)&&L==="resource")return W;try{const q=O(W,X);if(!q){const Pe=new URL(W,X);return(Pe.protocol!=="https:"||Pe.username||Pe.password||Pe.origin===new URL(d).origin)&&Mt("已阻止不安全的外部资源"),f.add(Pe.origin),Pe.href}const se=`${L}:${q.href}`;(F.has(se)||F.size>=8)&&Mt("预览资源存在循环或过深引用");const ie=y.get(se);if(ie)return ie;const me=new Set(F);me.add(se);const ge=(async()=>{const Pe=await K(q);return L==="css"?de(await ve(new TextDecoder().decode(Pe.bytes),q,me),"text/css"):L==="script"?de(Pe.bytes,"text/javascript"):de(Pe.bytes,Pe.type)})();return y.set(se,ge),await ge}catch(q){return m(q instanceof Error?q.message:"部分预览资源未能加载"),bg}}async function ve(W,X,L){return W=await Td(W,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async F=>`@import url("${await ne(F[1],X,"css",L)}")${F[2]};`),Td(W,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async F=>{const q=(F[1]??F[2]??F[3]).trim();return g.has(q)?F[0]:`url("${await ne(q,X,"resource",L)}")`})}try{const W=await $(A),X=de(fg,"text/javascript"),L=new DOMParser().parseFromString(new TextDecoder().decode(W.bytes),"text/html");L.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(M=>M.remove());for(const M of L.querySelectorAll("*")){if(M.removeAttribute("ping"),M.removeAttribute("srcdoc"),M.hasAttribute("style")&&M.setAttribute("style",await ve(M.getAttribute("style"),E,new Set)),M.tagName==="STYLE"&&(M.textContent=await ve(M.textContent??"",E,new Set)),M.tagName==="A"||M.tagName==="AREA"){const ee=M.getAttribute("href");try{if(ee&&!ee.startsWith("#")){const be=O(ee,E);if(be)M.setAttribute("href",new URL(be.pathname.slice(i.pathname.length)+be.search+be.hash,d).href);else{const Le=new URL(ee,E);if(Le.protocol!=="https:"){M.removeAttribute("href");continue}f.add(Le.origin),M.setAttribute("href",Le.href)}}}catch(be){M.removeAttribute("href"),m(be instanceof Error?be.message:"预览链接无法加载")}}for(const ee of["data","manifest"])M.removeAttribute(ee);if(M.tagName==="SCRIPT"&&M.getAttribute("type")==="module"){M.setAttribute("type","module-shim");const ee=M.getAttribute("src");if(ee){const be=O(ee,E);if(be)M.setAttribute("src",new URL(be.pathname.slice(i.pathname.length)+be.search,d).href);else{const Le=new URL(ee,E);if(Le.protocol!=="https:"){M.remove();continue}f.add(Le.origin),M.setAttribute("src",Le.href)}}continue}if(M.tagName==="SCRIPT"&&M.getAttribute("type")==="importmap"){M.setAttribute("type","importmap-shim");continue}if(M.tagName==="LINK"){const ee=(M.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(ee)){M.remove();continue}const be=M.getAttribute("href");be&&M.setAttribute("href",await ne(be,E,ee==="stylesheet"?"css":"resource"))}if(M.hasAttribute("src")&&M.setAttribute("src",await ne(M.getAttribute("src"),E,M.tagName==="SCRIPT"?"script":"resource")),M.hasAttribute("poster")&&M.setAttribute("poster",await ne(M.getAttribute("poster"),E,"resource")),M.hasAttribute("srcset")){const ee=M.getAttribute("srcset");/data:/i.test(ee)?(M.removeAttribute("srcset"),m("混合内嵌图片候选暂不支持安全预览")):M.setAttribute("srcset",(await Promise.all(ee.split(",").map(async be=>{const[Le,...Xe]=be.trim().split(/\s+/);return`${await ne(Le,E,"resource")} ${Xe.join(" ")}`}))).join(", "))}M.setAttribute("referrerpolicy","no-referrer"),M.removeAttribute("integrity"),M.removeAttribute("crossorigin")}const F=[...f].join(" "),q=L.createElement("meta");q.httpEquiv="Content-Security-Policy",q.content=`default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${F}; style-src 'unsafe-inline' blob: ${F}; img-src blob: data: ${F}; font-src blob: data: ${F}; media-src blob: data: ${F}; connect-src blob: ${F} ${[...f].map(M=>M.replace(/^https:/,"wss:")).join(" ")}; worker-src blob:; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const se=L.createElement("base");se.href=d;const ie=L.createElement("meta");ie.name="referrer",ie.content="no-referrer";const me=L.createElement("script");me.textContent=hg+`
|
|
1636
|
+
installPreviewRuntime(`+[u,d,[...f],X].map(xg).join(",")+");";const ge=L.createElement("script");ge.src=X,L.head.prepend(q,ie,se,me,ge);const Pe=`<!doctype html>
|
|
1637
|
+
`+L.documentElement.outerHTML;return{html:Pe,shellUrl:`/preview-shell.html#${u}`,errors:h,attach(M,ee){const be=new Set,Le=Ee=>{if(Ee.source!==M.contentWindow||Ee.data?.capability!==u)return;if(Ee.data.type==="preview-ready"){M.contentWindow?.postMessage({type:"preview-init",capability:u,html:Pe,resources:b},"*");return}if(Ee.data.type==="preview-error"){ee("部分动态内容被安全预览限制");return}if(Ee.data.type==="preview-navigate"){(async()=>{const Fe=C(String(Ee.data.url)),R=await Lu(Fe.pathname+Fe.search,n);if(I){R.dispose();return}const te=R.attach(M,ee);_.add(()=>{te(),R.dispose()}),M.src=R.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(Fe=>ee(Fe instanceof Error?Fe.message:"无法打开预览页面"));return}if(Ee.data.type==="preview-external"){try{const Fe=new URL(String(Ee.data.url));Fe.protocol==="https:"&&f.has(Fe.origin)&&window.open(Fe.href,"_blank","noopener,noreferrer")}catch{}return}if(Ee.data.type!=="preview-fetch"||Ee.ports.length!==1)return;const Qe=Ee.ports[0];if(be.size>=8||!["GET","HEAD"].includes(Ee.data.method)){Qe.postMessage({error:"预览仅允许读取已授权目录资源"}),Qe.close();return}be.add(Qe),(async()=>{const Fe=C(String(Ee.data.url)),R=await K(Fe);if(!be.has(Qe)||I)return;const te=Ee.data.method==="HEAD"?new Uint8Array:R.bytes.slice();Qe.postMessage({status:R.status,headers:{"content-type":R.type},data:te.buffer},[te.buffer])})().catch(()=>{Qe.postMessage({error:"预览资源不在授权范围或无法加载"}),ee("部分动态资源不可用或超出预览目录")}).finally(()=>{be.delete(Qe),Qe.close()})};window.addEventListener("message",Le);const Xe=()=>{window.removeEventListener("message",Le);for(const Ee of be)Ee.close();be.clear(),_.delete(Xe)};return _.add(Xe),Xe},dispose:B}}catch(W){throw B(),W}}const vg=a.forwardRef(function({src:n,title:s,exitFullscreenLabel:l,onFullscreenChange:u},d){const h=a.useRef(null),[m,g]=a.useState(null),[b,f]=a.useState(),[S,y]=a.useState("");a.useEffect(()=>{const T=new AbortController;let U;return f(void 0),y(""),(async()=>{const D=await Vh();if(U=await Lu(n,{fetch:(p,i)=>D.fetch(p,i),signal:T.signal}),T.signal.aborted){U.dispose();return}f(U),U.errors.length&&y(U.errors.join(";"))})().catch(D=>{T.signal.aborted||y(D instanceof Error?D.message:"安全预览加载失败")}),()=>{T.abort(),U?.dispose()}},[n]),a.useEffect(()=>{if(!(!b||!m))return b.attach(m,y)},[b,m]);const[N,I]=a.useState(!1),[_,B]=a.useState(!1),$=N||_;a.useEffect(()=>{u?.($)},[$,u]),a.useEffect(()=>{const T=()=>{I(document.fullscreenElement===h.current)};return document.addEventListener("fullscreenchange",T),()=>document.removeEventListener("fullscreenchange",T)},[]),a.useEffect(()=>{if(!_)return;const T=U=>{U.key==="Escape"&&B(!1)};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[_]);const E=a.useCallback(async()=>{const T=h.current;if(T){if(_){B(!1);return}if(document.fullscreenElement===T){await document.exitFullscreen();return}if(T.requestFullscreen&&document.fullscreenEnabled!==!1)try{await T.requestFullscreen();return}catch{}B(!0)}},[_]);a.useImperativeHandle(d,()=>({toggleFullscreen:E}),[E]);const A=e.jsxs("div",{ref:h,"data-html-preview-frame":!0,className:$?"fixed inset-0 z-modal-panel flex min-h-0 flex-col overflow-hidden bg-surface pt-[env(safe-area-inset-top,0px)] text-foreground":"flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[$&&e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/15 bg-[var(--chrome-bg)] px-3",children:[e.jsx("span",{className:"min-w-0 truncate text-[12px] font-semibold",children:s}),e.jsx("button",{type:"button",onClick:()=>{E()},"aria-label":l,title:`${l} (Esc)`,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:e.jsx(vu,{size:15})})]}),S&&e.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:S}),!b&&!S&&e.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),e.jsx("iframe",{ref:g,src:b?.shellUrl,referrerPolicy:"no-referrer",title:s,sandbox:"allow-scripts",className:"block min-h-0 w-full flex-1 border-0 bg-white"})]});return _?Yr.createPortal(A,document.body):A}),Au="termdock-file-search-match",qi="termdock-file-search-current";function yg(r){const n=r.metaKey||r.ctrlKey,s=r.key.toLocaleLowerCase();return n&&s==="f"?"open":n&&s==="g"||r.key==="F3"?r.shiftKey?"previous":"next":r.key==="Escape"?"close":null}function wg(r){return r.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function kg(r,n){const s=n.trim().toLocaleLowerCase();if(!s)return[];const l=[];let u="",d=null;const h=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);for(let f=h.nextNode();f;f=h.nextNode()){if(!(f instanceof Text)||!f.data)continue;const S=wg(f);if(!S)continue;d&&d!==S&&(u+=`
|
|
1638
|
+
`);const y=u.length;u+=f.data,l.push({node:f,start:y,end:u.length,group:S}),d=S}const m=u.toLocaleLowerCase(),g=[];let b=0;for(;b<=m.length-s.length;){const f=m.indexOf(s,b);if(f<0)break;const S=f+s.length,y=l.find(I=>I.start<=f&&I.end>f),N=l.find(I=>I.start<S&&I.end>=S);if(y&&N&&y.group===N.group){const I=document.createRange();I.setStart(y.node,f-y.start),I.setEnd(N.node,S-N.start),g.push(I)}b=f+Math.max(s.length,1)}return g}function Pu(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function qa(){const r=Pu();r?.delete(Au),r?.delete(qi)}function Id(r,n){const s=Pu();if(!s||typeof Highlight>"u")return;s.set(Au,new Highlight(...r));const l=r[n];l?s.set(qi,new Highlight(l)):s.delete(qi)}function Dd(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function Sg(r){return Array.from(new Set(r.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function jg(r,n){const s=n.trim();return!s||s==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Rg(r,n){if(n===r)return".";const s=`${r.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function Tu(r,n,s){return n?r:Yr.createPortal(r,s)}const il="termdock:right-sidebar:file-tree-scroll:v1",ll="termdock:right-sidebar:file-preview-reading-state:v1",Ls="termdock:right-sidebar:file-tree-width:v1",Iu="termdock:right-sidebar:markdown-view-mode:v1",Du="termdock:right-sidebar:diff-change-list-mode:v1",Fu="termdock:right-sidebar:diff-wrap:v1",_u="termdock:diff-viewer:view-type:v1",Bu="termdock:right-sidebar:file-search-mode:v1",yi="termdock:right-sidebar:collapsed-git-repo-groups:v1",Fd="termdock:right-sidebar:collapsed-diff-directories:v1",wi="termdock:right-sidebar:branch-audit-module-open:v1",Ou="termdock:right-sidebar:branch-audit-module:v1",Cg=150,_d="termdock:right-sidebar:context-draft-enabled:v1",Bd="termdock:right-sidebar:context-draft-collapsed:v1",Od="termdock:right-sidebar:context-draft-auto-collapse:v1",ki="termdock:right-sidebar:context-draft-text:v1",Ng=300,Eg=20,Mg=120,$g=250,Lg=250,Ag=120,Pg=700,Si=600,Tg=6e4;function Ns(r){return!!(r&&J.getState().nestedGitScanRoots[r])}const Ud=[2e3,5e3,15e3,3e4],Ig=320,Dg=500,Fg=20,_g=12e3,Yi=300,Hd=240,Bg=560,Uu="border-r px-2 py-1.5 sm:px-3 sm:py-2",lo="min-w-full max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",Hu=`${Uu} border-b border-border/15 font-semibold last:border-r-0`,zu=`${Uu} border-border/10 align-top text-muted-foreground last:border-r-0`,cl="termdock-file-preview-horizontal-scroll",zd=a.lazy(()=>Bs(()=>import("./ModelPreview-DtR_DlQF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Wu=`${cl} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function Gu(r,n,s){return r&&!n?"unified":s}const Og=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function Ug(r){return r==="preview"||r==="source"}function Hg(r){return r==="list"||r==="tree"||r==="ai"}function Wd(){return ht(Iu,Ug)??"preview"}function zg(){return ht(Du,Hg)??"tree"}function As(r){return typeof r=="boolean"}function Wg(r){return typeof r=="string"}function Gg(){return ht(Fu,As)??!0}function Kg(r){return r==="unified"||r==="split"}function Vg(){return ht(_u,Kg)??"unified"}function qg(r){return r==="name"||r==="content"||r==="regex"}function Yg(){return ht(Bu,qg)??"name"}function Ku(r){return r.repositories??(r.context?.root?[{id:r.context.root,root:r.context.root,relativeRoot:".",name:wt(r.context.root)||r.context.root,depth:0,nested:!1,available:r.available,files:r.files,context:r.context,error:r.error}]:[])}function Xg(r,n){if(!n)return null;const s=new Set((r.repoFilters??[]).map(l=>l.root));return s.has(n)?n:s.size>0?null:(r.repositories??[]).some(l=>l.root===n)?n:null}function Xi(r){return!r.activeGitRepoRoot&&(r.groupCount>1||r.label!==r.rootName)}function Vu(...r){const n=new Set;for(const s of r)for(const l of s)n.add(l.root);return n}function Ji(r){return Array.isArray(r)&&r.every(n=>typeof n=="string")}function Gd(r){const n=ht(r,Ji);return n?new Set(n):new Set}function ji(r,n){$t(r,[...n])}function Jg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.filePath=="string"&&typeof n.hunkHeader=="string"&&typeof n.hunkIndex=="number"&&typeof n.fingerprint=="string"&&typeof n.additions=="number"&&typeof n.deletions=="number"&&typeof n.diff=="string"&&(n.oldPath===void 0||n.oldPath===null||typeof n.oldPath=="string")&&(n.newPath===void 0||n.newPath===null||typeof n.newPath=="string")&&(n.source===void 0||n.source==="committed"||n.source==="uncommitted"||n.source==="unknown")&&(n.commit===void 0||n.commit===null||typeof n.commit=="string")}function Qg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.available=="boolean"&&(n.repoRoot===void 0||typeof n.repoRoot=="string")&&(n.workspaceRoot===void 0||typeof n.workspaceRoot=="string")&&(n.baseRef===void 0||typeof n.baseRef=="string")&&(n.baseBranch===void 0||typeof n.baseBranch=="string")&&(n.currentBranch===void 0||n.currentBranch===null||typeof n.currentBranch=="string")&&(n.headRef===void 0||n.headRef===null||typeof n.headRef=="string")&&(n.diffFingerprint===void 0||typeof n.diffFingerprint=="string")&&(n.stat===void 0||typeof n.stat=="string")&&(n.files===void 0||Ji(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(Jg))&&(n.commits===void 0||Ji(n.commits))&&(n.commitCount===void 0||typeof n.commitCount=="number")&&(n.diff===void 0||typeof n.diff=="string")&&(n.truncated===void 0||typeof n.truncated=="boolean")&&(n.error===void 0||typeof n.error=="string")}function Zg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.key=="string"&&Qg(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function eb(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(n=>{if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;return Array.isArray(s.selectedRepoRoots)&&s.selectedRepoRoots.every(l=>typeof l=="string")&&!!s.repoTargetBranches&&typeof s.repoTargetBranches=="object"&&!Array.isArray(s.repoTargetBranches)&&Object.values(s.repoTargetBranches).every(l=>typeof l=="string")&&(s.repoBaseBranches===void 0||!!s.repoBaseBranches&&typeof s.repoBaseBranches=="object"&&!Array.isArray(s.repoBaseBranches)&&Object.values(s.repoBaseBranches).every(l=>typeof l=="string"))&&(s.previewEntries===void 0||Array.isArray(s.previewEntries)&&s.previewEntries.every(Zg))&&(s.selectedPreviewKey===void 0||s.selectedPreviewKey===null||typeof s.selectedPreviewKey=="string")&&(s.selectedPreviewFileKey===void 0||s.selectedPreviewFileKey===null||typeof s.selectedPreviewFileKey=="string")&&(s.previewDetailOpen===void 0||typeof s.previewDetailOpen=="boolean")&&(s.previewScrollTops===void 0||!!s.previewScrollTops&&typeof s.previewScrollTops=="object"&&!Array.isArray(s.previewScrollTops)&&Object.values(s.previewScrollTops).every(l=>typeof l=="number"))&&(s.previewMobileSlideIndex===void 0||typeof s.previewMobileSlideIndex=="number")&&(s.repoIncludeUncommitted===void 0||!!s.repoIncludeUncommitted&&typeof s.repoIncludeUncommitted=="object"&&!Array.isArray(s.repoIncludeUncommitted)&&Object.values(s.repoIncludeUncommitted).every(l=>typeof l=="boolean"))&&(s.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function Kd(){return ht(Ou,eb)??{}}function Vd(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function qd(r){const n=r?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function qu(r,n){const s=r?.trim(),l=n?.trim();return!s||!l?!1:s===l||qd(s)===qd(l)}function Yd(r){const n=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(l=>l&&!qu(l,n))??""}function Qi(r,n){const s=Math.max(Hd,n-320),l=Math.min(Bg,s);return Math.min(l,Math.max(Hd,r))}function tb(r){return typeof r=="number"&&Number.isFinite(r)}function rb(r){return Qi(ht(Ls,tb)??Yi,r)}function Yu(r){const n=r.split(/[\\/]/).pop()??r,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function Es(r){return Og.has(Yu(r))}function Xu(r){const n=r.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function Zi(r){const n=r.trim();return/^#{1,6}\s+/.test(n)||Xu(r)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function Ju(r){const n=r.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const Qu=a.createContext(null);function so(r){return r.trim().replace(/\s+/g," ").toLowerCase()}function Zu(r){return r.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function ef(r){return r.replace(/\s+#+\s*$/,"").trim()}function el(r,n){const l=Zu(r).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",u=n.headingSlugCounts.get(l)??0;return n.headingSlugCounts.set(l,u+1),u===0?l:`${l}-${u}`}function Xd(r){return Zu(r)||r.trim()}function co(r){const n=r.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=rl(n[2]);return s?{id:so(n[1]),definition:{href:s.href,title:s.title}}:null}function nb(r){const n=new Map;for(const s of r){const l=co(s);l&&n.set(l.id,l.definition)}return n}function tf(r){return r.trim().toLowerCase()}function rf(r){const n=r.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:tf(n[1]),text:n[2]}:null}function sb(r){const n=new Map;let s=null;for(const l of r){const u=rf(l);if(u){s=u.id,n.set(u.id,{id:u.id,text:u.text,index:n.size+1});continue}if(s&&/^\s{4,}\S/.test(l)){const d=n.get(s);d&&(d.text=`${d.text} ${l.trim()}`);continue}l.trim()&&(s=null)}return n}function nf(r){const n=new Set;let s=!1;return r.forEach((l,u)=>{if(rf(l)){n.add(u),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(u);return}l.trim()&&(s=!1)}),n}function ab(r){const n=[...r];let s=0;const l=r[0]?.trim();if(l==="---"||l==="+++"){for(n[0]="",s=1;s<r.length&&r[s].trim()!==l;)n[s]="",s+=1;s<r.length&&(n[s]="",s+=1)}for(;s<r.length;){const u=r[s].trim();if(u.startsWith("<!--")){if(n[s]="",!u.includes("-->")){for(s+=1;s<r.length&&!r[s].includes("-->");)n[s]="",s+=1;s<r.length&&(n[s]="")}s+=1;continue}s+=1}return n}function sf(r){const n=r.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function Is(r){const n=r.split(/[?#]/,1)[0],s=n.startsWith("/"),l=[];for(const d of n.split("/"))if(!(!d||d===".")){if(d===".."){l.length>0&&l.pop();continue}l.push(d)}return`${s?"/":""}${l.join("/")}`||(s?"/":".")}function dl(r,n,s){const l=r.trim();if(!l||/^(?:https?:|mailto:|javascript:|data:)/i.test(l)||/^[a-z][a-z0-9+.-]*:/i.test(l))return null;if(l.startsWith("#")){if(!n)return null;try{return{path:n,fragment:decodeURIComponent(l.slice(1))||null,directory:!1}}catch{return null}}const u=l.indexOf("#"),d=u>=0?l.slice(0,u):l,h=u>=0?l.slice(u+1):"",m=d.split("?",1)[0];if(!m)return null;let g,b=null;try{g=decodeURIComponent(m),b=h?decodeURIComponent(h):null}catch{return null}const f=s?Is(s):null;let S;if(g.startsWith("/")){const y=f&&(g===f||g.startsWith(`${f}/`));S=Is(f&&!y?`${f}/${g.slice(1)}`:g)}else{if(!n)return null;S=Is(`${sf(n)}/${g}`)}return f&&S!==f&&!S.startsWith(`${f}/`)?null:{path:S,fragment:b,directory:/\/$/.test(m)}}function ul(r,n,s,l,u){const d=r.trim();if(!d||/^(?:javascript|data):/i.test(d))return null;if(/^https?:\/\//i.test(d))return d;if(!l(d.split(/[?#]/,1)[0]))return null;let h;if(d.startsWith("/")){const m=s&&(d===s||d.startsWith(`${s}/`));h=Is(s&&!m?`${s}/${d.slice(1)}`:d)}else{if(!n)return null;h=Is(`${sf(n)}/${d}`)}return u(h)}function ob(r,n,s){return ul(r,n,s,ol,l=>`/api/terminal/fs/blob?path=${encodeURIComponent(l)}`)}function ib(r,n,s){return ul(r,n,s,cu,du)}const tl=128,lb=360,Ri=480;function xo(r){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(r))}catch{return!1}}function af(r,n,s,l,u=0){if(!n||!s)return null;let d,h;return u>0?(d=l>0?Math.min(u,l):u,h=s*d/n):xo(r)?(h=Math.min(Math.max(s,tl),lb),d=n*h/s):(d=n,h=s),l>0&&d>l&&(h=h*l/d,d=l),h>Ri&&(d=d*Ri/h,h=Ri),{width:Math.max(1,Math.round(d)),height:Math.max(1,Math.round(h))}}function cb(r){if(!r.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(r.slice(r.indexOf("?"))).get("path")}catch{return null}}function of(r){const n=cb(r),s=J(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${r}&v=${s}`:r}function db({src:r,alt:n,title:s,requestedWidthPx:l}){const u=xo(r),d=of(r),h=go(d),m=a.useRef(null),[g,b]=a.useState(!1),[f,S]=a.useState(0),[y,N]=a.useState({status:"loading"}),[I,_]=a.useState(null);a.useLayoutEffect(()=>{const E=m.current,A=E?.parentElement?.parentElement??E?.parentElement;if(!A)return;const T=()=>S(A.clientWidth);if(T(),typeof ResizeObserver>"u")return;const U=new ResizeObserver(T);return U.observe(A),()=>U.disconnect()},[]),a.useEffect(()=>{if(g)return;const E=m.current;if(!E||typeof IntersectionObserver>"u"){b(!0);return}const A=new IntersectionObserver(T=>{T.some(U=>U.isIntersecting)&&(b(!0),A.disconnect())},{rootMargin:"400px"});return A.observe(E),()=>A.disconnect()},[g]),a.useEffect(()=>{if(!g)return;const E=new AbortController;let A=null;N({status:"loading"});const T=window.setTimeout(()=>{E.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return wm(d,{signal:E.signal}).then(async U=>{if(!U.ok)throw new Error(`HTTP ${U.status}`);const D=Number(U.headers.get("X-Image-Width"))||0,p=Number(U.headers.get("X-Image-Height"))||0;return{blob:await U.blob(),width:D,height:p}}).then(({blob:U,width:D,height:p})=>{E.signal.aborted||(A=URL.createObjectURL(U),D>0&&p>0&&_({width:D,height:p}),N({status:"ready",objectUrl:A}))}).catch(()=>{const U=E.signal.reason;E.signal.aborted&&!(U instanceof DOMException&&U.name==="TimeoutError")||N({status:"fallback"})}).finally(()=>{window.clearTimeout(T)}),()=>{window.clearTimeout(T),E.abort(),A&&URL.revokeObjectURL(A)}},[g,d]);const B=af(r,I?.width??0,I?.height??0,f,l??0),$=B??(l?{width:f>0?Math.min(l,f):l,height:Math.round(l*.75)}:{width:tl*2,height:tl});return e.jsx("div",{ref:m,className:"block max-w-full",style:B?{width:B.width,height:B.height}:void 0,children:y.status==="ready"?e.jsx("img",{src:y.objectUrl,alt:n,title:s,decoding:"async",className:`${u?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:B?{width:B.width,height:B.height}:void 0,onLoad:E=>{if(I)return;const A=E.currentTarget;A.naturalWidth>0&&A.naturalHeight>0&&_({width:A.naturalWidth,height:A.naturalHeight})}}):y.status==="fallback"?e.jsx("img",{src:h,alt:n,title:s,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:B?{width:B.width,height:B.height}:void 0,onLoad:E=>{if(I)return;const A=E.currentTarget;A.naturalWidth>0&&A.naturalHeight>0&&_({width:A.naturalWidth,height:A.naturalHeight})}}):e.jsx("div",{"aria-hidden":!0,className:"flex max-w-full animate-pulse items-center justify-center rounded bg-surface-elevated/60",style:{width:$.width,height:$.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function Ds(r,n,s,l,u,d){const h=ob(s,u.markdownFilePath,u.rootPath);if(!h)return d?.fallbackText??``;const m=u.images.length;u.images.push({kind:"image",src:h,alt:n,title:l});const g=e.jsx(db,{src:h,alt:n,title:l,requestedWidthPx:d?.requestedWidthPx});return u.onImageOpen&&d?.interactive!==!1?e.jsx("button",{type:"button",className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2 text-left transition hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-ring/45",title:l||n||"Open image",onClick:b=>{b.stopPropagation(),u.onImageOpen?.(m)},children:g},r):e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:g},r)}function Ci(r){let n=r,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function Jd(r){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(r)}function rl(r){const n=r.trim(),s=n.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(s)return{href:s[1],title:s[2]??s[3]??s[4]};const l=n.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return l?{href:l[1],title:l[2]??l[3]??l[4]}:null}const lf="",ub=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function fb(r){return r.replace(ub,(n,s)=>`${lf}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function Qd(r){return r.replace(new RegExp(`${lf}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function hb(r){const n=r.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const cf={ALLOWED_TAGS:["a","abbr","b","blockquote","br","code","del","details","div","em","i","kbd","li","mark","ol","p","pre","s","span","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],ALLOWED_ATTR:["href","title","class","id","colspan","rowspan"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0};let Ya=null;function df(){return Ya||(Ya=Bs(()=>import("./purify.es-4eNOHKSq.js"),[]).then(r=>r.default??r).catch(r=>{throw Ya=null,r})),Ya}function uf({html:r}){const{t:n}=kt(),[s,l]=a.useState(null);return a.useEffect(()=>{let u=!1;return l(null),df().then(d=>{u||l(d.sanitize(r,cf))}).catch(()=>{u||l("")}),()=>{u=!0}},[r]),s===null?e.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:n("rightSidebar.renderingHtml")}):s?e.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:s}}):null}function mb({html:r}){const[n,s]=a.useState(null);return a.useEffect(()=>{let l=!1;return s(null),df().then(u=>{l||s(u.sanitize(r,cf))}).catch(()=>{l||s("")}),()=>{l=!0}},[r]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):r}function ff(r){const n=r.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!n)return null;const s=n[1].toLowerCase();return{tag:s,selfContained:new RegExp(`</${s}>`,"i").test(r)}}let Xa=null;function pb(){return Xa||(Xa=Promise.all([Bs(()=>import("./katex-DnlPpQZa.js"),[]),Bs(()=>Promise.resolve({}),__vite__mapDeps([16]))]).then(([r])=>r.default??r).catch(r=>{throw Xa=null,r})),Xa}function Us({tex:r,display:n=!1}){const[s,l]=a.useState(null),[u,d]=a.useState(!1);if(a.useEffect(()=>{let m=!1;return l(null),d(!1),pb().then(g=>{m||l(g.renderToString(r,{displayMode:n,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{m||d(!0)}),()=>{m=!0}},[n,r]),u)return e.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:n?`$$${r}$$`:`$${r}$`});if(!s)return e.jsx("span",{className:"text-muted-foreground/70",children:n?"Rendering formula...":r});const h=n?"my-2 overflow-auto rounded-md bg-surface-2 px-3 py-2 text-center":"inline-block align-middle";return e.jsx("span",{className:h,dangerouslySetInnerHTML:{__html:s}})}function fl(r){const n=new Map;for(const s of r.matchAll(/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/gi))n.set(s[1].toLowerCase(),s[2]??s[3]??s[4]);return n}function Zd(r){const n=fl(r),s=n.get("src")?.trim()??"",l=n.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i);return{src:s,alt:n.get("alt"),title:n.get("title"),widthPx:l?Number(l[1]):void 0}}function gb(r){const n=r.indexOf(">"),s=n<0?r:r.slice(0,n+1),l=fl(s),u=l.get("src")?.trim()??"",d=l.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i),h=s.replace(/=\s*(?:"[^"]*"|'[^']*')/g," "),m=n<0?"":r.slice(n+1).replace(/<\/video\s*>$/i,"").replace(/<[^>]*>/g,"").trim();return{src:u,fallbackText:m,widthPx:d?Number(d[1]):void 0,controls:/\bcontrols\b/i.test(h)}}function bb({url:r,fallbackText:n,widthPx:s,hasControls:l}){const{t:u}=kt(),[d,h]=a.useState(!1),m=go(r,()=>h(!0));return m?e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:d?e.jsx("span",{className:"block px-3 py-2 text-xs text-muted-foreground",children:n?.trim()||u("rightSidebar.videoUnsupported")}):e.jsx("video",{className:"block max-w-full",src:m,style:s?{width:`${s}px`}:void 0,controls:l,preload:"metadata",playsInline:!0,onError:()=>h(!0)})}):null}function xb(r,n,s){if(/^<a\b[^>]*>\s*<\s*img\b[^>]*>\s*<\/a\s*>$/i.test(r)){const h=r.slice(0,r.indexOf(">")+1),m=fl(h).get("href")?.trim()??"",g=r.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:b,alt:f,title:S,widthPx:y}=Zd(g);if(!b)return null;const N=ul(b,s.markdownFilePath,s.rootPath,ol,E=>E);if(!N)return null;const I=m?dl(m,s.markdownFilePath,s.rootPath):null,B=!!!(I&&I.path===N)&&m?Ju(m):null,$=Ds(n,f??"",b,S,s,{requestedWidthPx:y,interactive:B?!1:void 0});return B?e.jsx("a",{href:B,target:"_blank",rel:"noreferrer",children:$},n):$}if(/^<\s*img\b[^>]*>$/i.test(r)){const{src:h,alt:m,title:g,widthPx:b}=Zd(r);return h?Ds(n,m??"",h,g,s,{fallbackText:r,requestedWidthPx:b}):null}if(/^<\s*video\b[^>]*>[\s\S]*?<\/video\s*>$/i.test(r)){const{src:h,fallbackText:m,widthPx:g,controls:b}=gb(r);if(!h)return null;const f=ib(h,s.markdownFilePath,s.rootPath);return f?e.jsx(bb,{url:f,fallbackText:m,widthPx:g,hasControls:b},n):null}if(/^<br\s*\/?>$/i.test(r))return e.jsx("br",{},n);const l=r.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!l)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(r)?e.jsx(mb,{html:r},n):null;const u=l[1].toLowerCase(),d=ct(l[2],`${n}-${u}`,!0,s);return u==="kbd"?e.jsx("kbd",{className:"rounded border border-border/30 bg-surface-2 px-1.5 py-0.5 font-mono text-[0.85em] text-foreground shadow-sm",children:d},n):u==="mark"?e.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:d},n):u==="sub"?e.jsx("sub",{children:d},n):e.jsx("sup",{children:d},n)}function ct(r,n,s=!0,l){const u=fb(r),d=/(\\\([^)]*\\\)|\$[^$\n]+\$|<br\s*\/?>|<\s*img\b[^>]*>|<\s*video\b[^>]*>[\s\S]*?<\/video\s*>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\b[\s\S]*?<\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\[[^\]]*\]\((?:<[^>]+>|(?:[^\s()]+|\([^()\s]*\))+)(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\)|!?\[[^\]]+\]\[[^\]]*\]|!?\[[^\]]+\]|\[\^[^\]]+\]|(`+)([\s\S]*?)\2|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|\*[^*\s][^*]*\*|_[^_\s][^_]*_|<https?:\/\/[^>\s]+>|<[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+>|https?:\/\/[^\s<]+|www\.[^\s<]+|[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+)/gi,h=[];let m=0,g;for(;(g=d.exec(u))!==null;){g.index>m&&h.push(Qd(u.slice(m,g.index)));const b=g[0],f=`${n}-${g.index}`,S=b.startsWith("<")?xb(b,f,l):null;if(S)h.push(S);else if(b.startsWith("\\(")&&b.endsWith("\\)"))h.push(e.jsx(Us,{tex:b.slice(2,-2)},f));else if(b.startsWith("$")&&b.endsWith("$"))h.push(e.jsx(Us,{tex:b.slice(1,-1)},f));else if(b.startsWith("`")){const y=b.match(/^`+/)?.[0].length??1;h.push(e.jsx("code",{className:`${s?"break-all":"whitespace-nowrap"} rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground`,children:hb(b.slice(y,-y))},f))}else if(b.startsWith("~~"))h.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:ct(b.slice(2,-2),`${f}-del`,s,l)},f));else if(b.startsWith("**")||b.startsWith("__"))h.push(e.jsx("strong",{className:"font-semibold text-foreground",children:ct(b.slice(2,-2),`${f}-strong`,s,l)},f));else if(b.startsWith("*")||b.startsWith("_"))h.push(e.jsx("em",{className:"italic",children:ct(b.slice(1,-1),`${f}-em`,s,l)},f));else if(b.startsWith("![")){const y=b.match(/^!\[([^\]]*)\]\((.*)\)$/),N=b.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),I=b.match(/^!\[([^\]]+)\]$/);if(y){const _=rl(y[2]);h.push(_?Ds(f,y[1],_.href,_.title,l):b)}else if(N){const _=N[2]||N[1],B=l.referenceDefinitions.get(so(_));h.push(B?Ds(f,N[1],B.href,B.title,l):b)}else if(I){const _=l.referenceDefinitions.get(so(I[1]));h.push(_?Ds(f,I[1],_.href,_.title,l):b)}else h.push(b)}else if(b.startsWith("[^")){const y=tf(b.slice(2,-1)),N=l.footnoteDefinitions.get(y);h.push(N?e.jsx("sup",{id:`fnref-${N.id}`,title:N.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:e.jsx("a",{href:`#fn-${N.id}`,className:"text-primary no-underline",children:N.index})},f):b)}else if(b.startsWith("<http")){const y=b.slice(1,-1);h.push(e.jsx("a",{href:y,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},f))}else if(b.startsWith("<")&&b.endsWith(">")&&Jd(b.slice(1,-1))){const y=b.slice(1,-1);h.push(e.jsx("a",{href:`mailto:${y}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},f))}else if(Jd(Ci(b).linkText)){const{linkText:y,suffix:N}=Ci(b);h.push(e.jsx("a",{href:`mailto:${y}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},f)),N&&h.push(N)}else if(b.startsWith("http")||b.startsWith("www.")){const{linkText:y,suffix:N}=Ci(b),I=y.startsWith("www.")?`https://${y}`:y;h.push(e.jsx("a",{href:I,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},f)),N&&h.push(N)}else{const y=b.match(/^\[([^\]]+)\]\((.*)\)$/),N=b.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),I=b.match(/^\[([^\]]+)\]$/),_=N?N[2]||N[1]:I?.[1]??null,B=_?l.referenceDefinitions.get(so(_)):null,$=y?rl(y[2]):null,E=$?.href??B?.href??null,A=E?Ju(E):null,T=y?.[1]??N?.[1]??I?.[1]??"";h.push(A?e.jsx("a",{href:A,title:$?.title??B?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:ct(T,`${f}-link`,s,l)},f):b)}m=d.lastIndex}return m<u.length&&h.push(Qd(u.slice(m))),h.length>0?h:[r]}function hf(r){return/(?: {2,}|\\)$/.test(r)}function mf(r){return r.replace(/(?: {2,}|\\)$/,"")}function uo(r){return/^(?: {4}|\t)/.test(r)}function pf(r){return r.startsWith(" ")?r.slice(1):r.replace(/^ {4}/,"")}function gf(r,n,s){const l=[];return r.forEach((u,d)=>{const h=hf(u);l.push(...ct(mf(u),`${n}-${d}`,!0,s)),d<r.length-1&&l.push(h?e.jsx("br",{},`${n}-${d}-br`):" ")}),l}function nl(r,n,s){const l=[],u=[];return r.forEach((d,h)=>{u.push(hf(d)),l.push(ct(mf(d),`${n}-${h}`,!0,s))}),{perLine:l,hardBreaks:u}}function sl(r,n,s,l,u){const d=[];return r.forEach((h,m)=>{const g=s[m]??0,b=!!(u&&g>=u.start&&g<=u.end);d.push(e.jsx("span",{"data-md-ref-start":g,"data-md-ref-end":g,"data-selected":b?"true":void 0,children:h},`${l}-ref-${m}`)),m<r.length-1&&d.push(n[m]?e.jsx("br",{},`${l}-${m}-br`):" ")}),d}function Hs(r){const n=r.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let l="",u=!1,d=0,h=0;for(let m=0;m<n.length;m+=1){const g=n[m];if(u){l+=g,u=!1;continue}if(g==="\\"){u=!0;continue}if(g==="`"){const b=m;for(;m+1<n.length&&n[m+1]==="`";)m+=1;const f=m-b+1;l+="`".repeat(f),d===0?d=f:d===f&&(d=0);continue}if(d===0&&g==="["?h+=1:d===0&&g==="]"&&h>0&&(h-=1),g==="|"&&d===0&&h===0){s.push(l.trim()),l="";continue}l+=g}return u&&(l+="\\"),s.push(l.trim()),s}function bf(r){return Hs(r).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function fo(r){return r==="center"?"text-center":r==="right"?"text-right":"text-left"}function ho(r){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(r.trim())}function xf(r,n){return r>96||r>44&&n>.35}function vo(r){return(r.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function zs(r){const n=r.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!n)return null;const s=/^\d+[.)]$/.test(n[1]);return{ordered:s,start:s?Number.parseInt(n[1],10):void 0,content:n[2]}}function hl(r,n,s,l,u,d=new Set){const h=[],m=[];let g=n;for(;g<r.length;){const b=r[g];if(u&&(co(b)||d.has(g))){g+=1;continue}const f=zs(b),S=vo(b);if(!f){if(S>s&&m.length>0){([...m].reverse().find(_=>_.indent<S)?.item??m[m.length-1].item).paragraphs.push(b.trim());for(const _ of m)_.item.lineEnd=g+1;g+=1;continue}break}if(S<s||S===s&&f.ordered!==l)break;const y={content:f.content,ordered:f.ordered,start:f.start,children:[],paragraphs:[],lineStart:g+1,lineEnd:g+1};for(;m.length>0&&m[m.length-1].indent>=S;)m.pop();const N=m[m.length-1]?.item??null;N?N.children.push(y):h.push(y),m.push({indent:S,item:y});for(const I of m)I.item.lineEnd=g+1;g+=1}return{items:h,nextIndex:g}}function vb(r){const n=r.find(l=>zs(l));if(!n)return[];const s=zs(n);return s?hl(r,0,vo(n),s.ordered,!0,nf(r)).items:[]}function ml(r,n,s,l=0){return r.map((u,d)=>{const h=u.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${d}`,taskItem:!!h,refStart:u.lineStart+l,refEnd:u.lineEnd+l,content:e.jsxs(e.Fragment,{children:[h?e.jsx("input",{type:"checkbox",checked:h[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,ct(h?.[2]??u.content,`li-${n}-${d}`,!0,s),u.paragraphs.length>0&&e.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:u.paragraphs.map((m,g)=>e.jsx("p",{children:ct(m,`li-${n}-${d}-p-${g}`,!0,s)},`paragraph-${g}`))})]}),groups:yb(u.children,`${n}-${d}`,s,l)}})}function yb(r,n,s,l=0){const u=[];for(const d of r){const h=u[u.length-1];h&&h.ordered===d.ordered?h.items.push(d):u.push({ordered:d.ordered,items:[d]})}return u.map((d,h)=>({ordered:d.ordered,start:d.ordered?d.items[0]?.start:void 0,items:ml(d.items,`${n}-g${h}`,s,l)}))}function pl(r,n){return r.map(s=>{const l=!!(n&&s.refStart<=n.end&&s.refEnd>=n.start);return e.jsxs("li",{className:s.taskItem?"list-none":void 0,"data-md-ref-start":s.refStart,"data-md-ref-end":s.refEnd,"data-selected":l?"true":void 0,children:[s.content,s.groups.length>0&&wb(s.groups,n)]},s.key)})}function wb(r,n){return r.map((s,l)=>{const u=s.ordered?"ol":"ul";return e.jsx(u,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:pl(s.items,n)},`nested-${l}`)})}function kb(r){const n=Array.from(r.footnoteDefinitions.values()).sort((s,l)=>s.index-l.index);return n.length===0?null:e.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:r.footnotesLabel}),e.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:n.map(s=>e.jsxs("li",{id:`fn-${s.id}`,children:[ct(s.text,`footnote-${s.id}`,!0,r)," ",e.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":r.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function Sb(r,n,s,l){const u=[];let d=0;const h=m=>l?.[m]??m+1;for(;d<r.length;){const m=r[d],g=m.trim();if(!g){d+=1;continue}if(/^<details>\s*$/i.test(g)){const $=d;let E="Details";const A=[];for(d+=1;d<r.length&&!/^<\/details>\s*$/i.test(r[d].trim());){const T=r[d].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);T?E=T[1].trim()||E:A.push(r[d].trimStart()),d+=1}d<r.length&&(d+=1),u.push({kind:"static",node:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ct(E,`${n}-details-${$}-summary`,!0,s)}),A.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:gf(A,`${n}-details-${$}`,s)})]},`${n}-details-${$}`)});continue}const b=ff(m);if(b){const $=[m],E=d;for(d+=1;d<r.length&&!b.selfContained&&!new RegExp(`</${b.tag}>`,"i").test(r[d]);)$.push(r[d]),d+=1;d<r.length&&!b.selfContained&&($.push(r[d]),d+=1),u.push({kind:"static",node:e.jsx(uf,{html:$.join(`
|
|
1639
|
+
`)},`${n}-html-${E}`)});continue}const f=g.match(/^(```|~~~)\s*(.*)$/);if(f){const $=[],E=f[1],A=f[2]?.trim(),T=d;for(d+=1;d<r.length&&!r[d].trim().startsWith(E);)$.push(r[d]),d+=1;d<r.length&&(d+=1),A.toLowerCase()==="mermaid"?u.push({kind:"static",node:e.jsx(yf,{code:$.join(`
|
|
1640
|
+
`),blockKey:`${n}-code-${T}`},`${n}-code-${T}`)}):["math","latex","tex"].includes(A.toLowerCase())?u.push({kind:"static",node:e.jsx(Us,{tex:$.join(`
|
|
1641
|
+
`),display:!0},`${n}-code-${T}`)}):u.push({kind:"code",key:`${n}-code-${T}`,code:$.join(`
|
|
1642
|
+
`),lang:A,blockKey:`${n}-code-${T}`,codeStartLine:h(T)+1});continue}if(uo(m)){const $=[],E=d;for(;d<r.length&&(uo(r[d])||!r[d].trim());)$.push(r[d].trim()?pf(r[d]):""),d+=1;u.push({kind:"code",key:`${n}-indented-code-${E}`,code:$.join(`
|
|
1643
|
+
`).replace(/\n+$/,""),lang:"",blockKey:`${n}-indented-code-${E}`,codeStartLine:h(E)});continue}const S=g.match(/^(#{1,6})\s+(.+)$/);if(S){const E=`h${Math.min(6,S[1].length+1)}`,A=ef(S[2]),T=el(A,s);u.push({kind:"static",node:e.jsx(E,{id:T,className:"scroll-mt-16 font-semibold text-foreground",children:ct(A,`${n}-heading-${d}`,!0,s)},`${n}-heading-${d}`)}),d+=1;continue}if(d+1<r.length&&m.includes("|")&&ho(r[d+1])){const $=Hs(m),E=bf(r[d+1]),A=[],T=d;for(d+=2;d<r.length&&r[d].includes("|")&&r[d].trim();)A.push(Hs(r[d])),d+=1;u.push({kind:"static",node:e.jsx("div",{className:Wu,"data-markdown-table-scroll":!0,children:e.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[e.jsx("thead",{className:"bg-surface-2 text-foreground",children:e.jsx("tr",{children:$.map((U,D)=>e.jsx("th",{className:`${Hu} ${fo(E[D]??null)}`,children:e.jsx("div",{className:lo,children:ct(U,`${n}-th-${T}-${D}`,!0,s)})},`h-${D}`))})}),e.jsx("tbody",{children:A.map((U,D)=>e.jsx("tr",{className:"border-t border-border/10",children:$.map((p,i)=>e.jsx("td",{className:`${zu} ${fo(E[i]??null)}`,children:e.jsx("div",{className:lo,children:ct(U[i]??"",`${n}-td-${T}-${D}-${i}`,!0,s)})},`c-${i}`))},`r-${D}`))})]})},`${n}-table-${T}`)});continue}const y=zs(m);if(y){const $=y.ordered,E=vo(m),A=y.start,T=d,U=hl(r,d,E,$,!1);d=U.nextIndex,u.push({kind:"list",keyPrefix:`${n}-list-${T}`,ordered:$,start:$?A:void 0,renders:ml(U.items,`${n}-list-${T}`,s,h(0)-1)});continue}const N=[m.trimStart()],I=[h(d)],_=d;for(d+=1;d<r.length&&r[d].trim()&&!Zi(r[d])&&!(d+1<r.length&&r[d].includes("|")&&ho(r[d+1]));)N.push(r[d].trimStart()),I.push(h(d)),d+=1;const B=nl(N,`${n}-p-${_}`,s);u.push({kind:"paragraph",keyPrefix:`${n}-p-${_}`,perLine:B.perLine,hardBreaks:B.hardBreaks,lineNums:I})}return u}function jb(r,n){return r.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return e.jsx("p",{children:sl(s.perLine,s.hardBreaks,s.lineNums,s.keyPrefix,n)},s.keyPrefix);case"list":{const l=s.ordered?"ol":"ul";return e.jsx(l,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} space-y-0.5 pl-4 marker:text-muted-foreground/70`,children:pl(s.renders,n)},s.keyPrefix)}case"code":return e.jsx(mo,{code:s.code,lang:s.lang,blockKey:s.blockKey,codeStartLine:s.codeStartLine,lineRange:n},s.key)}})}let Ja=null,eu=!1;const Qa=16,vf=192;function Rb(){return Ja||(Ja=Bs(()=>import("./mermaid.core-BxYAsCR4.js").then(r=>r.bl),__vite__mapDeps([17,1,2,3,4,5,18])).then(r=>r.default??r).catch(r=>{throw Ja=null,r})),Ja}function Cb(r){eu||(r.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),eu=!0)}function Nb(r){const n=r.match(/\sviewBox=(["'])([^"']+)\1/i);if(!n)return r;const[,,s]=n,l=s.trim().split(/[\s,]+/).map(Number),[,,u,d]=l;if(!Number.isFinite(u)||!Number.isFinite(d)||u<=0||d<=0)return r;const h=Math.max(vf,Math.ceil(u)),m=Math.ceil(h/u*d);return r.replace(/<svg\b([^>]*)>/i,(g,b)=>`<svg${b.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${h}" height="${m}">`)}function Eb(r){const n=r?.querySelector("svg");if(!n)return;let s;try{s=n.getBBox()}catch{return}if(!Number.isFinite(s.width)||!Number.isFinite(s.height)||s.width<=0||s.height<=0)return;const l=s.x-Qa,u=s.y-Qa,d=s.width+Qa*2,h=s.height+Qa*2,m=Math.max(vf,Math.ceil(d)),g=Math.ceil(m/d*h);n.setAttribute("viewBox",`${l} ${u} ${d} ${h}`),n.setAttribute("width",String(m)),n.setAttribute("height",String(g)),n.removeAttribute("style")}function Mb(r){const n=r.trim().split(/\s+/,1)[0]?.toLowerCase();if(!n)return null;const s=n.replace(/^language-/,"");return yu(`code.${s}`)??s}function yf({code:r,blockKey:n}){const{t:s}=kt(),[l,u]=a.useState(null),[d,h]=a.useState(!1),m=a.useRef(null),g=a.useContext(Qu);a.useEffect(()=>{let f=!1;return u(null),h(!1),Rb().then(async S=>{Cb(S);const y=`termdock-md-mermaid-${n.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:N}=await S.render(y,r);f||u(Nb(N))}).catch(()=>{f||h(!0)}),()=>{f=!0}},[n,r]),a.useLayoutEffect(()=>{l&&Eb(m.current)},[l]);const b=a.useCallback(()=>{const f=m.current?.querySelector("svg")?.outerHTML??l;f&&g?.(f)},[g,l]);return d?e.jsx(mo,{code:r,lang:"mermaid",blockKey:`${n}-fallback`}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[e.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"mermaid"}),e.jsx("div",{className:"bg-surface p-3",children:l?e.jsx("button",{type:"button",className:"block max-w-full rounded text-left focus:outline-none focus:ring-2 focus:ring-ring/45",title:s("rightSidebar.openMermaidDiagram"),onClick:f=>{f.stopPropagation(),b()},children:e.jsx("span",{ref:m,role:"img","aria-label":s("rightSidebar.mermaidDiagram"),className:"block max-h-[70vh] max-w-full overflow-auto rounded bg-white p-2 text-slate-900 [&_svg]:block [&_svg]:h-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:l}})}):e.jsx("div",{className:"py-6 text-center text-xs text-muted-foreground",children:s("rightSidebar.renderingDiagram")})})]})}function mo({code:r,lang:n,blockKey:s,codeStartLine:l,lineRange:u}){const d=Mb(n),[h,m]=a.useState(null);a.useEffect(()=>{if(!d||!wu(r)){m(null);return}let b=!1;return ku().then(f=>{if(b||!f.registered(d)){b||m(null);return}try{m(Su(f,r,d))}catch{b||m(null)}}).catch(()=>{b||m(null)}),()=>{b=!0}},[s,r,d]);const g=h??(r||" ").split(`
|
|
1644
|
+
`).map(b=>[b||" "]);return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[n&&e.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:n}),e.jsx("pre",{className:`${cl} termdock-code overflow-auto p-3 text-[11px] leading-relaxed text-foreground`,children:e.jsx("code",{children:g.map((b,f)=>{const S=l!=null?l+f:null,y=!!(u&&S!=null&&S>=u.start&&S<=u.end);return e.jsxs("span",{"data-md-ref-start":S??void 0,"data-md-ref-end":S??void 0,"data-selected":y?"true":void 0,children:[b,f<g.length-1?`
|
|
1645
|
+
`:null]},`${s}-line-${f}`)})})})]})}function gl(r,n,s,l,u){r=ab(r);const d=nb(r),h=nf(r),m=[],g={markdownFilePath:n,rootPath:s,referenceDefinitions:d,footnoteDefinitions:sb(r),headingSlugCounts:new Map,images:m,onImageOpen:l,footnotesLabel:u?.footnotes??"Footnotes",backToFootnoteLabel:u?.backToFootnote??(y=>`Back to footnote ${y}`)},b=[];let f=0;for(;f<r.length;){const y=r[f],N=y.trim();if(co(y)||h.has(f)){f+=1;continue}if(!N){f+=1;continue}if(/^<details>\s*$/i.test(N)){const D=f;let p="Details";const i=[];for(f+=1;f<r.length&&!/^<\/details>\s*$/i.test(r[f].trim());){const O=r[f].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);O?p=O[1].trim()||p:i.push(r[f].trimStart()),f+=1}f<r.length&&(f+=1),b.push({key:`details-${D}`,startLine:D+1,endLine:f,content:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ct(p,`details-${D}-summary`,!0,g)}),i.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:gf(i,`details-${D}`,g)})]})});continue}const I=ff(y);if(I){const D=[y],p=f;for(f+=1;f<r.length&&!I.selfContained&&!new RegExp(`</${I.tag}>`,"i").test(r[f]);)D.push(r[f]),f+=1;f<r.length&&!I.selfContained&&(D.push(r[f]),f+=1),b.push({key:`html-${p}`,startLine:p+1,endLine:f,content:e.jsx(uf,{html:D.join(`
|
|
1646
|
+
`)})});continue}const _=N.match(/^(```|~~~)\s*(.*)$/);if(_){const D=[],p=_[1],i=_[2]?.trim(),O=f;for(f+=1;f<r.length&&!r[f].trim().startsWith(p);)D.push(r[f]),f+=1;f<r.length&&(f+=1),b.push({key:`code-${O}`,startLine:O+1,endLine:f,fineGrained:i.toLowerCase()!=="mermaid"&&!["math","latex","tex"].includes(i.toLowerCase()),content:i.toLowerCase()==="mermaid"?e.jsx(yf,{code:D.join(`
|
|
1647
|
+
`),blockKey:`code-${O}`}):["math","latex","tex"].includes(i.toLowerCase())?e.jsx(Us,{tex:D.join(`
|
|
1648
|
+
`),display:!0}):C=>e.jsx(mo,{code:D.join(`
|
|
1649
|
+
`),lang:i,blockKey:`code-${O}`,codeStartLine:O+2,lineRange:C})});continue}if(uo(y)){const D=[],p=f;for(f+=0;f<r.length&&(uo(r[f])||!r[f].trim());)D.push(r[f].trim()?pf(r[f]):""),f+=1;b.push({key:`indented-code-${p}`,startLine:p+1,endLine:f,fineGrained:!0,content:i=>e.jsx(mo,{code:D.join(`
|
|
1650
|
+
`).replace(/\n+$/,""),lang:"",blockKey:`indented-code-${p}`,codeStartLine:p+1,lineRange:i})});continue}if(N.startsWith("$$")){const D=[],p=f,i=N.replace(/^\$\$\s*/,"");if(i.endsWith("$$")&&i.length>2)D.push(i.replace(/\s*\$\$$/,"")),f+=1;else{for(i&&D.push(i),f+=1;f<r.length&&!r[f].trim().endsWith("$$");)D.push(r[f]),f+=1;if(f<r.length){const O=r[f].trim().replace(/\s*\$\$$/,"");O&&D.push(O),f+=1}}b.push({key:`math-${p}`,startLine:p+1,endLine:f,content:e.jsx(Us,{tex:D.join(`
|
|
1651
|
+
`),display:!0})});continue}if(f+1<r.length&&N&&!Zi(y)&&/^(=+|-+)\s*$/.test(r[f+1].trim())){const D=r[f+1].trim().startsWith("=")?1:2,p=`h${D}`,i=el(N,g),O={level:D,text:Xd(N),id:i};b.push({key:`setext-heading-${f}`,startLine:f+1,endLine:f+2,heading:O,content:e.jsx(p,{id:i,className:`scroll-mt-16 font-semibold text-foreground ${D===1?"mt-1 border-b border-border/20 pb-1.5 text-lg sm:pb-2 sm:text-xl":"mt-1 border-b border-border/15 pb-1 text-base sm:pb-1.5 sm:text-lg"}`,children:ct(N,`setext-heading-${f}`,!0,g)})}),f+=2;continue}const B=N.match(/^(#{1,6})\s+(.+)$/);if(B){const D=B[1].length,p=ef(B[2]),i={1:"mt-1 border-b border-border/20 pb-1.5 text-lg sm:pb-2 sm:text-xl",2:"mt-1 border-b border-border/15 pb-1 text-base sm:pb-1.5 sm:text-lg",3:"text-sm sm:text-base",4:"text-[13px] sm:text-sm",5:"text-[11px] uppercase tracking-wide sm:text-xs",6:"text-[11px] uppercase tracking-wide text-muted-foreground"},O=`h${D}`,C=el(p,g),K={level:D,text:Xd(p),id:C};b.push({key:`heading-${f}`,startLine:f+1,endLine:f+1,heading:K,content:e.jsx(O,{id:C,className:`scroll-mt-16 font-semibold text-foreground ${i[D]}`,children:ct(p,`heading-${f}`,!0,g)})}),f+=1;continue}if(Xu(y)){b.push({key:`hr-${f}`,startLine:f+1,endLine:f+1,content:e.jsx("hr",{className:"border-border/20"})}),f+=1;continue}if(N.startsWith(">")){const D=[],p=[],i=f;for(;f<r.length&&/^>\s?/.test(r[f].trim());)D.push(r[f].trim().replace(/^>\s?/,"")),p.push(f+1),f+=1;const O=D[0]?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i);if(O){const K=O[1].toUpperCase(),de=O[2]?.trim(),ne=[...de?[de]:[],...D.slice(1)],ve=[...de?[p[0]]:[],...p.slice(1)],W=nl(ne,`callout-${i}`,g);b.push({key:`callout-${i}`,startLine:i+1,endLine:f,fineGrained:!0,content:X=>e.jsxs("aside",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-primary",children:K}),ne.length>0&&e.jsx("div",{children:sl(W.perLine,W.hardBreaks,ve,`callout-${i}`,X)})]})});continue}const C=Sb(D,`quote-${i}`,g,p);b.push({key:`quote-${i}`,startLine:i+1,endLine:f,fineGrained:!0,content:K=>e.jsx("blockquote",{className:"space-y-2 border-l-2 border-border-strong bg-surface-2/70 py-1.5 pl-2.5 pr-2 text-muted-foreground sm:py-2 sm:pl-3",children:jb(C,K)})});continue}if(f+1<r.length&&y.includes("|")&&ho(r[f+1])){const D=Hs(y),p=bf(r[f+1]),i=[],O=f;for(f+=2;f<r.length&&r[f].includes("|")&&r[f].trim();)i.push(Hs(r[f])),f+=1;const C=D.map((de,ne)=>ct(de,`th-${O}-${ne}`,!0,g)),K=i.map((de,ne)=>D.map((ve,W)=>ct(de[W]??"",`td-${O}-${ne}-${W}`,!0,g)));b.push({key:`table-${O}`,startLine:O+1,endLine:f,interactive:!1,kind:"table",content:de=>{const ne=ve=>!!(de&&ve>=de.start&&ve<=de.end);return e.jsx("div",{className:Wu,"data-markdown-table-scroll":!0,children:e.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[e.jsx("thead",{className:"bg-surface-2 text-foreground",children:e.jsx("tr",{"data-markdown-table-row-line":O+1,"data-md-ref-start":O+1,"data-md-ref-end":O+1,"data-selected":ne(O+1)?"true":void 0,children:C.map((ve,W)=>e.jsx("th",{className:`${Hu} ${fo(p[W]??null)}`,children:e.jsx("div",{className:lo,children:ve})},`h-${W}`))})}),e.jsx("tbody",{children:K.map((ve,W)=>{const X=O+W+3;return e.jsx("tr",{className:"border-t border-border/10","data-markdown-table-row-line":X,"data-md-ref-start":X,"data-md-ref-end":X,"data-selected":ne(X)?"true":void 0,children:D.map((L,F)=>e.jsx("td",{className:`${zu} ${fo(p[F]??null)}`,children:e.jsx("div",{className:lo,children:ve[F]})},`c-${F}`))},`r-${W}`)})})]})})}});continue}const $=zs(y);if($){const D=$.ordered,p=vo(y),i=$.start,O=f,C=hl(r,f,p,D,!0,h);f=C.nextIndex;const K=D?"ol":"ul",de=ml(C.items,`list-${O}`,g);b.push({key:`list-${O}`,startLine:O+1,endLine:f,fineGrained:!0,content:ne=>e.jsx(K,{start:D?i:void 0,className:`${D?"list-decimal":"list-disc"} space-y-0.5 pl-4 text-muted-foreground marker:text-muted-foreground/70 sm:space-y-1 sm:pl-5`,children:pl(de,ne)})});continue}const E=[y.trimStart()],A=[f+1],T=f;for(f+=1;f<r.length&&r[f].trim()&&!Zi(r[f])&&!(f+1<r.length&&r[f].includes("|")&&ho(r[f+1]));){if(co(r[f])||h.has(f)){f+=1;continue}E.push(r[f].trimStart()),A.push(f+1),f+=1}const U=nl(E,`p-${T}`,g);b.push({key:`p-${T}`,startLine:T+1,endLine:f,fineGrained:!0,content:D=>e.jsx("p",{className:"text-muted-foreground",children:sl(U.perLine,U.hardBreaks,A,`p-${T}`,D)})})}const S=kb(g);return S&&b.push({key:"footnotes",startLine:r.length,endLine:r.length,content:S}),{blocks:b,images:m}}function $b(r,n,s){return gl(r,n,s).blocks}function wf(r,n){const s=[];for(const l of r){if(l.startLine>n)break;if(l.heading){for(;s.length>0&&s[s.length-1].level>=l.heading.level;)s.pop();s.push({...l.heading,startLine:l.startLine})}}return s}function kf(r){return r.filter(n=>!!n.heading).map(n=>({...n.heading,startLine:n.startLine}))}function Lb({src:r,alt:n,onZoomChange:s,onDoubleTap:l}){const u=of(r);return e.jsx(If,{src:u,alt:n,onLoad:()=>{},onError:()=>{},onZoomChange:s,onDoubleTap:l})}function Sf({images:r,index:n,onChange:s,onClose:l}){const{t:u}=kt(),d=r[n],h=r.length>1,m=a.useRef(null),g=a.useRef(null),b=a.useRef(null),f=a.useRef(0),[S,y]=a.useState(!1),[N,I]=a.useState(0),[_,B]=a.useState(!1),$=a.useCallback(()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),E=a.useCallback(()=>{S||Date.now()<f.current||($(),b.current=window.setTimeout(()=>{b.current=null,l()},450))},[$,S,l]),A=a.useCallback(p=>{if(r.length===0)return;const i=(p+r.length)%r.length;m.current?.slideTo(i),s(i)},[r.length,s]),T=a.useCallback(()=>A(n-1),[A,n]),U=a.useCallback(()=>A(n+1),[A,n]);if(a.useEffect(()=>{$(),I(0),B(!1),y(!1)},[$,n]),a.useEffect(()=>{const p=m.current;p&&(p.allowTouchMove=h&&!S)},[h,S]),a.useEffect(()=>{const p=m.current;!p||p.activeIndex===n||p.slideTo(n,0)},[n]),a.useEffect(()=>$,[$]),a.useEffect(()=>{const p=i=>{if(i.key==="Escape"){i.preventDefault(),l();return}h&&(i.key==="ArrowLeft"?(i.preventDefault(),T()):i.key==="ArrowRight"&&(i.preventDefault(),U()))};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[h,U,T,l]),mu({onDrag:({movement:[p,i],pinching:O})=>{O||S||Math.abs(i)<Math.abs(p)*1.15&&N===0||(B(!0),Math.abs(i)>8&&(f.current=Date.now()+300),I(Math.max(0,i)))},onDragEnd:({movement:[p,i],velocity:[,O],pinching:C,canceled:K})=>{if(B(!1),C||K||S||Math.abs(i)<Math.abs(p)*1.15){I(0);return}if(Math.abs(i)>8&&(f.current=Date.now()+300),xf(i,O)){l();return}I(0)}},{target:g,drag:{filterTaps:!0,pointer:{touch:!0}}}),!d)return null;const D=d.title||d.alt||(d.kind==="mermaid"?u("rightSidebar.mermaidDiagram"):u("rightSidebar.image"));return typeof document>"u"?null:Yr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:l}),e.jsxs("div",{className:"fixed inset-0 z-modal-panel flex flex-col bg-background-subtle/95 pt-[var(--safe-top-inset,env(safe-area-inset-top,0px))] text-foreground","data-markdown-image-lightbox":!0,"data-sidebar-gesture-ignore":!0,children:[e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/20 bg-surface/80 px-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:D}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n+1," / ",r.length]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[h&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:T,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":u("rightSidebar.previousImage"),title:u("common.previous"),children:e.jsx(Fs,{size:17})}),e.jsx("button",{type:"button",onClick:U,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":u("rightSidebar.nextImage"),title:u("common.next"),children:e.jsx(om,{size:17})})]}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":u("rightSidebar.closeImagePreview"),title:u("common.close"),children:e.jsx(Vt,{size:18})})]})]}),e.jsx("div",{ref:g,className:"relative min-h-0 flex-1 overflow-hidden","data-markdown-image-lightbox-stage":!0,"data-sidebar-gesture-ignore":!0,onClick:E,children:e.jsx("div",{className:"h-full w-full",style:{transform:`translate3d(0, ${N}px, 0) scale(${Math.max(.86,1-N/900)})`,opacity:Math.max(.35,1-N/360),transition:_?"none":"transform 0.2s ease-out, opacity 0.2s ease-out",willChange:"transform, opacity"},children:e.jsx(pu,{onSwiper:p=>{m.current=p,p.allowTouchMove=h&&!S},onSlideChange:p=>{p.activeIndex!==n&&s(p.activeIndex)},onSliderMove:()=>{$(),f.current=Date.now()+450},initialSlide:n,speed:260,slidesPerView:1,resistanceRatio:.82,threshold:6,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,className:"h-full",children:r.map((p,i)=>e.jsx(Bi,{className:"h-full",children:e.jsx("div",{className:"h-full w-full px-3 py-4 sm:px-6 sm:py-6",children:p.kind==="image"?e.jsx(Lb,{src:p.src,alt:p.alt||p.title||u("rightSidebar.markdownImage"),onZoomChange:y,onDoubleTap:$}):e.jsx(Vb,{svg:p.svg,title:p.title||p.alt||u("rightSidebar.mermaidDiagram"),onZoomChange:y,onDoubleTap:$})})},`${p.kind}-${i}-${p.alt}`))})})})]})]}),document.body)}function jf({content:r,filePath:n,rootPath:s,lineRange:l,onLineRangeClick:u,onLineRangeDrag:d,scrollTop:h,outlineOpen:m,outlineCloseSignal:g,onOutlineOpen:b,onOutlineClose:f,lightboxOpen:S,lightboxCloseSignal:y,onLightboxOpen:N,onLightboxClose:I,onLocalLinkOpen:_}){const{t:B}=kt(),[$,E]=a.useState(null),[A,T]=a.useState(null),[U,D]=a.useState(1),[p,i]=a.useState(null),O=a.useRef(null),C=a.useRef(null),{blocks:K,images:de}=a.useMemo(()=>gl(r.split(`
|
|
1652
|
+
`),n,s,R=>{T(null),E(R),N?.()},{footnotes:B("rightSidebar.footnotes"),backToFootnote:R=>B("rightSidebar.backToFootnote",{index:R})}),[r,n,s,N,B]),ne=a.useMemo(()=>A?[...de,A]:de,[de,A]),ve=a.useCallback(R=>{T({kind:"mermaid",svg:R,alt:"Mermaid diagram",title:"Mermaid diagram"}),E(de.length),N?.()},[de.length,N]);a.useEffect(()=>{E(null),T(null)},[r,n]),a.useEffect(()=>{E(null),T(null)},[y]),a.useEffect(()=>{S||(E(null),T(null))},[S]),a.useEffect(()=>{D(1)},[r,n]),a.useLayoutEffect(()=>{const R=O.current;if(!R||K.length===0)return;const te=Array.from(R.querySelectorAll("[data-markdown-preview-block-start]"));let le=1;const Me=28;for(const je of te)if(je.offsetTop-h<=Me)le=Number(je.dataset.markdownPreviewBlockStart)||le;else break;D(je=>je===le?je:le)},[K,h]);const W=a.useMemo(()=>wf(K,U),[U,K]),X=a.useMemo(()=>kf(K),[K]),L=`${n??""}
|
|
1653
|
+
${r}`,F=a.useRef(L),q=a.useRef(null),se=a.useRef(null),ie=a.useRef(!1);a.useEffect(()=>{F.current!==L&&(F.current=L,f?.())},[f,L]),a.useEffect(()=>{g!==void 0&&i(null)},[g]),a.useLayoutEffect(()=>{if(!m){i(null);return}const R=()=>{const te=C.current;if(!te)return;const le=te.getBoundingClientRect(),Me=window.innerWidth;i({top:le.bottom+6,right:Math.max(8,Me-le.right)})};return R(),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[m,h,W]);const me=a.useCallback(R=>{const te=O.current,le=te?.closest("[data-markdown-preview-scroller]"),Me=te?.querySelector(`[data-markdown-preview-block-start="${R.startLine}"]`);if(!le||!Me)return;const je=le.getBoundingClientRect(),He=Me.getBoundingClientRect(),Ae=te?.querySelector("[data-markdown-heading-sticky]")?.getBoundingClientRect().height??0,nt=He.top-je.top+le.scrollTop;le.scrollTo({top:Math.max(0,nt-Ae-8),behavior:"smooth"}),D(R.startLine),f?.()},[f]),ge=a.useCallback(R=>{R.pointerType==="mouse"&&R.button!==0||Pi(R.target)||(q.current={pointerId:R.pointerId,startX:R.clientX,startY:R.clientY})},[]),Pe=a.useCallback((R,te,le)=>{const Me=q.current;if(q.current=null,!Me||Me.pointerId!==R.pointerId)return;const je=Math.abs(R.clientX-Me.startX),He=Math.abs(R.clientY-Me.startY);if(je>8||He>8)return;const ce=R.target;if(Pi(ce)||Ui())return;const Ae=iu(ce,te,le);u(R,Ae.start,Ae.end)},[u]),M=a.useCallback(R=>{q.current?.pointerId===R.pointerId&&(q.current=null)},[]),ee=a.useCallback((R,te)=>{const le=O.current;if(!le||typeof document.elementFromPoint!="function")return null;const Me=document.elementFromPoint(R,te);if(!(Me instanceof HTMLElement)||!le.contains(Me))return null;const je=Me.closest("[data-md-ref-start]");if(je){const he=Number(je.dataset.mdRefStart);if(Number.isFinite(he)&&he>0)return he}const He=Me.closest("[data-markdown-preview-block-start]");if(!He)return null;const ce=Number(He.dataset.markdownPreviewBlockStart),Ae=K.find(he=>he.startLine===ce);if(!Ae)return Number.isFinite(ce)&&ce>0?ce:null;if(Ae.endLine<=Ae.startLine)return Ae.startLine;const nt=He.getBoundingClientRect(),V=nt.height>0?Math.min(1,Math.max(0,(te-nt.top)/nt.height)):0;return Math.round(Ae.startLine+V*(Ae.endLine-Ae.startLine))},[K]),be=a.useCallback(R=>{if(!d||R.pointerType==="mouse"&&R.button!==0)return;const te=ee(R.clientX+24,R.clientY);if(te!=null){se.current={pointerId:R.pointerId,anchorLine:te,moved:!1};try{R.currentTarget.setPointerCapture(R.pointerId)}catch{}}},[d,ee]),Le=a.useCallback(R=>{const te=se.current;if(!te||te.pointerId!==R.pointerId||!d)return;const le=ee(R.clientX+16,R.clientY);le!=null&&(!te.moved&&le===te.anchorLine||(te.moved=!0,ie.current=!0,d(R,Math.min(te.anchorLine,le),Math.max(te.anchorLine,le),"move")))},[d,ee]),Xe=a.useCallback(R=>{const te=se.current;if(se.current=null,!te||te.pointerId!==R.pointerId||!d||!te.moved)return;const le=ee(R.clientX+16,R.clientY)??te.anchorLine;d(R,Math.min(te.anchorLine,le),Math.max(te.anchorLine,le),"end")},[d,ee]),Ee=a.useCallback(R=>{se.current?.pointerId===R.pointerId&&(se.current=null)},[]),Qe={onPointerDown:be,onPointerMove:Le,onPointerUp:Xe,onPointerCancel:Ee},Fe=()=>ie.current?(ie.current=!1,!0):!1;return K.length===0?e.jsx("div",{className:"min-w-0 max-w-full px-4 py-4 text-sm leading-6 text-foreground",children:e.jsx("p",{className:"text-muted-foreground",children:B("rightSidebar.emptyFile")})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:O,className:"relative min-w-0 max-w-full",onClickCapture:R=>{const te=R.target instanceof Element?R.target.closest("a[href]"):null;if(!te||!_)return;const le=te.getAttribute("href");if(!le)return;const Me=dl(le,n,s);Me&&(R.preventDefault(),_(Me))},children:[W.length>0&&e.jsx("div",{className:"sticky top-0 z-10 border-b border-border/15 bg-surface px-2 py-1 shadow-sm sm:px-3","data-markdown-heading-sticky":!0,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",title:W.map(R=>R.text).join(" / "),children:[e.jsx("span",{className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/70","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold leading-5 text-foreground sm:text-[13px]","data-markdown-heading-current":!0,children:W[W.length-1].text}),X.length>1&&e.jsxs("button",{ref:C,type:"button",onClick:()=>{m?f?.():b?.()},className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 ${m?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":m,"aria-label":B("rightSidebar.markdownOutline"),title:B("rightSidebar.markdownOutline"),children:[e.jsx(gu,{size:12}),e.jsx("span",{children:B("rightSidebar.markdownOutlineShort")})]})]})}),m&&typeof document<"u"&&Yr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-menu-backdrop bg-[rgb(var(--background-rgb)_/_0.18)] sm:hidden",onClick:f}),e.jsx("div",{className:"hidden fixed z-menu-panel w-80 max-w-[min(20rem,calc(100vw-2rem))] rounded-lg border border-border/20 bg-surface p-2 shadow-xl sm:block",style:p?{top:`${p.top}px`,right:`${p.right}px`}:{top:-9999,right:-9999},"data-markdown-heading-outline-desktop":!0,children:e.jsx("div",{className:"max-h-72 overflow-auto pr-1",children:X.map(R=>{const te=W[W.length-1]?.startLine===R.startLine;return e.jsxs("button",{type:"button",onClick:()=>me(R),className:`flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition active:scale-[0.995] ${te?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(R.level-1,4)*12+8}px`},title:R.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${te?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",R.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:R.text})]},`desktop-${R.id}-${R.startLine}`)})})}),e.jsxs("div",{className:"fixed inset-x-0 bottom-0 z-drawer-panel max-h-[min(74vh,34rem)] rounded-t-xl border border-border/20 bg-surface p-2 pb-[calc(0.5rem+env(safe-area-inset-bottom,0px))] shadow-[0_-18px_48px_var(--app-shadow-strong)] sm:hidden","data-markdown-heading-outline-mobile":!0,children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 px-1.5 py-1 sm:hidden",children:[e.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:B("rightSidebar.markdownOutlineShort")}),e.jsx("button",{type:"button",onClick:f,className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":B("rightSidebar.closeMarkdownOutline"),title:B("common.close"),children:e.jsx(Vt,{size:14})})]}),e.jsx("div",{className:"max-h-[calc(min(74vh,34rem)-3.25rem-env(safe-area-inset-bottom,0px))] overflow-auto overscroll-contain pr-1 sm:max-h-72",children:X.map(R=>{const te=W[W.length-1]?.startLine===R.startLine;return e.jsxs("button",{type:"button",onClick:()=>me(R),className:`flex min-h-10 w-full min-w-0 items-center gap-2 rounded-md px-2 py-2 text-left transition active:scale-[0.995] ${te?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(R.level-1,4)*12+8}px`},title:R.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${te?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",R.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:R.text})]},`${R.id}-${R.startLine}`)})})]})]}),document.body),e.jsx("div",{className:"min-w-0 max-w-full space-y-1.5 overflow-x-hidden break-words px-1.5 py-3 text-[13px] leading-5 text-foreground sm:space-y-2 sm:px-2 sm:py-4 sm:text-sm sm:leading-6",children:e.jsx(Qu.Provider,{value:ve,children:K.map(R=>{const te=!!(l&&R.startLine<=l.end&&R.endLine>=l.start),le=!!(l&&l.start<=R.startLine&&l.end>=R.endLine),Me=R.kind==="table"?!1:R.fineGrained?le:te,je=R.kind==="table"&&l?.start===R.startLine&&l.end===R.endLine;let He=null;if(R.kind!=="table"&&R.fineGrained&&te&&!le&&l){const V=R.endLine-R.startLine+1,he=Math.max(l.start,R.startLine),Be=Math.min(l.end,R.endLine),qe=(he-R.startLine)/V,qt=(Be-he+1)/V;He=e.jsx("span",{"aria-hidden":"true","data-md-rail-segment":!0,className:"absolute left-1/2 w-0.5 -translate-x-1/2 rounded-full bg-primary transition sm:w-1",style:{top:`calc(0.25rem + (100% - 0.5rem) * ${qe})`,height:`calc((100% - 0.5rem) * ${qt})`}})}const ce=typeof R.content=="function"?R.content(l):R.content,Ae=R.startLine===R.endLine?String(R.startLine):`${R.startLine}-${R.endLine}`,nt=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:$i(Me),"aria-hidden":"true",...Qe,children:[e.jsx("span",{className:Li(Me)}),He]}),e.jsx("div",{className:"min-w-0","data-sidebar-selectable":!0,children:ce})]});return R.interactive===!1?e.jsxs("div",{"data-markdown-preview-block-start":R.startLine,className:`group grid w-full grid-cols-[0.625rem_minmax(0,1fr)] gap-1.5 rounded-md py-0.5 pr-1.5 text-left outline-none transition sm:grid-cols-[0.875rem_minmax(0,1fr)] sm:gap-2 sm:pr-2 ${Me?"bg-primary/10":""}`,title:`Line ${Ae}`,"aria-label":`Line ${Ae}`,children:[R.kind==="table"?e.jsx("button",{type:"button",className:$i(je,"self"),onClick:V=>{V.preventDefault(),!Fe()&&u(V,R.startLine,R.endLine)},title:`Reference table lines ${Ae}`,"aria-label":`Reference table lines ${Ae}`,...Qe,children:e.jsx("span",{className:Li(je,"self")})}):e.jsxs("span",{className:$i(Me,"none"),"aria-hidden":"true",...Qe,children:[e.jsx("span",{className:Li(Me,"none")}),He]}),e.jsx("div",{className:"min-w-0 cursor-text select-text","data-sidebar-selectable":!0,role:"button",tabIndex:0,onPointerDown:ge,onPointerUp:V=>Pe(V,R.startLine,R.endLine),onPointerCancel:M,onKeyDown:V=>{V.key!=="Enter"&&V.key!==" "||(V.preventDefault(),u(V,R.startLine,R.endLine))},title:`Reference line ${Ae}`,"aria-label":`Reference line ${Ae}`,children:ce})]},R.key):e.jsx("div",{role:"button",tabIndex:0,"data-markdown-preview-block-start":R.startLine,onClick:V=>{const he=V.target;if(Pi(he)||Ui()||Fe())return;const Be=iu(he,R.startLine,R.endLine);u(V,Be.start,Be.end)},onKeyDown:V=>{V.key!=="Enter"&&V.key!==" "||(V.preventDefault(),u(V,R.startLine,R.endLine))},className:`group grid w-full cursor-pointer grid-cols-[0.625rem_minmax(0,1fr)] gap-1.5 rounded-md py-0.5 pr-1.5 text-left outline-none transition active:scale-[0.998] sm:grid-cols-[0.875rem_minmax(0,1fr)] sm:gap-2 sm:pr-2 ${Me?"bg-primary/10":"hover:bg-[var(--surface-2)]"}`,title:`Reference line ${Ae}`,"aria-label":`Reference line ${Ae}`,children:nt},R.key)})})})]}),S&&$!==null&&ne[$]&&e.jsx(Sf,{images:ne,index:$,onChange:E,onClose:()=>{E(null),T(null),I?.()}})]})}function Yn({label:r,value:n,options:s,placeholder:l,searchPlaceholder:u,emptyText:d,disabled:h,onChange:m}){const{t:g}=kt(),[b,f]=a.useState(!1),[S,y]=a.useState(""),[N,I]=a.useState(null),_=a.useRef(null),B=a.useRef(null),$=S.trim().toLowerCase(),E=a.useMemo(()=>$?s.filter(p=>`${p.label} ${p.meta??""}`.toLowerCase().includes($)):s,[$,s]),A=s.find(p=>p.value===n),T=()=>{const p=S.trim();p&&(m(p),f(!1),y(""))},U=a.useCallback(()=>{const p=_.current?.getBoundingClientRect();if(!p)return!1;const i=12,O=Math.max(220,Math.min(p.width,window.innerWidth-i*2)),C=Math.min(Math.max(i,p.left),window.innerWidth-O-i),K=window.innerHeight-p.bottom-i,de=p.top-i,ne=K>=180||K>=de,ve=Math.max(96,(ne?K:de)-4),W=Math.min(320,ve);return I({left:C,top:ne?p.bottom+4:Math.max(i,p.top-W-4),width:O,maxHeight:W}),!0},[]),D=()=>{U(),f(!0)};return a.useEffect(()=>{if(!b)return;let p=0;const i=()=>{p||(p=window.requestAnimationFrame(()=>{p=0,U()}))},O=C=>{const K=C.target;K instanceof Node&&(_.current?.contains(K)||B.current?.contains(K)||(f(!1),y("")))};return window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),document.addEventListener("pointerdown",O,!0),()=>{p&&window.cancelAnimationFrame(p),window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0),document.removeEventListener("pointerdown",O,!0)}},[b,U]),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:_,type:"button",disabled:h,onClick:()=>{if(!h){if(y(""),b){f(!1);return}D()}},className:"group flex w-full items-center justify-between gap-2 min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-left transition hover:bg-surface-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:r}),e.jsx("span",{className:`min-w-0 flex-1 truncate text-[13px] ${n?"text-foreground":"text-muted-foreground/70"}`,children:A?.label??(n||l)})]}),e.jsx(_s,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${b?"rotate-180":""}`})]}),b&&!h&&typeof document<"u"&&Yr.createPortal(e.jsxs("div",{ref:B,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:p=>p.stopPropagation(),style:{left:N?.left??12,top:N?.top??12,width:N?.width??260,maxHeight:N?.maxHeight??320},children:[e.jsx("div",{className:"border-b border-border/10 p-1.5",children:e.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5",children:[e.jsx(Xn,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:S,onChange:p=>y(p.target.value),onKeyDown:p=>{if(p.key==="Escape"){p.preventDefault(),f(!1),y("");return}p.key==="Enter"&&(p.preventDefault(),T())},onBlur:()=>{S.trim()&&E.length===0&&T()},placeholder:u,className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground outline-none placeholder:text-muted-foreground/70"})]})}),e.jsxs("div",{className:"overflow-y-auto p-1",style:{maxHeight:Math.max(96,(N?.maxHeight??320)-46)},children:[S.trim()&&!s.some(p=>p.value===S.trim())&&e.jsxs("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:T,className:"mb-1 flex w-full items-center justify-between gap-2 rounded-md bg-primary/10 px-2 py-1.5 text-left text-[12px] font-medium text-primary transition hover:bg-primary/15",children:[e.jsx("span",{className:"min-w-0 truncate",children:S.trim()}),e.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:g("common.use")})]}),E.length>0?E.map(p=>e.jsxs("button",{type:"button",onClick:()=>{m(p.value),f(!1),y("")},className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left text-[12px] transition hover:bg-surface-2 ${p.value===n?"bg-accent/10 text-accent":"text-foreground"}`,children:[e.jsx("span",{className:"min-w-0 truncate font-medium",children:p.label}),p.meta&&e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:p.meta})]},p.value)):e.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:d})]})]}),document.body)]})}function tu({open:r,onOpenChange:n,showScopePicker:s,selectedAll:l,repos:u,selectedRoots:d,onToggleRepo:h,onGenerate:m,onSecondaryAction:g,disabled:b,generateDisabled:f,secondaryDisabled:S,inserted:y,buttonLabel:N,insertedLabel:I,title:_,ariaLabel:B,scopeTitle:$,scopeLabel:E,allLabel:A,generateLabel:T,secondaryLabel:U,secondaryTitle:D,secondaryLoading:p,loading:i,error:O,statusTitle:C,extraContent:K,renderRepoExtra:de}){return e.jsxs("div",{className:"relative inline-flex shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>{s?n(!r):f||m()},disabled:b,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 disabled:cursor-not-allowed disabled:opacity-50 ${O?"text-destructive hover:bg-destructive/5":y?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":B,title:C??(s?`${$}: ${E}`:_),children:[i?e.jsx(Ct,{size:13,className:"animate-spin"}):e.jsx(Os,{size:13}),e.jsx("span",{children:y?I:N}),s&&e.jsx(_s,{size:11,className:`shrink-0 transition ${r?"rotate-180":""}`}),O&&e.jsx("span",{className:"absolute right-0.5 top-0.5 size-1.5 rounded-full bg-destructive"})]}),s&&r&&typeof document<"u"&&Yr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] px-3 py-6 backdrop-blur-sm animate-fade-in",onClick:()=>n(!1),children:e.jsxs("div",{className:"fixed left-1/2 top-1/2 z-modal-panel flex max-h-[min(82vh,36rem)] w-[calc(100vw-1.5rem)] max-w-[42rem] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/20 bg-surface text-[11px] shadow-2xl",onClick:ne=>ne.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border/15 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:$}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:E})]}),e.jsx("button",{type:"button",onClick:()=>n(!1),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":"Close",children:e.jsx(Vt,{size:14})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[K,e.jsxs("button",{type:"button",onClick:()=>h(null),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${l?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[e.jsx("span",{className:"truncate",children:A}),l&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),u.map(ne=>{const ve=d.includes(ne.root);return e.jsxs("div",{className:`mt-1 rounded-md transition ${ve?"bg-primary/15 text-primary":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>h(ne.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${ve?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:ne.root,children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate",children:ne.label}),ne.branch&&e.jsx("span",{className:"block truncate text-[9px] opacity-70",children:ne.branch})]}),ve&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),de&&(l||ve)&&e.jsx("div",{className:"px-2 pb-2",children:de(ne)})]},ne.root)})]}),e.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${g&&U?"sm:grid-cols-2":""}`,children:[g&&U&&e.jsxs("button",{type:"button",onClick:()=>{S||(n(!1),g())},disabled:S,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-surface-2 px-2 text-[11px] font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:D,children:[p?e.jsx(Ct,{size:12,className:"animate-spin"}):e.jsx(Ru,{size:12}),U]}),e.jsxs("button",{type:"button",onClick:()=>{f||(n(!1),m())},disabled:f,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-primary/15 px-2 text-[11px] font-semibold text-primary transition hover:bg-primary/25 disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:_,children:[e.jsx(Os,{size:12}),T]})]})]})}),document.body)]})}function Ab(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const n of Object.values(r)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function Rf(){return ht(il,Ab)??{}}function Pb(r,n){const s=Rf(),l=Object.entries({...s,[r]:{top:n,updatedAt:Date.now()}}).sort(([,u],[,d])=>d.updatedAt-u.updatedAt).slice(0,Eg);Ps(il,Object.fromEntries(l),$g)}function Tb(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.start=="number"&&Number.isFinite(n.start)&&typeof n.end=="number"&&Number.isFinite(n.end)&&n.start>=1&&n.end>=n.start}function Ib(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const n of Object.values(r)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||s.left!==void 0&&(typeof s.left!="number"||!Number.isFinite(s.left))||s.markdownTop!==void 0&&(typeof s.markdownTop!="number"||!Number.isFinite(s.markdownTop))||s.lineRange!==void 0&&s.lineRange!==null&&!Tb(s.lineRange)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function bl(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function Cf(){return ht(ll,Ib)??{}}function ru(r,n){const s=bl(r,n);return s?Cf()[s]??null:null}function Ni(r,n,s){const l=bl(r,n);if(!l)return;const u=Cf(),d=u[l]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},h=Object.entries({...u,[l]:{...d,...s,updatedAt:Date.now()}}).sort(([,m],[,g])=>g.updatedAt-m.updatedAt).slice(0,Mg);Ps(ll,Object.fromEntries(h),Lg)}function Za({active:r,mounted:n=!0,fallback:s=null,children:l}){return e.jsx("div",{className:`h-full min-h-0 overflow-hidden bg-surface text-foreground ${r?"block":"hidden"}`,"aria-hidden":!r,children:n?typeof l=="function"?l():l:s})}function Ei({slow:r}){return e.jsx(Wm,{slow:r})}function eo({message:r,onRetry:n}){const{t:s}=kt();return e.jsxs("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-5 text-center text-sm text-destructive",children:[e.jsx("div",{className:"font-medium",children:s("rightSidebar.gitChangesLoadFailed")}),e.jsx("div",{className:"mt-1 break-words text-xs opacity-85",children:r}),e.jsx("button",{type:"button",onClick:n,className:"mt-3 rounded-full bg-destructive/10 px-3 py-1.5 text-xs font-semibold text-destructive transition hover:bg-destructive/15 active:scale-95",children:s("rightSidebar.retryGitChanges")})]})}function ao(r,n){const s=n&&r.startsWith(`${n}/`)?r.slice(n.length+1):r,l=s.split("/").filter(Boolean);return{name:l.pop()||s,dir:l.join("/")}}function wt(r){if(!r)return"";const n=r.replace(/\/+$/,"");return n.split("/").pop()||n||"/"}function Mi(r){if(!r)return null;const n=r.replace(/\/+$/,"")||"/";if(n==="/")return null;const s=n.slice(0,n.lastIndexOf("/"))||"/";return s===n?null:s}function Db(r,n,s){return Hi(r,n,s)}function $i(r,n="group"){return`relative flex min-h-5 w-full touch-none select-none items-stretch justify-center rounded transition sm:min-h-6 ${r?"bg-primary/20":`bg-[var(--surface-2)] ${n==="group"?"group-hover:bg-[var(--surface-elevated)]":n==="self"?"hover:bg-[var(--surface-elevated)]":""}`}`}function Li(r,n="group"){return`my-1 w-0.5 rounded-full transition sm:w-1 ${r?"bg-primary":`bg-[var(--border-strong)] ${n==="group"?"group-hover:bg-[var(--muted-foreground)]":n==="self"?"hover:bg-[var(--muted-foreground)]":""}`}`}function Nf(r){const n=new Map;for(const s of r)n.set(xl(s),s);return n}function Ef(r,n){const s=new Map(r);for(const l of n)s.set(xl(l),l);return s}function nu(r,n){let s=0;for(const l of r){const u=pt(l,n);u&&n&&u!==n&&(s+=1)}return s}function Fb(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function _b(r,n){return Array.from(Ef(Nf(r),n).values()).sort((s,l)=>s.path.localeCompare(l.path))}function Bb(r,n){const s=r.relativeRoot==="."?wt(n??r.root)||r.name||r.root:r.relativeRoot||r.name||wt(r.root)||r.root;return{root:r.root,label:s,branch:r.context?.branch??null,count:r.files.length,staged:Fb(r.files)}}function Mf(r,n){const s=wt(n??"")||n||"";return r.map(l=>Bb(l,n)).sort((l,u)=>s&&l.label===s?-1:s&&u.label===s?1:l.label.localeCompare(u.label))}function $f(r,n,s,l,u){const d=Ku(s),h=d.find(_=>_.root===l)??d[0]??null,m=n.find(_=>_.root===l)??null,g=m?.relativeRoot??h?.relativeRoot??".",b=m?.name??h?.name??(wt(l)||l),f=(h?.files??s.files).map(_=>({..._,repoRoot:l,repoRelativeRoot:g,repoName:b})),S=h?.context??s.context,y={...m??h??{id:l,root:l,relativeRoot:g,name:b,depth:0,nested:!!(u&&l!==u),available:s.available,files:[],context:null},...h??{},id:m?.id??h?.id??l,root:l,displayRoot:m?.displayRoot??h?.displayRoot,relativeRoot:g,name:b,depth:m?.depth??h?.depth??0,nested:m?.nested??h?.nested??!!(u&&l!==u),available:h?.available??s.available,deferred:h?.deferred??!1,files:f,context:S?{...S,root:l,changedFiles:f.map(_=>({path:_.path,absolutePath:_.absolutePath,status:_.status}))}:null,untrackedDeferred:h?.untrackedDeferred??s.untrackedDeferred,error:h?.error??s.error},N=m?n.map(_=>_.root===l?y:_):[...n,y];return{files:Array.from(r).filter(_=>pt(_,u)!==l).concat(f),repositories:N,repoFilters:Mf(N,u)}}function pt(r,n){return r.repoRoot??n}function xl(r){return`${r.repoRoot??""}\0${r.path}`}function yt(r){return r.absolutePath||r.path}function Ai(r){return xl(r)}function Ob(r){return r.repoRelativeRoot&&r.repoRelativeRoot!=="."?r.repoRelativeRoot:r.repoName??""}function su(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function au(r){const n={added:0,modified:0,deleted:0,renamed:0,copied:0,untracked:0,conflicted:0,staged:0,other:0};for(const s of r)s.status==="added"?n.added+=1:s.status==="modified"?n.modified+=1:s.status==="deleted"?n.deleted+=1:s.status==="renamed"?n.renamed+=1:s.status==="copied"?n.copied+=1:s.status==="untracked"?n.untracked+=1:s.status==="conflicted"?n.conflicted+=1:n.other+=1,s.staged&&(n.staged+=1);return n}function Ms(r){let n=0;const s=r??"root";for(let l=0;l<s.length;l+=1)n=Math.imul(n^s.charCodeAt(l),16777619);return`right-sidebar-git-bundle:${(n>>>0).toString(36)}`}function $s(r,n){return typeof r!="number"||!Number.isFinite(r)||r<=0?null:new Intl.DateTimeFormat(n==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(r))}function dr(r){return r instanceof DOMException&&r.name==="AbortError"}function Ub(r){const n=r.error??r.context?.error??"";return n.includes("request was cancelled")||n.includes("IO_REQUEST_CANCELLED")}function ou(r){return r?.available===!1&&r.code==="NOT_GIT_REPOSITORY"}function Pi(r){return r instanceof HTMLElement&&!!r.closest('a, button, input, textarea, select, label, [contenteditable="true"]')}function iu(r,n,s){const l=r instanceof HTMLElement?r.closest("[data-md-ref-start]"):null,u=Number(l?.dataset.mdRefStart),d=Number(l?.dataset.mdRefEnd??l?.dataset.mdRefStart);return Number.isFinite(u)&&u>0&&Number.isFinite(d)&&d>0?{start:Math.min(u,d),end:Math.max(u,d)}:{start:n,end:s}}function Hb({actions:r,running:n,completed:s}){const{t:l}=kt(),[u,d]=a.useState(!1),h=a.useRef(null),m=r.find(b=>n?.action===b.key),g=r.find(b=>s?.action===b.key);return r.length===0?null:(a.useEffect(()=>{if(!u)return;const b=S=>{const y=S.target;y instanceof Node&&h.current?.contains(y)||d(!1)},f=S=>{S.key==="Escape"&&d(!1)};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",f),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",f)}},[u]),e.jsxs("div",{ref:h,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),d(f=>!f)},disabled:r.every(b=>b.disabled)&&!n&&!s,className:`inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md transition active:scale-95 disabled:opacity-50 ${u?"bg-surface-elevated text-foreground":g?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:m?.label??g?.label??l("rightSidebar.gitQuickActions"),children:m?e.jsx(Ct,{size:13,className:"animate-spin"}):g?e.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):e.jsx(oo,{size:14})}),u&&e.jsx("div",{className:"absolute right-0 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:r.map(b=>{const f=n?.action===b.key,S=s?.action===b.key;return e.jsxs("button",{type:"button",onClick:y=>{y.stopPropagation(),b.onClick(),d(!1)},disabled:b.disabled||!!n,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] disabled:opacity-50 ${S?"bg-accent/10 text-accent":b.destructive?"text-destructive hover:bg-destructive/10":"text-foreground hover:bg-surface-2"}`,children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:f?e.jsx(Ct,{size:13,className:"animate-spin"}):S?"✓":null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:b.label})]},b.key)})})]}))}function zb(r){const n=window.getComputedStyle(r).overflowY;return(n==="auto"||n==="scroll")&&r.scrollHeight>r.clientHeight+1}function Lf(r){let n=r;for(;n;){if(n.classList.contains("termdock-diff-stream-scroller")&&zb(n))return n;n=n.parentElement}return r.closest(".termdock-diff-stream-scroller")}function Jn(r){return r.getClientRects().length>0&&window.getComputedStyle(r).visibility!=="hidden"}const Ti=new WeakMap;function po(r){const n=Ti.get(r);n!==void 0&&window.clearTimeout(n),r.classList.remove("diff-walkthrough-target"),r.offsetWidth,r.classList.add("diff-walkthrough-target");const s=window.setTimeout(()=>{r.classList.remove("diff-walkthrough-target"),Ti.delete(r)},1700);Ti.set(r,s)}function Wb(r){const n=CSS.escape(r),s=[`[data-diff-stream-item="${n}"]`,`[data-diff-selection-path="${n}"]`,`[data-diff-absolute-path="${n}"]`].join(","),l=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let u=null;for(const m of l){if(!Jn(m))continue;const g=m.querySelector(s);if(g&&Jn(g)){u=g;break}}if(u??=Array.from(document.querySelectorAll(s)).find(Jn)??null,!u)return;const d=Lf(u);if(!d){u.scrollIntoView({block:"start",behavior:"smooth"}),po(u);return}const h=u.getBoundingClientRect().top-d.getBoundingClientRect().top+d.scrollTop;d.scrollTo({top:Math.max(0,h),behavior:"instant"}),po(u)}function kn(r){const n=CSS.escape(r.filePath),s=typeof r.sectionIndex=="number"?String(r.sectionIndex):null,l=typeof r.hunkIndex=="number"?String(r.hunkIndex):null,u=r.sectionFingerprint?CSS.escape(r.sectionFingerprint):null,d=r.hunkFingerprint?CSS.escape(r.hunkFingerprint):null,h=[s!==null&&u?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${u}"]`:null,s!==null&&u?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${u}"]`:null,s!==null?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"]`:null,s!==null?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"]`:null,l!==null&&d?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"][data-diff-hunk-fingerprint="${d}"]`:null,l!==null?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"]`:null,`[data-diff-file-path="${n}"]`].filter(I=>!!I),m=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let g=null;for(const I of m)if(Jn(I)){for(const _ of h){const B=I.querySelector(_);if(B&&Jn(B)){g=B;break}}if(g)break}if(g??=h.flatMap(I=>Array.from(document.querySelectorAll(I))).find(Jn)??null,!g){Wb(r.filePath);return}const b=Lf(g);if(!b){g.scrollIntoView({block:"center",behavior:"smooth"}),po(g);return}const f=g.getBoundingClientRect(),S=b.getBoundingClientRect(),N=f.top-S.top+b.scrollTop-Math.max(24,(b.clientHeight-f.height)/2);b.scrollTo({top:Math.max(0,N),behavior:"instant"}),po(g)}const Af=1,Pf=8;function Gb(r){return Math.min(Pf,Math.max(Af,r))}function Tf({resetKey:r,onZoomChange:n,onDoubleTap:s,children:l}){const u=a.useRef(null),[d,h]=a.useState({scale:1,x:0,y:0}),[m,g]=a.useState(!1),b=a.useRef(null),f=a.useRef(new Set),S=a.useRef(!1),y=a.useRef(null),N=a.useRef(0),I=a.useRef(d);I.current=d,a.useEffect(()=>{h({scale:1,x:0,y:0})},[r]);const _=a.useCallback((A,T,U)=>{const D=u.current;if(!D)return{x:T,y:U};const p=D.firstElementChild instanceof HTMLElement?D.firstElementChild:null,i=p?.clientWidth||D.clientWidth,O=p?.clientHeight||D.clientHeight,C=Math.max(0,(i*A-D.clientWidth)/2),K=Math.max(0,(O*A-D.clientHeight)/2);return{x:Math.min(C,Math.max(-C,T)),y:Math.min(K,Math.max(-K,U))}},[]),B=a.useCallback((A,T,U)=>{h(D=>{const p=Gb(A),i=u.current;if(!i||p===1)return{scale:p,x:0,y:0};const O=i.getBoundingClientRect(),C=(T??O.left+O.width/2)-O.left-O.width/2,K=(U??O.top+O.height/2)-O.top-O.height/2,de=p/D.scale,ne=C-(C-D.x)*de,ve=K-(K-D.y)*de;return{scale:p,..._(p,ne,ve)}})},[_]),$=a.useCallback((A,T)=>{g(!0),I.current.scale>1?h({scale:1,x:0,y:0}):B(2.5,A,T),window.setTimeout(()=>g(!1),220)},[B]);a.useEffect(()=>{const A=u.current;if(!A)return;const T=p=>{if(p.pointerType==="mouse"&&p.button!==0)return;const i=f.current.size===0;if(f.current.add(p.pointerId),i){const O=Date.now(),C=y.current;if(C&&O-C.time<350&&Math.hypot(p.clientX-C.x,p.clientY-C.y)<24){y.current=null,N.current=O,s?.(),$(p.clientX,p.clientY);return}}if(f.current.size>1){S.current=!0,b.current=null;return}if(!(I.current.scale<=1)){p.preventDefault(),b.current={pointerId:p.pointerId,startX:p.clientX,startY:p.clientY,originX:I.current.x,originY:I.current.y,moved:!1};try{A.setPointerCapture?.(p.pointerId)}catch{}g(!1)}},U=p=>{const i=b.current;if(!i||i.pointerId!==p.pointerId)return;const O=p.clientX-i.startX,C=p.clientY-i.startY;if(!i.moved){if(Math.hypot(O,C)<6)return;i.moved=!0}p.stopPropagation(),p.preventDefault(),h(K=>({...K,..._(K.scale,i.originX+O,i.originY+C)}))},D=p=>{const i=b.current,O=i?.pointerId===p.pointerId&&i.moved;if(i?.pointerId===p.pointerId){i.moved&&p.stopPropagation(),b.current=null;try{A.releasePointerCapture?.(p.pointerId)}catch{}}f.current.delete(p.pointerId)&&f.current.size===0&&(!S.current&&!O&&(y.current={time:Date.now(),x:p.clientX,y:p.clientY}),S.current=!1)};return A.addEventListener("pointerdown",T,{capture:!0,passive:!1}),window.addEventListener("pointermove",U,{capture:!0,passive:!1}),window.addEventListener("pointerup",D,{capture:!0}),window.addEventListener("pointercancel",D,{capture:!0}),()=>{A.removeEventListener("pointerdown",T,{capture:!0}),window.removeEventListener("pointermove",U,{capture:!0}),window.removeEventListener("pointerup",D,{capture:!0}),window.removeEventListener("pointercancel",D,{capture:!0})}},[_,s,$]),mu({onPinch:({offset:[A],origin:[T,U]})=>{g(!1),B(A,T,U)},onWheel:({event:A,delta:[T,U],ctrlKey:D})=>{if(D){A.preventDefault(),A.stopPropagation(),g(!1),B(I.current.scale*(1-U*.01),A.clientX,A.clientY);return}I.current.scale<=1||(A.preventDefault(),A.stopPropagation(),g(!1),h(p=>({...p,..._(p.scale,p.x-T,p.y-U)})))}},{target:u,eventOptions:{passive:!1},pinch:{scaleBounds:{min:Af,max:Pf},from:()=>[I.current.scale,0],rubberband:!0}});const E=d.scale>1;return a.useEffect(()=>{n?.(E)},[n,E]),e.jsx("div",{ref:u,"data-sidebar-gesture-ignore":E?"":void 0,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden",style:{cursor:E?"grab":"zoom-in"},onDoubleClick:A=>{A.stopPropagation(),!(Date.now()-N.current<500)&&(s?.(),$(A.clientX,A.clientY))},children:l({scale:d.scale,zoomed:E,animateTransform:m,transformStyle:{transform:`translate3d(${d.x}px, ${d.y}px, 0) scale(${d.scale})`,transformOrigin:"center center",transition:m?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none",willChange:"transform"},vectorTransformStyle:{transform:`translate3d(${d.x}px, ${d.y}px, 0)`,transformOrigin:"center center",transition:m?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}})})}function If({src:r,alt:n,vector:s,onLoad:l,onError:u,onZoomChange:d,onDoubleTap:h}){const m=go(r,u),[g,b]=a.useState(null),f=s??xo(r);return a.useEffect(()=>{b(null)},[r]),e.jsx(Tf,{resetKey:r,onZoomChange:d,onDoubleTap:h,children:({transformStyle:S,vectorTransformStyle:y,scale:N,animateTransform:I})=>{const _=e.jsx("img",{src:m,alt:n,draggable:!1,className:"max-h-full max-w-full touch-none select-none rounded border border-border/15 bg-surface object-contain shadow-sm",style:f&&g?{position:"absolute",left:"50%",top:"50%",width:g.width*N,height:g.height*N,maxWidth:"none",maxHeight:"none",transform:"translate3d(-50%, -50%, 0)",transition:I?"width 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}:g?{...S,width:g.width,height:g.height}:f?y:S,onLoad:B=>{const $=B.currentTarget,E=$.parentElement;if(E&&$.naturalWidth>0&&$.naturalHeight>0){const A=Math.max(1,E.clientWidth-2),T=Math.max(1,E.clientHeight-2),U=Math.min(A/$.naturalWidth,T/$.naturalHeight),D=f?U:Math.min(U,1);b({width:Math.max(1,Math.round($.naturalWidth*D)),height:Math.max(1,Math.round($.naturalHeight*D))})}l(B)},onError:u});return!f||!g?_:e.jsx("div",{"data-vector-zoom-surface":!0,className:"relative shrink-0 touch-none select-none",style:{...y,width:g.width,height:g.height},children:_})}})}function Kb({svg:r,title:n,scale:s,vectorTransformStyle:l}){const u=a.useRef(null);return a.useLayoutEffect(()=>{const d=u.current,h=d?.querySelector("svg");if(!d||!h)return;const m=()=>{const f=h.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number)??[];let S=f[2],y=f[3];if((!Number.isFinite(S)||!Number.isFinite(y)||S<=0||y<=0)&&(S=Number(h.getAttribute("width")),y=Number(h.getAttribute("height"))),!Number.isFinite(S)||!Number.isFinite(y)||S<=0||y<=0)return;const N=Math.max(1,d.clientWidth-24),I=Math.max(1,d.clientHeight-24),_=Math.min(N/S,I/y,1);h.style.width=`${Math.max(1,Math.floor(S*_*s))}px`,h.style.height=`${Math.max(1,Math.floor(y*_*s))}px`,h.style.maxWidth="none",h.style.maxHeight="none",h.style.transform=String(l.transform??""),h.style.transformOrigin="center center",h.style.transition=String(l.transition??"none")};m();const g=typeof ResizeObserver>"u"?null:new ResizeObserver(m);return g?.observe(d),()=>g?.disconnect()},[s,r,l]),e.jsx("div",{ref:u,role:"img","aria-label":n,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden rounded border border-border/15 bg-white p-3 text-slate-900 shadow-sm [&_svg]:block",dangerouslySetInnerHTML:{__html:r}})}function Vb({svg:r,title:n,onZoomChange:s,onDoubleTap:l}){return e.jsx(Tf,{resetKey:r,onZoomChange:s,onDoubleTap:l,children:({vectorTransformStyle:u,scale:d})=>e.jsx(Kb,{svg:r,title:n,scale:d,vectorTransformStyle:u})})}let qb=0,Yb=0,Xb=0,Jb=0,Qb=0;function Ii(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="still_active"?"warn":"info",message:`FILE_PREVIEW_LOADING ${r}`,data:{ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function lt(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="error"||r==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${r}`,data:{seq:++Yb,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function to(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${r}`,data:{seq:++Jb,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function Zb(){return`diff-ui-${Date.now().toString(36)}-${(++Qb).toString(36)}`}function ex(r){return r instanceof Element?r.closest("[data-diff-selection-path]"):null}function tx(r){const n=r.target instanceof HTMLElement?r.target:null;return{eventType:r.type,button:r.button,pointerType:r instanceof globalThis.PointerEvent?r.pointerType:void 0,targetTag:n?.tagName,targetClass:n?.className,targetText:n?.textContent?.slice(0,80)}}function al({onReviewReference:r,filePath:n,onInsertReference:s,onInsertText:l,onInsertFeature:u,onReferenceCopied:d,onClose:h,onDirectoryLinkOpen:m,isMobile:g,markdownOutlineOpen:b,markdownOutlineCloseSignal:f,onOpenMarkdownOutline:S,onCloseMarkdownOutline:y,markdownImageLightboxOpen:N,markdownImageLightboxCloseSignal:I,onOpenMarkdownImageLightbox:_,onCloseMarkdownImageLightbox:B,lineRange:$,onLineRangeChange:E,insertedReferenceKey:A,copiedReferenceKey:T,scrollToLine:U,onScrollToLineHandled:D}){const{t:p}=kt(),i=J(P=>P.rootPath),O=J(P=>P.selectFile),[C,K]=a.useState({kind:"idle"}),[de,ne]=a.useState("schematic"),[ve,W]=a.useState(null),X=a.useRef(null),[L,F]=a.useState(null),q=a.useRef(new Map),se=a.useRef(null),[ie,me]=a.useState(null),[ge,Pe]=a.useState(()=>Wd()),[M,ee]=a.useState(()=>Ld(i,n)),be=a.useRef(null),[Le,Xe]=a.useState(!1),[Ee,Qe]=a.useState(null),[Fe,R]=a.useState(0),[te,le]=a.useState([]),[Me,je]=a.useState(null),He=a.useRef(null),ce=a.useRef(n),[Ae,nt]=a.useState(null),[V,he]=a.useState({status:"idle"}),[Be,qe]=a.useState(!1),[qt,Ze]=a.useState(""),[dt,Pr]=a.useState([]),[Ft,H]=a.useState(0),ae=a.useRef(null),ye=ju(d),ze=bl(i,n);a.useEffect(()=>{if(ce.current===n)return;ce.current=n;const P=n&&i&&!n.startsWith("/")?`${i}/${n}`:n;if(He.current===P){He.current=null;return}He.current=null,le([]),je(null),qe(!1),Ze("")},[n,i]);const mt=n?i&&!n.startsWith("/")?`${i}/${n}`:n:null,ur=J(P=>mt?(P.fileChangeVersions.get(mt)??0)+P.fileWatchEpoch:P.fileWatchEpoch),fr=a.useRef(null),_t=a.useRef(null),[hr,mr]=a.useState(0),Sn=a.useCallback(()=>mr(P=>P+1),[]);a.useEffect(()=>{const P=X.current;return X.current=null,W(null),P&&URL.revokeObjectURL(P.objectUrl),()=>{const z=X.current;X.current=null,z&&URL.revokeObjectURL(z.objectUrl)}},[mt,ur,hr]),a.useEffect(()=>{if(!n){fr.current=null,K({kind:"idle"});return}const P=i&&!n.startsWith("/")?`${i}/${n}`:n,z=new AbortController,ue=++qb,Se=`right-sidebar-file-preview:${ue}`,Je=performance.now();let Te=!1;const We=(Q,Ge={})=>{Te||(Te=!0,Ii("end",{loadingId:ue,reason:Q,durationMs:Math.round(performance.now()-Je),filePath:n,fullPath:P,rootPath:i,...Ge}))};let Ie=null;const et=qh(P),ut=et?P.toLowerCase().endsWith(".kicad_pcb")?de==="schematic"?"pcb-front":de:"schematic":de,Nn=!et&&ol(P),rr=!et&&!Nn&&Yh(P),ss=!et&&!Nn&&!rr&&cu(P),en=Es(P),tn=Rs(P),Or=et?"eda":Nn?"image":rr?"model3d":ss?"video":"text",rn=fr.current!==P;if(fr.current=P,rn){Ii("start",{loadingId:ue,filePath:n,fullPath:P,rootPath:i,mode:Or,externalVersion:ur}),he({status:"idle"}),K({kind:"loading",mode:Or}),_t.current=null;const Q=ru(i,n);E(Q?.lineRange??null),Pe(en?Wd():"source"),ee(tn?Ld(i,n):"source"),et&&ne(Xh(P))}rn||K(Q=>Q.kind==="error"?{kind:"loading",mode:Or}:Q);const nn=window.setTimeout(()=>{Te||z.signal.aborted||Ii("still_active",{loadingId:ue,filePath:n,fullPath:P,rootPath:i,mode:Or,durationMs:Math.round(performance.now()-Je),isPathChange:rn})},3e3),as=window.setTimeout(()=>{if(Te||z.signal.aborted)return;const Q=et?p("rightSidebar.edaTimeout"):rr?p("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";z.abort(new DOMException(Q,"TimeoutError")),K({kind:"error",message:Q}),We("stuck_timeout",{error:Q})},et?Jh+5e3:rr?Qh+5e3:Zh(P)?35e3:_g);if(et){const Q=ut==="pcb-3d"?X.current:null;Q?(K(Q),We("eda_3d_client_cache_hit",{bytes:Q.meta.size,view:Q.view,mimeType:Q.meta.mimeType})):em(P,ut,z.signal,"view_file",Se).then(Ge=>{if(z.signal.aborted)return;Ie=URL.createObjectURL(Ge.blob);const Pt={kind:"eda",sourcePath:Ge.path||P,objectUrl:Ie,view:Ge.view,meta:{size:Ge.size,mimeType:Ge.mimeType,modified:Ge.modified}};if(Ge.view==="pcb-3d"){const nr=X.current;nr&&nr.objectUrl!==Ie&&URL.revokeObjectURL(nr.objectUrl),X.current=Pt,W(Pt),Ie=null}K(Pt),We("eda_loaded",{bytes:Ge.size,view:Ge.view,mimeType:Ge.mimeType})}).catch(Ge=>{z.signal.aborted||(K({kind:"error",message:Ge instanceof Error&&/timed out/i.test(Ge.message)?p("rightSidebar.edaTimeout"):Ge instanceof Error?Ge.message:p("rightSidebar.edaLoadFailed")}),We("error",{error:Ge instanceof Error?Ge.message:String(Ge)}))})}else if(Nn)tm(P,z.signal,"view_file",Se).then(Q=>{Ie=URL.createObjectURL(Q.blob),K({kind:"image",objectUrl:Ie,meta:{size:Q.size,mimeType:Q.mimeType,modified:Q.modified}}),We("image_loaded",{bytes:Q.size,mimeType:Q.mimeType})}).catch(Q=>{z.signal.aborted||(K({kind:"error",message:Q instanceof Error?Q.message:p("rightSidebar.imageLoadFailed")}),We("error",{error:Q instanceof Error?Q.message:String(Q)}))});else if(rr)rm(P,z.signal,"view_file",Se).then(Q=>{z.signal.aborted||(Ie=URL.createObjectURL(Q.blob),K({kind:"model3d",sourcePath:Q.path||P,objectUrl:Ie,ext:Q.ext,meta:{size:Q.size,mimeType:Q.mimeType,modified:Q.modified}}),We("model3d_loaded",{bytes:Q.size,ext:Q.ext}))}).catch(Q=>{z.signal.aborted||(K({kind:"error",message:Q instanceof Error&&(Q.name==="TimeoutError"||/timed out/i.test(Q.message))?p("rightSidebar.model3dTimeout"):Q instanceof Error?Q.message:p("rightSidebar.model3dLoadFailed")}),We("error",{error:Q instanceof Error?Q.message:String(Q)}))});else if(ss){const Q=nm(P)??"",Ge=du(P);K(Pt=>Pt.kind==="video"&&Pt.url===Ge?Pt:{kind:"video",url:Ge,meta:{size:null,mimeType:Q,modified:null}}),We("video_ready",{mimeType:Q})}else ad(P,z.signal,"view_file",Se).then(Q=>{if(!z.signal.aborted){if(Q.binary){K({kind:"binary"});return}K({kind:"text",content:Q.content,sourcePath:Q.path||P,meta:{size:Q.size,truncated:Q.truncated}}),We("text_loaded",{bytes:Q.size,truncated:!!Q.truncated})}}).catch(Q=>{z.signal.aborted||(K({kind:"error",message:Q instanceof Error?Q.message:"Failed to read file"}),We("error",{error:Q instanceof Error?Q.message:String(Q)}))});return()=>{z.abort(),Rt(Se),window.clearTimeout(nn),window.clearTimeout(as),Ie&&URL.revokeObjectURL(Ie),We("cleanup")}},[n,i,ur,hr,E,p,de]),a.useEffect(()=>{if(C.kind!=="model3d"||!n){F(null);return}let P=!1;const z=n.lastIndexOf("/"),ue=z>=0?n.slice(z+1):n,Se=z>=0?n.slice(0,z):"",Je=Se.lastIndexOf("/"),Te=Je>=0?Se.slice(0,Je):"",We=ue.replace(/\.(stl|glb|gltf)$/i,""),Ie=`${Te?`${Te}/`:""}features/${We}.json`;return ad(Ie).then(et=>{if(!P)try{const ut=JSON.parse(et.content);F(ut.version===1&&Array.isArray(ut.features)&&ut.features.length>0?ut.features:null)}catch{F(null)}}).catch(()=>{P||F(null)}),()=>{P=!0}},[C,n]),a.useEffect(()=>{if(C.kind!=="text"){nt(null);return}const P=i&&n&&!n.startsWith("/")?`${i}/${n}`:n,z=yu(P),ue=C.content,Se=Es(P??"")&&ge==="preview",Je=Rs(P??"")&&M==="preview";if(!z||Se||Je||!wu(ue)){nt(null);return}let Te=!1;const We=Ie=>{if(Te||!Ie.registered(z)){Te||nt(null);return}try{nt(Su(Ie,ue,z))}catch{nt(null)}};return Ee?We(Ee):(nt(null),ku().then(Ie=>{Te||(Qe(Ie),We(Ie))}).catch(()=>{})),()=>{Te=!0}},[C,Ee,n,i,ge,M]),a.useLayoutEffect(()=>{if(!ze||C.kind!=="text")return;const P=`${ze}:${ge}:${M}`;if(_t.current===P)return;const z=ru(i,n);if(_t.current=P,!z)return;const ue=requestAnimationFrame(()=>{const Se=se.current;if(!Se)return;const Je=ge==="preview"?z.markdownTop??z.top:z.top;Se.scrollTo({top:Math.max(0,Je??0),left:Math.max(0,z.left??0)}),R(ge==="preview"?Math.max(0,Je??0):0)});return()=>cancelAnimationFrame(ue)},[n,ge,M,C.kind,ze,i]),a.useEffect(()=>{ze&&Ni(i,n,{lineRange:$})},[n,$,ze,i]),a.useEffect(()=>{if(U==null||C.kind!=="text")return;me(null),E({start:U,end:U});const P=U,z=requestAnimationFrame(()=>{const ue=q.current.get(P);ue&&ue.scrollIntoView({block:"center"}),D?.()});return()=>cancelAnimationFrame(z)},[U,C,E,D]);const jn=a.useCallback(P=>{const z=se.current;if(!z)return!1;const ue=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(P):P.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Se=z.querySelector(`#${ue}`);return Se?(Se.scrollIntoView({block:"start"}),!0):!1},[]);a.useEffect(()=>{const P=i&&n&&!n.startsWith("/")?`${i}/${n}`:n,z=C.kind==="text"&&Es(P??"")&&ge==="preview";if(!Me||!z)return;const ue=requestAnimationFrame(()=>{jn(Me)&&je(null)});return()=>cancelAnimationFrame(ue)},[n,jn,ge,Me,C,i]),a.useLayoutEffect(()=>{const P=se.current;if(!P||!$){me(null);return}if(ie)return;const z=C.kind==="image"||C.kind==="loading"&&C.mode==="image",ue=i&&n&&!n.startsWith("/")?`${i}/${n}`:n,Se=C.kind==="text"&&Es(ue??"")&&ge==="preview",Je=C.kind==="text"&&Rs(ue??"")&&M==="preview";if(C.kind!=="text"||z||Se||Je){me(null);return}const Te=()=>{const Ie=q.current.get($.end);if(!Ie||!P){me(null);return}const et=Ie.offsetTop+Ie.offsetHeight/2,ut=P.scrollLeft+Math.max(8,P.clientWidth-120);me({top:et,left:ut})};Te();const We=new ResizeObserver(()=>Te());return We.observe(P),()=>We.disconnect()},[$,ie,C,ge,M,n,i,Ae]);const Tr=C.kind==="text"&&!(Rs(mt??"")&&M==="preview")&&!mt?.toLowerCase().endsWith(".csv")&&!mt?.toLowerCase().endsWith(".kicad_pro")&&!mt?.toLowerCase().endsWith(".kicad_prl"),pr=a.useCallback(()=>{qe(!1),Ze(""),Pr([]),H(0),qa()},[]),Rn=a.useCallback(()=>{Tr&&(qe(!0),requestAnimationFrame(()=>{ae.current?.focus(),ae.current?.select()}))},[Tr]),gt=a.useCallback(P=>{H(z=>dt.length===0?0:(z+P+dt.length)%dt.length)},[dt.length]);if(a.useEffect(()=>{const P=z=>{const ue=yg(z);if(ue==="open"&&Tr){z.preventDefault(),Rn();return}Be&&(ue==="close"?(z.preventDefault(),pr()):(ue==="next"||ue==="previous")&&(z.preventDefault(),gt(ue==="previous"?-1:1)))};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[pr,Be,gt,Rn,Tr]),a.useLayoutEffect(()=>{if(qa(),!Be||!qt.trim()||!se.current){Pr([]),H(0);return}const P=kg(se.current,qt);return Pr(P),H(0),Id(P,0),Dd(P[0]),qa},[Be,qt,Ae,ge,C]),a.useEffect(()=>{Be&&(Id(dt,Ft),Dd(dt[Ft]))},[Ft,dt,Be]),a.useEffect(()=>qa,[]),!n)return e.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:p("rightSidebar.selectFilePrompt")});const Ue=i&&!n.startsWith("/")?`${i}/${n}`:n,Lt=ao(Ue,i),gr=fu(Ue,i),br=C.kind==="text"&&C.content?C.content.split(`
|
|
1654
|
+
`):[],Ws=Math.max(2,String(br.length).length)+1,xr=C.kind==="text"||C.kind==="image"||C.kind==="model3d"||C.kind==="video"||C.kind==="eda"?C.meta:null,vr=Es(Ue),Gs=Ue.toLowerCase().endsWith(".csv"),At=Ue.toLowerCase().endsWith(".kicad_pro"),Qn=Ue.toLowerCase().endsWith(".kicad_prl"),Bt=C.kind==="text"&&vr&&ge==="preview",Ks=Rs(Ue),yr=C.kind==="text"&&Ks&&M==="preview",Vs=C.kind==="image"||C.kind==="loading"&&C.mode==="image",qs=C.kind==="model3d"||C.kind==="loading"&&C.mode==="model3d",Nt=C.kind==="video"||C.kind==="loading"&&C.mode==="video",Xr=C.kind==="eda"||C.kind==="loading"&&C.mode==="eda",Zn=C.kind==="text"?C.sourcePath:Ue,Ir=Mm(Zn,i,$),Dr=(()=>{if(!$||C.kind!=="text"||br.length===0)return Ir;const P=[];for(let Se=$.start;Se<=$.end;Se+=1)P.push(`${Se} ${br[Se-1]??""}`);const z=Yu(Ue).replace(/^\./,""),ue="```";return`${Ir}
|
|
1655
|
+
${ue}${z}
|
|
1656
|
+
${P.join(`
|
|
1657
|
+
`)}
|
|
1658
|
+
${ue}
|
|
1659
|
+
`})(),wr=`path:${Ue}`,kr=$?`path:${Ue}:${$.start}-${$.end}`:wr,Fr=A===wr,_r=A===kr,Cn=T===wr,es=T===kr,Jr=_r||es,Yt=$?$.start===$.end?`L${$.start}`:`L${$.start}-${$.end}`:null,Br=P=>{const z=se.current;if(!z)return;const ue=z.getBoundingClientRect(),Se=P.currentTarget.getBoundingClientRect(),Je=P.clientX||Se.left+Se.width/2,We=(P.clientY||Se.top+Se.height/2)-ue.top+z.scrollTop,Ie=g?116:132,et=z.scrollLeft+Math.max(8,z.clientWidth-Ie),ut=Math.min(Math.max(8,Je-ue.left+z.scrollLeft+10),et);me({top:We,left:ut})},ts=(P,z)=>{Ui()||(Br(P),E(ue=>{const Se=Hi(ue,z,z);return Se||me(null),Se}))},rs=(P,z,ue)=>{Br(P),E(Se=>{const Je=Hi(Se,z,ue);return Je||me(null),Je})},Sr=(P,z,ue,Se)=>{Se==="end"&&Br(P),E({start:z,end:ue})},tr=P=>{const{scrollTop:z,scrollLeft:ue}=P.currentTarget;R(z),Ni(i,n,{top:z,left:ue,markdownTop:z})},we=P=>{if(P.directory){m?.(P.path);return}if(P.path===Ue||C.kind==="text"&&P.path===C.sourcePath){P.fragment&&jn(P.fragment);return}le(z=>[...z,Ue]),He.current=P.path,je(P.fragment),E(null),O(P.path)},Xt=()=>{const P=te[te.length-1];P&&(le(z=>z.slice(0,-1)),He.current=P,je(null),E(null),O(P))},Qr=P=>{const{scrollTop:z,scrollLeft:ue}=P.currentTarget;Ni(i,n,{top:z,left:ue})},Zr=()=>{if(r){r(Dr,kr);return}$&&l(Dr,kr)},ns=async()=>{if(!(!Ue||V.status==="pending")&&!(C.kind==="loading"||C.kind==="error")){he({status:"pending"});try{await bm(Ue),he({status:"idle"})}catch(P){he({status:"error",message:P instanceof Error?P.message:p("rightSidebar.downloadFailed")})}}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[ye.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${g&&(Bt||yr)?"py-1.5":"py-2"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[g&&h&&e.jsx("button",{type:"button",onClick:h,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":p("rightSidebar.backToFileList"),title:p("rightSidebar.backToFileList"),children:e.jsx(gu,{size:16})}),te.length>0&&e.jsxs("button",{type:"button",onClick:Xt,className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-primary/10 text-primary transition hover:bg-primary/15 active:scale-95 ${g?"w-9":"px-2.5"}`,"aria-label":p("rightSidebar.backToPreviousPreview"),title:p("rightSidebar.backToPreviousPreview"),children:[e.jsx(Fs,{size:15}),!g&&e.jsx("span",{className:"text-[11px] font-medium",children:p("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:Ue,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Lt.name}),Lt.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Lt.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Tr&&e.jsx("button",{type:"button",onClick:Be?pr:Rn,className:`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${Be?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":p("rightSidebar.findInFile"),title:`${p("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(Xn,{size:14})}),vr&&C.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{b&&y?.(),Pe(P=>{const z=P==="preview"?"source":"preview";return $t(Iu,z),z}),E(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${g?"w-9 px-0":"px-3"}`,"aria-label":p(ge==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:p(ge==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:g?ge==="preview"?e.jsx(Wi,{size:14}):e.jsx(zi,{size:14}):p(ge==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),Ks&&C.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{ee(P=>{const z=P==="preview"?"source":"preview";return Op(i,n,z),z}),E(null)},className:`inline-flex h-9 shrink-0 items-center justify-center gap-1 rounded-full bg-surface-2 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${g?"w-9 px-0":"px-3"}`,"aria-label":p(M==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:p(M==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:g?M==="preview"?e.jsx(Wi,{size:14}):e.jsx(zi,{size:14}):p(M==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),yr&&e.jsx("button",{type:"button",onClick:()=>{be.current?.toggleFullscreen()},className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":p(Le?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:p(Le?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(bu,{size:15})}),!g&&e.jsx("button",{type:"button",onClick:()=>s(Ue,wr),...ye(gr,wr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${Fr||Cn?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:p("rightSidebar.insertReference",{reference:gr}),children:p(Cn?"rightSidebar.copied":Fr?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(gr)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:p("rightSidebar.copyReference",{reference:gr}),"aria-label":p("rightSidebar.copyFileRef"),children:e.jsx(sm,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{ns()},disabled:V.status==="pending"||C.kind==="loading"||C.kind==="error",className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:opacity-50 disabled:active:scale-100",title:V.status==="error"?V.message??p("rightSidebar.downloadFailed"):p("rightSidebar.downloadFile"),"aria-label":p("rightSidebar.downloadFile"),children:V.status==="pending"?e.jsx(Ct,{size:13,className:"animate-spin"}):e.jsx($m,{size:14})})]})]}),Be&&Tr&&e.jsxs("div",{className:"mt-2 flex min-w-0 items-center gap-1.5","data-file-preview-search":!0,children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center rounded-lg bg-surface-2 px-2 focus-within:bg-surface-elevated",children:[e.jsx(Xn,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:ae,type:"search",value:qt,onChange:P=>Ze(P.target.value),onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),gt(P.shiftKey?-1:1))},className:"h-8 min-w-0 flex-1 bg-transparent px-2 text-xs text-foreground outline-none placeholder:text-muted-foreground/70",placeholder:p("rightSidebar.findInFilePlaceholder"),"aria-label":p("rightSidebar.findInFile")}),e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:dt.length>0?`${Ft+1}/${dt.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>gt(-1),disabled:dt.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":p("rightSidebar.previousSearchMatch"),title:`${p("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:e.jsx(hu,{size:13})}),e.jsx("button",{type:"button",onClick:()=>gt(1),disabled:dt.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":p("rightSidebar.nextSearchMatch"),title:`${p("rightSidebar.nextSearchMatch")} (Enter)`,children:e.jsx(Lm,{size:13})}),e.jsx("button",{type:"button",onClick:pr,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":p("rightSidebar.closeFileSearch"),title:`${p("rightSidebar.closeFileSearch")} (Esc)`,children:e.jsx(Vt,{size:13})})]}),xr&&!(g&&(Bt||yr))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[xr.size!==null&&e.jsx("span",{children:p("rightSidebar.byteCount",{count:xr.size.toLocaleString()})}),"truncated"in xr&&xr.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:p("rightSidebar.previewTruncated")}),"mimeType"in xr&&e.jsx("span",{children:xr.mimeType}),"dimensions"in C&&C.dimensions&&e.jsxs("span",{children:[C.dimensions.width," × ",C.dimensions.height]})]}),!(g&&(Bt||yr))&&!qs&&C.kind!=="binary"&&e.jsx("div",{className:"mt-1 flex h-4 items-center gap-2 text-[10px] text-muted-foreground/75",children:e.jsx("span",{className:"truncate",children:Xr?p("rightSidebar.edaPickHint"):Gs?p("rightSidebar.csvTablePreview"):At||Qn?p("rightSidebar.kicadProjectPickHint"):Nt?p("rightSidebar.videoPreviewHint"):Vs?p("rightSidebar.imagePreviewHint"):Bt?$?p("rightSidebar.selectedLineHint",{lineLabel:Yt??""}):p("rightSidebar.markdownPreviewHint"):yr?p("rightSidebar.htmlPreviewHint"):$?p("rightSidebar.selectedLineHint",{lineLabel:Yt??""}):p("rightSidebar.multiLineHint")})})]}),C.kind==="loading"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8 text-center text-sm text-muted-foreground",children:C.mode==="eda"?p("rightSidebar.edaLoading"):C.mode==="image"?p("rightSidebar.loadingImage"):C.mode==="model3d"?p("rightSidebar.model3dLoading"):C.mode==="video"?p("rightSidebar.loadingVideo"):"Loading file…"}):C.kind==="error"?e.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[e.jsx("div",{className:"mx-3 mt-3 border border-destructive/20 bg-destructive/5 px-4 py-4 text-sm text-destructive",children:C.message}),e.jsx("button",{type:"button",onClick:Sn,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:p("common.retry")})]}):C.kind==="binary"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsx("div",{className:"mx-3 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-6 text-center text-sm text-muted-foreground",children:p("rightSidebar.binaryPreviewHint")})}):C.kind==="image"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:C.meta.mimeType==="image/svg+xml"?e.jsx($u,{blobUrl:C.objectUrl,filePath:Ue,viewLabel:"SVG 文件",onInsertAnnotation:u}):e.jsx(If,{src:C.objectUrl,alt:Lt.name,vector:!1,onLoad:P=>{const z=P.currentTarget;K(ue=>ue.kind==="image"?{...ue,dimensions:{width:z.naturalWidth,height:z.naturalHeight}}:ue)},onError:()=>K({kind:"error",message:p("rightSidebar.imageLoadFailed")})})}):C.kind==="video"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:e.jsx(Qp,{url:C.url,onLoadError:()=>K({kind:"error",message:p("rightSidebar.videoLoadFailed")})})}):C.kind==="eda"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(ag,{blobUrl:C.objectUrl,filePath:C.sourcePath,view:C.view,board:Ue.toLowerCase().endsWith(".kicad_pcb"),onViewChange:ne,onInsertAnnotation:r??u,onRefresh:Sn,interactive3d:ve?e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:p("rightSidebar.model3dLoading")}),children:e.jsx(zd,{blobUrl:ve.objectUrl,ext:".glb",fileName:Lt.name,filePath:ve.sourcePath,features:null,onInsertFeature:r??u,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:P=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(P)?P:"PCB板体/铜箔/丝印",active:C.view==="pcb-3d"})}):void 0})}):C.kind==="model3d"?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:p("rightSidebar.model3dLoading")}),children:e.jsx(zd,{blobUrl:C.objectUrl,ext:C.ext,fileName:Lt.name,filePath:C.sourcePath,features:L,onInsertFeature:r??u,onRefresh:Sn})})}):C.kind==="text"&&Gs?e.jsx(lg,{content:C.content,filePath:Ue,onInsertAnnotation:r??u},Ue):C.kind==="text"&&(At||Qn)?e.jsx(ug,{content:C.content,filePath:Ue,localState:Qn,onInsertAnnotation:r??u},Ue):Bt?e.jsxs("div",{ref:se,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:tr,style:{touchAction:"pan-x pan-y"},children:[e.jsx(jf,{content:C.content,filePath:C.sourcePath,rootPath:i,lineRange:$,onLineRangeClick:rs,onLineRangeDrag:Sr,scrollTop:Fe,outlineOpen:b,outlineCloseSignal:f,onOutlineOpen:S,onOutlineClose:y,lightboxOpen:N,lightboxCloseSignal:I,onLightboxOpen:_,onLightboxClose:B,onLocalLinkOpen:we}),$&&ie&&e.jsxs("button",{type:"button",onClick:Zr,...ye(Dr,kr),style:{top:ie.top,left:ie.left,transform:"translateY(-50%)"},className:Cd(g,Jr),title:`Insert markdown reference: ${Ir}`,children:[e.jsx(io,{size:g?13:11}),es?p("rightSidebar.copied"):_r?p("rightSidebar.inserted"):p("rightSidebar.insertLineRef",{lineLabel:Yt??""})]})]}):yr?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(vg,{ref:be,src:am(Ue),title:`${Lt.name} preview`,exitFullscreenLabel:p("rightSidebar.htmlFullscreenExit"),onFullscreenChange:Xe},`${Ue}:${ur}:${hr}`)}):C.kind==="text"?e.jsxs("div",{ref:se,onScroll:Qr,className:`${cl} termdock-native-select termdock-code relative min-h-0 flex-1 overflow-auto rounded-none bg-surface p-2 font-mono text-[11px] leading-relaxed text-foreground`,children:[br.length>0?e.jsx("div",{className:"min-w-full",children:br.map((P,z)=>{const ue=z+1,Se=!!($&&ue>=$.start&&ue<=$.end),Je=Ae&&Ae.length===br.length?Ae[z]:null;return e.jsxs("div",{ref:Te=>{Te?q.current.set(ue,Te):q.current.delete(ue)},role:"button","data-file-preview-line":ue,tabIndex:0,onClick:Te=>ts(Te,ue),onKeyDown:Te=>{Te.key!=="Enter"&&Te.key!==" "||(Te.preventDefault(),ts(Te,ue))},style:{gridTemplateColumns:`${Ws}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${Se?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${gr}:${ue}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${Se?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:ue}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Je??(P||" ")})]},z)})}):"Empty file.",$&&ie&&e.jsxs("button",{type:"button",onClick:Zr,...ye(Dr,kr),style:{top:ie.top,left:ie.left,transform:"translateY(-50%)"},className:Cd(g,Jr),title:`Insert code reference: ${Ir}`,children:[e.jsx(io,{size:g?13:11}),es?p("rightSidebar.copied"):_r?p("rightSidebar.inserted"):p("rightSidebar.insertLineRef",{lineLabel:Yt??""})]})]}):null]})}function rx({isOpen:r,sessionId:n,drawerWidthPx:s,onClose:l,onOpen:u,push:d,pinned:h=!1,onTogglePinned:m,rightSidebarFilePreviewOpen:g=!1,rightSidebarFilePreviewCloseSignal:b,onOpenRightSidebarFilePreview:f,onCloseRightSidebarFilePreview:S,rightSidebarRepoPickerOpen:y=!1,rightSidebarRepoPickerCloseSignal:N,onOpenRightSidebarRepoPicker:I,onCloseRightSidebarRepoPicker:_,markdownOutlineOpen:B=!1,markdownOutlineCloseSignal:$,onOpenMarkdownOutline:E,onCloseMarkdownOutline:A,markdownImageLightboxOpen:T=!1,markdownImageLightboxCloseSignal:U,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:p}){const{t:i,locale:O}=kt(),[C,K]=a.useState(""),[de,ne]=a.useState(null),ve=J(t=>t.rightSearchOpen),W=J(t=>t.setRightSearchOpen),X=J(t=>t.rightSidebarLayoutPreference),L=J(t=>t.setRightSidebarLayoutPreference),[F,q]=a.useState(()=>Yg()),[se,ie]=a.useState("."),[me,ge]=a.useState(""),[Pe,M]=a.useState(!1),[ee,be]=a.useState(!1),[Le,Xe]=a.useState(!1),[Ee,Qe]=a.useState(!1),Fe=a.useDeferredValue(C),[R,te]=a.useState(null),[le,Me]=a.useState([]),[je,He]=a.useState([]),ce=J(t=>t.contextKey?t.activeGitRepos[t.contextKey]??null:null),Ae=J(t=>t.setActiveGitRepo),[nt,V]=a.useState(null),[he,Be]=a.useState(null),[qe,qt]=a.useState(null),[Ze,dt]=a.useState(()=>ht(_d,As)??!1),[Pr,Ft]=a.useState(()=>ht(Bd,As)??!1),[H,ae]=a.useState(()=>ht(Od,As)??!1),[ye,ze]=a.useState(()=>ht(ki,Wg)??""),[mt,ur]=a.useState(0),[fr,_t]=a.useState(!1),[hr,mr]=a.useState(!1),Sn=a.useRef(null),jn=a.useRef(null),[Tr,pr]=a.useState(!1),[Rn,gt]=a.useState(null),[Ue,Lt]=a.useState(null),[gr,br]=a.useState(()=>Gd(yi)),[Ws,xr]=a.useState(()=>Gd(Fd)),[vr,Gs]=a.useState(()=>zg()),[At,Qn]=a.useState(()=>Gg()),[Bt,Ks]=a.useState(()=>Vg()),yr="words",[Vs,qs]=a.useState(0),[Nt,Xr]=a.useState([]),[Zn,Ir]=a.useState([]),[Dr,wr]=a.useState(!1),[kr,Fr]=a.useState(null),[_r,Cn]=a.useState([]),[es,Jr]=a.useState(!1),[Yt,Br]=a.useState([]),[ts,rs]=a.useState([]),[Sr,tr]=a.useState(!1),[we,Xt]=a.useState(null),[Qr,Zr]=a.useState([]),[ns,P]=a.useState({}),z=a.useRef(0),[ue,Se]=a.useState(0),[Je,Te]=a.useState(!1),[We,Ie]=a.useState(null),[et,ut]=a.useState(null),[Nn,rr]=a.useState(null),[ss,en]=a.useState(null),[tn,Or]=a.useState(!1),[rn,nn]=a.useState(""),as=a.useDeferredValue(rn),[Q,Ge]=a.useState({}),[Pt,nr]=a.useState([]),[Ys,os]=a.useState(!1),[Xs,is]=a.useState(!1),[vl,En]=a.useState(null),[yo,Mn]=a.useState(!1),sr=a.useRef(null),Ur=a.useRef(0),yl=a.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Df,Js]=a.useState(null),[ls,wl]=a.useState(()=>ht(wi,As)??!1),[wo,ko]=a.useState(!1),[Qs,So]=a.useState([]),[Jt,Zs]=a.useState({}),[Et,ea]=a.useState({}),[sn,jo]=a.useState({}),[kl,Sl]=a.useState(()=>new Set),[Ke,an]=a.useState(null),[Ro,on]=a.useState(null),[Ff,jr]=a.useState(!1),[jl,Rr]=a.useState(0),[,Co]=a.useState(0),[No,ta]=a.useState(!1),[ar,Eo]=a.useState(!1),[_f,Rl]=a.useState(()=>J.getState().rightTab==="diff"),[Mo,$o]=a.useState(()=>J.getState().rightTab==="android"),[Hr,Cl]=a.useState(!1),Bf=od(t=>!!t.docks[bd]),[Oe,cs]=a.useState(null),[$n,ds]=a.useState(null),[bt,ln]=a.useState(null),[Nl,xt]=a.useState(null),[Ln,El]=a.useState(null),[Lo,Of]=a.useState(()=>Date.now()),[Uf,Hf]=a.useState(!1),[cn,ra]=a.useState(!1),[na,Ml]=a.useState(""),[An,sa]=a.useState(""),[dn,aa]=a.useState(""),[un,oa]=a.useState(""),[$l,Pn]=a.useState(null),[ia,la]=a.useState(!1),[Ll,Ao]=a.useState(!1),[Al,Pl]=a.useState(!1),[ca,zf]=a.useState({key:null,nonce:0}),Tl=a.useRef(null),Il=a.useRef(null),re=xm(s,h,X),Wf=Gu(re,h,Bt),[Po,To]=a.useState(()=>rb(s)),Io=J(t=>t.rightTab),Qt=J(t=>t.setRightTab),x=J(t=>t.rootPath),Tn=J(t=>t.explorerRoot),Dl=J(t=>t.pinnedExplorerRootsCache),Fl=J(t=>t.hydratePinnedExplorerRoots),_l=J(t=>t.syncPinnedExplorerRoots),Ot=J(t=>t.setExplorerRoot),Bl=J(t=>t.resetExplorerToProject),In=J(t=>t.pinExplorerRoot),fn=J(t=>t.unpinExplorerRoot),st=J(t=>t.selectedFilePath),at=J(t=>t.selectFile),Do=J(t=>t.showHiddenFiles),Gf=J(t=>t.toggleShowHiddenFiles),Fo=J(t=>!!(x&&t.nestedGitScanRoots[x])),Re=J(t=>t.changedFiles),da=J(t=>t.setChangedFiles),ua=J(t=>t.invalidateDirectoryCache),Kf=J(t=>t.setDirectorySortMode),Ol=J(t=>t.applyFileWatchEvents),Ul=J(t=>t.reconcileDirectoryCache),Hl=J(t=>t.bumpFileWatchEpoch),zr=J(t=>t.gitBundleLoading),zl=J(t=>t.gitBundleSlow),hn=J(t=>t.gitBundleError),Dn=J(t=>t.gitBundleLastLoadedAt),Wl=J(t=>t.beginGitBundleLoading),Gl=J(t=>t.setGitBundleSlowFor),_o=J(t=>t.finishGitBundleLoading),fa=J(t=>t.resetGitBundleLoading),Bo=J(t=>t.setGitBundleError),Kl=J(t=>t.markGitBundleLoaded),xe=Tn??x,Vl=a.useMemo(()=>xe?jg(xe,se):"",[xe,se]),us=a.useMemo(()=>Sg(me),[me]),ql=a.useMemo(()=>({excludePatterns:us,caseSensitive:ee,wholeWord:Le,regex:Ee}),[ee,us,Ee,Le]),ha=J(t=>xe?t.fileSortModes[xe]??"name":"name"),Yl=J(t=>!!(xe&&t.directoryCache.has(xe))),Fn=a.useRef(null),St=a.useRef(0),[Xl]=a.useState(()=>++Xb),Cr=a.useRef(null),Wr=a.useRef(null),ma=a.useRef(0),Ut=a.useRef(new Map),Ht=a.useRef(new Map),or=a.useRef(new Set),mn=a.useRef(new Set),pn=a.useRef(0),Gr=a.useRef(null),_n=a.useRef(0),Bn=a.useRef(null),On=a.useRef(0),Kr=a.useRef(null),Oo=a.useRef(new Set),Uo=a.useRef(null),Ho=a.useRef(null),pa=a.useRef(null),zo=a.useRef(null),Wo=a.useRef(null),fs=a.useRef(new Set);a.useEffect(()=>{if(Ln===null)return;const t=Math.max(0,Date.now()-Ln),o=t<6e4?1e3:t<36e5?6e4:t<864e5?36e5:864e5,c=Math.max(50,o-t%o),v=window.setTimeout(()=>Of(Date.now()),c);return()=>window.clearTimeout(v)},[Lo,Ln]);const ga=a.useRef(null),Nr=a.useRef(null),ba=a.useRef(null),hs=a.useRef(null),Ce=a.useCallback(t=>J.getState().rootPath===t,[]);a.useEffect(()=>{if(!r||typeof window>"u")return;const t=o=>{const c=ex(o.target);c&&to("global_change_row_event",{...tx(o),selectionPath:c.dataset.diffSelectionPath,filePath:c.dataset.diffFilePath,absolutePath:c.dataset.diffAbsolutePath,repoRoot:c.dataset.diffRepoRoot,status:c.dataset.diffStatus,selectedFilePath:J.getState().selectedFilePath,rightTab:J.getState().rightTab,activeGitRepoRoot:ce,changedFiles:J.getState().changedFiles.size})};return window.addEventListener("pointerdown",t,{capture:!0}),window.addEventListener("click",t,{capture:!0}),()=>{window.removeEventListener("pointerdown",t,{capture:!0}),window.removeEventListener("click",t,{capture:!0})}},[ce,r]);const Jl=a.useCallback(async(t=x??void 0)=>{if(!t)return null;if(or.current.has(t)||mn.current.has(t))return lt("untracked_skip_cached",{cwd:t,rootPath:x,completed:or.current.has(t),running:mn.current.has(t)}),null;const o=x,c=ma.current+1;ma.current=c,Ut.current.set(t,c);const v=`right-sidebar-git-untracked:${t}`,w=new AbortController;Ht.current.set(t,w),mn.current.add(t),lt("untracked_start",{requestId:c,cwd:t,rootPath:x});try{let k=await id(t,w.signal,v),j=0;for(;k.status==="running"&&j<120;){if(Ut.current.get(t)!==c||w.signal.aborted)return lt("untracked_stale_result",{requestId:c,activeRequestId:Ut.current.get(t),cwd:t,status:k.status}),null;if(!Ce(o))return lt("untracked_root_changed",{requestId:c,cwd:t,expectedRootPath:o,currentRootPath:J.getState().rootPath}),null;await new Promise(Z=>window.setTimeout(Z,j<10?1e3:3e3)),j+=1,k=await id(t,w.signal,v)}if(Ut.current.get(t)!==c||!Ce(o))return lt("untracked_stale_result",{requestId:c,activeRequestId:Ut.current.get(t),cwd:t,expectedRootPath:o,currentRootPath:J.getState().rootPath,files:k.files.length,status:k.status}),null;if(k.status==="done")return da(Ef(J.getState().changedFiles,k.files)),k.files.length>0&&Me(Z=>{const $e=new Map(Z.map(Ne=>[Ne.root,Ne])).get(t);if(!$e)return Z;const Ve=_b($e.files,k.files),G=Z.map(Ne=>Ne.root===t?{...Ne,files:Ve,context:Ne.context?{...Ne.context,changedFiles:Ve.map(_e=>({path:_e.path,absolutePath:_e.absolutePath,status:_e.status})),truncated:!1}:Ne.context,untrackedDeferred:!1}:Ne);He(Mf(G,x));const Y=G.find(Ne=>Ne.root===x);return Y?.context&&te(Ne=>Ne?.root===Y.root?{...Ne,...Y.context}:Ne),G}),or.current.add(t),lt("untracked_apply",{requestId:c,cwd:t,files:k.files.length}),k;const oe=k.error||(k.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return or.current.add(t),lt("untracked_error",{requestId:c,cwd:t,message:oe,code:k.code,status:k.status}),null}catch(k){if(Ut.current.get(t)!==c||!Ce(o)||dr(k))return lt("untracked_aborted",{requestId:c,activeRequestId:Ut.current.get(t),cwd:t,expectedRootPath:o,currentRootPath:J.getState().rootPath,message:k instanceof Error?k.message:String(k)}),null;const j=k instanceof Error?k.message:"Failed to scan untracked files";return or.current.add(t),lt("untracked_error",{requestId:c,cwd:t,message:j}),null}finally{Ht.current.get(t)===w&&Ht.current.delete(t),Ut.current.get(t)===c&&Ut.current.delete(t),mn.current.delete(t)}},[R,Ce,x,da]),Zt=a.useMemo(()=>{const t=new Set(je.map(c=>c.root)),o=_r.filter(c=>t.has(c));return o.length>0?o:ce?[ce]:[]},[ce,_r,je]),Ql=Zt.length===0,gn=a.useMemo(()=>Zt.map(t=>le.find(o=>o.root===t)).filter(t=>!!t),[Zt,le]),Vf=a.useMemo(()=>je.map(t=>({root:t.root,label:t.label,branch:t.branch??null})),[je]),ir=a.useCallback(async()=>{if(!x){Xr([]),Ir([]);return}const t=x,o=_n.current+1;_n.current=o,Bn.current?.abort();const c=new AbortController;Bn.current=c,wr(Nt.length===0),Fr(null);try{const v=Zt.length>0?await Promise.all(Zt.map(w=>ld({workspaceRoot:x,repoRoot:w},c.signal))).then(w=>({records:w.flatMap(k=>k.records),walkthroughs:w.flatMap(k=>k.walkthroughs??[])})):await ld({workspaceRoot:x},c.signal);if(_n.current!==o||!Ce(t))return;Xr(v.records),Ir(v.walkthroughs??[])}catch(v){if(_n.current!==o||!Ce(t)||dr(v))return;Fr(v instanceof Error?v.message:"Failed to load change audit explanations")}finally{Bn.current===c&&(Bn.current=null),_n.current===o&&Ce(t)&&wr(!1)}},[Nt.length,Zt,Ce,x]),xa=a.useCallback(async(t,o,c)=>{if(!t&&!x){Br([]),rs([]);return}const v=x,w=On.current+1;On.current=w,Kr.current?.abort();const k=new AbortController;Kr.current=k;try{const j=t?[t]:Array.from(new Set([x,...le.map(Z=>Z.root)].filter(Z=>!!Z))),oe=await Promise.all(j.map(Z=>im({repoRoot:Z,baseRef:o,branchName:c},k.signal))).then(Z=>{const pe=new Map,$e=new Map;for(const Ve of Z){for(const G of Ve.records)pe.set(G.id,G);for(const G of Ve.walkthroughs??[])$e.set(G.id,G)}return{records:Array.from(pe.values()),walkthroughs:Array.from($e.values())}});if(On.current!==w||!Ce(v))return;Br(oe.records),rs(oe.walkthroughs??[])}catch(j){if(On.current!==w||!Ce(v)||dr(j))return;console.warn("[RightSidebar] Failed to load branch explanations",j)}finally{Kr.current===k&&(Kr.current=null)}},[le,Ce,x]),Un=a.useCallback((t,o={})=>{if(!Ce(x)){lt("apply_skipped_root_changed",{expectedRootPath:x,currentRootPath:J.getState().rootPath,bundleRoot:t.context?.root,files:t.files.length});return}lt(t.files.length===0?"empty_bundle":"apply",{rootPath:x,available:t.available,files:t.files.length,repositories:t.repositories?.map(Y=>({root:Y.root,relativeRoot:Y.relativeRoot,files:Y.files.length,available:Y.available,error:Y.error})),repoFilters:t.repoFilters?.map(Y=>({root:Y.root,label:Y.label,count:Y.count})),cached:t.cached,stale:t.stale,cacheAgeMs:t.cacheAgeMs,untrackedDeferred:t.untrackedDeferred,error:t.error});let c=Ku(t),v=t.repoFilters??[],w=t.files;const k=J.getState().changedFiles;if(!!(o.cacheOnly&&!t.cached&&t.files.length===0&&c.length===0)&&(k.size>0||le.length>0||R)){lt("cache_only_apply_skipped_empty_backend_cache",{rootPath:x,currentFiles:k.size,currentRepositories:le.length});return}const oe=c.some(Y=>Y.deferred);if(oe&&!o.replaceWorkspace){const Y=new Set(c.filter(_e=>!_e.deferred||_e.root===x).map(_e=>_e.root));w=[...Array.from(k.values()).filter(_e=>!Y.has(pt(_e,x)??"")),...t.files]}const Z=nu(k.values(),x),pe=nu(t.files,x),$e=c.some(Y=>Y.root!==x);if(!!(o.background&&!oe&&!o.replaceWorkspace&&k.size>0&&(t.files.length===0&&!t.error||Z>0&&pe===0&&!$e))){lt("background_apply_skipped_degraded_bundle",{rootPath:x,currentFiles:k.size,nextFiles:t.files.length,currentNestedCount:Z,nextNestedCount:pe,nextRepositories:c.map(Y=>({root:Y.root,relativeRoot:Y.relativeRoot,files:Y.files.length})),cached:t.cached,stale:t.stale,error:t.error});return}if(o.replaceRepoRoot){const Y=$f(k.values(),le,t,o.replaceRepoRoot,x);w=Y.files,c=Y.repositories,v=Y.repoFilters}if(da(Nf(w)),Me(c),He(v),Wo.current=x,o.syncActiveRepo!==!1){const{contextKey:Y,activeGitRepos:Ne}=J.getState(),_e=Y?Ne[Y]??null:null,rt=o.activeRepoRoot!==void 0?o.activeRepoRoot:_e,De=Xg({...t,repositories:c,repoFilters:v},rt);Ae(De)}typeof t.cacheUpdatedAt=="number"&&El(t.cacheUpdatedAt),te(Y=>{if(o.replaceRepoRoot&&o.replaceRepoRoot!==x)return Y;if(!t.context)return null;const Ne=Y?.root??x;return!Y?.available||Ne!==(t.context.root??x)?t.context:{...Y,...t.context}}),o.reloadDiff&&qs(Y=>Y+1);const G=J.getState().selectedFilePath;if(G&&!G.startsWith("/")&&!w.some(Y=>Y.path===G||Y.absolutePath===G)&&at(null),br(Y=>{const Ne=new Set(w.map(rt=>pt(rt,x)).filter(Boolean)),_e=new Set;for(const rt of Y)Ne.has(rt)&&_e.add(rt);return ji(yi,_e),_e}),o.loadDeferred!==!1){const Y=c.filter(Ne=>Ne.untrackedDeferred&&Ne.root).map(Ne=>Ne.root);for(const Ne of Y)Jl(Ne)}o.loadAudit!==!1&&ir()},[Ce,ir,Jl,x,at,Ae,da]);a.useEffect(()=>{fa(),Uo.current=null,Ho.current=x;const t=[],o=[];St.current+=1,pn.current+=1,ma.current+=1,Cr.current?.abort(),Rt(Ms(Wr.current?.cwd??x??void 0)),Wr.current=null,Cr.current=null,Gr.current?.abort(),Rt("right-sidebar-git-details"),Gr.current=null;for(const j of Ht.current.values())j.abort();for(const j of Ht.current.keys())Rt(`right-sidebar-git-untracked:${j}`);Ht.current.clear(),Ut.current.clear(),_n.current+=1,Bn.current?.abort(),Bn.current=null,On.current+=1,Kr.current?.abort(),Kr.current=null,Ur.current+=1,sr.current?.abort(),Rt("right-sidebar-recent-commits"),sr.current=null,Xr([]),Ir([]),wr(!1),Fr(null),Cn([]),Jr(!1),Br([]),rs([]),tr(!1),Xt(null),Te(!1),Ie(null),ut(null),rr(null),en(null),Or(!1),nn(""),nr([]),os(!1),is(!1),En(null),Mn(!1),Js(null),an(null),on(null),wl(!1),$t(wi,!1),ko(!1);const c=x?Kd()[x]:null,v=c?.previewEntries??[],w=c?.selectedPreviewKey??null,k=w?v.find(j=>j.key===w)??null:null;++z.current,Te(!1),So(c?.selectedRepoRoots??[]),Zs(c?.repoTargetBranches??{}),ea(c?.repoBaseBranches??{}),Zr(v),P(c?.previewScrollTops??{}),k&&c?.previewDetailOpen&&(k.diff.hunks?.length??0)>0&&(Xt(k.diff),an(k.key),on(c.selectedPreviewFileKey??(k.diff.hunks?.[0]?`${k.diff.hunks[0].filePath}\0${k.diff.hunks[0].hunkHeader}\0${k.diff.hunks[0].hunkIndex}`:null)),tr(!0)),jo(c?.repoIncludeUncommitted??Object.fromEntries(Object.keys(c?.repoTargetBranches??{}).map(j=>[j,c?.includeUncommitted??!0]))),Uo.current=x,ra(!1),or.current.clear(),mn.current.clear(),cs(null),ds(null),ln(null),xt(null),El(null),Me(t),He(o),te(null),zo.current=null,Wo.current=null,fs.current.clear()},[fa,x]);const Tt=a.useCallback(async(t=x??void 0,o={})=>{if(!t)return null;const c=x,v=St.current;if(await fp(()=>Promise.all([J.getState().hydrateNestedGitScanRoots(),J.getState().hydrateActiveGitRepos()]).then(()=>{})),St.current!==v||!Ce(c))return null;const w=t===x&&Ns(x),k=o.includeNested??w,j=o.refresh??o.reloadDiff??!1,oe=o.cacheOnly??!1,Z=o.background??!1,pe=k&&(o.discoverOnly??!1);j&&or.current.clear();const $e=Wr.current;if($e&&$e.cwd===t&&$e.includeNested===k&&$e.refresh===j&&$e.cacheOnly===oe&&$e.discoverOnly===pe)return lt("reuse_pending",{cwd:t,includeNested:k,refresh:j,cacheOnly:oe,discoverOnly:pe}),$e.promise;const Ve=St.current+1;St.current=Ve;const G=`right-sidebar:${Xl}:${Ve}`;Cr.current?.abort();const Y=Ms(t);Rt(Y);const Ne=new AbortController;Cr.current=Ne;let _e=null;Z||Wl(G),Bo(null),lt("start",{requestId:Ve,cwd:t,rootPath:x,requestSlotId:Y,includeNested:k,refresh:j,cacheOnly:oe,background:Z,existingChanges:Re.size,lastLoadedAt:Dn}),!Z&&typeof window<"u"&&(_e=window.setTimeout(()=>{St.current===Ve&&Gl(G,!0)},Pg));const rt=(async()=>{const De=await gi(t,Ne.signal,{includeNested:k,refresh:j,cacheOnly:oe,discoverOnly:pe,action:j?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:Y,requestTimeoutMs:j?null:void 0});if(Ub(De)){if(lt("cancelled_result_ignored",{requestId:Ve,activeRequestId:St.current,cwd:t,error:De.error??De.context?.error}),Ne.signal.aborted)return null;throw new Error(De.error??De.context?.error??"Failed to load Git changes")}return St.current!==Ve||!Ce(c)?(lt("stale_result",{requestId:Ve,activeRequestId:St.current,cwd:t,expectedRootPath:c,currentRootPath:J.getState().rootPath,files:De.files.length,repositories:De.repositories?.length??0}),null):(Un(De,{reloadDiff:o.reloadDiff,syncActiveRepo:o.replaceWorkspace?!0:k,background:Z,cacheOnly:oe,replaceRepoRoot:o.replaceRepoRoot,replaceWorkspace:o.replaceWorkspace}),De)})();Wr.current={cwd:t,includeNested:k,refresh:j,cacheOnly:oe,discoverOnly:pe,promise:rt};try{const De=await rt;return St.current===Ve&&De&&Ce(c)?Kl({cached:De.cached,stale:De.stale,cacheAgeMs:De.cacheAgeMs,nestedDeferred:!k||De.nestedDeferred,untrackedDeferred:De.untrackedDeferred}):St.current===Ve&&Ce(c)&&_o(G),De}catch(De){return St.current!==Ve||!Ce(c)||Ne.signal.aborted?(lt("aborted",{requestId:Ve,activeRequestId:St.current,cwd:t,expectedRootPath:c,currentRootPath:J.getState().rootPath,message:De instanceof Error?De.message:String(De)}),null):(lt("error",{requestId:Ve,cwd:t,includeNested:k,refresh:j,background:Z,message:De instanceof Error?De.message:String(De)}),Z||(te(null),Bo(De instanceof Error?De.message:"Failed to load Git changes")),null)}finally{_e!==null&&window.clearTimeout(_e),Cr.current===Ne&&(Cr.current=null),Wr.current?.promise===rt&&(Wr.current=null),!Z&&St.current===Ve&&Ce(c)&&_o(G)}},[Un,Wl,Re.size,_o,Xl,Dn,Ce,Kl,x,Bo,Gl]),ms=a.useCallback(async()=>{x&&await Tt(x,{reloadDiff:!0,refresh:!0})},[Tt,x]),Go=a.useCallback(async(t=x??void 0)=>{if(!t)return null;const o=x,c=pn.current+1;pn.current=c,Gr.current?.abort(),Rt("right-sidebar-git-details");const v=new AbortController;Gr.current=v,ra(!0);try{const w=await cd(t,v.signal,"load_git_details","right-sidebar-git-details");return pn.current!==c||!Ce(o)?null:(Me(k=>k.map(j=>j.root===w.root?{...j,available:w.available,context:w,error:w.error}:j)),te(k=>k?.root&&w.root&&k.root!==w.root?k:!k?.available||!w.available?w:{...k,...w}),w)}catch(w){return dr(w)||!Ce(o)||pn.current===c&&xt(w instanceof Error?w.message:"Failed to load Git details"),null}finally{Gr.current===v&&(Gr.current=null),pn.current===c&&Ce(o)&&ra(!1)}},[Ce,x]);a.useEffect(()=>{if(!r){St.current+=1,fa(),zo.current=null,pn.current+=1,ma.current+=1,Cr.current?.abort(),Rt(Ms(Wr.current?.cwd??x??void 0)),Wr.current=null,Cr.current=null,Gr.current?.abort(),Rt("right-sidebar-git-details"),Gr.current=null;for(const t of Ht.current.values())t.abort();for(const t of Ht.current.keys())Rt(`right-sidebar-git-untracked:${t}`);Ht.current.clear(),Ut.current.clear(),On.current+=1,Kr.current?.abort(),Kr.current=null,Ur.current+=1,sr.current?.abort(),Rt("right-sidebar-recent-commits"),sr.current=null,ra(!1),Te(!1),Ie(null),ut(null),rr(null),en(null),Or(!1),nn(""),nr([]),os(!1),is(!1),En(null),Mn(!1),K(""),W(!1),gt(null),Eo(!1),re&&Rl(!1)}},[re,r,fa,W]),a.useEffect(()=>{if(!ve)return;const t=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(t)},[ve]),a.useEffect(()=>{re||jr(!1)},[re]);const ps=a.useCallback(t=>{Co(t);const o=ba.current;o&&(o.update(),o.slideTo(t,0),window.requestAnimationFrame(()=>{o.update(),o.slideTo(t,0)}))},[]);a.useEffect(()=>{if(re)if(jr(g),g&&st){Rr(1);const t=Nr.current;t&&(t.update(),t.activeIndex!==1&&(hs.current=1,t.slideTo(1,0)))}else{Rr(0);const t=Nr.current;t&&t.activeIndex!==0&&(hs.current=0,t.slideTo(0,0)),gt(null)}},[re,g,x,st]),a.useEffect(()=>{if(b!==void 0&&!g){Rr(0);const t=Nr.current;t&&t.activeIndex!==0&&(hs.current=0,t.slideTo(0,0)),jr(!1),gt(null)}},[b,g]),a.useEffect(()=>{N!==void 0&&V(null)},[N]),a.useEffect(()=>{!re&&g&&S?.()},[re,S,g]),a.useEffect(()=>{To(t=>Qi(t,s))},[s]);const qf=a.useCallback(t=>{re||(t.preventDefault(),ga.current={startX:t.clientX,startWidth:Po,pointerId:t.pointerId},t.currentTarget.setPointerCapture(t.pointerId))},[Po,re]),Yf=a.useCallback(t=>{const o=ga.current;if(!o||o.pointerId!==t.pointerId)return;const c=Qi(o.startWidth+t.clientX-o.startX,s);To(c),Ps(Ls,c,Ag)},[s]),Zl=a.useCallback(t=>{const o=ga.current;if(!(!o||o.pointerId!==t.pointerId)){ga.current=null,Cs(Ls);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}},[]),Hn=!!(x&&Dn!==null&&ou(R)),Ko=!!(x&&!hn&&Re.size===0&&Dn===null),lr=(()=>{let t=Io;return t==="android"&&!Hr&&(t="files"),Hn&&(t==="git"||t==="diff")&&(t="files"),t})(),ot=lr==="git",zn=lr==="files",jt=lr==="diff",Wn=lr==="android",Xf=Am(t=>t.overlay==="sidebar")&&Wn;a.useEffect(()=>{if(!re){ta(!0);return}if(!r){const o=window.setTimeout(()=>{ta(!1)},Dg);return()=>window.clearTimeout(o)}ta(!1);const t=window.setTimeout(()=>{ta(!0)},Ig);return()=>window.clearTimeout(t)},[re,r]),a.useEffect(()=>{if(!re||!jt)return;const t=ba.current;if(!t)return;const o=window.requestAnimationFrame(()=>{t.update()});return()=>window.cancelAnimationFrame(o)},[jt,re]),a.useEffect(()=>{if(!Hn||!x||zr)return;const t=window.setTimeout(()=>{Tt(x,{background:!0})},3e3);return()=>window.clearTimeout(t)},[Hn,x,zr,Tt]);const Jf=a.useCallback(t=>{Tt(t,{discoverOnly:!0})},[Tt]);hp({active:r&&(ot||jt),rootPath:x,loading:zr,delay:ot&&!re?0:Si,lastStartedRoot:zo,load:Jf}),a.useEffect(()=>{!r||!ot||(!re||No)&&Eo(!0)},[ot,re,r,No]),a.useEffect(()=>{if(!r||ot)return;const t=window.setTimeout(()=>{Eo(!0)},Si);return()=>window.clearTimeout(t)},[ot,r]),a.useEffect(()=>{jt&&Rl(!0)},[jt]),a.useEffect(()=>{!r||!Wn||$o(!0)},[Wn,r]),a.useEffect(()=>{if(r&&Wn||!Mo)return;const t=window.setTimeout(()=>$o(!1),Tg);return()=>window.clearTimeout(t)},[r,Wn,Mo]),a.useEffect(()=>{$o(!1)},[n]),a.useEffect(()=>{let t=!1;return lu().then(o=>{!t&&o.androidPanel&&Cl(o.androidPanel.enabled===!0)}).catch(()=>{}),()=>{t=!0}},[]);const Qf=a.useCallback(t=>{Cl(t),t?Qt("android"):J.getState().rightTab==="android"&&Qt("files"),Fi({androidPanel:{enabled:t}}).catch(()=>{})},[Qt]),ec=a.useCallback(t=>{xe&&Pb(xe,t.currentTarget.scrollTop)},[xe]);a.useEffect(()=>()=>{Cr.current?.abort(),Cs(il),Cs(ll),Cs(Ls),Cs(ki)},[]),a.useEffect(()=>{if(!xe||!Yl)return;const t=Rf()[xe]?.top;if(typeof t!="number")return;let o=window.requestAnimationFrame(()=>{Fn.current&&(Fn.current.scrollTop=t),o=window.requestAnimationFrame(()=>{Fn.current&&(Fn.current.scrollTop=t)})});return()=>window.cancelAnimationFrame(o)},[xe,Yl]),a.useEffect(()=>{if(!r)return;const t=new AbortController;return lm(t.signal).then(o=>Pl(!!o.available)).catch(()=>Pl(!1)),()=>t.abort()},[r]);const gs=a.useCallback(t=>{if(ne(null),at(t),gt(null),re){jr(!0),Rr(1),Nr.current?.slideTo(1),f?.();return}},[re,f,at]),tc=a.useCallback((t,o)=>{if(ne(null),at(t),Lt(o),re){jr(!0),Rr(1),Nr.current?.slideTo(1),f?.();return}},[re,f,at]),bs=a.useCallback(async(t,o)=>{const c=o||Tn||x;if(!(!c||t.length===0)){la(!0);try{await Ua(c,t),ua(c,!1)}catch(v){xt(v instanceof Error?v.message:i("rightSidebar.uploadFailed")),window.setTimeout(()=>xt(null),4e3)}finally{la(!1)}}},[Tn,x,ua,i]),rc=a.useCallback(async t=>{try{await cm(t)}catch(o){xt(o instanceof Error?o.message:i("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>xt(null),4e3)}},[i]),va=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes("Files")&&Ao(!0)},[]),nc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),Ao(!1)},[]),sc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),Ao(!1);const o=t.dataTransfer.files;o.length>0&&bs(Array.from(o))},[bs]),Vo=a.useCallback(t=>{Be(t),window.setTimeout(()=>Be(o=>o===t?null:o),1400)},[]),Er=a.useCallback(t=>{qt(t),window.setTimeout(()=>qt(o=>o===t?null:o),1400)},[]);a.useEffect(()=>{$t(_d,Ze)},[Ze]),a.useEffect(()=>{$t(Bd,Pr)},[Pr]),a.useEffect(()=>{$t(Od,H)},[H]),a.useEffect(()=>{Ps(ki,ye,Ng)},[ye]),a.useEffect(()=>(Fl().catch(()=>{}),dd(t=>{t.type==="pinned-explorer-roots"&&_l(t.pinnedExplorerRoots)})),[Fl,_l]);const ac=a.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),ya=a.useRef(null),bn=a.useRef(null),[oc,qo]=a.useState(!1);a.useEffect(()=>{if(!r)return;qo(!1);let t=!1;dm().then(c=>{t||(ya.current=c.text,ze(v=>c.text&&c.text!==v?c.text:v),qo(!0))}).catch(()=>{t||qo(!0)});const o=dd(c=>{c.type==="context-draft"&&c.origin!==ac.current&&(ya.current=c.text,ze(c.text))});return()=>{t=!0,o(),bn.current!==null&&(window.clearTimeout(bn.current),bn.current=null)}},[r]),a.useEffect(()=>{if(!oc||ya.current===ye)return;bn.current!==null&&window.clearTimeout(bn.current);const t=ye;bn.current=window.setTimeout(()=>{bn.current=null,um(t,ac.current).then(()=>{ya.current=t}).catch(()=>{})},500)},[ye,oc]);const Gn=a.useCallback((t,o,c)=>{if(t){if(fm(c?t+c:t)){Vo(o);return}Ze?(ze(v=>Fp(v,t)+(c??"")),window.matchMedia("(pointer: coarse)").matches||(Ft(!1),ur(v=>v+1))):window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:c?t+c:t,focus:!0}})),Vo(o)}},[Ze,Vo]),wa=a.useCallback(t=>{const o=za(t,x);return Pm(o,x)},[x]),Yo=ju(Er),zt=a.useCallback((t,o)=>{const c=za(t,x);Gn(Tm(c,x),o??`path:${c}`)},[x,Gn]),Zf=a.useCallback(async t=>{la(!0);try{await Im(t,Ua,o=>{zt(o,`path:${o}`)}),re&&!Ze&&l()}catch(o){xt(o instanceof Error?o.message:i("rightSidebar.uploadFailed")),window.setTimeout(()=>xt(null),4e3)}finally{la(!1)}},[Ze,zt,re,l,i]),ka=a.useRef(!0),Xo=a.useRef(n);Xo.current=n,a.useEffect(()=>(ka.current=!0,()=>{ka.current=!1}),[]);const eh=a.useCallback(t=>{Dm.getState().enqueue(t,n??null,x||"/",o=>{if(Ze&&ka.current&&Xo.current===n)zt(o);else return xd(o,n)})},[n,x,Ze,zt]),th=a.useCallback(async t=>{const c=(await Ua("/tmp",[t])).files[0]?.path;if(!c)throw new Error("截图上传未返回文件路径");Ze&&ka.current&&Xo.current===n?zt(c):await xd(c,n)},[Ze,zt,n]),Mr=a.useCallback((t,o)=>{if(!t)return;const c=t.includes(`
|
|
1660
|
+
`)?`
|
|
1661
|
+
`:void 0;Gn(t.endsWith(`
|
|
1662
|
+
`)||t.endsWith(" ")?t:`${t} `,o,c)},[Gn]),ic=a.useRef(Mr);ic.current=Mr;const Jo=a.useRef(!0);a.useEffect(()=>(Jo.current=!0,()=>{Jo.current=!1}),[]);const Qo=a.useRef(new Set),lc=a.useCallback((t,o,c)=>{if(Qo.current.has(o))return;const v=vd.getState().activeSessionId;Qo.current.add(o),gp(t,o,c,{insert:Mr,upload:async(w,k)=>(await Ua("/tmp",[w],k)).files[0]?.path,isCurrent:()=>Jo.current&&ic.current===Mr&&v===vd.getState().activeSessionId}).finally(()=>Qo.current.delete(o))},[Mr]),$r=a.useCallback((t,o,c)=>{o&&Gn(o.endsWith(" ")?o:`${o} `,c??`context:${t}`,`
|
|
1663
|
+
`)},[Gn]),cc=a.useCallback(t=>{const o=_p(ye,t);if(!o)return;const c=t&&ye.trim().includes(`
|
|
1664
|
+
`),v=`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`;let w=!1;const k=Z=>{w||(w=!0,window.removeEventListener("termdock-insert-reference-ack",j),window.clearTimeout(oe),Z?(pr(!1),ze(""),H&&Ft(!0)):(pr(!0),Ft(!1)))},j=Z=>{const pe=Z.detail;pe?.nonce===v&&k(pe.ok===!0)},oe=window.setTimeout(()=>k(!1),1500);window.addEventListener("termdock-insert-reference-ack",j),pr(!1),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:o,focus:!0,paste:c,nonce:v}}))},[H,ye]),tt=a.useMemo(()=>x?wt(x):i("rightSidebar.workspace"),[x,i]),rh=a.useMemo(()=>wt(xe)||tt,[xe,tt]),Sa=a.useMemo(()=>Mi(xe),[xe]),ja=a.useMemo(()=>x?Dl[x]??[]:[],[Dl,x]),xn=a.useMemo(()=>new Set(ja.map(t=>t.path)),[ja]),xs=!!(xe&&xn.has(xe)),Zo=!!(x&&xe&&xe!==x),nh=!!(x&&Tn&&Tn!==x),It=xe?`path:${xe}`:null,dc="context:change-audit",sh=a.useCallback(()=>{Sa&&Ot(Sa)},[Sa,Ot]),uc=a.useCallback(()=>{Bl()},[Bl]),ah=a.useCallback(()=>{xe&&(ua(xe,!0),Hl())},[Hl,xe,ua]),oh=a.useCallback(()=>{!xe||!Zo||(xs?fn(xe):In(xe,"directory"))},[Zo,xe,xs,In,fn]),fc=a.useCallback(t=>{Ot(t),K("")},[Ot]),hc=a.useCallback(t=>{xe&&(ie(Rg(xe,t)),W(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[xe,W]),mc=a.useCallback(t=>{!x||t===x||(xn.has(t)?fn(t):In(t,"directory"))},[In,xn,x,fn]),pc=a.useCallback(t=>{!x||!t||(xn.has(t)?fn(t):In(t,"file"))},[In,xn,x,fn]),gc=J(t=>t.expandedPaths),ei=a.useMemo(()=>{const t=new Set;if(zn&&xe){t.add(xe);const o=`${xe.replace(/\/+$/,"")}/`;for(const c of gc)c.startsWith(o)&&t.add(c)}if(zn&&x&&st){const o=st.startsWith("/")?st:`${x}/${st}`,c=Mi(o);c&&t.add(c)}return Mp(t).join(`
|
|
1665
|
+
`)},[gc,zn,xe,x,st]),vn=a.useRef(new Map);a.useEffect(()=>{const t=ei?ei.split(`
|
|
1666
|
+
`):[];if(!r||t.length===0){Pn(null);return}const o=new AbortController;let c=!1,v=0,w=0;Pn(null);const k=async()=>{let j=0;for(;!c&&!o.signal.aborted;){let oe=null;try{Pn(null),await vm(t,pe=>{const{applicableEvents:$e,unavailableReason:Ve}=Lp(pe);$e.length>0&&Ol($e);for(const G of $e){if(G.type!=="rescan-required")continue;const Y=J.getState();if(!Y.directoryCache.has(G.path))continue;vn.current.get(G.path)?.abort();const _e=new AbortController;vn.current.set(G.path,_e);const rt=`file-watch-rescan:${G.path}`;Rt(rt),ym(G.path,_e.signal,Y.showHiddenFiles,"watch_rescan",rt,Y.fileSortModes[G.path]??"name").then(De=>{vn.current.get(G.path)===_e&&Ul(G.path,De.entries)}).catch(De=>{dr(De)||Pn(De instanceof Error?De.message:"File refresh unavailable")}).finally(()=>{vn.current.get(G.path)===_e&&vn.current.delete(G.path)})}Ve&&Pn(Ve)},o.signal),oe=new Error("File watch stream ended")}catch(pe){oe=pe}if(c||o.signal.aborted||dr(oe))return;Pn(oe instanceof Error?oe.message:"File watching unavailable");const Z=Ud[Math.min(j,Ud.length-1)];j+=1,await new Promise(pe=>{w=window.setTimeout(pe,Z)})}};return v=window.setTimeout(()=>{c||k()},Si),()=>{c=!0,window.clearTimeout(v),window.clearTimeout(w),o.abort();for(const j of vn.current.values())j.abort();vn.current.clear()}},[Ol,r,Ul,ei]),a.useEffect(()=>{if(!x||Uo.current!==x)return;if(Ho.current===x){Ho.current=null;return}const t=Kd();Ps(Ou,{...t,[x]:{selectedRepoRoots:Qs,repoTargetBranches:Jt,repoBaseBranches:Et,previewEntries:Qr,selectedPreviewKey:we&&Sr?Ke:null,selectedPreviewFileKey:we&&Sr?Ro:null,previewDetailOpen:!!(we&&Sr),previewScrollTops:ns,previewMobileSlideIndex:1,repoIncludeUncommitted:sn,updatedAt:Date.now()}},Cg)},[Sr,sn,we,Qr,ns,Et,Jt,Qs,x,Ro,Ke]);const ft=a.useMemo(()=>au(Re.values()),[Re]),it=a.useMemo(()=>{const t=new Map;for(const o of le)t.set(o.root,o);return t},[le]),vs=a.useMemo(()=>{const t=new Map;for(const o of le)o.deferred||t.set(o.root,o.files.length);return t},[le]),Ra=a.useCallback(t=>{if(t){if(!t.deferred){fs.current.delete(t.root);return}vs.has(t.root)||fs.current.has(t.root)||(fs.current.add(t.root),Tt(t.root,{includeNested:!1,background:!0,replaceRepoRoot:t.root}).then(o=>{o||fs.current.delete(t.root)}))}},[Tt,vs]),er=a.useMemo(()=>ce?je.find(t=>t.root===ce)??null:null,[ce,je]),Wt=a.useMemo(()=>st?Array.from(Re.values()).find(t=>t.path===st||t.absolutePath===st)??null:null,[Re,st]),Dt=a.useMemo(()=>{const t=new Map;for(const o of le)o.available&&o.context?.available&&t.set(o.root,o);return t.size===0&&R?.available&&R.root&&t.set(R.root,{id:R.root,root:R.root,relativeRoot:".",name:tt,depth:0,nested:!1,available:!0,files:Array.from(Re.values()).filter(o=>pt(o,x)===R.root),context:R}),Array.from(t.values()).sort((o,c)=>o.root===x?-1:c.root===x?1:(o.relativeRoot||o.name).localeCompare(c.relativeRoot||c.name)).map(o=>{const c=o.relativeRoot==="."?tt:o.relativeRoot||o.name||wt(o.root),v=su(o.files),w=o.files.length;return{value:o.root,label:c,meta:[o.context?.branch,w>0?i("rightSidebar.repoChangedCount",{count:w}):null,v>0?i("rightSidebar.repoStagedCount",{count:v}):null].filter(Boolean).join(" · ")}})},[Re,R,le,tt,x,i]),ke=a.useMemo(()=>ce&&Dt.some(t=>t.value===ce)?ce:Wt?.repoRoot&&Dt.some(t=>t.value===Wt.repoRoot)?Wt.repoRoot:Dt.length===1||Dt.length>1?Dt[0].value:null,[ce,Dt,Wt?.repoRoot]),bc=ke?it.get(ke)??null:null,fe=bc?.context?.available?bc.context:ke===R?.root?R:null,Ye=Dt.length>0&&!ke,xc=a.useMemo(()=>Ye?[]:ke?Array.from(Re.values()).filter(t=>pt(t,x)===ke):Array.from(Re.values()),[ke,Re,Ye,x]),yn=a.useMemo(()=>au(xc),[xc]),ti=!!(fe?.available&&fe.root&&ke&&fe.root===ke),ih=ke?Dt.find(t=>t.value===ke)?.label??wt(ke):i("rightSidebar.gitRepositoryPlaceholder"),vc=ti?fe?.branch??"HEAD":Ye?i("rightSidebar.selectRepositoryForGitActions"):cn?i("rightSidebar.gitActionRunning"):"HEAD",Kn=!!(fe?.available&&fe.root===ke&&fe.status);a.useEffect(()=>{yl.current={count:Pt.length,loading:Ys,loadingMore:Xs,hasMore:yo}},[Pt.length,yo,Ys,Xs]),a.useEffect(()=>{Ur.current+=1,sr.current?.abort(),Rt("right-sidebar-recent-commits"),sr.current=null,nn(""),nr([]),os(!1),is(!1),En(null),Mn(!1)},[ke]);const ys=a.useCallback(async(t={})=>{if(!x||!ke||Ye)return;const o=t.reset??!1,c=yl.current,v=o?0:c.count;if(!o&&(c.loading||c.loadingMore||!c.hasMore))return;const w=Ur.current+1;Ur.current=w,sr.current?.abort(),Rt("right-sidebar-recent-commits");const k=new AbortController;sr.current=k,o?os(!0):is(!0),En(null);try{const j=await hm({cwd:x,repoRoot:ke,limit:Fg,skip:v,query:as.trim(),requestSlotId:"right-sidebar-recent-commits"},k.signal);if(Ur.current!==w)return;if(!j.available){En(j.error??"Recent commits are unavailable"),o&&nr([]),Mn(!1);return}Ge(oe=>o?j.commitSyncStatus??{}:{...oe,...j.commitSyncStatus}),nr(oe=>o?j.commits:[...oe,...j.commits]),Mn(j.hasMore)}catch(j){if(Ur.current!==w||dr(j))return;En(j instanceof Error?j.message:"Failed to load recent commits"),o&&nr([]),Mn(!1)}finally{sr.current===k&&(sr.current=null),Ur.current===w&&(os(!1),is(!1))}},[ke,as,Ye,x]);a.useEffect(()=>{tn&&ys({reset:!0})},[as,ys,tn,fe?.ahead,fe?.behind,fe?.upstream]);const lh=a.useCallback(t=>{const o=t.currentTarget;o.scrollTop+o.clientHeight<o.scrollHeight-48||ys({reset:!1})},[ys]);a.useEffect(()=>{!ke||!R?.available||!ot||!ar||Kn||cn||Ye||Go(ke)},[ke,R?.available,Kn,cn,ot,ar,Go,Ye]),a.useEffect(()=>{!r||!jt&&!ot||!x||ir()},[jt,ot,r,ir,x]),a.useEffect(()=>{!r||!ot||!ar||!ls||!x||xa(null)},[ls,ot,ar,r,xa,x]);const ch=a.useMemo(()=>{if(!ce)return 0;const t=je.findIndex(o=>o.root===ce);return t>=0?t+1:0},[ce,je]),yc=a.useCallback(t=>{if(!t)return null;const o=Array.from(Re.values()).filter(c=>pt(c,x)===t).sort((c,v)=>c.path.localeCompare(v.path))[0];return o?yt(o):null},[Re,x]),wn=je.length>1,Ca=a.useMemo(()=>[{root:null,label:i("rightSidebar.allRepositories"),count:Re.size,branch:null,deferred:!1},...je.map(t=>({root:t.root,label:t.label,count:t.deferred?vs.get(t.root)??0:t.count,branch:t.branch??null,deferred:!!t.deferred&&!vs.has(t.root)}))],[Re.size,je,vs,i]),wc=Ca[ch]??Ca[0],Na=!!ce,kc=a.useMemo(()=>Vu(je,le),[je,le]);a.useEffect(()=>{Wo.current===x&&ce&&!kc.has(ce)&&Ae(null),Cn(t=>t.filter(o=>je.some(c=>c.root===o)))},[ce,je,kc,x,Ae]),a.useEffect(()=>{ce&&Ra(it.get(ce))},[ce,Ra,it]);const dh=a.useMemo(()=>{const t=new Set;fe?.branch&&t.add(fe.branch);for(const o of fe?.branches??[])t.add(o);return Array.from(t).map(o=>({value:o,label:o,meta:o===fe?.branch?i("rightSidebar.pushCurrentBranchBadge"):void 0}))},[fe?.branch,fe?.branches,i]),Sc=a.useMemo(()=>{const t=new Set;fe?.upstreamRemote&&t.add(fe.upstreamRemote);for(const o of fe?.remotes??[])t.add(o);return Array.from(t).map(o=>({value:o,label:o,meta:o===fe?.upstreamRemote?i("rightSidebar.pushUpstreamBadge"):void 0}))},[fe?.remotes,fe?.upstreamRemote,i]),jc=Sc.length>1,uh=a.useMemo(()=>{const t=[],o=new Set,c=(w,k)=>{!w||o.has(w)||(o.add(w),t.push({value:w,label:w,meta:k}))};c(fe?.upstreamBranch,fe?.upstreamBranch?i("rightSidebar.pushUpstreamBadge"):void 0),c(fe?.branch,fe?.branch?i("rightSidebar.pushCurrentBranchBadge"):void 0);for(const w of fe?.branches??[])c(w,w===fe?.branch?i("rightSidebar.pushCurrentBranchBadge"):"local");const v=fe?.upstreamRemote;for(const w of fe?.remoteBranches??[]){const k=w.indexOf("/"),j=k>=0?w.slice(0,k):null,oe=k>=0?w.slice(k+1):w;(!v||j===v)&&c(oe,"remote")}return t},[fe?.branch,fe?.branches,fe?.remoteBranches,fe?.upstreamBranch,fe?.upstreamRemote,i]),Gt=a.useMemo(()=>Dt.map(t=>{const o=it.get(t.value);return{root:t.value,label:t.label,branch:o?.context?.branch??null}}),[Dt,it]);a.useEffect(()=>{Gt.length!==0&&(Zs(t=>{let o=!1;const c={...t},v=new Set(Gt.map(w=>w.root));for(const w of Object.keys(c))v.has(w)||(delete c[w],o=!0);for(const w of Gt)!c[w.root]&&w.branch&&(c[w.root]=w.branch,o=!0);return o?c:t}),ea(t=>{let o=!1;const c={...t},v=new Set(Gt.map(w=>w.root));for(const w of Object.keys(c))v.has(w)||(delete c[w],o=!0);for(const w of Gt){const k=it.get(w.root)?.context;if(c[w.root]&&qu(c[w.root],k?.branch)&&(delete c[w.root],o=!0),c[w.root])continue;const j=Yd(k);j&&(c[w.root]=j,o=!0)}return o?c:t}))},[Gt,it]);const Ea=a.useMemo(()=>{const t=new Set(Gt.map(o=>o.root));return Qs.filter(o=>t.has(o))},[Qs,Gt]),Ma=Ea.length===0,cr=a.useMemo(()=>Ma?Gt:Gt.filter(t=>Ea.includes(t.root)),[Gt,Ea,Ma]),ws=a.useMemo(()=>cr.filter(t=>!!Et[t.root]?.trim()),[Et,cr]),Vr=a.useCallback((t,o)=>{const c=it.get(t)?.context?.branch;return!!(c&&o&&o.replace(/^refs\/heads\//,"")===c)},[it]),Rc=a.useMemo(()=>cr.filter(t=>!Et[t.root]?.trim()),[Et,cr]),Cc=a.useCallback(async t=>{if(!t||Oo.current.has(t))return;const o=it.get(t)?.context;if((o?.branches?.length??0)>0||(o?.remoteBranches?.length??0)>0||o?.upstream)return;const c=x;Oo.current.add(t),Sl(v=>new Set(v).add(t));try{const v=await cd(t,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${t}`);if(!v.available||!Ce(c))return;Me(w=>w.map(k=>k.root===t?{...k,available:!0,context:{...k.context,...v},error:void 0}:k)),Zs(w=>w[t]||!v.branch?w:{...w,[t]:v.branch}),ea(w=>{if(w[t])return w;const k=Yd(v);return k?{...w,[t]:k}:w})}catch(v){dr(v)||console.warn("[RightSidebar] Failed to load branch audit repo details",t,v)}finally{Oo.current.delete(t),Sl(v=>{const w=new Set(v);return w.delete(t),w})}},[it,Ce,x]);a.useEffect(()=>{if(wo)for(const t of cr)Cc(t.root)},[wo,cr,Cc]),a.useEffect(()=>{!ti||!fe||(sa(fe.branch||(fe.branches?.[0]??"")),aa(fe.upstreamRemote||(fe.remotes?.includes("origin")?"origin":fe.remotes?.[0]??"")),oa(fe.upstreamBranch||fe.branch||(fe.branches?.[0]??"")))},[fe,ti]);const Nc=a.useMemo(()=>{if(Ye)return{text:i("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!Kn||cn)return{text:i("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!fe?.upstream)return{text:i("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const t=fe.ahead??0,o=fe.behind??0;return t>0&&o>0?{text:i("rightSidebar.pushDivergedCount",{ahead:t,behind:o}),className:"bg-destructive/10 text-destructive"}:t>0?{text:i("rightSidebar.pushAheadCount",{count:t}),className:"bg-accent/10 text-accent"}:o>0?{text:i("rightSidebar.pushBehindCount",{count:o}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:i("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[fe?.ahead,fe?.behind,fe?.upstream,Kn,cn,Ye,i]),fh=a.useCallback(t=>{if(t&&!re){const o=t.currentTarget.getBoundingClientRect();V({x:Math.min(o.left,window.innerWidth-352),y:Math.min(o.bottom+6,window.innerHeight-64)})}else V(null);I?.()},[re,I]),ri=a.useCallback(()=>{V(null),_?.()},[_]);function Ec(){if(!wn)return null;const t=wc?.label??i("rightSidebar.allRepositories"),o=wc?.count??Re.size,c=wt(t)||t;return e.jsxs("button",{type:"button",onClick:fh,className:`inline-flex h-7 min-w-0 max-w-[13rem] shrink-0 items-center gap-1.5 rounded-md border px-2 text-[11px] font-medium transition active:scale-95 ${y?"border-primary/25 bg-primary/10 text-primary":"border-border/10 bg-surface-2 text-muted-foreground hover:border-border/25 hover:bg-surface-elevated hover:text-foreground"}`,"aria-haspopup":"listbox","aria-expanded":y,title:t,children:[e.jsx(Lr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:c}),e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${o>0?"bg-accent/10 text-accent":"bg-surface text-muted-foreground"}`,children:o}),e.jsx(_s,{size:12,className:"shrink-0"})]})}function hh(){if(!y||!wn||typeof document>"u")return null;const t=typeof window>"u"?1024:window.innerWidth,o=typeof window>"u"?768:window.innerHeight,c=Math.max(12,Math.min(nt?.x??t-368,t-352)),v=Math.max(12,Math.min(nt?.y??80,o-420)),w=re?void 0:{left:c,top:v},k=e.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${re?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:ri,children:e.jsxs("div",{className:re?"fixed inset-x-0 bottom-0 z-drawer-panel max-h-[72vh] overflow-hidden rounded-t-2xl border-t border-border/20 bg-surface-elevated shadow-2xl":"fixed z-drawer-panel w-[21rem] max-w-[calc(100vw-1.5rem)] max-h-[min(26rem,calc(100vh-1.5rem))] overflow-hidden rounded-lg border border-border/20 bg-surface-elevated shadow-xl ring-1 ring-black/5",style:w,onClick:j=>j.stopPropagation(),children:[e.jsxs("div",{className:re?"flex items-center justify-between border-b border-border/15 px-4 py-3":"flex items-center justify-between border-b border-border/12 px-3 py-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:re?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:i("rightSidebar.repositories")}),!re&&e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:Ca.length}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${Re.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Re.size})]})]}),e.jsx("button",{type:"button",onClick:ri,className:re?"rounded-full bg-surface-2 p-1.5 text-muted-foreground hover:bg-surface hover:text-foreground":"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground","aria-label":i("rightSidebar.close"),children:e.jsx(Vt,{size:re?16:14})})]}),e.jsx("div",{className:re?"max-h-[calc(72vh-3.25rem)] overflow-y-auto overscroll-contain px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+5.5rem)]":"max-h-[calc(min(26rem,100vh-1.5rem)-3.5rem)] overflow-y-auto overscroll-contain p-1.5",children:Ca.map(j=>{const oe=(j.root??null)===ce,Z=wt(j.label)||j.label;return e.jsxs("button",{type:"button",onClick:()=>{Yc(j.root),ri()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${re?"px-3 py-2":"px-2 py-1.5"} ${oe?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:j.label,role:"option","aria-selected":oe,children:[e.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${oe?"bg-primary":"bg-transparent group-hover:bg-border/40"}`}),e.jsx("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${oe?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:e.jsx(Lr,{size:13})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:`${re?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:Z}),e.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:j.root===null?i("rightSidebar.allRepositories"):j.label})]}),j.branch&&e.jsx("span",{className:"hidden max-w-[5.5rem] shrink min-w-0 truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground sm:inline",children:j.branch}),j.deferred?e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/70",children:i("rightSidebar.repoNotLoaded")}):e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${j.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:j.count})]},j.root??"all")})})]})});return Tu(k,re,document.body)}function mh(){return hh()}function Mc(t){const o=pt(t,x),c=t.absolutePath||(o?`${o}/${t.path}`:t.path),v=ao(c,o??x);return{key:yt(t),path:t.path,absolutePath:c,displayName:v.name,displayDir:v.dir,oldPath:t.oldPath,status:t.status,title:c}}function $c(t){return t.oldPath?e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:i("rightSidebar.changedFromPath",{path:t.oldPath})}):null}function Lc(t,o){const c=za(t,x),v=`path:${c}`,w=he===v,k=qe===v,j=w||k;return e.jsx("button",{type:"button",onClick:oe=>{oe.stopPropagation(),zt(c,v)},...Yo(wa(c),v),className:`inline-flex h-6 shrink-0 items-center justify-center overflow-hidden rounded-md text-[11px] font-semibold opacity-100 transition-[max-width,padding,opacity,transform,background-color,color] active:scale-95 ${j?"max-w-20 px-2":"max-w-20 px-2 md:max-w-0 md:px-0 md:opacity-0 md:group-hover:max-w-20 md:group-hover:px-2 md:group-hover:opacity-100"} ${j?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:o,children:e.jsx("span",{className:"whitespace-nowrap",children:i(k?"rightSidebar.copied":w?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function Ac(t){const o=pt(t,x),c=t.absolutePath||(o?`${o}/${t.path}`:t.path),v=Uh(t),w=Ai(t);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(Hb,{actions:v,running:Oe,completed:$n?.path===w?$n:null}),Lc(c,i("rightSidebar.insertThisFile"))]})}function Pc(t,o){const c=o.root??x;if(!c)return null;const v=za(t,c);return Lc(v,i("fileTree.insertRefTitle"))}function ni(){return e.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5","aria-label":i("diffViewer.view"),children:[e.jsx("button",{type:"button",onClick:()=>zc("unified"),"aria-pressed":Bt==="unified",title:i("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Bt==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:i("diffViewer.unified")}),e.jsx("button",{type:"button",onClick:()=>zc("split"),"aria-pressed":Bt==="split",title:i("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Bt==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:i("diffViewer.split")})]})}function Tc(){return ks.map(t=>{const o=su(t.files.map(([,k])=>k)),c=Xi({activeGitRepoRoot:ce,groupCount:ks.length,label:t.label,rootName:tt}),v=!!(c&&t.root&&gr.has(t.root));return{key:t.root??t.label,root:t.root,label:t.label,branch:t.branch,collapsed:v,files:t.files.map(([,k])=>Mc(k)),header:c?e.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${v?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Ah(t.root),"aria-expanded":!v,className:"flex min-w-0 flex-1 items-center gap-2 text-left active:scale-[0.99]",children:[e.jsx("span",{className:"shrink-0 text-muted-foreground",children:v?e.jsx(Ha,{size:13}):e.jsx(_s,{size:13})}),e.jsx(Lr,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:t.label}),t.branch&&e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:t.branch})]}),e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.files.length}),o>0&&e.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:o})]}),t.root&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),_a("stage-all",t.root,t.label)},disabled:!!Oe,className:"rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:i("rightSidebar.stageAll"),children:i("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),_a("stash-all",t.root,t.label)},disabled:!!Oe,className:"rounded-full bg-surface-2 px-2 py-0.5 text-[10px] font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:i("rightSidebar.stashAll"),children:i("rightSidebar.stashAll")})]})]}):null}})}function Ic(){return Re.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:i("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:La.map(([,t])=>{const o=pt(t,x),c=t.absolutePath||(o?`${o}/${t.path}`:t.path);return{key:yt(t),path:t.path,absolutePath:c,status:t.status,repoRoot:o,displayName:ao(c,o).name,displayDir:ao(c,o).dir,auditRecords:Nt}})}function Dc(t){const o=Array.from(Re.values()).find(w=>yt(w)===t.key),c=o?pt(o,x):null,v=xp(Nt,c,o?.path??t.path);return e.jsx(Gi,{changeStatus:t.status,auditStatus:v,renderChangeBadge:w=>e.jsx(Ts,{status:w})})}const $a=a.useCallback(t=>{if(re)return null;const o=Array.from(t.querySelectorAll("[data-diff-stream-item]"));if(o.length===0)return null;const v=t.getBoundingClientRect().top+48;let w=null,k=Number.POSITIVE_INFINITY;for(const oe of o){const Z=oe.getBoundingClientRect();if(Z.bottom<v)continue;const pe=Math.abs(Z.top-v);pe<k&&(w=oe,k=pe)}const j=w?.dataset.diffSelectionPath??w?.dataset.diffStreamItem??null;return j?(pa.current===j&&J.getState().selectedFilePath===j||(pa.current=j,at(j)),j):null},[re,at]),ph=!!(!Oe&&ke&&!Ye&&(fe?.upstream||dn.trim()&&un.trim())),gh=!!(!Oe&&ke&&!Ye&&(fe?.upstream||dn.trim()&&un.trim())),bh=!!(!Oe&&ke&&!Ye&&An.trim()&&An.trim()!==fe?.branch),Kt=a.useMemo(()=>{const t=Fe.trim().toLowerCase(),o=Array.from(Re.entries()).filter(([,c])=>!ce||pt(c,x)===ce).sort(([c],[v])=>c.localeCompare(v));return t?o.filter(([c,v])=>`${c} ${v.path} ${v.status} ${v.repoRelativeRoot??""} ${v.repoName??""}`.toLowerCase().includes(t)):o},[ce,Re,Fe,x]);a.useEffect(()=>{to("selected_file_state",{selectedFilePath:st,selectedChangedFilePath:Wt?.path??null,selectedChangedFileAbsolutePath:Wt?.absolutePath??null,selectedChangedFileRepoRoot:Wt?.repoRoot??null,rootPath:x,activeGitRepoRoot:ce,rightTab:Io,effectiveRightTab:lr,diffPaneActive:jt,changedFiles:Re.size,filteredChangedFiles:Kt.length,gitBundleLoading:zr,gitBundleLastLoadedAt:Dn})},[ce,Re.size,jt,lr,Kt.length,Dn,zr,Io,x,Wt?.absolutePath,Wt?.path,Wt?.repoRoot,st]);const ks=a.useMemo(()=>{const t=new Map;for(const o of Kt){const[,c]=o,v=pt(c,x),w=Ob(c)||tt,k=v??w,j=v?it.get(v):void 0,oe=t.get(k)??{root:v,label:w,branch:j?.context?.branch,files:[]};oe.files.push(o),t.set(k,oe)}return Array.from(t.values()).sort((o,c)=>o.label===tt?-1:c.label===tt?1:o.label.localeCompare(c.label))},[Kt,it,tt,x]),La=a.useMemo(()=>{const t=[],o=new Map;for(const c of Kt)o.set(yt(c[1]),c);for(const c of ks){if(!!(c.root&&Xi({activeGitRepoRoot:ce,groupCount:ks.length,label:c.label,rootName:tt})&&gr.has(c.root)))continue;if(vr!=="tree"){t.push(...c.files);continue}const w=c.files.map(([,k])=>Mc(k));for(const k of Km(w)){const j=o.get(k.key);j&&t.push(j)}}return t},[ce,gr,vr,ks,Kt,tt]);a.useEffect(()=>{if(!jt||La.length===0||re)return;const t=[],o=()=>{const c=document.querySelector(".termdock-diff-stream-scroller");if(c&&$a(c))return;const v=document.querySelector("[data-diff-stream-item]"),w=v?.dataset.diffSelectionPath??v?.dataset.diffStreamItem??null;if(w){pa.current=w,at(w);return}const k=La[0]?.[1];if(!k)return;const j=yt(k);pa.current=j,at(j)};for(const c of[80,240,600,1200])t.push(window.setTimeout(o,c));return()=>t.forEach(c=>window.clearTimeout(c))},[jt,re,La,at,$a]);const si=a.useMemo(()=>{const t=j=>`'${j.replace(/'/g,"'\\''")}'`,o=Zt.length>0?gn:le.filter(j=>j.files.length>0),c=o.length>0?o:x?[{root:x,relativeRoot:".",name:tt}]:[],v=c.length>0?c.map(j=>`- ${j.relativeRoot==="."?".":j.relativeRoot} (${j.root})`).join(`
|
|
1667
|
+
`):`- ${x?".":""}`,w=c.length>0?c.map(j=>` td audit-export ${t(j.root)}`).join(`
|
|
1668
|
+
`):" td audit-export",k=c.length>0?" td audit ~/.termdock/change-audit/payload-<repo>.json":" td audit ~/.termdock/change-audit/payload.json";return["任务:为目标仓库的 Git diff hunk 生成自包含审计解释,并通过 Termdock CLI 注入。","",`当前工作区:${x??""}`,"目标仓库:",v,"","执行步骤:","1. 仅对“目标仓库”逐个执行 audit-export。嵌套子仓使用括号内 repo 绝对路径作为命令参数。",w,"2. 先检查 audit-export 输出的 coverage[]:确认 untrackedFiles 是否为空、未跟踪文件是否已经出现在 hunks[].filePath 中;如果 coverage 显示存在未跟踪文件但 hunks[] 未包含对应文件,必须汇报导出异常,不要假装已解释。","3. 读取 audit-export 输出的全部 hunks[].diff,包含 tracked 与 untracked hunks;先理解整批改动的业务目标、行为变化、文件分工和跨 hunk 依赖。","4. 以 audit-export 内置 diff 为分析依据。仅在单个 hunk 信息不足时执行:td audit-show <hunkId> <对应仓库绝对路径>","5. 在 ~/.termdock/change-audit/ 生成批量 payload JSON。"," mkdir -p ~/.termdock/change-audit","6. payload 顶层字段:workspaceRoot、repoRoot、generatedBy、walkthrough、records[]。","7. walkthrough 必须先生成,用三层结构说明整批改动:highlights[] 面向不了解代码的人讲“改了什么/带来什么效果”;nodes[]/edges[] 表达关键链路;risks[]/checks[] 写真实风险和验证。节点可带 anchor,点击后会跳到对应 diff。","8. records[] 必须覆盖每个 hunk 内的多个 section,而不是只写 hunk 总结;从 audit-export hunk 原样复制 filePath、oldPath、newPath、hunkHeader、hunkIndex、fingerprint;如果解释的是 section,额外填写 sectionIndex 和 sectionFingerprint;补充 summary、explanation。","9. 写入 payload 后批量注入:",k,'10. 少量 hunk 或临时补单条时使用:printf "%s\\n" "这里写该 hunk 的改动意义" | td audit-explain <hunkId> <对应仓库绝对路径>',"11. 注入成功后清理本次 payload:rm -f ~/.termdock/change-audit/payload*.json","","payload.walkthrough 示例字段:","{",' "title": "一句话标题",',' "summary": "整批改动的目的和结果",',' "highlights": [{ "what": "改了什么", "effect": "用户或系统得到什么", "tag": "体验" }],',' "nodes": [{ "id": "n1", "title": "节点标题", "kind": "ui", "business": "零上下文业务解释", "anchor": { "repoRoot": "<repoRoot>", "filePath": "<filePath>", "hunkIndex": 0, "hunkFingerprint": "<fingerprint>", "sectionIndex": 0, "sectionFingerprint": "<sectionFingerprint>" } }],',' "edges": [{ "from": "n1", "to": "n2", "label": "调用/传递/消费", "desc": "这条关系的业务含义" }],',' "risks": [{ "title": "真实风险或口径疑问", "anchor": { "filePath": "<filePath>" } }],',' "checks": ["可执行验证动作"]',"}","","写作标准:","- summary:一句话概括该 hunk 在整批改动中的职责。","- explanation:自包含说明业务链路、该 hunk 的作用、解决的问题、与其它 hunk 的关系。","- walkthrough.highlights 必须大白话,不要堆文件名/函数名;只看 highlights 应该知道这次改动干嘛。","- walkthrough.nodes 优先对应方法、关键业务步骤或关键 section;每个有 anchor 的节点必须能跳回真实 diff。","- 面向不了解本轮对话的 AI 编写,补足必要上下文。","- 输出高信息量结论;避免铺垫、套话、流程复述、泛泛风险、逐行翻译 diff。","","完成条件:汇报每个目标仓库已注入的 hunk 数和总数。"].join(`
|
|
1669
|
+
`)},[Zt.length,gn,le,tt,x]),xh=a.useCallback((t="generate")=>{if(wn&&_r.length===0&&!ce){Jr(!0);return}const o=t==="generate"?si:[t==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",si].join(`
|
|
1670
|
+
`);lt("insert_change_audit_prompt",{rootPath:x,activeGitRepoRoots:Zt,mode:t,hasAuditListCommand:o.includes("td audit-list"),promptLength:o.length}),$r(i("rightSidebar.insertChangeAuditPrompt"),o,`${dc}:${t}`),ir(),d||l()},[ce,si,_r.length,Zt,$r,ir,l,d,x,wn,i]),Aa=a.useCallback(async t=>{try{await ud({ids:[t]}),Xr(o=>o.filter(c=>c.id!==t))}catch{ir()}},[ir]),vh=a.useCallback(async()=>{if(Nt.length===0)return;const t=Nt.map(o=>o.id);try{await ud({ids:t}),Xr(o=>o.filter(c=>!t.includes(c.id))),Fr(null)}catch(o){const c=o instanceof Error?o.message:"Failed to clear change audit explanations";Fr(i("rightSidebar.changeAuditClearFailed",{message:c})),ir()}},[Nt,ir,i]),yh=a.useCallback(async t=>{if(t.records.length===0)return;const o=t.records.map(c=>c.id);try{await mm({ids:o}),Br(c=>c.filter(v=>!o.includes(v.id))),Ke===t.key&&(an(null),tr(!1))}catch(c){xt(i("rightSidebar.branchAuditClearFailed",{message:c instanceof Error?c.message:"Failed to clear branch explanation"})),xa(null)}},[xa,Ke,i]),wh=a.useCallback(t=>{Cn(o=>t===null?(Jr(!1),[]):o.includes(t)?o.filter(c=>c!==t):[...o,t])},[]),kh=a.useCallback(t=>{So(o=>t===null?(ko(!1),[]):o.includes(t)?o.filter(c=>c!==t):[...o,t])},[]),ai=a.useMemo(()=>{if(!ar)return[];const t=o=>{const c=o.diff??"";let v=0,w=0;for(const k of c.split(`
|
|
1671
|
+
`))k.startsWith("+++")||k.startsWith("---")||(k.startsWith("+")&&(v+=1),k.startsWith("-")&&(w+=1));return{filePath:o.filePath,oldPath:o.oldPath,newPath:o.newPath,hunkHeader:o.hunkHeader,hunkIndex:o.hunkIndex??0,fingerprint:o.fingerprint,additions:v,deletions:w,diff:c}};return we?(we.hunks??[]).map(o=>{const c=Yt.find(v=>v.repoRoot===we.repoRoot&&v.baseRef===we.baseRef&&(v.branchName??null)===(we.currentBranch??null)&&v.filePath===o.filePath&&v.hunkHeader===o.hunkHeader&&(v.hunkIndex??0)===o.hunkIndex&&v.fingerprint===o.fingerprint)??null;return{key:`${o.filePath}\0${o.hunkHeader}\0${o.hunkIndex}`,hunk:o.previewRevert&&!Vr(o.previewRevert.cwd,o.previewRevert.comparisonBranch)?{...o,previewRevert:void 0}:o,current:c,stale:null}}):Ke?Yt.filter(o=>Vd(o)===Ke).map(o=>{const c=t(o);return{key:`${o.filePath}\0${o.hunkHeader}\0${o.hunkIndex??0}`,hunk:c,current:o,stale:null}}):[]},[we,Yt,Vr,ar,Ke]),oi=Yt.length>0,Vn=a.useMemo(()=>{if(!ar)return[];const t=new Map;for(const o of Yt){const c=o.repoRoot,v=it.get(c),w=v?.relativeRoot==="."?tt:v?.relativeRoot||v?.name||wt(c),k=Vd(o),j=t.get(k)??{key:k,repoRoot:c,repoLabel:w,baseRef:o.baseRef,branchName:o.branchName??null,headRef:o.headRef??null,diffFingerprint:o.diffFingerprint??null,records:[],latestInjectedAt:0};j.records.push(o),j.latestInjectedAt=Math.max(j.latestInjectedAt,o.injectedAt??0),t.set(k,j)}return Array.from(t.values()).sort((o,c)=>c.latestInjectedAt-o.latestInjectedAt)},[Yt,it,ar,tt]),ii=a.useMemo(()=>Ke?Vn.find(t=>t.key===Ke)??null:null,[Vn,Ke]),Pa=we?{repoRoot:we.repoRoot??"",repoLabel:we.repoRoot?it.get(we.repoRoot)?.relativeRoot==="."?tt:it.get(we.repoRoot)?.relativeRoot||it.get(we.repoRoot)?.name||wt(we.repoRoot):tt,baseRef:we.baseRef??we.baseBranch??"",branchName:we.currentBranch??null,headRef:we.headRef??null,diffFingerprint:we.diffFingerprint??null}:ii,Sh=a.useMemo(()=>(et?.hunks??[]).map(t=>({key:`${t.filePath}\0${t.hunkHeader}\0${t.hunkIndex}`,hunk:t,current:null,stale:null})),[et?.hunks]),jh=a.useMemo(()=>{if(we)return[];const t=ii;return t?ts.filter(o=>o.repoRoot===t.repoRoot&&o.baseRef===t.baseRef&&(o.branchName??null)===t.branchName&&(!t.diffFingerprint||o.diffFingerprint===t.diffFingerprint)):[]},[we,ts,ii]),Rh=a.useCallback(t=>{const o=ai.find(c=>c.hunk.filePath===t.filePath||(t.repoRoot?`${t.repoRoot}/${c.hunk.filePath}`===t.filePath:!1));o&&(on(o.key),window.setTimeout(()=>kn(t),90),window.setTimeout(()=>kn(t),320),window.setTimeout(()=>kn(t),760))},[ai]),li=a.useMemo(()=>{const t=w=>`'${w.replace(/'/g,"'\\''")}'`,o=ws,c=o.length>0?o.map(w=>`- ${w.label} (${w.root}),目标分支:${Jt[w.root]||w.branch||"(current branch)"},基线分支:${Et[w.root]||"(not set)"},包含本地未提交更改:${Vr(w.root,Jt[w.root]||w.branch)&&(sn[w.root]??!0)?"是":"否"}`).join(`
|
|
1672
|
+
`):`- ${x?".":""}`,v=o.length>0?o.map(w=>{const k=Jt[w.root]||w.branch||"",j=Et[w.root]||"",oe=w.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[k?` git -C ${t(w.root)} switch ${t(k)}`:` # ${w.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${t(j)} ${t(w.root)} > ~/.termdock/branch-audit/branch-audit-export-${oe}.json`].join(`
|
|
1673
|
+
`)}).join(`
|
|
1674
|
+
`):" td branch-audit-export <base-branch>";return["解释目标仓库当前分支相对于基线分支的改动,并把解释写回 Termdock。","",`当前工作区:${x??""}`,"每个仓库分别遵循下面列出的本地未提交更改选项。","目标仓库:",c,"","操作指令:","1. 只针对上面列出的目标仓库导出分支 hunk,按各仓库所选目标分支与基线对比。本地未提交更改标记为是的仓库纳入 staged/unstaged/untracked 改动;标记为否的仓库只解释提交改动,忽略导出中混入的本地改动。嵌套子仓或软链接子仓使用括号内的仓库绝对路径。示例:",v,"2. 读取导出的 ~/.termdock/branch-audit/branch-audit-export*.json 中的 hunks[],不要把临时 JSON 放到业务仓目录,也不要把整份 JSON 粘贴回输入框。导出工具使用 base...HEAD(三点)生成 diff,只表示当前分支独有改动;提交列表使用 base..HEAD(两点)。","3. 先生成 walkthrough,用 highlights[] 说明整批分支改动目的和影响,用 nodes[]/edges[] 画出主链路、分支链路和验证链路;节点可带 anchor,点击后会跳到对应 diff。","4. 逐个 hunk 写解释。解释要说明该 hunk 的意图、解决的问题、影响、风险,以及它和其它 hunk 的关系;不要逐行复述 diff。","5. 每个仓库分别生成 ~/.termdock/branch-audit/payload-<repo>.json,payload 必须包含 workspaceRoot、repoRoot、baseRef、branchName、headRef、diffFingerprint、walkthrough 和 records[];records[] 每条 record 对应一个 hunk,diff 字段必须从 hunk.diff 原样复制。","6. 把解释写入 payload 后执行:td branch-audit ~/.termdock/branch-audit/payload-<repo>.json","7. 注入成功后删除本次生成的临时 JSON:rm -f ~/.termdock/branch-audit/branch-audit-export-*.json ~/.termdock/branch-audit/payload-*.json","","payload 示例:","```json",JSON.stringify({workspaceRoot:x??null,repoRoot:"<target repo root>",baseRef:"<target repo base branch>",branchName:"<from export currentBranch>",headRef:"<from export headRef>",diffFingerprint:"<from export diffFingerprint>",generatedBy:"termdock-branch-audit",walkthrough:{title:"<one-line branch change title>",summary:"<branch change goal and effect>",highlights:[{what:"<what changed>",effect:"<user/system effect>",tag:"<category>"}],nodes:[{id:"n1",title:"<node title>",kind:"process",business:"<zero-context business explanation>",anchor:{repoRoot:"<target repo root>",filePath:"<from hunk.filePath>",hunkIndex:0,hunkFingerprint:"<from hunk.fingerprint>"}}],edges:[{from:"n1",to:"n2",label:"<relationship>",desc:"<business meaning>"}],risks:[{title:"<real risk or validation gap>"}],checks:["<executable validation step>"]},records:[{filePath:"<from hunk.filePath>",oldPath:"<from hunk.oldPath or null>",newPath:"<from hunk.newPath or null>",hunkHeader:"<from hunk.hunkHeader>",hunkIndex:0,fingerprint:"<from hunk.fingerprint>",diff:"<copy from hunk.diff exactly>",explanation:"<replace with hunk explanation>",summary:""}]},null,2),"```"].join(`
|
|
1675
|
+
`)},[sn,Vr,ws,Et,Jt,x]),Ch=a.useCallback((t="generate")=>{const o=t==="generate"?li:[t==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",li].join(`
|
|
1676
|
+
`);$r(i("rightSidebar.branchAuditShort"),o,`context:branch-audit-scope:${t}`),d||l()},[li,$r,l,d,i]),ci=a.useCallback(async(t={})=>{const o=t.refresh===!0,c=o&&we?.comparisonRepos?we.comparisonRepos:ws.map(j=>{const oe=(Jt[j.root]||j.branch||"").trim();return{repoRoot:j.root,label:j.label,base:Et[j.root]?.trim()??"",head:oe||null,includeUncommitted:sn[j.root]??!0}});if(!x||c.length===0)return;const v=++z.current,w=x,k=()=>Ce(w)&&v===z.current;Te(!0),Ie(null),o||(Xt(null),ut(null));try{const j=await Promise.all(c.map(async G=>{if(!G.base)throw new Error(i("rightSidebar.branchAuditMissingBase",{repo:G.label}));return fd({cwd:x,repoRoot:G.repoRoot,base:G.base,head:G.head,includeUncommitted:Vr(G.repoRoot,G.head)&&(t.repoRoot===G.repoRoot?t.includeUncommitted??!1:G.includeUncommitted??we?.includeUncommitted??!0),requestSlotId:`right-sidebar-branch-preview:${G.repoRoot}`})}));if(!k())return;const oe=j.find(G=>!G.available);if(oe){Ie(oe.error??"Branch diff is unavailable");return}const Z=j.length===1?j[0]:{available:!0,workspaceRoot:x,repoRoot:x,baseRef:j.map(G=>G.baseRef??G.baseBranch).filter(Boolean).join(", "),currentBranch:j.map(G=>G.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:j.map(G=>G.headRef).filter(Boolean).join(", "),diffFingerprint:j.map(G=>G.diffFingerprint).filter(Boolean).join("+"),stat:j.map(G=>G.stat).filter(Boolean).join(`
|
|
1677
|
+
`),files:j.flatMap((G,Y)=>{const Ne=c[Y];return(G.files??[]).map(_e=>`${Ne?.label??G.repoRoot??"repo"}/${_e}`)}),hunks:j.flatMap((G,Y)=>{const _e=c[Y]?.label??G.repoRoot??"repo";return(G.hunks??[]).map(rt=>({...rt,filePath:`${_e}/${rt.filePath}`,oldPath:rt.oldPath?`${_e}/${rt.oldPath}`:rt.oldPath,newPath:rt.newPath?`${_e}/${rt.newPath}`:rt.newPath}))}),commits:j.flatMap(G=>G.commits??[]),commitCount:j.reduce((G,Y)=>G+(Y.commitCount??Y.commits?.length??0),0),diff:j.map(G=>G.diff).filter(Boolean).join(`
|
|
1678
|
+
`),truncated:j.some(G=>G.truncated)};if(Z.comparisonRepos=c.map((G,Y)=>({...G,head:G.head??j[Y].currentBranch??null,includeUncommitted:j[Y].includeUncommitted===!0})),Z.canIncludeUncommitted=j.every(G=>G.canIncludeUncommitted===!0),Z.includeUncommitted=j.some(G=>G.includeUncommitted===!0),jo(G=>({...G,...Object.fromEntries(Z.comparisonRepos.map(Y=>[Y.repoRoot,Y.includeUncommitted??!1]))})),!o&&(Z.hunks??[]).length===0){Ie(i("rightSidebar.branchAuditDiffEmpty"));return}const pe=Date.now(),$e=(o?Ke:null)??["preview",Z.repoRoot??x,Z.baseRef??Z.baseBranch??"",Z.currentBranch??"",Z.headRef??"",Z.diffFingerprint??pe].join("\0"),Ve=c.length===1?c[0].label:`${c.length} repos`;Xt(Z),Zr(G=>[{key:$e,diff:Z,repoLabel:Ve,createdAt:pe},...G.filter(Y=>Y.key!==$e)].slice(0,8)),o||P(G=>G[$e]===void 0?G:{...G,[$e]:0}),an($e),on(G=>{const Y=Z.hunks?.[0],Ne=Y?`${Y.filePath}\0${Y.hunkHeader}\0${Y.hunkIndex}`:null;return o&&G&&(Z.hunks??[]).some(_e=>_e.filePath===G.split("\0")[0])?G:Ne}),tr(!0)}catch(j){if(!k()||dr(j))return;Ie(j instanceof Error?j.message:"Failed to load branch diff")}finally{k()&&Te(!1)}},[Vr,sn,we,Ke,ws,Et,Jt,Ce,x,i]),Nh=a.useCallback(t=>{++z.current,Te(!1),Xt(t.diff),Ie(null),an(t.key),on(t.diff.hunks?.[0]?`${t.diff.hunks[0].filePath}\0${t.diff.hunks[0].hunkHeader}\0${t.diff.hunks[0].hunkIndex}`:null),tr(!0)},[]),Eh=a.useCallback(t=>{Zr(o=>o.filter(c=>c.key!==t)),P(o=>{if(!(t in o))return o;const c={...o};return delete c[t],c}),Ke===t&&(an(null),Xt(null),tr(!1))},[Ke]),Mh=a.useCallback(t=>{++z.current,Te(!1);const o=Vn.find(c=>c.key===t);o&&(Xt(null),Ie(null),an(t),on(o.records[0]?.filePath??null),tr(!0))},[Vn]),$h=a.useCallback(async t=>{if(!x||!ke)return;const[o]=t.split(/\s+/);if(o){rr(o),en(null),ut(null);try{const c=await pm({cwd:x,repoRoot:ke,commit:o,requestSlotId:"right-sidebar-commit-diff"});if(!c.available){en(c.error??"Commit diff is unavailable");return}ut(c);const v=c.hunks?.[0];Js(v?`${v.filePath}\0${v.hunkHeader}\0${v.hunkIndex}`:null)}catch(c){en(c instanceof Error?c.message:"Failed to load commit diff")}finally{rr(null)}}},[ke,x]),Lh=a.useCallback(t=>{if(!we||!Ke)return;const o=Math.max(0,Math.round(t));P(c=>Math.abs((c[Ke]??0)-o)<24?c:{...c,[Ke]:o})},[we,Ke]);a.useEffect(()=>{!we||!Ke||Zr(t=>t.map(o=>o.key===Ke&&o.diff!==we?{...o,diff:we}:o))},[we,Ke]);const Fc=!!we;a.useEffect(()=>{!re||!Sr||!Fc||ps(1)},[Sr,Fc,re,ps]);const _c=a.useCallback(t=>{t&&zf(o=>Vm(o,t))},[]),Bc=ca.key===st?ca.key:null,Ta=a.useCallback(t=>{const o=J.getState(),c=Zb();to("select_diff_file",{interactionId:c,path:t,previousSelectedFilePath:o.selectedFilePath,rootPath:o.rootPath,activeGitRepoRoot:ce,changedFiles:o.changedFiles.size,gitBundleLoading:o.gitBundleLoading,gitBundleLastLoadedAt:o.gitBundleLastLoadedAt,rightTab:o.rightTab}),at(t),Qt("diff"),re&&t&&ps(1),_c(t),queueMicrotask(()=>{const v=J.getState();to("select_diff_file_after",{interactionId:c,requestedPath:t,selectedFilePath:v.selectedFilePath,rootPath:v.rootPath,rightTab:v.rightTab,changedFiles:v.changedFiles.size,activeGitRepoRoot:ce})})},[ce,re,_c,at,Qt,ps]),Oc=a.useCallback(t=>{const o=Array.from(Re.values()).find(c=>{const v=pt(c,x),w=yt(c);return c.path===t.filePath||w===t.filePath||c.absolutePath===t.filePath||(v?`${v}/${c.path}`===t.filePath:!1)||t.repoRoot&&v===t.repoRoot&&c.path===t.filePath});if(o){Ta(yt(o)),window.setTimeout(()=>kn(t),90),window.setTimeout(()=>kn(t),320),window.setTimeout(()=>kn(t),760);return}kn(t)},[Re,x,Ta]),Uc=a.useCallback(({slideToDetail:t,fullscreen:o,toggleFullscreen:c}={})=>Zn.length>0?e.jsx(xu,{walkthroughs:Zn,repoRoot:ce,fullscreen:o,onToggleFullscreen:c,onNavigate:v=>{re&&window.requestAnimationFrame(()=>t?.()),Oc(v)}}):e.jsxs("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:[e.jsx(Os,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),i("rightSidebar.changeWalkthroughEmpty")]}),[ce,Zn,Oc,re,i]),Ah=a.useCallback(t=>{t&&br(o=>{const c=new Set(o);return c.has(t)?c.delete(t):c.add(t),ji(yi,c),c})},[]),Hc=a.useCallback(t=>{xr(o=>{const c=new Set(o);return c.has(t)?c.delete(t):c.add(t),ji(Fd,c),c})},[]),Ia=a.useCallback(t=>{Gs(t),$t(Du,t)},[]);a.useEffect(()=>{Na||vr!=="ai"||Ia("tree")},[vr,Ia,Na]);const Da=a.useCallback(()=>{Qn(t=>{const o=!t;return $t(Fu,o),o})},[]),zc=a.useCallback(t=>{Ks(t),$t(_u,t)},[]),{whitespace:Wc,context:Gc}=Ym(),Kc=a.useMemo(()=>({algorithm:"histogram",whitespace:Wc,context:Gc}),[Wc,Gc]),Vc=a.useCallback(t=>{q(t),$t(Bu,t)},[]),Fa=a.useCallback(async(t,o,c,v)=>{let w=t;for(;w.ok&&w.status==="running";)await new Promise(j=>window.setTimeout(j,1500)),w=await hd({jobId:w.jobId,cwd:o.cwd,action:o.action});if(!w.ok)throw new Error("Git action status is unavailable");if(w.status==="error")throw new Error(w.error||w.message||"Git action failed");const k={action:o.action,path:v,label:c};return ds(k),window.setTimeout(()=>ds(j=>j?.action===k.action&&j.path===k.path?null:j),1400),w},[]),vt=a.useCallback(async(t,o,c)=>{const v=x;x&&or.current.delete(x),xt(null),ds(null),cs({action:t.action,path:c});try{const w=await gm({...t,includeNested:Ns(x)}),k=await Fa(w,t,o,c);if(!Ce(v))return!1;const j=x?await gi(x,void 0,{includeNested:Ns(x),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Ms(x)}).catch(()=>k.bundle):k.bundle;return Ce(v)?(j&&Un(j,{reloadDiff:!0,cacheOnly:!0}),ln(null),!0):!1}catch(w){return ds(null),xt(i("rightSidebar.gitActionFailed",{message:w instanceof Error?w.message:"Unknown error"})),!1}finally{Ce(v)&&cs(null)}},[Un,Ce,x,i,Fa]),qc=a.useCallback(async t=>{const o=x;await md({...t,includeNested:Ns(x)}),Ce(o)&&(qs(c=>c+1),Tt(x??void 0,{refresh:!0,background:!0}))},[Ce,Tt,x]),Ph=a.useCallback(async t=>{const o=we,c=z.current,v=o?.hunks?.find(k=>k.previewRevert?.cwd===t.cwd&&k.previewRevert.path===t.path);if(!o||!v||!t.comparisonBase)throw new Error(i("diffViewer.hunkActionUnavailable"));Se(k=>k+1),Ie(null);try{await md(t)}catch(k){throw Se(j=>j-1),k}if(c!==z.current||!Ce(x)){Se(k=>k-1);return}const w=k=>{Xt(j=>{if(!j||c!==z.current)return j;const oe=j.hunks??[],Z=k===void 0?oe.filter($e=>!($e.previewRevert?.cwd===t.cwd&&$e.previewRevert.patch===t.patch)):[...oe.filter($e=>$e.filePath!==v.filePath),...k];return{...j,hunks:Z}})};w(),fd({cwd:t.cwd,repoRoot:t.cwd,base:t.comparisonBase,comparisonBase:t.comparisonBase,filePath:t.path,requestSlotId:`branch-preview-file:${t.cwd}:${t.path}`}).then(k=>{if(c!==z.current||!Ce(x))return;if(!k.available||k.truncated)throw new Error(k.error??i("diffViewer.hunkActionUnavailable"));const j=t.path.slice(t.cwd.length+1),oe=v.filePath.slice(0,v.filePath.length-j.length);w((k.hunks??[]).map(Z=>({...Z,filePath:`${oe}${Z.filePath}`,oldPath:Z.oldPath?`${oe}${Z.oldPath}`:Z.oldPath,newPath:Z.newPath?`${oe}${Z.newPath}`:Z.newPath})))}).catch(k=>{c===z.current&&Ce(x)&&!dr(k)&&Ie(`${i("diffViewer.hunkActionReverted")} · ${k instanceof Error?k.message:String(k)}`)}).finally(()=>Se(k=>k-1))},[we,Ce,x,i]),_a=a.useCallback((t,o,c)=>{if(o){if(t==="stage-all"){vt({action:"stage-all",cwd:o},i("rightSidebar.stageAll"),`repo:${o}`);return}ln({kind:"stash-all",repoRoot:o,repoLabel:c})}},[vt,i]),Yc=a.useCallback(t=>{Ae(t),sa(""),aa(""),oa(""),at(yc(t)),ot||Qt("diff"),t&&Ra(it.get(t))},[Ra,yc,ot,it,at,Ae,Qt]),Xc=a.useCallback(t=>{const o=new Set([...Ht.current.keys(),...mn.current,...or.current]);for(const c of o)c!==t&&(Ut.current.delete(c),Ht.current.get(c)?.abort(),Ht.current.delete(c),Rt(`right-sidebar-git-untracked:${c}`),mn.current.delete(c),or.current.delete(c))},[]),Th=a.useCallback(async t=>{const o=x;if(!o||(await J.getState().setNestedGitScanRoot(o,t),!Ce(o)))return;if(t){await Tt(o,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}Xc(o),sa(""),aa(""),oa(""),So(v=>v.filter(w=>w===o));const c=Wt;c&&pt(c,o)!==o&&at(null),await Tt(o,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[Xc,Ce,Tt,x,at,Wt]),Ih=a.useCallback(async()=>{if(!ke||Ye){xt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=An.trim();!t||t===fe?.branch||await vt({action:"switch-branch",cwd:ke,branch:t},i("rightSidebar.switchBranch"))},[fe?.branch,ke,Ye,vt,An,i]),Jc=a.useCallback(async()=>{if(!ke||Ye){xt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=na.trim();if(!t)return;await vt({action:"commit",cwd:ke,message:t},i("rightSidebar.commitChanges"))&&Ml("")},[ke,na,Ye,vt,i]),Dh=a.useCallback(async()=>{if(!ke||Ye){xt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=dn.trim(),o=un.trim();await vt({action:"push",cwd:ke,...t?{remote:t}:{},...o?{branch:o}:{}},i("rightSidebar.pushChanges"))},[ke,un,dn,Ye,vt,i]),Fh=a.useCallback(async()=>{if(!ke||Ye){xt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=dn.trim(),o=un.trim();await vt({action:"pull",cwd:ke,...t?{remote:t}:{},...o?{branch:o}:{}},i("rightSidebar.pullChanges"))},[ke,un,dn,Ye,vt,i]);a.useEffect(()=>{if(!ot||!ke||Oe)return;let t=!1;const o={push:i("rightSidebar.pushChanges"),pull:i("rightSidebar.pullChanges"),commit:i("rightSidebar.commitChanges"),"switch-branch":i("rightSidebar.switchBranch"),"stage-all":i("rightSidebar.stageAll"),"stash-all":i("rightSidebar.stashAll")};return(async()=>{for(const c of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(t)return;const v=await hd({cwd:ke,action:c}).catch(()=>null);if(!v?.ok||v.status!=="running")continue;const w={action:c,cwd:ke},k=o[c]??c;cs({action:c});try{const j=await Fa(v,w,k);if(t||!Ce(x))return;const oe=x?await gi(x,void 0,{includeNested:Ns(x),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Ms(x)}).catch(()=>j.bundle):j.bundle;oe&&Un(oe,{reloadDiff:!0,cacheOnly:!0})}catch(j){t||xt(i("rightSidebar.gitActionFailed",{message:j instanceof Error?j.message:"Unknown error"}))}finally{t||cs(null)}return}})(),()=>{t=!0}},[ke,Un,ot,Ce,x,Oe,i,Fa]);const di=$n?.action==="commit",ui=$n?.action==="switch-branch",fi=$n?.action==="pull",hi=$n?.action==="push",Ba=ot||Uf,mi=Ma?i("rightSidebar.changeAuditScopeAll"):cr.length===1?cr[0].label:`${cr.length} repos`,_h=cr.length>0,Qc=ws.length>0,Bh=x?e.jsx(tu,{open:wo,onOpenChange:ko,showScopePicker:!0,selectedAll:Ma,repos:Gt,selectedRoots:Ea,onToggleRepo:kh,onGenerate:()=>Ch(oi?"regenerate":"generate"),disabled:!_h,generateDisabled:!Qc,inserted:he?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:i(oi?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:i("rightSidebar.inserted"),title:i("rightSidebar.branchAuditGenerateTitle"),ariaLabel:i("rightSidebar.branchAuditShort"),scopeTitle:i("rightSidebar.changeAuditScopeLabel"),scopeLabel:mi,allLabel:i("rightSidebar.changeAuditScopeAll"),generateLabel:i(oi?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{ci()},secondaryDisabled:!Qc||Je,secondaryLabel:i("rightSidebar.branchAuditViewDiff"),secondaryTitle:i("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:Je,loading:kl.size>0,statusTitle:kl.size>0?i("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsx("div",{className:"mb-2 space-y-1.5",children:Rc.length>0&&e.jsx("div",{className:"rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[10px] text-[color:var(--warning)]",children:i("rightSidebar.missingBaseReposSkipped",{repositories:Rc.map(t=>t.label).join(O==="zh"?"、":", ")})})}),renderRepoExtra:t=>{const o=it.get(t.root),c=Vr(t.root,Jt[t.root]||o?.context?.branch),v=[],w=new Set,k=(pe,$e)=>{!pe||w.has(pe)||(w.add(pe),v.push({value:pe,label:pe,meta:$e}))};k(Jt[t.root]||o?.context?.branch,i("rightSidebar.pushCurrentBranchBadge"));for(const pe of o?.context?.branches??[])k(pe,pe===o?.context?.branch?i("rightSidebar.pushCurrentBranchBadge"):i("rightSidebar.localBranch"));for(const pe of o?.context?.remoteBranches??[])k(pe,i("rightSidebar.remoteBranch"));const j=[],oe=new Set,Z=(pe,$e)=>{!pe||oe.has(pe)||(oe.add(pe),j.push({value:pe,label:pe,meta:$e}))};Z(Et[t.root],Et[t.root]?i("rightSidebar.pushUpstreamBadge"):void 0),Z(o?.context?.upstream,o?.context?.upstream?i("rightSidebar.pushUpstreamBadge"):void 0);for(const pe of o?.context?.remoteBranches??[])Z(pe,"remote");for(const pe of o?.context?.branches??[])Z(pe,pe===o?.context?.branch?i("rightSidebar.pushCurrentBranchBadge"):"local");return e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsx(Yn,{label:i("rightSidebar.currentBranchLabel"),value:Jt[t.root]||o?.context?.branch||"",options:v,placeholder:i("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:i("rightSidebar.switchBranchSearchPlaceholder"),emptyText:i("rightSidebar.switchNoBranches"),onChange:pe=>{Zs($e=>({...$e,[t.root]:pe}))}}),e.jsx(Yn,{label:i("rightSidebar.branchAuditBaseLabel"),value:Et[t.root]||"",options:j,placeholder:i("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:i("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:i("rightSidebar.branchAuditBaseEmpty"),onChange:pe=>{ea($e=>({...$e,[t.root]:pe}))}}),e.jsxs("label",{className:"sm:col-span-2 flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium",children:i("rightSidebar.includeUncommitted")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:i(c?"rightSidebar.includeUncommittedHint":"rightSidebar.includeUncommittedCurrentBranchOnly")})]}),e.jsx("input",{type:"checkbox",checked:c&&(sn[t.root]??!0),disabled:!c,onChange:pe=>jo($e=>({...$e,[t.root]:pe.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,Zc=$s(Nt.reduce((t,o)=>Math.max(t,o.injectedAt??0),0),O),Oh=x?e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>wl(t=>{const o=!t;return $t(wi,o),o}),className:"group flex w-full items-center gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":ls,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(Os,{size:14})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[12px] font-semibold text-foreground",children:i("rightSidebar.branchAuditTitle")}),e.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:mi})]}),e.jsx("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${ls?"rotate-90":""}`,children:e.jsx(Ha,{size:13})})]}),ls&&e.jsxs("div",{className:"mt-2 rounded-lg border border-border/10 bg-surface/60 p-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 text-[11px] text-muted-foreground",children:[i("rightSidebar.changeAuditScopeLabel"),": ",mi]}),Bh]}),We&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:We}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[Qr.map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ke===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Nh(t),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.diff.hunks?.length??0," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.currentBranch??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.baseRef??t.diff.baseBranch}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:i("rightSidebar.branchAuditViewDiff")})]}),$s(t.createdAt,O)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:$s(t.createdAt,O)})]}),e.jsx("button",{type:"button",onClick:()=>Eh(t.key),className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:i("common.delete"),"aria-label":i("common.delete"),children:e.jsx(ro,{size:12})})]},t.key)),Vn.length>0?Vn.slice(0,Math.max(0,8-Qr.length)).map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ke===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Mh(t.key),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.records.length," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.branchName??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.baseRef}),t.diffFingerprint&&e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diffFingerprint})]}),$s(t.latestInjectedAt,O)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:i("rightSidebar.branchAuditGeneratedAt",{time:$s(t.latestInjectedAt,O)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{yh(t)},className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:i("rightSidebar.branchAuditClearTitle"),"aria-label":i("rightSidebar.branchAuditClearTitle"),children:e.jsx(ro,{size:12})})]},t.key)):Qr.length===0?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:i("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,ed=ar&&x&&Kn?e.jsxs("div",{className:Ba?"overflow-visible":"overflow-hidden",children:[Oh,e.jsxs("button",{type:"button",onClick:()=>{ot||Hf(t=>{const o=!t;return o&&ke&&!Kn&&!cn&&Go(ke),o})},"aria-expanded":Ba,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${ot?"cursor-default":"rounded-lg hover:bg-surface-2 active:scale-[0.99]"}`,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(Lr,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:i("rightSidebar.gitQuickActions")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs("span",{className:`inline-flex items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${yn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[cn&&e.jsx(Ct,{size:10,className:"animate-spin"}),yn.staged>0?i("rightSidebar.stagedCount",{count:yn.staged}):i("rightSidebar.noStagedChangesShort")]}),!ot&&e.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${Ba?"rotate-90":""}`,children:e.jsx(Ha,{size:13})})]})]}),Ba&&e.jsxs("div",{className:"space-y-0",children:[Dt.length>1&&e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsx("div",{className:"mb-2 flex items-center justify-between gap-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:i("rightSidebar.gitRepositorySectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:ih})]})}),e.jsx(Yn,{label:i("rightSidebar.gitRepositoryLabel"),value:ke??"",options:Dt,placeholder:i("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:i("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:i("rightSidebar.gitRepositoryEmpty"),disabled:!!Oe,onChange:t=>{Yc(t||null)}}),Ye&&e.jsx("div",{className:"mt-2 rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[11px] text-[color:var(--warning)]",children:i("rightSidebar.selectRepositoryForGitActions")})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:i("rightSidebar.branchSectionTitle")}),e.jsx("div",{className:"mt-0.5 h-4 truncate text-[11px] leading-4 text-muted-foreground",children:An!==vc?vc:null})]}),e.jsxs("button",{type:"button",onClick:()=>{Ih()},disabled:!bh,className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${ui?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i("rightSidebar.switchBranch"),children:[e.jsx("span",{className:Oe?.action==="switch-branch"||ui?"opacity-0":"",children:i("rightSidebar.switchBranch")}),Oe?.action==="switch-branch"&&e.jsx(Ct,{size:12,className:"absolute animate-spin"}),ui&&Oe?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(Yn,{label:i("rightSidebar.currentBranchLabel"),value:An,options:dh,placeholder:i("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:i("rightSidebar.switchBranchSearchPlaceholder"),emptyText:i("rightSidebar.switchNoBranches"),disabled:!!Oe,onChange:sa})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:i("rightSidebar.commitSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Ye?i("rightSidebar.selectRepositoryForGitActions"):yn.staged>0?i("rightSidebar.commitReadyHint",{count:yn.staged}):i("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{Jc()},disabled:!!Oe||Ye||yn.staged===0||!na.trim(),className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition active:scale-95 ${di?"bg-accent/10 text-accent disabled:bg-accent/10 disabled:text-accent":"bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-surface-2 disabled:text-muted-foreground"} disabled:cursor-not-allowed`,title:Ye?i("rightSidebar.selectRepositoryForGitActions"):yn.staged===0?i("rightSidebar.commitNeedsStaged"):i("rightSidebar.commitChanges"),children:[e.jsx("span",{className:Oe?.action==="commit"||di?"opacity-0":"",children:i("rightSidebar.commitChanges")}),Oe?.action==="commit"&&e.jsx(Ct,{size:12,className:"absolute animate-spin"}),di&&Oe?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:na,onChange:t=>Ml(t.target.value),onKeyDown:t=>{(t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),Jc())},placeholder:i("rightSidebar.commitMessagePlaceholder"),disabled:!!Oe,className:"w-full min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-[13px] placeholder:text-[13px] text-foreground outline-none transition placeholder:text-muted-foreground/70 focus:border-primary focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-60",maxLength:300})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>Or(t=>!t),className:"group flex w-full items-center justify-between gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":tn,children:[e.jsx("span",{className:"min-w-0 text-[12px] font-medium text-foreground",children:i("rightSidebar.recentCommitsTitle")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[Ys&&e.jsx(Ct,{size:12,className:"animate-spin text-muted-foreground"}),e.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${tn?"rotate-90":""}`,children:e.jsx(Ha,{size:13})})]})]}),tn&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[e.jsx(Xn,{size:12,className:"shrink-0"}),e.jsx("input",{value:rn,onChange:t=>nn(t.target.value),placeholder:i("rightSidebar.recentCommitsSearchPlaceholder"),className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1}),rn&&e.jsx("button",{type:"button",onClick:()=>nn(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":i("rightSidebar.clearSearch"),children:e.jsx(Vt,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:lh,children:[Pt.length>0?Pt.map(t=>{const[o,...c]=t.split(/\s+/),v=c.join(" ")||t;return e.jsxs("button",{type:"button",onClick:()=>{$h(t)},className:"flex w-full min-w-0 items-start gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-left font-mono text-[10px] transition hover:bg-surface-elevated active:scale-[0.99]",title:v,children:[e.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:o}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:v,children:v}),Q[o]&&e.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${Q[o]==="ahead"?"bg-accent/10 text-accent":Q[o]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:i(Q[o]==="ahead"?"rightSidebar.commitAhead":Q[o]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),Nn===o&&e.jsx(Ct,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},t)}):Ys?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:i("common.loading")}):e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:i("rightSidebar.recentCommitsEmpty")}),Xs&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(Ct,{size:12,className:"animate-spin"})}),yo&&!Xs&&Pt.length>0&&e.jsx("button",{type:"button",onClick:()=>{ys({reset:!1})},className:"w-full rounded-md bg-surface-2 px-2 py-1.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:i("rightSidebar.recentCommitsLoadMore")})]})]}),ss&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:ss}),vl&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:vl})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:i("rightSidebar.pushSectionTitle")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>{Fh()},disabled:!ph,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${fi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i("rightSidebar.pullChanges"),children:[e.jsx("span",{className:Oe?.action==="pull"||fi?"opacity-0":"",children:i("rightSidebar.pullChanges")}),Oe?.action==="pull"&&e.jsx(Ct,{size:12,className:"absolute animate-spin"}),fi&&Oe?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{Dh()},disabled:!gh,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${hi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i("rightSidebar.pushChanges"),children:[e.jsx("span",{className:Oe?.action==="push"||hi?"opacity-0":"",children:i("rightSidebar.pushChanges")}),Oe?.action==="push"&&e.jsx(Ct,{size:12,className:"absolute animate-spin"}),hi&&Oe?.action!=="push"&&e.jsx("span",{className:"absolute",children:"✓"})]})]})]}),e.jsxs("div",{className:`mb-2 flex min-w-0 items-center justify-between gap-2 rounded-md px-2 py-1.5 text-[11px] ${Nc.className}`,title:fe?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:Nc.text}),e.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:fe?.upstream??""})]}),e.jsxs("div",{className:`grid gap-1.5 ${jc?"grid-cols-2":"grid-cols-1"}`,children:[jc&&e.jsx(Yn,{label:i("rightSidebar.pushRemoteLabel"),value:dn,options:Sc,placeholder:i("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:i("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:i("rightSidebar.pushNoRemotes"),disabled:!!Oe,onChange:aa}),e.jsx(Yn,{label:i("rightSidebar.pushBranchLabel"),value:un,options:uh,placeholder:i("rightSidebar.pushBranchPlaceholder",{branch:fe?.branch??"HEAD"}),searchPlaceholder:i("rightSidebar.pushBranchSearchPlaceholder"),emptyText:i("rightSidebar.pushNoBranches"),disabled:!!Oe,onChange:oa})]})]})]})]}):null,Uh=a.useCallback(t=>{const o=pt(t,x);if(!o)return[];const c=Ai(t),v=[];return t.canStage&&v.push({key:"stage-file",label:i("rightSidebar.stageFile"),onClick:()=>{vt({action:"stage-file",cwd:o,paths:[t.path]},i("rightSidebar.stageFile"),c)}}),t.canUnstage&&v.push({key:"unstage-file",label:i("rightSidebar.unstageFile"),onClick:()=>{vt({action:"unstage-file",cwd:o,paths:[t.path]},i("rightSidebar.unstageFile"),c)}}),t.canStash&&v.push({key:"stash-file",label:i("rightSidebar.stashFile"),onClick:()=>{vt({action:"stash-file",cwd:o,paths:[t.path]},i("rightSidebar.stashFile"),c)}}),t.canRestoreWorktree&&v.push({key:"restore-worktree-file",label:i("rightSidebar.restoreFile"),destructive:!0,onClick:()=>ln({kind:"restore",file:t,phrase:""})}),v},[x,vt,i]),Hh=a.useCallback(()=>{if(g){S?.();return}Rr(0),Nr.current?.slideTo(0),jr(!1),gt(null)},[S,g]),td=a.useCallback(t=>{if(K(""),Ot(t),at(null),gt(null),ne(null),re){g&&S?.(),Rr(0),Nr.current?.slideTo(0),jr(!1);return}},[re,S,g,at,Ot]);a.useEffect(()=>{const t=o=>{const c=o.detail,v=c?.path;if(typeof v!="string"||!v.startsWith("/"))return;K(""),gt(null),Lt(null);const w=!!(x&&(v===x||v.startsWith(`${x}/`)));if(c.kind==="file"){const k=Mi(v);gs(v),typeof c.line=="number"&&Number.isSafeInteger(c.line)&&c.line>0&&Lt(c.line),Ot(w?null:k),ne(j=>({path:v,nonce:(j?.nonce??0)+1}));return}at(null),w?(Ot(null),ne(k=>({path:v,nonce:(k?.nonce??0)+1}))):(ne(null),Ot(v)),re&&(g&&S?.(),Rr(0),Nr.current?.slideTo(0),jr(!1))};return window.addEventListener(yd,t),()=>window.removeEventListener(yd,t)},[gs,re,S,g,x,at,Ot]),a.useEffect(()=>{r||(_t(!1),mr(!1))},[r]),a.useEffect(()=>{if(!fr&&!hr)return;const t=o=>{o instanceof globalThis.KeyboardEvent&&o.key!=="Escape"||o instanceof globalThis.MouseEvent&&o.target instanceof Node&&(Sn.current?.contains(o.target)||jn.current?.contains(o.target))||(_t(!1),mr(!1))};return window.addEventListener("mousedown",t),window.addEventListener("keydown",t),()=>{window.removeEventListener("mousedown",t),window.removeEventListener("keydown",t)}},[hr,fr]);const rd=e.jsxs("div",{"data-local-layer":"file-explorer-menu-host",className:"sticky top-0 z-20 bg-surface/95 px-2.5 py-1.5 backdrop-blur",children:[e.jsxs("div",{className:"flex min-h-9 min-w-0 items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:sh,disabled:!Sa,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":i("rightSidebar.parentFolder"),title:i("rightSidebar.parentFolder"),children:e.jsx(hu,{size:14})}),e.jsx("button",{type:"button",onClick:uc,disabled:!x||Tn===x,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":i("rightSidebar.backToProjectRoot"),title:i("rightSidebar.backToProjectRoot"),children:e.jsx(wd,{size:14})}),e.jsx("button",{type:"button",onClick:ah,disabled:!xe,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":i("rightSidebar.refreshFiles"),title:$l?i("rightSidebar.fileWatchUnavailable",{message:$l}):i("rightSidebar.refreshFiles"),children:e.jsx(_i,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:xe??void 0,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[12px] font-medium text-foreground",children:[e.jsx("span",{className:"truncate",children:rh}),ha==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:i("fileTree.sortedByModified"),"aria-label":i("fileTree.sortedByModified"),children:e.jsx(kd,{size:11})})]})}),e.jsx("button",{type:"button",onClick:()=>xe&&zt(xe,It??void 0),disabled:!xe,...xe&&It?Yo(wa(xe),It):{},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition disabled:cursor-not-allowed disabled:opacity-35 active:scale-95 ${It&&(he===It||qe===It)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":i(It&&qe===It?"rightSidebar.copied":It&&he===It?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:i("rightSidebar.insertCurrentFolder"),children:It&&(he===It||qe===It)?e.jsx(Di,{size:13}):e.jsx(io,{size:13})}),e.jsxs("div",{ref:jn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{_t(!1),mr(t=>!t)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${hr?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":hr,"aria-haspopup":"menu","aria-label":i("sidebar.moreActions"),title:i("sidebar.moreActions"),children:e.jsx(oo,{size:14})}),hr&&e.jsxs("div",{role:"menu","data-local-layer":"file-explorer-menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-48 overflow-hidden rounded-xl border border-border/15 bg-surface p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in",children:[e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{mr(!1),oh()},disabled:!Zo,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${xs?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[xs?e.jsx(bi,{size:14}):e.jsx(Wa,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(xs?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{mr(!1),Gf()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${Do?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[Do?e.jsx(Zm,{size:14}):e.jsx(zi,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(Do?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!xe,onClick:()=>{xe&&(mr(!1),Kf(xe,ha==="modified"?"name":"modified"))},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-40",children:[ha==="modified"?e.jsx(Fm,{size:14}):e.jsx(kd,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(ha==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),x&&(ja.length>0||nh)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 pb-0.5 text-[11px]",children:[e.jsx("span",{className:"shrink-0 px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:i("rightSidebar.pinnedFolders")}),e.jsxs("button",{type:"button",onClick:uc,className:`inline-flex max-w-[9rem] shrink-0 items-center gap-1 rounded-md px-2 py-0.5 font-medium transition active:scale-95 ${xe===x?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:x,children:[e.jsx(wd,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:tt})]}),ja.map(t=>{const o=t.path,c=t.kind==="file",v=c?st===o:xe===o;return e.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${v?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o,children:[e.jsxs("button",{type:"button",onClick:()=>c?gs(o):Ot(o),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[c?e.jsx(Wi,{size:10,className:"shrink-0"}):e.jsx(Wa,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:wt(o)})]}),e.jsx("button",{type:"button",onClick:()=>fn(o),className:"mr-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":i("rightSidebar.unpinFolder",{name:wt(o)}),title:i("rightSidebar.unpinFolder",{name:wt(o)}),children:e.jsx(Vt,{size:9})})]},o)})]}),e.jsx("span",{"data-local-layer":"file-explorer-divider",className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-px bg-border/15","aria-hidden":"true"})]}),pi=a.useMemo(()=>{if(Ln===null)return null;const t=typeof navigator>"u"?void 0:navigator.language,o=Math.max(0,Math.floor((Lo-Ln)/1e3)),c=new Intl.RelativeTimeFormat(t,{numeric:"auto"}),[v,w]=o<60?[-o,"second"]:o<3600?[-Math.floor(o/60),"minute"]:o<86400?[-Math.floor(o/3600),"hour"]:[-Math.floor(o/86400),"day"];return c.format(v,w)},[Lo,Ln]),zh=x&&!Hn?e.jsx("button",{type:"button",onClick:()=>{Th(!Fo)},"aria-pressed":Fo,title:i("rightSidebar.multiRepoScanTitle"),className:`inline-flex h-7 shrink-0 items-center rounded-md px-2.5 text-[11px] font-medium transition active:scale-95 ${Fo?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:i("rightSidebar.multiRepoScan")}):null,nd=x?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[pi?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:i("rightSidebar.gitLastUpdated",{time:pi}),children:pi}):null,e.jsx("button",{type:"button",onClick:()=>{ms()},disabled:zr,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95","aria-label":i("rightSidebar.refreshGit"),title:i("rightSidebar.refreshGit"),children:e.jsx(_i,{size:13,className:zr?"animate-spin":""})})]}):null,Wh=Ql?i("rightSidebar.changeAuditScopeAll"):gn.length===1?gn[0].relativeRoot==="."?tt:gn[0].relativeRoot||gn[0].name:`${gn.length} repos`,Gh=x?e.jsxs("div",{className:"inline-flex min-h-9 shrink-0 items-center",children:[e.jsx(tu,{open:es,onOpenChange:Jr,showScopePicker:wn,selectedAll:Ql,repos:Vf,selectedRoots:Zt,onToggleRepo:wh,onGenerate:()=>xh(),disabled:!x,inserted:he===dc,buttonLabel:i("rightSidebar.changeAuditShort"),insertedLabel:i("rightSidebar.inserted"),title:i("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:i("rightSidebar.insertChangeAuditPrompt"),scopeTitle:i("rightSidebar.changeAuditScopeLabel"),scopeLabel:Wh,allLabel:i("rightSidebar.changeAuditScopeAll"),generateLabel:i("rightSidebar.changeAuditShort"),loading:Dr,error:!!kr,statusTitle:kr??(Dr?i("rightSidebar.changeAuditLoading"):Nt.length>0?`${i("rightSidebar.changeAuditLoaded",{count:Nt.length})}${Zc?` · ${i("rightSidebar.changeAuditLoadedAt",{time:Zc})}`:""}`:void 0)}),e.jsx("button",{type:"button",onClick:()=>{vh()},disabled:Dr||Nt.length===0,className:`inline-flex h-7 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:pointer-events-none active:scale-95 ${Nt.length>0?"":"invisible"}`,title:i("rightSidebar.clearChangeAuditTitle"),"aria-label":i("rightSidebar.clearChangeAudit"),children:e.jsx(ro,{size:12})})]}):null,Ss=er??(R?.available&&x&&Re.size>0&&le.length<=1?{root:x,label:tt}:null),sd=e.jsxs(e.Fragment,{children:[Ss&&e.jsxs("div",{className:"flex w-full flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>_a("stage-all",Ss.root,Ss.label),disabled:!!Oe,className:"flex-1 rounded-md bg-accent/10 px-2 py-1 text-[11px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",children:i("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:()=>_a("stash-all",Ss.root,Ss.label),disabled:!!Oe,className:"flex-1 rounded-md bg-surface-elevated px-2 py-1 text-[11px] font-medium text-foreground hover:bg-surface disabled:opacity-50",children:i("rightSidebar.stashAll")})]}),zh,Gh]}),Oa=e.jsxs("div",{className:"flex h-5 flex-nowrap items-center gap-1 overflow-x-auto whitespace-nowrap text-[10px] font-medium [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&>*]:shrink-0",children:[R?.available&&R.branch&&e.jsxs("span",{className:"inline-flex min-w-0 max-w-[8rem] items-center gap-0.5 truncate rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",title:R.branch,children:[e.jsx(Lr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:R.branch})]}),ft.modified>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[ft.modified,"M"]}),ft.added>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",ft.added]}),ft.deleted>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",ft.deleted]}),ft.renamed>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[ft.renamed,"R"]}),ft.copied>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[ft.copied,"C"]}),ft.untracked>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[ft.untracked,"U"]}),ft.conflicted>0&&e.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[ft.conflicted,"!"]}),ft.other>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[ft.other,"?"]}),ft.staged>0&&e.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:i("rightSidebar.stagedCountShort",{count:ft.staged})})]});return e.jsxs(_m,{side:"right",isOpen:r,drawerWidthPx:s,onClose:l,onOpen:u,push:d,pinned:h,children:[Yo.popoverNode,e.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${Xf?"hidden":""}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"min-w-0 flex-1 px-1",children:e.jsxs("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",title:x??void 0,children:tt}),(!re||No)&&R?.available&&R.branch&&e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:R.branch,children:[e.jsx(Lr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"max-w-[7rem] truncate",children:R.branch})]})]})}),e.jsx("button",{type:"button",onClick:()=>{const t=!ve;W(t),t?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):K("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${ve?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":i("rightSidebar.toggleSearch"),title:i("common.search"),children:e.jsx(Xn,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":Ze,onClick:()=>{dt(t=>!t),Ft(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Ze?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":i("rightSidebar.toggleContextDraft"),title:i("rightSidebar.contextDraftTitle"),children:[e.jsx(Bm,{size:14}),!Ze&&ye.trim()&&e.jsx("span",{className:"absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-primary","aria-hidden":"true"})]}),e.jsx("input",{ref:Tl,type:"file",multiple:!0,className:"hidden",onChange:t=>{const o=t.target.files;!o||o.length===0||(bs(Array.from(o)),t.target.value="")}}),e.jsx("input",{ref:Il,type:"file",accept:"image/*",className:"hidden",onChange:t=>{const o=t.target.files?.[0];t.target.value="",o&&Zf(o)}}),m&&e.jsx("button",{type:"button",onClick:m,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${h?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":i(h?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:i(h?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:h?e.jsx(bi,{size:14}):e.jsx(Wa,{size:14})}),e.jsxs("div",{ref:Sn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{mr(!1),_t(t=>!t)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${fr?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":fr,"aria-haspopup":"menu","aria-label":i("sidebar.moreActions"),title:i("sidebar.moreActions"),children:e.jsx(oo,{size:15})}),fr&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-56 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Hr,onClick:()=>Qf(!Hr),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[e.jsx(pd,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"flex-1",children:i("rightSidebar.showAndroidTab")}),e.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${Hr?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${Hr?"left-3.5":"left-0.5"}`})})]}),e.jsx("div",{className:"my-1 h-px bg-border/15",role:"separator"}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_t(!1),Tl.current?.click()},disabled:ia,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-50",children:[ia?e.jsx(Ct,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(cp,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_t(!1),Il.current?.click()},disabled:ia,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-50",children:[ia?e.jsx(Ct,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(np,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i("rightSidebar.insertLocalImage")})]}),m&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_t(!1),m()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${h?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[h?e.jsx(bi,{size:14}):e.jsx(Wa,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(h?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),h&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 border-t border-border/15 px-1.5 pt-1.5",role:"group","aria-label":i("rightSidebar.layoutMode"),children:[e.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:i("rightSidebar.layoutMode")}),e.jsx("div",{className:"grid min-w-0 flex-1 grid-cols-3 gap-0.5 rounded-lg bg-surface-2 p-0.5",children:[["auto",i("rightSidebar.layoutModeAuto")],["narrow",i("rightSidebar.layoutModeNarrow")],["wide",i("rightSidebar.layoutModeWide")]].map(([t,o])=>{const c=X===t;return e.jsx("button",{type:"button",role:"menuitemradio","aria-checked":c,onClick:()=>{L(t),_t(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${c?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:o},t)})})]})]})]}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":i("rightSidebar.close"),children:e.jsx(Vt,{size:14})})]}),ve&&e.jsxs("div",{className:"mt-2 space-y-1.5 pb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-surface-2 px-3 py-1.5 text-muted-foreground transition focus-within:bg-surface-elevated",children:[e.jsx(Xn,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:C,onChange:t=>K(t.target.value),placeholder:i(F==="content"?"rightSidebar.searchPlaceholderContent":"rightSidebar.filterChanges"),className:"min-w-0 flex-1 bg-transparent text-[13px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",enterKeyHint:"search",spellCheck:!1}),e.jsxs("div",{className:`flex shrink-0 items-center gap-0.5 rounded-full bg-surface/70 p-0.5 font-medium ${re?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>Vc("name"),"aria-pressed":F==="name",className:`rounded-full px-2 transition active:scale-95 ${re?"py-1":"py-0.5"} ${F==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:i("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>Vc("content"),"aria-pressed":F==="content",className:`rounded-full px-2 transition active:scale-95 ${re?"py-1":"py-0.5"} ${F==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:i("rightSidebar.searchModeContent")})]}),C&&e.jsx("button",{type:"button",onClick:()=>K(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":i("rightSidebar.clearSearch"),children:e.jsx(Vt,{size:12})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg bg-surface-2 px-2.5 py-1.5 text-muted-foreground transition focus-within:bg-surface-elevated",children:[e.jsx(Om,{size:12,className:"shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:i("rightSidebar.searchScope")}),e.jsx("input",{"data-search-scope":!0,value:se,onChange:t=>ie(t.target.value),onKeyDown:t=>{t.key==="Enter"&&document.querySelector("[data-right-search]")?.focus()},className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:i("rightSidebar.searchScopePlaceholder"),"aria-label":i("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),se!=="."&&e.jsx("button",{type:"button",onClick:()=>ie("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":i("rightSidebar.resetSearchScope"),children:e.jsx(Vt,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>M(t=>!t),"aria-expanded":Pe,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${Pe||us.length>0||ee||Le||Ee?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:i("rightSidebar.searchOptions"),"aria-label":i("rightSidebar.searchOptions"),children:[e.jsx(Um,{size:13}),us.length>0&&e.jsx("span",{className:"absolute -right-1 -top-1 min-w-4 rounded-full bg-primary px-1 text-[8px] font-bold leading-4 text-primary-foreground",children:us.length})]})]}),Pe&&e.jsxs("div",{className:"animate-fade-in rounded-xl bg-surface-2 p-2",children:[e.jsxs("label",{className:"flex items-center gap-2 rounded-lg bg-surface px-2.5 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:i("rightSidebar.searchExclude")}),e.jsx("input",{"data-search-exclude":!0,value:me,onChange:t=>ge(t.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:i("rightSidebar.searchExcludePlaceholder"),"aria-label":i("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),me&&e.jsx("button",{type:"button",onClick:()=>ge(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":i("rightSidebar.clearSearchExclude"),children:e.jsx(Vt,{size:11})})]}),F==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":i("rightSidebar.contentSearchOptions"),children:[[ee,()=>be(t=>!t),Jm,i("rightSidebar.matchCase")],[Le,()=>Xe(t=>!t),up,i("rightSidebar.matchWholeWord")],[Ee,()=>Qe(t=>!t),ap,i("rightSidebar.useRegex")]].map(([t,o,c,v])=>e.jsxs("button",{type:"button",onClick:o,"aria-pressed":t,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${t?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsx(c,{size:12}),v]},v))})]})]}),e.jsxs("div",{className:"mt-2 grid gap-0.5 rounded-md bg-surface-2 p-0.5",style:{gridTemplateColumns:`repeat(${(Hn?2:3)+(Hr?1:0)}, minmax(0, 1fr))`},children:[!Hn&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>Qt("git"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${lr==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Lr,{size:12}),i("rightSidebar.tabGit")]}),e.jsxs("button",{type:"button",onClick:()=>Qt("diff"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${lr==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Ru,{size:12}),i("rightSidebar.tabChanges"),Re.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:Re.size}):null]})]}),e.jsxs("button",{type:"button",onClick:()=>Qt("files"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${lr==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Gm,{size:12}),i("rightSidebar.tabFiles")]}),Hr&&e.jsxs("button",{type:"button",onClick:()=>Qt("android"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${lr==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(pd,{size:12}),i("rightSidebar.tabAndroid")]})]}),e.jsx("div",{className:"h-2"}),Nl&&e.jsx("div",{className:"pointer-events-none absolute right-3 top-10 z-20 max-w-[72%] rounded-lg bg-destructive/95 px-3 py-2 text-[11px] font-medium text-destructive-foreground shadow-md animate-fade-in",children:Nl})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(Za,{active:ot,mounted:ar,fallback:e.jsx(Ei,{slow:!1}),children:et?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(Md,{items:Sh,selectedKey:Df,onSelect:Js,emptyText:i("rightSidebar.noChanges"),mobile:re,backLabel:i("rightSidebar.backToChangeList"),headerTitle:i("rightSidebar.recentCommitsTitle"),headerMeta:`${et.headRef??""}${et.commits?.[0]?` · ${et.commits[0]}`:""}`,onClose:()=>{ut(null),Js(null)},closeLabel:i("common.back"),wrap:At,onToggleWrap:re?Da:void 0,wrapTitle:i("rightSidebar.wrapLongLines"),wrapOnLabel:i("rightSidebar.wrapOn"),wrapOffLabel:i("rightSidebar.wrapOff"),desktopLayout:re?"stacked":"split",onInsertDiffReference:$r,onReferenceCopied:Er,insertedReferenceKey:he,copiedReferenceKey:qe,onClearAuditRecord:Aa})}):Sr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(Md,{items:ai,selectedKey:Ro,onSelect:on,emptyText:i(we?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:re,backLabel:i("rightSidebar.backToChangeList"),headerTitle:i(we?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:Pa?`${Pa.repoLabel} · ${Pa.branchName??"HEAD"} → ${Pa.baseRef}`:void 0,onClose:()=>{++z.current,Te(!1),tr(!1),Xt(null)},closeLabel:i("common.back"),wrap:At,onToggleWrap:re?Da:void 0,wrapTitle:i("rightSidebar.wrapLongLines"),wrapOnLabel:i("rightSidebar.wrapOn"),wrapOffLabel:i("rightSidebar.wrapOff"),desktopLayout:re?"stacked":"split",onInsertDiffReference:$r,onReferenceCopied:Er,insertedReferenceKey:he,copiedReferenceKey:qe,onClearAuditRecord:Aa,localOptions:we?.comparisonRepos?.map(t=>({key:t.repoRoot,label:t.label,checked:t.includeUncommitted??we.includeUncommitted??!1,disabled:!Vr(t.repoRoot,t.head),onChange:o=>{ci({refresh:!0,repoRoot:t.repoRoot,includeUncommitted:o})}})),onHunkGitAction:we?.includeUncommitted?Ph:void 0,error:We,actionsBusy:ue>0,onRefresh:()=>{ci({refresh:!0})},refreshing:Je,refreshLabel:i("rightSidebar.branchAuditRefreshDiff"),refreshTitle:i("rightSidebar.branchAuditRefreshDiff"),walkthroughs:jh,onWalkthroughNavigate:Rh,initialDetailScrollTop:we&&Ke?ns[Ke]:void 0,onDetailScrollPositionChange:Lh,externalSwiperRef:re?ba:void 0,onMobileSlideChange:re?Co:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:ed?e.jsx("div",{className:"px-3",children:ed}):zr?e.jsx(Ei,{slow:zl}):hn?e.jsx(eo,{message:hn,onRetry:()=>{ms()}}):ou(R)?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i(x?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):R?.available===!1?e.jsx(eo,{message:R.error??i("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{ms()}}):x?e.jsx(Ei,{slow:zl}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i(x?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),e.jsx(Za,{active:zn,children:re?e.jsxs(pu,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:t=>{Nr.current=t,t.slideTo(jl,0)},onSlideChange:t=>{if(Rr(t.activeIndex),hs.current===t.activeIndex){hs.current=null;return}t.activeIndex===0&&(jr(!1),gt(null),S?.())},children:[e.jsx(Bi,{className:"h-full min-h-0",children:e.jsxs("div",{ref:Fn,onScroll:ec,onDragOver:va,onDragEnter:va,onDragLeave:nc,onDrop:sc,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[Ll&&e.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:e.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:i("rightSidebar.dropToUpload")})}),!C.trim()&&rd,e.jsx(Sd,{rootPath:xe??"",onFileSelect:gs,onPathReference:zt,getReferenceText:wa,onReferenceCopied:Er,insertedReferenceKey:he,copiedReferenceKey:qe,onDirectoryRoot:fc,onSearchFromDirectory:hc,onDirectoryPinToggle:mc,onFilePinToggle:pc,pinnedPaths:xn,selectedFilePath:st,query:Fe,searchRootPath:Vl,searchOptions:ql,searchMode:F,onContentMatchSelect:tc,onDirectoryDropFiles:(t,o)=>bs(o,t),revealDirectory:de,canOpenInFileBrowser:Al,onOpenInFileBrowser:rc})]})}),e.jsx(Bi,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(al,{filePath:zn&&(Ff||jl===1)?st:null,onInsertReference:zt,onInsertText:Mr,onInsertFeature:Mr,onReviewReference:lc,onReferenceCopied:Er,onClose:Hh,onDirectoryLinkOpen:td,isMobile:!0,lineRange:Rn,onLineRangeChange:gt,insertedReferenceKey:he,copiedReferenceKey:qe,scrollToLine:Ue,onScrollToLineHandled:()=>Lt(null),markdownOutlineOpen:B,markdownOutlineCloseSignal:$,onOpenMarkdownOutline:E,onCloseMarkdownOutline:A,markdownImageLightboxOpen:T,markdownImageLightboxCloseSignal:U,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:p})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:Fn,onScroll:ec,onDragOver:va,onDragEnter:va,onDragLeave:nc,onDrop:sc,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:Po},children:[Ll&&e.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:e.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:i("rightSidebar.dropToUpload")})}),!C.trim()&&rd,e.jsx(Sd,{rootPath:xe??"",onFileSelect:gs,onPathReference:zt,getReferenceText:wa,onReferenceCopied:Er,insertedReferenceKey:he,copiedReferenceKey:qe,onDirectoryRoot:fc,onSearchFromDirectory:hc,onDirectoryPinToggle:mc,onFilePinToggle:pc,pinnedPaths:xn,selectedFilePath:st,query:Fe,searchRootPath:Vl,searchOptions:ql,searchMode:F,onContentMatchSelect:tc,onDirectoryDropFiles:(t,o)=>bs(o,t),revealDirectory:de,canOpenInFileBrowser:Al,onOpenInFileBrowser:rc})]}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":i("rightSidebar.resizeFileTree"),title:i("rightSidebar.resizeFileTree"),"data-local-layer":"file-preview-separator",className:"group relative z-10 w-2 shrink-0 cursor-col-resize touch-none border-l border-border/15 bg-surface",onPointerDown:qf,onPointerMove:Yf,onPointerUp:Zl,onPointerCancel:Zl,onDoubleClick:()=>{To(Yi),$t(Ls,Yi)},children:e.jsx("span",{className:"absolute left-1/2 top-0 h-full w-px -translate-x-1/2 bg-border/20 transition group-hover:bg-primary/45"})}),e.jsx("div",{className:"min-w-0 flex-1 overflow-hidden bg-surface",children:e.jsx(al,{filePath:zn?st:null,onInsertReference:zt,onInsertText:Mr,onInsertFeature:Mr,onReviewReference:lc,onReferenceCopied:Er,onDirectoryLinkOpen:td,isMobile:!1,lineRange:Rn,onLineRangeChange:gt,insertedReferenceKey:he,copiedReferenceKey:qe,scrollToLine:Ue,onScrollToLineHandled:()=>Lt(null),markdownOutlineOpen:B,markdownOutlineCloseSignal:$,onOpenMarkdownOutline:E,onCloseMarkdownOutline:A,markdownImageLightboxOpen:T,markdownImageLightboxCloseSignal:U,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:p})})]})}),e.jsx(Za,{active:jt,mounted:_f||jt,children:()=>Ko?e.jsx(Hm,{}):re?e.jsx(Oi,{mobile:!0,backLabel:i("rightSidebar.backToChangeList"),externalSwiperRef:ba,onMobileSlideChange:Co,groups:Kt.length>0?Tc():[],mode:vr,onModeChange:Ia,selectedKey:st,scrollToKey:Bc,scrollToKeyNonce:ca.nonce,compact:!1,collapsedDirectoryKeys:Ws,onToggleDirectory:Hc,onSelectFile:t=>{const o=Array.from(Re.values()).find(c=>yt(c)===t.key);o&&Ta(yt(o))},renderLeading:Dc,renderTrailing:t=>{const o=Array.from(Re.values()).find(c=>yt(c)===t.key);return o?Ac(o):null},renderDirectoryTrailing:Pc,renderSubtitle:t=>{const o=Array.from(Re.values()).find(c=>yt(c)===t.key);return o?$c(o):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:t=>x&&e.jsxs("div",{className:"px-0 py-0",children:[Oa&&e.jsx("div",{className:"mb-2",children:Oa}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:i("rightSidebar.allChanges")})}),e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[Kt.length,"/",Re.size]})]}),e.jsxs(Nd,{actions:sd,children:[Ec(),t,h&&ni(),nd]},x),er&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:er.label}),er.branch&&e.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:er.branch})]}),!er&&wn&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[e.jsx(Lr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:i("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:Na?(t=>Uc(t)):void 0,emptyContent:Ko?null:hn&&Re.size===0?e.jsx(eo,{message:hn,onRetry:()=>{ms()}}):Re.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i("rightSidebar.noChanges")}):Kt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:i("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>ps(0),className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:i("rightSidebar.backToChangeList"),children:[e.jsx(Fs,{size:14}),i("rightSidebar.backToChangeList")]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-1.5",children:[h&&ni(),e.jsxs("button",{type:"button",onClick:Da,"aria-pressed":At,title:i("rightSidebar.wrapLongLines"),className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${At?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:i(At?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:Ic(),activePane:jt,wrap:At,diffViewType:Wf,inlineMode:yr,diffOptions:Kc,reloadKey:Vs,renderStreamBadge:t=>e.jsx(Ts,{status:t}),onHunkGitAction:qc,onInsertDiffReference:$r,onReferenceCopied:Er,insertedReferenceKey:he,copiedReferenceKey:qe,onClearAuditRecord:Aa,onDetailScroll:$a}):e.jsx(Oi,{mobile:!1,desktopLayout:"split",desktopSidePanel:null,desktopListClassName:"w-[320px] min-w-[260px] shrink-0 overflow-y-auto overscroll-contain border-r border-border/15 bg-surface",backLabel:i("rightSidebar.backToChangeList"),groups:Kt.length>0?Tc():[],mode:vr,onModeChange:Ia,selectedKey:st,scrollToKey:Bc,scrollToKeyNonce:ca.nonce,compact:!0,collapsedDirectoryKeys:Ws,onToggleDirectory:Hc,onSelectFile:t=>{const o=Array.from(Re.values()).find(c=>yt(c)===t.key);o&&Ta(yt(o))},renderLeading:Dc,renderTrailing:t=>{const o=Array.from(Re.values()).find(c=>yt(c)===t.key);return o?Ac(o):null},renderDirectoryTrailing:Pc,renderSubtitle:t=>{const o=Array.from(Re.values()).find(c=>yt(c)===t.key);return o?$c(o):null},aiContent:Na?(t=>Uc(t)):void 0,emptyContent:Ko?null:hn&&Re.size===0?e.jsx(eo,{message:hn,onRetry:()=>{ms()}}):Re.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i("rightSidebar.noChanges")}):Kt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:i("rightSidebar.noMatchingChanges")}):null,renderListHeader:t=>x&&e.jsxs("div",{className:"px-0 py-0",children:[Oa&&e.jsx("div",{className:"mb-2",children:Oa}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:i("rightSidebar.allChanges")}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[Kt.length,"/",Re.size]})})]}),e.jsxs(Nd,{actions:sd,children:[Ec(),t,ni(),e.jsxs("button",{type:"button",onClick:Da,"aria-pressed":At,title:i("rightSidebar.wrapLongLines"),className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${At?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:i(At?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),nd]},x),er&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:er.label}),er.branch&&e.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:er.branch})]}),!er&&wn&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[e.jsx(Lr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:i("rightSidebar.selectRepositoryForDiff")})]})]}),files:Ic(),activePane:jt,wrap:At,diffViewType:Bt,inlineMode:yr,diffOptions:Kc,reloadKey:Vs,renderStreamBadge:t=>e.jsx(Ts,{status:t}),onHunkGitAction:qc,onInsertDiffReference:$r,onReferenceCopied:Er,insertedReferenceKey:he,copiedReferenceKey:qe,onClearAuditRecord:Aa,onDetailScroll:$a})}),e.jsx(Za,{active:Wn,mounted:Mo&&Hr,children:Bf?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[e.jsx("span",{children:i("android.splitDockedHint")}),e.jsx("button",{type:"button",onClick:()=>{od.getState().setDock(bd,null),Fi({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:i("android.splitClose")})]}):e.jsx(zm,{sessionId:n??null,onInsertPrompt:t=>$r("android-deps",t),onInsertFile:th,onRecordingComplete:eh})})]}),r&&Ze&&e.jsx(Dp,{value:ye,collapsed:Pr,autoCollapseAfterSend:H,focusRequest:mt,insertError:Tr?i("rightSidebar.contextDraftInsertFailed"):null,onChange:t=>{pr(!1),ze(t)},onCollapsedChange:Ft,onAutoCollapseAfterSendChange:ae,onDisable:()=>dt(!1),onClear:()=>ze(""),onInsert:()=>cc(!1),onInsertAndSend:()=>cc(!0),labels:{title:i("rightSidebar.contextDraftTitle"),hint:i("rightSidebar.contextDraftHint"),placeholder:i("rightSidebar.contextDraftPlaceholder"),collapse:i("rightSidebar.contextDraftCollapse"),expand:i("rightSidebar.contextDraftExpand"),disable:i("rightSidebar.contextDraftDisable"),clear:i("rightSidebar.contextDraftClear"),insert:i("rightSidebar.contextDraftInsert"),insertAndSend:i("rightSidebar.contextDraftInsertAndSend"),inserted:i("rightSidebar.contextDraftInserted"),sent:i("rightSidebar.contextDraftSent"),send:i("rightSidebar.contextDraftSend"),appended:i("rightSidebar.contextDraftAppended"),resize:i("rightSidebar.contextDraftResize"),autoCollapseAfterSend:i("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:t=>i("rightSidebar.contextDraftCharacterCount",{count:t})}}),mh(),bt&&typeof document<"u"&&Yr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>ln(null),children:e.jsxs("div",{className:"fixed inset-x-3 bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto max-w-md rounded-2xl border border-border/20 bg-surface-elevated p-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:bt.kind==="restore"?i("rightSidebar.confirmRestoreTitle"):i("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:bt.kind==="restore"?i("rightSidebar.confirmRestoreDescription",{path:fu(bt.file.absolutePath,x)}):i("rightSidebar.confirmStashAllDescription")}),bt.kind==="restore"&&e.jsx("input",{value:bt.phrase,onChange:t=>ln({...bt,phrase:t.target.value}),placeholder:i("rightSidebar.confirmRestorePlaceholder"),className:"mt-3 w-full rounded-xl border border-border/20 bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground",autoFocus:!0}),e.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>ln(null),className:"rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:i("common.cancel")}),e.jsx("button",{type:"button",disabled:!!Oe||bt.kind==="restore"&&bt.phrase.trim()!==i("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(bt.kind==="restore"){const t=pt(bt.file,x);if(!t)return;vt({action:"restore-worktree-file",cwd:t,paths:[bt.file.path],confirm:{acknowledged:!0,phrase:bt.phrase}},i("rightSidebar.restoreFile"),Ai(bt.file))}else{const t=bt.repoRoot??x;if(!t)return;vt({action:"stash-all",cwd:t},i("rightSidebar.stashAll"),`repo:${t}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${bt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:i(Oe?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const mx=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:al,MarkdownImageLightbox:Sf,MarkdownPreview:jf,RightSidebar:rx,__testParseMarkdownListBlock:vb,buildMarkdownPreviewBlocks:$b,buildMarkdownPreviewRenderResult:gl,collectKnownGitRepoRoots:Vu,computeMarkdownImageDisplayBox:af,getMarkdownHeadingOutline:kf,getMarkdownHeadingPathAtLine:wf,getNextMarkdownPreviewLineRange:Db,isSvgImageSrc:xo,mountRightSidebarRepoPickerOverlay:Tu,replaceGitRepositorySnapshot:$f,resolveMarkdownLocalLinkTarget:dl,resolveRightSidebarDiffViewType:Gu,shouldCloseMarkdownImageLightboxDrag:xf,showsGitRepoGroupHeader:Xi},Symbol.toStringTag,{value:"Module"}));export{zi as E,mx as R,Zm as a,mp as c,hx as m};
|