termdock 1.4.248 → 1.4.249
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-DA7cQLR7.js → App-ySHLLxfl.js} +35 -35
- package/dist/client/assets/App-ySHLLxfl.js.br +0 -0
- package/dist/client/assets/App-ySHLLxfl.js.gz +0 -0
- package/dist/client/assets/{ChangeWalkthroughPanel-vDiLbIdv.js → ChangeWalkthroughPanel-DrsLVbFw.js} +2 -2
- package/dist/client/assets/ChangeWalkthroughPanel-DrsLVbFw.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-DrsLVbFw.js.gz +0 -0
- package/dist/client/assets/{DagPlayground-BvY_KblL.js → DagPlayground-CBUX-s8X.js} +1 -1
- package/dist/client/assets/DagPlayground-CBUX-s8X.js.br +0 -0
- package/dist/client/assets/DagPlayground-CBUX-s8X.js.gz +0 -0
- package/dist/client/assets/{DiffLab-Dra7cEKx.js → DiffLab-DD8m9b0G.js} +1 -1
- package/dist/client/assets/DiffLab-DD8m9b0G.js.br +0 -0
- package/dist/client/assets/DiffLab-DD8m9b0G.js.gz +0 -0
- package/dist/client/assets/{DiffReview-v9_1IS2n.js → DiffReview-BEFjWY01.js} +1 -1
- package/dist/client/assets/DiffReview-BEFjWY01.js.br +0 -0
- package/dist/client/assets/DiffReview-BEFjWY01.js.gz +0 -0
- package/dist/client/assets/{DiffReviewLab-BF8Dada6.js → DiffReviewLab-BS1rFkx9.js} +1 -1
- package/dist/client/assets/DiffReviewLab-BS1rFkx9.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-BS1rFkx9.js.gz +0 -0
- package/dist/client/assets/{DiffViewer-C2s4BXp0.js → DiffViewer-zb8C5YLR.js} +1 -1
- package/dist/client/assets/DiffViewer-zb8C5YLR.js.br +0 -0
- package/dist/client/assets/DiffViewer-zb8C5YLR.js.gz +0 -0
- package/dist/client/assets/{ModelPreview-D9pzW_YD.js → ModelPreview-BdY9A7GQ.js} +1 -1
- package/dist/client/assets/ModelPreview-BdY9A7GQ.js.br +0 -0
- package/dist/client/assets/ModelPreview-BdY9A7GQ.js.gz +0 -0
- package/dist/client/assets/RightSidebar-lV2Ca2-c.js +1678 -0
- package/dist/client/assets/RightSidebar-lV2Ca2-c.js.br +0 -0
- package/dist/client/assets/RightSidebar-lV2Ca2-c.js.gz +0 -0
- package/dist/client/assets/{abnfDiagram-VCTEODGH-DVOxqZDY.js → abnfDiagram-VCTEODGH-ChpMiLwB.js} +1 -1
- package/dist/client/assets/abnfDiagram-VCTEODGH-ChpMiLwB.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-ChpMiLwB.js.gz +0 -0
- package/dist/client/assets/{app-JK4pM9zv.js → app-DhyrRqRS.js} +11 -11
- package/dist/client/assets/app-DhyrRqRS.js.br +0 -0
- package/dist/client/assets/app-DhyrRqRS.js.gz +0 -0
- package/dist/client/assets/{arc-DY_WK1Ln.js → arc-CcPLW1-W.js} +1 -1
- package/dist/client/assets/arc-CcPLW1-W.js.br +0 -0
- package/dist/client/assets/arc-CcPLW1-W.js.gz +0 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-oyhVtQ5E.js → architectureDiagram-5GKGNRK7-CjWa2b5g.js} +1 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CjWa2b5g.js.br +0 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-oyhVtQ5E.js.gz → architectureDiagram-5GKGNRK7-CjWa2b5g.js.gz} +0 -0
- package/dist/client/assets/{blockDiagram-I7D4REHJ-DTMir8MU.js → blockDiagram-I7D4REHJ-D1AMj3Ey.js} +1 -1
- package/dist/client/assets/blockDiagram-I7D4REHJ-D1AMj3Ey.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-D1AMj3Ey.js.gz +0 -0
- package/dist/client/assets/{c4Diagram-7LVT6UL2-DpDHYMUW.js → c4Diagram-7LVT6UL2-Bo4f-Dyo.js} +1 -1
- package/dist/client/assets/c4Diagram-7LVT6UL2-Bo4f-Dyo.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-Bo4f-Dyo.js.gz +0 -0
- package/dist/client/assets/channel-B5npd3sc.js +1 -0
- package/dist/client/assets/{chunk-2Q5K7J3B-CZw9qV1g.js → chunk-2Q5K7J3B-EA_Ksody.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-7oLZ2vUy.js → chunk-5VM5RSS4-D49nnzNg.js} +1 -1
- package/dist/client/assets/{chunk-F27PBJKO-8wDqj2MV.js → chunk-F27PBJKO-BiHLxDgP.js} +1 -1
- package/dist/client/assets/chunk-F27PBJKO-BiHLxDgP.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-BiHLxDgP.js.gz +0 -0
- package/dist/client/assets/{chunk-IMKFNOWR-BnRNosQc.js → chunk-IMKFNOWR-B_x-RlD-.js} +1 -1
- package/dist/client/assets/chunk-IMKFNOWR-B_x-RlD-.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-B_x-RlD-.js.gz +0 -0
- package/dist/client/assets/{chunk-JWPE2WC7-DnbB0Lhi.js → chunk-JWPE2WC7-BO2gECxo.js} +1 -1
- package/dist/client/assets/{chunk-POPQ4Y6H-TXREax5x.js → chunk-POPQ4Y6H-CTJ8R53n.js} +1 -1
- package/dist/client/assets/{chunk-SVP7TREG-qPD0Q74z.js → chunk-SVP7TREG-jDMFhXej.js} +1 -1
- package/dist/client/assets/chunk-SVP7TREG-jDMFhXej.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-jDMFhXej.js.gz +0 -0
- package/dist/client/assets/{chunk-TICWLB2K-yzLwt_MH.js → chunk-TICWLB2K-DuOVjlA7.js} +1 -1
- package/dist/client/assets/chunk-TICWLB2K-DuOVjlA7.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-DuOVjlA7.js.gz +0 -0
- package/dist/client/assets/{chunk-XXDRQBXY-Dksq2NzZ.js → chunk-XXDRQBXY-Dg68j1ru.js} +1 -1
- package/dist/client/assets/classDiagram-ZZMXUADV-BxAMJQEG.js +1 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-BxAMJQEG.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-BZyAGO6R.js → cose-bilkent-JH36ORCC-eC0PV-vF.js} +1 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-eC0PV-vF.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-eC0PV-vF.js.gz +0 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-CyrkJWSU.js → cynefin-OW5HDTMX-CbwuuKCK.js} +1 -1
- package/dist/client/assets/cynefin-OW5HDTMX-CbwuuKCK.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-CbwuuKCK.js.gz +0 -0
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-BrqS8ZGX.js → cynefinDiagram-5FMLGOSQ-DiL62xjJ.js} +1 -1
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-DiL62xjJ.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-DiL62xjJ.js.gz +0 -0
- package/dist/client/assets/{dagre-GXQ25YYZ-ysmdkSNr.js → dagre-GXQ25YYZ-BoCcQeIF.js} +1 -1
- package/dist/client/assets/dagre-GXQ25YYZ-BoCcQeIF.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-BoCcQeIF.js.gz +0 -0
- package/dist/client/assets/{diagram-S7CK7UJ4-CWSuzX1d.js → diagram-S7CK7UJ4-BHxSkDxD.js} +1 -1
- package/dist/client/assets/diagram-S7CK7UJ4-BHxSkDxD.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-BHxSkDxD.js.gz +0 -0
- package/dist/client/assets/{diagram-UQ7AKVKN-BMxc5NDd.js → diagram-UQ7AKVKN-D2t82qXI.js} +1 -1
- package/dist/client/assets/diagram-UQ7AKVKN-D2t82qXI.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-D2t82qXI.js.gz +0 -0
- package/dist/client/assets/{diagram-VSXAHHWV-Cz5KpnGX.js → diagram-VSXAHHWV-DYQmQwL5.js} +1 -1
- package/dist/client/assets/diagram-VSXAHHWV-DYQmQwL5.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-DYQmQwL5.js.gz +0 -0
- package/dist/client/assets/{diagram-VX7I27RA-CNk1h20b.js → diagram-VX7I27RA-6SfVR4Z9.js} +1 -1
- package/dist/client/assets/diagram-VX7I27RA-6SfVR4Z9.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-6SfVR4Z9.js.gz +0 -0
- package/dist/client/assets/{diagram-Z3DM3KII-C4lcgl6z.js → diagram-Z3DM3KII-CQiCDGAx.js} +1 -1
- package/dist/client/assets/diagram-Z3DM3KII-CQiCDGAx.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-CQiCDGAx.js.gz +0 -0
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-Cwo356mF.js → ebnfDiagram-PWID7BFC-C7YMHrC7.js} +1 -1
- package/dist/client/assets/ebnfDiagram-PWID7BFC-C7YMHrC7.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-C7YMHrC7.js.gz +0 -0
- package/dist/client/assets/{erDiagram-RLTQ6QDP-B4DEocxu.js → erDiagram-RLTQ6QDP-C1-5SbSU.js} +1 -1
- package/dist/client/assets/erDiagram-RLTQ6QDP-C1-5SbSU.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-C1-5SbSU.js.gz +0 -0
- package/dist/client/assets/{flowDiagram-HODETNUW-CWP3R7jz.js → flowDiagram-HODETNUW-xNfUeMOl.js} +1 -1
- package/dist/client/assets/flowDiagram-HODETNUW-xNfUeMOl.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-xNfUeMOl.js.gz +0 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-DBdMWa6L.js → ganttDiagram-EL5Y4UJY-CHiEXULk.js} +1 -1
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CHiEXULk.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CHiEXULk.js.gz +0 -0
- package/dist/client/assets/{gestureArbiter-FNHriuhM.js → gestureArbiter-Q4qvTxJM.js} +1 -1
- package/dist/client/assets/gestureArbiter-Q4qvTxJM.js.br +0 -0
- package/dist/client/assets/gestureArbiter-Q4qvTxJM.js.gz +0 -0
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-B6qG6eRT.js → gitGraphDiagram-WWUBYQGX-DGHj-HHA.js} +1 -1
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DGHj-HHA.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DGHj-HHA.js.gz +0 -0
- package/dist/client/assets/{index-fjWWhVQp.css → index-CwuSutCd.css} +1 -1
- package/dist/client/assets/index-CwuSutCd.css.br +0 -0
- package/dist/client/assets/{index-fjWWhVQp.css.gz → index-CwuSutCd.css.gz} +0 -0
- package/dist/client/assets/{infoDiagram-27XIBGKW-DStk0sCn.js → infoDiagram-27XIBGKW-CkKjaZnz.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-Cz8OXUK9.js → ishikawaDiagram-5VMMS53U-BxwoaCAJ.js} +1 -1
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-BxwoaCAJ.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-BxwoaCAJ.js.gz +0 -0
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-CD4v2_eb.js → journeyDiagram-3NMN7TZE-Co0Qn6y1.js} +1 -1
- package/dist/client/assets/journeyDiagram-3NMN7TZE-Co0Qn6y1.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-Co0Qn6y1.js.gz +0 -0
- package/dist/client/assets/{kanban-definition-UXKFOSKX-DwLWqTSY.js → kanban-definition-UXKFOSKX-BSOfc04T.js} +1 -1
- package/dist/client/assets/kanban-definition-UXKFOSKX-BSOfc04T.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-BSOfc04T.js.gz +0 -0
- package/dist/client/assets/{layout-C1EhlDX0.js → layout-BmHMb94h.js} +1 -1
- package/dist/client/assets/layout-BmHMb94h.js.br +0 -0
- package/dist/client/assets/layout-BmHMb94h.js.gz +0 -0
- package/dist/client/assets/{linear-DQLRPRnN.js → linear-y-Abd9JO.js} +1 -1
- package/dist/client/assets/linear-y-Abd9JO.js.br +0 -0
- package/dist/client/assets/linear-y-Abd9JO.js.gz +0 -0
- package/dist/client/assets/{mermaid.core-BzEGo4OD.js → mermaid.core-B4rzVonW.js} +5 -5
- package/dist/client/assets/mermaid.core-B4rzVonW.js.br +0 -0
- package/dist/client/assets/mermaid.core-B4rzVonW.js.gz +0 -0
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-Dct8OiDY.js → mindmap-definition-YA3MSWOX-DY3bdl53.js} +1 -1
- package/dist/client/assets/mindmap-definition-YA3MSWOX-DY3bdl53.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-DY3bdl53.js.gz +0 -0
- package/dist/client/assets/{passwordBootstrap-C7Gy7ATG.js → passwordBootstrap-kiljsfOw.js} +1 -1
- package/dist/client/assets/passwordBootstrap-kiljsfOw.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-kiljsfOw.js.gz +0 -0
- package/dist/client/assets/{pegDiagram-XKGWAZYB-fIABDYj-.js → pegDiagram-XKGWAZYB-XdVcJb90.js} +1 -1
- package/dist/client/assets/pegDiagram-XKGWAZYB-XdVcJb90.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-XdVcJb90.js.gz +0 -0
- package/dist/client/assets/{pieDiagram-E7YTZNPT-D2EuLDIj.js → pieDiagram-E7YTZNPT-CgAHRPHX.js} +1 -1
- package/dist/client/assets/pieDiagram-E7YTZNPT-CgAHRPHX.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-CgAHRPHX.js.gz +0 -0
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-BjF42rwO.js → quadrantDiagram-AXDQQJYC-C-nwguRe.js} +1 -1
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-C-nwguRe.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-C-nwguRe.js.gz +0 -0
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-DjfSTDvw.js → railroadDiagram-O6MQD6OU-TcJFsMp6.js} +1 -1
- package/dist/client/assets/railroadDiagram-O6MQD6OU-TcJFsMp6.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-TcJFsMp6.js.gz +0 -0
- package/dist/client/assets/{referenceLongPress-Cz9no5pI.js → referenceLongPress-DcD1aZqh.js} +1 -1
- package/dist/client/assets/referenceLongPress-DcD1aZqh.js.br +0 -0
- package/dist/client/assets/referenceLongPress-DcD1aZqh.js.gz +0 -0
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-BewZ62Ou.js → requirementDiagram-BXWQKSXE-CDAoFFyT.js} +1 -1
- package/dist/client/assets/requirementDiagram-BXWQKSXE-CDAoFFyT.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-CDAoFFyT.js.gz +0 -0
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-BhlchAkm.js → sankeyDiagram-P5KCCOFB-rscTAtOd.js} +1 -1
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-rscTAtOd.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-rscTAtOd.js.gz +0 -0
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-CFzratAc.js → sequenceDiagram-WJ2MYXX4-w_pdEULi.js} +1 -1
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-w_pdEULi.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-w_pdEULi.js.gz +0 -0
- package/dist/client/assets/{sizeCapture-INFHLROL-DeLB3S5x.js → sizeCapture-INFHLROL-tqubtbTJ.js} +1 -1
- package/dist/client/assets/sizeCapture-INFHLROL-tqubtbTJ.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-tqubtbTJ.js.gz +0 -0
- package/dist/client/assets/{sparkles-BHsBDSo5.js → sparkles-BQVhXL1X.js} +1 -1
- package/dist/client/assets/{stateDiagram-D77RDMKH-smIkttxr.js → stateDiagram-D77RDMKH-DFm71XIp.js} +1 -1
- package/dist/client/assets/stateDiagram-D77RDMKH-DFm71XIp.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-DFm71XIp.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-aTUiN9r3.js +1 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-CVwGuPcK.js → swimlanes-42K2YHIH-Bg6TJPYj.js} +1 -1
- package/dist/client/assets/swimlanes-42K2YHIH-Bg6TJPYj.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-Bg6TJPYj.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-Bwf9yeLM.js +8 -0
- package/dist/client/assets/{timeline-definition-24CTP7MA-Dsn_Rxbd.js → timeline-definition-24CTP7MA-CwrKihuj.js} +1 -1
- package/dist/client/assets/timeline-definition-24CTP7MA-CwrKihuj.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-CwrKihuj.js.gz +0 -0
- package/dist/client/assets/{triangle-alert-DexJX8jR.js → triangle-alert-DZyRaNWe.js} +1 -1
- package/dist/client/assets/{vennDiagram-4TSXK5OY-Dtdth9UN.js → vennDiagram-4TSXK5OY-WqUYcege.js} +1 -1
- package/dist/client/assets/vennDiagram-4TSXK5OY-WqUYcege.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-WqUYcege.js.gz +0 -0
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-82oGoyOd.js → wardleyDiagram-VM6X3IG4-B7Xfv-yN.js} +1 -1
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-B7Xfv-yN.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-B7Xfv-yN.js.gz +0 -0
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-Ygu0NbUo.js → xychartDiagram-S5SC5T6Z-BJupQX5U.js} +1 -1
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-Ygu0NbUo.js.br → xychartDiagram-S5SC5T6Z-BJupQX5U.js.br} +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-BJupQX5U.js.gz +0 -0
- package/dist/client/index.html +2 -2
- package/dist/client/index.html.br +0 -0
- package/dist/client/index.html.gz +0 -0
- package/dist/client/sw.js +1 -1
- package/dist/client/sw.js.br +0 -0
- package/dist/client/sw.js.gz +0 -0
- package/dist/server/android/adb.js +154 -0
- package/dist/server/android/scrcpy.js +379 -0
- package/dist/server/entry.js +9 -1
- package/dist/server/federation/runtime.js +29 -4
- package/dist/server/routes/android.js +205 -0
- package/dist/server/routes/terminal.js +13 -1
- package/dist/server/utils/apiAccess.js +3 -1
- package/dist/server/utils/settings.js +47 -0
- package/package.json +1 -1
- package/runtime-manifest.json +3 -3
- package/dist/client/assets/App-DA7cQLR7.js.br +0 -0
- package/dist/client/assets/App-DA7cQLR7.js.gz +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-vDiLbIdv.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-vDiLbIdv.js.gz +0 -0
- package/dist/client/assets/DagPlayground-BvY_KblL.js.br +0 -0
- package/dist/client/assets/DagPlayground-BvY_KblL.js.gz +0 -0
- package/dist/client/assets/DiffLab-Dra7cEKx.js.br +0 -0
- package/dist/client/assets/DiffLab-Dra7cEKx.js.gz +0 -0
- package/dist/client/assets/DiffReview-v9_1IS2n.js.br +0 -0
- package/dist/client/assets/DiffReview-v9_1IS2n.js.gz +0 -0
- package/dist/client/assets/DiffReviewLab-BF8Dada6.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-BF8Dada6.js.gz +0 -0
- package/dist/client/assets/DiffViewer-C2s4BXp0.js.br +0 -0
- package/dist/client/assets/DiffViewer-C2s4BXp0.js.gz +0 -0
- package/dist/client/assets/ModelPreview-D9pzW_YD.js.br +0 -0
- package/dist/client/assets/ModelPreview-D9pzW_YD.js.gz +0 -0
- package/dist/client/assets/RightSidebar-DL8z6vvJ.js +0 -1678
- package/dist/client/assets/RightSidebar-DL8z6vvJ.js.br +0 -0
- package/dist/client/assets/RightSidebar-DL8z6vvJ.js.gz +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-DVOxqZDY.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-DVOxqZDY.js.gz +0 -0
- package/dist/client/assets/app-JK4pM9zv.js.br +0 -0
- package/dist/client/assets/app-JK4pM9zv.js.gz +0 -0
- package/dist/client/assets/arc-DY_WK1Ln.js.br +0 -0
- package/dist/client/assets/arc-DY_WK1Ln.js.gz +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-oyhVtQ5E.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-DTMir8MU.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-DTMir8MU.js.gz +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-DpDHYMUW.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-DpDHYMUW.js.gz +0 -0
- package/dist/client/assets/channel-cexw6K2f.js +0 -1
- package/dist/client/assets/chunk-F27PBJKO-8wDqj2MV.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-8wDqj2MV.js.gz +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-BnRNosQc.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-BnRNosQc.js.gz +0 -0
- package/dist/client/assets/chunk-SVP7TREG-qPD0Q74z.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-qPD0Q74z.js.gz +0 -0
- package/dist/client/assets/chunk-TICWLB2K-yzLwt_MH.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-yzLwt_MH.js.gz +0 -0
- package/dist/client/assets/classDiagram-ZZMXUADV-CpjKakYG.js +0 -1
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-CpjKakYG.js +0 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-BZyAGO6R.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-BZyAGO6R.js.gz +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-CyrkJWSU.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-CyrkJWSU.js.gz +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-BrqS8ZGX.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-BrqS8ZGX.js.gz +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-ysmdkSNr.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-ysmdkSNr.js.gz +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-CWSuzX1d.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-CWSuzX1d.js.gz +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-BMxc5NDd.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-BMxc5NDd.js.gz +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-Cz5KpnGX.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-Cz5KpnGX.js.gz +0 -0
- package/dist/client/assets/diagram-VX7I27RA-CNk1h20b.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-CNk1h20b.js.gz +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-C4lcgl6z.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-C4lcgl6z.js.gz +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-Cwo356mF.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-Cwo356mF.js.gz +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-B4DEocxu.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-B4DEocxu.js.gz +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-CWP3R7jz.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-CWP3R7jz.js.gz +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-DBdMWa6L.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-DBdMWa6L.js.gz +0 -0
- package/dist/client/assets/gestureArbiter-FNHriuhM.js.br +0 -0
- package/dist/client/assets/gestureArbiter-FNHriuhM.js.gz +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-B6qG6eRT.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-B6qG6eRT.js.gz +0 -0
- package/dist/client/assets/index-fjWWhVQp.css.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-Cz8OXUK9.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-Cz8OXUK9.js.gz +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-CD4v2_eb.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-CD4v2_eb.js.gz +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-DwLWqTSY.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-DwLWqTSY.js.gz +0 -0
- package/dist/client/assets/layout-C1EhlDX0.js.br +0 -0
- package/dist/client/assets/layout-C1EhlDX0.js.gz +0 -0
- package/dist/client/assets/linear-DQLRPRnN.js.br +0 -0
- package/dist/client/assets/linear-DQLRPRnN.js.gz +0 -0
- package/dist/client/assets/mermaid.core-BzEGo4OD.js.br +0 -0
- package/dist/client/assets/mermaid.core-BzEGo4OD.js.gz +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-Dct8OiDY.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-Dct8OiDY.js.gz +0 -0
- package/dist/client/assets/passwordBootstrap-C7Gy7ATG.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-C7Gy7ATG.js.gz +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-fIABDYj-.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-fIABDYj-.js.gz +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-D2EuLDIj.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-D2EuLDIj.js.gz +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-BjF42rwO.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-BjF42rwO.js.gz +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-DjfSTDvw.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-DjfSTDvw.js.gz +0 -0
- package/dist/client/assets/referenceLongPress-Cz9no5pI.js.br +0 -0
- package/dist/client/assets/referenceLongPress-Cz9no5pI.js.gz +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-BewZ62Ou.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-BewZ62Ou.js.gz +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-BhlchAkm.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-BhlchAkm.js.gz +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-CFzratAc.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-CFzratAc.js.gz +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-DeLB3S5x.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-DeLB3S5x.js.gz +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-smIkttxr.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-smIkttxr.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-BFDLILuN.js +0 -1
- package/dist/client/assets/swimlanes-42K2YHIH-CVwGuPcK.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-CVwGuPcK.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-B0Dzvkwg.js +0 -8
- package/dist/client/assets/timeline-definition-24CTP7MA-Dsn_Rxbd.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-Dsn_Rxbd.js.gz +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-Dtdth9UN.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-Dtdth9UN.js.gz +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-82oGoyOd.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-82oGoyOd.js.gz +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-Ygu0NbUo.js.gz +0 -0
|
@@ -1,1678 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-D9pzW_YD.js","assets/app-JK4pM9zv.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-fjWWhVQp.css","assets/App-DA7cQLR7.js","assets/gestureArbiter-FNHriuhM.js","assets/gestureArbiter-C2J0D0kV.css","assets/triangle-alert-DexJX8jR.js","assets/referenceLongPress-Cz9no5pI.js","assets/DiffReview-v9_1IS2n.js","assets/sparkles-BHsBDSo5.js","assets/DiffViewer-C2s4BXp0.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-vDiLbIdv.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-BzEGo4OD.js","assets/purify.es-4eNOHKSq.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a3 as Mt,a0 as uh,bc as e,cF as yt,cP as xt,bu as tt,a as Ns,aL as fh,C as bi,c as Ms,X as Ut,cC as hh,b0 as mh,y as gs,ak as ph,cJ as te,b4 as gh,b6 as Ui,b7 as bh,b8 as Td,b5 as bs,ax as xh,E as vh,i as yh,b3 as wh,bw as kh,by as Sh,bz as jh,aX as Rh,bx as Oc,x as bt,f as Ch,L as vt,u as Nh,b as Mh,aW as Uc,at as Hc,ap as $h,aB as Ca,aC as zc,cQ as Ss,ag as xs,aD as Eh,cD as Yo,bo as Lh,co as Wc,av as Ah,cA as Ph,bZ as Th,aG as Ih,N as Gc,K as Fh,aq as Dh,au as _h,az as qc,b$ as Bh,r as Oh,d as Na,g as xi,v as Id,ac as Uh,_ as $s,bT as Hh,cN as zh,bj as Wh,ae as Gh}from"./app-JK4pM9zv.js";import{x as qh,g as Kh,p as Ba,e as Vh,P as Yh,k as Xh,R as vi,q as Fd,r as Jh,S as Vn,D as Qh,c as Dd,a as Zh,w as _d,u as Ma,s as em,t as tm,v as rm,T as Kc,d as Vc,j as Xo,i as $a,b as nm,m as sm,h as am,f as om,n as im,F as Yc,C as lm,G as cm}from"./App-DA7cQLR7.js";import{b as o,r as Gr}from"./dnd-BCFAPC0L.js";import{a as dm,S as um,b as Bd,c as yi,F as fm}from"./gestureArbiter-FNHriuhM.js";import{D as wi,C as js,L as Od,f as hm,n as mm}from"./DiffReview-v9_1IS2n.js";import{T as pm,L as za,M as Ud,G as Rr}from"./triangle-alert-DexJX8jR.js";import{S as Es}from"./sparkles-BHsBDSo5.js";import{C as Hd,M as zd}from"./ChangeWalkthroughPanel-vDiLbIdv.js";import{r as Wd,s as Gd,l as qd,u as gm,h as Kd}from"./DiffViewer-C2s4BXp0.js";import{u as Vd,G as Yd}from"./referenceLongPress-Cz9no5pI.js";const bm=[["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"}]],xm=Mt("case-sensitive",bm);const vm=[["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"}]],ym=Mt("eye-off",vm);const wm=[["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=Mt("eye",wm);const km=[["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"}]],Si=Mt("file-text",km);const Sm=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Xc=Mt("house",Sm);const jm=[["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"}]],Rm=Mt("image-plus",jm);const Cm=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],Nm=Mt("maximize",Cm);const Mm=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],$m=Mt("minimize",Mm);const Em=[["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"}]],Lm=Mt("regex",Em);const Am=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Pm=Mt("rotate-cw",Am);const Tm=[["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"}]],Im=Mt("scan",Tm);const Fm=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Jc=Mt("send",Fm);const Dm=[["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"}]],_m=Mt("upload",Dm);const Bm=[["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"}]],Om=Mt("whole-word",Bm);async function Um(t){let n;try{await Promise.race([t(),new Promise(s=>{n=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(n)}}function Hm({active:t,rootPath:n,loading:s,delay:l,lastStartedRoot:d,load:c}){o.useEffect(()=>{if(!t||!n||s||d.current===n)return;const h=window.setTimeout(()=>{d.current=n,c(n)},l);return()=>window.clearTimeout(h)},[t,n,s,l,d,c])}function zm(t,n,s){try{const l=t instanceof HTMLImageElement?t.naturalWidth:t.width,d=t instanceof HTMLImageElement?t.naturalHeight:t.height;if(!l||!d)return Promise.resolve(null);const c=t instanceof HTMLImageElement?1400/Math.max(l,d):Math.min(1,1400/Math.max(l,d)),h=document.createElement("canvas");h.width=Math.max(1,Math.round(l*c)),h.height=Math.max(1,Math.round(d*c));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(t,0,0,h.width,h.height),s){const p=Math.max(10,Math.min(16,h.width/35));m.font=`${p}px sans-serif`;const f=[];let k="";for(const y of s.split(" "))k&&m.measureText(`${k} ${y}`).width>h.width-20?(f.push(k),k=y):k=k?`${k} ${y}`:y;k&&f.push(k),m.fillStyle=g.getPropertyValue("--surface").trim()||"white",m.fillRect(0,0,h.width,f.length*(p+4)+12),m.fillStyle=g.getPropertyValue("--foreground").trim()||"black",f.forEach((y,N)=>m.fillText(y,10,8+p+N*(p+4)))}if(n){const p=n.xPercent*h.width/100,f=n.yPercent*h.height/100,k=Math.max(4,Math.min(12,Math.min(h.width,h.height)*.015)),y=k*1.6;m.strokeStyle=g.getPropertyValue("--primary").trim()||"black",m.lineWidth=Math.max(1,k/3),m.beginPath(),m.arc(p,f,k,0,Math.PI*2),m.stroke(),m.beginPath(),m.moveTo(p-y,f),m.lineTo(p+y,f),m.moveTo(p,f-y),m.lineTo(p,f+y),m.stroke()}return new Promise(p=>h.toBlob(p,"image/png"))}catch{return Promise.resolve(null)}}function Wm(t,n,s,l){return[t.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
|
|
3
|
-
`)}function Fb(t,n,s){const l=n*Math.PI/360,d=Math.min(l,Math.atan(Math.tan(l)*Math.max(s,.05)));return Math.max(t,1e-6)/Math.sin(d)*1.15}async function Gm(t,n,s,l){if(!s?.snapshot){l.isCurrent()&&l.insert(t,n);return}const d=new Date().toISOString(),c=new AbortController;let h,m;try{m=await Promise.race([(async()=>{const g=await s.snapshot;if(!(!g||c.signal.aborted||!l.isCurrent()))return l.upload(new File([g],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),c.signal)})(),new Promise(g=>{h=setTimeout(()=>{c.abort(),g(void 0)},3e3)})])}catch{}finally{clearTimeout(h),c.abort()}l.isCurrent()&&l.insert(m?Wm(t,"",d,m):t,n)}function qm(t){let n=1,s="terminal";for(;;){let l=!1;for(const d of t.values())if(d.name===s){l=!0;break}if(!l)break;s=`terminal-${n}`,n++}return s}const Qc=uh((t,n)=>({sessions:new Map,activeSessionId:null,nextSessionNumber:1,createSession:s=>{const l=qh(),d=Date.now(),c=n().sessions,h=qm(c),m={id:l,cwd:s,sessionId:null,name:h,customName:!1,createdAt:d,lastActivity:d};return t(g=>{const p=new Map(g.sessions);return p.set(l,m),{sessions:p,activeSessionId:g.activeSessionId??l,nextSessionNumber:g.nextSessionNumber+1}}),l},closeSession:s=>{t(l=>{const d=new Map(l.sessions),c=l.activeSessionId===s;d.delete(s);let h=l.activeSessionId;if(c){const m=Array.from(d.keys());h=m.length>0?m[0]:null}return{sessions:d,activeSessionId:h}})},switchSession:s=>{t(l=>l.sessions.has(s)?{activeSessionId:s}:l)},updateSession:(s,l)=>{t(d=>{const c=d.sessions.get(s);if(!c)return d;const h=new Map(d.sessions);return h.set(s,{...c,...l,lastActivity:Date.now()}),{sessions:h}})},setTerminalSession:(s,l)=>{n().updateSession(s,{sessionId:l.sessionId})},getActiveSession:()=>{const s=n();if(s.activeSessionId)return s.sessions.get(s.activeSessionId)},getSessionCount:()=>n().sessions.size,clearAllSessions:()=>{t({sessions:new Map,activeSessionId:null,nextSessionNumber:1})}}));function Km(t,n){return t===n||n.endsWith(`/${t}`)||t.endsWith(`/${n}`)}function Zc(t,n){return`${t??""}\0${n}`}function Vm(t,n,s){if(!t||t.length===0||!s)return{explained:0,stale:0};const l=Zc(n,s);let d=0,c=0;for(const h of t){const m=[h.filePath,h.newPath,h.oldPath].filter(p=>typeof p=="string"&&p.length>0);(m.some(p=>Zc(h.repoRoot,p)===l)||m.some(p=>Km(p,s)))&&(d+=1)}return{explained:d,stale:c}}function Ym({status:t}){if(!t)return null;const n=t.stale>0&&t.explained===0;if(!(t.explained>0||t.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(pm,{size:10}):e.jsx(Es,{size:10})})}function ji({changeStatus:t,auditStatus:n,renderChangeBadge:s}){return e.jsxs("span",{className:"inline-flex items-center gap-1",children:[s(t),e.jsx(Ym,{status:n})]})}const Xd="termdock:right-sidebar:diff-change-list-mode:v1";function Xm(t){return t==="list"||t==="tree"}function Jm(){return tt(Xd,Xm)??"tree"}function Qm(t){for(const l of t){const d=l.hunk;if(d.oldPath&&d.newPath&&d.oldPath!==d.newPath)return"renamed";if(!d.oldPath&&d.newPath)return"added";if(d.oldPath&&!d.newPath)return"deleted"}const n=t.some(l=>l.hunk.additions>0),s=t.some(l=>l.hunk.deletions>0);return n&&!s?"added":!n&&s?"deleted":"modified"}function Zm(t){const n=new Map;for(const l of t){const d=n.get(l.hunk.filePath)??{key:l.hunk.filePath,filePath:l.hunk.filePath,items:[],additions:0,deletions:0,explained:0,stale:0,changeType:"modified"};d.items.push(l),d.additions+=l.hunk.additions,d.deletions+=l.hunk.deletions,l.current&&(d.explained+=1),l.stale&&(d.stale+=1),n.set(l.hunk.filePath,d)}const s=Array.from(n.values()).sort((l,d)=>l.filePath.localeCompare(d.filePath));for(const l of s)l.changeType=Qm(l.items);return s}function ep(t){const n=t.filePath.split("/").pop()??t.filePath;return{key:t.key,path:t.filePath,displayName:n,displayDir:t.filePath.includes("/")?t.filePath.slice(0,-n.length-1):"",status:t.changeType,title:t.filePath}}function tp(t,n){const s=t.filter(c=>c.trim().length>0);if(s.length<=1)return s[0]??"";const l=[],d=new Set;for(const[c,h]of s.entries()){const m=h.split(`
|
|
4
|
-
`),g=m.findIndex(k=>k.startsWith("@@ "));if(g<0){l.push(...m);continue}c===0&&l.push(...m.slice(0,g));const p=n[c];let f=g;for(;f>=0&&f<m.length;){const k=m.findIndex((E,$)=>$>f&&E.startsWith("@@ ")),y=k>=0?k:m.length,N=m.slice(f,y),I=N[0]??"",D=p?I===p:!0,B=I||p||N.join(`
|
|
5
|
-
`);D&&!d.has(B)&&(l.push(...N),d.add(B)),f=k}}return l.join(`
|
|
6
|
-
`)}function rp({groups:t,onInsertDiffReference:n}){return t.map(s=>{const l=tp(s.items.map(m=>m.hunk.diff||m.current?.diff||m.stale?.diff||""),s.items.map(m=>m.hunk.hunkHeader)),d=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})),c=s.filePath.split("/").pop()??s.filePath,h=s.filePath.includes("/")?s.filePath.slice(0,-c.length-1):"";return{key:s.key,path:s.filePath,absolutePath:d[0]?.repoRoot?`${d[0].repoRoot}/${s.filePath}`:s.filePath,status:s.changeType,repoRoot:d[0]?.repoRoot??null,displayName:c,displayDir:h,diffOverride:l,auditRecords:d,onInsertDiffReference:n}})}function np(t,n,s){const l=Array.from(t.querySelectorAll("[data-diff-stream-item]"));if(l.length===0)return null;const c=t.getBoundingClientRect().top+48;let h=null,m=Number.POSITIVE_INFINITY;for(const p of l){const f=p.getBoundingClientRect();if(f.bottom<c)continue;const k=Math.abs(f.top-c);k<m&&(h=p,m=k)}const g=h?.dataset.diffSelectionPath??h?.dataset.diffStreamItem??null;return!g||g===n||s(g),g}function ed({items:t,selectedKey:n,onSelect:s,emptyText:l,mobile:d=!1,backLabel:c="Back",headerTitle:h,headerMeta:m,onClose:g,closeLabel:p="Back",wrap:f=!0,onToggleWrap:k,wrapTitle:y,wrapOnLabel:N="Wrap on",wrapOffLabel:I="Wrap off",desktopLayout:D="split",onInsertDiffReference:B,onReferenceCopied:E,insertedReferenceKey:$,copiedReferenceKey:L,onClearAuditRecord:P,walkthroughs:U=[],onWalkthroughNavigate:F,initialDetailScrollTop:a,onDetailScrollPositionChange:w,scrollToKey:O,scrollToKeyNonce:j,externalSwiperRef:X,onMobileSlideChange:ne}){const{t:se}=yt(),fe=o.useMemo(()=>Zm(t),[t]),G=o.useMemo(()=>new Map(fe.map(le=>[le.key,le])),[fe]),[J,M]=o.useState(()=>Jm()),[_,K]=o.useState(()=>new Set),[re,oe]=o.useState({key:null,nonce:0}),he=fe.find(le=>le.explained>0||le.stale>0)?.key??fe[0]?.key??null,me=n&&fe.some(le=>le.key===n)?n:he,je=o.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:fe.map(ep)}],[fe]),C=o.useMemo(()=>rp({groups:fe,onInsertDiffReference:B}),[fe,B]),Z=o.useRef(he),ue=o.useRef(s);Z.current=he,ue.current=s,o.useEffect(()=>{!n&&Z.current&&ue.current(Z.current)},[n]);const Ee=k?e.jsxs("button",{type:"button",onClick:k,"aria-pressed":f,title:y,className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 text-[11px] font-medium transition active:scale-95 ${f?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:f?N:I})]}):null,Ge=le=>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(Ns,{size:14}),p]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[le,Ee]})]});if(t.length===0){const le=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?le:e.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[Ge(null),le]})}const De=k?({slideToList:le})=>e.jsxs("div",{className:"flex 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:le,children:[e.jsx(Ns,{size:14}),c]}),e.jsxs("button",{type:"button",onClick:k,"aria-pressed":f,title:y,className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${f?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:f?N:I})]})]}):void 0;return e.jsx(wi,{mobile:d,desktopLayout:D,backLabel:c,groups:je,selectedKey:me,mode:J,onModeChange:le=>{M(le),le!=="ai"&&xt(Xd,le)},compact:d,collapsedDirectoryKeys:_,onToggleDirectory:le=>{K(ae=>{const S=new Set(ae);return S.has(le)?S.delete(le):S.add(le),S})},onSelectFile:le=>{s(le.key),oe(ae=>({key:le.key,nonce:ae.nonce+1}))},renderLeading:le=>{const ae=G.get(le.key);return e.jsx(ji,{changeStatus:le.status,auditStatus:ae,renderChangeBadge:S=>e.jsx(js,{status:S})})},renderTrailing:le=>{const ae=G.get(le.key);return ae?e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",ae.additions," -",ae.deletions]}):null},renderListHeader:Ge,aiContent:({slideToDetail:le,fullscreen:ae,toggleFullscreen:S})=>U.length>0&&F?e.jsx(Hd,{walkthroughs:U,repoRoot:U[0]?.repoRoot,fullscreen:ae,onToggleFullscreen:S,onNavigate:V=>{d&&window.requestAnimationFrame(le),F(V)}}):e.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:se("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:De,externalSwiperRef:X,onMobileSlideChange:ne,detailContainerClassName:d?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:a,scrollToKey:O??re.key,scrollToKeyNonce:O==null?re.nonce:j,onDetailScroll:le=>{np(le,me,s),w?.(le.scrollTop)},files:C,activePane:!0,wrap:f,renderStreamBadge:(le,ae)=>{const S=G.get(ae.key);return e.jsx(ji,{changeStatus:le,auditStatus:S,renderChangeBadge:V=>e.jsx(js,{status:V})})},onInsertDiffReference:B,onReferenceCopied:E,insertedReferenceKey:$,copiedReferenceKey:L,onClearAuditRecord:P,emptyContent:e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l})})}function sp(t){return t.replace(/\/+$/,"")||"/"}function ap(t){return[...new Set(Array.from(t,sp))].sort((n,s)=>n.localeCompare(s))}function op(t){return t==="event-storm"||t==="reconnected"||t==="directory-rescan"||t==="polling-fallback"}function ip(t){let n=null;return{applicableEvents:t.filter(l=>{const d=l.type==="rescan-required"&&!op(l.reason);return d&&l.reason&&!n&&(n=l.reason),!d}),unavailableReason:n}}const lp=1400,cp=1200,Jd=44,dp=.7;function Jo(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function Ri(t){return`termdock:right-sidebar:context-draft-height:${t}:v1`}function up(t){try{const n=window.localStorage.getItem(Ri(t)),s=n===null?NaN:Number(n);return Number.isFinite(s)&&s>=Jd?s:null}catch{return null}}function td(t,n){try{n===null?window.localStorage.removeItem(Ri(t)):window.localStorage.setItem(Ri(t),String(n))}catch{}}function Ea(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function fp({value:t,collapsed:n,labels:s,focusRequest:l,insertError:d,autoCollapseAfterSend:c,onChange:h,onCollapsedChange:m,onAutoCollapseAfterSendChange:g,onDisable:p,onClear:f,onInsert:k,onInsertAndSend:y}){const[N,I]=o.useState(null),[D,B]=o.useState(!1),[E,$]=o.useState(()=>up(Jo())),L=o.useRef(E),P=o.useRef(null),U=o.useRef(null),F=o.useRef(t),a=o.useRef(null),w=o.useRef(null),O=!!t.trim(),j=t.trim().split(`
|
|
7
|
-
`)[0]??"",X=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";o.useEffect(()=>()=>{P.current!==null&&window.clearTimeout(P.current),U.current!==null&&window.clearTimeout(U.current)},[]),o.useEffect(()=>{let C=!1;const Z=Jo();return fh().then(ue=>{if(C)return;const Ee=ue.contextDraftHeight?.[Z]??null;td(Z,Ee),L.current=Ee,$(Ee)}).catch(()=>{}),()=>{C=!0}},[]),o.useEffect(()=>{if(l!==void 0&&l>0){const C=a.current;if(!C)return;Ea()||C.focus(),C.setSelectionRange(C.value.length,C.value.length),C.scrollTop=C.scrollHeight}},[l]),o.useEffect(()=>{const C=F.current;F.current=t,!(!n||t.length<=C.length)&&(B(!0),U.current!==null&&window.clearTimeout(U.current),U.current=window.setTimeout(()=>{U.current=null,B(!1)},cp))},[t,n]),o.useEffect(()=>{if(n)return;const C=a.current;C&&(C.style.height=E!==null?`${E}px`:"")},[t,n,E]),o.useEffect(()=>{if(n)return;const C=a.current;!C||document.activeElement===C||(C.scrollTop=C.scrollHeight)},[t,n]),o.useEffect(()=>{if(n||Ea())return;const C=a.current;!C||document.activeElement===C||(C.focus(),C.setSelectionRange(C.value.length,C.value.length))},[n]);const ne=o.useRef(null);o.useLayoutEffect(()=>{if(!Ea())return;const C=window.visualViewport;if(!C)return;const Z=()=>{const ue=ne.current;if(!ue)return;if(C.height>=window.innerHeight*.75){ue.style.transform="";return}const Ee=ue.getBoundingClientRect(),Ge=Math.round(C.height-Ee.bottom);ue.style.transform=Ge!==0?`translateY(${Ge}px)`:""};return Z(),C.addEventListener("resize",Z),C.addEventListener("scroll",Z),()=>{C.removeEventListener("resize",Z),C.removeEventListener("scroll",Z),ne.current&&(ne.current.style.transform="")}},[n]);const se=C=>{I(C),P.current!==null&&window.clearTimeout(P.current),P.current=window.setTimeout(()=>{P.current=null,I(null)},lp)},fe=C=>{m(!1),Ea()&&window.requestAnimationFrame(()=>{const Z=a.current;if(!Z)return;Z.focus();const ue=Z.value.length;Z.setSelectionRange(ue,ue),window.requestAnimationFrame(()=>{Z.setSelectionRange(ue,ue)})})},G=()=>{k(),se("inserted")},J=()=>{O&&(y(),se("sent"))},M=C=>{if(C.key==="Escape"){C.preventDefault(),m(!0);return}C.key!=="Enter"||!C.metaKey&&!C.ctrlKey||(C.preventDefault(),J())},_=C=>{C.preventDefault()},K=C=>{C.preventDefault();const Z=a.current;Z&&(w.current={startY:C.clientY,startHeight:Z.getBoundingClientRect().height},C.currentTarget.setPointerCapture?.(C.pointerId))},re=C=>{const Z=w.current;if(!Z)return;const ue=window.visualViewport?.height??window.innerHeight,Ee=Math.round(Math.min(Math.max(Z.startHeight+(Z.startY-C.clientY),Jd),ue*dp));L.current=Ee,$(Ee)},oe=C=>{const Z=Jo();td(Z,C),hh({contextDraftHeight:{[Z]:C}}).catch(()=>{})},he=()=>{w.current&&(w.current=null,L.current!==null&&oe(L.current))},me=()=>{L.current=null,$(null),oe(null)},je=t.length>0&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/50",children:s.characterCount(t.length)});return n?e.jsx("section",{ref:ne,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:()=>fe(),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(Kh,{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] ${d?"text-destructive":D?"text-primary":O?"text-foreground/80":"text-muted-foreground/50"}`,children:d??(D?s.appended:O?j:s.title)})]}),je,e.jsx("button",{type:"button",onClick:J,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(bi,{size:12}):e.jsx(Jc,{size:12})})]})}):e.jsxs("section",{ref:ne,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:K,onPointerMove:re,onPointerUp:he,onPointerCancel:he,onDoubleClick:me,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:_,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(Ms,{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}),je]}),e.jsx("button",{type:"button",role:"switch","aria-checked":c,onPointerDown:_,onClick:()=>g(!c),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 ${c?"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 ${c?"translate-x-2.5":"translate-x-0.5"}`})})}),e.jsx("button",{type:"button",onPointerDown:_,onClick:p,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(Ut,{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:a,value:t,onChange:C=>h(C.target.value),onKeyDown:M,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:_,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(Ba,{size:11})}),d?e.jsx("span",{className:"min-w-0 flex-1 truncate px-1 text-[10px] text-destructive",role:"alert",children:d}):e.jsx("span",{className:"flex-1"}),e.jsxs("button",{type:"button",onPointerDown:_,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(Vh,{size:11}),e.jsx("span",{children:N==="inserted"?s.inserted:s.insert})]}),e.jsxs("button",{type:"button",onPointerDown:_,onClick:J,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} · ${X}`,children:[N==="sent"?e.jsx(bi,{size:11}):e.jsx(Jc,{size:11}),e.jsx("span",{children:N==="sent"?s.sent:s.send})]})]})]})})]})}function hp(t,n){const s=n.trim();if(!s)return t;if(!t.trim())return s;const l=t.endsWith(`
|
|
8
|
-
|
|
9
|
-
`)?"":t.endsWith(`
|
|
10
|
-
`)?`
|
|
11
|
-
`:`
|
|
12
|
-
|
|
13
|
-
`;return`${t}${l}${s}`}function mp(t,n){const s=t.trim();return s?n?`${s}\r`:/\s$/.test(t)?t:`${s} `:""}const Ci="termdock:right-sidebar:html-view-mode-by-file:v1";function pp(t){return t==="preview"||t==="source"}function Qd(t){return!t||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(pp)}function Zd(t,n){if(!n)return null;const s=t&&!n.startsWith("/")?`${t}/${n}`:n;return t?`${t}::${s}`:s}function rd(t,n){const s=Zd(t,n);return s?tt(Ci,Qd)?.[s]??"source":"source"}function gp(t,n,s){const l=Zd(t,n);if(!l)return;const d=tt(Ci,Qd)??{};xt(Ci,{...d,[l]:s})}function nd(t){try{return new URL(t,location.href).pathname.startsWith("/api/")}catch{return!1}}function Ja(t,n){const[s,l]=o.useState(()=>!!navigator.serviceWorker?.controller);return o.useEffect(()=>{if(!nd(t)||s)return;const d=navigator.serviceWorker,c=()=>l(!!d?.controller);d?.addEventListener("controllerchange",c),c();const h=window.setTimeout(()=>{d?.controller||n?.()},1e4);return()=>{d?.removeEventListener("controllerchange",c),window.clearTimeout(h)}},[t,s,n]),nd(t)&&!s?void 0:t}function Qo(t){const n=Number.isFinite(t)&&t>0?Math.floor(t):0,s=Math.floor(n/3600),l=Math.floor(n%3600/60),d=n%60,c=String(l).padStart(2,"0"),h=String(d).padStart(2,"0");return s>0?`${s}:${c}:${h}`:`${c}:${h}`}function bp(t,n,s){return!Number.isFinite(s)||s<=0||!n.width?0:Math.min(1,Math.max(0,(t-n.left)/n.width))*s}const xp=350,vp=12,yp=90;function wp({url:t,onLoadError:n}){const s=Ja(t,n),{t:l}=yt(),d=o.useRef(null),c=o.useRef(null),h=o.useRef(null),m=o.useRef(null),g=o.useRef(!1),p=o.useRef(null),f=o.useRef(null),k=o.useRef(0),y=o.useRef(!1),N=o.useRef(!1),I=o.useRef(!1),D=o.useRef(null),B=o.useRef(null),E=o.useRef(!1),$=o.useRef(1),L=o.useRef(!1),[P,U]=o.useState(0),[F,a]=o.useState(0),[w,O]=o.useState(!1),[j,X]=o.useState(!1),[ne,se]=o.useState(null),[fe,G]=o.useState(!1),[J,M]=o.useState(0),[_,K]=o.useState(!1),[re,oe]=o.useState({width:0,height:0}),he=o.useCallback(()=>{D.current!==null&&(clearTimeout(D.current),D.current=null)},[]),me=o.useCallback(()=>{if(he(),B.current=null,!E.current)return!1;const W=h.current;return W&&(W.playbackRate=$.current),E.current=!1,G(!1),!0},[he]);o.useEffect(()=>()=>{p.current!==null&&cancelAnimationFrame(p.current),f.current!==null&&clearTimeout(f.current),he();const W=h.current;W&&E.current&&(W.playbackRate=$.current)},[he]),o.useEffect(()=>{const W=c.current;if(!W||typeof ResizeObserver>"u")return;const q=new ResizeObserver(([Se])=>{Se&&oe({width:Se.contentRect.width,height:Se.contentRect.height})});return q.observe(W),()=>q.disconnect()},[]),o.useEffect(()=>{const W=()=>K(document.fullscreenElement===d.current);return document.addEventListener("fullscreenchange",W),()=>document.removeEventListener("fullscreenchange",W)},[]);const je=o.useCallback((W,q=!1)=>{const Se=h.current;if(!Se)return!1;const Re=Number.isFinite(Se.duration)?Se.duration:W,lt=Math.min(Math.max(W,0),Re);if(a(lt),Math.abs(Se.currentTime-lt)<1/120)return!1;const Qe=Se.fastSeek;return q&&typeof Qe=="function"?Qe.call(Se,lt):Se.currentTime=lt,!0},[]),C=o.useCallback(()=>{p.current===null&&(p.current=requestAnimationFrame(()=>{p.current=null;const W=h.current;if(!W||!y.current||N.current||W.seeking)return;const q=I.current;I.current=!1,N.current=je(k.current,!q)}))},[je]),Z=o.useCallback(W=>{const q=m.current,Se=h.current;if(!q||!Se)return;const Re=q.getBoundingClientRect(),lt=bp(W,Re,Se.duration);k.current=lt,se(lt),I.current=!1,C(),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,I.current=!0,C()},yp)},[C]),ue=o.useCallback(()=>{p.current!==null&&(cancelAnimationFrame(p.current),p.current=null),f.current!==null&&(clearTimeout(f.current),f.current=null),I.current=!1,N.current=!1,je(k.current)},[je]),Ee=o.useCallback(W=>{const q=h.current;if(!(!q||!Number.isFinite(q.duration)||q.duration<=0)){g.current=!q.paused,q.pause(),y.current=!0,X(!0);try{W.currentTarget.setPointerCapture(W.pointerId)}catch{}Z(W.clientX)}},[Z]),Ge=o.useCallback(()=>{y.current=!1,ue(),X(!1),se(null);const W=h.current;W&&g.current&&!W.ended&&W.play().catch(()=>{}),g.current=!1},[ue]),De=o.useCallback(()=>{const W=h.current;if(W){if(L.current){L.current=!1;return}W.paused?W.play().catch(()=>{}):W.pause()}},[]),le=o.useCallback(W=>{const q=h.current;!q||q.paused||W.button!==0||(he(),B.current={id:W.pointerId,x:W.clientX,y:W.clientY},D.current=setTimeout(()=>{D.current=null,$.current=q.playbackRate,q.playbackRate=2,E.current=!0,G(!0)},xp))},[he]),ae=o.useCallback(W=>{const q=B.current;!q||q.id!==W.pointerId||E.current||Math.hypot(W.clientX-q.x,W.clientY-q.y)>vp&&(he(),B.current=null)},[he]),S=o.useCallback(()=>{me()&&(L.current=!0)},[me]);o.useEffect(()=>(window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S),window.addEventListener("blur",S),()=>{window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S),window.removeEventListener("blur",S)}),[S]);const V=o.useCallback(async()=>{const W=d.current,q=h.current;if(!(!W||!q))try{document.fullscreenElement===W?await document.exitFullscreen():W.requestFullscreen?await W.requestFullscreen():q.webkitEnterFullscreen?.()}catch{q.webkitEnterFullscreen?.()}},[]),ye=o.useCallback(()=>M(W=>(W+90)%360),[]),be=o.useCallback(W=>{const q=h.current;if(!q||!Number.isFinite(q.duration))return;const Se=W.shiftKey?10:5;let Re=null;W.key==="ArrowLeft"?Re=q.currentTime-Se:W.key==="ArrowRight"?Re=q.currentTime+Se:W.key==="Home"?Re=0:W.key==="End"&&(Re=q.duration),Re!==null&&(W.preventDefault(),je(Re))},[je]),Oe=j&&ne!==null?ne:F,ce=P>0?Math.min(1,Math.max(0,Oe/P)):0,Le=(J===90||J===270)&&re.width>0&&re.height>0?{width:`${re.height}px`,height:`${re.width}px`}:{width:"100%",height:"100%"};return e.jsxs("div",{ref:d,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":J,children:[e.jsxs("div",{ref:c,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 transition-transform duration-200",style:{...Le,transform:`translate(-50%, -50%) rotate(${J}deg)`},src:s,preload:"auto",playsInline:!0,onClick:De,onPointerDown:le,onPointerMove:ae,onPointerUp:S,onPointerCancel:S,onContextMenu:W=>{E.current&&W.preventDefault()},onPlay:()=>O(!0),onPause:()=>O(!1),onTimeUpdate:W=>a(W.currentTarget.currentTime),onSeeked:W=>{const q=W.currentTarget;if(a(q.currentTime),N.current=!1,!y.current)return;const Se=q.requestVideoFrameCallback;typeof Se=="function"?Se.call(q,()=>{y.current&&C()}):requestAnimationFrame(()=>{y.current&&C()})},onLoadedMetadata:W=>U(Number.isFinite(W.currentTarget.duration)?W.currentTarget.duration:0),onDurationChange:W=>U(Number.isFinite(W.currentTarget.duration)?W.currentTarget.duration:0),onError:n,children:l("rightSidebar.videoUnsupported")}),fe&&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")}),j&&ne!==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:`${ce*100}%`},"data-testid":"file-preview-video-scrub-time",children:Qo(ne)})]}),e.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${dm}`,[um]:"",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:De,"aria-label":l(w?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:l(w?"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:w?e.jsx(Yh,{size:14}):e.jsx(Xh,{size:14})}),e.jsxs("div",{ref:m,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(P),"aria-valuenow":Math.floor(Oe),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:Ee,onPointerMove:W=>{j&&Z(W.clientX)},onPointerUp:Ge,onPointerCancel:Ge,onKeyDown:be,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:`${ce*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:`${ce*100}%`}})]}),e.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[Qo(Oe)," / ",Qo(P)]}),e.jsx("button",{type:"button",onClick:ye,"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(Pm,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{V()},"aria-label":l(_?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:l(_?"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:_?e.jsx($m,{size:14}):e.jsx(Nm,{size:14})})]})})]})}function kp(t){const n=Math.max(0,Math.min(100,t.xPercent)),s=Math.max(0,Math.min(100,t.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 Qa({anchor:t,children:n,disabled:s=!1,onClick:l,title:d}){return e.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:s,onClick:c=>{c.stopPropagation(),l()},title:d,style:kp(t),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(za,{size:11}),n]})}function Sp(t,n,s,l){if(s.width<=0||s.height<=0||l.width<=0||l.height<=0)return null;const d=Math.min(s.width/l.width,s.height/l.height);if(!Number.isFinite(d)||d<=0)return null;const c=l.width*d,h=l.height*d,m=s.left+(s.width-c)/2,g=s.top+(s.height-h)/2,p=t-m,f=n-g;if(p<0||f<0||p>c||f>h)return null;const k=p/c*100,y=f/h*100;return{x:l.x+l.width*k/100,y:l.y+l.height*y/100,xPercent:k,yPercent:y}}function jp(t,n,s){const l=[`SVG标注: ${t}`,`视图: ${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 Rp(t){const n=new DOMParser().parseFromString(t,"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 d of Array.from(l.attributes)){const c=d.name.toLowerCase(),h=d.value.trim();(c.startsWith("on")||(c==="href"||c.endsWith(":href"))&&h&&!h.startsWith("#"))&&l.removeAttribute(d.name)}}),s.removeAttribute("width"),s.removeAttribute("height"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(s)}function Cp(t,n,s){let l=null;for(const d of Array.from(t.querySelectorAll("text"))){const c=(d.textContent??"").replace(/\s+/g," ").trim();if(!c)continue;const h=Number(d.getAttribute("x")),m=Number(d.getAttribute("y"));if(!Number.isFinite(h)||!Number.isFinite(m))continue;const g=Math.hypot(h-n,m-s);(!l||g<l.distance)&&(l={text:c,distance:g})}return l?.text.slice(0,120)}function eu({blobUrl:t,filePath:n,viewLabel:s,onInsertAnnotation:l}){const d=o.useRef(null),c=o.useRef(null),[h,m]=o.useState(null),[g,p]=o.useState(null),[f,k]=o.useState(1),[y,N]=o.useState(!1),[I,D]=o.useState(null),B=o.useRef(new Map),E=o.useRef(null),$=o.useRef(!1),L=o.useRef(null),P=o.useRef(f);P.current=f,o.useEffect(()=>{const M=new AbortController;return m(null),p(null),D(null),k(1),fetch(t,{signal:M.signal}).then(_=>_.text()).then(_=>m(Rp(_))).catch(_=>{M.signal.aborted||p(_ instanceof Error?_.message:"SVG preview failed")}),()=>M.abort()},[t]),o.useEffect(()=>{if(!y)return;const M=_=>{_.key==="Escape"&&N(!1)};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[y]),o.useLayoutEffect(()=>{const M=c.current,_=M?.querySelector("[data-svg-document] > svg");if(!M||!_)return;let K;try{K=_.getBBox()}catch{return}if(!K.width||!K.height)return;const re=Math.max(2,Math.min(K.width,K.height)*.025);_.setAttribute("viewBox",`${K.x-re} ${K.y-re} ${K.width+2*re} ${K.height+2*re}`),_.style.width=`${f*100}%`,_.style.height=`${f*100}%`,_.style.minWidth=`${f*100}%`,_.style.minHeight=`${f*100}%`,_.style.display="block"},[h,f]);const U=o.useMemo(()=>I?jp(n,s,I):null,[n,I,s]),F=M=>{if($.current){$.current=!1;return}const _=c.current,K=_?.querySelector("[data-svg-document] > svg"),re=d.current;if(!_||!K||!re)return;const oe=K.viewBox.baseVal,he=Sp(M.clientX,M.clientY,K.getBoundingClientRect(),oe);if(!he)return;const me=re.getBoundingClientRect();D({...he,nearestText:Cp(K,he.x,he.y),stageX:M.clientX-me.left,stageY:M.clientY-me.top,stageXPercent:(M.clientX-me.left)/me.width*100,stageYPercent:(M.clientY-me.top)/me.height*100})},a=M=>Math.max(1,Math.min(12,M)),w=(M,_)=>{const K=a(_),re=M.querySelector("[data-svg-document] > svg");if(!re)return K;const oe=`${K*100}%`;return re.style.width=oe,re.style.height=oe,re.style.minWidth=oe,re.style.minHeight=oe,P.current=K,K},O=(M,_,K,re)=>{const oe=P.current,he=M.getBoundingClientRect(),me=K-he.left,je=re-he.top,C=(M.scrollLeft+me)/oe,Z=(M.scrollTop+je)/oe,ue=w(M,_);return M.scrollLeft=C*ue-me,M.scrollTop=Z*ue-je,ue},j=()=>{const M=Array.from(B.current.values());return M.length>=2?Math.hypot(M[0].x-M[1].x,M[0].y-M[1].y):0},X=M=>{if(M.pointerType==="mouse"&&M.button!==0)return;const _=c.current;_&&(B.current.set(M.pointerId,{x:M.clientX,y:M.clientY}),_.setPointerCapture?.(M.pointerId),B.current.size>=2?(E.current={kind:"pinch",startX:M.clientX,startY:M.clientY,startScrollLeft:_.scrollLeft,startScrollTop:_.scrollTop,startDistance:j(),startZoom:P.current,moved:!1},$.current=!0):P.current>1&&(E.current={kind:"pan",startX:M.clientX,startY:M.clientY,startScrollLeft:_.scrollLeft,startScrollTop:_.scrollTop,startZoom:P.current,moved:!1}))},ne=M=>{if(!B.current.has(M.pointerId))return;B.current.set(M.pointerId,{x:M.clientX,y:M.clientY});const _=c.current,K=E.current;if(!(!_||!K)){if(B.current.size>=2&&K.kind==="pinch"){const re=j();if(!K.startDistance||!re)return;const oe=a(K.startZoom*re/K.startDistance);if(Math.abs(oe-P.current)<.01)return;const he=Array.from(B.current.values()),me=(he[0].x+he[1].x)/2,je=(he[0].y+he[1].y)/2;K.moved=!0,$.current=!0,O(_,oe,me,je),M.preventDefault();return}if(K.kind==="pan"&&B.current.size===1){const re=M.clientX-K.startX,oe=M.clientY-K.startY;if(!K.moved&&Math.hypot(re,oe)<6)return;K.moved=!0,$.current=!0,_.scrollLeft=K.startScrollLeft-re,_.scrollTop=K.startScrollTop-oe,M.preventDefault()}}},se=M=>{const _=c.current,K=E.current,re=B.current.size===1&&!K?.moved;B.current.delete(M.pointerId);try{_?.releasePointerCapture?.(M.pointerId)}catch{}if(B.current.size===1&&K?.kind==="pinch"){const me=Array.from(B.current.values())[0];E.current=_?{kind:"pan",startX:me.x,startY:me.y,startScrollLeft:_.scrollLeft,startScrollTop:_.scrollTop,startZoom:P.current,moved:!1}:null;return}if(B.current.size>0||(E.current=null,K?.kind==="pinch"&&k(P.current),!re||$.current))return;const oe=Date.now(),he=L.current;he&&oe-he.time<350&&Math.hypot(M.clientX-he.x,M.clientY-he.y)<24?(L.current=null,$.current=!0,k(me=>me>1?1:2.5)):L.current={time:oe,x:M.clientX,y:M.clientY}},fe=M=>{if(!M.ctrlKey&&!M.metaKey)return;const _=c.current;if(!_)return;M.preventDefault();const K=O(_,P.current*Math.exp(-M.deltaY*.01),M.clientX,M.clientY);k(K)},G=()=>{k(1),P.current=1,c.current&&(c.current.scrollLeft=0,c.current.scrollTop=0)},J=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:d,className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:c,role:"button",tabIndex:0,onClick:F,onDoubleClick:M=>{M.preventDefault(),k(_=>_>1?1:2.5)},onPointerDown:X,onPointerMove:ne,onPointerUp:se,onPointerCancel:se,onWheel:fe,onScroll:()=>D(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:g?e.jsx("div",{className:"p-4 text-sm text-destructive",children:g}):h?e.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:h}}):e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),I&&e.jsx("span",{"data-svg-pick-marker":!0,className:"pointer-events-none absolute z-10 h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm",style:{left:I.stageX,top:I.stageY}}),I&&U&&e.jsx(Qa,{anchor:{xPercent:I.stageXPercent,yPercent:I.stageYPercent},title:"引用 SVG 标注",onClick:()=>{l?.(U,`svg:${I.x.toFixed(2)}:${I.y.toFixed(2)}`),D(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:M=>{M.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(Im,{size:14})}),e.jsx("button",{type:"button","aria-label":y?"退出全屏 SVG":"全屏 SVG",title:y?"退出全屏 SVG":"全屏 SVG",onClick:M=>{M.stopPropagation(),N(_=>!_)},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(zd,{size:14}):e.jsx(Ud,{size:14})})]})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:I?`SVG (${I.x.toFixed(2)}, ${I.y.toFixed(2)}) · ${I.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return y?Gr.createPortal(J,document.body):J}function Oa(t){switch(t){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function Np(t,n,s,l){const d=[`电子标注: ${t}`,`视图: ${Oa(n)}`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(l?.available&&l.xMm!==void 0&&l.yMm!==void 0&&(d.push(`PCB坐标: (${l.xMm.toFixed(2)},${l.yMm.toFixed(2)})mm [KiCad板坐标]`),l.layer&&d.push(`显示层: ${l.layer}`),l.nearest)){const c=[l.nearest.net?`网络 ${l.nearest.net}`:null,`对象层 ${l.nearest.layer}`,`距离 ${l.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");d.push(`最近对象: ${l.nearest.label}${c?`(${c})`:""}`)}return`"${d.join(" / ")}"`}function Mp({blobUrl:t,filePath:n,view:s,board:l,onViewChange:d,onInsertAnnotation:c,onRefresh:h,interactive3d:m}){const{t:g}=yt(),p=o.useRef(null),f=o.useRef(null),k=o.useRef(null),[y,N]=o.useState(null),[I,D]=o.useState(!1);o.useEffect(()=>(k.current?.abort(),N(null),D(!1),()=>k.current?.abort()),[t,s]);const B=o.useMemo(()=>y?Np(n,s,y,y.inspection):null,[n,y,s]),E=L=>{const P=p.current,U=f.current;if(!P||!U||!U.naturalWidth||!U.naturalHeight)return;const F=P.getBoundingClientRect(),a=U.getBoundingClientRect(),w=Math.min(a.width/U.naturalWidth,a.height/U.naturalHeight),O=U.naturalWidth*w,j=U.naturalHeight*w,X=a.left+(a.width-O)/2,ne=a.top+(a.height-j)/2,se=L.clientX-X,fe=L.clientY-ne;if(se<0||fe<0||se>O||fe>j)return;const G={xPercent:Math.max(0,Math.min(100,se/O*100)),yPercent:Math.max(0,Math.min(100,fe/j*100)),stageXPercent:(L.clientX-F.left)/F.width*100,stageYPercent:(L.clientY-F.top)/F.height*100,inspecting:l&&s!=="pcb-3d"};if(N(G),k.current?.abort(),!G.inspecting)return;const J=new AbortController;k.current=J,mh(n,s,G.xPercent,G.yPercent,J.signal).then(M=>N(_=>_===G?{..._,inspection:M,inspecting:!1}:_)).catch(()=>{J.signal.aborted||N(M=>M===G?{...M,inspection:{available:!1},inspecting:!1}: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:$.map(L=>e.jsx("button",{type:"button",onClick:()=>d(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:Oa(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(vi,{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:p,role:"button",tabIndex:0,onClick:E,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:t,alt:`${n} ${Oa(s)}`,onLoad:()=>D(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${I?"opacity-100":"opacity-0"}`}),y&&e.jsx("span",{className:"pointer-events-none absolute h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-surface shadow-sm",style:{left:`${y.stageXPercent}%`,top:`${y.stageYPercent}%`}}),y&&B&&e.jsx(Qa,{anchor:{xPercent:y.stageXPercent,yPercent:y.stageYPercent},disabled:y.inspecting,title:g("rightSidebar.edaInsertAnnotation"),onClick:()=>{c?.(B,`eda:${s}:${y.xPercent.toFixed(1)}:${y.yPercent.toFixed(1)}`,{snapshot:f.current?zm(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(eu,{blobUrl:t,filePath:n,viewLabel:Oa(s),onInsertAnnotation:c})})]})}function $p(t){const n=[];let s=[],l="",d=!1;for(let c=0;c<t.length;c+=1){const h=t[c];d?h==='"'&&t[c+1]==='"'?(l+='"',c+=1):h==='"'?d=!1:l+=h:h==='"'?d=!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 Ep(t,n,s,l,d){const c=n[d]||`第${d+1}列`,h=s[d]??"",m=n.map((g,p)=>`${g||`第${p+1}列`}=${s[p]??""}`).join(";");return`"表格标注: ${t} / 数据行: ${l+1} / 列: ${c} / 值: ${h} / 记录: ${m}"`}function Lp({content:t,filePath:n,onInsertAnnotation:s}){const{t:l}=yt(),d=o.useMemo(()=>$p(t),[t]),c=d[0]??[],h=d.slice(1),m=o.useRef(null),[g,p]=o.useState(null),f=g?h[g.row]:null,k=g&&f?Ep(n,c,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:"#"}),c.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}),c.map((I,D)=>{const B=g?.row===N&&g.column===D;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:E=>{const $=m.current?.getBoundingClientRect(),L=E.currentTarget.getBoundingClientRect();if(!$?.width||!$.height)return;const P=E.clientX||L.left+L.width/2,U=E.clientY||L.top+L.height/2;p({row:N,column:D,xPercent:(P-$.left)/$.width*100,yPercent:(U-$.top)/$.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[D]||" "})},`cell:${N}:${D}`)})]},`row:${N}`))})]})}),g&&k&&e.jsx(Qa,{anchor:{xPercent:g.xPercent,yPercent:g.yPercent},title:l("rightSidebar.csvInsertAnnotation"),onClick:()=>{s?.(k,`csv:${n}:${g.row+1}:${g.column+1}`),p(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:c[g.column]||g.column+1}):l("rightSidebar.csvPickHint",{rows:h.length,columns:c.length})})})]})}function Wn(t,n){let s=t;for(const l of n){if(!s||typeof s!="object")return;s=s[l]}return s}function Ap(t,n){const s=JSON.parse(t),l=Wn(s,["meta","version"]);if(n)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(l??"未知")},{label:"活动层编号",value:String(Wn(s,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(Wn(s,["board","visible_layers"])??"未知")},{label:"Git 集成",value:Wn(s,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const d=Wn(s,["net_settings","classes"]),c=Array.isArray(d)?d.find(m=>m&&typeof m=="object"&&m.name==="Default"):void 0,h=Wn(s,["board","design_settings","drc_exclusions"]);return[{label:"文件性质",value:"KiCad 工程配置"},{label:"格式版本",value:String(l??"未知")},{label:"网络类数量",value:String(Array.isArray(d)?d.length:0)},{label:"默认间距",value:c?.clearance!==void 0?`${c.clearance} mm`:"未设置"},{label:"默认线宽",value:c?.track_width!==void 0?`${c.track_width} mm`:"未设置"},{label:"默认过孔",value:c?.via_diameter!==void 0?`${c.via_diameter} / ${c.via_drill??"—"} mm(外径/钻孔)`:"未设置"},{label:"DRC 排除项",value:String(Array.isArray(h)?h.length:0)}]}function Pp(t,n){return`"KiCad项目标注: ${t} / 项: ${n.label} / 值: ${n.value}"`}function Tp({content:t,filePath:n,localState:s,onInsertAnnotation:l}){const{t:d}=yt(),c=o.useRef(null),[h,m]=o.useState(null),g=o.useMemo(()=>{try{return{items:Ap(t,s),error:null}}catch(f){return{items:[],error:f instanceof Error?f.message:String(f)}}},[t,s]),p=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:t}):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:d("rightSidebar.kicadLocalStateNotice")}),e.jsxs("div",{ref:c,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,k)=>e.jsxs("button",{type:"button",onClick:y=>{const N=c.current?.getBoundingClientRect(),I=y.currentTarget.getBoundingClientRect();if(!N?.width||!N.height)return;const D=y.clientX||I.left+I.width/2,B=y.clientY||I.top+I.height/2;m({index:k,xPercent:(D-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===k?"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:d("rightSidebar.kicadShowRawJson")}),e.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre p-2 font-mono text-[10px] leading-relaxed text-foreground",children:t})]})]}),p&&h&&e.jsx(Qa,{anchor:{xPercent:h.xPercent,yPercent:h.yPercent},title:d("rightSidebar.kicadInsertSetting"),onClick:()=>{l?.(Pp(n,p),`kicad-project:${n}:${p.label}`),m(null)},children:d("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:p?`${p.label}: ${p.value}`:d("rightSidebar.kicadProjectPickHint")})})]})}const Ip=`/** 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
|
-
`,Fp=`/* 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
|
-
`,La="/api/terminal/fs/preview/",Dp=8*1024*1024,_p=32*1024*1024,Bp=128,Op="data:,";function Nt(t){throw new Error(t)}function Up(t){return JSON.stringify(t).replace(/</g,"\\u003c")}async function sd(t,n,s){let l="",d=0;for(const c of t.matchAll(n))l+=t.slice(d,c.index)+await s(c),d=c.index+c[0].length;return l+t.slice(d)}async function tu(t,n){const s=n.origin??location.origin,l=new URL(t,s);(l.origin!==s||!gs(l.pathname)?.startsWith(La))&&Nt("预览地址不是有效的本地文件入口");const d=crypto.randomUUID(),c=`https://termdock-preview.invalid/${d}/`,h=[],m=G=>{!h.includes(G)&&h.length<20&&h.push(G)},g=new Set,p=[],f=new Set,k=new Map,y=new Map;let N=0,I=!1;const D=new Set,B=()=>{I=!0;for(const G of[...D])G();g.clear(),p.length=0};async function E(G){G.ok||Nt(`预览资源读取失败(${G.status})`);const J=G.body?.getReader(),M=[];let _=0;try{if(J)for(;;){const oe=await J.read();if(oe.done)break;_+=oe.value.byteLength,N+=oe.value.byteLength,(_>Dp||N>_p)&&Nt("预览资源超出大小限制"),M.push(oe.value)}}catch(oe){throw await J?.cancel().catch(()=>{}),oe}finally{J?.releaseLock()}const K=new Uint8Array(_);let re=0;for(const oe of M)K.set(oe,re),re+=oe.length;return{bytes:K,type:G.headers.get("content-type")??"application/octet-stream",status:G.status}}let $=l,L;for(let G=0;G<4;G++){const J=await n.fetch($.pathname+$.search,{signal:n.signal,redirect:"manual"});if(![301,302,303,307,308].includes(J.status)){L=J;break}const M=J.headers.get("location");await J.body?.cancel(),M||Nt("预览重定向缺少目标");const _=new URL(M,$);(_.origin!==s||!gs(_.pathname)?.startsWith(La))&&Nt("预览重定向越出文件范围"),$=_}L||Nt("预览重定向次数过多");const P=gs($.pathname),U=P.slice(La.length).split("/");/^[a-f0-9]{32}$/.test(U[0])||Nt("服务未提供有效的预览资源授权");const F=gs(l.pathname).slice(La.length).split("/");/^[a-f0-9]{32}$/.test(F[0])&&F.shift(),F.join("/").replace(/\/$/,"")!==U.slice(1).join("/").replace(/\/$/,"")&&Nt("预览重定向改变了文件范围");const a=P.endsWith("/")?P:P.slice(0,P.lastIndexOf("/")+1),w=new URL($.pathname.endsWith("/")?$.pathname:$.pathname.slice(0,$.pathname.lastIndexOf("/")+1),s);function O(G,J){const M=new URL(G,J);return M.origin!==s?null:(gs(M.pathname)?.startsWith(a)||Nt("已阻止预览访问目录之外的资源"),M)}function j(G){const J=new URL(G,c);(J.origin!==new URL(c).origin||!J.pathname.startsWith(new URL(c).pathname))&&Nt("已阻止预览访问服务接口或目录之外的资源");const M=J.pathname.slice(new URL(c).pathname.length)+J.search;return O(M,w)??Nt("预览资源无效")}function X(G){const J=G.pathname+G.search,M=k.get(J);if(M)return M;if(I||n.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(k.size>=Bp)return Promise.reject(new Error("预览资源数量超出限制"));const _=n.fetch(J,{signal:n.signal,redirect:"manual"}).then(E);return k.set(J,_),_}function ne(G,J){I&&Nt("预览已关闭");const M=`termdock-resource-${d}-${p.length}`;return p.push({token:M,data:G,type:J}),g.add(M),M}async function se(G,J,M,_=new Set){if(!G||G.startsWith("#")||/^data:(?:image|font)\//i.test(G)&&M==="resource")return G;try{const K=O(G,J);if(!K){const je=new URL(G,J);return(je.protocol!=="https:"||je.username||je.password||je.origin===new URL(c).origin)&&Nt("已阻止不安全的外部资源"),f.add(je.origin),je.href}const re=`${M}:${K.href}`;(_.has(re)||_.size>=8)&&Nt("预览资源存在循环或过深引用");const oe=y.get(re);if(oe)return oe;const he=new Set(_);he.add(re);const me=(async()=>{const je=await X(K);return M==="css"?ne(await fe(new TextDecoder().decode(je.bytes),K,he),"text/css"):M==="script"?ne(je.bytes,"text/javascript"):ne(je.bytes,je.type)})();return y.set(re,me),await me}catch(K){return m(K instanceof Error?K.message:"部分预览资源未能加载"),Op}}async function fe(G,J,M){return G=await sd(G,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async _=>`@import url("${await se(_[1],J,"css",M)}")${_[2]};`),sd(G,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async _=>{const K=(_[1]??_[2]??_[3]).trim();return g.has(K)?_[0]:`url("${await se(K,J,"resource",M)}")`})}try{const G=await E(L),J=ne(Ip,"text/javascript"),M=new DOMParser().parseFromString(new TextDecoder().decode(G.bytes),"text/html");M.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(C=>C.remove());for(const C of M.querySelectorAll("*")){if(C.removeAttribute("ping"),C.removeAttribute("srcdoc"),C.hasAttribute("style")&&C.setAttribute("style",await fe(C.getAttribute("style"),$,new Set)),C.tagName==="STYLE"&&(C.textContent=await fe(C.textContent??"",$,new Set)),C.tagName==="A"||C.tagName==="AREA"){const Z=C.getAttribute("href");try{if(Z&&!Z.startsWith("#")){const ue=O(Z,$);if(ue)C.setAttribute("href",new URL(ue.pathname.slice(w.pathname.length)+ue.search+ue.hash,c).href);else{const Ee=new URL(Z,$);if(Ee.protocol!=="https:"){C.removeAttribute("href");continue}f.add(Ee.origin),C.setAttribute("href",Ee.href)}}}catch(ue){C.removeAttribute("href"),m(ue instanceof Error?ue.message:"预览链接无法加载")}}for(const Z of["data","manifest"])C.removeAttribute(Z);if(C.tagName==="SCRIPT"&&C.getAttribute("type")==="module"){C.setAttribute("type","module-shim");const Z=C.getAttribute("src");if(Z){const ue=O(Z,$);if(ue)C.setAttribute("src",new URL(ue.pathname.slice(w.pathname.length)+ue.search,c).href);else{const Ee=new URL(Z,$);if(Ee.protocol!=="https:"){C.remove();continue}f.add(Ee.origin),C.setAttribute("src",Ee.href)}}continue}if(C.tagName==="SCRIPT"&&C.getAttribute("type")==="importmap"){C.setAttribute("type","importmap-shim");continue}if(C.tagName==="LINK"){const Z=(C.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(Z)){C.remove();continue}const ue=C.getAttribute("href");ue&&C.setAttribute("href",await se(ue,$,Z==="stylesheet"?"css":"resource"))}if(C.hasAttribute("src")&&C.setAttribute("src",await se(C.getAttribute("src"),$,C.tagName==="SCRIPT"?"script":"resource")),C.hasAttribute("poster")&&C.setAttribute("poster",await se(C.getAttribute("poster"),$,"resource")),C.hasAttribute("srcset")){const Z=C.getAttribute("srcset");/data:/i.test(Z)?(C.removeAttribute("srcset"),m("混合内嵌图片候选暂不支持安全预览")):C.setAttribute("srcset",(await Promise.all(Z.split(",").map(async ue=>{const[Ee,...Ge]=ue.trim().split(/\s+/);return`${await se(Ee,$,"resource")} ${Ge.join(" ")}`}))).join(", "))}C.setAttribute("referrerpolicy","no-referrer"),C.removeAttribute("integrity"),C.removeAttribute("crossorigin")}const _=[...f].join(" "),K=M.createElement("meta");K.httpEquiv="Content-Security-Policy",K.content=`default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${_}; style-src 'unsafe-inline' blob: ${_}; img-src blob: data: ${_}; font-src blob: data: ${_}; media-src blob: data: ${_}; connect-src blob: ${_} ${[...f].map(C=>C.replace(/^https:/,"wss:")).join(" ")}; worker-src blob:; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const re=M.createElement("base");re.href=c;const oe=M.createElement("meta");oe.name="referrer",oe.content="no-referrer";const he=M.createElement("script");he.textContent=Fp+`
|
|
1636
|
-
installPreviewRuntime(`+[d,c,[...f],J].map(Up).join(",")+");";const me=M.createElement("script");me.src=J,M.head.prepend(K,oe,re,he,me);const je=`<!doctype html>
|
|
1637
|
-
`+M.documentElement.outerHTML;return{html:je,shellUrl:`/preview-shell.html#${d}`,errors:h,attach(C,Z){const ue=new Set,Ee=De=>{if(De.source!==C.contentWindow||De.data?.capability!==d)return;if(De.data.type==="preview-ready"){C.contentWindow?.postMessage({type:"preview-init",capability:d,html:je,resources:p},"*");return}if(De.data.type==="preview-error"){Z("部分动态内容被安全预览限制");return}if(De.data.type==="preview-navigate"){(async()=>{const ae=j(String(De.data.url)),S=await tu(ae.pathname+ae.search,n);if(I){S.dispose();return}const V=S.attach(C,Z);D.add(()=>{V(),S.dispose()}),C.src=S.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(ae=>Z(ae instanceof Error?ae.message:"无法打开预览页面"));return}if(De.data.type==="preview-external"){try{const ae=new URL(String(De.data.url));ae.protocol==="https:"&&f.has(ae.origin)&&window.open(ae.href,"_blank","noopener,noreferrer")}catch{}return}if(De.data.type!=="preview-fetch"||De.ports.length!==1)return;const le=De.ports[0];if(ue.size>=8||!["GET","HEAD"].includes(De.data.method)){le.postMessage({error:"预览仅允许读取已授权目录资源"}),le.close();return}ue.add(le),(async()=>{const ae=j(String(De.data.url)),S=await X(ae);if(!ue.has(le)||I)return;const V=De.data.method==="HEAD"?new Uint8Array:S.bytes.slice();le.postMessage({status:S.status,headers:{"content-type":S.type},data:V.buffer},[V.buffer])})().catch(()=>{le.postMessage({error:"预览资源不在授权范围或无法加载"}),Z("部分动态资源不可用或超出预览目录")}).finally(()=>{ue.delete(le),le.close()})};window.addEventListener("message",Ee);const Ge=()=>{window.removeEventListener("message",Ee);for(const De of ue)De.close();ue.clear(),D.delete(Ge)};return D.add(Ge),Ge},dispose:B}}catch(G){throw B(),G}}const Hp=o.forwardRef(function({src:n,title:s,exitFullscreenLabel:l,onFullscreenChange:d},c){const h=o.useRef(null),[m,g]=o.useState(null),[p,f]=o.useState(),[k,y]=o.useState("");o.useEffect(()=>{const P=new AbortController;let U;return f(void 0),y(""),(async()=>{const F=await ph();if(U=await tu(n,{fetch:(a,w)=>F.fetch(a,w),signal:P.signal}),P.signal.aborted){U.dispose();return}f(U),U.errors.length&&y(U.errors.join(";"))})().catch(F=>{P.signal.aborted||y(F instanceof Error?F.message:"安全预览加载失败")}),()=>{P.abort(),U?.dispose()}},[n]),o.useEffect(()=>{if(!(!p||!m))return p.attach(m,y)},[p,m]);const[N,I]=o.useState(!1),[D,B]=o.useState(!1),E=N||D;o.useEffect(()=>{d?.(E)},[E,d]),o.useEffect(()=>{const P=()=>{I(document.fullscreenElement===h.current)};return document.addEventListener("fullscreenchange",P),()=>document.removeEventListener("fullscreenchange",P)},[]),o.useEffect(()=>{if(!D)return;const P=U=>{U.key==="Escape"&&B(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[D]);const $=o.useCallback(async()=>{const P=h.current;if(P){if(D){B(!1);return}if(document.fullscreenElement===P){await document.exitFullscreen();return}if(P.requestFullscreen&&document.fullscreenEnabled!==!1)try{await P.requestFullscreen();return}catch{}B(!0)}},[D]);o.useImperativeHandle(c,()=>({toggleFullscreen:$}),[$]);const L=e.jsxs("div",{ref:h,"data-html-preview-frame":!0,className:E?"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&&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:()=>{$()},"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(zd,{size:15})})]}),k&&e.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:k}),!p&&!k&&e.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),e.jsx("iframe",{ref:g,src:p?.shellUrl,referrerPolicy:"no-referrer",title:s,sandbox:"allow-scripts",className:"block min-h-0 w-full flex-1 border-0 bg-white"})]});return D?Gr.createPortal(L,document.body):L}),ru="termdock-file-search-match",Ni="termdock-file-search-current";function zp(t){const n=t.metaKey||t.ctrlKey,s=t.key.toLocaleLowerCase();return n&&s==="f"?"open":n&&s==="g"||t.key==="F3"?t.shiftKey?"previous":"next":t.key==="Escape"?"close":null}function Wp(t){return t.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function Gp(t,n){const s=n.trim().toLocaleLowerCase();if(!s)return[];const l=[];let d="",c=null;const h=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let f=h.nextNode();f;f=h.nextNode()){if(!(f instanceof Text)||!f.data)continue;const k=Wp(f);if(!k)continue;c&&c!==k&&(d+=`
|
|
1638
|
-
`);const y=d.length;d+=f.data,l.push({node:f,start:y,end:d.length,group:k}),c=k}const m=d.toLocaleLowerCase(),g=[];let p=0;for(;p<=m.length-s.length;){const f=m.indexOf(s,p);if(f<0)break;const k=f+s.length,y=l.find(I=>I.start<=f&&I.end>f),N=l.find(I=>I.start<k&&I.end>=k);if(y&&N&&y.group===N.group){const I=document.createRange();I.setStart(y.node,f-y.start),I.setEnd(N.node,k-N.start),g.push(I)}p=f+Math.max(s.length,1)}return g}function nu(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function Aa(){const t=nu();t?.delete(ru),t?.delete(Ni)}function ad(t,n){const s=nu();if(!s||typeof Highlight>"u")return;s.set(ru,new Highlight(...t));const l=t[n];l?s.set(Ni,new Highlight(l)):s.delete(Ni)}function od(t){t?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function qp(t){return Array.from(new Set(t.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Kp(t,n){const s=n.trim();return!s||s==="."?t:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${t.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Vp(t,n){if(n===t)return".";const s=`${t.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function su(t,n,s){return n?t:Gr.createPortal(t,s)}const Hi="termdock:right-sidebar:file-tree-scroll:v1",zi="termdock:right-sidebar:file-preview-reading-state:v1",ws="termdock:right-sidebar:file-tree-width:v1",au="termdock:right-sidebar:markdown-view-mode:v1",ou="termdock:right-sidebar:diff-change-list-mode:v1",iu="termdock:right-sidebar:diff-wrap:v1",lu="termdock:diff-viewer:view-type:v1",cu="termdock:right-sidebar:file-search-mode:v1",Zo="termdock:right-sidebar:collapsed-git-repo-groups:v1",id="termdock:right-sidebar:collapsed-diff-directories:v1",ei="termdock:right-sidebar:branch-audit-module-open:v1",du="termdock:right-sidebar:branch-audit-module:v1",Yp=150,uu="termdock:right-sidebar:active-git-repo:v1",ld="termdock:right-sidebar:context-draft-enabled:v1",cd="termdock:right-sidebar:context-draft-collapsed:v1",dd="termdock:right-sidebar:context-draft-auto-collapse:v1",ti="termdock:right-sidebar:context-draft-text:v1",Xp=300,Jp=20,Qp=120,Zp=250,eg=250,tg=120,rg=700,ri=600;function Gn(t){return!!(t&&te.getState().nestedGitScanRoots[t])}const ud=[2e3,5e3,15e3,3e4],ng=320,sg=500,ag=20,og=12e3,Mi=300,fd=240,ig=560,fu="border-r px-2 py-1.5 sm:px-3 sm:py-2",Wa="max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",hu=`${fu} border-b border-border/15 font-semibold last:border-r-0`,mu=`${fu} border-border/10 align-top text-muted-foreground last:border-r-0`,Wi="termdock-file-preview-horizontal-scroll",hd=o.lazy(()=>$s(()=>import("./ModelPreview-D9pzW_YD.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),pu=`${Wi} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function gu(t,n,s){return t&&!n?"unified":s}const lg=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function cg(t){return t==="preview"||t==="source"}function dg(t){return t==="list"||t==="tree"||t==="ai"}function md(){return tt(au,cg)??"preview"}function ug(){return tt(ou,dg)??"tree"}function ks(t){return typeof t=="boolean"}function fg(t){return typeof t=="string"}function hg(){return tt(iu,ks)??!0}function mg(t){return t==="unified"||t==="split"}function pg(){return tt(lu,mg)??"unified"}function gg(t){return t==="name"||t==="content"||t==="regex"}function bg(){return tt(cu,gg)??"name"}function bu(t){return t.repositories??(t.context?.root?[{id:t.context.root,root:t.context.root,relativeRoot:".",name:ft(t.context.root)||t.context.root,depth:0,nested:!1,available:t.available,files:t.files,context:t.context,error:t.error}]:[])}function xg(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(n=>n===null||typeof n=="string")}function xu(){return tt(uu,xg)??{}}function pd(t){if(!t)return;const n=xu();return Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0}function ni(t,n){t&&xt(uu,{...xu(),[t]:n})}function vg(t,n){if(!n)return null;const s=new Set((t.repoFilters??[]).map(l=>l.root));return s.has(n)?n:s.size>0?null:(t.repositories??[]).some(l=>l.root===n)?n:null}function $i(t){return!t.activeGitRepoRoot&&(t.groupCount>1||t.label!==t.rootName)}function vu(...t){const n=new Set;for(const s of t)for(const l of s)n.add(l.root);return n}function Ei(t){return Array.isArray(t)&&t.every(n=>typeof n=="string")}function gd(t){const n=tt(t,Ei);return n?new Set(n):new Set}function si(t,n){xt(t,[...n])}function yg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;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 wg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;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||Ei(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(yg))&&(n.commits===void 0||Ei(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 kg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return typeof n.key=="string"&&wg(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function Sg(t){return!t||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).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(kg))&&(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.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function bd(){return tt(du,Sg)??{}}function xd(t){return[t.repoRoot,t.baseRef,t.branchName??"",t.headRef??"",t.diffFingerprint??""].join("\0")}function vd(t){const n=t?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function yu(t,n){const s=t?.trim(),l=n?.trim();return!s||!l?!1:s===l||vd(s)===vd(l)}function yd(t){const n=t?.branch??null;return[t?.upstream,...t?.remoteBranches??[],...t?.branches??[]].find(l=>l&&!yu(l,n))??""}function Li(t,n){const s=Math.max(fd,n-320),l=Math.min(ig,s);return Math.min(l,Math.max(fd,t))}function jg(t){return typeof t=="number"&&Number.isFinite(t)}function Rg(t){return Li(tt(ws,jg)??Mi,t)}function wu(t){const n=t.split(/[\\/]/).pop()??t,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function vs(t){return lg.has(wu(t))}function ku(t){const n=t.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function Ai(t){const n=t.trim();return/^#{1,6}\s+/.test(n)||ku(t)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function Su(t){const n=t.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const ju=o.createContext(null);function Ua(t){return t.trim().replace(/\s+/g," ").toLowerCase()}function Ru(t){return t.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function Cu(t){return t.replace(/\s+#+\s*$/,"").trim()}function Pi(t,n){const l=Ru(t).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",d=n.headingSlugCounts.get(l)??0;return n.headingSlugCounts.set(l,d+1),d===0?l:`${l}-${d}`}function wd(t){return Ru(t)||t.trim()}function Ga(t){const n=t.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=Ii(n[2]);return s?{id:Ua(n[1]),definition:{href:s.href,title:s.title}}:null}function Cg(t){const n=new Map;for(const s of t){const l=Ga(s);l&&n.set(l.id,l.definition)}return n}function Nu(t){return t.trim().toLowerCase()}function Mu(t){const n=t.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:Nu(n[1]),text:n[2]}:null}function Ng(t){const n=new Map;let s=null;for(const l of t){const d=Mu(l);if(d){s=d.id,n.set(d.id,{id:d.id,text:d.text,index:n.size+1});continue}if(s&&/^\s{4,}\S/.test(l)){const c=n.get(s);c&&(c.text=`${c.text} ${l.trim()}`);continue}l.trim()&&(s=null)}return n}function $u(t){const n=new Set;let s=!1;return t.forEach((l,d)=>{if(Mu(l)){n.add(d),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(d);return}l.trim()&&(s=!1)}),n}function Mg(t){const n=[...t];let s=0;const l=t[0]?.trim();if(l==="---"||l==="+++"){for(n[0]="",s=1;s<t.length&&t[s].trim()!==l;)n[s]="",s+=1;s<t.length&&(n[s]="",s+=1)}for(;s<t.length;){const d=t[s].trim();if(d.startsWith("<!--")){if(n[s]="",!d.includes("-->")){for(s+=1;s<t.length&&!t[s].includes("-->");)n[s]="",s+=1;s<t.length&&(n[s]="")}s+=1;continue}s+=1}return n}function Eu(t){const n=t.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function Rs(t){const n=t.split(/[?#]/,1)[0],s=n.startsWith("/"),l=[];for(const c of n.split("/"))if(!(!c||c===".")){if(c===".."){l.length>0&&l.pop();continue}l.push(c)}return`${s?"/":""}${l.join("/")}`||(s?"/":".")}function Gi(t,n,s){const l=t.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 d=l.indexOf("#"),c=d>=0?l.slice(0,d):l,h=d>=0?l.slice(d+1):"",m=c.split("?",1)[0];if(!m)return null;let g,p=null;try{g=decodeURIComponent(m),p=h?decodeURIComponent(h):null}catch{return null}const f=s?Rs(s):null;let k;if(g.startsWith("/")){const y=f&&(g===f||g.startsWith(`${f}/`));k=Rs(f&&!y?`${f}/${g.slice(1)}`:g)}else{if(!n)return null;k=Rs(`${Eu(n)}/${g}`)}return f&&k!==f&&!k.startsWith(`${f}/`)?null:{path:k,fragment:p,directory:/\/$/.test(m)}}function qi(t,n,s,l,d){const c=t.trim();if(!c||/^(?:javascript|data):/i.test(c))return null;if(/^https?:\/\//i.test(c))return c;if(!l(c.split(/[?#]/,1)[0]))return null;let h;if(c.startsWith("/")){const m=s&&(c===s||c.startsWith(`${s}/`));h=Rs(s&&!m?`${s}/${c.slice(1)}`:c)}else{if(!n)return null;h=Rs(`${Eu(n)}/${c}`)}return d(h)}function $g(t,n,s){return qi(t,n,s,Ui,l=>`/api/terminal/fs/blob?path=${encodeURIComponent(l)}`)}function Eg(t,n,s){return qi(t,n,s,Td,Id)}const Ti=128,Lg=360,ai=480;function Za(t){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(t))}catch{return!1}}function Lu(t,n,s,l,d=0){if(!n||!s)return null;let c,h;return d>0?(c=l>0?Math.min(d,l):d,h=s*c/n):Za(t)?(h=Math.min(Math.max(s,Ti),Lg),c=n*h/s):(c=n,h=s),l>0&&c>l&&(h=h*l/c,c=l),h>ai&&(c=c*ai/h,h=ai),{width:Math.max(1,Math.round(c)),height:Math.max(1,Math.round(h))}}function Ag(t){if(!t.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(t.slice(t.indexOf("?"))).get("path")}catch{return null}}function Au(t){const n=Ag(t),s=te(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${t}&v=${s}`:t}function Pg({src:t,alt:n,title:s,requestedWidthPx:l}){const d=Za(t),c=Au(t),h=Ja(c),m=o.useRef(null),[g,p]=o.useState(!1),[f,k]=o.useState(0),[y,N]=o.useState({status:"loading"}),[I,D]=o.useState(null);o.useLayoutEffect(()=>{const $=m.current,L=$?.parentElement?.parentElement??$?.parentElement;if(!L)return;const P=()=>k(L.clientWidth);if(P(),typeof ResizeObserver>"u")return;const U=new ResizeObserver(P);return U.observe(L),()=>U.disconnect()},[]),o.useEffect(()=>{if(g)return;const $=m.current;if(!$||typeof IntersectionObserver>"u"){p(!0);return}const L=new IntersectionObserver(P=>{P.some(U=>U.isIntersecting)&&(p(!0),L.disconnect())},{rootMargin:"400px"});return L.observe($),()=>L.disconnect()},[g]),o.useEffect(()=>{if(!g)return;const $=new AbortController;let L=null;N({status:"loading"});const P=window.setTimeout(()=>{$.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return Gh(c,{signal:$.signal}).then(async U=>{if(!U.ok)throw new Error(`HTTP ${U.status}`);const F=Number(U.headers.get("X-Image-Width"))||0,a=Number(U.headers.get("X-Image-Height"))||0;return{blob:await U.blob(),width:F,height:a}}).then(({blob:U,width:F,height:a})=>{$.signal.aborted||(L=URL.createObjectURL(U),F>0&&a>0&&D({width:F,height:a}),N({status:"ready",objectUrl:L}))}).catch(()=>{const U=$.signal.reason;$.signal.aborted&&!(U instanceof DOMException&&U.name==="TimeoutError")||N({status:"fallback"})}).finally(()=>{window.clearTimeout(P)}),()=>{window.clearTimeout(P),$.abort(),L&&URL.revokeObjectURL(L)}},[g,c]);const B=Lu(t,I?.width??0,I?.height??0,f,l??0),E=B??(l?{width:f>0?Math.min(l,f):l,height:Math.round(l*.75)}:{width:Ti*2,height:Ti});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:`${d?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:B?{width:B.width,height:B.height}:void 0,onLoad:$=>{if(I)return;const L=$.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&D({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:$=>{if(I)return;const L=$.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&D({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:E.width,height:E.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function Cs(t,n,s,l,d,c){const h=$g(s,d.markdownFilePath,d.rootPath);if(!h)return c?.fallbackText??``;const m=d.images.length;d.images.push({kind:"image",src:h,alt:n,title:l});const g=e.jsx(Pg,{src:h,alt:n,title:l,requestedWidthPx:c?.requestedWidthPx});return d.onImageOpen&&c?.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:p=>{p.stopPropagation(),d.onImageOpen?.(m)},children:g},t):e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:g},t)}function oi(t){let n=t,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function kd(t){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(t)}function Ii(t){const n=t.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 Pu="",Tg=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function Ig(t){return t.replace(Tg,(n,s)=>`${Pu}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function Sd(t){return t.replace(new RegExp(`${Pu}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function Fg(t){const n=t.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const Tu={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 Pa=null;function Iu(){return Pa||(Pa=$s(()=>import("./purify.es-4eNOHKSq.js"),[]).then(t=>t.default??t).catch(t=>{throw Pa=null,t})),Pa}function Fu({html:t}){const{t:n}=yt(),[s,l]=o.useState(null);return o.useEffect(()=>{let d=!1;return l(null),Iu().then(c=>{d||l(c.sanitize(t,Tu))}).catch(()=>{d||l("")}),()=>{d=!0}},[t]),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 Dg({html:t}){const[n,s]=o.useState(null);return o.useEffect(()=>{let l=!1;return s(null),Iu().then(d=>{l||s(d.sanitize(t,Tu))}).catch(()=>{l||s("")}),()=>{l=!0}},[t]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):t}function Du(t){const n=t.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(t)}}let Ta=null;function _g(){return Ta||(Ta=Promise.all([$s(()=>import("./katex-DnlPpQZa.js"),[]),$s(()=>Promise.resolve({}),__vite__mapDeps([16]))]).then(([t])=>t.default??t).catch(t=>{throw Ta=null,t})),Ta}function Ls({tex:t,display:n=!1}){const[s,l]=o.useState(null),[d,c]=o.useState(!1);if(o.useEffect(()=>{let m=!1;return l(null),c(!1),_g().then(g=>{m||l(g.renderToString(t,{displayMode:n,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{m||c(!0)}),()=>{m=!0}},[n,t]),d)return e.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:n?`$$${t}$$`:`$${t}$`});if(!s)return e.jsx("span",{className:"text-muted-foreground/70",children:n?"Rendering formula...":t});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 Ki(t){const n=new Map;for(const s of t.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 jd(t){const n=Ki(t),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 Bg(t){const n=t.indexOf(">"),s=n<0?t:t.slice(0,n+1),l=Ki(s),d=l.get("src")?.trim()??"",c=l.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i),h=s.replace(/=\s*(?:"[^"]*"|'[^']*')/g," "),m=n<0?"":t.slice(n+1).replace(/<\/video\s*>$/i,"").replace(/<[^>]*>/g,"").trim();return{src:d,fallbackText:m,widthPx:c?Number(c[1]):void 0,controls:/\bcontrols\b/i.test(h)}}function Og({url:t,fallbackText:n,widthPx:s,hasControls:l}){const{t:d}=yt(),[c,h]=o.useState(!1),m=Ja(t,()=>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:c?e.jsx("span",{className:"block px-3 py-2 text-xs text-muted-foreground",children:n?.trim()||d("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 Ug(t,n,s){if(/^<a\b[^>]*>\s*<\s*img\b[^>]*>\s*<\/a\s*>$/i.test(t)){const h=t.slice(0,t.indexOf(">")+1),m=Ki(h).get("href")?.trim()??"",g=t.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:p,alt:f,title:k,widthPx:y}=jd(g);if(!p)return null;const N=qi(p,s.markdownFilePath,s.rootPath,Ui,$=>$);if(!N)return null;const I=m?Gi(m,s.markdownFilePath,s.rootPath):null,B=!!!(I&&I.path===N)&&m?Su(m):null,E=Cs(n,f??"",p,k,s,{requestedWidthPx:y,interactive:B?!1:void 0});return B?e.jsx("a",{href:B,target:"_blank",rel:"noreferrer",children:E},n):E}if(/^<\s*img\b[^>]*>$/i.test(t)){const{src:h,alt:m,title:g,widthPx:p}=jd(t);return h?Cs(n,m??"",h,g,s,{fallbackText:t,requestedWidthPx:p}):null}if(/^<\s*video\b[^>]*>[\s\S]*?<\/video\s*>$/i.test(t)){const{src:h,fallbackText:m,widthPx:g,controls:p}=Bg(t);if(!h)return null;const f=Eg(h,s.markdownFilePath,s.rootPath);return f?e.jsx(Og,{url:f,fallbackText:m,widthPx:g,hasControls:p},n):null}if(/^<br\s*\/?>$/i.test(t))return e.jsx("br",{},n);const l=t.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(t)?e.jsx(Dg,{html:t},n):null;const d=l[1].toLowerCase(),c=rt(l[2],`${n}-${d}`,!0,s);return d==="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:c},n):d==="mark"?e.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:c},n):d==="sub"?e.jsx("sub",{children:c},n):e.jsx("sup",{children:c},n)}function rt(t,n,s=!0,l){const d=Ig(t),c=/(\\\([^)]*\\\)|\$[^$\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=c.exec(d))!==null;){g.index>m&&h.push(Sd(d.slice(m,g.index)));const p=g[0],f=`${n}-${g.index}`,k=p.startsWith("<")?Ug(p,f,l):null;if(k)h.push(k);else if(p.startsWith("\\(")&&p.endsWith("\\)"))h.push(e.jsx(Ls,{tex:p.slice(2,-2)},f));else if(p.startsWith("$")&&p.endsWith("$"))h.push(e.jsx(Ls,{tex:p.slice(1,-1)},f));else if(p.startsWith("`")){const y=p.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:Fg(p.slice(y,-y))},f))}else if(p.startsWith("~~"))h.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:rt(p.slice(2,-2),`${f}-del`,s,l)},f));else if(p.startsWith("**")||p.startsWith("__"))h.push(e.jsx("strong",{className:"font-semibold text-foreground",children:rt(p.slice(2,-2),`${f}-strong`,s,l)},f));else if(p.startsWith("*")||p.startsWith("_"))h.push(e.jsx("em",{className:"italic",children:rt(p.slice(1,-1),`${f}-em`,s,l)},f));else if(p.startsWith("![")){const y=p.match(/^!\[([^\]]*)\]\((.*)\)$/),N=p.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),I=p.match(/^!\[([^\]]+)\]$/);if(y){const D=Ii(y[2]);h.push(D?Cs(f,y[1],D.href,D.title,l):p)}else if(N){const D=N[2]||N[1],B=l.referenceDefinitions.get(Ua(D));h.push(B?Cs(f,N[1],B.href,B.title,l):p)}else if(I){const D=l.referenceDefinitions.get(Ua(I[1]));h.push(D?Cs(f,I[1],D.href,D.title,l):p)}else h.push(p)}else if(p.startsWith("[^")){const y=Nu(p.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):p)}else if(p.startsWith("<http")){const y=p.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(p.startsWith("<")&&p.endsWith(">")&&kd(p.slice(1,-1))){const y=p.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(kd(oi(p).linkText)){const{linkText:y,suffix:N}=oi(p);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(p.startsWith("http")||p.startsWith("www.")){const{linkText:y,suffix:N}=oi(p),I=y.startsWith("www.")?`https://${y}`:y;h.push(e.jsx("a",{href:I,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},f)),N&&h.push(N)}else{const y=p.match(/^\[([^\]]+)\]\((.*)\)$/),N=p.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),I=p.match(/^\[([^\]]+)\]$/),D=N?N[2]||N[1]:I?.[1]??null,B=D?l.referenceDefinitions.get(Ua(D)):null,E=y?Ii(y[2]):null,$=E?.href??B?.href??null,L=$?Su($):null,P=y?.[1]??N?.[1]??I?.[1]??"";h.push(L?e.jsx("a",{href:L,title:E?.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:rt(P,`${f}-link`,s,l)},f):p)}m=c.lastIndex}return m<d.length&&h.push(Sd(d.slice(m))),h.length>0?h:[t]}function _u(t){return/(?: {2,}|\\)$/.test(t)}function Bu(t){return t.replace(/(?: {2,}|\\)$/,"")}function qa(t){return/^(?: {4}|\t)/.test(t)}function Ou(t){return t.startsWith(" ")?t.slice(1):t.replace(/^ {4}/,"")}function Uu(t,n,s){const l=[];return t.forEach((d,c)=>{const h=_u(d);l.push(...rt(Bu(d),`${n}-${c}`,!0,s)),c<t.length-1&&l.push(h?e.jsx("br",{},`${n}-${c}-br`):" ")}),l}function Fi(t,n,s){const l=[],d=[];return t.forEach((c,h)=>{d.push(_u(c)),l.push(rt(Bu(c),`${n}-${h}`,!0,s))}),{perLine:l,hardBreaks:d}}function Di(t,n,s,l,d){const c=[];return t.forEach((h,m)=>{const g=s[m]??0,p=!!(d&&g>=d.start&&g<=d.end);c.push(e.jsx("span",{"data-md-ref-start":g,"data-md-ref-end":g,"data-selected":p?"true":void 0,children:h},`${l}-ref-${m}`)),m<t.length-1&&c.push(n[m]?e.jsx("br",{},`${l}-${m}-br`):" ")}),c}function As(t){const n=t.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let l="",d=!1,c=0,h=0;for(let m=0;m<n.length;m+=1){const g=n[m];if(d){l+=g,d=!1;continue}if(g==="\\"){d=!0;continue}if(g==="`"){const p=m;for(;m+1<n.length&&n[m+1]==="`";)m+=1;const f=m-p+1;l+="`".repeat(f),c===0?c=f:c===f&&(c=0);continue}if(c===0&&g==="["?h+=1:c===0&&g==="]"&&h>0&&(h-=1),g==="|"&&c===0&&h===0){s.push(l.trim()),l="";continue}l+=g}return d&&(l+="\\"),s.push(l.trim()),s}function Hu(t){return As(t).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function Ka(t){return t==="center"?"text-center":t==="right"?"text-right":"text-left"}function Va(t){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(t.trim())}function zu(t,n){return t>96||t>44&&n>.35}function eo(t){return(t.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function Ps(t){const n=t.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 Vi(t,n,s,l,d,c=new Set){const h=[],m=[];let g=n;for(;g<t.length;){const p=t[g];if(d&&(Ga(p)||c.has(g))){g+=1;continue}const f=Ps(p),k=eo(p);if(!f){if(k>s&&m.length>0){([...m].reverse().find(D=>D.indent<k)?.item??m[m.length-1].item).paragraphs.push(p.trim());for(const D of m)D.item.lineEnd=g+1;g+=1;continue}break}if(k<s||k===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>=k;)m.pop();const N=m[m.length-1]?.item??null;N?N.children.push(y):h.push(y),m.push({indent:k,item:y});for(const I of m)I.item.lineEnd=g+1;g+=1}return{items:h,nextIndex:g}}function Hg(t){const n=t.find(l=>Ps(l));if(!n)return[];const s=Ps(n);return s?Vi(t,0,eo(n),s.ordered,!0,$u(t)).items:[]}function Yi(t,n,s,l=0){return t.map((d,c)=>{const h=d.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${c}`,taskItem:!!h,refStart:d.lineStart+l,refEnd:d.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,rt(h?.[2]??d.content,`li-${n}-${c}`,!0,s),d.paragraphs.length>0&&e.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:d.paragraphs.map((m,g)=>e.jsx("p",{children:rt(m,`li-${n}-${c}-p-${g}`,!0,s)},`paragraph-${g}`))})]}),groups:zg(d.children,`${n}-${c}`,s,l)}})}function zg(t,n,s,l=0){const d=[];for(const c of t){const h=d[d.length-1];h&&h.ordered===c.ordered?h.items.push(c):d.push({ordered:c.ordered,items:[c]})}return d.map((c,h)=>({ordered:c.ordered,start:c.ordered?c.items[0]?.start:void 0,items:Yi(c.items,`${n}-g${h}`,s,l)}))}function Xi(t,n){return t.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&&Wg(s.groups,n)]},s.key)})}function Wg(t,n){return t.map((s,l)=>{const d=s.ordered?"ol":"ul";return e.jsx(d,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:Xi(s.items,n)},`nested-${l}`)})}function Gg(t){const n=Array.from(t.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:t.footnotesLabel}),e.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:n.map(s=>e.jsxs("li",{id:`fn-${s.id}`,children:[rt(s.text,`footnote-${s.id}`,!0,t)," ",e.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":t.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function qg(t,n,s,l){const d=[];let c=0;const h=m=>l?.[m]??m+1;for(;c<t.length;){const m=t[c],g=m.trim();if(!g){c+=1;continue}if(/^<details>\s*$/i.test(g)){const E=c;let $="Details";const L=[];for(c+=1;c<t.length&&!/^<\/details>\s*$/i.test(t[c].trim());){const P=t[c].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);P?$=P[1].trim()||$:L.push(t[c].trimStart()),c+=1}c<t.length&&(c+=1),d.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:rt($,`${n}-details-${E}-summary`,!0,s)}),L.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:Uu(L,`${n}-details-${E}`,s)})]},`${n}-details-${E}`)});continue}const p=Du(m);if(p){const E=[m],$=c;for(c+=1;c<t.length&&!p.selfContained&&!new RegExp(`</${p.tag}>`,"i").test(t[c]);)E.push(t[c]),c+=1;c<t.length&&!p.selfContained&&(E.push(t[c]),c+=1),d.push({kind:"static",node:e.jsx(Fu,{html:E.join(`
|
|
1639
|
-
`)},`${n}-html-${$}`)});continue}const f=g.match(/^(```|~~~)\s*(.*)$/);if(f){const E=[],$=f[1],L=f[2]?.trim(),P=c;for(c+=1;c<t.length&&!t[c].trim().startsWith($);)E.push(t[c]),c+=1;c<t.length&&(c+=1),L.toLowerCase()==="mermaid"?d.push({kind:"static",node:e.jsx(Gu,{code:E.join(`
|
|
1640
|
-
`),blockKey:`${n}-code-${P}`},`${n}-code-${P}`)}):["math","latex","tex"].includes(L.toLowerCase())?d.push({kind:"static",node:e.jsx(Ls,{tex:E.join(`
|
|
1641
|
-
`),display:!0},`${n}-code-${P}`)}):d.push({kind:"code",key:`${n}-code-${P}`,code:E.join(`
|
|
1642
|
-
`),lang:L,blockKey:`${n}-code-${P}`,codeStartLine:h(P)+1});continue}if(qa(m)){const E=[],$=c;for(;c<t.length&&(qa(t[c])||!t[c].trim());)E.push(t[c].trim()?Ou(t[c]):""),c+=1;d.push({kind:"code",key:`${n}-indented-code-${$}`,code:E.join(`
|
|
1643
|
-
`).replace(/\n+$/,""),lang:"",blockKey:`${n}-indented-code-${$}`,codeStartLine:h($)});continue}const k=g.match(/^(#{1,6})\s+(.+)$/);if(k){const $=`h${Math.min(6,k[1].length+1)}`,L=Cu(k[2]),P=Pi(L,s);d.push({kind:"static",node:e.jsx($,{id:P,className:"scroll-mt-16 font-semibold text-foreground",children:rt(L,`${n}-heading-${c}`,!0,s)},`${n}-heading-${c}`)}),c+=1;continue}if(c+1<t.length&&m.includes("|")&&Va(t[c+1])){const E=As(m),$=Hu(t[c+1]),L=[],P=c;for(c+=2;c<t.length&&t[c].includes("|")&&t[c].trim();)L.push(As(t[c])),c+=1;d.push({kind:"static",node:e.jsx("div",{className:pu,"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:E.map((U,F)=>e.jsx("th",{className:`${hu} ${Ka($[F]??null)}`,children:e.jsx("div",{className:Wa,children:rt(U,`${n}-th-${P}-${F}`,!0,s)})},`h-${F}`))})}),e.jsx("tbody",{children:L.map((U,F)=>e.jsx("tr",{className:"border-t border-border/10",children:E.map((a,w)=>e.jsx("td",{className:`${mu} ${Ka($[w]??null)}`,children:e.jsx("div",{className:Wa,children:rt(U[w]??"",`${n}-td-${P}-${F}-${w}`,!0,s)})},`c-${w}`))},`r-${F}`))})]})},`${n}-table-${P}`)});continue}const y=Ps(m);if(y){const E=y.ordered,$=eo(m),L=y.start,P=c,U=Vi(t,c,$,E,!1);c=U.nextIndex,d.push({kind:"list",keyPrefix:`${n}-list-${P}`,ordered:E,start:E?L:void 0,renders:Yi(U.items,`${n}-list-${P}`,s,h(0)-1)});continue}const N=[m.trimStart()],I=[h(c)],D=c;for(c+=1;c<t.length&&t[c].trim()&&!Ai(t[c])&&!(c+1<t.length&&t[c].includes("|")&&Va(t[c+1]));)N.push(t[c].trimStart()),I.push(h(c)),c+=1;const B=Fi(N,`${n}-p-${D}`,s);d.push({kind:"paragraph",keyPrefix:`${n}-p-${D}`,perLine:B.perLine,hardBreaks:B.hardBreaks,lineNums:I})}return d}function Kg(t,n){return t.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return e.jsx("p",{children:Di(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:Xi(s.renders,n)},s.keyPrefix)}case"code":return e.jsx(Ya,{code:s.code,lang:s.lang,blockKey:s.blockKey,codeStartLine:s.codeStartLine,lineRange:n},s.key)}})}let Ia=null,Rd=!1;const Fa=16,Wu=192;function Vg(){return Ia||(Ia=$s(()=>import("./mermaid.core-BzEGo4OD.js").then(t=>t.bl),__vite__mapDeps([17,1,2,3,4,5,18])).then(t=>t.default??t).catch(t=>{throw Ia=null,t})),Ia}function Yg(t){Rd||(t.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),Rd=!0)}function Xg(t){const n=t.match(/\sviewBox=(["'])([^"']+)\1/i);if(!n)return t;const[,,s]=n,l=s.trim().split(/[\s,]+/).map(Number),[,,d,c]=l;if(!Number.isFinite(d)||!Number.isFinite(c)||d<=0||c<=0)return t;const h=Math.max(Wu,Math.ceil(d)),m=Math.ceil(h/d*c);return t.replace(/<svg\b([^>]*)>/i,(g,p)=>`<svg${p.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${h}" height="${m}">`)}function Jg(t){const n=t?.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-Fa,d=s.y-Fa,c=s.width+Fa*2,h=s.height+Fa*2,m=Math.max(Wu,Math.ceil(c)),g=Math.ceil(m/c*h);n.setAttribute("viewBox",`${l} ${d} ${c} ${h}`),n.setAttribute("width",String(m)),n.setAttribute("height",String(g)),n.removeAttribute("style")}function Qg(t){const n=t.trim().split(/\s+/,1)[0]?.toLowerCase();if(!n)return null;const s=n.replace(/^language-/,"");return Wd(`code.${s}`)??s}function Gu({code:t,blockKey:n}){const{t:s}=yt(),[l,d]=o.useState(null),[c,h]=o.useState(!1),m=o.useRef(null),g=o.useContext(ju);o.useEffect(()=>{let f=!1;return d(null),h(!1),Vg().then(async k=>{Yg(k);const y=`termdock-md-mermaid-${n.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:N}=await k.render(y,t);f||d(Xg(N))}).catch(()=>{f||h(!0)}),()=>{f=!0}},[n,t]),o.useLayoutEffect(()=>{l&&Jg(m.current)},[l]);const p=o.useCallback(()=>{const f=m.current?.querySelector("svg")?.outerHTML??l;f&&g?.(f)},[g,l]);return c?e.jsx(Ya,{code:t,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(),p()},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 Ya({code:t,lang:n,blockKey:s,codeStartLine:l,lineRange:d}){const c=Qg(n),[h,m]=o.useState(null);o.useEffect(()=>{if(!c||!Gd(t)){m(null);return}let p=!1;return qd().then(f=>{if(p||!f.registered(c)){p||m(null);return}try{m(Kd(f,t,c))}catch{p||m(null)}}).catch(()=>{p||m(null)}),()=>{p=!0}},[s,t,c]);const g=h??(t||" ").split(`
|
|
1644
|
-
`).map(p=>[p||" "]);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:`${Wi} termdock-code overflow-auto p-3 text-[11px] leading-relaxed text-foreground`,children:e.jsx("code",{children:g.map((p,f)=>{const k=l!=null?l+f:null,y=!!(d&&k!=null&&k>=d.start&&k<=d.end);return e.jsxs("span",{"data-md-ref-start":k??void 0,"data-md-ref-end":k??void 0,"data-selected":y?"true":void 0,children:[p,f<g.length-1?`
|
|
1645
|
-
`:null]},`${s}-line-${f}`)})})})]})}function Ji(t,n,s,l,d){t=Mg(t);const c=Cg(t),h=$u(t),m=[],g={markdownFilePath:n,rootPath:s,referenceDefinitions:c,footnoteDefinitions:Ng(t),headingSlugCounts:new Map,images:m,onImageOpen:l,footnotesLabel:d?.footnotes??"Footnotes",backToFootnoteLabel:d?.backToFootnote??(y=>`Back to footnote ${y}`)},p=[];let f=0;for(;f<t.length;){const y=t[f],N=y.trim();if(Ga(y)||h.has(f)){f+=1;continue}if(!N){f+=1;continue}if(/^<details>\s*$/i.test(N)){const F=f;let a="Details";const w=[];for(f+=1;f<t.length&&!/^<\/details>\s*$/i.test(t[f].trim());){const O=t[f].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);O?a=O[1].trim()||a:w.push(t[f].trimStart()),f+=1}f<t.length&&(f+=1),p.push({key:`details-${F}`,startLine:F+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:rt(a,`details-${F}-summary`,!0,g)}),w.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:Uu(w,`details-${F}`,g)})]})});continue}const I=Du(y);if(I){const F=[y],a=f;for(f+=1;f<t.length&&!I.selfContained&&!new RegExp(`</${I.tag}>`,"i").test(t[f]);)F.push(t[f]),f+=1;f<t.length&&!I.selfContained&&(F.push(t[f]),f+=1),p.push({key:`html-${a}`,startLine:a+1,endLine:f,content:e.jsx(Fu,{html:F.join(`
|
|
1646
|
-
`)})});continue}const D=N.match(/^(```|~~~)\s*(.*)$/);if(D){const F=[],a=D[1],w=D[2]?.trim(),O=f;for(f+=1;f<t.length&&!t[f].trim().startsWith(a);)F.push(t[f]),f+=1;f<t.length&&(f+=1),p.push({key:`code-${O}`,startLine:O+1,endLine:f,fineGrained:w.toLowerCase()!=="mermaid"&&!["math","latex","tex"].includes(w.toLowerCase()),content:w.toLowerCase()==="mermaid"?e.jsx(Gu,{code:F.join(`
|
|
1647
|
-
`),blockKey:`code-${O}`}):["math","latex","tex"].includes(w.toLowerCase())?e.jsx(Ls,{tex:F.join(`
|
|
1648
|
-
`),display:!0}):j=>e.jsx(Ya,{code:F.join(`
|
|
1649
|
-
`),lang:w,blockKey:`code-${O}`,codeStartLine:O+2,lineRange:j})});continue}if(qa(y)){const F=[],a=f;for(f+=0;f<t.length&&(qa(t[f])||!t[f].trim());)F.push(t[f].trim()?Ou(t[f]):""),f+=1;p.push({key:`indented-code-${a}`,startLine:a+1,endLine:f,fineGrained:!0,content:w=>e.jsx(Ya,{code:F.join(`
|
|
1650
|
-
`).replace(/\n+$/,""),lang:"",blockKey:`indented-code-${a}`,codeStartLine:a+1,lineRange:w})});continue}if(N.startsWith("$$")){const F=[],a=f,w=N.replace(/^\$\$\s*/,"");if(w.endsWith("$$")&&w.length>2)F.push(w.replace(/\s*\$\$$/,"")),f+=1;else{for(w&&F.push(w),f+=1;f<t.length&&!t[f].trim().endsWith("$$");)F.push(t[f]),f+=1;if(f<t.length){const O=t[f].trim().replace(/\s*\$\$$/,"");O&&F.push(O),f+=1}}p.push({key:`math-${a}`,startLine:a+1,endLine:f,content:e.jsx(Ls,{tex:F.join(`
|
|
1651
|
-
`),display:!0})});continue}if(f+1<t.length&&N&&!Ai(y)&&/^(=+|-+)\s*$/.test(t[f+1].trim())){const F=t[f+1].trim().startsWith("=")?1:2,a=`h${F}`,w=Pi(N,g),O={level:F,text:wd(N),id:w};p.push({key:`setext-heading-${f}`,startLine:f+1,endLine:f+2,heading:O,content:e.jsx(a,{id:w,className:`scroll-mt-16 font-semibold text-foreground ${F===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:rt(N,`setext-heading-${f}`,!0,g)})}),f+=2;continue}const B=N.match(/^(#{1,6})\s+(.+)$/);if(B){const F=B[1].length,a=Cu(B[2]),w={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${F}`,j=Pi(a,g),X={level:F,text:wd(a),id:j};p.push({key:`heading-${f}`,startLine:f+1,endLine:f+1,heading:X,content:e.jsx(O,{id:j,className:`scroll-mt-16 font-semibold text-foreground ${w[F]}`,children:rt(a,`heading-${f}`,!0,g)})}),f+=1;continue}if(ku(y)){p.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 F=[],a=[],w=f;for(;f<t.length&&/^>\s?/.test(t[f].trim());)F.push(t[f].trim().replace(/^>\s?/,"")),a.push(f+1),f+=1;const O=F[0]?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i);if(O){const X=O[1].toUpperCase(),ne=O[2]?.trim(),se=[...ne?[ne]:[],...F.slice(1)],fe=[...ne?[a[0]]:[],...a.slice(1)],G=Fi(se,`callout-${w}`,g);p.push({key:`callout-${w}`,startLine:w+1,endLine:f,fineGrained:!0,content:J=>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:X}),se.length>0&&e.jsx("div",{children:Di(G.perLine,G.hardBreaks,fe,`callout-${w}`,J)})]})});continue}const j=qg(F,`quote-${w}`,g,a);p.push({key:`quote-${w}`,startLine:w+1,endLine:f,fineGrained:!0,content:X=>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:Kg(j,X)})});continue}if(f+1<t.length&&y.includes("|")&&Va(t[f+1])){const F=As(y),a=Hu(t[f+1]),w=[],O=f;for(f+=2;f<t.length&&t[f].includes("|")&&t[f].trim();)w.push(As(t[f])),f+=1;const j=F.map((ne,se)=>rt(ne,`th-${O}-${se}`,!0,g)),X=w.map((ne,se)=>F.map((fe,G)=>rt(ne[G]??"",`td-${O}-${se}-${G}`,!0,g)));p.push({key:`table-${O}`,startLine:O+1,endLine:f,interactive:!1,kind:"table",content:ne=>{const se=fe=>!!(ne&&fe>=ne.start&&fe<=ne.end);return e.jsx("div",{className:pu,"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:j.map((fe,G)=>e.jsx("th",{className:`${hu} ${Ka(a[G]??null)}`,children:e.jsx("div",{className:Wa,children:fe})},`h-${G}`))})}),e.jsx("tbody",{children:X.map((fe,G)=>{const J=O+G+3;return e.jsx("tr",{className:"border-t border-border/10","data-markdown-table-row-line":J,"data-md-ref-start":J,"data-md-ref-end":J,"data-selected":se(J)?"true":void 0,children:F.map((M,_)=>e.jsx("td",{className:`${mu} ${Ka(a[_]??null)}`,children:e.jsx("div",{className:Wa,children:fe[_]})},`c-${_}`))},`r-${G}`)})})]})})}});continue}const E=Ps(y);if(E){const F=E.ordered,a=eo(y),w=E.start,O=f,j=Vi(t,f,a,F,!0,h);f=j.nextIndex;const X=F?"ol":"ul",ne=Yi(j.items,`list-${O}`,g);p.push({key:`list-${O}`,startLine:O+1,endLine:f,fineGrained:!0,content:se=>e.jsx(X,{start:F?w:void 0,className:`${F?"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:Xi(ne,se)})});continue}const $=[y.trimStart()],L=[f+1],P=f;for(f+=1;f<t.length&&t[f].trim()&&!Ai(t[f])&&!(f+1<t.length&&t[f].includes("|")&&Va(t[f+1]));){if(Ga(t[f])||h.has(f)){f+=1;continue}$.push(t[f].trimStart()),L.push(f+1),f+=1}const U=Fi($,`p-${P}`,g);p.push({key:`p-${P}`,startLine:P+1,endLine:f,fineGrained:!0,content:F=>e.jsx("p",{className:"text-muted-foreground",children:Di(U.perLine,U.hardBreaks,L,`p-${P}`,F)})})}const k=Gg(g);return k&&p.push({key:"footnotes",startLine:t.length,endLine:t.length,content:k}),{blocks:p,images:m}}function Zg(t,n,s){return Ji(t,n,s).blocks}function qu(t,n){const s=[];for(const l of t){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 Ku(t){return t.filter(n=>!!n.heading).map(n=>({...n.heading,startLine:n.startLine}))}function eb({src:t,alt:n,onZoomChange:s,onDoubleTap:l}){const d=Au(t);return e.jsx(of,{src:d,alt:n,onLoad:()=>{},onError:()=>{},onZoomChange:s,onDoubleTap:l})}function Vu({images:t,index:n,onChange:s,onClose:l}){const{t:d}=yt(),c=t[n],h=t.length>1,m=o.useRef(null),g=o.useRef(null),p=o.useRef(null),f=o.useRef(0),[k,y]=o.useState(!1),[N,I]=o.useState(0),[D,B]=o.useState(!1),E=o.useCallback(()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null)},[]),$=o.useCallback(()=>{k||Date.now()<f.current||(E(),p.current=window.setTimeout(()=>{p.current=null,l()},450))},[E,k,l]),L=o.useCallback(a=>{if(t.length===0)return;const w=(a+t.length)%t.length;m.current?.slideTo(w),s(w)},[t.length,s]),P=o.useCallback(()=>L(n-1),[L,n]),U=o.useCallback(()=>L(n+1),[L,n]);if(o.useEffect(()=>{E(),I(0),B(!1),y(!1)},[E,n]),o.useEffect(()=>{const a=m.current;a&&(a.allowTouchMove=h&&!k)},[h,k]),o.useEffect(()=>{const a=m.current;!a||a.activeIndex===n||a.slideTo(n,0)},[n]),o.useEffect(()=>E,[E]),o.useEffect(()=>{const a=w=>{if(w.key==="Escape"){w.preventDefault(),l();return}h&&(w.key==="ArrowLeft"?(w.preventDefault(),P()):w.key==="ArrowRight"&&(w.preventDefault(),U()))};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[h,U,P,l]),_d({onDrag:({movement:[a,w],pinching:O})=>{O||k||Math.abs(w)<Math.abs(a)*1.15&&N===0||(B(!0),Math.abs(w)>8&&(f.current=Date.now()+300),I(Math.max(0,w)))},onDragEnd:({movement:[a,w],velocity:[,O],pinching:j,canceled:X})=>{if(B(!1),j||X||k||Math.abs(w)<Math.abs(a)*1.15){I(0);return}if(Math.abs(w)>8&&(f.current=Date.now()+300),zu(w,O)){l();return}I(0)}},{target:g,drag:{filterTaps:!0,pointer:{touch:!0}}}),!c)return null;const F=c.title||c.alt||(c.kind==="mermaid"?d("rightSidebar.mermaidDiagram"):d("rightSidebar.image"));return typeof document>"u"?null:Gr.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:F}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n+1," / ",t.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:P,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":d("rightSidebar.previousImage"),title:d("common.previous"),children:e.jsx(Ns,{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":d("rightSidebar.nextImage"),title:d("common.next"),children:e.jsx(Mh,{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":d("rightSidebar.closeImagePreview"),title:d("common.close"),children:e.jsx(Ut,{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:$,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:D?"none":"transform 0.2s ease-out, opacity 0.2s ease-out",willChange:"transform, opacity"},children:e.jsx(Bd,{onSwiper:a=>{m.current=a,a.allowTouchMove=h&&!k},onSlideChange:a=>{a.activeIndex!==n&&s(a.activeIndex)},onSliderMove:()=>{E(),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:t.map((a,w)=>e.jsx(yi,{className:"h-full",children:e.jsx("div",{className:"h-full w-full px-3 py-4 sm:px-6 sm:py-6",children:a.kind==="image"?e.jsx(eb,{src:a.src,alt:a.alt||a.title||d("rightSidebar.markdownImage"),onZoomChange:y,onDoubleTap:E}):e.jsx(gb,{svg:a.svg,title:a.title||a.alt||d("rightSidebar.mermaidDiagram"),onZoomChange:y,onDoubleTap:E})})},`${a.kind}-${w}-${a.alt}`))})})})]})]}),document.body)}function Yu({content:t,filePath:n,rootPath:s,lineRange:l,onLineRangeClick:d,onLineRangeDrag:c,scrollTop:h,outlineOpen:m,outlineCloseSignal:g,onOutlineOpen:p,onOutlineClose:f,lightboxOpen:k,lightboxCloseSignal:y,onLightboxOpen:N,onLightboxClose:I,onLocalLinkOpen:D}){const{t:B}=yt(),[E,$]=o.useState(null),[L,P]=o.useState(null),[U,F]=o.useState(1),[a,w]=o.useState(null),O=o.useRef(null),j=o.useRef(null),{blocks:X,images:ne}=o.useMemo(()=>Ji(t.split(`
|
|
1652
|
-
`),n,s,S=>{P(null),$(S),N?.()},{footnotes:B("rightSidebar.footnotes"),backToFootnote:S=>B("rightSidebar.backToFootnote",{index:S})}),[t,n,s,N,B]),se=o.useMemo(()=>L?[...ne,L]:ne,[ne,L]),fe=o.useCallback(S=>{P({kind:"mermaid",svg:S,alt:"Mermaid diagram",title:"Mermaid diagram"}),$(ne.length),N?.()},[ne.length,N]);o.useEffect(()=>{$(null),P(null)},[t,n]),o.useEffect(()=>{$(null),P(null)},[y]),o.useEffect(()=>{k||($(null),P(null))},[k]),o.useEffect(()=>{F(1)},[t,n]),o.useLayoutEffect(()=>{const S=O.current;if(!S||X.length===0)return;const V=Array.from(S.querySelectorAll("[data-markdown-preview-block-start]"));let ye=1;const be=28;for(const Oe of V)if(Oe.offsetTop-h<=be)ye=Number(Oe.dataset.markdownPreviewBlockStart)||ye;else break;F(Oe=>Oe===ye?Oe:ye)},[X,h]);const G=o.useMemo(()=>qu(X,U),[U,X]),J=o.useMemo(()=>Ku(X),[X]),M=`${n??""}
|
|
1653
|
-
${t}`,_=o.useRef(M),K=o.useRef(null),re=o.useRef(null),oe=o.useRef(!1);o.useEffect(()=>{_.current!==M&&(_.current=M,f?.())},[f,M]),o.useEffect(()=>{g!==void 0&&w(null)},[g]),o.useLayoutEffect(()=>{if(!m){w(null);return}const S=()=>{const V=j.current;if(!V)return;const ye=V.getBoundingClientRect(),be=window.innerWidth;w({top:ye.bottom+6,right:Math.max(8,be-ye.right)})};return S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[m,h,G]);const he=o.useCallback(S=>{const V=O.current,ye=V?.closest("[data-markdown-preview-scroller]"),be=V?.querySelector(`[data-markdown-preview-block-start="${S.startLine}"]`);if(!ye||!be)return;const Oe=ye.getBoundingClientRect(),ce=be.getBoundingClientRect(),Le=V?.querySelector("[data-markdown-heading-sticky]")?.getBoundingClientRect().height??0,W=ce.top-Oe.top+ye.scrollTop;ye.scrollTo({top:Math.max(0,W-Le-8),behavior:"smooth"}),F(S.startLine),f?.()},[f]),me=o.useCallback(S=>{S.pointerType==="mouse"&&S.button!==0||mi(S.target)||(K.current={pointerId:S.pointerId,startX:S.clientX,startY:S.clientY})},[]),je=o.useCallback((S,V,ye)=>{const be=K.current;if(K.current=null,!be||be.pointerId!==S.pointerId)return;const Oe=Math.abs(S.clientX-be.startX),ce=Math.abs(S.clientY-be.startY);if(Oe>8||ce>8)return;const Je=S.target;if(mi(Je)||Bi())return;const Le=Pd(Je,V,ye);d(S,Le.start,Le.end)},[d]),C=o.useCallback(S=>{K.current?.pointerId===S.pointerId&&(K.current=null)},[]),Z=o.useCallback((S,V)=>{const ye=O.current;if(!ye||typeof document.elementFromPoint!="function")return null;const be=document.elementFromPoint(S,V);if(!(be instanceof HTMLElement)||!ye.contains(be))return null;const Oe=be.closest("[data-md-ref-start]");if(Oe){const Se=Number(Oe.dataset.mdRefStart);if(Number.isFinite(Se)&&Se>0)return Se}const ce=be.closest("[data-markdown-preview-block-start]");if(!ce)return null;const Je=Number(ce.dataset.markdownPreviewBlockStart),Le=X.find(Se=>Se.startLine===Je);if(!Le)return Number.isFinite(Je)&&Je>0?Je:null;if(Le.endLine<=Le.startLine)return Le.startLine;const W=ce.getBoundingClientRect(),q=W.height>0?Math.min(1,Math.max(0,(V-W.top)/W.height)):0;return Math.round(Le.startLine+q*(Le.endLine-Le.startLine))},[X]),ue=o.useCallback(S=>{if(!c||S.pointerType==="mouse"&&S.button!==0)return;const V=Z(S.clientX+24,S.clientY);if(V!=null){re.current={pointerId:S.pointerId,anchorLine:V,moved:!1};try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}}},[c,Z]),Ee=o.useCallback(S=>{const V=re.current;if(!V||V.pointerId!==S.pointerId||!c)return;const ye=Z(S.clientX+16,S.clientY);ye!=null&&(!V.moved&&ye===V.anchorLine||(V.moved=!0,oe.current=!0,c(S,Math.min(V.anchorLine,ye),Math.max(V.anchorLine,ye),"move")))},[c,Z]),Ge=o.useCallback(S=>{const V=re.current;if(re.current=null,!V||V.pointerId!==S.pointerId||!c||!V.moved)return;const ye=Z(S.clientX+16,S.clientY)??V.anchorLine;c(S,Math.min(V.anchorLine,ye),Math.max(V.anchorLine,ye),"end")},[c,Z]),De=o.useCallback(S=>{re.current?.pointerId===S.pointerId&&(re.current=null)},[]),le={onPointerDown:ue,onPointerMove:Ee,onPointerUp:Ge,onPointerCancel:De},ae=()=>oe.current?(oe.current=!1,!0):!1;return X.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:S=>{const V=S.target instanceof Element?S.target.closest("a[href]"):null;if(!V||!D)return;const ye=V.getAttribute("href");if(!ye)return;const be=Gi(ye,n,s);be&&(S.preventDefault(),D(be))},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(S=>S.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}),J.length>1&&e.jsxs("button",{ref:j,type:"button",onClick:()=>{m?f?.():p?.()},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(Od,{size:12}),e.jsx("span",{children:B("rightSidebar.markdownOutlineShort")})]})]})}),m&&typeof document<"u"&&Gr.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:a?{top:`${a.top}px`,right:`${a.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:J.map(S=>{const V=G[G.length-1]?.startLine===S.startLine;return e.jsxs("button",{type:"button",onClick:()=>he(S),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] ${V?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(S.level-1,4)*12+8}px`},title:S.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${V?"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",S.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:S.text})]},`desktop-${S.id}-${S.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(Ut,{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:J.map(S=>{const V=G[G.length-1]?.startLine===S.startLine;return e.jsxs("button",{type:"button",onClick:()=>he(S),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] ${V?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(S.level-1,4)*12+8}px`},title:S.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${V?"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",S.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:S.text})]},`${S.id}-${S.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(ju.Provider,{value:fe,children:X.map(S=>{const V=!!(l&&S.startLine<=l.end&&S.endLine>=l.start),ye=!!(l&&l.start<=S.startLine&&l.end>=S.endLine),be=S.kind==="table"?!1:S.fineGrained?ye:V,Oe=S.kind==="table"&&l?.start===S.startLine&&l.end===S.endLine;let ce=null;if(S.kind!=="table"&&S.fineGrained&&V&&!ye&&l){const q=S.endLine-S.startLine+1,Se=Math.max(l.start,S.startLine),Re=Math.min(l.end,S.endLine),lt=(Se-S.startLine)/q,Qe=(Re-Se+1)/q;ce=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) * ${lt})`,height:`calc((100% - 0.5rem) * ${Qe})`}})}const Je=typeof S.content=="function"?S.content(l):S.content,Le=S.startLine===S.endLine?String(S.startLine):`${S.startLine}-${S.endLine}`,W=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:ui(be),"aria-hidden":"true",...le,children:[e.jsx("span",{className:fi(be)}),ce]}),e.jsx("div",{className:"min-w-0","data-sidebar-selectable":!0,children:Je})]});return S.interactive===!1?e.jsxs("div",{"data-markdown-preview-block-start":S.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 ${be?"bg-primary/10":""}`,title:`Line ${Le}`,"aria-label":`Line ${Le}`,children:[S.kind==="table"?e.jsx("button",{type:"button",className:ui(Oe,"self"),onClick:q=>{q.preventDefault(),!ae()&&d(q,S.startLine,S.endLine)},title:`Reference table lines ${Le}`,"aria-label":`Reference table lines ${Le}`,...le,children:e.jsx("span",{className:fi(Oe,"self")})}):e.jsxs("span",{className:ui(be,"none"),"aria-hidden":"true",...le,children:[e.jsx("span",{className:fi(be,"none")}),ce]}),e.jsx("div",{className:"min-w-0 cursor-text select-text","data-sidebar-selectable":!0,role:"button",tabIndex:0,onPointerDown:me,onPointerUp:q=>je(q,S.startLine,S.endLine),onPointerCancel:C,onKeyDown:q=>{q.key!=="Enter"&&q.key!==" "||(q.preventDefault(),d(q,S.startLine,S.endLine))},title:`Reference line ${Le}`,"aria-label":`Reference line ${Le}`,children:Je})]},S.key):e.jsx("div",{role:"button",tabIndex:0,"data-markdown-preview-block-start":S.startLine,onClick:q=>{const Se=q.target;if(mi(Se)||Bi()||ae())return;const Re=Pd(Se,S.startLine,S.endLine);d(q,Re.start,Re.end)},onKeyDown:q=>{q.key!=="Enter"&&q.key!==" "||(q.preventDefault(),d(q,S.startLine,S.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 ${be?"bg-primary/10":"hover:bg-[var(--surface-2)]"}`,title:`Reference line ${Le}`,"aria-label":`Reference line ${Le}`,children:W},S.key)})})})]}),k&&E!==null&&se[E]&&e.jsx(Vu,{images:se,index:E,onChange:$,onClose:()=>{$(null),P(null),I?.()}})]})}function qn({label:t,value:n,options:s,placeholder:l,searchPlaceholder:d,emptyText:c,disabled:h,onChange:m}){const{t:g}=yt(),[p,f]=o.useState(!1),[k,y]=o.useState(""),[N,I]=o.useState(null),D=o.useRef(null),B=o.useRef(null),E=k.trim().toLowerCase(),$=o.useMemo(()=>E?s.filter(a=>`${a.label} ${a.meta??""}`.toLowerCase().includes(E)):s,[E,s]),L=s.find(a=>a.value===n),P=()=>{const a=k.trim();a&&(m(a),f(!1),y(""))},U=o.useCallback(()=>{const a=D.current?.getBoundingClientRect();if(!a)return!1;const w=12,O=Math.max(220,Math.min(a.width,window.innerWidth-w*2)),j=Math.min(Math.max(w,a.left),window.innerWidth-O-w),X=window.innerHeight-a.bottom-w,ne=a.top-w,se=X>=180||X>=ne,fe=Math.max(96,(se?X:ne)-4),G=Math.min(320,fe);return I({left:j,top:se?a.bottom+4:Math.max(w,a.top-G-4),width:O,maxHeight:G}),!0},[]),F=()=>{U(),f(!0)};return o.useEffect(()=>{if(!p)return;let a=0;const w=()=>{a||(a=window.requestAnimationFrame(()=>{a=0,U()}))},O=j=>{const X=j.target;X instanceof Node&&(D.current?.contains(X)||B.current?.contains(X)||(f(!1),y("")))};return window.addEventListener("resize",w),window.addEventListener("scroll",w,!0),document.addEventListener("pointerdown",O,!0),()=>{a&&window.cancelAnimationFrame(a),window.removeEventListener("resize",w),window.removeEventListener("scroll",w,!0),document.removeEventListener("pointerdown",O,!0)}},[p,U]),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:D,type:"button",disabled:h,onClick:()=>{if(!h){if(y(""),p){f(!1);return}F()}},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:t}),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(Ms,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${p?"rotate-180":""}`})]}),p&&!h&&typeof document<"u"&&Gr.createPortal(e.jsxs("div",{ref:B,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:a=>a.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(Vn,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:k,onChange:a=>y(a.target.value),onKeyDown:a=>{if(a.key==="Escape"){a.preventDefault(),f(!1),y("");return}a.key==="Enter"&&(a.preventDefault(),P())},onBlur:()=>{k.trim()&&$.length===0&&P()},placeholder:d,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:[k.trim()&&!s.some(a=>a.value===k.trim())&&e.jsxs("button",{type:"button",onMouseDown:a=>a.preventDefault(),onClick:P,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:k.trim()}),e.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:g("common.use")})]}),$.length>0?$.map(a=>e.jsxs("button",{type:"button",onClick:()=>{m(a.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 ${a.value===n?"bg-accent/10 text-accent":"text-foreground"}`,children:[e.jsx("span",{className:"min-w-0 truncate font-medium",children:a.label}),a.meta&&e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:a.meta})]},a.value)):e.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:c})]})]}),document.body)]})}function Cd({open:t,onOpenChange:n,showScopePicker:s,selectedAll:l,repos:d,selectedRoots:c,onToggleRepo:h,onGenerate:m,onSecondaryAction:g,disabled:p,generateDisabled:f,secondaryDisabled:k,inserted:y,buttonLabel:N,insertedLabel:I,title:D,ariaLabel:B,scopeTitle:E,scopeLabel:$,allLabel:L,generateLabel:P,secondaryLabel:U,secondaryTitle:F,secondaryLoading:a,loading:w,error:O,statusTitle:j,extraContent:X,renderRepoExtra:ne}){return e.jsxs("div",{className:"relative inline-flex shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>{s?n(!t):f||m()},disabled:p,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:j??(s?`${E}: ${$}`:D),children:[w?e.jsx(vt,{size:13,className:"animate-spin"}):e.jsx(Es,{size:13}),e.jsx("span",{children:y?I:N}),s&&e.jsx(Ms,{size:11,className:`shrink-0 transition ${t?"rotate-180":""}`}),O&&e.jsx("span",{className:"absolute right-0.5 top-0.5 size-1.5 rounded-full bg-destructive"})]}),s&&t&&typeof document<"u"&&Gr.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}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:$})]}),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(Ut,{size:14})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[X,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:"✓"})]}),d.map(se=>{const fe=c.includes(se.root);return e.jsxs("div",{className:`mt-1 rounded-md transition ${fe?"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 ${fe?"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})]}),fe&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),ne&&(l||fe)&&e.jsx("div",{className:"px-2 pb-2",children:ne(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:()=>{k||(n(!1),g())},disabled:k,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:F,children:[a?e.jsx(vt,{size:12,className:"animate-spin"}):e.jsx(Yd,{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:D,children:[e.jsx(Es,{size:12}),P]})]})]})}),document.body)]})}function tb(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;for(const n of Object.values(t)){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 Xu(){return tt(Hi,tb)??{}}function rb(t,n){const s=Xu(),l=Object.entries({...s,[t]:{top:n,updatedAt:Date.now()}}).sort(([,d],[,c])=>c.updatedAt-d.updatedAt).slice(0,Jp);Ss(Hi,Object.fromEntries(l),Zp)}function nb(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;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 sb(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;for(const n of Object.values(t)){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&&!nb(s.lineRange)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function Qi(t,n){if(!n)return null;const s=t&&!n.startsWith("/")?`${t}/${n}`:n;return t?`${t}::${s}`:s}function Ju(){return tt(zi,sb)??{}}function Nd(t,n){const s=Qi(t,n);return s?Ju()[s]??null:null}function ii(t,n,s){const l=Qi(t,n);if(!l)return;const d=Ju(),c=d[l]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},h=Object.entries({...d,[l]:{...c,...s,updatedAt:Date.now()}}).sort(([,m],[,g])=>g.updatedAt-m.updatedAt).slice(0,Qp);Ss(zi,Object.fromEntries(h),eg)}function li({active:t,mounted:n=!0,fallback:s=null,children:l}){return e.jsx("div",{className:`h-full min-h-0 overflow-hidden bg-surface text-foreground ${t?"block":"hidden"}`,"aria-hidden":!t,children:n?typeof l=="function"?l():l:s})}function ci({slow:t}){return e.jsx(cm,{slow:t})}function Da({message:t,onRetry:n}){const{t:s}=yt();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:t}),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 Ha(t,n){const s=n&&t.startsWith(`${n}/`)?t.slice(n.length+1):t,l=s.split("/").filter(Boolean);return{name:l.pop()||s,dir:l.join("/")}}function ft(t){if(!t)return"";const n=t.replace(/\/+$/,"");return n.split("/").pop()||n||"/"}function di(t){if(!t)return null;const n=t.replace(/\/+$/,"")||"/";if(n==="/")return null;const s=n.slice(0,n.lastIndexOf("/"))||"/";return s===n?null:s}function _i(t,n,s){const l=Math.min(n,s),d=Math.max(n,s);return t?.start===l&&t.end===d?null:t&&t.start===t.end?{start:Math.min(t.start,l),end:Math.max(t.end,d)}:{start:l,end:d}}function ab(t,n,s){return _i(t,n,s)}function ui(t,n="group"){return`relative flex min-h-5 w-full touch-none select-none items-stretch justify-center rounded transition sm:min-h-6 ${t?"bg-primary/20":`bg-[var(--surface-2)] ${n==="group"?"group-hover:bg-[var(--surface-elevated)]":n==="self"?"hover:bg-[var(--surface-elevated)]":""}`}`}function fi(t,n="group"){return`my-1 w-0.5 rounded-full transition sm:w-1 ${t?"bg-primary":`bg-[var(--border-strong)] ${n==="group"?"group-hover:bg-[var(--muted-foreground)]":n==="self"?"hover:bg-[var(--muted-foreground)]":""}`}`}function Md(t,n){return`pointer-events-auto absolute z-30 inline-flex items-center gap-1 rounded-full font-semibold shadow-lg ring-1 transition active:scale-95 ${t?"h-9 px-4 text-[12px]":"h-7 px-3 text-[11px]"} ${n?"bg-surface-elevated text-foreground ring-border-strong/40 hover:bg-surface-2":"bg-primary text-primary-foreground ring-primary/30 hover:bg-primary/90"}`}function Qu(t){const n=new Map;for(const s of t)n.set(Zi(s),s);return n}function Zu(t,n){const s=new Map(t);for(const l of n)s.set(Zi(l),l);return s}function $d(t,n){let s=0;for(const l of t){const d=it(l,n);d&&n&&d!==n&&(s+=1)}return s}function ob(t){return t.reduce((n,s)=>n+(s.staged?1:0),0)}function ib(t,n){return Array.from(Zu(Qu(t),n).values()).sort((s,l)=>s.path.localeCompare(l.path))}function lb(t,n){const s=t.relativeRoot==="."?ft(n??t.root)||t.name||t.root:t.relativeRoot||t.name||ft(t.root)||t.root;return{root:t.root,label:s,branch:t.context?.branch??null,count:t.files.length,staged:ob(t.files)}}function ef(t,n){const s=ft(n??"")||n||"";return t.map(l=>lb(l,n)).sort((l,d)=>s&&l.label===s?-1:s&&d.label===s?1:l.label.localeCompare(d.label))}function tf(t,n,s,l,d){const c=bu(s),h=c.find(D=>D.root===l)??c[0]??null,m=n.find(D=>D.root===l)??null,g=m?.relativeRoot??h?.relativeRoot??".",p=m?.name??h?.name??(ft(l)||l),f=(h?.files??s.files).map(D=>({...D,repoRoot:l,repoRelativeRoot:g,repoName:p})),k=h?.context??s.context,y={...m??h??{id:l,root:l,relativeRoot:g,name:p,depth:0,nested:!!(d&&l!==d),available:s.available,files:[],context:null},...h??{},id:m?.id??h?.id??l,root:l,displayRoot:m?.displayRoot??h?.displayRoot,relativeRoot:g,name:p,depth:m?.depth??h?.depth??0,nested:m?.nested??h?.nested??!!(d&&l!==d),available:h?.available??s.available,files:f,context:k?{...k,root:l,changedFiles:f.map(D=>({path:D.path,absolutePath:D.absolutePath,status:D.status}))}:null,untrackedDeferred:h?.untrackedDeferred??s.untrackedDeferred,error:h?.error??s.error},N=m?n.map(D=>D.root===l?y:D):[...n,y];return{files:Array.from(t).filter(D=>it(D,d)!==l).concat(f),repositories:N,repoFilters:ef(N,d)}}function it(t,n){return t.repoRoot??n}function Zi(t){return`${t.repoRoot??""}\0${t.path}`}function ut(t){return t.absolutePath||t.path}function hi(t){return Zi(t)}function cb(t){return t.repoRelativeRoot&&t.repoRelativeRoot!=="."?t.repoRelativeRoot:t.repoName??""}function Ed(t){return t.reduce((n,s)=>n+(s.staged?1:0),0)}function Ld(t){const n={added:0,modified:0,deleted:0,renamed:0,copied:0,untracked:0,conflicted:0,staged:0,other:0};for(const s of t)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 Kn(t){let n=0;const s=t??"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 ys(t,n){return typeof t!="number"||!Number.isFinite(t)||t<=0?null:new Intl.DateTimeFormat(n==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}function Cr(t){return t instanceof DOMException&&t.name==="AbortError"}function db(t){const n=t.error??t.context?.error??"";return n.includes("request was cancelled")||n.includes("IO_REQUEST_CANCELLED")}function Ad(t){return t?.available===!1&&t.code==="NOT_GIT_REPOSITORY"}function Bi(){if(typeof window>"u")return!1;const t=window.getSelection();return!!(t&&!t.isCollapsed&&t.toString().trim())}function mi(t){return t instanceof HTMLElement&&!!t.closest('a, button, input, textarea, select, label, [contenteditable="true"]')}function Pd(t,n,s){const l=t instanceof HTMLElement?t.closest("[data-md-ref-start]"):null,d=Number(l?.dataset.mdRefStart),c=Number(l?.dataset.mdRefEnd??l?.dataset.mdRefStart);return Number.isFinite(d)&&d>0&&Number.isFinite(c)&&c>0?{start:Math.min(d,c),end:Math.max(d,c)}:{start:n,end:s}}function ub({actions:t,running:n,completed:s}){const{t:l}=yt(),[d,c]=o.useState(!1),h=o.useRef(null),m=t.find(p=>n?.action===p.key),g=t.find(p=>s?.action===p.key);return t.length===0?null:(o.useEffect(()=>{if(!d)return;const p=k=>{const y=k.target;y instanceof Node&&h.current?.contains(y)||c(!1)},f=k=>{k.key==="Escape"&&c(!1)};return document.addEventListener("pointerdown",p),document.addEventListener("keydown",f),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("keydown",f)}},[d]),e.jsxs("div",{ref:h,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),c(f=>!f)},disabled:t.every(p=>p.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 ${d?"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(vt,{size:13,className:"animate-spin"}):g?e.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):e.jsx(xi,{size:14})}),d&&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:t.map(p=>{const f=n?.action===p.key,k=s?.action===p.key;return e.jsxs("button",{type:"button",onClick:y=>{y.stopPropagation(),p.onClick(),c(!1)},disabled:p.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 ${k?"bg-accent/10 text-accent":p.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(vt,{size:13,className:"animate-spin"}):k?"✓":null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.label})]},p.key)})})]}))}function fb(t){const n=window.getComputedStyle(t).overflowY;return(n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight+1}function rf(t){let n=t;for(;n;){if(n.classList.contains("termdock-diff-stream-scroller")&&fb(n))return n;n=n.parentElement}return t.closest(".termdock-diff-stream-scroller")}function Yn(t){return t.getClientRects().length>0&&window.getComputedStyle(t).visibility!=="hidden"}const pi=new WeakMap;function Xa(t){const n=pi.get(t);n!==void 0&&window.clearTimeout(n),t.classList.remove("diff-walkthrough-target"),t.offsetWidth,t.classList.add("diff-walkthrough-target");const s=window.setTimeout(()=>{t.classList.remove("diff-walkthrough-target"),pi.delete(t)},1700);pi.set(t,s)}function hb(t){const n=CSS.escape(t),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 d=null;for(const m of l){if(!Yn(m))continue;const g=m.querySelector(s);if(g&&Yn(g)){d=g;break}}if(d??=Array.from(document.querySelectorAll(s)).find(Yn)??null,!d)return;const c=rf(d);if(!c){d.scrollIntoView({block:"start",behavior:"smooth"}),Xa(d);return}const h=d.getBoundingClientRect().top-c.getBoundingClientRect().top+c.scrollTop;c.scrollTo({top:Math.max(0,h),behavior:"instant"}),Xa(d)}function xn(t){const n=CSS.escape(t.filePath),s=typeof t.sectionIndex=="number"?String(t.sectionIndex):null,l=typeof t.hunkIndex=="number"?String(t.hunkIndex):null,d=t.sectionFingerprint?CSS.escape(t.sectionFingerprint):null,c=t.hunkFingerprint?CSS.escape(t.hunkFingerprint):null,h=[s!==null&&d?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${d}"]`:null,s!==null&&d?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${d}"]`: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&&c?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"][data-diff-hunk-fingerprint="${c}"]`:null,l!==null?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"]`:null,`[data-diff-file-path="${n}"]`].filter(I=>!!I),m=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let g=null;for(const I of m)if(Yn(I)){for(const D of h){const B=I.querySelector(D);if(B&&Yn(B)){g=B;break}}if(g)break}if(g??=h.flatMap(I=>Array.from(document.querySelectorAll(I))).find(Yn)??null,!g){hb(t.filePath);return}const p=rf(g);if(!p){g.scrollIntoView({block:"center",behavior:"smooth"}),Xa(g);return}const f=g.getBoundingClientRect(),k=p.getBoundingClientRect(),N=f.top-k.top+p.scrollTop-Math.max(24,(p.clientHeight-f.height)/2);p.scrollTo({top:Math.max(0,N),behavior:"instant"}),Xa(g)}const nf=1,sf=8;function mb(t){return Math.min(sf,Math.max(nf,t))}function af({resetKey:t,onZoomChange:n,onDoubleTap:s,children:l}){const d=o.useRef(null),[c,h]=o.useState({scale:1,x:0,y:0}),[m,g]=o.useState(!1),p=o.useRef(null),f=o.useRef(new Set),k=o.useRef(!1),y=o.useRef(null),N=o.useRef(0),I=o.useRef(c);I.current=c,o.useEffect(()=>{h({scale:1,x:0,y:0})},[t]);const D=o.useCallback((L,P,U)=>{const F=d.current;if(!F)return{x:P,y:U};const a=F.firstElementChild instanceof HTMLElement?F.firstElementChild:null,w=a?.clientWidth||F.clientWidth,O=a?.clientHeight||F.clientHeight,j=Math.max(0,(w*L-F.clientWidth)/2),X=Math.max(0,(O*L-F.clientHeight)/2);return{x:Math.min(j,Math.max(-j,P)),y:Math.min(X,Math.max(-X,U))}},[]),B=o.useCallback((L,P,U)=>{h(F=>{const a=mb(L),w=d.current;if(!w||a===1)return{scale:a,x:0,y:0};const O=w.getBoundingClientRect(),j=(P??O.left+O.width/2)-O.left-O.width/2,X=(U??O.top+O.height/2)-O.top-O.height/2,ne=a/F.scale,se=j-(j-F.x)*ne,fe=X-(X-F.y)*ne;return{scale:a,...D(a,se,fe)}})},[D]),E=o.useCallback((L,P)=>{g(!0),I.current.scale>1?h({scale:1,x:0,y:0}):B(2.5,L,P),window.setTimeout(()=>g(!1),220)},[B]);o.useEffect(()=>{const L=d.current;if(!L)return;const P=a=>{if(a.pointerType==="mouse"&&a.button!==0)return;const w=f.current.size===0;if(f.current.add(a.pointerId),w){const O=Date.now(),j=y.current;if(j&&O-j.time<350&&Math.hypot(a.clientX-j.x,a.clientY-j.y)<24){y.current=null,N.current=O,s?.(),E(a.clientX,a.clientY);return}}if(f.current.size>1){k.current=!0,p.current=null;return}if(!(I.current.scale<=1)){a.preventDefault(),p.current={pointerId:a.pointerId,startX:a.clientX,startY:a.clientY,originX:I.current.x,originY:I.current.y,moved:!1};try{L.setPointerCapture?.(a.pointerId)}catch{}g(!1)}},U=a=>{const w=p.current;if(!w||w.pointerId!==a.pointerId)return;const O=a.clientX-w.startX,j=a.clientY-w.startY;if(!w.moved){if(Math.hypot(O,j)<6)return;w.moved=!0}a.stopPropagation(),a.preventDefault(),h(X=>({...X,...D(X.scale,w.originX+O,w.originY+j)}))},F=a=>{const w=p.current,O=w?.pointerId===a.pointerId&&w.moved;if(w?.pointerId===a.pointerId){w.moved&&a.stopPropagation(),p.current=null;try{L.releasePointerCapture?.(a.pointerId)}catch{}}f.current.delete(a.pointerId)&&f.current.size===0&&(!k.current&&!O&&(y.current={time:Date.now(),x:a.clientX,y:a.clientY}),k.current=!1)};return L.addEventListener("pointerdown",P,{capture:!0,passive:!1}),window.addEventListener("pointermove",U,{capture:!0,passive:!1}),window.addEventListener("pointerup",F,{capture:!0}),window.addEventListener("pointercancel",F,{capture:!0}),()=>{L.removeEventListener("pointerdown",P,{capture:!0}),window.removeEventListener("pointermove",U,{capture:!0}),window.removeEventListener("pointerup",F,{capture:!0}),window.removeEventListener("pointercancel",F,{capture:!0})}},[D,s,E]),_d({onPinch:({offset:[L],origin:[P,U]})=>{g(!1),B(L,P,U)},onWheel:({event:L,delta:[P,U],ctrlKey:F})=>{if(F){L.preventDefault(),L.stopPropagation(),g(!1),B(I.current.scale*(1-U*.01),L.clientX,L.clientY);return}I.current.scale<=1||(L.preventDefault(),L.stopPropagation(),g(!1),h(a=>({...a,...D(a.scale,a.x-P,a.y-U)})))}},{target:d,eventOptions:{passive:!1},pinch:{scaleBounds:{min:nf,max:sf},from:()=>[I.current.scale,0],rubberband:!0}});const $=c.scale>1;return o.useEffect(()=>{n?.($)},[n,$]),e.jsx("div",{ref:d,"data-sidebar-gesture-ignore":$?"":void 0,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden",style:{cursor:$?"grab":"zoom-in"},onDoubleClick:L=>{L.stopPropagation(),!(Date.now()-N.current<500)&&(s?.(),E(L.clientX,L.clientY))},children:l({scale:c.scale,zoomed:$,animateTransform:m,transformStyle:{transform:`translate3d(${c.x}px, ${c.y}px, 0) scale(${c.scale})`,transformOrigin:"center center",transition:m?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none",willChange:"transform"},vectorTransformStyle:{transform:`translate3d(${c.x}px, ${c.y}px, 0)`,transformOrigin:"center center",transition:m?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}})})}function of({src:t,alt:n,vector:s,onLoad:l,onError:d,onZoomChange:c,onDoubleTap:h}){const m=Ja(t,d),[g,p]=o.useState(null),f=s??Za(t);return o.useEffect(()=>{p(null)},[t]),e.jsx(af,{resetKey:t,onZoomChange:c,onDoubleTap:h,children:({transformStyle:k,vectorTransformStyle:y,scale:N,animateTransform:I})=>{const D=e.jsx("img",{src:m,alt:n,draggable:!1,className:"max-h-full max-w-full touch-none select-none rounded border border-border/15 bg-surface object-contain shadow-sm",style:f&&g?{position:"absolute",left:"50%",top:"50%",width:g.width*N,height:g.height*N,maxWidth:"none",maxHeight:"none",transform:"translate3d(-50%, -50%, 0)",transition:I?"width 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}:g?{...k,width:g.width,height:g.height}:f?y:k,onLoad:B=>{const E=B.currentTarget,$=E.parentElement;if($&&E.naturalWidth>0&&E.naturalHeight>0){const L=Math.max(1,$.clientWidth-2),P=Math.max(1,$.clientHeight-2),U=Math.min(L/E.naturalWidth,P/E.naturalHeight),F=f?U:Math.min(U,1);p({width:Math.max(1,Math.round(E.naturalWidth*F)),height:Math.max(1,Math.round(E.naturalHeight*F))})}l(B)},onError:d});return!f||!g?D: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:D})}})}function pb({svg:t,title:n,scale:s,vectorTransformStyle:l}){const d=o.useRef(null);return o.useLayoutEffect(()=>{const c=d.current,h=c?.querySelector("svg");if(!c||!h)return;const m=()=>{const f=h.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number)??[];let k=f[2],y=f[3];if((!Number.isFinite(k)||!Number.isFinite(y)||k<=0||y<=0)&&(k=Number(h.getAttribute("width")),y=Number(h.getAttribute("height"))),!Number.isFinite(k)||!Number.isFinite(y)||k<=0||y<=0)return;const N=Math.max(1,c.clientWidth-24),I=Math.max(1,c.clientHeight-24),D=Math.min(N/k,I/y,1);h.style.width=`${Math.max(1,Math.floor(k*D*s))}px`,h.style.height=`${Math.max(1,Math.floor(y*D*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(c),()=>g?.disconnect()},[s,t,l]),e.jsx("div",{ref:d,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:t}})}function gb({svg:t,title:n,onZoomChange:s,onDoubleTap:l}){return e.jsx(af,{resetKey:t,onZoomChange:s,onDoubleTap:l,children:({vectorTransformStyle:d,scale:c})=>e.jsx(pb,{svg:t,title:n,scale:c,vectorTransformStyle:d})})}let bb=0,xb=0,vb=0,yb=0,wb=0;function gi(t,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:t==="still_active"?"warn":"info",message:`FILE_PREVIEW_LOADING ${t}`,data:{ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function et(t,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:t==="error"||t==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${t}`,data:{seq:++xb,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function _a(t,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${t}`,data:{seq:++yb,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function kb(){return`diff-ui-${Date.now().toString(36)}-${(++wb).toString(36)}`}function Sb(t){return t instanceof Element?t.closest("[data-diff-selection-path]"):null}function jb(t){const n=t.target instanceof HTMLElement?t.target:null;return{eventType:t.type,button:t.button,pointerType:t instanceof globalThis.PointerEvent?t.pointerType:void 0,targetTag:n?.tagName,targetClass:n?.className,targetText:n?.textContent?.slice(0,80)}}function Oi({onReviewReference:t,filePath:n,onInsertReference:s,onInsertText:l,onInsertFeature:d,onReferenceCopied:c,onClose:h,onDirectoryLinkOpen:m,isMobile:g,markdownOutlineOpen:p,markdownOutlineCloseSignal:f,onOpenMarkdownOutline:k,onCloseMarkdownOutline:y,markdownImageLightboxOpen:N,markdownImageLightboxCloseSignal:I,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:B,lineRange:E,onLineRangeChange:$,insertedReferenceKey:L,copiedReferenceKey:P,scrollToLine:U,onScrollToLineHandled:F}){const{t:a}=yt(),w=te(T=>T.rootPath),O=te(T=>T.selectFile),[j,X]=o.useState({kind:"idle"}),[ne,se]=o.useState("schematic"),[fe,G]=o.useState(null),J=o.useRef(null),[M,_]=o.useState(null),K=o.useRef(new Map),re=o.useRef(null),[oe,he]=o.useState(null),[me,je]=o.useState(()=>md()),[C,Z]=o.useState(()=>rd(w,n)),ue=o.useRef(null),[Ee,Ge]=o.useState(!1),[De,le]=o.useState(null),[ae,S]=o.useState(0),[V,ye]=o.useState([]),[be,Oe]=o.useState(null),ce=o.useRef(null),Je=o.useRef(n),[Le,W]=o.useState(null),[q,Se]=o.useState({status:"idle"}),[Re,lt]=o.useState(!1),[Qe,vn]=o.useState(""),[ht,lr]=o.useState([]),[Xt,yn]=o.useState(0),wt=o.useRef(null),Ht=Vd(c),qr=Qi(w,n);o.useEffect(()=>{if(Je.current===n)return;Je.current=n;const T=n&&w&&!n.startsWith("/")?`${w}/${n}`:n;if(ce.current===T){ce.current=null;return}ce.current=null,ye([]),Oe(null),lt(!1),vn("")},[n,w]);const cr=n?w&&!n.startsWith("/")?`${w}/${n}`:n:null,Jt=te(T=>cr?(T.fileChangeVersions.get(cr)??0)+T.fileWatchEpoch:T.fileWatchEpoch),At=o.useRef(null),dr=o.useRef(null),[zt,Ts]=o.useState(0),wn=o.useCallback(()=>Ts(T=>T+1),[]);o.useEffect(()=>{const T=J.current;return J.current=null,G(null),T&&URL.revokeObjectURL(T.objectUrl),()=>{const z=J.current;J.current=null,z&&URL.revokeObjectURL(z.objectUrl)}},[cr,Jt,zt]),o.useEffect(()=>{if(!n){At.current=null,X({kind:"idle"});return}const T=w&&!n.startsWith("/")?`${w}/${n}`:n,z=new AbortController,ie=++bb,xe=`right-sidebar-file-preview:${ie}`,Ue=performance.now();let $e=!1;const ze=(Q,Be={})=>{$e||($e=!0,gi("end",{loadingId:ie,reason:Q,durationMs:Math.round(performance.now()-Ue),filePath:n,fullPath:T,rootPath:w,...Be}))};let _e=null;const nt=gh(T),at=nt?T.toLowerCase().endsWith(".kicad_pcb")?ne==="schematic"?"pcb-front":ne:"schematic":ne,tr=!nt&&Ui(T),gr=!nt&&!tr&&bh(T),Cn=!nt&&!tr&&!gr&&Td(T),Zr=vs(T),ts=bs(T),rr=nt?"eda":tr?"image":gr?"model3d":Cn?"video":"text",rs=At.current!==T;if(At.current=T,rs){gi("start",{loadingId:ie,filePath:n,fullPath:T,rootPath:w,mode:rr,externalVersion:Jt}),Se({status:"idle"}),X({kind:"loading",mode:rr}),dr.current=null;const Q=Nd(w,n);$(Q?.lineRange??null),je(Zr?md():"source"),Z(ts?rd(w,n):"source"),nt&&se(xh(T))}rs||X(Q=>Q.kind==="error"?{kind:"loading",mode:rr}:Q);const en=window.setTimeout(()=>{$e||z.signal.aborted||gi("still_active",{loadingId:ie,filePath:n,fullPath:T,rootPath:w,mode:rr,durationMs:Math.round(performance.now()-Ue),isPathChange:rs})},3e3),Pr=window.setTimeout(()=>{if($e||z.signal.aborted)return;const Q=nt?a("rightSidebar.edaTimeout"):gr?a("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";z.abort(new DOMException(Q,"TimeoutError")),X({kind:"error",message:Q}),ze("stuck_timeout",{error:Q})},nt?vh+5e3:gr?yh+5e3:wh(T)?35e3:og);if(nt){const Q=at==="pcb-3d"?J.current:null;Q?(X(Q),ze("eda_3d_client_cache_hit",{bytes:Q.meta.size,view:Q.view,mimeType:Q.meta.mimeType})):kh(T,at,z.signal,"view_file",xe).then(Be=>{if(z.signal.aborted)return;_e=URL.createObjectURL(Be.blob);const Tt={kind:"eda",sourcePath:Be.path||T,objectUrl:_e,view:Be.view,meta:{size:Be.size,mimeType:Be.mimeType,modified:Be.modified}};if(Be.view==="pcb-3d"){const br=J.current;br&&br.objectUrl!==_e&&URL.revokeObjectURL(br.objectUrl),J.current=Tt,G(Tt),_e=null}X(Tt),ze("eda_loaded",{bytes:Be.size,view:Be.view,mimeType:Be.mimeType})}).catch(Be=>{z.signal.aborted||(X({kind:"error",message:Be instanceof Error&&/timed out/i.test(Be.message)?a("rightSidebar.edaTimeout"):Be instanceof Error?Be.message:a("rightSidebar.edaLoadFailed")}),ze("error",{error:Be instanceof Error?Be.message:String(Be)}))})}else if(tr)Sh(T,z.signal,"view_file",xe).then(Q=>{_e=URL.createObjectURL(Q.blob),X({kind:"image",objectUrl:_e,meta:{size:Q.size,mimeType:Q.mimeType,modified:Q.modified}}),ze("image_loaded",{bytes:Q.size,mimeType:Q.mimeType})}).catch(Q=>{z.signal.aborted||(X({kind:"error",message:Q instanceof Error?Q.message:a("rightSidebar.imageLoadFailed")}),ze("error",{error:Q instanceof Error?Q.message:String(Q)}))});else if(gr)jh(T,z.signal,"view_file",xe).then(Q=>{z.signal.aborted||(_e=URL.createObjectURL(Q.blob),X({kind:"model3d",sourcePath:Q.path||T,objectUrl:_e,ext:Q.ext,meta:{size:Q.size,mimeType:Q.mimeType,modified:Q.modified}}),ze("model3d_loaded",{bytes:Q.size,ext:Q.ext}))}).catch(Q=>{z.signal.aborted||(X({kind:"error",message:Q instanceof Error&&(Q.name==="TimeoutError"||/timed out/i.test(Q.message))?a("rightSidebar.model3dTimeout"):Q instanceof Error?Q.message:a("rightSidebar.model3dLoadFailed")}),ze("error",{error:Q instanceof Error?Q.message:String(Q)}))});else if(Cn){const Q=Rh(T)??"",Be=Id(T);X(Tt=>Tt.kind==="video"&&Tt.url===Be?Tt:{kind:"video",url:Be,meta:{size:null,mimeType:Q,modified:null}}),ze("video_ready",{mimeType:Q})}else Oc(T,z.signal,"view_file",xe).then(Q=>{if(!z.signal.aborted){if(Q.binary){X({kind:"binary"});return}X({kind:"text",content:Q.content,sourcePath:Q.path||T,meta:{size:Q.size,truncated:Q.truncated}}),ze("text_loaded",{bytes:Q.size,truncated:!!Q.truncated})}}).catch(Q=>{z.signal.aborted||(X({kind:"error",message:Q instanceof Error?Q.message:"Failed to read file"}),ze("error",{error:Q instanceof Error?Q.message:String(Q)}))});return()=>{z.abort(),bt(xe),window.clearTimeout(en),window.clearTimeout(Pr),_e&&URL.revokeObjectURL(_e),ze("cleanup")}},[n,w,Jt,zt,$,a,ne]),o.useEffect(()=>{if(j.kind!=="model3d"||!n){_(null);return}let T=!1;const z=n.lastIndexOf("/"),ie=z>=0?n.slice(z+1):n,xe=z>=0?n.slice(0,z):"",Ue=xe.lastIndexOf("/"),$e=Ue>=0?xe.slice(0,Ue):"",ze=ie.replace(/\.(stl|glb|gltf)$/i,""),_e=`${$e?`${$e}/`:""}features/${ze}.json`;return Oc(_e).then(nt=>{if(!T)try{const at=JSON.parse(nt.content);_(at.version===1&&Array.isArray(at.features)&&at.features.length>0?at.features:null)}catch{_(null)}}).catch(()=>{T||_(null)}),()=>{T=!0}},[j,n]),o.useEffect(()=>{if(j.kind!=="text"){W(null);return}const T=w&&n&&!n.startsWith("/")?`${w}/${n}`:n,z=Wd(T),ie=j.content,xe=vs(T??"")&&me==="preview",Ue=bs(T??"")&&C==="preview";if(!z||xe||Ue||!Gd(ie)){W(null);return}let $e=!1;const ze=_e=>{if($e||!_e.registered(z)){$e||W(null);return}try{W(Kd(_e,ie,z))}catch{W(null)}};return De?ze(De):(W(null),qd().then(_e=>{$e||(le(_e),ze(_e))}).catch(()=>{})),()=>{$e=!0}},[j,De,n,w,me,C]),o.useLayoutEffect(()=>{if(!qr||j.kind!=="text")return;const T=`${qr}:${me}:${C}`;if(dr.current===T)return;const z=Nd(w,n);if(dr.current=T,!z)return;const ie=requestAnimationFrame(()=>{const xe=re.current;if(!xe)return;const Ue=me==="preview"?z.markdownTop??z.top:z.top;xe.scrollTo({top:Math.max(0,Ue??0),left:Math.max(0,z.left??0)}),S(me==="preview"?Math.max(0,Ue??0):0)});return()=>cancelAnimationFrame(ie)},[n,me,C,j.kind,qr,w]),o.useEffect(()=>{qr&&ii(w,n,{lineRange:E})},[n,E,qr,w]),o.useEffect(()=>{if(U==null||j.kind!=="text")return;he(null),$({start:U,end:U});const T=U,z=requestAnimationFrame(()=>{const ie=K.current.get(T);ie&&ie.scrollIntoView({block:"center"}),F?.()});return()=>cancelAnimationFrame(z)},[U,j,$,F]);const Xn=o.useCallback(T=>{const z=re.current;if(!z)return!1;const ie=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(T):T.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),xe=z.querySelector(`#${ie}`);return xe?(xe.scrollIntoView({block:"start"}),!0):!1},[]);o.useEffect(()=>{const T=w&&n&&!n.startsWith("/")?`${w}/${n}`:n,z=j.kind==="text"&&vs(T??"")&&me==="preview";if(!be||!z)return;const ie=requestAnimationFrame(()=>{Xn(be)&&Oe(null)});return()=>cancelAnimationFrame(ie)},[n,Xn,me,be,j,w]),o.useLayoutEffect(()=>{const T=re.current;if(!T||!E){he(null);return}if(oe)return;const z=j.kind==="image"||j.kind==="loading"&&j.mode==="image",ie=w&&n&&!n.startsWith("/")?`${w}/${n}`:n,xe=j.kind==="text"&&vs(ie??"")&&me==="preview",Ue=j.kind==="text"&&bs(ie??"")&&C==="preview";if(j.kind!=="text"||z||xe||Ue){he(null);return}const $e=()=>{const _e=K.current.get(E.end);if(!_e||!T){he(null);return}const nt=_e.offsetTop+_e.offsetHeight/2,at=T.scrollLeft+Math.max(8,T.clientWidth-120);he({top:nt,left:at})};$e();const ze=new ResizeObserver(()=>$e());return ze.observe(T),()=>ze.disconnect()},[E,oe,j,me,C,n,w,Le]);const Wt=j.kind==="text"&&!(bs(cr??"")&&C==="preview")&&!cr?.toLowerCase().endsWith(".csv")&&!cr?.toLowerCase().endsWith(".kicad_pro")&&!cr?.toLowerCase().endsWith(".kicad_prl"),Kr=o.useCallback(()=>{lt(!1),vn(""),lr([]),yn(0),Aa()},[]),kt=o.useCallback(()=>{Wt&&(lt(!0),requestAnimationFrame(()=>{wt.current?.focus(),wt.current?.select()}))},[Wt]),Nr=o.useCallback(T=>{yn(z=>ht.length===0?0:(z+T+ht.length)%ht.length)},[ht.length]);if(o.useEffect(()=>{const T=z=>{const ie=zp(z);if(ie==="open"&&Wt){z.preventDefault(),kt();return}Re&&(ie==="close"?(z.preventDefault(),Kr()):(ie==="next"||ie==="previous")&&(z.preventDefault(),Nr(ie==="previous"?-1:1)))};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[Kr,Re,Nr,kt,Wt]),o.useLayoutEffect(()=>{if(Aa(),!Re||!Qe.trim()||!re.current){lr([]),yn(0);return}const T=Gp(re.current,Qe);return lr(T),yn(0),ad(T,0),od(T[0]),Aa},[Re,Qe,Le,me,j]),o.useEffect(()=>{Re&&(ad(ht,Xt),od(ht[Xt]))},[Xt,ht,Re]),o.useEffect(()=>Aa,[]),!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:a("rightSidebar.selectFilePrompt")});const Ie=w&&!n.startsWith("/")?`${w}/${n}`:n,Gt=Ha(Ie,w),Mr=Fd(Ie,w),ur=j.kind==="text"&&j.content?j.content.split(`
|
|
1654
|
-
`):[],to=Math.max(2,String(ur.length).length)+1,St=j.kind==="text"||j.kind==="image"||j.kind==="model3d"||j.kind==="video"||j.kind==="eda"?j.meta:null,Is=vs(Ie),$t=Ie.toLowerCase().endsWith(".csv"),Fs=Ie.toLowerCase().endsWith(".kicad_pro"),Qt=Ie.toLowerCase().endsWith(".kicad_prl"),Vr=j.kind==="text"&&Is&&me==="preview",Jn=bs(Ie),fr=j.kind==="text"&&Jn&&C==="preview",ro=j.kind==="image"||j.kind==="loading"&&j.mode==="image",jt=j.kind==="model3d"||j.kind==="loading"&&j.mode==="model3d",Yr=j.kind==="video"||j.kind==="loading"&&j.mode==="video",Qn=j.kind==="eda"||j.kind==="loading"&&j.mode==="eda",Zn=j.kind==="text"?j.sourcePath:Ie,$r=Jh(Zn,w,E),Er=(()=>{if(!E||j.kind!=="text"||ur.length===0)return $r;const T=[];for(let xe=E.start;xe<=E.end;xe+=1)T.push(`${xe} ${ur[xe-1]??""}`);const z=wu(Ie).replace(/^\./,""),ie="```";return`${$r}
|
|
1655
|
-
${ie}${z}
|
|
1656
|
-
${T.join(`
|
|
1657
|
-
`)}
|
|
1658
|
-
${ie}
|
|
1659
|
-
`})(),Lr=`path:${Ie}`,Pt=E?`path:${Ie}:${E.start}-${E.end}`:Lr,Xr=L===Lr,Jr=L===Pt,Ds=P===Lr,Ar=P===Pt,hr=Jr||Ar,mr=E?E.start===E.end?`L${E.start}`:`L${E.start}-${E.end}`:null,kn=T=>{const z=re.current;if(!z)return;const ie=z.getBoundingClientRect(),xe=T.currentTarget.getBoundingClientRect(),Ue=T.clientX||xe.left+xe.width/2,ze=(T.clientY||xe.top+xe.height/2)-ie.top+z.scrollTop,_e=g?116:132,nt=z.scrollLeft+Math.max(8,z.clientWidth-_e),at=Math.min(Math.max(8,Ue-ie.left+z.scrollLeft+10),nt);he({top:ze,left:at})},Sn=(T,z)=>{Bi()||(kn(T),$(ie=>{const xe=_i(ie,z,z);return xe||he(null),xe}))},pr=(T,z,ie)=>{kn(T),$(xe=>{const Ue=_i(xe,z,ie);return Ue||he(null),Ue})},Zt=(T,z,ie,xe)=>{xe==="end"&&kn(T),$({start:z,end:ie})},Me=T=>{const{scrollTop:z,scrollLeft:ie}=T.currentTarget;S(z),ii(w,n,{top:z,left:ie,markdownTop:z})},er=T=>{if(T.directory){m?.(T.path);return}if(T.path===Ie||j.kind==="text"&&T.path===j.sourcePath){T.fragment&&Xn(T.fragment);return}ye(z=>[...z,Ie]),ce.current=T.path,Oe(T.fragment),$(null),O(T.path)},Qr=()=>{const T=V[V.length-1];T&&(ye(z=>z.slice(0,-1)),ce.current=T,Oe(null),$(null),O(T))},es=T=>{const{scrollTop:z,scrollLeft:ie}=T.currentTarget;ii(w,n,{top:z,left:ie})},jn=()=>{if(t){t(Er,Pt);return}E&&l(Er,Pt)},Rn=async()=>{if(!(!Ie||q.status==="pending")&&!(j.kind==="loading"||j.kind==="error")){Se({status:"pending"});try{await Uh(Ie),Se({status:"idle"})}catch(T){Se({status:"error",message:T instanceof Error?T.message:a("rightSidebar.downloadFailed")})}}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[Ht.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${g&&(Vr||fr)?"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":a("rightSidebar.backToFileList"),title:a("rightSidebar.backToFileList"),children:e.jsx(Od,{size:16})}),V.length>0&&e.jsxs("button",{type:"button",onClick:Qr,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":a("rightSidebar.backToPreviousPreview"),title:a("rightSidebar.backToPreviousPreview"),children:[e.jsx(Ns,{size:15}),!g&&e.jsx("span",{className:"text-[11px] font-medium",children:a("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:Ie,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Gt.name}),Gt.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Gt.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Wt&&e.jsx("button",{type:"button",onClick:Re?Kr:kt,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 ${Re?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":a("rightSidebar.findInFile"),title:`${a("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(Vn,{size:14})}),Is&&j.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{p&&y?.(),je(T=>{const z=T==="preview"?"source":"preview";return xt(au,z),z}),$(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":a(me==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:a(me==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:g?me==="preview"?e.jsx(Si,{size:14}):e.jsx(ki,{size:14}):a(me==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),Jn&&j.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{Z(T=>{const z=T==="preview"?"source":"preview";return gp(w,n,z),z}),$(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":a(C==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:a(C==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:g?C==="preview"?e.jsx(Si,{size:14}):e.jsx(ki,{size:14}):a(C==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),fr&&e.jsx("button",{type:"button",onClick:()=>{ue.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":a(Ee?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:a(Ee?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(Ud,{size:15})}),!g&&e.jsx("button",{type:"button",onClick:()=>s(Ie,Lr),...Ht(Mr,Lr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${Xr||Ds?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:a("rightSidebar.insertReference",{reference:Mr}),children:a(Ds?"rightSidebar.copied":Xr?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Mr)},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:a("rightSidebar.copyReference",{reference:Mr}),"aria-label":a("rightSidebar.copyFileRef"),children:e.jsx(Ch,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{Rn()},disabled:q.status==="pending"||j.kind==="loading"||j.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:q.status==="error"?q.message??a("rightSidebar.downloadFailed"):a("rightSidebar.downloadFile"),"aria-label":a("rightSidebar.downloadFile"),children:q.status==="pending"?e.jsx(vt,{size:13,className:"animate-spin"}):e.jsx(Qh,{size:14})})]})]}),Re&&Wt&&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(Vn,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:wt,type:"search",value:Qe,onChange:T=>vn(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),Nr(T.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:a("rightSidebar.findInFilePlaceholder"),"aria-label":a("rightSidebar.findInFile")}),e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:ht.length>0?`${Xt+1}/${ht.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>Nr(-1),disabled:ht.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":a("rightSidebar.previousSearchMatch"),title:`${a("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:e.jsx(Dd,{size:13})}),e.jsx("button",{type:"button",onClick:()=>Nr(1),disabled:ht.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":a("rightSidebar.nextSearchMatch"),title:`${a("rightSidebar.nextSearchMatch")} (Enter)`,children:e.jsx(Zh,{size:13})}),e.jsx("button",{type:"button",onClick:Kr,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":a("rightSidebar.closeFileSearch"),title:`${a("rightSidebar.closeFileSearch")} (Esc)`,children:e.jsx(Ut,{size:13})})]}),St&&!(g&&(Vr||fr))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[St.size!==null&&e.jsx("span",{children:a("rightSidebar.byteCount",{count:St.size.toLocaleString()})}),"truncated"in St&&St.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:a("rightSidebar.previewTruncated")}),"mimeType"in St&&e.jsx("span",{children:St.mimeType}),"dimensions"in j&&j.dimensions&&e.jsxs("span",{children:[j.dimensions.width," × ",j.dimensions.height]})]}),!(g&&(Vr||fr))&&!jt&&j.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:Qn?a("rightSidebar.edaPickHint"):$t?a("rightSidebar.csvTablePreview"):Fs||Qt?a("rightSidebar.kicadProjectPickHint"):Yr?a("rightSidebar.videoPreviewHint"):ro?a("rightSidebar.imagePreviewHint"):Vr?E?a("rightSidebar.selectedLineHint",{lineLabel:mr??""}):a("rightSidebar.markdownPreviewHint"):fr?a("rightSidebar.htmlPreviewHint"):E?a("rightSidebar.selectedLineHint",{lineLabel:mr??""}):a("rightSidebar.multiLineHint")})})]}),j.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:j.mode==="eda"?a("rightSidebar.edaLoading"):j.mode==="image"?a("rightSidebar.loadingImage"):j.mode==="model3d"?a("rightSidebar.model3dLoading"):j.mode==="video"?a("rightSidebar.loadingVideo"):"Loading file…"}):j.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:j.message}),e.jsx("button",{type:"button",onClick:wn,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:a("common.retry")})]}):j.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:a("rightSidebar.binaryPreviewHint")})}):j.kind==="image"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:j.meta.mimeType==="image/svg+xml"?e.jsx(eu,{blobUrl:j.objectUrl,filePath:Ie,viewLabel:"SVG 文件",onInsertAnnotation:d}):e.jsx(of,{src:j.objectUrl,alt:Gt.name,vector:!1,onLoad:T=>{const z=T.currentTarget;X(ie=>ie.kind==="image"?{...ie,dimensions:{width:z.naturalWidth,height:z.naturalHeight}}:ie)},onError:()=>X({kind:"error",message:a("rightSidebar.imageLoadFailed")})})}):j.kind==="video"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:e.jsx(wp,{url:j.url,onLoadError:()=>X({kind:"error",message:a("rightSidebar.videoLoadFailed")})})}):j.kind==="eda"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Mp,{blobUrl:j.objectUrl,filePath:j.sourcePath,view:j.view,board:Ie.toLowerCase().endsWith(".kicad_pcb"),onViewChange:se,onInsertAnnotation:t??d,onRefresh:wn,interactive3d:fe?e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:a("rightSidebar.model3dLoading")}),children:e.jsx(hd,{blobUrl:fe.objectUrl,ext:".glb",fileName:Gt.name,filePath:fe.sourcePath,features:null,onInsertFeature:t??d,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:T=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(T)?T:"PCB板体/铜箔/丝印",active:j.view==="pcb-3d"})}):void 0})}):j.kind==="model3d"?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:a("rightSidebar.model3dLoading")}),children:e.jsx(hd,{blobUrl:j.objectUrl,ext:j.ext,fileName:Gt.name,filePath:j.sourcePath,features:M,onInsertFeature:t??d,onRefresh:wn})})}):j.kind==="text"&&$t?e.jsx(Lp,{content:j.content,filePath:Ie,onInsertAnnotation:t??d},Ie):j.kind==="text"&&(Fs||Qt)?e.jsx(Tp,{content:j.content,filePath:Ie,localState:Qt,onInsertAnnotation:t??d},Ie):Vr?e.jsxs("div",{ref:re,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:Me,style:{touchAction:"pan-x pan-y"},children:[e.jsx(Yu,{content:j.content,filePath:j.sourcePath,rootPath:w,lineRange:E,onLineRangeClick:pr,onLineRangeDrag:Zt,scrollTop:ae,outlineOpen:p,outlineCloseSignal:f,onOutlineOpen:k,onOutlineClose:y,lightboxOpen:N,lightboxCloseSignal:I,onLightboxOpen:D,onLightboxClose:B,onLocalLinkOpen:er}),E&&oe&&e.jsxs("button",{type:"button",onClick:jn,...Ht(Er,Pt),style:{top:oe.top,left:oe.left,transform:"translateY(-50%)"},className:Md(g,hr),title:`Insert markdown reference: ${$r}`,children:[e.jsx(za,{size:g?13:11}),Ar?a("rightSidebar.copied"):Jr?a("rightSidebar.inserted"):a("rightSidebar.insertLineRef",{lineLabel:mr??""})]})]}):fr?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Hp,{ref:ue,src:Nh(Ie),title:`${Gt.name} preview`,exitFullscreenLabel:a("rightSidebar.htmlFullscreenExit"),onFullscreenChange:Ge},`${Ie}:${Jt}:${zt}`)}):j.kind==="text"?e.jsxs("div",{ref:re,onScroll:es,className:`${Wi} 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:[ur.length>0?e.jsx("div",{className:"min-w-full",children:ur.map((T,z)=>{const ie=z+1,xe=!!(E&&ie>=E.start&&ie<=E.end),Ue=Le&&Le.length===ur.length?Le[z]:null;return e.jsxs("div",{ref:$e=>{$e?K.current.set(ie,$e):K.current.delete(ie)},role:"button","data-file-preview-line":ie,tabIndex:0,onClick:$e=>Sn($e,ie),onKeyDown:$e=>{$e.key!=="Enter"&&$e.key!==" "||($e.preventDefault(),Sn($e,ie))},style:{gridTemplateColumns:`${to}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${xe?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Mr}:${ie}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${xe?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:ie}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Ue??(T||" ")})]},z)})}):"Empty file.",E&&oe&&e.jsxs("button",{type:"button",onClick:jn,...Ht(Er,Pt),style:{top:oe.top,left:oe.left,transform:"translateY(-50%)"},className:Md(g,hr),title:`Insert code reference: ${$r}`,children:[e.jsx(za,{size:g?13:11}),Ar?a("rightSidebar.copied"):Jr?a("rightSidebar.inserted"):a("rightSidebar.insertLineRef",{lineLabel:mr??""})]})]}):null]})}function Rb({isOpen:t,drawerWidthPx:n,onClose:s,onOpen:l,push:d,pinned:c=!1,onTogglePinned:h,rightSidebarFilePreviewOpen:m=!1,rightSidebarFilePreviewCloseSignal:g,onOpenRightSidebarFilePreview:p,onCloseRightSidebarFilePreview:f,rightSidebarRepoPickerOpen:k=!1,rightSidebarRepoPickerCloseSignal:y,onOpenRightSidebarRepoPicker:N,onCloseRightSidebarRepoPicker:I,markdownOutlineOpen:D=!1,markdownOutlineCloseSignal:B,onOpenMarkdownOutline:E,onCloseMarkdownOutline:$,markdownImageLightboxOpen:L=!1,markdownImageLightboxCloseSignal:P,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:F}){const{t:a,locale:w}=yt(),[O,j]=o.useState(""),[X,ne]=o.useState(null),se=te(r=>r.rightSearchOpen),fe=te(r=>r.setRightSearchOpen),G=te(r=>r.rightSidebarLayoutPreference),J=te(r=>r.setRightSidebarLayoutPreference),[M,_]=o.useState(()=>bg()),[K,re]=o.useState("."),[oe,he]=o.useState(""),[me,je]=o.useState(!1),[C,Z]=o.useState(!1),[ue,Ee]=o.useState(!1),[Ge,De]=o.useState(!1),le=o.useDeferredValue(O),[ae,S]=o.useState(null),[V,ye]=o.useState([]),[be,Oe]=o.useState([]),[ce,Je]=o.useState(null),[Le,W]=o.useState(null),[q,Se]=o.useState(null),[Re,lt]=o.useState(null),[Qe,vn]=o.useState(()=>tt(ld,ks)??!1),[ht,lr]=o.useState(()=>tt(cd,ks)??!1),[Xt,yn]=o.useState(()=>tt(dd,ks)??!1),[wt,Ht]=o.useState(()=>tt(ti,fg)??""),[qr,cr]=o.useState(0),[Jt,At]=o.useState(!1),[dr,zt]=o.useState(!1),Ts=o.useRef(null),wn=o.useRef(null),[Xn,Wt]=o.useState(!1),[Kr,kt]=o.useState(null),[Nr,Ie]=o.useState(null),[Gt,Mr]=o.useState(()=>gd(Zo)),[ur,to]=o.useState(()=>gd(id)),[St,Is]=o.useState(()=>ug()),[$t,Fs]=o.useState(()=>hg()),[Qt,Vr]=o.useState(()=>pg()),Jn="words",[fr,ro]=o.useState(0),[jt,Yr]=o.useState([]),[Qn,Zn]=o.useState([]),[$r,Er]=o.useState(!1),[Lr,Pt]=o.useState(null),[Xr,Jr]=o.useState([]),[Ds,Ar]=o.useState(!1),[hr,mr]=o.useState([]),[kn,Sn]=o.useState([]),[pr,Zt]=o.useState(!1),[Me,er]=o.useState(null),[Qr,es]=o.useState([]),[jn,Rn]=o.useState({}),[T,z]=o.useState(!1),[ie,xe]=o.useState(null),[Ue,$e]=o.useState(null),[ze,_e]=o.useState(null),[nt,at]=o.useState(null),[tr,gr]=o.useState(!1),[Cn,Zr]=o.useState(""),ts=o.useDeferredValue(Cn),[rr,rs]=o.useState({}),[en,Pr]=o.useState([]),[Q,Be]=o.useState(!1),[Tt,br]=o.useState(!1),[el,Nn]=o.useState(null),[no,Mn]=o.useState(!1),nr=o.useRef(null),Tr=o.useRef(0),tl=o.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[lf,_s]=o.useState(null),[ns,rl]=o.useState(()=>tt(ei,ks)??!1),[so,ao]=o.useState(!1),[Bs,oo]=o.useState([]),[xr,Os]=o.useState({}),[Rt,Us]=o.useState({}),[Ir,nl]=o.useState(!0),[sl,al]=o.useState(()=>new Set),[Ze,tn]=o.useState(null),[io,rn]=o.useState(null),[cf,vr]=o.useState(!1),[ol,yr]=o.useState(0),[,lo]=o.useState(0),[co,Hs]=o.useState(!1),[sr,uo]=o.useState(!1),[df,il]=o.useState(()=>te.getState().rightTab==="diff"),[Ae,ss]=o.useState(null),[$n,as]=o.useState(null),[ct,Fr]=o.useState(null),[ll,dt]=o.useState(null),[En,cl]=o.useState(null),[fo,uf]=o.useState(()=>Date.now()),[ff,hf]=o.useState(!1),[nn,zs]=o.useState(!1),[Ws,dl]=o.useState(""),[Ln,Gs]=o.useState(""),[sn,qs]=o.useState(""),[an,Ks]=o.useState(""),[ul,An]=o.useState(null),[Vs,Ys]=o.useState(!1),[fl,ho]=o.useState(!1),[hl,ml]=o.useState(!1),[Xs,mf]=o.useState({key:null,nonce:0}),pl=o.useRef(null),gl=o.useRef(null),ee=Hh(n,c,G),pf=gu(ee,c,Qt),[mo,po]=o.useState(()=>Rg(n)),go=te(r=>r.rightTab),on=te(r=>r.setRightTab),b=te(r=>r.rootPath),Pn=te(r=>r.explorerRoot),bl=te(r=>r.pinnedExplorerRootsCache),xl=te(r=>r.hydratePinnedExplorerRoots),vl=te(r=>r.syncPinnedExplorerRoots),It=te(r=>r.setExplorerRoot),yl=te(r=>r.resetExplorerToProject),Tn=te(r=>r.pinExplorerRoot),ln=te(r=>r.unpinExplorerRoot),Ve=te(r=>r.selectedFilePath),Ye=te(r=>r.selectFile),bo=te(r=>r.showHiddenFiles),gf=te(r=>r.toggleShowHiddenFiles),xo=te(r=>!!(b&&r.nestedGitScanRoots[b])),we=te(r=>r.changedFiles),Js=te(r=>r.setChangedFiles),Qs=te(r=>r.invalidateDirectoryCache),bf=te(r=>r.setDirectorySortMode),wl=te(r=>r.applyFileWatchEvents),kl=te(r=>r.reconcileDirectoryCache),Sl=te(r=>r.bumpFileWatchEpoch),Dr=te(r=>r.gitBundleLoading),jl=te(r=>r.gitBundleSlow),cn=te(r=>r.gitBundleError),In=te(r=>r.gitBundleLastLoadedAt),Rl=te(r=>r.beginGitBundleLoading),Cl=te(r=>r.setGitBundleSlowFor),vo=te(r=>r.finishGitBundleLoading),Zs=te(r=>r.resetGitBundleLoading),yo=te(r=>r.setGitBundleError),Nl=te(r=>r.markGitBundleLoaded),pe=Pn??b,Ml=o.useMemo(()=>pe?Kp(pe,K):"",[pe,K]),os=o.useMemo(()=>qp(oe),[oe]),$l=o.useMemo(()=>({excludePatterns:os,caseSensitive:C,wholeWord:ue,regex:Ge}),[C,os,Ge,ue]),ea=te(r=>pe?r.fileSortModes[pe]??"name":"name"),El=te(r=>!!(pe&&r.directoryCache.has(pe))),Fn=o.useRef(null),mt=o.useRef(0),[Ll]=o.useState(()=>++vb),wr=o.useRef(null),_r=o.useRef(null),ta=o.useRef(0),Ft=o.useRef(new Map),Dt=o.useRef(new Map),ar=o.useRef(new Set),dn=o.useRef(new Set),un=o.useRef(0),Br=o.useRef(null),Dn=o.useRef(0),_n=o.useRef(null),Bn=o.useRef(0),Or=o.useRef(null),wo=o.useRef(new Set),ko=o.useRef(null),So=o.useRef(null),ra=o.useRef(null),jo=o.useRef(null);o.useEffect(()=>{if(En===null)return;const r=Math.max(0,Date.now()-En),i=r<6e4?1e3:r<36e5?6e4:r<864e5?36e5:864e5,u=Math.max(50,i-r%i),x=window.setTimeout(()=>uf(Date.now()),u);return()=>window.clearTimeout(x)},[fo,En]);const na=o.useRef(null),kr=o.useRef(null),sa=o.useRef(null),is=o.useRef(null),ke=o.useCallback(r=>te.getState().rootPath===r,[]);o.useEffect(()=>{if(!t||typeof window>"u")return;const r=i=>{const u=Sb(i.target);u&&_a("global_change_row_event",{...jb(i),selectionPath:u.dataset.diffSelectionPath,filePath:u.dataset.diffFilePath,absolutePath:u.dataset.diffAbsolutePath,repoRoot:u.dataset.diffRepoRoot,status:u.dataset.diffStatus,selectedFilePath:te.getState().selectedFilePath,rightTab:te.getState().rightTab,activeGitRepoRoot:ce,changedFiles:te.getState().changedFiles.size})};return window.addEventListener("pointerdown",r,{capture:!0}),window.addEventListener("click",r,{capture:!0}),()=>{window.removeEventListener("pointerdown",r,{capture:!0}),window.removeEventListener("click",r,{capture:!0})}},[ce,t]);const Al=o.useCallback(async(r=b??void 0)=>{if(!r)return null;if(ar.current.has(r)||dn.current.has(r))return et("untracked_skip_cached",{cwd:r,rootPath:b,completed:ar.current.has(r),running:dn.current.has(r)}),null;const i=b,u=ta.current+1;ta.current=u,Ft.current.set(r,u);const x=`right-sidebar-git-untracked:${r}`,v=new AbortController;Dt.current.set(r,v),dn.current.add(r),et("untracked_start",{requestId:u,cwd:r,rootPath:b});try{let R=await Uc(r,v.signal,x),A=0;for(;R.status==="running"&&A<120;){if(Ft.current.get(r)!==u||v.signal.aborted)return et("untracked_stale_result",{requestId:u,activeRequestId:Ft.current.get(r),cwd:r,status:R.status}),null;if(!ke(i))return et("untracked_root_changed",{requestId:u,cwd:r,expectedRootPath:i,currentRootPath:te.getState().rootPath}),null;await new Promise(Y=>window.setTimeout(Y,A<10?1e3:3e3)),A+=1,R=await Uc(r,v.signal,x)}if(Ft.current.get(r)!==u||!ke(i))return et("untracked_stale_result",{requestId:u,activeRequestId:Ft.current.get(r),cwd:r,expectedRootPath:i,currentRootPath:te.getState().rootPath,files:R.files.length,status:R.status}),null;if(R.status==="done")return Js(Zu(te.getState().changedFiles,R.files)),R.files.length>0&&ye(Y=>{const He=new Map(Y.map(Ne=>[Ne.root,Ne])).get(r);if(!He)return Y;const Pe=ib(He.files,R.files),Fe=Y.map(Ne=>Ne.root===r?{...Ne,files:Pe,context:Ne.context?{...Ne.context,changedFiles:Pe.map(qe=>({path:qe.path,absolutePath:qe.absolutePath,status:qe.status})),truncated:!1}:Ne.context,untrackedDeferred:!1}:Ne);Oe(ef(Fe,b));const ge=Fe.find(Ne=>Ne.root===b);return ge?.context&&S(Ne=>Ne?.root===ge.root?{...Ne,...ge.context}:Ne),Fe}),ar.current.add(r),et("untracked_apply",{requestId:u,cwd:r,files:R.files.length}),R;const H=R.error||(R.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return ar.current.add(r),et("untracked_error",{requestId:u,cwd:r,message:H,code:R.code,status:R.status}),null}catch(R){if(Ft.current.get(r)!==u||!ke(i)||Cr(R))return et("untracked_aborted",{requestId:u,activeRequestId:Ft.current.get(r),cwd:r,expectedRootPath:i,currentRootPath:te.getState().rootPath,message:R instanceof Error?R.message:String(R)}),null;const A=R instanceof Error?R.message:"Failed to scan untracked files";return ar.current.add(r),et("untracked_error",{requestId:u,cwd:r,message:A}),null}finally{Dt.current.get(r)===v&&Dt.current.delete(r),Ft.current.get(r)===u&&Ft.current.delete(r),dn.current.delete(r)}},[ae,ke,b,Js]),qt=o.useMemo(()=>{const r=new Set(be.map(u=>u.root)),i=Xr.filter(u=>r.has(u));return i.length>0?i:ce?[ce]:[]},[ce,Xr,be]),Pl=qt.length===0,fn=o.useMemo(()=>qt.map(r=>V.find(i=>i.root===r)).filter(r=>!!r),[qt,V]),xf=o.useMemo(()=>be.map(r=>({root:r.root,label:r.label,branch:r.branch??null})),[be]),or=o.useCallback(async()=>{if(!b){Yr([]),Zn([]);return}const r=b,i=Dn.current+1;Dn.current=i,_n.current?.abort();const u=new AbortController;_n.current=u,Er(jt.length===0),Pt(null);try{const x=qt.length>0?await Promise.all(qt.map(v=>Hc({workspaceRoot:b,repoRoot:v},u.signal))).then(v=>({records:v.flatMap(R=>R.records),walkthroughs:v.flatMap(R=>R.walkthroughs??[])})):await Hc({workspaceRoot:b},u.signal);if(Dn.current!==i||!ke(r))return;Yr(x.records),Zn(x.walkthroughs??[])}catch(x){if(Dn.current!==i||!ke(r)||Cr(x))return;Pt(x instanceof Error?x.message:"Failed to load change audit explanations")}finally{_n.current===u&&(_n.current=null),Dn.current===i&&ke(r)&&Er(!1)}},[jt.length,qt,ke,b]),aa=o.useCallback(async(r,i,u)=>{if(!r&&!b){mr([]),Sn([]);return}const x=b,v=Bn.current+1;Bn.current=v,Or.current?.abort();const R=new AbortController;Or.current=R;try{const A=r?[r]:Array.from(new Set([b,...V.map(Y=>Y.root)].filter(Y=>!!Y))),H=await Promise.all(A.map(Y=>$h({repoRoot:Y,baseRef:i,branchName:u},R.signal))).then(Y=>{const Ce=new Map,He=new Map;for(const Pe of Y){for(const Fe of Pe.records)Ce.set(Fe.id,Fe);for(const Fe of Pe.walkthroughs??[])He.set(Fe.id,Fe)}return{records:Array.from(Ce.values()),walkthroughs:Array.from(He.values())}});if(Bn.current!==v||!ke(x))return;mr(H.records),Sn(H.walkthroughs??[])}catch(A){if(Bn.current!==v||!ke(x)||Cr(A))return;console.warn("[RightSidebar] Failed to load branch explanations",A)}finally{Or.current===R&&(Or.current=null)}},[V,ke,b]),Ur=o.useCallback((r,i={})=>{if(!ke(b)){et("apply_skipped_root_changed",{expectedRootPath:b,currentRootPath:te.getState().rootPath,bundleRoot:r.context?.root,files:r.files.length});return}et(r.files.length===0?"empty_bundle":"apply",{rootPath:b,available:r.available,files:r.files.length,repositories:r.repositories?.map(ge=>({root:ge.root,relativeRoot:ge.relativeRoot,files:ge.files.length,available:ge.available,error:ge.error})),repoFilters:r.repoFilters?.map(ge=>({root:ge.root,label:ge.label,count:ge.count})),cached:r.cached,stale:r.stale,cacheAgeMs:r.cacheAgeMs,untrackedDeferred:r.untrackedDeferred,error:r.error});let u=bu(r),x=r.repoFilters??[],v=r.files;const R=te.getState().changedFiles;if(!!(i.cacheOnly&&!r.cached&&r.files.length===0&&u.length===0)&&(R.size>0||V.length>0||ae)){et("cache_only_apply_skipped_empty_backend_cache",{rootPath:b,currentFiles:R.size,currentRepositories:V.length});return}const H=u.some(ge=>ge.deferred);if(H&&!i.replaceWorkspace){const ge=new Set(u.filter(qe=>!qe.deferred||qe.root===b).map(qe=>qe.root));v=[...Array.from(R.values()).filter(qe=>!ge.has(it(qe,b)??"")),...r.files]}const Y=$d(R.values(),b),Ce=$d(r.files,b),He=u.some(ge=>ge.root!==b);if(!!(i.background&&!H&&!i.replaceWorkspace&&R.size>0&&(r.files.length===0&&!r.error||Y>0&&Ce===0&&!He))){et("background_apply_skipped_degraded_bundle",{rootPath:b,currentFiles:R.size,nextFiles:r.files.length,currentNestedCount:Y,nextNestedCount:Ce,nextRepositories:u.map(ge=>({root:ge.root,relativeRoot:ge.relativeRoot,files:ge.files.length})),cached:r.cached,stale:r.stale,error:r.error});return}if(i.replaceRepoRoot){const ge=tf(R.values(),V,r,i.replaceRepoRoot,b);v=ge.files,u=ge.repositories,x=ge.repoFilters}if(Js(Qu(v)),ye(u),Oe(x),i.syncActiveRepo!==!1){const ge=i.activeRepoRoot!==void 0?i.activeRepoRoot:ce??pd(b),Ne=vg({...r,repositories:u,repoFilters:x},ge);Je(Ne),ni(b,Ne)}typeof r.cacheUpdatedAt=="number"&&cl(r.cacheUpdatedAt),S(ge=>{if(i.replaceRepoRoot&&i.replaceRepoRoot!==b)return ge;if(!r.context)return null;const Ne=ge?.root??b;return!ge?.available||Ne!==(r.context.root??b)?r.context:{...ge,...r.context}}),i.reloadDiff&&ro(ge=>ge+1);const Fe=te.getState().selectedFilePath;if(Fe&&!Fe.startsWith("/")&&!v.some(ge=>ge.path===Fe||ge.absolutePath===Fe)&&Ye(null),Mr(ge=>{const Ne=new Set(v.map(Yt=>it(Yt,b)).filter(Boolean)),qe=new Set;for(const Yt of ge)Ne.has(Yt)&&qe.add(Yt);return si(Zo,qe),qe}),i.loadDeferred!==!1){const ge=u.filter(Ne=>Ne.untrackedDeferred&&Ne.root).map(Ne=>Ne.root);for(const Ne of ge)Al(Ne)}i.loadAudit!==!1&&or()},[ce,ke,or,Al,b,Ye,Js]);o.useEffect(()=>{Zs(),ko.current=null,So.current=b;const r=[],i=[],x=pd(b);mt.current+=1,un.current+=1,ta.current+=1,wr.current?.abort(),bt(Kn(_r.current?.cwd??b??void 0)),_r.current=null,wr.current=null,Br.current?.abort(),bt("right-sidebar-git-details"),Br.current=null;for(const Y of Dt.current.values())Y.abort();for(const Y of Dt.current.keys())bt(`right-sidebar-git-untracked:${Y}`);Dt.current.clear(),Ft.current.clear(),Dn.current+=1,_n.current?.abort(),_n.current=null,Bn.current+=1,Or.current?.abort(),Or.current=null,Tr.current+=1,nr.current?.abort(),bt("right-sidebar-recent-commits"),nr.current=null,Yr([]),Zn([]),Er(!1),Pt(null),Jr([]),Ar(!1),mr([]),Sn([]),Zt(!1),er(null),z(!1),xe(null),$e(null),_e(null),at(null),gr(!1),Zr(""),Pr([]),Be(!1),br(!1),Nn(null),Mn(!1),_s(null),tn(null),rn(null),rl(!1),xt(ei,!1),ao(!1);const v=b?bd()[b]:null,R=v?.previewEntries??[],A=v?.selectedPreviewKey??null,H=A?R.find(Y=>Y.key===A)??null:null;oo(v?.selectedRepoRoots??[]),Os(v?.repoTargetBranches??{}),Us(v?.repoBaseBranches??{}),es(R),Rn(v?.previewScrollTops??{}),H&&v?.previewDetailOpen&&(H.diff.hunks?.length??0)>0&&(er(H.diff),tn(H.key),rn(v.selectedPreviewFileKey??(H.diff.hunks?.[0]?`${H.diff.hunks[0].filePath}\0${H.diff.hunks[0].hunkHeader}\0${H.diff.hunks[0].hunkIndex}`:null)),Zt(!0)),nl(v?.includeUncommitted??!0),ko.current=b,zs(!1),Je(x??null),ar.current.clear(),dn.current.clear(),ss(null),as(null),Fr(null),dt(null),cl(null),ye(r),Oe(i),S(null),jo.current=null},[Zs,b]);const Kt=o.useCallback(async(r=b??void 0,i={})=>{if(!r)return null;const u=b,x=mt.current;if(await Um(te.getState().hydrateNestedGitScanRoots),mt.current!==x||!ke(u))return null;const v=r===b&&Gn(b),R=i.includeNested??v,A=i.refresh??i.reloadDiff??!1,H=i.cacheOnly??!1,Y=i.background??!1,Ce=R&&(i.discoverOnly??!1);A&&ar.current.clear();const He=_r.current;if(He&&He.cwd===r&&He.includeNested===R&&He.refresh===A&&He.cacheOnly===H&&He.discoverOnly===Ce)return et("reuse_pending",{cwd:r,includeNested:R,refresh:A,cacheOnly:H,discoverOnly:Ce}),He.promise;const Pe=mt.current+1;mt.current=Pe;const Fe=`right-sidebar:${Ll}:${Pe}`;wr.current?.abort();const ge=Kn(r);bt(ge);const Ne=new AbortController;wr.current=Ne;let qe=null;Y||Rl(Fe),yo(null),et("start",{requestId:Pe,cwd:r,rootPath:b,requestSlotId:ge,includeNested:R,refresh:A,cacheOnly:H,background:Y,existingChanges:we.size,lastLoadedAt:In}),!Y&&typeof window<"u"&&(qe=window.setTimeout(()=>{mt.current===Pe&&Cl(Fe,!0)},rg));const Yt=(async()=>{const Te=await Ca(r,Ne.signal,{includeNested:R,refresh:A,cacheOnly:H,discoverOnly:Ce,action:A?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:ge,requestTimeoutMs:A?null:void 0});if(db(Te)){if(et("cancelled_result_ignored",{requestId:Pe,activeRequestId:mt.current,cwd:r,error:Te.error??Te.context?.error}),Ne.signal.aborted)return null;throw new Error(Te.error??Te.context?.error??"Failed to load Git changes")}return mt.current!==Pe||!ke(u)?(et("stale_result",{requestId:Pe,activeRequestId:mt.current,cwd:r,expectedRootPath:u,currentRootPath:te.getState().rootPath,files:Te.files.length,repositories:Te.repositories?.length??0}),null):(Ur(Te,{reloadDiff:i.reloadDiff,syncActiveRepo:i.replaceWorkspace?!0:R,background:Y,cacheOnly:H,replaceRepoRoot:i.replaceRepoRoot,replaceWorkspace:i.replaceWorkspace}),Te)})();_r.current={cwd:r,includeNested:R,refresh:A,cacheOnly:H,discoverOnly:Ce,promise:Yt};try{const Te=await Yt;return mt.current===Pe&&Te&&ke(u)?Nl({cached:Te.cached,stale:Te.stale,cacheAgeMs:Te.cacheAgeMs,nestedDeferred:!R||Te.nestedDeferred,untrackedDeferred:Te.untrackedDeferred}):mt.current===Pe&&ke(u)&&vo(Fe),Te}catch(Te){return mt.current!==Pe||!ke(u)||Ne.signal.aborted?(et("aborted",{requestId:Pe,activeRequestId:mt.current,cwd:r,expectedRootPath:u,currentRootPath:te.getState().rootPath,message:Te instanceof Error?Te.message:String(Te)}),null):(et("error",{requestId:Pe,cwd:r,includeNested:R,refresh:A,background:Y,message:Te instanceof Error?Te.message:String(Te)}),Y||(S(null),yo(Te instanceof Error?Te.message:"Failed to load Git changes")),null)}finally{qe!==null&&window.clearTimeout(qe),wr.current===Ne&&(wr.current=null),_r.current?.promise===Yt&&(_r.current=null),!Y&&mt.current===Pe&&ke(u)&&vo(Fe)}},[Ur,Rl,we.size,vo,Ll,In,ke,Nl,b,yo,Cl]),ls=o.useCallback(async()=>{b&&await Kt(b,{reloadDiff:!0,refresh:!0})},[Kt,b]),Ro=o.useCallback(async(r=b??void 0)=>{if(!r)return null;const i=b,u=un.current+1;un.current=u,Br.current?.abort(),bt("right-sidebar-git-details");const x=new AbortController;Br.current=x,zs(!0);try{const v=await zc(r,x.signal,"load_git_details","right-sidebar-git-details");return un.current!==u||!ke(i)?null:(ye(R=>R.map(A=>A.root===v.root?{...A,available:v.available,context:v,error:v.error}:A)),S(R=>R?.root&&v.root&&R.root!==v.root?R:!R?.available||!v.available?v:{...R,...v}),v)}catch(v){return Cr(v)||!ke(i)||un.current===u&&dt(v instanceof Error?v.message:"Failed to load Git details"),null}finally{Br.current===x&&(Br.current=null),un.current===u&&ke(i)&&zs(!1)}},[ke,b]);o.useEffect(()=>{if(!t){mt.current+=1,Zs(),jo.current=null,un.current+=1,ta.current+=1,wr.current?.abort(),bt(Kn(_r.current?.cwd??b??void 0)),_r.current=null,wr.current=null,Br.current?.abort(),bt("right-sidebar-git-details"),Br.current=null;for(const r of Dt.current.values())r.abort();for(const r of Dt.current.keys())bt(`right-sidebar-git-untracked:${r}`);Dt.current.clear(),Ft.current.clear(),Bn.current+=1,Or.current?.abort(),Or.current=null,Tr.current+=1,nr.current?.abort(),bt("right-sidebar-recent-commits"),nr.current=null,zs(!1),z(!1),xe(null),$e(null),_e(null),at(null),gr(!1),Zr(""),Pr([]),Be(!1),br(!1),Nn(null),Mn(!1),j(""),fe(!1),kt(null),uo(!1),ee&&il(!1)}},[ee,t,Zs,fe]),o.useEffect(()=>{if(!se)return;const r=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(r)},[se]),o.useEffect(()=>{ee||vr(!1)},[ee]);const cs=o.useCallback(r=>{lo(r);const i=sa.current;i&&(i.update(),i.slideTo(r,0),window.requestAnimationFrame(()=>{i.update(),i.slideTo(r,0)}))},[]);o.useEffect(()=>{if(ee)if(vr(m),m&&Ve){yr(1);const r=kr.current;r&&(r.update(),r.activeIndex!==1&&(is.current=1,r.slideTo(1,0)))}else{yr(0);const r=kr.current;r&&r.activeIndex!==0&&(is.current=0,r.slideTo(0,0)),kt(null)}},[ee,m,b,Ve]),o.useEffect(()=>{if(g!==void 0&&!m){yr(0);const r=kr.current;r&&r.activeIndex!==0&&(is.current=0,r.slideTo(0,0)),vr(!1),kt(null)}},[g,m]),o.useEffect(()=>{y!==void 0&&W(null)},[y]),o.useEffect(()=>{!ee&&m&&f?.()},[ee,f,m]),o.useEffect(()=>{po(r=>Li(r,n))},[n]);const vf=o.useCallback(r=>{ee||(r.preventDefault(),na.current={startX:r.clientX,startWidth:mo,pointerId:r.pointerId},r.currentTarget.setPointerCapture(r.pointerId))},[mo,ee]),yf=o.useCallback(r=>{const i=na.current;if(!i||i.pointerId!==r.pointerId)return;const u=Li(i.startWidth+r.clientX-i.startX,n);po(u),Ss(ws,u,tg)},[n]),Tl=o.useCallback(r=>{const i=na.current;if(!(!i||i.pointerId!==r.pointerId)){na.current=null,xs(ws);try{r.currentTarget.releasePointerCapture(r.pointerId)}catch{}}},[]),ds=!!(b&&In!==null&&Ad(ae)),Co=!!(b&&!cn&&we.size===0&&In===null),Hr=ds?"files":go,Xe=Hr==="git",On=Hr==="files",pt=Hr==="diff";o.useEffect(()=>{if(!ee){Hs(!0);return}if(!t){const i=window.setTimeout(()=>{Hs(!1)},sg);return()=>window.clearTimeout(i)}Hs(!1);const r=window.setTimeout(()=>{Hs(!0)},ng);return()=>window.clearTimeout(r)},[ee,t]),o.useEffect(()=>{if(!ee||!pt)return;const r=sa.current;if(!r)return;const i=window.requestAnimationFrame(()=>{r.update()});return()=>window.cancelAnimationFrame(i)},[pt,ee]),o.useEffect(()=>{if(!ds||!b||Dr)return;const r=window.setTimeout(()=>{Kt(b,{background:!0})},3e3);return()=>window.clearTimeout(r)},[ds,b,Dr,Kt]);const wf=o.useCallback(r=>{Kt(r,{discoverOnly:!0})},[Kt]);Hm({active:t&&(Xe||pt),rootPath:b,loading:Dr,delay:Xe&&!ee?0:ri,lastStartedRoot:jo,load:wf}),o.useEffect(()=>{!t||!Xe||(!ee||co)&&uo(!0)},[Xe,ee,t,co]),o.useEffect(()=>{if(!t||Xe)return;const r=window.setTimeout(()=>{uo(!0)},ri);return()=>window.clearTimeout(r)},[Xe,t]),o.useEffect(()=>{pt&&il(!0)},[pt]);const Il=o.useCallback(r=>{pe&&rb(pe,r.currentTarget.scrollTop)},[pe]);o.useEffect(()=>()=>{wr.current?.abort(),xs(Hi),xs(zi),xs(ws),xs(ti)},[]),o.useEffect(()=>{if(!pe||!El)return;const r=Xu()[pe]?.top;if(typeof r!="number")return;let i=window.requestAnimationFrame(()=>{Fn.current&&(Fn.current.scrollTop=r),i=window.requestAnimationFrame(()=>{Fn.current&&(Fn.current.scrollTop=r)})});return()=>window.cancelAnimationFrame(i)},[pe,El]),o.useEffect(()=>{if(!t)return;const r=new AbortController;return Eh(r.signal).then(i=>ml(!!i.available)).catch(()=>ml(!1)),()=>r.abort()},[t]);const us=o.useCallback(r=>{if(ne(null),Ye(r),kt(null),ee){vr(!0),yr(1),kr.current?.slideTo(1),p?.();return}},[ee,p,Ye]),Fl=o.useCallback((r,i)=>{if(ne(null),Ye(r),Ie(i),ee){vr(!0),yr(1),kr.current?.slideTo(1),p?.();return}},[ee,p,Ye]),fs=o.useCallback(async(r,i)=>{const u=i||Pn||b;if(!(!u||r.length===0)){Ys(!0);try{await Yo(u,r),Qs(u,!1)}catch(x){dt(x instanceof Error?x.message:a("rightSidebar.uploadFailed")),window.setTimeout(()=>dt(null),4e3)}finally{Ys(!1)}}},[Pn,b,Qs,a]),Dl=o.useCallback(async r=>{try{await Lh(r)}catch(i){dt(i instanceof Error?i.message:a("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>dt(null),4e3)}},[a]),oa=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),r.dataTransfer.types.includes("Files")&&ho(!0)},[]),_l=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),ho(!1)},[]),Bl=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),ho(!1);const i=r.dataTransfer.files;i.length>0&&fs(Array.from(i))},[fs]),No=o.useCallback(r=>{Se(r),window.setTimeout(()=>Se(i=>i===r?null:i),1400)},[]),Sr=o.useCallback(r=>{lt(r),window.setTimeout(()=>lt(i=>i===r?null:i),1400)},[]);o.useEffect(()=>{xt(ld,Qe)},[Qe]),o.useEffect(()=>{xt(cd,ht)},[ht]),o.useEffect(()=>{xt(dd,Xt)},[Xt]),o.useEffect(()=>{Ss(ti,wt,Xp)},[wt]),o.useEffect(()=>(xl().catch(()=>{}),Wc(r=>{r.type==="pinned-explorer-roots"&&vl(r.pinnedExplorerRoots)})),[xl,vl]);const Ol=o.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),ia=o.useRef(null),hn=o.useRef(null),[Ul,Mo]=o.useState(!1);o.useEffect(()=>{if(!t)return;Mo(!1);let r=!1;Ah().then(u=>{r||(ia.current=u.text,Ht(x=>u.text&&u.text!==x?u.text:x),Mo(!0))}).catch(()=>{r||Mo(!0)});const i=Wc(u=>{u.type==="context-draft"&&u.origin!==Ol.current&&(ia.current=u.text,Ht(u.text))});return()=>{r=!0,i(),hn.current!==null&&(window.clearTimeout(hn.current),hn.current=null)}},[t]),o.useEffect(()=>{if(!Ul||ia.current===wt)return;hn.current!==null&&window.clearTimeout(hn.current);const r=wt;hn.current=window.setTimeout(()=>{hn.current=null,Ph(r,Ol.current).then(()=>{ia.current=r}).catch(()=>{})},500)},[wt,Ul]);const Un=o.useCallback((r,i,u)=>{if(r){if(Th(u?r+u:r)){No(i);return}Qe?(Ht(x=>hp(x,r)+(u??"")),window.matchMedia("(pointer: coarse)").matches||(lr(!1),cr(x=>x+1))):window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:u?r+u:r,focus:!0}})),No(i)}},[Qe,No]),la=o.useCallback(r=>{const i=Ma(r,b);return em(i,b)},[b]),$o=Vd(Sr),zr=o.useCallback((r,i)=>{const u=Ma(r,b);Un(tm(u,b),i??`path:${u}`)},[b,Un]),kf=o.useCallback(async r=>{Ys(!0);try{await rm(r,Yo,i=>{zr(i,`path:${i}`)}),ee&&!Qe&&s()}catch(i){dt(i instanceof Error?i.message:a("rightSidebar.uploadFailed")),window.setTimeout(()=>dt(null),4e3)}finally{Ys(!1)}},[Qe,zr,ee,s,a]),jr=o.useCallback((r,i)=>{if(!r)return;const u=r.includes(`
|
|
1660
|
-
`)?`
|
|
1661
|
-
`:void 0;Un(r.endsWith(`
|
|
1662
|
-
`)||r.endsWith(" ")?r:`${r} `,i,u)},[Un]),Hl=o.useRef(jr);Hl.current=jr;const Eo=o.useRef(!0);o.useEffect(()=>(Eo.current=!0,()=>{Eo.current=!1}),[]);const Lo=o.useRef(new Set),zl=o.useCallback((r,i,u)=>{if(Lo.current.has(i))return;const x=Qc.getState().activeSessionId;Lo.current.add(i),Gm(r,i,u,{insert:jr,upload:async(v,R)=>(await Yo("/tmp",[v],R)).files[0]?.path,isCurrent:()=>Eo.current&&Hl.current===jr&&x===Qc.getState().activeSessionId}).finally(()=>Lo.current.delete(i))},[jr]),Wr=o.useCallback((r,i,u)=>{i&&Un(i.endsWith(" ")?i:`${i} `,u??`context:${r}`,`
|
|
1663
|
-
`)},[Un]),Wl=o.useCallback(r=>{const i=mp(wt,r);if(!i)return;const u=r&&wt.trim().includes(`
|
|
1664
|
-
`),x=`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`;let v=!1;const R=Y=>{v||(v=!0,window.removeEventListener("termdock-insert-reference-ack",A),window.clearTimeout(H),Y?(Wt(!1),Ht(""),Xt&&lr(!0)):(Wt(!0),lr(!1)))},A=Y=>{const Ce=Y.detail;Ce?.nonce===x&&R(Ce.ok===!0)},H=window.setTimeout(()=>R(!1),1500);window.addEventListener("termdock-insert-reference-ack",A),Wt(!1),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:i,focus:!0,paste:u,nonce:x}}))},[Xt,wt]),Ke=o.useMemo(()=>b?ft(b):a("rightSidebar.workspace"),[b,a]),Sf=o.useMemo(()=>ft(pe)||Ke,[pe,Ke]),ca=o.useMemo(()=>di(pe),[pe]),da=o.useMemo(()=>b?bl[b]??[]:[],[bl,b]),mn=o.useMemo(()=>new Set(da.map(r=>r.path)),[da]),hs=!!(pe&&mn.has(pe)),Ao=!!(b&&pe&&pe!==b),jf=!!(b&&Pn&&Pn!==b),Et=pe?`path:${pe}`:null,Gl="context:change-audit",Rf=o.useCallback(()=>{ca&&It(ca)},[ca,It]),ql=o.useCallback(()=>{yl()},[yl]),Cf=o.useCallback(()=>{pe&&(Qs(pe,!0),Sl())},[Sl,pe,Qs]),Nf=o.useCallback(()=>{!pe||!Ao||(hs?ln(pe):Tn(pe,"directory"))},[Ao,pe,hs,Tn,ln]),Kl=o.useCallback(r=>{It(r),j("")},[It]),Vl=o.useCallback(r=>{pe&&(re(Vp(pe,r)),fe(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[pe,fe]),Yl=o.useCallback(r=>{!b||r===b||(mn.has(r)?ln(r):Tn(r,"directory"))},[Tn,mn,b,ln]),Xl=o.useCallback(r=>{!b||!r||(mn.has(r)?ln(r):Tn(r,"file"))},[Tn,mn,b,ln]),Jl=te(r=>r.expandedPaths),Po=o.useMemo(()=>{const r=new Set;if(On&&pe){r.add(pe);const i=`${pe.replace(/\/+$/,"")}/`;for(const u of Jl)u.startsWith(i)&&r.add(u)}if(On&&b&&Ve){const i=Ve.startsWith("/")?Ve:`${b}/${Ve}`,u=di(i);u&&r.add(u)}return ap(r).join(`
|
|
1665
|
-
`)},[Jl,On,pe,b,Ve]),pn=o.useRef(new Map);o.useEffect(()=>{const r=Po?Po.split(`
|
|
1666
|
-
`):[];if(!t||r.length===0){An(null);return}const i=new AbortController;let u=!1,x=0,v=0;An(null);const R=async()=>{let A=0;for(;!u&&!i.signal.aborted;){let H=null;try{An(null),await zh(r,Ce=>{const{applicableEvents:He,unavailableReason:Pe}=ip(Ce);He.length>0&&wl(He);for(const Fe of He){if(Fe.type!=="rescan-required")continue;const ge=te.getState();if(!ge.directoryCache.has(Fe.path))continue;pn.current.get(Fe.path)?.abort();const qe=new AbortController;pn.current.set(Fe.path,qe);const Yt=`file-watch-rescan:${Fe.path}`;bt(Yt),Wh(Fe.path,qe.signal,ge.showHiddenFiles,"watch_rescan",Yt,ge.fileSortModes[Fe.path]??"name").then(Te=>{pn.current.get(Fe.path)===qe&&kl(Fe.path,Te.entries)}).catch(Te=>{Cr(Te)||An(Te instanceof Error?Te.message:"File refresh unavailable")}).finally(()=>{pn.current.get(Fe.path)===qe&&pn.current.delete(Fe.path)})}Pe&&An(Pe)},i.signal),H=new Error("File watch stream ended")}catch(Ce){H=Ce}if(u||i.signal.aborted||Cr(H))return;An(H instanceof Error?H.message:"File watching unavailable");const Y=ud[Math.min(A,ud.length-1)];A+=1,await new Promise(Ce=>{v=window.setTimeout(Ce,Y)})}};return x=window.setTimeout(()=>{u||R()},ri),()=>{u=!0,window.clearTimeout(x),window.clearTimeout(v),i.abort();for(const A of pn.current.values())A.abort();pn.current.clear()}},[wl,t,kl,Po]),o.useEffect(()=>{if(!b||ko.current!==b)return;if(So.current===b){So.current=null;return}const r=bd();Ss(du,{...r,[b]:{selectedRepoRoots:Bs,repoTargetBranches:xr,repoBaseBranches:Rt,previewEntries:Qr,selectedPreviewKey:Me&&pr?Ze:null,selectedPreviewFileKey:Me&&pr?io:null,previewDetailOpen:!!(Me&&pr),previewScrollTops:jn,previewMobileSlideIndex:1,includeUncommitted:Ir,updatedAt:Date.now()}},Yp)},[pr,Ir,Me,Qr,jn,Rt,xr,Bs,b,io,Ze]);const st=o.useMemo(()=>Ld(we.values()),[we]),gt=o.useMemo(()=>{const r=new Map;for(const i of V)r.set(i.root,i);return r},[V]),To=o.useMemo(()=>{const r=new Map;for(const i of V)i.deferred||r.set(i.root,i.files.length);return r},[V]),Ct=o.useMemo(()=>ce?be.find(r=>r.root===ce)??null:null,[ce,be]),_t=o.useMemo(()=>Ve?Array.from(we.values()).find(r=>r.path===Ve||r.absolutePath===Ve)??null:null,[we,Ve]),Lt=o.useMemo(()=>{const r=new Map;for(const i of V)i.available&&i.context?.available&&r.set(i.root,i);return r.size===0&&ae?.available&&ae.root&&r.set(ae.root,{id:ae.root,root:ae.root,relativeRoot:".",name:Ke,depth:0,nested:!1,available:!0,files:Array.from(we.values()).filter(i=>it(i,b)===ae.root),context:ae}),Array.from(r.values()).sort((i,u)=>i.root===b?-1:u.root===b?1:(i.relativeRoot||i.name).localeCompare(u.relativeRoot||u.name)).map(i=>{const u=i.relativeRoot==="."?Ke:i.relativeRoot||i.name||ft(i.root),x=Ed(i.files),v=i.files.length;return{value:i.root,label:u,meta:[i.context?.branch,v>0?a("rightSidebar.repoChangedCount",{count:v}):null,x>0?a("rightSidebar.repoStagedCount",{count:x}):null].filter(Boolean).join(" · ")}})},[we,ae,V,Ke,b,a]),ve=o.useMemo(()=>ce&&Lt.some(r=>r.value===ce)?ce:_t?.repoRoot&&Lt.some(r=>r.value===_t.repoRoot)?_t.repoRoot:Lt.length===1||Lt.length>1?Lt[0].value:null,[ce,Lt,_t?.repoRoot]),Ql=ve?gt.get(ve)??null:null,de=Ql?.context?.available?Ql.context:ve===ae?.root?ae:null,We=Lt.length>0&&!ve,Zl=o.useMemo(()=>We?[]:ve?Array.from(we.values()).filter(r=>it(r,b)===ve):Array.from(we.values()),[ve,we,We,b]),gn=o.useMemo(()=>Ld(Zl),[Zl]),Io=!!(de?.available&&de.root&&ve&&de.root===ve),Mf=ve?Lt.find(r=>r.value===ve)?.label??ft(ve):a("rightSidebar.gitRepositoryPlaceholder"),ec=Io?de?.branch??"HEAD":We?a("rightSidebar.selectRepositoryForGitActions"):nn?a("rightSidebar.gitActionRunning"):"HEAD",Hn=!!(de?.available&&de.root===ve&&de.status);o.useEffect(()=>{tl.current={count:en.length,loading:Q,loadingMore:Tt,hasMore:no}},[en.length,no,Q,Tt]),o.useEffect(()=>{Tr.current+=1,nr.current?.abort(),bt("right-sidebar-recent-commits"),nr.current=null,Zr(""),Pr([]),Be(!1),br(!1),Nn(null),Mn(!1)},[ve]);const ms=o.useCallback(async(r={})=>{if(!b||!ve||We)return;const i=r.reset??!1,u=tl.current,x=i?0:u.count;if(!i&&(u.loading||u.loadingMore||!u.hasMore))return;const v=Tr.current+1;Tr.current=v,nr.current?.abort(),bt("right-sidebar-recent-commits");const R=new AbortController;nr.current=R,i?Be(!0):br(!0),Nn(null);try{const A=await Ih({cwd:b,repoRoot:ve,limit:ag,skip:x,query:ts.trim(),requestSlotId:"right-sidebar-recent-commits"},R.signal);if(Tr.current!==v)return;if(!A.available){Nn(A.error??"Recent commits are unavailable"),i&&Pr([]),Mn(!1);return}rs(H=>i?A.commitSyncStatus??{}:{...H,...A.commitSyncStatus}),Pr(H=>i?A.commits:[...H,...A.commits]),Mn(A.hasMore)}catch(A){if(Tr.current!==v||Cr(A))return;Nn(A instanceof Error?A.message:"Failed to load recent commits"),i&&Pr([]),Mn(!1)}finally{nr.current===R&&(nr.current=null),Tr.current===v&&(Be(!1),br(!1))}},[ve,ts,We,b]);o.useEffect(()=>{tr&&ms({reset:!0})},[ts,ms,tr,de?.ahead,de?.behind,de?.upstream]);const $f=o.useCallback(r=>{const i=r.currentTarget;i.scrollTop+i.clientHeight<i.scrollHeight-48||ms({reset:!1})},[ms]);o.useEffect(()=>{!ve||!ae?.available||!Xe||!sr||Hn||nn||We||Ro(ve)},[ve,ae?.available,Hn,nn,Xe,sr,Ro,We]),o.useEffect(()=>{!t||!pt&&!Xe||!b||or()},[pt,Xe,t,or,b]),o.useEffect(()=>{!t||!Xe||!sr||!ns||!b||aa(null)},[ns,Xe,sr,t,aa,b]);const Ef=o.useMemo(()=>{if(!ce)return 0;const r=be.findIndex(i=>i.root===ce);return r>=0?r+1:0},[ce,be]),tc=o.useCallback(r=>{if(!r)return null;const i=Array.from(we.values()).filter(u=>it(u,b)===r).sort((u,x)=>u.path.localeCompare(x.path))[0];return i?ut(i):null},[we,b]),bn=be.length>1,ua=o.useMemo(()=>[{root:null,label:a("rightSidebar.allRepositories"),count:we.size,branch:null,deferred:!1},...be.map(r=>({root:r.root,label:r.label,count:r.deferred?To.get(r.root)??0:r.count,branch:r.branch??null,deferred:!!r.deferred&&!To.has(r.root)}))],[we.size,be,To,a]),rc=ua[Ef]??ua[0],fa=!!ce,nc=o.useMemo(()=>vu(be,V),[be,V]);o.useEffect(()=>{ce&&!nc.has(ce)&&(Je(null),ni(b,null)),Jr(r=>r.filter(i=>be.some(u=>u.root===i)))},[ce,be,nc,b]);const Lf=o.useMemo(()=>{const r=new Set;de?.branch&&r.add(de.branch);for(const i of de?.branches??[])r.add(i);return Array.from(r).map(i=>({value:i,label:i,meta:i===de?.branch?a("rightSidebar.pushCurrentBranchBadge"):void 0}))},[de?.branch,de?.branches,a]),sc=o.useMemo(()=>{const r=new Set;de?.upstreamRemote&&r.add(de.upstreamRemote);for(const i of de?.remotes??[])r.add(i);return Array.from(r).map(i=>({value:i,label:i,meta:i===de?.upstreamRemote?a("rightSidebar.pushUpstreamBadge"):void 0}))},[de?.remotes,de?.upstreamRemote,a]),ac=sc.length>1,Af=o.useMemo(()=>{const r=[],i=new Set,u=(v,R)=>{!v||i.has(v)||(i.add(v),r.push({value:v,label:v,meta:R}))};u(de?.upstreamBranch,de?.upstreamBranch?a("rightSidebar.pushUpstreamBadge"):void 0),u(de?.branch,de?.branch?a("rightSidebar.pushCurrentBranchBadge"):void 0);for(const v of de?.branches??[])u(v,v===de?.branch?a("rightSidebar.pushCurrentBranchBadge"):"local");const x=de?.upstreamRemote;for(const v of de?.remoteBranches??[]){const R=v.indexOf("/"),A=R>=0?v.slice(0,R):null,H=R>=0?v.slice(R+1):v;(!x||A===x)&&u(H,"remote")}return r},[de?.branch,de?.branches,de?.remoteBranches,de?.upstreamBranch,de?.upstreamRemote,a]),Bt=o.useMemo(()=>Lt.map(r=>{const i=gt.get(r.value);return{root:r.value,label:r.label,branch:i?.context?.branch??null}}),[Lt,gt]);o.useEffect(()=>{Bt.length!==0&&(Os(r=>{let i=!1;const u={...r},x=new Set(Bt.map(v=>v.root));for(const v of Object.keys(u))x.has(v)||(delete u[v],i=!0);for(const v of Bt)!u[v.root]&&v.branch&&(u[v.root]=v.branch,i=!0);return i?u:r}),Us(r=>{let i=!1;const u={...r},x=new Set(Bt.map(v=>v.root));for(const v of Object.keys(u))x.has(v)||(delete u[v],i=!0);for(const v of Bt){const R=gt.get(v.root)?.context;if(u[v.root]&&yu(u[v.root],R?.branch)&&(delete u[v.root],i=!0),u[v.root])continue;const A=yd(R);A&&(u[v.root]=A,i=!0)}return i?u:r}))},[Bt,gt]);const ha=o.useMemo(()=>{const r=new Set(Bt.map(i=>i.root));return Bs.filter(i=>r.has(i))},[Bs,Bt]),ma=ha.length===0,ir=o.useMemo(()=>ma?Bt:Bt.filter(r=>ha.includes(r.root)),[Bt,ha,ma]),Vt=o.useMemo(()=>ir.filter(r=>!!Rt[r.root]?.trim()),[Rt,ir]),oc=o.useMemo(()=>ir.filter(r=>!Rt[r.root]?.trim()),[Rt,ir]),ic=o.useCallback(async r=>{if(!r||wo.current.has(r))return;const i=gt.get(r)?.context;if((i?.branches?.length??0)>0||(i?.remoteBranches?.length??0)>0||i?.upstream)return;const u=b;wo.current.add(r),al(x=>new Set(x).add(r));try{const x=await zc(r,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${r}`);if(!x.available||!ke(u))return;ye(v=>v.map(R=>R.root===r?{...R,available:!0,context:{...R.context,...x},error:void 0}:R)),Os(v=>v[r]||!x.branch?v:{...v,[r]:x.branch}),Us(v=>{if(v[r])return v;const R=yd(x);return R?{...v,[r]:R}:v})}catch(x){Cr(x)||console.warn("[RightSidebar] Failed to load branch audit repo details",r,x)}finally{wo.current.delete(r),al(x=>{const v=new Set(x);return v.delete(r),v})}},[gt,ke,b]);o.useEffect(()=>{if(so)for(const r of ir)ic(r.root)},[so,ir,ic]),o.useEffect(()=>{!Io||!de||(Gs(de.branch||(de.branches?.[0]??"")),qs(de.upstreamRemote||(de.remotes?.includes("origin")?"origin":de.remotes?.[0]??"")),Ks(de.upstreamBranch||de.branch||(de.branches?.[0]??"")))},[de,Io]);const lc=o.useMemo(()=>{if(We)return{text:a("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!Hn||nn)return{text:a("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!de?.upstream)return{text:a("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const r=de.ahead??0,i=de.behind??0;return r>0&&i>0?{text:a("rightSidebar.pushDivergedCount",{ahead:r,behind:i}),className:"bg-destructive/10 text-destructive"}:r>0?{text:a("rightSidebar.pushAheadCount",{count:r}),className:"bg-accent/10 text-accent"}:i>0?{text:a("rightSidebar.pushBehindCount",{count:i}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:a("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[de?.ahead,de?.behind,de?.upstream,Hn,nn,We,a]),Pf=o.useCallback(r=>{if(r&&!ee){const i=r.currentTarget.getBoundingClientRect();W({x:Math.min(i.left,window.innerWidth-352),y:Math.min(i.bottom+6,window.innerHeight-64)})}else W(null);N?.()},[ee,N]),Fo=o.useCallback(()=>{W(null),I?.()},[I]);function cc(){if(!bn)return null;const r=rc?.label??a("rightSidebar.allRepositories"),i=rc?.count??we.size,u=ft(r)||r;return e.jsxs("button",{type:"button",onClick:Pf,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 ${k?"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":k,title:r,children:[e.jsx(Rr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:u}),e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${i>0?"bg-accent/10 text-accent":"bg-surface text-muted-foreground"}`,children:i}),e.jsx(Ms,{size:12,className:"shrink-0"})]})}function Tf(){if(!k||!bn||typeof document>"u")return null;const r=typeof window>"u"?1024:window.innerWidth,i=typeof window>"u"?768:window.innerHeight,u=Math.max(12,Math.min(Le?.x??r-368,r-352)),x=Math.max(12,Math.min(Le?.y??80,i-420)),v=ee?void 0:{left:u,top:x},R=e.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${ee?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:Fo,children:e.jsxs("div",{className:ee?"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:v,onClick:A=>A.stopPropagation(),children:[e.jsxs("div",{className:ee?"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:ee?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:a("rightSidebar.repositories")}),!ee&&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:ua.length}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${we.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:we.size})]})]}),e.jsx("button",{type:"button",onClick:Fo,className:ee?"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":a("rightSidebar.close"),children:e.jsx(Ut,{size:ee?16:14})})]}),e.jsx("div",{className:ee?"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:ua.map(A=>{const H=(A.root??null)===ce,Y=ft(A.label)||A.label;return e.jsxs("button",{type:"button",onClick:()=>{$c(A.root),Fo()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${ee?"px-3 py-2":"px-2 py-1.5"} ${H?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:A.label,role:"option","aria-selected":H,children:[e.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${H?"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 ${H?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:e.jsx(Rr,{size:13})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:`${ee?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:Y}),e.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:A.root===null?a("rightSidebar.allRepositories"):A.label})]}),A.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:A.branch}),A.deferred?e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/70",children:a("rightSidebar.repoNotLoaded")}):e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${A.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:A.count})]},A.root??"all")})})]})});return su(R,ee,document.body)}function If(){return Tf()}function dc(r){const i=it(r,b),u=r.absolutePath||(i?`${i}/${r.path}`:r.path),x=Ha(u,i??b);return{key:ut(r),path:r.path,absolutePath:u,displayName:x.name,displayDir:x.dir,oldPath:r.oldPath,status:r.status,title:u}}function uc(r){return r.oldPath?e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:a("rightSidebar.changedFromPath",{path:r.oldPath})}):null}function fc(r,i){const u=Ma(r,b),x=`path:${u}`,v=q===x,R=Re===x,A=v||R;return e.jsx("button",{type:"button",onClick:H=>{H.stopPropagation(),zr(u,x)},...$o(la(u),x),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 ${A?"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"} ${A?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:i,children:e.jsx("span",{className:"whitespace-nowrap",children:a(R?"rightSidebar.copied":v?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function hc(r){const i=it(r,b),u=r.absolutePath||(i?`${i}/${r.path}`:r.path),x=lh(r),v=hi(r);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(ub,{actions:x,running:Ae,completed:$n?.path===v?$n:null}),fc(u,a("rightSidebar.insertThisFile"))]})}function mc(r,i){const u=i.root??b;if(!u)return null;const x=Ma(r,u);return fc(x,a("fileTree.insertRefTitle"))}function Do(){return e.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5","aria-label":a("diffViewer.view"),children:[e.jsx("button",{type:"button",onClick:()=>Sc("unified"),"aria-pressed":Qt==="unified",title:a("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Qt==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:a("diffViewer.unified")}),e.jsx("button",{type:"button",onClick:()=>Sc("split"),"aria-pressed":Qt==="split",title:a("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Qt==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:a("diffViewer.split")})]})}function pc(){return ps.map(r=>{const i=Ed(r.files.map(([,R])=>R)),u=$i({activeGitRepoRoot:ce,groupCount:ps.length,label:r.label,rootName:Ke}),x=!!(u&&r.root&&Gt.has(r.root));return{key:r.root??r.label,root:r.root,label:r.label,branch:r.branch,collapsed:x,files:r.files.map(([,R])=>dc(R)),header:u?e.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${x?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[e.jsxs("button",{type:"button",onClick:()=>eh(r.root),"aria-expanded":!x,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:x?e.jsx(Na,{size:13}):e.jsx(Ms,{size:13})}),e.jsx(Rr,{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:r.label}),r.branch&&e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:r.branch})]}),e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:r.files.length}),i>0&&e.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:i})]}),r.root&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),Sa("stage-all",r.root,r.label)},disabled:!!Ae,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:a("rightSidebar.stageAll"),children:a("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),Sa("stash-all",r.root,r.label)},disabled:!!Ae,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:a("rightSidebar.stashAll"),children:a("rightSidebar.stashAll")})]})]}):null}})}function gc(){return we.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:a("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:ga.map(([,r])=>{const i=it(r,b),u=r.absolutePath||(i?`${i}/${r.path}`:r.path);return{key:ut(r),path:r.path,absolutePath:u,status:r.status,repoRoot:i,displayName:Ha(u,i).name,displayDir:Ha(u,i).dir,auditRecords:jt}})}function bc(r){const i=Array.from(we.values()).find(v=>ut(v)===r.key),u=i?it(i,b):null,x=Vm(jt,u,i?.path??r.path);return e.jsx(ji,{changeStatus:r.status,auditStatus:x,renderChangeBadge:v=>e.jsx(js,{status:v})})}const pa=o.useCallback(r=>{if(ee)return null;const i=Array.from(r.querySelectorAll("[data-diff-stream-item]"));if(i.length===0)return null;const x=r.getBoundingClientRect().top+48;let v=null,R=Number.POSITIVE_INFINITY;for(const H of i){const Y=H.getBoundingClientRect();if(Y.bottom<x)continue;const Ce=Math.abs(Y.top-x);Ce<R&&(v=H,R=Ce)}const A=v?.dataset.diffSelectionPath??v?.dataset.diffStreamItem??null;return A?(ra.current===A&&te.getState().selectedFilePath===A||(ra.current=A,Ye(A)),A):null},[ee,Ye]),Ff=!!(!Ae&&ve&&!We&&(de?.upstream||sn.trim()&&an.trim())),Df=!!(!Ae&&ve&&!We&&(de?.upstream||sn.trim()&&an.trim())),_f=!!(!Ae&&ve&&!We&&Ln.trim()&&Ln.trim()!==de?.branch),Ot=o.useMemo(()=>{const r=le.trim().toLowerCase(),i=Array.from(we.entries()).filter(([,u])=>!ce||it(u,b)===ce).sort(([u],[x])=>u.localeCompare(x));return r?i.filter(([u,x])=>`${u} ${x.path} ${x.status} ${x.repoRelativeRoot??""} ${x.repoName??""}`.toLowerCase().includes(r)):i},[ce,we,le,b]);o.useEffect(()=>{_a("selected_file_state",{selectedFilePath:Ve,selectedChangedFilePath:_t?.path??null,selectedChangedFileAbsolutePath:_t?.absolutePath??null,selectedChangedFileRepoRoot:_t?.repoRoot??null,rootPath:b,activeGitRepoRoot:ce,rightTab:go,effectiveRightTab:Hr,diffPaneActive:pt,changedFiles:we.size,filteredChangedFiles:Ot.length,gitBundleLoading:Dr,gitBundleLastLoadedAt:In})},[ce,we.size,pt,Hr,Ot.length,In,Dr,go,b,_t?.absolutePath,_t?.path,_t?.repoRoot,Ve]);const ps=o.useMemo(()=>{const r=new Map;for(const i of Ot){const[,u]=i,x=it(u,b),v=cb(u)||Ke,R=x??v,A=x?gt.get(x):void 0,H=r.get(R)??{root:x,label:v,branch:A?.context?.branch,files:[]};H.files.push(i),r.set(R,H)}return Array.from(r.values()).sort((i,u)=>i.label===Ke?-1:u.label===Ke?1:i.label.localeCompare(u.label))},[Ot,gt,Ke,b]),ga=o.useMemo(()=>{const r=[],i=new Map;for(const u of Ot)i.set(ut(u[1]),u);for(const u of ps){if(!!(u.root&&$i({activeGitRepoRoot:ce,groupCount:ps.length,label:u.label,rootName:Ke})&&Gt.has(u.root)))continue;if(St!=="tree"){r.push(...u.files);continue}const v=u.files.map(([,R])=>dc(R));for(const R of hm(v)){const A=i.get(R.key);A&&r.push(A)}}return r},[ce,Gt,St,ps,Ot,Ke]);o.useEffect(()=>{if(!pt||ga.length===0||ee)return;const r=[],i=()=>{const u=document.querySelector(".termdock-diff-stream-scroller");if(u&&pa(u))return;const x=document.querySelector("[data-diff-stream-item]"),v=x?.dataset.diffSelectionPath??x?.dataset.diffStreamItem??null;if(v){ra.current=v,Ye(v);return}const R=ga[0]?.[1];if(!R)return;const A=ut(R);ra.current=A,Ye(A)};for(const u of[80,240,600,1200])r.push(window.setTimeout(i,u));return()=>r.forEach(u=>window.clearTimeout(u))},[pt,ee,ga,Ye,pa]);const _o=o.useMemo(()=>{const r=A=>`'${A.replace(/'/g,"'\\''")}'`,i=qt.length>0?fn:V.filter(A=>A.files.length>0),u=i.length>0?i:b?[{root:b,relativeRoot:".",name:Ke}]:[],x=u.length>0?u.map(A=>`- ${A.relativeRoot==="."?".":A.relativeRoot} (${A.root})`).join(`
|
|
1667
|
-
`):`- ${b?".":""}`,v=u.length>0?u.map(A=>` td audit-export ${r(A.root)}`).join(`
|
|
1668
|
-
`):" td audit-export",R=u.length>0?" td audit ~/.termdock/change-audit/payload-<repo>.json":" td audit ~/.termdock/change-audit/payload.json";return["任务:为目标仓库的 Git diff hunk 生成自包含审计解释,并通过 Termdock CLI 注入。","",`当前工作区:${b??""}`,"目标仓库:",x,"","执行步骤:","1. 仅对“目标仓库”逐个执行 audit-export。嵌套子仓使用括号内 repo 绝对路径作为命令参数。",v,"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 后批量注入:",R,'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
|
-
`)},[qt.length,fn,V,Ke,b]),Bf=o.useCallback((r="generate")=>{if(bn&&Xr.length===0&&!ce){Ar(!0);return}const i=r==="generate"?_o:[r==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",_o].join(`
|
|
1670
|
-
`);et("insert_change_audit_prompt",{rootPath:b,activeGitRepoRoots:qt,mode:r,hasAuditListCommand:i.includes("td audit-list"),promptLength:i.length}),Wr(a("rightSidebar.insertChangeAuditPrompt"),i,`${Gl}:${r}`),or(),d||s()},[ce,_o,Xr.length,qt,Wr,or,s,d,b,bn,a]),ba=o.useCallback(async r=>{try{await Gc({ids:[r]}),Yr(i=>i.filter(u=>u.id!==r))}catch{or()}},[or]),Of=o.useCallback(async()=>{if(jt.length===0)return;const r=jt.map(i=>i.id);try{await Gc({ids:r}),Yr(i=>i.filter(u=>!r.includes(u.id))),Pt(null)}catch(i){const u=i instanceof Error?i.message:"Failed to clear change audit explanations";Pt(a("rightSidebar.changeAuditClearFailed",{message:u})),or()}},[jt,or,a]),Uf=o.useCallback(async r=>{if(r.records.length===0)return;const i=r.records.map(u=>u.id);try{await Fh({ids:i}),mr(u=>u.filter(x=>!i.includes(x.id))),Ze===r.key&&(tn(null),Zt(!1))}catch(u){dt(a("rightSidebar.branchAuditClearFailed",{message:u instanceof Error?u.message:"Failed to clear branch explanation"})),aa(null)}},[aa,Ze,a]),Hf=o.useCallback(r=>{Jr(i=>r===null?(Ar(!1),[]):i.includes(r)?i.filter(u=>u!==r):[...i,r])},[]),zf=o.useCallback(r=>{oo(i=>r===null?(ao(!1),[]):i.includes(r)?i.filter(u=>u!==r):[...i,r])},[]),Bo=o.useMemo(()=>{if(!sr)return[];const r=i=>{const u=i.diff??"";let x=0,v=0;for(const R of u.split(`
|
|
1671
|
-
`))R.startsWith("+++")||R.startsWith("---")||(R.startsWith("+")&&(x+=1),R.startsWith("-")&&(v+=1));return{filePath:i.filePath,oldPath:i.oldPath,newPath:i.newPath,hunkHeader:i.hunkHeader,hunkIndex:i.hunkIndex??0,fingerprint:i.fingerprint,additions:x,deletions:v,diff:u}};return Me?(Me.hunks??[]).map(i=>{const u=hr.find(x=>x.repoRoot===Me.repoRoot&&x.baseRef===Me.baseRef&&(x.branchName??null)===(Me.currentBranch??null)&&x.filePath===i.filePath&&x.hunkHeader===i.hunkHeader&&(x.hunkIndex??0)===i.hunkIndex&&x.fingerprint===i.fingerprint)??null;return{key:`${i.filePath}\0${i.hunkHeader}\0${i.hunkIndex}`,hunk:i,current:u,stale:null}}):Ze?hr.filter(i=>xd(i)===Ze).map(i=>{const u=r(i);return{key:`${i.filePath}\0${i.hunkHeader}\0${i.hunkIndex??0}`,hunk:u,current:i,stale:null}}):[]},[Me,hr,sr,Ze]),Oo=hr.length>0,zn=o.useMemo(()=>{if(!sr)return[];const r=new Map;for(const i of hr){const u=i.repoRoot,x=gt.get(u),v=x?.relativeRoot==="."?Ke:x?.relativeRoot||x?.name||ft(u),R=xd(i),A=r.get(R)??{key:R,repoRoot:u,repoLabel:v,baseRef:i.baseRef,branchName:i.branchName??null,headRef:i.headRef??null,diffFingerprint:i.diffFingerprint??null,records:[],latestInjectedAt:0};A.records.push(i),A.latestInjectedAt=Math.max(A.latestInjectedAt,i.injectedAt??0),r.set(R,A)}return Array.from(r.values()).sort((i,u)=>u.latestInjectedAt-i.latestInjectedAt)},[hr,gt,sr,Ke]),Uo=o.useMemo(()=>Ze?zn.find(r=>r.key===Ze)??null:null,[zn,Ze]),xa=Me?{repoRoot:Me.repoRoot??"",repoLabel:Me.repoRoot?gt.get(Me.repoRoot)?.relativeRoot==="."?Ke:gt.get(Me.repoRoot)?.relativeRoot||gt.get(Me.repoRoot)?.name||ft(Me.repoRoot):Ke,baseRef:Me.baseRef??Me.baseBranch??"",branchName:Me.currentBranch??null,headRef:Me.headRef??null,diffFingerprint:Me.diffFingerprint??null}:Uo,Wf=o.useMemo(()=>(Ue?.hunks??[]).map(r=>({key:`${r.filePath}\0${r.hunkHeader}\0${r.hunkIndex}`,hunk:r,current:null,stale:null})),[Ue?.hunks]),Gf=o.useMemo(()=>{if(Me)return[];const r=Uo;return r?kn.filter(i=>i.repoRoot===r.repoRoot&&i.baseRef===r.baseRef&&(i.branchName??null)===r.branchName&&(!r.diffFingerprint||i.diffFingerprint===r.diffFingerprint)):[]},[Me,kn,Uo]),qf=o.useCallback(r=>{const i=Bo.find(u=>u.hunk.filePath===r.filePath||(r.repoRoot?`${r.repoRoot}/${u.hunk.filePath}`===r.filePath:!1));i&&(rn(i.key),window.setTimeout(()=>xn(r),90),window.setTimeout(()=>xn(r),320),window.setTimeout(()=>xn(r),760))},[Bo]),Ho=o.useMemo(()=>{const r=v=>`'${v.replace(/'/g,"'\\''")}'`,i=Vt,u=i.length>0?i.map(v=>`- ${v.label} (${v.root}),目标分支:${xr[v.root]||v.branch||"(current branch)"},基线分支:${Rt[v.root]||"(not set)"}`).join(`
|
|
1672
|
-
`):`- ${b?".":""}`,x=i.length>0?i.map(v=>{const R=xr[v.root]||v.branch||"",A=Rt[v.root]||"",H=v.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[R?` git -C ${r(v.root)} switch ${r(R)}`:` # ${v.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${r(A)} ${r(v.root)} > ~/.termdock/branch-audit/branch-audit-export-${H}.json`].join(`
|
|
1673
|
-
`)}).join(`
|
|
1674
|
-
`):" td branch-audit-export <base-branch>";return["解释目标仓库当前分支相对于基线分支的改动,并把解释写回 Termdock。","",`当前工作区:${b??""}`,`包含本地未提交更改:${Ir?"是":"否"}`,"目标仓库:",u,"","操作指令:",Ir?"1. 只针对上面列出的目标仓库导出分支 hunk;如果指定了目标分支,先在对应仓库切到目标分支。导出内容需要包含目标分支相对基线分支的提交改动,以及当前工作区 staged/unstaged/untracked 改动。嵌套子仓或软链接子仓必须使用括号里的仓库绝对路径,不要改用当前工作区根目录。示例:":"1. 只针对上面列出的目标仓库导出分支 hunk;如果指定了目标分支,先在对应仓库切到目标分支。不要包含本地 staged/unstaged/untracked 改动;如果导出结果里混入了本地工作区改动,生成解释时必须忽略这些本地改动,只解释目标分支相对基线分支的提交改动。嵌套子仓或软链接子仓必须使用括号里的仓库绝对路径,不要改用当前工作区根目录。示例:",x,"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:b??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
|
-
`)},[Ir,Vt,Rt,xr,b]),Kf=o.useCallback((r="generate")=>{const i=r==="generate"?Ho:[r==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",Ho].join(`
|
|
1676
|
-
`);Wr(a("rightSidebar.branchAuditShort"),i,`context:branch-audit-scope:${r}`),d||s()},[Ho,Wr,s,d,a]),Vf=o.useCallback(async()=>{if(!b||Vt.length===0)return;const r=b;z(!0),xe(null),er(null),$e(null);try{const i=await Promise.all(Vt.map(async H=>{const Y=Rt[H.root]?.trim();if(!Y)throw new Error(a("rightSidebar.branchAuditMissingBase",{repo:H.label}));const Ce=(xr[H.root]||H.branch||"").trim();return Dh({cwd:b,repoRoot:H.root,base:Y,head:Ce&&Ce!==H.branch?Ce:null,includeUncommitted:Ir,requestSlotId:`right-sidebar-branch-preview:${H.root}`})}));if(!ke(r))return;const u=i.find(H=>!H.available);if(u){xe(u.error??"Branch diff is unavailable");return}const x=i.length===1?i[0]:{available:!0,workspaceRoot:b,repoRoot:b,baseRef:i.map(H=>H.baseRef??H.baseBranch).filter(Boolean).join(", "),currentBranch:i.map(H=>H.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:i.map(H=>H.headRef).filter(Boolean).join(", "),diffFingerprint:i.map(H=>H.diffFingerprint).filter(Boolean).join("+"),stat:i.map(H=>H.stat).filter(Boolean).join(`
|
|
1677
|
-
`),files:i.flatMap((H,Y)=>{const Ce=Vt[Y];return(H.files??[]).map(He=>`${Ce?.label??H.repoRoot??"repo"}/${He}`)}),hunks:i.flatMap((H,Y)=>{const He=Vt[Y]?.label??H.repoRoot??"repo";return(H.hunks??[]).map(Pe=>({...Pe,filePath:`${He}/${Pe.filePath}`,oldPath:Pe.oldPath?`${He}/${Pe.oldPath}`:Pe.oldPath,newPath:Pe.newPath?`${He}/${Pe.newPath}`:Pe.newPath}))}),commits:i.flatMap(H=>H.commits??[]),commitCount:i.reduce((H,Y)=>H+(Y.commitCount??Y.commits?.length??0),0),diff:i.map(H=>H.diff).filter(Boolean).join(`
|
|
1678
|
-
`),truncated:i.some(H=>H.truncated)};if((x.hunks??[]).length===0){xe(a("rightSidebar.branchAuditDiffEmpty"));return}const v=Date.now(),R=["preview",x.repoRoot??b,x.baseRef??x.baseBranch??"",x.currentBranch??"",x.headRef??"",x.diffFingerprint??v].join("\0"),A=Vt.length===1?Vt[0].label:`${Vt.length} repos`;er(x),es(H=>[{key:R,diff:x,repoLabel:A,createdAt:v},...H.filter(Y=>Y.key!==R)].slice(0,8)),Rn(H=>H[R]===void 0?H:{...H,[R]:0}),tn(R),rn(x.hunks?.[0]?`${x.hunks[0].filePath}\0${x.hunks[0].hunkHeader}\0${x.hunks[0].hunkIndex}`:null),Zt(!0)}catch(i){if(!ke(r)||Cr(i))return;xe(i instanceof Error?i.message:"Failed to load branch diff")}finally{ke(r)&&z(!1)}},[Ir,Vt,Rt,xr,ke,b,a]),Yf=o.useCallback(r=>{er(r.diff),xe(null),tn(r.key),rn(r.diff.hunks?.[0]?`${r.diff.hunks[0].filePath}\0${r.diff.hunks[0].hunkHeader}\0${r.diff.hunks[0].hunkIndex}`:null),Zt(!0)},[]),Xf=o.useCallback(r=>{es(i=>i.filter(u=>u.key!==r)),Rn(i=>{if(!(r in i))return i;const u={...i};return delete u[r],u}),Ze===r&&(tn(null),er(null),Zt(!1))},[Ze]),Jf=o.useCallback(r=>{const i=zn.find(u=>u.key===r);i&&(er(null),xe(null),tn(r),rn(i.records[0]?.filePath??null),Zt(!0))},[zn]),Qf=o.useCallback(async r=>{if(!b||!ve)return;const[i]=r.split(/\s+/);if(i){_e(i),at(null),$e(null);try{const u=await _h({cwd:b,repoRoot:ve,commit:i,requestSlotId:"right-sidebar-commit-diff"});if(!u.available){at(u.error??"Commit diff is unavailable");return}$e(u);const x=u.hunks?.[0];_s(x?`${x.filePath}\0${x.hunkHeader}\0${x.hunkIndex}`:null)}catch(u){at(u instanceof Error?u.message:"Failed to load commit diff")}finally{_e(null)}}},[ve,b]),Zf=o.useCallback(r=>{if(!Me||!Ze)return;const i=Math.max(0,Math.round(r));Rn(u=>Math.abs((u[Ze]??0)-i)<24?u:{...u,[Ze]:i})},[Me,Ze]);o.useEffect(()=>{!ee||!pr||!Me||cs(1)},[pr,Me,ee,cs]);const xc=o.useCallback(r=>{r&&mf(i=>mm(i,r))},[]),vc=Xs.key===Ve?Xs.key:null,va=o.useCallback(r=>{const i=te.getState(),u=kb();_a("select_diff_file",{interactionId:u,path:r,previousSelectedFilePath:i.selectedFilePath,rootPath:i.rootPath,activeGitRepoRoot:ce,changedFiles:i.changedFiles.size,gitBundleLoading:i.gitBundleLoading,gitBundleLastLoadedAt:i.gitBundleLastLoadedAt,rightTab:i.rightTab}),Ye(r),on("diff"),ee&&r&&cs(1),xc(r),queueMicrotask(()=>{const x=te.getState();_a("select_diff_file_after",{interactionId:u,requestedPath:r,selectedFilePath:x.selectedFilePath,rootPath:x.rootPath,rightTab:x.rightTab,changedFiles:x.changedFiles.size,activeGitRepoRoot:ce})})},[ce,ee,xc,Ye,on,cs]),yc=o.useCallback(r=>{const i=Array.from(we.values()).find(u=>{const x=it(u,b),v=ut(u);return u.path===r.filePath||v===r.filePath||u.absolutePath===r.filePath||(x?`${x}/${u.path}`===r.filePath:!1)||r.repoRoot&&x===r.repoRoot&&u.path===r.filePath});if(i){va(ut(i)),window.setTimeout(()=>xn(r),90),window.setTimeout(()=>xn(r),320),window.setTimeout(()=>xn(r),760);return}xn(r)},[we,b,va]),wc=o.useCallback(({slideToDetail:r,fullscreen:i,toggleFullscreen:u}={})=>Qn.length>0?e.jsx(Hd,{walkthroughs:Qn,repoRoot:ce,fullscreen:i,onToggleFullscreen:u,onNavigate:x=>{ee&&window.requestAnimationFrame(()=>r?.()),yc(x)}}):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(Es,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),a("rightSidebar.changeWalkthroughEmpty")]}),[ce,Qn,yc,ee,a]),eh=o.useCallback(r=>{r&&Mr(i=>{const u=new Set(i);return u.has(r)?u.delete(r):u.add(r),si(Zo,u),u})},[]),kc=o.useCallback(r=>{to(i=>{const u=new Set(i);return u.has(r)?u.delete(r):u.add(r),si(id,u),u})},[]),ya=o.useCallback(r=>{Is(r),xt(ou,r)},[]);o.useEffect(()=>{fa||St!=="ai"||ya("tree")},[St,ya,fa]);const wa=o.useCallback(()=>{Fs(r=>{const i=!r;return xt(iu,i),i})},[]),Sc=o.useCallback(r=>{Vr(r),xt(lu,r)},[]),{whitespace:jc,context:Rc}=gm(),Cc=o.useMemo(()=>({algorithm:"histogram",whitespace:jc,context:Rc}),[jc,Rc]),Nc=o.useCallback(r=>{_(r),xt(cu,r)},[]),ka=o.useCallback(async(r,i,u,x)=>{let v=r;for(;v.ok&&v.status==="running";)await new Promise(A=>window.setTimeout(A,1500)),v=await qc({jobId:v.jobId,cwd:i.cwd,action:i.action});if(!v.ok)throw new Error("Git action status is unavailable");if(v.status==="error")throw new Error(v.error||v.message||"Git action failed");const R={action:i.action,path:x,label:u};return as(R),window.setTimeout(()=>as(A=>A?.action===R.action&&A.path===R.path?null:A),1400),v},[]),ot=o.useCallback(async(r,i,u)=>{const x=b;b&&ar.current.delete(b),dt(null),as(null),ss({action:r.action,path:u});try{const v=await Bh({...r,includeNested:Gn(b)}),R=await ka(v,r,i,u);if(!ke(x))return!1;const A=b?await Ca(b,void 0,{includeNested:Gn(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Kn(b)}).catch(()=>R.bundle):R.bundle;return ke(x)?(A&&Ur(A,{reloadDiff:!0,cacheOnly:!0}),Fr(null),!0):!1}catch(v){return as(null),dt(a("rightSidebar.gitActionFailed",{message:v instanceof Error?v.message:"Unknown error"})),!1}finally{ke(x)&&ss(null)}},[Ur,ke,b,a,ka]),Mc=o.useCallback(async r=>{const i=b,u=await Oh({...r,includeNested:Gn(b)});if(!ke(i))return;const x=b?await Ca(b,void 0,{includeNested:Gn(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Kn(b)}).catch(()=>u.bundle):u.bundle;ke(i)&&x&&Ur(x,{reloadDiff:!0,cacheOnly:!0})},[Ur,ke,b]),Sa=o.useCallback((r,i,u)=>{if(i){if(r==="stage-all"){ot({action:"stage-all",cwd:i},a("rightSidebar.stageAll"),`repo:${i}`);return}Fr({kind:"stash-all",repoRoot:i,repoLabel:u})}},[ot,a]),$c=o.useCallback(r=>{Je(r),ni(b,r),Gs(""),qs(""),Ks(""),Ye(tc(r)),Xe||on("diff"),r&&r!==b&&V.find(u=>u.root===r)?.deferred&&Kt(r,{includeNested:!1,background:!0,replaceRepoRoot:r})},[tc,Xe,V,Kt,b,Ye,on]),Ec=o.useCallback(r=>{const i=new Set([...Dt.current.keys(),...dn.current,...ar.current]);for(const u of i)u!==r&&(Ft.current.delete(u),Dt.current.get(u)?.abort(),Dt.current.delete(u),bt(`right-sidebar-git-untracked:${u}`),dn.current.delete(u),ar.current.delete(u))},[]),th=o.useCallback(async r=>{const i=b;if(!i||(await te.getState().setNestedGitScanRoot(i,r),!ke(i)))return;if(r){await Kt(i,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}Ec(i),Gs(""),qs(""),Ks(""),oo(x=>x.filter(v=>v===i));const u=_t;u&&it(u,i)!==i&&Ye(null),await Kt(i,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[Ec,ke,Kt,b,Ye,_t]),rh=o.useCallback(async()=>{if(!ve||We){dt(a("rightSidebar.selectRepositoryForGitActions"));return}const r=Ln.trim();!r||r===de?.branch||await ot({action:"switch-branch",cwd:ve,branch:r},a("rightSidebar.switchBranch"))},[de?.branch,ve,We,ot,Ln,a]),Lc=o.useCallback(async()=>{if(!ve||We){dt(a("rightSidebar.selectRepositoryForGitActions"));return}const r=Ws.trim();if(!r)return;await ot({action:"commit",cwd:ve,message:r},a("rightSidebar.commitChanges"))&&dl("")},[ve,Ws,We,ot,a]),nh=o.useCallback(async()=>{if(!ve||We){dt(a("rightSidebar.selectRepositoryForGitActions"));return}const r=sn.trim(),i=an.trim();await ot({action:"push",cwd:ve,...r?{remote:r}:{},...i?{branch:i}:{}},a("rightSidebar.pushChanges"))},[ve,an,sn,We,ot,a]),sh=o.useCallback(async()=>{if(!ve||We){dt(a("rightSidebar.selectRepositoryForGitActions"));return}const r=sn.trim(),i=an.trim();await ot({action:"pull",cwd:ve,...r?{remote:r}:{},...i?{branch:i}:{}},a("rightSidebar.pullChanges"))},[ve,an,sn,We,ot,a]);o.useEffect(()=>{if(!Xe||!ve||Ae)return;let r=!1;const i={push:a("rightSidebar.pushChanges"),pull:a("rightSidebar.pullChanges"),commit:a("rightSidebar.commitChanges"),"switch-branch":a("rightSidebar.switchBranch"),"stage-all":a("rightSidebar.stageAll"),"stash-all":a("rightSidebar.stashAll")};return(async()=>{for(const u of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(r)return;const x=await qc({cwd:ve,action:u}).catch(()=>null);if(!x?.ok||x.status!=="running")continue;const v={action:u,cwd:ve},R=i[u]??u;ss({action:u});try{const A=await ka(x,v,R);if(r||!ke(b))return;const H=b?await Ca(b,void 0,{includeNested:Gn(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Kn(b)}).catch(()=>A.bundle):A.bundle;H&&Ur(H,{reloadDiff:!0,cacheOnly:!0})}catch(A){r||dt(a("rightSidebar.gitActionFailed",{message:A instanceof Error?A.message:"Unknown error"}))}finally{r||ss(null)}return}})(),()=>{r=!0}},[ve,Ur,Xe,ke,b,Ae,a,ka]);const zo=$n?.action==="commit",Wo=$n?.action==="switch-branch",Go=$n?.action==="pull",qo=$n?.action==="push",ja=Xe||ff,Ko=ma?a("rightSidebar.changeAuditScopeAll"):ir.length===1?ir[0].label:`${ir.length} repos`,ah=ir.length>0,Ac=Vt.length>0,oh=b?e.jsx(Cd,{open:so,onOpenChange:ao,showScopePicker:!0,selectedAll:ma,repos:Bt,selectedRoots:ha,onToggleRepo:zf,onGenerate:()=>Kf(Oo?"regenerate":"generate"),disabled:!ah,generateDisabled:!Ac,inserted:q?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:a(Oo?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:a("rightSidebar.inserted"),title:a("rightSidebar.branchAuditGenerateTitle"),ariaLabel:a("rightSidebar.branchAuditShort"),scopeTitle:a("rightSidebar.changeAuditScopeLabel"),scopeLabel:Ko,allLabel:a("rightSidebar.changeAuditScopeAll"),generateLabel:a(Oo?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{Vf()},secondaryDisabled:!Ac||T,secondaryLabel:a("rightSidebar.branchAuditViewDiff"),secondaryTitle:a("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:T,loading:sl.size>0,statusTitle:sl.size>0?a("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsxs("div",{className:"mb-2 space-y-1.5",children:[e.jsxs("label",{className:"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:a("rightSidebar.includeUncommitted")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:a("rightSidebar.includeUncommittedHint")})]}),e.jsx("input",{type:"checkbox",checked:Ir,onChange:r=>nl(r.target.checked),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]}),oc.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:a("rightSidebar.missingBaseReposSkipped",{repositories:oc.map(r=>r.label).join(w==="zh"?"、":", ")})})]}),renderRepoExtra:r=>{const i=gt.get(r.root),u=[],x=new Set,v=(Y,Ce)=>{!Y||x.has(Y)||(x.add(Y),u.push({value:Y,label:Y,meta:Ce}))};v(xr[r.root]||i?.context?.branch,a("rightSidebar.pushCurrentBranchBadge"));for(const Y of i?.context?.branches??[])v(Y,Y===i?.context?.branch?a("rightSidebar.pushCurrentBranchBadge"):a("rightSidebar.localBranch"));for(const Y of i?.context?.remoteBranches??[])v(Y,a("rightSidebar.remoteBranch"));const R=[],A=new Set,H=(Y,Ce)=>{!Y||A.has(Y)||(A.add(Y),R.push({value:Y,label:Y,meta:Ce}))};H(Rt[r.root],Rt[r.root]?a("rightSidebar.pushUpstreamBadge"):void 0),H(i?.context?.upstream,i?.context?.upstream?a("rightSidebar.pushUpstreamBadge"):void 0);for(const Y of i?.context?.remoteBranches??[])H(Y,"remote");for(const Y of i?.context?.branches??[])H(Y,Y===i?.context?.branch?a("rightSidebar.pushCurrentBranchBadge"):"local");return e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsx(qn,{label:a("rightSidebar.currentBranchLabel"),value:xr[r.root]||i?.context?.branch||"",options:u,placeholder:a("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:a("rightSidebar.switchBranchSearchPlaceholder"),emptyText:a("rightSidebar.switchNoBranches"),onChange:Y=>{Os(Ce=>({...Ce,[r.root]:Y}))}}),e.jsx(qn,{label:a("rightSidebar.branchAuditBaseLabel"),value:Rt[r.root]||"",options:R,placeholder:a("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:a("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:a("rightSidebar.branchAuditBaseEmpty"),onChange:Y=>{Us(Ce=>({...Ce,[r.root]:Y}))}})]})}}):null,Pc=ys(jt.reduce((r,i)=>Math.max(r,i.injectedAt??0),0),w),ih=b?e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>rl(r=>{const i=!r;return xt(ei,i),i}),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":ns,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(Es,{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:a("rightSidebar.branchAuditTitle")}),e.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:Ko})]}),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 ${ns?"rotate-90":""}`,children:e.jsx(Na,{size:13})})]}),ns&&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:[a("rightSidebar.changeAuditScopeLabel"),": ",Ko]}),oh]}),ie&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:ie}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[Qr.map(r=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ze===r.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:()=>Yf(r),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:r.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[r.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:r.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:r.diff.baseRef??r.diff.baseBranch}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:a("rightSidebar.branchAuditViewDiff")})]}),ys(r.createdAt,w)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:ys(r.createdAt,w)})]}),e.jsx("button",{type:"button",onClick:()=>Xf(r.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:a("common.delete"),"aria-label":a("common.delete"),children:e.jsx(Ba,{size:12})})]},r.key)),zn.length>0?zn.slice(0,Math.max(0,8-Qr.length)).map(r=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ze===r.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:()=>Jf(r.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:r.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[r.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:r.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:r.baseRef}),r.diffFingerprint&&e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.diffFingerprint})]}),ys(r.latestInjectedAt,w)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:a("rightSidebar.branchAuditGeneratedAt",{time:ys(r.latestInjectedAt,w)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{Uf(r)},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:a("rightSidebar.branchAuditClearTitle"),"aria-label":a("rightSidebar.branchAuditClearTitle"),children:e.jsx(Ba,{size:12})})]},r.key)):Qr.length===0?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:a("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,Tc=sr&&b&&Hn?e.jsxs("div",{className:ja?"overflow-visible":"overflow-hidden",children:[ih,e.jsxs("button",{type:"button",onClick:()=>{Xe||hf(r=>{const i=!r;return i&&ve&&!Hn&&!nn&&Ro(ve),i})},"aria-expanded":ja,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${Xe?"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(Rr,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:a("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 ${gn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[nn&&e.jsx(vt,{size:10,className:"animate-spin"}),gn.staged>0?a("rightSidebar.stagedCount",{count:gn.staged}):a("rightSidebar.noStagedChangesShort")]}),!Xe&&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 ${ja?"rotate-90":""}`,children:e.jsx(Na,{size:13})})]})]}),ja&&e.jsxs("div",{className:"space-y-0",children:[Lt.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:a("rightSidebar.gitRepositorySectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Mf})]})}),e.jsx(qn,{label:a("rightSidebar.gitRepositoryLabel"),value:ve??"",options:Lt,placeholder:a("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:a("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:a("rightSidebar.gitRepositoryEmpty"),disabled:!!Ae,onChange:r=>{$c(r||null)}}),We&&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:a("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:a("rightSidebar.branchSectionTitle")}),e.jsx("div",{className:"mt-0.5 h-4 truncate text-[11px] leading-4 text-muted-foreground",children:Ln!==ec?ec:null})]}),e.jsxs("button",{type:"button",onClick:()=>{rh()},disabled:!_f,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 ${Wo?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.switchBranch"),children:[e.jsx("span",{className:Ae?.action==="switch-branch"||Wo?"opacity-0":"",children:a("rightSidebar.switchBranch")}),Ae?.action==="switch-branch"&&e.jsx(vt,{size:12,className:"absolute animate-spin"}),Wo&&Ae?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(qn,{label:a("rightSidebar.currentBranchLabel"),value:Ln,options:Lf,placeholder:a("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:a("rightSidebar.switchBranchSearchPlaceholder"),emptyText:a("rightSidebar.switchNoBranches"),disabled:!!Ae,onChange:Gs})]}),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:a("rightSidebar.commitSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:We?a("rightSidebar.selectRepositoryForGitActions"):gn.staged>0?a("rightSidebar.commitReadyHint",{count:gn.staged}):a("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{Lc()},disabled:!!Ae||We||gn.staged===0||!Ws.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 ${zo?"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:We?a("rightSidebar.selectRepositoryForGitActions"):gn.staged===0?a("rightSidebar.commitNeedsStaged"):a("rightSidebar.commitChanges"),children:[e.jsx("span",{className:Ae?.action==="commit"||zo?"opacity-0":"",children:a("rightSidebar.commitChanges")}),Ae?.action==="commit"&&e.jsx(vt,{size:12,className:"absolute animate-spin"}),zo&&Ae?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:Ws,onChange:r=>dl(r.target.value),onKeyDown:r=>{(r.metaKey||r.ctrlKey)&&r.key==="Enter"&&(r.preventDefault(),Lc())},placeholder:a("rightSidebar.commitMessagePlaceholder"),disabled:!!Ae,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:()=>gr(r=>!r),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":tr,children:[e.jsx("span",{className:"min-w-0 text-[12px] font-medium text-foreground",children:a("rightSidebar.recentCommitsTitle")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[Q&&e.jsx(vt,{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 ${tr?"rotate-90":""}`,children:e.jsx(Na,{size:13})})]})]}),tr&&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(Vn,{size:12,className:"shrink-0"}),e.jsx("input",{value:Cn,onChange:r=>Zr(r.target.value),placeholder:a("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}),Cn&&e.jsx("button",{type:"button",onClick:()=>Zr(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.clearSearch"),children:e.jsx(Ut,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:$f,children:[en.length>0?en.map(r=>{const[i,...u]=r.split(/\s+/),x=u.join(" ")||r;return e.jsxs("button",{type:"button",onClick:()=>{Qf(r)},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:x,children:[e.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:x,children:x}),rr[i]&&e.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${rr[i]==="ahead"?"bg-accent/10 text-accent":rr[i]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:a(rr[i]==="ahead"?"rightSidebar.commitAhead":rr[i]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),ze===i&&e.jsx(vt,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},r)}):Q?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:a("common.loading")}):e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:a("rightSidebar.recentCommitsEmpty")}),Tt&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(vt,{size:12,className:"animate-spin"})}),no&&!Tt&&en.length>0&&e.jsx("button",{type:"button",onClick:()=>{ms({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:a("rightSidebar.recentCommitsLoadMore")})]})]}),nt&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:nt}),el&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:el})]}),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:a("rightSidebar.pushSectionTitle")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>{sh()},disabled:!Ff,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 ${Go?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.pullChanges"),children:[e.jsx("span",{className:Ae?.action==="pull"||Go?"opacity-0":"",children:a("rightSidebar.pullChanges")}),Ae?.action==="pull"&&e.jsx(vt,{size:12,className:"absolute animate-spin"}),Go&&Ae?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{nh()},disabled:!Df,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 ${qo?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.pushChanges"),children:[e.jsx("span",{className:Ae?.action==="push"||qo?"opacity-0":"",children:a("rightSidebar.pushChanges")}),Ae?.action==="push"&&e.jsx(vt,{size:12,className:"absolute animate-spin"}),qo&&Ae?.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:de?.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:de?.upstream??""})]}),e.jsxs("div",{className:`grid gap-1.5 ${ac?"grid-cols-2":"grid-cols-1"}`,children:[ac&&e.jsx(qn,{label:a("rightSidebar.pushRemoteLabel"),value:sn,options:sc,placeholder:a("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:a("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:a("rightSidebar.pushNoRemotes"),disabled:!!Ae,onChange:qs}),e.jsx(qn,{label:a("rightSidebar.pushBranchLabel"),value:an,options:Af,placeholder:a("rightSidebar.pushBranchPlaceholder",{branch:de?.branch??"HEAD"}),searchPlaceholder:a("rightSidebar.pushBranchSearchPlaceholder"),emptyText:a("rightSidebar.pushNoBranches"),disabled:!!Ae,onChange:Ks})]})]})]})]}):null,lh=o.useCallback(r=>{const i=it(r,b);if(!i)return[];const u=hi(r),x=[];return r.canStage&&x.push({key:"stage-file",label:a("rightSidebar.stageFile"),onClick:()=>{ot({action:"stage-file",cwd:i,paths:[r.path]},a("rightSidebar.stageFile"),u)}}),r.canUnstage&&x.push({key:"unstage-file",label:a("rightSidebar.unstageFile"),onClick:()=>{ot({action:"unstage-file",cwd:i,paths:[r.path]},a("rightSidebar.unstageFile"),u)}}),r.canStash&&x.push({key:"stash-file",label:a("rightSidebar.stashFile"),onClick:()=>{ot({action:"stash-file",cwd:i,paths:[r.path]},a("rightSidebar.stashFile"),u)}}),r.canRestoreWorktree&&x.push({key:"restore-worktree-file",label:a("rightSidebar.restoreFile"),destructive:!0,onClick:()=>Fr({kind:"restore",file:r,phrase:""})}),x},[b,ot,a]),ch=o.useCallback(()=>{if(m){f?.();return}yr(0),kr.current?.slideTo(0),vr(!1),kt(null)},[f,m]),Ic=o.useCallback(r=>{if(j(""),It(r),Ye(null),kt(null),ne(null),ee){m&&f?.(),yr(0),kr.current?.slideTo(0),vr(!1);return}},[ee,f,m,Ye,It]);o.useEffect(()=>{const r=i=>{const u=i.detail,x=u?.path;if(typeof x!="string"||!x.startsWith("/"))return;j(""),kt(null),Ie(null);const v=!!(b&&(x===b||x.startsWith(`${b}/`)));if(u.kind==="file"){const R=di(x);us(x),typeof u.line=="number"&&Number.isSafeInteger(u.line)&&u.line>0&&Ie(u.line),It(v?null:R),ne(A=>({path:x,nonce:(A?.nonce??0)+1}));return}Ye(null),v?(It(null),ne(R=>({path:x,nonce:(R?.nonce??0)+1}))):(ne(null),It(x)),ee&&(m&&f?.(),yr(0),kr.current?.slideTo(0),vr(!1))};return window.addEventListener(Kc,r),()=>window.removeEventListener(Kc,r)},[us,ee,f,m,b,Ye,It]),o.useEffect(()=>{t||(At(!1),zt(!1))},[t]),o.useEffect(()=>{if(!Jt&&!dr)return;const r=i=>{i instanceof globalThis.KeyboardEvent&&i.key!=="Escape"||i instanceof globalThis.MouseEvent&&i.target instanceof Node&&(Ts.current?.contains(i.target)||wn.current?.contains(i.target))||(At(!1),zt(!1))};return window.addEventListener("mousedown",r),window.addEventListener("keydown",r),()=>{window.removeEventListener("mousedown",r),window.removeEventListener("keydown",r)}},[dr,Jt]);const Fc=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:Rf,disabled:!ca,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":a("rightSidebar.parentFolder"),title:a("rightSidebar.parentFolder"),children:e.jsx(Dd,{size:14})}),e.jsx("button",{type:"button",onClick:ql,disabled:!b||Pn===b,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":a("rightSidebar.backToProjectRoot"),title:a("rightSidebar.backToProjectRoot"),children:e.jsx(Xc,{size:14})}),e.jsx("button",{type:"button",onClick:Cf,disabled:!pe,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":a("rightSidebar.refreshFiles"),title:ul?a("rightSidebar.fileWatchUnavailable",{message:ul}):a("rightSidebar.refreshFiles"),children:e.jsx(vi,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:pe??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:Sf}),ea==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:a("fileTree.sortedByModified"),"aria-label":a("fileTree.sortedByModified"),children:e.jsx(Vc,{size:11})})]})}),e.jsx("button",{type:"button",onClick:()=>pe&&zr(pe,Et??void 0),disabled:!pe,...pe&&Et?$o(la(pe),Et):{},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 ${Et&&(q===Et||Re===Et)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":a(Et&&Re===Et?"rightSidebar.copied":Et&&q===Et?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:a("rightSidebar.insertCurrentFolder"),children:Et&&(q===Et||Re===Et)?e.jsx(bi,{size:13}):e.jsx(za,{size:13})}),e.jsxs("div",{ref:wn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{At(!1),zt(r=>!r)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${dr?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":dr,"aria-haspopup":"menu","aria-label":a("sidebar.moreActions"),title:a("sidebar.moreActions"),children:e.jsx(xi,{size:14})}),dr&&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:()=>{zt(!1),Nf()},disabled:!Ao,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${hs?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[hs?e.jsx(Xo,{size:14}):e.jsx($a,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(hs?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),gf()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${bo?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[bo?e.jsx(ym,{size:14}):e.jsx(ki,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(bo?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!pe,onClick:()=>{pe&&(zt(!1),bf(pe,ea==="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:[ea==="modified"?e.jsx(nm,{size:14}):e.jsx(Vc,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(ea==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),b&&(da.length>0||jf)&&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:a("rightSidebar.pinnedFolders")}),e.jsxs("button",{type:"button",onClick:ql,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 ${pe===b?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:b,children:[e.jsx(Xc,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:Ke})]}),da.map(r=>{const i=r.path,u=r.kind==="file",x=u?Ve===i:pe===i;return e.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${x?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i,children:[e.jsxs("button",{type:"button",onClick:()=>u?us(i):It(i),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[u?e.jsx(Si,{size:10,className:"shrink-0"}):e.jsx($a,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:ft(i)})]}),e.jsx("button",{type:"button",onClick:()=>ln(i),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":a("rightSidebar.unpinFolder",{name:ft(i)}),title:a("rightSidebar.unpinFolder",{name:ft(i)}),children:e.jsx(Ut,{size:9})})]},i)})]}),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"})]}),Vo=o.useMemo(()=>{if(En===null)return null;const r=typeof navigator>"u"?void 0:navigator.language,i=Math.max(0,Math.floor((fo-En)/1e3)),u=new Intl.RelativeTimeFormat(r,{numeric:"auto"}),[x,v]=i<60?[-i,"second"]:i<3600?[-Math.floor(i/60),"minute"]:i<86400?[-Math.floor(i/3600),"hour"]:[-Math.floor(i/86400),"day"];return u.format(x,v)},[fo,En]),Dc=b&&!ds?e.jsx("button",{type:"button",onClick:()=>{th(!xo)},"aria-pressed":xo,title:a("rightSidebar.multiRepoScanTitle"),className:`inline-flex h-7 shrink-0 items-center rounded-md px-2.5 text-[11px] font-medium transition active:scale-95 ${xo?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:a("rightSidebar.multiRepoScan")}):null,_c=b?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[Vo?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:a("rightSidebar.gitLastUpdated",{time:Vo}),children:Vo}):null,e.jsx("button",{type:"button",onClick:()=>{ls()},disabled:Dr,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":a("rightSidebar.refreshGit"),title:a("rightSidebar.refreshGit"),children:e.jsx(vi,{size:13,className:Dr?"animate-spin":""})})]}):null,dh=Pl?a("rightSidebar.changeAuditScopeAll"):fn.length===1?fn[0].relativeRoot==="."?Ke:fn[0].relativeRoot||fn[0].name:`${fn.length} repos`,Bc=b?e.jsxs("div",{className:"inline-flex h-7 shrink-0 items-center",children:[e.jsx(Cd,{open:Ds,onOpenChange:Ar,showScopePicker:bn,selectedAll:Pl,repos:xf,selectedRoots:qt,onToggleRepo:Hf,onGenerate:()=>Bf(),disabled:!b,inserted:q===Gl,buttonLabel:a("rightSidebar.changeAuditShort"),insertedLabel:a("rightSidebar.inserted"),title:a("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:a("rightSidebar.insertChangeAuditPrompt"),scopeTitle:a("rightSidebar.changeAuditScopeLabel"),scopeLabel:dh,allLabel:a("rightSidebar.changeAuditScopeAll"),generateLabel:a("rightSidebar.changeAuditShort"),loading:$r,error:!!Lr,statusTitle:Lr??($r?a("rightSidebar.changeAuditLoading"):jt.length>0?`${a("rightSidebar.changeAuditLoaded",{count:jt.length})}${Pc?` · ${a("rightSidebar.changeAuditLoadedAt",{time:Pc})}`:""}`:void 0)}),e.jsx("button",{type:"button",onClick:()=>{Of()},disabled:$r||jt.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 ${jt.length>0?"":"invisible"}`,title:a("rightSidebar.clearChangeAuditTitle"),"aria-label":a("rightSidebar.clearChangeAudit"),children:e.jsx(Ba,{size:12})})]}):null,Ra=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:[ae?.available&&ae.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:ae.branch,children:[e.jsx(Rr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:ae.branch})]}),st.modified>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[st.modified,"M"]}),st.added>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",st.added]}),st.deleted>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",st.deleted]}),st.renamed>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[st.renamed,"R"]}),st.copied>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[st.copied,"C"]}),st.untracked>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[st.untracked,"U"]}),st.conflicted>0&&e.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[st.conflicted,"!"]}),st.other>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[st.other,"?"]}),st.staged>0&&e.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:a("rightSidebar.stagedCountShort",{count:st.staged})}),ae?.available&&b&&we.size>0&&V.length<=1&&e.jsx("button",{type:"button",onClick:()=>{ot({action:"stage-all",cwd:b},a("rightSidebar.stageAll"))},disabled:!!Ae,className:"rounded-md bg-accent/10 px-2 py-0.5 font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:a("rightSidebar.stageAll"),children:a("rightSidebar.stageAll")}),ae?.available&&b&&we.size>0&&V.length<=1&&e.jsx("button",{type:"button",onClick:()=>Fr({kind:"stash-all",repoRoot:b,repoLabel:Ke}),disabled:!!Ae,className:"rounded-md bg-surface-2 px-2 py-0.5 font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:a("rightSidebar.stashAll"),children:a("rightSidebar.stashAll")})]});return e.jsxs(sm,{side:"right",isOpen:t,drawerWidthPx:n,onClose:s,onOpen:l,push:d,pinned:c,children:[$o.popoverNode,e.jsxs("div",{className:"relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2",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:b??void 0,children:Ke}),(!ee||co)&&ae?.available&&ae.branch&&e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:ae.branch,children:[e.jsx(Rr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"max-w-[7rem] truncate",children:ae.branch})]})]})}),e.jsx("button",{type:"button",onClick:()=>{const r=!se;fe(r),r?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):j("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${se?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a("rightSidebar.toggleSearch"),title:a("common.search"),children:e.jsx(Vn,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":Qe,onClick:()=>{vn(r=>!r),lr(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Qe?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a("rightSidebar.toggleContextDraft"),title:a("rightSidebar.contextDraftTitle"),children:[e.jsx(am,{size:14}),!Qe&&wt.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:pl,type:"file",multiple:!0,className:"hidden",onChange:r=>{const i=r.target.files;!i||i.length===0||(fs(Array.from(i)),r.target.value="")}}),e.jsx("input",{ref:gl,type:"file",accept:"image/*",className:"hidden",onChange:r=>{const i=r.target.files?.[0];r.target.value="",i&&kf(i)}}),h&&e.jsx("button",{type:"button",onClick:h,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${c?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a(c?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:a(c?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:c?e.jsx(Xo,{size:14}):e.jsx($a,{size:14})}),e.jsxs("div",{ref:Ts,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{zt(!1),At(r=>!r)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${Jt?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":Jt,"aria-haspopup":"menu","aria-label":a("sidebar.moreActions"),title:a("sidebar.moreActions"),children:e.jsx(xi,{size:15})}),Jt&&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:"menuitem",onClick:()=>{At(!1),pl.current?.click()},disabled:Vs,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:[Vs?e.jsx(vt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(_m,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{At(!1),gl.current?.click()},disabled:Vs,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:[Vs?e.jsx(vt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(Rm,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a("rightSidebar.insertLocalImage")})]}),h&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{At(!1),h()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${c?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[c?e.jsx(Xo,{size:14}):e.jsx($a,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(c?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),c&&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":a("rightSidebar.layoutMode"),children:[e.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:a("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",a("rightSidebar.layoutModeAuto")],["narrow",a("rightSidebar.layoutModeNarrow")],["wide",a("rightSidebar.layoutModeWide")]].map(([r,i])=>{const u=G===r;return e.jsx("button",{type:"button",role:"menuitemradio","aria-checked":u,onClick:()=>{J(r),At(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${u?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:i},r)})})]})]})]}),e.jsx("button",{type:"button",onClick:s,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":a("rightSidebar.close"),children:e.jsx(Ut,{size:14})})]}),se&&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(Vn,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:O,onChange:r=>j(r.target.value),placeholder:a(M==="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 ${ee?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>Nc("name"),"aria-pressed":M==="name",className:`rounded-full px-2 transition active:scale-95 ${ee?"py-1":"py-0.5"} ${M==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:a("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>Nc("content"),"aria-pressed":M==="content",className:`rounded-full px-2 transition active:scale-95 ${ee?"py-1":"py-0.5"} ${M==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:a("rightSidebar.searchModeContent")})]}),O&&e.jsx("button",{type:"button",onClick:()=>j(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.clearSearch"),children:e.jsx(Ut,{size:12})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg bg-surface-2 px-2.5 py-1.5 text-muted-foreground transition focus-within:bg-surface-elevated",children:[e.jsx(om,{size:12,className:"shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:a("rightSidebar.searchScope")}),e.jsx("input",{"data-search-scope":!0,value:K,onChange:r=>re(r.target.value),onKeyDown:r=>{r.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:a("rightSidebar.searchScopePlaceholder"),"aria-label":a("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),K!=="."&&e.jsx("button",{type:"button",onClick:()=>re("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.resetSearchScope"),children:e.jsx(Ut,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>je(r=>!r),"aria-expanded":me,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${me||os.length>0||C||ue||Ge?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:a("rightSidebar.searchOptions"),"aria-label":a("rightSidebar.searchOptions"),children:[e.jsx(im,{size:13}),os.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:os.length})]})]}),me&&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:a("rightSidebar.searchExclude")}),e.jsx("input",{"data-search-exclude":!0,value:oe,onChange:r=>he(r.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:a("rightSidebar.searchExcludePlaceholder"),"aria-label":a("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),oe&&e.jsx("button",{type:"button",onClick:()=>he(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":a("rightSidebar.clearSearchExclude"),children:e.jsx(Ut,{size:11})})]}),M==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":a("rightSidebar.contentSearchOptions"),children:[[C,()=>Z(r=>!r),xm,a("rightSidebar.matchCase")],[ue,()=>Ee(r=>!r),Om,a("rightSidebar.matchWholeWord")],[Ge,()=>De(r=>!r),Lm,a("rightSidebar.useRegex")]].map(([r,i,u,x])=>e.jsxs("button",{type:"button",onClick:i,"aria-pressed":r,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${r?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsx(u,{size:12}),x]},x))})]})]}),ds?null:e.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-0.5 rounded-md bg-surface-2 p-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>on("git"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Hr==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Rr,{size:12}),a("rightSidebar.tabGit")]}),e.jsxs("button",{type:"button",onClick:()=>on("diff"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Hr==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Yd,{size:12}),a("rightSidebar.tabChanges"),we.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:we.size}):null]}),e.jsxs("button",{type:"button",onClick:()=>on("files"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Hr==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(fm,{size:12}),a("rightSidebar.tabFiles")]})]}),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(li,{active:Xe,mounted:sr,fallback:e.jsx(ci,{slow:!1}),children:Ue?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(ed,{items:Wf,selectedKey:lf,onSelect:_s,emptyText:a("rightSidebar.noChanges"),mobile:ee,backLabel:a("rightSidebar.backToChangeList"),headerTitle:a("rightSidebar.recentCommitsTitle"),headerMeta:`${Ue.headRef??""}${Ue.commits?.[0]?` · ${Ue.commits[0]}`:""}`,onClose:()=>{$e(null),_s(null)},closeLabel:a("common.back"),wrap:$t,onToggleWrap:ee?wa:void 0,wrapTitle:a("rightSidebar.wrapLongLines"),wrapOnLabel:a("rightSidebar.wrapOn"),wrapOffLabel:a("rightSidebar.wrapOff"),desktopLayout:ee?"stacked":"split",onInsertDiffReference:Wr,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onClearAuditRecord:ba})}):pr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(ed,{items:Bo,selectedKey:io,onSelect:rn,emptyText:a(Me?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:ee,backLabel:a("rightSidebar.backToChangeList"),headerTitle:a(Me?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:xa?`${xa.repoLabel} · ${xa.branchName??"HEAD"} → ${xa.baseRef}`:void 0,onClose:()=>{Zt(!1),er(null)},closeLabel:a("common.back"),wrap:$t,onToggleWrap:ee?wa:void 0,wrapTitle:a("rightSidebar.wrapLongLines"),wrapOnLabel:a("rightSidebar.wrapOn"),wrapOffLabel:a("rightSidebar.wrapOff"),desktopLayout:ee?"stacked":"split",onInsertDiffReference:Wr,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onClearAuditRecord:ba,walkthroughs:Gf,onWalkthroughNavigate:qf,initialDetailScrollTop:Me&&Ze?jn[Ze]:void 0,onDetailScrollPositionChange:Zf,externalSwiperRef:ee?sa:void 0,onMobileSlideChange:ee?lo:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:Tc?e.jsx("div",{className:"px-3",children:Tc}):Dr?e.jsx(ci,{slow:jl}):cn?e.jsx(Da,{message:cn,onRetry:()=>{ls()}}):Ad(ae)?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a(b?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):ae?.available===!1?e.jsx(Da,{message:ae.error??a("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{ls()}}):b?e.jsx(ci,{slow:jl}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a(b?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),e.jsx(li,{active:On,children:ee?e.jsxs(Bd,{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:r=>{kr.current=r,r.slideTo(ol,0)},onSlideChange:r=>{if(yr(r.activeIndex),is.current===r.activeIndex){is.current=null;return}r.activeIndex===0&&(vr(!1),kt(null),f?.())},children:[e.jsx(yi,{className:"h-full min-h-0",children:e.jsxs("div",{ref:Fn,onScroll:Il,onDragOver:oa,onDragEnter:oa,onDragLeave:_l,onDrop:Bl,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[fl&&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:a("rightSidebar.dropToUpload")})}),!O.trim()&&Fc,e.jsx(Yc,{rootPath:pe??"",onFileSelect:us,onPathReference:zr,getReferenceText:la,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onDirectoryRoot:Kl,onSearchFromDirectory:Vl,onDirectoryPinToggle:Yl,onFilePinToggle:Xl,pinnedPaths:mn,selectedFilePath:Ve,query:le,searchRootPath:Ml,searchOptions:$l,searchMode:M,onContentMatchSelect:Fl,onDirectoryDropFiles:(r,i)=>fs(i,r),revealDirectory:X,canOpenInFileBrowser:hl,onOpenInFileBrowser:Dl})]})}),e.jsx(yi,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(Oi,{filePath:On&&(cf||ol===1)?Ve:null,onInsertReference:zr,onInsertText:jr,onInsertFeature:jr,onReviewReference:zl,onReferenceCopied:Sr,onClose:ch,onDirectoryLinkOpen:Ic,isMobile:!0,lineRange:Kr,onLineRangeChange:kt,insertedReferenceKey:q,copiedReferenceKey:Re,scrollToLine:Nr,onScrollToLineHandled:()=>Ie(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:B,onOpenMarkdownOutline:E,onCloseMarkdownOutline:$,markdownImageLightboxOpen:L,markdownImageLightboxCloseSignal:P,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:F})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:Fn,onScroll:Il,onDragOver:oa,onDragEnter:oa,onDragLeave:_l,onDrop:Bl,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:mo},children:[fl&&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:a("rightSidebar.dropToUpload")})}),!O.trim()&&Fc,e.jsx(Yc,{rootPath:pe??"",onFileSelect:us,onPathReference:zr,getReferenceText:la,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onDirectoryRoot:Kl,onSearchFromDirectory:Vl,onDirectoryPinToggle:Yl,onFilePinToggle:Xl,pinnedPaths:mn,selectedFilePath:Ve,query:le,searchRootPath:Ml,searchOptions:$l,searchMode:M,onContentMatchSelect:Fl,onDirectoryDropFiles:(r,i)=>fs(i,r),revealDirectory:X,canOpenInFileBrowser:hl,onOpenInFileBrowser:Dl})]}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":a("rightSidebar.resizeFileTree"),title:a("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:vf,onPointerMove:yf,onPointerUp:Tl,onPointerCancel:Tl,onDoubleClick:()=>{po(Mi),xt(ws,Mi)},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(Oi,{filePath:On?Ve:null,onInsertReference:zr,onInsertText:jr,onInsertFeature:jr,onReviewReference:zl,onReferenceCopied:Sr,onDirectoryLinkOpen:Ic,isMobile:!1,lineRange:Kr,onLineRangeChange:kt,insertedReferenceKey:q,copiedReferenceKey:Re,scrollToLine:Nr,onScrollToLineHandled:()=>Ie(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:B,onOpenMarkdownOutline:E,onCloseMarkdownOutline:$,markdownImageLightboxOpen:L,markdownImageLightboxCloseSignal:P,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:F})})]})}),e.jsx(li,{active:pt,mounted:df||pt,children:()=>Co?e.jsx(lm,{}):ee?e.jsx(wi,{mobile:!0,backLabel:a("rightSidebar.backToChangeList"),externalSwiperRef:sa,onMobileSlideChange:lo,groups:Ot.length>0?pc():[],mode:St,onModeChange:ya,selectedKey:Ve,scrollToKey:vc,scrollToKeyNonce:Xs.nonce,compact:!1,collapsedDirectoryKeys:ur,onToggleDirectory:kc,onSelectFile:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);i&&va(ut(i))},renderLeading:bc,renderTrailing:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);return i?hc(i):null},renderDirectoryTrailing:mc,renderSubtitle:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);return i?uc(i):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:r=>b&&e.jsxs("div",{className:"px-0 py-0",children:[Ra&&e.jsx("div",{className:"mb-2",children:Ra}),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:a("rightSidebar.allChanges")})}),e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[Ot.length,"/",we.size]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[cc(),Dc,r,c&&Do(),Bc,_c]}),Ct&&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:Ct.label}),Ct.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:Ct.branch})]}),!Ct&&bn&&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(Rr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:a("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:fa?(r=>wc(r)):void 0,emptyContent:Co?null:cn&&we.size===0?e.jsx(Da,{message:cn,onRetry:()=>{ls()}}):we.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a("rightSidebar.noChanges")}):Ot.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:a("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>cs(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:a("rightSidebar.backToChangeList"),children:[e.jsx(Ns,{size:14}),a("rightSidebar.backToChangeList")]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-1.5",children:[c&&Do(),e.jsxs("button",{type:"button",onClick:wa,"aria-pressed":$t,title:a("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 ${$t?"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:a($t?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:gc(),activePane:pt,wrap:$t,diffViewType:pf,inlineMode:Jn,diffOptions:Cc,reloadKey:fr,renderStreamBadge:r=>e.jsx(js,{status:r}),onHunkGitAction:Mc,onInsertDiffReference:Wr,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onClearAuditRecord:ba,onDetailScroll:pa}):e.jsx(wi,{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:a("rightSidebar.backToChangeList"),groups:Ot.length>0?pc():[],mode:St,onModeChange:ya,selectedKey:Ve,scrollToKey:vc,scrollToKeyNonce:Xs.nonce,compact:!0,collapsedDirectoryKeys:ur,onToggleDirectory:kc,onSelectFile:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);i&&va(ut(i))},renderLeading:bc,renderTrailing:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);return i?hc(i):null},renderDirectoryTrailing:mc,renderSubtitle:r=>{const i=Array.from(we.values()).find(u=>ut(u)===r.key);return i?uc(i):null},aiContent:fa?(r=>wc(r)):void 0,emptyContent:Co?null:cn&&we.size===0?e.jsx(Da,{message:cn,onRetry:()=>{ls()}}):we.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a("rightSidebar.noChanges")}):Ot.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:a("rightSidebar.noMatchingChanges")}):null,renderListHeader:r=>b&&e.jsxs("div",{className:"px-0 py-0",children:[Ra&&e.jsx("div",{className:"mb-2",children:Ra}),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:a("rightSidebar.allChanges")}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[Ot.length,"/",we.size]})})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[cc(),Dc,r,Do(),e.jsxs("button",{type:"button",onClick:wa,"aria-pressed":$t,title:a("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 ${$t?"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:a($t?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),Bc,_c]}),Ct&&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:Ct.label}),Ct.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:Ct.branch}),e.jsx("button",{type:"button",onClick:()=>Sa("stage-all",Ct.root,Ct.label),disabled:!!Ae,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:a("rightSidebar.stageAll"),children:a("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:()=>Sa("stash-all",Ct.root,Ct.label),disabled:!!Ae,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:a("rightSidebar.stashAll"),children:a("rightSidebar.stashAll")})]}),!Ct&&bn&&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(Rr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:a("rightSidebar.selectRepositoryForDiff")})]})]}),files:gc(),activePane:pt,wrap:$t,diffViewType:Qt,inlineMode:Jn,diffOptions:Cc,reloadKey:fr,renderStreamBadge:r=>e.jsx(js,{status:r}),onHunkGitAction:Mc,onInsertDiffReference:Wr,onReferenceCopied:Sr,insertedReferenceKey:q,copiedReferenceKey:Re,onClearAuditRecord:ba,onDetailScroll:pa})})]}),t&&Qe&&e.jsx(fp,{value:wt,collapsed:ht,autoCollapseAfterSend:Xt,focusRequest:qr,insertError:Xn?a("rightSidebar.contextDraftInsertFailed"):null,onChange:r=>{Wt(!1),Ht(r)},onCollapsedChange:lr,onAutoCollapseAfterSendChange:yn,onDisable:()=>vn(!1),onClear:()=>Ht(""),onInsert:()=>Wl(!1),onInsertAndSend:()=>Wl(!0),labels:{title:a("rightSidebar.contextDraftTitle"),hint:a("rightSidebar.contextDraftHint"),placeholder:a("rightSidebar.contextDraftPlaceholder"),collapse:a("rightSidebar.contextDraftCollapse"),expand:a("rightSidebar.contextDraftExpand"),disable:a("rightSidebar.contextDraftDisable"),clear:a("rightSidebar.contextDraftClear"),insert:a("rightSidebar.contextDraftInsert"),insertAndSend:a("rightSidebar.contextDraftInsertAndSend"),inserted:a("rightSidebar.contextDraftInserted"),sent:a("rightSidebar.contextDraftSent"),send:a("rightSidebar.contextDraftSend"),appended:a("rightSidebar.contextDraftAppended"),resize:a("rightSidebar.contextDraftResize"),autoCollapseAfterSend:a("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:r=>a("rightSidebar.contextDraftCharacterCount",{count:r})}}),If(),ct&&typeof document<"u"&&Gr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>Fr(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:r=>r.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:ct.kind==="restore"?a("rightSidebar.confirmRestoreTitle"):a("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:ct.kind==="restore"?a("rightSidebar.confirmRestoreDescription",{path:Fd(ct.file.absolutePath,b)}):a("rightSidebar.confirmStashAllDescription")}),ct.kind==="restore"&&e.jsx("input",{value:ct.phrase,onChange:r=>Fr({...ct,phrase:r.target.value}),placeholder:a("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:()=>Fr(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:a("common.cancel")}),e.jsx("button",{type:"button",disabled:!!Ae||ct.kind==="restore"&&ct.phrase.trim()!==a("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(ct.kind==="restore"){const r=it(ct.file,b);if(!r)return;ot({action:"restore-worktree-file",cwd:r,paths:[ct.file.path],confirm:{acknowledged:!0,phrase:ct.phrase}},a("rightSidebar.restoreFile"),hi(ct.file))}else{const r=ct.repoRoot??b;if(!r)return;ot({action:"stash-all",cwd:r},a("rightSidebar.stashAll"),`repo:${r}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${ct.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:a(Ae?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const Db=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:Oi,MarkdownImageLightbox:Vu,MarkdownPreview:Yu,RightSidebar:Rb,__testParseMarkdownListBlock:Hg,buildMarkdownPreviewBlocks:Zg,buildMarkdownPreviewRenderResult:Ji,collectKnownGitRepoRoots:vu,computeMarkdownImageDisplayBox:Lu,getMarkdownHeadingOutline:Ku,getMarkdownHeadingPathAtLine:qu,getNextMarkdownPreviewLineRange:ab,isSvgImageSrc:Za,mountRightSidebarRepoPickerOverlay:su,replaceGitRepositorySnapshot:tf,resolveMarkdownLocalLinkTarget:Gi,resolveRightSidebarDiffViewType:gu,shouldCloseMarkdownImageLightboxDrag:zu,showsGitRepoGroupHeader:$i},Symbol.toStringTag,{value:"Module"}));export{ki as E,Xc as H,Nm as M,Db as R,ym as a,$m as b,zm as c,Fb as m};
|