termdock 1.4.274 → 1.4.276
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-Bgmz2KFR.js → App-Cq29NTOz.js} +39 -39
- package/dist/client/assets/App-Cq29NTOz.js.br +0 -0
- package/dist/client/assets/App-Cq29NTOz.js.gz +0 -0
- package/dist/client/assets/{ChangeWalkthroughPanel-DzqfGdXE.js → ChangeWalkthroughPanel-t4NOgjxM.js} +1 -1
- package/dist/client/assets/ChangeWalkthroughPanel-t4NOgjxM.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-t4NOgjxM.js.gz +0 -0
- package/dist/client/assets/{DagPlayground-D-blt_ce.js → DagPlayground-CxQvsac8.js} +1 -1
- package/dist/client/assets/DagPlayground-CxQvsac8.js.br +0 -0
- package/dist/client/assets/DagPlayground-CxQvsac8.js.gz +0 -0
- package/dist/client/assets/{DiffLab-DolN7Thu.js → DiffLab-B5_y5WUP.js} +1 -1
- package/dist/client/assets/DiffLab-B5_y5WUP.js.br +0 -0
- package/dist/client/assets/DiffLab-B5_y5WUP.js.gz +0 -0
- package/dist/client/assets/DiffReview-J3wlEpHg.js +1 -0
- package/dist/client/assets/DiffReview-J3wlEpHg.js.br +0 -0
- package/dist/client/assets/DiffReview-J3wlEpHg.js.gz +0 -0
- package/dist/client/assets/{DiffReviewLab-BGAJuFRb.js → DiffReviewLab-DZI1-J1D.js} +1 -1
- package/dist/client/assets/DiffReviewLab-DZI1-J1D.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-DZI1-J1D.js.gz +0 -0
- package/dist/client/assets/DiffViewer-CgtVILev.js +37 -0
- package/dist/client/assets/DiffViewer-CgtVILev.js.br +0 -0
- package/dist/client/assets/DiffViewer-CgtVILev.js.gz +0 -0
- package/dist/client/assets/{ModelPreview-BqBbpxd1.js → ModelPreview-CFe_gbXI.js} +1 -1
- package/dist/client/assets/ModelPreview-CFe_gbXI.js.br +0 -0
- package/dist/client/assets/ModelPreview-CFe_gbXI.js.gz +0 -0
- package/dist/client/assets/RightSidebar-iy7-XSSb.js +1678 -0
- package/dist/client/assets/RightSidebar-iy7-XSSb.js.br +0 -0
- package/dist/client/assets/RightSidebar-iy7-XSSb.js.gz +0 -0
- package/dist/client/assets/{abnfDiagram-VCTEODGH-C4A-2OCs.js → abnfDiagram-VCTEODGH-CXXSvKzJ.js} +1 -1
- package/dist/client/assets/abnfDiagram-VCTEODGH-CXXSvKzJ.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-CXXSvKzJ.js.gz +0 -0
- package/dist/client/assets/app-DbY083Oo.js +35 -0
- package/dist/client/assets/app-DbY083Oo.js.br +0 -0
- package/dist/client/assets/app-DbY083Oo.js.gz +0 -0
- package/dist/client/assets/{arc-D9baZTlD.js → arc-cp7SkvLQ.js} +1 -1
- package/dist/client/assets/arc-cp7SkvLQ.js.br +0 -0
- package/dist/client/assets/arc-cp7SkvLQ.js.gz +0 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-DENwPPJf.js → architectureDiagram-5GKGNRK7-C644wSuo.js} +1 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-C644wSuo.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-C644wSuo.js.gz +0 -0
- package/dist/client/assets/{blockDiagram-I7D4REHJ-D5aOKdyM.js → blockDiagram-I7D4REHJ-D5KyGuKi.js} +1 -1
- package/dist/client/assets/blockDiagram-I7D4REHJ-D5KyGuKi.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-D5KyGuKi.js.gz +0 -0
- package/dist/client/assets/{c4Diagram-7LVT6UL2-CBOCvHOL.js → c4Diagram-7LVT6UL2-me7O251H.js} +1 -1
- package/dist/client/assets/c4Diagram-7LVT6UL2-me7O251H.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-me7O251H.js.gz +0 -0
- package/dist/client/assets/channel-D7fov9Fv.js +1 -0
- package/dist/client/assets/{chunk-2Q5K7J3B-dlg_y1Yt.js → chunk-2Q5K7J3B-BwXplC7w.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-CO7nRL4g.js → chunk-5VM5RSS4-Cxv0b7hH.js} +1 -1
- package/dist/client/assets/{chunk-F27PBJKO-_XEmDjbM.js → chunk-F27PBJKO-DocSLwjs.js} +1 -1
- package/dist/client/assets/chunk-F27PBJKO-DocSLwjs.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-DocSLwjs.js.gz +0 -0
- package/dist/client/assets/{chunk-IMKFNOWR-DsG6lLDO.js → chunk-IMKFNOWR-Crh3XcBw.js} +1 -1
- package/dist/client/assets/chunk-IMKFNOWR-Crh3XcBw.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-Crh3XcBw.js.gz +0 -0
- package/dist/client/assets/{chunk-JWPE2WC7-BNa5Lx63.js → chunk-JWPE2WC7-DhvxSds2.js} +1 -1
- package/dist/client/assets/{chunk-POPQ4Y6H-ixOhaIZ8.js → chunk-POPQ4Y6H-CTsXvY77.js} +1 -1
- package/dist/client/assets/{chunk-SVP7TREG-CuF6ZXR9.js → chunk-SVP7TREG-B6tUp675.js} +1 -1
- package/dist/client/assets/chunk-SVP7TREG-B6tUp675.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-B6tUp675.js.gz +0 -0
- package/dist/client/assets/{chunk-TICWLB2K-DXcx3LRb.js → chunk-TICWLB2K-Cq3Ij5FB.js} +1 -1
- package/dist/client/assets/chunk-TICWLB2K-Cq3Ij5FB.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-Cq3Ij5FB.js.gz +0 -0
- package/dist/client/assets/{chunk-XXDRQBXY-D6gKWE42.js → chunk-XXDRQBXY-BFnmmnaf.js} +1 -1
- package/dist/client/assets/classDiagram-ZZMXUADV-DhMDhp7_.js +1 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-DhMDhp7_.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-ByD4BHe2.js → cose-bilkent-JH36ORCC-CH79v5Nm.js} +1 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-CH79v5Nm.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-CH79v5Nm.js.gz +0 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-BxCxFVsn.js → cynefin-OW5HDTMX-DPtsHlxo.js} +1 -1
- package/dist/client/assets/cynefin-OW5HDTMX-DPtsHlxo.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-DPtsHlxo.js.gz +0 -0
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-Dbs_tQyc.js → cynefinDiagram-5FMLGOSQ-Ynazqz1w.js} +1 -1
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Ynazqz1w.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Ynazqz1w.js.gz +0 -0
- package/dist/client/assets/{dagre-GXQ25YYZ-DhTTWuBG.js → dagre-GXQ25YYZ-DfM9ezHp.js} +1 -1
- package/dist/client/assets/dagre-GXQ25YYZ-DfM9ezHp.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-DfM9ezHp.js.gz +0 -0
- package/dist/client/assets/{diagram-S7CK7UJ4-Ds8MxWZY.js → diagram-S7CK7UJ4-B_h8RQqw.js} +1 -1
- package/dist/client/assets/diagram-S7CK7UJ4-B_h8RQqw.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-B_h8RQqw.js.gz +0 -0
- package/dist/client/assets/{diagram-UQ7AKVKN-BUj7vQY5.js → diagram-UQ7AKVKN-pPwb9I5q.js} +1 -1
- package/dist/client/assets/diagram-UQ7AKVKN-pPwb9I5q.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-pPwb9I5q.js.gz +0 -0
- package/dist/client/assets/{diagram-VSXAHHWV-CKKKX8QT.js → diagram-VSXAHHWV-CBpO8J25.js} +1 -1
- package/dist/client/assets/diagram-VSXAHHWV-CBpO8J25.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-CBpO8J25.js.gz +0 -0
- package/dist/client/assets/{diagram-VX7I27RA-nny7llCn.js → diagram-VX7I27RA-DNyQxlf3.js} +1 -1
- package/dist/client/assets/diagram-VX7I27RA-DNyQxlf3.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-DNyQxlf3.js.gz +0 -0
- package/dist/client/assets/{diagram-Z3DM3KII-DY1uLAKN.js → diagram-Z3DM3KII-dAyb1bjd.js} +1 -1
- package/dist/client/assets/diagram-Z3DM3KII-dAyb1bjd.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-dAyb1bjd.js.gz +0 -0
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-CE9OBwSc.js → ebnfDiagram-PWID7BFC-DMacuimR.js} +1 -1
- package/dist/client/assets/ebnfDiagram-PWID7BFC-DMacuimR.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-DMacuimR.js.gz +0 -0
- package/dist/client/assets/{erDiagram-RLTQ6QDP-Ba2unHup.js → erDiagram-RLTQ6QDP-DryfjFD1.js} +1 -1
- package/dist/client/assets/erDiagram-RLTQ6QDP-DryfjFD1.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-DryfjFD1.js.gz +0 -0
- package/dist/client/assets/{flowDiagram-HODETNUW-C4_qq0Cb.js → flowDiagram-HODETNUW-c6F7RHIg.js} +1 -1
- package/dist/client/assets/flowDiagram-HODETNUW-c6F7RHIg.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-c6F7RHIg.js.gz +0 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-C9piJJxc.js → ganttDiagram-EL5Y4UJY-j2F3mG_i.js} +1 -1
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-j2F3mG_i.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-j2F3mG_i.js.gz +0 -0
- package/dist/client/assets/{gestureArbiter-DuZwkHF0.js → gestureArbiter-BKuMofhC.js} +1 -1
- package/dist/client/assets/gestureArbiter-BKuMofhC.js.br +0 -0
- package/dist/client/assets/gestureArbiter-BKuMofhC.js.gz +0 -0
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-CHKtPIr2.js → gitGraphDiagram-WWUBYQGX-wHkJC0Y4.js} +1 -1
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-wHkJC0Y4.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-wHkJC0Y4.js.gz +0 -0
- package/dist/client/assets/{index-t8Mh8TuP.css → index-DeTcW7aT.css} +1 -1
- package/dist/client/assets/index-DeTcW7aT.css.br +0 -0
- package/dist/client/assets/index-DeTcW7aT.css.gz +0 -0
- package/dist/client/assets/{infoDiagram-27XIBGKW-Dq_Jycxf.js → infoDiagram-27XIBGKW-CMjoG3lb.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-BlUBm6UK.js → ishikawaDiagram-5VMMS53U-Di0_L7ly.js} +1 -1
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-Di0_L7ly.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-Di0_L7ly.js.gz +0 -0
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-Uk9X_Qjo.js → journeyDiagram-3NMN7TZE-Bxe0PyVR.js} +1 -1
- package/dist/client/assets/journeyDiagram-3NMN7TZE-Bxe0PyVR.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-Bxe0PyVR.js.gz +0 -0
- package/dist/client/assets/{kanban-definition-UXKFOSKX-B_FSzUKj.js → kanban-definition-UXKFOSKX-CV4lZYuw.js} +1 -1
- package/dist/client/assets/kanban-definition-UXKFOSKX-CV4lZYuw.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-CV4lZYuw.js.gz +0 -0
- package/dist/client/assets/{layout-DarffDx8.js → layout-Dr592wOu.js} +1 -1
- package/dist/client/assets/layout-Dr592wOu.js.br +0 -0
- package/dist/client/assets/layout-Dr592wOu.js.gz +0 -0
- package/dist/client/assets/{linear-CAT9PhQc.js → linear-C68vc9xn.js} +1 -1
- package/dist/client/assets/{linear-CAT9PhQc.js.br → linear-C68vc9xn.js.br} +0 -0
- package/dist/client/assets/linear-C68vc9xn.js.gz +0 -0
- package/dist/client/assets/{mermaid.core-DVQ8ioL7.js → mermaid.core-2nIFOgS5.js} +5 -5
- package/dist/client/assets/mermaid.core-2nIFOgS5.js.br +0 -0
- package/dist/client/assets/mermaid.core-2nIFOgS5.js.gz +0 -0
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-BvFKP0v8.js → mindmap-definition-YA3MSWOX-DNHcj6nu.js} +1 -1
- package/dist/client/assets/mindmap-definition-YA3MSWOX-DNHcj6nu.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-DNHcj6nu.js.gz +0 -0
- package/dist/client/assets/{passwordBootstrap-CvkenXI7.js → passwordBootstrap-LVdEOMqV.js} +1 -1
- package/dist/client/assets/passwordBootstrap-LVdEOMqV.js.br +0 -0
- package/dist/client/assets/{passwordBootstrap-CvkenXI7.js.gz → passwordBootstrap-LVdEOMqV.js.gz} +0 -0
- package/dist/client/assets/{pegDiagram-XKGWAZYB-D2IrhbK3.js → pegDiagram-XKGWAZYB-H95jp1fe.js} +1 -1
- package/dist/client/assets/pegDiagram-XKGWAZYB-H95jp1fe.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-H95jp1fe.js.gz +0 -0
- package/dist/client/assets/{pieDiagram-E7YTZNPT-DjkoPbvN.js → pieDiagram-E7YTZNPT-CSTb71Ib.js} +1 -1
- package/dist/client/assets/pieDiagram-E7YTZNPT-CSTb71Ib.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-CSTb71Ib.js.gz +0 -0
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-B6y7YJVk.js → quadrantDiagram-AXDQQJYC-Cj0bkb73.js} +1 -1
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-Cj0bkb73.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-Cj0bkb73.js.gz +0 -0
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-B0zcdgZ7.js → railroadDiagram-O6MQD6OU-CaYCI8KZ.js} +1 -1
- package/dist/client/assets/railroadDiagram-O6MQD6OU-CaYCI8KZ.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-CaYCI8KZ.js.gz +0 -0
- package/dist/client/assets/{referenceLongPress-DsXbPK_4.js → referenceLongPress-oAK_YNlu.js} +1 -1
- package/dist/client/assets/referenceLongPress-oAK_YNlu.js.br +0 -0
- package/dist/client/assets/referenceLongPress-oAK_YNlu.js.gz +0 -0
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-D_vSRB6l.js → requirementDiagram-BXWQKSXE-DpvXahus.js} +1 -1
- package/dist/client/assets/requirementDiagram-BXWQKSXE-DpvXahus.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-DpvXahus.js.gz +0 -0
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-DCRHfG7q.js → sankeyDiagram-P5KCCOFB-h5n85VQj.js} +1 -1
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-h5n85VQj.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-h5n85VQj.js.gz +0 -0
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-CbSi7J6V.js → sequenceDiagram-WJ2MYXX4-BHJ1nrRd.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-CbSi7J6V.js.br → sequenceDiagram-WJ2MYXX4-BHJ1nrRd.js.br} +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BHJ1nrRd.js.gz +0 -0
- package/dist/client/assets/{sizeCapture-INFHLROL-vh3eSHbb.js → sizeCapture-INFHLROL-DX2fcAbk.js} +1 -1
- package/dist/client/assets/sizeCapture-INFHLROL-DX2fcAbk.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-DX2fcAbk.js.gz +0 -0
- package/dist/client/assets/{sparkles-CWkaqdcm.js → sparkles-DheyoSzk.js} +1 -1
- package/dist/client/assets/{stateDiagram-D77RDMKH-Cewpo9Nj.js → stateDiagram-D77RDMKH-CC2yYkck.js} +1 -1
- package/dist/client/assets/stateDiagram-D77RDMKH-CC2yYkck.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-CC2yYkck.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-C4wTnOPJ.js +1 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-D_W8ryi7.js → swimlanes-42K2YHIH-_T5qwTlD.js} +1 -1
- package/dist/client/assets/swimlanes-42K2YHIH-_T5qwTlD.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-_T5qwTlD.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-DKcGlYxN.js +8 -0
- package/dist/client/assets/{timeline-definition-24CTP7MA-CmCMrrPG.js → timeline-definition-24CTP7MA-BqFoa3XX.js} +1 -1
- package/dist/client/assets/timeline-definition-24CTP7MA-BqFoa3XX.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-BqFoa3XX.js.gz +0 -0
- package/dist/client/assets/{triangle-alert-Djeo1xe8.js → triangle-alert-BbXTlgzI.js} +1 -1
- package/dist/client/assets/{vennDiagram-4TSXK5OY-CIAyfZB9.js → vennDiagram-4TSXK5OY-CSpiX1Bh.js} +1 -1
- package/dist/client/assets/vennDiagram-4TSXK5OY-CSpiX1Bh.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-CSpiX1Bh.js.gz +0 -0
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-JHK18PKF.js → wardleyDiagram-VM6X3IG4-cGdw8Ed4.js} +1 -1
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-cGdw8Ed4.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-cGdw8Ed4.js.gz +0 -0
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-B9gfTSaV.js → xychartDiagram-S5SC5T6Z-Du4geU5J.js} +1 -1
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-Du4geU5J.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-Du4geU5J.js.gz +0 -0
- package/dist/client/boot-logo.png +0 -0
- package/dist/client/index.html +71 -6
- 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 +48 -14
- package/package.json +1 -1
- package/runtime-manifest.json +3 -3
- package/dist/client/assets/App-Bgmz2KFR.js.br +0 -0
- package/dist/client/assets/App-Bgmz2KFR.js.gz +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-DzqfGdXE.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-DzqfGdXE.js.gz +0 -0
- package/dist/client/assets/DagPlayground-D-blt_ce.js.br +0 -0
- package/dist/client/assets/DagPlayground-D-blt_ce.js.gz +0 -0
- package/dist/client/assets/DiffLab-DolN7Thu.js.br +0 -0
- package/dist/client/assets/DiffLab-DolN7Thu.js.gz +0 -0
- package/dist/client/assets/DiffReview-D93d8aDU.js +0 -1
- package/dist/client/assets/DiffReview-D93d8aDU.js.br +0 -0
- package/dist/client/assets/DiffReview-D93d8aDU.js.gz +0 -0
- package/dist/client/assets/DiffReviewLab-BGAJuFRb.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-BGAJuFRb.js.gz +0 -0
- package/dist/client/assets/DiffViewer-sF09Yuq0.js +0 -37
- package/dist/client/assets/DiffViewer-sF09Yuq0.js.br +0 -0
- package/dist/client/assets/DiffViewer-sF09Yuq0.js.gz +0 -0
- package/dist/client/assets/ModelPreview-BqBbpxd1.js.br +0 -0
- package/dist/client/assets/ModelPreview-BqBbpxd1.js.gz +0 -0
- package/dist/client/assets/RightSidebar-DW9yAEi4.js +0 -1678
- package/dist/client/assets/RightSidebar-DW9yAEi4.js.br +0 -0
- package/dist/client/assets/RightSidebar-DW9yAEi4.js.gz +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-C4A-2OCs.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-C4A-2OCs.js.gz +0 -0
- package/dist/client/assets/app-D83E7C03.js +0 -35
- package/dist/client/assets/app-D83E7C03.js.br +0 -0
- package/dist/client/assets/app-D83E7C03.js.gz +0 -0
- package/dist/client/assets/arc-D9baZTlD.js.br +0 -0
- package/dist/client/assets/arc-D9baZTlD.js.gz +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DENwPPJf.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DENwPPJf.js.gz +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-D5aOKdyM.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-D5aOKdyM.js.gz +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-CBOCvHOL.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-CBOCvHOL.js.gz +0 -0
- package/dist/client/assets/channel-Cmgcruvo.js +0 -1
- package/dist/client/assets/chunk-F27PBJKO-_XEmDjbM.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-_XEmDjbM.js.gz +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-DsG6lLDO.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-DsG6lLDO.js.gz +0 -0
- package/dist/client/assets/chunk-SVP7TREG-CuF6ZXR9.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-CuF6ZXR9.js.gz +0 -0
- package/dist/client/assets/chunk-TICWLB2K-DXcx3LRb.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-DXcx3LRb.js.gz +0 -0
- package/dist/client/assets/classDiagram-ZZMXUADV-DwSIwPNN.js +0 -1
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-DwSIwPNN.js +0 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-ByD4BHe2.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-ByD4BHe2.js.gz +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-BxCxFVsn.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-BxCxFVsn.js.gz +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Dbs_tQyc.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Dbs_tQyc.js.gz +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-DhTTWuBG.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-DhTTWuBG.js.gz +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-Ds8MxWZY.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-Ds8MxWZY.js.gz +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-BUj7vQY5.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-BUj7vQY5.js.gz +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-CKKKX8QT.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-CKKKX8QT.js.gz +0 -0
- package/dist/client/assets/diagram-VX7I27RA-nny7llCn.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-nny7llCn.js.gz +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-DY1uLAKN.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-DY1uLAKN.js.gz +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-CE9OBwSc.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-CE9OBwSc.js.gz +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-Ba2unHup.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-Ba2unHup.js.gz +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-C4_qq0Cb.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-C4_qq0Cb.js.gz +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-C9piJJxc.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-C9piJJxc.js.gz +0 -0
- package/dist/client/assets/gestureArbiter-DuZwkHF0.js.br +0 -0
- package/dist/client/assets/gestureArbiter-DuZwkHF0.js.gz +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-CHKtPIr2.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-CHKtPIr2.js.gz +0 -0
- package/dist/client/assets/index-t8Mh8TuP.css.br +0 -0
- package/dist/client/assets/index-t8Mh8TuP.css.gz +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-BlUBm6UK.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-BlUBm6UK.js.gz +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-Uk9X_Qjo.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-Uk9X_Qjo.js.gz +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-B_FSzUKj.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-B_FSzUKj.js.gz +0 -0
- package/dist/client/assets/layout-DarffDx8.js.br +0 -0
- package/dist/client/assets/layout-DarffDx8.js.gz +0 -0
- package/dist/client/assets/linear-CAT9PhQc.js.gz +0 -0
- package/dist/client/assets/mermaid.core-DVQ8ioL7.js.br +0 -0
- package/dist/client/assets/mermaid.core-DVQ8ioL7.js.gz +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-BvFKP0v8.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-BvFKP0v8.js.gz +0 -0
- package/dist/client/assets/passwordBootstrap-CvkenXI7.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-D2IrhbK3.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-D2IrhbK3.js.gz +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-DjkoPbvN.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-DjkoPbvN.js.gz +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-B6y7YJVk.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-B6y7YJVk.js.gz +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-B0zcdgZ7.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-B0zcdgZ7.js.gz +0 -0
- package/dist/client/assets/referenceLongPress-DsXbPK_4.js.br +0 -0
- package/dist/client/assets/referenceLongPress-DsXbPK_4.js.gz +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-D_vSRB6l.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-D_vSRB6l.js.gz +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-DCRHfG7q.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-DCRHfG7q.js.gz +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-CbSi7J6V.js.gz +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-vh3eSHbb.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-vh3eSHbb.js.gz +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-Cewpo9Nj.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-Cewpo9Nj.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-C1r0741_.js +0 -1
- package/dist/client/assets/swimlanes-42K2YHIH-D_W8ryi7.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-D_W8ryi7.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-BhrvhgDT.js +0 -8
- package/dist/client/assets/timeline-definition-24CTP7MA-CmCMrrPG.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-CmCMrrPG.js.gz +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-CIAyfZB9.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-CIAyfZB9.js.gz +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-JHK18PKF.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-JHK18PKF.js.gz +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-B9gfTSaV.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-B9gfTSaV.js.gz +0 -0
|
@@ -1,1678 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-BqBbpxd1.js","assets/app-D83E7C03.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-t8Mh8TuP.css","assets/App-Bgmz2KFR.js","assets/gestureArbiter-DuZwkHF0.js","assets/gestureArbiter-C2J0D0kV.css","assets/triangle-alert-Djeo1xe8.js","assets/referenceLongPress-DsXbPK_4.js","assets/DiffReview-D93d8aDU.js","assets/sparkles-CWkaqdcm.js","assets/DiffViewer-sF09Yuq0.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-DzqfGdXE.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-DVQ8ioL7.js","assets/purify.es-4eNOHKSq.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a5 as Ar,cL as kt,bh as e,g as lo,cV as Lt,bz as ht,a as Bs,aQ as cu,C as Oi,c as Os,X as qt,cI as no,b5 as Vh,F as Cs,ao as qh,cP as J,b9 as Yh,bb as cl,bc as Xh,bd as du,ba as Ns,aB as Jh,E as Qh,i as Zh,b8 as em,bB as tm,bD as rm,bE as nm,b0 as sm,bC as ld,z as Ct,f as am,L as Nt,w as om,b as im,cK as xi,a$ as cd,ax as dd,at as lm,aF as vi,aG as ud,cW as Is,ak as Ms,aH as cm,cJ as za,bt as dm,cu as fd,az as um,cG as fm,c2 as hm,aK as mm,Q as hd,O as pm,au as md,ay as gm,aD as pd,c4 as bm,s as gd,d as Wa,m as bd,x as uu,af as xm,_ as Us,bY as vm,cT as ym,bo as wm,ai as km}from"./app-D83E7C03.js";import{b as a,r as Yr}from"./dnd-BCFAPC0L.js";import{q as fu,k as Sm,r as xd,v as so,g as jm,V as Rm,P as Cm,o as Nm,i as Mm,M as Em,R as Ui,w as hu,x as $m,S as Jn,D as Lm,e as mu,c as Am,N as pu,A as yi,J as Pm,E as kn,y as Tm,z as Im,I as Dm,K as Fm,B as vd,O as yd,T as wd,H as kd,f as Sd,n as wi,m as Ga,d as _m,s as Bm,l as Om,h as Um,t as Hm,F as jd,C as zm,a as Wm,G as Gm}from"./App-Bgmz2KFR.js";import{a as Rd,S as Cd,b as gu,c as Hi,F as Km}from"./gestureArbiter-DuZwkHF0.js";import{D as zi,C as Ds,L as bu,f as Vm,n as qm}from"./DiffReview-D93d8aDU.js";import{T as Ym,L as co,M as xu,G as Lr}from"./triangle-alert-Djeo1xe8.js";import{S as Hs}from"./sparkles-CWkaqdcm.js";import{C as vu,M as yu}from"./ChangeWalkthroughPanel-DzqfGdXE.js";import{r as wu,s as ku,l as Su,a as Nd,h as Wi,u as Xm,g as Gi,b as ju}from"./DiffViewer-sF09Yuq0.js";import{u as Ru,G as Cu}from"./referenceLongPress-DsXbPK_4.js";const Jm=[["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"}]],Qm=Ar("case-sensitive",Jm);const Zm=[["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"}]],ep=Ar("eye-off",Zm);const tp=[["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"}]],Ki=Ar("eye",tp);const rp=[["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"}]],Vi=Ar("file-text",rp);const np=[["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"}]],sp=Ar("image-plus",np);const ap=[["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"}]],op=Ar("regex",ap);const ip=[["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"}]],lp=Ar("scan",ip);const cp=[["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"}]],dp=Ar("upload",cp);const up=[["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"}]],fp=Ar("whole-word",up);function Md({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(lo,{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 hp(r){let n;try{await Promise.race([r(),new Promise(s=>{n=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(n)}}function mp({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 pp(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 gp(r,n,s,l){return[r.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
|
|
3
|
-
`)}function mx(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 bp(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?gp(r,"",u,m):r,n)}function xp(r,n){return r===n||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function Ed(r,n){return`${r??""}\0${n}`}function vp(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=>xp(b,s)))&&(u+=1)}return{explained:u,stale:d}}function yp({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(Ym,{size:10}):e.jsx(Hs,{size:10})})}function qi({changeStatus:r,auditStatus:n,renderChangeBadge:s}){return e.jsxs("span",{className:"inline-flex items-center gap-1",children:[s(r),e.jsx(yp,{status:n})]})}const Nu="termdock:right-sidebar:diff-change-list-mode:v1";function wp(r){return r==="list"||r==="tree"}function kp(){return ht(Nu,wp)??"tree"}function Sp(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 jp(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=Sp(l.items);return s}function Rp(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 Cp(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(($,M)=>M>f&&$.startsWith("@@ ")),y=S>=0?S:m.length,N=m.slice(f,y),D=N[0]??"",_=b?D===b:!0,B=D||b||N.join(`
|
|
5
|
-
`);_&&!u.has(B)&&(l.push(...N),u.add(B)),f=S}}return l.join(`
|
|
6
|
-
`)}function Np({groups:r,onInsertDiffReference:n}){return r.map(s=>{const l=Cp(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 Mp(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 $d({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:D="Wrap off",desktopLayout:_="split",onInsertDiffReference:B,onReferenceCopied:$,renderPathReference:M,insertedReferenceKey:L,copiedReferenceKey:T,onClearAuditRecord:U,onRefresh:I,localOptions:p,onHunkGitAction:i,error:O,refreshing:C,actionsBusy:V,refreshLabel:ie,refreshTitle:se,walkthroughs:be=[],onWalkthroughNavigate:G,initialDetailScrollTop:X,onDetailScrollPositionChange:A,scrollToKey:F,scrollToKeyNonce:q,externalSwiperRef:ne,onMobileSlideChange:de}){const{t:xe}=kt(),ue=a.useMemo(()=>jp(r),[r]),Ae=a.useMemo(()=>new Map(ue.map(W=>[W.key,W])),[ue]),[E,ee]=a.useState(()=>kp()),[pe,$e]=a.useState(()=>new Set),[Ye,Le]=a.useState({key:null,nonce:0}),Je=ue.find(W=>W.explained>0||W.stale>0)?.key??ue[0]?.key??null,Fe=n&&ue.some(W=>W.key===n)?n:Je,R=a.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:ue.map(Rp)}],[ue]),re=a.useMemo(()=>Np({groups:ue,onInsertDiffReference:B}),[ue,B]),le=a.useRef(Je),Re=a.useRef(s);le.current=Je,Re.current=s,a.useEffect(()=>{!n&&le.current&&Re.current(le.current)},[n]);const Ce=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:D})]}):null,ze=p?.map(W=>e.jsxs("label",{title:W.disabled?xe("rightSidebar.includeUncommittedCurrentBranchOnly"):W.key,className:"inline-flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx("input",{type:"checkbox",checked:W.checked,disabled:C||V||W.disabled&&!W.checked,onChange:Te=>W.onChange(Te.target.checked),className:"accent-primary"}),e.jsxs("span",{children:[W.label," · ",xe("rightSidebar.includeUncommitted"),W.disabled&&e.jsx("span",{className:"block text-[10px]",children:xe("rightSidebar.includeUncommittedCurrentBranchOnly")})]})]},W.key)),ce=O?e.jsx("div",{role:"alert",className:"w-full text-xs text-destructive",children:O}):null,Ee=I?e.jsxs("button",{type:"button",onClick:I,disabled:C||V,title:se??ie,"aria-label":se??ie,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(fu,{size:12,className:C?"animate-spin":""}),ie&&e.jsx("span",{children:ie})]}):null,et=W=>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(Bs,{size:14}),b]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[W,ze,Ee,Ce,ce]})]});if(r.length===0){const W=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?W:e.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[et(null),W]})}const Pe=S||I?({slideToList:W})=>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:W,children:[e.jsx(Bs,{size:14}),d]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[ze,Ee,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:D})]})]}),ce]}):void 0;return e.jsx(zi,{mobile:u,preserveScrollOnUpdate:!!p?.length,desktopLayout:_,backLabel:d,groups:R,selectedKey:Fe,mode:E,onModeChange:W=>{ee(W),W!=="ai"&&Lt(Nu,W)},compact:u,collapsedDirectoryKeys:pe,onToggleDirectory:W=>{$e(Te=>{const Oe=new Set(Te);return Oe.has(W)?Oe.delete(W):Oe.add(W),Oe})},onSelectFile:W=>{s(W.key),Le(Te=>({key:W.key,nonce:Te.nonce+1}))},renderLeading:W=>{const Te=Ae.get(W.key);return e.jsx(qi,{changeStatus:W.status,auditStatus:Te,renderChangeBadge:Oe=>e.jsx(Ds,{status:Oe})})},renderTrailing:W=>{const Te=Ae.get(W.key);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[Te&&e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",Te.additions," -",Te.deletions]}),M?.(W.path,"file")]})},renderDirectoryTrailing:W=>M?.(W,"directory"),renderListHeader:et,aiContent:({slideToDetail:W,fullscreen:Te,toggleFullscreen:Oe})=>be.length>0&&G?e.jsx(vu,{walkthroughs:be,repoRoot:be[0]?.repoRoot,fullscreen:Te,onToggleFullscreen:Oe,onNavigate:St=>{u&&window.requestAnimationFrame(W),G(St)}}):e.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:xe("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:Pe,externalSwiperRef:ne,onMobileSlideChange:de,detailContainerClassName:u?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:X,scrollToKey:F??Ye.key,scrollToKeyNonce:F==null?Ye.nonce:q,onDetailScroll:W=>{Mp(W,Fe,s),A?.(W.scrollTop)},files:re,activePane:!0,wrap:f,renderStreamBadge:(W,Te)=>{const Oe=Ae.get(Te.key);return e.jsx(qi,{changeStatus:W,auditStatus:Oe,renderChangeBadge:St=>e.jsx(Ds,{status:St})})},onInsertDiffReference:B,onReferenceCopied:$,insertedReferenceKey:L,copiedReferenceKey:T,onClearAuditRecord:U,onHunkGitAction:C?void 0:i,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 $p(r){return[...new Set(Array.from(r,Ep))].sort((n,s)=>n.localeCompare(s))}function Lp(r){return r==="event-storm"||r==="reconnected"||r==="directory-rescan"||r==="polling-fallback"}function Ap(r){let n=null;return{applicableEvents:r.filter(l=>{const u=l.type==="rescan-required"&&!Lp(l.reason);return u&&l.reason&&!n&&(n=l.reason),!u}),unavailableReason:n}}const Pp=1400,Tp=1200,Mu=44,Ip=.7;function ki(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function Yi(r){return`termdock:right-sidebar:context-draft-height:${r}:v1`}function Dp(r){try{const n=window.localStorage.getItem(Yi(r)),s=n===null?NaN:Number(n);return Number.isFinite(s)&&s>=Mu?s:null}catch{return null}}function Ld(r,n){try{n===null?window.localStorage.removeItem(Yi(r)):window.localStorage.setItem(Yi(r),String(n))}catch{}}function Ka(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Fp({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,D]=a.useState(null),[_,B]=a.useState(!1),[$,M]=a.useState(()=>Dp(ki())),L=a.useRef($),T=a.useRef(null),U=a.useRef(null),I=a.useRef(r),p=a.useRef(null),i=a.useRef(null),O=!!r.trim(),C=r.trim().split(`
|
|
7
|
-
`)[0]??"",V=/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 E=!1;const ee=ki();return cu().then(pe=>{if(E)return;const $e=pe.contextDraftHeight?.[ee]??null;Ld(ee,$e),L.current=$e,M($e)}).catch(()=>{}),()=>{E=!0}},[]),a.useEffect(()=>{if(l!==void 0&&l>0){const E=p.current;if(!E)return;Ka()||E.focus(),E.setSelectionRange(E.value.length,E.value.length),E.scrollTop=E.scrollHeight}},[l]),a.useEffect(()=>{const E=I.current;I.current=r,!(!n||r.length<=E.length)&&(B(!0),U.current!==null&&window.clearTimeout(U.current),U.current=window.setTimeout(()=>{U.current=null,B(!1)},Tp))},[r,n]),a.useEffect(()=>{if(n)return;const E=p.current;E&&(E.style.height=$!==null?`${$}px`:"")},[r,n,$]),a.useEffect(()=>{if(n)return;const E=p.current;!E||document.activeElement===E||(E.scrollTop=E.scrollHeight)},[r,n]),a.useEffect(()=>{if(n||Ka())return;const E=p.current;!E||document.activeElement===E||(E.focus(),E.setSelectionRange(E.value.length,E.value.length))},[n]);const ie=a.useRef(null);a.useLayoutEffect(()=>{if(!Ka())return;const E=window.visualViewport;if(!E)return;const ee=()=>{const pe=ie.current;if(!pe)return;if(E.height>=window.innerHeight*.75){pe.style.transform="";return}const $e=pe.getBoundingClientRect(),Ye=Math.round(E.height-$e.bottom);pe.style.transform=Ye!==0?`translateY(${Ye}px)`:""};return ee(),E.addEventListener("resize",ee),E.addEventListener("scroll",ee),()=>{E.removeEventListener("resize",ee),E.removeEventListener("scroll",ee),ie.current&&(ie.current.style.transform="")}},[n]);const se=E=>{D(E),T.current!==null&&window.clearTimeout(T.current),T.current=window.setTimeout(()=>{T.current=null,D(null)},Pp)},be=E=>{m(!1),Ka()&&window.requestAnimationFrame(()=>{const ee=p.current;if(!ee)return;ee.focus();const pe=ee.value.length;ee.setSelectionRange(pe,pe),window.requestAnimationFrame(()=>{ee.setSelectionRange(pe,pe)})})},G=()=>{S(),se("inserted")},X=()=>{O&&(y(),se("sent"))},A=E=>{if(E.key==="Escape"){E.preventDefault(),m(!0);return}E.key!=="Enter"||!E.metaKey&&!E.ctrlKey||(E.preventDefault(),X())},F=E=>{E.preventDefault()},q=E=>{E.preventDefault();const ee=p.current;ee&&(i.current={startY:E.clientY,startHeight:ee.getBoundingClientRect().height},E.currentTarget.setPointerCapture?.(E.pointerId))},ne=E=>{const ee=i.current;if(!ee)return;const pe=window.visualViewport?.height??window.innerHeight,$e=Math.round(Math.min(Math.max(ee.startHeight+(ee.startY-E.clientY),Mu),pe*Ip));L.current=$e,M($e)},de=E=>{const ee=ki();Ld(ee,E),no({contextDraftHeight:{[ee]:E}}).catch(()=>{})},xe=()=>{i.current&&(i.current=null,L.current!==null&&de(L.current))},ue=()=>{L.current=null,M(null),de(null)},Ae=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:ie,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:()=>be(),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(Sm,{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)})]}),Ae,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(Oi,{size:12}):e.jsx(xd,{size:12})})]})}):e.jsxs("section",{ref:ie,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:ne,onPointerUp:xe,onPointerCancel:xe,onDoubleClick:ue,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(Os,{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}),Ae]}),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(qt,{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:E=>h(E.target.value),onKeyDown:A,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(so,{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:G,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(jm,{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} · ${V}`,children:[N==="sent"?e.jsx(Oi,{size:11}):e.jsx(xd,{size:11}),e.jsx("span",{children:N==="sent"?s.sent:s.send})]})]})]})})]})}function _p(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 Bp(r,n){const s=r.trim();return s?n?`${s}\r`:/\s$/.test(r)?r:`${s} `:""}const Xi="termdock:right-sidebar:html-view-mode-by-file:v1";function Op(r){return r==="preview"||r==="source"}function Eu(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(Op)}function $u(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function Ad(r,n){const s=$u(r,n);return s?ht(Xi,Eu)?.[s]??"source":"source"}function Up(r,n,s){const l=$u(r,n);if(!l)return;const u=ht(Xi,Eu)??{};Lt(Xi,{...u,[l]:s})}function Hp(r){try{return new URL(r,location.href).pathname.startsWith("/api/")}catch{return!1}}const zp=1500,Pd=256*1024*1024;async function Wp(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>Pd)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>Pd)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 xo(r,n){const s=Hp(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(()=>{Wp(r,f.signal).then(y=>{if(g){URL.revokeObjectURL(y);return}b=y,h(y)}).catch(()=>{g||f.signal.aborted||m.current?.()})},zp);return()=>{g=!0,window.clearTimeout(S),f.abort(),b&&URL.revokeObjectURL(b)}},[s,l,r]),!s||l?r:d}function Si(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 Gp(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,Kp=8,Vp=60,Va=5,Td=.05,qp=900;function Yp(r){return!Number.isFinite(r)||r<=0?qr:Math.min(Kp,qr+Math.floor(r/Vp))}const Xp=350,Jp=6,Qp=90;function Zp({url:r,onLoadError:n}){const s=xo(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),D=a.useRef(!1),_=a.useRef(null),B=a.useRef(null),$=a.useRef(!1),M=a.useRef(1),L=a.useRef(!1),[T,U]=a.useState(0),[I,p]=a.useState(0),[i,O]=a.useState(!1),[C,V]=a.useState(!1),[ie,se]=a.useState(null),[be,G]=a.useState(!1),[X,A]=a.useState(0),[F,q]=a.useState(!1),[ne,de]=a.useState({width:0,height:0}),[xe,ue]=a.useState(qr),[Ae,E]=a.useState(1),[ee,pe]=a.useState(null),$e=a.useRef(qr),Ye=a.useRef(null),Le=a.useCallback(()=>{_.current!==null&&(clearTimeout(_.current),_.current=null)},[]),Je=a.useCallback(()=>{Le();const H=B.current;if(B.current=null,!$.current)return!1;const ae=h.current;if(ae&&(ae.playbackRate=M.current,H))try{ae.releasePointerCapture?.(H.id)}catch{}return $.current=!1,$e.current=qr,G(!1),!0},[Le]);a.useEffect(()=>()=>{b.current!==null&&cancelAnimationFrame(b.current),f.current!==null&&clearTimeout(f.current),Ye.current!==null&&clearTimeout(Ye.current),Le();const H=h.current;H&&$.current&&(H.playbackRate=M.current)},[Le]),a.useEffect(()=>{const H=d.current;if(!H||typeof ResizeObserver>"u")return;const ae=new ResizeObserver(([ve])=>{ve&&de({width:ve.contentRect.width,height:ve.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 ve=h.current;if(!ve)return!1;const We=Number.isFinite(ve.duration)?ve.duration:H,mt=Math.min(Math.max(H,0),We);if(p(mt),Math.abs(ve.currentTime-mt)<1/120)return!1;const ur=ve.fastSeek;return ae&&typeof ur=="function"?ur.call(ve,mt):ve.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=D.current;D.current=!1,N.current=Fe(S.current,!ae)}))},[Fe]),re=a.useCallback(H=>{const ae=m.current,ve=h.current;if(!ae||!ve)return;const We=ae.getBoundingClientRect(),mt=Gp(H,We,ve.duration);S.current=mt,se(mt),D.current=!1,R(),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,D.current=!0,R()},Qp)},[R]),le=a.useCallback(()=>{b.current!==null&&(cancelAnimationFrame(b.current),b.current=null),f.current!==null&&(clearTimeout(f.current),f.current=null),D.current=!1,N.current=!1,Fe(S.current)},[Fe]),Re=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,V(!0);try{H.currentTarget.setPointerCapture(H.pointerId)}catch{}re(H.clientX)}},[re]),Ce=a.useCallback(()=>{y.current=!1,le(),V(!1),se(null);const H=h.current;H&&g.current&&!H.ended&&H.play().catch(()=>{}),g.current=!1},[le]),ze=a.useCallback(()=>{const H=h.current;if(H){if(L.current){L.current=!1;return}H.paused?H.play().catch(()=>{}):H.pause()}},[]),ce=a.useCallback(H=>{const ae=h.current;if(!ae)return;const ve=Math.min(1,Math.max(0,Math.round((ae.volume+H)*100)/100));ae.volume=ve,ve>0&&(ae.muted=!1),E(ve),pe(ve),Ye.current!==null&&clearTimeout(Ye.current),Ye.current=setTimeout(()=>{Ye.current=null,pe(null)},qp)},[]),Ee=a.useCallback(H=>{const ae=h.current;if(ae){if(H.key==="ArrowLeft"){H.preventDefault(),Fe(ae.currentTime-(H.shiftKey?Va*2:Va));return}if(H.key==="ArrowRight"){H.preventDefault(),Fe(ae.currentTime+(H.shiftKey?Va*2:Va));return}if(H.key==="ArrowUp"){H.preventDefault(),ce(Td);return}if(H.key==="ArrowDown"){H.preventDefault(),ce(-Td);return}(H.key===" "||H.key==="Spacebar"||H.key==="k"||H.key==="K")&&(H.preventDefault(),ae.paused?ae.play().catch(()=>{}):ae.pause())}},[Fe,ce]),et=a.useCallback(H=>{const ae=h.current;!ae||ae.paused||H.button!==0||(Le(),B.current={id:H.pointerId,x:H.clientX,y:H.clientY},_.current=setTimeout(()=>{_.current=null;const ve=B.current;if(M.current=ae.playbackRate,ae.playbackRate=qr,$e.current=qr,ue(qr),$.current=!0,G(!0),ve)try{ae.setPointerCapture?.(ve.id)}catch{}},Xp))},[Le]),Pe=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)>Jp&&(Le(),B.current=null);return}const ve=Yp(H.clientX-ae.x);if(ve===$e.current)return;$e.current=ve,ue(ve);const We=h.current;We&&(We.playbackRate=ve)},[Le]),W=a.useCallback(()=>{Je()&&(L.current=!0)},[Je]);a.useEffect(()=>(window.addEventListener("pointerup",W),window.addEventListener("pointercancel",W),window.addEventListener("blur",W),()=>{window.removeEventListener("pointerup",W),window.removeEventListener("pointercancel",W),window.removeEventListener("blur",W)}),[W]);const Te=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?.()}},[]),Oe=a.useCallback(()=>A(H=>(H+90)%360),[]),St=a.useCallback(H=>{const ae=h.current;if(!ae||!Number.isFinite(ae.duration))return;const ve=H.shiftKey?10:5;let We=null;H.key==="ArrowLeft"?We=ae.currentTime-ve:H.key==="ArrowRight"?We=ae.currentTime+ve:H.key==="Home"?We=0:H.key==="End"&&(We=ae.duration),We!==null&&(H.preventDefault(),Fe(We))},[Fe]),tt=C&&ie!==null?ie:I,dt=T>0?Math.min(1,Math.max(0,tt/T)):0,_t=(X===90||X===270)&&ne.width>0&&ne.height>0?{width:`${ne.height}px`,height:`${ne.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${be?` ${Rd}`:""}`,style:{..._t,transform:`translate(-50%, -50%) rotate(${X}deg)`},src:s,preload:"auto",playsInline:!0,tabIndex:0,...be?{[Cd]:""}:{},onClick:ze,onKeyDown:Ee,onVolumeChange:H=>E(H.currentTarget.volume),onPointerDown:et,onPointerMove:Pe,onPointerUp:W,onPointerCancel:W,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 ve=ae.requestVideoFrameCallback;typeof ve=="function"?ve.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")}),be&&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(xe)})}),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(Rm,{size:13}),l("rightSidebar.videoVolume",{percent:Math.round(Ae*100)})]}),C&&ie!==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:Si(ie)})]}),e.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${Rd}`,[Cd]:"",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:ze,"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(Cm,{size:14}):e.jsx(Nm,{size:14})}),e.jsxs("div",{ref:m,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(T),"aria-valuenow":Math.floor(tt),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:Re,onPointerMove:H=>{C&&re(H.clientX)},onPointerUp:Ce,onPointerCancel:Ce,onKeyDown:St,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:[Si(tt)," / ",Si(T)]}),e.jsx("button",{type:"button",onClick:Oe,"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(fu,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{Te()},"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(Mm,{size:14}):e.jsx(Em,{size:14})})]})})]})}function eg(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 vo({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:eg(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(co,{size:11}),n]})}function tg(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 rg(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 ng(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 sg(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 Lu({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),[D,_]=a.useState(null),B=a.useRef(new Map),$=a.useRef(null),M=a.useRef(!1),L=a.useRef(null),T=a.useRef(f);T.current=f,a.useEffect(()=>{const A=new AbortController;return m(null),b(null),_(null),S(1),fetch(r,{signal:A.signal}).then(F=>F.text()).then(F=>m(ng(F))).catch(F=>{A.signal.aborted||b(F instanceof Error?F.message:"SVG preview failed")}),()=>A.abort()},[r]),a.useEffect(()=>{if(!y)return;const A=F=>{F.key==="Escape"&&N(!1)};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[y]),a.useLayoutEffect(()=>{const A=d.current,F=A?.querySelector("[data-svg-document] > svg");if(!A||!F)return;let q;try{q=F.getBBox()}catch{return}if(!q.width||!q.height)return;const ne=Math.max(2,Math.min(q.width,q.height)*.025);F.setAttribute("viewBox",`${q.x-ne} ${q.y-ne} ${q.width+2*ne} ${q.height+2*ne}`),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(()=>D?rg(n,s,D):null,[n,D,s]),I=A=>{if(M.current){M.current=!1;return}const F=d.current,q=F?.querySelector("[data-svg-document] > svg"),ne=u.current;if(!F||!q||!ne)return;const de=q.viewBox.baseVal,xe=tg(A.clientX,A.clientY,q.getBoundingClientRect(),de);if(!xe)return;const ue=ne.getBoundingClientRect();_({...xe,nearestText:sg(q,xe.x,xe.y),stageX:A.clientX-ue.left,stageY:A.clientY-ue.top,stageXPercent:(A.clientX-ue.left)/ue.width*100,stageYPercent:(A.clientY-ue.top)/ue.height*100})},p=A=>Math.max(1,Math.min(12,A)),i=(A,F)=>{const q=p(F),ne=A.querySelector("[data-svg-document] > svg");if(!ne)return q;const de=`${q*100}%`;return ne.style.width=de,ne.style.height=de,ne.style.minWidth=de,ne.style.minHeight=de,T.current=q,q},O=(A,F,q,ne)=>{const de=T.current,xe=A.getBoundingClientRect(),ue=q-xe.left,Ae=ne-xe.top,E=(A.scrollLeft+ue)/de,ee=(A.scrollTop+Ae)/de,pe=i(A,F);return A.scrollLeft=E*pe-ue,A.scrollTop=ee*pe-Ae,pe},C=()=>{const A=Array.from(B.current.values());return A.length>=2?Math.hypot(A[0].x-A[1].x,A[0].y-A[1].y):0},V=A=>{if(A.pointerType==="mouse"&&A.button!==0)return;const F=d.current;F&&(B.current.set(A.pointerId,{x:A.clientX,y:A.clientY}),F.setPointerCapture?.(A.pointerId),B.current.size>=2?($.current={kind:"pinch",startX:A.clientX,startY:A.clientY,startScrollLeft:F.scrollLeft,startScrollTop:F.scrollTop,startDistance:C(),startZoom:T.current,moved:!1},M.current=!0):T.current>1&&($.current={kind:"pan",startX:A.clientX,startY:A.clientY,startScrollLeft:F.scrollLeft,startScrollTop:F.scrollTop,startZoom:T.current,moved:!1}))},ie=A=>{if(!B.current.has(A.pointerId))return;B.current.set(A.pointerId,{x:A.clientX,y:A.clientY});const F=d.current,q=$.current;if(!(!F||!q)){if(B.current.size>=2&&q.kind==="pinch"){const ne=C();if(!q.startDistance||!ne)return;const de=p(q.startZoom*ne/q.startDistance);if(Math.abs(de-T.current)<.01)return;const xe=Array.from(B.current.values()),ue=(xe[0].x+xe[1].x)/2,Ae=(xe[0].y+xe[1].y)/2;q.moved=!0,M.current=!0,O(F,de,ue,Ae),A.preventDefault();return}if(q.kind==="pan"&&B.current.size===1){const ne=A.clientX-q.startX,de=A.clientY-q.startY;if(!q.moved&&Math.hypot(ne,de)<6)return;q.moved=!0,M.current=!0,F.scrollLeft=q.startScrollLeft-ne,F.scrollTop=q.startScrollTop-de,A.preventDefault()}}},se=A=>{const F=d.current,q=$.current,ne=B.current.size===1&&!q?.moved;B.current.delete(A.pointerId);try{F?.releasePointerCapture?.(A.pointerId)}catch{}if(B.current.size===1&&q?.kind==="pinch"){const ue=Array.from(B.current.values())[0];$.current=F?{kind:"pan",startX:ue.x,startY:ue.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),!ne||M.current))return;const de=Date.now(),xe=L.current;xe&&de-xe.time<350&&Math.hypot(A.clientX-xe.x,A.clientY-xe.y)<24?(L.current=null,M.current=!0,S(ue=>ue>1?1:2.5)):L.current={time:de,x:A.clientX,y:A.clientY}},be=A=>{if(!A.ctrlKey&&!A.metaKey)return;const F=d.current;if(!F)return;A.preventDefault();const q=O(F,T.current*Math.exp(-A.deltaY*.01),A.clientX,A.clientY);S(q)},G=()=>{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:I,onDoubleClick:A=>{A.preventDefault(),S(F=>F>1?1:2.5)},onPointerDown:V,onPointerMove:ie,onPointerUp:se,onPointerCancel:se,onWheel:be,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…"})}),D&&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:D.stageX,top:D.stageY}}),D&&U&&e.jsx(vo,{anchor:{xPercent:D.stageXPercent,yPercent:D.stageYPercent},title:"引用 SVG 标注",onClick:()=>{l?.(U,`svg:${D.x.toFixed(2)}:${D.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:A=>{A.stopPropagation(),G()},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(lp,{size:14})}),e.jsx("button",{type:"button","aria-label":y?"退出全屏 SVG":"全屏 SVG",title:y?"退出全屏 SVG":"全屏 SVG",onClick:A=>{A.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(yu,{size:14}):e.jsx(xu,{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:D?`SVG (${D.x.toFixed(2)}, ${D.y.toFixed(2)}) · ${D.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return y?Yr.createPortal(X,document.body):X}function ao(r){switch(r){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function ag(r,n,s,l){const u=[`电子标注: ${r}`,`视图: ${ao(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 og({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),[D,_]=a.useState(!1);a.useEffect(()=>(S.current?.abort(),N(null),_(!1),()=>S.current?.abort()),[r,s]);const B=a.useMemo(()=>y?ag(n,s,y,y.inspection):null,[n,y,s]),$=L=>{const T=b.current,U=f.current;if(!T||!U||!U.naturalWidth||!U.naturalHeight)return;const I=T.getBoundingClientRect(),p=U.getBoundingClientRect(),i=Math.min(p.width/U.naturalWidth,p.height/U.naturalHeight),O=U.naturalWidth*i,C=U.naturalHeight*i,V=p.left+(p.width-O)/2,ie=p.top+(p.height-C)/2,se=L.clientX-V,be=L.clientY-ie;if(se<0||be<0||se>O||be>C)return;const G={xPercent:Math.max(0,Math.min(100,se/O*100)),yPercent:Math.max(0,Math.min(100,be/C*100)),stageXPercent:(L.clientX-I.left)/I.width*100,stageYPercent:(L.clientY-I.top)/I.height*100,inspecting:l&&s!=="pcb-3d"};if(N(G),S.current?.abort(),!G.inspecting)return;const X=new AbortController;S.current=X,Vh(n,s,G.xPercent,G.yPercent,X.signal).then(A=>N(F=>F===G?{...F,inspection:A,inspecting:!1}:F)).catch(()=>{X.signal.aborted||N(A=>A===G?{...A,inspection:{available:!1},inspecting:!1}:A)})},M=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:M.map(L=>e.jsx("button",{type:"button",onClick:()=>u(L),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${L===s?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:ao(L)},L))}),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(Ui,{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:L=>{L.key!=="Enter"&&L.key!==" "||(L.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} ${ao(s)}`,onLoad:()=>_(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${D?"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(vo,{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?pp(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(Lu,{blobUrl:r,filePath:n,viewLabel:ao(s),onInsertAnnotation:d})})]})}function ig(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 lg(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 cg({content:r,filePath:n,onInsertAnnotation:s}){const{t:l}=kt(),u=a.useMemo(()=>ig(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?lg(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((D,_)=>{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 M=m.current?.getBoundingClientRect(),L=$.currentTarget.getBoundingClientRect();if(!M?.width||!M.height)return;const T=$.clientX||L.left+L.width/2,U=$.clientY||L.top+L.height/2;b({row:N,column:_,xPercent:(T-M.left)/M.width*100,yPercent:(U-M.top)/M.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(vo,{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 Yn(r,n){let s=r;for(const l of n){if(!s||typeof s!="object")return;s=s[l]}return s}function dg(r,n){const s=JSON.parse(r),l=Yn(s,["meta","version"]);if(n)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(l??"未知")},{label:"活动层编号",value:String(Yn(s,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(Yn(s,["board","visible_layers"])??"未知")},{label:"Git 集成",value:Yn(s,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const u=Yn(s,["net_settings","classes"]),d=Array.isArray(u)?u.find(m=>m&&typeof m=="object"&&m.name==="Default"):void 0,h=Yn(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 ug(r,n){return`"KiCad项目标注: ${r} / 项: ${n.label} / 值: ${n.value}"`}function fg({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:dg(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(),D=y.currentTarget.getBoundingClientRect();if(!N?.width||!N.height)return;const _=y.clientX||D.left+D.width/2,B=y.clientY||D.top+D.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(vo,{anchor:{xPercent:h.xPercent,yPercent:h.yPercent},title:u("rightSidebar.kicadInsertSetting"),onClick:()=>{l?.(ug(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 hg=`/** 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
|
-
`,mg=`/* 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
|
-
`,qa="/api/terminal/fs/preview/",pg=8*1024*1024,gg=32*1024*1024,bg=128,xg="data:,";function $t(r){throw new Error(r)}function vg(r){return JSON.stringify(r).replace(/</g,"\\u003c")}async function Id(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 Au(r,n){const s=n.origin??location.origin,l=new URL(r,s);(l.origin!==s||!Cs(l.pathname)?.startsWith(qa))&&$t("预览地址不是有效的本地文件入口");const u=crypto.randomUUID(),d=`https://termdock-preview.invalid/${u}/`,h=[],m=G=>{!h.includes(G)&&h.length<20&&h.push(G)},g=new Set,b=[],f=new Set,S=new Map,y=new Map;let N=0,D=!1;const _=new Set,B=()=>{D=!0;for(const G of[..._])G();g.clear(),b.length=0};async function $(G){G.ok||$t(`预览资源读取失败(${G.status})`);const X=G.body?.getReader(),A=[];let F=0;try{if(X)for(;;){const de=await X.read();if(de.done)break;F+=de.value.byteLength,N+=de.value.byteLength,(F>pg||N>gg)&&$t("预览资源超出大小限制"),A.push(de.value)}}catch(de){throw await X?.cancel().catch(()=>{}),de}finally{X?.releaseLock()}const q=new Uint8Array(F);let ne=0;for(const de of A)q.set(de,ne),ne+=de.length;return{bytes:q,type:G.headers.get("content-type")??"application/octet-stream",status:G.status}}let M=l,L;for(let G=0;G<4;G++){const X=await n.fetch(M.pathname+M.search,{signal:n.signal,redirect:"manual"});if(![301,302,303,307,308].includes(X.status)){L=X;break}const A=X.headers.get("location");await X.body?.cancel(),A||$t("预览重定向缺少目标");const F=new URL(A,M);(F.origin!==s||!Cs(F.pathname)?.startsWith(qa))&&$t("预览重定向越出文件范围"),M=F}L||$t("预览重定向次数过多");const T=Cs(M.pathname),U=T.slice(qa.length).split("/");/^[a-f0-9]{32}$/.test(U[0])||$t("服务未提供有效的预览资源授权");const I=Cs(l.pathname).slice(qa.length).split("/");/^[a-f0-9]{32}$/.test(I[0])&&I.shift(),I.join("/").replace(/\/$/,"")!==U.slice(1).join("/").replace(/\/$/,"")&&$t("预览重定向改变了文件范围");const p=T.endsWith("/")?T:T.slice(0,T.lastIndexOf("/")+1),i=new URL(M.pathname.endsWith("/")?M.pathname:M.pathname.slice(0,M.pathname.lastIndexOf("/")+1),s);function O(G,X){const A=new URL(G,X);return A.origin!==s?null:(Cs(A.pathname)?.startsWith(p)||$t("已阻止预览访问目录之外的资源"),A)}function C(G){const X=new URL(G,d);(X.origin!==new URL(d).origin||!X.pathname.startsWith(new URL(d).pathname))&&$t("已阻止预览访问服务接口或目录之外的资源");const A=X.pathname.slice(new URL(d).pathname.length)+X.search;return O(A,i)??$t("预览资源无效")}function V(G){const X=G.pathname+G.search,A=S.get(X);if(A)return A;if(D||n.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(S.size>=bg)return Promise.reject(new Error("预览资源数量超出限制"));const F=n.fetch(X,{signal:n.signal,redirect:"manual"}).then($);return S.set(X,F),F}function ie(G,X){D&&$t("预览已关闭");const A=`termdock-resource-${u}-${b.length}`;return b.push({token:A,data:G,type:X}),g.add(A),A}async function se(G,X,A,F=new Set){if(!G||G.startsWith("#")||/^data:(?:image|font)\//i.test(G)&&A==="resource")return G;try{const q=O(G,X);if(!q){const Ae=new URL(G,X);return(Ae.protocol!=="https:"||Ae.username||Ae.password||Ae.origin===new URL(d).origin)&&$t("已阻止不安全的外部资源"),f.add(Ae.origin),Ae.href}const ne=`${A}:${q.href}`;(F.has(ne)||F.size>=8)&&$t("预览资源存在循环或过深引用");const de=y.get(ne);if(de)return de;const xe=new Set(F);xe.add(ne);const ue=(async()=>{const Ae=await V(q);return A==="css"?ie(await be(new TextDecoder().decode(Ae.bytes),q,xe),"text/css"):A==="script"?ie(Ae.bytes,"text/javascript"):ie(Ae.bytes,Ae.type)})();return y.set(ne,ue),await ue}catch(q){return m(q instanceof Error?q.message:"部分预览资源未能加载"),xg}}async function be(G,X,A){return G=await Id(G,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async F=>`@import url("${await se(F[1],X,"css",A)}")${F[2]};`),Id(G,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async F=>{const q=(F[1]??F[2]??F[3]).trim();return g.has(q)?F[0]:`url("${await se(q,X,"resource",A)}")`})}try{const G=await $(L),X=ie(hg,"text/javascript"),A=new DOMParser().parseFromString(new TextDecoder().decode(G.bytes),"text/html");A.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(E=>E.remove());for(const E of A.querySelectorAll("*")){if(E.removeAttribute("ping"),E.removeAttribute("srcdoc"),E.hasAttribute("style")&&E.setAttribute("style",await be(E.getAttribute("style"),M,new Set)),E.tagName==="STYLE"&&(E.textContent=await be(E.textContent??"",M,new Set)),E.tagName==="A"||E.tagName==="AREA"){const ee=E.getAttribute("href");try{if(ee&&!ee.startsWith("#")){const pe=O(ee,M);if(pe)E.setAttribute("href",new URL(pe.pathname.slice(i.pathname.length)+pe.search+pe.hash,d).href);else{const $e=new URL(ee,M);if($e.protocol!=="https:"){E.removeAttribute("href");continue}f.add($e.origin),E.setAttribute("href",$e.href)}}}catch(pe){E.removeAttribute("href"),m(pe instanceof Error?pe.message:"预览链接无法加载")}}for(const ee of["data","manifest"])E.removeAttribute(ee);if(E.tagName==="SCRIPT"&&E.getAttribute("type")==="module"){E.setAttribute("type","module-shim");const ee=E.getAttribute("src");if(ee){const pe=O(ee,M);if(pe)E.setAttribute("src",new URL(pe.pathname.slice(i.pathname.length)+pe.search,d).href);else{const $e=new URL(ee,M);if($e.protocol!=="https:"){E.remove();continue}f.add($e.origin),E.setAttribute("src",$e.href)}}continue}if(E.tagName==="SCRIPT"&&E.getAttribute("type")==="importmap"){E.setAttribute("type","importmap-shim");continue}if(E.tagName==="LINK"){const ee=(E.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(ee)){E.remove();continue}const pe=E.getAttribute("href");pe&&E.setAttribute("href",await se(pe,M,ee==="stylesheet"?"css":"resource"))}if(E.hasAttribute("src")&&E.setAttribute("src",await se(E.getAttribute("src"),M,E.tagName==="SCRIPT"?"script":"resource")),E.hasAttribute("poster")&&E.setAttribute("poster",await se(E.getAttribute("poster"),M,"resource")),E.hasAttribute("srcset")){const ee=E.getAttribute("srcset");/data:/i.test(ee)?(E.removeAttribute("srcset"),m("混合内嵌图片候选暂不支持安全预览")):E.setAttribute("srcset",(await Promise.all(ee.split(",").map(async pe=>{const[$e,...Ye]=pe.trim().split(/\s+/);return`${await se($e,M,"resource")} ${Ye.join(" ")}`}))).join(", "))}E.setAttribute("referrerpolicy","no-referrer"),E.removeAttribute("integrity"),E.removeAttribute("crossorigin")}const F=[...f].join(" "),q=A.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(E=>E.replace(/^https:/,"wss:")).join(" ")}; worker-src blob:; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const ne=A.createElement("base");ne.href=d;const de=A.createElement("meta");de.name="referrer",de.content="no-referrer";const xe=A.createElement("script");xe.textContent=mg+`
|
|
1636
|
-
installPreviewRuntime(`+[u,d,[...f],X].map(vg).join(",")+");";const ue=A.createElement("script");ue.src=X,A.head.prepend(q,de,ne,xe,ue);const Ae=`<!doctype html>
|
|
1637
|
-
`+A.documentElement.outerHTML;return{html:Ae,shellUrl:`/preview-shell.html#${u}`,errors:h,attach(E,ee){const pe=new Set,$e=Le=>{if(Le.source!==E.contentWindow||Le.data?.capability!==u)return;if(Le.data.type==="preview-ready"){E.contentWindow?.postMessage({type:"preview-init",capability:u,html:Ae,resources:b},"*");return}if(Le.data.type==="preview-error"){ee("部分动态内容被安全预览限制");return}if(Le.data.type==="preview-navigate"){(async()=>{const Fe=C(String(Le.data.url)),R=await Au(Fe.pathname+Fe.search,n);if(D){R.dispose();return}const re=R.attach(E,ee);_.add(()=>{re(),R.dispose()}),E.src=R.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(Fe=>ee(Fe instanceof Error?Fe.message:"无法打开预览页面"));return}if(Le.data.type==="preview-external"){try{const Fe=new URL(String(Le.data.url));Fe.protocol==="https:"&&f.has(Fe.origin)&&window.open(Fe.href,"_blank","noopener,noreferrer")}catch{}return}if(Le.data.type!=="preview-fetch"||Le.ports.length!==1)return;const Je=Le.ports[0];if(pe.size>=8||!["GET","HEAD"].includes(Le.data.method)){Je.postMessage({error:"预览仅允许读取已授权目录资源"}),Je.close();return}pe.add(Je),(async()=>{const Fe=C(String(Le.data.url)),R=await V(Fe);if(!pe.has(Je)||D)return;const re=Le.data.method==="HEAD"?new Uint8Array:R.bytes.slice();Je.postMessage({status:R.status,headers:{"content-type":R.type},data:re.buffer},[re.buffer])})().catch(()=>{Je.postMessage({error:"预览资源不在授权范围或无法加载"}),ee("部分动态资源不可用或超出预览目录")}).finally(()=>{pe.delete(Je),Je.close()})};window.addEventListener("message",$e);const Ye=()=>{window.removeEventListener("message",$e);for(const Le of pe)Le.close();pe.clear(),_.delete(Ye)};return _.add(Ye),Ye},dispose:B}}catch(G){throw B(),G}}const yg=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 I=await qh();if(U=await Au(n,{fetch:(p,i)=>I.fetch(p,i),signal:T.signal}),T.signal.aborted){U.dispose();return}f(U),U.errors.length&&y(U.errors.join(";"))})().catch(I=>{T.signal.aborted||y(I instanceof Error?I.message:"安全预览加载失败")}),()=>{T.abort(),U?.dispose()}},[n]),a.useEffect(()=>{if(!(!b||!m))return b.attach(m,y)},[b,m]);const[N,D]=a.useState(!1),[_,B]=a.useState(!1),$=N||_;a.useEffect(()=>{u?.($)},[$,u]),a.useEffect(()=>{const T=()=>{D(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 M=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:M}),[M]);const L=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:()=>{M()},"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(yu,{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(L,document.body):L}),Pu="termdock-file-search-match",Ji="termdock-file-search-current";function wg(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 kg(r){return r.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function Sg(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=kg(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(D=>D.start<=f&&D.end>f),N=l.find(D=>D.start<S&&D.end>=S);if(y&&N&&y.group===N.group){const D=document.createRange();D.setStart(y.node,f-y.start),D.setEnd(N.node,S-N.start),g.push(D)}b=f+Math.max(s.length,1)}return g}function Tu(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function Ya(){const r=Tu();r?.delete(Pu),r?.delete(Ji)}function Dd(r,n){const s=Tu();if(!s||typeof Highlight>"u")return;s.set(Pu,new Highlight(...r));const l=r[n];l?s.set(Ji,new Highlight(l)):s.delete(Ji)}function Fd(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function jg(r){return Array.from(new Set(r.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Rg(r,n){const s=n.trim();return!s||s==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Cg(r,n){if(n===r)return".";const s=`${r.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function Iu(r,n,s){return n?r:Yr.createPortal(r,s)}const dl="termdock:right-sidebar:file-tree-scroll:v1",ul="termdock:right-sidebar:file-preview-reading-state:v1",Ps="termdock:right-sidebar:file-tree-width:v1",Du="termdock:right-sidebar:markdown-view-mode:v1",Fu="termdock:right-sidebar:diff-change-list-mode:v1",_u="termdock:right-sidebar:diff-wrap:v1",Bu="termdock:diff-viewer:view-type:v1",Ou="termdock:right-sidebar:file-search-mode:v1",ji="termdock:right-sidebar:collapsed-git-repo-groups:v1",_d="termdock:right-sidebar:collapsed-diff-directories:v1",Ri="termdock:right-sidebar:branch-audit-module-open:v1",Uu="termdock:right-sidebar:branch-audit-module:v1",Ng=150,Bd="termdock:right-sidebar:context-draft-enabled:v1",Od="termdock:right-sidebar:context-draft-collapsed:v1",Ud="termdock:right-sidebar:context-draft-auto-collapse:v1",Ci="termdock:right-sidebar:context-draft-text:v1",Mg=300,Eg=20,$g=120,Lg=250,Ag=250,Pg=120,Tg=700,Ni=600,Ig=6e4;function Es(r){return!!(r&&J.getState().nestedGitScanRoots[r])}const Hd=[2e3,5e3,15e3,3e4],Dg=320,Fg=500,_g=20,Bg=12e3,Qi=300,zd=240,Og=560,Hu="border-r px-2 py-1.5 sm:px-3 sm:py-2",uo="min-w-full max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",zu=`${Hu} border-b border-border/15 font-semibold last:border-r-0`,Wu=`${Hu} border-border/10 align-top text-muted-foreground last:border-r-0`,fl="termdock-file-preview-horizontal-scroll",Wd=a.lazy(()=>Us(()=>import("./ModelPreview-BqBbpxd1.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Gu=`${fl} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function Ku(r,n,s){return r&&!n?"unified":s}const Ug=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function Hg(r){return r==="preview"||r==="source"}function zg(r){return r==="list"||r==="tree"||r==="ai"}function Gd(){return ht(Du,Hg)??"preview"}function Wg(){return ht(Fu,zg)??"tree"}function Ts(r){return typeof r=="boolean"}function Gg(r){return typeof r=="string"}function Kg(){return ht(_u,Ts)??!0}function Vg(r){return r==="unified"||r==="split"}function qg(){return ht(Bu,Vg)??"unified"}function Yg(r){return r==="name"||r==="content"||r==="regex"}function Xg(){return ht(Ou,Yg)??"name"}function Vu(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 Jg(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 Zi(r){return!r.activeGitRepoRoot&&(r.groupCount>1||r.label!==r.rootName)}function qu(...r){const n=new Set;for(const s of r)for(const l of s)n.add(l.root);return n}function el(r){return Array.isArray(r)&&r.every(n=>typeof n=="string")}function Kd(r){const n=ht(r,el);return n?new Set(n):new Set}function Mi(r,n){Lt(r,[...n])}function Qg(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 Zg(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||el(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(Qg))&&(n.commits===void 0||el(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 eb(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.key=="string"&&Zg(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function tb(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(eb))&&(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 Vd(){return ht(Uu,tb)??{}}function qd(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function Yd(r){const n=r?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function Yu(r,n){const s=r?.trim(),l=n?.trim();return!s||!l?!1:s===l||Yd(s)===Yd(l)}function Xd(r){const n=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(l=>l&&!Yu(l,n))??""}function tl(r,n){const s=Math.max(zd,n-320),l=Math.min(Og,s);return Math.min(l,Math.max(zd,r))}function rb(r){return typeof r=="number"&&Number.isFinite(r)}function nb(r){return tl(ht(Ps,rb)??Qi,r)}function Xu(r){const n=r.split(/[\\/]/).pop()??r,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function $s(r){return Ug.has(Xu(r))}function Ju(r){const n=r.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function rl(r){const n=r.trim();return/^#{1,6}\s+/.test(n)||Ju(r)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function Qu(r){const n=r.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const Zu=a.createContext(null);function oo(r){return r.trim().replace(/\s+/g," ").toLowerCase()}function ef(r){return r.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function tf(r){return r.replace(/\s+#+\s*$/,"").trim()}function nl(r,n){const l=ef(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 Jd(r){return ef(r)||r.trim()}function fo(r){const n=r.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=al(n[2]);return s?{id:oo(n[1]),definition:{href:s.href,title:s.title}}:null}function sb(r){const n=new Map;for(const s of r){const l=fo(s);l&&n.set(l.id,l.definition)}return n}function rf(r){return r.trim().toLowerCase()}function nf(r){const n=r.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:rf(n[1]),text:n[2]}:null}function ab(r){const n=new Map;let s=null;for(const l of r){const u=nf(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 sf(r){const n=new Set;let s=!1;return r.forEach((l,u)=>{if(nf(l)){n.add(u),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(u);return}l.trim()&&(s=!1)}),n}function ob(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 af(r){const n=r.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function Fs(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 hl(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?Fs(s):null;let S;if(g.startsWith("/")){const y=f&&(g===f||g.startsWith(`${f}/`));S=Fs(f&&!y?`${f}/${g.slice(1)}`:g)}else{if(!n)return null;S=Fs(`${af(n)}/${g}`)}return f&&S!==f&&!S.startsWith(`${f}/`)?null:{path:S,fragment:b,directory:/\/$/.test(m)}}function ml(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=Fs(s&&!m?`${s}/${d.slice(1)}`:d)}else{if(!n)return null;h=Fs(`${af(n)}/${d}`)}return u(h)}function ib(r,n,s){return ml(r,n,s,cl,l=>`/api/terminal/fs/blob?path=${encodeURIComponent(l)}`)}function lb(r,n,s){return ml(r,n,s,du,uu)}const sl=128,cb=360,Ei=480;function yo(r){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(r))}catch{return!1}}function of(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):yo(r)?(h=Math.min(Math.max(s,sl),cb),d=n*h/s):(d=n,h=s),l>0&&d>l&&(h=h*l/d,d=l),h>Ei&&(d=d*Ei/h,h=Ei),{width:Math.max(1,Math.round(d)),height:Math.max(1,Math.round(h))}}function db(r){if(!r.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(r.slice(r.indexOf("?"))).get("path")}catch{return null}}function lf(r){const n=db(r),s=J(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${r}&v=${s}`:r}function ub({src:r,alt:n,title:s,requestedWidthPx:l}){const u=yo(r),d=lf(r),h=xo(d),m=a.useRef(null),[g,b]=a.useState(!1),[f,S]=a.useState(0),[y,N]=a.useState({status:"loading"}),[D,_]=a.useState(null);a.useLayoutEffect(()=>{const M=m.current,L=M?.parentElement?.parentElement??M?.parentElement;if(!L)return;const T=()=>S(L.clientWidth);if(T(),typeof ResizeObserver>"u")return;const U=new ResizeObserver(T);return U.observe(L),()=>U.disconnect()},[]),a.useEffect(()=>{if(g)return;const M=m.current;if(!M||typeof IntersectionObserver>"u"){b(!0);return}const L=new IntersectionObserver(T=>{T.some(U=>U.isIntersecting)&&(b(!0),L.disconnect())},{rootMargin:"400px"});return L.observe(M),()=>L.disconnect()},[g]),a.useEffect(()=>{if(!g)return;const M=new AbortController;let L=null;N({status:"loading"});const T=window.setTimeout(()=>{M.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return km(d,{signal:M.signal}).then(async U=>{if(!U.ok)throw new Error(`HTTP ${U.status}`);const I=Number(U.headers.get("X-Image-Width"))||0,p=Number(U.headers.get("X-Image-Height"))||0;return{blob:await U.blob(),width:I,height:p}}).then(({blob:U,width:I,height:p})=>{M.signal.aborted||(L=URL.createObjectURL(U),I>0&&p>0&&_({width:I,height:p}),N({status:"ready",objectUrl:L}))}).catch(()=>{const U=M.signal.reason;M.signal.aborted&&!(U instanceof DOMException&&U.name==="TimeoutError")||N({status:"fallback"})}).finally(()=>{window.clearTimeout(T)}),()=>{window.clearTimeout(T),M.abort(),L&&URL.revokeObjectURL(L)}},[g,d]);const B=of(r,D?.width??0,D?.height??0,f,l??0),$=B??(l?{width:f>0?Math.min(l,f):l,height:Math.round(l*.75)}:{width:sl*2,height:sl});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:M=>{if(D)return;const L=M.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&_({width:L.naturalWidth,height:L.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:M=>{if(D)return;const L=M.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&_({width:L.naturalWidth,height:L.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 _s(r,n,s,l,u,d){const h=ib(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(ub,{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 $i(r){let n=r,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function Qd(r){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(r)}function al(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 cf="",fb=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function hb(r){return r.replace(fb,(n,s)=>`${cf}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function Zd(r){return r.replace(new RegExp(`${cf}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function mb(r){const n=r.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const df={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 Xa=null;function uf(){return Xa||(Xa=Us(()=>import("./purify.es-4eNOHKSq.js"),[]).then(r=>r.default??r).catch(r=>{throw Xa=null,r})),Xa}function ff({html:r}){const{t:n}=kt(),[s,l]=a.useState(null);return a.useEffect(()=>{let u=!1;return l(null),uf().then(d=>{u||l(d.sanitize(r,df))}).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 pb({html:r}){const[n,s]=a.useState(null);return a.useEffect(()=>{let l=!1;return s(null),uf().then(u=>{l||s(u.sanitize(r,df))}).catch(()=>{l||s("")}),()=>{l=!0}},[r]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):r}function hf(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 Ja=null;function gb(){return Ja||(Ja=Promise.all([Us(()=>import("./katex-DnlPpQZa.js"),[]),Us(()=>Promise.resolve({}),__vite__mapDeps([16]))]).then(([r])=>r.default??r).catch(r=>{throw Ja=null,r})),Ja}function zs({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),gb().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 pl(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 eu(r){const n=pl(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 bb(r){const n=r.indexOf(">"),s=n<0?r:r.slice(0,n+1),l=pl(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 xb({url:r,fallbackText:n,widthPx:s,hasControls:l}){const{t:u}=kt(),[d,h]=a.useState(!1),m=xo(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 vb(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=pl(h).get("href")?.trim()??"",g=r.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:b,alt:f,title:S,widthPx:y}=eu(g);if(!b)return null;const N=ml(b,s.markdownFilePath,s.rootPath,cl,M=>M);if(!N)return null;const D=m?hl(m,s.markdownFilePath,s.rootPath):null,B=!!!(D&&D.path===N)&&m?Qu(m):null,$=_s(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}=eu(r);return h?_s(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}=bb(r);if(!h)return null;const f=lb(h,s.markdownFilePath,s.rootPath);return f?e.jsx(xb,{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(pb,{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=hb(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(Zd(u.slice(m,g.index)));const b=g[0],f=`${n}-${g.index}`,S=b.startsWith("<")?vb(b,f,l):null;if(S)h.push(S);else if(b.startsWith("\\(")&&b.endsWith("\\)"))h.push(e.jsx(zs,{tex:b.slice(2,-2)},f));else if(b.startsWith("$")&&b.endsWith("$"))h.push(e.jsx(zs,{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:mb(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(/^!\[([^\]]+)\]\[([^\]]*)\]$/),D=b.match(/^!\[([^\]]+)\]$/);if(y){const _=al(y[2]);h.push(_?_s(f,y[1],_.href,_.title,l):b)}else if(N){const _=N[2]||N[1],B=l.referenceDefinitions.get(oo(_));h.push(B?_s(f,N[1],B.href,B.title,l):b)}else if(D){const _=l.referenceDefinitions.get(oo(D[1]));h.push(_?_s(f,D[1],_.href,_.title,l):b)}else h.push(b)}else if(b.startsWith("[^")){const y=rf(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(">")&&Qd(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(Qd($i(b).linkText)){const{linkText:y,suffix:N}=$i(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}=$i(b),D=y.startsWith("www.")?`https://${y}`:y;h.push(e.jsx("a",{href:D,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(/^\[([^\]]+)\]\[([^\]]*)\]$/),D=b.match(/^\[([^\]]+)\]$/),_=N?N[2]||N[1]:D?.[1]??null,B=_?l.referenceDefinitions.get(oo(_)):null,$=y?al(y[2]):null,M=$?.href??B?.href??null,L=M?Qu(M):null,T=y?.[1]??N?.[1]??D?.[1]??"";h.push(L?e.jsx("a",{href:L,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(Zd(u.slice(m))),h.length>0?h:[r]}function mf(r){return/(?: {2,}|\\)$/.test(r)}function pf(r){return r.replace(/(?: {2,}|\\)$/,"")}function ho(r){return/^(?: {4}|\t)/.test(r)}function gf(r){return r.startsWith(" ")?r.slice(1):r.replace(/^ {4}/,"")}function bf(r,n,s){const l=[];return r.forEach((u,d)=>{const h=mf(u);l.push(...ct(pf(u),`${n}-${d}`,!0,s)),d<r.length-1&&l.push(h?e.jsx("br",{},`${n}-${d}-br`):" ")}),l}function ol(r,n,s){const l=[],u=[];return r.forEach((d,h)=>{u.push(mf(d)),l.push(ct(pf(d),`${n}-${h}`,!0,s))}),{perLine:l,hardBreaks:u}}function il(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 Ws(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 xf(r){return Ws(r).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function mo(r){return r==="center"?"text-center":r==="right"?"text-right":"text-left"}function po(r){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(r.trim())}function vf(r,n){return r>96||r>44&&n>.35}function wo(r){return(r.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function Gs(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 gl(r,n,s,l,u,d=new Set){const h=[],m=[];let g=n;for(;g<r.length;){const b=r[g];if(u&&(fo(b)||d.has(g))){g+=1;continue}const f=Gs(b),S=wo(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 D of m)D.item.lineEnd=g+1;g+=1}return{items:h,nextIndex:g}}function yb(r){const n=r.find(l=>Gs(l));if(!n)return[];const s=Gs(n);return s?gl(r,0,wo(n),s.ordered,!0,sf(r)).items:[]}function bl(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:wb(u.children,`${n}-${d}`,s,l)}})}function wb(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:bl(d.items,`${n}-g${h}`,s,l)}))}function xl(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&&kb(s.groups,n)]},s.key)})}function kb(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:xl(s.items,n)},`nested-${l}`)})}function Sb(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 jb(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 M="Details";const L=[];for(d+=1;d<r.length&&!/^<\/details>\s*$/i.test(r[d].trim());){const T=r[d].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);T?M=T[1].trim()||M:L.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(M,`${n}-details-${$}-summary`,!0,s)}),L.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:bf(L,`${n}-details-${$}`,s)})]},`${n}-details-${$}`)});continue}const b=hf(m);if(b){const $=[m],M=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(ff,{html:$.join(`
|
|
1639
|
-
`)},`${n}-html-${M}`)});continue}const f=g.match(/^(```|~~~)\s*(.*)$/);if(f){const $=[],M=f[1],L=f[2]?.trim(),T=d;for(d+=1;d<r.length&&!r[d].trim().startsWith(M);)$.push(r[d]),d+=1;d<r.length&&(d+=1),L.toLowerCase()==="mermaid"?u.push({kind:"static",node:e.jsx(wf,{code:$.join(`
|
|
1640
|
-
`),blockKey:`${n}-code-${T}`},`${n}-code-${T}`)}):["math","latex","tex"].includes(L.toLowerCase())?u.push({kind:"static",node:e.jsx(zs,{tex:$.join(`
|
|
1641
|
-
`),display:!0},`${n}-code-${T}`)}):u.push({kind:"code",key:`${n}-code-${T}`,code:$.join(`
|
|
1642
|
-
`),lang:L,blockKey:`${n}-code-${T}`,codeStartLine:h(T)+1});continue}if(ho(m)){const $=[],M=d;for(;d<r.length&&(ho(r[d])||!r[d].trim());)$.push(r[d].trim()?gf(r[d]):""),d+=1;u.push({kind:"code",key:`${n}-indented-code-${M}`,code:$.join(`
|
|
1643
|
-
`).replace(/\n+$/,""),lang:"",blockKey:`${n}-indented-code-${M}`,codeStartLine:h(M)});continue}const S=g.match(/^(#{1,6})\s+(.+)$/);if(S){const M=`h${Math.min(6,S[1].length+1)}`,L=tf(S[2]),T=nl(L,s);u.push({kind:"static",node:e.jsx(M,{id:T,className:"scroll-mt-16 font-semibold text-foreground",children:ct(L,`${n}-heading-${d}`,!0,s)},`${n}-heading-${d}`)}),d+=1;continue}if(d+1<r.length&&m.includes("|")&&po(r[d+1])){const $=Ws(m),M=xf(r[d+1]),L=[],T=d;for(d+=2;d<r.length&&r[d].includes("|")&&r[d].trim();)L.push(Ws(r[d])),d+=1;u.push({kind:"static",node:e.jsx("div",{className:Gu,"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,I)=>e.jsx("th",{className:`${zu} ${mo(M[I]??null)}`,children:e.jsx("div",{className:uo,children:ct(U,`${n}-th-${T}-${I}`,!0,s)})},`h-${I}`))})}),e.jsx("tbody",{children:L.map((U,I)=>e.jsx("tr",{className:"border-t border-border/10",children:$.map((p,i)=>e.jsx("td",{className:`${Wu} ${mo(M[i]??null)}`,children:e.jsx("div",{className:uo,children:ct(U[i]??"",`${n}-td-${T}-${I}-${i}`,!0,s)})},`c-${i}`))},`r-${I}`))})]})},`${n}-table-${T}`)});continue}const y=Gs(m);if(y){const $=y.ordered,M=wo(m),L=y.start,T=d,U=gl(r,d,M,$,!1);d=U.nextIndex,u.push({kind:"list",keyPrefix:`${n}-list-${T}`,ordered:$,start:$?L:void 0,renders:bl(U.items,`${n}-list-${T}`,s,h(0)-1)});continue}const N=[m.trimStart()],D=[h(d)],_=d;for(d+=1;d<r.length&&r[d].trim()&&!rl(r[d])&&!(d+1<r.length&&r[d].includes("|")&&po(r[d+1]));)N.push(r[d].trimStart()),D.push(h(d)),d+=1;const B=ol(N,`${n}-p-${_}`,s);u.push({kind:"paragraph",keyPrefix:`${n}-p-${_}`,perLine:B.perLine,hardBreaks:B.hardBreaks,lineNums:D})}return u}function Rb(r,n){return r.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return e.jsx("p",{children:il(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:xl(s.renders,n)},s.keyPrefix)}case"code":return e.jsx(go,{code:s.code,lang:s.lang,blockKey:s.blockKey,codeStartLine:s.codeStartLine,lineRange:n},s.key)}})}let Qa=null,tu=!1;const Za=16,yf=192;function Cb(){return Qa||(Qa=Us(()=>import("./mermaid.core-DVQ8ioL7.js").then(r=>r.bl),__vite__mapDeps([17,1,2,3,4,5,18])).then(r=>r.default??r).catch(r=>{throw Qa=null,r})),Qa}function Nb(r){tu||(r.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),tu=!0)}function Mb(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(yf,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-Za,u=s.y-Za,d=s.width+Za*2,h=s.height+Za*2,m=Math.max(yf,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 $b(r){const n=r.trim().split(/\s+/,1)[0]?.toLowerCase();if(!n)return null;const s=n.replace(/^language-/,"");return wu(`code.${s}`)??s}function wf({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(Zu);a.useEffect(()=>{let f=!1;return u(null),h(!1),Cb().then(async S=>{Nb(S);const y=`termdock-md-mermaid-${n.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:N}=await S.render(y,r);f||u(Mb(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(go,{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 go({code:r,lang:n,blockKey:s,codeStartLine:l,lineRange:u}){const d=$b(n),[h,m]=a.useState(null);a.useEffect(()=>{if(!d||!ku(r)){m(null);return}let b=!1;return Su().then(f=>{if(b||!f.registered(d)){b||m(null);return}try{m(ju(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:`${fl} 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 vl(r,n,s,l,u){r=ob(r);const d=sb(r),h=sf(r),m=[],g={markdownFilePath:n,rootPath:s,referenceDefinitions:d,footnoteDefinitions:ab(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(fo(y)||h.has(f)){f+=1;continue}if(!N){f+=1;continue}if(/^<details>\s*$/i.test(N)){const I=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-${I}`,startLine:I+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-${I}-summary`,!0,g)}),i.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:bf(i,`details-${I}`,g)})]})});continue}const D=hf(y);if(D){const I=[y],p=f;for(f+=1;f<r.length&&!D.selfContained&&!new RegExp(`</${D.tag}>`,"i").test(r[f]);)I.push(r[f]),f+=1;f<r.length&&!D.selfContained&&(I.push(r[f]),f+=1),b.push({key:`html-${p}`,startLine:p+1,endLine:f,content:e.jsx(ff,{html:I.join(`
|
|
1646
|
-
`)})});continue}const _=N.match(/^(```|~~~)\s*(.*)$/);if(_){const I=[],p=_[1],i=_[2]?.trim(),O=f;for(f+=1;f<r.length&&!r[f].trim().startsWith(p);)I.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(wf,{code:I.join(`
|
|
1647
|
-
`),blockKey:`code-${O}`}):["math","latex","tex"].includes(i.toLowerCase())?e.jsx(zs,{tex:I.join(`
|
|
1648
|
-
`),display:!0}):C=>e.jsx(go,{code:I.join(`
|
|
1649
|
-
`),lang:i,blockKey:`code-${O}`,codeStartLine:O+2,lineRange:C})});continue}if(ho(y)){const I=[],p=f;for(f+=0;f<r.length&&(ho(r[f])||!r[f].trim());)I.push(r[f].trim()?gf(r[f]):""),f+=1;b.push({key:`indented-code-${p}`,startLine:p+1,endLine:f,fineGrained:!0,content:i=>e.jsx(go,{code:I.join(`
|
|
1650
|
-
`).replace(/\n+$/,""),lang:"",blockKey:`indented-code-${p}`,codeStartLine:p+1,lineRange:i})});continue}if(N.startsWith("$$")){const I=[],p=f,i=N.replace(/^\$\$\s*/,"");if(i.endsWith("$$")&&i.length>2)I.push(i.replace(/\s*\$\$$/,"")),f+=1;else{for(i&&I.push(i),f+=1;f<r.length&&!r[f].trim().endsWith("$$");)I.push(r[f]),f+=1;if(f<r.length){const O=r[f].trim().replace(/\s*\$\$$/,"");O&&I.push(O),f+=1}}b.push({key:`math-${p}`,startLine:p+1,endLine:f,content:e.jsx(zs,{tex:I.join(`
|
|
1651
|
-
`),display:!0})});continue}if(f+1<r.length&&N&&!rl(y)&&/^(=+|-+)\s*$/.test(r[f+1].trim())){const I=r[f+1].trim().startsWith("=")?1:2,p=`h${I}`,i=nl(N,g),O={level:I,text:Jd(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 ${I===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 I=B[1].length,p=tf(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${I}`,C=nl(p,g),V={level:I,text:Jd(p),id:C};b.push({key:`heading-${f}`,startLine:f+1,endLine:f+1,heading:V,content:e.jsx(O,{id:C,className:`scroll-mt-16 font-semibold text-foreground ${i[I]}`,children:ct(p,`heading-${f}`,!0,g)})}),f+=1;continue}if(Ju(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 I=[],p=[],i=f;for(;f<r.length&&/^>\s?/.test(r[f].trim());)I.push(r[f].trim().replace(/^>\s?/,"")),p.push(f+1),f+=1;const O=I[0]?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i);if(O){const V=O[1].toUpperCase(),ie=O[2]?.trim(),se=[...ie?[ie]:[],...I.slice(1)],be=[...ie?[p[0]]:[],...p.slice(1)],G=ol(se,`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:V}),se.length>0&&e.jsx("div",{children:il(G.perLine,G.hardBreaks,be,`callout-${i}`,X)})]})});continue}const C=jb(I,`quote-${i}`,g,p);b.push({key:`quote-${i}`,startLine:i+1,endLine:f,fineGrained:!0,content:V=>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:Rb(C,V)})});continue}if(f+1<r.length&&y.includes("|")&&po(r[f+1])){const I=Ws(y),p=xf(r[f+1]),i=[],O=f;for(f+=2;f<r.length&&r[f].includes("|")&&r[f].trim();)i.push(Ws(r[f])),f+=1;const C=I.map((ie,se)=>ct(ie,`th-${O}-${se}`,!0,g)),V=i.map((ie,se)=>I.map((be,G)=>ct(ie[G]??"",`td-${O}-${se}-${G}`,!0,g)));b.push({key:`table-${O}`,startLine:O+1,endLine:f,interactive:!1,kind:"table",content:ie=>{const se=be=>!!(ie&&be>=ie.start&&be<=ie.end);return e.jsx("div",{className:Gu,"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":se(O+1)?"true":void 0,children:C.map((be,G)=>e.jsx("th",{className:`${zu} ${mo(p[G]??null)}`,children:e.jsx("div",{className:uo,children:be})},`h-${G}`))})}),e.jsx("tbody",{children:V.map((be,G)=>{const X=O+G+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":se(X)?"true":void 0,children:I.map((A,F)=>e.jsx("td",{className:`${Wu} ${mo(p[F]??null)}`,children:e.jsx("div",{className:uo,children:be[F]})},`c-${F}`))},`r-${G}`)})})]})})}});continue}const $=Gs(y);if($){const I=$.ordered,p=wo(y),i=$.start,O=f,C=gl(r,f,p,I,!0,h);f=C.nextIndex;const V=I?"ol":"ul",ie=bl(C.items,`list-${O}`,g);b.push({key:`list-${O}`,startLine:O+1,endLine:f,fineGrained:!0,content:se=>e.jsx(V,{start:I?i:void 0,className:`${I?"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:xl(ie,se)})});continue}const M=[y.trimStart()],L=[f+1],T=f;for(f+=1;f<r.length&&r[f].trim()&&!rl(r[f])&&!(f+1<r.length&&r[f].includes("|")&&po(r[f+1]));){if(fo(r[f])||h.has(f)){f+=1;continue}M.push(r[f].trimStart()),L.push(f+1),f+=1}const U=ol(M,`p-${T}`,g);b.push({key:`p-${T}`,startLine:T+1,endLine:f,fineGrained:!0,content:I=>e.jsx("p",{className:"text-muted-foreground",children:il(U.perLine,U.hardBreaks,L,`p-${T}`,I)})})}const S=Sb(g);return S&&b.push({key:"footnotes",startLine:r.length,endLine:r.length,content:S}),{blocks:b,images:m}}function Lb(r,n,s){return vl(r,n,s).blocks}function kf(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 Sf(r){return r.filter(n=>!!n.heading).map(n=>({...n.heading,startLine:n.startLine}))}function Ab({src:r,alt:n,onZoomChange:s,onDoubleTap:l}){const u=lf(r);return e.jsx(Df,{src:u,alt:n,onLoad:()=>{},onError:()=>{},onZoomChange:s,onDoubleTap:l})}function jf({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,D]=a.useState(0),[_,B]=a.useState(!1),$=a.useCallback(()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),M=a.useCallback(()=>{S||Date.now()<f.current||($(),b.current=window.setTimeout(()=>{b.current=null,l()},450))},[$,S,l]),L=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(()=>L(n-1),[L,n]),U=a.useCallback(()=>L(n+1),[L,n]);if(a.useEffect(()=>{$(),D(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]),pu({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),D(Math.max(0,i)))},onDragEnd:({movement:[p,i],velocity:[,O],pinching:C,canceled:V})=>{if(B(!1),C||V||S||Math.abs(i)<Math.abs(p)*1.15){D(0);return}if(Math.abs(i)>8&&(f.current=Date.now()+300),vf(i,O)){l();return}D(0)}},{target:g,drag:{filterTaps:!0,pointer:{touch:!0}}}),!d)return null;const I=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:I}),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(Bs,{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(im,{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(qt,{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:M,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(gu,{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(Hi,{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(Ab,{src:p.src,alt:p.alt||p.title||u("rightSidebar.markdownImage"),onZoomChange:y,onDoubleTap:$}):e.jsx(qb,{svg:p.svg,title:p.title||p.alt||u("rightSidebar.mermaidDiagram"),onZoomChange:y,onDoubleTap:$})})},`${p.kind}-${i}-${p.alt}`))})})})]})]}),document.body)}function Rf({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:D,onLocalLinkOpen:_}){const{t:B}=kt(),[$,M]=a.useState(null),[L,T]=a.useState(null),[U,I]=a.useState(1),[p,i]=a.useState(null),O=a.useRef(null),C=a.useRef(null),{blocks:V,images:ie}=a.useMemo(()=>vl(r.split(`
|
|
1652
|
-
`),n,s,R=>{T(null),M(R),N?.()},{footnotes:B("rightSidebar.footnotes"),backToFootnote:R=>B("rightSidebar.backToFootnote",{index:R})}),[r,n,s,N,B]),se=a.useMemo(()=>L?[...ie,L]:ie,[ie,L]),be=a.useCallback(R=>{T({kind:"mermaid",svg:R,alt:"Mermaid diagram",title:"Mermaid diagram"}),M(ie.length),N?.()},[ie.length,N]);a.useEffect(()=>{M(null),T(null)},[r,n]),a.useEffect(()=>{M(null),T(null)},[y]),a.useEffect(()=>{S||(M(null),T(null))},[S]),a.useEffect(()=>{I(1)},[r,n]),a.useLayoutEffect(()=>{const R=O.current;if(!R||V.length===0)return;const re=Array.from(R.querySelectorAll("[data-markdown-preview-block-start]"));let le=1;const Re=28;for(const Ce of re)if(Ce.offsetTop-h<=Re)le=Number(Ce.dataset.markdownPreviewBlockStart)||le;else break;I(Ce=>Ce===le?Ce:le)},[V,h]);const G=a.useMemo(()=>kf(V,U),[U,V]),X=a.useMemo(()=>Sf(V),[V]),A=`${n??""}
|
|
1653
|
-
${r}`,F=a.useRef(A),q=a.useRef(null),ne=a.useRef(null),de=a.useRef(!1);a.useEffect(()=>{F.current!==A&&(F.current=A,f?.())},[f,A]),a.useEffect(()=>{g!==void 0&&i(null)},[g]),a.useLayoutEffect(()=>{if(!m){i(null);return}const R=()=>{const re=C.current;if(!re)return;const le=re.getBoundingClientRect(),Re=window.innerWidth;i({top:le.bottom+6,right:Math.max(8,Re-le.right)})};return R(),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[m,h,G]);const xe=a.useCallback(R=>{const re=O.current,le=re?.closest("[data-markdown-preview-scroller]"),Re=re?.querySelector(`[data-markdown-preview-block-start="${R.startLine}"]`);if(!le||!Re)return;const Ce=le.getBoundingClientRect(),ze=Re.getBoundingClientRect(),Ee=re?.querySelector("[data-markdown-heading-sticky]")?.getBoundingClientRect().height??0,et=ze.top-Ce.top+le.scrollTop;le.scrollTo({top:Math.max(0,et-Ee-8),behavior:"smooth"}),I(R.startLine),f?.()},[f]),ue=a.useCallback(R=>{R.pointerType==="mouse"&&R.button!==0||Fi(R.target)||(q.current={pointerId:R.pointerId,startX:R.clientX,startY:R.clientY})},[]),Ae=a.useCallback((R,re,le)=>{const Re=q.current;if(q.current=null,!Re||Re.pointerId!==R.pointerId)return;const Ce=Math.abs(R.clientX-Re.startX),ze=Math.abs(R.clientY-Re.startY);if(Ce>8||ze>8)return;const ce=R.target;if(Fi(ce)||Wi())return;const Ee=lu(ce,re,le);u(R,Ee.start,Ee.end)},[u]),E=a.useCallback(R=>{q.current?.pointerId===R.pointerId&&(q.current=null)},[]),ee=a.useCallback((R,re)=>{const le=O.current;if(!le||typeof document.elementFromPoint!="function")return null;const Re=document.elementFromPoint(R,re);if(!(Re instanceof HTMLElement)||!le.contains(Re))return null;const Ce=Re.closest("[data-md-ref-start]");if(Ce){const W=Number(Ce.dataset.mdRefStart);if(Number.isFinite(W)&&W>0)return W}const ze=Re.closest("[data-markdown-preview-block-start]");if(!ze)return null;const ce=Number(ze.dataset.markdownPreviewBlockStart),Ee=V.find(W=>W.startLine===ce);if(!Ee)return Number.isFinite(ce)&&ce>0?ce:null;if(Ee.endLine<=Ee.startLine)return Ee.startLine;const et=ze.getBoundingClientRect(),Pe=et.height>0?Math.min(1,Math.max(0,(re-et.top)/et.height)):0;return Math.round(Ee.startLine+Pe*(Ee.endLine-Ee.startLine))},[V]),pe=a.useCallback(R=>{if(!d||R.pointerType==="mouse"&&R.button!==0)return;const re=ee(R.clientX+24,R.clientY);if(re!=null){ne.current={pointerId:R.pointerId,anchorLine:re,moved:!1};try{R.currentTarget.setPointerCapture(R.pointerId)}catch{}}},[d,ee]),$e=a.useCallback(R=>{const re=ne.current;if(!re||re.pointerId!==R.pointerId||!d)return;const le=ee(R.clientX+16,R.clientY);le!=null&&(!re.moved&&le===re.anchorLine||(re.moved=!0,de.current=!0,d(R,Math.min(re.anchorLine,le),Math.max(re.anchorLine,le),"move")))},[d,ee]),Ye=a.useCallback(R=>{const re=ne.current;if(ne.current=null,!re||re.pointerId!==R.pointerId||!d||!re.moved)return;const le=ee(R.clientX+16,R.clientY)??re.anchorLine;d(R,Math.min(re.anchorLine,le),Math.max(re.anchorLine,le),"end")},[d,ee]),Le=a.useCallback(R=>{ne.current?.pointerId===R.pointerId&&(ne.current=null)},[]),Je={onPointerDown:pe,onPointerMove:$e,onPointerUp:Ye,onPointerCancel:Le},Fe=()=>de.current?(de.current=!1,!0):!1;return V.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 re=R.target instanceof Element?R.target.closest("a[href]"):null;if(!re||!_)return;const le=re.getAttribute("href");if(!le)return;const Re=hl(le,n,s);Re&&(R.preventDefault(),_(Re))},children:[G.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:G.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:G[G.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(bu,{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 re=G[G.length-1]?.startLine===R.startLine;return e.jsxs("button",{type:"button",onClick:()=>xe(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] ${re?"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 ${re?"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(qt,{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 re=G[G.length-1]?.startLine===R.startLine;return e.jsxs("button",{type:"button",onClick:()=>xe(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] ${re?"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 ${re?"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(Zu.Provider,{value:be,children:V.map(R=>{const re=!!(l&&R.startLine<=l.end&&R.endLine>=l.start),le=!!(l&&l.start<=R.startLine&&l.end>=R.endLine),Re=R.kind==="table"?!1:R.fineGrained?le:re,Ce=R.kind==="table"&&l?.start===R.startLine&&l.end===R.endLine;let ze=null;if(R.kind!=="table"&&R.fineGrained&&re&&!le&&l){const Pe=R.endLine-R.startLine+1,W=Math.max(l.start,R.startLine),Te=Math.min(l.end,R.endLine),Oe=(W-R.startLine)/Pe,St=(Te-W+1)/Pe;ze=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) * ${Oe})`,height:`calc((100% - 0.5rem) * ${St})`}})}const ce=typeof R.content=="function"?R.content(l):R.content,Ee=R.startLine===R.endLine?String(R.startLine):`${R.startLine}-${R.endLine}`,et=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:Ti(Re),"aria-hidden":"true",...Je,children:[e.jsx("span",{className:Ii(Re)}),ze]}),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 ${Re?"bg-primary/10":""}`,title:`Line ${Ee}`,"aria-label":`Line ${Ee}`,children:[R.kind==="table"?e.jsx("button",{type:"button",className:Ti(Ce,"self"),onClick:Pe=>{Pe.preventDefault(),!Fe()&&u(Pe,R.startLine,R.endLine)},title:`Reference table lines ${Ee}`,"aria-label":`Reference table lines ${Ee}`,...Je,children:e.jsx("span",{className:Ii(Ce,"self")})}):e.jsxs("span",{className:Ti(Re,"none"),"aria-hidden":"true",...Je,children:[e.jsx("span",{className:Ii(Re,"none")}),ze]}),e.jsx("div",{className:"min-w-0 cursor-text select-text","data-sidebar-selectable":!0,role:"button",tabIndex:0,onPointerDown:ue,onPointerUp:Pe=>Ae(Pe,R.startLine,R.endLine),onPointerCancel:E,onKeyDown:Pe=>{Pe.key!=="Enter"&&Pe.key!==" "||(Pe.preventDefault(),u(Pe,R.startLine,R.endLine))},title:`Reference line ${Ee}`,"aria-label":`Reference line ${Ee}`,children:ce})]},R.key):e.jsx("div",{role:"button",tabIndex:0,"data-markdown-preview-block-start":R.startLine,onClick:Pe=>{const W=Pe.target;if(Fi(W)||Wi()||Fe())return;const Te=lu(W,R.startLine,R.endLine);u(Pe,Te.start,Te.end)},onKeyDown:Pe=>{Pe.key!=="Enter"&&Pe.key!==" "||(Pe.preventDefault(),u(Pe,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 ${Re?"bg-primary/10":"hover:bg-[var(--surface-2)]"}`,title:`Reference line ${Ee}`,"aria-label":`Reference line ${Ee}`,children:et},R.key)})})})]}),S&&$!==null&&se[$]&&e.jsx(jf,{images:se,index:$,onChange:M,onClose:()=>{M(null),T(null),D?.()}})]})}function Xn({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,D]=a.useState(null),_=a.useRef(null),B=a.useRef(null),$=S.trim().toLowerCase(),M=a.useMemo(()=>$?s.filter(p=>`${p.label} ${p.meta??""}`.toLowerCase().includes($)):s,[$,s]),L=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),V=window.innerHeight-p.bottom-i,ie=p.top-i,se=V>=180||V>=ie,be=Math.max(96,(se?V:ie)-4),G=Math.min(320,be);return D({left:C,top:se?p.bottom+4:Math.max(i,p.top-G-4),width:O,maxHeight:G}),!0},[]),I=()=>{U(),f(!0)};return a.useEffect(()=>{if(!b)return;let p=0;const i=()=>{p||(p=window.requestAnimationFrame(()=>{p=0,U()}))},O=C=>{const V=C.target;V instanceof Node&&(_.current?.contains(V)||B.current?.contains(V)||(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}I()}},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:L?.label??(n||l)})]}),e.jsx(Os,{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(Jn,{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()&&M.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")})]}),M.length>0?M.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 ru({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:D,title:_,ariaLabel:B,scopeTitle:$,scopeLabel:M,allLabel:L,generateLabel:T,secondaryLabel:U,secondaryTitle:I,secondaryLoading:p,loading:i,error:O,statusTitle:C,extraContent:V,renderRepoExtra:ie}){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?`${$}: ${M}`:_),children:[i?e.jsx(Nt,{size:13,className:"animate-spin"}):e.jsx(Hs,{size:13}),e.jsx("span",{children:y?D:N}),s&&e.jsx(Os,{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:se=>se.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:M})]}),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(qt,{size:14})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[V,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:L}),l&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),u.map(se=>{const be=d.includes(se.root);return e.jsxs("div",{className:`mt-1 rounded-md transition ${be?"bg-primary/15 text-primary":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>h(se.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${be?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:se.root,children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate",children:se.label}),se.branch&&e.jsx("span",{className:"block truncate text-[9px] opacity-70",children:se.branch})]}),be&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),ie&&(l||be)&&e.jsx("div",{className:"px-2 pb-2",children:ie(se)})]},se.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:I,children:[p?e.jsx(Nt,{size:12,className:"animate-spin"}):e.jsx(Cu,{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(Hs,{size:12}),T]})]})]})}),document.body)]})}function Pb(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 Cf(){return ht(dl,Pb)??{}}function Tb(r,n){const s=Cf(),l=Object.entries({...s,[r]:{top:n,updatedAt:Date.now()}}).sort(([,u],[,d])=>d.updatedAt-u.updatedAt).slice(0,Eg);Is(dl,Object.fromEntries(l),Lg)}function Ib(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 Db(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&&!Ib(s.lineRange)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function yl(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function Nf(){return ht(ul,Db)??{}}function nu(r,n){const s=yl(r,n);return s?Nf()[s]??null:null}function Li(r,n,s){const l=yl(r,n);if(!l)return;const u=Nf(),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,$g);Is(ul,Object.fromEntries(h),Ag)}function eo({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 Ai({slow:r}){return e.jsx(Gm,{slow:r})}function to({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 io(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 Pi(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 Fb(r,n,s){return Gi(r,n,s)}function Ti(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 Ii(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 Mf(r){const n=new Map;for(const s of r)n.set(wl(s),s);return n}function Ef(r,n){const s=new Map(r);for(const l of n)s.set(wl(l),l);return s}function su(r,n){let s=0;for(const l of r){const u=pt(l,n);u&&n&&u!==n&&(s+=1)}return s}function _b(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function Bb(r,n){return Array.from(Ef(Mf(r),n).values()).sort((s,l)=>s.path.localeCompare(l.path))}function Ob(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:_b(r.files)}}function $f(r,n){const s=wt(n??"")||n||"";return r.map(l=>Ob(l,n)).sort((l,u)=>s&&l.label===s?-1:s&&u.label===s?1:l.label.localeCompare(u.label))}function Lf(r,n,s,l,u){const d=Vu(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:$f(N,u)}}function pt(r,n){return r.repoRoot??n}function wl(r){return`${r.repoRoot??""}\0${r.path}`}function yt(r){return r.absolutePath||r.path}function Di(r){return wl(r)}function Ub(r){return r.repoRelativeRoot&&r.repoRelativeRoot!=="."?r.repoRelativeRoot:r.repoName??""}function au(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function ou(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 Ls(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 As(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 Hb(r){const n=r.error??r.context?.error??"";return n.includes("request was cancelled")||n.includes("IO_REQUEST_CANCELLED")}function iu(r){return r?.available===!1&&r.code==="NOT_GIT_REPOSITORY"}function Fi(r){return r instanceof HTMLElement&&!!r.closest('a, button, input, textarea, select, label, [contenteditable="true"]')}function lu(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 zb({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(Nt,{size:13,className:"animate-spin"}):g?e.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):e.jsx(lo,{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(Nt,{size:13,className:"animate-spin"}):S?"✓":null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:b.label})]},b.key)})})]}))}function Wb(r){const n=window.getComputedStyle(r).overflowY;return(n==="auto"||n==="scroll")&&r.scrollHeight>r.clientHeight+1}function Af(r){let n=r;for(;n;){if(n.classList.contains("termdock-diff-stream-scroller")&&Wb(n))return n;n=n.parentElement}return r.closest(".termdock-diff-stream-scroller")}function Qn(r){return r.getClientRects().length>0&&window.getComputedStyle(r).visibility!=="hidden"}const _i=new WeakMap;function bo(r){const n=_i.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"),_i.delete(r)},1700);_i.set(r,s)}function Gb(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(!Qn(m))continue;const g=m.querySelector(s);if(g&&Qn(g)){u=g;break}}if(u??=Array.from(document.querySelectorAll(s)).find(Qn)??null,!u)return;const d=Af(u);if(!d){u.scrollIntoView({block:"start",behavior:"smooth"}),bo(u);return}const h=u.getBoundingClientRect().top-d.getBoundingClientRect().top+d.scrollTop;d.scrollTo({top:Math.max(0,h),behavior:"instant"}),bo(u)}function Sn(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(D=>!!D),m=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let g=null;for(const D of m)if(Qn(D)){for(const _ of h){const B=D.querySelector(_);if(B&&Qn(B)){g=B;break}}if(g)break}if(g??=h.flatMap(D=>Array.from(document.querySelectorAll(D))).find(Qn)??null,!g){Gb(r.filePath);return}const b=Af(g);if(!b){g.scrollIntoView({block:"center",behavior:"smooth"}),bo(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"}),bo(g)}const Pf=1,Tf=8;function Kb(r){return Math.min(Tf,Math.max(Pf,r))}function If({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),D=a.useRef(d);D.current=d,a.useEffect(()=>{h({scale:1,x:0,y:0})},[r]);const _=a.useCallback((L,T,U)=>{const I=u.current;if(!I)return{x:T,y:U};const p=I.firstElementChild instanceof HTMLElement?I.firstElementChild:null,i=p?.clientWidth||I.clientWidth,O=p?.clientHeight||I.clientHeight,C=Math.max(0,(i*L-I.clientWidth)/2),V=Math.max(0,(O*L-I.clientHeight)/2);return{x:Math.min(C,Math.max(-C,T)),y:Math.min(V,Math.max(-V,U))}},[]),B=a.useCallback((L,T,U)=>{h(I=>{const p=Kb(L),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,V=(U??O.top+O.height/2)-O.top-O.height/2,ie=p/I.scale,se=C-(C-I.x)*ie,be=V-(V-I.y)*ie;return{scale:p,..._(p,se,be)}})},[_]),$=a.useCallback((L,T)=>{g(!0),D.current.scale>1?h({scale:1,x:0,y:0}):B(2.5,L,T),window.setTimeout(()=>g(!1),220)},[B]);a.useEffect(()=>{const L=u.current;if(!L)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(!(D.current.scale<=1)){p.preventDefault(),b.current={pointerId:p.pointerId,startX:p.clientX,startY:p.clientY,originX:D.current.x,originY:D.current.y,moved:!1};try{L.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(V=>({...V,..._(V.scale,i.originX+O,i.originY+C)}))},I=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{L.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 L.addEventListener("pointerdown",T,{capture:!0,passive:!1}),window.addEventListener("pointermove",U,{capture:!0,passive:!1}),window.addEventListener("pointerup",I,{capture:!0}),window.addEventListener("pointercancel",I,{capture:!0}),()=>{L.removeEventListener("pointerdown",T,{capture:!0}),window.removeEventListener("pointermove",U,{capture:!0}),window.removeEventListener("pointerup",I,{capture:!0}),window.removeEventListener("pointercancel",I,{capture:!0})}},[_,s,$]),pu({onPinch:({offset:[L],origin:[T,U]})=>{g(!1),B(L,T,U)},onWheel:({event:L,delta:[T,U],ctrlKey:I})=>{if(I){L.preventDefault(),L.stopPropagation(),g(!1),B(D.current.scale*(1-U*.01),L.clientX,L.clientY);return}D.current.scale<=1||(L.preventDefault(),L.stopPropagation(),g(!1),h(p=>({...p,..._(p.scale,p.x-T,p.y-U)})))}},{target:u,eventOptions:{passive:!1},pinch:{scaleBounds:{min:Pf,max:Tf},from:()=>[D.current.scale,0],rubberband:!0}});const M=d.scale>1;return a.useEffect(()=>{n?.(M)},[n,M]),e.jsx("div",{ref:u,"data-sidebar-gesture-ignore":M?"":void 0,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden",style:{cursor:M?"grab":"zoom-in"},onDoubleClick:L=>{L.stopPropagation(),!(Date.now()-N.current<500)&&(s?.(),$(L.clientX,L.clientY))},children:l({scale:d.scale,zoomed:M,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 Df({src:r,alt:n,vector:s,onLoad:l,onError:u,onZoomChange:d,onDoubleTap:h}){const m=xo(r,u),[g,b]=a.useState(null),f=s??yo(r);return a.useEffect(()=>{b(null)},[r]),e.jsx(If,{resetKey:r,onZoomChange:d,onDoubleTap:h,children:({transformStyle:S,vectorTransformStyle:y,scale:N,animateTransform:D})=>{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:D?"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,M=$.parentElement;if(M&&$.naturalWidth>0&&$.naturalHeight>0){const L=Math.max(1,M.clientWidth-2),T=Math.max(1,M.clientHeight-2),U=Math.min(L/$.naturalWidth,T/$.naturalHeight),I=f?U:Math.min(U,1);b({width:Math.max(1,Math.round($.naturalWidth*I)),height:Math.max(1,Math.round($.naturalHeight*I))})}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 Vb({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),D=Math.max(1,d.clientHeight-24),_=Math.min(N/S,D/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 qb({svg:r,title:n,onZoomChange:s,onDoubleTap:l}){return e.jsx(If,{resetKey:r,onZoomChange:s,onDoubleTap:l,children:({vectorTransformStyle:u,scale:d})=>e.jsx(Vb,{svg:r,title:n,scale:d,vectorTransformStyle:u})})}let Yb=0,Xb=0,Jb=0,Qb=0,Zb=0;function Bi(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:++Xb,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function ro(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${r}`,data:{seq:++Qb,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function ex(){return`diff-ui-${Date.now().toString(36)}-${(++Zb).toString(36)}`}function tx(r){return r instanceof Element?r.closest("[data-diff-selection-path]"):null}function rx(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 ll({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:D,onOpenMarkdownImageLightbox:_,onCloseMarkdownImageLightbox:B,lineRange:$,onLineRangeChange:M,insertedReferenceKey:L,copiedReferenceKey:T,scrollToLine:U,onScrollToLineHandled:I}){const{t:p}=kt(),i=J(P=>P.rootPath),O=J(P=>P.selectFile),[C,V]=a.useState({kind:"idle"}),[ie,se]=a.useState("schematic"),[be,G]=a.useState(null),X=a.useRef(null),[A,F]=a.useState(null),q=a.useRef(new Map),ne=a.useRef(null),[de,xe]=a.useState(null),[ue,Ae]=a.useState(()=>Gd()),[E,ee]=a.useState(()=>Ad(i,n)),pe=a.useRef(null),[$e,Ye]=a.useState(!1),[Le,Je]=a.useState(null),[Fe,R]=a.useState(0),[re,le]=a.useState([]),[Re,Ce]=a.useState(null),ze=a.useRef(null),ce=a.useRef(n),[Ee,et]=a.useState(null),[Pe,W]=a.useState({status:"idle"}),[Te,Oe]=a.useState(!1),[St,tt]=a.useState(""),[dt,Pr]=a.useState([]),[_t,H]=a.useState(0),ae=a.useRef(null),ve=Ru(d),We=yl(i,n);a.useEffect(()=>{if(ce.current===n)return;ce.current=n;const P=n&&i&&!n.startsWith("/")?`${i}/${n}`:n;if(ze.current===P){ze.current=null;return}ze.current=null,le([]),Ce(null),Oe(!1),tt("")},[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),Bt=a.useRef(null),[hr,mr]=a.useState(0),jn=a.useCallback(()=>mr(P=>P+1),[]);a.useEffect(()=>{const P=X.current;return X.current=null,G(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,V({kind:"idle"});return}const P=i&&!n.startsWith("/")?`${i}/${n}`:n,z=new AbortController,fe=++Yb,ke=`right-sidebar-file-preview:${fe}`,Qe=performance.now();let Ie=!1;const Ge=(Q,Ke={})=>{Ie||(Ie=!0,Bi("end",{loadingId:fe,reason:Q,durationMs:Math.round(performance.now()-Qe),filePath:n,fullPath:P,rootPath:i,...Ke}))};let De=null;const Ze=Yh(P),ut=Ze?P.toLowerCase().endsWith(".kicad_pcb")?ie==="schematic"?"pcb-front":ie:"schematic":ie,Mn=!Ze&&cl(P),rr=!Ze&&!Mn&&Xh(P),as=!Ze&&!Mn&&!rr&&du(P),en=$s(P),tn=Ns(P),Or=Ze?"eda":Mn?"image":rr?"model3d":as?"video":"text",rn=fr.current!==P;if(fr.current=P,rn){Bi("start",{loadingId:fe,filePath:n,fullPath:P,rootPath:i,mode:Or,externalVersion:ur}),W({status:"idle"}),V({kind:"loading",mode:Or}),Bt.current=null;const Q=nu(i,n);M(Q?.lineRange??null),Ae(en?Gd():"source"),ee(tn?Ad(i,n):"source"),Ze&&se(Jh(P))}rn||V(Q=>Q.kind==="error"?{kind:"loading",mode:Or}:Q);const nn=window.setTimeout(()=>{Ie||z.signal.aborted||Bi("still_active",{loadingId:fe,filePath:n,fullPath:P,rootPath:i,mode:Or,durationMs:Math.round(performance.now()-Qe),isPathChange:rn})},3e3),os=window.setTimeout(()=>{if(Ie||z.signal.aborted)return;const Q=Ze?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")),V({kind:"error",message:Q}),Ge("stuck_timeout",{error:Q})},Ze?Qh+5e3:rr?Zh+5e3:em(P)?35e3:Bg);if(Ze){const Q=ut==="pcb-3d"?X.current:null;Q?(V(Q),Ge("eda_3d_client_cache_hit",{bytes:Q.meta.size,view:Q.view,mimeType:Q.meta.mimeType})):tm(P,ut,z.signal,"view_file",ke).then(Ke=>{if(z.signal.aborted)return;De=URL.createObjectURL(Ke.blob);const Tt={kind:"eda",sourcePath:Ke.path||P,objectUrl:De,view:Ke.view,meta:{size:Ke.size,mimeType:Ke.mimeType,modified:Ke.modified}};if(Ke.view==="pcb-3d"){const nr=X.current;nr&&nr.objectUrl!==De&&URL.revokeObjectURL(nr.objectUrl),X.current=Tt,G(Tt),De=null}V(Tt),Ge("eda_loaded",{bytes:Ke.size,view:Ke.view,mimeType:Ke.mimeType})}).catch(Ke=>{z.signal.aborted||(V({kind:"error",message:Ke instanceof Error&&/timed out/i.test(Ke.message)?p("rightSidebar.edaTimeout"):Ke instanceof Error?Ke.message:p("rightSidebar.edaLoadFailed")}),Ge("error",{error:Ke instanceof Error?Ke.message:String(Ke)}))})}else if(Mn)rm(P,z.signal,"view_file",ke).then(Q=>{De=URL.createObjectURL(Q.blob),V({kind:"image",objectUrl:De,meta:{size:Q.size,mimeType:Q.mimeType,modified:Q.modified}}),Ge("image_loaded",{bytes:Q.size,mimeType:Q.mimeType})}).catch(Q=>{z.signal.aborted||(V({kind:"error",message:Q instanceof Error?Q.message:p("rightSidebar.imageLoadFailed")}),Ge("error",{error:Q instanceof Error?Q.message:String(Q)}))});else if(rr)nm(P,z.signal,"view_file",ke).then(Q=>{z.signal.aborted||(De=URL.createObjectURL(Q.blob),V({kind:"model3d",sourcePath:Q.path||P,objectUrl:De,ext:Q.ext,meta:{size:Q.size,mimeType:Q.mimeType,modified:Q.modified}}),Ge("model3d_loaded",{bytes:Q.size,ext:Q.ext}))}).catch(Q=>{z.signal.aborted||(V({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")}),Ge("error",{error:Q instanceof Error?Q.message:String(Q)}))});else if(as){const Q=sm(P)??"",Ke=uu(P);V(Tt=>Tt.kind==="video"&&Tt.url===Ke?Tt:{kind:"video",url:Ke,meta:{size:null,mimeType:Q,modified:null}}),Ge("video_ready",{mimeType:Q})}else ld(P,z.signal,"view_file",ke).then(Q=>{if(!z.signal.aborted){if(Q.binary){V({kind:"binary"});return}V({kind:"text",content:Q.content,sourcePath:Q.path||P,meta:{size:Q.size,truncated:Q.truncated}}),Ge("text_loaded",{bytes:Q.size,truncated:!!Q.truncated})}}).catch(Q=>{z.signal.aborted||(V({kind:"error",message:Q instanceof Error?Q.message:"Failed to read file"}),Ge("error",{error:Q instanceof Error?Q.message:String(Q)}))});return()=>{z.abort(),Ct(ke),window.clearTimeout(nn),window.clearTimeout(os),De&&URL.revokeObjectURL(De),Ge("cleanup")}},[n,i,ur,hr,M,p,ie]),a.useEffect(()=>{if(C.kind!=="model3d"||!n){F(null);return}let P=!1;const z=n.lastIndexOf("/"),fe=z>=0?n.slice(z+1):n,ke=z>=0?n.slice(0,z):"",Qe=ke.lastIndexOf("/"),Ie=Qe>=0?ke.slice(0,Qe):"",Ge=fe.replace(/\.(stl|glb|gltf)$/i,""),De=`${Ie?`${Ie}/`:""}features/${Ge}.json`;return ld(De).then(Ze=>{if(!P)try{const ut=JSON.parse(Ze.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"){et(null);return}const P=i&&n&&!n.startsWith("/")?`${i}/${n}`:n,z=wu(P),fe=C.content,ke=$s(P??"")&&ue==="preview",Qe=Ns(P??"")&&E==="preview";if(!z||ke||Qe||!ku(fe)){et(null);return}let Ie=!1;const Ge=De=>{if(Ie||!De.registered(z)){Ie||et(null);return}try{et(ju(De,fe,z))}catch{et(null)}};return Le?Ge(Le):(et(null),Su().then(De=>{Ie||(Je(De),Ge(De))}).catch(()=>{})),()=>{Ie=!0}},[C,Le,n,i,ue,E]),a.useLayoutEffect(()=>{if(!We||C.kind!=="text")return;const P=`${We}:${ue}:${E}`;if(Bt.current===P)return;const z=nu(i,n);if(Bt.current=P,!z)return;const fe=requestAnimationFrame(()=>{const ke=ne.current;if(!ke)return;const Qe=ue==="preview"?z.markdownTop??z.top:z.top;ke.scrollTo({top:Math.max(0,Qe??0),left:Math.max(0,z.left??0)}),R(ue==="preview"?Math.max(0,Qe??0):0)});return()=>cancelAnimationFrame(fe)},[n,ue,E,C.kind,We,i]),a.useEffect(()=>{We&&Li(i,n,{lineRange:$})},[n,$,We,i]),a.useEffect(()=>{if(U==null||C.kind!=="text")return;xe(null),M({start:U,end:U});const P=U,z=requestAnimationFrame(()=>{const fe=q.current.get(P);fe&&fe.scrollIntoView({block:"center"}),I?.()});return()=>cancelAnimationFrame(z)},[U,C,M,I]);const Rn=a.useCallback(P=>{const z=ne.current;if(!z)return!1;const fe=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(P):P.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),ke=z.querySelector(`#${fe}`);return ke?(ke.scrollIntoView({block:"start"}),!0):!1},[]);a.useEffect(()=>{const P=i&&n&&!n.startsWith("/")?`${i}/${n}`:n,z=C.kind==="text"&&$s(P??"")&&ue==="preview";if(!Re||!z)return;const fe=requestAnimationFrame(()=>{Rn(Re)&&Ce(null)});return()=>cancelAnimationFrame(fe)},[n,Rn,ue,Re,C,i]),a.useLayoutEffect(()=>{const P=ne.current;if(!P||!$){xe(null);return}if(de)return;const z=C.kind==="image"||C.kind==="loading"&&C.mode==="image",fe=i&&n&&!n.startsWith("/")?`${i}/${n}`:n,ke=C.kind==="text"&&$s(fe??"")&&ue==="preview",Qe=C.kind==="text"&&Ns(fe??"")&&E==="preview";if(C.kind!=="text"||z||ke||Qe){xe(null);return}const Ie=()=>{const De=q.current.get($.end);if(!De||!P){xe(null);return}const Ze=De.offsetTop+De.offsetHeight/2,ut=P.scrollLeft+Math.max(8,P.clientWidth-120);xe({top:Ze,left:ut})};Ie();const Ge=new ResizeObserver(()=>Ie());return Ge.observe(P),()=>Ge.disconnect()},[$,de,C,ue,E,n,i,Ee]);const Tr=C.kind==="text"&&!(Ns(mt??"")&&E==="preview")&&!mt?.toLowerCase().endsWith(".csv")&&!mt?.toLowerCase().endsWith(".kicad_pro")&&!mt?.toLowerCase().endsWith(".kicad_prl"),pr=a.useCallback(()=>{Oe(!1),tt(""),Pr([]),H(0),Ya()},[]),Cn=a.useCallback(()=>{Tr&&(Oe(!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 fe=wg(z);if(fe==="open"&&Tr){z.preventDefault(),Cn();return}Te&&(fe==="close"?(z.preventDefault(),pr()):(fe==="next"||fe==="previous")&&(z.preventDefault(),gt(fe==="previous"?-1:1)))};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[pr,Te,gt,Cn,Tr]),a.useLayoutEffect(()=>{if(Ya(),!Te||!St.trim()||!ne.current){Pr([]),H(0);return}const P=Sg(ne.current,St);return Pr(P),H(0),Dd(P,0),Fd(P[0]),Ya},[Te,St,Ee,ue,C]),a.useEffect(()=>{Te&&(Dd(dt,_t),Fd(dt[_t]))},[_t,dt,Te]),a.useEffect(()=>Ya,[]),!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 He=i&&!n.startsWith("/")?`${i}/${n}`:n,At=io(He,i),gr=hu(He,i),br=C.kind==="text"&&C.content?C.content.split(`
|
|
1654
|
-
`):[],Ks=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=$s(He),Vs=He.toLowerCase().endsWith(".csv"),Pt=He.toLowerCase().endsWith(".kicad_pro"),Zn=He.toLowerCase().endsWith(".kicad_prl"),Ot=C.kind==="text"&&vr&&ue==="preview",qs=Ns(He),yr=C.kind==="text"&&qs&&E==="preview",Ys=C.kind==="image"||C.kind==="loading"&&C.mode==="image",ko=C.kind==="model3d"||C.kind==="loading"&&C.mode==="model3d",Mt=C.kind==="video"||C.kind==="loading"&&C.mode==="video",Xr=C.kind==="eda"||C.kind==="loading"&&C.mode==="eda",es=C.kind==="text"?C.sourcePath:He,Ir=$m(es,i,$),Dr=(()=>{if(!$||C.kind!=="text"||br.length===0)return Ir;const P=[];for(let ke=$.start;ke<=$.end;ke+=1)P.push(`${ke} ${br[ke-1]??""}`);const z=Xu(He).replace(/^\./,""),fe="```";return`${Ir}
|
|
1655
|
-
${fe}${z}
|
|
1656
|
-
${P.join(`
|
|
1657
|
-
`)}
|
|
1658
|
-
${fe}
|
|
1659
|
-
`})(),wr=`path:${He}`,kr=$?`path:${He}:${$.start}-${$.end}`:wr,Fr=L===wr,_r=L===kr,Nn=T===wr,ts=T===kr,Jr=_r||ts,Yt=$?$.start===$.end?`L${$.start}`:`L${$.start}-${$.end}`:null,Br=P=>{const z=ne.current;if(!z)return;const fe=z.getBoundingClientRect(),ke=P.currentTarget.getBoundingClientRect(),Qe=P.clientX||ke.left+ke.width/2,Ge=(P.clientY||ke.top+ke.height/2)-fe.top+z.scrollTop,De=g?116:132,Ze=z.scrollLeft+Math.max(8,z.clientWidth-De),ut=Math.min(Math.max(8,Qe-fe.left+z.scrollLeft+10),Ze);xe({top:Ge,left:ut})},rs=(P,z)=>{Wi()||(Br(P),M(fe=>{const ke=Gi(fe,z,z);return ke||xe(null),ke}))},ns=(P,z,fe)=>{Br(P),M(ke=>{const Qe=Gi(ke,z,fe);return Qe||xe(null),Qe})},Sr=(P,z,fe,ke)=>{ke==="end"&&Br(P),M({start:z,end:fe})},tr=P=>{const{scrollTop:z,scrollLeft:fe}=P.currentTarget;R(z),Li(i,n,{top:z,left:fe,markdownTop:z})},ye=P=>{if(P.directory){m?.(P.path);return}if(P.path===He||C.kind==="text"&&P.path===C.sourcePath){P.fragment&&Rn(P.fragment);return}le(z=>[...z,He]),ze.current=P.path,Ce(P.fragment),M(null),O(P.path)},Xt=()=>{const P=re[re.length-1];P&&(le(z=>z.slice(0,-1)),ze.current=P,Ce(null),M(null),O(P))},Qr=P=>{const{scrollTop:z,scrollLeft:fe}=P.currentTarget;Li(i,n,{top:z,left:fe})},Zr=()=>{if(r){r(Dr,kr);return}$&&l(Dr,kr)},ss=async()=>{if(!(!He||Pe.status==="pending")&&!(C.kind==="loading"||C.kind==="error")){W({status:"pending"});try{await xm(He),W({status:"idle"})}catch(P){W({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:[ve.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${g&&(Ot||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(bu,{size:16})}),re.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(Bs,{size:15}),!g&&e.jsx("span",{className:"text-[11px] font-medium",children:p("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:He,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:At.name}),At.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:At.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Tr&&e.jsx("button",{type:"button",onClick:Te?pr:Cn,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 ${Te?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":p("rightSidebar.findInFile"),title:`${p("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(Jn,{size:14})}),vr&&C.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{b&&y?.(),Ae(P=>{const z=P==="preview"?"source":"preview";return Lt(Du,z),z}),M(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(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:p(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:g?ue==="preview"?e.jsx(Vi,{size:14}):e.jsx(Ki,{size:14}):p(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),qs&&C.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{ee(P=>{const z=P==="preview"?"source":"preview";return Up(i,n,z),z}),M(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(E==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:p(E==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:g?E==="preview"?e.jsx(Vi,{size:14}):e.jsx(Ki,{size:14}):p(E==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),yr&&e.jsx("button",{type:"button",onClick:()=>{pe.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($e?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:p($e?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(xu,{size:15})}),!g&&e.jsx("button",{type:"button",onClick:()=>s(He,wr),...ve(gr,wr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${Fr||Nn?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:p("rightSidebar.insertReference",{reference:gr}),children:p(Nn?"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(am,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{ss()},disabled:Pe.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:Pe.status==="error"?Pe.message??p("rightSidebar.downloadFailed"):p("rightSidebar.downloadFile"),"aria-label":p("rightSidebar.downloadFile"),children:Pe.status==="pending"?e.jsx(Nt,{size:13,className:"animate-spin"}):e.jsx(Lm,{size:14})})]})]}),Te&&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(Jn,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:ae,type:"search",value:St,onChange:P=>tt(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?`${_t+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(mu,{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(Am,{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(qt,{size:13})})]}),xr&&!(g&&(Ot||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&&(Ot||yr))&&!ko&&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"):Vs?p("rightSidebar.csvTablePreview"):Pt||Zn?p("rightSidebar.kicadProjectPickHint"):Mt?p("rightSidebar.videoPreviewHint"):Ys?p("rightSidebar.imagePreviewHint"):Ot?$?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:jn,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(Lu,{blobUrl:C.objectUrl,filePath:He,viewLabel:"SVG 文件",onInsertAnnotation:u}):e.jsx(Df,{src:C.objectUrl,alt:At.name,vector:!1,onLoad:P=>{const z=P.currentTarget;V(fe=>fe.kind==="image"?{...fe,dimensions:{width:z.naturalWidth,height:z.naturalHeight}}:fe)},onError:()=>V({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(Zp,{url:C.url,onLoadError:()=>V({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(og,{blobUrl:C.objectUrl,filePath:C.sourcePath,view:C.view,board:He.toLowerCase().endsWith(".kicad_pcb"),onViewChange:se,onInsertAnnotation:r??u,onRefresh:jn,interactive3d:be?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(Wd,{blobUrl:be.objectUrl,ext:".glb",fileName:At.name,filePath:be.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(Wd,{blobUrl:C.objectUrl,ext:C.ext,fileName:At.name,filePath:C.sourcePath,features:A,onInsertFeature:r??u,onRefresh:jn})})}):C.kind==="text"&&Vs?e.jsx(cg,{content:C.content,filePath:He,onInsertAnnotation:r??u},He):C.kind==="text"&&(Pt||Zn)?e.jsx(fg,{content:C.content,filePath:He,localState:Zn,onInsertAnnotation:r??u},He):Ot?e.jsxs("div",{ref:ne,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(Rf,{content:C.content,filePath:C.sourcePath,rootPath:i,lineRange:$,onLineRangeClick:ns,onLineRangeDrag:Sr,scrollTop:Fe,outlineOpen:b,outlineCloseSignal:f,onOutlineOpen:S,onOutlineClose:y,lightboxOpen:N,lightboxCloseSignal:D,onLightboxOpen:_,onLightboxClose:B,onLocalLinkOpen:ye}),$&&de&&e.jsxs("button",{type:"button",onClick:Zr,...ve(Dr,kr),style:{top:de.top,left:de.left,transform:"translateY(-50%)"},className:Nd(g,Jr),title:`Insert markdown reference: ${Ir}`,children:[e.jsx(co,{size:g?13:11}),ts?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(yg,{ref:pe,src:om(He),title:`${At.name} preview`,exitFullscreenLabel:p("rightSidebar.htmlFullscreenExit"),onFullscreenChange:Ye},`${He}:${ur}:${hr}`)}):C.kind==="text"?e.jsxs("div",{ref:ne,onScroll:Qr,className:`${fl} 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 fe=z+1,ke=!!($&&fe>=$.start&&fe<=$.end),Qe=Ee&&Ee.length===br.length?Ee[z]:null;return e.jsxs("div",{ref:Ie=>{Ie?q.current.set(fe,Ie):q.current.delete(fe)},role:"button","data-file-preview-line":fe,tabIndex:0,onClick:Ie=>rs(Ie,fe),onKeyDown:Ie=>{Ie.key!=="Enter"&&Ie.key!==" "||(Ie.preventDefault(),rs(Ie,fe))},style:{gridTemplateColumns:`${Ks}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${ke?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${gr}:${fe}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${ke?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:fe}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Qe??(P||" ")})]},z)})}):"Empty file.",$&&de&&e.jsxs("button",{type:"button",onClick:Zr,...ve(Dr,kr),style:{top:de.top,left:de.left,transform:"translateY(-50%)"},className:Nd(g,Jr),title:`Insert code reference: ${Ir}`,children:[e.jsx(co,{size:g?13:11}),ts?p("rightSidebar.copied"):_r?p("rightSidebar.inserted"):p("rightSidebar.insertLineRef",{lineLabel:Yt??""})]})]}):null]})}function nx({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:D,onCloseRightSidebarRepoPicker:_,markdownOutlineOpen:B=!1,markdownOutlineCloseSignal:$,onOpenMarkdownOutline:M,onCloseMarkdownOutline:L,markdownImageLightboxOpen:T=!1,markdownImageLightboxCloseSignal:U,onOpenMarkdownImageLightbox:I,onCloseMarkdownImageLightbox:p}){const{t:i,locale:O}=kt(),[C,V]=a.useState(""),[ie,se]=a.useState(null),be=J(t=>t.rightSearchOpen),G=J(t=>t.setRightSearchOpen),X=J(t=>t.rightSidebarLayoutPreference),A=J(t=>t.setRightSidebarLayoutPreference),[F,q]=a.useState(()=>Xg()),[ne,de]=a.useState("."),[xe,ue]=a.useState(""),[Ae,E]=a.useState(!1),[ee,pe]=a.useState(!1),[$e,Ye]=a.useState(!1),[Le,Je]=a.useState(!1),Fe=a.useDeferredValue(C),[R,re]=a.useState(null),[le,Re]=a.useState([]),[Ce,ze]=a.useState([]),ce=J(t=>t.contextKey?t.activeGitRepos[t.contextKey]??null:null),Ee=J(t=>t.setActiveGitRepo),[et,Pe]=a.useState(null),[W,Te]=a.useState(null),[Oe,St]=a.useState(null),[tt,dt]=a.useState(()=>ht(Bd,Ts)??!1),[Pr,_t]=a.useState(()=>ht(Od,Ts)??!1),[H,ae]=a.useState(()=>ht(Ud,Ts)??!1),[ve,We]=a.useState(()=>ht(Ci,Gg)??""),[mt,ur]=a.useState(0),[fr,Bt]=a.useState(!1),[hr,mr]=a.useState(!1),jn=a.useRef(null),Rn=a.useRef(null),[Tr,pr]=a.useState(!1),[Cn,gt]=a.useState(null),[He,At]=a.useState(null),[gr,br]=a.useState(()=>Kd(ji)),[Ks,xr]=a.useState(()=>Kd(_d)),[vr,Vs]=a.useState(()=>Wg()),[Pt,Zn]=a.useState(()=>Kg()),[Ot,qs]=a.useState(()=>qg()),yr="words",[Ys,ko]=a.useState(0),[Mt,Xr]=a.useState([]),[es,Ir]=a.useState([]),[Dr,wr]=a.useState(!1),[kr,Fr]=a.useState(null),[_r,Nn]=a.useState([]),[ts,Jr]=a.useState(!1),[Yt,Br]=a.useState([]),[rs,ns]=a.useState([]),[Sr,tr]=a.useState(!1),[ye,Xt]=a.useState(null),[Qr,Zr]=a.useState([]),[ss,P]=a.useState({}),z=a.useRef(0),[fe,ke]=a.useState(0),[Qe,Ie]=a.useState(!1),[Ge,De]=a.useState(null),[Ze,ut]=a.useState(null),[Mn,rr]=a.useState(null),[as,en]=a.useState(null),[tn,Or]=a.useState(!1),[rn,nn]=a.useState(""),os=a.useDeferredValue(rn),[Q,Ke]=a.useState({}),[Tt,nr]=a.useState([]),[Xs,is]=a.useState(!1),[Js,ls]=a.useState(!1),[kl,En]=a.useState(null),[So,$n]=a.useState(!1),sr=a.useRef(null),Ur=a.useRef(0),Sl=a.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Ff,Qs]=a.useState(null),[cs,jl]=a.useState(()=>ht(Ri,Ts)??!1),[jo,Ro]=a.useState(!1),[Zs,Co]=a.useState([]),[Jt,ea]=a.useState({}),[Et,ta]=a.useState({}),[sn,No]=a.useState({}),[Rl,Cl]=a.useState(()=>new Set),[Ve,an]=a.useState(null),[Mo,on]=a.useState(null),[_f,jr]=a.useState(!1),[Nl,Rr]=a.useState(0),[,Eo]=a.useState(0),[$o,ra]=a.useState(!1),[ar,Lo]=a.useState(!1),[Bf,Ml]=a.useState(()=>J.getState().rightTab==="diff"),[Ao,El]=a.useState(()=>J.getState().rightTab==="android"),[Hr,$l]=a.useState(!1),na=xi(t=>t.docks[yi]),Of=!!na,[Ue,ds]=a.useState(null),[Ln,us]=a.useState(null),[bt,ln]=a.useState(null),[Ll,xt]=a.useState(null),[An,Al]=a.useState(null),[Po,Uf]=a.useState(()=>Date.now()),[Hf,zf]=a.useState(!1),[cn,sa]=a.useState(!1),[aa,Pl]=a.useState(""),[Pn,oa]=a.useState(""),[dn,ia]=a.useState(""),[un,la]=a.useState(""),[Tl,Tn]=a.useState(null),[ca,da]=a.useState(!1),[Il,To]=a.useState(!1),[Dl,Fl]=a.useState(!1),[ua,Wf]=a.useState({key:null,nonce:0}),_l=a.useRef(null),Bl=a.useRef(null),te=vm(s,h,X),Gf=Ku(te,h,Ot),[Io,Do]=a.useState(()=>nb(s)),Fo=J(t=>t.rightTab),Qt=J(t=>t.setRightTab),x=J(t=>t.rootPath),In=J(t=>t.explorerRoot),Ol=J(t=>t.pinnedExplorerRootsCache),Ul=J(t=>t.hydratePinnedExplorerRoots),Hl=J(t=>t.syncPinnedExplorerRoots),Ut=J(t=>t.setExplorerRoot),zl=J(t=>t.resetExplorerToProject),Dn=J(t=>t.pinExplorerRoot),fn=J(t=>t.unpinExplorerRoot),st=J(t=>t.selectedFilePath),at=J(t=>t.selectFile),_o=J(t=>t.showHiddenFiles),Kf=J(t=>t.toggleShowHiddenFiles),Bo=J(t=>!!(x&&t.nestedGitScanRoots[x])),Se=J(t=>t.changedFiles),fa=J(t=>t.setChangedFiles),ha=J(t=>t.invalidateDirectoryCache),Vf=J(t=>t.setDirectorySortMode),Wl=J(t=>t.applyFileWatchEvents),Gl=J(t=>t.reconcileDirectoryCache),Kl=J(t=>t.bumpFileWatchEpoch),zr=J(t=>t.gitBundleLoading),Vl=J(t=>t.gitBundleSlow),hn=J(t=>t.gitBundleError),Fn=J(t=>t.gitBundleLastLoadedAt),ql=J(t=>t.beginGitBundleLoading),Yl=J(t=>t.setGitBundleSlowFor),Oo=J(t=>t.finishGitBundleLoading),ma=J(t=>t.resetGitBundleLoading),Uo=J(t=>t.setGitBundleError),Xl=J(t=>t.markGitBundleLoaded),ge=In??x,Jl=a.useMemo(()=>ge?Rg(ge,ne):"",[ge,ne]),fs=a.useMemo(()=>jg(xe),[xe]),Ql=a.useMemo(()=>({excludePatterns:fs,caseSensitive:ee,wholeWord:$e,regex:Le}),[ee,fs,Le,$e]),pa=J(t=>ge?t.fileSortModes[ge]??"name":"name"),Zl=J(t=>!!(ge&&t.directoryCache.has(ge))),_n=a.useRef(null),jt=a.useRef(0),[ec]=a.useState(()=>++Jb),Cr=a.useRef(null),Wr=a.useRef(null),ga=a.useRef(0),Ht=a.useRef(new Map),zt=a.useRef(new Map),or=a.useRef(new Set),mn=a.useRef(new Set),pn=a.useRef(0),Gr=a.useRef(null),Bn=a.useRef(0),On=a.useRef(null),Un=a.useRef(0),Kr=a.useRef(null),Ho=a.useRef(new Set),zo=a.useRef(null),Wo=a.useRef(null),ba=a.useRef(null),Go=a.useRef(null),Ko=a.useRef(null),hs=a.useRef(new Set);a.useEffect(()=>{if(An===null)return;const t=Math.max(0,Date.now()-An),o=t<6e4?1e3:t<36e5?6e4:t<864e5?36e5:864e5,c=Math.max(50,o-t%o),v=window.setTimeout(()=>Uf(Date.now()),c);return()=>window.clearTimeout(v)},[Po,An]);const xa=a.useRef(null),Nr=a.useRef(null),va=a.useRef(null),ms=a.useRef(null),je=a.useCallback(t=>J.getState().rootPath===t,[]);a.useEffect(()=>{if(!r||typeof window>"u")return;const t=o=>{const c=tx(o.target);c&&ro("global_change_row_event",{...rx(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 tc=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=ga.current+1;ga.current=c,Ht.current.set(t,c);const v=`right-sidebar-git-untracked:${t}`,w=new AbortController;zt.current.set(t,w),mn.current.add(t),lt("untracked_start",{requestId:c,cwd:t,rootPath:x});try{let k=await cd(t,w.signal,v),j=0;for(;k.status==="running"&&j<120;){if(Ht.current.get(t)!==c||w.signal.aborted)return lt("untracked_stale_result",{requestId:c,activeRequestId:Ht.current.get(t),cwd:t,status:k.status}),null;if(!je(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 cd(t,w.signal,v)}if(Ht.current.get(t)!==c||!je(o))return lt("untracked_stale_result",{requestId:c,activeRequestId:Ht.current.get(t),cwd:t,expectedRootPath:o,currentRootPath:J.getState().rootPath,files:k.files.length,status:k.status}),null;if(k.status==="done")return fa(Ef(J.getState().changedFiles,k.files)),k.files.length>0&&Re(Z=>{const Me=new Map(Z.map(Ne=>[Ne.root,Ne])).get(t);if(!Me)return Z;const qe=Bb(Me.files,k.files),K=Z.map(Ne=>Ne.root===t?{...Ne,files:qe,context:Ne.context?{...Ne.context,changedFiles:qe.map(Be=>({path:Be.path,absolutePath:Be.absolutePath,status:Be.status})),truncated:!1}:Ne.context,untrackedDeferred:!1}:Ne);ze($f(K,x));const Y=K.find(Ne=>Ne.root===x);return Y?.context&&re(Ne=>Ne?.root===Y.root?{...Ne,...Y.context}:Ne),K}),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(Ht.current.get(t)!==c||!je(o)||dr(k))return lt("untracked_aborted",{requestId:c,activeRequestId:Ht.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{zt.current.get(t)===w&&zt.current.delete(t),Ht.current.get(t)===c&&Ht.current.delete(t),mn.current.delete(t)}},[R,je,x,fa]),Zt=a.useMemo(()=>{const t=new Set(Ce.map(c=>c.root)),o=_r.filter(c=>t.has(c));return o.length>0?o:ce?[ce]:[]},[ce,_r,Ce]),rc=Zt.length===0,gn=a.useMemo(()=>Zt.map(t=>le.find(o=>o.root===t)).filter(t=>!!t),[Zt,le]),qf=a.useMemo(()=>Ce.map(t=>({root:t.root,label:t.label,branch:t.branch??null})),[Ce]),ir=a.useCallback(async()=>{if(!x){Xr([]),Ir([]);return}const t=x,o=Bn.current+1;Bn.current=o,On.current?.abort();const c=new AbortController;On.current=c,wr(Mt.length===0),Fr(null);try{const v=Zt.length>0?await Promise.all(Zt.map(w=>dd({workspaceRoot:x,repoRoot:w},c.signal))).then(w=>({records:w.flatMap(k=>k.records),walkthroughs:w.flatMap(k=>k.walkthroughs??[])})):await dd({workspaceRoot:x},c.signal);if(Bn.current!==o||!je(t))return;Xr(v.records),Ir(v.walkthroughs??[])}catch(v){if(Bn.current!==o||!je(t)||dr(v))return;Fr(v instanceof Error?v.message:"Failed to load change audit explanations")}finally{On.current===c&&(On.current=null),Bn.current===o&&je(t)&&wr(!1)}},[Mt.length,Zt,je,x]),ya=a.useCallback(async(t,o,c)=>{if(!t&&!x){Br([]),ns([]);return}const v=x,w=Un.current+1;Un.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=>lm({repoRoot:Z,baseRef:o,branchName:c},k.signal))).then(Z=>{const me=new Map,Me=new Map;for(const qe of Z){for(const K of qe.records)me.set(K.id,K);for(const K of qe.walkthroughs??[])Me.set(K.id,K)}return{records:Array.from(me.values()),walkthroughs:Array.from(Me.values())}});if(Un.current!==w||!je(v))return;Br(oe.records),ns(oe.walkthroughs??[])}catch(j){if(Un.current!==w||!je(v)||dr(j))return;console.warn("[RightSidebar] Failed to load branch explanations",j)}finally{Kr.current===k&&(Kr.current=null)}},[le,je,x]),Hn=a.useCallback((t,o={})=>{if(!je(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=Vu(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(Be=>!Be.deferred||Be.root===x).map(Be=>Be.root));w=[...Array.from(k.values()).filter(Be=>!Y.has(pt(Be,x)??"")),...t.files]}const Z=su(k.values(),x),me=su(t.files,x),Me=c.some(Y=>Y.root!==x);if(!!(o.background&&!oe&&!o.replaceWorkspace&&k.size>0&&(t.files.length===0&&!t.error||Z>0&&me===0&&!Me))){lt("background_apply_skipped_degraded_bundle",{rootPath:x,currentFiles:k.size,nextFiles:t.files.length,currentNestedCount:Z,nextNestedCount:me,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=Lf(k.values(),le,t,o.replaceRepoRoot,x);w=Y.files,c=Y.repositories,v=Y.repoFilters}if(fa(Mf(w)),Re(c),ze(v),Ko.current=x,o.syncActiveRepo!==!1){const{contextKey:Y,activeGitRepos:Ne}=J.getState(),Be=Y?Ne[Y]??null:null,nt=o.activeRepoRoot!==void 0?o.activeRepoRoot:Be,_e=Jg({...t,repositories:c,repoFilters:v},nt);Ee(_e)}typeof t.cacheUpdatedAt=="number"&&Al(t.cacheUpdatedAt),re(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&&ko(Y=>Y+1);const K=J.getState().selectedFilePath;if(K&&!K.startsWith("/")&&!w.some(Y=>Y.path===K||Y.absolutePath===K)&&at(null),br(Y=>{const Ne=new Set(w.map(nt=>pt(nt,x)).filter(Boolean)),Be=new Set;for(const nt of Y)Ne.has(nt)&&Be.add(nt);return Mi(ji,Be),Be}),o.loadDeferred!==!1){const Y=c.filter(Ne=>Ne.untrackedDeferred&&Ne.root).map(Ne=>Ne.root);for(const Ne of Y)tc(Ne)}o.loadAudit!==!1&&ir()},[je,ir,tc,x,at,Ee,fa]);a.useEffect(()=>{ma(),zo.current=null,Wo.current=x;const t=[],o=[];jt.current+=1,pn.current+=1,ga.current+=1,Cr.current?.abort(),Ct(Ls(Wr.current?.cwd??x??void 0)),Wr.current=null,Cr.current=null,Gr.current?.abort(),Ct("right-sidebar-git-details"),Gr.current=null;for(const j of zt.current.values())j.abort();for(const j of zt.current.keys())Ct(`right-sidebar-git-untracked:${j}`);zt.current.clear(),Ht.current.clear(),Bn.current+=1,On.current?.abort(),On.current=null,Un.current+=1,Kr.current?.abort(),Kr.current=null,Ur.current+=1,sr.current?.abort(),Ct("right-sidebar-recent-commits"),sr.current=null,Xr([]),Ir([]),wr(!1),Fr(null),Nn([]),Jr(!1),Br([]),ns([]),tr(!1),Xt(null),Ie(!1),De(null),ut(null),rr(null),en(null),Or(!1),nn(""),nr([]),is(!1),ls(!1),En(null),$n(!1),Qs(null),an(null),on(null),jl(!1),Lt(Ri,!1),Ro(!1);const c=x?Vd()[x]:null,v=c?.previewEntries??[],w=c?.selectedPreviewKey??null,k=w?v.find(j=>j.key===w)??null:null;++z.current,Ie(!1),Co(c?.selectedRepoRoots??[]),ea(c?.repoTargetBranches??{}),ta(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)),No(c?.repoIncludeUncommitted??Object.fromEntries(Object.keys(c?.repoTargetBranches??{}).map(j=>[j,c?.includeUncommitted??!0]))),zo.current=x,sa(!1),or.current.clear(),mn.current.clear(),ds(null),us(null),ln(null),xt(null),Al(null),Re(t),ze(o),re(null),Go.current=null,Ko.current=null,hs.current.clear()},[ma,x]);const It=a.useCallback(async(t=x??void 0,o={})=>{if(!t)return null;const c=x,v=jt.current;if(await hp(()=>Promise.all([J.getState().hydrateNestedGitScanRoots(),J.getState().hydrateActiveGitRepos()]).then(()=>{})),jt.current!==v||!je(c))return null;const w=t===x&&Es(x),k=o.includeNested??w,j=o.refresh??o.reloadDiff??!1,oe=o.cacheOnly??!1,Z=o.background??!1,me=k&&(o.discoverOnly??!1);j&&or.current.clear();const Me=Wr.current;if(Me&&Me.cwd===t&&Me.includeNested===k&&Me.refresh===j&&Me.cacheOnly===oe&&Me.discoverOnly===me)return lt("reuse_pending",{cwd:t,includeNested:k,refresh:j,cacheOnly:oe,discoverOnly:me}),Me.promise;const qe=jt.current+1;jt.current=qe;const K=`right-sidebar:${ec}:${qe}`;Cr.current?.abort();const Y=Ls(t);Ct(Y);const Ne=new AbortController;Cr.current=Ne;let Be=null;Z||ql(K),Uo(null),lt("start",{requestId:qe,cwd:t,rootPath:x,requestSlotId:Y,includeNested:k,refresh:j,cacheOnly:oe,background:Z,existingChanges:Se.size,lastLoadedAt:Fn}),!Z&&typeof window<"u"&&(Be=window.setTimeout(()=>{jt.current===qe&&Yl(K,!0)},Tg));const nt=(async()=>{const _e=await vi(t,Ne.signal,{includeNested:k,refresh:j,cacheOnly:oe,discoverOnly:me,action:j?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:Y,requestTimeoutMs:j?null:void 0});if(Hb(_e)){if(lt("cancelled_result_ignored",{requestId:qe,activeRequestId:jt.current,cwd:t,error:_e.error??_e.context?.error}),Ne.signal.aborted)return null;throw new Error(_e.error??_e.context?.error??"Failed to load Git changes")}return jt.current!==qe||!je(c)?(lt("stale_result",{requestId:qe,activeRequestId:jt.current,cwd:t,expectedRootPath:c,currentRootPath:J.getState().rootPath,files:_e.files.length,repositories:_e.repositories?.length??0}),null):(Hn(_e,{reloadDiff:o.reloadDiff,syncActiveRepo:o.replaceWorkspace?!0:k,background:Z,cacheOnly:oe,replaceRepoRoot:o.replaceRepoRoot,replaceWorkspace:o.replaceWorkspace}),_e)})();Wr.current={cwd:t,includeNested:k,refresh:j,cacheOnly:oe,discoverOnly:me,promise:nt};try{const _e=await nt;return jt.current===qe&&_e&&je(c)?Xl({cached:_e.cached,stale:_e.stale,cacheAgeMs:_e.cacheAgeMs,nestedDeferred:!k||_e.nestedDeferred,untrackedDeferred:_e.untrackedDeferred}):jt.current===qe&&je(c)&&Oo(K),_e}catch(_e){return jt.current!==qe||!je(c)||Ne.signal.aborted?(lt("aborted",{requestId:qe,activeRequestId:jt.current,cwd:t,expectedRootPath:c,currentRootPath:J.getState().rootPath,message:_e instanceof Error?_e.message:String(_e)}),null):(lt("error",{requestId:qe,cwd:t,includeNested:k,refresh:j,background:Z,message:_e instanceof Error?_e.message:String(_e)}),Z||(re(null),Uo(_e instanceof Error?_e.message:"Failed to load Git changes")),null)}finally{Be!==null&&window.clearTimeout(Be),Cr.current===Ne&&(Cr.current=null),Wr.current?.promise===nt&&(Wr.current=null),!Z&&jt.current===qe&&je(c)&&Oo(K)}},[Hn,ql,Se.size,Oo,ec,Fn,je,Xl,x,Uo,Yl]),ps=a.useCallback(async()=>{x&&await It(x,{reloadDiff:!0,refresh:!0})},[It,x]),Vo=a.useCallback(async(t=x??void 0)=>{if(!t)return null;const o=x,c=pn.current+1;pn.current=c,Gr.current?.abort(),Ct("right-sidebar-git-details");const v=new AbortController;Gr.current=v,sa(!0);try{const w=await ud(t,v.signal,"load_git_details","right-sidebar-git-details");return pn.current!==c||!je(o)?null:(Re(k=>k.map(j=>j.root===w.root?{...j,available:w.available,context:w,error:w.error}:j)),re(k=>k?.root&&w.root&&k.root!==w.root?k:!k?.available||!w.available?w:{...k,...w}),w)}catch(w){return dr(w)||!je(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&&je(o)&&sa(!1)}},[je,x]);a.useEffect(()=>{if(!r){jt.current+=1,ma(),Go.current=null,pn.current+=1,ga.current+=1,Cr.current?.abort(),Ct(Ls(Wr.current?.cwd??x??void 0)),Wr.current=null,Cr.current=null,Gr.current?.abort(),Ct("right-sidebar-git-details"),Gr.current=null;for(const t of zt.current.values())t.abort();for(const t of zt.current.keys())Ct(`right-sidebar-git-untracked:${t}`);zt.current.clear(),Ht.current.clear(),Un.current+=1,Kr.current?.abort(),Kr.current=null,Ur.current+=1,sr.current?.abort(),Ct("right-sidebar-recent-commits"),sr.current=null,sa(!1),Ie(!1),De(null),ut(null),rr(null),en(null),Or(!1),nn(""),nr([]),is(!1),ls(!1),En(null),$n(!1),V(""),G(!1),gt(null),Lo(!1),te&&Ml(!1)}},[te,r,ma,G]),a.useEffect(()=>{if(!be)return;const t=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(t)},[be]),a.useEffect(()=>{te||jr(!1)},[te]);const gs=a.useCallback(t=>{Eo(t);const o=va.current;o&&(o.update(),o.slideTo(t,0),window.requestAnimationFrame(()=>{o.update(),o.slideTo(t,0)}))},[]);a.useEffect(()=>{if(te)if(jr(g),g&&st){Rr(1);const t=Nr.current;t&&(t.update(),t.activeIndex!==1&&(ms.current=1,t.slideTo(1,0)))}else{Rr(0);const t=Nr.current;t&&t.activeIndex!==0&&(ms.current=0,t.slideTo(0,0)),gt(null)}},[te,g,x,st]),a.useEffect(()=>{if(b!==void 0&&!g){Rr(0);const t=Nr.current;t&&t.activeIndex!==0&&(ms.current=0,t.slideTo(0,0)),jr(!1),gt(null)}},[b,g]),a.useEffect(()=>{N!==void 0&&Pe(null)},[N]),a.useEffect(()=>{!te&&g&&S?.()},[te,S,g]),a.useEffect(()=>{Do(t=>tl(t,s))},[s]);const Yf=a.useCallback(t=>{te||(t.preventDefault(),xa.current={startX:t.clientX,startWidth:Io,pointerId:t.pointerId},t.currentTarget.setPointerCapture(t.pointerId))},[Io,te]),Xf=a.useCallback(t=>{const o=xa.current;if(!o||o.pointerId!==t.pointerId)return;const c=tl(o.startWidth+t.clientX-o.startX,s);Do(c),Is(Ps,c,Pg)},[s]),nc=a.useCallback(t=>{const o=xa.current;if(!(!o||o.pointerId!==t.pointerId)){xa.current=null,Ms(Ps);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}},[]),zn=!!(x&&Fn!==null&&iu(R)),qo=!!(x&&!hn&&Se.size===0&&Fn===null),lr=(()=>{let t=Fo;return t==="android"&&!Hr&&(t="files"),zn&&(t==="git"||t==="diff")&&(t="files"),t})(),ot=lr==="git",Wn=lr==="files",Rt=lr==="diff",Gn=lr==="android",Jf=Pm(t=>t.overlay==="sidebar")&&Gn;a.useEffect(()=>{if(!te){ra(!0);return}if(!r){const o=window.setTimeout(()=>{ra(!1)},Fg);return()=>window.clearTimeout(o)}ra(!1);const t=window.setTimeout(()=>{ra(!0)},Dg);return()=>window.clearTimeout(t)},[te,r]),a.useEffect(()=>{if(!te||!Rt)return;const t=va.current;if(!t)return;const o=window.requestAnimationFrame(()=>{t.update()});return()=>window.cancelAnimationFrame(o)},[Rt,te]),a.useEffect(()=>{if(!zn||!x||zr)return;const t=window.setTimeout(()=>{It(x,{background:!0})},3e3);return()=>window.clearTimeout(t)},[zn,x,zr,It]);const Qf=a.useCallback(t=>{It(t,{discoverOnly:!0})},[It]);mp({active:r&&(ot||Rt),rootPath:x,loading:zr,delay:ot&&!te?0:Ni,lastStartedRoot:Go,load:Qf}),a.useEffect(()=>{!r||!ot||(!te||$o)&&Lo(!0)},[ot,te,r,$o]),a.useEffect(()=>{if(!r||ot)return;const t=window.setTimeout(()=>{Lo(!0)},Ni);return()=>window.clearTimeout(t)},[ot,r]),a.useEffect(()=>{Rt&&Ml(!0)},[Rt]),a.useEffect(()=>{!r||!Gn||(n&&na&&na.sessionId!==n&&(xi.getState().setDock(yi,null),no({androidPanel:{docked:null}}).catch(()=>{})),El(!0))},[Gn,r,n,na]),a.useEffect(()=>{if(r&&Gn||!Ao)return;const t=window.setTimeout(()=>El(!1),Ig);return()=>window.clearTimeout(t)},[r,Gn,Ao]),a.useEffect(()=>{let t=!1;return cu().then(o=>{!t&&o.androidPanel&&$l(o.androidPanel.enabled===!0)}).catch(()=>{}),()=>{t=!0}},[]);const Zf=a.useCallback(t=>{$l(t),t?Qt("android"):J.getState().rightTab==="android"&&Qt("files"),no({androidPanel:{enabled:t}}).catch(()=>{})},[Qt]),sc=a.useCallback(t=>{ge&&Tb(ge,t.currentTarget.scrollTop)},[ge]);a.useEffect(()=>()=>{Cr.current?.abort(),Ms(dl),Ms(ul),Ms(Ps),Ms(Ci)},[]),a.useEffect(()=>{if(!ge||!Zl)return;const t=Cf()[ge]?.top;if(typeof t!="number")return;let o=window.requestAnimationFrame(()=>{_n.current&&(_n.current.scrollTop=t),o=window.requestAnimationFrame(()=>{_n.current&&(_n.current.scrollTop=t)})});return()=>window.cancelAnimationFrame(o)},[ge,Zl]),a.useEffect(()=>{if(!r)return;const t=new AbortController;return cm(t.signal).then(o=>Fl(!!o.available)).catch(()=>Fl(!1)),()=>t.abort()},[r]);const bs=a.useCallback(t=>{if(se(null),at(t),gt(null),te){jr(!0),Rr(1),Nr.current?.slideTo(1),f?.();return}},[te,f,at]),ac=a.useCallback((t,o)=>{if(se(null),at(t),At(o),te){jr(!0),Rr(1),Nr.current?.slideTo(1),f?.();return}},[te,f,at]),xs=a.useCallback(async(t,o)=>{const c=o||In||x;if(!(!c||t.length===0)){da(!0);try{await za(c,t),ha(c,!1)}catch(v){xt(v instanceof Error?v.message:i("rightSidebar.uploadFailed")),window.setTimeout(()=>xt(null),4e3)}finally{da(!1)}}},[In,x,ha,i]),oc=a.useCallback(async t=>{try{await dm(t)}catch(o){xt(o instanceof Error?o.message:i("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>xt(null),4e3)}},[i]),wa=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes("Files")&&To(!0)},[]),ic=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),To(!1)},[]),lc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),To(!1);const o=t.dataTransfer.files;o.length>0&&xs(Array.from(o))},[xs]),Yo=a.useCallback(t=>{Te(t),window.setTimeout(()=>Te(o=>o===t?null:o),1400)},[]),Mr=a.useCallback(t=>{St(t),window.setTimeout(()=>St(o=>o===t?null:o),1400)},[]);a.useEffect(()=>{Lt(Bd,tt)},[tt]),a.useEffect(()=>{Lt(Od,Pr)},[Pr]),a.useEffect(()=>{Lt(Ud,H)},[H]),a.useEffect(()=>{Is(Ci,ve,Mg)},[ve]),a.useEffect(()=>(Ul().catch(()=>{}),fd(t=>{t.type==="pinned-explorer-roots"&&Hl(t.pinnedExplorerRoots)})),[Ul,Hl]);const cc=a.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),ka=a.useRef(null),bn=a.useRef(null),[dc,Xo]=a.useState(!1);a.useEffect(()=>{if(!r)return;Xo(!1);let t=!1;um().then(c=>{t||(ka.current=c.text,We(v=>c.text&&c.text!==v?c.text:v),Xo(!0))}).catch(()=>{t||Xo(!0)});const o=fd(c=>{c.type==="context-draft"&&c.origin!==cc.current&&(ka.current=c.text,We(c.text))});return()=>{t=!0,o(),bn.current!==null&&(window.clearTimeout(bn.current),bn.current=null)}},[r]),a.useEffect(()=>{if(!dc||ka.current===ve)return;bn.current!==null&&window.clearTimeout(bn.current);const t=ve;bn.current=window.setTimeout(()=>{bn.current=null,fm(t,cc.current).then(()=>{ka.current=t}).catch(()=>{})},500)},[ve,dc]);const Kn=a.useCallback((t,o,c)=>{if(t){if(hm(c?t+c:t)){Yo(o);return}tt?(We(v=>_p(v,t)+(c??"")),window.matchMedia("(pointer: coarse)").matches||(_t(!1),ur(v=>v+1))):window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:c?t+c:t,focus:!0}})),Yo(o)}},[tt,Yo]),Sa=a.useCallback(t=>{const o=kn(t,x);return Tm(o,x)},[x]),Jo=Ru(Mr),Wt=a.useCallback((t,o)=>{const c=kn(t,x);Kn(Im(c,x),o??`path:${c}`)},[x,Kn]),eh=a.useCallback(async t=>{da(!0);try{await Dm(t,za,o=>{Wt(o,`path:${o}`)}),te&&!tt&&l()}catch(o){xt(o instanceof Error?o.message:i("rightSidebar.uploadFailed")),window.setTimeout(()=>xt(null),4e3)}finally{da(!1)}},[tt,Wt,te,l,i]),ja=a.useRef(!0),Qo=a.useRef(n);Qo.current=n,a.useEffect(()=>(ja.current=!0,()=>{ja.current=!1}),[]);const th=a.useCallback(t=>{Fm.getState().enqueue(t,n??null,x||"/",o=>{if(tt&&ja.current&&Qo.current===n)Wt(o);else return vd(o,n)})},[n,x,tt,Wt]),rh=a.useCallback(async t=>{const c=(await za("/tmp",[t])).files[0]?.path;if(!c)throw new Error("截图上传未返回文件路径");tt&&ja.current&&Qo.current===n?Wt(c):await vd(c,n)},[tt,Wt,n]),Er=a.useCallback((t,o)=>{if(!t)return;const c=t.includes(`
|
|
1660
|
-
`)?`
|
|
1661
|
-
`:void 0;Kn(t.endsWith(`
|
|
1662
|
-
`)||t.endsWith(" ")?t:`${t} `,o,c)},[Kn]),uc=a.useRef(Er);uc.current=Er;const Zo=a.useRef(!0);a.useEffect(()=>(Zo.current=!0,()=>{Zo.current=!1}),[]);const ei=a.useRef(new Set),fc=a.useCallback((t,o,c)=>{if(ei.current.has(o))return;const v=yd.getState().activeSessionId;ei.current.add(o),bp(t,o,c,{insert:Er,upload:async(w,k)=>(await za("/tmp",[w],k)).files[0]?.path,isCurrent:()=>Zo.current&&uc.current===Er&&v===yd.getState().activeSessionId}).finally(()=>ei.current.delete(o))},[Er]),$r=a.useCallback((t,o,c)=>{o&&Kn(o.endsWith(" ")?o:`${o} `,c??`context:${t}`,`
|
|
1663
|
-
`)},[Kn]),hc=a.useCallback(t=>{const o=Bp(ve,t);if(!o)return;const c=t&&ve.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),We(""),H&&_t(!0)):(pr(!0),_t(!1)))},j=Z=>{const me=Z.detail;me?.nonce===v&&k(me.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,ve]),rt=a.useMemo(()=>x?wt(x):i("rightSidebar.workspace"),[x,i]),nh=a.useMemo(()=>wt(ge)||rt,[ge,rt]),Ra=a.useMemo(()=>Pi(ge),[ge]),Ca=a.useMemo(()=>x?Ol[x]??[]:[],[Ol,x]),xn=a.useMemo(()=>new Set(Ca.map(t=>t.path)),[Ca]),vs=!!(ge&&xn.has(ge)),ti=!!(x&&ge&&ge!==x),sh=!!(x&&In&&In!==x),Dt=ge?`path:${ge}`:null,mc="context:change-audit",ah=a.useCallback(()=>{Ra&&Ut(Ra)},[Ra,Ut]),pc=a.useCallback(()=>{zl()},[zl]),oh=a.useCallback(()=>{ge&&(ha(ge,!0),Kl())},[Kl,ge,ha]),ih=a.useCallback(()=>{!ge||!ti||(vs?fn(ge):Dn(ge,"directory"))},[ti,ge,vs,Dn,fn]),gc=a.useCallback(t=>{Ut(t),V("")},[Ut]),bc=a.useCallback(t=>{ge&&(de(Cg(ge,t)),G(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[ge,G]),xc=a.useCallback(t=>{!x||t===x||(xn.has(t)?fn(t):Dn(t,"directory"))},[Dn,xn,x,fn]),vc=a.useCallback(t=>{!x||!t||(xn.has(t)?fn(t):Dn(t,"file"))},[Dn,xn,x,fn]),yc=J(t=>t.expandedPaths),ri=a.useMemo(()=>{const t=new Set;if(Wn&&ge){t.add(ge);const o=`${ge.replace(/\/+$/,"")}/`;for(const c of yc)c.startsWith(o)&&t.add(c)}if(Wn&&x&&st){const o=st.startsWith("/")?st:`${x}/${st}`,c=Pi(o);c&&t.add(c)}return $p(t).join(`
|
|
1665
|
-
`)},[yc,Wn,ge,x,st]),vn=a.useRef(new Map);a.useEffect(()=>{const t=ri?ri.split(`
|
|
1666
|
-
`):[];if(!r||t.length===0){Tn(null);return}const o=new AbortController;let c=!1,v=0,w=0;Tn(null);const k=async()=>{let j=0;for(;!c&&!o.signal.aborted;){let oe=null;try{Tn(null),await ym(t,me=>{const{applicableEvents:Me,unavailableReason:qe}=Ap(me);Me.length>0&&Wl(Me);for(const K of Me){if(K.type!=="rescan-required")continue;const Y=J.getState();if(!Y.directoryCache.has(K.path))continue;vn.current.get(K.path)?.abort();const Be=new AbortController;vn.current.set(K.path,Be);const nt=`file-watch-rescan:${K.path}`;Ct(nt),wm(K.path,Be.signal,Y.showHiddenFiles,"watch_rescan",nt,Y.fileSortModes[K.path]??"name").then(_e=>{vn.current.get(K.path)===Be&&Gl(K.path,_e.entries)}).catch(_e=>{dr(_e)||Tn(_e instanceof Error?_e.message:"File refresh unavailable")}).finally(()=>{vn.current.get(K.path)===Be&&vn.current.delete(K.path)})}qe&&Tn(qe)},o.signal),oe=new Error("File watch stream ended")}catch(me){oe=me}if(c||o.signal.aborted||dr(oe))return;Tn(oe instanceof Error?oe.message:"File watching unavailable");const Z=Hd[Math.min(j,Hd.length-1)];j+=1,await new Promise(me=>{w=window.setTimeout(me,Z)})}};return v=window.setTimeout(()=>{c||k()},Ni),()=>{c=!0,window.clearTimeout(v),window.clearTimeout(w),o.abort();for(const j of vn.current.values())j.abort();vn.current.clear()}},[Wl,r,Gl,ri]),a.useEffect(()=>{if(!x||zo.current!==x)return;if(Wo.current===x){Wo.current=null;return}const t=Vd();Is(Uu,{...t,[x]:{selectedRepoRoots:Zs,repoTargetBranches:Jt,repoBaseBranches:Et,previewEntries:Qr,selectedPreviewKey:ye&&Sr?Ve:null,selectedPreviewFileKey:ye&&Sr?Mo:null,previewDetailOpen:!!(ye&&Sr),previewScrollTops:ss,previewMobileSlideIndex:1,repoIncludeUncommitted:sn,updatedAt:Date.now()}},Ng)},[Sr,sn,ye,Qr,ss,Et,Jt,Zs,x,Mo,Ve]);const ft=a.useMemo(()=>ou(Se.values()),[Se]),it=a.useMemo(()=>{const t=new Map;for(const o of le)t.set(o.root,o);return t},[le]),ys=a.useMemo(()=>{const t=new Map;for(const o of le)o.deferred||t.set(o.root,o.files.length);return t},[le]),Na=a.useCallback(t=>{if(t){if(!t.deferred){hs.current.delete(t.root);return}ys.has(t.root)||hs.current.has(t.root)||(hs.current.add(t.root),It(t.root,{includeNested:!1,background:!0,replaceRepoRoot:t.root}).then(o=>{o||hs.current.delete(t.root)}))}},[It,ys]),er=a.useMemo(()=>ce?Ce.find(t=>t.root===ce)??null:null,[ce,Ce]),Gt=a.useMemo(()=>st?Array.from(Se.values()).find(t=>t.path===st||t.absolutePath===st)??null:null,[Se,st]),Ft=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:rt,depth:0,nested:!1,available:!0,files:Array.from(Se.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==="."?rt:o.relativeRoot||o.name||wt(o.root),v=au(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(" · ")}})},[Se,R,le,rt,x,i]),we=a.useMemo(()=>ce&&Ft.some(t=>t.value===ce)?ce:Gt?.repoRoot&&Ft.some(t=>t.value===Gt.repoRoot)?Gt.repoRoot:Ft.length===1||Ft.length>1?Ft[0].value:null,[ce,Ft,Gt?.repoRoot]),wc=we?it.get(we)??null:null,he=wc?.context?.available?wc.context:we===R?.root?R:null,Xe=Ft.length>0&&!we,kc=a.useMemo(()=>Xe?[]:we?Array.from(Se.values()).filter(t=>pt(t,x)===we):Array.from(Se.values()),[we,Se,Xe,x]),yn=a.useMemo(()=>ou(kc),[kc]),ni=!!(he?.available&&he.root&&we&&he.root===we),lh=we?Ft.find(t=>t.value===we)?.label??wt(we):i("rightSidebar.gitRepositoryPlaceholder"),Sc=ni?he?.branch??"HEAD":Xe?i("rightSidebar.selectRepositoryForGitActions"):cn?i("rightSidebar.gitActionRunning"):"HEAD",Vn=!!(he?.available&&he.root===we&&he.status);a.useEffect(()=>{Sl.current={count:Tt.length,loading:Xs,loadingMore:Js,hasMore:So}},[Tt.length,So,Xs,Js]),a.useEffect(()=>{Ur.current+=1,sr.current?.abort(),Ct("right-sidebar-recent-commits"),sr.current=null,nn(""),nr([]),is(!1),ls(!1),En(null),$n(!1)},[we]);const ws=a.useCallback(async(t={})=>{if(!x||!we||Xe)return;const o=t.reset??!1,c=Sl.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(),Ct("right-sidebar-recent-commits");const k=new AbortController;sr.current=k,o?is(!0):ls(!0),En(null);try{const j=await mm({cwd:x,repoRoot:we,limit:_g,skip:v,query:os.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([]),$n(!1);return}Ke(oe=>o?j.commitSyncStatus??{}:{...oe,...j.commitSyncStatus}),nr(oe=>o?j.commits:[...oe,...j.commits]),$n(j.hasMore)}catch(j){if(Ur.current!==w||dr(j))return;En(j instanceof Error?j.message:"Failed to load recent commits"),o&&nr([]),$n(!1)}finally{sr.current===k&&(sr.current=null),Ur.current===w&&(is(!1),ls(!1))}},[we,os,Xe,x]);a.useEffect(()=>{tn&&ws({reset:!0})},[os,ws,tn,he?.ahead,he?.behind,he?.upstream]);const ch=a.useCallback(t=>{const o=t.currentTarget;o.scrollTop+o.clientHeight<o.scrollHeight-48||ws({reset:!1})},[ws]);a.useEffect(()=>{!we||!R?.available||!ot||!ar||Vn||cn||Xe||Vo(we)},[we,R?.available,Vn,cn,ot,ar,Vo,Xe]),a.useEffect(()=>{!r||!Rt&&!ot||!x||ir()},[Rt,ot,r,ir,x]),a.useEffect(()=>{!r||!ot||!ar||!cs||!x||ya(null)},[cs,ot,ar,r,ya,x]);const dh=a.useMemo(()=>{if(!ce)return 0;const t=Ce.findIndex(o=>o.root===ce);return t>=0?t+1:0},[ce,Ce]),jc=a.useCallback(t=>{if(!t)return null;const o=Array.from(Se.values()).filter(c=>pt(c,x)===t).sort((c,v)=>c.path.localeCompare(v.path))[0];return o?yt(o):null},[Se,x]),wn=Ce.length>1,Ma=a.useMemo(()=>[{root:null,label:i("rightSidebar.allRepositories"),count:Se.size,branch:null,deferred:!1},...Ce.map(t=>({root:t.root,label:t.label,count:t.deferred?ys.get(t.root)??0:t.count,branch:t.branch??null,deferred:!!t.deferred&&!ys.has(t.root)}))],[Se.size,Ce,ys,i]),Rc=Ma[dh]??Ma[0],Ea=!!ce,Cc=a.useMemo(()=>qu(Ce,le),[Ce,le]);a.useEffect(()=>{Ko.current===x&&ce&&!Cc.has(ce)&&Ee(null),Nn(t=>t.filter(o=>Ce.some(c=>c.root===o)))},[ce,Ce,Cc,x,Ee]),a.useEffect(()=>{ce&&Na(it.get(ce))},[ce,Na,it]);const uh=a.useMemo(()=>{const t=new Set;he?.branch&&t.add(he.branch);for(const o of he?.branches??[])t.add(o);return Array.from(t).map(o=>({value:o,label:o,meta:o===he?.branch?i("rightSidebar.pushCurrentBranchBadge"):void 0}))},[he?.branch,he?.branches,i]),Nc=a.useMemo(()=>{const t=new Set;he?.upstreamRemote&&t.add(he.upstreamRemote);for(const o of he?.remotes??[])t.add(o);return Array.from(t).map(o=>({value:o,label:o,meta:o===he?.upstreamRemote?i("rightSidebar.pushUpstreamBadge"):void 0}))},[he?.remotes,he?.upstreamRemote,i]),Mc=Nc.length>1,fh=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(he?.upstreamBranch,he?.upstreamBranch?i("rightSidebar.pushUpstreamBadge"):void 0),c(he?.branch,he?.branch?i("rightSidebar.pushCurrentBranchBadge"):void 0);for(const w of he?.branches??[])c(w,w===he?.branch?i("rightSidebar.pushCurrentBranchBadge"):"local");const v=he?.upstreamRemote;for(const w of he?.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},[he?.branch,he?.branches,he?.remoteBranches,he?.upstreamBranch,he?.upstreamRemote,i]),Kt=a.useMemo(()=>Ft.map(t=>{const o=it.get(t.value);return{root:t.value,label:t.label,branch:o?.context?.branch??null}}),[Ft,it]);a.useEffect(()=>{Kt.length!==0&&(ea(t=>{let o=!1;const c={...t},v=new Set(Kt.map(w=>w.root));for(const w of Object.keys(c))v.has(w)||(delete c[w],o=!0);for(const w of Kt)!c[w.root]&&w.branch&&(c[w.root]=w.branch,o=!0);return o?c:t}),ta(t=>{let o=!1;const c={...t},v=new Set(Kt.map(w=>w.root));for(const w of Object.keys(c))v.has(w)||(delete c[w],o=!0);for(const w of Kt){const k=it.get(w.root)?.context;if(c[w.root]&&Yu(c[w.root],k?.branch)&&(delete c[w.root],o=!0),c[w.root])continue;const j=Xd(k);j&&(c[w.root]=j,o=!0)}return o?c:t}))},[Kt,it]);const $a=a.useMemo(()=>{const t=new Set(Kt.map(o=>o.root));return Zs.filter(o=>t.has(o))},[Zs,Kt]),La=$a.length===0,cr=a.useMemo(()=>La?Kt:Kt.filter(t=>$a.includes(t.root)),[Kt,$a,La]),ks=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]),Ec=a.useMemo(()=>cr.filter(t=>!Et[t.root]?.trim()),[Et,cr]),$c=a.useCallback(async t=>{if(!t||Ho.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;Ho.current.add(t),Cl(v=>new Set(v).add(t));try{const v=await ud(t,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${t}`);if(!v.available||!je(c))return;Re(w=>w.map(k=>k.root===t?{...k,available:!0,context:{...k.context,...v},error:void 0}:k)),ea(w=>w[t]||!v.branch?w:{...w,[t]:v.branch}),ta(w=>{if(w[t])return w;const k=Xd(v);return k?{...w,[t]:k}:w})}catch(v){dr(v)||console.warn("[RightSidebar] Failed to load branch audit repo details",t,v)}finally{Ho.current.delete(t),Cl(v=>{const w=new Set(v);return w.delete(t),w})}},[it,je,x]);a.useEffect(()=>{if(jo)for(const t of cr)$c(t.root)},[jo,cr,$c]),a.useEffect(()=>{!ni||!he||(oa(he.branch||(he.branches?.[0]??"")),ia(he.upstreamRemote||(he.remotes?.includes("origin")?"origin":he.remotes?.[0]??"")),la(he.upstreamBranch||he.branch||(he.branches?.[0]??"")))},[he,ni]);const Lc=a.useMemo(()=>{if(Xe)return{text:i("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!Vn||cn)return{text:i("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!he?.upstream)return{text:i("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const t=he.ahead??0,o=he.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"}},[he?.ahead,he?.behind,he?.upstream,Vn,cn,Xe,i]),hh=a.useCallback(t=>{if(t&&!te){const o=t.currentTarget.getBoundingClientRect();Pe({x:Math.min(o.left,window.innerWidth-352),y:Math.min(o.bottom+6,window.innerHeight-64)})}else Pe(null);D?.()},[te,D]),si=a.useCallback(()=>{Pe(null),_?.()},[_]);function Ac(){if(!wn)return null;const t=Rc?.label??i("rightSidebar.allRepositories"),o=Rc?.count??Se.size,c=wt(t)||t;return e.jsxs("button",{type:"button",onClick:hh,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(Os,{size:12,className:"shrink-0"})]})}function mh(){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(et?.x??t-368,t-352)),v=Math.max(12,Math.min(et?.y??80,o-420)),w=te?void 0:{left:c,top:v},k=e.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${te?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:si,children:e.jsxs("div",{className:te?"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:te?"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:te?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:i("rightSidebar.repositories")}),!te&&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:Ma.length}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${Se.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Se.size})]})]}),e.jsx("button",{type:"button",onClick:si,className:te?"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(qt,{size:te?16:14})})]}),e.jsx("div",{className:te?"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:Ma.map(j=>{const oe=(j.root??null)===ce,Z=wt(j.label)||j.label;return e.jsxs("button",{type:"button",onClick:()=>{Qc(j.root),si()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${te?"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:`${te?"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 Iu(k,te,document.body)}function ph(){return mh()}function Pc(t){const o=pt(t,x),c=t.absolutePath||(o?`${o}/${t.path}`:t.path),v=io(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 Tc(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 Aa(t,o){const c=kn(t,x),v=`path:${c}`,w=W===v,k=Oe===v,j=w||k;return e.jsx("button",{type:"button",onClick:oe=>{oe.stopPropagation(),Wt(c,v)},...Jo(Sa(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 Ic(t){const o=pt(t,x),c=t.absolutePath||(o?`${o}/${t.path}`:t.path),v=Hh(t),w=Di(t);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(zb,{actions:v,running:Ue,completed:Ln?.path===w?Ln:null}),Aa(c,i("rightSidebar.insertThisFile"))]})}function Dc(t,o){const c=o.root??x;if(!c)return null;const v=kn(t,c);return Aa(v,i("fileTree.insertRefTitle"))}function ai(){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:()=>Kc("unified"),"aria-pressed":Ot==="unified",title:i("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Ot==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:i("diffViewer.unified")}),e.jsx("button",{type:"button",onClick:()=>Kc("split"),"aria-pressed":Ot==="split",title:i("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Ot==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:i("diffViewer.split")})]})}function Fc(){return Ss.map(t=>{const o=au(t.files.map(([,k])=>k)),c=Zi({activeGitRepoRoot:ce,groupCount:Ss.length,label:t.label,rootName:rt}),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])=>Pc(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:()=>Ph(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(Wa,{size:13}):e.jsx(Os,{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(),Oa("stage-all",t.root,t.label)},disabled:!!Ue,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(),Oa("stash-all",t.root,t.label)},disabled:!!Ue,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 _c(){return Se.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:i("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Ta.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:io(c,o).name,displayDir:io(c,o).dir,auditRecords:Mt}})}function Bc(t){const o=Array.from(Se.values()).find(w=>yt(w)===t.key),c=o?pt(o,x):null,v=vp(Mt,c,o?.path??t.path);return e.jsx(qi,{changeStatus:t.status,auditStatus:v,renderChangeBadge:w=>e.jsx(Ds,{status:w})})}const Pa=a.useCallback(t=>{if(te)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 me=Math.abs(Z.top-v);me<k&&(w=oe,k=me)}const j=w?.dataset.diffSelectionPath??w?.dataset.diffStreamItem??null;return j?(ba.current===j&&J.getState().selectedFilePath===j||(ba.current=j,at(j)),j):null},[te,at]),gh=!!(!Ue&&we&&!Xe&&(he?.upstream||dn.trim()&&un.trim())),bh=!!(!Ue&&we&&!Xe&&(he?.upstream||dn.trim()&&un.trim())),xh=!!(!Ue&&we&&!Xe&&Pn.trim()&&Pn.trim()!==he?.branch),Vt=a.useMemo(()=>{const t=Fe.trim().toLowerCase(),o=Array.from(Se.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,Se,Fe,x]);a.useEffect(()=>{ro("selected_file_state",{selectedFilePath:st,selectedChangedFilePath:Gt?.path??null,selectedChangedFileAbsolutePath:Gt?.absolutePath??null,selectedChangedFileRepoRoot:Gt?.repoRoot??null,rootPath:x,activeGitRepoRoot:ce,rightTab:Fo,effectiveRightTab:lr,diffPaneActive:Rt,changedFiles:Se.size,filteredChangedFiles:Vt.length,gitBundleLoading:zr,gitBundleLastLoadedAt:Fn})},[ce,Se.size,Rt,lr,Vt.length,Fn,zr,Fo,x,Gt?.absolutePath,Gt?.path,Gt?.repoRoot,st]);const Ss=a.useMemo(()=>{const t=new Map;for(const o of Vt){const[,c]=o,v=pt(c,x),w=Ub(c)||rt,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===rt?-1:c.label===rt?1:o.label.localeCompare(c.label))},[Vt,it,rt,x]),Ta=a.useMemo(()=>{const t=[],o=new Map;for(const c of Vt)o.set(yt(c[1]),c);for(const c of Ss){if(!!(c.root&&Zi({activeGitRepoRoot:ce,groupCount:Ss.length,label:c.label,rootName:rt})&&gr.has(c.root)))continue;if(vr!=="tree"){t.push(...c.files);continue}const w=c.files.map(([,k])=>Pc(k));for(const k of Vm(w)){const j=o.get(k.key);j&&t.push(j)}}return t},[ce,gr,vr,Ss,Vt,rt]);a.useEffect(()=>{if(!Rt||Ta.length===0||te)return;const t=[],o=()=>{const c=document.querySelector(".termdock-diff-stream-scroller");if(c&&Pa(c))return;const v=document.querySelector("[data-diff-stream-item]"),w=v?.dataset.diffSelectionPath??v?.dataset.diffStreamItem??null;if(w){ba.current=w,at(w);return}const k=Ta[0]?.[1];if(!k)return;const j=yt(k);ba.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))},[Rt,te,Ta,at,Pa]);const oi=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:rt}]:[],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,rt,x]),vh=a.useCallback((t="generate")=>{if(wn&&_r.length===0&&!ce){Jr(!0);return}const o=t==="generate"?oi:[t==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",oi].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,`${mc}:${t}`),ir(),d||l()},[ce,oi,_r.length,Zt,$r,ir,l,d,x,wn,i]),Ia=a.useCallback(async t=>{try{await hd({ids:[t]}),Xr(o=>o.filter(c=>c.id!==t))}catch{ir()}},[ir]),yh=a.useCallback(async()=>{if(Mt.length===0)return;const t=Mt.map(o=>o.id);try{await hd({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()}},[Mt,ir,i]),wh=a.useCallback(async t=>{if(t.records.length===0)return;const o=t.records.map(c=>c.id);try{await pm({ids:o}),Br(c=>c.filter(v=>!o.includes(v.id))),Ve===t.key&&(an(null),tr(!1))}catch(c){xt(i("rightSidebar.branchAuditClearFailed",{message:c instanceof Error?c.message:"Failed to clear branch explanation"})),ya(null)}},[ya,Ve,i]),kh=a.useCallback(t=>{Nn(o=>t===null?(Jr(!1),[]):o.includes(t)?o.filter(c=>c!==t):[...o,t])},[]),Sh=a.useCallback(t=>{Co(o=>t===null?(Ro(!1),[]):o.includes(t)?o.filter(c=>c!==t):[...o,t])},[]),ii=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 ye?(ye.hunks??[]).map(o=>{const c=Yt.find(v=>v.repoRoot===ye.repoRoot&&v.baseRef===ye.baseRef&&(v.branchName??null)===(ye.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}}):Ve?Yt.filter(o=>qd(o)===Ve).map(o=>{const c=t(o);return{key:`${o.filePath}\0${o.hunkHeader}\0${o.hunkIndex??0}`,hunk:c,current:o,stale:null}}):[]},[ye,Yt,Vr,ar,Ve]),li=Yt.length>0,qn=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==="."?rt:v?.relativeRoot||v?.name||wt(c),k=qd(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,rt]),ci=a.useMemo(()=>Ve?qn.find(t=>t.key===Ve)??null:null,[qn,Ve]),js=ye?{repoRoot:ye.repoRoot??"",repoLabel:ye.repoRoot?it.get(ye.repoRoot)?.relativeRoot==="."?rt:it.get(ye.repoRoot)?.relativeRoot||it.get(ye.repoRoot)?.name||wt(ye.repoRoot):rt,baseRef:ye.baseRef??ye.baseBranch??"",branchName:ye.currentBranch??null,headRef:ye.headRef??null,diffFingerprint:ye.diffFingerprint??null}:ci,jh=a.useMemo(()=>(Ze?.hunks??[]).map(t=>({key:`${t.filePath}\0${t.hunkHeader}\0${t.hunkIndex}`,hunk:t,current:null,stale:null})),[Ze?.hunks]),Rh=a.useMemo(()=>{if(ye)return[];const t=ci;return t?rs.filter(o=>o.repoRoot===t.repoRoot&&o.baseRef===t.baseRef&&(o.branchName??null)===t.branchName&&(!t.diffFingerprint||o.diffFingerprint===t.diffFingerprint)):[]},[ye,rs,ci]),Ch=a.useCallback(t=>{const o=ii.find(c=>c.hunk.filePath===t.filePath||(t.repoRoot?`${t.repoRoot}/${c.hunk.filePath}`===t.filePath:!1));o&&(on(o.key),window.setTimeout(()=>Sn(t),90),window.setTimeout(()=>Sn(t),320),window.setTimeout(()=>Sn(t),760))},[ii]),di=a.useMemo(()=>{const t=w=>`'${w.replace(/'/g,"'\\''")}'`,o=ks,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,ks,Et,Jt,x]),Nh=a.useCallback((t="generate")=>{const o=t==="generate"?di:[t==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",di].join(`
|
|
1676
|
-
`);$r(i("rightSidebar.branchAuditShort"),o,`context:branch-audit-scope:${t}`),d||l()},[di,$r,l,d,i]),ui=a.useCallback(async(t={})=>{const o=t.refresh===!0,c=o&&ye?.comparisonRepos?ye.comparisonRepos:ks.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=()=>je(w)&&v===z.current;Ie(!0),De(null),o||(Xt(null),ut(null));try{const j=await Promise.all(c.map(async K=>{if(!K.base)throw new Error(i("rightSidebar.branchAuditMissingBase",{repo:K.label}));return md({cwd:x,repoRoot:K.repoRoot,base:K.base,head:K.head,includeUncommitted:Vr(K.repoRoot,K.head)&&(t.repoRoot===K.repoRoot?t.includeUncommitted??!1:K.includeUncommitted??ye?.includeUncommitted??!0),requestSlotId:`right-sidebar-branch-preview:${K.repoRoot}`})}));if(!k())return;const oe=j.find(K=>!K.available);if(oe){De(oe.error??"Branch diff is unavailable");return}const Z=j.length===1?j[0]:{available:!0,workspaceRoot:x,repoRoot:x,baseRef:j.map(K=>K.baseRef??K.baseBranch).filter(Boolean).join(", "),currentBranch:j.map(K=>K.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:j.map(K=>K.headRef).filter(Boolean).join(", "),diffFingerprint:j.map(K=>K.diffFingerprint).filter(Boolean).join("+"),stat:j.map(K=>K.stat).filter(Boolean).join(`
|
|
1677
|
-
`),files:j.flatMap((K,Y)=>{const Ne=c[Y];return(K.files??[]).map(Be=>`${Ne?.label??K.repoRoot??"repo"}/${Be}`)}),hunks:j.flatMap((K,Y)=>{const Be=c[Y]?.label??K.repoRoot??"repo";return(K.hunks??[]).map(nt=>({...nt,filePath:`${Be}/${nt.filePath}`,oldPath:nt.oldPath?`${Be}/${nt.oldPath}`:nt.oldPath,newPath:nt.newPath?`${Be}/${nt.newPath}`:nt.newPath}))}),commits:j.flatMap(K=>K.commits??[]),commitCount:j.reduce((K,Y)=>K+(Y.commitCount??Y.commits?.length??0),0),diff:j.map(K=>K.diff).filter(Boolean).join(`
|
|
1678
|
-
`),truncated:j.some(K=>K.truncated)};if(Z.comparisonRepos=c.map((K,Y)=>({...K,head:K.head??j[Y].currentBranch??null,includeUncommitted:j[Y].includeUncommitted===!0})),Z.canIncludeUncommitted=j.every(K=>K.canIncludeUncommitted===!0),Z.includeUncommitted=j.some(K=>K.includeUncommitted===!0),No(K=>({...K,...Object.fromEntries(Z.comparisonRepos.map(Y=>[Y.repoRoot,Y.includeUncommitted??!1]))})),!o&&(Z.hunks??[]).length===0){De(i("rightSidebar.branchAuditDiffEmpty"));return}const me=Date.now(),Me=(o?Ve:null)??["preview",Z.repoRoot??x,Z.baseRef??Z.baseBranch??"",Z.currentBranch??"",Z.headRef??"",Z.diffFingerprint??me].join("\0"),qe=c.length===1?c[0].label:`${c.length} repos`;Xt(Z),Zr(K=>[{key:Me,diff:Z,repoLabel:qe,createdAt:me},...K.filter(Y=>Y.key!==Me)].slice(0,8)),o||P(K=>K[Me]===void 0?K:{...K,[Me]:0}),an(Me),on(K=>{const Y=Z.hunks?.[0],Ne=Y?`${Y.filePath}\0${Y.hunkHeader}\0${Y.hunkIndex}`:null;return o&&K&&(Z.hunks??[]).some(Be=>Be.filePath===K.split("\0")[0])?K:Ne}),tr(!0)}catch(j){if(!k()||dr(j))return;De(j instanceof Error?j.message:"Failed to load branch diff")}finally{k()&&Ie(!1)}},[Vr,sn,ye,Ve,ks,Et,Jt,je,x,i]),Mh=a.useCallback(t=>{++z.current,Ie(!1),Xt(t.diff),De(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}),Ve===t&&(an(null),Xt(null),tr(!1))},[Ve]),$h=a.useCallback(t=>{++z.current,Ie(!1);const o=qn.find(c=>c.key===t);o&&(Xt(null),De(null),an(t),on(o.records[0]?.filePath??null),tr(!0))},[qn]),Lh=a.useCallback(async t=>{if(!x||!we)return;const[o]=t.split(/\s+/);if(o){rr(o),en(null),ut(null);try{const c=await gm({cwd:x,repoRoot:we,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];Qs(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)}}},[we,x]),Ah=a.useCallback(t=>{if(!ye||!Ve)return;const o=Math.max(0,Math.round(t));P(c=>Math.abs((c[Ve]??0)-o)<24?c:{...c,[Ve]:o})},[ye,Ve]);a.useEffect(()=>{!ye||!Ve||Zr(t=>t.map(o=>o.key===Ve&&o.diff!==ye?{...o,diff:ye}:o))},[ye,Ve]);const Oc=!!ye;a.useEffect(()=>{!te||!Sr||!Oc||gs(1)},[Sr,Oc,te,gs]);const Uc=a.useCallback(t=>{t&&Wf(o=>qm(o,t))},[]),Hc=ua.key===st?ua.key:null,Da=a.useCallback(t=>{const o=J.getState(),c=ex();ro("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"),te&&t&&gs(1),Uc(t),queueMicrotask(()=>{const v=J.getState();ro("select_diff_file_after",{interactionId:c,requestedPath:t,selectedFilePath:v.selectedFilePath,rootPath:v.rootPath,rightTab:v.rightTab,changedFiles:v.changedFiles.size,activeGitRepoRoot:ce})})},[ce,te,Uc,at,Qt,gs]),zc=a.useCallback(t=>{const o=Array.from(Se.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){Da(yt(o)),window.setTimeout(()=>Sn(t),90),window.setTimeout(()=>Sn(t),320),window.setTimeout(()=>Sn(t),760);return}Sn(t)},[Se,x,Da]),Wc=a.useCallback(({slideToDetail:t,fullscreen:o,toggleFullscreen:c}={})=>es.length>0?e.jsx(vu,{walkthroughs:es,repoRoot:ce,fullscreen:o,onToggleFullscreen:c,onNavigate:v=>{te&&window.requestAnimationFrame(()=>t?.()),zc(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(Hs,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),i("rightSidebar.changeWalkthroughEmpty")]}),[ce,es,zc,te,i]),Ph=a.useCallback(t=>{t&&br(o=>{const c=new Set(o);return c.has(t)?c.delete(t):c.add(t),Mi(ji,c),c})},[]),Gc=a.useCallback(t=>{xr(o=>{const c=new Set(o);return c.has(t)?c.delete(t):c.add(t),Mi(_d,c),c})},[]),Fa=a.useCallback(t=>{Vs(t),Lt(Fu,t)},[]);a.useEffect(()=>{Ea||vr!=="ai"||Fa("tree")},[vr,Fa,Ea]);const _a=a.useCallback(()=>{Zn(t=>{const o=!t;return Lt(_u,o),o})},[]),Kc=a.useCallback(t=>{qs(t),Lt(Bu,t)},[]),{whitespace:Vc,context:qc}=Xm(),Yc=a.useMemo(()=>({algorithm:"histogram",whitespace:Vc,context:qc}),[Vc,qc]),Xc=a.useCallback(t=>{q(t),Lt(Ou,t)},[]),Ba=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 pd({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 us(k),window.setTimeout(()=>us(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),us(null),ds({action:t.action,path:c});try{const w=await bm({...t,includeNested:Es(x)}),k=await Ba(w,t,o,c);if(!je(v))return!1;const j=x?await vi(x,void 0,{includeNested:Es(x),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Ls(x)}).catch(()=>k.bundle):k.bundle;return je(v)?(j&&Hn(j,{reloadDiff:!0,cacheOnly:!0}),ln(null),!0):!1}catch(w){return us(null),xt(i("rightSidebar.gitActionFailed",{message:w instanceof Error?w.message:"Unknown error"})),!1}finally{je(v)&&ds(null)}},[Hn,je,x,i,Ba]),Jc=a.useCallback(async t=>{const o=x;await gd({...t,includeNested:Es(x)}),je(o)&&It(x??void 0,{refresh:!0,background:!0})},[je,It,x]),Th=a.useCallback(async t=>{const o=ye,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"));ke(k=>k+1),De(null);try{await gd(t)}catch(k){throw ke(j=>j-1),k}if(c!==z.current||!je(x)){ke(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(Me=>!(Me.previewRevert?.cwd===t.cwd&&Me.previewRevert.patch===t.patch)):[...oe.filter(Me=>Me.filePath!==v.filePath),...k];return{...j,hunks:Z}})};w(),md({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||!je(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&&je(x)&&!dr(k)&&De(`${i("diffViewer.hunkActionReverted")} · ${k instanceof Error?k.message:String(k)}`)}).finally(()=>ke(k=>k-1))},[ye,je,x,i]),Oa=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]),Qc=a.useCallback(t=>{Ee(t),oa(""),ia(""),la(""),at(jc(t)),ot||Qt("diff"),t&&Na(it.get(t))},[Na,jc,ot,it,at,Ee,Qt]),Zc=a.useCallback(t=>{const o=new Set([...zt.current.keys(),...mn.current,...or.current]);for(const c of o)c!==t&&(Ht.current.delete(c),zt.current.get(c)?.abort(),zt.current.delete(c),Ct(`right-sidebar-git-untracked:${c}`),mn.current.delete(c),or.current.delete(c))},[]),Ih=a.useCallback(async t=>{const o=x;if(!o||(await J.getState().setNestedGitScanRoot(o,t),!je(o)))return;if(t){await It(o,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}Zc(o),oa(""),ia(""),la(""),Co(v=>v.filter(w=>w===o));const c=Gt;c&&pt(c,o)!==o&&at(null),await It(o,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[Zc,je,It,x,at,Gt]),Dh=a.useCallback(async()=>{if(!we||Xe){xt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=Pn.trim();!t||t===he?.branch||await vt({action:"switch-branch",cwd:we,branch:t},i("rightSidebar.switchBranch"))},[he?.branch,we,Xe,vt,Pn,i]),ed=a.useCallback(async()=>{if(!we||Xe){xt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=aa.trim();if(!t)return;await vt({action:"commit",cwd:we,message:t},i("rightSidebar.commitChanges"))&&Pl("")},[we,aa,Xe,vt,i]),Fh=a.useCallback(async()=>{if(!we||Xe){xt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=dn.trim(),o=un.trim();await vt({action:"push",cwd:we,...t?{remote:t}:{},...o?{branch:o}:{}},i("rightSidebar.pushChanges"))},[we,un,dn,Xe,vt,i]),_h=a.useCallback(async()=>{if(!we||Xe){xt(i("rightSidebar.selectRepositoryForGitActions"));return}const t=dn.trim(),o=un.trim();await vt({action:"pull",cwd:we,...t?{remote:t}:{},...o?{branch:o}:{}},i("rightSidebar.pullChanges"))},[we,un,dn,Xe,vt,i]);a.useEffect(()=>{if(!ot||!we||Ue)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 pd({cwd:we,action:c}).catch(()=>null);if(!v?.ok||v.status!=="running")continue;const w={action:c,cwd:we},k=o[c]??c;ds({action:c});try{const j=await Ba(v,w,k);if(t||!je(x))return;const oe=x?await vi(x,void 0,{includeNested:Es(x),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Ls(x)}).catch(()=>j.bundle):j.bundle;oe&&Hn(oe,{reloadDiff:!0,cacheOnly:!0})}catch(j){t||xt(i("rightSidebar.gitActionFailed",{message:j instanceof Error?j.message:"Unknown error"}))}finally{t||ds(null)}return}})(),()=>{t=!0}},[we,Hn,ot,je,x,Ue,i,Ba]);const fi=Ln?.action==="commit",hi=Ln?.action==="switch-branch",mi=Ln?.action==="pull",pi=Ln?.action==="push",Ua=ot||Hf,gi=La?i("rightSidebar.changeAuditScopeAll"):cr.length===1?cr[0].label:`${cr.length} repos`,Bh=cr.length>0,td=ks.length>0,Oh=x?e.jsx(ru,{open:jo,onOpenChange:Ro,showScopePicker:!0,selectedAll:La,repos:Kt,selectedRoots:$a,onToggleRepo:Sh,onGenerate:()=>Nh(li?"regenerate":"generate"),disabled:!Bh,generateDisabled:!td,inserted:W?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:i(li?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:i("rightSidebar.inserted"),title:i("rightSidebar.branchAuditGenerateTitle"),ariaLabel:i("rightSidebar.branchAuditShort"),scopeTitle:i("rightSidebar.changeAuditScopeLabel"),scopeLabel:gi,allLabel:i("rightSidebar.changeAuditScopeAll"),generateLabel:i(li?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{ui()},secondaryDisabled:!td||Qe,secondaryLabel:i("rightSidebar.branchAuditViewDiff"),secondaryTitle:i("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:Qe,loading:Rl.size>0,statusTitle:Rl.size>0?i("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsx("div",{className:"mb-2 space-y-1.5",children:Ec.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:Ec.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=(me,Me)=>{!me||w.has(me)||(w.add(me),v.push({value:me,label:me,meta:Me}))};k(Jt[t.root]||o?.context?.branch,i("rightSidebar.pushCurrentBranchBadge"));for(const me of o?.context?.branches??[])k(me,me===o?.context?.branch?i("rightSidebar.pushCurrentBranchBadge"):i("rightSidebar.localBranch"));for(const me of o?.context?.remoteBranches??[])k(me,i("rightSidebar.remoteBranch"));const j=[],oe=new Set,Z=(me,Me)=>{!me||oe.has(me)||(oe.add(me),j.push({value:me,label:me,meta:Me}))};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 me of o?.context?.remoteBranches??[])Z(me,"remote");for(const me of o?.context?.branches??[])Z(me,me===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(Xn,{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:me=>{ea(Me=>({...Me,[t.root]:me}))}}),e.jsx(Xn,{label:i("rightSidebar.branchAuditBaseLabel"),value:Et[t.root]||"",options:j,placeholder:i("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:i("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:i("rightSidebar.branchAuditBaseEmpty"),onChange:me=>{ta(Me=>({...Me,[t.root]:me}))}}),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:me=>No(Me=>({...Me,[t.root]:me.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,rd=As(Mt.reduce((t,o)=>Math.max(t,o.injectedAt??0),0),O),Uh=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:()=>jl(t=>{const o=!t;return Lt(Ri,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":cs,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(Hs,{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:gi})]}),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 ${cs?"rotate-90":""}`,children:e.jsx(Wa,{size:13})})]}),cs&&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"),": ",gi]}),Oh]}),Ge&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:Ge}),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 ${Ve===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),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")})]}),As(t.createdAt,O)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:As(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(so,{size:12})})]},t.key)),qn.length>0?qn.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 ${Ve===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:()=>$h(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})]}),As(t.latestInjectedAt,O)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:i("rightSidebar.branchAuditGeneratedAt",{time:As(t.latestInjectedAt,O)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{wh(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(so,{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,nd=ar&&x&&Vn?e.jsxs("div",{className:Ua?"overflow-visible":"overflow-hidden",children:[Uh,e.jsxs("button",{type:"button",onClick:()=>{ot||zf(t=>{const o=!t;return o&&we&&!Vn&&!cn&&Vo(we),o})},"aria-expanded":Ua,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(Nt,{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 ${Ua?"rotate-90":""}`,children:e.jsx(Wa,{size:13})})]})]}),Ua&&e.jsxs("div",{className:"space-y-0",children:[Ft.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:lh})]})}),e.jsx(Xn,{label:i("rightSidebar.gitRepositoryLabel"),value:we??"",options:Ft,placeholder:i("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:i("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:i("rightSidebar.gitRepositoryEmpty"),disabled:!!Ue,onChange:t=>{Qc(t||null)}}),Xe&&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:Pn!==Sc?Sc:null})]}),e.jsxs("button",{type:"button",onClick:()=>{Dh()},disabled:!xh,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 ${hi?"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:Ue?.action==="switch-branch"||hi?"opacity-0":"",children:i("rightSidebar.switchBranch")}),Ue?.action==="switch-branch"&&e.jsx(Nt,{size:12,className:"absolute animate-spin"}),hi&&Ue?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(Xn,{label:i("rightSidebar.currentBranchLabel"),value:Pn,options:uh,placeholder:i("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:i("rightSidebar.switchBranchSearchPlaceholder"),emptyText:i("rightSidebar.switchNoBranches"),disabled:!!Ue,onChange:oa})]}),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:Xe?i("rightSidebar.selectRepositoryForGitActions"):yn.staged>0?i("rightSidebar.commitReadyHint",{count:yn.staged}):i("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{ed()},disabled:!!Ue||Xe||yn.staged===0||!aa.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 ${fi?"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:Xe?i("rightSidebar.selectRepositoryForGitActions"):yn.staged===0?i("rightSidebar.commitNeedsStaged"):i("rightSidebar.commitChanges"),children:[e.jsx("span",{className:Ue?.action==="commit"||fi?"opacity-0":"",children:i("rightSidebar.commitChanges")}),Ue?.action==="commit"&&e.jsx(Nt,{size:12,className:"absolute animate-spin"}),fi&&Ue?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:aa,onChange:t=>Pl(t.target.value),onKeyDown:t=>{(t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),ed())},placeholder:i("rightSidebar.commitMessagePlaceholder"),disabled:!!Ue,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:[Xs&&e.jsx(Nt,{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(Wa,{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(Jn,{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(qt,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:ch,children:[Tt.length>0?Tt.map(t=>{const[o,...c]=t.split(/\s+/),v=c.join(" ")||t;return e.jsxs("button",{type:"button",onClick:()=>{Lh(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")}),Mn===o&&e.jsx(Nt,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},t)}):Xs?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")}),Js&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(Nt,{size:12,className:"animate-spin"})}),So&&!Js&&Tt.length>0&&e.jsx("button",{type:"button",onClick:()=>{ws({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")})]})]}),as&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:as}),kl&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:kl})]}),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:()=>{_h()},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 ${mi?"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:Ue?.action==="pull"||mi?"opacity-0":"",children:i("rightSidebar.pullChanges")}),Ue?.action==="pull"&&e.jsx(Nt,{size:12,className:"absolute animate-spin"}),mi&&Ue?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{Fh()},disabled:!bh,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 ${pi?"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:Ue?.action==="push"||pi?"opacity-0":"",children:i("rightSidebar.pushChanges")}),Ue?.action==="push"&&e.jsx(Nt,{size:12,className:"absolute animate-spin"}),pi&&Ue?.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] ${Lc.className}`,title:he?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:Lc.text}),e.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:he?.upstream??""})]}),e.jsxs("div",{className:`grid gap-1.5 ${Mc?"grid-cols-2":"grid-cols-1"}`,children:[Mc&&e.jsx(Xn,{label:i("rightSidebar.pushRemoteLabel"),value:dn,options:Nc,placeholder:i("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:i("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:i("rightSidebar.pushNoRemotes"),disabled:!!Ue,onChange:ia}),e.jsx(Xn,{label:i("rightSidebar.pushBranchLabel"),value:un,options:fh,placeholder:i("rightSidebar.pushBranchPlaceholder",{branch:he?.branch??"HEAD"}),searchPlaceholder:i("rightSidebar.pushBranchSearchPlaceholder"),emptyText:i("rightSidebar.pushNoBranches"),disabled:!!Ue,onChange:la})]})]})]})]}):null,Hh=a.useCallback(t=>{const o=pt(t,x);if(!o)return[];const c=Di(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]),zh=a.useCallback(()=>{if(g){S?.();return}Rr(0),Nr.current?.slideTo(0),jr(!1),gt(null)},[S,g]),sd=a.useCallback(t=>{if(V(""),Ut(t),at(null),gt(null),se(null),te){g&&S?.(),Rr(0),Nr.current?.slideTo(0),jr(!1);return}},[te,S,g,at,Ut]);a.useEffect(()=>{const t=o=>{const c=o.detail,v=c?.path;if(typeof v!="string"||!v.startsWith("/"))return;V(""),gt(null),At(null);const w=!!(x&&(v===x||v.startsWith(`${x}/`)));if(c.kind==="file"){const k=Pi(v);bs(v),typeof c.line=="number"&&Number.isSafeInteger(c.line)&&c.line>0&&At(c.line),Ut(w?null:k),se(j=>({path:v,nonce:(j?.nonce??0)+1}));return}at(null),w?(Ut(null),se(k=>({path:v,nonce:(k?.nonce??0)+1}))):(se(null),Ut(v)),te&&(g&&S?.(),Rr(0),Nr.current?.slideTo(0),jr(!1))};return window.addEventListener(wd,t),()=>window.removeEventListener(wd,t)},[bs,te,S,g,x,at,Ut]),a.useEffect(()=>{r||(Bt(!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&&(jn.current?.contains(o.target)||Rn.current?.contains(o.target))||(Bt(!1),mr(!1))};return window.addEventListener("mousedown",t),window.addEventListener("keydown",t),()=>{window.removeEventListener("mousedown",t),window.removeEventListener("keydown",t)}},[hr,fr]);const ad=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:ah,disabled:!Ra,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(mu,{size:14})}),e.jsx("button",{type:"button",onClick:pc,disabled:!x||In===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(kd,{size:14})}),e.jsx("button",{type:"button",onClick:oh,disabled:!ge,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:Tl?i("rightSidebar.fileWatchUnavailable",{message:Tl}):i("rightSidebar.refreshFiles"),children:e.jsx(Ui,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:ge??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:nh}),pa==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:i("fileTree.sortedByModified"),"aria-label":i("fileTree.sortedByModified"),children:e.jsx(Sd,{size:11})})]})}),e.jsx("button",{type:"button",onClick:()=>ge&&Wt(ge,Dt??void 0),disabled:!ge,...ge&&Dt?Jo(Sa(ge),Dt):{},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 ${Dt&&(W===Dt||Oe===Dt)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":i(Dt&&Oe===Dt?"rightSidebar.copied":Dt&&W===Dt?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:i("rightSidebar.insertCurrentFolder"),children:Dt&&(W===Dt||Oe===Dt)?e.jsx(Oi,{size:13}):e.jsx(co,{size:13})}),e.jsxs("div",{ref:Rn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{Bt(!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(lo,{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),ih()},disabled:!ti,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${vs?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[vs?e.jsx(wi,{size:14}):e.jsx(Ga,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(vs?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{mr(!1),Kf()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${_o?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[_o?e.jsx(ep,{size:14}):e.jsx(Ki,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(_o?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!ge,onClick:()=>{ge&&(mr(!1),Vf(ge,pa==="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:[pa==="modified"?e.jsx(_m,{size:14}):e.jsx(Sd,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i(pa==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),x&&(Ca.length>0||sh)&&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:pc,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 ${ge===x?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:x,children:[e.jsx(kd,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:rt})]}),Ca.map(t=>{const o=t.path,c=t.kind==="file",v=c?st===o:ge===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?bs(o):Ut(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(Vi,{size:10,className:"shrink-0"}):e.jsx(Ga,{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(qt,{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"})]}),bi=a.useMemo(()=>{if(An===null)return null;const t=typeof navigator>"u"?void 0:navigator.language,o=Math.max(0,Math.floor((Po-An)/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)},[Po,An]),Wh=x&&!zn?e.jsx("button",{type:"button",onClick:()=>{Ih(!Bo)},"aria-pressed":Bo,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 ${Bo?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:i("rightSidebar.multiRepoScan")}):null,od=x?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[bi?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:i("rightSidebar.gitLastUpdated",{time:bi}),children:bi}):null,e.jsx("button",{type:"button",onClick:()=>{ps()},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(Ui,{size:13,className:zr?"animate-spin":""})})]}):null,Gh=rc?i("rightSidebar.changeAuditScopeAll"):gn.length===1?gn[0].relativeRoot==="."?rt:gn[0].relativeRoot||gn[0].name:`${gn.length} repos`,Kh=x?e.jsxs("div",{className:"inline-flex min-h-9 shrink-0 items-center",children:[e.jsx(ru,{open:ts,onOpenChange:Jr,showScopePicker:wn,selectedAll:rc,repos:qf,selectedRoots:Zt,onToggleRepo:kh,onGenerate:()=>vh(),disabled:!x,inserted:W===mc,buttonLabel:i("rightSidebar.changeAuditShort"),insertedLabel:i("rightSidebar.inserted"),title:i("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:i("rightSidebar.insertChangeAuditPrompt"),scopeTitle:i("rightSidebar.changeAuditScopeLabel"),scopeLabel:Gh,allLabel:i("rightSidebar.changeAuditScopeAll"),generateLabel:i("rightSidebar.changeAuditShort"),loading:Dr,error:!!kr,statusTitle:kr??(Dr?i("rightSidebar.changeAuditLoading"):Mt.length>0?`${i("rightSidebar.changeAuditLoaded",{count:Mt.length})}${rd?` · ${i("rightSidebar.changeAuditLoadedAt",{time:rd})}`:""}`:void 0)}),e.jsx("button",{type:"button",onClick:()=>{yh()},disabled:Dr||Mt.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 ${Mt.length>0?"":"invisible"}`,title:i("rightSidebar.clearChangeAuditTitle"),"aria-label":i("rightSidebar.clearChangeAudit"),children:e.jsx(so,{size:12})})]}):null,Rs=er??(R?.available&&x&&Se.size>0&&le.length<=1?{root:x,label:rt}:null),id=e.jsxs(e.Fragment,{children:[Rs&&e.jsxs("div",{className:"flex w-full flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Oa("stage-all",Rs.root,Rs.label),disabled:!!Ue,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:()=>Oa("stash-all",Rs.root,Rs.label),disabled:!!Ue,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")})]}),Wh,Kh]}),Ha=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(Bm,{side:"right",isOpen:r,drawerWidthPx:s,onClose:l,onOpen:u,push:d,pinned:h,children:[Jo.popoverNode,e.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${Jf?"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:rt}),(!te||$o)&&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=!be;G(t),t?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):V("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${be?"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(Jn,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":tt,onClick:()=>{dt(t=>!t),_t(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${tt?"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(Om,{size:14}),!tt&&ve.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:_l,type:"file",multiple:!0,className:"hidden",onChange:t=>{const o=t.target.files;!o||o.length===0||(xs(Array.from(o)),t.target.value="")}}),e.jsx("input",{ref:Bl,type:"file",accept:"image/*",className:"hidden",onChange:t=>{const o=t.target.files?.[0];t.target.value="",o&&eh(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(wi,{size:14}):e.jsx(Ga,{size:14})}),e.jsxs("div",{ref:jn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{mr(!1),Bt(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(lo,{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:()=>Zf(!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(bd,{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:()=>{Bt(!1),_l.current?.click()},disabled:ca,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:[ca?e.jsx(Nt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(dp,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Bt(!1),Bl.current?.click()},disabled:ca,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:[ca?e.jsx(Nt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(sp,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:i("rightSidebar.insertLocalImage")})]}),m&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Bt(!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(wi,{size:14}):e.jsx(Ga,{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:()=>{A(t),Bt(!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(qt,{size:14})})]}),be&&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(Jn,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:C,onChange:t=>V(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 ${te?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>Xc("name"),"aria-pressed":F==="name",className:`rounded-full px-2 transition active:scale-95 ${te?"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:()=>Xc("content"),"aria-pressed":F==="content",className:`rounded-full px-2 transition active:scale-95 ${te?"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:()=>V(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":i("rightSidebar.clearSearch"),children:e.jsx(qt,{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(Um,{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:ne,onChange:t=>de(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}),ne!=="."&&e.jsx("button",{type:"button",onClick:()=>de("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":i("rightSidebar.resetSearchScope"),children:e.jsx(qt,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>E(t=>!t),"aria-expanded":Ae,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${Ae||fs.length>0||ee||$e||Le?"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(Hm,{size:13}),fs.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:fs.length})]})]}),Ae&&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:xe,onChange:t=>ue(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}),xe&&e.jsx("button",{type:"button",onClick:()=>ue(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":i("rightSidebar.clearSearchExclude"),children:e.jsx(qt,{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,()=>pe(t=>!t),Qm,i("rightSidebar.matchCase")],[$e,()=>Ye(t=>!t),fp,i("rightSidebar.matchWholeWord")],[Le,()=>Je(t=>!t),op,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(${(zn?2:3)+(Hr?1:0)}, minmax(0, 1fr))`},children:[!zn&&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(Cu,{size:12}),i("rightSidebar.tabChanges"),Se.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:Se.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(Km,{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(bd,{size:12}),i("rightSidebar.tabAndroid")]})]}),e.jsx("div",{className:"h-2"}),Ll&&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:Ll})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(eo,{active:ot,mounted:ar,fallback:e.jsx(Ai,{slow:!1}),children:Ze?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx($d,{items:jh,renderPathReference:(t,o)=>Aa(kn(t,Ze.repoRoot??x),i(o==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle")),selectedKey:Ff,onSelect:Qs,emptyText:i("rightSidebar.noChanges"),mobile:te,backLabel:i("rightSidebar.backToChangeList"),headerTitle:i("rightSidebar.recentCommitsTitle"),headerMeta:`${Ze.headRef??""}${Ze.commits?.[0]?` · ${Ze.commits[0]}`:""}`,onClose:()=>{ut(null),Qs(null)},closeLabel:i("common.back"),wrap:Pt,onToggleWrap:te?_a:void 0,wrapTitle:i("rightSidebar.wrapLongLines"),wrapOnLabel:i("rightSidebar.wrapOn"),wrapOffLabel:i("rightSidebar.wrapOff"),desktopLayout:te?"stacked":"split",onInsertDiffReference:$r,onReferenceCopied:Mr,insertedReferenceKey:W,copiedReferenceKey:Oe,onClearAuditRecord:Ia})}):Sr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx($d,{items:ii,renderPathReference:(t,o)=>{const c=ye?.comparisonRepos,v=c&&c.length>1?[...c].sort((k,j)=>j.label.length-k.label.length).find(k=>t===k.label||t.startsWith(`${k.label}/`)):void 0,w=v?t===v.label?v.repoRoot:kn(t.slice(v.label.length+1),v.repoRoot):kn(t,js?.repoRoot||x);return Aa(w,i(o==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle"))},selectedKey:Mo,onSelect:on,emptyText:i(ye?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:te,backLabel:i("rightSidebar.backToChangeList"),headerTitle:i(ye?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:js?`${js.repoLabel} · ${js.branchName??"HEAD"} → ${js.baseRef}`:void 0,onClose:()=>{++z.current,Ie(!1),tr(!1),Xt(null)},closeLabel:i("common.back"),wrap:Pt,onToggleWrap:te?_a:void 0,wrapTitle:i("rightSidebar.wrapLongLines"),wrapOnLabel:i("rightSidebar.wrapOn"),wrapOffLabel:i("rightSidebar.wrapOff"),desktopLayout:te?"stacked":"split",onInsertDiffReference:$r,onReferenceCopied:Mr,insertedReferenceKey:W,copiedReferenceKey:Oe,onClearAuditRecord:Ia,localOptions:ye?.comparisonRepos?.map(t=>({key:t.repoRoot,label:t.label,checked:t.includeUncommitted??ye.includeUncommitted??!1,disabled:!Vr(t.repoRoot,t.head),onChange:o=>{ui({refresh:!0,repoRoot:t.repoRoot,includeUncommitted:o})}})),onHunkGitAction:ye?.includeUncommitted?Th:void 0,error:Ge,actionsBusy:fe>0,onRefresh:()=>{ui({refresh:!0})},refreshing:Qe,refreshLabel:i("rightSidebar.branchAuditRefreshDiff"),refreshTitle:i("rightSidebar.branchAuditRefreshDiff"),walkthroughs:Rh,onWalkthroughNavigate:Ch,initialDetailScrollTop:ye&&Ve?ss[Ve]:void 0,onDetailScrollPositionChange:Ah,externalSwiperRef:te?va:void 0,onMobileSlideChange:te?Eo:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:nd?e.jsx("div",{className:"px-3",children:nd}):zr?e.jsx(Ai,{slow:Vl}):hn?e.jsx(to,{message:hn,onRetry:()=>{ps()}}):iu(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(to,{message:R.error??i("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{ps()}}):x?e.jsx(Ai,{slow:Vl}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i(x?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),e.jsx(eo,{active:Wn,children:te?e.jsxs(gu,{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(Nl,0)},onSlideChange:t=>{if(Rr(t.activeIndex),ms.current===t.activeIndex){ms.current=null;return}t.activeIndex===0&&(jr(!1),gt(null),S?.())},children:[e.jsx(Hi,{className:"h-full min-h-0",children:e.jsxs("div",{ref:_n,onScroll:sc,onDragOver:wa,onDragEnter:wa,onDragLeave:ic,onDrop:lc,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[Il&&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()&&ad,e.jsx(jd,{rootPath:ge??"",onFileSelect:bs,onPathReference:Wt,getReferenceText:Sa,onReferenceCopied:Mr,insertedReferenceKey:W,copiedReferenceKey:Oe,onDirectoryRoot:gc,onSearchFromDirectory:bc,onDirectoryPinToggle:xc,onFilePinToggle:vc,pinnedPaths:xn,selectedFilePath:st,query:Fe,searchRootPath:Jl,searchOptions:Ql,searchMode:F,onContentMatchSelect:ac,onDirectoryDropFiles:(t,o)=>xs(o,t),revealDirectory:ie,canOpenInFileBrowser:Dl,onOpenInFileBrowser:oc})]})}),e.jsx(Hi,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(ll,{filePath:Wn&&(_f||Nl===1)?st:null,onInsertReference:Wt,onInsertText:Er,onInsertFeature:Er,onReviewReference:fc,onReferenceCopied:Mr,onClose:zh,onDirectoryLinkOpen:sd,isMobile:!0,lineRange:Cn,onLineRangeChange:gt,insertedReferenceKey:W,copiedReferenceKey:Oe,scrollToLine:He,onScrollToLineHandled:()=>At(null),markdownOutlineOpen:B,markdownOutlineCloseSignal:$,onOpenMarkdownOutline:M,onCloseMarkdownOutline:L,markdownImageLightboxOpen:T,markdownImageLightboxCloseSignal:U,onOpenMarkdownImageLightbox:I,onCloseMarkdownImageLightbox:p})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:_n,onScroll:sc,onDragOver:wa,onDragEnter:wa,onDragLeave:ic,onDrop:lc,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:Io},children:[Il&&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()&&ad,e.jsx(jd,{rootPath:ge??"",onFileSelect:bs,onPathReference:Wt,getReferenceText:Sa,onReferenceCopied:Mr,insertedReferenceKey:W,copiedReferenceKey:Oe,onDirectoryRoot:gc,onSearchFromDirectory:bc,onDirectoryPinToggle:xc,onFilePinToggle:vc,pinnedPaths:xn,selectedFilePath:st,query:Fe,searchRootPath:Jl,searchOptions:Ql,searchMode:F,onContentMatchSelect:ac,onDirectoryDropFiles:(t,o)=>xs(o,t),revealDirectory:ie,canOpenInFileBrowser:Dl,onOpenInFileBrowser:oc})]}),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:Yf,onPointerMove:Xf,onPointerUp:nc,onPointerCancel:nc,onDoubleClick:()=>{Do(Qi),Lt(Ps,Qi)},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(ll,{filePath:Wn?st:null,onInsertReference:Wt,onInsertText:Er,onInsertFeature:Er,onReviewReference:fc,onReferenceCopied:Mr,onDirectoryLinkOpen:sd,isMobile:!1,lineRange:Cn,onLineRangeChange:gt,insertedReferenceKey:W,copiedReferenceKey:Oe,scrollToLine:He,onScrollToLineHandled:()=>At(null),markdownOutlineOpen:B,markdownOutlineCloseSignal:$,onOpenMarkdownOutline:M,onCloseMarkdownOutline:L,markdownImageLightboxOpen:T,markdownImageLightboxCloseSignal:U,onOpenMarkdownImageLightbox:I,onCloseMarkdownImageLightbox:p})})]})}),e.jsx(eo,{active:Rt,mounted:Bf||Rt,children:()=>qo?e.jsx(zm,{}):te?e.jsx(zi,{mobile:!0,backLabel:i("rightSidebar.backToChangeList"),externalSwiperRef:va,onMobileSlideChange:Eo,groups:Vt.length>0?Fc():[],mode:vr,onModeChange:Fa,selectedKey:st,scrollToKey:Hc,scrollToKeyNonce:ua.nonce,compact:!1,collapsedDirectoryKeys:Ks,onToggleDirectory:Gc,onSelectFile:t=>{const o=Array.from(Se.values()).find(c=>yt(c)===t.key);o&&Da(yt(o))},renderLeading:Bc,renderTrailing:t=>{const o=Array.from(Se.values()).find(c=>yt(c)===t.key);return o?Ic(o):null},renderDirectoryTrailing:Dc,renderSubtitle:t=>{const o=Array.from(Se.values()).find(c=>yt(c)===t.key);return o?Tc(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:[Ha&&e.jsx("div",{className:"mb-2",children:Ha}),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:[Vt.length,"/",Se.size]})]}),e.jsxs(Md,{actions:id,children:[Ac(),t,h&&ai(),od]},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:Ea?(t=>Wc(t)):void 0,emptyContent:qo?null:hn&&Se.size===0?e.jsx(to,{message:hn,onRetry:()=>{ps()}}):Se.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i("rightSidebar.noChanges")}):Vt.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:()=>gs(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(Bs,{size:14}),i("rightSidebar.backToChangeList")]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-1.5",children:[h&&ai(),e.jsxs("button",{type:"button",onClick:_a,"aria-pressed":Pt,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 ${Pt?"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(Pt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:_c(),activePane:Rt,wrap:Pt,diffViewType:Gf,inlineMode:yr,diffOptions:Yc,reloadKey:Ys,renderStreamBadge:t=>e.jsx(Ds,{status:t}),onHunkGitAction:Jc,onInsertDiffReference:$r,onReferenceCopied:Mr,insertedReferenceKey:W,copiedReferenceKey:Oe,onClearAuditRecord:Ia,onDetailScroll:Pa}):e.jsx(zi,{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:Vt.length>0?Fc():[],mode:vr,onModeChange:Fa,selectedKey:st,scrollToKey:Hc,scrollToKeyNonce:ua.nonce,compact:!0,collapsedDirectoryKeys:Ks,onToggleDirectory:Gc,onSelectFile:t=>{const o=Array.from(Se.values()).find(c=>yt(c)===t.key);o&&Da(yt(o))},renderLeading:Bc,renderTrailing:t=>{const o=Array.from(Se.values()).find(c=>yt(c)===t.key);return o?Ic(o):null},renderDirectoryTrailing:Dc,renderSubtitle:t=>{const o=Array.from(Se.values()).find(c=>yt(c)===t.key);return o?Tc(o):null},aiContent:Ea?(t=>Wc(t)):void 0,emptyContent:qo?null:hn&&Se.size===0?e.jsx(to,{message:hn,onRetry:()=>{ps()}}):Se.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i("rightSidebar.noChanges")}):Vt.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:[Ha&&e.jsx("div",{className:"mb-2",children:Ha}),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:[Vt.length,"/",Se.size]})})]}),e.jsxs(Md,{actions:id,children:[Ac(),t,ai(),e.jsxs("button",{type:"button",onClick:_a,"aria-pressed":Pt,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 ${Pt?"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(Pt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),od]},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:_c(),activePane:Rt,wrap:Pt,diffViewType:Ot,inlineMode:yr,diffOptions:Yc,reloadKey:Ys,renderStreamBadge:t=>e.jsx(Ds,{status:t}),onHunkGitAction:Jc,onInsertDiffReference:$r,onReferenceCopied:Mr,insertedReferenceKey:W,copiedReferenceKey:Oe,onClearAuditRecord:Ia,onDetailScroll:Pa})}),e.jsx(eo,{active:Gn,mounted:Ao&&Hr,children:Of?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:()=>{xi.getState().setDock(yi,null),no({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:i("android.splitClose")})]}):e.jsx(Wm,{sessionId:n??null,onInsertPrompt:t=>$r("android-deps",t),onInsertFile:rh,onRecordingComplete:th})})]}),r&&tt&&e.jsx(Fp,{value:ve,collapsed:Pr,autoCollapseAfterSend:H,focusRequest:mt,insertError:Tr?i("rightSidebar.contextDraftInsertFailed"):null,onChange:t=>{pr(!1),We(t)},onCollapsedChange:_t,onAutoCollapseAfterSendChange:ae,onDisable:()=>dt(!1),onClear:()=>We(""),onInsert:()=>hc(!1),onInsertAndSend:()=>hc(!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})}}),ph(),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:hu(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:!!Ue||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"),Di(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(Ue?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const px=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:ll,MarkdownImageLightbox:jf,MarkdownPreview:Rf,RightSidebar:nx,__testParseMarkdownListBlock:yb,buildMarkdownPreviewBlocks:Lb,buildMarkdownPreviewRenderResult:vl,collectKnownGitRepoRoots:qu,computeMarkdownImageDisplayBox:of,getMarkdownHeadingOutline:Sf,getMarkdownHeadingPathAtLine:kf,getNextMarkdownPreviewLineRange:Fb,isSvgImageSrc:yo,mountRightSidebarRepoPickerOverlay:Iu,replaceGitRepositorySnapshot:Lf,resolveMarkdownLocalLinkTarget:hl,resolveRightSidebarDiffViewType:Ku,shouldCloseMarkdownImageLightboxDrag:vf,showsGitRepoGroupHeader:Zi},Symbol.toStringTag,{value:"Module"}));export{Ki as E,px as R,ep as a,pp as c,mx as m};
|