termdock 1.4.356 → 1.4.357
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/README.md +22 -4
- package/dist/client/assets/AndroidMirrorView-BGagwKtL.js +3 -0
- package/dist/client/assets/AndroidMirrorView-BGagwKtL.js.br +0 -0
- package/dist/client/assets/AndroidMirrorView-BGagwKtL.js.gz +0 -0
- package/dist/client/assets/App-DpMhxwYW.js +178 -0
- package/dist/client/assets/App-DpMhxwYW.js.br +0 -0
- package/dist/client/assets/App-DpMhxwYW.js.gz +0 -0
- package/dist/client/assets/ArchitecturePanel-Bd_l74EC.js +9 -0
- package/dist/client/assets/ArchitecturePanel-Bd_l74EC.js.br +0 -0
- package/dist/client/assets/ArchitecturePanel-Bd_l74EC.js.gz +0 -0
- package/dist/client/assets/{ChangeWalkthroughPanel-DO_zJfZr.js → ChangeWalkthroughPanel-6DN-2BdR.js} +2 -2
- package/dist/client/assets/ChangeWalkthroughPanel-6DN-2BdR.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-6DN-2BdR.js.gz +0 -0
- package/dist/client/assets/{ChatRichContent-Cu1E1cJ8.js → ChatRichContent-DjwpmW7d.js} +29 -29
- package/dist/client/assets/ChatRichContent-DjwpmW7d.js.br +0 -0
- package/dist/client/assets/ChatRichContent-DjwpmW7d.js.gz +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-DPTJ9pCt.js +1 -0
- package/dist/client/assets/CollaborationMainWorkspace-DPTJ9pCt.js.br +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-DPTJ9pCt.js.gz +0 -0
- package/dist/client/assets/CollaborationTaskContent-Cbu1Bjl0.js +1 -0
- package/dist/client/assets/ComputerControlView-CwB-wQqB.js +6 -0
- package/dist/client/assets/ComputerControlView-CwB-wQqB.js.br +0 -0
- package/dist/client/assets/ComputerControlView-CwB-wQqB.js.gz +0 -0
- package/dist/client/assets/{DagPlayground-CPYwfryM.js → DagPlayground-DMn9Gyrw.js} +1 -1
- package/dist/client/assets/DagPlayground-DMn9Gyrw.js.br +0 -0
- package/dist/client/assets/DagPlayground-DMn9Gyrw.js.gz +0 -0
- package/dist/client/assets/{DiffLab-ptw96Q_4.js → DiffLab-YBWlCU2T.js} +1 -1
- package/dist/client/assets/DiffLab-YBWlCU2T.js.br +0 -0
- package/dist/client/assets/DiffLab-YBWlCU2T.js.gz +0 -0
- package/dist/client/assets/DiffReview-YOPDWqhv.js +1 -0
- package/dist/client/assets/DiffReview-YOPDWqhv.js.br +0 -0
- package/dist/client/assets/DiffReview-YOPDWqhv.js.gz +0 -0
- package/dist/client/assets/{DiffReviewLab-eEi3y-0G.js → DiffReviewLab-SYomq14c.js} +1 -1
- package/dist/client/assets/DiffReviewLab-SYomq14c.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-SYomq14c.js.gz +0 -0
- package/dist/client/assets/{DiffViewer-DqcQxp4Q.js → DiffViewer-mh9cBl5v.js} +1 -1
- package/dist/client/assets/DiffViewer-mh9cBl5v.js.br +0 -0
- package/dist/client/assets/DiffViewer-mh9cBl5v.js.gz +0 -0
- package/dist/client/assets/{GitLoadingSkeleton-DYrDIDF1.js → GitLoadingSkeleton-DKRTc5sz.js} +1 -1
- package/dist/client/assets/GitLoadingSkeleton-DKRTc5sz.js.br +0 -0
- package/dist/client/assets/GitLoadingSkeleton-DKRTc5sz.js.gz +0 -0
- package/dist/client/assets/Markdown-C8OP1j-g.js +23 -0
- package/dist/client/assets/Markdown-C8OP1j-g.js.br +0 -0
- package/dist/client/assets/Markdown-C8OP1j-g.js.gz +0 -0
- package/dist/client/assets/Markdown-DKQhs57e.css +1 -0
- package/dist/client/assets/Markdown-DKQhs57e.css.br +0 -0
- package/dist/client/assets/Markdown-DKQhs57e.css.gz +0 -0
- package/dist/client/assets/{ModelPreview-DjtHLlqP.js → ModelPreview-CsZry3Wd.js} +3 -3
- package/dist/client/assets/ModelPreview-CsZry3Wd.js.br +0 -0
- package/dist/client/assets/ModelPreview-CsZry3Wd.js.gz +0 -0
- package/dist/client/assets/RecordingSaveDialog-CoRGi97z.js +1 -0
- package/dist/client/assets/RecordingSaveDialog-CoRGi97z.js.br +0 -0
- package/dist/client/assets/RecordingSaveDialog-CoRGi97z.js.gz +0 -0
- package/dist/client/assets/RightSidebar-DNY2kC6B.js +1662 -0
- package/dist/client/assets/RightSidebar-DNY2kC6B.js.br +0 -0
- package/dist/client/assets/RightSidebar-DNY2kC6B.js.gz +0 -0
- package/dist/client/assets/SessionChatView-DXNpYUrk.js +13 -0
- package/dist/client/assets/SessionChatView-DXNpYUrk.js.br +0 -0
- package/dist/client/assets/SessionChatView-DXNpYUrk.js.gz +0 -0
- package/dist/client/assets/SessionResourceSidebar-B_379HBJ.js +2 -0
- package/dist/client/assets/SessionResourceSidebar-B_379HBJ.js.br +0 -0
- package/dist/client/assets/SessionResourceSidebar-B_379HBJ.js.gz +0 -0
- package/dist/client/assets/TodoWorkspace-DfwGOAHB.js +1 -0
- package/dist/client/assets/TodoWorkspace-DfwGOAHB.js.br +0 -0
- package/dist/client/assets/TodoWorkspace-DfwGOAHB.js.gz +0 -0
- package/dist/client/assets/{abnfDiagram-VCTEODGH-Cvf_KWZ0.js → abnfDiagram-VCTEODGH-C9M0gnl-.js} +1 -1
- package/dist/client/assets/abnfDiagram-VCTEODGH-C9M0gnl-.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-C9M0gnl-.js.gz +0 -0
- package/dist/client/assets/app-CovJYQoW.js +37 -0
- package/dist/client/assets/app-CovJYQoW.js.br +0 -0
- package/dist/client/assets/app-CovJYQoW.js.gz +0 -0
- package/dist/client/assets/{arc-UvdowQOf.js → arc-q4wfkQcT.js} +1 -1
- package/dist/client/assets/arc-q4wfkQcT.js.br +0 -0
- package/dist/client/assets/arc-q4wfkQcT.js.gz +0 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-DotsbCCA.js → architectureDiagram-5GKGNRK7-CCuna3ab.js} +1 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CCuna3ab.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CCuna3ab.js.gz +0 -0
- package/dist/client/assets/{arrow-down-FGzRy9D-.js → arrow-down-WyzmLXwQ.js} +1 -1
- package/dist/client/assets/{blockDiagram-I7D4REHJ-CoOfSG4k.js → blockDiagram-I7D4REHJ-BXK68Qyt.js} +1 -1
- package/dist/client/assets/blockDiagram-I7D4REHJ-BXK68Qyt.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-BXK68Qyt.js.gz +0 -0
- package/dist/client/assets/{c4Diagram-7LVT6UL2-BAfjgs8B.js → c4Diagram-7LVT6UL2-BqwmmVmS.js} +1 -1
- package/dist/client/assets/c4Diagram-7LVT6UL2-BqwmmVmS.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-BqwmmVmS.js.gz +0 -0
- package/dist/client/assets/channel-Dd6WQGB7.js +1 -0
- package/dist/client/assets/{chevron-left-xqARwD-7.js → chevron-left-CxeWIsDK.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-DiiQ7BvG.js → chunk-2Q5K7J3B-esKGR38U.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-CczSK8wW.js → chunk-5VM5RSS4-B3InxqDA.js} +1 -1
- package/dist/client/assets/{chunk-F27PBJKO-BI3Di4Ve.js → chunk-F27PBJKO-CjUVyF-E.js} +1 -1
- package/dist/client/assets/chunk-F27PBJKO-CjUVyF-E.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-CjUVyF-E.js.gz +0 -0
- package/dist/client/assets/{chunk-IMKFNOWR-Cvvs1wmn.js → chunk-IMKFNOWR-BR8mmBs7.js} +1 -1
- package/dist/client/assets/chunk-IMKFNOWR-BR8mmBs7.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-BR8mmBs7.js.gz +0 -0
- package/dist/client/assets/{chunk-JWPE2WC7-lrJRD9WA.js → chunk-JWPE2WC7-CplXNOA7.js} +1 -1
- package/dist/client/assets/{chunk-POPQ4Y6H-CnPC9D8B.js → chunk-POPQ4Y6H-D0JWCGnb.js} +1 -1
- package/dist/client/assets/{chunk-SVP7TREG-BZfMhm64.js → chunk-SVP7TREG-BdJtJSmy.js} +1 -1
- package/dist/client/assets/chunk-SVP7TREG-BdJtJSmy.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-BdJtJSmy.js.gz +0 -0
- package/dist/client/assets/{chunk-TICWLB2K-DmkEaRK3.js → chunk-TICWLB2K-CoevFj8I.js} +1 -1
- package/dist/client/assets/chunk-TICWLB2K-CoevFj8I.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-CoevFj8I.js.gz +0 -0
- package/dist/client/assets/{chunk-XXDRQBXY-BP9Lccpe.js → chunk-XXDRQBXY-D7qYRhMH.js} +1 -1
- package/dist/client/assets/{circle-DGZOpG8V.js → circle-xgKDXpwG.js} +1 -1
- package/dist/client/assets/classDiagram-ZZMXUADV-BdIUq_D7.js +1 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-BdIUq_D7.js +1 -0
- package/dist/client/assets/{clipboard-rLx5CzbY.js → clipboard-DeK6pJD3.js} +1 -1
- package/dist/client/assets/clipboardText-BWOwer6N.js +1 -0
- package/dist/client/assets/clipboardText-BWOwer6N.js.br +0 -0
- package/dist/client/assets/clipboardText-BWOwer6N.js.gz +0 -0
- package/dist/client/assets/clipboardText-vX90C7eX.css +1 -0
- package/dist/client/assets/clipboardText-vX90C7eX.css.br +0 -0
- package/dist/client/assets/clipboardText-vX90C7eX.css.gz +0 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-0xPYMc2z.js → cose-bilkent-JH36ORCC-CvnsiaWP.js} +1 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-CvnsiaWP.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-CvnsiaWP.js.gz +0 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-BQ7-lCHm.js → cynefin-OW5HDTMX-BSGz8Olu.js} +1 -1
- package/dist/client/assets/cynefin-OW5HDTMX-BSGz8Olu.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-BSGz8Olu.js.gz +0 -0
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-CazHuSj1.js → cynefinDiagram-5FMLGOSQ-DYYT0AHs.js} +1 -1
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-DYYT0AHs.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-DYYT0AHs.js.gz +0 -0
- package/dist/client/assets/{dagre-GXQ25YYZ-CJNgsyHQ.js → dagre-GXQ25YYZ-BM883MN7.js} +1 -1
- package/dist/client/assets/dagre-GXQ25YYZ-BM883MN7.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-BM883MN7.js.gz +0 -0
- package/dist/client/assets/{diagram-S7CK7UJ4-D4xXIj1P.js → diagram-S7CK7UJ4-CYnxXy7R.js} +1 -1
- package/dist/client/assets/diagram-S7CK7UJ4-CYnxXy7R.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-CYnxXy7R.js.gz +0 -0
- package/dist/client/assets/{diagram-UQ7AKVKN-BWhpL-35.js → diagram-UQ7AKVKN-UOIBVxRf.js} +1 -1
- package/dist/client/assets/diagram-UQ7AKVKN-UOIBVxRf.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-UOIBVxRf.js.gz +0 -0
- package/dist/client/assets/{diagram-VSXAHHWV-DG9A7EgJ.js → diagram-VSXAHHWV-CqTJzfmm.js} +1 -1
- package/dist/client/assets/diagram-VSXAHHWV-CqTJzfmm.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-CqTJzfmm.js.gz +0 -0
- package/dist/client/assets/{diagram-VX7I27RA-L5PSvynM.js → diagram-VX7I27RA-T9Y88CFB.js} +1 -1
- package/dist/client/assets/diagram-VX7I27RA-T9Y88CFB.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-T9Y88CFB.js.gz +0 -0
- package/dist/client/assets/{diagram-Z3DM3KII-moBH7ruR.js → diagram-Z3DM3KII-kIQDy7E0.js} +1 -1
- package/dist/client/assets/diagram-Z3DM3KII-kIQDy7E0.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-kIQDy7E0.js.gz +0 -0
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-DEiGgcRP.js → ebnfDiagram-PWID7BFC-z_VqR_JE.js} +1 -1
- package/dist/client/assets/ebnfDiagram-PWID7BFC-z_VqR_JE.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-z_VqR_JE.js.gz +0 -0
- package/dist/client/assets/{erDiagram-RLTQ6QDP-BboIleYi.js → erDiagram-RLTQ6QDP-0q52Z-pm.js} +1 -1
- package/dist/client/assets/erDiagram-RLTQ6QDP-0q52Z-pm.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-0q52Z-pm.js.gz +0 -0
- package/dist/client/assets/{external-link-AZ3wjUg5.js → external-link-CsydVmO1.js} +1 -1
- package/dist/client/assets/{flowDiagram-HODETNUW-COxz7Rda.js → flowDiagram-HODETNUW-BrGqcUWn.js} +1 -1
- package/dist/client/assets/flowDiagram-HODETNUW-BrGqcUWn.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-BrGqcUWn.js.gz +0 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-_XdRvgyZ.js → ganttDiagram-EL5Y4UJY-CHAN6vQv.js} +1 -1
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CHAN6vQv.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CHAN6vQv.js.gz +0 -0
- package/dist/client/assets/{git-compare-90v75Jal.js → git-compare-BmKAtQTt.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-CBb9xBNW.js → gitGraphDiagram-WWUBYQGX-C0ZV4FeB.js} +1 -1
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-C0ZV4FeB.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-C0ZV4FeB.js.gz +0 -0
- package/dist/client/assets/index-DEAMSl55.css +1 -0
- package/dist/client/assets/index-DEAMSl55.css.br +0 -0
- package/dist/client/assets/index-DEAMSl55.css.gz +0 -0
- package/dist/client/assets/{infoDiagram-27XIBGKW-DjLdeNZi.js → infoDiagram-27XIBGKW-CrLj9y1o.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-Bcr-lhIE.js → ishikawaDiagram-5VMMS53U-BxGvUfLX.js} +1 -1
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-BxGvUfLX.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-BxGvUfLX.js.gz +0 -0
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-3vK6s9Pq.js → journeyDiagram-3NMN7TZE-rW9xlQ8G.js} +1 -1
- package/dist/client/assets/journeyDiagram-3NMN7TZE-rW9xlQ8G.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-rW9xlQ8G.js.gz +0 -0
- package/dist/client/assets/{kanban-definition-UXKFOSKX-DqDYDca0.js → kanban-definition-UXKFOSKX-CFI5iv9R.js} +1 -1
- package/dist/client/assets/kanban-definition-UXKFOSKX-CFI5iv9R.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-CFI5iv9R.js.gz +0 -0
- package/dist/client/assets/{layout-C7_WwzCP.js → layout-Ct_an5XT.js} +1 -1
- package/dist/client/assets/layout-Ct_an5XT.js.br +0 -0
- package/dist/client/assets/layout-Ct_an5XT.js.gz +0 -0
- package/dist/client/assets/{linear-BQCRhl6P.js → linear-DpEFOA9l.js} +1 -1
- package/dist/client/assets/linear-DpEFOA9l.js.br +0 -0
- package/dist/client/assets/linear-DpEFOA9l.js.gz +0 -0
- package/dist/client/assets/{link-Cq14tNBm.js → link-34ChBc4F.js} +3 -3
- package/dist/client/assets/{link-Cq14tNBm.js.br → link-34ChBc4F.js.br} +0 -0
- package/dist/client/assets/link-34ChBc4F.js.gz +0 -0
- package/dist/client/assets/{list-tree-C281zrdg.js → list-tree-48dzbuUh.js} +1 -1
- package/dist/client/assets/{maximize-2-CovPxWdw.js → maximize-2-CbvSsu7O.js} +1 -1
- package/dist/client/assets/{mermaid.core-DGsccxt-.js → mermaid.core-DnVKnMmy.js} +5 -5
- package/dist/client/assets/mermaid.core-DnVKnMmy.js.br +0 -0
- package/dist/client/assets/mermaid.core-DnVKnMmy.js.gz +0 -0
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-l0eF1PQE.js → mindmap-definition-YA3MSWOX-C6shupTY.js} +1 -1
- package/dist/client/assets/mindmap-definition-YA3MSWOX-C6shupTY.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-C6shupTY.js.gz +0 -0
- package/dist/client/assets/{passwordBootstrap-B5VzheZz.js → passwordBootstrap-Doe50DSa.js} +1 -1
- package/dist/client/assets/{passwordBootstrap-B5VzheZz.js.br → passwordBootstrap-Doe50DSa.js.br} +0 -0
- package/dist/client/assets/passwordBootstrap-Doe50DSa.js.gz +0 -0
- package/dist/client/assets/{pegDiagram-XKGWAZYB-fRrxGIDM.js → pegDiagram-XKGWAZYB-CDcnrvKX.js} +1 -1
- package/dist/client/assets/pegDiagram-XKGWAZYB-CDcnrvKX.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-CDcnrvKX.js.gz +0 -0
- package/dist/client/assets/{pieDiagram-E7YTZNPT-B-EBa3qN.js → pieDiagram-E7YTZNPT-CrGc03Tg.js} +1 -1
- package/dist/client/assets/pieDiagram-E7YTZNPT-CrGc03Tg.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-CrGc03Tg.js.gz +0 -0
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-Dj4e6f4h.js → quadrantDiagram-AXDQQJYC-3-aldwKj.js} +1 -1
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-3-aldwKj.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-3-aldwKj.js.gz +0 -0
- package/dist/client/assets/{quote-COQfrXhi.js → quote-B5GeKEq1.js} +1 -1
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-CEMppxTC.js → railroadDiagram-O6MQD6OU-51uKwR2_.js} +1 -1
- package/dist/client/assets/railroadDiagram-O6MQD6OU-51uKwR2_.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-51uKwR2_.js.gz +0 -0
- package/dist/client/assets/rdpSession-ocpkj4XY.js +1 -0
- package/dist/client/assets/rdpSession-ocpkj4XY.js.br +0 -0
- package/dist/client/assets/rdpSession-ocpkj4XY.js.gz +0 -0
- package/dist/client/assets/referenceSelection-fvfRDbgp.js +4 -0
- package/dist/client/assets/referenceSelection-fvfRDbgp.js.br +0 -0
- package/dist/client/assets/referenceSelection-fvfRDbgp.js.gz +0 -0
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-Dri1k4_x.js → requirementDiagram-BXWQKSXE-CY6kp0_Y.js} +1 -1
- package/dist/client/assets/requirementDiagram-BXWQKSXE-CY6kp0_Y.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-CY6kp0_Y.js.gz +0 -0
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-CMsL_tYL.js → sankeyDiagram-P5KCCOFB-BsA0NkHG.js} +1 -1
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-BsA0NkHG.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-BsA0NkHG.js.gz +0 -0
- package/dist/client/assets/{search-Dg6HWygj.js → search-CbpNLSpd.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-4_4hZtOd.js → sequenceDiagram-WJ2MYXX4-BDzn7N2D.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-4_4hZtOd.js.br → sequenceDiagram-WJ2MYXX4-BDzn7N2D.js.br} +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BDzn7N2D.js.gz +0 -0
- package/dist/client/assets/{sizeCapture-INFHLROL-3QA6qj2j.js → sizeCapture-INFHLROL-gxtam7nc.js} +1 -1
- package/dist/client/assets/sizeCapture-INFHLROL-gxtam7nc.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-gxtam7nc.js.gz +0 -0
- package/dist/client/assets/{stateDiagram-D77RDMKH-90IFPhD9.js → stateDiagram-D77RDMKH-C4XjYLZR.js} +1 -1
- package/dist/client/assets/stateDiagram-D77RDMKH-C4XjYLZR.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-C4XjYLZR.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-BfHWFf-I.js +1 -0
- package/dist/client/assets/{sun-BAMMjiA8.js → sun-CMXn_ntS.js} +1 -1
- package/dist/client/assets/{swimlanes-42K2YHIH-BuHieVWC.js → swimlanes-42K2YHIH--a1wkQO8.js} +1 -1
- package/dist/client/assets/swimlanes-42K2YHIH--a1wkQO8.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH--a1wkQO8.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-DsiDF1XD.js +8 -0
- package/dist/client/assets/swiper-CTPycjLq.js +1 -0
- package/dist/client/assets/swiper-CTPycjLq.js.br +0 -0
- package/dist/client/assets/swiper-CTPycjLq.js.gz +0 -0
- package/dist/client/assets/{terminal-Dea8wJF3.js → terminal-DaiFCKy_.js} +7 -7
- package/dist/client/assets/terminal-DaiFCKy_.js.br +0 -0
- package/dist/client/assets/terminal-DaiFCKy_.js.gz +0 -0
- package/dist/client/assets/{timeline-definition-24CTP7MA-C7FpaNwf.js → timeline-definition-24CTP7MA-DFmXXUuU.js} +1 -1
- package/dist/client/assets/timeline-definition-24CTP7MA-DFmXXUuU.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-DFmXXUuU.js.gz +0 -0
- package/dist/client/assets/triangle-alert-DgGU_xB4.js +1 -0
- package/dist/client/assets/{unplug-DN2SNXUL.js → unplug-CnZtWzVW.js} +1 -1
- package/dist/client/assets/use-gesture-react.esm-DHU0wi7Q.js +1 -0
- package/dist/client/assets/use-gesture-react.esm-DHU0wi7Q.js.br +0 -0
- package/dist/client/assets/use-gesture-react.esm-DHU0wi7Q.js.gz +0 -0
- package/dist/client/assets/{vennDiagram-4TSXK5OY-CxoHHVcs.js → vennDiagram-4TSXK5OY-DgR4zroQ.js} +1 -1
- package/dist/client/assets/vennDiagram-4TSXK5OY-DgR4zroQ.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-DgR4zroQ.js.gz +0 -0
- package/dist/client/assets/{videoCompression-rr2lu3uy.js → videoCompression-CcffRZdP.js} +1 -1
- package/dist/client/assets/videoCompression-CcffRZdP.js.br +0 -0
- package/dist/client/assets/videoCompression-CcffRZdP.js.gz +0 -0
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-B4Hsh-Ad.js → wardleyDiagram-VM6X3IG4-CY4SVUkf.js} +1 -1
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-CY4SVUkf.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-CY4SVUkf.js.gz +0 -0
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-CghzsxQv.js → xychartDiagram-S5SC5T6Z-PblQhR-b.js} +1 -1
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-PblQhR-b.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-PblQhR-b.js.gz +0 -0
- package/dist/client/index.html +3 -3
- package/dist/client/index.html.br +0 -0
- package/dist/client/index.html.gz +0 -0
- package/dist/client/sw-encrypted-background.js +1 -1
- package/dist/client/sw-encrypted-background.js.br +0 -0
- package/dist/client/sw-encrypted-background.js.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/agent/collaborationPeerTransport.js +14 -69
- package/dist/server/agent/collaborationStore.js +5 -0
- package/dist/server/agent/installers.js +89 -33
- package/dist/server/agent/integrationServer.js +31 -2
- package/dist/server/agent/pluginPackages.js +51 -22
- package/dist/server/agent/sessionChatRoutes.js +45 -7
- package/dist/server/agentHook.js +56 -12
- package/dist/server/android/adb.js +24 -31
- package/dist/server/cli.js +52 -110
- package/dist/server/entry.js +17 -23
- package/dist/server/federation/cli.js +13 -47
- package/dist/server/federation/connectionErrors.js +37 -0
- package/dist/server/federation/connectionModel.js +83 -0
- package/dist/server/federation/desktopTargets.js +35 -13
- package/dist/server/federation/directRoutes.js +28 -36
- package/dist/server/federation/directTargetRegistry.js +106 -0
- package/dist/server/federation/httpUploadLimit.js +8 -0
- package/dist/server/federation/relay.js +13 -6
- package/dist/server/federation/relayTransport.js +147 -0
- package/dist/server/federation/routeAccess.js +5 -3
- package/dist/server/federation/runtime.js +4 -2
- package/dist/server/federation/selfRelay.js +10 -59
- package/dist/server/federation/serviceTransport.js +123 -0
- package/dist/server/federation/streamLimits.js +3 -0
- package/dist/server/federation/trustedCa.js +61 -0
- package/dist/server/routes/android.js +5 -7
- package/dist/server/routes/terminal.js +149 -111
- package/dist/server/shared/androidDevices.js +64 -0
- package/dist/server/shared/programStatus.js +174 -0
- package/dist/server/shared/shareResources.js +3 -2
- package/dist/server/todos/routes.js +36 -0
- package/dist/server/todos/store.js +31 -1
- package/dist/server/utils/bootCheck.js +41 -271
- package/dist/server/utils/localHttpsSetup.js +257 -0
- package/dist/server/utils/oscBuffer.js +9 -0
- package/dist/server/utils/sessionDisplayName.js +11 -9
- package/dist/server/utils/settings.js +6 -3
- package/dist/server/utils/tmuxDisplayGeometry.js +54 -0
- package/dist/server/utils/tmuxObserverSize.js +26 -0
- package/docs/integrations.md +2 -1
- package/package.json +5 -1
- package/runtime-manifest.json +3 -3
- package/scripts/install-utils.cjs +81 -0
- package/scripts/postinstall.mjs +19 -106
- package/dist/client/assets/AndroidMirrorView-DW9oRr0w.js +0 -3
- package/dist/client/assets/AndroidMirrorView-DW9oRr0w.js.br +0 -0
- package/dist/client/assets/AndroidMirrorView-DW9oRr0w.js.gz +0 -0
- package/dist/client/assets/App-DEZ2i9ZZ.js +0 -178
- package/dist/client/assets/App-DEZ2i9ZZ.js.br +0 -0
- package/dist/client/assets/App-DEZ2i9ZZ.js.gz +0 -0
- package/dist/client/assets/ArchitecturePanel-Bf4b-6An.js +0 -9
- package/dist/client/assets/ArchitecturePanel-Bf4b-6An.js.br +0 -0
- package/dist/client/assets/ArchitecturePanel-Bf4b-6An.js.gz +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-DO_zJfZr.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-DO_zJfZr.js.gz +0 -0
- package/dist/client/assets/ChatRichContent-Cu1E1cJ8.js.br +0 -0
- package/dist/client/assets/ChatRichContent-Cu1E1cJ8.js.gz +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-BhmpSEbf.js +0 -1
- package/dist/client/assets/CollaborationMainWorkspace-BhmpSEbf.js.br +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-BhmpSEbf.js.gz +0 -0
- package/dist/client/assets/CollaborationTaskContent-CX0Aqdi2.js +0 -2
- package/dist/client/assets/ComputerControlView-DjQLzn10.js +0 -6
- package/dist/client/assets/ComputerControlView-DjQLzn10.js.br +0 -0
- package/dist/client/assets/ComputerControlView-DjQLzn10.js.gz +0 -0
- package/dist/client/assets/DagPlayground-CPYwfryM.js.br +0 -0
- package/dist/client/assets/DagPlayground-CPYwfryM.js.gz +0 -0
- package/dist/client/assets/DiffLab-ptw96Q_4.js.br +0 -0
- package/dist/client/assets/DiffLab-ptw96Q_4.js.gz +0 -0
- package/dist/client/assets/DiffReview-12E2zWyL.js +0 -1
- package/dist/client/assets/DiffReview-12E2zWyL.js.br +0 -0
- package/dist/client/assets/DiffReview-12E2zWyL.js.gz +0 -0
- package/dist/client/assets/DiffReviewLab-eEi3y-0G.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-eEi3y-0G.js.gz +0 -0
- package/dist/client/assets/DiffViewer-DqcQxp4Q.js.br +0 -0
- package/dist/client/assets/DiffViewer-DqcQxp4Q.js.gz +0 -0
- package/dist/client/assets/GitLoadingSkeleton-DYrDIDF1.js.br +0 -0
- package/dist/client/assets/GitLoadingSkeleton-DYrDIDF1.js.gz +0 -0
- package/dist/client/assets/MarkdownPreview-CsJGsDRL.js +0 -19
- package/dist/client/assets/MarkdownPreview-CsJGsDRL.js.br +0 -0
- package/dist/client/assets/MarkdownPreview-CsJGsDRL.js.gz +0 -0
- package/dist/client/assets/ModelPreview-DjtHLlqP.js.br +0 -0
- package/dist/client/assets/ModelPreview-DjtHLlqP.js.gz +0 -0
- package/dist/client/assets/RecordingSaveDialog-DUtwgIME.js +0 -1
- package/dist/client/assets/RecordingSaveDialog-DUtwgIME.js.br +0 -0
- package/dist/client/assets/RecordingSaveDialog-DUtwgIME.js.gz +0 -0
- package/dist/client/assets/RightSidebar-BltjUFwI.js +0 -1662
- package/dist/client/assets/RightSidebar-BltjUFwI.js.br +0 -0
- package/dist/client/assets/RightSidebar-BltjUFwI.js.gz +0 -0
- package/dist/client/assets/SessionChatView-CdKfHRp8.js +0 -13
- package/dist/client/assets/SessionChatView-CdKfHRp8.js.br +0 -0
- package/dist/client/assets/SessionChatView-CdKfHRp8.js.gz +0 -0
- package/dist/client/assets/SessionChatView-D8GoESjb.css +0 -1
- package/dist/client/assets/SessionChatView-D8GoESjb.css.br +0 -0
- package/dist/client/assets/SessionChatView-D8GoESjb.css.gz +0 -0
- package/dist/client/assets/SessionResourceSidebar-DmQOydhf.js +0 -2
- package/dist/client/assets/SessionResourceSidebar-DmQOydhf.js.br +0 -0
- package/dist/client/assets/SessionResourceSidebar-DmQOydhf.js.gz +0 -0
- package/dist/client/assets/TodoWorkspace-Bh1C035B.js +0 -1
- package/dist/client/assets/TodoWorkspace-Bh1C035B.js.br +0 -0
- package/dist/client/assets/TodoWorkspace-Bh1C035B.js.gz +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-Cvf_KWZ0.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-Cvf_KWZ0.js.gz +0 -0
- package/dist/client/assets/app-DuUnqxq-.js +0 -37
- package/dist/client/assets/app-DuUnqxq-.js.br +0 -0
- package/dist/client/assets/app-DuUnqxq-.js.gz +0 -0
- package/dist/client/assets/arc-UvdowQOf.js.br +0 -0
- package/dist/client/assets/arc-UvdowQOf.js.gz +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DotsbCCA.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-DotsbCCA.js.gz +0 -0
- package/dist/client/assets/arrow-up-DNkfesW0.js +0 -1
- package/dist/client/assets/blockDiagram-I7D4REHJ-CoOfSG4k.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-CoOfSG4k.js.gz +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-BAfjgs8B.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-BAfjgs8B.js.gz +0 -0
- package/dist/client/assets/channel-BzMU9Wks.js +0 -1
- package/dist/client/assets/chunk-F27PBJKO-BI3Di4Ve.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-BI3Di4Ve.js.gz +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-Cvvs1wmn.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-Cvvs1wmn.js.gz +0 -0
- package/dist/client/assets/chunk-SVP7TREG-BZfMhm64.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-BZfMhm64.js.gz +0 -0
- package/dist/client/assets/chunk-TICWLB2K-DmkEaRK3.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-DmkEaRK3.js.gz +0 -0
- package/dist/client/assets/classDiagram-ZZMXUADV-DtAtEoWU.js +0 -1
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-DtAtEoWU.js +0 -1
- package/dist/client/assets/clipboardText-cZXParp1.js +0 -1
- package/dist/client/assets/clipboardText-cZXParp1.js.br +0 -0
- package/dist/client/assets/clipboardText-cZXParp1.js.gz +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-0xPYMc2z.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-0xPYMc2z.js.gz +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-BQ7-lCHm.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-BQ7-lCHm.js.gz +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CazHuSj1.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CazHuSj1.js.gz +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-CJNgsyHQ.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-CJNgsyHQ.js.gz +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-D4xXIj1P.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-D4xXIj1P.js.gz +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-BWhpL-35.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-BWhpL-35.js.gz +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-DG9A7EgJ.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-DG9A7EgJ.js.gz +0 -0
- package/dist/client/assets/diagram-VX7I27RA-L5PSvynM.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-L5PSvynM.js.gz +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-moBH7ruR.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-moBH7ruR.js.gz +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-DEiGgcRP.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-DEiGgcRP.js.gz +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-BboIleYi.js.br +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-BboIleYi.js.gz +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-COxz7Rda.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-COxz7Rda.js.gz +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-_XdRvgyZ.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-_XdRvgyZ.js.gz +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-CBb9xBNW.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-CBb9xBNW.js.gz +0 -0
- package/dist/client/assets/index-nIgxJ6I3.css +0 -1
- package/dist/client/assets/index-nIgxJ6I3.css.br +0 -0
- package/dist/client/assets/index-nIgxJ6I3.css.gz +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-Bcr-lhIE.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-Bcr-lhIE.js.gz +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-3vK6s9Pq.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-3vK6s9Pq.js.gz +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-DqDYDca0.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-DqDYDca0.js.gz +0 -0
- package/dist/client/assets/layout-C7_WwzCP.js.br +0 -0
- package/dist/client/assets/layout-C7_WwzCP.js.gz +0 -0
- package/dist/client/assets/linear-BQCRhl6P.js.br +0 -0
- package/dist/client/assets/linear-BQCRhl6P.js.gz +0 -0
- package/dist/client/assets/link-Cq14tNBm.js.gz +0 -0
- package/dist/client/assets/loader-circle-Df0zpx5N.js +0 -1
- package/dist/client/assets/mermaid.core-DGsccxt-.js.br +0 -0
- package/dist/client/assets/mermaid.core-DGsccxt-.js.gz +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-l0eF1PQE.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-l0eF1PQE.js.gz +0 -0
- package/dist/client/assets/passwordBootstrap-B5VzheZz.js.gz +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-fRrxGIDM.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-fRrxGIDM.js.gz +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-B-EBa3qN.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-B-EBa3qN.js.gz +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-Dj4e6f4h.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-Dj4e6f4h.js.gz +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-CEMppxTC.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-CEMppxTC.js.gz +0 -0
- package/dist/client/assets/rdpSession-C5rS-ImV.js +0 -1
- package/dist/client/assets/rdpSession-C5rS-ImV.js.br +0 -0
- package/dist/client/assets/rdpSession-C5rS-ImV.js.gz +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-Dri1k4_x.js.br +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-Dri1k4_x.js.gz +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-CMsL_tYL.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-CMsL_tYL.js.gz +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-4_4hZtOd.js.gz +0 -0
- package/dist/client/assets/settings-2-iGqzPez0.js +0 -1
- package/dist/client/assets/sizeCapture-INFHLROL-3QA6qj2j.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-3QA6qj2j.js.gz +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-90IFPhD9.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-90IFPhD9.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CH-yvmL4.js +0 -1
- package/dist/client/assets/swimlanes-42K2YHIH-BuHieVWC.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-BuHieVWC.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-P_rDqbtg.js +0 -8
- package/dist/client/assets/swiper-DJjq1TYT.js +0 -1
- package/dist/client/assets/swiper-DJjq1TYT.js.br +0 -0
- package/dist/client/assets/swiper-DJjq1TYT.js.gz +0 -0
- package/dist/client/assets/syntaxHighlight-Cz6TPDW9.js +0 -4
- package/dist/client/assets/syntaxHighlight-Cz6TPDW9.js.br +0 -0
- package/dist/client/assets/syntaxHighlight-Cz6TPDW9.js.gz +0 -0
- package/dist/client/assets/terminal-Dea8wJF3.js.br +0 -0
- package/dist/client/assets/terminal-Dea8wJF3.js.gz +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-C7FpaNwf.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-C7FpaNwf.js.gz +0 -0
- package/dist/client/assets/triangle-alert-Oj-OsZDw.js +0 -1
- package/dist/client/assets/use-gesture-react.esm-DYpdiE_k.js +0 -1
- package/dist/client/assets/use-gesture-react.esm-DYpdiE_k.js.br +0 -0
- package/dist/client/assets/use-gesture-react.esm-DYpdiE_k.js.gz +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-CxoHHVcs.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-CxoHHVcs.js.gz +0 -0
- package/dist/client/assets/videoCompression-rr2lu3uy.js.br +0 -0
- package/dist/client/assets/videoCompression-rr2lu3uy.js.gz +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-B4Hsh-Ad.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-B4Hsh-Ad.js.gz +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-CghzsxQv.js.br +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-CghzsxQv.js.gz +0 -0
|
@@ -0,0 +1,1662 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-CsZry3Wd.js","assets/app-CovJYQoW.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-DaiFCKy_.js","assets/index-DEAMSl55.css","assets/search-CbpNLSpd.js","assets/sun-CMXn_ntS.js","assets/list-tree-48dzbuUh.js","assets/AndroidMirrorView-BGagwKtL.js","assets/v4-EwEgHOG0.js","assets/RecordingSaveDialog-CoRGi97z.js","assets/use-gesture-react.esm-DHU0wi7Q.js","assets/gestureArbiter-DszagC-d.js","assets/unplug-CnZtWzVW.js","assets/circle-xgKDXpwG.js","assets/quote-B5GeKEq1.js","assets/swiper-CTPycjLq.js","assets/swiper-C2J0D0kV.css","assets/Markdown-C8OP1j-g.js","assets/referenceSelection-fvfRDbgp.js","assets/Markdown-DKQhs57e.css","assets/GitLoadingSkeleton-DKRTc5sz.js","assets/DiffReview-YOPDWqhv.js","assets/DiffViewer-mh9cBl5v.js","assets/git-compare-BmKAtQTt.js","assets/DiffViewer-T3uj2-aP.css","assets/triangle-alert-DgGU_xB4.js","assets/ChangeWalkthroughPanel-6DN-2BdR.js","assets/chevron-left-CxeWIsDK.js","assets/maximize-2-CbvSsu7O.js","assets/arrow-down-WyzmLXwQ.js","assets/ArchitecturePanel-Bd_l74EC.js","assets/link-34ChBc4F.js","assets/purify.es-4eNOHKSq.js","assets/ArchitecturePanel-B_BDrrfR.css","assets/ComputerControlView-CwB-wQqB.js","assets/clipboard-DeK6pJD3.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a$ as Jr,cq as t,ez as Bt,p as ho,cf as th,cG as Jd,d5 as rh,ew as nh,x as ct,t as Qd,F as sh,h as ps,a8 as Qt,eK as B,Y as aa,eR as Et,cU as dt,c as po,bR as Zd,w as ed,C as mo,g as oa,a2 as co,eq as ta,er as Gi,a3 as td,dg as eu,L as go,R as Wi,c8 as ah,aw as Vs,bl as oh,ey as ih,eC as tu,ch as lh,cj as ch,ck as dh,cl as uh,ci as Ys,bB as fh,E as hh,z as ph,cc as mh,cW as gh,cZ as bh,c_ as xh,c2 as yh,cX as rd,av as wt,ao as ru,aq as vh,r as Ki,m as wh,n as kh,o as Sh,y as Ri,ap as Rh,eu as ji,c1 as nd,bv as sd,br as jh,bF as Ci,bG as ad,eS as na,bh as cs,bH as Ch,cI as Nh,ea as od,by as Ph,eo as Eh,ax as Ni,dv as Ah,eL as Yr,dk as Mn,ar as Th,as as id,bK as Mh,aG as ld,aF as Lh,bs as cd,bx as Ih,bD as dd,dy as $h,ah as ud,l as fd,N as Pi,K as ro,b as Fh,H as hd,X as pd,v as Dh,s as md,at as _h,a9 as sl,dm as Bh,cN as Uh,eP as Oh,cA as Hh,O as zh}from"./app-CovJYQoW.js";import{u as vo,S as Gh,a as gd}from"./swiper-CTPycjLq.js";import{M as Wh,u as Kh,j as Ei,Z as qh,F as Vh,b as Yh,_ as Xh,c as Jh,d as Qh,e as Zh,g as ep,f as tp,h as rp,r as np,s as sp}from"./Markdown-C8OP1j-g.js";import{b as n,r as Qr}from"./dnd-BCFAPC0L.js";import{b as ap,a as op,P as ip,d as lp,c as cp,N as bd,S as dp,C as up,G as fp,A as hp}from"./GitLoadingSkeleton-DKRTc5sz.js";import{u as pp,F as nu,H as mp,S as gp,U as bp}from"./RecordingSaveDialog-CoRGi97z.js";import{D as qi,C as sa,f as xp,n as yp}from"./DiffReview-YOPDWqhv.js";import{T as vp,G as xr}from"./triangle-alert-DgGU_xB4.js";import{C as su,M as au}from"./ChangeWalkthroughPanel-6DN-2BdR.js";import{R as ou,S as xd,V as wp,d as kp,M as Sp,A as Ai,u as Rp,f as jp,i as yd,b as Cp}from"./AndroidMirrorView-BGagwKtL.js";import{u as Np}from"./DiffViewer-mh9cBl5v.js";import{r as Pp,s as Ep,l as Ap,a as vd,g as Vi,b as Tp,h as Mp}from"./referenceSelection-fvfRDbgp.js";import{a as wd,S as kd}from"./gestureArbiter-DszagC-d.js";import{M as iu}from"./maximize-2-CbvSsu7O.js";import{L as Lp}from"./list-tree-48dzbuUh.js";import{S as ms}from"./search-CbpNLSpd.js";import{A as Ip}from"./use-gesture-react.esm-DHU0wi7Q.js";import{A as $p}from"./arrow-down-WyzmLXwQ.js";import{G as lu}from"./git-compare-BmKAtQTt.js";const Fp=[["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"}]],Dp=Jr("case-sensitive",Fp);const _p=[["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"}]],Bp=Jr("eye-off",_p);const Up=[["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"}]],Yi=Jr("eye",Up);const Op=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Hp=Jr("funnel",Op);const zp=[["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"}]],Gp=Jr("image-plus",zp);const Wp=[["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"}]],Kp=Jr("regex",Wp);const qp=[["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"}]],Vp=Jr("scan",qp);const Yp=[["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"}]],Xp=Jr("whole-word",Yp);function cu({embedded:r=!1,referenceLines:a=!0,content:i,filePath:c,rootPath:f,onLocalLinkOpen:m,lineRange:p,onLineRangeClick:S,onLineRangeDrag:g,scrollTop:x,outlineOpen:w,outlineCloseSignal:k,onOutlineOpen:b,onOutlineClose:E,lightboxOpen:P,lightboxCloseSignal:M,onLightboxOpen:$,onLightboxClose:J}){return t.jsx(Wh,{content:i,variant:r?"prose":"document",filePath:c,rootPath:f,onLocalLinkOpen:m,fileControls:a?{lineRange:p,onLineRangeClick:S,onLineRangeDrag:g,scrollTop:x,outlineOpen:w,outlineCloseSignal:k,onOutlineOpen:b,onOutlineClose:E}:void 0,lightbox:P===void 0?void 0:{open:P,closeSignal:M,onOpen:$,onClose:J}})}function Sd({children:r,actions:a}){const{t:i}=Bt(),[c,f]=n.useState(!1),m=n.useId(),p=n.useRef(null),S=n.useRef(null),g=()=>{f(!1),p.current?.focus({preventScroll:!0})};return n.useLayoutEffect(()=>{if(!c)return;const x=p.current,w=S.current;if(!x||!w)return;const k=window.visualViewport,b=()=>{const P=x.getBoundingClientRect(),M=(k?.offsetLeft??0)+8,$=(k?.offsetTop??0)+8,J=Math.max(0,(k?.width??window.innerWidth)-16),N=$+(k?.height??window.innerHeight)-16,O=Math.min(240,J),K=Math.max(0,P.top-$-6),X=Math.max(0,N-P.bottom-6),xe=w.scrollHeight>X&&K>X;Object.assign(w.style,{width:`${O}px`,left:`${Math.max(M,Math.min(P.right-O,M+J-O))}px`,top:`${xe?P.top-6:P.bottom+6}px`,maxHeight:`${xe?K:X}px`,transform:xe?"translateY(-100%)":"none"})};b();const E=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return E?.observe(x),E?.observe(w),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),k?.addEventListener("resize",b),k?.addEventListener("scroll",b),()=>{E?.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0),k?.removeEventListener("resize",b),k?.removeEventListener("scroll",b)}},[c]),n.useEffect(()=>{if(!c)return;S.current?.querySelector("button:not(:disabled)")?.focus({preventScroll:!0});const x=w=>{w.target instanceof Node&&!p.current?.contains(w.target)&&!S.current?.contains(w.target)&&f(!1)};return document.addEventListener("pointerdown",x),()=>document.removeEventListener("pointerdown",x)},[c]),t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[r,t.jsxs("button",{ref:p,type:"button","aria-haspopup":"menu","aria-expanded":c,"aria-controls":c?m:void 0,onClick:()=>f(x=>!x),onKeyDown:x=>{(x.key==="ArrowDown"||x.key==="ArrowUp")&&(x.preventDefault(),f(!0))},className:`ml-auto inline-flex h-8 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md px-2 text-[11px] font-medium transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${c?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[t.jsx(ho,{size:14}),i("sidebar.moreActions")]})]}),typeof document<"u"&&Qr.createPortal(t.jsx("div",{ref:S,id:m,hidden:!c,role:"menu","data-sidebar-gesture-ignore":!0,"aria-label":i("sidebar.moreActions"),className:"fixed z-menu-panel overflow-y-auto overscroll-contain rounded-lg border border-border/30 bg-surface p-1 shadow-[0_8px_24px_var(--app-shadow-soft)]",onKeyDown:x=>{if(!x.currentTarget.contains(x.target))return;const w=[...x.currentTarget.querySelectorAll("button:not(:disabled)")],k=w.indexOf(document.activeElement);let b;if(x.key==="Escape"){x.preventDefault(),x.stopPropagation(),g();return}if(x.key==="Tab"){g();return}if(x.key==="ArrowDown")b=(k+1)%w.length;else if(x.key==="ArrowUp")b=(k-1+w.length)%w.length;else if(x.key==="Home")b=0;else if(x.key==="End")b=w.length-1;else return;x.preventDefault(),w[b]?.focus({preventScroll:!0})},children:a(g)}),document.body)]})}const Ti="a[href],button,input,select,textarea,[tabindex],[contenteditable],iframe,summary,audio[controls],video[controls]",ds=n.memo(function({active:a,mounted:i=!0,fallback:c=null,children:f}){const m=n.useRef(null);return n.useLayoutEffect(()=>{const p=m.current;if(!p||a)return;const S=new Map,g=k=>{S.has(k)||(S.set(k,k.inert),k.inert=!0)},x=k=>{k instanceof HTMLElement&&k.matches(Ti)&&g(k),k.querySelectorAll(Ti).forEach(g)};x(p);const w=new MutationObserver(k=>{for(const b of k)b.type==="attributes"?b.target instanceof HTMLElement&&b.target.matches(Ti)&&g(b.target):b.addedNodes.forEach(E=>{E instanceof Element&&x(E)})});return w.observe(p,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex","href","contenteditable","controls"]}),()=>{w.disconnect();for(const[k,b]of S)k.inert=b}},[a,i]),t.jsx("div",{ref:m,className:"absolute inset-0 min-h-0 overflow-hidden bg-surface text-foreground",style:a?void 0:{clipPath:"inset(100%)"},"aria-hidden":!a,children:i?typeof f=="function"?f():f:c})},(r,a)=>!r.active&&!a.active&&r.mounted===a.mounted);async function Jp(r){let a;try{await Promise.race([r(),new Promise(i=>{a=setTimeout(i,3e3)})])}catch{}finally{clearTimeout(a)}}function Qp({active:r,rootPath:a,loading:i,delay:c,lastStartedRoot:f,load:m}){n.useEffect(()=>{if(!r||!a||i||f.current===a)return;const p=window.setTimeout(()=>{f.current=a,m(a)},c);return()=>window.clearTimeout(p)},[r,a,i,c,f,m])}function Zp(r,a,i,c){if(!a||r.defaultPrevented||r.nativeEvent.isComposing||r.altKey||r.ctrlKey||r.metaKey||r.shiftKey||r.key!=="ArrowUp"&&r.key!=="ArrowDown")return;const f=r.target;if(!(f instanceof HTMLElement)||!r.currentTarget.contains(f)||!th(f))return;const m=f.closest('button, a, input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="button"], [role="textbox"], [role="menu"], [role="listbox"], [role="slider"], [role="dialog"]');if(m&&!m.matches("[data-file-tree-path]")||window.getSelection()?.isCollapsed===!1)return;const p=Array.from(a.querySelectorAll("[data-file-tree-path]")).filter(k=>!k.closest('[hidden], [inert], [aria-hidden="true"]'));if(!p.some(k=>k.dataset.fileTreeType==="file"))return;const S=f.closest("[data-file-tree-path]"),g=p.findIndex(k=>S?k===S:k.dataset.fileTreePath===i),x=r.key==="ArrowDown"?1:-1;let w=g<0?x===1?0:p.length-1:g+x;for(r.preventDefault(),r.stopPropagation();w>=0&&w<p.length;w+=x){const k=p[w];if(k.dataset.fileTreeType==="file"){c(k.dataset.fileTreePath),a.contains(f)&&k.focus({preventScroll:!0}),k.scrollIntoView({block:"nearest",inline:"nearest"});return}}}function em({rootPath:r,paths:a,disabled:i,onChange:c}){const{t:f}=Bt(),m=Jd(r),p=pp(m,m),S=p.path,g=rh(S,m)??"",{result:x,error:w,reload:k}=nh({path:S,showHidden:!0,action:"pick_git_ignore_exception"}),b=!!w,E=!!x,[P,M]=n.useState(!1),$=N=>p.navigate(N?`${m==="/"?"":m}/${N}`:m),J=N=>{if(N.length>200){M(!0);return}M(!1),c(N)};return t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/30 bg-surface-2",children:[t.jsxs("div",{className:"flex items-center gap-2 border-b border-border/20 p-2",children:[t.jsx(nu,{buttonClassName:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-30",parent:{disabled:i||!p.canGoParent,onClick:p.goParent},root:{disabled:i||!g,onClick:p.goRoot}}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:S,children:g||"./"})]}),t.jsxs("div",{className:"h-56 overflow-y-auto overscroll-contain p-1",role:"group","aria-label":f("rightSidebar.gitIgnoreExceptionsPaths"),"aria-busy":!E&&!b,children:[b?t.jsxs("div",{className:"flex flex-col items-center gap-2 p-4 text-center text-xs",children:[t.jsx("p",{role:"alert",className:"text-destructive",children:f("rightSidebar.gitIgnoreExceptionsLoadFailed")}),t.jsx("button",{type:"button",disabled:i,onClick:k,className:"rounded-md px-3 py-2 text-primary hover:bg-surface-elevated disabled:opacity-40",children:f("common.retry")})]}):x?x.entries.length===0?t.jsx("p",{className:"p-4 text-center text-xs text-muted-foreground",children:f("rightSidebar.gitIgnoreExceptionsEmptyDirectory")}):x.entries.map(N=>{const O=g?`${g}/${N.name}`:N.name,K=O+(N.type==="directory"?"/":""),X=a.includes(K)||a.includes(O),xe=a.some(o=>o.endsWith("/")&&O.startsWith(o)),F=N.type==="directory"?Qd:sh;return t.jsxs("div",{className:"flex items-center gap-1 rounded-md hover:bg-surface-elevated",children:[t.jsxs("label",{className:"flex min-h-10 min-w-0 flex-1 cursor-pointer items-center gap-2 px-2 text-xs",children:[t.jsx("input",{type:"checkbox",checked:X||xe,disabled:i||xe,onChange:()=>J(X?a.filter(o=>o!==K&&o!==O):[...a,K]),className:"h-4 w-4 shrink-0 accent-[var(--primary)] disabled:opacity-40"}),t.jsx(F,{size:14,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"truncate",title:N.name,children:N.name})]}),N.type==="directory"&&t.jsx("button",{type:"button",disabled:i,onClick:()=>$(O),"aria-label":f("rightSidebar.gitIgnoreExceptionsOpenDirectory",{name:N.name}),className:"inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface hover:text-foreground disabled:opacity-40",children:t.jsx(ps,{size:15})})]},N.name)}):t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(ct,{size:18})}),x?.truncated&&t.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:f("rightSidebar.gitIgnoreExceptionsTruncated")})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[t.jsx("span",{className:"font-medium",children:f("rightSidebar.gitIgnoreExceptionsSelected",{count:a.length})}),t.jsx("button",{type:"button",disabled:i||a.length===0,onClick:()=>J([]),className:"rounded-md px-2 py-1 text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:f("rightSidebar.gitIgnoreExceptionsClear")})]}),a.length>0&&t.jsx("ul",{className:"max-h-24 overflow-y-auto overscroll-contain",children:a.map(N=>t.jsxs("li",{className:"flex items-center gap-2 rounded-md pl-2 text-xs hover:bg-surface-2",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",title:N,children:N}),t.jsx("button",{type:"button",disabled:i,onClick:()=>J(a.filter(O=>O!==N)),"aria-label":f("rightSidebar.gitIgnoreExceptionsRemove",{path:N}),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-40",children:t.jsx(Qt,{size:13})})]},N))}),P&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:f("rightSidebar.gitIgnoreExceptionsInvalid")})]})}function tm({rootPath:r,disabled:a,pressed:i,saving:c,onToggle:f}){const{t:m}=Bt(),p=n.useId(),S=n.useRef(null),g=n.useRef(null),x=n.useRef(null),w=n.useRef(null),k=n.useRef(!1),[b,E]=n.useState(!1),[P,M]=n.useState([]),[$,J]=n.useState(!1),[N,O]=n.useState(null),K=B(W=>W.setGitIgnoreExceptions),X=()=>{x.current!==null&&clearTimeout(x.current),x.current=null,w.current=null},xe=()=>{X(),!(a||$||!r)&&(M([...B.getState().gitIgnoreExceptions[r]??[]]),O(null),E(!0))},F=()=>{$||E(!1)},o=W=>{X(),k.current=!1,!(W.button!==0||!W.isPrimary||a)&&(W.currentTarget.setPointerCapture(W.pointerId),w.current={x:W.clientX,y:W.clientY},x.current=setTimeout(()=>{k.current=!0,xe()},450))};n.useEffect(()=>(E(!1),X(),X),[r]),n.useEffect(()=>{if(b)return g.current?.focus(),()=>S.current?.focus()},[b]);const fe=m(i?"rightSidebar.showGitIgnoredFiles":"rightSidebar.hideGitIgnoredFiles");return t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:S,type:"button",disabled:a||$,"aria-pressed":i,"aria-label":fe,"aria-description":m("rightSidebar.gitIgnoreConfigureHint"),title:`${fe} · ${m("rightSidebar.gitIgnoreConfigureHint")}`,onClick:W=>{if(k.current&&W.detail!==0){k.current=!1,W.preventDefault();return}f()},onContextMenu:W=>{W.preventDefault(),k.current=!0,b||xe()},onPointerDown:o,onPointerMove:W=>{const ge=w.current;ge&&Math.hypot(W.clientX-ge.x,W.clientY-ge.y)>10&&X()},onPointerUp:X,onPointerCancel:X,onLostPointerCapture:X,className:`inline-flex h-7 w-7 shrink-0 select-none items-center justify-center rounded-md transition active:scale-95 disabled:cursor-not-allowed disabled:opacity-35 [-webkit-touch-callout:none] ${i?"bg-surface-2 text-primary hover:bg-surface-elevated":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:c?t.jsx(ct,{size:14}):t.jsx(Hp,{size:14})}),b&&Qr.createPortal(t.jsx("div",{className:"fixed inset-0 z-modal-backdrop flex items-center justify-center bg-[var(--app-backdrop)] p-3 backdrop-blur-sm",onClick:F,children:t.jsxs("form",{ref:g,role:"dialog",tabIndex:-1,"aria-modal":"true","aria-labelledby":`${p}-title`,"aria-describedby":`${p}-hint`,className:"relative z-modal-panel flex max-h-[80dvh] w-full max-w-lg flex-col gap-3 overflow-y-auto rounded-xl border border-border/20 bg-surface p-4 text-foreground shadow-2xl",onClick:W=>W.stopPropagation(),onKeyDown:W=>{if(W.key==="Escape"&&(W.preventDefault(),W.stopPropagation(),F()),W.key==="Tab"){const ge=Array.from(g.current?.querySelectorAll("button:not(:disabled), input:not(:disabled)")??[]);if(!ge.length){W.preventDefault(),g.current?.focus();return}const H=ge[0],ce=ge[ge.length-1];W.shiftKey&&document.activeElement===H&&(W.preventDefault(),ce?.focus()),document.activeElement===g.current?(W.preventDefault(),(W.shiftKey?ce:H)?.focus()):!W.shiftKey&&document.activeElement===ce&&(W.preventDefault(),H?.focus())}},onSubmit:W=>{if(W.preventDefault(),!(!r||$)){if(P.length>200){O(m("rightSidebar.gitIgnoreExceptionsInvalid"));return}J(!0),O(null),K(r,P).then(()=>E(!1)).catch(()=>O(m("rightSidebar.gitIgnoreExceptionsSaveFailed"))).finally(()=>J(!1))}},children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("h2",{id:`${p}-title`,className:"text-sm font-medium",children:m("rightSidebar.gitIgnoreExceptionsTitle")}),t.jsx("button",{type:"button",disabled:$,onClick:F,"aria-label":m("common.close"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:t.jsx(Qt,{size:16})})]}),t.jsx("p",{className:"truncate text-xs text-muted-foreground",title:r??void 0,children:r}),t.jsx("p",{id:`${p}-hint`,className:"text-xs leading-relaxed text-muted-foreground",children:m("rightSidebar.gitIgnoreExceptionsHint")}),t.jsx("p",{className:"text-xs font-medium",children:m("rightSidebar.gitIgnoreExceptionsPaths")}),r&&t.jsx(em,{rootPath:r,paths:P,onChange:M,disabled:$}),N&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:N}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",disabled:$,onClick:F,className:"rounded-lg px-3 py-2 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40",children:m("common.cancel")}),t.jsxs("button",{type:"submit",disabled:$,className:"inline-flex items-center gap-2 rounded-lg bg-primary px-3 py-2 text-xs font-medium text-primary-foreground disabled:opacity-50",children:[$&&t.jsx(ct,{size:13}),m("common.save")]})]})]})}),document.body)]})}function rm(r,a,i){try{const c=r instanceof HTMLImageElement?r.naturalWidth:r.width,f=r instanceof HTMLImageElement?r.naturalHeight:r.height;if(!c||!f)return Promise.resolve(null);const m=r instanceof HTMLImageElement?1400/Math.max(c,f):Math.min(1,1400/Math.max(c,f)),p=document.createElement("canvas");p.width=Math.max(1,Math.round(c*m)),p.height=Math.max(1,Math.round(f*m));const S=p.getContext("2d");if(!S)return Promise.resolve(null);const g=getComputedStyle(document.documentElement);if(S.fillStyle=g.getPropertyValue("--surface").trim()||"white",S.fillRect(0,0,p.width,p.height),S.drawImage(r,0,0,p.width,p.height),i){const x=Math.max(10,Math.min(16,p.width/35));S.font=`${x}px sans-serif`;const w=[];let k="";for(const b of i.split(" "))k&&S.measureText(`${k} ${b}`).width>p.width-20?(w.push(k),k=b):k=k?`${k} ${b}`:b;k&&w.push(k),S.fillStyle=g.getPropertyValue("--surface").trim()||"white",S.fillRect(0,0,p.width,w.length*(x+4)+12),S.fillStyle=g.getPropertyValue("--foreground").trim()||"black",w.forEach((b,E)=>S.fillText(b,10,8+x+E*(x+4)))}if(a){const x=a.xPercent*p.width/100,w=a.yPercent*p.height/100,k=Math.max(4,Math.min(12,Math.min(p.width,p.height)*.015)),b=k*1.6;S.strokeStyle=g.getPropertyValue("--primary").trim()||"black",S.lineWidth=Math.max(1,k/3),S.beginPath(),S.arc(x,w,k,0,Math.PI*2),S.stroke(),S.beginPath(),S.moveTo(x-b,w),S.lineTo(x+b,w),S.moveTo(x,w-b),S.lineTo(x,w+b),S.stroke()}return new Promise(x=>p.toBlob(x,"image/png"))}catch{return Promise.resolve(null)}}function nm(r,a,i,c){return[r.trim(),a.trim(),c?`截图:${c}`:""].filter(Boolean).join(`
|
|
3
|
+
`)}function Db(r,a,i){const c=a*Math.PI/360,f=Math.min(c,Math.atan(Math.tan(c)*Math.max(i,.05)));return Math.max(r,1e-6)/Math.sin(f)*1.15}async function sm(r,a,i,c){if(!i?.snapshot)return c.isCurrent()?await c.insert(r,a):!1;const f=new Date().toISOString(),m=new AbortController;let p,S;try{S=await Promise.race([(async()=>{const g=await i.snapshot;if(!(!g||m.signal.aborted||!c.isCurrent()))return c.upload(new File([g],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),m.signal)})(),new Promise(g=>{p=setTimeout(()=>{m.abort(),g(void 0)},3e3)})])}catch{}finally{clearTimeout(p),m.abort()}return c.isCurrent()?await c.insert(S?nm(r,"",f,S):r,a):!1}function am(r,a){return r===a||a.endsWith(`/${r}`)||r.endsWith(`/${a}`)}function Rd(r,a){return`${r??""}\0${a}`}function om(r,a,i){if(!r||r.length===0||!i)return{explained:0,stale:0};const c=Rd(a,i);let f=0,m=0;for(const p of r){const S=[p.filePath,p.newPath,p.oldPath].filter(x=>typeof x=="string"&&x.length>0);(S.some(x=>Rd(p.repoRoot,x)===c)||S.some(x=>am(x,i)))&&(f+=1)}return{explained:f,stale:m}}function im({status:r}){if(!r)return null;const a=r.stale>0&&r.explained===0;if(!(r.explained>0||r.stale>0))return null;const c=a?"AI audit explanation is stale":"AI audit explanation available";return t.jsx("span",{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full ${a?"bg-[color:var(--warning)]/15 text-[color:var(--warning)]":"bg-accent/10 text-accent"}`,title:c,"aria-label":c,children:a?t.jsx(vp,{size:10}):t.jsx(aa,{size:10})})}function Xi({changeStatus:r,auditStatus:a,renderChangeBadge:i}){return t.jsxs("span",{className:"inline-flex items-center gap-1",children:[i(r),t.jsx(im,{status:a})]})}const du="termdock:right-sidebar:diff-change-list-mode:v1";function lm(r){return r==="list"||r==="tree"}function cm(){return dt(du,lm)??"tree"}function dm(r){for(const a of r){const i=a.hunk;if(i.oldPath&&i.newPath&&i.oldPath!==i.newPath)return"renamed";if(i.oldPath===null&&i.newPath)return"added";if(i.oldPath&&i.newPath===null)return"deleted"}return"modified"}function um(r){const a=new Map;for(const c of r){const f=a.get(c.hunk.filePath)??{key:c.hunk.filePath,filePath:c.hunk.filePath,items:[],additions:0,deletions:0,explained:0,stale:0,changeType:"modified"};f.items.push(c),f.additions+=c.hunk.additions,f.deletions+=c.hunk.deletions,c.current&&(f.explained+=1),c.stale&&(f.stale+=1),a.set(c.hunk.filePath,f)}const i=Array.from(a.values()).sort((c,f)=>c.filePath.localeCompare(f.filePath));for(const c of i)c.changeType=dm(c.items);return i}function fm(r){const a=r.filePath.split("/").pop()??r.filePath;return{key:r.key,path:r.filePath,displayName:a,displayDir:r.filePath.includes("/")?r.filePath.slice(0,-a.length-1):"",status:r.changeType,title:r.filePath}}function hm(r,a){const i=r.filter(m=>m.trim().length>0);if(i.length<=1)return i[0]??"";const c=[],f=new Set;for(const[m,p]of i.entries()){const S=p.split(`
|
|
4
|
+
`),g=S.findIndex(k=>k.startsWith("@@ "));if(g<0){c.push(...S);continue}m===0&&c.push(...S.slice(0,g));const x=a[m];let w=g;for(;w>=0&&w<S.length;){const k=S.findIndex((J,N)=>N>w&&J.startsWith("@@ ")),b=k>=0?k:S.length,E=S.slice(w,b),P=E[0]??"",M=x?P===x:!0,$=P||x||E.join(`
|
|
5
|
+
`);M&&!f.has($)&&(c.push(...E),f.add($)),w=k}}return c.join(`
|
|
6
|
+
`)}function pm({groups:r,onInsertDiffReference:a}){return r.map(i=>{const c=hm(i.items.map(g=>g.hunk.diff||g.current?.diff||g.stale?.diff||""),i.items.map(g=>g.hunk.hunkHeader)),f=i.items.map(g=>g.current??g.stale).filter(g=>!!g).map(g=>({id:g.id,repoRoot:g.repoRoot,filePath:g.filePath,oldPath:g.oldPath,newPath:g.newPath,hunkHeader:g.hunkHeader,hunkIndex:g.hunkIndex,fingerprint:g.fingerprint,diff:g.diff,explanation:g.explanation,summary:g.summary,workspaceRoot:g.workspaceRoot,generatedBy:g.generatedBy,injectedAt:g.injectedAt})),m=i.filePath.split("/").pop()??i.filePath,p=i.filePath.includes("/")?i.filePath.slice(0,-m.length-1):"",S=i.items[0]?.repoRoot??f[0]?.repoRoot??null;return{key:i.key,path:i.filePath,oldPath:i.items[0]?.hunk.oldPath??void 0,absolutePath:S?`${S}/${i.items[0]?.repositoryPath??i.filePath}`:i.filePath,status:i.changeType,repoRoot:S,displayName:m,displayDir:p,diffOverride:c,oldSourceRef:i.items[0]?.current?.headRef?`${i.items[0].current.baseRef}...${i.items[0].current.headRef}`:i.items[0]?.stale?.headRef?`${i.items[0].stale.baseRef}...${i.items[0].stale.headRef}`:void 0,previewReverts:Object.fromEntries(i.items.flatMap(g=>g.hunk.previewRevert?[[g.hunk.hunkHeader,g.hunk.previewRevert]]:[])),auditRecords:f,onInsertDiffReference:a}})}function mm(r,a,i){const c=Array.from(r.querySelectorAll("[data-diff-stream-item]"));if(c.length===0)return null;const m=r.getBoundingClientRect().top+48;let p=null,S=Number.POSITIVE_INFINITY;for(const x of c){const w=x.getBoundingClientRect();if(w.bottom<m)continue;const k=Math.abs(w.top-m);k<S&&(p=x,S=k)}const g=p?.dataset.diffSelectionPath??p?.dataset.diffStreamItem??null;return!g||g===a||i(g),g}function jd({items:r,selectedKey:a,onSelect:i,emptyText:c,mobile:f=!1,backLabel:m="Back",headerTitle:p,headerMeta:S,onClose:g,closeLabel:x="Back",wrap:w=!0,diffViewType:k,inlineMode:b,viewControls:E,onToggleWrap:P,wrapTitle:M,wrapOnLabel:$="Wrap on",wrapOffLabel:J="Wrap off",desktopLayout:N="split",onInsertDiffReference:O,onReferenceCopied:K,renderPathReference:X,insertedReferenceKey:xe,copiedReferenceKey:F,onClearAuditRecord:o,onRefresh:fe,localOptions:W,onHunkGitAction:ge,error:H,refreshing:ce,actionsBusy:j,refreshLabel:I,refreshTitle:te,walkthroughs:re=[],onWalkthroughNavigate:C,initialDetailScrollTop:D,onDetailScrollPositionChange:z,scrollToKey:ie,scrollToKeyNonce:Ce,externalSwiperRef:ve,onMobileSlideChange:he}){const{t:U}=Bt(),pe=n.useMemo(()=>um(r),[r]),le=n.useMemo(()=>new Map(pe.map(Q=>[Q.key,Q])),[pe]),[Ie,De]=n.useState(()=>cm()),[Pe,L]=n.useState(()=>new Set),[se,Te]=n.useState({key:null,nonce:0}),_e=pe.find(Q=>Q.explained>0||Q.stale>0)?.key??pe[0]?.key??null,Ee=a&&pe.some(Q=>Q.key===a)?a:_e,Ut=n.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:pe.map(fm)}],[pe]),Ge=n.useMemo(()=>pm({groups:pe,onInsertDiffReference:O}),[pe,O]),ut=n.useRef(_e),We=n.useRef(i);ut.current=_e,We.current=i,n.useEffect(()=>{!a&&ut.current&&We.current(ut.current)},[a]);const At=P?t.jsxs("button",{type:"button",onClick:P,"aria-pressed":w,title:M,className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 text-[11px] font-medium transition active:scale-95 ${w?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[t.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),t.jsx("span",{children:w?$:J})]}):null,be=W?.map(Q=>t.jsxs("label",{title:Q.disabled?U("rightSidebar.includeUncommittedCurrentBranchOnly"):Q.key,className:"inline-flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[t.jsx("input",{type:"checkbox",checked:Q.checked,disabled:ce||j||Q.disabled&&!Q.checked,onChange:Se=>Q.onChange(Se.target.checked),className:"accent-primary"}),t.jsxs("span",{children:[Q.label," · ",U("rightSidebar.includeUncommitted"),Q.disabled&&t.jsx("span",{className:"block text-[10px]",children:U("rightSidebar.includeUncommittedCurrentBranchOnly")})]})]},Q.key)),ft=H?t.jsx("div",{role:"alert",className:"w-full text-xs text-destructive",children:H}):null,lr=fe?t.jsxs("button",{type:"button",onClick:fe,disabled:ce||j,title:te??I,"aria-label":te??I,className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-full bg-surface-2 px-2.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:cursor-not-allowed disabled:opacity-60",children:[t.jsx(ou,{size:12,className:ce?"animate-spin":""}),I&&t.jsx("span",{children:I})]}):null,Je=Q=>t.jsxs("div",{className:"px-0 py-0",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[p&&t.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:p}),S&&t.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:S})]}),g&&t.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:[t.jsx(po,{size:14}),x]})]}),t.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[Q,be,lr,E,At,ft]})]});if(r.length===0){const Q=t.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:c});return!p&&!g?Q:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[Je(null),Q]})}const Oe=P||fe?({slideToList:Q})=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.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:Q,children:[t.jsx(po,{size:14}),m]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[be,lr,E,P&&t.jsxs("button",{type:"button",onClick:P,"aria-pressed":w,title:M,className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${w?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[t.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),t.jsx("span",{children:w?$:J})]})]}),ft]}):void 0;return t.jsx(qi,{mobile:f,preserveScrollOnUpdate:!!W?.length,desktopLayout:N,backLabel:m,groups:Ut,selectedKey:Ee,mode:Ie,onModeChange:Q=>{De(Q),Q!=="ai"&&Et(du,Q)},compact:f,collapsedDirectoryKeys:Pe,onToggleDirectory:Q=>{L(Se=>{const rt=new Set(Se);return rt.has(Q)?rt.delete(Q):rt.add(Q),rt})},onSelectFile:Q=>{i(Q.key),Te(Se=>({key:Q.key,nonce:Se.nonce+1}))},renderLeading:Q=>{const Se=le.get(Q.key);return t.jsx(Xi,{changeStatus:Q.status,auditStatus:Se,renderChangeBadge:rt=>t.jsx(sa,{status:rt})})},renderTrailing:Q=>{const Se=le.get(Q.key);return t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[Se&&t.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",Se.additions," -",Se.deletions]}),X?.(Q.path,"file")]})},renderDirectoryTrailing:Q=>X?.(Q,"directory"),renderListHeader:Je,aiContent:({slideToDetail:Q,fullscreen:Se,toggleFullscreen:rt})=>re.length>0&&C?t.jsx(su,{walkthroughs:re,repoRoot:re[0]?.repoRoot,fullscreen:Se,onToggleFullscreen:rt,onNavigate:ht=>{f&&window.requestAnimationFrame(Q),C(ht)}}):t.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:U("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:Oe,externalSwiperRef:ve,onMobileSlideChange:he,detailContainerClassName:f?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:D,scrollToKey:ie??se.key,scrollToKeyNonce:ie==null?se.nonce:Ce,onDetailScroll:Q=>{mm(Q,Ee,i),z?.(Q.scrollTop)},files:Ge,activePane:!0,wrap:w,diffViewType:k,inlineMode:b,renderStreamBadge:(Q,Se)=>{const rt=le.get(Se.key);return t.jsx(Xi,{changeStatus:Q,auditStatus:rt,renderChangeBadge:ht=>t.jsx(sa,{status:ht})})},onInsertDiffReference:O,onReferenceCopied:K,insertedReferenceKey:xe,copiedReferenceKey:F,onClearAuditRecord:o,onHunkGitAction:ce?void 0:ge,emptyContent:t.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:c})})}function gm(r){return r.replace(/\/+$/,"")||"/"}function bm(r){return[...new Set(Array.from(r,gm))].sort((a,i)=>a.localeCompare(i))}function xm(r){return r==="event-storm"||r==="reconnected"||r==="directory-rescan"||r==="polling-fallback"}function ym(r){let a=null;return{applicableEvents:r.filter(c=>{const f=c.type==="rescan-required"&&!xm(c.reason);return f&&c.reason&&!a&&(a=c.reason),!f}),unavailableReason:a}}const vm=1400,wm=1200,uu=44,km=.7;function Mi(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function Ji(r){return`termdock:right-sidebar:context-draft-height:${r}:v1`}function Sm(r){try{const a=window.localStorage.getItem(Ji(r)),i=a===null?NaN:Number(a);return Number.isFinite(i)&&i>=uu?i:null}catch{return null}}function Cd(r,a){try{a===null?window.localStorage.removeItem(Ji(r)):window.localStorage.setItem(Ji(r),String(a))}catch{}}function no(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Rm({value:r,collapsed:a,labels:i,focusRequest:c,insertError:f,autoCollapseAfterSend:m,onChange:p,onCollapsedChange:S,onAutoCollapseAfterSendChange:g,onDisable:x,onClear:w,onInsert:k,onInsertAndSend:b}){const[E,P]=n.useState(null),[M,$]=n.useState(!1),J=n.useRef(!1),N=n.useRef(!0),[O,K]=n.useState(!1),[X,xe]=n.useState(()=>Sm(Mi())),F=n.useRef(X),o=n.useRef(null),fe=n.useRef(null),W=n.useRef(r),ge=n.useRef(null),H=n.useRef(null),ce=!!r.trim(),j=r.trim().split(`
|
|
7
|
+
`)[0]??"",I=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";n.useEffect(()=>(N.current=!0,()=>{N.current=!1,o.current!==null&&window.clearTimeout(o.current),fe.current!==null&&window.clearTimeout(fe.current)}),[]),n.useEffect(()=>{let L=!1;const se=Mi();return Zd().then(Te=>{if(L)return;const _e=Te.contextDraftHeight?.[se]??null;Cd(se,_e),F.current=_e,xe(_e)}).catch(()=>{}),()=>{L=!0}},[]),n.useEffect(()=>{if(c!==void 0&&c>0){const L=ge.current;if(!L)return;no()||L.focus(),L.setSelectionRange(L.value.length,L.value.length),L.scrollTop=L.scrollHeight}},[c]),n.useEffect(()=>{const L=W.current;W.current=r,!(!a||r.length<=L.length)&&(K(!0),fe.current!==null&&window.clearTimeout(fe.current),fe.current=window.setTimeout(()=>{fe.current=null,K(!1)},wm))},[r,a]),n.useEffect(()=>{if(a)return;const L=ge.current;L&&(L.style.height=X!==null?`${X}px`:"")},[r,a,X]),n.useEffect(()=>{if(a)return;const L=ge.current;!L||document.activeElement===L||(L.scrollTop=L.scrollHeight)},[r,a]),n.useEffect(()=>{if(a||no())return;const L=ge.current;!L||document.activeElement===L||(L.focus(),L.setSelectionRange(L.value.length,L.value.length))},[a]);const te=n.useRef(null);n.useLayoutEffect(()=>{if(!no())return;const L=window.visualViewport;if(!L)return;const se=()=>{const Te=te.current;if(!Te)return;if(L.height>=window.innerHeight*.75){Te.style.transform="";return}const _e=Te.getBoundingClientRect(),Ee=Math.round(L.height-_e.bottom);Te.style.transform=Ee!==0?`translateY(${Ee}px)`:""};return se(),L.addEventListener("resize",se),L.addEventListener("scroll",se),()=>{L.removeEventListener("resize",se),L.removeEventListener("scroll",se),te.current&&(te.current.style.transform="")}},[a]);const re=L=>{P(L),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{o.current=null,P(null)},vm)},C=L=>{S(!1),no()&&window.requestAnimationFrame(()=>{const se=ge.current;if(!se)return;se.focus();const Te=se.value.length;se.setSelectionRange(Te,Te),window.requestAnimationFrame(()=>{se.setSelectionRange(Te,Te)})})},D=async(L,se)=>{if(!(!ce||J.current)){J.current=!0,$(!0),P(null);try{await(L==="sent"?b(se):k(se))&&N.current&&re(L)}catch{}finally{J.current=!1,N.current&&$(!1)}}},z=L=>{D("inserted",L.currentTarget)},ie=L=>{D("sent",L.currentTarget)},Ce=L=>{if(L.key==="Escape"){L.preventDefault(),S(!0);return}L.nativeEvent.isComposing||L.keyCode===229||L.key!=="Enter"||!L.metaKey&&!L.ctrlKey||(L.preventDefault(),ie(L))},ve=L=>{L.preventDefault()},he=vo(()=>{H.current&&(H.current=null)}),U=L=>{L.preventDefault();const se=ge.current;se&&(he(L),H.current={startY:L.clientY,startHeight:se.getBoundingClientRect().height},L.currentTarget.setPointerCapture?.(L.pointerId))},pe=L=>{const se=H.current;if(!se)return;const Te=window.visualViewport?.height??window.innerHeight,_e=Math.round(Math.min(Math.max(se.startHeight+(se.startY-L.clientY),uu),Te*km));F.current=_e,xe(_e)},le=L=>{const se=Mi();Cd(se,L),ta({contextDraftHeight:{[se]:L}}).catch(()=>{})},Ie=()=>{H.current&&(H.current=null,F.current!==null&&le(F.current))},De=()=>{F.current=null,xe(null),le(null)},Pe=r.length>0&&t.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/50",children:i.characterCount(r.length)});return a?t.jsx("section",{ref:te,className:"shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:t.jsxs("div",{className:"flex h-8 items-center gap-1 px-2",children:[t.jsxs("button",{type:"button",onClick:()=>C(),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":i.expand,title:i.expand,children:[t.jsx(ap,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),t.jsx("span",{className:`truncate text-[11px] ${f?"text-destructive":O?"text-primary":ce?"text-foreground/80":"text-muted-foreground/50"}`,children:f??(O?i.appended:ce?j:i.title)})]}),Pe,t.jsx("button",{type:"button",onClick:ie,disabled:!ce||M,"aria-busy":M,className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-30 ${ce?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground"}`,"aria-label":i.send,title:i.send,children:M?t.jsx(ed,{size:12,className:"animate-spin"}):E==="sent"?t.jsx(mo,{size:12}):t.jsx(xd,{size:12})})]})}):t.jsxs("section",{ref:te,className:"relative shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:[t.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:U,onPointerMove:pe,onPointerUp:Ie,onPointerCancel:Ie,onDoubleClick:De,title:i.resize,"aria-hidden":"true",children:t.jsx("span",{className:"h-1 w-8 rounded-full bg-border/50 transition group-hover:bg-border"})}),t.jsxs("div",{className:"flex h-7 items-center gap-0.5 px-2",children:[t.jsxs("button",{type:"button",onPointerDown:ve,onClick:()=>S(!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":i.collapse,title:i.collapse,children:[t.jsx(oa,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-[10px] font-medium text-foreground/75",children:i.title}),Pe]}),t.jsx("button",{type:"button",role:"switch","aria-checked":m,onPointerDown:ve,onClick:()=>g(!m),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":i.autoCollapseAfterSend,title:i.autoCollapseAfterSend,children:t.jsx("span",{"aria-hidden":"true",className:`relative h-3 w-5 rounded-full transition-colors ${m?"bg-primary":"bg-surface-elevated"}`,children:t.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-primary-foreground transition-transform ${m?"translate-x-2.5":"translate-x-0.5"}`})})}),t.jsx("button",{type:"button",onPointerDown:ve,onClick:x,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":i.disable,title:i.disable,children:t.jsx(Qt,{size:11})})]}),t.jsx("div",{className:"px-2 pb-2",children:t.jsxs("div",{className:"overflow-hidden rounded-lg bg-surface/80 ring-1 ring-border/10 transition focus-within:ring-primary/35",children:[t.jsx("textarea",{ref:ge,value:r,onChange:L=>p(L.target.value),onKeyDown:Ce,placeholder:i.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}),t.jsxs("div",{className:"flex items-center gap-0.5 border-t border-border/10 px-1 py-1",children:[t.jsx("button",{type:"button",onPointerDown:ve,onClick:w,disabled:!ce,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":i.clear,title:i.clear,children:t.jsx(co,{size:11})}),f?t.jsx("span",{className:"min-w-0 flex-1 truncate px-1 text-[10px] text-destructive",role:"alert",children:f}):t.jsx("span",{className:"flex-1"}),t.jsxs("button",{type:"button",onPointerDown:ve,onClick:z,disabled:!ce||M,"aria-busy":M,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:[t.jsx(op,{size:11}),t.jsx("span",{children:M?i.pending??i.insert:E==="inserted"?i.inserted:i.insert})]}),t.jsxs("button",{type:"button",onPointerDown:ve,onClick:ie,disabled:!ce||M,"aria-busy":M,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:`${i.insertAndSend} · ${I}`,children:[M?t.jsx(ed,{size:11,className:"animate-spin"}):E==="sent"?t.jsx(mo,{size:11}):t.jsx(xd,{size:11}),t.jsx("span",{children:E==="sent"?i.sent:i.send})]})]})]})})]})}function jm(r,a){const i=a.trim();if(!i)return r;if(!r.trim())return i;const c=r.endsWith(`
|
|
8
|
+
|
|
9
|
+
`)?"":r.endsWith(`
|
|
10
|
+
`)?`
|
|
11
|
+
`:`
|
|
12
|
+
|
|
13
|
+
`;return`${r}${c}${i}`}function Cm(r,a){const i=r.trim();return i?a?`${i}\r`:/\s$/.test(r)?r:`${i} `:""}function Nm(r,a){return{text:Cm(r,a),options:{paste:/[\r\n]/.test(r),submitAfterPaste:a}}}function Pm(r){const[a,i]=n.useState(null),c=n.useRef(null),f=n.useRef(null),m=n.useRef(!0),p=n.useRef(r);p.current=r,n.useEffect(()=>(m.current=!0,()=>{m.current=!1,c.current?.controller.abort()}),[]);const S=n.useCallback(async b=>{if(c.current)return!1;c.current=b,f.current=b;const E=P=>{b.task={...b.task,...P},m.current&&c.current===b&&i(b.task)};E({status:b.task.retryFiles.length?"uploading":"inserting",error:void 0});try{if(b.task.retryFiles.length){const P=await Gi(b.task.directory,b.task.retryFiles,b.controller.signal);if(E({uploaded:[...b.task.uploaded,...P.files]}),p.current(b.task.directory),P.files.length!==b.task.retryFiles.length){const M=new Set(P.results?.filter($=>$.status==="uploaded").map($=>$.index)??[]);throw E({retryFiles:P.results?b.task.retryFiles.filter(($,J)=>!M.has(J)):[]}),new Error("Incomplete upload result. Check the saved paths before retrying.")}E({retryFiles:[]})}if(b.controller.signal.aborted)throw new DOMException("Upload canceled","AbortError");if(b.insert){E({status:"inserting"});const P=b.task.uploaded[0]?.path;if(!P||!b.isCurrent?.()||!await b.insert(P)||!b.isCurrent?.()||b.controller.signal.aborted)return E({status:"error",error:"reference"}),!1}return E({status:"done"}),!0}catch(P){if(P instanceof td&&P.result?.files.length){const M=new Set(P.result.results?.filter($=>$.status==="uploaded").map($=>$.index)??[]);E({uploaded:[...b.task.uploaded,...P.result.files],retryFiles:P.result.results?b.task.retryFiles.filter(($,J)=>!M.has(J)):[]}),p.current(b.task.directory)}return E({status:b.controller.signal.aborted?"canceled":"error",error:P instanceof td&&P.code==="UPLOAD_LIMIT"?"UPLOAD_LIMIT":P instanceof Error?P.message:String(P)}),!1}finally{c.current===b&&(c.current=null)}},[]),g=n.useCallback((b,E,P,M)=>E.length?S({task:{kind:P?"image":"files",directory:b,files:E,retryFiles:E,uploaded:[],status:"uploading"},controller:new AbortController,insert:P,isCurrent:M}):Promise.resolve(!1),[S]),x=n.useCallback(()=>{const b=f.current;if(!b||c.current||!b.insert&&!b.task.retryFiles.length)return Promise.resolve(!1);const E={...b,controller:new AbortController,task:{...b.task}};return S(E)},[S]),w=n.useCallback(()=>{const b=c.current;!b||b.task.status!=="uploading"||b.controller.abort()},[]),k=n.useCallback(()=>{c.current||(f.current=null,i(null))},[]);return{task:a,start:g,retry:x,cancel:w,dismiss:k,busy:a?.status==="uploading"||a?.status==="inserting"}}function Em({task:r,labels:a,onCancel:i,onRetry:c,onDismiss:f}){const m=r.status==="uploading"||r.status==="inserting",p=r.error==="reference"?a.referenceRejected:r.error==="UPLOAD_LIMIT"?a.limit:r.status==="error"?`${a.failed}: ${r.error??""}`:a[r.status],S=r.status==="error"&&(r.kind==="image"&&r.uploaded.length>0||r.retryFiles.length>0&&r.retryFiles.length<=50);return t.jsxs("section",{className:"shrink-0 border-t border-border/20 bg-surface/80 px-3 py-2 text-xs","data-sidebar-upload-status":!0,"aria-busy":m,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`min-w-0 flex-1 break-words ${r.status==="error"?"text-destructive":"text-foreground"}`,role:r.status==="error"?"alert":"status",children:p}),r.status==="uploading"&&t.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-2 py-1 hover:bg-surface-elevated",onClick:i,children:a.cancel}),S&&t.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-2 py-1 hover:bg-surface-elevated",onClick:c,children:a.retry}),!m&&t.jsx("button",{type:"button",className:"shrink-0 rounded px-2 py-1 text-muted-foreground hover:bg-surface-2",onClick:f,"aria-label":a.dismiss,children:"×"})]}),t.jsx("div",{className:"mt-1 truncate text-muted-foreground",title:r.directory,children:r.directory}),t.jsxs("details",{className:"mt-1 min-w-0 text-muted-foreground",children:[t.jsxs("summary",{className:"cursor-pointer truncate",children:[a.files," · ",r.files[0]?.name]}),t.jsxs("ul",{className:"mt-1 max-h-24 overflow-y-auto font-mono text-[10px]",children:[r.files.map((g,x)=>t.jsx("li",{className:"break-all",children:g.name},`${x}:${g.name}`)),r.uploaded.map(g=>t.jsx("li",{className:"break-all text-foreground",children:g.path},g.path))]})]})]})}function Am(r){const a=n.useRef(r),i=n.useRef(0);(a.current.text!==r.text||a.current.sessionId!==r.sessionId||a.current.active!==r.active)&&(i.current+=1),a.current=r;const c=n.useRef(!0),f=n.useRef(!1);return n.useEffect(()=>(c.current=!0,()=>{c.current=!1,i.current+=1}),[]),n.useCallback(async(m,p)=>{if(f.current||!a.current.active)return!1;const S=a.current,g=i.current,{text:x,options:w}=Nm(S.text,m);if(!x)return!1;f.current=!0;try{const k=await eu(x,S.sessionId,()=>c.current&&a.current.active&&a.current.sessionId===S.sessionId,p,w),b=c.current&&g===i.current;return b&&(k?a.current.onAccepted():a.current.onRejected()),k&&b}finally{f.current=!1}},[])}const Qi="termdock:right-sidebar:html-view-mode-by-file:v1";function Tm(r){return r==="preview"||r==="source"}function fu(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(Tm)}function hu(r,a){if(!a)return null;const i=r&&!a.startsWith("/")?`${r}/${a}`:a;return r?`${r}::${i}`:i}function Nd(r,a){const i=hu(r,a);return i?dt(Qi,fu)?.[i]??"source":"source"}function Mm(r,a,i){const c=hu(r,a);if(!c)return;const f=dt(Qi,fu)??{};Et(Qi,{...f,[c]:i})}function Li(r){const a=Number.isFinite(r)&&r>0?Math.floor(r):0,i=Math.floor(a/3600),c=Math.floor(a%3600/60),f=a%60,m=String(c).padStart(2,"0"),p=String(f).padStart(2,"0");return i>0?`${i}:${m}:${p}`:`${m}:${p}`}function Lm(r,a,i){return!Number.isFinite(i)||i<=0||!a.width?0:Math.min(1,Math.max(0,(r-a.left)/a.width))*i}const Xr=2,Im=8,$m=60,so=5,Pd=.05,Fm=900;function Dm(r){return!Number.isFinite(r)||r<=0?Xr:Math.min(Im,Xr+Math.floor(r/$m))}const _m=350,Bm=6,Um=90;function Om({url:r,onLoadError:a}){const i=Kh(r,a),{t:c}=Bt(),f=n.useRef(null),m=n.useRef(null),p=n.useRef(null),S=n.useRef(null),g=n.useRef(!1),x=n.useRef(null),w=n.useRef(null),k=n.useRef(0),b=n.useRef(!1),E=n.useRef(!1),P=n.useRef(!1),M=n.useRef(null),$=n.useRef(null),J=n.useRef(!1),N=n.useRef(1),O=n.useRef(!1),[K,X]=n.useState(0),[xe,F]=n.useState(0),[o,fe]=n.useState(!1),[W,ge]=n.useState(!1),[H,ce]=n.useState(null),[j,I]=n.useState(!1),[te,re]=n.useState(0),[C,D]=n.useState(!1),[z,ie]=n.useState({width:0,height:0}),[Ce,ve]=n.useState(Xr),[he,U]=n.useState(1),[pe,le]=n.useState(null),Ie=n.useRef(Xr),De=n.useRef(null),Pe=n.useCallback(()=>{M.current!==null&&(clearTimeout(M.current),M.current=null)},[]),L=n.useCallback(()=>{Pe();const T=$.current;if($.current=null,!J.current)return!1;const V=p.current;if(V&&(V.playbackRate=N.current,T))try{V.releasePointerCapture?.(T.id)}catch{}return J.current=!1,Ie.current=Xr,I(!1),!0},[Pe]);n.useEffect(()=>()=>{x.current!==null&&cancelAnimationFrame(x.current),w.current!==null&&clearTimeout(w.current),De.current!==null&&clearTimeout(De.current),Pe();const T=p.current;T&&J.current&&(T.playbackRate=N.current)},[Pe]),n.useEffect(()=>{const T=m.current;if(!T||typeof ResizeObserver>"u")return;const V=new ResizeObserver(([we])=>{we&&ie({width:we.contentRect.width,height:we.contentRect.height})});return V.observe(T),()=>V.disconnect()},[]),n.useEffect(()=>{const T=()=>D(document.fullscreenElement===f.current);return document.addEventListener("fullscreenchange",T),()=>document.removeEventListener("fullscreenchange",T)},[]);const se=n.useCallback((T,V=!1)=>{const we=p.current;if(!we)return!1;const et=Number.isFinite(we.duration)?we.duration:T,kt=Math.min(Math.max(T,0),et);if(F(kt),Math.abs(we.currentTime-kt)<1/120)return!1;const pt=we.fastSeek;return V&&typeof pt=="function"?pt.call(we,kt):we.currentTime=kt,!0},[]),Te=n.useCallback(()=>{x.current===null&&(x.current=requestAnimationFrame(()=>{x.current=null;const T=p.current;if(!T||!b.current||E.current||T.seeking)return;const V=P.current;P.current=!1,E.current=se(k.current,!V)}))},[se]),_e=n.useCallback(T=>{const V=S.current,we=p.current;if(!V||!we)return;const et=V.getBoundingClientRect(),kt=Lm(T,et,we.duration);k.current=kt,ce(kt),P.current=!1,Te(),w.current!==null&&clearTimeout(w.current),w.current=setTimeout(()=>{w.current=null,P.current=!0,Te()},Um)},[Te]),Ee=n.useCallback(()=>{x.current!==null&&(cancelAnimationFrame(x.current),x.current=null),w.current!==null&&(clearTimeout(w.current),w.current=null),P.current=!1,E.current=!1,se(k.current)},[se]),Ut=vo(()=>{b.current&&ut()}),Ge=n.useCallback(T=>{const V=p.current;if(!(!V||!Number.isFinite(V.duration)||V.duration<=0)&&T.button===0){Ut(T),g.current=!V.paused,V.pause(),b.current=!0,ge(!0);try{T.currentTarget.setPointerCapture(T.pointerId)}catch{}_e(T.clientX)}},[_e,Ut]),ut=n.useCallback(()=>{b.current=!1,Ee(),ge(!1),ce(null);const T=p.current;T&&g.current&&!T.ended&&T.play().catch(()=>{}),g.current=!1},[Ee]),We=n.useCallback(()=>{const T=p.current;if(T){if(O.current){O.current=!1;return}T.paused?T.play().catch(()=>{}):T.pause()}},[]),At=n.useCallback(T=>{const V=p.current;if(!V)return;const we=Math.min(1,Math.max(0,Math.round((V.volume+T)*100)/100));V.volume=we,we>0&&(V.muted=!1),U(we),le(we),De.current!==null&&clearTimeout(De.current),De.current=setTimeout(()=>{De.current=null,le(null)},Fm)},[]),be=n.useCallback(T=>{const V=p.current;if(V){if(T.key==="ArrowLeft"){T.preventDefault(),se(V.currentTime-(T.shiftKey?so*2:so));return}if(T.key==="ArrowRight"){T.preventDefault(),se(V.currentTime+(T.shiftKey?so*2:so));return}if(T.key==="ArrowUp"){T.preventDefault(),At(Pd);return}if(T.key==="ArrowDown"){T.preventDefault(),At(-Pd);return}(T.key===" "||T.key==="Spacebar"||T.key==="k"||T.key==="K")&&(T.preventDefault(),V.paused?V.play().catch(()=>{}):V.pause())}},[se,At]),ft=n.useCallback(T=>{const V=p.current;!V||V.paused||T.button!==0||(Pe(),$.current={id:T.pointerId,x:T.clientX,y:T.clientY},M.current=setTimeout(()=>{M.current=null;const we=$.current;if(N.current=V.playbackRate,V.playbackRate=Xr,Ie.current=Xr,ve(Xr),J.current=!0,I(!0),we)try{V.setPointerCapture?.(we.id)}catch{}},_m))},[Pe]),lr=n.useCallback(T=>{const V=$.current;if(!V||V.id!==T.pointerId)return;if(!J.current){Math.hypot(T.clientX-V.x,T.clientY-V.y)>Bm&&(Pe(),$.current=null);return}const we=Dm(T.clientX-V.x);if(we===Ie.current)return;Ie.current=we,ve(we);const et=p.current;et&&(et.playbackRate=we)},[Pe]),Je=n.useCallback(()=>{L()&&(O.current=!0)},[L]);n.useEffect(()=>(window.addEventListener("pointerup",Je),window.addEventListener("pointercancel",Je),window.addEventListener("blur",Je),()=>{window.removeEventListener("pointerup",Je),window.removeEventListener("pointercancel",Je),window.removeEventListener("blur",Je)}),[Je]);const Oe=n.useCallback(async()=>{const T=f.current,V=p.current;if(!(!T||!V))try{document.fullscreenElement===T?await document.exitFullscreen():T.requestFullscreen?await T.requestFullscreen():V.webkitEnterFullscreen?.()}catch{V.webkitEnterFullscreen?.()}},[]),Q=n.useCallback(()=>re(T=>(T+90)%360),[]),Se=n.useCallback(T=>{const V=p.current;if(!V||!Number.isFinite(V.duration))return;const we=T.shiftKey?10:5;let et=null;T.key==="ArrowLeft"?et=V.currentTime-we:T.key==="ArrowRight"?et=V.currentTime+we:T.key==="Home"?et=0:T.key==="End"&&(et=V.duration),et!==null&&(T.preventDefault(),se(et))},[se]),rt=W&&H!==null?H:xe,ht=K>0?Math.min(1,Math.max(0,rt/K)):0,$e=(te===90||te===270)&&z.width>0&&z.height>0?{width:`${z.height}px`,height:`${z.width}px`}:{width:"100%",height:"100%"};return t.jsxs("div",{ref:f,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":te,children:[t.jsxs("div",{ref:m,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[t.jsx("video",{ref:p,"data-testid":"file-preview-video",className:`absolute left-1/2 top-1/2 max-w-none object-contain outline-none transition-transform duration-200 focus-visible:ring-2 focus-visible:ring-primary/60${j?` ${wd}`:""}`,style:{...$e,transform:`translate(-50%, -50%) rotate(${te}deg)`},src:i,preload:"auto",playsInline:!0,tabIndex:0,...j?{[kd]:""}:{},onClick:We,onKeyDown:be,onVolumeChange:T=>U(T.currentTarget.volume),onPointerDown:ft,onPointerMove:lr,onPointerUp:Je,onPointerCancel:Je,onContextMenu:T=>{J.current&&T.preventDefault()},onPlay:()=>fe(!0),onPause:()=>fe(!1),onTimeUpdate:T=>F(T.currentTarget.currentTime),onSeeked:T=>{const V=T.currentTarget;if(F(V.currentTime),E.current=!1,!b.current)return;const we=V.requestVideoFrameCallback;typeof we=="function"?we.call(V,()=>{b.current&&Te()}):requestAnimationFrame(()=>{b.current&&Te()})},onLoadedMetadata:T=>X(Number.isFinite(T.currentTarget.duration)?T.currentTarget.duration:0),onDurationChange:T=>X(Number.isFinite(T.currentTarget.duration)?T.currentTarget.duration:0),onError:a,children:c("rightSidebar.videoUnsupported")}),j&&t.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:c("rightSidebar.videoLongPressSpeed",{rate:String(Ce)})}),pe!==null&&t.jsxs("div",{className:"pointer-events-none absolute right-3 top-3 z-10 inline-flex items-center gap-1 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md","data-testid":"file-preview-video-volume",children:[t.jsx(wp,{size:13}),c("rightSidebar.videoVolume",{percent:Math.round(he*100)})]}),W&&H!==null&&t.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:`${ht*100}%`},"data-testid":"file-preview-video-scrub-time",children:Li(H)})]}),t.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${wd}`,[kd]:"",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:We,"aria-label":c(o?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:c(o?"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:o?t.jsx(ip,{size:14}):t.jsx(lp,{size:14})}),t.jsxs("div",{ref:S,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(K),"aria-valuenow":Math.floor(rt),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:Ge,onPointerMove:T=>{b.current&&_e(T.clientX)},onPointerUp:ut,onPointerCancel:ut,onKeyDown:Se,children:[t.jsx("div",{className:"h-1 w-full rounded-full bg-surface-elevated"}),t.jsx("div",{className:"absolute inset-y-0 left-0 my-auto h-1 rounded-full bg-primary",style:{width:`${ht*100}%`}}),t.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:`${ht*100}%`}})]}),t.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[Li(rt)," / ",Li(K)]}),t.jsx("button",{type:"button",onClick:Q,"aria-label":c("rightSidebar.videoRotate"),title:c("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:t.jsx(ou,{size:14})}),t.jsx("button",{type:"button",onClick:()=>{Oe()},"aria-label":c(C?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:c(C?"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:C?t.jsx(kp,{size:14}):t.jsx(Sp,{size:14})})]})})]})}function Hm(r){const a=Math.max(0,Math.min(100,r.xPercent)),i=Math.max(0,Math.min(100,r.yPercent));return{...a<=50?{left:`calc(${a}% + 8px)`}:{right:`calc(${100-a}% + 8px)`},...i<=50?{top:`calc(${i}% + 8px)`}:{bottom:`calc(${100-i}% + 8px)`}}}function wo({anchor:r,children:a,disabled:i=!1,onClick:c,title:f}){return t.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:i,onClick:m=>{m.stopPropagation(),c(m.currentTarget)},title:f,style:Hm(r),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[t.jsx(go,{size:11}),a]})}function zm(r,a,i,c){if(i.width<=0||i.height<=0||c.width<=0||c.height<=0)return null;const f=Math.min(i.width/c.width,i.height/c.height);if(!Number.isFinite(f)||f<=0)return null;const m=c.width*f,p=c.height*f,S=i.left+(i.width-m)/2,g=i.top+(i.height-p)/2,x=r-S,w=a-g;if(x<0||w<0||x>m||w>p)return null;const k=x/m*100,b=w/p*100;return{x:c.x+c.width*k/100,y:c.y+c.height*b/100,xPercent:k,yPercent:b}}function Gm(r,a,i){const c=[`SVG标注: ${r}`,`视图: ${a}`,`SVG坐标: (${i.x.toFixed(2)},${i.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${i.xPercent.toFixed(1)}%,${i.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return i.nearestText&&c.push(`最近文字: ${i.nearestText}`),`"${c.join(" / ")}"`}function Wm(r){const a=new DOMParser().parseFromString(r,"image/svg+xml"),i=a.documentElement;if(i.nodeName.toLowerCase()!=="svg"||a.querySelector("parsererror"))throw new Error("Invalid SVG document");return a.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(c=>c.remove()),a.querySelectorAll("*").forEach(c=>{for(const f of Array.from(c.attributes)){const m=f.name.toLowerCase(),p=f.value.trim();(m.startsWith("on")||(m==="href"||m.endsWith(":href"))&&p&&!p.startsWith("#"))&&c.removeAttribute(f.name)}}),i.removeAttribute("width"),i.removeAttribute("height"),i.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(i)}function Km(r,a,i){let c=null;for(const f of Array.from(r.querySelectorAll("text"))){const m=(f.textContent??"").replace(/\s+/g," ").trim();if(!m)continue;const p=Number(f.getAttribute("x")),S=Number(f.getAttribute("y"));if(!Number.isFinite(p)||!Number.isFinite(S))continue;const g=Math.hypot(p-a,S-i);(!c||g<c.distance)&&(c={text:m,distance:g})}return c?.text.slice(0,120)}function pu({blobUrl:r,filePath:a,viewLabel:i,onInsertAnnotation:c}){const f=n.useRef(null),m=n.useRef(null),[p,S]=n.useState(null),[g,x]=n.useState(null),[w,k]=n.useState(1),[b,E]=n.useState(!1),[P,M]=n.useState(null),$=n.useRef(new Map),J=n.useRef(null),N=n.useRef(!1),O=n.useRef(null),K=n.useRef(w);K.current=w,n.useEffect(()=>{const C=new AbortController;return S(null),x(null),M(null),k(1),fetch(r,{signal:C.signal}).then(D=>D.text()).then(D=>S(Wm(D))).catch(D=>{C.signal.aborted||x(D instanceof Error?D.message:"SVG preview failed")}),()=>C.abort()},[r]),n.useEffect(()=>{if(!b)return;const C=D=>{D.key==="Escape"&&E(!1)};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[b]),n.useLayoutEffect(()=>{const C=m.current,D=C?.querySelector("[data-svg-document] > svg");if(!C||!D)return;let z;try{z=D.getBBox()}catch{return}if(!z.width||!z.height)return;const ie=Math.max(2,Math.min(z.width,z.height)*.025);D.setAttribute("viewBox",`${z.x-ie} ${z.y-ie} ${z.width+2*ie} ${z.height+2*ie}`),D.style.width=`${w*100}%`,D.style.height=`${w*100}%`,D.style.minWidth=`${w*100}%`,D.style.minHeight=`${w*100}%`,D.style.display="block"},[p,w]);const X=n.useMemo(()=>P?Gm(a,i,P):null,[a,P,i]),xe=C=>{if(N.current){N.current=!1;return}const D=m.current,z=D?.querySelector("[data-svg-document] > svg"),ie=f.current;if(!D||!z||!ie)return;const Ce=z.viewBox.baseVal,ve=zm(C.clientX,C.clientY,z.getBoundingClientRect(),Ce);if(!ve)return;const he=ie.getBoundingClientRect();M({...ve,nearestText:Km(z,ve.x,ve.y),stageX:C.clientX-he.left,stageY:C.clientY-he.top,stageXPercent:(C.clientX-he.left)/he.width*100,stageYPercent:(C.clientY-he.top)/he.height*100})},F=C=>Math.max(1,Math.min(12,C)),o=(C,D)=>{const z=F(D),ie=C.querySelector("[data-svg-document] > svg");if(!ie)return z;const Ce=`${z*100}%`;return ie.style.width=Ce,ie.style.height=Ce,ie.style.minWidth=Ce,ie.style.minHeight=Ce,K.current=z,z},fe=(C,D,z,ie)=>{const Ce=K.current,ve=C.getBoundingClientRect(),he=z-ve.left,U=ie-ve.top,pe=(C.scrollLeft+he)/Ce,le=(C.scrollTop+U)/Ce,Ie=o(C,D);return C.scrollLeft=pe*Ie-he,C.scrollTop=le*Ie-U,Ie},W=()=>{const C=Array.from($.current.values());return C.length>=2?Math.hypot(C[0].x-C[1].x,C[0].y-C[1].y):0},ge=vo((C,D)=>{$.current.delete(D)&&(J.current=null,N.current=!0)},!0),H=C=>{if(C.pointerType==="mouse"&&C.button!==0)return;const D=m.current;D&&(ge(C),$.current.set(C.pointerId,{x:C.clientX,y:C.clientY}),D.setPointerCapture?.(C.pointerId),$.current.size>=2?(J.current={kind:"pinch",startX:C.clientX,startY:C.clientY,startScrollLeft:D.scrollLeft,startScrollTop:D.scrollTop,startDistance:W(),startZoom:K.current,moved:!1},N.current=!0):K.current>1&&(J.current={kind:"pan",startX:C.clientX,startY:C.clientY,startScrollLeft:D.scrollLeft,startScrollTop:D.scrollTop,startZoom:K.current,moved:!1}))},ce=C=>{if(!$.current.has(C.pointerId))return;$.current.set(C.pointerId,{x:C.clientX,y:C.clientY});const D=m.current,z=J.current;if(!(!D||!z)){if($.current.size>=2&&z.kind==="pinch"){const ie=W();if(!z.startDistance||!ie)return;const Ce=F(z.startZoom*ie/z.startDistance);if(Math.abs(Ce-K.current)<.01)return;const ve=Array.from($.current.values()),he=(ve[0].x+ve[1].x)/2,U=(ve[0].y+ve[1].y)/2;z.moved=!0,N.current=!0,fe(D,Ce,he,U),C.preventDefault();return}if(z.kind==="pan"&&$.current.size===1){const ie=C.clientX-z.startX,Ce=C.clientY-z.startY;if(!z.moved&&Math.hypot(ie,Ce)<6)return;z.moved=!0,N.current=!0,D.scrollLeft=z.startScrollLeft-ie,D.scrollTop=z.startScrollTop-Ce,C.preventDefault()}}},j=C=>{const D=m.current,z=J.current,ie=$.current.size===1&&!z?.moved;$.current.delete(C.pointerId);try{D?.releasePointerCapture?.(C.pointerId)}catch{}if($.current.size===1&&z?.kind==="pinch"){const he=Array.from($.current.values())[0];J.current=D?{kind:"pan",startX:he.x,startY:he.y,startScrollLeft:D.scrollLeft,startScrollTop:D.scrollTop,startZoom:K.current,moved:!1}:null;return}if($.current.size>0||(J.current=null,z?.kind==="pinch"&&k(K.current),!ie||N.current))return;const Ce=Date.now(),ve=O.current;ve&&Ce-ve.time<350&&Math.hypot(C.clientX-ve.x,C.clientY-ve.y)<24?(O.current=null,N.current=!0,k(he=>he>1?1:2.5)):O.current={time:Ce,x:C.clientX,y:C.clientY}},I=C=>{if(!C.ctrlKey&&!C.metaKey)return;const D=m.current;if(!D)return;C.preventDefault();const z=fe(D,K.current*Math.exp(-C.deltaY*.01),C.clientX,C.clientY);k(z)},te=()=>{k(1),K.current=1,m.current&&(m.current.scrollLeft=0,m.current.scrollTop=0)},re=t.jsxs("div",{className:b?"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:[t.jsxs("div",{ref:f,className:"relative min-h-0 flex-1",children:[t.jsx("div",{ref:m,role:"button",tabIndex:0,onClick:xe,onDoubleClick:C=>{C.preventDefault(),k(D=>D>1?1:2.5)},onPointerDown:H,onPointerMove:ce,onPointerUp:j,onPointerCancel:j,onWheel:I,onScroll:()=>M(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:g?t.jsx("div",{className:"p-4 text-sm text-destructive",children:g}):p?t.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:p}}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),P&&t.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:P.stageX,top:P.stageY}}),P&&X&&t.jsx(wo,{anchor:{xPercent:P.stageXPercent,yPercent:P.stageYPercent},title:"引用 SVG 标注",onClick:async C=>{await c?.(X,`svg:${P.x.toFixed(2)}:${P.y.toFixed(2)}`,void 0,C)!==!1&&M(null)},children:"引用 SVG 标注"}),t.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[w>1.001&&t.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:C=>{C.stopPropagation(),te()},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:t.jsx(Vp,{size:14})}),t.jsx("button",{type:"button","aria-label":b?"退出全屏 SVG":"全屏 SVG",title:b?"退出全屏 SVG":"全屏 SVG",onClick:C=>{C.stopPropagation(),E(D=>!D)},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:b?t.jsx(au,{size:14}):t.jsx(iu,{size:14})})]})]}),t.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:t.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:P?`SVG (${P.x.toFixed(2)}, ${P.y.toFixed(2)}) · ${P.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return b?Qr.createPortal(re,document.body):re}function uo(r){switch(r){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function qm(r,a,i,c){const f=[`电子标注: ${r}`,`视图: ${uo(a)}`,`图片位置: (${i.xPercent.toFixed(1)}%,${i.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(c?.available&&c.xMm!==void 0&&c.yMm!==void 0&&(f.push(`PCB坐标: (${c.xMm.toFixed(2)},${c.yMm.toFixed(2)})mm [KiCad板坐标]`),c.layer&&f.push(`显示层: ${c.layer}`),c.nearest)){const m=[c.nearest.net?`网络 ${c.nearest.net}`:null,`对象层 ${c.nearest.layer}`,`距离 ${c.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");f.push(`最近对象: ${c.nearest.label}${m?`(${m})`:""}`)}return`"${f.join(" / ")}"`}function Vm({blobUrl:r,filePath:a,view:i,board:c,onViewChange:f,onInsertAnnotation:m,onRefresh:p,interactive3d:S}){const{t:g}=Bt(),x=n.useRef(null),w=n.useRef(null),k=n.useRef(null),[b,E]=n.useState(null),[P,M]=n.useState(!1);n.useEffect(()=>(k.current?.abort(),E(null),M(!1),()=>k.current?.abort()),[r,i]);const $=n.useMemo(()=>b?qm(a,i,b,b.inspection):null,[a,b,i]),J=O=>{const K=x.current,X=w.current;if(!K||!X||!X.naturalWidth||!X.naturalHeight)return;const xe=K.getBoundingClientRect(),F=X.getBoundingClientRect(),o=Math.min(F.width/X.naturalWidth,F.height/X.naturalHeight),fe=X.naturalWidth*o,W=X.naturalHeight*o,ge=F.left+(F.width-fe)/2,H=F.top+(F.height-W)/2,ce=O.clientX-ge,j=O.clientY-H;if(ce<0||j<0||ce>fe||j>W)return;const I={xPercent:Math.max(0,Math.min(100,ce/fe*100)),yPercent:Math.max(0,Math.min(100,j/W*100)),stageXPercent:(O.clientX-xe.left)/xe.width*100,stageYPercent:(O.clientY-xe.top)/xe.height*100,inspecting:c&&i!=="pcb-3d"};if(E(I),k.current?.abort(),!I.inspecting)return;const te=new AbortController;k.current=te,ah(a,i,I.xPercent,I.yPercent,te.signal).then(re=>E(C=>C===I?{...C,inspection:re,inspecting:!1}:C)).catch(()=>{te.signal.aborted||E(re=>re===I?{...re,inspection:{available:!1},inspecting:!1}:re)})},N=c?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:N.map(O=>t.jsx("button",{type:"button",onClick:()=>f(O),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${O===i?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:uo(O)},O))}),t.jsx("button",{type:"button",onClick:p,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:t.jsx(Wi,{size:13})})]}),c&&S?t.jsx("div",{className:i==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:S}):null,c?i==="pcb-3d"?S?null:t.jsx("div",{className:"min-h-0 flex-1"}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:x,role:"button",tabIndex:0,onClick:J,onKeyDown:O=>{O.key!=="Enter"&&O.key!==" "||(O.preventDefault(),E({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:[t.jsx("img",{ref:w,src:r,alt:`${a} ${uo(i)}`,onLoad:()=>M(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${P?"opacity-100":"opacity-0"}`}),b&&t.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:`${b.stageXPercent}%`,top:`${b.stageYPercent}%`}}),b&&$&&t.jsx(wo,{anchor:{xPercent:b.stageXPercent,yPercent:b.stageYPercent},disabled:b.inspecting,title:g("rightSidebar.edaInsertAnnotation"),onClick:async O=>{await m?.($,`eda:${i}:${b.xPercent.toFixed(1)}:${b.yPercent.toFixed(1)}`,{snapshot:w.current?rm(w.current,b):Promise.resolve(null)},O)!==!1&&E(null)},children:g("rightSidebar.edaInsertAnnotation")})]}),t.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:t.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:b?b.inspecting?g("rightSidebar.edaInspecting"):b.inspection?.available?g("rightSidebar.edaPickedBoardPosition",{x:b.inspection.xMm?.toFixed(2)??"—",y:b.inspection.yMm?.toFixed(2)??"—",object:b.inspection.nearest?.label??g("rightSidebar.edaNoNearbyObject")}):g("rightSidebar.edaPickedPosition",{x:b.xPercent.toFixed(1),y:b.yPercent.toFixed(1)}):g("rightSidebar.edaPickHint")})})]}):t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(pu,{blobUrl:r,filePath:a,viewLabel:uo(i),onInsertAnnotation:m})})]})}function Ym(r){const a=[];let i=[],c="",f=!1;for(let m=0;m<r.length;m+=1){const p=r[m];f?p==='"'&&r[m+1]==='"'?(c+='"',m+=1):p==='"'?f=!1:c+=p:p==='"'?f=!0:p===","?(i.push(c),c=""):p===`
|
|
14
|
+
`?(i.push(c.replace(/\r$/,"")),a.push(i),i=[],c=""):c+=p}return(c||i.length>0)&&(i.push(c.replace(/\r$/,"")),a.push(i)),a}function Xm(r,a,i,c,f){const m=a[f]||`第${f+1}列`,p=i[f]??"",S=a.map((g,x)=>`${g||`第${x+1}列`}=${i[x]??""}`).join(";");return`"表格标注: ${r} / 数据行: ${c+1} / 列: ${m} / 值: ${p} / 记录: ${S}"`}function Jm({content:r,filePath:a,onInsertAnnotation:i}){const{t:c}=Bt(),f=n.useMemo(()=>Ym(r),[r]),m=f[0]??[],p=f.slice(1),S=n.useRef(null),[g,x]=n.useState(null),w=g?p[g.row]:null,k=g&&w?Xm(a,m,w,g.row+1,g.column):null;return t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[t.jsxs("div",{ref:S,className:"relative min-h-0 flex-1",children:[t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("table",{className:"min-w-full border-separate border-spacing-0 text-left text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.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:"#"}),m.map((b,E)=>t.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:b||c("rightSidebar.csvUnnamedColumn",{index:E+1})},`${b}:${E}`))]})}),t.jsx("tbody",{children:p.map((b,E)=>t.jsxs("tr",{className:"hover:bg-surface-2",children:[t.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:E+1}),m.map((P,M)=>{const $=g?.row===E&&g.column===M;return t.jsx("td",{className:`border-b border-r border-border/15 p-0 ${$?"bg-primary/15":""}`,children:t.jsx("button",{type:"button",onClick:J=>{const N=S.current?.getBoundingClientRect(),O=J.currentTarget.getBoundingClientRect();if(!N?.width||!N.height)return;const K=J.clientX||O.left+O.width/2,X=J.clientY||O.top+O.height/2;x({row:E,column:M,xPercent:(K-N.left)/N.width*100,yPercent:(X-N.top)/N.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:b[M]||" "})},`cell:${E}:${M}`)})]},`row:${E}`))})]})}),g&&k&&t.jsx(wo,{anchor:{xPercent:g.xPercent,yPercent:g.yPercent},title:c("rightSidebar.csvInsertAnnotation"),onClick:async b=>{await i?.(k,`csv:${a}:${g.row+1}:${g.column+1}`,void 0,b)!==!1&&x(null)},children:c("rightSidebar.csvInsertAnnotation")})]}),t.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:t.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:g&&w?c("rightSidebar.csvSelectedCell",{row:g.row+1,column:m[g.column]||g.column+1}):c("rightSidebar.csvPickHint",{rows:p.length,columns:m.length})})})]})}function us(r,a){let i=r;for(const c of a){if(!i||typeof i!="object")return;i=i[c]}return i}function Qm(r,a){const i=JSON.parse(r),c=us(i,["meta","version"]);if(a)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(c??"未知")},{label:"活动层编号",value:String(us(i,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(us(i,["board","visible_layers"])??"未知")},{label:"Git 集成",value:us(i,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const f=us(i,["net_settings","classes"]),m=Array.isArray(f)?f.find(S=>S&&typeof S=="object"&&S.name==="Default"):void 0,p=us(i,["board","design_settings","drc_exclusions"]);return[{label:"文件性质",value:"KiCad 工程配置"},{label:"格式版本",value:String(c??"未知")},{label:"网络类数量",value:String(Array.isArray(f)?f.length:0)},{label:"默认间距",value:m?.clearance!==void 0?`${m.clearance} mm`:"未设置"},{label:"默认线宽",value:m?.track_width!==void 0?`${m.track_width} mm`:"未设置"},{label:"默认过孔",value:m?.via_diameter!==void 0?`${m.via_diameter} / ${m.via_drill??"—"} mm(外径/钻孔)`:"未设置"},{label:"DRC 排除项",value:String(Array.isArray(p)?p.length:0)}]}function Zm(r,a){return`"KiCad项目标注: ${r} / 项: ${a.label} / 值: ${a.value}"`}function eg({content:r,filePath:a,localState:i,onInsertAnnotation:c}){const{t:f}=Bt(),m=n.useRef(null),[p,S]=n.useState(null),g=n.useMemo(()=>{try{return{items:Qm(r,i),error:null}}catch(w){return{items:[],error:w instanceof Error?w.message:String(w)}}},[r,i]),x=p===null?null:g.items[p.index];return g.error?t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-3 font-mono text-xs text-foreground",children:r}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[i&&t.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:f("rightSidebar.kicadLocalStateNotice")}),t.jsxs("div",{ref:m,className:"relative min-h-0 flex-1",children:[t.jsxs("div",{className:"h-full overflow-auto px-3 py-2",children:[t.jsx("div",{className:"divide-y divide-border/15",children:g.items.map((w,k)=>t.jsxs("button",{type:"button",onClick:b=>{const E=m.current?.getBoundingClientRect(),P=b.currentTarget.getBoundingClientRect();if(!E?.width||!E.height)return;const M=b.clientX||P.left+P.width/2,$=b.clientY||P.top+P.height/2;S({index:k,xPercent:(M-E.left)/E.width*100,yPercent:($-E.top)/E.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 ${p?.index===k?"bg-primary/10":""}`,children:[t.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:w.label}),t.jsx("span",{className:"break-words text-xs text-foreground",children:w.value})]},w.label))}),t.jsxs("details",{className:"mt-3 border-t border-border/15 pt-3",children:[t.jsx("summary",{className:"cursor-pointer text-xs font-semibold text-muted-foreground",children:f("rightSidebar.kicadShowRawJson")}),t.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre p-2 font-mono text-[10px] leading-relaxed text-foreground",children:r})]})]}),x&&p&&t.jsx(wo,{anchor:{xPercent:p.xPercent,yPercent:p.yPercent},title:f("rightSidebar.kicadInsertSetting"),onClick:async w=>{await c?.(Zm(a,x),`kicad-project:${a}:${x.label}`,void 0,w)!==!1&&S(null)},children:f("rightSidebar.kicadInsertSetting")})]}),t.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:t.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:x?`${x.label}: ${x.value}`:f("rightSidebar.kicadProjectPickHint")})})]})}const tg=`/** 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
|
+
`,rg=`/* 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
|
+
`,ao="/api/terminal/fs/preview/",ng=8*1024*1024,sg=32*1024*1024,ag=128,og="data:,";function Pt(r){throw new Error(r)}function ig(r){return JSON.stringify(r).replace(/</g,"\\u003c")}async function Ed(r,a,i){let c="",f=0;for(const m of r.matchAll(a))c+=r.slice(f,m.index)+await i(m),f=m.index+m[0].length;return c+r.slice(f)}async function mu(r,a){const i=a.origin??location.origin,c=new URL(r,i);(c.origin!==i||!Vs(c.pathname)?.startsWith(ao))&&Pt("预览地址不是有效的本地文件入口");const f=crypto.randomUUID(),m=`https://termdock-preview.invalid/${f}/`,p=[],S=I=>{!p.includes(I)&&p.length<20&&p.push(I)},g=new Set,x=[],w=new Set,k=new Map,b=new Map;let E=0,P=!1;const M=new Set,$=()=>{P=!0;for(const I of[...M])I();g.clear(),x.length=0};async function J(I){I.ok||Pt(`预览资源读取失败(${I.status})`);const te=I.body?.getReader(),re=[];let C=0;try{if(te)for(;;){const ie=await te.read();if(ie.done)break;C+=ie.value.byteLength,E+=ie.value.byteLength,(C>ng||E>sg)&&Pt("预览资源超出大小限制"),re.push(ie.value)}}catch(ie){throw await te?.cancel().catch(()=>{}),ie}finally{te?.releaseLock()}const D=new Uint8Array(C);let z=0;for(const ie of re)D.set(ie,z),z+=ie.length;return{bytes:D,type:I.headers.get("content-type")??"application/octet-stream",status:I.status}}let N=c,O;for(let I=0;I<4;I++){const te=await a.fetch(N.pathname+N.search,{signal:a.signal,redirect:"manual"});if(![301,302,303,307,308].includes(te.status)){O=te;break}const re=te.headers.get("location");await te.body?.cancel(),re||Pt("预览重定向缺少目标");const C=new URL(re,N);(C.origin!==i||!Vs(C.pathname)?.startsWith(ao))&&Pt("预览重定向越出文件范围"),N=C}O||Pt("预览重定向次数过多");const K=Vs(N.pathname),X=K.slice(ao.length).split("/");/^[a-f0-9]{32}$/.test(X[0])||Pt("服务未提供有效的预览资源授权");const xe=Vs(c.pathname).slice(ao.length).split("/");/^[a-f0-9]{32}$/.test(xe[0])&&xe.shift(),xe.join("/").replace(/\/$/,"")!==X.slice(1).join("/").replace(/\/$/,"")&&Pt("预览重定向改变了文件范围");const F=K.endsWith("/")?K:K.slice(0,K.lastIndexOf("/")+1),o=new URL(N.pathname.endsWith("/")?N.pathname:N.pathname.slice(0,N.pathname.lastIndexOf("/")+1),i);function fe(I,te){const re=new URL(I,te);return re.origin!==i?null:(Vs(re.pathname)?.startsWith(F)||Pt("已阻止预览访问目录之外的资源"),re)}function W(I){const te=new URL(I,m);(te.origin!==new URL(m).origin||!te.pathname.startsWith(new URL(m).pathname))&&Pt("已阻止预览访问服务接口或目录之外的资源");const re=te.pathname.slice(new URL(m).pathname.length)+te.search;return fe(re,o)??Pt("预览资源无效")}function ge(I){const te=I.pathname+I.search,re=k.get(te);if(re)return re;if(P||a.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(k.size>=ag)return Promise.reject(new Error("预览资源数量超出限制"));const C=a.fetch(te,{signal:a.signal,redirect:"manual"}).then(J);return k.set(te,C),C}function H(I,te){P&&Pt("预览已关闭");const re=`termdock-resource-${f}-${x.length}`;return x.push({token:re,data:I,type:te}),g.add(re),re}async function ce(I,te,re,C=new Set){if(!I||I.startsWith("#")||/^data:(?:image|font)\//i.test(I)&&re==="resource")return I;try{const D=fe(I,te);if(!D){const he=new URL(I,te);return(he.protocol!=="https:"||he.username||he.password||he.origin===new URL(m).origin)&&Pt("已阻止不安全的外部资源"),w.add(he.origin),he.href}const z=`${re}:${D.href}`;(C.has(z)||C.size>=8)&&Pt("预览资源存在循环或过深引用");const ie=b.get(z);if(ie)return ie;const Ce=new Set(C);Ce.add(z);const ve=(async()=>{const he=await ge(D);return re==="css"?H(await j(new TextDecoder().decode(he.bytes),D,Ce),"text/css"):re==="script"?H(he.bytes,"text/javascript"):H(he.bytes,he.type)})();return b.set(z,ve),await ve}catch(D){return S(D instanceof Error?D.message:"部分预览资源未能加载"),og}}async function j(I,te,re){return I=await Ed(I,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async C=>`@import url("${await ce(C[1],te,"css",re)}")${C[2]};`),Ed(I,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async C=>{const D=(C[1]??C[2]??C[3]).trim();return g.has(D)?C[0]:`url("${await ce(D,te,"resource",re)}")`})}try{const I=await J(O),te=H(tg,"text/javascript"),re=new DOMParser().parseFromString(new TextDecoder().decode(I.bytes),"text/html");re.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(U=>U.remove());for(const U of re.querySelectorAll("*")){if(U.removeAttribute("ping"),U.removeAttribute("srcdoc"),U.hasAttribute("style")&&U.setAttribute("style",await j(U.getAttribute("style"),N,new Set)),U.tagName==="STYLE"&&(U.textContent=await j(U.textContent??"",N,new Set)),U.tagName==="A"||U.tagName==="AREA"){const pe=U.getAttribute("href");try{if(pe&&!pe.startsWith("#")){const le=fe(pe,N);if(le)U.setAttribute("href",new URL(le.pathname.slice(o.pathname.length)+le.search+le.hash,m).href);else{const Ie=new URL(pe,N);if(Ie.protocol!=="https:"){U.removeAttribute("href");continue}w.add(Ie.origin),U.setAttribute("href",Ie.href)}}}catch(le){U.removeAttribute("href"),S(le instanceof Error?le.message:"预览链接无法加载")}}for(const pe of["data","manifest"])U.removeAttribute(pe);if(U.tagName==="SCRIPT"&&U.getAttribute("type")==="module"){U.setAttribute("type","module-shim");const pe=U.getAttribute("src");if(pe){const le=fe(pe,N);if(le)U.setAttribute("src",new URL(le.pathname.slice(o.pathname.length)+le.search,m).href);else{const Ie=new URL(pe,N);if(Ie.protocol!=="https:"){U.remove();continue}w.add(Ie.origin),U.setAttribute("src",Ie.href)}}continue}if(U.tagName==="SCRIPT"&&U.getAttribute("type")==="importmap"){U.setAttribute("type","importmap-shim");continue}if(U.tagName==="LINK"){const pe=(U.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(pe)){U.remove();continue}const le=U.getAttribute("href");le&&U.setAttribute("href",await ce(le,N,pe==="stylesheet"?"css":"resource"))}if(U.hasAttribute("src")&&U.setAttribute("src",await ce(U.getAttribute("src"),N,U.tagName==="SCRIPT"?"script":"resource")),U.hasAttribute("poster")&&U.setAttribute("poster",await ce(U.getAttribute("poster"),N,"resource")),U.hasAttribute("srcset")){const pe=U.getAttribute("srcset");/data:/i.test(pe)?(U.removeAttribute("srcset"),S("混合内嵌图片候选暂不支持安全预览")):U.setAttribute("srcset",(await Promise.all(pe.split(",").map(async le=>{const[Ie,...De]=le.trim().split(/\s+/);return`${await ce(Ie,N,"resource")} ${De.join(" ")}`}))).join(", "))}U.setAttribute("referrerpolicy","no-referrer"),U.removeAttribute("integrity"),U.removeAttribute("crossorigin")}const C=[...w].join(" "),D=re.createElement("meta");D.httpEquiv="Content-Security-Policy",D.content=`default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${C}; style-src 'unsafe-inline' blob: ${C}; img-src blob: data: ${C}; font-src blob: data: ${C}; media-src blob: data: ${C}; connect-src blob: ${C} ${[...w].map(U=>U.replace(/^https:/,"wss:")).join(" ")}; worker-src blob:; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const z=re.createElement("base");z.href=m;const ie=re.createElement("meta");ie.name="referrer",ie.content="no-referrer";const Ce=re.createElement("script");Ce.textContent=rg+`
|
|
1636
|
+
installPreviewRuntime(`+[f,m,[...w],te].map(ig).join(",")+");";const ve=re.createElement("script");ve.src=te,re.head.prepend(D,ie,z,Ce,ve);const he=`<!doctype html>
|
|
1637
|
+
`+re.documentElement.outerHTML;return{html:he,shellUrl:`/preview-shell.html#${f}`,errors:p,attach(U,pe){const le=new Set,Ie=Pe=>{if(Pe.source!==U.contentWindow||Pe.data?.capability!==f)return;if(Pe.data.type==="preview-ready"){U.contentWindow?.postMessage({type:"preview-init",capability:f,html:he,resources:x},"*");return}if(Pe.data.type==="preview-error"){pe("部分动态内容被安全预览限制");return}if(Pe.data.type==="preview-navigate"){(async()=>{const se=W(String(Pe.data.url)),Te=await mu(se.pathname+se.search,a);if(P){Te.dispose();return}const _e=Te.attach(U,pe);M.add(()=>{_e(),Te.dispose()}),U.src=Te.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(se=>pe(se instanceof Error?se.message:"无法打开预览页面"));return}if(Pe.data.type==="preview-external"){try{const se=new URL(String(Pe.data.url));se.protocol==="https:"&&w.has(se.origin)&&window.open(se.href,"_blank","noopener,noreferrer")}catch{}return}if(Pe.data.type!=="preview-fetch"||Pe.ports.length!==1)return;const L=Pe.ports[0];if(le.size>=8||!["GET","HEAD"].includes(Pe.data.method)){L.postMessage({error:"预览仅允许读取已授权目录资源"}),L.close();return}le.add(L),(async()=>{const se=W(String(Pe.data.url)),Te=await ge(se);if(!le.has(L)||P)return;const _e=Pe.data.method==="HEAD"?new Uint8Array:Te.bytes.slice();L.postMessage({status:Te.status,headers:{"content-type":Te.type},data:_e.buffer},[_e.buffer])})().catch(()=>{L.postMessage({error:"预览资源不在授权范围或无法加载"}),pe("部分动态资源不可用或超出预览目录")}).finally(()=>{le.delete(L),L.close()})};window.addEventListener("message",Ie);const De=()=>{window.removeEventListener("message",Ie);for(const Pe of le)Pe.close();le.clear(),M.delete(De)};return M.add(De),De},dispose:$}}catch(I){throw $(),I}}const lg=n.forwardRef(function({src:a,title:i,exitFullscreenLabel:c,onFullscreenChange:f},m){const p=n.useRef(null),[S,g]=n.useState(null),[x,w]=n.useState(),[k,b]=n.useState("");n.useEffect(()=>{const K=new AbortController;let X;return w(void 0),b(""),(async()=>{const xe=await oh();if(X=await mu(a,{fetch:(F,o)=>xe.fetch(F,o),signal:K.signal}),K.signal.aborted){X.dispose();return}w(X),X.errors.length&&b(X.errors.join(";"))})().catch(xe=>{K.signal.aborted||b(xe instanceof Error?xe.message:"安全预览加载失败")}),()=>{K.abort(),X?.dispose()}},[a]),n.useEffect(()=>{if(!(!x||!S))return x.attach(S,b)},[x,S]);const[E,P]=n.useState(!1),[M,$]=n.useState(!1),J=E||M;n.useEffect(()=>{f?.(J)},[J,f]),n.useEffect(()=>{const K=()=>{P(document.fullscreenElement===p.current)};return document.addEventListener("fullscreenchange",K),()=>document.removeEventListener("fullscreenchange",K)},[]),n.useEffect(()=>{if(!M)return;const K=X=>{X.key==="Escape"&&$(!1)};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[M]);const N=n.useCallback(async()=>{const K=p.current;if(K){if(M){$(!1);return}if(document.fullscreenElement===K){await document.exitFullscreen();return}if(K.requestFullscreen&&document.fullscreenEnabled!==!1)try{await K.requestFullscreen();return}catch{}$(!0)}},[M]);n.useImperativeHandle(m,()=>({toggleFullscreen:N}),[N]);const O=t.jsxs("div",{ref:p,"data-html-preview-frame":!0,className:J?"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:[J&&t.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:[t.jsx("span",{className:"min-w-0 truncate text-[12px] font-semibold",children:i}),t.jsx("button",{type:"button",onClick:()=>{N()},"aria-label":c,title:`${c} (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:t.jsx(au,{size:15})})]}),k&&t.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:k}),!x&&!k&&t.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),t.jsx("iframe",{ref:g,src:x?.shellUrl,referrerPolicy:"no-referrer",title:i,sandbox:"allow-scripts",className:"block min-h-0 w-full flex-1 border-0 bg-white"})]});return M?Qr.createPortal(O,document.body):O}),gu="termdock-file-search-match",Zi="termdock-file-search-current";function cg(r,a,i){return!!(a&&r?.isConnected&&!i.defaultPrevented&&!r.closest('[inert], [aria-hidden="true"], [hidden]')&&i.target instanceof Node&&r.contains(i.target))}function dg(r){const a=r.metaKey||r.ctrlKey,i=r.key.toLocaleLowerCase();return a&&i==="f"?"open":a&&i==="g"||r.key==="F3"?r.shiftKey?"previous":"next":r.key==="Escape"?"close":null}function ug(r){return r.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function fg(r,a){const i=a.trim().toLocaleLowerCase();if(!i)return[];const c=[];let f="",m=null;const p=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);for(let w=p.nextNode();w;w=p.nextNode()){if(!(w instanceof Text)||!w.data)continue;const k=ug(w);if(!k)continue;m&&m!==k&&(f+=`
|
|
1638
|
+
`);const b=f.length;f+=w.data,c.push({node:w,start:b,end:f.length,group:k}),m=k}const S=f.toLocaleLowerCase(),g=[];let x=0;for(;x<=S.length-i.length;){const w=S.indexOf(i,x);if(w<0)break;const k=w+i.length,b=c.find(P=>P.start<=w&&P.end>w),E=c.find(P=>P.start<k&&P.end>=k);if(b&&E&&b.group===E.group){const P=document.createRange();P.setStart(b.node,w-b.start),P.setEnd(E.node,k-E.start),g.push(P)}x=w+Math.max(i.length,1)}return g}function bu(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}let bo;function Ad(r){return bo===r}function oo(r){if(r&&bo!==r)return;const a=bu();a?.delete(gu),a?.delete(Zi),bo=void 0}function Ii(r,a,i){const c=bu();if(!c||typeof Highlight>"u")return;bo=i,c.set(gu,new Highlight(...r));const f=r[a];f?c.set(Zi,new Highlight(f)):c.delete(Zi)}function Td(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function hg(r){return Array.from(new Set(r.split(/[\n,]/).map(a=>a.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function pg(r,a){const i=a.trim();return!i||i==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(i)?i.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${i.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function mg(r,a){if(a===r)return".";const i=`${r.replace(/[\\/]+$/,"")}/`;return a.startsWith(i)?a.slice(i.length):a}function xu(r,a,i){return a?r:Qr.createPortal(r,i)}const al="termdock:right-sidebar:file-tree-scroll:v1",ol="termdock:right-sidebar:file-preview-reading-state:v1",hs="termdock:right-sidebar:file-tree-width:v1",yu="termdock:right-sidebar:markdown-view-mode:v1",vu="termdock:right-sidebar:diff-change-list-mode:v1",wu="termdock:right-sidebar:diff-wrap:v1",ku="termdock:diff-viewer:view-type:v1",Su="termdock:right-sidebar:file-search-mode:v1",$i="termdock:right-sidebar:collapsed-git-repo-groups:v1",Md="termdock:right-sidebar:collapsed-diff-directories:v1",Fi="termdock:right-sidebar:branch-audit-module-open:v1",Ru="termdock:right-sidebar:branch-audit-module:v1",gg=150,Ld="termdock:right-sidebar:context-draft-enabled:v1",Id="termdock:right-sidebar:context-draft-collapsed:v1",$d="termdock:right-sidebar:context-draft-auto-collapse:v1",Di="termdock:right-sidebar:context-draft-text:v1",bg=300,xg=20,yg=120,vg=250,wg=250,kg=120,Sg=700,_i=600,Rg=6e4;function Xs(r){return!!(r&&B.getState().nestedGitScanRoots[r])}const Fd=[2e3,5e3,15e3,3e4],jg=320,Cg=500,Ng=20,Pg=12e3,el=300,Dd=240,Eg=560,_d=n.lazy(()=>sl(()=>import("./ModelPreview-CsZry3Wd.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]))),Ag=n.lazy(()=>sl(()=>import("./ArchitecturePanel-Bd_l74EC.js"),__vite__mapDeps([32,1,2,3,4,5,33,11,12,13,24,20,25,26,17,18,34,19,8,21,9,10,14,15,22,23,27,28,29,30,6,31,35])).then(r=>({default:r.ArchitecturePanel}))),Tg=n.lazy(()=>sl(()=>import("./ComputerControlView-CwB-wQqB.js").then(r=>r.a),__vite__mapDeps([36,1,2,3,4,5,29,14,37,30])));function ju(r,a,i){return r&&!a?"unified":i}const Mg=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function Lg(r){return r==="preview"||r==="source"}function Ig(r){return r==="list"||r==="tree"||r==="ai"}function Bd(){return dt(yu,Lg)??"preview"}function $g(){return dt(vu,Ig)??"tree"}function ra(r){return typeof r=="boolean"}function Fg(r){return typeof r=="string"}function Dg(){return dt(wu,ra)??!0}function _g(r){return r==="unified"||r==="split"}function Bg(){return dt(ku,_g)??"unified"}function Ug(r){return r==="name"||r==="content"||r==="regex"}function Og(){return dt(Su,Ug)??"name"}function Cu(r){return r.repositories??(r.context?.root?[{id:r.context.root,root:r.context.root,relativeRoot:".",name:xt(r.context.root)||r.context.root,depth:0,nested:!1,available:r.available,files:r.files,context:r.context,error:r.error}]:[])}function Hg(r,a){if(!a)return null;const i=new Set((r.repoFilters??[]).map(c=>c.root));return i.has(a)?a:i.size>0?null:(r.repositories??[]).some(c=>c.root===a)?a:null}function tl(r){return!r.activeGitRepoRoot&&(r.groupCount>1||r.label!==r.rootName)}function Nu(...r){const a=new Set;for(const i of r)for(const c of i)a.add(c.root);return a}function rl(r){return Array.isArray(r)&&r.every(a=>typeof a=="string")}function Ud(r){const a=dt(r,rl);return a?new Set(a):new Set}function Bi(r,a){Et(r,[...a])}function zg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const a=r;return typeof a.filePath=="string"&&typeof a.hunkHeader=="string"&&typeof a.hunkIndex=="number"&&typeof a.fingerprint=="string"&&typeof a.additions=="number"&&typeof a.deletions=="number"&&typeof a.diff=="string"&&(a.oldPath===void 0||a.oldPath===null||typeof a.oldPath=="string")&&(a.newPath===void 0||a.newPath===null||typeof a.newPath=="string")&&(a.source===void 0||a.source==="committed"||a.source==="uncommitted"||a.source==="unknown")&&(a.commit===void 0||a.commit===null||typeof a.commit=="string")}function Gg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const a=r;return typeof a.available=="boolean"&&(a.repoRoot===void 0||typeof a.repoRoot=="string")&&(a.workspaceRoot===void 0||typeof a.workspaceRoot=="string")&&(a.baseRef===void 0||typeof a.baseRef=="string")&&(a.baseBranch===void 0||typeof a.baseBranch=="string")&&(a.currentBranch===void 0||a.currentBranch===null||typeof a.currentBranch=="string")&&(a.headRef===void 0||a.headRef===null||typeof a.headRef=="string")&&(a.diffFingerprint===void 0||typeof a.diffFingerprint=="string")&&(a.stat===void 0||typeof a.stat=="string")&&(a.files===void 0||rl(a.files))&&(a.hunks===void 0||Array.isArray(a.hunks)&&a.hunks.every(zg))&&(a.commits===void 0||rl(a.commits))&&(a.commitCount===void 0||typeof a.commitCount=="number")&&(a.diff===void 0||typeof a.diff=="string")&&(a.truncated===void 0||typeof a.truncated=="boolean")&&(a.error===void 0||typeof a.error=="string")}function Wg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const a=r;return typeof a.key=="string"&&Gg(a.diff)&&typeof a.repoLabel=="string"&&typeof a.createdAt=="number"}function Kg(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(a=>{if(!a||typeof a!="object"||Array.isArray(a))return!1;const i=a;return Array.isArray(i.selectedRepoRoots)&&i.selectedRepoRoots.every(c=>typeof c=="string")&&!!i.repoTargetBranches&&typeof i.repoTargetBranches=="object"&&!Array.isArray(i.repoTargetBranches)&&Object.values(i.repoTargetBranches).every(c=>typeof c=="string")&&(i.repoBaseBranches===void 0||!!i.repoBaseBranches&&typeof i.repoBaseBranches=="object"&&!Array.isArray(i.repoBaseBranches)&&Object.values(i.repoBaseBranches).every(c=>typeof c=="string"))&&(i.previewEntries===void 0||Array.isArray(i.previewEntries)&&i.previewEntries.every(Wg))&&(i.selectedPreviewKey===void 0||i.selectedPreviewKey===null||typeof i.selectedPreviewKey=="string")&&(i.selectedPreviewFileKey===void 0||i.selectedPreviewFileKey===null||typeof i.selectedPreviewFileKey=="string")&&(i.previewDetailOpen===void 0||typeof i.previewDetailOpen=="boolean")&&(i.previewScrollTops===void 0||!!i.previewScrollTops&&typeof i.previewScrollTops=="object"&&!Array.isArray(i.previewScrollTops)&&Object.values(i.previewScrollTops).every(c=>typeof c=="number"))&&(i.previewMobileSlideIndex===void 0||typeof i.previewMobileSlideIndex=="number")&&(i.repoIncludeUncommitted===void 0||!!i.repoIncludeUncommitted&&typeof i.repoIncludeUncommitted=="object"&&!Array.isArray(i.repoIncludeUncommitted)&&Object.values(i.repoIncludeUncommitted).every(c=>typeof c=="boolean"))&&(i.includeUncommitted===void 0||typeof i.includeUncommitted=="boolean")&&typeof i.updatedAt=="number"})}function Od(){return dt(Ru,Kg)??{}}function Hd(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function zd(r){const a=r?.trim()??"",i=a.indexOf("/");return i>=0?a.slice(i+1):a}function Pu(r,a){const i=r?.trim(),c=a?.trim();return!i||!c?!1:i===c||zd(i)===zd(c)}function Gd(r){const a=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(c=>c&&!Pu(c,a))??""}function nl(r,a){const i=Math.max(Dd,a-320),c=Math.min(Eg,i);return Math.min(c,Math.max(Dd,r))}function qg(r){return typeof r=="number"&&Number.isFinite(r)}function Vg(r){return nl(dt(hs,qg)??el,r)}function Eu(r){const a=r.split(/[\\/]/).pop()??r,i=a.lastIndexOf(".");return i>=0?a.slice(i).toLowerCase():""}function Js(r){return Mg.has(Eu(r))}function fs({label:r,value:a,options:i,placeholder:c,searchPlaceholder:f,emptyText:m,disabled:p,onChange:S}){const{t:g}=Bt(),[x,w]=n.useState(!1),[k,b]=n.useState(""),[E,P]=n.useState(null),M=n.useRef(null),$=n.useRef(null),J=k.trim().toLowerCase(),N=n.useMemo(()=>J?i.filter(F=>`${F.label} ${F.meta??""}`.toLowerCase().includes(J)):i,[J,i]),O=i.find(F=>F.value===a),K=()=>{const F=k.trim();F&&(S(F),w(!1),b(""))},X=n.useCallback(()=>{const F=M.current?.getBoundingClientRect();if(!F)return!1;const o=12,fe=Math.max(220,Math.min(F.width,window.innerWidth-o*2)),W=Math.min(Math.max(o,F.left),window.innerWidth-fe-o),ge=window.innerHeight-F.bottom-o,H=F.top-o,ce=ge>=180||ge>=H,j=Math.max(96,(ce?ge:H)-4),I=Math.min(320,j);return P({left:W,top:ce?F.bottom+4:Math.max(o,F.top-I-4),width:fe,maxHeight:I}),!0},[]),xe=()=>{X(),w(!0)};return n.useEffect(()=>{if(!x)return;let F=0;const o=()=>{F||(F=window.requestAnimationFrame(()=>{F=0,X()}))},fe=W=>{const ge=W.target;ge instanceof Node&&(M.current?.contains(ge)||$.current?.contains(ge)||(w(!1),b("")))};return window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),document.addEventListener("pointerdown",fe,!0),()=>{F&&window.cancelAnimationFrame(F),window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0),document.removeEventListener("pointerdown",fe,!0)}},[x,X]),t.jsxs("div",{className:"relative min-w-0",children:[t.jsxs("button",{ref:M,type:"button",disabled:p,onClick:()=>{if(!p){if(b(""),x){w(!1);return}xe()}},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:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:r}),t.jsx("span",{className:`min-w-0 flex-1 truncate text-[13px] ${a?"text-foreground":"text-muted-foreground/70"}`,children:O?.label??(a||c)})]}),t.jsx(oa,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${x?"rotate-180":""}`})]}),x&&!p&&typeof document<"u"&&Qr.createPortal(t.jsxs("div",{ref:$,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:F=>F.stopPropagation(),style:{left:E?.left??12,top:E?.top??12,width:E?.width??260,maxHeight:E?.maxHeight??320},children:[t.jsx("div",{className:"border-b border-border/10 p-1.5",children:t.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5",children:[t.jsx(ms,{size:12,className:"shrink-0 text-muted-foreground"}),t.jsx("input",{autoFocus:!0,value:k,onChange:F=>b(F.target.value),onKeyDown:F=>{if(F.key==="Escape"){F.preventDefault(),w(!1),b("");return}F.key==="Enter"&&(F.preventDefault(),K())},onBlur:()=>{k.trim()&&N.length===0&&K()},placeholder:f,className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground outline-none placeholder:text-muted-foreground/70"})]})}),t.jsxs("div",{className:"overflow-y-auto p-1",style:{maxHeight:Math.max(96,(E?.maxHeight??320)-46)},children:[k.trim()&&!i.some(F=>F.value===k.trim())&&t.jsxs("button",{type:"button",onMouseDown:F=>F.preventDefault(),onClick:K,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:[t.jsx("span",{className:"min-w-0 truncate",children:k.trim()}),t.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:g("common.use")})]}),N.length>0?N.map(F=>t.jsxs("button",{type:"button",onClick:()=>{S(F.value),w(!1),b("")},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 ${F.value===a?"bg-accent/10 text-accent":"text-foreground"}`,children:[t.jsx("span",{className:"min-w-0 truncate font-medium",children:F.label}),F.meta&&t.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:F.meta})]},F.value)):t.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:m})]})]}),document.body)]})}function Wd({open:r,onOpenChange:a,showScopePicker:i,selectedAll:c,repos:f,selectedRoots:m,onToggleRepo:p,onGenerate:S,onSecondaryAction:g,disabled:x,generateDisabled:w,secondaryDisabled:k,inserted:b,buttonLabel:E,insertedLabel:P,title:M,ariaLabel:$,scopeTitle:J,scopeLabel:N,allLabel:O,generateLabel:K,secondaryLabel:X,secondaryTitle:xe,secondaryLoading:F,loading:o,error:fe,statusTitle:W,extraContent:ge,renderRepoExtra:H,menuItem:ce=!1}){return t.jsxs("div",{className:ce?"relative w-full":"relative inline-flex shrink-0",children:[t.jsxs("button",{type:"button",role:ce?"menuitem":void 0,tabIndex:ce?-1:void 0,onClick:j=>{i?a(!r):w||S(j.currentTarget)},disabled:x,className:`relative flex items-center rounded-md transition disabled:cursor-not-allowed disabled:opacity-50 ${ce?"min-h-10 w-full gap-2.5 px-2.5 text-left text-[12px] focus:bg-surface-2 focus:outline-none [@media(pointer:coarse)]:min-h-11":"h-7 shrink-0 justify-center gap-1 px-2 text-[11px] font-medium active:scale-95"} ${fe?"text-destructive hover:bg-destructive/5":b?"bg-surface-elevated text-foreground":ce?"text-foreground hover:bg-surface-2":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":$,title:W??(i?`${J}: ${N}`:M),children:[o?t.jsx(ct,{size:ce?15:13,className:"shrink-0 animate-spin"}):t.jsx(aa,{size:ce?15:13,className:ce?"shrink-0 text-muted-foreground":void 0}),t.jsx("span",{className:ce?"min-w-0 flex-1":void 0,children:b?P:E}),i&&(ce?t.jsx(ps,{size:13,className:"shrink-0 text-muted-foreground"}):t.jsx(oa,{size:11,className:`shrink-0 transition ${r?"rotate-180":""}`})),fe&&t.jsx("span",{className:"absolute right-0.5 top-0.5 size-1.5 rounded-full bg-destructive"})]}),i&&r&&typeof document<"u"&&Qr.createPortal(t.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] px-3 py-6 backdrop-blur-sm animate-fade-in",onClick:()=>a(!1),children:t.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:j=>j.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border/15 px-3 py-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:J}),t.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:N})]}),t.jsx("button",{type:"button",onClick:()=>a(!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:t.jsx(Qt,{size:14})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[ge,t.jsxs("button",{type:"button",onClick:()=>p(null),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${c?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[t.jsx("span",{className:"truncate",children:O}),c&&t.jsx("span",{className:"text-[10px]",children:"✓"})]}),f.map(j=>{const I=m.includes(j.root);return t.jsxs("div",{className:`mt-1 rounded-md transition ${I?"bg-primary/15 text-primary":""}`,children:[t.jsxs("button",{type:"button",onClick:()=>p(j.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${I?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:j.root,children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate",children:j.label}),j.branch&&t.jsx("span",{className:"block truncate text-[9px] opacity-70",children:j.branch})]}),I&&t.jsx("span",{className:"text-[10px]",children:"✓"})]}),H&&(c||I)&&t.jsx("div",{className:"px-2 pb-2",children:H(j)})]},j.root)})]}),t.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${g&&X?"sm:grid-cols-2":""}`,children:[g&&X&&t.jsxs("button",{type:"button",onClick:()=>{k||(a(!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:xe,children:[F?t.jsx(ct,{size:12,className:"animate-spin"}):t.jsx(lu,{size:12}),X]}),t.jsxs("button",{type:"button",onClick:async j=>{if(w)return;await S(j.currentTarget)!==!1&&a(!1)},disabled:w,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:M,children:[t.jsx(aa,{size:12}),K]})]})]})}),document.body)]})}function Yg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const a of Object.values(r)){if(!a||typeof a!="object"||Array.isArray(a))return!1;const i=a;if(typeof i.top!="number"||!Number.isFinite(i.top)||typeof i.updatedAt!="number"||!Number.isFinite(i.updatedAt))return!1}return!0}function Au(){return dt(al,Yg)??{}}function Xg(r,a){const i=Au(),c=Object.entries({...i,[r]:{top:a,updatedAt:Date.now()}}).sort(([,f],[,m])=>m.updatedAt-f.updatedAt).slice(0,xg);na(al,Object.fromEntries(c),vg)}function Jg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const a=r;return typeof a.start=="number"&&Number.isFinite(a.start)&&typeof a.end=="number"&&Number.isFinite(a.end)&&a.start>=1&&a.end>=a.start}function Qg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const a of Object.values(r)){if(!a||typeof a!="object"||Array.isArray(a))return!1;const i=a;if(typeof i.top!="number"||!Number.isFinite(i.top)||i.left!==void 0&&(typeof i.left!="number"||!Number.isFinite(i.left))||i.markdownTop!==void 0&&(typeof i.markdownTop!="number"||!Number.isFinite(i.markdownTop))||i.lineRange!==void 0&&i.lineRange!==null&&!Jg(i.lineRange)||typeof i.updatedAt!="number"||!Number.isFinite(i.updatedAt))return!1}return!0}function il(r,a){if(!a)return null;const i=r&&!a.startsWith("/")?`${r}/${a}`:a;return r?`${r}::${i}`:i}function Tu(){return dt(ol,Qg)??{}}function Kd(r,a){const i=il(r,a);return i?Tu()[i]??null:null}function Ui(r,a,i){const c=il(r,a);if(!c)return;const f=Tu(),m=f[c]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},p=Object.entries({...f,[c]:{...m,...i,updatedAt:Date.now()}}).sort(([,S],[,g])=>g.updatedAt-S.updatedAt).slice(0,yg);na(ol,Object.fromEntries(p),wg)}function Oi({slow:r}){return t.jsx(fp,{slow:r})}function io({message:r,onRetry:a}){const{t:i}=Bt();return t.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:[t.jsx("div",{className:"font-medium",children:i("rightSidebar.gitChangesLoadFailed")}),t.jsx("div",{className:"mt-1 break-words text-xs opacity-85",children:r}),t.jsx("button",{type:"button",onClick:a,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:i("rightSidebar.retryGitChanges")})]})}function fo(r,a){const i=a&&r.startsWith(`${a}/`)?r.slice(a.length+1):r,c=i.split("/").filter(Boolean);return{name:c.pop()||i,dir:c.join("/")}}function xt(r){if(!r)return"";const a=r.replace(/\/+$/,"");return a.split("/").pop()||a||"/"}function lo(r){if(!r)return null;const a=Jd(r);return a==="/"?null:Uh(a)}function Zg(r,a,i){return Vi(r,a,i)}function Mu(r){const a=new Map;for(const i of r)a.set(ll(i),i);return a}function Lu(r,a){const i=new Map(r);for(const c of a)i.set(ll(c),c);return i}function qd(r,a){let i=0;for(const c of r){const f=mt(c,a);f&&a&&f!==a&&(i+=1)}return i}function eb(r){return r.reduce((a,i)=>a+(i.staged?1:0),0)}function tb(r,a){return Array.from(Lu(Mu(r),a).values()).sort((i,c)=>i.path.localeCompare(c.path))}function rb(r,a){const i=r.relativeRoot==="."?xt(a??r.root)||r.name||r.root:r.relativeRoot||r.name||xt(r.root)||r.root;return{root:r.root,label:i,branch:r.context?.branch??null,count:r.files.length,staged:eb(r.files)}}function Iu(r,a){const i=xt(a??"")||a||"";return r.map(c=>rb(c,a)).sort((c,f)=>i&&c.label===i?-1:i&&f.label===i?1:c.label.localeCompare(f.label))}function $u(r,a,i,c,f){const m=Cu(i),p=m.find(M=>M.root===c)??m[0]??null,S=a.find(M=>M.root===c)??null,g=S?.relativeRoot??p?.relativeRoot??".",x=S?.name??p?.name??(xt(c)||c),w=(p?.files??i.files).map(M=>({...M,repoRoot:c,repoRelativeRoot:g,repoName:x})),k=p?.context??i.context,b={...S??p??{id:c,root:c,relativeRoot:g,name:x,depth:0,nested:!!(f&&c!==f),available:i.available,files:[],context:null},...p??{},id:S?.id??p?.id??c,root:c,displayRoot:S?.displayRoot??p?.displayRoot,relativeRoot:g,name:x,depth:S?.depth??p?.depth??0,nested:S?.nested??p?.nested??!!(f&&c!==f),available:p?.available??i.available,deferred:p?.deferred??!1,files:w,context:k?{...k,root:c,changedFiles:w.map(M=>({path:M.path,absolutePath:M.absolutePath,status:M.status}))}:null,untrackedDeferred:p?.untrackedDeferred??i.untrackedDeferred,error:p?.error??i.error},E=S?a.map(M=>M.root===c?b:M):[...a,b];return{files:Array.from(r).filter(M=>mt(M,f)!==c).concat(w),repositories:E,repoFilters:Iu(E,f)}}function mt(r,a){return r.repoRoot??a}function ll(r){return`${r.repoRoot??""}\0${r.path}`}function yr(r){return r.absolutePath||r.path}function Hi(r){return ll(r)}function nb(r){return r.repoRelativeRoot&&r.repoRelativeRoot!=="."?r.repoRelativeRoot:r.repoName??""}function Vd(r){return r.reduce((a,i)=>a+(i.staged?1:0),0)}function Yd(r){const a={added:0,modified:0,deleted:0,renamed:0,copied:0,untracked:0,conflicted:0,staged:0,other:0};for(const i of r)i.status==="added"?a.added+=1:i.status==="modified"?a.modified+=1:i.status==="deleted"?a.deleted+=1:i.status==="renamed"?a.renamed+=1:i.status==="copied"?a.copied+=1:i.status==="untracked"?a.untracked+=1:i.status==="conflicted"?a.conflicted+=1:a.other+=1,i.staged&&(a.staged+=1);return a}function Qs(r){let a=0;const i=r??"root";for(let c=0;c<i.length;c+=1)a=Math.imul(a^i.charCodeAt(c),16777619);return`right-sidebar-git-bundle:${(a>>>0).toString(36)}`}function Zs(r,a){return typeof r!="number"||!Number.isFinite(r)||r<=0?null:new Intl.DateTimeFormat(a==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(r))}function vr(r){return r instanceof DOMException&&r.name==="AbortError"}function sb(r){const a=r.error??r.context?.error??"";return a.includes("request was cancelled")||a.includes("IO_REQUEST_CANCELLED")}function Xd(r){return r?.available===!1&&r.code==="NOT_GIT_REPOSITORY"}function ab({actions:r,running:a,completed:i}){const{t:c}=Bt(),[f,m]=n.useState(!1),p=n.useRef(null),S=r.find(x=>a?.action===x.key),g=r.find(x=>i?.action===x.key);return r.length===0?null:(n.useEffect(()=>{if(!f)return;const x=k=>{const b=k.target;b instanceof Node&&p.current?.contains(b)||m(!1)},w=k=>{k.key==="Escape"&&m(!1)};return document.addEventListener("pointerdown",x),document.addEventListener("keydown",w),()=>{document.removeEventListener("pointerdown",x),document.removeEventListener("keydown",w)}},[f]),t.jsxs("div",{ref:p,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),m(w=>!w)},disabled:r.every(x=>x.disabled)&&!a&&!i,className:`inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md transition active:scale-95 disabled:opacity-50 ${f?"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:S?.label??g?.label??c("rightSidebar.gitQuickActions"),children:S?t.jsx(ct,{size:13,className:"animate-spin"}):g?t.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):t.jsx(ho,{size:14})}),f&&t.jsx("div",{className:"absolute right-0 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:r.map(x=>{const w=a?.action===x.key,k=i?.action===x.key;return t.jsxs("button",{type:"button",onClick:b=>{b.stopPropagation(),x.onClick(),m(!1)},disabled:x.disabled||!!a,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":x.destructive?"text-destructive hover:bg-destructive/10":"text-foreground hover:bg-surface-2"}`,children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:w?t.jsx(ct,{size:13,className:"animate-spin"}):k?"✓":null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:x.label})]},x.key)})})]}))}function ob(r){const a=window.getComputedStyle(r).overflowY;return(a==="auto"||a==="scroll")&&r.scrollHeight>r.clientHeight+1}function Fu(r){let a=r;for(;a;){if(a.classList.contains("termdock-diff-stream-scroller")&&ob(a))return a;a=a.parentElement}return r.closest(".termdock-diff-stream-scroller")}function gs(r){return r.getClientRects().length>0&&window.getComputedStyle(r).visibility!=="hidden"}const zi=new WeakMap;function xo(r){const a=zi.get(r);a!==void 0&&window.clearTimeout(a),r.classList.remove("diff-walkthrough-target"),r.offsetWidth,r.classList.add("diff-walkthrough-target");const i=window.setTimeout(()=>{r.classList.remove("diff-walkthrough-target"),zi.delete(r)},1700);zi.set(r,i)}function ib(r){const a=CSS.escape(r),i=[`[data-diff-stream-item="${a}"]`,`[data-diff-selection-path="${a}"]`,`[data-diff-absolute-path="${a}"]`].join(","),c=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let f=null;for(const S of c){if(!gs(S))continue;const g=S.querySelector(i);if(g&&gs(g)){f=g;break}}if(f??=Array.from(document.querySelectorAll(i)).find(gs)??null,!f)return;const m=Fu(f);if(!m){f.scrollIntoView({block:"start",behavior:"smooth"}),xo(f);return}const p=f.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop;m.scrollTo({top:Math.max(0,p),behavior:"instant"}),xo(f)}function Ln(r){const a=CSS.escape(r.filePath),i=typeof r.sectionIndex=="number"?String(r.sectionIndex):null,c=typeof r.hunkIndex=="number"?String(r.hunkIndex):null,f=r.sectionFingerprint?CSS.escape(r.sectionFingerprint):null,m=r.hunkFingerprint?CSS.escape(r.hunkFingerprint):null,p=[i!==null&&f?`[data-diff-section-audit="${a}"][data-diff-section-index="${i}"][data-diff-section-fingerprint="${f}"]`:null,i!==null&&f?`[data-diff-section-anchor="${a}"][data-diff-section-index="${i}"][data-diff-section-fingerprint="${f}"]`:null,i!==null?`[data-diff-section-audit="${a}"][data-diff-section-index="${i}"]`:null,i!==null?`[data-diff-section-anchor="${a}"][data-diff-section-index="${i}"]`:null,c!==null&&m?`[data-diff-hunk-anchor="${a}"][data-diff-hunk-index="${c}"][data-diff-hunk-fingerprint="${m}"]`:null,c!==null?`[data-diff-hunk-anchor="${a}"][data-diff-hunk-index="${c}"]`:null,`[data-diff-file-path="${a}"]`].filter(P=>!!P),S=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let g=null;for(const P of S)if(gs(P)){for(const M of p){const $=P.querySelector(M);if($&&gs($)){g=$;break}}if(g)break}if(g??=p.flatMap(P=>Array.from(document.querySelectorAll(P))).find(gs)??null,!g){ib(r.filePath);return}const x=Fu(g);if(!x){g.scrollIntoView({block:"center",behavior:"smooth"}),xo(g);return}const w=g.getBoundingClientRect(),k=x.getBoundingClientRect(),E=w.top-k.top+x.scrollTop-Math.max(24,(x.clientHeight-w.height)/2);x.scrollTo({top:Math.max(0,E),behavior:"instant"}),xo(g)}let lb=0,cb=0,db=0,ub=0,fb=0;function ot(r,a={}){if(typeof window>"u")return;const i=JSON.stringify({level:r==="error"||r==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${r}`,data:{seq:++cb,ts:Date.now(),...a}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0}).catch(()=>{})}function ea(r,a={}){if(typeof window>"u")return;const i=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${r}`,data:{seq:++ub,ts:Date.now(),...a}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0}).catch(()=>{})}function hb(){return`diff-ui-${Date.now().toString(36)}-${(++fb).toString(36)}`}function pb(r){return r instanceof Element?r.closest("[data-diff-selection-path]"):null}function mb(r){const a=r.target instanceof HTMLElement?r.target:null;return{eventType:r.type,button:r.button,pointerType:r instanceof globalThis.PointerEvent?r.pointerType:void 0,targetTag:a?.tagName,targetClass:a?.className,targetText:a?.textContent?.slice(0,80)}}function yo({onReviewReference:r,filePath:a,active:i=!0,onInsertReference:c,onInsertText:f,onInsertFeature:m,onReferenceCopied:p,onClose:S,onDirectoryLinkOpen:g,isMobile:x,markdownOutlineOpen:w,markdownOutlineCloseSignal:k,onOpenMarkdownOutline:b,onCloseMarkdownOutline:E,markdownImageLightboxOpen:P,markdownImageLightboxCloseSignal:M,onOpenMarkdownImageLightbox:$,onCloseMarkdownImageLightbox:J,lineRange:N,onLineRangeChange:O,insertedReferenceKey:K,copiedReferenceKey:X,scrollToLine:xe,onScrollToLineHandled:F}){const{t:o}=Bt(),fe=n.useRef(null),W=n.useRef({}),ge=n.useRef(i);ge.current=i,n.useEffect(()=>{i||fe.current?.querySelectorAll("video").forEach(R=>R.pause())},[i]);const H=B(R=>R.rootPath),ce=B(R=>R.selectFile),[j,I]=n.useState({kind:"idle"}),[te,re]=n.useState("schematic"),[C,D]=n.useState(null),z=n.useRef(null),[ie,Ce]=n.useState(null),ve=n.useRef(new Map),he=n.useRef(null),[U,pe]=n.useState(null),[le,Ie]=n.useState(()=>Bd()),[De,Pe]=n.useState(()=>Nd(H,a)),L=n.useRef(null),[se,Te]=n.useState(!1),[_e,Ee]=n.useState(null),[Ut,Ge]=n.useState(0),[ut,We]=n.useState([]),[At,be]=n.useState(null),ft=n.useRef(null),lr=n.useRef(a),[Je,Oe]=n.useState(null),Q=ih(H&&a&&!a.startsWith("/")?`${H}/${a}`:a,i),[Se,rt]=n.useState(!1),[ht,wr]=n.useState(""),[$e,T]=n.useState([]),[V,we]=n.useState(0),et=n.useRef(null),kt=tu(p),pt=il(H,a);n.useEffect(()=>{if(lr.current===a)return;lr.current=a;const R=a&&H&&!a.startsWith("/")?`${H}/${a}`:a;if(ft.current===R){ft.current=null;return}ft.current=null,We([]),be(null),rt(!1),wr("")},[a,H]);const St=a?H&&!a.startsWith("/")?`${H}/${a}`:a:null,In=B(R=>St?(R.fileChangeVersions.get(St)??0)+R.fileWatchEpoch:R.fileWatchEpoch),bs=n.useRef(null),kr=n.useRef(null),[Ot,Zr]=n.useState(0),Zt=n.useCallback(()=>Zr(R=>R+1),[]);n.useEffect(()=>{const R=z.current;return z.current=null,D(null),R&&URL.revokeObjectURL(R.objectUrl),()=>{const A=z.current;z.current=null,A&&URL.revokeObjectURL(A.objectUrl)}},[St,In,Ot]),n.useEffect(()=>{if(!a){bs.current=null,I({kind:"idle"});return}const R=H&&!a.startsWith("/")?`${H}/${a}`:a,A=new AbortController,de=++lb,ke=`right-sidebar-file-preview:${de}`,Qe=performance.now();let Me=!1;const ze=(q,qe={})=>{Me||(Me=!0,Ei("end",{loadingId:de,reason:q,durationMs:Math.round(performance.now()-Qe),filePath:a,fullPath:R,rootPath:H,...qe}))};let Le=null;const Ke=lh(R),it=Ke?R.toLowerCase().endsWith(".kicad_pcb")?te==="schematic"?"pcb-front":te:"schematic":te,_n=!Ke&&ch(R),dr=!Ke&&!_n&&dh(R),Rs=!Ke&&!_n&&!dr&&uh(R),an=Js(R),on=Ys(R),zr=Ke?"eda":_n?"image":dr?"model3d":Rs?"video":"text",ln=bs.current!==R;if(bs.current=R,ln){Ei("start",{loadingId:de,filePath:a,fullPath:R,rootPath:H,mode:zr,externalVersion:In}),I({kind:"loading",mode:zr}),kr.current=null;const q=Kd(H,a);O(q?.lineRange??null),Ie(an?Bd():"source"),Pe(on?Nd(H,a):"source"),Ke&&re(fh(R))}ln||I(q=>q.kind==="error"?{kind:"loading",mode:zr}:q);const cn=window.setTimeout(()=>{Me||A.signal.aborted||Ei("still_active",{loadingId:de,filePath:a,fullPath:R,rootPath:H,mode:zr,durationMs:Math.round(performance.now()-Qe),isPathChange:ln})},3e3),js=window.setTimeout(()=>{if(Me||A.signal.aborted)return;const q=Ke?o("rightSidebar.edaTimeout"):dr?o("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";A.abort(new DOMException(q,"TimeoutError")),I({kind:"error",message:q}),ze("stuck_timeout",{error:q})},Ke?hh+5e3:dr?ph+5e3:mh(R)?35e3:Pg);if(Ke){const q=it==="pcb-3d"?z.current:null;q?(I(q),ze("eda_3d_client_cache_hit",{bytes:q.meta.size,view:q.view,mimeType:q.meta.mimeType})):gh(R,it,A.signal,"view_file",ke).then(qe=>{if(A.signal.aborted)return;Le=URL.createObjectURL(qe.blob);const Mt={kind:"eda",sourcePath:qe.path||R,objectUrl:Le,view:qe.view,meta:{size:qe.size,mimeType:qe.mimeType,modified:qe.modified}};if(qe.view==="pcb-3d"){const ur=z.current;ur&&ur.objectUrl!==Le&&URL.revokeObjectURL(ur.objectUrl),z.current=Mt,D(Mt),Le=null}I(Mt),ze("eda_loaded",{bytes:qe.size,view:qe.view,mimeType:qe.mimeType})}).catch(qe=>{A.signal.aborted||(I({kind:"error",message:qe instanceof Error&&/timed out/i.test(qe.message)?o("rightSidebar.edaTimeout"):qe instanceof Error?qe.message:o("rightSidebar.edaLoadFailed")}),ze("error",{error:qe instanceof Error?qe.message:String(qe)}))})}else if(_n)bh(R,A.signal,"view_file",ke).then(q=>{Le=URL.createObjectURL(q.blob),I({kind:"image",objectUrl:Le,meta:{size:q.size,mimeType:q.mimeType,modified:q.modified}}),ze("image_loaded",{bytes:q.size,mimeType:q.mimeType})}).catch(q=>{A.signal.aborted||(I({kind:"error",message:q instanceof Error?q.message:o("rightSidebar.imageLoadFailed")}),ze("error",{error:q instanceof Error?q.message:String(q)}))});else if(dr)xh(R,A.signal,"view_file",ke).then(q=>{A.signal.aborted||(Le=URL.createObjectURL(q.blob),I({kind:"model3d",sourcePath:q.path||R,objectUrl:Le,ext:q.ext,meta:{size:q.size,mimeType:q.mimeType,modified:q.modified}}),ze("model3d_loaded",{bytes:q.size,ext:q.ext}))}).catch(q=>{A.signal.aborted||(I({kind:"error",message:q instanceof Error&&(q.name==="TimeoutError"||/timed out/i.test(q.message))?o("rightSidebar.model3dTimeout"):q instanceof Error?q.message:o("rightSidebar.model3dLoadFailed")}),ze("error",{error:q instanceof Error?q.message:String(q)}))});else if(Rs){const q=yh(R)??"",qe=_h(R);I(Mt=>Mt.kind==="video"&&Mt.url===qe?Mt:{kind:"video",url:qe,meta:{size:null,mimeType:q,modified:null}}),ze("video_ready",{mimeType:q})}else rd(R,A.signal,"view_file",ke).then(q=>{if(!A.signal.aborted){if(q.binary){I({kind:"binary"});return}I({kind:"text",content:q.content,sourcePath:q.path||R,meta:{size:q.size,truncated:q.truncated}}),ze("text_loaded",{bytes:q.size,truncated:!!q.truncated})}}).catch(q=>{A.signal.aborted||(I({kind:"error",message:q instanceof Error?q.message:"Failed to read file"}),ze("error",{error:q instanceof Error?q.message:String(q)}))});return()=>{A.abort(),wt(ke),window.clearTimeout(cn),window.clearTimeout(js),Le&&URL.revokeObjectURL(Le),ze("cleanup")}},[a,H,In,Ot,O,o,te]),n.useEffect(()=>{if(j.kind!=="model3d"||!a){Ce(null);return}let R=!1;const A=a.lastIndexOf("/"),de=A>=0?a.slice(A+1):a,ke=A>=0?a.slice(0,A):"",Qe=ke.lastIndexOf("/"),Me=Qe>=0?ke.slice(0,Qe):"",ze=de.replace(/\.(stl|glb|gltf)$/i,""),Le=`${Me?`${Me}/`:""}features/${ze}.json`;return rd(Le).then(Ke=>{if(!R)try{const it=JSON.parse(Ke.content);Ce(it.version===1&&Array.isArray(it.features)&&it.features.length>0?it.features:null)}catch{Ce(null)}}).catch(()=>{R||Ce(null)}),()=>{R=!0}},[j,a]),n.useEffect(()=>{if(j.kind!=="text"){Oe(null);return}const R=H&&a&&!a.startsWith("/")?`${H}/${a}`:a,A=Pp(R),de=j.content,ke=Js(R??"")&&le==="preview",Qe=Ys(R??"")&&De==="preview";if(!A||ke||Qe||!Ep(de)){Oe(null);return}let Me=!1;const ze=Le=>{if(Me||!Le.registered(A)){Me||Oe(null);return}try{Oe(Tp(Le,de,A))}catch{Oe(null)}};return _e?ze(_e):(Oe(null),Ap().then(Le=>{Me||(Ee(Le),ze(Le))}).catch(()=>{})),()=>{Me=!0}},[j,_e,a,H,le,De]),n.useLayoutEffect(()=>{if(!pt||j.kind!=="text")return;const R=`${pt}:${le}:${De}`;if(kr.current===R)return;const A=Kd(H,a);if(kr.current=R,!A)return;const de=requestAnimationFrame(()=>{const ke=he.current;if(!ke)return;const Qe=le==="preview"?A.markdownTop??A.top:A.top;ke.scrollTo({top:Math.max(0,Qe??0),left:Math.max(0,A.left??0)}),Ge(le==="preview"?Math.max(0,Qe??0):0)});return()=>cancelAnimationFrame(de)},[a,le,De,j.kind,pt,H]),n.useEffect(()=>{pt&&Ui(H,a,{lineRange:N})},[a,N,pt,H]),n.useEffect(()=>{if(xe==null||j.kind!=="text")return;pe(null),O({start:xe,end:xe});const R=xe,A=requestAnimationFrame(()=>{const de=ve.current.get(R);de&&de.scrollIntoView({block:"center"}),F?.()});return()=>cancelAnimationFrame(A)},[xe,j,O,F]);const $n=n.useCallback(R=>{const A=he.current;if(!A)return!1;const de=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(R):R.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),ke=A.querySelector(`#${de}`);return ke?(ke.scrollIntoView({block:"start"}),!0):!1},[]);n.useEffect(()=>{const R=H&&a&&!a.startsWith("/")?`${H}/${a}`:a,A=j.kind==="text"&&Js(R??"")&&le==="preview";if(!At||!A)return;const de=requestAnimationFrame(()=>{$n(At)&&be(null)});return()=>cancelAnimationFrame(de)},[a,$n,le,At,j,H]),n.useLayoutEffect(()=>{const R=he.current;if(!R||!N){pe(null);return}if(U)return;const A=j.kind==="image"||j.kind==="loading"&&j.mode==="image",de=H&&a&&!a.startsWith("/")?`${H}/${a}`:a,ke=j.kind==="text"&&Js(de??"")&&le==="preview",Qe=j.kind==="text"&&Ys(de??"")&&De==="preview";if(j.kind!=="text"||A||ke||Qe){pe(null);return}const Me=()=>{const Le=ve.current.get(N.end);if(!Le||!R){pe(null);return}const Ke=Le.offsetTop+Le.offsetHeight/2,it=R.scrollLeft+Math.max(8,R.clientWidth-120);pe({top:Ke,left:it})};Me();const ze=new ResizeObserver(()=>Me());return ze.observe(R),()=>ze.disconnect()},[N,U,j,le,De,a,H,Je]);const Sr=j.kind==="text"&&!(Ys(St??"")&&De==="preview")&&!St?.toLowerCase().endsWith(".csv")&&!St?.toLowerCase().endsWith(".kicad_pro")&&!St?.toLowerCase().endsWith(".kicad_prl"),Fn=n.useCallback(()=>{rt(!1),wr(""),T([]),we(0),oo(W.current)},[]),en=n.useCallback(()=>{!i||!Sr||(rt(!0),requestAnimationFrame(()=>{const R=fe.current;!ge.current||!R?.isConnected||R.closest('[inert], [aria-hidden="true"], [hidden]')||R.getClientRects().length===0||getComputedStyle(R).visibility==="hidden"||!R.contains(document.activeElement)||(et.current?.focus(),et.current?.select())}))},[i,Sr]),Dr=n.useCallback(R=>{we(A=>$e.length===0?0:(A+R+$e.length)%$e.length)},[$e.length]),Ht=n.useCallback(R=>{if(R.nativeEvent.isComposing||!cg(fe.current,i,R))return;const A=dg(R);if(A==="open"&&Sr){R.preventDefault(),en();return}Se&&(A==="close"?(R.preventDefault(),Fn()):(A==="next"||A==="previous")&&(R.preventDefault(),Dr(A==="previous"?-1:1)))},[i,Fn,Se,Dr,en,Sr]);if(n.useLayoutEffect(()=>{if(oo(W.current),!i||!Se||!ht.trim()||!he.current){T([]),we(0);return}const R=fg(he.current,ht);return T(R),we(0),(fe.current?.contains(document.activeElement)||Ad(W.current))&&(Ii(R,0,W.current),Td(R[0])),()=>oo(W.current)},[i,Se,ht,Je,le,j]),n.useEffect(()=>{!i||!Se||!ht.trim()||!fe.current?.contains(document.activeElement)&&!Ad(W.current)||(Ii($e,V,W.current),Td($e[V]))},[i,V,$e,Se,ht]),n.useEffect(()=>()=>oo(W.current),[]),!a)return t.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:o("rightSidebar.selectFilePrompt")});const He=H&&!a.startsWith("/")?`${H}/${a}`:a,Rt=fo(He,H),Rr=ru(He,H),jr=j.kind==="text"&&j.content?j.content.split(`
|
|
1639
|
+
`):[],ia=Math.max(2,String(jr.length).length)+1,Cr=j.kind==="text"||j.kind==="image"||j.kind==="model3d"||j.kind==="video"||j.kind==="eda"?j.meta:null,Nr=Js(He),la=He.toLowerCase().endsWith(".csv"),Tt=He.toLowerCase().endsWith(".kicad_pro"),xs=He.toLowerCase().endsWith(".kicad_prl"),zt=j.kind==="text"&&Nr&&le==="preview",ca=Ys(He),Gt=j.kind==="text"&&ca&&De==="preview",da=j.kind==="image"||j.kind==="loading"&&j.mode==="image",ko=j.kind==="model3d"||j.kind==="loading"&&j.mode==="model3d",yt=j.kind==="video"||j.kind==="loading"&&j.mode==="video",tn=j.kind==="eda"||j.kind==="loading"&&j.mode==="eda",ys=j.kind==="text"?j.sourcePath:He,_r=vh(ys,H,N),Br=(()=>{if(!N||j.kind!=="text"||jr.length===0)return _r;const R=[];for(let ke=N.start;ke<=N.end;ke+=1)R.push(`${ke} ${jr[ke-1]??""}`);const A=Eu(He).replace(/^\./,""),de="```";return`${_r}
|
|
1640
|
+
${de}${A}
|
|
1641
|
+
${R.join(`
|
|
1642
|
+
`)}
|
|
1643
|
+
${de}
|
|
1644
|
+
`})(),Pr=`path:${He}`,Er=N?`path:${He}:${N.start}-${N.end}`:Pr,Ur=K===Pr,Or=K===Er,Dn=X===Pr,vs=X===Er,rn=Or||vs,er=N?N.start===N.end?`L${N.start}`:`L${N.start}-${N.end}`:null,Hr=R=>{const A=he.current;if(!A)return;const de=A.getBoundingClientRect(),ke=R.currentTarget.getBoundingClientRect(),Qe=R.clientX||ke.left+ke.width/2,ze=(R.clientY||ke.top+ke.height/2)-de.top+A.scrollTop,Le=x?116:132,Ke=A.scrollLeft+Math.max(8,A.clientWidth-Le),it=Math.min(Math.max(8,Qe-de.left+A.scrollLeft+10),Ke);pe({top:ze,left:it})},ws=(R,A)=>{Mp()||(Hr(R),O(de=>{const ke=Vi(de,A,A);return ke||pe(null),ke}))},ks=(R,A,de)=>{Hr(R),O(ke=>{const Qe=Vi(ke,A,de);return Qe||pe(null),Qe})},Ar=(R,A,de,ke)=>{ke==="end"&&Hr(R),O({start:A,end:de})},cr=R=>{const{scrollTop:A,scrollLeft:de}=R.currentTarget;Ge(A),Ui(H,a,{top:A,left:de,markdownTop:A})},me=R=>{if(R.directory){g?.(R.path);return}if(R.path===He||j.kind==="text"&&R.path===j.sourcePath){R.fragment&&$n(R.fragment);return}We(A=>[...A,He]),ft.current=R.path,be(R.fragment),O(null),ce(R.path)},tr=()=>{const R=ut[ut.length-1];R&&(We(A=>A.slice(0,-1)),ft.current=R,be(null),O(null),ce(R))},nn=R=>{const{scrollTop:A,scrollLeft:de}=R.currentTarget;Ui(H,a,{top:A,left:de})},sn=R=>{if(r){r(Br,Er,void 0,R.currentTarget);return}N&&f(Br,Er,R.currentTarget)},Ss=()=>{if(!(j.kind==="loading"||j.kind==="error"))return Q.start()};return t.jsxs("div",{ref:fe,tabIndex:-1,onKeyDown:Ht,onFocusCapture:()=>{i&&Se&&ht.trim()&&Ii($e,V,W.current)},onPointerDownCapture:R=>{R.target instanceof Element&&!R.target.closest('button, input, textarea, select, a, [tabindex]:not([tabindex="-1"])')&&R.currentTarget.focus({preventScroll:!0})},className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[kt.popoverNode,t.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${x&&(zt||Gt)?"py-1.5":"py-2"}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[x&&S&&t.jsx("button",{type:"button",onClick:S,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":o("rightSidebar.backToFileList"),title:o("rightSidebar.backToFileList"),children:t.jsx(Lp,{size:16})}),ut.length>0&&t.jsxs("button",{type:"button",onClick:tr,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 ${x?"w-9":"px-2.5"}`,"aria-label":o("rightSidebar.backToPreviousPreview"),title:o("rightSidebar.backToPreviousPreview"),children:[t.jsx(po,{size:15}),!x&&t.jsx("span",{className:"text-[11px] font-medium",children:o("rightSidebar.backToPreviousPreview")})]}),t.jsxs("div",{className:"min-w-0",title:He,children:[t.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Rt.name}),Rt.dir&&t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Rt.dir})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Sr&&t.jsx("button",{type:"button",onClick:Se?Fn:en,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 ${Se?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":o("rightSidebar.findInFile"),title:`${o("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:t.jsx(ms,{size:14})}),Nr&&j.kind==="text"&&t.jsx("button",{type:"button",onClick:()=>{w&&E?.(),Ie(R=>{const A=R==="preview"?"source":"preview";return Et(yu,A),A}),O(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 ${x?"w-9 px-0":"px-3"}`,"aria-label":o(le==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:o(le==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:x?le==="preview"?t.jsx(Ki,{size:14}):t.jsx(Yi,{size:14}):o(le==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),ca&&j.kind==="text"&&t.jsx("button",{type:"button",onClick:()=>{Pe(R=>{const A=R==="preview"?"source":"preview";return Mm(H,a,A),A}),O(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 ${x?"w-9 px-0":"px-3"}`,"aria-label":o(De==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:o(De==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:x?De==="preview"?t.jsx(Ki,{size:14}):t.jsx(Yi,{size:14}):o(De==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),Gt&&t.jsx("button",{type:"button",onClick:()=>{L.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":o(se?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:o(se?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:t.jsx(iu,{size:15})}),!x&&t.jsx("button",{type:"button",onClick:R=>c(He,Pr,R.currentTarget),...kt(Rr,Pr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${Ur||Dn?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:o("rightSidebar.insertReference",{reference:Rr}),children:o(Dn?"rightSidebar.copied":Ur?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),t.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Rr)},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:o("rightSidebar.copyReference",{reference:Rr}),"aria-label":o("rightSidebar.copyFileRef"),children:t.jsx(wh,{size:13})}),t.jsx("button",{type:"button",onClick:()=>{Ss()},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.error??o("rightSidebar.downloadFailed"):o("rightSidebar.downloadFile"),"aria-label":o("rightSidebar.downloadFile"),children:Q.status==="pending"?t.jsx(ct,{size:13,className:"animate-spin"}):t.jsx(kh,{size:14})}),Q.status==="pending"&&t.jsx("button",{type:"button",onClick:Q.cancel,className:"inline-flex h-9 shrink-0 items-center rounded-full bg-surface-2 px-2 text-xs text-foreground hover:bg-surface-elevated",children:o("common.cancel")})]})]}),t.jsx(Sh,{status:Q.status,error:Q.error}),Se&&Sr&&t.jsxs("div",{className:"mt-2 flex min-w-0 items-center gap-1.5","data-file-preview-search":!0,children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center rounded-lg bg-surface-2 px-2 focus-within:bg-surface-elevated",children:[t.jsx(ms,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),t.jsx("input",{ref:et,type:"search",value:ht,onChange:R=>wr(R.target.value),onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),Dr(R.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:o("rightSidebar.findInFilePlaceholder"),"aria-label":o("rightSidebar.findInFile")}),t.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:$e.length>0?`${V+1}/${$e.length}`:"0/0"})]}),t.jsx("button",{type:"button",onClick:()=>Dr(-1),disabled:$e.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":o("rightSidebar.previousSearchMatch"),title:`${o("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:t.jsx(Ip,{size:13})}),t.jsx("button",{type:"button",onClick:()=>Dr(1),disabled:$e.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":o("rightSidebar.nextSearchMatch"),title:`${o("rightSidebar.nextSearchMatch")} (Enter)`,children:t.jsx($p,{size:13})}),t.jsx("button",{type:"button",onClick:Fn,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":o("rightSidebar.closeFileSearch"),title:`${o("rightSidebar.closeFileSearch")} (Esc)`,children:t.jsx(Qt,{size:13})})]}),Cr&&!(x&&(zt||Gt))&&t.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[Cr.size!==null&&t.jsx("span",{children:o("rightSidebar.byteCount",{count:Cr.size.toLocaleString()})}),"truncated"in Cr&&Cr.truncated&&t.jsx("span",{className:"text-[color:var(--warning)]",children:o("rightSidebar.previewTruncated")}),"mimeType"in Cr&&t.jsx("span",{children:Cr.mimeType}),"dimensions"in j&&j.dimensions&&t.jsxs("span",{children:[j.dimensions.width," × ",j.dimensions.height]})]}),!(x&&(zt||Gt))&&!ko&&j.kind!=="binary"&&t.jsx("div",{className:"mt-1 flex h-4 items-center gap-2 text-[10px] text-muted-foreground/75",children:t.jsx("span",{className:"truncate",children:tn?o("rightSidebar.edaPickHint"):la?o("rightSidebar.csvTablePreview"):Tt||xs?o("rightSidebar.kicadProjectPickHint"):yt?o("rightSidebar.videoPreviewHint"):da?o("rightSidebar.imagePreviewHint"):zt?N?o("rightSidebar.selectedLineHint",{lineLabel:er??""}):o("rightSidebar.markdownPreviewHint"):Gt?o("rightSidebar.htmlPreviewHint"):N?o("rightSidebar.selectedLineHint",{lineLabel:er??""}):o("rightSidebar.multiLineHint")})})]}),!i&&(j.kind==="video"||j.kind==="model3d"||j.kind==="eda"||Gt)?null:j.kind==="loading"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8",children:t.jsx(Ri,{label:j.mode==="eda"?o("rightSidebar.edaLoading"):j.mode==="image"?o("rightSidebar.loadingImage"):j.mode==="model3d"?o("rightSidebar.model3dLoading"):j.mode==="video"?o("rightSidebar.loadingVideo"):o("common.loading")})}):j.kind==="error"?t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[t.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}),t.jsx("button",{type:"button",onClick:Zt,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:o("common.retry")})]}):j.kind==="binary"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.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:o("rightSidebar.binaryPreviewHint")})}):j.kind==="image"?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:j.meta.mimeType==="image/svg+xml"?t.jsx(pu,{blobUrl:j.objectUrl,filePath:He,viewLabel:"SVG 文件",onInsertAnnotation:r??m}):t.jsx(qh,{src:j.objectUrl,alt:Rt.name,vector:!1,onLoad:R=>{const A=R.currentTarget;I(de=>de.kind==="image"?{...de,dimensions:{width:A.naturalWidth,height:A.naturalHeight}}:de)},onError:()=>I({kind:"error",message:o("rightSidebar.imageLoadFailed")})})}):j.kind==="video"?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:t.jsx(Om,{url:j.url,onLoadError:()=>I({kind:"error",message:o("rightSidebar.videoLoadFailed")})})}):j.kind==="eda"?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:t.jsx(Vm,{blobUrl:j.objectUrl,filePath:j.sourcePath,view:j.view,board:He.toLowerCase().endsWith(".kicad_pcb"),onViewChange:re,onInsertAnnotation:r??m,onRefresh:Zt,interactive3d:C?t.jsx(n.Suspense,{fallback:t.jsx(Ri,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:t.jsx(_d,{blobUrl:C.objectUrl,ext:".glb",fileName:Rt.name,filePath:C.sourcePath,features:null,onInsertFeature:r??m,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:R=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(R)?R:"PCB板体/铜箔/丝印",active:j.view==="pcb-3d"})}):void 0})}):j.kind==="model3d"?t.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:t.jsx(n.Suspense,{fallback:t.jsx(Ri,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:t.jsx(_d,{blobUrl:j.objectUrl,ext:j.ext,fileName:Rt.name,filePath:j.sourcePath,features:ie,onInsertFeature:r??m,onRefresh:Zt})})}):j.kind==="text"&&la?t.jsx(Jm,{content:j.content,filePath:He,onInsertAnnotation:r??m},He):j.kind==="text"&&(Tt||xs)?t.jsx(eg,{content:j.content,filePath:He,localState:xs,onInsertAnnotation:r??m},He):zt?t.jsxs("div",{ref:he,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:cr,style:{touchAction:"pan-x pan-y"},children:[t.jsx(cu,{content:j.content,filePath:j.sourcePath,rootPath:H,lineRange:N,onLineRangeClick:ks,onLineRangeDrag:Ar,scrollTop:Ut,outlineOpen:w,outlineCloseSignal:k,onOutlineOpen:b,onOutlineClose:E,lightboxOpen:P,lightboxCloseSignal:M,onLightboxOpen:$,onLightboxClose:J,onLocalLinkOpen:me}),N&&U&&t.jsxs("button",{type:"button",onClick:sn,...kt(Br,Er),style:{top:U.top,left:U.left,transform:"translateY(-50%)"},className:vd(x,rn),title:`Insert markdown reference: ${_r}`,children:[t.jsx(go,{size:x?13:11}),vs?o("rightSidebar.copied"):Or?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:er??""})]})]}):Gt?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:t.jsx(lg,{ref:L,src:Rh(He),title:`${Rt.name} preview`,exitFullscreenLabel:o("rightSidebar.htmlFullscreenExit"),onFullscreenChange:Te},`${He}:${In}:${Ot}`)}):j.kind==="text"?t.jsxs("div",{ref:he,onScroll:nn,className:`${Vh} 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:[jr.length>0?t.jsx("div",{className:"min-w-full",children:jr.map((R,A)=>{const de=A+1,ke=!!(N&&de>=N.start&&de<=N.end),Qe=Je&&Je.length===jr.length?Je[A]:null;return t.jsxs("div",{ref:Me=>{Me?ve.current.set(de,Me):ve.current.delete(de)},role:"button","data-file-preview-line":de,tabIndex:0,onClick:Me=>ws(Me,de),onKeyDown:Me=>{Me.key!=="Enter"&&Me.key!==" "||(Me.preventDefault(),ws(Me,de))},style:{gridTemplateColumns:`${ia}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${ke?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Rr}:${de}`,children:[t.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${ke?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:de}),t.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Qe??(R||" ")})]},A)})}):"Empty file.",N&&U&&t.jsxs("button",{type:"button",onClick:sn,...kt(Br,Er),style:{top:U.top,left:U.left,transform:"translateY(-50%)"},className:vd(x,rn),title:`Insert code reference: ${_r}`,children:[t.jsx(go,{size:x?13:11}),vs?o("rightSidebar.copied"):Or?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:er??""})]})]}):null]})}function gb({rootPath:r,file:a,active:i,...c}){const[f,m]=n.useState(null),[p,S]=n.useState(a.line??1),g=n.useCallback(()=>S(null),[]);return t.jsx("div",{"data-architecture-source":!0,className:"h-full min-h-0",children:t.jsx(yo,{...c,filePath:`${r.replace(/\/+$/,"")}/${a.path}`,active:i,lineRange:f,onLineRangeChange:m,scrollToLine:p,onScrollToLineHandled:g,markdownOutlineOpen:!1,markdownImageLightboxOpen:!1})})}function bb({isOpen:r,sessionId:a,drawerWidthPx:i,onClose:c,onOpen:f,push:m,pinned:p=!1,onTogglePinned:S,rightSidebarFilePreviewOpen:g=!1,rightSidebarFilePreviewCloseSignal:x,onOpenRightSidebarFilePreview:w,onCloseRightSidebarFilePreview:k,rightSidebarRepoPickerOpen:b=!1,rightSidebarRepoPickerCloseSignal:E,onOpenRightSidebarRepoPicker:P,onCloseRightSidebarRepoPicker:M,markdownOutlineOpen:$=!1,markdownOutlineCloseSignal:J,onOpenMarkdownOutline:N,onCloseMarkdownOutline:O,markdownImageLightboxOpen:K=!1,markdownImageLightboxCloseSignal:X,onOpenMarkdownImageLightbox:xe,onCloseMarkdownImageLightbox:F}){const{t:o,locale:fe}=Bt(),[W,ge]=n.useState(""),H=B(e=>e.pendingTerminalPath),[ce,j]=n.useState(null),I=n.useRef(0),te=B(e=>e.rightSearchOpen),re=B(e=>e.setRightSearchOpen),C=B(e=>e.rightSidebarLayoutPreference),D=B(e=>e.setRightSidebarLayoutPreference),[z,ie]=n.useState(()=>Og()),[Ce,ve]=n.useState("."),[he,U]=n.useState(""),[pe,le]=n.useState(!1),[Ie,De]=n.useState(!1),[Pe,L]=n.useState(!1),[se,Te]=n.useState(!1),_e=n.useDeferredValue(W),[Ee,Ut]=n.useState(null),[Ge,ut]=n.useState([]),[We,At]=n.useState([]),be=B(e=>e.contextKey?e.activeGitRepos[e.contextKey]??null:null),ft=B(e=>e.setActiveGitRepo),[lr,Je]=n.useState(null),[Oe,Q]=n.useState(null),[Se,rt]=n.useState(null),[ht,wr]=n.useState(!1),[$e,T]=n.useState(()=>dt(Ld,ra)??!1),[V,we]=n.useState(()=>dt(Id,ra)??!1),[et,kt]=n.useState(()=>dt($d,ra)??!1),[pt,St]=n.useState(()=>dt(Di,Fg)??""),[In,bs]=n.useState(0),[kr,Ot]=n.useState(!1),[Zr,Zt]=n.useState(!1),$n=n.useRef(null),Sr=n.useRef(null),[Fn,en]=n.useState(!1),[Dr,Ht]=n.useState(null),[He,Rt]=n.useState(null),[Rr,jr]=n.useState(()=>Ud($i)),[ia,Cr]=n.useState(()=>Ud(Md)),[Nr,la]=n.useState(()=>$g()),[Tt,xs]=n.useState(()=>Dg()),[zt,ca]=n.useState(()=>Bg()),Gt="words",[da,ko]=n.useState(0),[yt,tn]=n.useState([]),[ys,_r]=n.useState([]),[Br,Pr]=n.useState(!1),[Er,Ur]=n.useState(null),[Or,Dn]=n.useState([]),[vs,rn]=n.useState(!1),[er,Hr]=n.useState([]),[ws,ks]=n.useState([]),[Ar,cr]=n.useState(!1),[me,tr]=n.useState(null),[nn,sn]=n.useState([]),[Ss,R]=n.useState({}),A=n.useRef(0),[de,ke]=n.useState(0),[Qe,Me]=n.useState(!1),[ze,Le]=n.useState(null),[Ke,it]=n.useState(null),[_n,dr]=n.useState(null),[Rs,an]=n.useState(null),[on,zr]=n.useState(!1),[ln,cn]=n.useState(""),js=n.useDeferredValue(ln),[q,qe]=n.useState({}),[Mt,ur]=n.useState([]),[ua,Cs]=n.useState(!1),[fa,Ns]=n.useState(!1),[So,Bn]=n.useState(null),[Ro,Un]=n.useState(!1),fr=n.useRef(null),Gr=n.useRef(0),cl=n.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Du,ha]=n.useState(null),[Ps,dl]=n.useState(()=>dt(Fi,ra)??!1),[jo,Co]=n.useState(!1),[pa,No]=n.useState([]),[rr,ma]=n.useState({}),[jt,ga]=n.useState({}),[dn,Po]=n.useState({}),[ul,fl]=n.useState(()=>new Set),[Ve,un]=n.useState(null),[Eo,fn]=n.useState(null),[_u,Tr]=n.useState(!1),[Ao,Mr]=n.useState(0),[,To]=n.useState(0),[Mo,ba]=n.useState(!1),[Bu,Uu]=n.useState(()=>B.getState().rightTab==="files"),[nr,Lo]=n.useState(!1),[Ou,hl]=n.useState(()=>B.getState().rightTab==="diff"),[Io,pl]=n.useState(()=>B.getState().rightTab==="android"),[Wr,ml]=n.useState(!1),[sr,gl]=n.useState({architecture:!1,computer:!1}),Es=n.useRef(new Set),xa=ji(e=>e.docks[Ai]),Hu=!!xa,[Be,As]=n.useState(null),[On,Ts]=n.useState(null),[gt,hn]=n.useState(null),[bl,Wt]=n.useState(null),[Hn,xl]=n.useState(null),[$o,zu]=n.useState(()=>Date.now()),[Gu,Wu]=n.useState(!1),[pn,ya]=n.useState(!1),[va,yl]=n.useState(""),[zn,wa]=n.useState(""),[mn,ka]=n.useState(""),[gn,Sa]=n.useState(""),[vl,Gn]=n.useState(null),[wl,Fo]=n.useState(!1),[kl,Sl]=n.useState(!1),[Ra,Ku]=n.useState({key:null,nonce:0}),Rl=n.useRef(null),jl=n.useRef(null),Z=Bh(i,p,C),Do=ju(Z,p,zt),[_o,Bo]=n.useState(()=>Vg(i)),Uo=B(e=>e.rightTab),Lt=B(e=>e.setRightTab),d=B(e=>e.rootPath),Wn=B(e=>e.explorerRoot),Cl=B(e=>e.pinnedExplorerRootsCache),Nl=B(e=>e.hydratePinnedExplorerRoots),Pl=B(e=>e.syncPinnedExplorerRoots),It=B(e=>e.setExplorerRoot),El=B(e=>e.resetExplorerToProject),Kn=B(e=>e.pinExplorerRoot),bn=B(e=>e.unpinExplorerRoot),Ze=B(e=>e.selectedFilePath),nt=B(e=>e.selectFile),Oo=B(e=>e.showHiddenFiles),qu=B(e=>e.toggleShowHiddenFiles),Ho=B(e=>!!(d&&e.nestedGitScanRoots[d])),Ae=B(e=>e.changedFiles),ja=B(e=>e.setChangedFiles),Ms=B(e=>e.invalidateDirectoryCache),Vu=B(e=>e.setDirectorySortMode),Al=B(e=>e.applyFileWatchEvents),Tl=B(e=>e.reconcileDirectoryCache),Ml=B(e=>e.bumpFileWatchEpoch),hr=B(e=>e.gitBundleLoading),Ll=B(e=>e.gitBundleSlow),xn=B(e=>e.gitBundleError),qn=B(e=>e.gitBundleLastLoadedAt),Il=B(e=>e.beginGitBundleLoading),$l=B(e=>e.setGitBundleSlowFor),zo=B(e=>e.finishGitBundleLoading),Ca=B(e=>e.resetGitBundleLoading),Go=B(e=>e.setGitBundleError),Fl=B(e=>e.markGitBundleLoaded),ne=Wn??d,Na=B(e=>!!(ne&&e.hideGitIgnoredRoots[ne])),Yu=B(e=>e.hideGitIgnoredRootsHydrated),Xu=B(e=>e.setHideGitIgnoredRoot),[Wo,Dl]=n.useState(!1),[_l,Ko]=n.useState(null);n.useEffect(()=>{Ko(null)},[ne]);const Bl=n.useMemo(()=>ne?pg(ne,Ce):"",[ne,Ce]),Ls=n.useMemo(()=>hg(he),[he]),Ul=n.useMemo(()=>({excludePatterns:Ls,caseSensitive:Ie,wholeWord:Pe,regex:se}),[Ie,Ls,se,Pe]),Pa=B(e=>ne?e.fileSortModes[ne]??"name":"name"),Ol=B(e=>!!(ne&&e.directoryCache.has(ne))),yn=n.useRef(null),vt=n.useRef(0),[Hl]=n.useState(()=>++db),Lr=n.useRef(null),Kr=n.useRef(null),Ea=n.useRef(0),Kt=n.useRef(new Map),qt=n.useRef(new Map),pr=n.useRef(new Set),vn=n.useRef(new Set),wn=n.useRef(0),qr=n.useRef(null),Vn=n.useRef(0),Yn=n.useRef(null),Xn=n.useRef(0),Vr=n.useRef(null),qo=n.useRef(new Set),Vo=n.useRef(null),Yo=n.useRef(null),Aa=n.useRef(null),Xo=n.useRef(null),Jo=n.useRef(null),Is=n.useRef(new Set);n.useEffect(()=>{if(Hn===null)return;const e=Math.max(0,Date.now()-Hn),s=e<6e4?1e3:e<36e5?6e4:e<864e5?36e5:864e5,l=Math.max(50,s-e%s),h=window.setTimeout(()=>zu(Date.now()),l);return()=>window.clearTimeout(h)},[$o,Hn]);const Jn=n.useRef(null),Ir=n.useRef(null),Qo=n.useRef(null),zl=n.useRef(null),$s=n.useRef(null),Re=n.useCallback(e=>B.getState().rootPath===e,[]);n.useEffect(()=>{if(!r||typeof window>"u")return;const e=s=>{const l=pb(s.target);l&&ea("global_change_row_event",{...mb(s),selectionPath:l.dataset.diffSelectionPath,filePath:l.dataset.diffFilePath,absolutePath:l.dataset.diffAbsolutePath,repoRoot:l.dataset.diffRepoRoot,status:l.dataset.diffStatus,selectedFilePath:B.getState().selectedFilePath,rightTab:B.getState().rightTab,activeGitRepoRoot:be,changedFiles:B.getState().changedFiles.size})};return window.addEventListener("pointerdown",e,{capture:!0}),window.addEventListener("click",e,{capture:!0}),()=>{window.removeEventListener("pointerdown",e,{capture:!0}),window.removeEventListener("click",e,{capture:!0})}},[be,r]);const Gl=n.useCallback(async(e=d??void 0)=>{if(!e)return null;if(pr.current.has(e)||vn.current.has(e))return ot("untracked_skip_cached",{cwd:e,rootPath:d,completed:pr.current.has(e),running:vn.current.has(e)}),null;const s=d,l=Ea.current+1;Ea.current=l,Kt.current.set(e,l);const h=`right-sidebar-git-untracked:${e}`,u=new AbortController;qt.current.set(e,u),vn.current.add(e),ot("untracked_start",{requestId:l,cwd:e,rootPath:d});try{let y=await nd(e,u.signal,h),v=0;for(;y.status==="running"&&v<120;){if(Kt.current.get(e)!==l||u.signal.aborted)return ot("untracked_stale_result",{requestId:l,activeRequestId:Kt.current.get(e),cwd:e,status:y.status}),null;if(!Re(s))return ot("untracked_root_changed",{requestId:l,cwd:e,expectedRootPath:s,currentRootPath:B.getState().rootPath}),null;await new Promise(ee=>window.setTimeout(ee,v<10?1e3:3e3)),v+=1,y=await nd(e,u.signal,h)}if(Kt.current.get(e)!==l||!Re(s))return ot("untracked_stale_result",{requestId:l,activeRequestId:Kt.current.get(e),cwd:e,expectedRootPath:s,currentRootPath:B.getState().rootPath,files:y.files.length,status:y.status}),null;if(y.status==="done")return ja(Lu(B.getState().changedFiles,y.files)),y.files.length>0&&ut(ee=>{const je=new Map(ee.map(oe=>[oe.root,oe])).get(e);if(!je)return ee;const Ye=tb(je.files,y.files),G=ee.map(oe=>oe.root===e?{...oe,files:Ye,context:oe.context?{...oe.context,changedFiles:Ye.map(Ne=>({path:Ne.path,absolutePath:Ne.absolutePath,status:Ne.status})),truncated:!1}:oe.context,untrackedDeferred:!1}:oe);At(Iu(G,d));const _=G.find(oe=>oe.root===d);return _?.context&&Ut(oe=>oe?.root===_.root?{...oe,..._.context}:oe),G}),pr.current.add(e),ot("untracked_apply",{requestId:l,cwd:e,files:y.files.length}),y;const Y=y.error||(y.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return pr.current.add(e),ot("untracked_error",{requestId:l,cwd:e,message:Y,code:y.code,status:y.status}),null}catch(y){if(Kt.current.get(e)!==l||!Re(s)||vr(y))return ot("untracked_aborted",{requestId:l,activeRequestId:Kt.current.get(e),cwd:e,expectedRootPath:s,currentRootPath:B.getState().rootPath,message:y instanceof Error?y.message:String(y)}),null;const v=y instanceof Error?y.message:"Failed to scan untracked files";return pr.current.add(e),ot("untracked_error",{requestId:l,cwd:e,message:v}),null}finally{qt.current.get(e)===u&&qt.current.delete(e),Kt.current.get(e)===l&&Kt.current.delete(e),vn.current.delete(e)}},[Ee,Re,d,ja]),ar=n.useMemo(()=>{const e=new Set(We.map(l=>l.root)),s=Or.filter(l=>e.has(l));return s.length>0?s:be?[be]:[]},[be,Or,We]),Wl=ar.length===0,kn=n.useMemo(()=>ar.map(e=>Ge.find(s=>s.root===e)).filter(e=>!!e),[ar,Ge]),Ju=n.useMemo(()=>We.map(e=>({root:e.root,label:e.label,branch:e.branch??null})),[We]),mr=n.useCallback(async()=>{if(!d){tn([]),_r([]);return}const e=d,s=Vn.current+1;Vn.current=s,Yn.current?.abort();const l=new AbortController;Yn.current=l,Pr(yt.length===0),Ur(null);try{const h=ar.length>0?await Promise.all(ar.map(u=>sd({workspaceRoot:d,repoRoot:u},l.signal))).then(u=>({records:u.flatMap(y=>y.records),walkthroughs:u.flatMap(y=>y.walkthroughs??[])})):await sd({workspaceRoot:d},l.signal);if(Vn.current!==s||!Re(e))return;tn(h.records),_r(h.walkthroughs??[])}catch(h){if(Vn.current!==s||!Re(e)||vr(h))return;Ur(h instanceof Error?h.message:"Failed to load change audit explanations")}finally{Yn.current===l&&(Yn.current=null),Vn.current===s&&Re(e)&&Pr(!1)}},[yt.length,ar,Re,d]),Ta=n.useCallback(async(e,s,l)=>{if(!e&&!d){Hr([]),ks([]);return}const h=d,u=Xn.current+1;Xn.current=u,Vr.current?.abort();const y=new AbortController;Vr.current=y;try{const v=e?[e]:Array.from(new Set([d,...Ge.map(ee=>ee.root)].filter(ee=>!!ee))),Y=await Promise.all(v.map(ee=>jh({repoRoot:ee,baseRef:s,branchName:l},y.signal))).then(ee=>{const ue=new Map,je=new Map;for(const Ye of ee){for(const G of Ye.records)ue.set(G.id,G);for(const G of Ye.walkthroughs??[])je.set(G.id,G)}return{records:Array.from(ue.values()),walkthroughs:Array.from(je.values())}});if(Xn.current!==u||!Re(h))return;Hr(Y.records),ks(Y.walkthroughs??[])}catch(v){if(Xn.current!==u||!Re(h)||vr(v))return;console.warn("[RightSidebar] Failed to load branch explanations",v)}finally{Vr.current===y&&(Vr.current=null)}},[Ge,Re,d]),Qn=n.useCallback((e,s={})=>{if(!Re(d)){ot("apply_skipped_root_changed",{expectedRootPath:d,currentRootPath:B.getState().rootPath,bundleRoot:e.context?.root,files:e.files.length});return}ot(e.files.length===0?"empty_bundle":"apply",{rootPath:d,available:e.available,files:e.files.length,repositories:e.repositories?.map(_=>({root:_.root,relativeRoot:_.relativeRoot,files:_.files.length,available:_.available,error:_.error})),repoFilters:e.repoFilters?.map(_=>({root:_.root,label:_.label,count:_.count})),cached:e.cached,stale:e.stale,cacheAgeMs:e.cacheAgeMs,untrackedDeferred:e.untrackedDeferred,error:e.error});let l=Cu(e),h=e.repoFilters??[],u=e.files;const y=B.getState().changedFiles;if(!!(s.cacheOnly&&!e.cached&&e.files.length===0&&l.length===0)&&(y.size>0||Ge.length>0||Ee)){ot("cache_only_apply_skipped_empty_backend_cache",{rootPath:d,currentFiles:y.size,currentRepositories:Ge.length});return}const Y=l.some(_=>_.deferred);if(Y&&!s.replaceWorkspace){const _=new Set(l.filter(Ne=>!Ne.deferred||Ne.root===d).map(Ne=>Ne.root));u=[...Array.from(y.values()).filter(Ne=>!_.has(mt(Ne,d)??"")),...e.files]}const ee=qd(y.values(),d),ue=qd(e.files,d),je=l.some(_=>_.root!==d);if(!!(s.background&&!Y&&!s.replaceWorkspace&&y.size>0&&(e.files.length===0&&!e.error||ee>0&&ue===0&&!je))){ot("background_apply_skipped_degraded_bundle",{rootPath:d,currentFiles:y.size,nextFiles:e.files.length,currentNestedCount:ee,nextNestedCount:ue,nextRepositories:l.map(_=>({root:_.root,relativeRoot:_.relativeRoot,files:_.files.length})),cached:e.cached,stale:e.stale,error:e.error});return}if(s.replaceRepoRoot){const _=$u(y.values(),Ge,e,s.replaceRepoRoot,d);u=_.files,l=_.repositories,h=_.repoFilters}if(ja(Mu(u)),ut(_=>{if(!Y||s.replaceWorkspace)return l;const oe=new Map(_.map(Ne=>[Ne.root,Ne]));return l.map(Ne=>{const Ue=oe.get(Ne.root);return!Ne.deferred||!Ue?Ne:{...Ne,available:Ue.available,files:Ue.files,context:Ue.context,deferred:Ue.deferred,untrackedDeferred:Ue.untrackedDeferred,error:Ue.error}})}),At(h),Jo.current=d,s.syncActiveRepo!==!1){const{contextKey:_,activeGitRepos:oe}=B.getState(),Ne=_?oe[_]??null:null,Ue=s.activeRepoRoot!==void 0?s.activeRepoRoot:Ne,Fe=Hg({...e,repositories:l,repoFilters:h},Ue);ft(Fe)}typeof e.cacheUpdatedAt=="number"&&xl(e.cacheUpdatedAt),Ut(_=>{if(s.replaceRepoRoot&&s.replaceRepoRoot!==d)return _;if(!e.context)return null;const oe=_?.root??d;return!_?.available||oe!==(e.context.root??d)?e.context:{..._,...e.context}}),s.reloadDiff&&ko(_=>_+1);const G=B.getState().selectedFilePath;if(G&&!G.startsWith("/")&&!u.some(_=>_.path===G||_.absolutePath===G)&&nt(null),jr(_=>{const oe=new Set(u.map(Ue=>mt(Ue,d)).filter(Boolean)),Ne=new Set;for(const Ue of _)oe.has(Ue)&&Ne.add(Ue);return Bi($i,Ne),Ne}),s.loadDeferred!==!1){const _=l.filter(oe=>oe.untrackedDeferred&&oe.root).map(oe=>oe.root);for(const oe of _)Gl(oe)}s.loadAudit!==!1&&mr()},[Re,mr,Gl,d,nt,ft,ja]);n.useEffect(()=>{Ca(),Vo.current=null,Yo.current=d;const e=[],s=[];vt.current+=1,wn.current+=1,Ea.current+=1,Lr.current?.abort(),wt(Qs(Kr.current?.cwd??d??void 0)),Kr.current=null,Lr.current=null,qr.current?.abort(),wt("right-sidebar-git-details"),qr.current=null;for(const v of qt.current.values())v.abort();for(const v of qt.current.keys())wt(`right-sidebar-git-untracked:${v}`);qt.current.clear(),Kt.current.clear(),Vn.current+=1,Yn.current?.abort(),Yn.current=null,Xn.current+=1,Vr.current?.abort(),Vr.current=null,Gr.current+=1,fr.current?.abort(),wt("right-sidebar-recent-commits"),fr.current=null,tn([]),_r([]),Pr(!1),Ur(null),Dn([]),rn(!1),Hr([]),ks([]),cr(!1),tr(null),Me(!1),Le(null),it(null),dr(null),an(null),zr(!1),cn(""),ur([]),Cs(!1),Ns(!1),Bn(null),Un(!1),ha(null),un(null),fn(null),dl(!1),Et(Fi,!1),Co(!1);const l=d?Od()[d]:null,h=l?.previewEntries??[],u=l?.selectedPreviewKey??null,y=u?h.find(v=>v.key===u)??null:null;++A.current,Me(!1),No(l?.selectedRepoRoots??[]),ma(l?.repoTargetBranches??{}),ga(l?.repoBaseBranches??{}),sn(h),R(l?.previewScrollTops??{}),y&&l?.previewDetailOpen&&(y.diff.hunks?.length??0)>0&&(tr(y.diff),un(y.key),fn(l.selectedPreviewFileKey??(y.diff.hunks?.[0]?`${y.diff.hunks[0].filePath}\0${y.diff.hunks[0].hunkHeader}\0${y.diff.hunks[0].hunkIndex}`:null)),cr(!0)),Po(l?.repoIncludeUncommitted??Object.fromEntries(Object.keys(l?.repoTargetBranches??{}).map(v=>[v,l?.includeUncommitted??!0]))),Vo.current=d,ya(!1),pr.current.clear(),vn.current.clear(),As(null),Ts(null),hn(null),Wt(null),xl(null),ut(e),At(s),Ut(null),Xo.current=null,Jo.current=null,Is.current.clear()},[Ca,d]);const $t=n.useCallback(async(e=d??void 0,s={})=>{if(!e)return null;const l=d,h=vt.current;if(await Jp(()=>Promise.all([B.getState().hydrateNestedGitScanRoots(),B.getState().hydrateActiveGitRepos()]).then(()=>{})),vt.current!==h||!Re(l))return null;const u=e===d&&Xs(d),y=s.includeNested??u,v=s.refresh??s.reloadDiff??!1,Y=s.cacheOnly??!1,ee=s.background??!1,ue=y&&(s.discoverOnly??!1);v&&pr.current.clear();const je=Kr.current;if(je&&je.cwd===e&&je.includeNested===y&&je.refresh===v&&je.cacheOnly===Y&&je.discoverOnly===ue)return ot("reuse_pending",{cwd:e,includeNested:y,refresh:v,cacheOnly:Y,discoverOnly:ue}),je.promise;const Ye=vt.current+1;vt.current=Ye;const G=`right-sidebar:${Hl}:${Ye}`;Lr.current?.abort();const _=Qs(e);wt(_);const oe=new AbortController;Lr.current=oe;let Ne=null;ee||Il(G),Go(null),ot("start",{requestId:Ye,cwd:e,rootPath:d,requestSlotId:_,includeNested:y,refresh:v,cacheOnly:Y,background:ee,existingChanges:Ae.size,lastLoadedAt:qn}),!ee&&typeof window<"u"&&(Ne=window.setTimeout(()=>{vt.current===Ye&&$l(G,!0)},Sg));const Ue=(async()=>{const Fe=await Ci(e,oe.signal,{includeNested:y,refresh:v,cacheOnly:Y,discoverOnly:ue,action:v?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:_,requestTimeoutMs:v?null:void 0});if(sb(Fe)){if(ot("cancelled_result_ignored",{requestId:Ye,activeRequestId:vt.current,cwd:e,error:Fe.error??Fe.context?.error}),oe.signal.aborted)return null;throw new Error(Fe.error??Fe.context?.error??"Failed to load Git changes")}return vt.current!==Ye||!Re(l)?(ot("stale_result",{requestId:Ye,activeRequestId:vt.current,cwd:e,expectedRootPath:l,currentRootPath:B.getState().rootPath,files:Fe.files.length,repositories:Fe.repositories?.length??0}),null):(Qn(Fe,{reloadDiff:s.reloadDiff,syncActiveRepo:s.replaceWorkspace?!0:y,background:ee,cacheOnly:Y,replaceRepoRoot:s.replaceRepoRoot,replaceWorkspace:s.replaceWorkspace}),Fe)})();Kr.current={cwd:e,includeNested:y,refresh:v,cacheOnly:Y,discoverOnly:ue,promise:Ue};try{const Fe=await Ue;return vt.current===Ye&&Fe&&Re(l)?Fl({cached:Fe.cached,stale:Fe.stale,cacheAgeMs:Fe.cacheAgeMs,nestedDeferred:!y||Fe.nestedDeferred,untrackedDeferred:Fe.untrackedDeferred}):vt.current===Ye&&Re(l)&&zo(G),Fe}catch(Fe){return vt.current!==Ye||!Re(l)||oe.signal.aborted?(ot("aborted",{requestId:Ye,activeRequestId:vt.current,cwd:e,expectedRootPath:l,currentRootPath:B.getState().rootPath,message:Fe instanceof Error?Fe.message:String(Fe)}),null):(ot("error",{requestId:Ye,cwd:e,includeNested:y,refresh:v,background:ee,message:Fe instanceof Error?Fe.message:String(Fe)}),ee||(Ut(null),Go(Fe instanceof Error?Fe.message:"Failed to load Git changes")),null)}finally{Ne!==null&&window.clearTimeout(Ne),Lr.current===oe&&(Lr.current=null),Kr.current?.promise===Ue&&(Kr.current=null),!ee&&vt.current===Ye&&Re(l)&&zo(G)}},[Qn,Il,Ae.size,zo,Hl,qn,Re,Fl,d,Go,$l]),Zn=n.useCallback(async()=>{d&&await $t(d,{reloadDiff:!0,refresh:!0})},[$t,d]),Zo=n.useCallback(async(e=d??void 0)=>{if(!e)return null;const s=d,l=wn.current+1;wn.current=l,qr.current?.abort(),wt("right-sidebar-git-details");const h=new AbortController;qr.current=h,ya(!0);try{const u=await ad(e,h.signal,"load_git_details","right-sidebar-git-details");return wn.current!==l||!Re(s)?null:(ut(y=>y.map(v=>v.root===u.root?{...v,available:u.available,context:u,error:u.error}:v)),Ut(y=>y?.root&&u.root&&y.root!==u.root?y:!y?.available||!u.available?u:{...y,...u}),u)}catch(u){return vr(u)||!Re(s)||wn.current===l&&Wt(u instanceof Error?u.message:"Failed to load Git details"),null}finally{qr.current===h&&(qr.current=null),wn.current===l&&Re(s)&&ya(!1)}},[Re,d]);n.useEffect(()=>{if(!r){vt.current+=1,Ca(),Xo.current=null,wn.current+=1,Ea.current+=1,Lr.current?.abort(),wt(Qs(Kr.current?.cwd??d??void 0)),Kr.current=null,Lr.current=null,qr.current?.abort(),wt("right-sidebar-git-details"),qr.current=null;for(const e of qt.current.values())e.abort();for(const e of qt.current.keys())wt(`right-sidebar-git-untracked:${e}`);qt.current.clear(),Kt.current.clear(),Xn.current+=1,Vr.current?.abort(),Vr.current=null,Gr.current+=1,fr.current?.abort(),wt("right-sidebar-recent-commits"),fr.current=null,ya(!1),Me(!1),Le(null),it(null),dr(null),an(null),zr(!1),cn(""),ur([]),Cs(!1),Ns(!1),Bn(null),Un(!1),ge(""),re(!1),Ht(null),Lo(!1),Z&&hl(!1)}},[Z,r,Ca,re]),n.useEffect(()=>{if(!te)return;const e=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(e)},[te]),n.useEffect(()=>{Z||Tr(!1)},[Z]);const Kl=n.useCallback(e=>{To(e);const s=Qo.current;s&&(s.update(),s.slideTo(e,0),window.requestAnimationFrame(()=>{s.update(),s.slideTo(e,0)}))},[]);n.useEffect(()=>{if(Z)if(Tr(g),g&&Ze){Mr(1);const e=Ir.current;e&&(e.update(),e.activeIndex!==1&&($s.current=1,e.slideTo(1,0)))}else{Mr(0);const e=Ir.current;e&&e.activeIndex!==0&&($s.current=0,e.slideTo(0,0)),Ht(null)}},[Z,g,d,Ze]),n.useEffect(()=>{if(x!==void 0&&!g){Mr(0);const e=Ir.current;e&&e.activeIndex!==0&&($s.current=0,e.slideTo(0,0)),Tr(!1),Ht(null)}},[x,g]),n.useEffect(()=>{E!==void 0&&Je(null)},[E]),n.useEffect(()=>{!Z&&g&&k?.()},[Z,k,g]),n.useEffect(()=>{Bo(e=>nl(e,i))},[i]);const ql=vo(()=>{Jn.current&&(Jn.current=null,cs(hs))}),Qu=n.useCallback(e=>{Z||(e.preventDefault(),ql(e),Jn.current={startX:e.clientX,startWidth:_o,pointerId:e.pointerId},e.currentTarget.setPointerCapture(e.pointerId))},[_o,Z,ql]),Zu=n.useCallback(e=>{const s=Jn.current;if(!s||s.pointerId!==e.pointerId)return;const l=nl(s.startWidth+e.clientX-s.startX,i);Bo(l),na(hs,l,kg)},[i]),Vl=n.useCallback(e=>{const s=Jn.current;if(!(!s||s.pointerId!==e.pointerId)){Jn.current=null,cs(hs);try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}},[]),es=!!(d&&qn!==null&&Xd(Ee)),ei=!!(d&&!xn&&Ae.size===0&&qn===null),Ct=(()=>{let e=Uo;return e==="android"&&!Wr&&(e="files"),(e==="architecture"||e==="computer")&&!sr[e]&&(e="files"),es&&(e==="git"||e==="diff")&&(e="files"),e})(),at=Ct==="git",or=Ct==="files",Nt=Ct==="diff",ts=Ct==="android",rs=Ct==="computer",Sn=Ct==="architecture",[ef,tf]=n.useState(!1);n.useEffect(()=>{r&&rs&&tf(!0)},[r,rs]);const[rf,nf]=n.useState(!1);n.useEffect(()=>{r&&Sn&&nf(!0)},[r,Sn]);const ti=n.useRef(null),ns=n.useCallback((e,s)=>{const l=B.getState().rightTab;if(l===e)return;const h=performance.now(),u=h-s.timeStamp;ti.current={from:l,to:e,startedAt:h,inputDelayMs:u>=0&&u<6e4?Math.round(u):null},Lt(e)},[Lt]);n.useEffect(()=>{const e=ti.current;if(!e||e.to!==Ct)return;ti.current=null;const s=Math.round(performance.now()-e.startedAt);let l=window.requestAnimationFrame(()=>{l=window.requestAnimationFrame(()=>{ea("tab_switch_presented",{from:e.from,to:e.to,inputDelayMs:e.inputDelayMs,commitMs:s,frameMs:Math.round(performance.now()-e.startedAt)})})});return()=>window.cancelAnimationFrame(l)},[Ct]);const sf=Rp(e=>e.overlay==="sidebar")&&ts;n.useEffect(()=>{if(!Z){ba(!0);return}if(!r){const s=window.setTimeout(()=>{ba(!1)},Cg);return()=>window.clearTimeout(s)}ba(!1);const e=window.setTimeout(()=>{ba(!0)},jg);return()=>window.clearTimeout(e)},[Z,r]),n.useEffect(()=>{if(!Z||!Nt)return;const e=Qo.current;if(!e)return;const s=window.requestAnimationFrame(()=>{e.update()});return()=>window.cancelAnimationFrame(s)},[Nt,Z]),n.useEffect(()=>{if(!es||!d||hr)return;const e=window.setTimeout(()=>{$t(d,{background:!0})},3e3);return()=>window.clearTimeout(e)},[es,d,hr,$t]);const af=n.useCallback(e=>{$t(e,{discoverOnly:!0})},[$t]);Qp({active:r&&(at||Nt),rootPath:d,loading:hr,delay:at&&!Z?0:_i,lastStartedRoot:Xo,load:af}),n.useEffect(()=>{!r||!at||(!Z||Mo)&&Lo(!0)},[at,Z,r,Mo]),n.useEffect(()=>{if(!r||at)return;const e=window.setTimeout(()=>{Lo(!0)},_i);return()=>window.clearTimeout(e)},[at,r]),n.useEffect(()=>{or&&Uu(!0)},[or]),n.useEffect(()=>{Nt&&hl(!0)},[Nt]),n.useEffect(()=>{!r||!ts||(a&&xa&&xa.sessionId!==a&&(ji.getState().setDock(Ai,null),ta({androidPanel:{docked:null}}).catch(()=>{})),pl(!0))},[ts,r,a,xa]),n.useEffect(()=>{if(r&&ts||!Io)return;const e=window.setTimeout(()=>pl(!1),Rg);return()=>window.clearTimeout(e)},[r,ts,Io]),n.useEffect(()=>{let e=!1;return Zd().then(s=>{e||(Es.current.has("android")||ml(s.androidPanel?.enabled===!0),gl(l=>({architecture:Es.current.has("architecture")?l.architecture:s.rightSidebarTabs?.architecture===!0,computer:Es.current.has("computer")?l.computer:s.rightSidebarTabs?.computer===!0})))}).catch(()=>{}),()=>{e=!0}},[]);const Yl=n.useCallback(e=>{Es.current.add("android"),ml(e),e?Lt("android"):B.getState().rightTab==="android"&&Lt("files"),ta({androidPanel:{enabled:e}}).catch(()=>{})},[Lt]),of=n.useCallback((e,s)=>{Es.current.add(e),gl(l=>({...l,[e]:s})),s?Lt(e):B.getState().rightTab===e&&Lt("files"),ta({rightSidebarTabs:{[e]:s}}).catch(()=>{})},[Lt]),Xl=n.useCallback(e=>{ne&&Xg(ne,e.currentTarget.scrollTop)},[ne]);n.useEffect(()=>()=>{Lr.current?.abort(),cs(al),cs(ol),cs(hs),cs(Di)},[]),n.useEffect(()=>{if(!ne||!Ol)return;const e=Au()[ne]?.top;if(typeof e!="number")return;let s=window.requestAnimationFrame(()=>{yn.current&&(yn.current.scrollTop=e),s=window.requestAnimationFrame(()=>{yn.current&&(yn.current.scrollTop=e)})});return()=>window.cancelAnimationFrame(s)},[ne,Ol]),n.useEffect(()=>{if(!r)return;const e=new AbortController;return Ch(e.signal).then(s=>Sl(!!s.available)).catch(()=>Sl(!1)),()=>e.abort()},[r]);const Rn=n.useCallback(e=>{if(j(null),nt(e),Ht(null),Z){Tr(!0),Mr(1),Ir.current?.slideTo(1),w?.();return}},[Z,w,nt]),Jl=n.useCallback(e=>{!r||!or||Zp(e,yn.current,Ze,s=>{Rt(null),Rn(s)})},[or,Rn,r,Ze]),ri=n.useCallback((e,s)=>{if(j(null),nt(e),Rt(s),Z){Tr(!0),Mr(1),Ir.current?.slideTo(1),w?.();return}},[Z,w,nt]),Ft=Pm(e=>Ms(e,!1)),Ma=Ft.busy,Fs=n.useCallback(async(e,s)=>{const l=s||Wn||d;!l||!e.length||await Ft.start(l,e)},[Wn,d,Ft.start]),Ql=n.useCallback(async e=>{try{await Nh(e)}catch(s){Wt(s instanceof Error?s.message:o("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>Wt(null),4e3)}},[o]),La=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.types.includes("Files")&&Fo(!0)},[]),Zl=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),Fo(!1)},[]),ec=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),Fo(!1);const s=e.dataTransfer.files;s.length>0&&Fs(Array.from(s))},[Fs]),ni=n.useCallback(e=>{Q(e),window.setTimeout(()=>Q(s=>s===e?null:s),1400)},[]),gr=n.useCallback(e=>{rt(e),window.setTimeout(()=>rt(s=>s===e?null:s),1400)},[]);n.useEffect(()=>{Et(Ld,$e)},[$e]),n.useEffect(()=>{Et(Id,V)},[V]),n.useEffect(()=>{Et($d,et)},[et]),n.useEffect(()=>{na(Di,pt,bg)},[pt]),n.useEffect(()=>(Nl().catch(()=>{}),od(e=>{e.type==="pinned-explorer-roots"&&Pl(e.pinnedExplorerRoots)})),[Nl,Pl]);const tc=n.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),Ia=n.useRef(null),jn=n.useRef(null),[rc,si]=n.useState(!1);n.useEffect(()=>{if(!r)return;si(!1);let e=!1;Ph().then(l=>{e||(Ia.current=l.text,St(h=>l.text&&l.text!==h?l.text:h),si(!0))}).catch(()=>{e||si(!0)});const s=od(l=>{l.type==="context-draft"&&l.origin!==tc.current&&(Ia.current=l.text,St(l.text))});return()=>{e=!0,s(),jn.current!==null&&(window.clearTimeout(jn.current),jn.current=null)}},[r]),n.useEffect(()=>{if(!rc||Ia.current===pt)return;jn.current!==null&&window.clearTimeout(jn.current);const e=pt;jn.current=window.setTimeout(()=>{jn.current=null,Eh(e,tc.current).then(()=>{Ia.current=e}).catch(()=>{})},500)},[pt,rc]);const ss=n.useCallback(async(e,s,l,h)=>{if(!e)return!1;if(wr(!1),h&&!Ni(h)())return wr(!0),!1;if(Ah(l?e+l:e))return ni(s),!0;if($e)St(u=>jm(u,e)+(l??"")),window.matchMedia("(pointer: coarse)").matches||(we(!1),bs(u=>u+1));else{const u=a??Yr.getState().activeSessionId;if(!await eu(l?e+l:e,u,()=>_s.current&&u===Yr.getState().activeSessionId,h))return wr(!0),!1}return ni(s),!0},[$e,ni,a]),$a=n.useCallback(e=>{const s=Mn(e,d);return Th(s,d)},[d]),ai=tu(gr),Vt=n.useCallback((e,s,l)=>{const h=Mn(e,d);return ss(id(h,d),s??`path:${h}`,void 0,l)},[d,ss]),as=n.useRef({sessionId:a,contextDraftEnabled:$e,isOpen:r});as.current={sessionId:a,contextDraftEnabled:$e,isOpen:r};const lf=n.useCallback(async(e,s)=>{const l=a??Yr.getState().activeSessionId,h=()=>_s.current&&as.current.isOpen&&(as.current.sessionId??Yr.getState().activeSessionId)===l&&Yr.getState().activeSessionId===l&&as.current.contextDraftEnabled===$e;await Ft.start("/tmp",[e],y=>Vt(y,`path:${y}`,s),h)&&h()&&Z&&!$e&&c()},[$e,Vt,Z,c,a,Ft.start]),Ds=n.useRef(!0),Fa=n.useRef(a);Fa.current=a,n.useEffect(()=>(Ds.current=!0,()=>{Ds.current=!1}),[]);const cf=n.useCallback(e=>{jp.getState().enqueue(e,a??null,d||"/",async(s,l)=>{if(as.current.contextDraftEnabled&&Ds.current&&Fa.current===a){if(!await oi.current(id(s,null),`path:${s}`,l))throw new Error(o("rightSidebar.uploadReferenceRejected"))}else return yd(s,a,l)})},[a,d,$e,Vt,o]),df=n.useCallback(async(e,s)=>{const l=Ni(s),u=(await Gi("/tmp",[e])).files[0]?.path;if(!u)throw new Error("截图上传未返回文件路径");if(!l()||!Ds.current||Fa.current!==a||as.current.contextDraftEnabled!==$e)throw new Error(o("rightSidebar.uploadReferenceRejected"));if($e&&Ds.current&&Fa.current===a){if(!await Vt(u,void 0,s))throw new Error(o("rightSidebar.uploadReferenceRejected"))}else await yd(u,a,s)},[$e,Vt,a,o]),$r=n.useCallback((e,s,l)=>{if(!e)return Promise.resolve(!1);const h=e.includes(`
|
|
1645
|
+
`)?`
|
|
1646
|
+
`:void 0;return ss(e.endsWith(`
|
|
1647
|
+
`)||e.endsWith(" ")?e:`${e} `,s,h,l)},[ss]),oi=n.useRef($r);oi.current=$r;const _s=n.useRef(!0);n.useEffect(()=>(_s.current=!0,()=>{_s.current=!1}),[]);const ii=n.useRef(new Set),Da=n.useCallback((e,s,l,h)=>{if(ii.current.has(s))return!1;const u=Ni(h);if(!u())return!1;const y=a??Yr.getState().activeSessionId;return ii.current.add(s),sm(e,s,l,{insert:(v,Y)=>$r(v,Y,h),upload:async(v,Y)=>(await Gi("/tmp",[v],Y)).files[0]?.path,isCurrent:()=>u()&&_s.current&&oi.current===$r&&y===Yr.getState().activeSessionId}).catch(()=>(wr(!0),!1)).finally(()=>ii.current.delete(s))},[$r,a]),Fr=n.useCallback((e,s,l,h)=>s?ss(s.endsWith(" ")?s:`${s} `,l??`context:${e}`,`
|
|
1648
|
+
`,h):Promise.resolve(!1),[ss]),nc=Am({text:pt,sessionId:a??Yr.getState().activeSessionId,active:r&&$e,onAccepted:()=>{en(!1),St(""),et&&we(!0)},onRejected:()=>{en(!0),we(!1)}}),tt=n.useMemo(()=>d?xt(d):o("rightSidebar.workspace"),[d,o]),uf=n.useMemo(()=>xt(ne)||tt,[ne,tt]),_a=n.useMemo(()=>lo(ne),[ne]),Ba=n.useMemo(()=>d?Cl[d]??[]:[],[Cl,d]),Cn=n.useMemo(()=>new Set(Ba.map(e=>e.path)),[Ba]),Bs=!!(ne&&Cn.has(ne)),li=!!(d&&ne&&ne!==d),ff=!!(d&&Wn&&Wn!==d),Dt=ne?`path:${ne}`:null,sc="context:change-audit",hf=n.useCallback(()=>{_a&&It(_a)},[_a,It]),ac=n.useCallback(()=>{El()},[El]),pf=n.useCallback(()=>{ne&&(Ms(ne,!0),Ml())},[Ml,ne,Ms]),mf=n.useCallback(()=>{!ne||!li||(Bs?bn(ne):Kn(ne,"directory"))},[li,ne,Bs,Kn,bn]),oc=n.useCallback(e=>{It(e),ge("")},[It]),ic=n.useCallback(e=>{ne&&(ve(mg(ne,e)),re(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[ne,re]),lc=n.useCallback(e=>{!d||e===d||(Cn.has(e)?bn(e):Kn(e,"directory"))},[Kn,Cn,d,bn]),cc=n.useCallback(e=>{!d||!e||(Cn.has(e)?bn(e):Kn(e,"file"))},[Kn,Cn,d,bn]),dc=B(e=>e.expandedPaths),ci=n.useMemo(()=>{const e=new Set;if(or&&ne){e.add(ne);const s=`${ne.replace(/\/+$/,"")}/`;for(const l of dc)l.startsWith(s)&&e.add(l)}if(or&&d&&Ze){const s=Ze.startsWith("/")?Ze:`${d}/${Ze}`,l=lo(s);l&&e.add(l)}return bm(e).join(`
|
|
1649
|
+
`)},[dc,or,ne,d,Ze]),Nn=n.useRef(new Map);n.useEffect(()=>{const e=ci?ci.split(`
|
|
1650
|
+
`):[];if(!r||e.length===0){Gn(null);return}const s=new AbortController;let l=!1,h=0,u=0;Gn(null);const y=async()=>{let v=0;for(;!l&&!s.signal.aborted;){let Y=null;try{Gn(null),await Oh(e,ue=>{const{applicableEvents:je,unavailableReason:Ye}=ym(ue);je.length>0&&Al(je);const G=new Set(je.filter(_=>_.type==="rescan-required").map(_=>_.path));if(Na)for(const _ of je){if(_.type==="created"||_.type==="updated"){const oe=lo(_.path);oe&&G.add(oe)}_.path.endsWith("/.gitignore")&&ne&&Ms(ne,!0)}for(const _ of G){const oe={path:_},Ne=B.getState();if(!Ne.directoryCache.has(oe.path))continue;Nn.current.get(oe.path)?.abort();const Fe=new AbortController;Nn.current.set(oe.path,Fe);const Zc=`file-watch-rescan:${oe.path}`;wt(Zc),Hh(oe.path,Fe.signal,Ne.showHiddenFiles,"watch_rescan",Zc,Ne.fileSortModes[oe.path]??"name",ne??void 0).then(qs=>{Nn.current.get(oe.path)===Fe&&Tl(oe.path,qs.entries)}).catch(qs=>{vr(qs)||Gn(qs instanceof Error?qs.message:"File refresh unavailable")}).finally(()=>{Nn.current.get(oe.path)===Fe&&Nn.current.delete(oe.path)})}Ye&&Gn(Ye)},s.signal),Y=new Error("File watch stream ended")}catch(ue){Y=ue}if(l||s.signal.aborted||vr(Y))return;Gn(Y instanceof Error?Y.message:"File watching unavailable");const ee=Fd[Math.min(v,Fd.length-1)];v+=1,await new Promise(ue=>{u=window.setTimeout(ue,ee)})}};return h=window.setTimeout(()=>{l||y()},_i),()=>{l=!0,window.clearTimeout(h),window.clearTimeout(u),s.abort();for(const v of Nn.current.values())v.abort();Nn.current.clear()}},[Al,r,Tl,ci,ne,Na,Ms]),n.useEffect(()=>{if(!d||Vo.current!==d)return;if(Yo.current===d){Yo.current=null;return}const e=Od();na(Ru,{...e,[d]:{selectedRepoRoots:pa,repoTargetBranches:rr,repoBaseBranches:jt,previewEntries:nn,selectedPreviewKey:me&&Ar?Ve:null,selectedPreviewFileKey:me&&Ar?Eo:null,previewDetailOpen:!!(me&&Ar),previewScrollTops:Ss,previewMobileSlideIndex:1,repoIncludeUncommitted:dn,updatedAt:Date.now()}},gg)},[Ar,dn,me,nn,Ss,jt,rr,pa,d,Eo,Ve]);const lt=n.useMemo(()=>Yd(Ae.values()),[Ae]),st=n.useMemo(()=>{const e=new Map;for(const s of Ge)e.set(s.root,s);return e},[Ge]),Us=n.useMemo(()=>{const e=new Map;for(const s of Ge)s.deferred||e.set(s.root,s.files.length);return e},[Ge]),Ua=n.useCallback(e=>{if(e){if(!e.deferred){Is.current.delete(e.root);return}Us.has(e.root)||Is.current.has(e.root)||(Is.current.add(e.root),$t(e.root,{includeNested:!1,background:!0,replaceRepoRoot:e.root}).then(s=>{s||Is.current.delete(e.root)}))}},[$t,Us]),ir=n.useMemo(()=>be?We.find(e=>e.root===be)??null:null,[be,We]),Yt=n.useMemo(()=>Ze?Array.from(Ae.values()).find(e=>e.path===Ze||e.absolutePath===Ze)??null:null,[Ae,Ze]),_t=n.useMemo(()=>{const e=new Map;for(const s of Ge)s.available&&s.context?.available&&e.set(s.root,s);return e.size===0&&Ee?.available&&Ee.root&&e.set(Ee.root,{id:Ee.root,root:Ee.root,relativeRoot:".",name:tt,depth:0,nested:!1,available:!0,files:Array.from(Ae.values()).filter(s=>mt(s,d)===Ee.root),context:Ee}),Array.from(e.values()).sort((s,l)=>s.root===d?-1:l.root===d?1:(s.relativeRoot||s.name).localeCompare(l.relativeRoot||l.name)).map(s=>{const l=s.relativeRoot==="."?tt:s.relativeRoot||s.name||xt(s.root),h=Vd(s.files),u=s.files.length;return{value:s.root,label:l,meta:[s.context?.branch,u>0?o("rightSidebar.repoChangedCount",{count:u}):null,h>0?o("rightSidebar.repoStagedCount",{count:h}):null].filter(Boolean).join(" · ")}})},[Ae,Ee,Ge,tt,d,o]),ye=n.useMemo(()=>be&&_t.some(e=>e.value===be)?be:Yt?.repoRoot&&_t.some(e=>e.value===Yt.repoRoot)?Yt.repoRoot:_t.length===1||_t.length>1?_t[0].value:null,[be,_t,Yt?.repoRoot]),uc=ye?st.get(ye)??null:null,ae=uc?.context?.available?uc.context:ye===Ee?.root?Ee:null,Xe=_t.length>0&&!ye,fc=n.useMemo(()=>Xe?[]:ye?Array.from(Ae.values()).filter(e=>mt(e,d)===ye):Array.from(Ae.values()),[ye,Ae,Xe,d]),Pn=n.useMemo(()=>Yd(fc),[fc]),di=!!(ae?.available&&ae.root&&ye&&ae.root===ye),gf=ye?_t.find(e=>e.value===ye)?.label??xt(ye):o("rightSidebar.gitRepositoryPlaceholder"),hc=di?ae?.branch??"HEAD":Xe?o("rightSidebar.selectRepositoryForGitActions"):pn?o("rightSidebar.gitActionRunning"):"HEAD",En=!!(ae?.available&&ae.root===ye&&ae.status);n.useEffect(()=>{cl.current={count:Mt.length,loading:ua,loadingMore:fa,hasMore:Ro}},[Mt.length,Ro,ua,fa]),n.useEffect(()=>{Gr.current+=1,fr.current?.abort(),wt("right-sidebar-recent-commits"),fr.current=null,cn(""),ur([]),Cs(!1),Ns(!1),Bn(null),Un(!1)},[ye]);const Os=n.useCallback(async(e={})=>{if(!d||!ye||Xe)return;const s=e.reset??!1,l=cl.current,h=s?0:l.count;if(!s&&(l.loading||l.loadingMore||!l.hasMore))return;const u=Gr.current+1;Gr.current=u,fr.current?.abort(),wt("right-sidebar-recent-commits");const y=new AbortController;fr.current=y,s?Cs(!0):Ns(!0),Bn(null);try{const v=await Mh({cwd:d,repoRoot:ye,limit:Ng,skip:h,query:js.trim(),requestSlotId:"right-sidebar-recent-commits"},y.signal);if(Gr.current!==u)return;if(!v.available){Bn(v.error??"Recent commits are unavailable"),s&&ur([]),Un(!1);return}qe(Y=>s?v.commitSyncStatus??{}:{...Y,...v.commitSyncStatus}),ur(Y=>s?v.commits:[...Y,...v.commits]),Un(v.hasMore)}catch(v){if(Gr.current!==u||vr(v))return;Bn(v instanceof Error?v.message:"Failed to load recent commits"),s&&ur([]),Un(!1)}finally{fr.current===y&&(fr.current=null),Gr.current===u&&(Cs(!1),Ns(!1))}},[ye,js,Xe,d]);n.useEffect(()=>{on&&Os({reset:!0})},[js,Os,on,ae?.ahead,ae?.behind,ae?.upstream]);const bf=n.useCallback(e=>{const s=e.currentTarget;s.scrollTop+s.clientHeight<s.scrollHeight-48||Os({reset:!1})},[Os]);n.useEffect(()=>{!ye||!Ee?.available||!at||!nr||En||pn||Xe||Zo(ye)},[ye,Ee?.available,En,pn,at,nr,Zo,Xe]);const pc=r&&(Nt||at);n.useEffect(()=>{!pc||!d||mr()},[pc,mr,d]),n.useEffect(()=>{!r||!at||!nr||!Ps||!d||Ta(null)},[Ps,at,nr,r,Ta,d]);const xf=n.useMemo(()=>{if(!be)return 0;const e=We.findIndex(s=>s.root===be);return e>=0?e+1:0},[be,We]),mc=n.useCallback(e=>{if(!e)return null;const s=Array.from(Ae.values()).filter(l=>mt(l,d)===e).sort((l,h)=>l.path.localeCompare(h.path))[0];return s?yr(s):null},[Ae,d]),An=We.length>1,Oa=n.useMemo(()=>[{root:null,label:o("rightSidebar.allRepositories"),count:Ae.size,branch:null,deferred:!1},...We.map(e=>({root:e.root,label:e.label,count:e.deferred?Us.get(e.root)??0:e.count,branch:e.branch??null,deferred:!!e.deferred&&!Us.has(e.root)}))],[Ae.size,We,Us,o]),gc=Oa[xf]??Oa[0],Ha=!!be,bc=n.useMemo(()=>Nu(We,Ge),[We,Ge]);n.useEffect(()=>{Jo.current===d&&be&&!bc.has(be)&&ft(null),Dn(e=>e.filter(s=>We.some(l=>l.root===s)))},[be,We,bc,d,ft]),n.useEffect(()=>{be&&Ua(st.get(be))},[be,Ua,st]);const yf=n.useMemo(()=>{const e=new Set;ae?.branch&&e.add(ae.branch);for(const s of ae?.branches??[])e.add(s);return Array.from(e).map(s=>({value:s,label:s,meta:s===ae?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0}))},[ae?.branch,ae?.branches,o]),xc=n.useMemo(()=>{const e=new Set;ae?.upstreamRemote&&e.add(ae.upstreamRemote);for(const s of ae?.remotes??[])e.add(s);return Array.from(e).map(s=>({value:s,label:s,meta:s===ae?.upstreamRemote?o("rightSidebar.pushUpstreamBadge"):void 0}))},[ae?.remotes,ae?.upstreamRemote,o]),yc=xc.length>1,vf=n.useMemo(()=>{const e=[],s=new Set,l=(u,y)=>{!u||s.has(u)||(s.add(u),e.push({value:u,label:u,meta:y}))};l(ae?.upstreamBranch,ae?.upstreamBranch?o("rightSidebar.pushUpstreamBadge"):void 0),l(ae?.branch,ae?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0);for(const u of ae?.branches??[])l(u,u===ae?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");const h=ae?.upstreamRemote;for(const u of ae?.remoteBranches??[]){const y=u.indexOf("/"),v=y>=0?u.slice(0,y):null,Y=y>=0?u.slice(y+1):u;(!h||v===h)&&l(Y,"remote")}return e},[ae?.branch,ae?.branches,ae?.remoteBranches,ae?.upstreamBranch,ae?.upstreamRemote,o]),Xt=n.useMemo(()=>_t.map(e=>{const s=st.get(e.value);return{root:e.value,label:e.label,branch:s?.context?.branch??null}}),[_t,st]);n.useEffect(()=>{Xt.length!==0&&(ma(e=>{let s=!1;const l={...e},h=new Set(Xt.map(u=>u.root));for(const u of Object.keys(l))h.has(u)||(delete l[u],s=!0);for(const u of Xt)!l[u.root]&&u.branch&&(l[u.root]=u.branch,s=!0);return s?l:e}),ga(e=>{let s=!1;const l={...e},h=new Set(Xt.map(u=>u.root));for(const u of Object.keys(l))h.has(u)||(delete l[u],s=!0);for(const u of Xt){const y=st.get(u.root)?.context;if(l[u.root]&&Pu(l[u.root],y?.branch)&&(delete l[u.root],s=!0),l[u.root])continue;const v=Gd(y);v&&(l[u.root]=v,s=!0)}return s?l:e}))},[Xt,st]);const za=n.useMemo(()=>{const e=new Set(Xt.map(s=>s.root));return pa.filter(s=>e.has(s))},[pa,Xt]),Ga=za.length===0,br=n.useMemo(()=>Ga?Xt:Xt.filter(e=>za.includes(e.root)),[Xt,za,Ga]),Hs=n.useMemo(()=>br.filter(e=>!!jt[e.root]?.trim()),[jt,br]),os=n.useCallback((e,s)=>{const l=st.get(e)?.context?.branch;return!!(l&&s&&s.replace(/^refs\/heads\//,"")===l)},[st]),vc=n.useMemo(()=>br.filter(e=>!jt[e.root]?.trim()),[jt,br]),wc=n.useCallback(async e=>{if(!e||qo.current.has(e))return;const s=st.get(e)?.context;if((s?.branches?.length??0)>0||(s?.remoteBranches?.length??0)>0||s?.upstream)return;const l=d;qo.current.add(e),fl(h=>new Set(h).add(e));try{const h=await ad(e,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${e}`);if(!h.available||!Re(l))return;ut(u=>u.map(y=>y.root===e?{...y,available:!0,context:{...y.context,...h},error:void 0}:y)),ma(u=>u[e]||!h.branch?u:{...u,[e]:h.branch}),ga(u=>{if(u[e])return u;const y=Gd(h);return y?{...u,[e]:y}:u})}catch(h){vr(h)||console.warn("[RightSidebar] Failed to load branch audit repo details",e,h)}finally{qo.current.delete(e),fl(h=>{const u=new Set(h);return u.delete(e),u})}},[st,Re,d]);n.useEffect(()=>{if(jo)for(const e of br)wc(e.root)},[jo,br,wc]),n.useEffect(()=>{!di||!ae||(wa(ae.branch||(ae.branches?.[0]??"")),ka(ae.upstreamRemote||(ae.remotes?.includes("origin")?"origin":ae.remotes?.[0]??"")),Sa(ae.upstreamBranch||ae.branch||(ae.branches?.[0]??"")))},[ae,di]);const kc=n.useMemo(()=>{if(Xe)return{text:o("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!En||pn)return{text:o("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!ae?.upstream)return{text:o("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const e=ae.ahead??0,s=ae.behind??0;return e>0&&s>0?{text:o("rightSidebar.pushDivergedCount",{ahead:e,behind:s}),className:"bg-destructive/10 text-destructive"}:e>0?{text:o("rightSidebar.pushAheadCount",{count:e}),className:"bg-accent/10 text-accent"}:s>0?{text:o("rightSidebar.pushBehindCount",{count:s}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:o("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[ae?.ahead,ae?.behind,ae?.upstream,En,pn,Xe,o]),wf=n.useCallback(e=>{if(e&&!Z){const s=e.currentTarget.getBoundingClientRect();Je({x:Math.min(s.left,window.innerWidth-352),y:Math.min(s.bottom+6,window.innerHeight-64)})}else Je(null);P?.()},[Z,P]),ui=n.useCallback(()=>{Je(null),M?.()},[M]);function Sc(){if(!An)return null;const e=gc?.label??o("rightSidebar.allRepositories"),s=gc?.count??Ae.size,l=xt(e)||e;return t.jsxs("button",{type:"button",onClick:wf,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 ${b?"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":b,title:e,children:[t.jsx(xr,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 truncate",children:l}),t.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${s>0?"bg-accent/10 text-accent":"bg-surface text-muted-foreground"}`,children:s}),t.jsx(oa,{size:12,className:"shrink-0"})]})}function kf(){if(!b||!An||typeof document>"u")return null;const e=typeof window>"u"?1024:window.innerWidth,s=typeof window>"u"?768:window.innerHeight,l=Math.max(12,Math.min(lr?.x??e-368,e-352)),h=Math.max(12,Math.min(lr?.y??80,s-420)),u=Z?void 0:{left:l,top:h},y=t.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${Z?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:ui,children:t.jsxs("div",{className:Z?"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:u,onClick:v=>v.stopPropagation(),children:[t.jsxs("div",{className:Z?"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:[t.jsxs("div",{children:[t.jsx("div",{className:Z?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:o("rightSidebar.repositories")}),!Z&&t.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[t.jsx("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:Oa.length}),t.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${Ae.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Ae.size})]})]}),t.jsx("button",{type:"button",onClick:ui,className:Z?"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":o("rightSidebar.close"),children:t.jsx(Qt,{size:Z?16:14})})]}),t.jsx("div",{className:Z?"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:Oa.map(v=>{const Y=(v.root??null)===be,ee=xt(v.label)||v.label;return t.jsxs("button",{type:"button",onClick:()=>{zc(v.root),ui()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${Z?"px-3 py-2":"px-2 py-1.5"} ${Y?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:v.label,role:"option","aria-selected":Y,children:[t.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${Y?"bg-primary":"bg-transparent group-hover:bg-border/40"}`}),t.jsx("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${Y?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:t.jsx(xr,{size:13})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:`${Z?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:ee}),t.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:v.root===null?o("rightSidebar.allRepositories"):v.label})]}),v.branch&&t.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:v.branch}),v.deferred?t.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/70",children:o("rightSidebar.repoNotLoaded")}):t.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${v.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:v.count})]},v.root??"all")})})]})});return xu(y,Z,document.body)}function Sf(){return kf()}function Rc(e){const s=mt(e,d),l=e.absolutePath||(s?`${s}/${e.path}`:e.path),h=fo(l,s??d);return{key:yr(e),path:e.path,absolutePath:l,displayName:h.name,displayDir:h.dir,oldPath:e.oldPath,status:e.status,title:l}}function jc(e){return e.oldPath?t.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:o("rightSidebar.changedFromPath",{path:e.oldPath})}):null}function Wa(e,s){const l=Mn(e,d),h=`path:${l}`,u=Oe===h,y=Se===h,v=u||y;return t.jsx("button",{type:"button",onClick:Y=>{Y.stopPropagation(),Vt(l,h,Y.currentTarget)},...ai($a(l),h),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 ${v?"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"} ${v?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:s,children:t.jsx("span",{className:"whitespace-nowrap",children:o(y?"rightSidebar.copied":u?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function Cc(e){const s=mt(e,d),l=e.absolutePath||(s?`${s}/${e.path}`:e.path),h=Jf(e),u=Hi(e);return t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(ab,{actions:h,running:Be,completed:On?.path===u?On:null}),Wa(l,o("rightSidebar.insertThisFile"))]})}function Nc(e,s){const l=s.root??d;if(!l)return null;const h=Mn(e,l);return Wa(h,o("fileTree.insertRefTitle"))}function zs(){return t.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5","aria-label":o("diffViewer.view"),children:[t.jsx("button",{type:"button",onClick:()=>Dc("unified"),"aria-pressed":zt==="unified",title:o("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${zt==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.unified")}),t.jsx("button",{type:"button",onClick:()=>Dc("split"),"aria-pressed":zt==="split",title:o("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${zt==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.split")})]})}function Pc(){return Gs.map(e=>{const s=Vd(e.files.map(([,y])=>y)),l=tl({activeGitRepoRoot:be,groupCount:Gs.length,label:e.label,rootName:tt}),h=!!(l&&e.root&&Rr.has(e.root));return{key:e.root??e.label,root:e.root,label:e.label,branch:e.branch,collapsed:h,files:e.files.map(([,y])=>Rc(y)),header:l?t.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${h?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[t.jsxs("button",{type:"button",onClick:()=>Of(e.root),"aria-expanded":!h,className:"flex min-w-0 flex-1 items-center gap-2 text-left active:scale-[0.99]",children:[t.jsx("span",{className:"shrink-0 text-muted-foreground",children:h?t.jsx(ps,{size:13}):t.jsx(oa,{size:13})}),t.jsx(xr,{size:12,className:"shrink-0 text-muted-foreground"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:e.label}),e.branch&&t.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:e.branch})]}),t.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:e.files.length}),s>0&&t.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:s})]}),e.root&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),Qa("stage-all",e.root,e.label)},disabled:!!Be,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:o("rightSidebar.stageAll"),children:o("rightSidebar.stageAll")}),t.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),Qa("stash-all",e.root,e.label)},disabled:!!Be,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:o("rightSidebar.stashAll"),children:o("rightSidebar.stashAll")})]})]}):null}})}const Tn=n.useMemo(()=>new Map(Array.from(Ae.values(),e=>[yr(e),e])),[Ae]);function Ec(e){const s=Tn.get(e.key),l=s?mt(s,d):null,h=om(yt,l,s?.path??e.path);return t.jsx(Xi,{changeStatus:e.status,auditStatus:h,renderChangeBadge:u=>t.jsx(sa,{status:u})})}const Ka=n.useCallback(e=>{if(Z)return null;const s=Array.from(e.querySelectorAll("[data-diff-stream-item]"));if(s.length===0)return null;const h=e.getBoundingClientRect().top+48;let u=null,y=Number.POSITIVE_INFINITY;for(const Y of s){const ee=Y.getBoundingClientRect();if(ee.bottom<h)continue;const ue=Math.abs(ee.top-h);ue<y&&(u=Y,y=ue)}const v=u?.dataset.diffSelectionPath??u?.dataset.diffStreamItem??null;return v?(Aa.current===v&&B.getState().selectedFilePath===v||(Aa.current=v,nt(v)),v):null},[Z,nt]),Rf=!!(!Be&&ye&&!Xe&&(ae?.upstream||mn.trim()&&gn.trim())),jf=!!(!Be&&ye&&!Xe&&(ae?.upstream||mn.trim()&&gn.trim())),Cf=!!(!Be&&ye&&!Xe&&zn.trim()&&zn.trim()!==ae?.branch),Jt=n.useMemo(()=>{const e=_e.trim().toLowerCase(),s=Array.from(Ae.entries()).filter(([,l])=>!be||mt(l,d)===be).sort(([l],[h])=>l.localeCompare(h));return e?s.filter(([l,h])=>`${l} ${h.path} ${h.status} ${h.repoRelativeRoot??""} ${h.repoName??""}`.toLowerCase().includes(e)):s},[be,Ae,_e,d]);n.useEffect(()=>{ea("selected_file_state",{selectedFilePath:Ze,selectedChangedFilePath:Yt?.path??null,selectedChangedFileAbsolutePath:Yt?.absolutePath??null,selectedChangedFileRepoRoot:Yt?.repoRoot??null,rootPath:d,activeGitRepoRoot:be,rightTab:Uo,effectiveRightTab:Ct,diffPaneActive:Nt,changedFiles:Ae.size,filteredChangedFiles:Jt.length,gitBundleLoading:hr,gitBundleLastLoadedAt:qn})},[be,Ae.size,Nt,Ct,Jt.length,qn,hr,Uo,d,Yt?.absolutePath,Yt?.path,Yt?.repoRoot,Ze]);const Gs=n.useMemo(()=>{const e=new Map;for(const s of Jt){const[,l]=s,h=mt(l,d),u=nb(l)||tt,y=h??u,v=h?st.get(h):void 0,Y=e.get(y)??{root:h,label:u,branch:v?.context?.branch,files:[]};Y.files.push(s),e.set(y,Y)}return Array.from(e.values()).sort((s,l)=>s.label===tt?-1:l.label===tt?1:s.label.localeCompare(l.label))},[Jt,st,tt,d]),Ws=n.useMemo(()=>{const e=[],s=new Map;for(const l of Jt)s.set(yr(l[1]),l);for(const l of Gs){if(!!(l.root&&tl({activeGitRepoRoot:be,groupCount:Gs.length,label:l.label,rootName:tt})&&Rr.has(l.root)))continue;if(Nr!=="tree"){e.push(...l.files);continue}const u=l.files.map(([,y])=>Rc(y));for(const y of xp(u)){const v=s.get(y.key);v&&e.push(v)}}return e},[be,Rr,Nr,Gs,Jt,tt]),Ac=n.useMemo(()=>Ae.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:o("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Ws.map(([,e])=>{const s=mt(e,d),l=e.absolutePath||(s?`${s}/${e.path}`:e.path);return{key:yr(e),path:e.path,absolutePath:l,status:e.status,repoRoot:s,displayName:fo(l,s).name,displayDir:fo(l,s).dir,auditRecords:yt}}),[yt,Ae.size,Ws,d,o]);n.useEffect(()=>{if(!Nt||Ws.length===0||Z)return;const e=[],s=()=>{const l=document.querySelector(".termdock-diff-stream-scroller");if(l&&Ka(l))return;const h=document.querySelector("[data-diff-stream-item]"),u=h?.dataset.diffSelectionPath??h?.dataset.diffStreamItem??null;if(u){Aa.current=u,nt(u);return}const y=Ws[0]?.[1];if(!y)return;const v=yr(y);Aa.current=v,nt(v)};for(const l of[80,240,600,1200])e.push(window.setTimeout(s,l));return()=>e.forEach(l=>window.clearTimeout(l))},[Nt,Z,Ws,nt,Ka]);const fi=n.useMemo(()=>{const e=v=>`'${v.replace(/'/g,"'\\''")}'`,s=ar.length>0?kn:Ge.filter(v=>v.files.length>0),l=s.length>0?s:d?[{root:d,relativeRoot:".",name:tt}]:[],h=l.length>0?l.map(v=>`- ${v.relativeRoot==="."?".":v.relativeRoot} (${v.root})`).join(`
|
|
1651
|
+
`):`- ${d?".":""}`,u=l.length>0?l.map(v=>` td audit-export ${e(v.root)}`).join(`
|
|
1652
|
+
`):" td audit-export",y=l.length>0?" td audit ~/.termdock/change-audit/payload-<repo>.json":" td audit ~/.termdock/change-audit/payload.json";return["任务:为目标仓库的 Git diff hunk 生成自包含审计解释,并通过 Termdock CLI 注入。","",`当前工作区:${d??""}`,"目标仓库:",h,"","执行步骤:","1. 仅对“目标仓库”逐个执行 audit-export。嵌套子仓使用括号内 repo 绝对路径作为命令参数。",u,"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 后批量注入:",y,'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(`
|
|
1653
|
+
`)},[ar.length,kn,Ge,tt,d]),Nf=n.useCallback(async(e="generate",s)=>{if(An&&Or.length===0&&!be){rn(!0);return}const l=e==="generate"?fi:[e==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",fi].join(`
|
|
1654
|
+
`);return ot("insert_change_audit_prompt",{rootPath:d,activeGitRepoRoots:ar,mode:e,hasAuditListCommand:l.includes("td audit-list"),promptLength:l.length}),await Fr(o("rightSidebar.insertChangeAuditPrompt"),l,`${sc}:${e}`,s)?(mr(),m||c(),!0):!1},[be,fi,Or.length,ar,Fr,mr,c,m,d,An,o]),qa=n.useCallback(async e=>{try{await ld({ids:[e]}),tn(s=>s.filter(l=>l.id!==e))}catch{mr()}},[mr]),Pf=n.useCallback(async()=>{if(yt.length===0)return;const e=yt.map(s=>s.id);try{await ld({ids:e}),tn(s=>s.filter(l=>!e.includes(l.id))),Ur(null)}catch(s){const l=s instanceof Error?s.message:"Failed to clear change audit explanations";Ur(o("rightSidebar.changeAuditClearFailed",{message:l})),mr()}},[yt,mr,o]),Ef=n.useCallback(async e=>{if(e.records.length===0)return;const s=e.records.map(l=>l.id);try{await Lh({ids:s}),Hr(l=>l.filter(h=>!s.includes(h.id))),Ve===e.key&&(un(null),cr(!1))}catch(l){Wt(o("rightSidebar.branchAuditClearFailed",{message:l instanceof Error?l.message:"Failed to clear branch explanation"})),Ta(null)}},[Ta,Ve,o]),Af=n.useCallback(e=>{Dn(s=>e===null?(rn(!1),[]):s.includes(e)?s.filter(l=>l!==e):[...s,e])},[]),Tf=n.useCallback(e=>{No(s=>e===null?(Co(!1),[]):s.includes(e)?s.filter(l=>l!==e):[...s,e])},[]),hi=n.useMemo(()=>{if(!nr)return[];const e=s=>{const l=s.diff??"";let h=0,u=0;for(const y of l.split(`
|
|
1655
|
+
`))y.startsWith("+++")||y.startsWith("---")||(y.startsWith("+")&&(h+=1),y.startsWith("-")&&(u+=1));return{filePath:s.filePath,oldPath:s.oldPath,newPath:s.newPath,hunkHeader:s.hunkHeader,hunkIndex:s.hunkIndex??0,fingerprint:s.fingerprint,additions:h,deletions:u,diff:l}};return me?(me.hunks??[]).map(s=>{const l=me.comparisonRepos&&me.comparisonRepos.length>1?[...me.comparisonRepos].sort((u,y)=>y.label.length-u.label.length).find(u=>s.filePath.startsWith(`${u.label}/`)):void 0,h=er.find(u=>u.repoRoot===me.repoRoot&&u.baseRef===me.baseRef&&(u.branchName??null)===(me.currentBranch??null)&&u.filePath===s.filePath&&u.hunkHeader===s.hunkHeader&&(u.hunkIndex??0)===s.hunkIndex&&u.fingerprint===s.fingerprint)??null;return{key:`${s.filePath}\0${s.hunkHeader}\0${s.hunkIndex}`,repoRoot:l?.repoRoot??me.repoRoot,repositoryPath:l?s.filePath.slice(l.label.length+1):s.filePath,hunk:s.previewRevert&&!os(s.previewRevert.cwd,s.previewRevert.comparisonBranch)?{...s,previewRevert:void 0}:s,current:h,stale:null}}):Ve?er.filter(s=>Hd(s)===Ve).map(s=>{const l=e(s);return{key:`${s.filePath}\0${s.hunkHeader}\0${s.hunkIndex??0}`,hunk:l,current:s,stale:null}}):[]},[me,er,os,nr,Ve]),pi=er.length>0,is=n.useMemo(()=>{if(!nr)return[];const e=new Map;for(const s of er){const l=s.repoRoot,h=st.get(l),u=h?.relativeRoot==="."?tt:h?.relativeRoot||h?.name||xt(l),y=Hd(s),v=e.get(y)??{key:y,repoRoot:l,repoLabel:u,baseRef:s.baseRef,branchName:s.branchName??null,headRef:s.headRef??null,diffFingerprint:s.diffFingerprint??null,records:[],latestInjectedAt:0};v.records.push(s),v.latestInjectedAt=Math.max(v.latestInjectedAt,s.injectedAt??0),e.set(y,v)}return Array.from(e.values()).sort((s,l)=>l.latestInjectedAt-s.latestInjectedAt)},[er,st,nr,tt]),mi=n.useMemo(()=>Ve?is.find(e=>e.key===Ve)??null:null,[is,Ve]),Ks=me?{repoRoot:me.repoRoot??"",repoLabel:me.repoRoot?st.get(me.repoRoot)?.relativeRoot==="."?tt:st.get(me.repoRoot)?.relativeRoot||st.get(me.repoRoot)?.name||xt(me.repoRoot):tt,baseRef:me.baseRef??me.baseBranch??"",branchName:me.currentBranch??null,headRef:me.headRef??null,diffFingerprint:me.diffFingerprint??null}:mi,Mf=n.useMemo(()=>(Ke?.hunks??[]).map(e=>({key:`${e.filePath}\0${e.hunkHeader}\0${e.hunkIndex}`,repoRoot:Ke?.repoRoot,hunk:e,current:null,stale:null})),[Ke?.hunks,Ke?.repoRoot]),Lf=n.useMemo(()=>{if(me)return[];const e=mi;return e?ws.filter(s=>s.repoRoot===e.repoRoot&&s.baseRef===e.baseRef&&(s.branchName??null)===e.branchName&&(!e.diffFingerprint||s.diffFingerprint===e.diffFingerprint)):[]},[me,ws,mi]),If=n.useCallback(e=>{const s=hi.find(l=>l.hunk.filePath===e.filePath||(e.repoRoot?`${e.repoRoot}/${l.hunk.filePath}`===e.filePath:!1));s&&(fn(s.key),window.setTimeout(()=>Ln(e),90),window.setTimeout(()=>Ln(e),320),window.setTimeout(()=>Ln(e),760))},[hi]),gi=n.useMemo(()=>{const e=u=>`'${u.replace(/'/g,"'\\''")}'`,s=Hs,l=s.length>0?s.map(u=>`- ${u.label} (${u.root}),目标分支:${rr[u.root]||u.branch||"(current branch)"},基线分支:${jt[u.root]||"(not set)"},包含本地未提交更改:${os(u.root,rr[u.root]||u.branch)&&(dn[u.root]??!0)?"是":"否"}`).join(`
|
|
1656
|
+
`):`- ${d?".":""}`,h=s.length>0?s.map(u=>{const y=rr[u.root]||u.branch||"",v=jt[u.root]||"",Y=u.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[y?` git -C ${e(u.root)} switch ${e(y)}`:` # ${u.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${e(v)} ${e(u.root)} > ~/.termdock/branch-audit/branch-audit-export-${Y}.json`].join(`
|
|
1657
|
+
`)}).join(`
|
|
1658
|
+
`):" td branch-audit-export <base-branch>";return["解释目标仓库当前分支相对于基线分支的改动,并把解释写回 Termdock。","",`当前工作区:${d??""}`,"每个仓库分别遵循下面列出的本地未提交更改选项。","目标仓库:",l,"","操作指令:","1. 只针对上面列出的目标仓库导出分支 hunk,按各仓库所选目标分支与基线对比。本地未提交更改标记为是的仓库纳入 staged/unstaged/untracked 改动;标记为否的仓库只解释提交改动,忽略导出中混入的本地改动。嵌套子仓或软链接子仓使用括号内的仓库绝对路径。示例:",h,"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:d??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(`
|
|
1659
|
+
`)},[dn,os,Hs,jt,rr,d]),$f=n.useCallback(async(e="generate",s)=>{const l=e==="generate"?gi:[e==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",gi].join(`
|
|
1660
|
+
`);return await Fr(o("rightSidebar.branchAuditShort"),l,`context:branch-audit-scope:${e}`,s)?(m||c(),!0):!1},[gi,Fr,c,m,o]),bi=n.useCallback(async(e={})=>{const s=e.refresh===!0,l=s&&me?.comparisonRepos?me.comparisonRepos:Hs.map(v=>{const Y=(rr[v.root]||v.branch||"").trim();return{repoRoot:v.root,label:v.label,base:jt[v.root]?.trim()??"",head:Y||null,includeUncommitted:dn[v.root]??!0}});if(!d||l.length===0)return;const h=++A.current,u=d,y=()=>Re(u)&&h===A.current;Me(!0),Le(null),s||(tr(null),it(null));try{const v=await Promise.all(l.map(async G=>{if(!G.base)throw new Error(o("rightSidebar.branchAuditMissingBase",{repo:G.label}));return cd({cwd:d,repoRoot:G.repoRoot,base:G.base,head:G.head,includeUncommitted:e.repoRoot===G.repoRoot?e.includeUncommitted??!1:G.includeUncommitted??me?.includeUncommitted??!0,requestSlotId:`right-sidebar-branch-preview:${G.repoRoot}`})}));if(!y())return;const Y=v.find(G=>!G.available);if(Y){Le(Y.error??"Branch diff is unavailable");return}const ee=v.length===1?v[0]:{available:!0,workspaceRoot:d,repoRoot:d,baseRef:v.map(G=>G.baseRef??G.baseBranch).filter(Boolean).join(", "),currentBranch:v.map(G=>G.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:v.map(G=>G.headRef).filter(Boolean).join(", "),diffFingerprint:v.map(G=>G.diffFingerprint).filter(Boolean).join("+"),stat:v.map(G=>G.stat).filter(Boolean).join(`
|
|
1661
|
+
`),files:v.flatMap((G,_)=>{const oe=l[_];return(G.files??[]).map(Ne=>`${oe?.label??G.repoRoot??"repo"}/${Ne}`)}),hunks:v.flatMap((G,_)=>{const Ne=l[_]?.label??G.repoRoot??"repo";return(G.hunks??[]).map(Ue=>({...Ue,filePath:`${Ne}/${Ue.filePath}`,oldPath:Ue.oldPath?`${Ne}/${Ue.oldPath}`:Ue.oldPath,newPath:Ue.newPath?`${Ne}/${Ue.newPath}`:Ue.newPath}))}),commits:v.flatMap(G=>G.commits??[]),commitCount:v.reduce((G,_)=>G+(_.commitCount??_.commits?.length??0),0),diff:v.map(G=>G.diff).filter(Boolean).join(`
|
|
1662
|
+
`),truncated:v.some(G=>G.truncated)};if(ee.comparisonRepos=l.map((G,_)=>({...G,head:G.head??v[_].currentBranch??null,includeUncommitted:v[_].includeUncommitted===!0,canIncludeUncommitted:v[_].canIncludeUncommitted})),ee.canIncludeUncommitted=v.every(G=>G.canIncludeUncommitted===!0),ee.includeUncommitted=v.some(G=>G.includeUncommitted===!0),Po(G=>({...G,...Object.fromEntries(ee.comparisonRepos.map(_=>[_.repoRoot,_.includeUncommitted??!1]))})),!s&&(ee.hunks??[]).length===0){Le(o("rightSidebar.branchAuditDiffEmpty"));return}const ue=Date.now(),je=(s?Ve:null)??["preview",ee.repoRoot??d,ee.baseRef??ee.baseBranch??"",ee.currentBranch??"",ee.headRef??"",ee.diffFingerprint??ue].join("\0"),Ye=l.length===1?l[0].label:`${l.length} repos`;tr(ee),sn(G=>[{key:je,diff:ee,repoLabel:Ye,createdAt:ue},...G.filter(_=>_.key!==je)].slice(0,8)),s||R(G=>G[je]===void 0?G:{...G,[je]:0}),un(je),fn(G=>{const _=ee.hunks?.[0],oe=_?`${_.filePath}\0${_.hunkHeader}\0${_.hunkIndex}`:null;return s&&G&&(ee.hunks??[]).some(Ne=>Ne.filePath===G.split("\0")[0])?G:oe}),cr(!0)}catch(v){if(!y()||vr(v))return;Le(v instanceof Error?v.message:"Failed to load branch diff")}finally{y()&&Me(!1)}},[dn,me,Ve,Hs,jt,rr,Re,d,o]),Ff=n.useCallback(e=>{++A.current,Me(!1),tr(e.diff),Le(null),un(e.key),fn(e.diff.hunks?.[0]?`${e.diff.hunks[0].filePath}\0${e.diff.hunks[0].hunkHeader}\0${e.diff.hunks[0].hunkIndex}`:null),cr(!0)},[]),Df=n.useCallback(e=>{sn(s=>s.filter(l=>l.key!==e)),R(s=>{if(!(e in s))return s;const l={...s};return delete l[e],l}),Ve===e&&(un(null),tr(null),cr(!1))},[Ve]),_f=n.useCallback(e=>{++A.current,Me(!1);const s=is.find(l=>l.key===e);s&&(tr(null),Le(null),un(e),fn(s.records[0]?.filePath??null),cr(!0))},[is]),Bf=n.useCallback(async e=>{if(!d||!ye)return;const[s]=e.split(/\s+/);if(s){dr(s),an(null),it(null);try{const l=await Ih({cwd:d,repoRoot:ye,commit:s,requestSlotId:"right-sidebar-commit-diff"});if(!l.available){an(l.error??"Commit diff is unavailable");return}it(l);const h=l.hunks?.[0];ha(h?`${h.filePath}\0${h.hunkHeader}\0${h.hunkIndex}`:null)}catch(l){an(l instanceof Error?l.message:"Failed to load commit diff")}finally{dr(null)}}},[ye,d]),Uf=n.useCallback(e=>{if(!me||!Ve)return;const s=Math.max(0,Math.round(e));R(l=>Math.abs((l[Ve]??0)-s)<24?l:{...l,[Ve]:s})},[me,Ve]);n.useEffect(()=>{!me||!Ve||sn(e=>e.map(s=>s.key===Ve&&s.diff!==me?{...s,diff:me}:s))},[me,Ve]);const Tc=!!me;n.useEffect(()=>{if(!Z||!Ar||!Tc)return;const e=zl.current;if(!e||e.destroyed)return;e.update(),e.slideTo(1,0);const s=window.requestAnimationFrame(()=>{e.destroyed||(e.update(),e.slideTo(1,0))});return()=>window.cancelAnimationFrame(s)},[Ar,Tc,Z]);const Mc=n.useCallback(e=>{e&&Ku(s=>yp(s,e))},[]),Lc=Ra.key===Ze?Ra.key:null,Va=n.useCallback(e=>{const s=B.getState(),l=hb();ea("select_diff_file",{interactionId:l,path:e,previousSelectedFilePath:s.selectedFilePath,rootPath:s.rootPath,activeGitRepoRoot:be,changedFiles:s.changedFiles.size,gitBundleLoading:s.gitBundleLoading,gitBundleLastLoadedAt:s.gitBundleLastLoadedAt,rightTab:s.rightTab}),nt(e),Lt("diff"),Z&&e&&Kl(1),Mc(e),queueMicrotask(()=>{const h=B.getState();ea("select_diff_file_after",{interactionId:l,requestedPath:e,selectedFilePath:h.selectedFilePath,rootPath:h.rootPath,rightTab:h.rightTab,changedFiles:h.changedFiles.size,activeGitRepoRoot:be})})},[be,Z,Mc,nt,Lt,Kl]),Ic=n.useCallback(e=>{const s=Array.from(Ae.values()).find(l=>{const h=mt(l,d),u=yr(l);return l.path===e.filePath||u===e.filePath||l.absolutePath===e.filePath||(h?`${h}/${l.path}`===e.filePath:!1)||e.repoRoot&&h===e.repoRoot&&l.path===e.filePath});if(s){Va(yr(s)),window.setTimeout(()=>Ln(e),90),window.setTimeout(()=>Ln(e),320),window.setTimeout(()=>Ln(e),760);return}Ln(e)},[Ae,d,Va]),$c=n.useCallback(({slideToDetail:e,fullscreen:s,toggleFullscreen:l}={})=>ys.length>0?t.jsx(su,{walkthroughs:ys,repoRoot:be,fullscreen:s,onToggleFullscreen:l,onNavigate:h=>{Z&&window.requestAnimationFrame(()=>e?.()),Ic(h)}}):t.jsxs("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:[t.jsx(aa,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),o("rightSidebar.changeWalkthroughEmpty")]}),[be,ys,Ic,Z,o]),Of=n.useCallback(e=>{e&&jr(s=>{const l=new Set(s);return l.has(e)?l.delete(e):l.add(e),Bi($i,l),l})},[]),Fc=n.useCallback(e=>{Cr(s=>{const l=new Set(s);return l.has(e)?l.delete(e):l.add(e),Bi(Md,l),l})},[]),Ya=n.useCallback(e=>{la(e),Et(vu,e)},[]);n.useEffect(()=>{Ha||Nr!=="ai"||Ya("tree")},[Nr,Ya,Ha]);const Xa=n.useCallback(()=>{xs(e=>{const s=!e;return Et(wu,s),s})},[]),Dc=n.useCallback(e=>{ca(e),Et(ku,e)},[]),{whitespace:_c,context:Bc}=Np(),Uc=n.useMemo(()=>({algorithm:"histogram",whitespace:_c,context:Bc}),[_c,Bc]),Oc=n.useCallback(e=>{ie(e),Et(Su,e)},[]),Ja=n.useCallback(async(e,s,l,h)=>{let u=e;for(;u.ok&&u.status==="running";)await new Promise(v=>window.setTimeout(v,1500)),u=await dd({jobId:u.jobId,cwd:s.cwd,action:s.action});if(!u.ok)throw new Error("Git action status is unavailable");if(u.status==="error")throw new Error(u.error||u.message||"Git action failed");const y={action:s.action,path:h,label:l};return Ts(y),window.setTimeout(()=>Ts(v=>v?.action===y.action&&v.path===y.path?null:v),1400),u},[]),bt=n.useCallback(async(e,s,l)=>{const h=d;d&&pr.current.delete(d),Wt(null),Ts(null),As({action:e.action,path:l});try{const u=await $h({...e,includeNested:Xs(d)}),y=await Ja(u,e,s,l);if(!Re(h))return!1;const v=d?await Ci(d,void 0,{includeNested:Xs(d),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Qs(d)}).catch(()=>y.bundle):y.bundle;return Re(h)?(v&&Qn(v,{reloadDiff:!0,cacheOnly:!0}),hn(null),!0):!1}catch(u){return Ts(null),Wt(o("rightSidebar.gitActionFailed",{message:u instanceof Error?u.message:"Unknown error"})),!1}finally{Re(h)&&As(null)}},[Qn,Re,d,o,Ja]),Hc=n.useCallback(async e=>{const s=d;await ud({...e,includeNested:Xs(d)}),Re(s)&&$t(d??void 0,{refresh:!0,background:!0})},[Re,$t,d]),Hf=n.useCallback(async e=>{const s=me,l=A.current,h=s?.hunks?.find(y=>y.previewRevert?.cwd===e.cwd&&y.previewRevert.path===e.path);if(!s||!h||!e.comparisonBase)throw new Error(o("diffViewer.hunkActionUnavailable"));ke(y=>y+1),Le(null);try{await ud(e)}catch(y){throw ke(v=>v-1),y}if(l!==A.current||!Re(d)){ke(y=>y-1);return}const u=y=>{tr(v=>{if(!v||l!==A.current)return v;const Y=v.hunks??[],ee=y===void 0?Y.filter(je=>!(je.previewRevert?.cwd===e.cwd&&je.previewRevert.patch===e.patch)):[...Y.filter(je=>je.filePath!==h.filePath),...y];return{...v,hunks:ee}})};u(),cd({cwd:e.cwd,repoRoot:e.cwd,base:e.comparisonBase,comparisonBase:e.comparisonBase,filePath:e.path,requestSlotId:`branch-preview-file:${e.cwd}:${e.path}`}).then(y=>{if(l!==A.current||!Re(d))return;if(!y.available||y.truncated)throw new Error(y.error??o("diffViewer.hunkActionUnavailable"));const v=e.path.slice(e.cwd.length+1),Y=h.filePath.slice(0,h.filePath.length-v.length);u((y.hunks??[]).map(ee=>({...ee,filePath:`${Y}${ee.filePath}`,oldPath:ee.oldPath?`${Y}${ee.oldPath}`:ee.oldPath,newPath:ee.newPath?`${Y}${ee.newPath}`:ee.newPath})))}).catch(y=>{l===A.current&&Re(d)&&!vr(y)&&Le(`${o("diffViewer.hunkActionReverted")} · ${y instanceof Error?y.message:String(y)}`)}).finally(()=>ke(y=>y-1))},[me,Re,d,o]),Qa=n.useCallback((e,s,l)=>{if(s){if(e==="stage-all"){bt({action:"stage-all",cwd:s},o("rightSidebar.stageAll"),`repo:${s}`);return}hn({kind:"stash-all",repoRoot:s,repoLabel:l})}},[bt,o]),zc=n.useCallback(e=>{ft(e),wa(""),ka(""),Sa(""),nt(mc(e)),at||Lt("diff"),e&&Ua(st.get(e))},[Ua,mc,at,st,nt,ft,Lt]),Gc=n.useCallback(e=>{const s=new Set([...qt.current.keys(),...vn.current,...pr.current]);for(const l of s)l!==e&&(Kt.current.delete(l),qt.current.get(l)?.abort(),qt.current.delete(l),wt(`right-sidebar-git-untracked:${l}`),vn.current.delete(l),pr.current.delete(l))},[]),zf=n.useCallback(async e=>{const s=d;if(!s||(await B.getState().setNestedGitScanRoot(s,e),!Re(s)))return;if(e){await $t(s,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}Gc(s),wa(""),ka(""),Sa(""),No(h=>h.filter(u=>u===s));const l=Yt;l&&mt(l,s)!==s&&nt(null),await $t(s,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[Gc,Re,$t,d,nt,Yt]),Gf=n.useCallback(async()=>{if(!ye||Xe){Wt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=zn.trim();!e||e===ae?.branch||await bt({action:"switch-branch",cwd:ye,branch:e},o("rightSidebar.switchBranch"))},[ae?.branch,ye,Xe,bt,zn,o]),Wc=n.useCallback(async()=>{if(!ye||Xe){Wt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=va.trim();if(!e)return;await bt({action:"commit",cwd:ye,message:e},o("rightSidebar.commitChanges"))&&yl("")},[ye,va,Xe,bt,o]),Wf=n.useCallback(async()=>{if(!ye||Xe){Wt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=mn.trim(),s=gn.trim();await bt({action:"push",cwd:ye,...e?{remote:e}:{},...s?{branch:s}:{}},o("rightSidebar.pushChanges"))},[ye,gn,mn,Xe,bt,o]),Kf=n.useCallback(async()=>{if(!ye||Xe){Wt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=mn.trim(),s=gn.trim();await bt({action:"pull",cwd:ye,...e?{remote:e}:{},...s?{branch:s}:{}},o("rightSidebar.pullChanges"))},[ye,gn,mn,Xe,bt,o]);n.useEffect(()=>{if(!at||!ye||Be)return;let e=!1;const s={push:o("rightSidebar.pushChanges"),pull:o("rightSidebar.pullChanges"),commit:o("rightSidebar.commitChanges"),"switch-branch":o("rightSidebar.switchBranch"),"stage-all":o("rightSidebar.stageAll"),"stash-all":o("rightSidebar.stashAll")};return(async()=>{for(const l of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(e)return;const h=await dd({cwd:ye,action:l}).catch(()=>null);if(!h?.ok||h.status!=="running")continue;const u={action:l,cwd:ye},y=s[l]??l;As({action:l});try{const v=await Ja(h,u,y);if(e||!Re(d))return;const Y=d?await Ci(d,void 0,{includeNested:Xs(d),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Qs(d)}).catch(()=>v.bundle):v.bundle;Y&&Qn(Y,{reloadDiff:!0,cacheOnly:!0})}catch(v){e||Wt(o("rightSidebar.gitActionFailed",{message:v instanceof Error?v.message:"Unknown error"}))}finally{e||As(null)}return}})(),()=>{e=!0}},[ye,Qn,at,Re,d,Be,o,Ja]);const xi=On?.action==="commit",yi=On?.action==="switch-branch",vi=On?.action==="pull",wi=On?.action==="push",Za=at||Gu,ki=Ga?o("rightSidebar.changeAuditScopeAll"):br.length===1?br[0].label:`${br.length} repos`,qf=br.length>0,Kc=Hs.length>0,Vf=d?t.jsx(Wd,{open:jo,onOpenChange:Co,showScopePicker:!0,selectedAll:Ga,repos:Xt,selectedRoots:za,onToggleRepo:Tf,onGenerate:e=>$f(pi?"regenerate":"generate",e),disabled:!qf,generateDisabled:!Kc,inserted:Oe?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:o(pi?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.branchAuditGenerateTitle"),ariaLabel:o("rightSidebar.branchAuditShort"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:ki,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o(pi?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{bi()},secondaryDisabled:!Kc||Qe,secondaryLabel:o("rightSidebar.branchAuditViewDiff"),secondaryTitle:o("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:Qe,loading:ul.size>0,statusTitle:ul.size>0?o("rightSidebar.branchCandidatesLoading"):void 0,extraContent:t.jsx("div",{className:"mb-2 space-y-1.5",children:vc.length>0&&t.jsx("div",{className:"rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[10px] text-[color:var(--warning)]",children:o("rightSidebar.missingBaseReposSkipped",{repositories:vc.map(e=>e.label).join(fe==="zh"?"、":", ")})})}),renderRepoExtra:e=>{const s=st.get(e.root),l=os(e.root,rr[e.root]||s?.context?.branch),h=[],u=new Set,y=(ue,je)=>{!ue||u.has(ue)||(u.add(ue),h.push({value:ue,label:ue,meta:je}))};y(rr[e.root]||s?.context?.branch,o("rightSidebar.pushCurrentBranchBadge"));for(const ue of s?.context?.branches??[])y(ue,ue===s?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):o("rightSidebar.localBranch"));for(const ue of s?.context?.remoteBranches??[])y(ue,o("rightSidebar.remoteBranch"));const v=[],Y=new Set,ee=(ue,je)=>{!ue||Y.has(ue)||(Y.add(ue),v.push({value:ue,label:ue,meta:je}))};ee(jt[e.root],jt[e.root]?o("rightSidebar.pushUpstreamBadge"):void 0),ee(s?.context?.upstream,s?.context?.upstream?o("rightSidebar.pushUpstreamBadge"):void 0);for(const ue of s?.context?.remoteBranches??[])ee(ue,"remote");for(const ue of s?.context?.branches??[])ee(ue,ue===s?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");return t.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[t.jsx(fs,{label:o("rightSidebar.currentBranchLabel"),value:rr[e.root]||s?.context?.branch||"",options:h,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),onChange:ue=>{ma(je=>({...je,[e.root]:ue}))}}),t.jsx(fs,{label:o("rightSidebar.branchAuditBaseLabel"),value:jt[e.root]||"",options:v,placeholder:o("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:o("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:o("rightSidebar.branchAuditBaseEmpty"),onChange:ue=>{ga(je=>({...je,[e.root]:ue}))}}),t.jsxs("label",{className:"sm:col-span-2 flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block font-medium",children:o("rightSidebar.includeUncommitted")}),t.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:o(l?"rightSidebar.includeUncommittedHint":"rightSidebar.includeUncommittedCurrentBranchOnly")})]}),t.jsx("input",{type:"checkbox",checked:l&&(dn[e.root]??!0),disabled:!l,onChange:ue=>Po(je=>({...je,[e.root]:ue.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,qc=Zs(yt.reduce((e,s)=>Math.max(e,s.injectedAt??0),0),fe),Yf=()=>d?t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("button",{type:"button",onClick:()=>dl(e=>{const s=!e;return Et(Fi,s),s}),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":Ps,children:[t.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:t.jsx(aa,{size:14})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-[12px] font-semibold text-foreground",children:o("rightSidebar.branchAuditTitle")}),t.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:ki})]}),t.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 ${Ps?"rotate-90":""}`,children:t.jsx(ps,{size:13})})]}),Ps&&t.jsxs("div",{className:"mt-2 rounded-lg border border-border/10 bg-surface/60 p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0 text-[11px] text-muted-foreground",children:[o("rightSidebar.changeAuditScopeLabel"),": ",ki]}),Vf]}),ze&&t.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:ze}),t.jsxs("div",{className:"mt-2 space-y-1.5",children:[nn.map(e=>t.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ve===e.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[t.jsxs("button",{type:"button",onClick:()=>Ff(e),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:e.repoLabel}),t.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[e.diff.hunks?.length??0," hunk"]})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:e.diff.currentBranch??"HEAD"}),t.jsx("span",{className:"text-muted-foreground/60",children:"→"}),t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:e.diff.baseRef??e.diff.baseBranch}),t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:o("rightSidebar.branchAuditViewDiff")})]}),Zs(e.createdAt,fe)&&t.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:Zs(e.createdAt,fe)})]}),t.jsx("button",{type:"button",onClick:()=>Df(e.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:o("common.delete"),"aria-label":o("common.delete"),children:t.jsx(co,{size:12})})]},e.key)),is.length>0?is.slice(0,Math.max(0,8-nn.length)).map(e=>t.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ve===e.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[t.jsxs("button",{type:"button",onClick:()=>_f(e.key),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:e.repoLabel}),t.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[e.records.length," hunk"]})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:e.branchName??"HEAD"}),t.jsx("span",{className:"text-muted-foreground/60",children:"→"}),t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:e.baseRef}),e.diffFingerprint&&t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:e.diffFingerprint})]}),Zs(e.latestInjectedAt,fe)&&t.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:o("rightSidebar.branchAuditGeneratedAt",{time:Zs(e.latestInjectedAt,fe)??""})})]}),t.jsx("button",{type:"button",onClick:()=>{Ef(e)},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:o("rightSidebar.branchAuditClearTitle"),"aria-label":o("rightSidebar.branchAuditClearTitle"),children:t.jsx(co,{size:12})})]},e.key)):nn.length===0?t.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,Xf=()=>nr&&d&&En?t.jsxs("div",{className:Za?"overflow-visible":"overflow-hidden",children:[Yf(),t.jsxs("button",{type:"button",onClick:()=>{at||Wu(e=>{const s=!e;return s&&ye&&!En&&!pn&&Zo(ye),s})},"aria-expanded":Za,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${at?"cursor-default":"rounded-lg hover:bg-surface-2 active:scale-[0.99]"}`,children:[t.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:t.jsx(xr,{size:14})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:o("rightSidebar.gitQuickActions")}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[t.jsxs("span",{className:`inline-flex items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${Pn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[pn&&t.jsx(ct,{size:10,className:"animate-spin"}),Pn.staged>0?o("rightSidebar.stagedCount",{count:Pn.staged}):o("rightSidebar.noStagedChangesShort")]}),!at&&t.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 ${Za?"rotate-90":""}`,children:t.jsx(ps,{size:13})})]})]}),Za&&t.jsxs("div",{className:"space-y-0",children:[_t.length>1&&t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsx("div",{className:"mb-2 flex items-center justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.gitRepositorySectionTitle")}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:gf})]})}),t.jsx(fs,{label:o("rightSidebar.gitRepositoryLabel"),value:ye??"",options:_t,placeholder:o("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:o("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:o("rightSidebar.gitRepositoryEmpty"),disabled:!!Be,onChange:e=>{zc(e||null)}}),Xe&&t.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:o("rightSidebar.selectRepositoryForGitActions")})]}),t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.branchSectionTitle")}),t.jsx("div",{className:"mt-0.5 h-4 truncate text-[11px] leading-4 text-muted-foreground",children:zn!==hc?hc:null})]}),t.jsxs("button",{type:"button",onClick:()=>{Gf()},disabled:!Cf,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 ${yi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.switchBranch"),children:[t.jsx("span",{className:Be?.action==="switch-branch"||yi?"opacity-0":"",children:o("rightSidebar.switchBranch")}),Be?.action==="switch-branch"&&t.jsx(ct,{size:12,className:"absolute animate-spin"}),yi&&Be?.action!=="switch-branch"&&t.jsx("span",{className:"absolute",children:"✓"})]})]}),t.jsx(fs,{label:o("rightSidebar.currentBranchLabel"),value:zn,options:yf,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),disabled:!!Be,onChange:wa})]}),t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.commitSectionTitle")}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Xe?o("rightSidebar.selectRepositoryForGitActions"):Pn.staged>0?o("rightSidebar.commitReadyHint",{count:Pn.staged}):o("rightSidebar.commitNeedsStaged")})]}),t.jsxs("button",{type:"button",onClick:()=>{Wc()},disabled:!!Be||Xe||Pn.staged===0||!va.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 ${xi?"bg-accent/10 text-accent disabled:bg-accent/10 disabled:text-accent":"bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-surface-2 disabled:text-muted-foreground"} disabled:cursor-not-allowed`,title:Xe?o("rightSidebar.selectRepositoryForGitActions"):Pn.staged===0?o("rightSidebar.commitNeedsStaged"):o("rightSidebar.commitChanges"),children:[t.jsx("span",{className:Be?.action==="commit"||xi?"opacity-0":"",children:o("rightSidebar.commitChanges")}),Be?.action==="commit"&&t.jsx(ct,{size:12,className:"absolute animate-spin"}),xi&&Be?.action!=="commit"&&t.jsx("span",{className:"absolute",children:"✓"})]})]}),t.jsx("input",{value:va,onChange:e=>yl(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key==="Enter"&&(e.preventDefault(),Wc())},placeholder:o("rightSidebar.commitMessagePlaceholder"),disabled:!!Be,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})]}),t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("button",{type:"button",onClick:()=>zr(e=>!e),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":on,children:[t.jsx("span",{className:"min-w-0 text-[12px] font-medium text-foreground",children:o("rightSidebar.recentCommitsTitle")}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[ua&&t.jsx(ct,{size:12,className:"animate-spin text-muted-foreground"}),t.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 ${on?"rotate-90":""}`,children:t.jsx(ps,{size:13})})]})]}),on&&t.jsxs("div",{className:"mt-2 space-y-2",children:[t.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:[t.jsx(ms,{size:12,className:"shrink-0"}),t.jsx("input",{value:ln,onChange:e=>cn(e.target.value),placeholder:o("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}),ln&&t.jsx("button",{type:"button",onClick:()=>cn(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:t.jsx(Qt,{size:12})})]}),t.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:bf,children:[Mt.length>0?Mt.map(e=>{const[s,...l]=e.split(/\s+/),h=l.join(" ")||e;return t.jsxs("button",{type:"button",onClick:()=>{Bf(e)},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:h,children:[t.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:s}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:h,children:h}),q[s]&&t.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${q[s]==="ahead"?"bg-accent/10 text-accent":q[s]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:o(q[s]==="ahead"?"rightSidebar.commitAhead":q[s]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),_n===s&&t.jsx(ct,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},e)}):ua?t.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:o("common.loading")}):So?null:t.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.recentCommitsEmpty")}),fa&&t.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:t.jsx(ct,{size:12,className:"animate-spin"})}),Ro&&!fa&&Mt.length>0&&t.jsx("button",{type:"button",onClick:()=>{Os({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:o("rightSidebar.recentCommitsLoadMore")})]})]}),Rs&&t.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Rs}),So&&t.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:So})]}),t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.pushSectionTitle")}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Kf()},disabled:!Rf,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 ${vi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pullChanges"),children:[t.jsx("span",{className:Be?.action==="pull"||vi?"opacity-0":"",children:o("rightSidebar.pullChanges")}),Be?.action==="pull"&&t.jsx(ct,{size:12,className:"absolute animate-spin"}),vi&&Be?.action!=="pull"&&t.jsx("span",{className:"absolute",children:"✓"})]}),t.jsxs("button",{type:"button",onClick:()=>{Wf()},disabled:!jf,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 ${wi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pushChanges"),children:[t.jsx("span",{className:Be?.action==="push"||wi?"opacity-0":"",children:o("rightSidebar.pushChanges")}),Be?.action==="push"&&t.jsx(ct,{size:12,className:"absolute animate-spin"}),wi&&Be?.action!=="push"&&t.jsx("span",{className:"absolute",children:"✓"})]})]})]}),t.jsxs("div",{className:`mb-2 flex min-w-0 items-center justify-between gap-2 rounded-md px-2 py-1.5 text-[11px] ${kc.className}`,title:ae?.upstream??void 0,children:[t.jsx("span",{className:"truncate font-medium",children:kc.text}),t.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:ae?.upstream??""})]}),t.jsxs("div",{className:`grid gap-1.5 ${yc?"grid-cols-2":"grid-cols-1"}`,children:[yc&&t.jsx(fs,{label:o("rightSidebar.pushRemoteLabel"),value:mn,options:xc,placeholder:o("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:o("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:o("rightSidebar.pushNoRemotes"),disabled:!!Be,onChange:ka}),t.jsx(fs,{label:o("rightSidebar.pushBranchLabel"),value:gn,options:vf,placeholder:o("rightSidebar.pushBranchPlaceholder",{branch:ae?.branch??"HEAD"}),searchPlaceholder:o("rightSidebar.pushBranchSearchPlaceholder"),emptyText:o("rightSidebar.pushNoBranches"),disabled:!!Be,onChange:Sa})]})]})]})]}):null,Jf=n.useCallback(e=>{const s=mt(e,d);if(!s)return[];const l=Hi(e),h=[];return e.canStage&&h.push({key:"stage-file",label:o("rightSidebar.stageFile"),onClick:()=>{bt({action:"stage-file",cwd:s,paths:[e.path]},o("rightSidebar.stageFile"),l)}}),e.canUnstage&&h.push({key:"unstage-file",label:o("rightSidebar.unstageFile"),onClick:()=>{bt({action:"unstage-file",cwd:s,paths:[e.path]},o("rightSidebar.unstageFile"),l)}}),e.canStash&&h.push({key:"stash-file",label:o("rightSidebar.stashFile"),onClick:()=>{bt({action:"stash-file",cwd:s,paths:[e.path]},o("rightSidebar.stashFile"),l)}}),e.canRestoreWorktree&&h.push({key:"restore-worktree-file",label:o("rightSidebar.restoreFile"),destructive:!0,onClick:()=>hn({kind:"restore",file:e,phrase:""})}),h},[d,bt,o]),Qf=n.useCallback(()=>{if(g){k?.();return}Mr(0),Ir.current?.slideTo(0),Tr(!1),Ht(null)},[k,g]),Vc=n.useCallback(e=>{if(ge(""),It(e),nt(null),Ht(null),j(null),Z){g&&k?.(),Mr(0),Ir.current?.slideTo(0),Tr(!1);return}},[Z,k,g,nt,It]);n.useEffect(()=>{if(!H||B.getState().pendingTerminalPath!==H)return;B.setState({pendingTerminalPath:null}),(()=>{const s=H,l=s.path;if(!l.startsWith("/"))return;ge(""),Ht(null),Rt(null);const h=!!(d&&(l===d||l.startsWith(`${d}/`)));if(s.kind==="file"){const u=lo(l);Rn(l),typeof s.line=="number"&&Number.isSafeInteger(s.line)&&s.line>0&&Rt(s.line),It(h?null:u),j({path:l,nonce:++I.current});return}nt(null),h?(It(null),j({path:l,nonce:++I.current})):(j(null),It(l)),Z&&(g&&k?.(),Mr(0),Ir.current?.slideTo(0),Tr(!1))})()},[H,Rn,Z,k,g,d,nt,It]),n.useEffect(()=>{r||(Ot(!1),Zt(!1))},[r]),n.useEffect(()=>{if(!kr&&!Zr)return;const e=s=>{s instanceof globalThis.KeyboardEvent&&s.key!=="Escape"||s instanceof globalThis.MouseEvent&&s.target instanceof Node&&($n.current?.contains(s.target)||Sr.current?.contains(s.target))||(Ot(!1),Zt(!1))};return window.addEventListener("mousedown",e),window.addEventListener("keydown",e),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("keydown",e)}},[Zr,kr]);const Yc=t.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:[t.jsxs("div",{className:"flex min-h-9 min-w-0 items-center gap-1.5",children:[t.jsx(nu,{buttonClassName:"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",parent:{onClick:hf,disabled:!_a},root:{onClick:ac,disabled:!d||Wn===d},refresh:{onClick:pf,disabled:!ne,title:vl?o("rightSidebar.fileWatchUnavailable",{message:vl}):void 0}}),t.jsx("div",{className:"min-w-0 flex-1 px-1",title:ne??void 0,children:t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[12px] font-medium text-foreground",children:[t.jsx("span",{className:"truncate",children:uf}),Pa==="modified"&&t.jsx("span",{className:"inline-flex shrink-0 text-primary",title:o("fileTree.sortedByModified"),"aria-label":o("fileTree.sortedByModified"),children:t.jsx(fd,{size:11})})]})}),t.jsx("button",{type:"button",onClick:e=>ne&&Vt(ne,Dt??void 0,e.currentTarget),disabled:!ne,...ne&&Dt?ai($a(ne),Dt):{},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition disabled:cursor-not-allowed disabled:opacity-35 active:scale-95 ${Dt&&(Oe===Dt||Se===Dt)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":o(Dt&&Se===Dt?"rightSidebar.copied":Dt&&Oe===Dt?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:o("rightSidebar.insertCurrentFolder"),children:Dt&&(Oe===Dt||Se===Dt)?t.jsx(mo,{size:13}):t.jsx(go,{size:13})}),t.jsx(tm,{rootPath:ne,disabled:!ne||!Yu||Wo,pressed:Na,saving:Wo,onToggle:()=>{if(!ne||Wo)return;const e=ne;Dl(!0),Ko(null),Xu(e,!Na).catch(()=>{const s=B.getState();(s.explorerRoot??s.rootPath)===e&&Ko(o("rightSidebar.gitIgnoreSaveFailed"))}).finally(()=>Dl(!1))}}),t.jsxs("div",{ref:Sr,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>{Ot(!1),Zt(e=>!e)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${Zr?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":Zr,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:t.jsx(ho,{size:14})}),Zr&&t.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:[t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Zt(!1),mf()},disabled:!li,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${Bs?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[Bs?t.jsx(Pi,{size:14}):t.jsx(ro,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(Bs?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Zt(!1),qu()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${Oo?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[Oo?t.jsx(Bp,{size:14}):t.jsx(Yi,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(Oo?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),t.jsxs("button",{type:"button",role:"menuitem",disabled:!ne,onClick:()=>{ne&&(Zt(!1),Vu(ne,Pa==="modified"?"name":"modified"))},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-40",children:[Pa==="modified"?t.jsx(Fh,{size:14}):t.jsx(fd,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(Pa==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),_l&&t.jsx("p",{role:"alert",className:"px-1 py-1 text-[11px] text-destructive",children:_l}),d&&(Ba.length>0||ff)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 pb-0.5 text-[11px]",children:[t.jsx("span",{className:"shrink-0 px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.pinnedFolders")}),t.jsxs("button",{type:"button",onClick:ac,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 ${ne===d?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:d,children:[t.jsx(mp,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:tt})]}),Ba.map(e=>{const s=e.path,l=e.kind==="file",h=l?Ze===s:ne===s;return t.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${h?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:s,children:[t.jsxs("button",{type:"button",onClick:()=>l?Rn(s):It(s),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[l?t.jsx(Ki,{size:10,className:"shrink-0"}):t.jsx(ro,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:xt(s)})]}),t.jsx("button",{type:"button",onClick:()=>bn(s),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":o("rightSidebar.unpinFolder",{name:xt(s)}),title:o("rightSidebar.unpinFolder",{name:xt(s)}),children:t.jsx(Qt,{size:9})})]},s)})]}),t.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"})]}),Si=n.useMemo(()=>{if(Hn===null)return null;const e=typeof navigator>"u"?void 0:navigator.language,s=Math.max(0,Math.floor(($o-Hn)/1e3)),l=new Intl.RelativeTimeFormat(e,{numeric:"auto"}),[h,u]=s<60?[-s,"second"]:s<3600?[-Math.floor(s/60),"minute"]:s<86400?[-Math.floor(s/3600),"hour"]:[-Math.floor(s/86400),"day"];return l.format(h,u)},[$o,Hn]),eo="flex min-h-10 w-full items-center gap-2.5 rounded-md px-2.5 text-left text-[12px] text-foreground transition hover:bg-surface-2 focus:bg-surface-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [@media(pointer:coarse)]:min-h-11",Xc=d&&!es?t.jsxs("button",{type:"button",role:"menuitemcheckbox",tabIndex:-1,onClick:()=>{zf(!Ho)},"aria-checked":Ho,title:o("rightSidebar.multiRepoScanTitle"),className:eo,children:[t.jsx(xr,{size:15,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"min-w-0 flex-1",children:o("rightSidebar.multiRepoScan")}),Ho&&t.jsx(mo,{size:14,className:"shrink-0 text-primary"})]}):null,Jc=d?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[Si?t.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:o("rightSidebar.gitLastUpdated",{time:Si}),children:Si}):null,t.jsx("button",{type:"button",onClick:()=>{Zn()},disabled:hr,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":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),children:t.jsx(Wi,{size:13,className:hr?"animate-spin":""})})]}):null,Zf=Wl?o("rightSidebar.changeAuditScopeAll"):kn.length===1?kn[0].relativeRoot==="."?tt:kn[0].relativeRoot||kn[0].name:`${kn.length} repos`,eh=e=>d?t.jsxs("div",{role:"none",children:[t.jsx(Wd,{menuItem:!0,open:vs,onOpenChange:s=>{rn(s),s&&e()},showScopePicker:An,selectedAll:Wl,repos:Ju,selectedRoots:ar,onToggleRepo:Af,onGenerate:async s=>{const l=await Nf("generate",s);return l!==!1&&e(),l},disabled:!d,inserted:Oe===sc,buttonLabel:o("rightSidebar.changeAuditShort"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:o("rightSidebar.insertChangeAuditPrompt"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Zf,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o("rightSidebar.changeAuditShort"),loading:Br,error:!!Er,statusTitle:Er??(Br?o("rightSidebar.changeAuditLoading"):yt.length>0?`${o("rightSidebar.changeAuditLoaded",{count:yt.length})}${qc?` · ${o("rightSidebar.changeAuditLoadedAt",{time:qc})}`:""}`:void 0)}),yt.length>0&&t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{e(),Pf()},disabled:Br||yt.length===0,className:eo,title:o("rightSidebar.clearChangeAuditTitle"),"aria-label":o("rightSidebar.clearChangeAudit"),children:[t.jsx(co,{size:15,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{children:o("rightSidebar.clearChangeAudit")})]})]}):null,ls=ir??(Ee?.available&&d&&Ae.size>0&&Ge.length<=1?{root:d,label:tt}:null),Qc=e=>t.jsxs(t.Fragment,{children:[ls&&t.jsxs("div",{role:"group","aria-label":o("rightSidebar.gitQuickActions"),children:[t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{e(),Qa("stage-all",ls.root,ls.label)},disabled:!!Be,className:eo,children:[t.jsx(zh,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stageAll")]}),t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{e(),Qa("stash-all",ls.root,ls.label)},disabled:!!Be,className:eo,children:[t.jsx(hp,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stashAll")]})]}),ls&&t.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),eh(e),Xc&&t.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Xc]}),to=t.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:[Ee?.available&&Ee.branch&&t.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:Ee.branch,children:[t.jsx(xr,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:Ee.branch})]}),lt.modified>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[lt.modified,"M"]}),lt.added>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",lt.added]}),lt.deleted>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",lt.deleted]}),lt.renamed>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[lt.renamed,"R"]}),lt.copied>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[lt.copied,"C"]}),lt.untracked>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[lt.untracked,"U"]}),lt.conflicted>0&&t.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[lt.conflicted,"!"]}),lt.other>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[lt.other,"?"]}),lt.staged>0&&t.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:o("rightSidebar.stagedCountShort",{count:lt.staged})})]});return t.jsxs(gp,{side:"right",isOpen:r,drawerWidthPx:i,onClose:c,onOpen:f,push:m,pinned:p,children:[ai.popoverNode,t.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${sf?"hidden":""}`,children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsxs("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",title:d??void 0,children:tt}),(!Z||Mo)&&Ee?.available&&Ee.branch&&t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:Ee.branch,children:[t.jsx(xr,{size:10,className:"shrink-0"}),t.jsx("span",{className:"max-w-[7rem] truncate",children:Ee.branch})]})]})}),t.jsx("button",{type:"button",onClick:()=>{const e=!te;re(e),e?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):ge("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${te?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleSearch"),title:o("common.search"),children:t.jsx(ms,{size:14})}),t.jsxs("button",{type:"button",role:"switch","aria-checked":$e,onClick:()=>{T(e=>!e),we(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${$e?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleContextDraft"),title:o("rightSidebar.contextDraftTitle"),children:[t.jsx(cp,{size:14}),!$e&&pt.trim()&&t.jsx("span",{className:"absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-primary","aria-hidden":"true"})]}),t.jsx("input",{ref:Rl,type:"file",multiple:!0,className:"hidden",onChange:e=>{const s=e.target.files;!s||s.length===0||(Fs(Array.from(s)),e.target.value="")}}),t.jsx("input",{ref:jl,type:"file",accept:"image/*",className:"hidden",onChange:e=>{const s=e.target.files?.[0];e.target.value="",s&&lf(s,e.currentTarget.closest("[data-sidebar]")??void 0)}}),S&&t.jsx("button",{type:"button",onClick:S,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${p?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o(p?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:o(p?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:p?t.jsx(Pi,{size:14}):t.jsx(ro,{size:14})}),t.jsxs("div",{ref:$n,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>{Zt(!1),Ot(e=>!e)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${kr?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":kr,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:t.jsx(ho,{size:15})}),kr&&t.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:[["architecture","computer"].map(e=>t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":sr[e],onClick:()=>of(e,!sr[e]),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[e==="architecture"?t.jsx(bd,{size:14,className:"text-muted-foreground"}):t.jsx(hd,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"flex-1",children:o(e==="architecture"?"rightSidebar.showArchitectureTab":"rightSidebar.showComputerTab")}),t.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${sr[e]?"bg-primary":"bg-surface-elevated"}`,children:t.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${sr[e]?"left-3.5":"left-0.5"}`})})]},e)),t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Wr,onClick:()=>Yl(!Wr),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[t.jsx(pd,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"flex-1",children:o("rightSidebar.showAndroidTab")}),t.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${Wr?"bg-primary":"bg-surface-elevated"}`,children:t.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${Wr?"left-3.5":"left-0.5"}`})})]}),t.jsx("div",{className:"my-1 h-px bg-border/15",role:"separator"}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Ot(!1),Rl.current?.click()},disabled:Ma,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:[Ma?t.jsx(ct,{size:14,className:"animate-spin text-muted-foreground"}):t.jsx(bp,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o("rightSidebar.uploadFiles")})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Ot(!1),jl.current?.click()},disabled:Ma,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:[Ma?t.jsx(ct,{size:14,className:"animate-spin text-muted-foreground"}):t.jsx(Gp,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o("rightSidebar.insertLocalImage")})]}),S&&t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Ot(!1),S()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${p?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[p?t.jsx(Pi,{size:14}):t.jsx(ro,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(p?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),p&&t.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":o("rightSidebar.layoutMode"),children:[t.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:o("rightSidebar.layoutMode")}),t.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",o("rightSidebar.layoutModeAuto")],["narrow",o("rightSidebar.layoutModeNarrow")],["wide",o("rightSidebar.layoutModeWide")]].map(([e,s])=>{const l=C===e;return t.jsx("button",{type:"button",role:"menuitemradio","aria-checked":l,onClick:()=>{D(e),Ot(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${l?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:s},e)})})]})]})]}),t.jsx("button",{type:"button",onClick:c,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":o("rightSidebar.close"),children:t.jsx(Qt,{size:14})})]}),te&&t.jsxs("div",{className:"mt-2 space-y-1.5 pb-0.5",children:[t.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:[t.jsx(ms,{size:12,className:"shrink-0"}),t.jsx("input",{"data-right-search":!0,type:"search",value:W,onChange:e=>ge(e.target.value),placeholder:o(z==="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}),t.jsxs("div",{className:`flex shrink-0 items-center gap-0.5 rounded-full bg-surface/70 p-0.5 font-medium ${Z?"text-[11px]":"text-[10px]"}`,children:[t.jsx("button",{type:"button",onClick:()=>Oc("name"),"aria-pressed":z==="name",className:`rounded-full px-2 transition active:scale-95 ${Z?"py-1":"py-0.5"} ${z==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeName")}),t.jsx("button",{type:"button",onClick:()=>Oc("content"),"aria-pressed":z==="content",className:`rounded-full px-2 transition active:scale-95 ${Z?"py-1":"py-0.5"} ${z==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeContent")})]}),W&&t.jsx("button",{type:"button",onClick:()=>ge(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:t.jsx(Qt,{size:12})})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.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:[t.jsx(Dh,{size:12,className:"shrink-0 text-primary"}),t.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:o("rightSidebar.searchScope")}),t.jsx("input",{"data-search-scope":!0,value:Ce,onChange:e=>ve(e.target.value),onKeyDown:e=>{e.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:o("rightSidebar.searchScopePlaceholder"),"aria-label":o("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),Ce!=="."&&t.jsx("button",{type:"button",onClick:()=>ve("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.resetSearchScope"),children:t.jsx(Qt,{size:11})})]}),t.jsxs("button",{type:"button",onClick:()=>le(e=>!e),"aria-expanded":pe,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${pe||Ls.length>0||Ie||Pe||se?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:o("rightSidebar.searchOptions"),"aria-label":o("rightSidebar.searchOptions"),children:[t.jsx(dp,{size:13}),Ls.length>0&&t.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:Ls.length})]})]}),pe&&t.jsxs("div",{className:"animate-fade-in rounded-xl bg-surface-2 p-2",children:[t.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:[t.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:o("rightSidebar.searchExclude")}),t.jsx("input",{"data-search-exclude":!0,value:he,onChange:e=>U(e.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:o("rightSidebar.searchExcludePlaceholder"),"aria-label":o("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),he&&t.jsx("button",{type:"button",onClick:()=>U(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.clearSearchExclude"),children:t.jsx(Qt,{size:11})})]}),z==="content"&&t.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":o("rightSidebar.contentSearchOptions"),children:[[Ie,()=>De(e=>!e),Dp,o("rightSidebar.matchCase")],[Pe,()=>L(e=>!e),Xp,o("rightSidebar.matchWholeWord")],[se,()=>Te(e=>!e),Kp,o("rightSidebar.useRegex")]].map(([e,s,l,h])=>t.jsxs("button",{type:"button",onClick:s,"aria-pressed":e,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${e?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[t.jsx(l,{size:12}),h]},h))})]})]}),t.jsxs("div",{className:"mt-2 grid gap-0.5 rounded-md bg-surface-2 p-0.5",style:{gridTemplateColumns:`repeat(${(es?1:3)+Number(sr.architecture)+Number(sr.computer)+Number(Wr)}, minmax(0, 1fr))`},children:[!es&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:e=>ns("git",e),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Ct==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(xr,{size:12}),o("rightSidebar.tabGit")]}),t.jsxs("button",{type:"button",onClick:e=>ns("diff",e),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Ct==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(lu,{size:12}),o("rightSidebar.tabChanges"),Ae.size>0?t.jsx("span",{className:"text-[10px] text-accent",children:Ae.size}):null]})]}),t.jsxs("button",{type:"button",onClick:e=>ns("files",e),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Ct==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(Qd,{size:12}),o("rightSidebar.tabFiles")]}),sr.architecture&&t.jsxs("button",{type:"button",onClick:e=>ns("architecture",e),className:`flex items-center justify-center gap-1 rounded px-1 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Sn?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(bd,{size:12}),o("architecture.tab")]}),sr.computer&&t.jsxs("button",{type:"button",onClick:e=>ns("computer",e),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${rs?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(hd,{size:12}),o("rightSidebar.tabComputer")]}),Wr&&t.jsxs("button",{type:"button",onClick:e=>ns("android",e),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Ct==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(pd,{size:12}),o("rightSidebar.tabAndroid")]})]}),t.jsx("div",{className:"h-2"}),bl&&t.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:bl})]}),t.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-surface",children:[t.jsx(ds,{active:at,mounted:nr,fallback:t.jsx(Oi,{slow:!1}),children:()=>Ke?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:t.jsx(jd,{items:Mf,diffViewType:Do,inlineMode:Gt,viewControls:p?zs():void 0,renderPathReference:(e,s)=>Wa(Mn(e,Ke.repoRoot??d),o(s==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle")),selectedKey:Du,onSelect:ha,emptyText:o("rightSidebar.noChanges"),mobile:Z,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o("rightSidebar.recentCommitsTitle"),headerMeta:`${Ke.headRef??""}${Ke.commits?.[0]?` · ${Ke.commits[0]}`:""}`,onClose:()=>{it(null),ha(null)},closeLabel:o("common.back"),wrap:Tt,onToggleWrap:Xa,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:Z?"stacked":"split",onInsertDiffReference:Fr,onReferenceCopied:gr,insertedReferenceKey:Oe,copiedReferenceKey:Se,onClearAuditRecord:qa})}):Ar?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:t.jsx(jd,{items:hi,diffViewType:Do,inlineMode:Gt,viewControls:p?zs():void 0,renderPathReference:(e,s)=>{const l=me?.comparisonRepos,h=l&&l.length>1?[...l].sort((y,v)=>v.label.length-y.label.length).find(y=>e===y.label||e.startsWith(`${y.label}/`)):void 0,u=h?e===h.label?h.repoRoot:Mn(e.slice(h.label.length+1),h.repoRoot):Mn(e,Ks?.repoRoot||d);return Wa(u,o(s==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle"))},selectedKey:Eo,onSelect:fn,emptyText:o(me?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:Z,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o(me?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:Ks?`${Ks.repoLabel} · ${Ks.branchName??"HEAD"} → ${Ks.baseRef}`:void 0,onClose:()=>{++A.current,Me(!1),cr(!1),tr(null)},closeLabel:o("common.back"),wrap:Tt,onToggleWrap:Xa,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:Z?"stacked":"split",onInsertDiffReference:Fr,onReferenceCopied:gr,insertedReferenceKey:Oe,copiedReferenceKey:Se,onClearAuditRecord:qa,localOptions:me?.comparisonRepos?.map(e=>({key:e.repoRoot,label:e.label,checked:e.includeUncommitted??me.includeUncommitted??!1,disabled:!(e.canIncludeUncommitted??os(e.repoRoot,e.head)),onChange:s=>{bi({refresh:!0,repoRoot:e.repoRoot,includeUncommitted:s})}})),onHunkGitAction:me?.includeUncommitted?Hf:void 0,error:ze,actionsBusy:de>0,onRefresh:()=>{bi({refresh:!0})},refreshing:Qe,refreshLabel:o("rightSidebar.branchAuditRefreshDiff"),refreshTitle:o("rightSidebar.branchAuditRefreshDiff"),walkthroughs:Lf,onWalkthroughNavigate:If,initialDetailScrollTop:me&&Ve?Ss[Ve]:void 0,onDetailScrollPositionChange:Uf,externalSwiperRef:Z?zl:void 0,onMobileSlideChange:Z?To:void 0})}):t.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:nr&&d&&En?t.jsx("div",{className:"px-3",children:Xf()}):hr?t.jsx(Oi,{slow:Ll}):xn?t.jsx(io,{message:xn,onRetry:()=>{Zn()}}):Xd(Ee)?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(d?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):Ee?.available===!1?t.jsx(io,{message:Ee.error??o("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{Zn()}}):d?t.jsx(Oi,{slow:Ll}):t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(d?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),t.jsx(ds,{active:or,mounted:Bu||or,children:()=>Z?t.jsxs(Gh,{className:"h-full min-h-0 w-full","data-file-browser-keyboard":!0,tabIndex:-1,onKeyDown:Jl,slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:e=>{Ir.current=e,e.slideTo(Ao,0)},onSlideChange:e=>{if(Mr(e.activeIndex),$s.current===e.activeIndex){$s.current=null;return}e.activeIndex===0&&(Tr(!1),Ht(null),k?.())},children:[t.jsx(gd,{className:"h-full min-h-0",children:t.jsxs("div",{ref:yn,onScroll:Xl,onDragOver:La,onDragEnter:La,onDragLeave:Zl,onDrop:ec,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[wl&&t.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:t.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:o("rightSidebar.dropToUpload")})}),!W.trim()&&Yc,t.jsx(md,{rootPath:ne??"",onFileSelect:Rn,onPathReference:Vt,getReferenceText:$a,onReferenceCopied:gr,insertedReferenceKey:Oe,copiedReferenceKey:Se,onDirectoryRoot:oc,onSearchFromDirectory:ic,onDirectoryPinToggle:lc,onFilePinToggle:cc,pinnedPaths:Cn,selectedFilePath:Ze,query:_e,searchRootPath:Bl,searchOptions:Ul,searchMode:z,onContentMatchSelect:ri,onDirectoryDropFiles:(e,s)=>Fs(s,e),revealDirectory:ce,canOpenInFileBrowser:kl,onOpenInFileBrowser:Ql})]})}),t.jsx(gd,{className:"h-full min-h-0",children:t.jsx("div",{className:"h-full overflow-hidden bg-surface",children:t.jsx(yo,{filePath:_u||Ao===1?Ze:null,active:r&&or&&Ao===1,onInsertReference:Vt,onInsertText:$r,onInsertFeature:Da,onReviewReference:Da,onReferenceCopied:gr,onClose:Qf,onDirectoryLinkOpen:Vc,isMobile:!0,lineRange:Dr,onLineRangeChange:Ht,insertedReferenceKey:Oe,copiedReferenceKey:Se,scrollToLine:He,onScrollToLineHandled:()=>Rt(null),markdownOutlineOpen:$,markdownOutlineCloseSignal:J,onOpenMarkdownOutline:N,onCloseMarkdownOutline:O,markdownImageLightboxOpen:K,markdownImageLightboxCloseSignal:X,onOpenMarkdownImageLightbox:xe,onCloseMarkdownImageLightbox:F})})})]}):t.jsxs("div",{"data-file-browser-keyboard":!0,className:"flex h-full min-h-0",tabIndex:-1,onKeyDown:Jl,children:[t.jsxs("div",{ref:yn,onScroll:Xl,onDragOver:La,onDragEnter:La,onDragLeave:Zl,onDrop:ec,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:_o},children:[wl&&t.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:t.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:o("rightSidebar.dropToUpload")})}),!W.trim()&&Yc,t.jsx(md,{rootPath:ne??"",onFileSelect:Rn,onPathReference:Vt,getReferenceText:$a,onReferenceCopied:gr,insertedReferenceKey:Oe,copiedReferenceKey:Se,onDirectoryRoot:oc,onSearchFromDirectory:ic,onDirectoryPinToggle:lc,onFilePinToggle:cc,pinnedPaths:Cn,selectedFilePath:Ze,query:_e,searchRootPath:Bl,searchOptions:Ul,searchMode:z,onContentMatchSelect:ri,onDirectoryDropFiles:(e,s)=>Fs(s,e),revealDirectory:ce,canOpenInFileBrowser:kl,onOpenInFileBrowser:Ql})]}),t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":o("rightSidebar.resizeFileTree"),title:o("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:Qu,onPointerMove:Zu,onPointerUp:Vl,onPointerCancel:Vl,onDoubleClick:()=>{Bo(el),Et(hs,el)},children:t.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"})}),t.jsx("div",{className:"min-w-0 flex-1 overflow-hidden bg-surface",children:t.jsx(yo,{filePath:Ze,active:r&&or,onInsertReference:Vt,onInsertText:$r,onInsertFeature:Da,onReviewReference:Da,onReferenceCopied:gr,onDirectoryLinkOpen:Vc,isMobile:!1,lineRange:Dr,onLineRangeChange:Ht,insertedReferenceKey:Oe,copiedReferenceKey:Se,scrollToLine:He,onScrollToLineHandled:()=>Rt(null),markdownOutlineOpen:$,markdownOutlineCloseSignal:J,onOpenMarkdownOutline:N,onCloseMarkdownOutline:O,markdownImageLightboxOpen:K,markdownImageLightboxCloseSignal:X,onOpenMarkdownImageLightbox:xe,onCloseMarkdownImageLightbox:F})})]})}),t.jsx(ds,{active:Nt,mounted:Ou||Nt,children:()=>ei?t.jsx(up,{}):Z?t.jsx(qi,{mobile:!0,backLabel:o("rightSidebar.backToChangeList"),externalSwiperRef:Qo,onMobileSlideChange:To,groups:Jt.length>0?Pc():[],mode:Nr,onModeChange:Ya,selectedKey:Ze,scrollToKey:Lc,scrollToKeyNonce:Ra.nonce,compact:!1,collapsedDirectoryKeys:ia,onToggleDirectory:Fc,onSelectFile:e=>{const s=Tn.get(e.key);s&&Va(yr(s))},renderLeading:Ec,renderTrailing:e=>{const s=Tn.get(e.key);return s?Cc(s):null},renderDirectoryTrailing:Nc,renderSubtitle:e=>{const s=Tn.get(e.key);return s?jc(s):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:e=>d&&t.jsxs("div",{className:"px-0 py-0",children:[to&&t.jsx("div",{className:"mb-2",children:to}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:"min-w-0",children:t.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.allChanges")})}),t.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[Jt.length,"/",Ae.size]})]}),t.jsxs(Sd,{actions:Qc,children:[Sc(),e,p&&zs(),Jc]},d),ir&&t.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:ir.label}),ir.branch&&t.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:ir.branch})]}),!ir&&An&&t.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:[t.jsx(xr,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:Ha?(e=>$c(e)):void 0,emptyContent:ei?null:xn&&Ae.size===0?t.jsx(io,{message:xn,onRetry:()=>{Zn()}}):Ae.size===0?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Jt.length===0?t.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:({slideToList:e})=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("button",{type:"button",onClick:e,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:o("rightSidebar.backToChangeList"),children:[t.jsx(po,{size:14}),o("rightSidebar.backToChangeList")]}),t.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-1.5",children:[p&&zs(),t.jsxs("button",{type:"button",onClick:Xa,"aria-pressed":Tt,title:o("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 ${Tt?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[t.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),t.jsx("span",{children:o(Tt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),d&&t.jsx("button",{type:"button",onClick:()=>{Zn()},disabled:hr,"aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),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 disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",children:t.jsx(Wi,{size:14,className:hr?"animate-spin":""})})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:Ac,activePane:Nt,wrap:Tt,diffViewType:Do,inlineMode:Gt,diffOptions:Uc,reloadKey:da,renderStreamBadge:e=>t.jsx(sa,{status:e}),onHunkGitAction:Hc,onInsertDiffReference:Fr,onReferenceCopied:gr,insertedReferenceKey:Oe,copiedReferenceKey:Se,onClearAuditRecord:qa,onDetailScroll:Ka}):t.jsx(qi,{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:o("rightSidebar.backToChangeList"),groups:Jt.length>0?Pc():[],mode:Nr,onModeChange:Ya,selectedKey:Ze,scrollToKey:Lc,scrollToKeyNonce:Ra.nonce,compact:!0,collapsedDirectoryKeys:ia,onToggleDirectory:Fc,onSelectFile:e=>{const s=Tn.get(e.key);s&&Va(yr(s))},renderLeading:Ec,renderTrailing:e=>{const s=Tn.get(e.key);return s?Cc(s):null},renderDirectoryTrailing:Nc,renderSubtitle:e=>{const s=Tn.get(e.key);return s?jc(s):null},aiContent:Ha?(e=>$c(e)):void 0,emptyContent:ei?null:xn&&Ae.size===0?t.jsx(io,{message:xn,onRetry:()=>{Zn()}}):Ae.size===0?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Jt.length===0?t.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderListHeader:e=>d&&t.jsxs("div",{className:"px-0 py-0",children:[to&&t.jsx("div",{className:"mb-2",children:to}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.allChanges")}),t.jsx("div",{className:"flex items-center gap-1.5",children:t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[Jt.length,"/",Ae.size]})})]}),t.jsxs(Sd,{actions:Qc,children:[Sc(),e,zs(),t.jsxs("button",{type:"button",onClick:Xa,"aria-pressed":Tt,title:o("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 ${Tt?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[t.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),t.jsx("span",{children:o(Tt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),Jc]},d),ir&&t.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:ir.label}),ir.branch&&t.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:ir.branch})]}),!ir&&An&&t.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:[t.jsx(xr,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),files:Ac,activePane:Nt,wrap:Tt,diffViewType:zt,inlineMode:Gt,diffOptions:Uc,reloadKey:da,renderStreamBadge:e=>t.jsx(sa,{status:e}),onHunkGitAction:Hc,onInsertDiffReference:Fr,onReferenceCopied:gr,insertedReferenceKey:Oe,copiedReferenceKey:Se,onClearAuditRecord:qa,onDetailScroll:Ka})}),t.jsx(ds,{active:Sn,mounted:sr.architecture&&(rf||r&&Sn),children:t.jsx(n.Suspense,{fallback:t.jsx("p",{role:"status",className:"p-4 text-sm text-muted-foreground",children:o("architecture.loading")}),children:t.jsx(Ag,{rootPath:d,active:r&&Sn,onInsertPrompt:(e,s)=>$r(e,`architecture:${d}`,s),renderSource:e=>d&&t.jsx(gb,{rootPath:d,file:e,active:r&&Sn,isMobile:Z,onInsertReference:Vt,onInsertText:$r,onReferenceCopied:gr,insertedReferenceKey:Oe,copiedReferenceKey:Se},`${e.path}:${e.line??1}`),onOpenFile:e=>{d&&(Lt("files"),It(null),ri(`${d.replace(/\/+$/,"")}/${e.path}`,e.line??1))}},d)})}),t.jsx(ds,{active:r&&rs,mounted:sr.computer&&(ef||r&&rs),children:t.jsx(n.Suspense,{fallback:t.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:o("computer.loading")}),children:t.jsx(Tg,{active:r&&rs})})}),t.jsx(ds,{active:ts,mounted:Io&&Wr,children:Hu?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[t.jsx("span",{children:o("android.splitDockedHint")}),t.jsx("button",{type:"button",onClick:()=>{ji.getState().setDock(Ai,null),ta({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:o("android.splitClose")})]}):t.jsx(Cp,{sessionId:a??null,onCloseTab:()=>Yl(!1),onInsertPrompt:async(e,s)=>{if(!await Fr("android-deps",e,void 0,s))throw new Error(o("rightSidebar.uploadReferenceRejected"))},onInsertFile:df,onRecordingComplete:cf})})]}),r&&ht&&t.jsx("div",{role:"alert",className:"shrink-0 border-t border-border/15 px-3 py-2 text-xs text-destructive",children:o("rightSidebar.referenceInsertFailed")}),r&&Ft.task&&t.jsx(Em,{task:Ft.task,onCancel:Ft.cancel,onRetry:()=>{Ft.retry()},onDismiss:Ft.dismiss,labels:{uploading:o("rightSidebar.uploadPending"),inserting:o("rightSidebar.uploadInserting"),done:o(Ft.task.kind==="image"?"rightSidebar.uploadReferenceDone":"rightSidebar.uploadDone",{count:Ft.task.uploaded.length}),failed:o("rightSidebar.uploadFailed"),canceled:o("rightSidebar.uploadCanceled"),referenceRejected:o("rightSidebar.uploadReferenceRejected"),limit:o("rightSidebar.uploadLimit"),cancel:o("common.cancel"),retry:o("common.retry"),dismiss:o("common.close"),files:o("rightSidebar.uploadFileCount",{count:Ft.task.files.length})}}),r&&$e&&t.jsx(Rm,{value:pt,collapsed:V,autoCollapseAfterSend:et,focusRequest:In,insertError:Fn?o("rightSidebar.contextDraftInsertFailed"):null,onChange:e=>{en(!1),St(e)},onCollapsedChange:we,onAutoCollapseAfterSendChange:kt,onDisable:()=>T(!1),onClear:()=>St(""),onInsert:e=>nc(!1,e),onInsertAndSend:e=>nc(!0,e),labels:{title:o("rightSidebar.contextDraftTitle"),hint:o("rightSidebar.contextDraftHint"),placeholder:o("rightSidebar.contextDraftPlaceholder"),collapse:o("rightSidebar.contextDraftCollapse"),expand:o("rightSidebar.contextDraftExpand"),disable:o("rightSidebar.contextDraftDisable"),clear:o("rightSidebar.contextDraftClear"),insert:o("rightSidebar.contextDraftInsert"),insertAndSend:o("rightSidebar.contextDraftInsertAndSend"),inserted:o("rightSidebar.contextDraftInserted"),sent:o("rightSidebar.contextDraftSent"),pending:o("rightSidebar.contextDraftPending"),send:o("rightSidebar.contextDraftSend"),appended:o("rightSidebar.contextDraftAppended"),resize:o("rightSidebar.contextDraftResize"),autoCollapseAfterSend:o("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:e=>o("rightSidebar.contextDraftCharacterCount",{count:e})}}),Sf(),gt&&typeof document<"u"&&Qr.createPortal(t.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>hn(null),children:t.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:e=>e.stopPropagation(),children:[t.jsx("div",{className:"text-sm font-semibold text-foreground",children:gt.kind==="restore"?o("rightSidebar.confirmRestoreTitle"):o("rightSidebar.confirmStashAllTitle")}),t.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:gt.kind==="restore"?o("rightSidebar.confirmRestoreDescription",{path:ru(gt.file.absolutePath,d)}):o("rightSidebar.confirmStashAllDescription")}),gt.kind==="restore"&&t.jsx("input",{value:gt.phrase,onChange:e=>hn({...gt,phrase:e.target.value}),placeholder:o("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}),t.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:()=>hn(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:o("common.cancel")}),t.jsx("button",{type:"button",disabled:!!Be||gt.kind==="restore"&>.phrase.trim()!==o("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(gt.kind==="restore"){const e=mt(gt.file,d);if(!e)return;bt({action:"restore-worktree-file",cwd:e,paths:[gt.file.path],confirm:{acknowledged:!0,phrase:gt.phrase}},o("rightSidebar.restoreFile"),Hi(gt.file))}else{const e=gt.repoRoot??d;if(!e)return;bt({action:"stash-all",cwd:e},o("rightSidebar.stashAll"),`repo:${e}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${gt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:o(Be?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const _b=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:yo,MarkdownImageLightbox:Yh,MarkdownPreview:cu,RightSidebar:bb,__testParseMarkdownListBlock:Xh,buildMarkdownPreviewBlocks:Jh,buildMarkdownPreviewRenderResult:Qh,collectKnownGitRepoRoots:Nu,computeMarkdownImageDisplayBox:Zh,getMarkdownHeadingOutline:ep,getMarkdownHeadingPathAtLine:tp,getNextMarkdownPreviewLineRange:Zg,isSvgImageSrc:rp,mountRightSidebarRepoPickerOverlay:xu,replaceGitRepositorySnapshot:$u,resolveMarkdownLocalLinkTarget:np,resolveRightSidebarDiffViewType:ju,shouldCloseMarkdownImageLightboxDrag:sp,showsGitRepoGroupHeader:tl},Symbol.toStringTag,{value:"Module"}));export{Yi as E,_b as R,Vp as S,Bp as a,rm as c,Db as m};
|