termdock 1.4.354 → 1.4.355
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/THIRD_PARTY_NOTICES.md +56 -0
- package/dist/client/assets/{AndroidMirrorView-D9CMPmet.js → AndroidMirrorView-BC_6L3mG.js} +3 -3
- package/dist/client/assets/AndroidMirrorView-BC_6L3mG.js.br +0 -0
- package/dist/client/assets/AndroidMirrorView-BC_6L3mG.js.gz +0 -0
- package/dist/client/assets/{App-CqLXOAnv.js → App-BGECv_n_.js} +36 -36
- package/dist/client/assets/App-BGECv_n_.js.br +0 -0
- package/dist/client/assets/App-BGECv_n_.js.gz +0 -0
- package/dist/client/assets/{ArchitecturePanel-Dlnd9PH-.js → ArchitecturePanel-CYdolNzT.js} +3 -3
- package/dist/client/assets/ArchitecturePanel-CYdolNzT.js.br +0 -0
- package/dist/client/assets/ArchitecturePanel-CYdolNzT.js.gz +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-mAiaX5i8.js +2 -0
- package/dist/client/assets/ChangeWalkthroughPanel-mAiaX5i8.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-mAiaX5i8.js.gz +0 -0
- package/dist/client/assets/ChatRichContent-D2NtgMuL.js +277 -0
- package/dist/client/assets/ChatRichContent-D2NtgMuL.js.br +0 -0
- package/dist/client/assets/ChatRichContent-D2NtgMuL.js.gz +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-CcHsVfXD.js +1 -0
- package/dist/client/assets/CollaborationMainWorkspace-CcHsVfXD.js.br +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-CcHsVfXD.js.gz +0 -0
- package/dist/client/assets/{CollaborationTaskContent-GMhtQgeq.js → CollaborationTaskContent-FcrGGSr_.js} +1 -1
- package/dist/client/assets/{ComputerControlView-VNUyl2Gb.js → ComputerControlView-DU9krDsg.js} +4 -4
- package/dist/client/assets/ComputerControlView-DU9krDsg.js.br +0 -0
- package/dist/client/assets/ComputerControlView-DU9krDsg.js.gz +0 -0
- package/dist/client/assets/DagPlayground-CbEuQA68.js +1 -0
- package/dist/client/assets/DagPlayground-CbEuQA68.js.br +0 -0
- package/dist/client/assets/DagPlayground-CbEuQA68.js.gz +0 -0
- package/dist/client/assets/{DiffLab-CKBHu65J.js → DiffLab-PysBkJrJ.js} +1 -1
- package/dist/client/assets/DiffLab-PysBkJrJ.js.br +0 -0
- package/dist/client/assets/DiffLab-PysBkJrJ.js.gz +0 -0
- package/dist/client/assets/DiffReview-Ce3wKMBk.js +1 -0
- package/dist/client/assets/DiffReview-Ce3wKMBk.js.br +0 -0
- package/dist/client/assets/DiffReview-Ce3wKMBk.js.gz +0 -0
- package/dist/client/assets/{DiffReviewLab--PbhIP71.js → DiffReviewLab-D6PxvtBY.js} +2 -2
- package/dist/client/assets/DiffReviewLab-D6PxvtBY.js.br +0 -0
- package/dist/client/assets/DiffReviewLab-D6PxvtBY.js.gz +0 -0
- package/dist/client/assets/{DiffViewer-Cg3GhKcU.js → DiffViewer-Bp-BLT2f.js} +1 -1
- package/dist/client/assets/DiffViewer-Bp-BLT2f.js.br +0 -0
- package/dist/client/assets/DiffViewer-Bp-BLT2f.js.gz +0 -0
- package/dist/client/assets/GitLoadingSkeleton-Fa4AXG-N.js +1 -0
- package/dist/client/assets/GitLoadingSkeleton-Fa4AXG-N.js.br +0 -0
- package/dist/client/assets/GitLoadingSkeleton-Fa4AXG-N.js.gz +0 -0
- package/dist/client/assets/{MarkdownPreview-b_bwDNcY.js → MarkdownPreview-_Z5UzhLt.js} +2 -2
- package/dist/client/assets/MarkdownPreview-_Z5UzhLt.js.br +0 -0
- package/dist/client/assets/MarkdownPreview-_Z5UzhLt.js.gz +0 -0
- package/dist/client/assets/{ModelPreview-C9nka14O.js → ModelPreview-Cl0X7I-U.js} +3 -3
- package/dist/client/assets/ModelPreview-Cl0X7I-U.js.br +0 -0
- package/dist/client/assets/ModelPreview-Cl0X7I-U.js.gz +0 -0
- package/dist/client/assets/{RecordingSaveDialog-1YvzwTzo.js → RecordingSaveDialog-Ca2iJsOW.js} +1 -1
- package/dist/client/assets/RecordingSaveDialog-Ca2iJsOW.js.br +0 -0
- package/dist/client/assets/RecordingSaveDialog-Ca2iJsOW.js.gz +0 -0
- package/dist/client/assets/{RightSidebar-CCk8ovoK.js → RightSidebar-CwXIBpEw.js} +20 -20
- package/dist/client/assets/RightSidebar-CwXIBpEw.js.br +0 -0
- package/dist/client/assets/RightSidebar-CwXIBpEw.js.gz +0 -0
- package/dist/client/assets/SessionChatView-D3sLcYAc.js +13 -0
- package/dist/client/assets/SessionChatView-D3sLcYAc.js.br +0 -0
- package/dist/client/assets/SessionChatView-D3sLcYAc.js.gz +0 -0
- package/dist/client/assets/SessionResourceSidebar-BObKJeA9.js +2 -0
- package/dist/client/assets/SessionResourceSidebar-BObKJeA9.js.br +0 -0
- package/dist/client/assets/SessionResourceSidebar-BObKJeA9.js.gz +0 -0
- package/dist/client/assets/TodoWorkspace-BdesAuz4.js +1 -0
- package/dist/client/assets/TodoWorkspace-BdesAuz4.js.br +0 -0
- package/dist/client/assets/TodoWorkspace-BdesAuz4.js.gz +0 -0
- package/dist/client/assets/{abnfDiagram-VCTEODGH-CTqKSsYV.js → abnfDiagram-VCTEODGH-BajyXVpH.js} +1 -1
- package/dist/client/assets/abnfDiagram-VCTEODGH-BajyXVpH.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-BajyXVpH.js.gz +0 -0
- package/dist/client/assets/app-C3WX_u_Z.js +37 -0
- package/dist/client/assets/app-C3WX_u_Z.js.br +0 -0
- package/dist/client/assets/app-C3WX_u_Z.js.gz +0 -0
- package/dist/client/assets/{arc-CcvWcKBR.js → arc-CbhM5I2d.js} +1 -1
- package/dist/client/assets/arc-CbhM5I2d.js.br +0 -0
- package/dist/client/assets/arc-CbhM5I2d.js.gz +0 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-B_2ae8Tt.js → architectureDiagram-5GKGNRK7-CDKLcS6D.js} +1 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CDKLcS6D.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CDKLcS6D.js.gz +0 -0
- package/dist/client/assets/{arrow-down-DaWRHIlh.js → arrow-down-Dp27yS0N.js} +1 -1
- package/dist/client/assets/{arrow-up-DE9Z7GTI.js → arrow-up-BEUQcf-s.js} +1 -1
- package/dist/client/assets/{blockDiagram-I7D4REHJ-CGXUOwJg.js → blockDiagram-I7D4REHJ-CXiIO6_W.js} +1 -1
- package/dist/client/assets/blockDiagram-I7D4REHJ-CXiIO6_W.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-CXiIO6_W.js.gz +0 -0
- package/dist/client/assets/{c4Diagram-7LVT6UL2-BSU3omYQ.js → c4Diagram-7LVT6UL2-uZ-i2eKH.js} +1 -1
- package/dist/client/assets/c4Diagram-7LVT6UL2-uZ-i2eKH.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-uZ-i2eKH.js.gz +0 -0
- package/dist/client/assets/channel-Dg7JKsqi.js +1 -0
- package/dist/client/assets/{chevron-left-ZgHOf4aC.js → chevron-left-D8ntyw2S.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-B67WsCJN.js → chunk-2Q5K7J3B-DVe3dVJR.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-B8k7JXrn.js → chunk-5VM5RSS4-BDBNKGuU.js} +1 -1
- package/dist/client/assets/{chunk-F27PBJKO-CP85XeHB.js → chunk-F27PBJKO-BP7hTwtm.js} +1 -1
- package/dist/client/assets/chunk-F27PBJKO-BP7hTwtm.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-BP7hTwtm.js.gz +0 -0
- package/dist/client/assets/{chunk-IMKFNOWR-BjTbac0d.js → chunk-IMKFNOWR-LIGuOtnb.js} +1 -1
- package/dist/client/assets/chunk-IMKFNOWR-LIGuOtnb.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-LIGuOtnb.js.gz +0 -0
- package/dist/client/assets/{chunk-JWPE2WC7-vEdRTCxh.js → chunk-JWPE2WC7-C1_iFEvk.js} +1 -1
- package/dist/client/assets/{chunk-POPQ4Y6H-BI8tSW7F.js → chunk-POPQ4Y6H-CYZsO-QL.js} +1 -1
- package/dist/client/assets/{chunk-SVP7TREG-Dde8KTpr.js → chunk-SVP7TREG-FnWYLNCS.js} +1 -1
- package/dist/client/assets/chunk-SVP7TREG-FnWYLNCS.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-FnWYLNCS.js.gz +0 -0
- package/dist/client/assets/{chunk-TICWLB2K-DIBgH5zV.js → chunk-TICWLB2K-dcOCcmQq.js} +1 -1
- package/dist/client/assets/chunk-TICWLB2K-dcOCcmQq.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-dcOCcmQq.js.gz +0 -0
- package/dist/client/assets/{chunk-XXDRQBXY-LSjj35mz.js → chunk-XXDRQBXY-B2H2Yt9G.js} +1 -1
- package/dist/client/assets/circle-Pldg1yI9.js +1 -0
- package/dist/client/assets/classDiagram-ZZMXUADV-D6QBd_IP.js +1 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-D6QBd_IP.js +1 -0
- package/dist/client/assets/{clipboard-BGpbRBdi.js → clipboard-tTkMEO1S.js} +1 -1
- package/dist/client/assets/clipboardText-BapOM7QN.js +1 -0
- package/dist/client/assets/clipboardText-BapOM7QN.js.br +0 -0
- package/dist/client/assets/clipboardText-BapOM7QN.js.gz +0 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-v4utSIkX.js → cose-bilkent-JH36ORCC-Bz38mqD8.js} +1 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-Bz38mqD8.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-Bz38mqD8.js.gz +0 -0
- package/dist/client/assets/{cynefin-OW5HDTMX-BdbtIufa.js → cynefin-OW5HDTMX-CZAa1A6y.js} +1 -1
- package/dist/client/assets/cynefin-OW5HDTMX-CZAa1A6y.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-CZAa1A6y.js.gz +0 -0
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-B9EVx2-N.js → cynefinDiagram-5FMLGOSQ-BaQnW4VG.js} +1 -1
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-BaQnW4VG.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-BaQnW4VG.js.gz +0 -0
- package/dist/client/assets/{dagre-GXQ25YYZ-Do2YjWuC.js → dagre-GXQ25YYZ-BdnT61bc.js} +1 -1
- package/dist/client/assets/dagre-GXQ25YYZ-BdnT61bc.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-BdnT61bc.js.gz +0 -0
- package/dist/client/assets/{diagram-S7CK7UJ4-BnJa3bbo.js → diagram-S7CK7UJ4-BWiF8QNc.js} +1 -1
- package/dist/client/assets/diagram-S7CK7UJ4-BWiF8QNc.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-BWiF8QNc.js.gz +0 -0
- package/dist/client/assets/{diagram-UQ7AKVKN-C09N8-nE.js → diagram-UQ7AKVKN-DLURjCFp.js} +1 -1
- package/dist/client/assets/diagram-UQ7AKVKN-DLURjCFp.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-DLURjCFp.js.gz +0 -0
- package/dist/client/assets/{diagram-VSXAHHWV-mMv3O2zK.js → diagram-VSXAHHWV-DYIcLklz.js} +1 -1
- package/dist/client/assets/diagram-VSXAHHWV-DYIcLklz.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-DYIcLklz.js.gz +0 -0
- package/dist/client/assets/{diagram-VX7I27RA-B0aepUKS.js → diagram-VX7I27RA-C9vqviXX.js} +1 -1
- package/dist/client/assets/diagram-VX7I27RA-C9vqviXX.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-C9vqviXX.js.gz +0 -0
- package/dist/client/assets/{diagram-Z3DM3KII-BstqsbCO.js → diagram-Z3DM3KII-BJuQxTkw.js} +1 -1
- package/dist/client/assets/diagram-Z3DM3KII-BJuQxTkw.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-BJuQxTkw.js.gz +0 -0
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-CPINc9LK.js → ebnfDiagram-PWID7BFC-BcbISm-z.js} +1 -1
- package/dist/client/assets/ebnfDiagram-PWID7BFC-BcbISm-z.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-BcbISm-z.js.gz +0 -0
- package/dist/client/assets/{erDiagram-RLTQ6QDP-dUgaGLHP.js → erDiagram-RLTQ6QDP-fhNpRzUG.js} +1 -1
- package/dist/client/assets/{erDiagram-RLTQ6QDP-dUgaGLHP.js.br → erDiagram-RLTQ6QDP-fhNpRzUG.js.br} +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-fhNpRzUG.js.gz +0 -0
- package/dist/client/assets/external-link-DE8Gj-da.js +1 -0
- package/dist/client/assets/{flowDiagram-HODETNUW-4ottFlnS.js → flowDiagram-HODETNUW-CVDJ_1Zu.js} +1 -1
- package/dist/client/assets/flowDiagram-HODETNUW-CVDJ_1Zu.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-CVDJ_1Zu.js.gz +0 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-CZOkoivd.js → ganttDiagram-EL5Y4UJY-Dzn-mrfe.js} +1 -1
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-Dzn-mrfe.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-Dzn-mrfe.js.gz +0 -0
- package/dist/client/assets/{git-compare-C7n2uha2.js → git-compare-Ct2eJNs4.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-kh9xx53r.js → gitGraphDiagram-WWUBYQGX-Ci-wfvCz.js} +1 -1
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-Ci-wfvCz.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-Ci-wfvCz.js.gz +0 -0
- package/dist/client/assets/index-ByrWASlZ.js +1 -0
- package/dist/client/assets/index-ByrWASlZ.js.br +0 -0
- package/dist/client/assets/index-ByrWASlZ.js.gz +0 -0
- package/dist/client/assets/{index-bfj9dYEg.css → index-DOq3vkFG.css} +1 -1
- package/dist/client/assets/index-DOq3vkFG.css.br +0 -0
- package/dist/client/assets/{index-bfj9dYEg.css.gz → index-DOq3vkFG.css.gz} +0 -0
- package/dist/client/assets/{infoDiagram-27XIBGKW-zRkMruS-.js → infoDiagram-27XIBGKW-npBmeTt7.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-DPntAz12.js → ishikawaDiagram-5VMMS53U-CCn5Ha25.js} +1 -1
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-CCn5Ha25.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-CCn5Ha25.js.gz +0 -0
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-B074bD6a.js → journeyDiagram-3NMN7TZE-CPl5oPfe.js} +1 -1
- package/dist/client/assets/journeyDiagram-3NMN7TZE-CPl5oPfe.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-CPl5oPfe.js.gz +0 -0
- package/dist/client/assets/{kanban-definition-UXKFOSKX-wPbpE7ij.js → kanban-definition-UXKFOSKX-Dmia2kLZ.js} +1 -1
- package/dist/client/assets/kanban-definition-UXKFOSKX-Dmia2kLZ.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-Dmia2kLZ.js.gz +0 -0
- package/dist/client/assets/{layout-D-nTHjVE.js → layout-B2Kz5M73.js} +1 -1
- package/dist/client/assets/layout-B2Kz5M73.js.br +0 -0
- package/dist/client/assets/layout-B2Kz5M73.js.gz +0 -0
- package/dist/client/assets/{linear-BVxgfw5H.js → linear-D2CT7wE3.js} +1 -1
- package/dist/client/assets/linear-D2CT7wE3.js.br +0 -0
- package/dist/client/assets/linear-D2CT7wE3.js.gz +0 -0
- package/dist/client/assets/{link-D-fkBp5k.js → link-x33s12VI.js} +3 -3
- package/dist/client/assets/link-x33s12VI.js.br +0 -0
- package/dist/client/assets/link-x33s12VI.js.gz +0 -0
- package/dist/client/assets/{list-tree-DKTcSR9r.js → list-tree-XBmm9il2.js} +1 -1
- package/dist/client/assets/{loader-circle-DZn9iP0u.js → loader-circle-D_nJKmMD.js} +1 -1
- package/dist/client/assets/{maximize-2-dFjMEqgh.js → maximize-2-t-zzENew.js} +1 -1
- package/dist/client/assets/{mermaid.core-D89ctjDO.js → mermaid.core-G9XIcppl.js} +5 -5
- package/dist/client/assets/mermaid.core-G9XIcppl.js.br +0 -0
- package/dist/client/assets/mermaid.core-G9XIcppl.js.gz +0 -0
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-1TrbOKNK.js → mindmap-definition-YA3MSWOX-D2OX9OkO.js} +1 -1
- package/dist/client/assets/mindmap-definition-YA3MSWOX-D2OX9OkO.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-D2OX9OkO.js.gz +0 -0
- package/dist/client/assets/{passwordBootstrap-8XHlXyYk.js → passwordBootstrap-DkTynZfV.js} +2 -2
- package/dist/client/assets/passwordBootstrap-DkTynZfV.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-DkTynZfV.js.gz +0 -0
- package/dist/client/assets/{pegDiagram-XKGWAZYB-CJYo1Bz4.js → pegDiagram-XKGWAZYB-qNjd6dbd.js} +1 -1
- package/dist/client/assets/pegDiagram-XKGWAZYB-qNjd6dbd.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-qNjd6dbd.js.gz +0 -0
- package/dist/client/assets/{pieDiagram-E7YTZNPT-DyE6_2FS.js → pieDiagram-E7YTZNPT-DcCmKDFh.js} +1 -1
- package/dist/client/assets/pieDiagram-E7YTZNPT-DcCmKDFh.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-DcCmKDFh.js.gz +0 -0
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-OgNN7-oZ.js → quadrantDiagram-AXDQQJYC-BpDzkl9h.js} +1 -1
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-BpDzkl9h.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-BpDzkl9h.js.gz +0 -0
- package/dist/client/assets/{quote-QwQvV6RF.js → quote-DeByS04O.js} +1 -1
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-Dmqw_B10.js → railroadDiagram-O6MQD6OU-DkwV8w7x.js} +1 -1
- package/dist/client/assets/railroadDiagram-O6MQD6OU-DkwV8w7x.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-DkwV8w7x.js.gz +0 -0
- package/dist/client/assets/{rdpSession-tgxFIJYE.js → rdpSession-D5NrFTav.js} +1 -1
- package/dist/client/assets/rdpSession-D5NrFTav.js.br +0 -0
- package/dist/client/assets/rdpSession-D5NrFTav.js.gz +0 -0
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-nZK7--1f.js → requirementDiagram-BXWQKSXE-BRwt5MXl.js} +1 -1
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-nZK7--1f.js.br → requirementDiagram-BXWQKSXE-BRwt5MXl.js.br} +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-BRwt5MXl.js.gz +0 -0
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-Db_TVWjx.js → sankeyDiagram-P5KCCOFB-DZ8y_gv3.js} +1 -1
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-DZ8y_gv3.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-DZ8y_gv3.js.gz +0 -0
- package/dist/client/assets/search-CDJ4fv-q.js +1 -0
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-B7TK9j0_.js → sequenceDiagram-WJ2MYXX4-CJ9lZEsN.js} +1 -1
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-CJ9lZEsN.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-CJ9lZEsN.js.gz +0 -0
- package/dist/client/assets/{settings-2-9tlRImVo.js → settings-2-DtFz7lgk.js} +1 -1
- package/dist/client/assets/{sizeCapture-INFHLROL-roX-pGgF.js → sizeCapture-INFHLROL-Dt9ZzegQ.js} +1 -1
- package/dist/client/assets/sizeCapture-INFHLROL-Dt9ZzegQ.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-Dt9ZzegQ.js.gz +0 -0
- package/dist/client/assets/{stateDiagram-D77RDMKH-BdBm0h1F.js → stateDiagram-D77RDMKH-DgeQtV3s.js} +1 -1
- package/dist/client/assets/stateDiagram-D77RDMKH-DgeQtV3s.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-DgeQtV3s.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CKS6y2rR.js +1 -0
- package/dist/client/assets/sun-CvzpsfHU.js +1 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-DUulb0LD.js → swimlanes-42K2YHIH-DHB6MQ8v.js} +1 -1
- package/dist/client/assets/swimlanes-42K2YHIH-DHB6MQ8v.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-DHB6MQ8v.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-DvUzDKPI.js +8 -0
- package/dist/client/assets/{syntaxHighlight-Bgt0lmWx.js → syntaxHighlight-DF6Q5phI.js} +1 -1
- package/dist/client/assets/syntaxHighlight-DF6Q5phI.js.br +0 -0
- package/dist/client/assets/syntaxHighlight-DF6Q5phI.js.gz +0 -0
- package/dist/client/assets/{timeline-definition-24CTP7MA-CIQuxjVB.js → timeline-definition-24CTP7MA-EqVVyv-E.js} +1 -1
- package/dist/client/assets/timeline-definition-24CTP7MA-EqVVyv-E.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-EqVVyv-E.js.gz +0 -0
- package/dist/client/assets/{triangle-alert-LpKfIn7N.js → triangle-alert--5QOrsVl.js} +1 -1
- package/dist/client/assets/{unplug-CLBg6VOD.js → unplug-BNUx6Lmk.js} +1 -1
- package/dist/client/assets/{vennDiagram-4TSXK5OY-CMRFApvJ.js → vennDiagram-4TSXK5OY-BBE17-sL.js} +1 -1
- package/dist/client/assets/vennDiagram-4TSXK5OY-BBE17-sL.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-BBE17-sL.js.gz +0 -0
- package/dist/client/assets/{videoCompression-DjyAuV3i.js → videoCompression-B09OiyP5.js} +1 -1
- package/dist/client/assets/videoCompression-B09OiyP5.js.br +0 -0
- package/dist/client/assets/videoCompression-B09OiyP5.js.gz +0 -0
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-BEb3x-zl.js → wardleyDiagram-VM6X3IG4-B4gZGXiA.js} +1 -1
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-B4gZGXiA.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-B4gZGXiA.js.gz +0 -0
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-DUvoeYl2.js → xychartDiagram-S5SC5T6Z-BDO5xF5D.js} +1 -1
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-BDO5xF5D.js.br +0 -0
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-DUvoeYl2.js.gz → xychartDiagram-S5SC5T6Z-BDO5xF5D.js.gz} +0 -0
- package/dist/client/index.html +2 -2
- package/dist/client/index.html.br +0 -0
- package/dist/client/index.html.gz +0 -0
- package/dist/client/sw.js +1 -1
- package/dist/client/sw.js.br +0 -0
- package/dist/client/sw.js.gz +0 -0
- package/dist/server/agent/chatUIPrompt.js +13 -0
- package/dist/server/agent/collaborationCli.js +8 -2
- package/dist/server/agent/collaborationPrompt.js +2 -2
- package/dist/server/agent/collaborationStore.js +17 -0
- package/dist/server/agent/sessionChatRoutes.js +23 -1
- package/dist/server/cli.js +5 -0
- package/dist/server/federation/accessPolicy.js +3 -0
- package/dist/server/federation/authorization.js +7 -3
- package/dist/server/federation/invitations.js +9 -6
- package/dist/server/federation/runtime.js +8 -1
- package/dist/server/shared/chatPresentation.js +36 -0
- package/dist/server/shared/chatUILibrary.js +26 -0
- package/dist/server/shared/sessionAppearance.js +17 -0
- package/package.json +4 -1
- package/runtime-manifest.json +4 -4
- package/dist/client/assets/AndroidMirrorView-D9CMPmet.js.br +0 -0
- package/dist/client/assets/AndroidMirrorView-D9CMPmet.js.gz +0 -0
- package/dist/client/assets/App-CqLXOAnv.js.br +0 -0
- package/dist/client/assets/App-CqLXOAnv.js.gz +0 -0
- package/dist/client/assets/ArchitecturePanel-Dlnd9PH-.js.br +0 -0
- package/dist/client/assets/ArchitecturePanel-Dlnd9PH-.js.gz +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-BYb27GTC.js +0 -2
- package/dist/client/assets/ChangeWalkthroughPanel-BYb27GTC.js.br +0 -0
- package/dist/client/assets/ChangeWalkthroughPanel-BYb27GTC.js.gz +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-BJ_pbIlW.js +0 -1
- package/dist/client/assets/CollaborationMainWorkspace-BJ_pbIlW.js.br +0 -0
- package/dist/client/assets/CollaborationMainWorkspace-BJ_pbIlW.js.gz +0 -0
- package/dist/client/assets/ComputerControlView-VNUyl2Gb.js.br +0 -0
- package/dist/client/assets/ComputerControlView-VNUyl2Gb.js.gz +0 -0
- package/dist/client/assets/DagPlayground-Bzu6gfYW.js +0 -1
- package/dist/client/assets/DagPlayground-Bzu6gfYW.js.br +0 -0
- package/dist/client/assets/DagPlayground-Bzu6gfYW.js.gz +0 -0
- package/dist/client/assets/DiffLab-CKBHu65J.js.br +0 -0
- package/dist/client/assets/DiffLab-CKBHu65J.js.gz +0 -0
- package/dist/client/assets/DiffReview-DAUBgpsh.js +0 -1
- package/dist/client/assets/DiffReview-DAUBgpsh.js.br +0 -0
- package/dist/client/assets/DiffReview-DAUBgpsh.js.gz +0 -0
- package/dist/client/assets/DiffReviewLab--PbhIP71.js.br +0 -0
- package/dist/client/assets/DiffReviewLab--PbhIP71.js.gz +0 -0
- package/dist/client/assets/DiffViewer-Cg3GhKcU.js.br +0 -0
- package/dist/client/assets/DiffViewer-Cg3GhKcU.js.gz +0 -0
- package/dist/client/assets/GitLoadingSkeleton-ieGTuTuO.js +0 -1
- package/dist/client/assets/GitLoadingSkeleton-ieGTuTuO.js.br +0 -0
- package/dist/client/assets/GitLoadingSkeleton-ieGTuTuO.js.gz +0 -0
- package/dist/client/assets/MarkdownPreview-b_bwDNcY.js.br +0 -0
- package/dist/client/assets/MarkdownPreview-b_bwDNcY.js.gz +0 -0
- package/dist/client/assets/ModelPreview-C9nka14O.js.br +0 -0
- package/dist/client/assets/ModelPreview-C9nka14O.js.gz +0 -0
- package/dist/client/assets/RecordingSaveDialog-1YvzwTzo.js.br +0 -0
- package/dist/client/assets/RecordingSaveDialog-1YvzwTzo.js.gz +0 -0
- package/dist/client/assets/RightSidebar-CCk8ovoK.js.br +0 -0
- package/dist/client/assets/RightSidebar-CCk8ovoK.js.gz +0 -0
- package/dist/client/assets/SessionChatView-DORRzcNq.js +0 -13
- package/dist/client/assets/SessionChatView-DORRzcNq.js.br +0 -0
- package/dist/client/assets/SessionChatView-DORRzcNq.js.gz +0 -0
- package/dist/client/assets/SessionResourceSidebar-De0sHmdG.js +0 -2
- package/dist/client/assets/SessionResourceSidebar-De0sHmdG.js.br +0 -0
- package/dist/client/assets/SessionResourceSidebar-De0sHmdG.js.gz +0 -0
- package/dist/client/assets/TodoWorkspace-BHHT954s.js +0 -1
- package/dist/client/assets/TodoWorkspace-BHHT954s.js.br +0 -0
- package/dist/client/assets/TodoWorkspace-BHHT954s.js.gz +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-CTqKSsYV.js.br +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-CTqKSsYV.js.gz +0 -0
- package/dist/client/assets/app-stNRNTO-.js +0 -37
- package/dist/client/assets/app-stNRNTO-.js.br +0 -0
- package/dist/client/assets/app-stNRNTO-.js.gz +0 -0
- package/dist/client/assets/arc-CcvWcKBR.js.br +0 -0
- package/dist/client/assets/arc-CcvWcKBR.js.gz +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-B_2ae8Tt.js.br +0 -0
- package/dist/client/assets/architectureDiagram-5GKGNRK7-B_2ae8Tt.js.gz +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-CGXUOwJg.js.br +0 -0
- package/dist/client/assets/blockDiagram-I7D4REHJ-CGXUOwJg.js.gz +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-BSU3omYQ.js.br +0 -0
- package/dist/client/assets/c4Diagram-7LVT6UL2-BSU3omYQ.js.gz +0 -0
- package/dist/client/assets/channel-CREmT4wq.js +0 -1
- package/dist/client/assets/chunk-F27PBJKO-CP85XeHB.js.br +0 -0
- package/dist/client/assets/chunk-F27PBJKO-CP85XeHB.js.gz +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-BjTbac0d.js.br +0 -0
- package/dist/client/assets/chunk-IMKFNOWR-BjTbac0d.js.gz +0 -0
- package/dist/client/assets/chunk-SVP7TREG-Dde8KTpr.js.br +0 -0
- package/dist/client/assets/chunk-SVP7TREG-Dde8KTpr.js.gz +0 -0
- package/dist/client/assets/chunk-TICWLB2K-DIBgH5zV.js.br +0 -0
- package/dist/client/assets/chunk-TICWLB2K-DIBgH5zV.js.gz +0 -0
- package/dist/client/assets/classDiagram-ZZMXUADV-CTHA5GVu.js +0 -1
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-CTHA5GVu.js +0 -1
- package/dist/client/assets/clipboardText-B0NK9NMn.js +0 -1
- package/dist/client/assets/clipboardText-B0NK9NMn.js.br +0 -0
- package/dist/client/assets/clipboardText-B0NK9NMn.js.gz +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-v4utSIkX.js.br +0 -0
- package/dist/client/assets/cose-bilkent-JH36ORCC-v4utSIkX.js.gz +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-BdbtIufa.js.br +0 -0
- package/dist/client/assets/cynefin-OW5HDTMX-BdbtIufa.js.gz +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-B9EVx2-N.js.br +0 -0
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-B9EVx2-N.js.gz +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-Do2YjWuC.js.br +0 -0
- package/dist/client/assets/dagre-GXQ25YYZ-Do2YjWuC.js.gz +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-BnJa3bbo.js.br +0 -0
- package/dist/client/assets/diagram-S7CK7UJ4-BnJa3bbo.js.gz +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-C09N8-nE.js.br +0 -0
- package/dist/client/assets/diagram-UQ7AKVKN-C09N8-nE.js.gz +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-mMv3O2zK.js.br +0 -0
- package/dist/client/assets/diagram-VSXAHHWV-mMv3O2zK.js.gz +0 -0
- package/dist/client/assets/diagram-VX7I27RA-B0aepUKS.js.br +0 -0
- package/dist/client/assets/diagram-VX7I27RA-B0aepUKS.js.gz +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-BstqsbCO.js.br +0 -0
- package/dist/client/assets/diagram-Z3DM3KII-BstqsbCO.js.gz +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-CPINc9LK.js.br +0 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-CPINc9LK.js.gz +0 -0
- package/dist/client/assets/erDiagram-RLTQ6QDP-dUgaGLHP.js.gz +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-4ottFlnS.js.br +0 -0
- package/dist/client/assets/flowDiagram-HODETNUW-4ottFlnS.js.gz +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CZOkoivd.js.br +0 -0
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-CZOkoivd.js.gz +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-kh9xx53r.js.br +0 -0
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-kh9xx53r.js.gz +0 -0
- package/dist/client/assets/index-bfj9dYEg.css.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-DPntAz12.js.br +0 -0
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-DPntAz12.js.gz +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-B074bD6a.js.br +0 -0
- package/dist/client/assets/journeyDiagram-3NMN7TZE-B074bD6a.js.gz +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-wPbpE7ij.js.br +0 -0
- package/dist/client/assets/kanban-definition-UXKFOSKX-wPbpE7ij.js.gz +0 -0
- package/dist/client/assets/layout-D-nTHjVE.js.br +0 -0
- package/dist/client/assets/layout-D-nTHjVE.js.gz +0 -0
- package/dist/client/assets/linear-BVxgfw5H.js.br +0 -0
- package/dist/client/assets/linear-BVxgfw5H.js.gz +0 -0
- package/dist/client/assets/link-D-fkBp5k.js.br +0 -0
- package/dist/client/assets/link-D-fkBp5k.js.gz +0 -0
- package/dist/client/assets/mermaid.core-D89ctjDO.js.br +0 -0
- package/dist/client/assets/mermaid.core-D89ctjDO.js.gz +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-1TrbOKNK.js.br +0 -0
- package/dist/client/assets/mindmap-definition-YA3MSWOX-1TrbOKNK.js.gz +0 -0
- package/dist/client/assets/passwordBootstrap-8XHlXyYk.js.br +0 -0
- package/dist/client/assets/passwordBootstrap-8XHlXyYk.js.gz +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-CJYo1Bz4.js.br +0 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-CJYo1Bz4.js.gz +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-DyE6_2FS.js.br +0 -0
- package/dist/client/assets/pieDiagram-E7YTZNPT-DyE6_2FS.js.gz +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-OgNN7-oZ.js.br +0 -0
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-OgNN7-oZ.js.gz +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-Dmqw_B10.js.br +0 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-Dmqw_B10.js.gz +0 -0
- package/dist/client/assets/rdpSession-tgxFIJYE.js.br +0 -0
- package/dist/client/assets/rdpSession-tgxFIJYE.js.gz +0 -0
- package/dist/client/assets/requirementDiagram-BXWQKSXE-nZK7--1f.js.gz +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-Db_TVWjx.js.br +0 -0
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-Db_TVWjx.js.gz +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-B7TK9j0_.js.br +0 -0
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-B7TK9j0_.js.gz +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-roX-pGgF.js.br +0 -0
- package/dist/client/assets/sizeCapture-INFHLROL-roX-pGgF.js.gz +0 -0
- package/dist/client/assets/sparkles-B64EiCUM.js +0 -1
- package/dist/client/assets/stateDiagram-D77RDMKH-BdBm0h1F.js.br +0 -0
- package/dist/client/assets/stateDiagram-D77RDMKH-BdBm0h1F.js.gz +0 -0
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-ClZ2Tfz8.js +0 -1
- package/dist/client/assets/sun-BFxiDkET.js +0 -1
- package/dist/client/assets/swimlanes-42K2YHIH-DUulb0LD.js.br +0 -0
- package/dist/client/assets/swimlanes-42K2YHIH-DUulb0LD.js.gz +0 -0
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-CGI6rSok.js +0 -8
- package/dist/client/assets/syntaxHighlight-Bgt0lmWx.js.br +0 -0
- package/dist/client/assets/syntaxHighlight-Bgt0lmWx.js.gz +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-CIQuxjVB.js.br +0 -0
- package/dist/client/assets/timeline-definition-24CTP7MA-CIQuxjVB.js.gz +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-CMRFApvJ.js.br +0 -0
- package/dist/client/assets/vennDiagram-4TSXK5OY-CMRFApvJ.js.gz +0 -0
- package/dist/client/assets/videoCompression-DjyAuV3i.js.br +0 -0
- package/dist/client/assets/videoCompression-DjyAuV3i.js.gz +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-BEb3x-zl.js.br +0 -0
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-BEb3x-zl.js.gz +0 -0
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-DUvoeYl2.js.br +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-
|
|
2
|
-
import{aR as Dr,e6 as _t,cc as t,m as po,cm as Qd,p as Gi,s as lt,F as eh,g as ds,a0 as Xt,ef as U,em as Pt,cC as ct,c as mo,bG as Zd,C as go,f as sa,W as co,e1 as Zs,e2 as Wi,X as Zc,cZ as eu,dP as th,dl as rh,b1 as nh,L as bo,R as uo,bY as sh,ao as Ws,ba as ah,e9 as tu,c4 as oh,c6 as ih,c7 as lh,c8 as ch,c5 as qs,bq as dh,E as uh,u as fh,c0 as hh,cE as ph,cH as mh,cI as gh,bT as bh,cF as ed,an as yt,ag as ru,ai as xh,j as vh,l as yh,t as Ri,ah as wh,e4 as ji,bS as td,bk as rd,bg as kh,bu as Ci,bv as nd,en as ra,b7 as Ks,bw as Sh,cs as Rh,dM as sd,bn as jh,d$ as Ch,ap as Ni,da as Nh,eg as Xr,d1 as An,aj as Ph,ak as ad,bz as Eh,ax as od,aw as Ah,bh as id,bm as Th,bs as ld,dd as Mh,a9 as cd,i as dd,G as Pi,z as ro,b as Lh,w as ud,O as fd,r as Ih,o as hd,al as $h,a1 as sl,d2 as Fh,ek as Dh,H as _h}from"./app-stNRNTO-.js";import{u as Bh,j as Ei,Z as Uh,a as nu,F as Oh,M as Hh,_ as zh,c as Gh,d as Wh,e as qh,g as Kh,f as Vh,h as Yh,r as Xh,s as Jh}from"./MarkdownPreview-b_bwDNcY.js";import{b as n,r as Qr}from"./dnd-BCFAPC0L.js";import{b as Qh,a as Zh,P as ep,d as tp,S as us,c as rp,N as pd,e as np,C as sp,G as ap,A as op}from"./GitLoadingSkeleton-ieGTuTuO.js";import{S as ip,a as md}from"./swiper-DJjq1TYT.js";import{S as lp,U as cp}from"./RecordingSaveDialog-1YvzwTzo.js";import{A as al}from"./arrow-up-DE9Z7GTI.js";import{D as qi,C as na,f as dp,n as up}from"./DiffReview-DAUBgpsh.js";import{T as fp,G as br}from"./triangle-alert-LpKfIn7N.js";import{S as aa}from"./sparkles-B64EiCUM.js";import{C as su,M as au}from"./ChangeWalkthroughPanel-BYb27GTC.js";import{R as ou,S as gd,V as hp,e as pp,M as mp,A as Ai,u as gp,g as bp,i as bd,H as xd,b as xp}from"./AndroidMirrorView-D9CMPmet.js";import{u as vp}from"./DiffViewer-Cg3GhKcU.js";import{r as yp,s as wp,l as kp,a as vd,g as Ki,b as Sp,h as Rp}from"./syntaxHighlight-Bgt0lmWx.js";import{L as yd}from"./loader-circle-DZn9iP0u.js";import{a as wd,S as kd}from"./gestureArbiter-DszagC-d.js";import{M as iu}from"./maximize-2-dFjMEqgh.js";import{L as jp}from"./list-tree-DKTcSR9r.js";import{A as Cp}from"./arrow-down-DaWRHIlh.js";import{G as lu}from"./git-compare-C7n2uha2.js";const Np=[["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"}]],Pp=Dr("case-sensitive",Np);const Ep=[["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"}]],Ap=Dr("eye-off",Ep);const Tp=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Vi=Dr("eye",Tp);const Mp=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Yi=Dr("file-text",Mp);const Lp=[["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"}]],Ip=Dr("funnel",Lp);const $p=[["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"}]],Fp=Dr("image-plus",$p);const Dp=[["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"}]],_p=Dr("regex",Dp);const Bp=[["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"}]],Up=Dr("scan",Bp);const Op=[["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"}]],Hp=Dr("whole-word",Op);function Sd({children:r,actions:a}){const{t:i}=_t(),[c,f]=n.useState(!1),p=n.useId(),g=n.useRef(null),k=n.useRef(null),m=()=>{f(!1),g.current?.focus({preventScroll:!0})};return n.useLayoutEffect(()=>{if(!c)return;const x=g.current,w=k.current;if(!x||!w)return;const R=window.visualViewport,b=()=>{const P=x.getBoundingClientRect(),$=(R?.offsetLeft??0)+8,D=(R?.offsetTop??0)+8,te=Math.max(0,(R?.width??window.innerWidth)-16),M=D+(R?.height??window.innerHeight)-16,I=Math.min(240,te),H=Math.max(0,P.top-D-6),Y=Math.max(0,M-P.bottom-6),be=w.scrollHeight>Y&&H>Y;Object.assign(w.style,{width:`${I}px`,left:`${Math.max($,Math.min(P.right-I,$+te-I))}px`,top:`${be?P.top-6:P.bottom+6}px`,maxHeight:`${be?H:Y}px`,transform:be?"translateY(-100%)":"none"})};b();const A=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return A?.observe(x),A?.observe(w),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),R?.addEventListener("resize",b),R?.addEventListener("scroll",b),()=>{A?.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0),R?.removeEventListener("resize",b),R?.removeEventListener("scroll",b)}},[c]),n.useEffect(()=>{if(!c)return;k.current?.querySelector("button:not(:disabled)")?.focus({preventScroll:!0});const x=w=>{w.target instanceof Node&&!g.current?.contains(w.target)&&!k.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:g,type:"button","aria-haspopup":"menu","aria-expanded":c,"aria-controls":c?p: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(po,{size:14}),i("sidebar.moreActions")]})]}),typeof document<"u"&&Qr.createPortal(t.jsx("div",{ref:k,id:p,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)")],R=w.indexOf(document.activeElement);let b;if(x.key==="Escape"){x.preventDefault(),x.stopPropagation(),m();return}if(x.key==="Tab"){m();return}if(x.key==="ArrowDown")b=(R+1)%w.length;else if(x.key==="ArrowUp")b=(R-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(m)}),document.body)]})}const Ti="a[href],button,input,select,textarea,[tabindex],[contenteditable],iframe,summary,audio[controls],video[controls]",is=n.memo(function({active:a,mounted:i=!0,fallback:c=null,children:f}){const p=n.useRef(null);return n.useLayoutEffect(()=>{const g=p.current;if(!g||a)return;const k=new Map,m=R=>{k.has(R)||(k.set(R,R.inert),R.inert=!0)},x=R=>{R instanceof HTMLElement&&R.matches(Ti)&&m(R),R.querySelectorAll(Ti).forEach(m)};x(g);const w=new MutationObserver(R=>{for(const b of R)b.type==="attributes"?b.target instanceof HTMLElement&&b.target.matches(Ti)&&m(b.target):b.addedNodes.forEach(A=>{A instanceof Element&&x(A)})});return w.observe(g,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex","href","contenteditable","controls"]}),()=>{w.disconnect();for(const[R,b]of k)R.inert=b}},[a,i]),t.jsx("div",{ref:p,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 zp(r){let a;try{await Promise.race([r(),new Promise(i=>{a=setTimeout(i,3e3)})])}catch{}finally{clearTimeout(a)}}function Gp({active:r,rootPath:a,loading:i,delay:c,lastStartedRoot:f,load:p}){n.useEffect(()=>{if(!r||!a||i||f.current===a)return;const g=window.setTimeout(()=>{f.current=a,p(a)},c);return()=>window.clearTimeout(g)},[r,a,i,c,f,p])}function Wp({rootPath:r,paths:a,disabled:i,onChange:c}){const{t:f}=_t(),[p,g]=n.useState(""),[k,m]=n.useState(0),[x,w]=n.useState(null),[R,b]=n.useState(!1),[A,P]=n.useState(!1),$=`${r.replace(/[\\/]+$/,"")}/${p}`;n.useEffect(()=>{const I=new AbortController;return w(null),b(!1),Qd($,I.signal,!0,"pick_git_ignore_exception").then(H=>{I.signal.aborted||w({directory:p,entries:H.entries,truncated:!!H.truncated})}).catch(()=>{I.signal.aborted||b(!0)}),()=>I.abort()},[$,p,k]);const D=I=>{w(null),b(!1),g(I)},te=x?.directory===p,M=I=>{if(I.length>200){P(!0);return}P(!1),c(I)};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("button",{type:"button",disabled:i||!p,onClick:()=>D(p.slice(0,Math.max(0,p.lastIndexOf("/")))),"aria-label":f("rightSidebar.parentFolder"),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-30",children:t.jsx(al,{size:14})}),t.jsx("button",{type:"button",disabled:i||!p,onClick:()=>D(""),"aria-label":f("rightSidebar.backToProjectRoot"),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-30",children:t.jsx(Gi,{size:14})}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:$,children:p||"./"})]}),t.jsxs("div",{className:"h-56 overflow-y-auto overscroll-contain p-1",role:"group","aria-label":f("rightSidebar.gitIgnoreExceptionsPaths"),"aria-busy":!te&&!R,children:[R?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:()=>{b(!1),m(I=>I+1)},className:"rounded-md px-3 py-2 text-primary hover:bg-surface-elevated disabled:opacity-40",children:f("common.retry")})]}):te?x.entries.length===0?t.jsx("p",{className:"p-4 text-center text-xs text-muted-foreground",children:f("rightSidebar.gitIgnoreExceptionsEmptyDirectory")}):x.entries.map(I=>{const H=p?`${p}/${I.name}`:I.name,Y=H+(I.type==="directory"?"/":""),be=a.includes(Y)||a.includes(H),_=a.some(ae=>ae.endsWith("/")&&H.startsWith(ae)),o=I.type==="directory"?Gi:eh;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:be||_,disabled:i||_,onChange:()=>M(be?a.filter(ae=>ae!==Y&&ae!==H):[...a,Y]),className:"h-4 w-4 shrink-0 accent-[var(--primary)] disabled:opacity-40"}),t.jsx(o,{size:14,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"truncate",title:I.name,children:I.name})]}),I.type==="directory"&&t.jsx("button",{type:"button",disabled:i,onClick:()=>D(H),"aria-label":f("rightSidebar.gitIgnoreExceptionsOpenDirectory",{name:I.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(ds,{size:15})})]},I.name)}):t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(lt,{size:18})}),te&&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:()=>M([]),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(I=>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:I,children:I}),t.jsx("button",{type:"button",disabled:i,onClick:()=>M(a.filter(H=>H!==I)),"aria-label":f("rightSidebar.gitIgnoreExceptionsRemove",{path:I}),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(Xt,{size:13})})]},I))}),A&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:f("rightSidebar.gitIgnoreExceptionsInvalid")})]})}function qp({rootPath:r,disabled:a,pressed:i,saving:c,onToggle:f}){const{t:p}=_t(),g=n.useId(),k=n.useRef(null),m=n.useRef(null),x=n.useRef(null),w=n.useRef(null),R=n.useRef(!1),[b,A]=n.useState(!1),[P,$]=n.useState([]),[D,te]=n.useState(!1),[M,I]=n.useState(null),H=U(W=>W.setGitIgnoreExceptions),Y=()=>{x.current!==null&&clearTimeout(x.current),x.current=null,w.current=null},be=()=>{Y(),!(a||D||!r)&&($([...U.getState().gitIgnoreExceptions[r]??[]]),I(null),A(!0))},_=()=>{D||A(!1)},o=W=>{Y(),R.current=!1,!(W.button!==0||!W.isPrimary||a)&&(W.currentTarget.setPointerCapture(W.pointerId),w.current={x:W.clientX,y:W.clientY},x.current=setTimeout(()=>{R.current=!0,be()},450))};n.useEffect(()=>(A(!1),Y(),Y),[r]),n.useEffect(()=>{if(b)return m.current?.focus(),()=>k.current?.focus()},[b]);const ae=p(i?"rightSidebar.showGitIgnoredFiles":"rightSidebar.hideGitIgnoredFiles");return t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:k,type:"button",disabled:a||D,"aria-pressed":i,"aria-label":ae,"aria-description":p("rightSidebar.gitIgnoreConfigureHint"),title:`${ae} · ${p("rightSidebar.gitIgnoreConfigureHint")}`,onClick:W=>{if(R.current&&W.detail!==0){R.current=!1,W.preventDefault();return}f()},onContextMenu:W=>{W.preventDefault(),R.current=!0,b||be()},onPointerDown:o,onPointerMove:W=>{const he=w.current;he&&Math.hypot(W.clientX-he.x,W.clientY-he.y)>10&&Y()},onPointerUp:Y,onPointerCancel:Y,onLostPointerCapture:Y,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(lt,{size:14}):t.jsx(Ip,{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:_,children:t.jsxs("form",{ref:m,role:"dialog",tabIndex:-1,"aria-modal":"true","aria-labelledby":`${g}-title`,"aria-describedby":`${g}-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(),_()),W.key==="Tab"){const he=Array.from(m.current?.querySelectorAll("button:not(:disabled), input:not(:disabled)")??[]);if(!he.length){W.preventDefault(),m.current?.focus();return}const G=he[0],le=he[he.length-1];W.shiftKey&&document.activeElement===G&&(W.preventDefault(),le?.focus()),document.activeElement===m.current?(W.preventDefault(),(W.shiftKey?le:G)?.focus()):!W.shiftKey&&document.activeElement===le&&(W.preventDefault(),G?.focus())}},onSubmit:W=>{if(W.preventDefault(),!(!r||D)){if(P.length>200){I(p("rightSidebar.gitIgnoreExceptionsInvalid"));return}te(!0),I(null),H(r,P).then(()=>A(!1)).catch(()=>I(p("rightSidebar.gitIgnoreExceptionsSaveFailed"))).finally(()=>te(!1))}},children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("h2",{id:`${g}-title`,className:"text-sm font-medium",children:p("rightSidebar.gitIgnoreExceptionsTitle")}),t.jsx("button",{type:"button",disabled:D,onClick:_,"aria-label":p("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(Xt,{size:16})})]}),t.jsx("p",{className:"truncate text-xs text-muted-foreground",title:r??void 0,children:r}),t.jsx("p",{id:`${g}-hint`,className:"text-xs leading-relaxed text-muted-foreground",children:p("rightSidebar.gitIgnoreExceptionsHint")}),t.jsx("p",{className:"text-xs font-medium",children:p("rightSidebar.gitIgnoreExceptionsPaths")}),r&&t.jsx(Wp,{rootPath:r,paths:P,onChange:$,disabled:D}),M&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:M}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",disabled:D,onClick:_,className:"rounded-lg px-3 py-2 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40",children:p("common.cancel")}),t.jsxs("button",{type:"submit",disabled:D,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:[D&&t.jsx(lt,{size:13}),p("common.save")]})]})]})}),document.body)]})}function Kp(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 p=r instanceof HTMLImageElement?1400/Math.max(c,f):Math.min(1,1400/Math.max(c,f)),g=document.createElement("canvas");g.width=Math.max(1,Math.round(c*p)),g.height=Math.max(1,Math.round(f*p));const k=g.getContext("2d");if(!k)return Promise.resolve(null);const m=getComputedStyle(document.documentElement);if(k.fillStyle=m.getPropertyValue("--surface").trim()||"white",k.fillRect(0,0,g.width,g.height),k.drawImage(r,0,0,g.width,g.height),i){const x=Math.max(10,Math.min(16,g.width/35));k.font=`${x}px sans-serif`;const w=[];let R="";for(const b of i.split(" "))R&&k.measureText(`${R} ${b}`).width>g.width-20?(w.push(R),R=b):R=R?`${R} ${b}`:b;R&&w.push(R),k.fillStyle=m.getPropertyValue("--surface").trim()||"white",k.fillRect(0,0,g.width,w.length*(x+4)+12),k.fillStyle=m.getPropertyValue("--foreground").trim()||"black",w.forEach((b,A)=>k.fillText(b,10,8+x+A*(x+4)))}if(a){const x=a.xPercent*g.width/100,w=a.yPercent*g.height/100,R=Math.max(4,Math.min(12,Math.min(g.width,g.height)*.015)),b=R*1.6;k.strokeStyle=m.getPropertyValue("--primary").trim()||"black",k.lineWidth=Math.max(1,R/3),k.beginPath(),k.arc(x,w,R,0,Math.PI*2),k.stroke(),k.beginPath(),k.moveTo(x-b,w),k.lineTo(x+b,w),k.moveTo(x,w-b),k.lineTo(x,w+b),k.stroke()}return new Promise(x=>g.toBlob(x,"image/png"))}catch{return Promise.resolve(null)}}function Vp(r,a,i,c){return[r.trim(),a.trim(),c?`截图:${c}`:""].filter(Boolean).join(`
|
|
3
|
-
`)}function
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-Cl0X7I-U.js","assets/app-C3WX_u_Z.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-Dea8wJF3.js","assets/index-DOq3vkFG.css","assets/search-CDJ4fv-q.js","assets/sun-CvzpsfHU.js","assets/list-tree-XBmm9il2.js","assets/AndroidMirrorView-BC_6L3mG.js","assets/v4-EwEgHOG0.js","assets/RecordingSaveDialog-Ca2iJsOW.js","assets/use-gesture-react.esm-DYpdiE_k.js","assets/gestureArbiter-DszagC-d.js","assets/arrow-up-BEUQcf-s.js","assets/unplug-BNUx6Lmk.js","assets/circle-Pldg1yI9.js","assets/quote-DeByS04O.js","assets/MarkdownPreview-_Z5UzhLt.js","assets/swiper-DJjq1TYT.js","assets/swiper-C2J0D0kV.css","assets/syntaxHighlight-DF6Q5phI.js","assets/GitLoadingSkeleton-Fa4AXG-N.js","assets/DiffReview-Ce3wKMBk.js","assets/DiffViewer-Bp-BLT2f.js","assets/git-compare-Ct2eJNs4.js","assets/DiffViewer-T3uj2-aP.css","assets/triangle-alert--5QOrsVl.js","assets/ChangeWalkthroughPanel-mAiaX5i8.js","assets/chevron-left-D8ntyw2S.js","assets/maximize-2-t-zzENew.js","assets/loader-circle-D_nJKmMD.js","assets/arrow-down-Dp27yS0N.js","assets/ArchitecturePanel-CYdolNzT.js","assets/link-x33s12VI.js","assets/purify.es-4eNOHKSq.js","assets/ArchitecturePanel-B_BDrrfR.css","assets/ComputerControlView-DU9krDsg.js","assets/clipboard-tTkMEO1S.js","assets/settings-2-DtFz7lgk.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{aV as Jr,ea as _t,cg as t,n as po,cq as Qd,r as Gi,u as lt,F as eh,h as ds,a4 as Xt,ej as U,V as sa,eq as Pt,cG as ct,c as mo,bK as Zd,C as go,g as aa,_ as co,e5 as Zs,e6 as Wi,$ as Zc,d1 as eu,dT as th,dq as rh,b5 as nh,L as bo,R as uo,c0 as sh,as as Ws,be as ah,ed as tu,c8 as oh,ca as ih,cb as lh,cc as ch,c9 as qs,bu as dh,E as uh,w as fh,c4 as hh,cI as ph,cL as mh,cM as gh,bX as bh,cJ as ed,ar as yt,ak as ru,am as xh,p as qi,k as vh,m as yh,v as Ri,al as wh,e8 as ji,bW as td,bo as rd,bk as kh,by as Ci,bz as nd,er as ra,bb as Ks,bA as Sh,cw as Rh,dQ as sd,br as jh,e3 as Ch,at as Ni,de as Nh,ek as Yr,d5 as An,an as Ph,ao as ad,bD as Eh,aB as od,aA as Ah,bl as id,bq as Th,bw as ld,dh as Mh,ad as cd,j as dd,I as Pi,H as ro,b as Lh,y as ud,U as fd,t as Ih,q as hd,ap as $h,a5 as sl,d6 as Fh,eo as Dh,J as _h}from"./app-C3WX_u_Z.js";import{u as Bh,j as Ei,Z as Uh,a as nu,F as Oh,M as Hh,_ as zh,c as Gh,d as Wh,e as qh,g as Kh,f as Vh,h as Yh,r as Xh,s as Jh}from"./MarkdownPreview-_Z5UzhLt.js";import{b as n,r as Qr}from"./dnd-BCFAPC0L.js";import{b as Qh,a as Zh,P as ep,d as tp,c as rp,N as pd,S as np,C as sp,G as ap,A as op}from"./GitLoadingSkeleton-Fa4AXG-N.js";import{S as ip,a as md}from"./swiper-DJjq1TYT.js";import{S as lp,U as cp}from"./RecordingSaveDialog-Ca2iJsOW.js";import{A as al}from"./arrow-up-BEUQcf-s.js";import{D as Ki,C as na,f as dp,n as up}from"./DiffReview-Ce3wKMBk.js";import{T as fp,G as br}from"./triangle-alert--5QOrsVl.js";import{C as su,M as au}from"./ChangeWalkthroughPanel-mAiaX5i8.js";import{R as ou,S as gd,V as hp,d as pp,M as mp,A as Ai,u as gp,f as bp,i as bd,H as xd,b as xp}from"./AndroidMirrorView-BC_6L3mG.js";import{u as vp}from"./DiffViewer-Bp-BLT2f.js";import{r as yp,s as wp,l as kp,a as vd,g as Vi,b as Sp,h as Rp}from"./syntaxHighlight-DF6Q5phI.js";import{L as yd}from"./loader-circle-D_nJKmMD.js";import{a as wd,S as kd}from"./gestureArbiter-DszagC-d.js";import{M as iu}from"./maximize-2-t-zzENew.js";import{L as jp}from"./list-tree-XBmm9il2.js";import{S as us}from"./search-CDJ4fv-q.js";import{A as Cp}from"./arrow-down-Dp27yS0N.js";import{G as lu}from"./git-compare-Ct2eJNs4.js";const Np=[["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"}]],Pp=Jr("case-sensitive",Np);const Ep=[["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"}]],Ap=Jr("eye-off",Ep);const Tp=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Yi=Jr("eye",Tp);const Mp=[["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"}]],Lp=Jr("funnel",Mp);const Ip=[["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"}]],$p=Jr("image-plus",Ip);const Fp=[["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"}]],Dp=Jr("regex",Fp);const _p=[["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"}]],Bp=Jr("scan",_p);const Up=[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]],Op=Jr("whole-word",Up);function Sd({children:r,actions:a}){const{t:i}=_t(),[c,f]=n.useState(!1),p=n.useId(),g=n.useRef(null),k=n.useRef(null),m=()=>{f(!1),g.current?.focus({preventScroll:!0})};return n.useLayoutEffect(()=>{if(!c)return;const x=g.current,w=k.current;if(!x||!w)return;const R=window.visualViewport,b=()=>{const P=x.getBoundingClientRect(),$=(R?.offsetLeft??0)+8,D=(R?.offsetTop??0)+8,te=Math.max(0,(R?.width??window.innerWidth)-16),M=D+(R?.height??window.innerHeight)-16,I=Math.min(240,te),H=Math.max(0,P.top-D-6),Y=Math.max(0,M-P.bottom-6),be=w.scrollHeight>Y&&H>Y;Object.assign(w.style,{width:`${I}px`,left:`${Math.max($,Math.min(P.right-I,$+te-I))}px`,top:`${be?P.top-6:P.bottom+6}px`,maxHeight:`${be?H:Y}px`,transform:be?"translateY(-100%)":"none"})};b();const A=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return A?.observe(x),A?.observe(w),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),R?.addEventListener("resize",b),R?.addEventListener("scroll",b),()=>{A?.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0),R?.removeEventListener("resize",b),R?.removeEventListener("scroll",b)}},[c]),n.useEffect(()=>{if(!c)return;k.current?.querySelector("button:not(:disabled)")?.focus({preventScroll:!0});const x=w=>{w.target instanceof Node&&!g.current?.contains(w.target)&&!k.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:g,type:"button","aria-haspopup":"menu","aria-expanded":c,"aria-controls":c?p: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(po,{size:14}),i("sidebar.moreActions")]})]}),typeof document<"u"&&Qr.createPortal(t.jsx("div",{ref:k,id:p,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)")],R=w.indexOf(document.activeElement);let b;if(x.key==="Escape"){x.preventDefault(),x.stopPropagation(),m();return}if(x.key==="Tab"){m();return}if(x.key==="ArrowDown")b=(R+1)%w.length;else if(x.key==="ArrowUp")b=(R-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(m)}),document.body)]})}const Ti="a[href],button,input,select,textarea,[tabindex],[contenteditable],iframe,summary,audio[controls],video[controls]",is=n.memo(function({active:a,mounted:i=!0,fallback:c=null,children:f}){const p=n.useRef(null);return n.useLayoutEffect(()=>{const g=p.current;if(!g||a)return;const k=new Map,m=R=>{k.has(R)||(k.set(R,R.inert),R.inert=!0)},x=R=>{R instanceof HTMLElement&&R.matches(Ti)&&m(R),R.querySelectorAll(Ti).forEach(m)};x(g);const w=new MutationObserver(R=>{for(const b of R)b.type==="attributes"?b.target instanceof HTMLElement&&b.target.matches(Ti)&&m(b.target):b.addedNodes.forEach(A=>{A instanceof Element&&x(A)})});return w.observe(g,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex","href","contenteditable","controls"]}),()=>{w.disconnect();for(const[R,b]of k)R.inert=b}},[a,i]),t.jsx("div",{ref:p,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 Hp(r){let a;try{await Promise.race([r(),new Promise(i=>{a=setTimeout(i,3e3)})])}catch{}finally{clearTimeout(a)}}function zp({active:r,rootPath:a,loading:i,delay:c,lastStartedRoot:f,load:p}){n.useEffect(()=>{if(!r||!a||i||f.current===a)return;const g=window.setTimeout(()=>{f.current=a,p(a)},c);return()=>window.clearTimeout(g)},[r,a,i,c,f,p])}function Gp({rootPath:r,paths:a,disabled:i,onChange:c}){const{t:f}=_t(),[p,g]=n.useState(""),[k,m]=n.useState(0),[x,w]=n.useState(null),[R,b]=n.useState(!1),[A,P]=n.useState(!1),$=`${r.replace(/[\\/]+$/,"")}/${p}`;n.useEffect(()=>{const I=new AbortController;return w(null),b(!1),Qd($,I.signal,!0,"pick_git_ignore_exception").then(H=>{I.signal.aborted||w({directory:p,entries:H.entries,truncated:!!H.truncated})}).catch(()=>{I.signal.aborted||b(!0)}),()=>I.abort()},[$,p,k]);const D=I=>{w(null),b(!1),g(I)},te=x?.directory===p,M=I=>{if(I.length>200){P(!0);return}P(!1),c(I)};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("button",{type:"button",disabled:i||!p,onClick:()=>D(p.slice(0,Math.max(0,p.lastIndexOf("/")))),"aria-label":f("rightSidebar.parentFolder"),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-30",children:t.jsx(al,{size:14})}),t.jsx("button",{type:"button",disabled:i||!p,onClick:()=>D(""),"aria-label":f("rightSidebar.backToProjectRoot"),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-30",children:t.jsx(Gi,{size:14})}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:$,children:p||"./"})]}),t.jsxs("div",{className:"h-56 overflow-y-auto overscroll-contain p-1",role:"group","aria-label":f("rightSidebar.gitIgnoreExceptionsPaths"),"aria-busy":!te&&!R,children:[R?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:()=>{b(!1),m(I=>I+1)},className:"rounded-md px-3 py-2 text-primary hover:bg-surface-elevated disabled:opacity-40",children:f("common.retry")})]}):te?x.entries.length===0?t.jsx("p",{className:"p-4 text-center text-xs text-muted-foreground",children:f("rightSidebar.gitIgnoreExceptionsEmptyDirectory")}):x.entries.map(I=>{const H=p?`${p}/${I.name}`:I.name,Y=H+(I.type==="directory"?"/":""),be=a.includes(Y)||a.includes(H),_=a.some(ae=>ae.endsWith("/")&&H.startsWith(ae)),o=I.type==="directory"?Gi:eh;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:be||_,disabled:i||_,onChange:()=>M(be?a.filter(ae=>ae!==Y&&ae!==H):[...a,Y]),className:"h-4 w-4 shrink-0 accent-[var(--primary)] disabled:opacity-40"}),t.jsx(o,{size:14,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"truncate",title:I.name,children:I.name})]}),I.type==="directory"&&t.jsx("button",{type:"button",disabled:i,onClick:()=>D(H),"aria-label":f("rightSidebar.gitIgnoreExceptionsOpenDirectory",{name:I.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(ds,{size:15})})]},I.name)}):t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(lt,{size:18})}),te&&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:()=>M([]),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(I=>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:I,children:I}),t.jsx("button",{type:"button",disabled:i,onClick:()=>M(a.filter(H=>H!==I)),"aria-label":f("rightSidebar.gitIgnoreExceptionsRemove",{path:I}),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(Xt,{size:13})})]},I))}),A&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:f("rightSidebar.gitIgnoreExceptionsInvalid")})]})}function Wp({rootPath:r,disabled:a,pressed:i,saving:c,onToggle:f}){const{t:p}=_t(),g=n.useId(),k=n.useRef(null),m=n.useRef(null),x=n.useRef(null),w=n.useRef(null),R=n.useRef(!1),[b,A]=n.useState(!1),[P,$]=n.useState([]),[D,te]=n.useState(!1),[M,I]=n.useState(null),H=U(W=>W.setGitIgnoreExceptions),Y=()=>{x.current!==null&&clearTimeout(x.current),x.current=null,w.current=null},be=()=>{Y(),!(a||D||!r)&&($([...U.getState().gitIgnoreExceptions[r]??[]]),I(null),A(!0))},_=()=>{D||A(!1)},o=W=>{Y(),R.current=!1,!(W.button!==0||!W.isPrimary||a)&&(W.currentTarget.setPointerCapture(W.pointerId),w.current={x:W.clientX,y:W.clientY},x.current=setTimeout(()=>{R.current=!0,be()},450))};n.useEffect(()=>(A(!1),Y(),Y),[r]),n.useEffect(()=>{if(b)return m.current?.focus(),()=>k.current?.focus()},[b]);const ae=p(i?"rightSidebar.showGitIgnoredFiles":"rightSidebar.hideGitIgnoredFiles");return t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:k,type:"button",disabled:a||D,"aria-pressed":i,"aria-label":ae,"aria-description":p("rightSidebar.gitIgnoreConfigureHint"),title:`${ae} · ${p("rightSidebar.gitIgnoreConfigureHint")}`,onClick:W=>{if(R.current&&W.detail!==0){R.current=!1,W.preventDefault();return}f()},onContextMenu:W=>{W.preventDefault(),R.current=!0,b||be()},onPointerDown:o,onPointerMove:W=>{const he=w.current;he&&Math.hypot(W.clientX-he.x,W.clientY-he.y)>10&&Y()},onPointerUp:Y,onPointerCancel:Y,onLostPointerCapture:Y,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(lt,{size:14}):t.jsx(Lp,{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:_,children:t.jsxs("form",{ref:m,role:"dialog",tabIndex:-1,"aria-modal":"true","aria-labelledby":`${g}-title`,"aria-describedby":`${g}-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(),_()),W.key==="Tab"){const he=Array.from(m.current?.querySelectorAll("button:not(:disabled), input:not(:disabled)")??[]);if(!he.length){W.preventDefault(),m.current?.focus();return}const G=he[0],le=he[he.length-1];W.shiftKey&&document.activeElement===G&&(W.preventDefault(),le?.focus()),document.activeElement===m.current?(W.preventDefault(),(W.shiftKey?le:G)?.focus()):!W.shiftKey&&document.activeElement===le&&(W.preventDefault(),G?.focus())}},onSubmit:W=>{if(W.preventDefault(),!(!r||D)){if(P.length>200){I(p("rightSidebar.gitIgnoreExceptionsInvalid"));return}te(!0),I(null),H(r,P).then(()=>A(!1)).catch(()=>I(p("rightSidebar.gitIgnoreExceptionsSaveFailed"))).finally(()=>te(!1))}},children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("h2",{id:`${g}-title`,className:"text-sm font-medium",children:p("rightSidebar.gitIgnoreExceptionsTitle")}),t.jsx("button",{type:"button",disabled:D,onClick:_,"aria-label":p("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(Xt,{size:16})})]}),t.jsx("p",{className:"truncate text-xs text-muted-foreground",title:r??void 0,children:r}),t.jsx("p",{id:`${g}-hint`,className:"text-xs leading-relaxed text-muted-foreground",children:p("rightSidebar.gitIgnoreExceptionsHint")}),t.jsx("p",{className:"text-xs font-medium",children:p("rightSidebar.gitIgnoreExceptionsPaths")}),r&&t.jsx(Gp,{rootPath:r,paths:P,onChange:$,disabled:D}),M&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:M}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",disabled:D,onClick:_,className:"rounded-lg px-3 py-2 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40",children:p("common.cancel")}),t.jsxs("button",{type:"submit",disabled:D,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:[D&&t.jsx(lt,{size:13}),p("common.save")]})]})]})}),document.body)]})}function qp(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 p=r instanceof HTMLImageElement?1400/Math.max(c,f):Math.min(1,1400/Math.max(c,f)),g=document.createElement("canvas");g.width=Math.max(1,Math.round(c*p)),g.height=Math.max(1,Math.round(f*p));const k=g.getContext("2d");if(!k)return Promise.resolve(null);const m=getComputedStyle(document.documentElement);if(k.fillStyle=m.getPropertyValue("--surface").trim()||"white",k.fillRect(0,0,g.width,g.height),k.drawImage(r,0,0,g.width,g.height),i){const x=Math.max(10,Math.min(16,g.width/35));k.font=`${x}px sans-serif`;const w=[];let R="";for(const b of i.split(" "))R&&k.measureText(`${R} ${b}`).width>g.width-20?(w.push(R),R=b):R=R?`${R} ${b}`:b;R&&w.push(R),k.fillStyle=m.getPropertyValue("--surface").trim()||"white",k.fillRect(0,0,g.width,w.length*(x+4)+12),k.fillStyle=m.getPropertyValue("--foreground").trim()||"black",w.forEach((b,A)=>k.fillText(b,10,8+x+A*(x+4)))}if(a){const x=a.xPercent*g.width/100,w=a.yPercent*g.height/100,R=Math.max(4,Math.min(12,Math.min(g.width,g.height)*.015)),b=R*1.6;k.strokeStyle=m.getPropertyValue("--primary").trim()||"black",k.lineWidth=Math.max(1,R/3),k.beginPath(),k.arc(x,w,R,0,Math.PI*2),k.stroke(),k.beginPath(),k.moveTo(x-b,w),k.lineTo(x+b,w),k.moveTo(x,w-b),k.lineTo(x,w+b),k.stroke()}return new Promise(x=>g.toBlob(x,"image/png"))}catch{return Promise.resolve(null)}}function Kp(r,a,i,c){return[r.trim(),a.trim(),c?`截图:${c}`:""].filter(Boolean).join(`
|
|
3
|
+
`)}function Eb(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 Vp(r,a,i,c){if(!i?.snapshot)return c.isCurrent()?await c.insert(r,a):!1;const f=new Date().toISOString(),p=new AbortController;let g,k;try{k=await Promise.race([(async()=>{const m=await i.snapshot;if(!(!m||p.signal.aborted||!c.isCurrent()))return c.upload(new File([m],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),p.signal)})(),new Promise(m=>{g=setTimeout(()=>{p.abort(),m(void 0)},3e3)})])}catch{}finally{clearTimeout(g),p.abort()}return c.isCurrent()?await c.insert(k?Kp(r,"",f,k):r,a):!1}function Yp(r,a){return r===a||a.endsWith(`/${r}`)||r.endsWith(`/${a}`)}function Rd(r,a){return`${r??""}\0${a}`}function Xp(r,a,i){if(!r||r.length===0||!i)return{explained:0,stale:0};const c=Rd(a,i);let f=0,p=0;for(const g of r){const k=[g.filePath,g.newPath,g.oldPath].filter(x=>typeof x=="string"&&x.length>0);(k.some(x=>Rd(g.repoRoot,x)===c)||k.some(x=>Yp(x,i)))&&(f+=1)}return{explained:f,stale:p}}function Jp({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(fp,{size:10}):t.jsx(sa,{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(Jp,{status:a})]})}const cu="termdock:right-sidebar:diff-change-list-mode:v1";function Qp(r){return r==="list"||r==="tree"}function Zp(){return ct(cu,Qp)??"tree"}function em(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 tm(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=em(c.items);return i}function rm(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 nm(r,a){const i=r.filter(p=>p.trim().length>0);if(i.length<=1)return i[0]??"";const c=[],f=new Set;for(const[p,g]of i.entries()){const k=g.split(`
|
|
4
4
|
`),m=k.findIndex(R=>R.startsWith("@@ "));if(m<0){c.push(...k);continue}p===0&&c.push(...k.slice(0,m));const x=a[p];let w=m;for(;w>=0&&w<k.length;){const R=k.findIndex((te,M)=>M>w&&te.startsWith("@@ ")),b=R>=0?R:k.length,A=k.slice(w,b),P=A[0]??"",$=x?P===x:!0,D=P||x||A.join(`
|
|
5
5
|
`);$&&!f.has(D)&&(c.push(...A),f.add(D)),w=R}}return c.join(`
|
|
6
|
-
`)}function
|
|
7
|
-
`)[0]??"",F=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";n.useEffect(()=>(M.current=!0,()=>{M.current=!1,o.current!==null&&window.clearTimeout(o.current),ae.current!==null&&window.clearTimeout(ae.current)}),[]),n.useEffect(()=>{let E=!1;const xe=Mi();return Zd().then(ge=>{if(E)return;const De=ge.contextDraftHeight?.[xe]??null;Cd(xe,De),_.current=De,be(De)}).catch(()=>{}),()=>{E=!0}},[]),n.useEffect(()=>{if(c!==void 0&&c>0){const E=he.current;if(!E)return;no()||E.focus(),E.setSelectionRange(E.value.length,E.value.length),E.scrollTop=E.scrollHeight}},[c]),n.useEffect(()=>{const E=W.current;W.current=r,!(!a||r.length<=E.length)&&(H(!0),ae.current!==null&&window.clearTimeout(ae.current),ae.current=window.setTimeout(()=>{ae.current=null,H(!1)},
|
|
6
|
+
`)}function sm({groups:r,onInsertDiffReference:a}){return r.map(i=>{const c=nm(i.items.map(m=>m.hunk.diff||m.current?.diff||m.stale?.diff||""),i.items.map(m=>m.hunk.hunkHeader)),f=i.items.map(m=>m.current??m.stale).filter(m=>!!m).map(m=>({id:m.id,repoRoot:m.repoRoot,filePath:m.filePath,oldPath:m.oldPath,newPath:m.newPath,hunkHeader:m.hunkHeader,hunkIndex:m.hunkIndex,fingerprint:m.fingerprint,diff:m.diff,explanation:m.explanation,summary:m.summary,workspaceRoot:m.workspaceRoot,generatedBy:m.generatedBy,injectedAt:m.injectedAt})),p=i.filePath.split("/").pop()??i.filePath,g=i.filePath.includes("/")?i.filePath.slice(0,-p.length-1):"",k=i.items[0]?.repoRoot??f[0]?.repoRoot??null;return{key:i.key,path:i.filePath,oldPath:i.items[0]?.hunk.oldPath??void 0,absolutePath:k?`${k}/${i.items[0]?.repositoryPath??i.filePath}`:i.filePath,status:i.changeType,repoRoot:k,displayName:p,displayDir:g,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(m=>m.hunk.previewRevert?[[m.hunk.hunkHeader,m.hunk.previewRevert]]:[])),auditRecords:f,onInsertDiffReference:a}})}function am(r,a,i){const c=Array.from(r.querySelectorAll("[data-diff-stream-item]"));if(c.length===0)return null;const p=r.getBoundingClientRect().top+48;let g=null,k=Number.POSITIVE_INFINITY;for(const x of c){const w=x.getBoundingClientRect();if(w.bottom<p)continue;const R=Math.abs(w.top-p);R<k&&(g=x,k=R)}const m=g?.dataset.diffSelectionPath??g?.dataset.diffStreamItem??null;return!m||m===a||i(m),m}function jd({items:r,selectedKey:a,onSelect:i,emptyText:c,mobile:f=!1,backLabel:p="Back",headerTitle:g,headerMeta:k,onClose:m,closeLabel:x="Back",wrap:w=!0,diffViewType:R,inlineMode:b,viewControls:A,onToggleWrap:P,wrapTitle:$,wrapOnLabel:D="Wrap on",wrapOffLabel:te="Wrap off",desktopLayout:M="split",onInsertDiffReference:I,onReferenceCopied:H,renderPathReference:Y,insertedReferenceKey:be,copiedReferenceKey:_,onClearAuditRecord:o,onRefresh:ae,localOptions:W,onHunkGitAction:he,error:G,refreshing:le,actionsBusy:j,refreshLabel:F,refreshTitle:ee,walkthroughs:C=[],onWalkthroughNavigate:L,initialDetailScrollTop:q,onDetailScrollPositionChange:ne,scrollToKey:pe,scrollToKeyNonce:Ne,externalSwiperRef:we,onMobileSlideChange:Pe}){const{t:O}=_t(),ue=n.useMemo(()=>tm(r),[r]),oe=n.useMemo(()=>new Map(ue.map(V=>[V.key,V])),[ue]),[Fe,Ie]=n.useState(()=>Zp()),[E,xe]=n.useState(()=>new Set),[ge,De]=n.useState({key:null,nonce:0}),Ve=ue.find(V=>V.explained>0||V.stale>0)?.key??ue[0]?.key??null,Ae=a&&ue.some(V=>V.key===a)?a:Ve,Jt=n.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:ue.map(rm)}],[ue]),Be=n.useMemo(()=>sm({groups:ue,onInsertDiffReference:I}),[ue,I]),ft=n.useRef(Ve),Ue=n.useRef(i);ft.current=Ve,Ue.current=i,n.useEffect(()=>{!a&&ft.current&&Ue.current(ft.current)},[a]);const Qt=P?t.jsxs("button",{type:"button",onClick:P,"aria-pressed":w,title:$,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?D:te})]}):null,me=W?.map(V=>t.jsxs("label",{title:V.disabled?O("rightSidebar.includeUncommittedCurrentBranchOnly"):V.key,className:"inline-flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[t.jsx("input",{type:"checkbox",checked:V.checked,disabled:le||j||V.disabled&&!V.checked,onChange:ye=>V.onChange(ye.target.checked),className:"accent-primary"}),t.jsxs("span",{children:[V.label," · ",O("rightSidebar.includeUncommitted"),V.disabled&&t.jsx("span",{className:"block text-[10px]",children:O("rightSidebar.includeUncommittedCurrentBranchOnly")})]})]},V.key)),dt=G?t.jsx("div",{role:"alert",className:"w-full text-xs text-destructive",children:G}):null,at=ae?t.jsxs("button",{type:"button",onClick:ae,disabled:le||j,title:ee??F,"aria-label":ee??F,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:le?"animate-spin":""}),F&&t.jsx("span",{children:F})]}):null,bt=V=>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:[g&&t.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:g}),k&&t.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:k})]}),m&&t.jsxs("button",{type:"button",onClick:m,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(mo,{size:14}),x]})]}),t.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[V,me,at,A,Qt,dt]})]});if(r.length===0){const V=t.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:c});return!g&&!m?V:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[bt(null),V]})}const Oe=P||ae?({slideToList:V})=>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:V,children:[t.jsx(mo,{size:14}),p]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[me,at,A,P&&t.jsxs("button",{type:"button",onClick:P,"aria-pressed":w,title:$,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?D:te})]})]}),dt]}):void 0;return t.jsx(Ki,{mobile:f,preserveScrollOnUpdate:!!W?.length,desktopLayout:M,backLabel:p,groups:Jt,selectedKey:Ae,mode:Fe,onModeChange:V=>{Ie(V),V!=="ai"&&Pt(cu,V)},compact:f,collapsedDirectoryKeys:E,onToggleDirectory:V=>{xe(ye=>{const Ze=new Set(ye);return Ze.has(V)?Ze.delete(V):Ze.add(V),Ze})},onSelectFile:V=>{i(V.key),De(ye=>({key:V.key,nonce:ye.nonce+1}))},renderLeading:V=>{const ye=oe.get(V.key);return t.jsx(Xi,{changeStatus:V.status,auditStatus:ye,renderChangeBadge:Ze=>t.jsx(na,{status:Ze})})},renderTrailing:V=>{const ye=oe.get(V.key);return t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[ye&&t.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",ye.additions," -",ye.deletions]}),Y?.(V.path,"file")]})},renderDirectoryTrailing:V=>Y?.(V,"directory"),renderListHeader:bt,aiContent:({slideToDetail:V,fullscreen:ye,toggleFullscreen:Ze})=>C.length>0&&L?t.jsx(su,{walkthroughs:C,repoRoot:C[0]?.repoRoot,fullscreen:ye,onToggleFullscreen:Ze,onNavigate:wt=>{f&&window.requestAnimationFrame(V),L(wt)}}):t.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:O("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:Oe,externalSwiperRef:we,onMobileSlideChange:Pe,detailContainerClassName:f?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:q,scrollToKey:pe??ge.key,scrollToKeyNonce:pe==null?ge.nonce:Ne,onDetailScroll:V=>{am(V,Ae,i),ne?.(V.scrollTop)},files:Be,activePane:!0,wrap:w,diffViewType:R,inlineMode:b,renderStreamBadge:(V,ye)=>{const Ze=oe.get(ye.key);return t.jsx(Xi,{changeStatus:V,auditStatus:Ze,renderChangeBadge:wt=>t.jsx(na,{status:wt})})},onInsertDiffReference:I,onReferenceCopied:H,insertedReferenceKey:be,copiedReferenceKey:_,onClearAuditRecord:o,onHunkGitAction:le?void 0:he,emptyContent:t.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:c})})}function om(r){return r.replace(/\/+$/,"")||"/"}function im(r){return[...new Set(Array.from(r,om))].sort((a,i)=>a.localeCompare(i))}function lm(r){return r==="event-storm"||r==="reconnected"||r==="directory-rescan"||r==="polling-fallback"}function cm(r){let a=null;return{applicableEvents:r.filter(c=>{const f=c.type==="rescan-required"&&!lm(c.reason);return f&&c.reason&&!a&&(a=c.reason),!f}),unavailableReason:a}}const dm=1400,um=1200,du=44,fm=.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 hm(r){try{const a=window.localStorage.getItem(Ji(r)),i=a===null?NaN:Number(a);return Number.isFinite(i)&&i>=du?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 pm({value:r,collapsed:a,labels:i,focusRequest:c,insertError:f,autoCollapseAfterSend:p,onChange:g,onCollapsedChange:k,onAutoCollapseAfterSendChange:m,onDisable:x,onClear:w,onInsert:R,onInsertAndSend:b}){const[A,P]=n.useState(null),[$,D]=n.useState(!1),te=n.useRef(!1),M=n.useRef(!0),[I,H]=n.useState(!1),[Y,be]=n.useState(()=>hm(Mi())),_=n.useRef(Y),o=n.useRef(null),ae=n.useRef(null),W=n.useRef(r),he=n.useRef(null),G=n.useRef(null),le=!!r.trim(),j=r.trim().split(`
|
|
7
|
+
`)[0]??"",F=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";n.useEffect(()=>(M.current=!0,()=>{M.current=!1,o.current!==null&&window.clearTimeout(o.current),ae.current!==null&&window.clearTimeout(ae.current)}),[]),n.useEffect(()=>{let E=!1;const xe=Mi();return Zd().then(ge=>{if(E)return;const De=ge.contextDraftHeight?.[xe]??null;Cd(xe,De),_.current=De,be(De)}).catch(()=>{}),()=>{E=!0}},[]),n.useEffect(()=>{if(c!==void 0&&c>0){const E=he.current;if(!E)return;no()||E.focus(),E.setSelectionRange(E.value.length,E.value.length),E.scrollTop=E.scrollHeight}},[c]),n.useEffect(()=>{const E=W.current;W.current=r,!(!a||r.length<=E.length)&&(H(!0),ae.current!==null&&window.clearTimeout(ae.current),ae.current=window.setTimeout(()=>{ae.current=null,H(!1)},um))},[r,a]),n.useEffect(()=>{if(a)return;const E=he.current;E&&(E.style.height=Y!==null?`${Y}px`:"")},[r,a,Y]),n.useEffect(()=>{if(a)return;const E=he.current;!E||document.activeElement===E||(E.scrollTop=E.scrollHeight)},[r,a]),n.useEffect(()=>{if(a||no())return;const E=he.current;!E||document.activeElement===E||(E.focus(),E.setSelectionRange(E.value.length,E.value.length))},[a]);const ee=n.useRef(null);n.useLayoutEffect(()=>{if(!no())return;const E=window.visualViewport;if(!E)return;const xe=()=>{const ge=ee.current;if(!ge)return;if(E.height>=window.innerHeight*.75){ge.style.transform="";return}const De=ge.getBoundingClientRect(),Ve=Math.round(E.height-De.bottom);ge.style.transform=Ve!==0?`translateY(${Ve}px)`:""};return xe(),E.addEventListener("resize",xe),E.addEventListener("scroll",xe),()=>{E.removeEventListener("resize",xe),E.removeEventListener("scroll",xe),ee.current&&(ee.current.style.transform="")}},[a]);const C=E=>{P(E),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{o.current=null,P(null)},dm)},L=E=>{k(!1),no()&&window.requestAnimationFrame(()=>{const xe=he.current;if(!xe)return;xe.focus();const ge=xe.value.length;xe.setSelectionRange(ge,ge),window.requestAnimationFrame(()=>{xe.setSelectionRange(ge,ge)})})},q=async(E,xe)=>{if(!(!le||te.current)){te.current=!0,D(!0),P(null);try{await(E==="sent"?b(xe):R(xe))&&M.current&&C(E)}catch{}finally{te.current=!1,M.current&&D(!1)}}},ne=E=>{q("inserted",E.currentTarget)},pe=E=>{q("sent",E.currentTarget)},Ne=E=>{if(E.key==="Escape"){E.preventDefault(),k(!0);return}E.nativeEvent.isComposing||E.keyCode===229||E.key!=="Enter"||!E.metaKey&&!E.ctrlKey||(E.preventDefault(),pe(E))},we=E=>{E.preventDefault()},Pe=E=>{E.preventDefault();const xe=he.current;xe&&(G.current={startY:E.clientY,startHeight:xe.getBoundingClientRect().height},E.currentTarget.setPointerCapture?.(E.pointerId))},O=E=>{const xe=G.current;if(!xe)return;const ge=window.visualViewport?.height??window.innerHeight,De=Math.round(Math.min(Math.max(xe.startHeight+(xe.startY-E.clientY),du),ge*fm));_.current=De,be(De)},ue=E=>{const xe=Mi();Cd(xe,E),Zs({contextDraftHeight:{[xe]:E}}).catch(()=>{})},oe=()=>{G.current&&(G.current=null,_.current!==null&&ue(_.current))},Fe=()=>{_.current=null,be(null),ue(null)},Ie=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:ee,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:()=>L(),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(Qh,{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":I?"text-primary":le?"text-foreground/80":"text-muted-foreground/50"}`,children:f??(I?i.appended:le?j:i.title)})]}),Ie,t.jsx("button",{type:"button",onClick:pe,disabled:!le||$,"aria-busy":$,className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-30 ${le?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground"}`,"aria-label":i.send,title:i.send,children:$?t.jsx(yd,{size:12,className:"animate-spin"}):A==="sent"?t.jsx(go,{size:12}):t.jsx(gd,{size:12})})]})}):t.jsxs("section",{ref:ee,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:Pe,onPointerMove:O,onPointerUp:oe,onPointerCancel:oe,onDoubleClick:Fe,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:we,onClick:()=>k(!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(aa,{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}),Ie]}),t.jsx("button",{type:"button",role:"switch","aria-checked":p,onPointerDown:we,onClick:()=>m(!p),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 ${p?"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 ${p?"translate-x-2.5":"translate-x-0.5"}`})})}),t.jsx("button",{type:"button",onPointerDown:we,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(Xt,{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:he,value:r,onChange:E=>g(E.target.value),onKeyDown:Ne,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:we,onClick:w,disabled:!le,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:we,onClick:ne,disabled:!le||$,"aria-busy":$,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(Zh,{size:11}),t.jsx("span",{children:$?i.pending??i.insert:A==="inserted"?i.inserted:i.insert})]}),t.jsxs("button",{type:"button",onPointerDown:we,onClick:pe,disabled:!le||$,"aria-busy":$,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} · ${F}`,children:[$?t.jsx(yd,{size:11,className:"animate-spin"}):A==="sent"?t.jsx(go,{size:11}):t.jsx(gd,{size:11}),t.jsx("span",{children:A==="sent"?i.sent:i.send})]})]})]})})]})}function mm(r,a){const i=a.trim();if(!i)return r;if(!r.trim())return i;const c=r.endsWith(`
|
|
8
8
|
|
|
9
9
|
`)?"":r.endsWith(`
|
|
10
10
|
`)?`
|
|
11
11
|
`:`
|
|
12
12
|
|
|
13
|
-
`;return`${r}${c}${i}`}function bm(r,a){const i=r.trim();return i?a?`${i}\r`:/\s$/.test(r)?r:`${i} `:""}function xm(r,a){return{text:bm(r,a),options:{paste:/[\r\n]/.test(r),submitAfterPaste:a}}}function vm(r){const[a,i]=n.useState(null),c=n.useRef(null),f=n.useRef(null),p=n.useRef(!0),g=n.useRef(r);g.current=r,n.useEffect(()=>(p.current=!0,()=>{p.current=!1,c.current?.controller.abort()}),[]);const k=n.useCallback(async b=>{if(c.current)return!1;c.current=b,f.current=b;const A=P=>{b.task={...b.task,...P},p.current&&c.current===b&&i(b.task)};A({status:b.task.retryFiles.length?"uploading":"inserting",error:void 0});try{if(b.task.retryFiles.length){const P=await Wi(b.task.directory,b.task.retryFiles,b.controller.signal);if(A({uploaded:[...b.task.uploaded,...P.files]}),g.current(b.task.directory),P.files.length!==b.task.retryFiles.length){const $=new Set(P.results?.filter(D=>D.status==="uploaded").map(D=>D.index)??[]);throw A({retryFiles:P.results?b.task.retryFiles.filter((D,te)=>!$.has(te)):[]}),new Error("Incomplete upload result. Check the saved paths before retrying.")}A({retryFiles:[]})}if(b.controller.signal.aborted)throw new DOMException("Upload canceled","AbortError");if(b.insert){A({status:"inserting"});const P=b.task.uploaded[0]?.path;if(!P||!b.isCurrent?.()||!await b.insert(P)||!b.isCurrent?.()||b.controller.signal.aborted)return A({status:"error",error:"reference"}),!1}return A({status:"done"}),!0}catch(P){if(P instanceof Zc&&P.result?.files.length){const $=new Set(P.result.results?.filter(D=>D.status==="uploaded").map(D=>D.index)??[]);A({uploaded:[...b.task.uploaded,...P.result.files],retryFiles:P.result.results?b.task.retryFiles.filter((D,te)=>!$.has(te)):[]}),g.current(b.task.directory)}return A({status:b.controller.signal.aborted?"canceled":"error",error:P instanceof Zc&&P.code==="UPLOAD_LIMIT"?"UPLOAD_LIMIT":P instanceof Error?P.message:String(P)}),!1}finally{c.current===b&&(c.current=null)}},[]),m=n.useCallback((b,A,P,$)=>A.length?k({task:{kind:P?"image":"files",directory:b,files:A,retryFiles:A,uploaded:[],status:"uploading"},controller:new AbortController,insert:P,isCurrent:$}):Promise.resolve(!1),[k]),x=n.useCallback(()=>{const b=f.current;if(!b||c.current||!b.insert&&!b.task.retryFiles.length)return Promise.resolve(!1);const A={...b,controller:new AbortController,task:{...b.task}};return k(A)},[k]),w=n.useCallback(()=>{const b=c.current;!b||b.task.status!=="uploading"||b.controller.abort()},[]),R=n.useCallback(()=>{c.current||(f.current=null,i(null))},[]);return{task:a,start:m,retry:x,cancel:w,dismiss:R,busy:a?.status==="uploading"||a?.status==="inserting"}}function ym({task:r,labels:a,onCancel:i,onRetry:c,onDismiss:f}){const p=r.status==="uploading"||r.status==="inserting",g=r.error==="reference"?a.referenceRejected:r.error==="UPLOAD_LIMIT"?a.limit:r.status==="error"?`${a.failed}: ${r.error??""}`:a[r.status],k=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":p,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:g}),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}),k&&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}),!p&&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((m,x)=>t.jsx("li",{className:"break-all",children:m.name},`${x}:${m.name}`)),r.uploaded.map(m=>t.jsx("li",{className:"break-all text-foreground",children:m.path},m.path))]})]})]})}function wm(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(p,g)=>{if(f.current||!a.current.active)return!1;const k=a.current,m=i.current,{text:x,options:w}=xm(k.text,p);if(!x)return!1;f.current=!0;try{const R=await eu(x,k.sessionId,()=>c.current&&a.current.active&&a.current.sessionId===k.sessionId,g,w),b=c.current&&m===i.current;return b&&(R?a.current.onAccepted():a.current.onRejected()),R&&b}finally{f.current=!1}},[])}const Nd={status:"idle",error:null,result:null};function km(r,a=!0){const[i,c]=n.useState(Nd),f=n.useRef(null);n.useEffect(()=>th(k=>{const m=f.current;!m||m.targetPeerId===k?.targetPeerId||(f.current=null,m.controller.abort(new DOMException("Download target changed","AbortError")),c({status:"canceled",error:null,result:"canceled"}))}),[]),n.useLayoutEffect(()=>(c(Nd),()=>{const k=f.current;f.current=null,k?.controller.abort()}),[r,a]);const p=n.useCallback(()=>{const k=f.current;k&&(f.current=null,k.controller.abort(),c({status:"canceled",error:null,result:"canceled"}))},[]),g=n.useCallback(async()=>{if(!a||!r||f.current)return;const k=new AbortController,m=rh()?.targetPeerId;f.current={controller:k,targetPeerId:m},c({status:"pending",error:null,result:null});try{const x=await nh(r,k.signal);if(f.current?.controller!==k)return;f.current=null;const w=k.signal.aborted?"canceled":x;c({status:w,error:null,result:w})}catch(x){if(f.current?.controller!==k)return;f.current=null,k.signal.aborted?c({status:"canceled",error:null,result:"canceled"}):c({status:"error",error:x instanceof Error?x.message:String(x),result:null})}},[r,a]);return{...i,start:g,cancel:p}}const Qi="termdock:right-sidebar:html-view-mode-by-file:v1";function Sm(r){return r==="preview"||r==="source"}function uu(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(Sm)}function fu(r,a){if(!a)return null;const i=r&&!a.startsWith("/")?`${r}/${a}`:a;return r?`${r}::${i}`:i}function Pd(r,a){const i=fu(r,a);return i?ct(Qi,uu)?.[i]??"source":"source"}function Rm(r,a,i){const c=fu(r,a);if(!c)return;const f=ct(Qi,uu)??{};Pt(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,p=String(c).padStart(2,"0"),g=String(f).padStart(2,"0");return i>0?`${i}:${p}:${g}`:`${p}:${g}`}function jm(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 Jr=2,Cm=8,Nm=60,so=5,Ed=.05,Pm=900;function Em(r){return!Number.isFinite(r)||r<=0?Jr:Math.min(Cm,Jr+Math.floor(r/Nm))}const Am=350,Tm=6,Mm=90;function Lm({url:r,onLoadError:a}){const i=Bh(r,a),{t:c}=_t(),f=n.useRef(null),p=n.useRef(null),g=n.useRef(null),k=n.useRef(null),m=n.useRef(!1),x=n.useRef(null),w=n.useRef(null),R=n.useRef(0),b=n.useRef(!1),A=n.useRef(!1),P=n.useRef(!1),$=n.useRef(null),D=n.useRef(null),te=n.useRef(!1),M=n.useRef(1),I=n.useRef(!1),[H,Y]=n.useState(0),[be,_]=n.useState(0),[o,ae]=n.useState(!1),[W,he]=n.useState(!1),[G,le]=n.useState(null),[j,F]=n.useState(!1),[ee,C]=n.useState(0),[L,q]=n.useState(!1),[ne,pe]=n.useState({width:0,height:0}),[Ne,we]=n.useState(Jr),[Pe,O]=n.useState(1),[ue,oe]=n.useState(null),Fe=n.useRef(Jr),Ie=n.useRef(null),E=n.useCallback(()=>{$.current!==null&&(clearTimeout($.current),$.current=null)},[]),xe=n.useCallback(()=>{E();const N=D.current;if(D.current=null,!te.current)return!1;const Q=g.current;if(Q&&(Q.playbackRate=M.current,N))try{Q.releasePointerCapture?.(N.id)}catch{}return te.current=!1,Fe.current=Jr,F(!1),!0},[E]);n.useEffect(()=>()=>{x.current!==null&&cancelAnimationFrame(x.current),w.current!==null&&clearTimeout(w.current),Ie.current!==null&&clearTimeout(Ie.current),E();const N=g.current;N&&te.current&&(N.playbackRate=M.current)},[E]),n.useEffect(()=>{const N=p.current;if(!N||typeof ResizeObserver>"u")return;const Q=new ResizeObserver(([ke])=>{ke&&pe({width:ke.contentRect.width,height:ke.contentRect.height})});return Q.observe(N),()=>Q.disconnect()},[]),n.useEffect(()=>{const N=()=>q(document.fullscreenElement===f.current);return document.addEventListener("fullscreenchange",N),()=>document.removeEventListener("fullscreenchange",N)},[]);const ge=n.useCallback((N,Q=!1)=>{const ke=g.current;if(!ke)return!1;const Ye=Number.isFinite(ke.duration)?ke.duration:N,ht=Math.min(Math.max(N,0),Ye);if(_(ht),Math.abs(ke.currentTime-ht)<1/120)return!1;const yr=ke.fastSeek;return Q&&typeof yr=="function"?yr.call(ke,ht):ke.currentTime=ht,!0},[]),De=n.useCallback(()=>{x.current===null&&(x.current=requestAnimationFrame(()=>{x.current=null;const N=g.current;if(!N||!b.current||A.current||N.seeking)return;const Q=P.current;P.current=!1,A.current=ge(R.current,!Q)}))},[ge]),Ve=n.useCallback(N=>{const Q=k.current,ke=g.current;if(!Q||!ke)return;const Ye=Q.getBoundingClientRect(),ht=jm(N,Ye,ke.duration);R.current=ht,le(ht),P.current=!1,De(),w.current!==null&&clearTimeout(w.current),w.current=setTimeout(()=>{w.current=null,P.current=!0,De()},Mm)},[De]),Ae=n.useCallback(()=>{x.current!==null&&(cancelAnimationFrame(x.current),x.current=null),w.current!==null&&(clearTimeout(w.current),w.current=null),P.current=!1,A.current=!1,ge(R.current)},[ge]),Jt=n.useCallback(N=>{const Q=g.current;if(!(!Q||!Number.isFinite(Q.duration)||Q.duration<=0)){m.current=!Q.paused,Q.pause(),b.current=!0,he(!0);try{N.currentTarget.setPointerCapture(N.pointerId)}catch{}Ve(N.clientX)}},[Ve]),Be=n.useCallback(()=>{b.current=!1,Ae(),he(!1),le(null);const N=g.current;N&&m.current&&!N.ended&&N.play().catch(()=>{}),m.current=!1},[Ae]),ft=n.useCallback(()=>{const N=g.current;if(N){if(I.current){I.current=!1;return}N.paused?N.play().catch(()=>{}):N.pause()}},[]),Ue=n.useCallback(N=>{const Q=g.current;if(!Q)return;const ke=Math.min(1,Math.max(0,Math.round((Q.volume+N)*100)/100));Q.volume=ke,ke>0&&(Q.muted=!1),O(ke),oe(ke),Ie.current!==null&&clearTimeout(Ie.current),Ie.current=setTimeout(()=>{Ie.current=null,oe(null)},Pm)},[]),Qt=n.useCallback(N=>{const Q=g.current;if(Q){if(N.key==="ArrowLeft"){N.preventDefault(),ge(Q.currentTime-(N.shiftKey?so*2:so));return}if(N.key==="ArrowRight"){N.preventDefault(),ge(Q.currentTime+(N.shiftKey?so*2:so));return}if(N.key==="ArrowUp"){N.preventDefault(),Ue(Ed);return}if(N.key==="ArrowDown"){N.preventDefault(),Ue(-Ed);return}(N.key===" "||N.key==="Spacebar"||N.key==="k"||N.key==="K")&&(N.preventDefault(),Q.paused?Q.play().catch(()=>{}):Q.pause())}},[ge,Ue]),me=n.useCallback(N=>{const Q=g.current;!Q||Q.paused||N.button!==0||(E(),D.current={id:N.pointerId,x:N.clientX,y:N.clientY},$.current=setTimeout(()=>{$.current=null;const ke=D.current;if(M.current=Q.playbackRate,Q.playbackRate=Jr,Fe.current=Jr,we(Jr),te.current=!0,F(!0),ke)try{Q.setPointerCapture?.(ke.id)}catch{}},Am))},[E]),dt=n.useCallback(N=>{const Q=D.current;if(!Q||Q.id!==N.pointerId)return;if(!te.current){Math.hypot(N.clientX-Q.x,N.clientY-Q.y)>Tm&&(E(),D.current=null);return}const ke=Em(N.clientX-Q.x);if(ke===Fe.current)return;Fe.current=ke,we(ke);const Ye=g.current;Ye&&(Ye.playbackRate=ke)},[E]),at=n.useCallback(()=>{xe()&&(I.current=!0)},[xe]);n.useEffect(()=>(window.addEventListener("pointerup",at),window.addEventListener("pointercancel",at),window.addEventListener("blur",at),()=>{window.removeEventListener("pointerup",at),window.removeEventListener("pointercancel",at),window.removeEventListener("blur",at)}),[at]);const bt=n.useCallback(async()=>{const N=f.current,Q=g.current;if(!(!N||!Q))try{document.fullscreenElement===N?await document.exitFullscreen():N.requestFullscreen?await N.requestFullscreen():Q.webkitEnterFullscreen?.()}catch{Q.webkitEnterFullscreen?.()}},[]),Oe=n.useCallback(()=>C(N=>(N+90)%360),[]),V=n.useCallback(N=>{const Q=g.current;if(!Q||!Number.isFinite(Q.duration))return;const ke=N.shiftKey?10:5;let Ye=null;N.key==="ArrowLeft"?Ye=Q.currentTime-ke:N.key==="ArrowRight"?Ye=Q.currentTime+ke:N.key==="Home"?Ye=0:N.key==="End"&&(Ye=Q.duration),Ye!==null&&(N.preventDefault(),ge(Ye))},[ge]),ye=W&&G!==null?G:be,Ze=H>0?Math.min(1,Math.max(0,ye/H)):0,ir=(ee===90||ee===270)&&ne.width>0&&ne.height>0?{width:`${ne.height}px`,height:`${ne.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":ee,children:[t.jsxs("div",{ref:p,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[t.jsx("video",{ref:g,"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:{...ir,transform:`translate(-50%, -50%) rotate(${ee}deg)`},src:i,preload:"auto",playsInline:!0,tabIndex:0,...j?{[kd]:""}:{},onClick:ft,onKeyDown:Qt,onVolumeChange:N=>O(N.currentTarget.volume),onPointerDown:me,onPointerMove:dt,onPointerUp:at,onPointerCancel:at,onContextMenu:N=>{te.current&&N.preventDefault()},onPlay:()=>ae(!0),onPause:()=>ae(!1),onTimeUpdate:N=>_(N.currentTarget.currentTime),onSeeked:N=>{const Q=N.currentTarget;if(_(Q.currentTime),A.current=!1,!b.current)return;const ke=Q.requestVideoFrameCallback;typeof ke=="function"?ke.call(Q,()=>{b.current&&De()}):requestAnimationFrame(()=>{b.current&&De()})},onLoadedMetadata:N=>Y(Number.isFinite(N.currentTarget.duration)?N.currentTarget.duration:0),onDurationChange:N=>Y(Number.isFinite(N.currentTarget.duration)?N.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(Ne)})}),ue!==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(hp,{size:13}),c("rightSidebar.videoVolume",{percent:Math.round(Pe*100)})]}),W&&G!==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:`${Ze*100}%`},"data-testid":"file-preview-video-scrub-time",children:Li(G)})]}),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:ft,"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(ep,{size:14}):t.jsx(tp,{size:14})}),t.jsxs("div",{ref:k,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(H),"aria-valuenow":Math.floor(ye),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:Jt,onPointerMove:N=>{W&&Ve(N.clientX)},onPointerUp:Be,onPointerCancel:Be,onKeyDown:V,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:`${Ze*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:`${Ze*100}%`}})]}),t.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[Li(ye)," / ",Li(H)]}),t.jsx("button",{type:"button",onClick:Oe,"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:()=>{bt()},"aria-label":c(L?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:c(L?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-fullscreen",children:L?t.jsx(pp,{size:14}):t.jsx(mp,{size:14})})]})})]})}function Im(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:p=>{p.stopPropagation(),c(p.currentTarget)},title:f,style:Im(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(bo,{size:11}),a]})}function $m(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 p=c.width*f,g=c.height*f,k=i.left+(i.width-p)/2,m=i.top+(i.height-g)/2,x=r-k,w=a-m;if(x<0||w<0||x>p||w>g)return null;const R=x/p*100,b=w/g*100;return{x:c.x+c.width*R/100,y:c.y+c.height*b/100,xPercent:R,yPercent:b}}function Fm(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 Dm(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 p=f.name.toLowerCase(),g=f.value.trim();(p.startsWith("on")||(p==="href"||p.endsWith(":href"))&&g&&!g.startsWith("#"))&&c.removeAttribute(f.name)}}),i.removeAttribute("width"),i.removeAttribute("height"),i.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(i)}function _m(r,a,i){let c=null;for(const f of Array.from(r.querySelectorAll("text"))){const p=(f.textContent??"").replace(/\s+/g," ").trim();if(!p)continue;const g=Number(f.getAttribute("x")),k=Number(f.getAttribute("y"));if(!Number.isFinite(g)||!Number.isFinite(k))continue;const m=Math.hypot(g-a,k-i);(!c||m<c.distance)&&(c={text:p,distance:m})}return c?.text.slice(0,120)}function hu({blobUrl:r,filePath:a,viewLabel:i,onInsertAnnotation:c}){const f=n.useRef(null),p=n.useRef(null),[g,k]=n.useState(null),[m,x]=n.useState(null),[w,R]=n.useState(1),[b,A]=n.useState(!1),[P,$]=n.useState(null),D=n.useRef(new Map),te=n.useRef(null),M=n.useRef(!1),I=n.useRef(null),H=n.useRef(w);H.current=w,n.useEffect(()=>{const C=new AbortController;return k(null),x(null),$(null),R(1),fetch(r,{signal:C.signal}).then(L=>L.text()).then(L=>k(Dm(L))).catch(L=>{C.signal.aborted||x(L instanceof Error?L.message:"SVG preview failed")}),()=>C.abort()},[r]),n.useEffect(()=>{if(!b)return;const C=L=>{L.key==="Escape"&&A(!1)};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[b]),n.useLayoutEffect(()=>{const C=p.current,L=C?.querySelector("[data-svg-document] > svg");if(!C||!L)return;let q;try{q=L.getBBox()}catch{return}if(!q.width||!q.height)return;const ne=Math.max(2,Math.min(q.width,q.height)*.025);L.setAttribute("viewBox",`${q.x-ne} ${q.y-ne} ${q.width+2*ne} ${q.height+2*ne}`),L.style.width=`${w*100}%`,L.style.height=`${w*100}%`,L.style.minWidth=`${w*100}%`,L.style.minHeight=`${w*100}%`,L.style.display="block"},[g,w]);const Y=n.useMemo(()=>P?Fm(a,i,P):null,[a,P,i]),be=C=>{if(M.current){M.current=!1;return}const L=p.current,q=L?.querySelector("[data-svg-document] > svg"),ne=f.current;if(!L||!q||!ne)return;const pe=q.viewBox.baseVal,Ne=$m(C.clientX,C.clientY,q.getBoundingClientRect(),pe);if(!Ne)return;const we=ne.getBoundingClientRect();$({...Ne,nearestText:_m(q,Ne.x,Ne.y),stageX:C.clientX-we.left,stageY:C.clientY-we.top,stageXPercent:(C.clientX-we.left)/we.width*100,stageYPercent:(C.clientY-we.top)/we.height*100})},_=C=>Math.max(1,Math.min(12,C)),o=(C,L)=>{const q=_(L),ne=C.querySelector("[data-svg-document] > svg");if(!ne)return q;const pe=`${q*100}%`;return ne.style.width=pe,ne.style.height=pe,ne.style.minWidth=pe,ne.style.minHeight=pe,H.current=q,q},ae=(C,L,q,ne)=>{const pe=H.current,Ne=C.getBoundingClientRect(),we=q-Ne.left,Pe=ne-Ne.top,O=(C.scrollLeft+we)/pe,ue=(C.scrollTop+Pe)/pe,oe=o(C,L);return C.scrollLeft=O*oe-we,C.scrollTop=ue*oe-Pe,oe},W=()=>{const C=Array.from(D.current.values());return C.length>=2?Math.hypot(C[0].x-C[1].x,C[0].y-C[1].y):0},he=C=>{if(C.pointerType==="mouse"&&C.button!==0)return;const L=p.current;L&&(D.current.set(C.pointerId,{x:C.clientX,y:C.clientY}),L.setPointerCapture?.(C.pointerId),D.current.size>=2?(te.current={kind:"pinch",startX:C.clientX,startY:C.clientY,startScrollLeft:L.scrollLeft,startScrollTop:L.scrollTop,startDistance:W(),startZoom:H.current,moved:!1},M.current=!0):H.current>1&&(te.current={kind:"pan",startX:C.clientX,startY:C.clientY,startScrollLeft:L.scrollLeft,startScrollTop:L.scrollTop,startZoom:H.current,moved:!1}))},G=C=>{if(!D.current.has(C.pointerId))return;D.current.set(C.pointerId,{x:C.clientX,y:C.clientY});const L=p.current,q=te.current;if(!(!L||!q)){if(D.current.size>=2&&q.kind==="pinch"){const ne=W();if(!q.startDistance||!ne)return;const pe=_(q.startZoom*ne/q.startDistance);if(Math.abs(pe-H.current)<.01)return;const Ne=Array.from(D.current.values()),we=(Ne[0].x+Ne[1].x)/2,Pe=(Ne[0].y+Ne[1].y)/2;q.moved=!0,M.current=!0,ae(L,pe,we,Pe),C.preventDefault();return}if(q.kind==="pan"&&D.current.size===1){const ne=C.clientX-q.startX,pe=C.clientY-q.startY;if(!q.moved&&Math.hypot(ne,pe)<6)return;q.moved=!0,M.current=!0,L.scrollLeft=q.startScrollLeft-ne,L.scrollTop=q.startScrollTop-pe,C.preventDefault()}}},le=C=>{const L=p.current,q=te.current,ne=D.current.size===1&&!q?.moved;D.current.delete(C.pointerId);try{L?.releasePointerCapture?.(C.pointerId)}catch{}if(D.current.size===1&&q?.kind==="pinch"){const we=Array.from(D.current.values())[0];te.current=L?{kind:"pan",startX:we.x,startY:we.y,startScrollLeft:L.scrollLeft,startScrollTop:L.scrollTop,startZoom:H.current,moved:!1}:null;return}if(D.current.size>0||(te.current=null,q?.kind==="pinch"&&R(H.current),!ne||M.current))return;const pe=Date.now(),Ne=I.current;Ne&&pe-Ne.time<350&&Math.hypot(C.clientX-Ne.x,C.clientY-Ne.y)<24?(I.current=null,M.current=!0,R(we=>we>1?1:2.5)):I.current={time:pe,x:C.clientX,y:C.clientY}},j=C=>{if(!C.ctrlKey&&!C.metaKey)return;const L=p.current;if(!L)return;C.preventDefault();const q=ae(L,H.current*Math.exp(-C.deltaY*.01),C.clientX,C.clientY);R(q)},F=()=>{R(1),H.current=1,p.current&&(p.current.scrollLeft=0,p.current.scrollTop=0)},ee=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:p,role:"button",tabIndex:0,onClick:be,onDoubleClick:C=>{C.preventDefault(),R(L=>L>1?1:2.5)},onPointerDown:he,onPointerMove:G,onPointerUp:le,onPointerCancel:le,onWheel:j,onScroll:()=>$(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:m?t.jsx("div",{className:"p-4 text-sm text-destructive",children:m}):g?t.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:g}}):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&&Y&&t.jsx(wo,{anchor:{xPercent:P.stageXPercent,yPercent:P.stageYPercent},title:"引用 SVG 标注",onClick:async C=>{await c?.(Y,`svg:${P.x.toFixed(2)}:${P.y.toFixed(2)}`,void 0,C)!==!1&&$(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(),F()},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:t.jsx(Up,{size:14})}),t.jsx("button",{type:"button","aria-label":b?"退出全屏 SVG":"全屏 SVG",title:b?"退出全屏 SVG":"全屏 SVG",onClick:C=>{C.stopPropagation(),A(L=>!L)},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(ee,document.body):ee}function fo(r){switch(r){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function Bm(r,a,i,c){const f=[`电子标注: ${r}`,`视图: ${fo(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 p=[c.nearest.net?`网络 ${c.nearest.net}`:null,`对象层 ${c.nearest.layer}`,`距离 ${c.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");f.push(`最近对象: ${c.nearest.label}${p?`(${p})`:""}`)}return`"${f.join(" / ")}"`}function Um({blobUrl:r,filePath:a,view:i,board:c,onViewChange:f,onInsertAnnotation:p,onRefresh:g,interactive3d:k}){const{t:m}=_t(),x=n.useRef(null),w=n.useRef(null),R=n.useRef(null),[b,A]=n.useState(null),[P,$]=n.useState(!1);n.useEffect(()=>(R.current?.abort(),A(null),$(!1),()=>R.current?.abort()),[r,i]);const D=n.useMemo(()=>b?Bm(a,i,b,b.inspection):null,[a,b,i]),te=I=>{const H=x.current,Y=w.current;if(!H||!Y||!Y.naturalWidth||!Y.naturalHeight)return;const be=H.getBoundingClientRect(),_=Y.getBoundingClientRect(),o=Math.min(_.width/Y.naturalWidth,_.height/Y.naturalHeight),ae=Y.naturalWidth*o,W=Y.naturalHeight*o,he=_.left+(_.width-ae)/2,G=_.top+(_.height-W)/2,le=I.clientX-he,j=I.clientY-G;if(le<0||j<0||le>ae||j>W)return;const F={xPercent:Math.max(0,Math.min(100,le/ae*100)),yPercent:Math.max(0,Math.min(100,j/W*100)),stageXPercent:(I.clientX-be.left)/be.width*100,stageYPercent:(I.clientY-be.top)/be.height*100,inspecting:c&&i!=="pcb-3d"};if(A(F),R.current?.abort(),!F.inspecting)return;const ee=new AbortController;R.current=ee,sh(a,i,F.xPercent,F.yPercent,ee.signal).then(C=>A(L=>L===F?{...L,inspection:C,inspecting:!1}:L)).catch(()=>{ee.signal.aborted||A(C=>C===F?{...C,inspection:{available:!1},inspecting:!1}:C)})},M=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:M.map(I=>t.jsx("button",{type:"button",onClick:()=>f(I),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${I===i?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:fo(I)},I))}),t.jsx("button",{type:"button",onClick:g,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:m("rightSidebar.edaRefresh"),"aria-label":m("rightSidebar.edaRefresh"),children:t.jsx(uo,{size:13})})]}),c&&k?t.jsx("div",{className:i==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:k}):null,c?i==="pcb-3d"?k?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:te,onKeyDown:I=>{I.key!=="Enter"&&I.key!==" "||(I.preventDefault(),A({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:m("rightSidebar.edaPickHint"),children:[t.jsx("img",{ref:w,src:r,alt:`${a} ${fo(i)}`,onLoad:()=>$(!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&&D&&t.jsx(wo,{anchor:{xPercent:b.stageXPercent,yPercent:b.stageYPercent},disabled:b.inspecting,title:m("rightSidebar.edaInsertAnnotation"),onClick:async I=>{await p?.(D,`eda:${i}:${b.xPercent.toFixed(1)}:${b.yPercent.toFixed(1)}`,{snapshot:w.current?Kp(w.current,b):Promise.resolve(null)},I)!==!1&&A(null)},children:m("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?m("rightSidebar.edaInspecting"):b.inspection?.available?m("rightSidebar.edaPickedBoardPosition",{x:b.inspection.xMm?.toFixed(2)??"—",y:b.inspection.yMm?.toFixed(2)??"—",object:b.inspection.nearest?.label??m("rightSidebar.edaNoNearbyObject")}):m("rightSidebar.edaPickedPosition",{x:b.xPercent.toFixed(1),y:b.yPercent.toFixed(1)}):m("rightSidebar.edaPickHint")})})]}):t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(hu,{blobUrl:r,filePath:a,viewLabel:fo(i),onInsertAnnotation:p})})]})}function Om(r){const a=[];let i=[],c="",f=!1;for(let p=0;p<r.length;p+=1){const g=r[p];f?g==='"'&&r[p+1]==='"'?(c+='"',p+=1):g==='"'?f=!1:c+=g:g==='"'?f=!0:g===","?(i.push(c),c=""):g===`
|
|
14
|
-
`?(i.push(c.replace(/\r$/,"")),a.push(i),i=[],c=""):c+=g}return(c||i.length>0)&&(i.push(c.replace(/\r$/,"")),a.push(i)),a}function
|
|
13
|
+
`;return`${r}${c}${i}`}function gm(r,a){const i=r.trim();return i?a?`${i}\r`:/\s$/.test(r)?r:`${i} `:""}function bm(r,a){return{text:gm(r,a),options:{paste:/[\r\n]/.test(r),submitAfterPaste:a}}}function xm(r){const[a,i]=n.useState(null),c=n.useRef(null),f=n.useRef(null),p=n.useRef(!0),g=n.useRef(r);g.current=r,n.useEffect(()=>(p.current=!0,()=>{p.current=!1,c.current?.controller.abort()}),[]);const k=n.useCallback(async b=>{if(c.current)return!1;c.current=b,f.current=b;const A=P=>{b.task={...b.task,...P},p.current&&c.current===b&&i(b.task)};A({status:b.task.retryFiles.length?"uploading":"inserting",error:void 0});try{if(b.task.retryFiles.length){const P=await Wi(b.task.directory,b.task.retryFiles,b.controller.signal);if(A({uploaded:[...b.task.uploaded,...P.files]}),g.current(b.task.directory),P.files.length!==b.task.retryFiles.length){const $=new Set(P.results?.filter(D=>D.status==="uploaded").map(D=>D.index)??[]);throw A({retryFiles:P.results?b.task.retryFiles.filter((D,te)=>!$.has(te)):[]}),new Error("Incomplete upload result. Check the saved paths before retrying.")}A({retryFiles:[]})}if(b.controller.signal.aborted)throw new DOMException("Upload canceled","AbortError");if(b.insert){A({status:"inserting"});const P=b.task.uploaded[0]?.path;if(!P||!b.isCurrent?.()||!await b.insert(P)||!b.isCurrent?.()||b.controller.signal.aborted)return A({status:"error",error:"reference"}),!1}return A({status:"done"}),!0}catch(P){if(P instanceof Zc&&P.result?.files.length){const $=new Set(P.result.results?.filter(D=>D.status==="uploaded").map(D=>D.index)??[]);A({uploaded:[...b.task.uploaded,...P.result.files],retryFiles:P.result.results?b.task.retryFiles.filter((D,te)=>!$.has(te)):[]}),g.current(b.task.directory)}return A({status:b.controller.signal.aborted?"canceled":"error",error:P instanceof Zc&&P.code==="UPLOAD_LIMIT"?"UPLOAD_LIMIT":P instanceof Error?P.message:String(P)}),!1}finally{c.current===b&&(c.current=null)}},[]),m=n.useCallback((b,A,P,$)=>A.length?k({task:{kind:P?"image":"files",directory:b,files:A,retryFiles:A,uploaded:[],status:"uploading"},controller:new AbortController,insert:P,isCurrent:$}):Promise.resolve(!1),[k]),x=n.useCallback(()=>{const b=f.current;if(!b||c.current||!b.insert&&!b.task.retryFiles.length)return Promise.resolve(!1);const A={...b,controller:new AbortController,task:{...b.task}};return k(A)},[k]),w=n.useCallback(()=>{const b=c.current;!b||b.task.status!=="uploading"||b.controller.abort()},[]),R=n.useCallback(()=>{c.current||(f.current=null,i(null))},[]);return{task:a,start:m,retry:x,cancel:w,dismiss:R,busy:a?.status==="uploading"||a?.status==="inserting"}}function vm({task:r,labels:a,onCancel:i,onRetry:c,onDismiss:f}){const p=r.status==="uploading"||r.status==="inserting",g=r.error==="reference"?a.referenceRejected:r.error==="UPLOAD_LIMIT"?a.limit:r.status==="error"?`${a.failed}: ${r.error??""}`:a[r.status],k=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":p,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:g}),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}),k&&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}),!p&&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((m,x)=>t.jsx("li",{className:"break-all",children:m.name},`${x}:${m.name}`)),r.uploaded.map(m=>t.jsx("li",{className:"break-all text-foreground",children:m.path},m.path))]})]})]})}function ym(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(p,g)=>{if(f.current||!a.current.active)return!1;const k=a.current,m=i.current,{text:x,options:w}=bm(k.text,p);if(!x)return!1;f.current=!0;try{const R=await eu(x,k.sessionId,()=>c.current&&a.current.active&&a.current.sessionId===k.sessionId,g,w),b=c.current&&m===i.current;return b&&(R?a.current.onAccepted():a.current.onRejected()),R&&b}finally{f.current=!1}},[])}const Nd={status:"idle",error:null,result:null};function wm(r,a=!0){const[i,c]=n.useState(Nd),f=n.useRef(null);n.useEffect(()=>th(k=>{const m=f.current;!m||m.targetPeerId===k?.targetPeerId||(f.current=null,m.controller.abort(new DOMException("Download target changed","AbortError")),c({status:"canceled",error:null,result:"canceled"}))}),[]),n.useLayoutEffect(()=>(c(Nd),()=>{const k=f.current;f.current=null,k?.controller.abort()}),[r,a]);const p=n.useCallback(()=>{const k=f.current;k&&(f.current=null,k.controller.abort(),c({status:"canceled",error:null,result:"canceled"}))},[]),g=n.useCallback(async()=>{if(!a||!r||f.current)return;const k=new AbortController,m=rh()?.targetPeerId;f.current={controller:k,targetPeerId:m},c({status:"pending",error:null,result:null});try{const x=await nh(r,k.signal);if(f.current?.controller!==k)return;f.current=null;const w=k.signal.aborted?"canceled":x;c({status:w,error:null,result:w})}catch(x){if(f.current?.controller!==k)return;f.current=null,k.signal.aborted?c({status:"canceled",error:null,result:"canceled"}):c({status:"error",error:x instanceof Error?x.message:String(x),result:null})}},[r,a]);return{...i,start:g,cancel:p}}const Qi="termdock:right-sidebar:html-view-mode-by-file:v1";function km(r){return r==="preview"||r==="source"}function uu(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(km)}function fu(r,a){if(!a)return null;const i=r&&!a.startsWith("/")?`${r}/${a}`:a;return r?`${r}::${i}`:i}function Pd(r,a){const i=fu(r,a);return i?ct(Qi,uu)?.[i]??"source":"source"}function Sm(r,a,i){const c=fu(r,a);if(!c)return;const f=ct(Qi,uu)??{};Pt(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,p=String(c).padStart(2,"0"),g=String(f).padStart(2,"0");return i>0?`${i}:${p}:${g}`:`${p}:${g}`}function Rm(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,jm=8,Cm=60,so=5,Ed=.05,Nm=900;function Pm(r){return!Number.isFinite(r)||r<=0?Xr:Math.min(jm,Xr+Math.floor(r/Cm))}const Em=350,Am=6,Tm=90;function Mm({url:r,onLoadError:a}){const i=Bh(r,a),{t:c}=_t(),f=n.useRef(null),p=n.useRef(null),g=n.useRef(null),k=n.useRef(null),m=n.useRef(!1),x=n.useRef(null),w=n.useRef(null),R=n.useRef(0),b=n.useRef(!1),A=n.useRef(!1),P=n.useRef(!1),$=n.useRef(null),D=n.useRef(null),te=n.useRef(!1),M=n.useRef(1),I=n.useRef(!1),[H,Y]=n.useState(0),[be,_]=n.useState(0),[o,ae]=n.useState(!1),[W,he]=n.useState(!1),[G,le]=n.useState(null),[j,F]=n.useState(!1),[ee,C]=n.useState(0),[L,q]=n.useState(!1),[ne,pe]=n.useState({width:0,height:0}),[Ne,we]=n.useState(Xr),[Pe,O]=n.useState(1),[ue,oe]=n.useState(null),Fe=n.useRef(Xr),Ie=n.useRef(null),E=n.useCallback(()=>{$.current!==null&&(clearTimeout($.current),$.current=null)},[]),xe=n.useCallback(()=>{E();const N=D.current;if(D.current=null,!te.current)return!1;const Q=g.current;if(Q&&(Q.playbackRate=M.current,N))try{Q.releasePointerCapture?.(N.id)}catch{}return te.current=!1,Fe.current=Xr,F(!1),!0},[E]);n.useEffect(()=>()=>{x.current!==null&&cancelAnimationFrame(x.current),w.current!==null&&clearTimeout(w.current),Ie.current!==null&&clearTimeout(Ie.current),E();const N=g.current;N&&te.current&&(N.playbackRate=M.current)},[E]),n.useEffect(()=>{const N=p.current;if(!N||typeof ResizeObserver>"u")return;const Q=new ResizeObserver(([ke])=>{ke&&pe({width:ke.contentRect.width,height:ke.contentRect.height})});return Q.observe(N),()=>Q.disconnect()},[]),n.useEffect(()=>{const N=()=>q(document.fullscreenElement===f.current);return document.addEventListener("fullscreenchange",N),()=>document.removeEventListener("fullscreenchange",N)},[]);const ge=n.useCallback((N,Q=!1)=>{const ke=g.current;if(!ke)return!1;const Ye=Number.isFinite(ke.duration)?ke.duration:N,ht=Math.min(Math.max(N,0),Ye);if(_(ht),Math.abs(ke.currentTime-ht)<1/120)return!1;const yr=ke.fastSeek;return Q&&typeof yr=="function"?yr.call(ke,ht):ke.currentTime=ht,!0},[]),De=n.useCallback(()=>{x.current===null&&(x.current=requestAnimationFrame(()=>{x.current=null;const N=g.current;if(!N||!b.current||A.current||N.seeking)return;const Q=P.current;P.current=!1,A.current=ge(R.current,!Q)}))},[ge]),Ve=n.useCallback(N=>{const Q=k.current,ke=g.current;if(!Q||!ke)return;const Ye=Q.getBoundingClientRect(),ht=Rm(N,Ye,ke.duration);R.current=ht,le(ht),P.current=!1,De(),w.current!==null&&clearTimeout(w.current),w.current=setTimeout(()=>{w.current=null,P.current=!0,De()},Tm)},[De]),Ae=n.useCallback(()=>{x.current!==null&&(cancelAnimationFrame(x.current),x.current=null),w.current!==null&&(clearTimeout(w.current),w.current=null),P.current=!1,A.current=!1,ge(R.current)},[ge]),Jt=n.useCallback(N=>{const Q=g.current;if(!(!Q||!Number.isFinite(Q.duration)||Q.duration<=0)){m.current=!Q.paused,Q.pause(),b.current=!0,he(!0);try{N.currentTarget.setPointerCapture(N.pointerId)}catch{}Ve(N.clientX)}},[Ve]),Be=n.useCallback(()=>{b.current=!1,Ae(),he(!1),le(null);const N=g.current;N&&m.current&&!N.ended&&N.play().catch(()=>{}),m.current=!1},[Ae]),ft=n.useCallback(()=>{const N=g.current;if(N){if(I.current){I.current=!1;return}N.paused?N.play().catch(()=>{}):N.pause()}},[]),Ue=n.useCallback(N=>{const Q=g.current;if(!Q)return;const ke=Math.min(1,Math.max(0,Math.round((Q.volume+N)*100)/100));Q.volume=ke,ke>0&&(Q.muted=!1),O(ke),oe(ke),Ie.current!==null&&clearTimeout(Ie.current),Ie.current=setTimeout(()=>{Ie.current=null,oe(null)},Nm)},[]),Qt=n.useCallback(N=>{const Q=g.current;if(Q){if(N.key==="ArrowLeft"){N.preventDefault(),ge(Q.currentTime-(N.shiftKey?so*2:so));return}if(N.key==="ArrowRight"){N.preventDefault(),ge(Q.currentTime+(N.shiftKey?so*2:so));return}if(N.key==="ArrowUp"){N.preventDefault(),Ue(Ed);return}if(N.key==="ArrowDown"){N.preventDefault(),Ue(-Ed);return}(N.key===" "||N.key==="Spacebar"||N.key==="k"||N.key==="K")&&(N.preventDefault(),Q.paused?Q.play().catch(()=>{}):Q.pause())}},[ge,Ue]),me=n.useCallback(N=>{const Q=g.current;!Q||Q.paused||N.button!==0||(E(),D.current={id:N.pointerId,x:N.clientX,y:N.clientY},$.current=setTimeout(()=>{$.current=null;const ke=D.current;if(M.current=Q.playbackRate,Q.playbackRate=Xr,Fe.current=Xr,we(Xr),te.current=!0,F(!0),ke)try{Q.setPointerCapture?.(ke.id)}catch{}},Em))},[E]),dt=n.useCallback(N=>{const Q=D.current;if(!Q||Q.id!==N.pointerId)return;if(!te.current){Math.hypot(N.clientX-Q.x,N.clientY-Q.y)>Am&&(E(),D.current=null);return}const ke=Pm(N.clientX-Q.x);if(ke===Fe.current)return;Fe.current=ke,we(ke);const Ye=g.current;Ye&&(Ye.playbackRate=ke)},[E]),at=n.useCallback(()=>{xe()&&(I.current=!0)},[xe]);n.useEffect(()=>(window.addEventListener("pointerup",at),window.addEventListener("pointercancel",at),window.addEventListener("blur",at),()=>{window.removeEventListener("pointerup",at),window.removeEventListener("pointercancel",at),window.removeEventListener("blur",at)}),[at]);const bt=n.useCallback(async()=>{const N=f.current,Q=g.current;if(!(!N||!Q))try{document.fullscreenElement===N?await document.exitFullscreen():N.requestFullscreen?await N.requestFullscreen():Q.webkitEnterFullscreen?.()}catch{Q.webkitEnterFullscreen?.()}},[]),Oe=n.useCallback(()=>C(N=>(N+90)%360),[]),V=n.useCallback(N=>{const Q=g.current;if(!Q||!Number.isFinite(Q.duration))return;const ke=N.shiftKey?10:5;let Ye=null;N.key==="ArrowLeft"?Ye=Q.currentTime-ke:N.key==="ArrowRight"?Ye=Q.currentTime+ke:N.key==="Home"?Ye=0:N.key==="End"&&(Ye=Q.duration),Ye!==null&&(N.preventDefault(),ge(Ye))},[ge]),ye=W&&G!==null?G:be,Ze=H>0?Math.min(1,Math.max(0,ye/H)):0,ir=(ee===90||ee===270)&&ne.width>0&&ne.height>0?{width:`${ne.height}px`,height:`${ne.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":ee,children:[t.jsxs("div",{ref:p,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[t.jsx("video",{ref:g,"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:{...ir,transform:`translate(-50%, -50%) rotate(${ee}deg)`},src:i,preload:"auto",playsInline:!0,tabIndex:0,...j?{[kd]:""}:{},onClick:ft,onKeyDown:Qt,onVolumeChange:N=>O(N.currentTarget.volume),onPointerDown:me,onPointerMove:dt,onPointerUp:at,onPointerCancel:at,onContextMenu:N=>{te.current&&N.preventDefault()},onPlay:()=>ae(!0),onPause:()=>ae(!1),onTimeUpdate:N=>_(N.currentTarget.currentTime),onSeeked:N=>{const Q=N.currentTarget;if(_(Q.currentTime),A.current=!1,!b.current)return;const ke=Q.requestVideoFrameCallback;typeof ke=="function"?ke.call(Q,()=>{b.current&&De()}):requestAnimationFrame(()=>{b.current&&De()})},onLoadedMetadata:N=>Y(Number.isFinite(N.currentTarget.duration)?N.currentTarget.duration:0),onDurationChange:N=>Y(Number.isFinite(N.currentTarget.duration)?N.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(Ne)})}),ue!==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(hp,{size:13}),c("rightSidebar.videoVolume",{percent:Math.round(Pe*100)})]}),W&&G!==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:`${Ze*100}%`},"data-testid":"file-preview-video-scrub-time",children:Li(G)})]}),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:ft,"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(ep,{size:14}):t.jsx(tp,{size:14})}),t.jsxs("div",{ref:k,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(H),"aria-valuenow":Math.floor(ye),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:Jt,onPointerMove:N=>{W&&Ve(N.clientX)},onPointerUp:Be,onPointerCancel:Be,onKeyDown:V,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:`${Ze*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:`${Ze*100}%`}})]}),t.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[Li(ye)," / ",Li(H)]}),t.jsx("button",{type:"button",onClick:Oe,"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:()=>{bt()},"aria-label":c(L?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:c(L?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-fullscreen",children:L?t.jsx(pp,{size:14}):t.jsx(mp,{size:14})})]})})]})}function Lm(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:p=>{p.stopPropagation(),c(p.currentTarget)},title:f,style:Lm(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(bo,{size:11}),a]})}function Im(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 p=c.width*f,g=c.height*f,k=i.left+(i.width-p)/2,m=i.top+(i.height-g)/2,x=r-k,w=a-m;if(x<0||w<0||x>p||w>g)return null;const R=x/p*100,b=w/g*100;return{x:c.x+c.width*R/100,y:c.y+c.height*b/100,xPercent:R,yPercent:b}}function $m(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 Fm(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 p=f.name.toLowerCase(),g=f.value.trim();(p.startsWith("on")||(p==="href"||p.endsWith(":href"))&&g&&!g.startsWith("#"))&&c.removeAttribute(f.name)}}),i.removeAttribute("width"),i.removeAttribute("height"),i.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(i)}function Dm(r,a,i){let c=null;for(const f of Array.from(r.querySelectorAll("text"))){const p=(f.textContent??"").replace(/\s+/g," ").trim();if(!p)continue;const g=Number(f.getAttribute("x")),k=Number(f.getAttribute("y"));if(!Number.isFinite(g)||!Number.isFinite(k))continue;const m=Math.hypot(g-a,k-i);(!c||m<c.distance)&&(c={text:p,distance:m})}return c?.text.slice(0,120)}function hu({blobUrl:r,filePath:a,viewLabel:i,onInsertAnnotation:c}){const f=n.useRef(null),p=n.useRef(null),[g,k]=n.useState(null),[m,x]=n.useState(null),[w,R]=n.useState(1),[b,A]=n.useState(!1),[P,$]=n.useState(null),D=n.useRef(new Map),te=n.useRef(null),M=n.useRef(!1),I=n.useRef(null),H=n.useRef(w);H.current=w,n.useEffect(()=>{const C=new AbortController;return k(null),x(null),$(null),R(1),fetch(r,{signal:C.signal}).then(L=>L.text()).then(L=>k(Fm(L))).catch(L=>{C.signal.aborted||x(L instanceof Error?L.message:"SVG preview failed")}),()=>C.abort()},[r]),n.useEffect(()=>{if(!b)return;const C=L=>{L.key==="Escape"&&A(!1)};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[b]),n.useLayoutEffect(()=>{const C=p.current,L=C?.querySelector("[data-svg-document] > svg");if(!C||!L)return;let q;try{q=L.getBBox()}catch{return}if(!q.width||!q.height)return;const ne=Math.max(2,Math.min(q.width,q.height)*.025);L.setAttribute("viewBox",`${q.x-ne} ${q.y-ne} ${q.width+2*ne} ${q.height+2*ne}`),L.style.width=`${w*100}%`,L.style.height=`${w*100}%`,L.style.minWidth=`${w*100}%`,L.style.minHeight=`${w*100}%`,L.style.display="block"},[g,w]);const Y=n.useMemo(()=>P?$m(a,i,P):null,[a,P,i]),be=C=>{if(M.current){M.current=!1;return}const L=p.current,q=L?.querySelector("[data-svg-document] > svg"),ne=f.current;if(!L||!q||!ne)return;const pe=q.viewBox.baseVal,Ne=Im(C.clientX,C.clientY,q.getBoundingClientRect(),pe);if(!Ne)return;const we=ne.getBoundingClientRect();$({...Ne,nearestText:Dm(q,Ne.x,Ne.y),stageX:C.clientX-we.left,stageY:C.clientY-we.top,stageXPercent:(C.clientX-we.left)/we.width*100,stageYPercent:(C.clientY-we.top)/we.height*100})},_=C=>Math.max(1,Math.min(12,C)),o=(C,L)=>{const q=_(L),ne=C.querySelector("[data-svg-document] > svg");if(!ne)return q;const pe=`${q*100}%`;return ne.style.width=pe,ne.style.height=pe,ne.style.minWidth=pe,ne.style.minHeight=pe,H.current=q,q},ae=(C,L,q,ne)=>{const pe=H.current,Ne=C.getBoundingClientRect(),we=q-Ne.left,Pe=ne-Ne.top,O=(C.scrollLeft+we)/pe,ue=(C.scrollTop+Pe)/pe,oe=o(C,L);return C.scrollLeft=O*oe-we,C.scrollTop=ue*oe-Pe,oe},W=()=>{const C=Array.from(D.current.values());return C.length>=2?Math.hypot(C[0].x-C[1].x,C[0].y-C[1].y):0},he=C=>{if(C.pointerType==="mouse"&&C.button!==0)return;const L=p.current;L&&(D.current.set(C.pointerId,{x:C.clientX,y:C.clientY}),L.setPointerCapture?.(C.pointerId),D.current.size>=2?(te.current={kind:"pinch",startX:C.clientX,startY:C.clientY,startScrollLeft:L.scrollLeft,startScrollTop:L.scrollTop,startDistance:W(),startZoom:H.current,moved:!1},M.current=!0):H.current>1&&(te.current={kind:"pan",startX:C.clientX,startY:C.clientY,startScrollLeft:L.scrollLeft,startScrollTop:L.scrollTop,startZoom:H.current,moved:!1}))},G=C=>{if(!D.current.has(C.pointerId))return;D.current.set(C.pointerId,{x:C.clientX,y:C.clientY});const L=p.current,q=te.current;if(!(!L||!q)){if(D.current.size>=2&&q.kind==="pinch"){const ne=W();if(!q.startDistance||!ne)return;const pe=_(q.startZoom*ne/q.startDistance);if(Math.abs(pe-H.current)<.01)return;const Ne=Array.from(D.current.values()),we=(Ne[0].x+Ne[1].x)/2,Pe=(Ne[0].y+Ne[1].y)/2;q.moved=!0,M.current=!0,ae(L,pe,we,Pe),C.preventDefault();return}if(q.kind==="pan"&&D.current.size===1){const ne=C.clientX-q.startX,pe=C.clientY-q.startY;if(!q.moved&&Math.hypot(ne,pe)<6)return;q.moved=!0,M.current=!0,L.scrollLeft=q.startScrollLeft-ne,L.scrollTop=q.startScrollTop-pe,C.preventDefault()}}},le=C=>{const L=p.current,q=te.current,ne=D.current.size===1&&!q?.moved;D.current.delete(C.pointerId);try{L?.releasePointerCapture?.(C.pointerId)}catch{}if(D.current.size===1&&q?.kind==="pinch"){const we=Array.from(D.current.values())[0];te.current=L?{kind:"pan",startX:we.x,startY:we.y,startScrollLeft:L.scrollLeft,startScrollTop:L.scrollTop,startZoom:H.current,moved:!1}:null;return}if(D.current.size>0||(te.current=null,q?.kind==="pinch"&&R(H.current),!ne||M.current))return;const pe=Date.now(),Ne=I.current;Ne&&pe-Ne.time<350&&Math.hypot(C.clientX-Ne.x,C.clientY-Ne.y)<24?(I.current=null,M.current=!0,R(we=>we>1?1:2.5)):I.current={time:pe,x:C.clientX,y:C.clientY}},j=C=>{if(!C.ctrlKey&&!C.metaKey)return;const L=p.current;if(!L)return;C.preventDefault();const q=ae(L,H.current*Math.exp(-C.deltaY*.01),C.clientX,C.clientY);R(q)},F=()=>{R(1),H.current=1,p.current&&(p.current.scrollLeft=0,p.current.scrollTop=0)},ee=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:p,role:"button",tabIndex:0,onClick:be,onDoubleClick:C=>{C.preventDefault(),R(L=>L>1?1:2.5)},onPointerDown:he,onPointerMove:G,onPointerUp:le,onPointerCancel:le,onWheel:j,onScroll:()=>$(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:m?t.jsx("div",{className:"p-4 text-sm text-destructive",children:m}):g?t.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:g}}):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&&Y&&t.jsx(wo,{anchor:{xPercent:P.stageXPercent,yPercent:P.stageYPercent},title:"引用 SVG 标注",onClick:async C=>{await c?.(Y,`svg:${P.x.toFixed(2)}:${P.y.toFixed(2)}`,void 0,C)!==!1&&$(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(),F()},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:t.jsx(Bp,{size:14})}),t.jsx("button",{type:"button","aria-label":b?"退出全屏 SVG":"全屏 SVG",title:b?"退出全屏 SVG":"全屏 SVG",onClick:C=>{C.stopPropagation(),A(L=>!L)},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(ee,document.body):ee}function fo(r){switch(r){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function _m(r,a,i,c){const f=[`电子标注: ${r}`,`视图: ${fo(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 p=[c.nearest.net?`网络 ${c.nearest.net}`:null,`对象层 ${c.nearest.layer}`,`距离 ${c.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");f.push(`最近对象: ${c.nearest.label}${p?`(${p})`:""}`)}return`"${f.join(" / ")}"`}function Bm({blobUrl:r,filePath:a,view:i,board:c,onViewChange:f,onInsertAnnotation:p,onRefresh:g,interactive3d:k}){const{t:m}=_t(),x=n.useRef(null),w=n.useRef(null),R=n.useRef(null),[b,A]=n.useState(null),[P,$]=n.useState(!1);n.useEffect(()=>(R.current?.abort(),A(null),$(!1),()=>R.current?.abort()),[r,i]);const D=n.useMemo(()=>b?_m(a,i,b,b.inspection):null,[a,b,i]),te=I=>{const H=x.current,Y=w.current;if(!H||!Y||!Y.naturalWidth||!Y.naturalHeight)return;const be=H.getBoundingClientRect(),_=Y.getBoundingClientRect(),o=Math.min(_.width/Y.naturalWidth,_.height/Y.naturalHeight),ae=Y.naturalWidth*o,W=Y.naturalHeight*o,he=_.left+(_.width-ae)/2,G=_.top+(_.height-W)/2,le=I.clientX-he,j=I.clientY-G;if(le<0||j<0||le>ae||j>W)return;const F={xPercent:Math.max(0,Math.min(100,le/ae*100)),yPercent:Math.max(0,Math.min(100,j/W*100)),stageXPercent:(I.clientX-be.left)/be.width*100,stageYPercent:(I.clientY-be.top)/be.height*100,inspecting:c&&i!=="pcb-3d"};if(A(F),R.current?.abort(),!F.inspecting)return;const ee=new AbortController;R.current=ee,sh(a,i,F.xPercent,F.yPercent,ee.signal).then(C=>A(L=>L===F?{...L,inspection:C,inspecting:!1}:L)).catch(()=>{ee.signal.aborted||A(C=>C===F?{...C,inspection:{available:!1},inspecting:!1}:C)})},M=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:M.map(I=>t.jsx("button",{type:"button",onClick:()=>f(I),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${I===i?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:fo(I)},I))}),t.jsx("button",{type:"button",onClick:g,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:m("rightSidebar.edaRefresh"),"aria-label":m("rightSidebar.edaRefresh"),children:t.jsx(uo,{size:13})})]}),c&&k?t.jsx("div",{className:i==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:k}):null,c?i==="pcb-3d"?k?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:te,onKeyDown:I=>{I.key!=="Enter"&&I.key!==" "||(I.preventDefault(),A({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:m("rightSidebar.edaPickHint"),children:[t.jsx("img",{ref:w,src:r,alt:`${a} ${fo(i)}`,onLoad:()=>$(!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&&D&&t.jsx(wo,{anchor:{xPercent:b.stageXPercent,yPercent:b.stageYPercent},disabled:b.inspecting,title:m("rightSidebar.edaInsertAnnotation"),onClick:async I=>{await p?.(D,`eda:${i}:${b.xPercent.toFixed(1)}:${b.yPercent.toFixed(1)}`,{snapshot:w.current?qp(w.current,b):Promise.resolve(null)},I)!==!1&&A(null)},children:m("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?m("rightSidebar.edaInspecting"):b.inspection?.available?m("rightSidebar.edaPickedBoardPosition",{x:b.inspection.xMm?.toFixed(2)??"—",y:b.inspection.yMm?.toFixed(2)??"—",object:b.inspection.nearest?.label??m("rightSidebar.edaNoNearbyObject")}):m("rightSidebar.edaPickedPosition",{x:b.xPercent.toFixed(1),y:b.yPercent.toFixed(1)}):m("rightSidebar.edaPickHint")})})]}):t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(hu,{blobUrl:r,filePath:a,viewLabel:fo(i),onInsertAnnotation:p})})]})}function Um(r){const a=[];let i=[],c="",f=!1;for(let p=0;p<r.length;p+=1){const g=r[p];f?g==='"'&&r[p+1]==='"'?(c+='"',p+=1):g==='"'?f=!1:c+=g:g==='"'?f=!0:g===","?(i.push(c),c=""):g===`
|
|
14
|
+
`?(i.push(c.replace(/\r$/,"")),a.push(i),i=[],c=""):c+=g}return(c||i.length>0)&&(i.push(c.replace(/\r$/,"")),a.push(i)),a}function Om(r,a,i,c,f){const p=a[f]||`第${f+1}列`,g=i[f]??"",k=a.map((m,x)=>`${m||`第${x+1}列`}=${i[x]??""}`).join(";");return`"表格标注: ${r} / 数据行: ${c+1} / 列: ${p} / 值: ${g} / 记录: ${k}"`}function Hm({content:r,filePath:a,onInsertAnnotation:i}){const{t:c}=_t(),f=n.useMemo(()=>Um(r),[r]),p=f[0]??[],g=f.slice(1),k=n.useRef(null),[m,x]=n.useState(null),w=m?g[m.row]:null,R=m&&w?Om(a,p,w,m.row+1,m.column):null;return t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[t.jsxs("div",{ref:k,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:"#"}),p.map((b,A)=>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:A+1})},`${b}:${A}`))]})}),t.jsx("tbody",{children:g.map((b,A)=>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:A+1}),p.map((P,$)=>{const D=m?.row===A&&m.column===$;return t.jsx("td",{className:`border-b border-r border-border/15 p-0 ${D?"bg-primary/15":""}`,children:t.jsx("button",{type:"button",onClick:te=>{const M=k.current?.getBoundingClientRect(),I=te.currentTarget.getBoundingClientRect();if(!M?.width||!M.height)return;const H=te.clientX||I.left+I.width/2,Y=te.clientY||I.top+I.height/2;x({row:A,column:$,xPercent:(H-M.left)/M.width*100,yPercent:(Y-M.top)/M.height*100})},className:"block h-full min-h-9 w-full whitespace-pre-wrap px-3 py-2 text-left text-foreground outline-none hover:bg-primary/10 focus-visible:bg-primary/10",children:b[$]||" "})},`cell:${A}:${$}`)})]},`row:${A}`))})]})}),m&&R&&t.jsx(wo,{anchor:{xPercent:m.xPercent,yPercent:m.yPercent},title:c("rightSidebar.csvInsertAnnotation"),onClick:async b=>{await i?.(R,`csv:${a}:${m.row+1}:${m.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:m&&w?c("rightSidebar.csvSelectedCell",{row:m.row+1,column:p[m.column]||m.column+1}):c("rightSidebar.csvPickHint",{rows:g.length,columns:p.length})})})]})}function ls(r,a){let i=r;for(const c of a){if(!i||typeof i!="object")return;i=i[c]}return i}function zm(r,a){const i=JSON.parse(r),c=ls(i,["meta","version"]);if(a)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(c??"未知")},{label:"活动层编号",value:String(ls(i,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(ls(i,["board","visible_layers"])??"未知")},{label:"Git 集成",value:ls(i,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const f=ls(i,["net_settings","classes"]),p=Array.isArray(f)?f.find(k=>k&&typeof k=="object"&&k.name==="Default"):void 0,g=ls(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:p?.clearance!==void 0?`${p.clearance} mm`:"未设置"},{label:"默认线宽",value:p?.track_width!==void 0?`${p.track_width} mm`:"未设置"},{label:"默认过孔",value:p?.via_diameter!==void 0?`${p.via_diameter} / ${p.via_drill??"—"} mm(外径/钻孔)`:"未设置"},{label:"DRC 排除项",value:String(Array.isArray(g)?g.length:0)}]}function Gm(r,a){return`"KiCad项目标注: ${r} / 项: ${a.label} / 值: ${a.value}"`}function Wm({content:r,filePath:a,localState:i,onInsertAnnotation:c}){const{t:f}=_t(),p=n.useRef(null),[g,k]=n.useState(null),m=n.useMemo(()=>{try{return{items:zm(r,i),error:null}}catch(w){return{items:[],error:w instanceof Error?w.message:String(w)}}},[r,i]),x=g===null?null:m.items[g.index];return m.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:p,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:m.items.map((w,R)=>t.jsxs("button",{type:"button",onClick:b=>{const A=p.current?.getBoundingClientRect(),P=b.currentTarget.getBoundingClientRect();if(!A?.width||!A.height)return;const $=b.clientX||P.left+P.width/2,D=b.clientY||P.top+P.height/2;k({index:R,xPercent:($-A.left)/A.width*100,yPercent:(D-A.top)/A.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 ${g?.index===R?"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&&g&&t.jsx(wo,{anchor:{xPercent:g.xPercent,yPercent:g.yPercent},title:f("rightSidebar.kicadInsertSetting"),onClick:async w=>{await c?.(Gm(a,x),`kicad-project:${a}:${x.label}`,void 0,w)!==!1&&k(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 qm=`/** ES Module Shims Wasm @version 2.8.4 */
|
|
15
15
|
(function () {
|
|
16
16
|
|
|
17
17
|
const self_ = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
@@ -1497,7 +1497,7 @@ import{aR as Dr,e6 as _t,cc as t,m as po,cm as Qd,p as Gi,s as lt,F as eh,g as d
|
|
|
1497
1497
|
};
|
|
1498
1498
|
|
|
1499
1499
|
})();
|
|
1500
|
-
`,
|
|
1500
|
+
`,Km=`/* Runs only in the opaque preview frame. All local reads use its directory capability. */
|
|
1501
1501
|
function installPreviewRuntime(capability, base, externalOrigins, shimUrl) {
|
|
1502
1502
|
const external = new Set(externalOrigins);
|
|
1503
1503
|
const report = () => parent.postMessage({ type: 'preview-error', capability }, '*');
|
|
@@ -1632,26 +1632,26 @@ function installPreviewRuntime(capability, base, externalOrigins, shimUrl) {
|
|
|
1632
1632
|
window.addEventListener('error', report, true);
|
|
1633
1633
|
window.addEventListener('unhandledrejection', report);
|
|
1634
1634
|
}
|
|
1635
|
-
`,ao="/api/terminal/fs/preview/",
|
|
1636
|
-
installPreviewRuntime(`+[f,p,[...w],ee].map(
|
|
1637
|
-
`+C.documentElement.outerHTML;return{html:Pe,shellUrl:`/preview-shell.html#${f}`,errors:g,attach(O,ue){const oe=new Set,Fe=E=>{if(E.source!==O.contentWindow||E.data?.capability!==f)return;if(E.data.type==="preview-ready"){O.contentWindow?.postMessage({type:"preview-init",capability:f,html:Pe,resources:x},"*");return}if(E.data.type==="preview-error"){ue("部分动态内容被安全预览限制");return}if(E.data.type==="preview-navigate"){(async()=>{const ge=W(String(E.data.url)),De=await pu(ge.pathname+ge.search,a);if(P){De.dispose();return}const Ve=De.attach(O,ue);$.add(()=>{Ve(),De.dispose()}),O.src=De.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(ge=>ue(ge instanceof Error?ge.message:"无法打开预览页面"));return}if(E.data.type==="preview-external"){try{const ge=new URL(String(E.data.url));ge.protocol==="https:"&&w.has(ge.origin)&&window.open(ge.href,"_blank","noopener,noreferrer")}catch{}return}if(E.data.type!=="preview-fetch"||E.ports.length!==1)return;const xe=E.ports[0];if(oe.size>=8||!["GET","HEAD"].includes(E.data.method)){xe.postMessage({error:"预览仅允许读取已授权目录资源"}),xe.close();return}oe.add(xe),(async()=>{const ge=W(String(E.data.url)),De=await he(ge);if(!oe.has(xe)||P)return;const Ve=E.data.method==="HEAD"?new Uint8Array:De.bytes.slice();xe.postMessage({status:De.status,headers:{"content-type":De.type},data:Ve.buffer},[Ve.buffer])})().catch(()=>{xe.postMessage({error:"预览资源不在授权范围或无法加载"}),ue("部分动态资源不可用或超出预览目录")}).finally(()=>{oe.delete(xe),xe.close()})};window.addEventListener("message",Fe);const Ie=()=>{window.removeEventListener("message",Fe);for(const E of oe)E.close();oe.clear(),$.delete(Ie)};return $.add(Ie),Ie},dispose:D}}catch(F){throw D(),F}}const
|
|
1638
|
-
`);const b=f.length;f+=w.data,c.push({node:w,start:b,end:f.length,group:R}),p=R}const k=f.toLocaleLowerCase(),m=[];let x=0;for(;x<=k.length-i.length;){const w=k.indexOf(i,x);if(w<0)break;const R=w+i.length,b=c.find(P=>P.start<=w&&P.end>w),A=c.find(P=>P.start<R&&P.end>=R);if(b&&A&&b.group===A.group){const P=document.createRange();P.setStart(b.node,w-b.start),P.setEnd(A.node,R-A.start),m.push(P)}x=w+Math.max(i.length,1)}return m}function gu(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}let xo;function Td(r){return xo===r}function oo(r){if(r&&xo!==r)return;const a=gu();a?.delete(mu),a?.delete(Zi),xo=void 0}function Ii(r,a,i){const c=gu();if(!c||typeof Highlight>"u")return;xo=i,c.set(mu,new Highlight(...r));const f=r[a];f?c.set(Zi,new Highlight(f)):c.delete(Zi)}function Md(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function ag(r){return Array.from(new Set(r.split(/[\n,]/).map(a=>a.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function og(r,a){const i=a.trim();return!i||i==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(i)?i.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${i.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function ig(r,a){if(a===r)return".";const i=`${r.replace(/[\\/]+$/,"")}/`;return a.startsWith(i)?a.slice(i.length):a}function bu(r,a,i){return a?r:Qr.createPortal(r,i)}const ol="termdock:right-sidebar:file-tree-scroll:v1",il="termdock:right-sidebar:file-preview-reading-state:v1",ea="termdock:right-sidebar:file-tree-width:v1",xu="termdock:right-sidebar:markdown-view-mode:v1",vu="termdock:right-sidebar:diff-change-list-mode:v1",yu="termdock:right-sidebar:diff-wrap:v1",wu="termdock:diff-viewer:view-type:v1",ku="termdock:right-sidebar:file-search-mode:v1",$i="termdock:right-sidebar:collapsed-git-repo-groups:v1",Ld="termdock:right-sidebar:collapsed-diff-directories:v1",Fi="termdock:right-sidebar:branch-audit-module-open:v1",Su="termdock:right-sidebar:branch-audit-module:v1",lg=150,Id="termdock:right-sidebar:context-draft-enabled:v1",$d="termdock:right-sidebar:context-draft-collapsed:v1",Fd="termdock:right-sidebar:context-draft-auto-collapse:v1",Di="termdock:right-sidebar:context-draft-text:v1",cg=300,dg=20,ug=120,fg=250,hg=250,pg=120,mg=700,_i=600,gg=6e4;function Vs(r){return!!(r&&U.getState().nestedGitScanRoots[r])}const Dd=[2e3,5e3,15e3,3e4],bg=320,xg=500,vg=20,yg=12e3,el=300,_d=240,wg=560,Bd=n.lazy(()=>sl(()=>import("./ModelPreview-C9nka14O.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]))),kg=n.lazy(()=>sl(()=>import("./ArchitecturePanel-Dlnd9PH-.js"),__vite__mapDeps([32,1,2,3,4,5,33,11,12,13,14,23,20,24,25,34,17,18,19,8,9,10,15,22,6,21,26,27,28,29,30,31,35])).then(r=>({default:r.ArchitecturePanel}))),Sg=n.lazy(()=>sl(()=>import("./ComputerControlView-VNUyl2Gb.js").then(r=>r.a),__vite__mapDeps([36,1,2,3,4,5,28,30,15,37,29,38])));function Ru(r,a,i){return r&&!a?"unified":i}const Rg=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function jg(r){return r==="preview"||r==="source"}function Cg(r){return r==="list"||r==="tree"||r==="ai"}function Ud(){return ct(xu,jg)??"preview"}function Ng(){return ct(vu,Cg)??"tree"}function ta(r){return typeof r=="boolean"}function Pg(r){return typeof r=="string"}function Eg(){return ct(yu,ta)??!0}function Ag(r){return r==="unified"||r==="split"}function Tg(){return ct(wu,Ag)??"unified"}function Mg(r){return r==="name"||r==="content"||r==="regex"}function Lg(){return ct(ku,Mg)??"name"}function ju(r){return r.repositories??(r.context?.root?[{id:r.context.root,root:r.context.root,relativeRoot:".",name:gt(r.context.root)||r.context.root,depth:0,nested:!1,available:r.available,files:r.files,context:r.context,error:r.error}]:[])}function Ig(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 Cu(...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 Od(r){const a=ct(r,rl);return a?new Set(a):new Set}function Bi(r,a){Pt(r,[...a])}function $g(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 Fg(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($g))&&(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 Dg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const a=r;return typeof a.key=="string"&&Fg(a.diff)&&typeof a.repoLabel=="string"&&typeof a.createdAt=="number"}function _g(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(Dg))&&(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 Hd(){return ct(Su,_g)??{}}function zd(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function Gd(r){const a=r?.trim()??"",i=a.indexOf("/");return i>=0?a.slice(i+1):a}function Nu(r,a){const i=r?.trim(),c=a?.trim();return!i||!c?!1:i===c||Gd(i)===Gd(c)}function Wd(r){const a=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(c=>c&&!Nu(c,a))??""}function nl(r,a){const i=Math.max(_d,a-320),c=Math.min(wg,i);return Math.min(c,Math.max(_d,r))}function Bg(r){return typeof r=="number"&&Number.isFinite(r)}function Ug(r){return nl(ct(ea,Bg)??el,r)}function Pu(r){const a=r.split(/[\\/]/).pop()??r,i=a.lastIndexOf(".");return i>=0?a.slice(i).toLowerCase():""}function Ys(r){return Rg.has(Pu(r))}function cs({label:r,value:a,options:i,placeholder:c,searchPlaceholder:f,emptyText:p,disabled:g,onChange:k}){const{t:m}=_t(),[x,w]=n.useState(!1),[R,b]=n.useState(""),[A,P]=n.useState(null),$=n.useRef(null),D=n.useRef(null),te=R.trim().toLowerCase(),M=n.useMemo(()=>te?i.filter(_=>`${_.label} ${_.meta??""}`.toLowerCase().includes(te)):i,[te,i]),I=i.find(_=>_.value===a),H=()=>{const _=R.trim();_&&(k(_),w(!1),b(""))},Y=n.useCallback(()=>{const _=$.current?.getBoundingClientRect();if(!_)return!1;const o=12,ae=Math.max(220,Math.min(_.width,window.innerWidth-o*2)),W=Math.min(Math.max(o,_.left),window.innerWidth-ae-o),he=window.innerHeight-_.bottom-o,G=_.top-o,le=he>=180||he>=G,j=Math.max(96,(le?he:G)-4),F=Math.min(320,j);return P({left:W,top:le?_.bottom+4:Math.max(o,_.top-F-4),width:ae,maxHeight:F}),!0},[]),be=()=>{Y(),w(!0)};return n.useEffect(()=>{if(!x)return;let _=0;const o=()=>{_||(_=window.requestAnimationFrame(()=>{_=0,Y()}))},ae=W=>{const he=W.target;he instanceof Node&&($.current?.contains(he)||D.current?.contains(he)||(w(!1),b("")))};return window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),document.addEventListener("pointerdown",ae,!0),()=>{_&&window.cancelAnimationFrame(_),window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0),document.removeEventListener("pointerdown",ae,!0)}},[x,Y]),t.jsxs("div",{className:"relative min-w-0",children:[t.jsxs("button",{ref:$,type:"button",disabled:g,onClick:()=>{if(!g){if(b(""),x){w(!1);return}be()}},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:I?.label??(a||c)})]}),t.jsx(sa,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${x?"rotate-180":""}`})]}),x&&!g&&typeof document<"u"&&Qr.createPortal(t.jsxs("div",{ref:D,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:_=>_.stopPropagation(),style:{left:A?.left??12,top:A?.top??12,width:A?.width??260,maxHeight:A?.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(us,{size:12,className:"shrink-0 text-muted-foreground"}),t.jsx("input",{autoFocus:!0,value:R,onChange:_=>b(_.target.value),onKeyDown:_=>{if(_.key==="Escape"){_.preventDefault(),w(!1),b("");return}_.key==="Enter"&&(_.preventDefault(),H())},onBlur:()=>{R.trim()&&M.length===0&&H()},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,(A?.maxHeight??320)-46)},children:[R.trim()&&!i.some(_=>_.value===R.trim())&&t.jsxs("button",{type:"button",onMouseDown:_=>_.preventDefault(),onClick:H,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:R.trim()}),t.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:m("common.use")})]}),M.length>0?M.map(_=>t.jsxs("button",{type:"button",onClick:()=>{k(_.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 ${_.value===a?"bg-accent/10 text-accent":"text-foreground"}`,children:[t.jsx("span",{className:"min-w-0 truncate font-medium",children:_.label}),_.meta&&t.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:_.meta})]},_.value)):t.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:p})]})]}),document.body)]})}function qd({open:r,onOpenChange:a,showScopePicker:i,selectedAll:c,repos:f,selectedRoots:p,onToggleRepo:g,onGenerate:k,onSecondaryAction:m,disabled:x,generateDisabled:w,secondaryDisabled:R,inserted:b,buttonLabel:A,insertedLabel:P,title:$,ariaLabel:D,scopeTitle:te,scopeLabel:M,allLabel:I,generateLabel:H,secondaryLabel:Y,secondaryTitle:be,secondaryLoading:_,loading:o,error:ae,statusTitle:W,extraContent:he,renderRepoExtra:G,menuItem:le=!1}){return t.jsxs("div",{className:le?"relative w-full":"relative inline-flex shrink-0",children:[t.jsxs("button",{type:"button",role:le?"menuitem":void 0,tabIndex:le?-1:void 0,onClick:j=>{i?a(!r):w||k(j.currentTarget)},disabled:x,className:`relative flex items-center rounded-md transition disabled:cursor-not-allowed disabled:opacity-50 ${le?"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"} ${ae?"text-destructive hover:bg-destructive/5":b?"bg-surface-elevated text-foreground":le?"text-foreground hover:bg-surface-2":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":D,title:W??(i?`${te}: ${M}`:$),children:[o?t.jsx(lt,{size:le?15:13,className:"shrink-0 animate-spin"}):t.jsx(aa,{size:le?15:13,className:le?"shrink-0 text-muted-foreground":void 0}),t.jsx("span",{className:le?"min-w-0 flex-1":void 0,children:b?P:A}),i&&(le?t.jsx(ds,{size:13,className:"shrink-0 text-muted-foreground"}):t.jsx(sa,{size:11,className:`shrink-0 transition ${r?"rotate-180":""}`})),ae&&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:te}),t.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:M})]}),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(Xt,{size:14})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[he,t.jsxs("button",{type:"button",onClick:()=>g(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:I}),c&&t.jsx("span",{className:"text-[10px]",children:"✓"})]}),f.map(j=>{const F=p.includes(j.root);return t.jsxs("div",{className:`mt-1 rounded-md transition ${F?"bg-primary/15 text-primary":""}`,children:[t.jsxs("button",{type:"button",onClick:()=>g(j.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${F?"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})]}),F&&t.jsx("span",{className:"text-[10px]",children:"✓"})]}),G&&(c||F)&&t.jsx("div",{className:"px-2 pb-2",children:G(j)})]},j.root)})]}),t.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${m&&Y?"sm:grid-cols-2":""}`,children:[m&&Y&&t.jsxs("button",{type:"button",onClick:()=>{R||(a(!1),m())},disabled:R,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:be,children:[_?t.jsx(lt,{size:12,className:"animate-spin"}):t.jsx(lu,{size:12}),Y]}),t.jsxs("button",{type:"button",onClick:async j=>{if(w)return;await k(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:$,children:[t.jsx(aa,{size:12}),H]})]})]})}),document.body)]})}function Og(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 Eu(){return ct(ol,Og)??{}}function Hg(r,a){const i=Eu(),c=Object.entries({...i,[r]:{top:a,updatedAt:Date.now()}}).sort(([,f],[,p])=>p.updatedAt-f.updatedAt).slice(0,dg);ra(ol,Object.fromEntries(c),fg)}function zg(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 Gg(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&&!zg(i.lineRange)||typeof i.updatedAt!="number"||!Number.isFinite(i.updatedAt))return!1}return!0}function ll(r,a){if(!a)return null;const i=r&&!a.startsWith("/")?`${r}/${a}`:a;return r?`${r}::${i}`:i}function Au(){return ct(il,Gg)??{}}function Kd(r,a){const i=ll(r,a);return i?Au()[i]??null:null}function Ui(r,a,i){const c=ll(r,a);if(!c)return;const f=Au(),p=f[c]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},g=Object.entries({...f,[c]:{...p,...i,updatedAt:Date.now()}}).sort(([,k],[,m])=>m.updatedAt-k.updatedAt).slice(0,ug);ra(il,Object.fromEntries(g),hg)}function Oi({slow:r}){return t.jsx(ap,{slow:r})}function io({message:r,onRetry:a}){const{t:i}=_t();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 ho(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 gt(r){if(!r)return"";const a=r.replace(/\/+$/,"");return a.split("/").pop()||a||"/"}function lo(r){if(!r)return null;const a=r.replace(/\/+$/,"")||"/";if(a==="/")return null;const i=a.slice(0,a.lastIndexOf("/"))||"/";return i===a?null:i}function Wg(r,a,i){return Ki(r,a,i)}function Tu(r){const a=new Map;for(const i of r)a.set(cl(i),i);return a}function Mu(r,a){const i=new Map(r);for(const c of a)i.set(cl(c),c);return i}function Vd(r,a){let i=0;for(const c of r){const f=ut(c,a);f&&a&&f!==a&&(i+=1)}return i}function qg(r){return r.reduce((a,i)=>a+(i.staged?1:0),0)}function Kg(r,a){return Array.from(Mu(Tu(r),a).values()).sort((i,c)=>i.path.localeCompare(c.path))}function Vg(r,a){const i=r.relativeRoot==="."?gt(a??r.root)||r.name||r.root:r.relativeRoot||r.name||gt(r.root)||r.root;return{root:r.root,label:i,branch:r.context?.branch??null,count:r.files.length,staged:qg(r.files)}}function Lu(r,a){const i=gt(a??"")||a||"";return r.map(c=>Vg(c,a)).sort((c,f)=>i&&c.label===i?-1:i&&f.label===i?1:c.label.localeCompare(f.label))}function Iu(r,a,i,c,f){const p=ju(i),g=p.find($=>$.root===c)??p[0]??null,k=a.find($=>$.root===c)??null,m=k?.relativeRoot??g?.relativeRoot??".",x=k?.name??g?.name??(gt(c)||c),w=(g?.files??i.files).map($=>({...$,repoRoot:c,repoRelativeRoot:m,repoName:x})),R=g?.context??i.context,b={...k??g??{id:c,root:c,relativeRoot:m,name:x,depth:0,nested:!!(f&&c!==f),available:i.available,files:[],context:null},...g??{},id:k?.id??g?.id??c,root:c,displayRoot:k?.displayRoot??g?.displayRoot,relativeRoot:m,name:x,depth:k?.depth??g?.depth??0,nested:k?.nested??g?.nested??!!(f&&c!==f),available:g?.available??i.available,deferred:g?.deferred??!1,files:w,context:R?{...R,root:c,changedFiles:w.map($=>({path:$.path,absolutePath:$.absolutePath,status:$.status}))}:null,untrackedDeferred:g?.untrackedDeferred??i.untrackedDeferred,error:g?.error??i.error},A=k?a.map($=>$.root===c?b:$):[...a,b];return{files:Array.from(r).filter($=>ut($,f)!==c).concat(w),repositories:A,repoFilters:Lu(A,f)}}function ut(r,a){return r.repoRoot??a}function cl(r){return`${r.repoRoot??""}\0${r.path}`}function xr(r){return r.absolutePath||r.path}function Hi(r){return cl(r)}function Yg(r){return r.repoRelativeRoot&&r.repoRelativeRoot!=="."?r.repoRelativeRoot:r.repoName??""}function Yd(r){return r.reduce((a,i)=>a+(i.staged?1:0),0)}function Xd(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 Xs(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 Js(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 Xg(r){const a=r.error??r.context?.error??"";return a.includes("request was cancelled")||a.includes("IO_REQUEST_CANCELLED")}function Jd(r){return r?.available===!1&&r.code==="NOT_GIT_REPOSITORY"}function Jg({actions:r,running:a,completed:i}){const{t:c}=_t(),[f,p]=n.useState(!1),g=n.useRef(null),k=r.find(x=>a?.action===x.key),m=r.find(x=>i?.action===x.key);return r.length===0?null:(n.useEffect(()=>{if(!f)return;const x=R=>{const b=R.target;b instanceof Node&&g.current?.contains(b)||p(!1)},w=R=>{R.key==="Escape"&&p(!1)};return document.addEventListener("pointerdown",x),document.addEventListener("keydown",w),()=>{document.removeEventListener("pointerdown",x),document.removeEventListener("keydown",w)}},[f]),t.jsxs("div",{ref:g,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),p(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":m?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:k?.label??m?.label??c("rightSidebar.gitQuickActions"),children:k?t.jsx(lt,{size:13,className:"animate-spin"}):m?t.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):t.jsx(po,{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,R=i?.action===x.key;return t.jsxs("button",{type:"button",onClick:b=>{b.stopPropagation(),x.onClick(),p(!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 ${R?"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(lt,{size:13,className:"animate-spin"}):R?"✓":null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:x.label})]},x.key)})})]}))}function Qg(r){const a=window.getComputedStyle(r).overflowY;return(a==="auto"||a==="scroll")&&r.scrollHeight>r.clientHeight+1}function $u(r){let a=r;for(;a;){if(a.classList.contains("termdock-diff-stream-scroller")&&Qg(a))return a;a=a.parentElement}return r.closest(".termdock-diff-stream-scroller")}function fs(r){return r.getClientRects().length>0&&window.getComputedStyle(r).visibility!=="hidden"}const zi=new WeakMap;function vo(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 Zg(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 k of c){if(!fs(k))continue;const m=k.querySelector(i);if(m&&fs(m)){f=m;break}}if(f??=Array.from(document.querySelectorAll(i)).find(fs)??null,!f)return;const p=$u(f);if(!p){f.scrollIntoView({block:"start",behavior:"smooth"}),vo(f);return}const g=f.getBoundingClientRect().top-p.getBoundingClientRect().top+p.scrollTop;p.scrollTo({top:Math.max(0,g),behavior:"instant"}),vo(f)}function Tn(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,p=r.hunkFingerprint?CSS.escape(r.hunkFingerprint):null,g=[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&&p?`[data-diff-hunk-anchor="${a}"][data-diff-hunk-index="${c}"][data-diff-hunk-fingerprint="${p}"]`:null,c!==null?`[data-diff-hunk-anchor="${a}"][data-diff-hunk-index="${c}"]`:null,`[data-diff-file-path="${a}"]`].filter(P=>!!P),k=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let m=null;for(const P of k)if(fs(P)){for(const $ of g){const D=P.querySelector($);if(D&&fs(D)){m=D;break}}if(m)break}if(m??=g.flatMap(P=>Array.from(document.querySelectorAll(P))).find(fs)??null,!m){Zg(r.filePath);return}const x=$u(m);if(!x){m.scrollIntoView({block:"center",behavior:"smooth"}),vo(m);return}const w=m.getBoundingClientRect(),R=x.getBoundingClientRect(),A=w.top-R.top+x.scrollTop-Math.max(24,(x.clientHeight-w.height)/2);x.scrollTo({top:Math.max(0,A),behavior:"instant"}),vo(m)}let eb=0,tb=0,rb=0,nb=0,sb=0;function st(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:++tb,ts:Date.now(),...a}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0}).catch(()=>{})}function Qs(r,a={}){if(typeof window>"u")return;const i=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${r}`,data:{seq:++nb,ts:Date.now(),...a}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0}).catch(()=>{})}function ab(){return`diff-ui-${Date.now().toString(36)}-${(++sb).toString(36)}`}function ob(r){return r instanceof Element?r.closest("[data-diff-selection-path]"):null}function ib(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:p,onReferenceCopied:g,onClose:k,onDirectoryLinkOpen:m,isMobile:x,markdownOutlineOpen:w,markdownOutlineCloseSignal:R,onOpenMarkdownOutline:b,onCloseMarkdownOutline:A,markdownImageLightboxOpen:P,markdownImageLightboxCloseSignal:$,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:te,lineRange:M,onLineRangeChange:I,insertedReferenceKey:H,copiedReferenceKey:Y,scrollToLine:be,onScrollToLineHandled:_}){const{t:o}=_t(),ae=n.useRef(null),W=n.useRef({}),he=n.useRef(i);he.current=i,n.useEffect(()=>{i||ae.current?.querySelectorAll("video").forEach(S=>S.pause())},[i]);const G=U(S=>S.rootPath),le=U(S=>S.selectFile),[j,F]=n.useState({kind:"idle"}),[ee,C]=n.useState("schematic"),[L,q]=n.useState(null),ne=n.useRef(null),[pe,Ne]=n.useState(null),we=n.useRef(new Map),Pe=n.useRef(null),[O,ue]=n.useState(null),[oe,Fe]=n.useState(()=>Ud()),[Ie,E]=n.useState(()=>Pd(G,a)),xe=n.useRef(null),[ge,De]=n.useState(!1),[Ve,Ae]=n.useState(null),[Jt,Be]=n.useState(0),[ft,Ue]=n.useState([]),[Qt,me]=n.useState(null),dt=n.useRef(null),at=n.useRef(a),[bt,Oe]=n.useState(null),V=km(G&&a&&!a.startsWith("/")?`${G}/${a}`:a,i),[ye,Ze]=n.useState(!1),[wt,ir]=n.useState(""),[N,Q]=n.useState([]),[ke,Ye]=n.useState(0),ht=n.useRef(null),yr=tu(g),kt=ll(G,a);n.useEffect(()=>{if(at.current===a)return;at.current=a;const S=a&&G&&!a.startsWith("/")?`${G}/${a}`:a;if(dt.current===S){dt.current=null;return}dt.current=null,Ue([]),me(null),Ze(!1),ir("")},[a,G]);const St=a?G&&!a.startsWith("/")?`${G}/${a}`:a:null,Mn=U(S=>St?(S.fileChangeVersions.get(St)??0)+S.fileWatchEpoch:S.fileWatchEpoch),hs=n.useRef(null),wr=n.useRef(null),[Bt,Zr]=n.useState(0),Zt=n.useCallback(()=>Zr(S=>S+1),[]);n.useEffect(()=>{const S=ne.current;return ne.current=null,q(null),S&&URL.revokeObjectURL(S.objectUrl),()=>{const T=ne.current;ne.current=null,T&&URL.revokeObjectURL(T.objectUrl)}},[St,Mn,Bt]),n.useEffect(()=>{if(!a){hs.current=null,F({kind:"idle"});return}const S=G&&!a.startsWith("/")?`${G}/${a}`:a,T=new AbortController,ce=++eb,Se=`right-sidebar-file-preview:${ce}`,Je=performance.now();let Te=!1;const ze=(K,We={})=>{Te||(Te=!0,Ei("end",{loadingId:ce,reason:K,durationMs:Math.round(performance.now()-Je),filePath:a,fullPath:S,rootPath:G,...We}))};let Me=null;const Ge=oh(S),ot=Ge?S.toLowerCase().endsWith(".kicad_pcb")?ee==="schematic"?"pcb-front":ee:"schematic":ee,Fn=!Ge&&ih(S),cr=!Ge&&!Fn&&lh(S),ys=!Ge&&!Fn&&!cr&&ch(S),an=Ys(S),on=qs(S),Gr=Ge?"eda":Fn?"image":cr?"model3d":ys?"video":"text",ln=hs.current!==S;if(hs.current=S,ln){Ei("start",{loadingId:ce,filePath:a,fullPath:S,rootPath:G,mode:Gr,externalVersion:Mn}),F({kind:"loading",mode:Gr}),wr.current=null;const K=Kd(G,a);I(K?.lineRange??null),Fe(an?Ud():"source"),E(on?Pd(G,a):"source"),Ge&&C(dh(S))}ln||F(K=>K.kind==="error"?{kind:"loading",mode:Gr}:K);const cn=window.setTimeout(()=>{Te||T.signal.aborted||Ei("still_active",{loadingId:ce,filePath:a,fullPath:S,rootPath:G,mode:Gr,durationMs:Math.round(performance.now()-Je),isPathChange:ln})},3e3),ws=window.setTimeout(()=>{if(Te||T.signal.aborted)return;const K=Ge?o("rightSidebar.edaTimeout"):cr?o("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";T.abort(new DOMException(K,"TimeoutError")),F({kind:"error",message:K}),ze("stuck_timeout",{error:K})},Ge?uh+5e3:cr?fh+5e3:hh(S)?35e3:yg);if(Ge){const K=ot==="pcb-3d"?ne.current:null;K?(F(K),ze("eda_3d_client_cache_hit",{bytes:K.meta.size,view:K.view,mimeType:K.meta.mimeType})):ph(S,ot,T.signal,"view_file",Se).then(We=>{if(T.signal.aborted)return;Me=URL.createObjectURL(We.blob);const Tt={kind:"eda",sourcePath:We.path||S,objectUrl:Me,view:We.view,meta:{size:We.size,mimeType:We.mimeType,modified:We.modified}};if(We.view==="pcb-3d"){const dr=ne.current;dr&&dr.objectUrl!==Me&&URL.revokeObjectURL(dr.objectUrl),ne.current=Tt,q(Tt),Me=null}F(Tt),ze("eda_loaded",{bytes:We.size,view:We.view,mimeType:We.mimeType})}).catch(We=>{T.signal.aborted||(F({kind:"error",message:We instanceof Error&&/timed out/i.test(We.message)?o("rightSidebar.edaTimeout"):We instanceof Error?We.message:o("rightSidebar.edaLoadFailed")}),ze("error",{error:We instanceof Error?We.message:String(We)}))})}else if(Fn)mh(S,T.signal,"view_file",Se).then(K=>{Me=URL.createObjectURL(K.blob),F({kind:"image",objectUrl:Me,meta:{size:K.size,mimeType:K.mimeType,modified:K.modified}}),ze("image_loaded",{bytes:K.size,mimeType:K.mimeType})}).catch(K=>{T.signal.aborted||(F({kind:"error",message:K instanceof Error?K.message:o("rightSidebar.imageLoadFailed")}),ze("error",{error:K instanceof Error?K.message:String(K)}))});else if(cr)gh(S,T.signal,"view_file",Se).then(K=>{T.signal.aborted||(Me=URL.createObjectURL(K.blob),F({kind:"model3d",sourcePath:K.path||S,objectUrl:Me,ext:K.ext,meta:{size:K.size,mimeType:K.mimeType,modified:K.modified}}),ze("model3d_loaded",{bytes:K.size,ext:K.ext}))}).catch(K=>{T.signal.aborted||(F({kind:"error",message:K instanceof Error&&(K.name==="TimeoutError"||/timed out/i.test(K.message))?o("rightSidebar.model3dTimeout"):K instanceof Error?K.message:o("rightSidebar.model3dLoadFailed")}),ze("error",{error:K instanceof Error?K.message:String(K)}))});else if(ys){const K=bh(S)??"",We=$h(S);F(Tt=>Tt.kind==="video"&&Tt.url===We?Tt:{kind:"video",url:We,meta:{size:null,mimeType:K,modified:null}}),ze("video_ready",{mimeType:K})}else ed(S,T.signal,"view_file",Se).then(K=>{if(!T.signal.aborted){if(K.binary){F({kind:"binary"});return}F({kind:"text",content:K.content,sourcePath:K.path||S,meta:{size:K.size,truncated:K.truncated}}),ze("text_loaded",{bytes:K.size,truncated:!!K.truncated})}}).catch(K=>{T.signal.aborted||(F({kind:"error",message:K instanceof Error?K.message:"Failed to read file"}),ze("error",{error:K instanceof Error?K.message:String(K)}))});return()=>{T.abort(),yt(Se),window.clearTimeout(cn),window.clearTimeout(ws),Me&&URL.revokeObjectURL(Me),ze("cleanup")}},[a,G,Mn,Bt,I,o,ee]),n.useEffect(()=>{if(j.kind!=="model3d"||!a){Ne(null);return}let S=!1;const T=a.lastIndexOf("/"),ce=T>=0?a.slice(T+1):a,Se=T>=0?a.slice(0,T):"",Je=Se.lastIndexOf("/"),Te=Je>=0?Se.slice(0,Je):"",ze=ce.replace(/\.(stl|glb|gltf)$/i,""),Me=`${Te?`${Te}/`:""}features/${ze}.json`;return ed(Me).then(Ge=>{if(!S)try{const ot=JSON.parse(Ge.content);Ne(ot.version===1&&Array.isArray(ot.features)&&ot.features.length>0?ot.features:null)}catch{Ne(null)}}).catch(()=>{S||Ne(null)}),()=>{S=!0}},[j,a]),n.useEffect(()=>{if(j.kind!=="text"){Oe(null);return}const S=G&&a&&!a.startsWith("/")?`${G}/${a}`:a,T=yp(S),ce=j.content,Se=Ys(S??"")&&oe==="preview",Je=qs(S??"")&&Ie==="preview";if(!T||Se||Je||!wp(ce)){Oe(null);return}let Te=!1;const ze=Me=>{if(Te||!Me.registered(T)){Te||Oe(null);return}try{Oe(Sp(Me,ce,T))}catch{Oe(null)}};return Ve?ze(Ve):(Oe(null),kp().then(Me=>{Te||(Ae(Me),ze(Me))}).catch(()=>{})),()=>{Te=!0}},[j,Ve,a,G,oe,Ie]),n.useLayoutEffect(()=>{if(!kt||j.kind!=="text")return;const S=`${kt}:${oe}:${Ie}`;if(wr.current===S)return;const T=Kd(G,a);if(wr.current=S,!T)return;const ce=requestAnimationFrame(()=>{const Se=Pe.current;if(!Se)return;const Je=oe==="preview"?T.markdownTop??T.top:T.top;Se.scrollTo({top:Math.max(0,Je??0),left:Math.max(0,T.left??0)}),Be(oe==="preview"?Math.max(0,Je??0):0)});return()=>cancelAnimationFrame(ce)},[a,oe,Ie,j.kind,kt,G]),n.useEffect(()=>{kt&&Ui(G,a,{lineRange:M})},[a,M,kt,G]),n.useEffect(()=>{if(be==null||j.kind!=="text")return;ue(null),I({start:be,end:be});const S=be,T=requestAnimationFrame(()=>{const ce=we.current.get(S);ce&&ce.scrollIntoView({block:"center"}),_?.()});return()=>cancelAnimationFrame(T)},[be,j,I,_]);const Ln=n.useCallback(S=>{const T=Pe.current;if(!T)return!1;const ce=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(S):S.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Se=T.querySelector(`#${ce}`);return Se?(Se.scrollIntoView({block:"start"}),!0):!1},[]);n.useEffect(()=>{const S=G&&a&&!a.startsWith("/")?`${G}/${a}`:a,T=j.kind==="text"&&Ys(S??"")&&oe==="preview";if(!Qt||!T)return;const ce=requestAnimationFrame(()=>{Ln(Qt)&&me(null)});return()=>cancelAnimationFrame(ce)},[a,Ln,oe,Qt,j,G]),n.useLayoutEffect(()=>{const S=Pe.current;if(!S||!M){ue(null);return}if(O)return;const T=j.kind==="image"||j.kind==="loading"&&j.mode==="image",ce=G&&a&&!a.startsWith("/")?`${G}/${a}`:a,Se=j.kind==="text"&&Ys(ce??"")&&oe==="preview",Je=j.kind==="text"&&qs(ce??"")&&Ie==="preview";if(j.kind!=="text"||T||Se||Je){ue(null);return}const Te=()=>{const Me=we.current.get(M.end);if(!Me||!S){ue(null);return}const Ge=Me.offsetTop+Me.offsetHeight/2,ot=S.scrollLeft+Math.max(8,S.clientWidth-120);ue({top:Ge,left:ot})};Te();const ze=new ResizeObserver(()=>Te());return ze.observe(S),()=>ze.disconnect()},[M,O,j,oe,Ie,a,G,bt]);const kr=j.kind==="text"&&!(qs(St??"")&&Ie==="preview")&&!St?.toLowerCase().endsWith(".csv")&&!St?.toLowerCase().endsWith(".kicad_pro")&&!St?.toLowerCase().endsWith(".kicad_prl"),In=n.useCallback(()=>{Ze(!1),ir(""),Q([]),Ye(0),oo(W.current)},[]),en=n.useCallback(()=>{!i||!kr||(Ze(!0),requestAnimationFrame(()=>{const S=ae.current;!he.current||!S?.isConnected||S.closest('[inert], [aria-hidden="true"], [hidden]')||S.getClientRects().length===0||getComputedStyle(S).visibility==="hidden"||!S.contains(document.activeElement)||(ht.current?.focus(),ht.current?.select())}))},[i,kr]),_r=n.useCallback(S=>{Ye(T=>N.length===0?0:(T+S+N.length)%N.length)},[N.length]),Ut=n.useCallback(S=>{if(S.nativeEvent.isComposing||!tg(ae.current,i,S))return;const T=rg(S);if(T==="open"&&kr){S.preventDefault(),en();return}ye&&(T==="close"?(S.preventDefault(),In()):(T==="next"||T==="previous")&&(S.preventDefault(),_r(T==="previous"?-1:1)))},[i,In,ye,_r,en,kr]);if(n.useLayoutEffect(()=>{if(oo(W.current),!i||!ye||!wt.trim()||!Pe.current){Q([]),Ye(0);return}const S=sg(Pe.current,wt);return Q(S),Ye(0),(ae.current?.contains(document.activeElement)||Td(W.current))&&(Ii(S,0,W.current),Md(S[0])),()=>oo(W.current)},[i,ye,wt,bt,oe,j]),n.useEffect(()=>{!i||!ye||!wt.trim()||!ae.current?.contains(document.activeElement)&&!Td(W.current)||(Ii(N,ke,W.current),Md(N[ke]))},[i,ke,N,ye,wt]),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=G&&!a.startsWith("/")?`${G}/${a}`:a,Et=ho(He,G),Sr=ru(He,G),Rr=j.kind==="text"&&j.content?j.content.split(`
|
|
1639
|
-
`):[],oa=Math.max(2,String(Rr.length).length)+1,jr=j.kind==="text"||j.kind==="image"||j.kind==="model3d"||j.kind==="video"||j.kind==="eda"?j.meta:null,Cr=Ys(He),ia=He.toLowerCase().endsWith(".csv"),At=He.toLowerCase().endsWith(".kicad_pro"),ps=He.toLowerCase().endsWith(".kicad_prl"),Ot=j.kind==="text"&&Cr&&oe==="preview",la=qs(He),Ht=j.kind==="text"&&la&&Ie==="preview",ca=j.kind==="image"||j.kind==="loading"&&j.mode==="image",ko=j.kind==="model3d"||j.kind==="loading"&&j.mode==="model3d",xt=j.kind==="video"||j.kind==="loading"&&j.mode==="video",tn=j.kind==="eda"||j.kind==="loading"&&j.mode==="eda",ms=j.kind==="text"?j.sourcePath:He,
|
|
1635
|
+
`,ao="/api/terminal/fs/preview/",Vm=8*1024*1024,Ym=32*1024*1024,Xm=128,Jm="data:,";function Nt(r){throw new Error(r)}function Qm(r){return JSON.stringify(r).replace(/</g,"\\u003c")}async function Ad(r,a,i){let c="",f=0;for(const p of r.matchAll(a))c+=r.slice(f,p.index)+await i(p),f=p.index+p[0].length;return c+r.slice(f)}async function pu(r,a){const i=a.origin??location.origin,c=new URL(r,i);(c.origin!==i||!Ws(c.pathname)?.startsWith(ao))&&Nt("预览地址不是有效的本地文件入口");const f=crypto.randomUUID(),p=`https://termdock-preview.invalid/${f}/`,g=[],k=F=>{!g.includes(F)&&g.length<20&&g.push(F)},m=new Set,x=[],w=new Set,R=new Map,b=new Map;let A=0,P=!1;const $=new Set,D=()=>{P=!0;for(const F of[...$])F();m.clear(),x.length=0};async function te(F){F.ok||Nt(`预览资源读取失败(${F.status})`);const ee=F.body?.getReader(),C=[];let L=0;try{if(ee)for(;;){const pe=await ee.read();if(pe.done)break;L+=pe.value.byteLength,A+=pe.value.byteLength,(L>Vm||A>Ym)&&Nt("预览资源超出大小限制"),C.push(pe.value)}}catch(pe){throw await ee?.cancel().catch(()=>{}),pe}finally{ee?.releaseLock()}const q=new Uint8Array(L);let ne=0;for(const pe of C)q.set(pe,ne),ne+=pe.length;return{bytes:q,type:F.headers.get("content-type")??"application/octet-stream",status:F.status}}let M=c,I;for(let F=0;F<4;F++){const ee=await a.fetch(M.pathname+M.search,{signal:a.signal,redirect:"manual"});if(![301,302,303,307,308].includes(ee.status)){I=ee;break}const C=ee.headers.get("location");await ee.body?.cancel(),C||Nt("预览重定向缺少目标");const L=new URL(C,M);(L.origin!==i||!Ws(L.pathname)?.startsWith(ao))&&Nt("预览重定向越出文件范围"),M=L}I||Nt("预览重定向次数过多");const H=Ws(M.pathname),Y=H.slice(ao.length).split("/");/^[a-f0-9]{32}$/.test(Y[0])||Nt("服务未提供有效的预览资源授权");const be=Ws(c.pathname).slice(ao.length).split("/");/^[a-f0-9]{32}$/.test(be[0])&&be.shift(),be.join("/").replace(/\/$/,"")!==Y.slice(1).join("/").replace(/\/$/,"")&&Nt("预览重定向改变了文件范围");const _=H.endsWith("/")?H:H.slice(0,H.lastIndexOf("/")+1),o=new URL(M.pathname.endsWith("/")?M.pathname:M.pathname.slice(0,M.pathname.lastIndexOf("/")+1),i);function ae(F,ee){const C=new URL(F,ee);return C.origin!==i?null:(Ws(C.pathname)?.startsWith(_)||Nt("已阻止预览访问目录之外的资源"),C)}function W(F){const ee=new URL(F,p);(ee.origin!==new URL(p).origin||!ee.pathname.startsWith(new URL(p).pathname))&&Nt("已阻止预览访问服务接口或目录之外的资源");const C=ee.pathname.slice(new URL(p).pathname.length)+ee.search;return ae(C,o)??Nt("预览资源无效")}function he(F){const ee=F.pathname+F.search,C=R.get(ee);if(C)return C;if(P||a.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(R.size>=Xm)return Promise.reject(new Error("预览资源数量超出限制"));const L=a.fetch(ee,{signal:a.signal,redirect:"manual"}).then(te);return R.set(ee,L),L}function G(F,ee){P&&Nt("预览已关闭");const C=`termdock-resource-${f}-${x.length}`;return x.push({token:C,data:F,type:ee}),m.add(C),C}async function le(F,ee,C,L=new Set){if(!F||F.startsWith("#")||/^data:(?:image|font)\//i.test(F)&&C==="resource")return F;try{const q=ae(F,ee);if(!q){const Pe=new URL(F,ee);return(Pe.protocol!=="https:"||Pe.username||Pe.password||Pe.origin===new URL(p).origin)&&Nt("已阻止不安全的外部资源"),w.add(Pe.origin),Pe.href}const ne=`${C}:${q.href}`;(L.has(ne)||L.size>=8)&&Nt("预览资源存在循环或过深引用");const pe=b.get(ne);if(pe)return pe;const Ne=new Set(L);Ne.add(ne);const we=(async()=>{const Pe=await he(q);return C==="css"?G(await j(new TextDecoder().decode(Pe.bytes),q,Ne),"text/css"):C==="script"?G(Pe.bytes,"text/javascript"):G(Pe.bytes,Pe.type)})();return b.set(ne,we),await we}catch(q){return k(q instanceof Error?q.message:"部分预览资源未能加载"),Jm}}async function j(F,ee,C){return F=await Ad(F,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async L=>`@import url("${await le(L[1],ee,"css",C)}")${L[2]};`),Ad(F,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async L=>{const q=(L[1]??L[2]??L[3]).trim();return m.has(q)?L[0]:`url("${await le(q,ee,"resource",C)}")`})}try{const F=await te(I),ee=G(qm,"text/javascript"),C=new DOMParser().parseFromString(new TextDecoder().decode(F.bytes),"text/html");C.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(O=>O.remove());for(const O of C.querySelectorAll("*")){if(O.removeAttribute("ping"),O.removeAttribute("srcdoc"),O.hasAttribute("style")&&O.setAttribute("style",await j(O.getAttribute("style"),M,new Set)),O.tagName==="STYLE"&&(O.textContent=await j(O.textContent??"",M,new Set)),O.tagName==="A"||O.tagName==="AREA"){const ue=O.getAttribute("href");try{if(ue&&!ue.startsWith("#")){const oe=ae(ue,M);if(oe)O.setAttribute("href",new URL(oe.pathname.slice(o.pathname.length)+oe.search+oe.hash,p).href);else{const Fe=new URL(ue,M);if(Fe.protocol!=="https:"){O.removeAttribute("href");continue}w.add(Fe.origin),O.setAttribute("href",Fe.href)}}}catch(oe){O.removeAttribute("href"),k(oe instanceof Error?oe.message:"预览链接无法加载")}}for(const ue of["data","manifest"])O.removeAttribute(ue);if(O.tagName==="SCRIPT"&&O.getAttribute("type")==="module"){O.setAttribute("type","module-shim");const ue=O.getAttribute("src");if(ue){const oe=ae(ue,M);if(oe)O.setAttribute("src",new URL(oe.pathname.slice(o.pathname.length)+oe.search,p).href);else{const Fe=new URL(ue,M);if(Fe.protocol!=="https:"){O.remove();continue}w.add(Fe.origin),O.setAttribute("src",Fe.href)}}continue}if(O.tagName==="SCRIPT"&&O.getAttribute("type")==="importmap"){O.setAttribute("type","importmap-shim");continue}if(O.tagName==="LINK"){const ue=(O.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(ue)){O.remove();continue}const oe=O.getAttribute("href");oe&&O.setAttribute("href",await le(oe,M,ue==="stylesheet"?"css":"resource"))}if(O.hasAttribute("src")&&O.setAttribute("src",await le(O.getAttribute("src"),M,O.tagName==="SCRIPT"?"script":"resource")),O.hasAttribute("poster")&&O.setAttribute("poster",await le(O.getAttribute("poster"),M,"resource")),O.hasAttribute("srcset")){const ue=O.getAttribute("srcset");/data:/i.test(ue)?(O.removeAttribute("srcset"),k("混合内嵌图片候选暂不支持安全预览")):O.setAttribute("srcset",(await Promise.all(ue.split(",").map(async oe=>{const[Fe,...Ie]=oe.trim().split(/\s+/);return`${await le(Fe,M,"resource")} ${Ie.join(" ")}`}))).join(", "))}O.setAttribute("referrerpolicy","no-referrer"),O.removeAttribute("integrity"),O.removeAttribute("crossorigin")}const L=[...w].join(" "),q=C.createElement("meta");q.httpEquiv="Content-Security-Policy",q.content=`default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${L}; style-src 'unsafe-inline' blob: ${L}; img-src blob: data: ${L}; font-src blob: data: ${L}; media-src blob: data: ${L}; connect-src blob: ${L} ${[...w].map(O=>O.replace(/^https:/,"wss:")).join(" ")}; worker-src blob:; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const ne=C.createElement("base");ne.href=p;const pe=C.createElement("meta");pe.name="referrer",pe.content="no-referrer";const Ne=C.createElement("script");Ne.textContent=Km+`
|
|
1636
|
+
installPreviewRuntime(`+[f,p,[...w],ee].map(Qm).join(",")+");";const we=C.createElement("script");we.src=ee,C.head.prepend(q,pe,ne,Ne,we);const Pe=`<!doctype html>
|
|
1637
|
+
`+C.documentElement.outerHTML;return{html:Pe,shellUrl:`/preview-shell.html#${f}`,errors:g,attach(O,ue){const oe=new Set,Fe=E=>{if(E.source!==O.contentWindow||E.data?.capability!==f)return;if(E.data.type==="preview-ready"){O.contentWindow?.postMessage({type:"preview-init",capability:f,html:Pe,resources:x},"*");return}if(E.data.type==="preview-error"){ue("部分动态内容被安全预览限制");return}if(E.data.type==="preview-navigate"){(async()=>{const ge=W(String(E.data.url)),De=await pu(ge.pathname+ge.search,a);if(P){De.dispose();return}const Ve=De.attach(O,ue);$.add(()=>{Ve(),De.dispose()}),O.src=De.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(ge=>ue(ge instanceof Error?ge.message:"无法打开预览页面"));return}if(E.data.type==="preview-external"){try{const ge=new URL(String(E.data.url));ge.protocol==="https:"&&w.has(ge.origin)&&window.open(ge.href,"_blank","noopener,noreferrer")}catch{}return}if(E.data.type!=="preview-fetch"||E.ports.length!==1)return;const xe=E.ports[0];if(oe.size>=8||!["GET","HEAD"].includes(E.data.method)){xe.postMessage({error:"预览仅允许读取已授权目录资源"}),xe.close();return}oe.add(xe),(async()=>{const ge=W(String(E.data.url)),De=await he(ge);if(!oe.has(xe)||P)return;const Ve=E.data.method==="HEAD"?new Uint8Array:De.bytes.slice();xe.postMessage({status:De.status,headers:{"content-type":De.type},data:Ve.buffer},[Ve.buffer])})().catch(()=>{xe.postMessage({error:"预览资源不在授权范围或无法加载"}),ue("部分动态资源不可用或超出预览目录")}).finally(()=>{oe.delete(xe),xe.close()})};window.addEventListener("message",Fe);const Ie=()=>{window.removeEventListener("message",Fe);for(const E of oe)E.close();oe.clear(),$.delete(Ie)};return $.add(Ie),Ie},dispose:D}}catch(F){throw D(),F}}const Zm=n.forwardRef(function({src:a,title:i,exitFullscreenLabel:c,onFullscreenChange:f},p){const g=n.useRef(null),[k,m]=n.useState(null),[x,w]=n.useState(),[R,b]=n.useState("");n.useEffect(()=>{const H=new AbortController;let Y;return w(void 0),b(""),(async()=>{const be=await ah();if(Y=await pu(a,{fetch:(_,o)=>be.fetch(_,o),signal:H.signal}),H.signal.aborted){Y.dispose();return}w(Y),Y.errors.length&&b(Y.errors.join(";"))})().catch(be=>{H.signal.aborted||b(be instanceof Error?be.message:"安全预览加载失败")}),()=>{H.abort(),Y?.dispose()}},[a]),n.useEffect(()=>{if(!(!x||!k))return x.attach(k,b)},[x,k]);const[A,P]=n.useState(!1),[$,D]=n.useState(!1),te=A||$;n.useEffect(()=>{f?.(te)},[te,f]),n.useEffect(()=>{const H=()=>{P(document.fullscreenElement===g.current)};return document.addEventListener("fullscreenchange",H),()=>document.removeEventListener("fullscreenchange",H)},[]),n.useEffect(()=>{if(!$)return;const H=Y=>{Y.key==="Escape"&&D(!1)};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[$]);const M=n.useCallback(async()=>{const H=g.current;if(H){if($){D(!1);return}if(document.fullscreenElement===H){await document.exitFullscreen();return}if(H.requestFullscreen&&document.fullscreenEnabled!==!1)try{await H.requestFullscreen();return}catch{}D(!0)}},[$]);n.useImperativeHandle(p,()=>({toggleFullscreen:M}),[M]);const I=t.jsxs("div",{ref:g,"data-html-preview-frame":!0,className:te?"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:[te&&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:()=>{M()},"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})})]}),R&&t.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:R}),!x&&!R&&t.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),t.jsx("iframe",{ref:m,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 $?Qr.createPortal(I,document.body):I}),mu="termdock-file-search-match",Zi="termdock-file-search-current";function eg(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 tg(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 rg(r){return r.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function ng(r,a){const i=a.trim().toLocaleLowerCase();if(!i)return[];const c=[];let f="",p=null;const g=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);for(let w=g.nextNode();w;w=g.nextNode()){if(!(w instanceof Text)||!w.data)continue;const R=rg(w);if(!R)continue;p&&p!==R&&(f+=`
|
|
1638
|
+
`);const b=f.length;f+=w.data,c.push({node:w,start:b,end:f.length,group:R}),p=R}const k=f.toLocaleLowerCase(),m=[];let x=0;for(;x<=k.length-i.length;){const w=k.indexOf(i,x);if(w<0)break;const R=w+i.length,b=c.find(P=>P.start<=w&&P.end>w),A=c.find(P=>P.start<R&&P.end>=R);if(b&&A&&b.group===A.group){const P=document.createRange();P.setStart(b.node,w-b.start),P.setEnd(A.node,R-A.start),m.push(P)}x=w+Math.max(i.length,1)}return m}function gu(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}let xo;function Td(r){return xo===r}function oo(r){if(r&&xo!==r)return;const a=gu();a?.delete(mu),a?.delete(Zi),xo=void 0}function Ii(r,a,i){const c=gu();if(!c||typeof Highlight>"u")return;xo=i,c.set(mu,new Highlight(...r));const f=r[a];f?c.set(Zi,new Highlight(f)):c.delete(Zi)}function Md(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function sg(r){return Array.from(new Set(r.split(/[\n,]/).map(a=>a.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function ag(r,a){const i=a.trim();return!i||i==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(i)?i.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${i.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function og(r,a){if(a===r)return".";const i=`${r.replace(/[\\/]+$/,"")}/`;return a.startsWith(i)?a.slice(i.length):a}function bu(r,a,i){return a?r:Qr.createPortal(r,i)}const ol="termdock:right-sidebar:file-tree-scroll:v1",il="termdock:right-sidebar:file-preview-reading-state:v1",ea="termdock:right-sidebar:file-tree-width:v1",xu="termdock:right-sidebar:markdown-view-mode:v1",vu="termdock:right-sidebar:diff-change-list-mode:v1",yu="termdock:right-sidebar:diff-wrap:v1",wu="termdock:diff-viewer:view-type:v1",ku="termdock:right-sidebar:file-search-mode:v1",$i="termdock:right-sidebar:collapsed-git-repo-groups:v1",Ld="termdock:right-sidebar:collapsed-diff-directories:v1",Fi="termdock:right-sidebar:branch-audit-module-open:v1",Su="termdock:right-sidebar:branch-audit-module:v1",ig=150,Id="termdock:right-sidebar:context-draft-enabled:v1",$d="termdock:right-sidebar:context-draft-collapsed:v1",Fd="termdock:right-sidebar:context-draft-auto-collapse:v1",Di="termdock:right-sidebar:context-draft-text:v1",lg=300,cg=20,dg=120,ug=250,fg=250,hg=120,pg=700,_i=600,mg=6e4;function Vs(r){return!!(r&&U.getState().nestedGitScanRoots[r])}const Dd=[2e3,5e3,15e3,3e4],gg=320,bg=500,xg=20,vg=12e3,el=300,_d=240,yg=560,Bd=n.lazy(()=>sl(()=>import("./ModelPreview-Cl0X7I-U.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,32]))),wg=n.lazy(()=>sl(()=>import("./ArchitecturePanel-CYdolNzT.js"),__vite__mapDeps([33,1,2,3,4,5,34,11,12,13,14,24,21,25,26,35,18,19,20,8,9,10,15,16,22,23,27,28,29,30,31,6,32,36])).then(r=>({default:r.ArchitecturePanel}))),kg=n.lazy(()=>sl(()=>import("./ComputerControlView-DU9krDsg.js").then(r=>r.a),__vite__mapDeps([37,1,2,3,4,5,29,31,15,38,30,39])));function Ru(r,a,i){return r&&!a?"unified":i}const Sg=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function Rg(r){return r==="preview"||r==="source"}function jg(r){return r==="list"||r==="tree"||r==="ai"}function Ud(){return ct(xu,Rg)??"preview"}function Cg(){return ct(vu,jg)??"tree"}function ta(r){return typeof r=="boolean"}function Ng(r){return typeof r=="string"}function Pg(){return ct(yu,ta)??!0}function Eg(r){return r==="unified"||r==="split"}function Ag(){return ct(wu,Eg)??"unified"}function Tg(r){return r==="name"||r==="content"||r==="regex"}function Mg(){return ct(ku,Tg)??"name"}function ju(r){return r.repositories??(r.context?.root?[{id:r.context.root,root:r.context.root,relativeRoot:".",name:gt(r.context.root)||r.context.root,depth:0,nested:!1,available:r.available,files:r.files,context:r.context,error:r.error}]:[])}function Lg(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 Cu(...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 Od(r){const a=ct(r,rl);return a?new Set(a):new Set}function Bi(r,a){Pt(r,[...a])}function Ig(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 $g(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(Ig))&&(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 Fg(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const a=r;return typeof a.key=="string"&&$g(a.diff)&&typeof a.repoLabel=="string"&&typeof a.createdAt=="number"}function Dg(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(Fg))&&(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 Hd(){return ct(Su,Dg)??{}}function zd(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function Gd(r){const a=r?.trim()??"",i=a.indexOf("/");return i>=0?a.slice(i+1):a}function Nu(r,a){const i=r?.trim(),c=a?.trim();return!i||!c?!1:i===c||Gd(i)===Gd(c)}function Wd(r){const a=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(c=>c&&!Nu(c,a))??""}function nl(r,a){const i=Math.max(_d,a-320),c=Math.min(yg,i);return Math.min(c,Math.max(_d,r))}function _g(r){return typeof r=="number"&&Number.isFinite(r)}function Bg(r){return nl(ct(ea,_g)??el,r)}function Pu(r){const a=r.split(/[\\/]/).pop()??r,i=a.lastIndexOf(".");return i>=0?a.slice(i).toLowerCase():""}function Ys(r){return Sg.has(Pu(r))}function cs({label:r,value:a,options:i,placeholder:c,searchPlaceholder:f,emptyText:p,disabled:g,onChange:k}){const{t:m}=_t(),[x,w]=n.useState(!1),[R,b]=n.useState(""),[A,P]=n.useState(null),$=n.useRef(null),D=n.useRef(null),te=R.trim().toLowerCase(),M=n.useMemo(()=>te?i.filter(_=>`${_.label} ${_.meta??""}`.toLowerCase().includes(te)):i,[te,i]),I=i.find(_=>_.value===a),H=()=>{const _=R.trim();_&&(k(_),w(!1),b(""))},Y=n.useCallback(()=>{const _=$.current?.getBoundingClientRect();if(!_)return!1;const o=12,ae=Math.max(220,Math.min(_.width,window.innerWidth-o*2)),W=Math.min(Math.max(o,_.left),window.innerWidth-ae-o),he=window.innerHeight-_.bottom-o,G=_.top-o,le=he>=180||he>=G,j=Math.max(96,(le?he:G)-4),F=Math.min(320,j);return P({left:W,top:le?_.bottom+4:Math.max(o,_.top-F-4),width:ae,maxHeight:F}),!0},[]),be=()=>{Y(),w(!0)};return n.useEffect(()=>{if(!x)return;let _=0;const o=()=>{_||(_=window.requestAnimationFrame(()=>{_=0,Y()}))},ae=W=>{const he=W.target;he instanceof Node&&($.current?.contains(he)||D.current?.contains(he)||(w(!1),b("")))};return window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),document.addEventListener("pointerdown",ae,!0),()=>{_&&window.cancelAnimationFrame(_),window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0),document.removeEventListener("pointerdown",ae,!0)}},[x,Y]),t.jsxs("div",{className:"relative min-w-0",children:[t.jsxs("button",{ref:$,type:"button",disabled:g,onClick:()=>{if(!g){if(b(""),x){w(!1);return}be()}},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:I?.label??(a||c)})]}),t.jsx(aa,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${x?"rotate-180":""}`})]}),x&&!g&&typeof document<"u"&&Qr.createPortal(t.jsxs("div",{ref:D,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:_=>_.stopPropagation(),style:{left:A?.left??12,top:A?.top??12,width:A?.width??260,maxHeight:A?.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(us,{size:12,className:"shrink-0 text-muted-foreground"}),t.jsx("input",{autoFocus:!0,value:R,onChange:_=>b(_.target.value),onKeyDown:_=>{if(_.key==="Escape"){_.preventDefault(),w(!1),b("");return}_.key==="Enter"&&(_.preventDefault(),H())},onBlur:()=>{R.trim()&&M.length===0&&H()},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,(A?.maxHeight??320)-46)},children:[R.trim()&&!i.some(_=>_.value===R.trim())&&t.jsxs("button",{type:"button",onMouseDown:_=>_.preventDefault(),onClick:H,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:R.trim()}),t.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:m("common.use")})]}),M.length>0?M.map(_=>t.jsxs("button",{type:"button",onClick:()=>{k(_.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 ${_.value===a?"bg-accent/10 text-accent":"text-foreground"}`,children:[t.jsx("span",{className:"min-w-0 truncate font-medium",children:_.label}),_.meta&&t.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:_.meta})]},_.value)):t.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:p})]})]}),document.body)]})}function qd({open:r,onOpenChange:a,showScopePicker:i,selectedAll:c,repos:f,selectedRoots:p,onToggleRepo:g,onGenerate:k,onSecondaryAction:m,disabled:x,generateDisabled:w,secondaryDisabled:R,inserted:b,buttonLabel:A,insertedLabel:P,title:$,ariaLabel:D,scopeTitle:te,scopeLabel:M,allLabel:I,generateLabel:H,secondaryLabel:Y,secondaryTitle:be,secondaryLoading:_,loading:o,error:ae,statusTitle:W,extraContent:he,renderRepoExtra:G,menuItem:le=!1}){return t.jsxs("div",{className:le?"relative w-full":"relative inline-flex shrink-0",children:[t.jsxs("button",{type:"button",role:le?"menuitem":void 0,tabIndex:le?-1:void 0,onClick:j=>{i?a(!r):w||k(j.currentTarget)},disabled:x,className:`relative flex items-center rounded-md transition disabled:cursor-not-allowed disabled:opacity-50 ${le?"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"} ${ae?"text-destructive hover:bg-destructive/5":b?"bg-surface-elevated text-foreground":le?"text-foreground hover:bg-surface-2":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":D,title:W??(i?`${te}: ${M}`:$),children:[o?t.jsx(lt,{size:le?15:13,className:"shrink-0 animate-spin"}):t.jsx(sa,{size:le?15:13,className:le?"shrink-0 text-muted-foreground":void 0}),t.jsx("span",{className:le?"min-w-0 flex-1":void 0,children:b?P:A}),i&&(le?t.jsx(ds,{size:13,className:"shrink-0 text-muted-foreground"}):t.jsx(aa,{size:11,className:`shrink-0 transition ${r?"rotate-180":""}`})),ae&&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:te}),t.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:M})]}),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(Xt,{size:14})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[he,t.jsxs("button",{type:"button",onClick:()=>g(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:I}),c&&t.jsx("span",{className:"text-[10px]",children:"✓"})]}),f.map(j=>{const F=p.includes(j.root);return t.jsxs("div",{className:`mt-1 rounded-md transition ${F?"bg-primary/15 text-primary":""}`,children:[t.jsxs("button",{type:"button",onClick:()=>g(j.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${F?"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})]}),F&&t.jsx("span",{className:"text-[10px]",children:"✓"})]}),G&&(c||F)&&t.jsx("div",{className:"px-2 pb-2",children:G(j)})]},j.root)})]}),t.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${m&&Y?"sm:grid-cols-2":""}`,children:[m&&Y&&t.jsxs("button",{type:"button",onClick:()=>{R||(a(!1),m())},disabled:R,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:be,children:[_?t.jsx(lt,{size:12,className:"animate-spin"}):t.jsx(lu,{size:12}),Y]}),t.jsxs("button",{type:"button",onClick:async j=>{if(w)return;await k(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:$,children:[t.jsx(sa,{size:12}),H]})]})]})}),document.body)]})}function Ug(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 Eu(){return ct(ol,Ug)??{}}function Og(r,a){const i=Eu(),c=Object.entries({...i,[r]:{top:a,updatedAt:Date.now()}}).sort(([,f],[,p])=>p.updatedAt-f.updatedAt).slice(0,cg);ra(ol,Object.fromEntries(c),ug)}function Hg(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 zg(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&&!Hg(i.lineRange)||typeof i.updatedAt!="number"||!Number.isFinite(i.updatedAt))return!1}return!0}function ll(r,a){if(!a)return null;const i=r&&!a.startsWith("/")?`${r}/${a}`:a;return r?`${r}::${i}`:i}function Au(){return ct(il,zg)??{}}function Kd(r,a){const i=ll(r,a);return i?Au()[i]??null:null}function Ui(r,a,i){const c=ll(r,a);if(!c)return;const f=Au(),p=f[c]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},g=Object.entries({...f,[c]:{...p,...i,updatedAt:Date.now()}}).sort(([,k],[,m])=>m.updatedAt-k.updatedAt).slice(0,dg);ra(il,Object.fromEntries(g),fg)}function Oi({slow:r}){return t.jsx(ap,{slow:r})}function io({message:r,onRetry:a}){const{t:i}=_t();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 ho(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 gt(r){if(!r)return"";const a=r.replace(/\/+$/,"");return a.split("/").pop()||a||"/"}function lo(r){if(!r)return null;const a=r.replace(/\/+$/,"")||"/";if(a==="/")return null;const i=a.slice(0,a.lastIndexOf("/"))||"/";return i===a?null:i}function Gg(r,a,i){return Vi(r,a,i)}function Tu(r){const a=new Map;for(const i of r)a.set(cl(i),i);return a}function Mu(r,a){const i=new Map(r);for(const c of a)i.set(cl(c),c);return i}function Vd(r,a){let i=0;for(const c of r){const f=ut(c,a);f&&a&&f!==a&&(i+=1)}return i}function Wg(r){return r.reduce((a,i)=>a+(i.staged?1:0),0)}function qg(r,a){return Array.from(Mu(Tu(r),a).values()).sort((i,c)=>i.path.localeCompare(c.path))}function Kg(r,a){const i=r.relativeRoot==="."?gt(a??r.root)||r.name||r.root:r.relativeRoot||r.name||gt(r.root)||r.root;return{root:r.root,label:i,branch:r.context?.branch??null,count:r.files.length,staged:Wg(r.files)}}function Lu(r,a){const i=gt(a??"")||a||"";return r.map(c=>Kg(c,a)).sort((c,f)=>i&&c.label===i?-1:i&&f.label===i?1:c.label.localeCompare(f.label))}function Iu(r,a,i,c,f){const p=ju(i),g=p.find($=>$.root===c)??p[0]??null,k=a.find($=>$.root===c)??null,m=k?.relativeRoot??g?.relativeRoot??".",x=k?.name??g?.name??(gt(c)||c),w=(g?.files??i.files).map($=>({...$,repoRoot:c,repoRelativeRoot:m,repoName:x})),R=g?.context??i.context,b={...k??g??{id:c,root:c,relativeRoot:m,name:x,depth:0,nested:!!(f&&c!==f),available:i.available,files:[],context:null},...g??{},id:k?.id??g?.id??c,root:c,displayRoot:k?.displayRoot??g?.displayRoot,relativeRoot:m,name:x,depth:k?.depth??g?.depth??0,nested:k?.nested??g?.nested??!!(f&&c!==f),available:g?.available??i.available,deferred:g?.deferred??!1,files:w,context:R?{...R,root:c,changedFiles:w.map($=>({path:$.path,absolutePath:$.absolutePath,status:$.status}))}:null,untrackedDeferred:g?.untrackedDeferred??i.untrackedDeferred,error:g?.error??i.error},A=k?a.map($=>$.root===c?b:$):[...a,b];return{files:Array.from(r).filter($=>ut($,f)!==c).concat(w),repositories:A,repoFilters:Lu(A,f)}}function ut(r,a){return r.repoRoot??a}function cl(r){return`${r.repoRoot??""}\0${r.path}`}function xr(r){return r.absolutePath||r.path}function Hi(r){return cl(r)}function Vg(r){return r.repoRelativeRoot&&r.repoRelativeRoot!=="."?r.repoRelativeRoot:r.repoName??""}function Yd(r){return r.reduce((a,i)=>a+(i.staged?1:0),0)}function Xd(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 Xs(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 Js(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 Yg(r){const a=r.error??r.context?.error??"";return a.includes("request was cancelled")||a.includes("IO_REQUEST_CANCELLED")}function Jd(r){return r?.available===!1&&r.code==="NOT_GIT_REPOSITORY"}function Xg({actions:r,running:a,completed:i}){const{t:c}=_t(),[f,p]=n.useState(!1),g=n.useRef(null),k=r.find(x=>a?.action===x.key),m=r.find(x=>i?.action===x.key);return r.length===0?null:(n.useEffect(()=>{if(!f)return;const x=R=>{const b=R.target;b instanceof Node&&g.current?.contains(b)||p(!1)},w=R=>{R.key==="Escape"&&p(!1)};return document.addEventListener("pointerdown",x),document.addEventListener("keydown",w),()=>{document.removeEventListener("pointerdown",x),document.removeEventListener("keydown",w)}},[f]),t.jsxs("div",{ref:g,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),p(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":m?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:k?.label??m?.label??c("rightSidebar.gitQuickActions"),children:k?t.jsx(lt,{size:13,className:"animate-spin"}):m?t.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):t.jsx(po,{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,R=i?.action===x.key;return t.jsxs("button",{type:"button",onClick:b=>{b.stopPropagation(),x.onClick(),p(!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 ${R?"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(lt,{size:13,className:"animate-spin"}):R?"✓":null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:x.label})]},x.key)})})]}))}function Jg(r){const a=window.getComputedStyle(r).overflowY;return(a==="auto"||a==="scroll")&&r.scrollHeight>r.clientHeight+1}function $u(r){let a=r;for(;a;){if(a.classList.contains("termdock-diff-stream-scroller")&&Jg(a))return a;a=a.parentElement}return r.closest(".termdock-diff-stream-scroller")}function fs(r){return r.getClientRects().length>0&&window.getComputedStyle(r).visibility!=="hidden"}const zi=new WeakMap;function vo(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 Qg(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 k of c){if(!fs(k))continue;const m=k.querySelector(i);if(m&&fs(m)){f=m;break}}if(f??=Array.from(document.querySelectorAll(i)).find(fs)??null,!f)return;const p=$u(f);if(!p){f.scrollIntoView({block:"start",behavior:"smooth"}),vo(f);return}const g=f.getBoundingClientRect().top-p.getBoundingClientRect().top+p.scrollTop;p.scrollTo({top:Math.max(0,g),behavior:"instant"}),vo(f)}function Tn(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,p=r.hunkFingerprint?CSS.escape(r.hunkFingerprint):null,g=[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&&p?`[data-diff-hunk-anchor="${a}"][data-diff-hunk-index="${c}"][data-diff-hunk-fingerprint="${p}"]`:null,c!==null?`[data-diff-hunk-anchor="${a}"][data-diff-hunk-index="${c}"]`:null,`[data-diff-file-path="${a}"]`].filter(P=>!!P),k=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let m=null;for(const P of k)if(fs(P)){for(const $ of g){const D=P.querySelector($);if(D&&fs(D)){m=D;break}}if(m)break}if(m??=g.flatMap(P=>Array.from(document.querySelectorAll(P))).find(fs)??null,!m){Qg(r.filePath);return}const x=$u(m);if(!x){m.scrollIntoView({block:"center",behavior:"smooth"}),vo(m);return}const w=m.getBoundingClientRect(),R=x.getBoundingClientRect(),A=w.top-R.top+x.scrollTop-Math.max(24,(x.clientHeight-w.height)/2);x.scrollTo({top:Math.max(0,A),behavior:"instant"}),vo(m)}let Zg=0,eb=0,tb=0,rb=0,nb=0;function st(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:++eb,ts:Date.now(),...a}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0}).catch(()=>{})}function Qs(r,a={}){if(typeof window>"u")return;const i=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${r}`,data:{seq:++rb,ts:Date.now(),...a}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0}).catch(()=>{})}function sb(){return`diff-ui-${Date.now().toString(36)}-${(++nb).toString(36)}`}function ab(r){return r instanceof Element?r.closest("[data-diff-selection-path]"):null}function ob(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:p,onReferenceCopied:g,onClose:k,onDirectoryLinkOpen:m,isMobile:x,markdownOutlineOpen:w,markdownOutlineCloseSignal:R,onOpenMarkdownOutline:b,onCloseMarkdownOutline:A,markdownImageLightboxOpen:P,markdownImageLightboxCloseSignal:$,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:te,lineRange:M,onLineRangeChange:I,insertedReferenceKey:H,copiedReferenceKey:Y,scrollToLine:be,onScrollToLineHandled:_}){const{t:o}=_t(),ae=n.useRef(null),W=n.useRef({}),he=n.useRef(i);he.current=i,n.useEffect(()=>{i||ae.current?.querySelectorAll("video").forEach(S=>S.pause())},[i]);const G=U(S=>S.rootPath),le=U(S=>S.selectFile),[j,F]=n.useState({kind:"idle"}),[ee,C]=n.useState("schematic"),[L,q]=n.useState(null),ne=n.useRef(null),[pe,Ne]=n.useState(null),we=n.useRef(new Map),Pe=n.useRef(null),[O,ue]=n.useState(null),[oe,Fe]=n.useState(()=>Ud()),[Ie,E]=n.useState(()=>Pd(G,a)),xe=n.useRef(null),[ge,De]=n.useState(!1),[Ve,Ae]=n.useState(null),[Jt,Be]=n.useState(0),[ft,Ue]=n.useState([]),[Qt,me]=n.useState(null),dt=n.useRef(null),at=n.useRef(a),[bt,Oe]=n.useState(null),V=wm(G&&a&&!a.startsWith("/")?`${G}/${a}`:a,i),[ye,Ze]=n.useState(!1),[wt,ir]=n.useState(""),[N,Q]=n.useState([]),[ke,Ye]=n.useState(0),ht=n.useRef(null),yr=tu(g),kt=ll(G,a);n.useEffect(()=>{if(at.current===a)return;at.current=a;const S=a&&G&&!a.startsWith("/")?`${G}/${a}`:a;if(dt.current===S){dt.current=null;return}dt.current=null,Ue([]),me(null),Ze(!1),ir("")},[a,G]);const St=a?G&&!a.startsWith("/")?`${G}/${a}`:a:null,Mn=U(S=>St?(S.fileChangeVersions.get(St)??0)+S.fileWatchEpoch:S.fileWatchEpoch),hs=n.useRef(null),wr=n.useRef(null),[Bt,Zr]=n.useState(0),Zt=n.useCallback(()=>Zr(S=>S+1),[]);n.useEffect(()=>{const S=ne.current;return ne.current=null,q(null),S&&URL.revokeObjectURL(S.objectUrl),()=>{const T=ne.current;ne.current=null,T&&URL.revokeObjectURL(T.objectUrl)}},[St,Mn,Bt]),n.useEffect(()=>{if(!a){hs.current=null,F({kind:"idle"});return}const S=G&&!a.startsWith("/")?`${G}/${a}`:a,T=new AbortController,ce=++Zg,Se=`right-sidebar-file-preview:${ce}`,Je=performance.now();let Te=!1;const ze=(K,We={})=>{Te||(Te=!0,Ei("end",{loadingId:ce,reason:K,durationMs:Math.round(performance.now()-Je),filePath:a,fullPath:S,rootPath:G,...We}))};let Me=null;const Ge=oh(S),ot=Ge?S.toLowerCase().endsWith(".kicad_pcb")?ee==="schematic"?"pcb-front":ee:"schematic":ee,Fn=!Ge&&ih(S),cr=!Ge&&!Fn&&lh(S),ys=!Ge&&!Fn&&!cr&&ch(S),an=Ys(S),on=qs(S),zr=Ge?"eda":Fn?"image":cr?"model3d":ys?"video":"text",ln=hs.current!==S;if(hs.current=S,ln){Ei("start",{loadingId:ce,filePath:a,fullPath:S,rootPath:G,mode:zr,externalVersion:Mn}),F({kind:"loading",mode:zr}),wr.current=null;const K=Kd(G,a);I(K?.lineRange??null),Fe(an?Ud():"source"),E(on?Pd(G,a):"source"),Ge&&C(dh(S))}ln||F(K=>K.kind==="error"?{kind:"loading",mode:zr}:K);const cn=window.setTimeout(()=>{Te||T.signal.aborted||Ei("still_active",{loadingId:ce,filePath:a,fullPath:S,rootPath:G,mode:zr,durationMs:Math.round(performance.now()-Je),isPathChange:ln})},3e3),ws=window.setTimeout(()=>{if(Te||T.signal.aborted)return;const K=Ge?o("rightSidebar.edaTimeout"):cr?o("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";T.abort(new DOMException(K,"TimeoutError")),F({kind:"error",message:K}),ze("stuck_timeout",{error:K})},Ge?uh+5e3:cr?fh+5e3:hh(S)?35e3:vg);if(Ge){const K=ot==="pcb-3d"?ne.current:null;K?(F(K),ze("eda_3d_client_cache_hit",{bytes:K.meta.size,view:K.view,mimeType:K.meta.mimeType})):ph(S,ot,T.signal,"view_file",Se).then(We=>{if(T.signal.aborted)return;Me=URL.createObjectURL(We.blob);const Tt={kind:"eda",sourcePath:We.path||S,objectUrl:Me,view:We.view,meta:{size:We.size,mimeType:We.mimeType,modified:We.modified}};if(We.view==="pcb-3d"){const dr=ne.current;dr&&dr.objectUrl!==Me&&URL.revokeObjectURL(dr.objectUrl),ne.current=Tt,q(Tt),Me=null}F(Tt),ze("eda_loaded",{bytes:We.size,view:We.view,mimeType:We.mimeType})}).catch(We=>{T.signal.aborted||(F({kind:"error",message:We instanceof Error&&/timed out/i.test(We.message)?o("rightSidebar.edaTimeout"):We instanceof Error?We.message:o("rightSidebar.edaLoadFailed")}),ze("error",{error:We instanceof Error?We.message:String(We)}))})}else if(Fn)mh(S,T.signal,"view_file",Se).then(K=>{Me=URL.createObjectURL(K.blob),F({kind:"image",objectUrl:Me,meta:{size:K.size,mimeType:K.mimeType,modified:K.modified}}),ze("image_loaded",{bytes:K.size,mimeType:K.mimeType})}).catch(K=>{T.signal.aborted||(F({kind:"error",message:K instanceof Error?K.message:o("rightSidebar.imageLoadFailed")}),ze("error",{error:K instanceof Error?K.message:String(K)}))});else if(cr)gh(S,T.signal,"view_file",Se).then(K=>{T.signal.aborted||(Me=URL.createObjectURL(K.blob),F({kind:"model3d",sourcePath:K.path||S,objectUrl:Me,ext:K.ext,meta:{size:K.size,mimeType:K.mimeType,modified:K.modified}}),ze("model3d_loaded",{bytes:K.size,ext:K.ext}))}).catch(K=>{T.signal.aborted||(F({kind:"error",message:K instanceof Error&&(K.name==="TimeoutError"||/timed out/i.test(K.message))?o("rightSidebar.model3dTimeout"):K instanceof Error?K.message:o("rightSidebar.model3dLoadFailed")}),ze("error",{error:K instanceof Error?K.message:String(K)}))});else if(ys){const K=bh(S)??"",We=$h(S);F(Tt=>Tt.kind==="video"&&Tt.url===We?Tt:{kind:"video",url:We,meta:{size:null,mimeType:K,modified:null}}),ze("video_ready",{mimeType:K})}else ed(S,T.signal,"view_file",Se).then(K=>{if(!T.signal.aborted){if(K.binary){F({kind:"binary"});return}F({kind:"text",content:K.content,sourcePath:K.path||S,meta:{size:K.size,truncated:K.truncated}}),ze("text_loaded",{bytes:K.size,truncated:!!K.truncated})}}).catch(K=>{T.signal.aborted||(F({kind:"error",message:K instanceof Error?K.message:"Failed to read file"}),ze("error",{error:K instanceof Error?K.message:String(K)}))});return()=>{T.abort(),yt(Se),window.clearTimeout(cn),window.clearTimeout(ws),Me&&URL.revokeObjectURL(Me),ze("cleanup")}},[a,G,Mn,Bt,I,o,ee]),n.useEffect(()=>{if(j.kind!=="model3d"||!a){Ne(null);return}let S=!1;const T=a.lastIndexOf("/"),ce=T>=0?a.slice(T+1):a,Se=T>=0?a.slice(0,T):"",Je=Se.lastIndexOf("/"),Te=Je>=0?Se.slice(0,Je):"",ze=ce.replace(/\.(stl|glb|gltf)$/i,""),Me=`${Te?`${Te}/`:""}features/${ze}.json`;return ed(Me).then(Ge=>{if(!S)try{const ot=JSON.parse(Ge.content);Ne(ot.version===1&&Array.isArray(ot.features)&&ot.features.length>0?ot.features:null)}catch{Ne(null)}}).catch(()=>{S||Ne(null)}),()=>{S=!0}},[j,a]),n.useEffect(()=>{if(j.kind!=="text"){Oe(null);return}const S=G&&a&&!a.startsWith("/")?`${G}/${a}`:a,T=yp(S),ce=j.content,Se=Ys(S??"")&&oe==="preview",Je=qs(S??"")&&Ie==="preview";if(!T||Se||Je||!wp(ce)){Oe(null);return}let Te=!1;const ze=Me=>{if(Te||!Me.registered(T)){Te||Oe(null);return}try{Oe(Sp(Me,ce,T))}catch{Oe(null)}};return Ve?ze(Ve):(Oe(null),kp().then(Me=>{Te||(Ae(Me),ze(Me))}).catch(()=>{})),()=>{Te=!0}},[j,Ve,a,G,oe,Ie]),n.useLayoutEffect(()=>{if(!kt||j.kind!=="text")return;const S=`${kt}:${oe}:${Ie}`;if(wr.current===S)return;const T=Kd(G,a);if(wr.current=S,!T)return;const ce=requestAnimationFrame(()=>{const Se=Pe.current;if(!Se)return;const Je=oe==="preview"?T.markdownTop??T.top:T.top;Se.scrollTo({top:Math.max(0,Je??0),left:Math.max(0,T.left??0)}),Be(oe==="preview"?Math.max(0,Je??0):0)});return()=>cancelAnimationFrame(ce)},[a,oe,Ie,j.kind,kt,G]),n.useEffect(()=>{kt&&Ui(G,a,{lineRange:M})},[a,M,kt,G]),n.useEffect(()=>{if(be==null||j.kind!=="text")return;ue(null),I({start:be,end:be});const S=be,T=requestAnimationFrame(()=>{const ce=we.current.get(S);ce&&ce.scrollIntoView({block:"center"}),_?.()});return()=>cancelAnimationFrame(T)},[be,j,I,_]);const Ln=n.useCallback(S=>{const T=Pe.current;if(!T)return!1;const ce=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(S):S.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Se=T.querySelector(`#${ce}`);return Se?(Se.scrollIntoView({block:"start"}),!0):!1},[]);n.useEffect(()=>{const S=G&&a&&!a.startsWith("/")?`${G}/${a}`:a,T=j.kind==="text"&&Ys(S??"")&&oe==="preview";if(!Qt||!T)return;const ce=requestAnimationFrame(()=>{Ln(Qt)&&me(null)});return()=>cancelAnimationFrame(ce)},[a,Ln,oe,Qt,j,G]),n.useLayoutEffect(()=>{const S=Pe.current;if(!S||!M){ue(null);return}if(O)return;const T=j.kind==="image"||j.kind==="loading"&&j.mode==="image",ce=G&&a&&!a.startsWith("/")?`${G}/${a}`:a,Se=j.kind==="text"&&Ys(ce??"")&&oe==="preview",Je=j.kind==="text"&&qs(ce??"")&&Ie==="preview";if(j.kind!=="text"||T||Se||Je){ue(null);return}const Te=()=>{const Me=we.current.get(M.end);if(!Me||!S){ue(null);return}const Ge=Me.offsetTop+Me.offsetHeight/2,ot=S.scrollLeft+Math.max(8,S.clientWidth-120);ue({top:Ge,left:ot})};Te();const ze=new ResizeObserver(()=>Te());return ze.observe(S),()=>ze.disconnect()},[M,O,j,oe,Ie,a,G,bt]);const kr=j.kind==="text"&&!(qs(St??"")&&Ie==="preview")&&!St?.toLowerCase().endsWith(".csv")&&!St?.toLowerCase().endsWith(".kicad_pro")&&!St?.toLowerCase().endsWith(".kicad_prl"),In=n.useCallback(()=>{Ze(!1),ir(""),Q([]),Ye(0),oo(W.current)},[]),en=n.useCallback(()=>{!i||!kr||(Ze(!0),requestAnimationFrame(()=>{const S=ae.current;!he.current||!S?.isConnected||S.closest('[inert], [aria-hidden="true"], [hidden]')||S.getClientRects().length===0||getComputedStyle(S).visibility==="hidden"||!S.contains(document.activeElement)||(ht.current?.focus(),ht.current?.select())}))},[i,kr]),Dr=n.useCallback(S=>{Ye(T=>N.length===0?0:(T+S+N.length)%N.length)},[N.length]),Ut=n.useCallback(S=>{if(S.nativeEvent.isComposing||!eg(ae.current,i,S))return;const T=tg(S);if(T==="open"&&kr){S.preventDefault(),en();return}ye&&(T==="close"?(S.preventDefault(),In()):(T==="next"||T==="previous")&&(S.preventDefault(),Dr(T==="previous"?-1:1)))},[i,In,ye,Dr,en,kr]);if(n.useLayoutEffect(()=>{if(oo(W.current),!i||!ye||!wt.trim()||!Pe.current){Q([]),Ye(0);return}const S=ng(Pe.current,wt);return Q(S),Ye(0),(ae.current?.contains(document.activeElement)||Td(W.current))&&(Ii(S,0,W.current),Md(S[0])),()=>oo(W.current)},[i,ye,wt,bt,oe,j]),n.useEffect(()=>{!i||!ye||!wt.trim()||!ae.current?.contains(document.activeElement)&&!Td(W.current)||(Ii(N,ke,W.current),Md(N[ke]))},[i,ke,N,ye,wt]),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=G&&!a.startsWith("/")?`${G}/${a}`:a,Et=ho(He,G),Sr=ru(He,G),Rr=j.kind==="text"&&j.content?j.content.split(`
|
|
1639
|
+
`):[],oa=Math.max(2,String(Rr.length).length)+1,jr=j.kind==="text"||j.kind==="image"||j.kind==="model3d"||j.kind==="video"||j.kind==="eda"?j.meta:null,Cr=Ys(He),ia=He.toLowerCase().endsWith(".csv"),At=He.toLowerCase().endsWith(".kicad_pro"),ps=He.toLowerCase().endsWith(".kicad_prl"),Ot=j.kind==="text"&&Cr&&oe==="preview",la=qs(He),Ht=j.kind==="text"&&la&&Ie==="preview",ca=j.kind==="image"||j.kind==="loading"&&j.mode==="image",ko=j.kind==="model3d"||j.kind==="loading"&&j.mode==="model3d",xt=j.kind==="video"||j.kind==="loading"&&j.mode==="video",tn=j.kind==="eda"||j.kind==="loading"&&j.mode==="eda",ms=j.kind==="text"?j.sourcePath:He,_r=xh(ms,G,M),Br=(()=>{if(!M||j.kind!=="text"||Rr.length===0)return _r;const S=[];for(let Se=M.start;Se<=M.end;Se+=1)S.push(`${Se} ${Rr[Se-1]??""}`);const T=Pu(He).replace(/^\./,""),ce="```";return`${_r}
|
|
1640
1640
|
${ce}${T}
|
|
1641
1641
|
${S.join(`
|
|
1642
1642
|
`)}
|
|
1643
1643
|
${ce}
|
|
1644
|
-
`})(),Nr=`path:${He}`,Pr=M?`path:${He}:${M.start}-${M.end}`:Nr,Or=H===Nr,Hr=H===Pr,$n=Y===Nr,gs=Y===Pr,rn=Hr||gs,er=M?M.start===M.end?`L${M.start}`:`L${M.start}-${M.end}`:null,zr=S=>{const T=Pe.current;if(!T)return;const ce=T.getBoundingClientRect(),Se=S.currentTarget.getBoundingClientRect(),Je=S.clientX||Se.left+Se.width/2,ze=(S.clientY||Se.top+Se.height/2)-ce.top+T.scrollTop,Me=x?116:132,Ge=T.scrollLeft+Math.max(8,T.clientWidth-Me),ot=Math.min(Math.max(8,Je-ce.left+T.scrollLeft+10),Ge);ue({top:ze,left:ot})},bs=(S,T)=>{Rp()||(zr(S),I(ce=>{const Se=Ki(ce,T,T);return Se||ue(null),Se}))},xs=(S,T,ce)=>{zr(S),I(Se=>{const Je=Ki(Se,T,ce);return Je||ue(null),Je})},Er=(S,T,ce,Se)=>{Se==="end"&&zr(S),I({start:T,end:ce})},lr=S=>{const{scrollTop:T,scrollLeft:ce}=S.currentTarget;Be(T),Ui(G,a,{top:T,left:ce,markdownTop:T})},fe=S=>{if(S.directory){m?.(S.path);return}if(S.path===He||j.kind==="text"&&S.path===j.sourcePath){S.fragment&&Ln(S.fragment);return}Ue(T=>[...T,He]),dt.current=S.path,me(S.fragment),I(null),le(S.path)},tr=()=>{const S=ft[ft.length-1];S&&(Ue(T=>T.slice(0,-1)),dt.current=S,me(null),I(null),le(S))},nn=S=>{const{scrollTop:T,scrollLeft:ce}=S.currentTarget;Ui(G,a,{top:T,left:ce})},sn=S=>{if(r){r(Ur,Pr,void 0,S.currentTarget);return}M&&f(Ur,Pr,S.currentTarget)},vs=()=>{if(!(j.kind==="loading"||j.kind==="error"))return V.start()};return t.jsxs("div",{ref:ae,tabIndex:-1,onKeyDown:Ut,onFocusCapture:()=>{i&&ye&&wt.trim()&&Ii(N,ke,W.current)},onPointerDownCapture:S=>{S.target instanceof Element&&!S.target.closest('button, input, textarea, select, a, [tabindex]:not([tabindex="-1"])')&&S.currentTarget.focus({preventScroll:!0})},className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[yr.popoverNode,t.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${x&&(Ot||Ht)?"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&&k&&t.jsx("button",{type:"button",onClick:k,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(jp,{size:16})}),ft.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(mo,{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:Et.name}),Et.dir&&t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Et.dir})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[kr&&t.jsx("button",{type:"button",onClick:ye?In: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 ${ye?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":o("rightSidebar.findInFile"),title:`${o("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:t.jsx(us,{size:14})}),Cr&&j.kind==="text"&&t.jsx("button",{type:"button",onClick:()=>{w&&A?.(),Fe(S=>{const T=S==="preview"?"source":"preview";return Pt(xu,T),T}),I(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(oe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:o(oe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:x?oe==="preview"?t.jsx(Yi,{size:14}):t.jsx(Vi,{size:14}):o(oe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),la&&j.kind==="text"&&t.jsx("button",{type:"button",onClick:()=>{E(S=>{const T=S==="preview"?"source":"preview";return Rm(G,a,T),T}),I(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(Ie==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:o(Ie==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:x?Ie==="preview"?t.jsx(Yi,{size:14}):t.jsx(Vi,{size:14}):o(Ie==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),Ht&&t.jsx("button",{type:"button",onClick:()=>{xe.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(ge?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:o(ge?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:t.jsx(iu,{size:15})}),!x&&t.jsx("button",{type:"button",onClick:S=>c(He,Nr,S.currentTarget),...yr(Sr,Nr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${Or||$n?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:o("rightSidebar.insertReference",{reference:Sr}),children:o($n?"rightSidebar.copied":Or?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),t.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Sr)},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:Sr}),"aria-label":o("rightSidebar.copyFileRef"),children:t.jsx(vh,{size:13})}),t.jsx("button",{type:"button",onClick:()=>{vs()},disabled:V.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:V.status==="error"?V.error??o("rightSidebar.downloadFailed"):o("rightSidebar.downloadFile"),"aria-label":o("rightSidebar.downloadFile"),children:V.status==="pending"?t.jsx(lt,{size:13,className:"animate-spin"}):t.jsx(yh,{size:14})}),V.status==="pending"&&t.jsx("button",{type:"button",onClick:V.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")})]})]}),V.status==="error"&&t.jsxs("div",{role:"alert",className:"mt-2 text-xs text-destructive",children:[o("rightSidebar.downloadFailed"),": ",V.error]}),V.status==="canceled"&&t.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadCanceled")}),V.status==="saved"&&t.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadSaved")}),V.status==="started"&&t.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadStarted")}),ye&&kr&&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(us,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),t.jsx("input",{ref:ht,type:"search",value:wt,onChange:S=>ir(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),_r(S.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:N.length>0?`${ke+1}/${N.length}`:"0/0"})]}),t.jsx("button",{type:"button",onClick:()=>_r(-1),disabled:N.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(al,{size:13})}),t.jsx("button",{type:"button",onClick:()=>_r(1),disabled:N.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(Cp,{size:13})}),t.jsx("button",{type:"button",onClick:In,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(Xt,{size:13})})]}),jr&&!(x&&(Ot||Ht))&&t.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[jr.size!==null&&t.jsx("span",{children:o("rightSidebar.byteCount",{count:jr.size.toLocaleString()})}),"truncated"in jr&&jr.truncated&&t.jsx("span",{className:"text-[color:var(--warning)]",children:o("rightSidebar.previewTruncated")}),"mimeType"in jr&&t.jsx("span",{children:jr.mimeType}),"dimensions"in j&&j.dimensions&&t.jsxs("span",{children:[j.dimensions.width," × ",j.dimensions.height]})]}),!(x&&(Ot||Ht))&&!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"):ia?o("rightSidebar.csvTablePreview"):At||ps?o("rightSidebar.kicadProjectPickHint"):xt?o("rightSidebar.videoPreviewHint"):ca?o("rightSidebar.imagePreviewHint"):Ot?M?o("rightSidebar.selectedLineHint",{lineLabel:er??""}):o("rightSidebar.markdownPreviewHint"):Ht?o("rightSidebar.htmlPreviewHint"):M?o("rightSidebar.selectedLineHint",{lineLabel:er??""}):o("rightSidebar.multiLineHint")})})]}),!i&&(j.kind==="video"||j.kind==="model3d"||j.kind==="eda"||Ht)?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(hu,{blobUrl:j.objectUrl,filePath:He,viewLabel:"SVG 文件",onInsertAnnotation:r??p}):t.jsx(Uh,{src:j.objectUrl,alt:Et.name,vector:!1,onLoad:S=>{const T=S.currentTarget;F(ce=>ce.kind==="image"?{...ce,dimensions:{width:T.naturalWidth,height:T.naturalHeight}}:ce)},onError:()=>F({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(Lm,{url:j.url,onLoadError:()=>F({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(Um,{blobUrl:j.objectUrl,filePath:j.sourcePath,view:j.view,board:He.toLowerCase().endsWith(".kicad_pcb"),onViewChange:C,onInsertAnnotation:r??p,onRefresh:Zt,interactive3d:L?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(Bd,{blobUrl:L.objectUrl,ext:".glb",fileName:Et.name,filePath:L.sourcePath,features:null,onInsertFeature:r??p,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:S=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(S)?S:"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(Bd,{blobUrl:j.objectUrl,ext:j.ext,fileName:Et.name,filePath:j.sourcePath,features:pe,onInsertFeature:r??p,onRefresh:Zt})})}):j.kind==="text"&&ia?t.jsx(zm,{content:j.content,filePath:He,onInsertAnnotation:r??p},He):j.kind==="text"&&(At||ps)?t.jsx(qm,{content:j.content,filePath:He,localState:ps,onInsertAnnotation:r??p},He):Ot?t.jsxs("div",{ref:Pe,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:lr,style:{touchAction:"pan-x pan-y"},children:[t.jsx(nu,{content:j.content,filePath:j.sourcePath,rootPath:G,lineRange:M,onLineRangeClick:xs,onLineRangeDrag:Er,scrollTop:Jt,outlineOpen:w,outlineCloseSignal:R,onOutlineOpen:b,onOutlineClose:A,lightboxOpen:P,lightboxCloseSignal:$,onLightboxOpen:D,onLightboxClose:te,onLocalLinkOpen:fe}),M&&O&&t.jsxs("button",{type:"button",onClick:sn,...yr(Ur,Pr),style:{top:O.top,left:O.left,transform:"translateY(-50%)"},className:vd(x,rn),title:`Insert markdown reference: ${Br}`,children:[t.jsx(bo,{size:x?13:11}),gs?o("rightSidebar.copied"):Hr?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:er??""})]})]}):Ht?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:t.jsx(eg,{ref:xe,src:wh(He),title:`${Et.name} preview`,exitFullscreenLabel:o("rightSidebar.htmlFullscreenExit"),onFullscreenChange:De},`${He}:${Mn}:${Bt}`)}):j.kind==="text"?t.jsxs("div",{ref:Pe,onScroll:nn,className:`${Oh} 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:[Rr.length>0?t.jsx("div",{className:"min-w-full",children:Rr.map((S,T)=>{const ce=T+1,Se=!!(M&&ce>=M.start&&ce<=M.end),Je=bt&&bt.length===Rr.length?bt[T]:null;return t.jsxs("div",{ref:Te=>{Te?we.current.set(ce,Te):we.current.delete(ce)},role:"button","data-file-preview-line":ce,tabIndex:0,onClick:Te=>bs(Te,ce),onKeyDown:Te=>{Te.key!=="Enter"&&Te.key!==" "||(Te.preventDefault(),bs(Te,ce))},style:{gridTemplateColumns:`${oa}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${Se?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Sr}:${ce}`,children:[t.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${Se?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:ce}),t.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Je??(S||" ")})]},T)})}):"Empty file.",M&&O&&t.jsxs("button",{type:"button",onClick:sn,...yr(Ur,Pr),style:{top:O.top,left:O.left,transform:"translateY(-50%)"},className:vd(x,rn),title:`Insert code reference: ${Br}`,children:[t.jsx(bo,{size:x?13:11}),gs?o("rightSidebar.copied"):Hr?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:er??""})]})]}):null]})}function lb({rootPath:r,file:a,active:i,...c}){const[f,p]=n.useState(null),[g,k]=n.useState(a.line??1),m=n.useCallback(()=>k(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:p,scrollToLine:g,onScrollToLineHandled:m,markdownOutlineOpen:!1,markdownImageLightboxOpen:!1})})}function cb({isOpen:r,sessionId:a,drawerWidthPx:i,onClose:c,onOpen:f,push:p,pinned:g=!1,onTogglePinned:k,rightSidebarFilePreviewOpen:m=!1,rightSidebarFilePreviewCloseSignal:x,onOpenRightSidebarFilePreview:w,onCloseRightSidebarFilePreview:R,rightSidebarRepoPickerOpen:b=!1,rightSidebarRepoPickerCloseSignal:A,onOpenRightSidebarRepoPicker:P,onCloseRightSidebarRepoPicker:$,markdownOutlineOpen:D=!1,markdownOutlineCloseSignal:te,onOpenMarkdownOutline:M,onCloseMarkdownOutline:I,markdownImageLightboxOpen:H=!1,markdownImageLightboxCloseSignal:Y,onOpenMarkdownImageLightbox:be,onCloseMarkdownImageLightbox:_}){const{t:o,locale:ae}=_t(),[W,he]=n.useState(""),G=U(e=>e.pendingTerminalPath),[le,j]=n.useState(null),F=n.useRef(0),ee=U(e=>e.rightSearchOpen),C=U(e=>e.setRightSearchOpen),L=U(e=>e.rightSidebarLayoutPreference),q=U(e=>e.setRightSidebarLayoutPreference),[ne,pe]=n.useState(()=>Lg()),[Ne,we]=n.useState("."),[Pe,O]=n.useState(""),[ue,oe]=n.useState(!1),[Fe,Ie]=n.useState(!1),[E,xe]=n.useState(!1),[ge,De]=n.useState(!1),Ve=n.useDeferredValue(W),[Ae,Jt]=n.useState(null),[Be,ft]=n.useState([]),[Ue,Qt]=n.useState([]),me=U(e=>e.contextKey?e.activeGitRepos[e.contextKey]??null:null),dt=U(e=>e.setActiveGitRepo),[at,bt]=n.useState(null),[Oe,V]=n.useState(null),[ye,Ze]=n.useState(null),[wt,ir]=n.useState(!1),[N,Q]=n.useState(()=>ct(Id,ta)??!1),[ke,Ye]=n.useState(()=>ct($d,ta)??!1),[ht,yr]=n.useState(()=>ct(Fd,ta)??!1),[kt,St]=n.useState(()=>ct(Di,Pg)??""),[Mn,hs]=n.useState(0),[wr,Bt]=n.useState(!1),[Zr,Zt]=n.useState(!1),Ln=n.useRef(null),kr=n.useRef(null),[In,en]=n.useState(!1),[_r,Ut]=n.useState(null),[He,Et]=n.useState(null),[Sr,Rr]=n.useState(()=>Od($i)),[oa,jr]=n.useState(()=>Od(Ld)),[Cr,ia]=n.useState(()=>Ng()),[At,ps]=n.useState(()=>Eg()),[Ot,la]=n.useState(()=>Tg()),Ht="words",[ca,ko]=n.useState(0),[xt,tn]=n.useState([]),[ms,Br]=n.useState([]),[Ur,Nr]=n.useState(!1),[Pr,Or]=n.useState(null),[Hr,$n]=n.useState([]),[gs,rn]=n.useState(!1),[er,zr]=n.useState([]),[bs,xs]=n.useState([]),[Er,lr]=n.useState(!1),[fe,tr]=n.useState(null),[nn,sn]=n.useState([]),[vs,S]=n.useState({}),T=n.useRef(0),[ce,Se]=n.useState(0),[Je,Te]=n.useState(!1),[ze,Me]=n.useState(null),[Ge,ot]=n.useState(null),[Fn,cr]=n.useState(null),[ys,an]=n.useState(null),[on,Gr]=n.useState(!1),[ln,cn]=n.useState(""),ws=n.useDeferredValue(ln),[K,We]=n.useState({}),[Tt,dr]=n.useState([]),[da,ks]=n.useState(!1),[ua,Ss]=n.useState(!1),[So,Dn]=n.useState(null),[Ro,_n]=n.useState(!1),ur=n.useRef(null),Wr=n.useRef(0),dl=n.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Fu,fa]=n.useState(null),[Rs,ul]=n.useState(()=>ct(Fi,ta)??!1),[jo,Co]=n.useState(!1),[ha,No]=n.useState([]),[rr,pa]=n.useState({}),[Rt,ma]=n.useState({}),[dn,Po]=n.useState({}),[fl,hl]=n.useState(()=>new Set),[qe,un]=n.useState(null),[Eo,fn]=n.useState(null),[Du,Ar]=n.useState(!1),[Ao,Tr]=n.useState(0),[,To]=n.useState(0),[Mo,ga]=n.useState(!1),[_u,Bu]=n.useState(()=>U.getState().rightTab==="files"),[nr,Lo]=n.useState(!1),[Uu,pl]=n.useState(()=>U.getState().rightTab==="diff"),[Io,ml]=n.useState(()=>U.getState().rightTab==="android"),[qr,gl]=n.useState(!1),[sr,bl]=n.useState({architecture:!1,computer:!1}),js=n.useRef(new Set),ba=ji(e=>e.docks[Ai]),Ou=!!ba,[$e,Cs]=n.useState(null),[Bn,Ns]=n.useState(null),[pt,hn]=n.useState(null),[xl,zt]=n.useState(null),[Un,vl]=n.useState(null),[$o,Hu]=n.useState(()=>Date.now()),[zu,Gu]=n.useState(!1),[pn,xa]=n.useState(!1),[va,yl]=n.useState(""),[On,ya]=n.useState(""),[mn,wa]=n.useState(""),[gn,ka]=n.useState(""),[wl,Hn]=n.useState(null),[kl,Fo]=n.useState(!1),[Sl,Rl]=n.useState(!1),[Sa,Wu]=n.useState({key:null,nonce:0}),jl=n.useRef(null),Cl=n.useRef(null),J=Fh(i,g,L),Do=Ru(J,g,Ot),[_o,Bo]=n.useState(()=>Ug(i)),Uo=U(e=>e.rightTab),Mt=U(e=>e.setRightTab),d=U(e=>e.rootPath),zn=U(e=>e.explorerRoot),Nl=U(e=>e.pinnedExplorerRootsCache),Pl=U(e=>e.hydratePinnedExplorerRoots),El=U(e=>e.syncPinnedExplorerRoots),Lt=U(e=>e.setExplorerRoot),Al=U(e=>e.resetExplorerToProject),Gn=U(e=>e.pinExplorerRoot),bn=U(e=>e.unpinExplorerRoot),et=U(e=>e.selectedFilePath),tt=U(e=>e.selectFile),Oo=U(e=>e.showHiddenFiles),qu=U(e=>e.toggleShowHiddenFiles),Ho=U(e=>!!(d&&e.nestedGitScanRoots[d])),Ee=U(e=>e.changedFiles),Ra=U(e=>e.setChangedFiles),Ps=U(e=>e.invalidateDirectoryCache),Ku=U(e=>e.setDirectorySortMode),Tl=U(e=>e.applyFileWatchEvents),Ml=U(e=>e.reconcileDirectoryCache),Ll=U(e=>e.bumpFileWatchEpoch),fr=U(e=>e.gitBundleLoading),Il=U(e=>e.gitBundleSlow),xn=U(e=>e.gitBundleError),Wn=U(e=>e.gitBundleLastLoadedAt),$l=U(e=>e.beginGitBundleLoading),Fl=U(e=>e.setGitBundleSlowFor),zo=U(e=>e.finishGitBundleLoading),ja=U(e=>e.resetGitBundleLoading),Go=U(e=>e.setGitBundleError),Dl=U(e=>e.markGitBundleLoaded),re=zn??d,Ca=U(e=>!!(re&&e.hideGitIgnoredRoots[re])),Vu=U(e=>e.hideGitIgnoredRootsHydrated),Yu=U(e=>e.setHideGitIgnoredRoot),[Wo,_l]=n.useState(!1),[Bl,qo]=n.useState(null);n.useEffect(()=>{qo(null)},[re]);const Ul=n.useMemo(()=>re?og(re,Ne):"",[re,Ne]),Es=n.useMemo(()=>ag(Pe),[Pe]),Ol=n.useMemo(()=>({excludePatterns:Es,caseSensitive:Fe,wholeWord:E,regex:ge}),[Fe,Es,ge,E]),Na=U(e=>re?e.fileSortModes[re]??"name":"name"),Hl=U(e=>!!(re&&e.directoryCache.has(re))),qn=n.useRef(null),vt=n.useRef(0),[zl]=n.useState(()=>++rb),Mr=n.useRef(null),Kr=n.useRef(null),Pa=n.useRef(0),Gt=n.useRef(new Map),Wt=n.useRef(new Map),hr=n.useRef(new Set),vn=n.useRef(new Set),yn=n.useRef(0),Vr=n.useRef(null),Kn=n.useRef(0),Vn=n.useRef(null),Yn=n.useRef(0),Yr=n.useRef(null),Ko=n.useRef(new Set),Vo=n.useRef(null),Yo=n.useRef(null),Ea=n.useRef(null),Xo=n.useRef(null),Jo=n.useRef(null),As=n.useRef(new Set);n.useEffect(()=>{if(Un===null)return;const e=Math.max(0,Date.now()-Un),s=e<6e4?1e3:e<36e5?6e4:e<864e5?36e5:864e5,l=Math.max(50,s-e%s),h=window.setTimeout(()=>Hu(Date.now()),l);return()=>window.clearTimeout(h)},[$o,Un]);const Aa=n.useRef(null),Lr=n.useRef(null),Qo=n.useRef(null),Gl=n.useRef(null),Ts=n.useRef(null),Re=n.useCallback(e=>U.getState().rootPath===e,[]);n.useEffect(()=>{if(!r||typeof window>"u")return;const e=s=>{const l=ob(s.target);l&&Qs("global_change_row_event",{...ib(s),selectionPath:l.dataset.diffSelectionPath,filePath:l.dataset.diffFilePath,absolutePath:l.dataset.diffAbsolutePath,repoRoot:l.dataset.diffRepoRoot,status:l.dataset.diffStatus,selectedFilePath:U.getState().selectedFilePath,rightTab:U.getState().rightTab,activeGitRepoRoot:me,changedFiles:U.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})}},[me,r]);const Wl=n.useCallback(async(e=d??void 0)=>{if(!e)return null;if(hr.current.has(e)||vn.current.has(e))return st("untracked_skip_cached",{cwd:e,rootPath:d,completed:hr.current.has(e),running:vn.current.has(e)}),null;const s=d,l=Pa.current+1;Pa.current=l,Gt.current.set(e,l);const h=`right-sidebar-git-untracked:${e}`,u=new AbortController;Wt.current.set(e,u),vn.current.add(e),st("untracked_start",{requestId:l,cwd:e,rootPath:d});try{let v=await td(e,u.signal,h),y=0;for(;v.status==="running"&&y<120;){if(Gt.current.get(e)!==l||u.signal.aborted)return st("untracked_stale_result",{requestId:l,activeRequestId:Gt.current.get(e),cwd:e,status:v.status}),null;if(!Re(s))return st("untracked_root_changed",{requestId:l,cwd:e,expectedRootPath:s,currentRootPath:U.getState().rootPath}),null;await new Promise(Z=>window.setTimeout(Z,y<10?1e3:3e3)),y+=1,v=await td(e,u.signal,h)}if(Gt.current.get(e)!==l||!Re(s))return st("untracked_stale_result",{requestId:l,activeRequestId:Gt.current.get(e),cwd:e,expectedRootPath:s,currentRootPath:U.getState().rootPath,files:v.files.length,status:v.status}),null;if(v.status==="done")return Ra(Mu(U.getState().changedFiles,v.files)),v.files.length>0&&ft(Z=>{const je=new Map(Z.map(ie=>[ie.root,ie])).get(e);if(!je)return Z;const Ke=Kg(je.files,v.files),z=Z.map(ie=>ie.root===e?{...ie,files:Ke,context:ie.context?{...ie.context,changedFiles:Ke.map(Ce=>({path:Ce.path,absolutePath:Ce.absolutePath,status:Ce.status})),truncated:!1}:ie.context,untrackedDeferred:!1}:ie);Qt(Lu(z,d));const B=z.find(ie=>ie.root===d);return B?.context&&Jt(ie=>ie?.root===B.root?{...ie,...B.context}:ie),z}),hr.current.add(e),st("untracked_apply",{requestId:l,cwd:e,files:v.files.length}),v;const X=v.error||(v.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return hr.current.add(e),st("untracked_error",{requestId:l,cwd:e,message:X,code:v.code,status:v.status}),null}catch(v){if(Gt.current.get(e)!==l||!Re(s)||vr(v))return st("untracked_aborted",{requestId:l,activeRequestId:Gt.current.get(e),cwd:e,expectedRootPath:s,currentRootPath:U.getState().rootPath,message:v instanceof Error?v.message:String(v)}),null;const y=v instanceof Error?v.message:"Failed to scan untracked files";return hr.current.add(e),st("untracked_error",{requestId:l,cwd:e,message:y}),null}finally{Wt.current.get(e)===u&&Wt.current.delete(e),Gt.current.get(e)===l&&Gt.current.delete(e),vn.current.delete(e)}},[Ae,Re,d,Ra]),ar=n.useMemo(()=>{const e=new Set(Ue.map(l=>l.root)),s=Hr.filter(l=>e.has(l));return s.length>0?s:me?[me]:[]},[me,Hr,Ue]),ql=ar.length===0,wn=n.useMemo(()=>ar.map(e=>Be.find(s=>s.root===e)).filter(e=>!!e),[ar,Be]),Xu=n.useMemo(()=>Ue.map(e=>({root:e.root,label:e.label,branch:e.branch??null})),[Ue]),pr=n.useCallback(async()=>{if(!d){tn([]),Br([]);return}const e=d,s=Kn.current+1;Kn.current=s,Vn.current?.abort();const l=new AbortController;Vn.current=l,Nr(xt.length===0),Or(null);try{const h=ar.length>0?await Promise.all(ar.map(u=>rd({workspaceRoot:d,repoRoot:u},l.signal))).then(u=>({records:u.flatMap(v=>v.records),walkthroughs:u.flatMap(v=>v.walkthroughs??[])})):await rd({workspaceRoot:d},l.signal);if(Kn.current!==s||!Re(e))return;tn(h.records),Br(h.walkthroughs??[])}catch(h){if(Kn.current!==s||!Re(e)||vr(h))return;Or(h instanceof Error?h.message:"Failed to load change audit explanations")}finally{Vn.current===l&&(Vn.current=null),Kn.current===s&&Re(e)&&Nr(!1)}},[xt.length,ar,Re,d]),Ta=n.useCallback(async(e,s,l)=>{if(!e&&!d){zr([]),xs([]);return}const h=d,u=Yn.current+1;Yn.current=u,Yr.current?.abort();const v=new AbortController;Yr.current=v;try{const y=e?[e]:Array.from(new Set([d,...Be.map(Z=>Z.root)].filter(Z=>!!Z))),X=await Promise.all(y.map(Z=>kh({repoRoot:Z,baseRef:s,branchName:l},v.signal))).then(Z=>{const de=new Map,je=new Map;for(const Ke of Z){for(const z of Ke.records)de.set(z.id,z);for(const z of Ke.walkthroughs??[])je.set(z.id,z)}return{records:Array.from(de.values()),walkthroughs:Array.from(je.values())}});if(Yn.current!==u||!Re(h))return;zr(X.records),xs(X.walkthroughs??[])}catch(y){if(Yn.current!==u||!Re(h)||vr(y))return;console.warn("[RightSidebar] Failed to load branch explanations",y)}finally{Yr.current===v&&(Yr.current=null)}},[Be,Re,d]),Xn=n.useCallback((e,s={})=>{if(!Re(d)){st("apply_skipped_root_changed",{expectedRootPath:d,currentRootPath:U.getState().rootPath,bundleRoot:e.context?.root,files:e.files.length});return}st(e.files.length===0?"empty_bundle":"apply",{rootPath:d,available:e.available,files:e.files.length,repositories:e.repositories?.map(B=>({root:B.root,relativeRoot:B.relativeRoot,files:B.files.length,available:B.available,error:B.error})),repoFilters:e.repoFilters?.map(B=>({root:B.root,label:B.label,count:B.count})),cached:e.cached,stale:e.stale,cacheAgeMs:e.cacheAgeMs,untrackedDeferred:e.untrackedDeferred,error:e.error});let l=ju(e),h=e.repoFilters??[],u=e.files;const v=U.getState().changedFiles;if(!!(s.cacheOnly&&!e.cached&&e.files.length===0&&l.length===0)&&(v.size>0||Be.length>0||Ae)){st("cache_only_apply_skipped_empty_backend_cache",{rootPath:d,currentFiles:v.size,currentRepositories:Be.length});return}const X=l.some(B=>B.deferred);if(X&&!s.replaceWorkspace){const B=new Set(l.filter(Ce=>!Ce.deferred||Ce.root===d).map(Ce=>Ce.root));u=[...Array.from(v.values()).filter(Ce=>!B.has(ut(Ce,d)??"")),...e.files]}const Z=Vd(v.values(),d),de=Vd(e.files,d),je=l.some(B=>B.root!==d);if(!!(s.background&&!X&&!s.replaceWorkspace&&v.size>0&&(e.files.length===0&&!e.error||Z>0&&de===0&&!je))){st("background_apply_skipped_degraded_bundle",{rootPath:d,currentFiles:v.size,nextFiles:e.files.length,currentNestedCount:Z,nextNestedCount:de,nextRepositories:l.map(B=>({root:B.root,relativeRoot:B.relativeRoot,files:B.files.length})),cached:e.cached,stale:e.stale,error:e.error});return}if(s.replaceRepoRoot){const B=Iu(v.values(),Be,e,s.replaceRepoRoot,d);u=B.files,l=B.repositories,h=B.repoFilters}if(Ra(Tu(u)),ft(B=>{if(!X||s.replaceWorkspace)return l;const ie=new Map(B.map(Ce=>[Ce.root,Ce]));return l.map(Ce=>{const _e=ie.get(Ce.root);return!Ce.deferred||!_e?Ce:{...Ce,available:_e.available,files:_e.files,context:_e.context,deferred:_e.deferred,untrackedDeferred:_e.untrackedDeferred,error:_e.error}})}),Qt(h),Jo.current=d,s.syncActiveRepo!==!1){const{contextKey:B,activeGitRepos:ie}=U.getState(),Ce=B?ie[B]??null:null,_e=s.activeRepoRoot!==void 0?s.activeRepoRoot:Ce,Le=Ig({...e,repositories:l,repoFilters:h},_e);dt(Le)}typeof e.cacheUpdatedAt=="number"&&vl(e.cacheUpdatedAt),Jt(B=>{if(s.replaceRepoRoot&&s.replaceRepoRoot!==d)return B;if(!e.context)return null;const ie=B?.root??d;return!B?.available||ie!==(e.context.root??d)?e.context:{...B,...e.context}}),s.reloadDiff&&ko(B=>B+1);const z=U.getState().selectedFilePath;if(z&&!z.startsWith("/")&&!u.some(B=>B.path===z||B.absolutePath===z)&&tt(null),Rr(B=>{const ie=new Set(u.map(_e=>ut(_e,d)).filter(Boolean)),Ce=new Set;for(const _e of B)ie.has(_e)&&Ce.add(_e);return Bi($i,Ce),Ce}),s.loadDeferred!==!1){const B=l.filter(ie=>ie.untrackedDeferred&&ie.root).map(ie=>ie.root);for(const ie of B)Wl(ie)}s.loadAudit!==!1&&pr()},[Re,pr,Wl,d,tt,dt,Ra]);n.useEffect(()=>{ja(),Vo.current=null,Yo.current=d;const e=[],s=[];vt.current+=1,yn.current+=1,Pa.current+=1,Mr.current?.abort(),yt(Xs(Kr.current?.cwd??d??void 0)),Kr.current=null,Mr.current=null,Vr.current?.abort(),yt("right-sidebar-git-details"),Vr.current=null;for(const y of Wt.current.values())y.abort();for(const y of Wt.current.keys())yt(`right-sidebar-git-untracked:${y}`);Wt.current.clear(),Gt.current.clear(),Kn.current+=1,Vn.current?.abort(),Vn.current=null,Yn.current+=1,Yr.current?.abort(),Yr.current=null,Wr.current+=1,ur.current?.abort(),yt("right-sidebar-recent-commits"),ur.current=null,tn([]),Br([]),Nr(!1),Or(null),$n([]),rn(!1),zr([]),xs([]),lr(!1),tr(null),Te(!1),Me(null),ot(null),cr(null),an(null),Gr(!1),cn(""),dr([]),ks(!1),Ss(!1),Dn(null),_n(!1),fa(null),un(null),fn(null),ul(!1),Pt(Fi,!1),Co(!1);const l=d?Hd()[d]:null,h=l?.previewEntries??[],u=l?.selectedPreviewKey??null,v=u?h.find(y=>y.key===u)??null:null;++T.current,Te(!1),No(l?.selectedRepoRoots??[]),pa(l?.repoTargetBranches??{}),ma(l?.repoBaseBranches??{}),sn(h),S(l?.previewScrollTops??{}),v&&l?.previewDetailOpen&&(v.diff.hunks?.length??0)>0&&(tr(v.diff),un(v.key),fn(l.selectedPreviewFileKey??(v.diff.hunks?.[0]?`${v.diff.hunks[0].filePath}\0${v.diff.hunks[0].hunkHeader}\0${v.diff.hunks[0].hunkIndex}`:null)),lr(!0)),Po(l?.repoIncludeUncommitted??Object.fromEntries(Object.keys(l?.repoTargetBranches??{}).map(y=>[y,l?.includeUncommitted??!0]))),Vo.current=d,xa(!1),hr.current.clear(),vn.current.clear(),Cs(null),Ns(null),hn(null),zt(null),vl(null),ft(e),Qt(s),Jt(null),Xo.current=null,Jo.current=null,As.current.clear()},[ja,d]);const It=n.useCallback(async(e=d??void 0,s={})=>{if(!e)return null;const l=d,h=vt.current;if(await zp(()=>Promise.all([U.getState().hydrateNestedGitScanRoots(),U.getState().hydrateActiveGitRepos()]).then(()=>{})),vt.current!==h||!Re(l))return null;const u=e===d&&Vs(d),v=s.includeNested??u,y=s.refresh??s.reloadDiff??!1,X=s.cacheOnly??!1,Z=s.background??!1,de=v&&(s.discoverOnly??!1);y&&hr.current.clear();const je=Kr.current;if(je&&je.cwd===e&&je.includeNested===v&&je.refresh===y&&je.cacheOnly===X&&je.discoverOnly===de)return st("reuse_pending",{cwd:e,includeNested:v,refresh:y,cacheOnly:X,discoverOnly:de}),je.promise;const Ke=vt.current+1;vt.current=Ke;const z=`right-sidebar:${zl}:${Ke}`;Mr.current?.abort();const B=Xs(e);yt(B);const ie=new AbortController;Mr.current=ie;let Ce=null;Z||$l(z),Go(null),st("start",{requestId:Ke,cwd:e,rootPath:d,requestSlotId:B,includeNested:v,refresh:y,cacheOnly:X,background:Z,existingChanges:Ee.size,lastLoadedAt:Wn}),!Z&&typeof window<"u"&&(Ce=window.setTimeout(()=>{vt.current===Ke&&Fl(z,!0)},mg));const _e=(async()=>{const Le=await Ci(e,ie.signal,{includeNested:v,refresh:y,cacheOnly:X,discoverOnly:de,action:y?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:B,requestTimeoutMs:y?null:void 0});if(Xg(Le)){if(st("cancelled_result_ignored",{requestId:Ke,activeRequestId:vt.current,cwd:e,error:Le.error??Le.context?.error}),ie.signal.aborted)return null;throw new Error(Le.error??Le.context?.error??"Failed to load Git changes")}return vt.current!==Ke||!Re(l)?(st("stale_result",{requestId:Ke,activeRequestId:vt.current,cwd:e,expectedRootPath:l,currentRootPath:U.getState().rootPath,files:Le.files.length,repositories:Le.repositories?.length??0}),null):(Xn(Le,{reloadDiff:s.reloadDiff,syncActiveRepo:s.replaceWorkspace?!0:v,background:Z,cacheOnly:X,replaceRepoRoot:s.replaceRepoRoot,replaceWorkspace:s.replaceWorkspace}),Le)})();Kr.current={cwd:e,includeNested:v,refresh:y,cacheOnly:X,discoverOnly:de,promise:_e};try{const Le=await _e;return vt.current===Ke&&Le&&Re(l)?Dl({cached:Le.cached,stale:Le.stale,cacheAgeMs:Le.cacheAgeMs,nestedDeferred:!v||Le.nestedDeferred,untrackedDeferred:Le.untrackedDeferred}):vt.current===Ke&&Re(l)&&zo(z),Le}catch(Le){return vt.current!==Ke||!Re(l)||ie.signal.aborted?(st("aborted",{requestId:Ke,activeRequestId:vt.current,cwd:e,expectedRootPath:l,currentRootPath:U.getState().rootPath,message:Le instanceof Error?Le.message:String(Le)}),null):(st("error",{requestId:Ke,cwd:e,includeNested:v,refresh:y,background:Z,message:Le instanceof Error?Le.message:String(Le)}),Z||(Jt(null),Go(Le instanceof Error?Le.message:"Failed to load Git changes")),null)}finally{Ce!==null&&window.clearTimeout(Ce),Mr.current===ie&&(Mr.current=null),Kr.current?.promise===_e&&(Kr.current=null),!Z&&vt.current===Ke&&Re(l)&&zo(z)}},[Xn,$l,Ee.size,zo,zl,Wn,Re,Dl,d,Go,Fl]),Jn=n.useCallback(async()=>{d&&await It(d,{reloadDiff:!0,refresh:!0})},[It,d]),Zo=n.useCallback(async(e=d??void 0)=>{if(!e)return null;const s=d,l=yn.current+1;yn.current=l,Vr.current?.abort(),yt("right-sidebar-git-details");const h=new AbortController;Vr.current=h,xa(!0);try{const u=await nd(e,h.signal,"load_git_details","right-sidebar-git-details");return yn.current!==l||!Re(s)?null:(ft(v=>v.map(y=>y.root===u.root?{...y,available:u.available,context:u,error:u.error}:y)),Jt(v=>v?.root&&u.root&&v.root!==u.root?v:!v?.available||!u.available?u:{...v,...u}),u)}catch(u){return vr(u)||!Re(s)||yn.current===l&&zt(u instanceof Error?u.message:"Failed to load Git details"),null}finally{Vr.current===h&&(Vr.current=null),yn.current===l&&Re(s)&&xa(!1)}},[Re,d]);n.useEffect(()=>{if(!r){vt.current+=1,ja(),Xo.current=null,yn.current+=1,Pa.current+=1,Mr.current?.abort(),yt(Xs(Kr.current?.cwd??d??void 0)),Kr.current=null,Mr.current=null,Vr.current?.abort(),yt("right-sidebar-git-details"),Vr.current=null;for(const e of Wt.current.values())e.abort();for(const e of Wt.current.keys())yt(`right-sidebar-git-untracked:${e}`);Wt.current.clear(),Gt.current.clear(),Yn.current+=1,Yr.current?.abort(),Yr.current=null,Wr.current+=1,ur.current?.abort(),yt("right-sidebar-recent-commits"),ur.current=null,xa(!1),Te(!1),Me(null),ot(null),cr(null),an(null),Gr(!1),cn(""),dr([]),ks(!1),Ss(!1),Dn(null),_n(!1),he(""),C(!1),Ut(null),Lo(!1),J&&pl(!1)}},[J,r,ja,C]),n.useEffect(()=>{if(!ee)return;const e=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(e)},[ee]),n.useEffect(()=>{J||Ar(!1)},[J]);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(J)if(Ar(m),m&&et){Tr(1);const e=Lr.current;e&&(e.update(),e.activeIndex!==1&&(Ts.current=1,e.slideTo(1,0)))}else{Tr(0);const e=Lr.current;e&&e.activeIndex!==0&&(Ts.current=0,e.slideTo(0,0)),Ut(null)}},[J,m,d,et]),n.useEffect(()=>{if(x!==void 0&&!m){Tr(0);const e=Lr.current;e&&e.activeIndex!==0&&(Ts.current=0,e.slideTo(0,0)),Ar(!1),Ut(null)}},[x,m]),n.useEffect(()=>{A!==void 0&&bt(null)},[A]),n.useEffect(()=>{!J&&m&&R?.()},[J,R,m]),n.useEffect(()=>{Bo(e=>nl(e,i))},[i]);const Ju=n.useCallback(e=>{J||(e.preventDefault(),Aa.current={startX:e.clientX,startWidth:_o,pointerId:e.pointerId},e.currentTarget.setPointerCapture(e.pointerId))},[_o,J]),Qu=n.useCallback(e=>{const s=Aa.current;if(!s||s.pointerId!==e.pointerId)return;const l=nl(s.startWidth+e.clientX-s.startX,i);Bo(l),ra(ea,l,pg)},[i]),Vl=n.useCallback(e=>{const s=Aa.current;if(!(!s||s.pointerId!==e.pointerId)){Aa.current=null,Ks(ea);try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}},[]),Qn=!!(d&&Wn!==null&&Jd(Ae)),ei=!!(d&&!xn&&Ee.size===0&&Wn===null),jt=(()=>{let e=Uo;return e==="android"&&!qr&&(e="files"),(e==="architecture"||e==="computer")&&!sr[e]&&(e="files"),Qn&&(e==="git"||e==="diff")&&(e="files"),e})(),nt=jt==="git",Ir=jt==="files",Ct=jt==="diff",Zn=jt==="android",es=jt==="computer",kn=jt==="architecture",[Zu,ef]=n.useState(!1);n.useEffect(()=>{r&&es&&ef(!0)},[r,es]);const[tf,rf]=n.useState(!1);n.useEffect(()=>{r&&kn&&rf(!0)},[r,kn]);const ti=n.useRef(null),ts=n.useCallback((e,s)=>{const l=U.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},Mt(e)},[Mt]);n.useEffect(()=>{const e=ti.current;if(!e||e.to!==jt)return;ti.current=null;const s=Math.round(performance.now()-e.startedAt);let l=window.requestAnimationFrame(()=>{l=window.requestAnimationFrame(()=>{Qs("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)},[jt]);const nf=gp(e=>e.overlay==="sidebar")&&Zn;n.useEffect(()=>{if(!J){ga(!0);return}if(!r){const s=window.setTimeout(()=>{ga(!1)},xg);return()=>window.clearTimeout(s)}ga(!1);const e=window.setTimeout(()=>{ga(!0)},bg);return()=>window.clearTimeout(e)},[J,r]),n.useEffect(()=>{if(!J||!Ct)return;const e=Qo.current;if(!e)return;const s=window.requestAnimationFrame(()=>{e.update()});return()=>window.cancelAnimationFrame(s)},[Ct,J]),n.useEffect(()=>{if(!Qn||!d||fr)return;const e=window.setTimeout(()=>{It(d,{background:!0})},3e3);return()=>window.clearTimeout(e)},[Qn,d,fr,It]);const sf=n.useCallback(e=>{It(e,{discoverOnly:!0})},[It]);Gp({active:r&&(nt||Ct),rootPath:d,loading:fr,delay:nt&&!J?0:_i,lastStartedRoot:Xo,load:sf}),n.useEffect(()=>{!r||!nt||(!J||Mo)&&Lo(!0)},[nt,J,r,Mo]),n.useEffect(()=>{if(!r||nt)return;const e=window.setTimeout(()=>{Lo(!0)},_i);return()=>window.clearTimeout(e)},[nt,r]),n.useEffect(()=>{Ir&&Bu(!0)},[Ir]),n.useEffect(()=>{Ct&&pl(!0)},[Ct]),n.useEffect(()=>{!r||!Zn||(a&&ba&&ba.sessionId!==a&&(ji.getState().setDock(Ai,null),Zs({androidPanel:{docked:null}}).catch(()=>{})),ml(!0))},[Zn,r,a,ba]),n.useEffect(()=>{if(r&&Zn||!Io)return;const e=window.setTimeout(()=>ml(!1),gg);return()=>window.clearTimeout(e)},[r,Zn,Io]),n.useEffect(()=>{let e=!1;return Zd().then(s=>{e||(js.current.has("android")||gl(s.androidPanel?.enabled===!0),bl(l=>({architecture:js.current.has("architecture")?l.architecture:s.rightSidebarTabs?.architecture===!0,computer:js.current.has("computer")?l.computer:s.rightSidebarTabs?.computer===!0})))}).catch(()=>{}),()=>{e=!0}},[]);const Yl=n.useCallback(e=>{js.current.add("android"),gl(e),e?Mt("android"):U.getState().rightTab==="android"&&Mt("files"),Zs({androidPanel:{enabled:e}}).catch(()=>{})},[Mt]),af=n.useCallback((e,s)=>{js.current.add(e),bl(l=>({...l,[e]:s})),s?Mt(e):U.getState().rightTab===e&&Mt("files"),Zs({rightSidebarTabs:{[e]:s}}).catch(()=>{})},[Mt]),Xl=n.useCallback(e=>{re&&Hg(re,e.currentTarget.scrollTop)},[re]);n.useEffect(()=>()=>{Mr.current?.abort(),Ks(ol),Ks(il),Ks(ea),Ks(Di)},[]),n.useEffect(()=>{if(!re||!Hl)return;const e=Eu()[re]?.top;if(typeof e!="number")return;let s=window.requestAnimationFrame(()=>{qn.current&&(qn.current.scrollTop=e),s=window.requestAnimationFrame(()=>{qn.current&&(qn.current.scrollTop=e)})});return()=>window.cancelAnimationFrame(s)},[re,Hl]),n.useEffect(()=>{if(!r)return;const e=new AbortController;return Sh(e.signal).then(s=>Rl(!!s.available)).catch(()=>Rl(!1)),()=>e.abort()},[r]);const Ms=n.useCallback(e=>{if(j(null),tt(e),Ut(null),J){Ar(!0),Tr(1),Lr.current?.slideTo(1),w?.();return}},[J,w,tt]),ri=n.useCallback((e,s)=>{if(j(null),tt(e),Et(s),J){Ar(!0),Tr(1),Lr.current?.slideTo(1),w?.();return}},[J,w,tt]),$t=vm(e=>Ps(e,!1)),Ma=$t.busy,Ls=n.useCallback(async(e,s)=>{const l=s||zn||d;!l||!e.length||await $t.start(l,e)},[zn,d,$t.start]),Jl=n.useCallback(async e=>{try{await Rh(e)}catch(s){zt(s instanceof Error?s.message:o("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>zt(null),4e3)}},[o]),La=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.types.includes("Files")&&Fo(!0)},[]),Ql=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),Fo(!1)},[]),Zl=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),Fo(!1);const s=e.dataTransfer.files;s.length>0&&Ls(Array.from(s))},[Ls]),ni=n.useCallback(e=>{V(e),window.setTimeout(()=>V(s=>s===e?null:s),1400)},[]),mr=n.useCallback(e=>{Ze(e),window.setTimeout(()=>Ze(s=>s===e?null:s),1400)},[]);n.useEffect(()=>{Pt(Id,N)},[N]),n.useEffect(()=>{Pt($d,ke)},[ke]),n.useEffect(()=>{Pt(Fd,ht)},[ht]),n.useEffect(()=>{ra(Di,kt,cg)},[kt]),n.useEffect(()=>(Pl().catch(()=>{}),sd(e=>{e.type==="pinned-explorer-roots"&&El(e.pinnedExplorerRoots)})),[Pl,El]);const ec=n.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),Ia=n.useRef(null),Sn=n.useRef(null),[tc,si]=n.useState(!1);n.useEffect(()=>{if(!r)return;si(!1);let e=!1;jh().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=sd(l=>{l.type==="context-draft"&&l.origin!==ec.current&&(Ia.current=l.text,St(l.text))});return()=>{e=!0,s(),Sn.current!==null&&(window.clearTimeout(Sn.current),Sn.current=null)}},[r]),n.useEffect(()=>{if(!tc||Ia.current===kt)return;Sn.current!==null&&window.clearTimeout(Sn.current);const e=kt;Sn.current=window.setTimeout(()=>{Sn.current=null,Ch(e,ec.current).then(()=>{Ia.current=e}).catch(()=>{})},500)},[kt,tc]);const rs=n.useCallback(async(e,s,l,h)=>{if(!e)return!1;if(ir(!1),h&&!Ni(h)())return ir(!0),!1;if(Nh(l?e+l:e))return ni(s),!0;if(N)St(u=>gm(u,e)+(l??"")),window.matchMedia("(pointer: coarse)").matches||(Ye(!1),hs(u=>u+1));else{const u=a??Xr.getState().activeSessionId;if(!await eu(l?e+l:e,u,()=>$s.current&&u===Xr.getState().activeSessionId,h))return ir(!0),!1}return ni(s),!0},[N,ni,a]),$a=n.useCallback(e=>{const s=An(e,d);return Ph(s,d)},[d]),ai=tu(mr),qt=n.useCallback((e,s,l)=>{const h=An(e,d);return rs(ad(h,d),s??`path:${h}`,void 0,l)},[d,rs]),ns=n.useRef({sessionId:a,contextDraftEnabled:N,isOpen:r});ns.current={sessionId:a,contextDraftEnabled:N,isOpen:r};const of=n.useCallback(async(e,s)=>{const l=a??Xr.getState().activeSessionId,h=()=>$s.current&&ns.current.isOpen&&(ns.current.sessionId??Xr.getState().activeSessionId)===l&&Xr.getState().activeSessionId===l&&ns.current.contextDraftEnabled===N;await $t.start("/tmp",[e],v=>qt(v,`path:${v}`,s),h)&&h()&&J&&!N&&c()},[N,qt,J,c,a,$t.start]),Is=n.useRef(!0),Fa=n.useRef(a);Fa.current=a,n.useEffect(()=>(Is.current=!0,()=>{Is.current=!1}),[]);const lf=n.useCallback(e=>{bp.getState().enqueue(e,a??null,d||"/",async(s,l)=>{if(ns.current.contextDraftEnabled&&Is.current&&Fa.current===a){if(!await oi.current(ad(s,null),`path:${s}`,l))throw new Error(o("rightSidebar.uploadReferenceRejected"))}else return bd(s,a,l)})},[a,d,N,qt,o]),cf=n.useCallback(async(e,s)=>{const l=Ni(s),u=(await Wi("/tmp",[e])).files[0]?.path;if(!u)throw new Error("截图上传未返回文件路径");if(!l()||!Is.current||Fa.current!==a||ns.current.contextDraftEnabled!==N)throw new Error(o("rightSidebar.uploadReferenceRejected"));if(N&&Is.current&&Fa.current===a){if(!await qt(u,void 0,s))throw new Error(o("rightSidebar.uploadReferenceRejected"))}else await bd(u,a,s)},[N,qt,a,o]),$r=n.useCallback((e,s,l)=>{if(!e)return Promise.resolve(!1);const h=e.includes(`
|
|
1644
|
+
`})(),Nr=`path:${He}`,Pr=M?`path:${He}:${M.start}-${M.end}`:Nr,Ur=H===Nr,Or=H===Pr,$n=Y===Nr,gs=Y===Pr,rn=Or||gs,er=M?M.start===M.end?`L${M.start}`:`L${M.start}-${M.end}`:null,Hr=S=>{const T=Pe.current;if(!T)return;const ce=T.getBoundingClientRect(),Se=S.currentTarget.getBoundingClientRect(),Je=S.clientX||Se.left+Se.width/2,ze=(S.clientY||Se.top+Se.height/2)-ce.top+T.scrollTop,Me=x?116:132,Ge=T.scrollLeft+Math.max(8,T.clientWidth-Me),ot=Math.min(Math.max(8,Je-ce.left+T.scrollLeft+10),Ge);ue({top:ze,left:ot})},bs=(S,T)=>{Rp()||(Hr(S),I(ce=>{const Se=Vi(ce,T,T);return Se||ue(null),Se}))},xs=(S,T,ce)=>{Hr(S),I(Se=>{const Je=Vi(Se,T,ce);return Je||ue(null),Je})},Er=(S,T,ce,Se)=>{Se==="end"&&Hr(S),I({start:T,end:ce})},lr=S=>{const{scrollTop:T,scrollLeft:ce}=S.currentTarget;Be(T),Ui(G,a,{top:T,left:ce,markdownTop:T})},fe=S=>{if(S.directory){m?.(S.path);return}if(S.path===He||j.kind==="text"&&S.path===j.sourcePath){S.fragment&&Ln(S.fragment);return}Ue(T=>[...T,He]),dt.current=S.path,me(S.fragment),I(null),le(S.path)},tr=()=>{const S=ft[ft.length-1];S&&(Ue(T=>T.slice(0,-1)),dt.current=S,me(null),I(null),le(S))},nn=S=>{const{scrollTop:T,scrollLeft:ce}=S.currentTarget;Ui(G,a,{top:T,left:ce})},sn=S=>{if(r){r(Br,Pr,void 0,S.currentTarget);return}M&&f(Br,Pr,S.currentTarget)},vs=()=>{if(!(j.kind==="loading"||j.kind==="error"))return V.start()};return t.jsxs("div",{ref:ae,tabIndex:-1,onKeyDown:Ut,onFocusCapture:()=>{i&&ye&&wt.trim()&&Ii(N,ke,W.current)},onPointerDownCapture:S=>{S.target instanceof Element&&!S.target.closest('button, input, textarea, select, a, [tabindex]:not([tabindex="-1"])')&&S.currentTarget.focus({preventScroll:!0})},className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[yr.popoverNode,t.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${x&&(Ot||Ht)?"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&&k&&t.jsx("button",{type:"button",onClick:k,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(jp,{size:16})}),ft.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(mo,{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:Et.name}),Et.dir&&t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Et.dir})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[kr&&t.jsx("button",{type:"button",onClick:ye?In: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 ${ye?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":o("rightSidebar.findInFile"),title:`${o("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:t.jsx(us,{size:14})}),Cr&&j.kind==="text"&&t.jsx("button",{type:"button",onClick:()=>{w&&A?.(),Fe(S=>{const T=S==="preview"?"source":"preview";return Pt(xu,T),T}),I(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(oe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:o(oe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:x?oe==="preview"?t.jsx(qi,{size:14}):t.jsx(Yi,{size:14}):o(oe==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),la&&j.kind==="text"&&t.jsx("button",{type:"button",onClick:()=>{E(S=>{const T=S==="preview"?"source":"preview";return Sm(G,a,T),T}),I(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(Ie==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:o(Ie==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:x?Ie==="preview"?t.jsx(qi,{size:14}):t.jsx(Yi,{size:14}):o(Ie==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),Ht&&t.jsx("button",{type:"button",onClick:()=>{xe.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(ge?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:o(ge?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:t.jsx(iu,{size:15})}),!x&&t.jsx("button",{type:"button",onClick:S=>c(He,Nr,S.currentTarget),...yr(Sr,Nr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${Ur||$n?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:o("rightSidebar.insertReference",{reference:Sr}),children:o($n?"rightSidebar.copied":Ur?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),t.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Sr)},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:Sr}),"aria-label":o("rightSidebar.copyFileRef"),children:t.jsx(vh,{size:13})}),t.jsx("button",{type:"button",onClick:()=>{vs()},disabled:V.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:V.status==="error"?V.error??o("rightSidebar.downloadFailed"):o("rightSidebar.downloadFile"),"aria-label":o("rightSidebar.downloadFile"),children:V.status==="pending"?t.jsx(lt,{size:13,className:"animate-spin"}):t.jsx(yh,{size:14})}),V.status==="pending"&&t.jsx("button",{type:"button",onClick:V.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")})]})]}),V.status==="error"&&t.jsxs("div",{role:"alert",className:"mt-2 text-xs text-destructive",children:[o("rightSidebar.downloadFailed"),": ",V.error]}),V.status==="canceled"&&t.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadCanceled")}),V.status==="saved"&&t.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadSaved")}),V.status==="started"&&t.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadStarted")}),ye&&kr&&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(us,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),t.jsx("input",{ref:ht,type:"search",value:wt,onChange:S=>ir(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),Dr(S.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:N.length>0?`${ke+1}/${N.length}`:"0/0"})]}),t.jsx("button",{type:"button",onClick:()=>Dr(-1),disabled:N.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(al,{size:13})}),t.jsx("button",{type:"button",onClick:()=>Dr(1),disabled:N.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(Cp,{size:13})}),t.jsx("button",{type:"button",onClick:In,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(Xt,{size:13})})]}),jr&&!(x&&(Ot||Ht))&&t.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[jr.size!==null&&t.jsx("span",{children:o("rightSidebar.byteCount",{count:jr.size.toLocaleString()})}),"truncated"in jr&&jr.truncated&&t.jsx("span",{className:"text-[color:var(--warning)]",children:o("rightSidebar.previewTruncated")}),"mimeType"in jr&&t.jsx("span",{children:jr.mimeType}),"dimensions"in j&&j.dimensions&&t.jsxs("span",{children:[j.dimensions.width," × ",j.dimensions.height]})]}),!(x&&(Ot||Ht))&&!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"):ia?o("rightSidebar.csvTablePreview"):At||ps?o("rightSidebar.kicadProjectPickHint"):xt?o("rightSidebar.videoPreviewHint"):ca?o("rightSidebar.imagePreviewHint"):Ot?M?o("rightSidebar.selectedLineHint",{lineLabel:er??""}):o("rightSidebar.markdownPreviewHint"):Ht?o("rightSidebar.htmlPreviewHint"):M?o("rightSidebar.selectedLineHint",{lineLabel:er??""}):o("rightSidebar.multiLineHint")})})]}),!i&&(j.kind==="video"||j.kind==="model3d"||j.kind==="eda"||Ht)?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(hu,{blobUrl:j.objectUrl,filePath:He,viewLabel:"SVG 文件",onInsertAnnotation:r??p}):t.jsx(Uh,{src:j.objectUrl,alt:Et.name,vector:!1,onLoad:S=>{const T=S.currentTarget;F(ce=>ce.kind==="image"?{...ce,dimensions:{width:T.naturalWidth,height:T.naturalHeight}}:ce)},onError:()=>F({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(Mm,{url:j.url,onLoadError:()=>F({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(Bm,{blobUrl:j.objectUrl,filePath:j.sourcePath,view:j.view,board:He.toLowerCase().endsWith(".kicad_pcb"),onViewChange:C,onInsertAnnotation:r??p,onRefresh:Zt,interactive3d:L?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(Bd,{blobUrl:L.objectUrl,ext:".glb",fileName:Et.name,filePath:L.sourcePath,features:null,onInsertFeature:r??p,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:S=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(S)?S:"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(Bd,{blobUrl:j.objectUrl,ext:j.ext,fileName:Et.name,filePath:j.sourcePath,features:pe,onInsertFeature:r??p,onRefresh:Zt})})}):j.kind==="text"&&ia?t.jsx(Hm,{content:j.content,filePath:He,onInsertAnnotation:r??p},He):j.kind==="text"&&(At||ps)?t.jsx(Wm,{content:j.content,filePath:He,localState:ps,onInsertAnnotation:r??p},He):Ot?t.jsxs("div",{ref:Pe,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:lr,style:{touchAction:"pan-x pan-y"},children:[t.jsx(nu,{content:j.content,filePath:j.sourcePath,rootPath:G,lineRange:M,onLineRangeClick:xs,onLineRangeDrag:Er,scrollTop:Jt,outlineOpen:w,outlineCloseSignal:R,onOutlineOpen:b,onOutlineClose:A,lightboxOpen:P,lightboxCloseSignal:$,onLightboxOpen:D,onLightboxClose:te,onLocalLinkOpen:fe}),M&&O&&t.jsxs("button",{type:"button",onClick:sn,...yr(Br,Pr),style:{top:O.top,left:O.left,transform:"translateY(-50%)"},className:vd(x,rn),title:`Insert markdown reference: ${_r}`,children:[t.jsx(bo,{size:x?13:11}),gs?o("rightSidebar.copied"):Or?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:er??""})]})]}):Ht?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:t.jsx(Zm,{ref:xe,src:wh(He),title:`${Et.name} preview`,exitFullscreenLabel:o("rightSidebar.htmlFullscreenExit"),onFullscreenChange:De},`${He}:${Mn}:${Bt}`)}):j.kind==="text"?t.jsxs("div",{ref:Pe,onScroll:nn,className:`${Oh} 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:[Rr.length>0?t.jsx("div",{className:"min-w-full",children:Rr.map((S,T)=>{const ce=T+1,Se=!!(M&&ce>=M.start&&ce<=M.end),Je=bt&&bt.length===Rr.length?bt[T]:null;return t.jsxs("div",{ref:Te=>{Te?we.current.set(ce,Te):we.current.delete(ce)},role:"button","data-file-preview-line":ce,tabIndex:0,onClick:Te=>bs(Te,ce),onKeyDown:Te=>{Te.key!=="Enter"&&Te.key!==" "||(Te.preventDefault(),bs(Te,ce))},style:{gridTemplateColumns:`${oa}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${Se?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Sr}:${ce}`,children:[t.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${Se?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:ce}),t.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Je??(S||" ")})]},T)})}):"Empty file.",M&&O&&t.jsxs("button",{type:"button",onClick:sn,...yr(Br,Pr),style:{top:O.top,left:O.left,transform:"translateY(-50%)"},className:vd(x,rn),title:`Insert code reference: ${_r}`,children:[t.jsx(bo,{size:x?13:11}),gs?o("rightSidebar.copied"):Or?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:er??""})]})]}):null]})}function ib({rootPath:r,file:a,active:i,...c}){const[f,p]=n.useState(null),[g,k]=n.useState(a.line??1),m=n.useCallback(()=>k(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:p,scrollToLine:g,onScrollToLineHandled:m,markdownOutlineOpen:!1,markdownImageLightboxOpen:!1})})}function lb({isOpen:r,sessionId:a,drawerWidthPx:i,onClose:c,onOpen:f,push:p,pinned:g=!1,onTogglePinned:k,rightSidebarFilePreviewOpen:m=!1,rightSidebarFilePreviewCloseSignal:x,onOpenRightSidebarFilePreview:w,onCloseRightSidebarFilePreview:R,rightSidebarRepoPickerOpen:b=!1,rightSidebarRepoPickerCloseSignal:A,onOpenRightSidebarRepoPicker:P,onCloseRightSidebarRepoPicker:$,markdownOutlineOpen:D=!1,markdownOutlineCloseSignal:te,onOpenMarkdownOutline:M,onCloseMarkdownOutline:I,markdownImageLightboxOpen:H=!1,markdownImageLightboxCloseSignal:Y,onOpenMarkdownImageLightbox:be,onCloseMarkdownImageLightbox:_}){const{t:o,locale:ae}=_t(),[W,he]=n.useState(""),G=U(e=>e.pendingTerminalPath),[le,j]=n.useState(null),F=n.useRef(0),ee=U(e=>e.rightSearchOpen),C=U(e=>e.setRightSearchOpen),L=U(e=>e.rightSidebarLayoutPreference),q=U(e=>e.setRightSidebarLayoutPreference),[ne,pe]=n.useState(()=>Mg()),[Ne,we]=n.useState("."),[Pe,O]=n.useState(""),[ue,oe]=n.useState(!1),[Fe,Ie]=n.useState(!1),[E,xe]=n.useState(!1),[ge,De]=n.useState(!1),Ve=n.useDeferredValue(W),[Ae,Jt]=n.useState(null),[Be,ft]=n.useState([]),[Ue,Qt]=n.useState([]),me=U(e=>e.contextKey?e.activeGitRepos[e.contextKey]??null:null),dt=U(e=>e.setActiveGitRepo),[at,bt]=n.useState(null),[Oe,V]=n.useState(null),[ye,Ze]=n.useState(null),[wt,ir]=n.useState(!1),[N,Q]=n.useState(()=>ct(Id,ta)??!1),[ke,Ye]=n.useState(()=>ct($d,ta)??!1),[ht,yr]=n.useState(()=>ct(Fd,ta)??!1),[kt,St]=n.useState(()=>ct(Di,Ng)??""),[Mn,hs]=n.useState(0),[wr,Bt]=n.useState(!1),[Zr,Zt]=n.useState(!1),Ln=n.useRef(null),kr=n.useRef(null),[In,en]=n.useState(!1),[Dr,Ut]=n.useState(null),[He,Et]=n.useState(null),[Sr,Rr]=n.useState(()=>Od($i)),[oa,jr]=n.useState(()=>Od(Ld)),[Cr,ia]=n.useState(()=>Cg()),[At,ps]=n.useState(()=>Pg()),[Ot,la]=n.useState(()=>Ag()),Ht="words",[ca,ko]=n.useState(0),[xt,tn]=n.useState([]),[ms,_r]=n.useState([]),[Br,Nr]=n.useState(!1),[Pr,Ur]=n.useState(null),[Or,$n]=n.useState([]),[gs,rn]=n.useState(!1),[er,Hr]=n.useState([]),[bs,xs]=n.useState([]),[Er,lr]=n.useState(!1),[fe,tr]=n.useState(null),[nn,sn]=n.useState([]),[vs,S]=n.useState({}),T=n.useRef(0),[ce,Se]=n.useState(0),[Je,Te]=n.useState(!1),[ze,Me]=n.useState(null),[Ge,ot]=n.useState(null),[Fn,cr]=n.useState(null),[ys,an]=n.useState(null),[on,zr]=n.useState(!1),[ln,cn]=n.useState(""),ws=n.useDeferredValue(ln),[K,We]=n.useState({}),[Tt,dr]=n.useState([]),[da,ks]=n.useState(!1),[ua,Ss]=n.useState(!1),[So,Dn]=n.useState(null),[Ro,_n]=n.useState(!1),ur=n.useRef(null),Gr=n.useRef(0),dl=n.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Fu,fa]=n.useState(null),[Rs,ul]=n.useState(()=>ct(Fi,ta)??!1),[jo,Co]=n.useState(!1),[ha,No]=n.useState([]),[rr,pa]=n.useState({}),[Rt,ma]=n.useState({}),[dn,Po]=n.useState({}),[fl,hl]=n.useState(()=>new Set),[qe,un]=n.useState(null),[Eo,fn]=n.useState(null),[Du,Ar]=n.useState(!1),[Ao,Tr]=n.useState(0),[,To]=n.useState(0),[Mo,ga]=n.useState(!1),[_u,Bu]=n.useState(()=>U.getState().rightTab==="files"),[nr,Lo]=n.useState(!1),[Uu,pl]=n.useState(()=>U.getState().rightTab==="diff"),[Io,ml]=n.useState(()=>U.getState().rightTab==="android"),[Wr,gl]=n.useState(!1),[sr,bl]=n.useState({architecture:!1,computer:!1}),js=n.useRef(new Set),ba=ji(e=>e.docks[Ai]),Ou=!!ba,[$e,Cs]=n.useState(null),[Bn,Ns]=n.useState(null),[pt,hn]=n.useState(null),[xl,zt]=n.useState(null),[Un,vl]=n.useState(null),[$o,Hu]=n.useState(()=>Date.now()),[zu,Gu]=n.useState(!1),[pn,xa]=n.useState(!1),[va,yl]=n.useState(""),[On,ya]=n.useState(""),[mn,wa]=n.useState(""),[gn,ka]=n.useState(""),[wl,Hn]=n.useState(null),[kl,Fo]=n.useState(!1),[Sl,Rl]=n.useState(!1),[Sa,Wu]=n.useState({key:null,nonce:0}),jl=n.useRef(null),Cl=n.useRef(null),J=Fh(i,g,L),Do=Ru(J,g,Ot),[_o,Bo]=n.useState(()=>Bg(i)),Uo=U(e=>e.rightTab),Mt=U(e=>e.setRightTab),d=U(e=>e.rootPath),zn=U(e=>e.explorerRoot),Nl=U(e=>e.pinnedExplorerRootsCache),Pl=U(e=>e.hydratePinnedExplorerRoots),El=U(e=>e.syncPinnedExplorerRoots),Lt=U(e=>e.setExplorerRoot),Al=U(e=>e.resetExplorerToProject),Gn=U(e=>e.pinExplorerRoot),bn=U(e=>e.unpinExplorerRoot),et=U(e=>e.selectedFilePath),tt=U(e=>e.selectFile),Oo=U(e=>e.showHiddenFiles),qu=U(e=>e.toggleShowHiddenFiles),Ho=U(e=>!!(d&&e.nestedGitScanRoots[d])),Ee=U(e=>e.changedFiles),Ra=U(e=>e.setChangedFiles),Ps=U(e=>e.invalidateDirectoryCache),Ku=U(e=>e.setDirectorySortMode),Tl=U(e=>e.applyFileWatchEvents),Ml=U(e=>e.reconcileDirectoryCache),Ll=U(e=>e.bumpFileWatchEpoch),fr=U(e=>e.gitBundleLoading),Il=U(e=>e.gitBundleSlow),xn=U(e=>e.gitBundleError),Wn=U(e=>e.gitBundleLastLoadedAt),$l=U(e=>e.beginGitBundleLoading),Fl=U(e=>e.setGitBundleSlowFor),zo=U(e=>e.finishGitBundleLoading),ja=U(e=>e.resetGitBundleLoading),Go=U(e=>e.setGitBundleError),Dl=U(e=>e.markGitBundleLoaded),re=zn??d,Ca=U(e=>!!(re&&e.hideGitIgnoredRoots[re])),Vu=U(e=>e.hideGitIgnoredRootsHydrated),Yu=U(e=>e.setHideGitIgnoredRoot),[Wo,_l]=n.useState(!1),[Bl,qo]=n.useState(null);n.useEffect(()=>{qo(null)},[re]);const Ul=n.useMemo(()=>re?ag(re,Ne):"",[re,Ne]),Es=n.useMemo(()=>sg(Pe),[Pe]),Ol=n.useMemo(()=>({excludePatterns:Es,caseSensitive:Fe,wholeWord:E,regex:ge}),[Fe,Es,ge,E]),Na=U(e=>re?e.fileSortModes[re]??"name":"name"),Hl=U(e=>!!(re&&e.directoryCache.has(re))),qn=n.useRef(null),vt=n.useRef(0),[zl]=n.useState(()=>++tb),Mr=n.useRef(null),qr=n.useRef(null),Pa=n.useRef(0),Gt=n.useRef(new Map),Wt=n.useRef(new Map),hr=n.useRef(new Set),vn=n.useRef(new Set),yn=n.useRef(0),Kr=n.useRef(null),Kn=n.useRef(0),Vn=n.useRef(null),Yn=n.useRef(0),Vr=n.useRef(null),Ko=n.useRef(new Set),Vo=n.useRef(null),Yo=n.useRef(null),Ea=n.useRef(null),Xo=n.useRef(null),Jo=n.useRef(null),As=n.useRef(new Set);n.useEffect(()=>{if(Un===null)return;const e=Math.max(0,Date.now()-Un),s=e<6e4?1e3:e<36e5?6e4:e<864e5?36e5:864e5,l=Math.max(50,s-e%s),h=window.setTimeout(()=>Hu(Date.now()),l);return()=>window.clearTimeout(h)},[$o,Un]);const Aa=n.useRef(null),Lr=n.useRef(null),Qo=n.useRef(null),Gl=n.useRef(null),Ts=n.useRef(null),Re=n.useCallback(e=>U.getState().rootPath===e,[]);n.useEffect(()=>{if(!r||typeof window>"u")return;const e=s=>{const l=ab(s.target);l&&Qs("global_change_row_event",{...ob(s),selectionPath:l.dataset.diffSelectionPath,filePath:l.dataset.diffFilePath,absolutePath:l.dataset.diffAbsolutePath,repoRoot:l.dataset.diffRepoRoot,status:l.dataset.diffStatus,selectedFilePath:U.getState().selectedFilePath,rightTab:U.getState().rightTab,activeGitRepoRoot:me,changedFiles:U.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})}},[me,r]);const Wl=n.useCallback(async(e=d??void 0)=>{if(!e)return null;if(hr.current.has(e)||vn.current.has(e))return st("untracked_skip_cached",{cwd:e,rootPath:d,completed:hr.current.has(e),running:vn.current.has(e)}),null;const s=d,l=Pa.current+1;Pa.current=l,Gt.current.set(e,l);const h=`right-sidebar-git-untracked:${e}`,u=new AbortController;Wt.current.set(e,u),vn.current.add(e),st("untracked_start",{requestId:l,cwd:e,rootPath:d});try{let v=await td(e,u.signal,h),y=0;for(;v.status==="running"&&y<120;){if(Gt.current.get(e)!==l||u.signal.aborted)return st("untracked_stale_result",{requestId:l,activeRequestId:Gt.current.get(e),cwd:e,status:v.status}),null;if(!Re(s))return st("untracked_root_changed",{requestId:l,cwd:e,expectedRootPath:s,currentRootPath:U.getState().rootPath}),null;await new Promise(Z=>window.setTimeout(Z,y<10?1e3:3e3)),y+=1,v=await td(e,u.signal,h)}if(Gt.current.get(e)!==l||!Re(s))return st("untracked_stale_result",{requestId:l,activeRequestId:Gt.current.get(e),cwd:e,expectedRootPath:s,currentRootPath:U.getState().rootPath,files:v.files.length,status:v.status}),null;if(v.status==="done")return Ra(Mu(U.getState().changedFiles,v.files)),v.files.length>0&&ft(Z=>{const je=new Map(Z.map(ie=>[ie.root,ie])).get(e);if(!je)return Z;const Ke=qg(je.files,v.files),z=Z.map(ie=>ie.root===e?{...ie,files:Ke,context:ie.context?{...ie.context,changedFiles:Ke.map(Ce=>({path:Ce.path,absolutePath:Ce.absolutePath,status:Ce.status})),truncated:!1}:ie.context,untrackedDeferred:!1}:ie);Qt(Lu(z,d));const B=z.find(ie=>ie.root===d);return B?.context&&Jt(ie=>ie?.root===B.root?{...ie,...B.context}:ie),z}),hr.current.add(e),st("untracked_apply",{requestId:l,cwd:e,files:v.files.length}),v;const X=v.error||(v.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return hr.current.add(e),st("untracked_error",{requestId:l,cwd:e,message:X,code:v.code,status:v.status}),null}catch(v){if(Gt.current.get(e)!==l||!Re(s)||vr(v))return st("untracked_aborted",{requestId:l,activeRequestId:Gt.current.get(e),cwd:e,expectedRootPath:s,currentRootPath:U.getState().rootPath,message:v instanceof Error?v.message:String(v)}),null;const y=v instanceof Error?v.message:"Failed to scan untracked files";return hr.current.add(e),st("untracked_error",{requestId:l,cwd:e,message:y}),null}finally{Wt.current.get(e)===u&&Wt.current.delete(e),Gt.current.get(e)===l&&Gt.current.delete(e),vn.current.delete(e)}},[Ae,Re,d,Ra]),ar=n.useMemo(()=>{const e=new Set(Ue.map(l=>l.root)),s=Or.filter(l=>e.has(l));return s.length>0?s:me?[me]:[]},[me,Or,Ue]),ql=ar.length===0,wn=n.useMemo(()=>ar.map(e=>Be.find(s=>s.root===e)).filter(e=>!!e),[ar,Be]),Xu=n.useMemo(()=>Ue.map(e=>({root:e.root,label:e.label,branch:e.branch??null})),[Ue]),pr=n.useCallback(async()=>{if(!d){tn([]),_r([]);return}const e=d,s=Kn.current+1;Kn.current=s,Vn.current?.abort();const l=new AbortController;Vn.current=l,Nr(xt.length===0),Ur(null);try{const h=ar.length>0?await Promise.all(ar.map(u=>rd({workspaceRoot:d,repoRoot:u},l.signal))).then(u=>({records:u.flatMap(v=>v.records),walkthroughs:u.flatMap(v=>v.walkthroughs??[])})):await rd({workspaceRoot:d},l.signal);if(Kn.current!==s||!Re(e))return;tn(h.records),_r(h.walkthroughs??[])}catch(h){if(Kn.current!==s||!Re(e)||vr(h))return;Ur(h instanceof Error?h.message:"Failed to load change audit explanations")}finally{Vn.current===l&&(Vn.current=null),Kn.current===s&&Re(e)&&Nr(!1)}},[xt.length,ar,Re,d]),Ta=n.useCallback(async(e,s,l)=>{if(!e&&!d){Hr([]),xs([]);return}const h=d,u=Yn.current+1;Yn.current=u,Vr.current?.abort();const v=new AbortController;Vr.current=v;try{const y=e?[e]:Array.from(new Set([d,...Be.map(Z=>Z.root)].filter(Z=>!!Z))),X=await Promise.all(y.map(Z=>kh({repoRoot:Z,baseRef:s,branchName:l},v.signal))).then(Z=>{const de=new Map,je=new Map;for(const Ke of Z){for(const z of Ke.records)de.set(z.id,z);for(const z of Ke.walkthroughs??[])je.set(z.id,z)}return{records:Array.from(de.values()),walkthroughs:Array.from(je.values())}});if(Yn.current!==u||!Re(h))return;Hr(X.records),xs(X.walkthroughs??[])}catch(y){if(Yn.current!==u||!Re(h)||vr(y))return;console.warn("[RightSidebar] Failed to load branch explanations",y)}finally{Vr.current===v&&(Vr.current=null)}},[Be,Re,d]),Xn=n.useCallback((e,s={})=>{if(!Re(d)){st("apply_skipped_root_changed",{expectedRootPath:d,currentRootPath:U.getState().rootPath,bundleRoot:e.context?.root,files:e.files.length});return}st(e.files.length===0?"empty_bundle":"apply",{rootPath:d,available:e.available,files:e.files.length,repositories:e.repositories?.map(B=>({root:B.root,relativeRoot:B.relativeRoot,files:B.files.length,available:B.available,error:B.error})),repoFilters:e.repoFilters?.map(B=>({root:B.root,label:B.label,count:B.count})),cached:e.cached,stale:e.stale,cacheAgeMs:e.cacheAgeMs,untrackedDeferred:e.untrackedDeferred,error:e.error});let l=ju(e),h=e.repoFilters??[],u=e.files;const v=U.getState().changedFiles;if(!!(s.cacheOnly&&!e.cached&&e.files.length===0&&l.length===0)&&(v.size>0||Be.length>0||Ae)){st("cache_only_apply_skipped_empty_backend_cache",{rootPath:d,currentFiles:v.size,currentRepositories:Be.length});return}const X=l.some(B=>B.deferred);if(X&&!s.replaceWorkspace){const B=new Set(l.filter(Ce=>!Ce.deferred||Ce.root===d).map(Ce=>Ce.root));u=[...Array.from(v.values()).filter(Ce=>!B.has(ut(Ce,d)??"")),...e.files]}const Z=Vd(v.values(),d),de=Vd(e.files,d),je=l.some(B=>B.root!==d);if(!!(s.background&&!X&&!s.replaceWorkspace&&v.size>0&&(e.files.length===0&&!e.error||Z>0&&de===0&&!je))){st("background_apply_skipped_degraded_bundle",{rootPath:d,currentFiles:v.size,nextFiles:e.files.length,currentNestedCount:Z,nextNestedCount:de,nextRepositories:l.map(B=>({root:B.root,relativeRoot:B.relativeRoot,files:B.files.length})),cached:e.cached,stale:e.stale,error:e.error});return}if(s.replaceRepoRoot){const B=Iu(v.values(),Be,e,s.replaceRepoRoot,d);u=B.files,l=B.repositories,h=B.repoFilters}if(Ra(Tu(u)),ft(B=>{if(!X||s.replaceWorkspace)return l;const ie=new Map(B.map(Ce=>[Ce.root,Ce]));return l.map(Ce=>{const _e=ie.get(Ce.root);return!Ce.deferred||!_e?Ce:{...Ce,available:_e.available,files:_e.files,context:_e.context,deferred:_e.deferred,untrackedDeferred:_e.untrackedDeferred,error:_e.error}})}),Qt(h),Jo.current=d,s.syncActiveRepo!==!1){const{contextKey:B,activeGitRepos:ie}=U.getState(),Ce=B?ie[B]??null:null,_e=s.activeRepoRoot!==void 0?s.activeRepoRoot:Ce,Le=Lg({...e,repositories:l,repoFilters:h},_e);dt(Le)}typeof e.cacheUpdatedAt=="number"&&vl(e.cacheUpdatedAt),Jt(B=>{if(s.replaceRepoRoot&&s.replaceRepoRoot!==d)return B;if(!e.context)return null;const ie=B?.root??d;return!B?.available||ie!==(e.context.root??d)?e.context:{...B,...e.context}}),s.reloadDiff&&ko(B=>B+1);const z=U.getState().selectedFilePath;if(z&&!z.startsWith("/")&&!u.some(B=>B.path===z||B.absolutePath===z)&&tt(null),Rr(B=>{const ie=new Set(u.map(_e=>ut(_e,d)).filter(Boolean)),Ce=new Set;for(const _e of B)ie.has(_e)&&Ce.add(_e);return Bi($i,Ce),Ce}),s.loadDeferred!==!1){const B=l.filter(ie=>ie.untrackedDeferred&&ie.root).map(ie=>ie.root);for(const ie of B)Wl(ie)}s.loadAudit!==!1&&pr()},[Re,pr,Wl,d,tt,dt,Ra]);n.useEffect(()=>{ja(),Vo.current=null,Yo.current=d;const e=[],s=[];vt.current+=1,yn.current+=1,Pa.current+=1,Mr.current?.abort(),yt(Xs(qr.current?.cwd??d??void 0)),qr.current=null,Mr.current=null,Kr.current?.abort(),yt("right-sidebar-git-details"),Kr.current=null;for(const y of Wt.current.values())y.abort();for(const y of Wt.current.keys())yt(`right-sidebar-git-untracked:${y}`);Wt.current.clear(),Gt.current.clear(),Kn.current+=1,Vn.current?.abort(),Vn.current=null,Yn.current+=1,Vr.current?.abort(),Vr.current=null,Gr.current+=1,ur.current?.abort(),yt("right-sidebar-recent-commits"),ur.current=null,tn([]),_r([]),Nr(!1),Ur(null),$n([]),rn(!1),Hr([]),xs([]),lr(!1),tr(null),Te(!1),Me(null),ot(null),cr(null),an(null),zr(!1),cn(""),dr([]),ks(!1),Ss(!1),Dn(null),_n(!1),fa(null),un(null),fn(null),ul(!1),Pt(Fi,!1),Co(!1);const l=d?Hd()[d]:null,h=l?.previewEntries??[],u=l?.selectedPreviewKey??null,v=u?h.find(y=>y.key===u)??null:null;++T.current,Te(!1),No(l?.selectedRepoRoots??[]),pa(l?.repoTargetBranches??{}),ma(l?.repoBaseBranches??{}),sn(h),S(l?.previewScrollTops??{}),v&&l?.previewDetailOpen&&(v.diff.hunks?.length??0)>0&&(tr(v.diff),un(v.key),fn(l.selectedPreviewFileKey??(v.diff.hunks?.[0]?`${v.diff.hunks[0].filePath}\0${v.diff.hunks[0].hunkHeader}\0${v.diff.hunks[0].hunkIndex}`:null)),lr(!0)),Po(l?.repoIncludeUncommitted??Object.fromEntries(Object.keys(l?.repoTargetBranches??{}).map(y=>[y,l?.includeUncommitted??!0]))),Vo.current=d,xa(!1),hr.current.clear(),vn.current.clear(),Cs(null),Ns(null),hn(null),zt(null),vl(null),ft(e),Qt(s),Jt(null),Xo.current=null,Jo.current=null,As.current.clear()},[ja,d]);const It=n.useCallback(async(e=d??void 0,s={})=>{if(!e)return null;const l=d,h=vt.current;if(await Hp(()=>Promise.all([U.getState().hydrateNestedGitScanRoots(),U.getState().hydrateActiveGitRepos()]).then(()=>{})),vt.current!==h||!Re(l))return null;const u=e===d&&Vs(d),v=s.includeNested??u,y=s.refresh??s.reloadDiff??!1,X=s.cacheOnly??!1,Z=s.background??!1,de=v&&(s.discoverOnly??!1);y&&hr.current.clear();const je=qr.current;if(je&&je.cwd===e&&je.includeNested===v&&je.refresh===y&&je.cacheOnly===X&&je.discoverOnly===de)return st("reuse_pending",{cwd:e,includeNested:v,refresh:y,cacheOnly:X,discoverOnly:de}),je.promise;const Ke=vt.current+1;vt.current=Ke;const z=`right-sidebar:${zl}:${Ke}`;Mr.current?.abort();const B=Xs(e);yt(B);const ie=new AbortController;Mr.current=ie;let Ce=null;Z||$l(z),Go(null),st("start",{requestId:Ke,cwd:e,rootPath:d,requestSlotId:B,includeNested:v,refresh:y,cacheOnly:X,background:Z,existingChanges:Ee.size,lastLoadedAt:Wn}),!Z&&typeof window<"u"&&(Ce=window.setTimeout(()=>{vt.current===Ke&&Fl(z,!0)},pg));const _e=(async()=>{const Le=await Ci(e,ie.signal,{includeNested:v,refresh:y,cacheOnly:X,discoverOnly:de,action:y?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:B,requestTimeoutMs:y?null:void 0});if(Yg(Le)){if(st("cancelled_result_ignored",{requestId:Ke,activeRequestId:vt.current,cwd:e,error:Le.error??Le.context?.error}),ie.signal.aborted)return null;throw new Error(Le.error??Le.context?.error??"Failed to load Git changes")}return vt.current!==Ke||!Re(l)?(st("stale_result",{requestId:Ke,activeRequestId:vt.current,cwd:e,expectedRootPath:l,currentRootPath:U.getState().rootPath,files:Le.files.length,repositories:Le.repositories?.length??0}),null):(Xn(Le,{reloadDiff:s.reloadDiff,syncActiveRepo:s.replaceWorkspace?!0:v,background:Z,cacheOnly:X,replaceRepoRoot:s.replaceRepoRoot,replaceWorkspace:s.replaceWorkspace}),Le)})();qr.current={cwd:e,includeNested:v,refresh:y,cacheOnly:X,discoverOnly:de,promise:_e};try{const Le=await _e;return vt.current===Ke&&Le&&Re(l)?Dl({cached:Le.cached,stale:Le.stale,cacheAgeMs:Le.cacheAgeMs,nestedDeferred:!v||Le.nestedDeferred,untrackedDeferred:Le.untrackedDeferred}):vt.current===Ke&&Re(l)&&zo(z),Le}catch(Le){return vt.current!==Ke||!Re(l)||ie.signal.aborted?(st("aborted",{requestId:Ke,activeRequestId:vt.current,cwd:e,expectedRootPath:l,currentRootPath:U.getState().rootPath,message:Le instanceof Error?Le.message:String(Le)}),null):(st("error",{requestId:Ke,cwd:e,includeNested:v,refresh:y,background:Z,message:Le instanceof Error?Le.message:String(Le)}),Z||(Jt(null),Go(Le instanceof Error?Le.message:"Failed to load Git changes")),null)}finally{Ce!==null&&window.clearTimeout(Ce),Mr.current===ie&&(Mr.current=null),qr.current?.promise===_e&&(qr.current=null),!Z&&vt.current===Ke&&Re(l)&&zo(z)}},[Xn,$l,Ee.size,zo,zl,Wn,Re,Dl,d,Go,Fl]),Jn=n.useCallback(async()=>{d&&await It(d,{reloadDiff:!0,refresh:!0})},[It,d]),Zo=n.useCallback(async(e=d??void 0)=>{if(!e)return null;const s=d,l=yn.current+1;yn.current=l,Kr.current?.abort(),yt("right-sidebar-git-details");const h=new AbortController;Kr.current=h,xa(!0);try{const u=await nd(e,h.signal,"load_git_details","right-sidebar-git-details");return yn.current!==l||!Re(s)?null:(ft(v=>v.map(y=>y.root===u.root?{...y,available:u.available,context:u,error:u.error}:y)),Jt(v=>v?.root&&u.root&&v.root!==u.root?v:!v?.available||!u.available?u:{...v,...u}),u)}catch(u){return vr(u)||!Re(s)||yn.current===l&&zt(u instanceof Error?u.message:"Failed to load Git details"),null}finally{Kr.current===h&&(Kr.current=null),yn.current===l&&Re(s)&&xa(!1)}},[Re,d]);n.useEffect(()=>{if(!r){vt.current+=1,ja(),Xo.current=null,yn.current+=1,Pa.current+=1,Mr.current?.abort(),yt(Xs(qr.current?.cwd??d??void 0)),qr.current=null,Mr.current=null,Kr.current?.abort(),yt("right-sidebar-git-details"),Kr.current=null;for(const e of Wt.current.values())e.abort();for(const e of Wt.current.keys())yt(`right-sidebar-git-untracked:${e}`);Wt.current.clear(),Gt.current.clear(),Yn.current+=1,Vr.current?.abort(),Vr.current=null,Gr.current+=1,ur.current?.abort(),yt("right-sidebar-recent-commits"),ur.current=null,xa(!1),Te(!1),Me(null),ot(null),cr(null),an(null),zr(!1),cn(""),dr([]),ks(!1),Ss(!1),Dn(null),_n(!1),he(""),C(!1),Ut(null),Lo(!1),J&&pl(!1)}},[J,r,ja,C]),n.useEffect(()=>{if(!ee)return;const e=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(e)},[ee]),n.useEffect(()=>{J||Ar(!1)},[J]);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(J)if(Ar(m),m&&et){Tr(1);const e=Lr.current;e&&(e.update(),e.activeIndex!==1&&(Ts.current=1,e.slideTo(1,0)))}else{Tr(0);const e=Lr.current;e&&e.activeIndex!==0&&(Ts.current=0,e.slideTo(0,0)),Ut(null)}},[J,m,d,et]),n.useEffect(()=>{if(x!==void 0&&!m){Tr(0);const e=Lr.current;e&&e.activeIndex!==0&&(Ts.current=0,e.slideTo(0,0)),Ar(!1),Ut(null)}},[x,m]),n.useEffect(()=>{A!==void 0&&bt(null)},[A]),n.useEffect(()=>{!J&&m&&R?.()},[J,R,m]),n.useEffect(()=>{Bo(e=>nl(e,i))},[i]);const Ju=n.useCallback(e=>{J||(e.preventDefault(),Aa.current={startX:e.clientX,startWidth:_o,pointerId:e.pointerId},e.currentTarget.setPointerCapture(e.pointerId))},[_o,J]),Qu=n.useCallback(e=>{const s=Aa.current;if(!s||s.pointerId!==e.pointerId)return;const l=nl(s.startWidth+e.clientX-s.startX,i);Bo(l),ra(ea,l,hg)},[i]),Vl=n.useCallback(e=>{const s=Aa.current;if(!(!s||s.pointerId!==e.pointerId)){Aa.current=null,Ks(ea);try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}},[]),Qn=!!(d&&Wn!==null&&Jd(Ae)),ei=!!(d&&!xn&&Ee.size===0&&Wn===null),jt=(()=>{let e=Uo;return e==="android"&&!Wr&&(e="files"),(e==="architecture"||e==="computer")&&!sr[e]&&(e="files"),Qn&&(e==="git"||e==="diff")&&(e="files"),e})(),nt=jt==="git",Ir=jt==="files",Ct=jt==="diff",Zn=jt==="android",es=jt==="computer",kn=jt==="architecture",[Zu,ef]=n.useState(!1);n.useEffect(()=>{r&&es&&ef(!0)},[r,es]);const[tf,rf]=n.useState(!1);n.useEffect(()=>{r&&kn&&rf(!0)},[r,kn]);const ti=n.useRef(null),ts=n.useCallback((e,s)=>{const l=U.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},Mt(e)},[Mt]);n.useEffect(()=>{const e=ti.current;if(!e||e.to!==jt)return;ti.current=null;const s=Math.round(performance.now()-e.startedAt);let l=window.requestAnimationFrame(()=>{l=window.requestAnimationFrame(()=>{Qs("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)},[jt]);const nf=gp(e=>e.overlay==="sidebar")&&Zn;n.useEffect(()=>{if(!J){ga(!0);return}if(!r){const s=window.setTimeout(()=>{ga(!1)},bg);return()=>window.clearTimeout(s)}ga(!1);const e=window.setTimeout(()=>{ga(!0)},gg);return()=>window.clearTimeout(e)},[J,r]),n.useEffect(()=>{if(!J||!Ct)return;const e=Qo.current;if(!e)return;const s=window.requestAnimationFrame(()=>{e.update()});return()=>window.cancelAnimationFrame(s)},[Ct,J]),n.useEffect(()=>{if(!Qn||!d||fr)return;const e=window.setTimeout(()=>{It(d,{background:!0})},3e3);return()=>window.clearTimeout(e)},[Qn,d,fr,It]);const sf=n.useCallback(e=>{It(e,{discoverOnly:!0})},[It]);zp({active:r&&(nt||Ct),rootPath:d,loading:fr,delay:nt&&!J?0:_i,lastStartedRoot:Xo,load:sf}),n.useEffect(()=>{!r||!nt||(!J||Mo)&&Lo(!0)},[nt,J,r,Mo]),n.useEffect(()=>{if(!r||nt)return;const e=window.setTimeout(()=>{Lo(!0)},_i);return()=>window.clearTimeout(e)},[nt,r]),n.useEffect(()=>{Ir&&Bu(!0)},[Ir]),n.useEffect(()=>{Ct&&pl(!0)},[Ct]),n.useEffect(()=>{!r||!Zn||(a&&ba&&ba.sessionId!==a&&(ji.getState().setDock(Ai,null),Zs({androidPanel:{docked:null}}).catch(()=>{})),ml(!0))},[Zn,r,a,ba]),n.useEffect(()=>{if(r&&Zn||!Io)return;const e=window.setTimeout(()=>ml(!1),mg);return()=>window.clearTimeout(e)},[r,Zn,Io]),n.useEffect(()=>{let e=!1;return Zd().then(s=>{e||(js.current.has("android")||gl(s.androidPanel?.enabled===!0),bl(l=>({architecture:js.current.has("architecture")?l.architecture:s.rightSidebarTabs?.architecture===!0,computer:js.current.has("computer")?l.computer:s.rightSidebarTabs?.computer===!0})))}).catch(()=>{}),()=>{e=!0}},[]);const Yl=n.useCallback(e=>{js.current.add("android"),gl(e),e?Mt("android"):U.getState().rightTab==="android"&&Mt("files"),Zs({androidPanel:{enabled:e}}).catch(()=>{})},[Mt]),af=n.useCallback((e,s)=>{js.current.add(e),bl(l=>({...l,[e]:s})),s?Mt(e):U.getState().rightTab===e&&Mt("files"),Zs({rightSidebarTabs:{[e]:s}}).catch(()=>{})},[Mt]),Xl=n.useCallback(e=>{re&&Og(re,e.currentTarget.scrollTop)},[re]);n.useEffect(()=>()=>{Mr.current?.abort(),Ks(ol),Ks(il),Ks(ea),Ks(Di)},[]),n.useEffect(()=>{if(!re||!Hl)return;const e=Eu()[re]?.top;if(typeof e!="number")return;let s=window.requestAnimationFrame(()=>{qn.current&&(qn.current.scrollTop=e),s=window.requestAnimationFrame(()=>{qn.current&&(qn.current.scrollTop=e)})});return()=>window.cancelAnimationFrame(s)},[re,Hl]),n.useEffect(()=>{if(!r)return;const e=new AbortController;return Sh(e.signal).then(s=>Rl(!!s.available)).catch(()=>Rl(!1)),()=>e.abort()},[r]);const Ms=n.useCallback(e=>{if(j(null),tt(e),Ut(null),J){Ar(!0),Tr(1),Lr.current?.slideTo(1),w?.();return}},[J,w,tt]),ri=n.useCallback((e,s)=>{if(j(null),tt(e),Et(s),J){Ar(!0),Tr(1),Lr.current?.slideTo(1),w?.();return}},[J,w,tt]),$t=xm(e=>Ps(e,!1)),Ma=$t.busy,Ls=n.useCallback(async(e,s)=>{const l=s||zn||d;!l||!e.length||await $t.start(l,e)},[zn,d,$t.start]),Jl=n.useCallback(async e=>{try{await Rh(e)}catch(s){zt(s instanceof Error?s.message:o("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>zt(null),4e3)}},[o]),La=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.types.includes("Files")&&Fo(!0)},[]),Ql=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),Fo(!1)},[]),Zl=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),Fo(!1);const s=e.dataTransfer.files;s.length>0&&Ls(Array.from(s))},[Ls]),ni=n.useCallback(e=>{V(e),window.setTimeout(()=>V(s=>s===e?null:s),1400)},[]),mr=n.useCallback(e=>{Ze(e),window.setTimeout(()=>Ze(s=>s===e?null:s),1400)},[]);n.useEffect(()=>{Pt(Id,N)},[N]),n.useEffect(()=>{Pt($d,ke)},[ke]),n.useEffect(()=>{Pt(Fd,ht)},[ht]),n.useEffect(()=>{ra(Di,kt,lg)},[kt]),n.useEffect(()=>(Pl().catch(()=>{}),sd(e=>{e.type==="pinned-explorer-roots"&&El(e.pinnedExplorerRoots)})),[Pl,El]);const ec=n.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),Ia=n.useRef(null),Sn=n.useRef(null),[tc,si]=n.useState(!1);n.useEffect(()=>{if(!r)return;si(!1);let e=!1;jh().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=sd(l=>{l.type==="context-draft"&&l.origin!==ec.current&&(Ia.current=l.text,St(l.text))});return()=>{e=!0,s(),Sn.current!==null&&(window.clearTimeout(Sn.current),Sn.current=null)}},[r]),n.useEffect(()=>{if(!tc||Ia.current===kt)return;Sn.current!==null&&window.clearTimeout(Sn.current);const e=kt;Sn.current=window.setTimeout(()=>{Sn.current=null,Ch(e,ec.current).then(()=>{Ia.current=e}).catch(()=>{})},500)},[kt,tc]);const rs=n.useCallback(async(e,s,l,h)=>{if(!e)return!1;if(ir(!1),h&&!Ni(h)())return ir(!0),!1;if(Nh(l?e+l:e))return ni(s),!0;if(N)St(u=>mm(u,e)+(l??"")),window.matchMedia("(pointer: coarse)").matches||(Ye(!1),hs(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 ir(!0),!1}return ni(s),!0},[N,ni,a]),$a=n.useCallback(e=>{const s=An(e,d);return Ph(s,d)},[d]),ai=tu(mr),qt=n.useCallback((e,s,l)=>{const h=An(e,d);return rs(ad(h,d),s??`path:${h}`,void 0,l)},[d,rs]),ns=n.useRef({sessionId:a,contextDraftEnabled:N,isOpen:r});ns.current={sessionId:a,contextDraftEnabled:N,isOpen:r};const of=n.useCallback(async(e,s)=>{const l=a??Yr.getState().activeSessionId,h=()=>$s.current&&ns.current.isOpen&&(ns.current.sessionId??Yr.getState().activeSessionId)===l&&Yr.getState().activeSessionId===l&&ns.current.contextDraftEnabled===N;await $t.start("/tmp",[e],v=>qt(v,`path:${v}`,s),h)&&h()&&J&&!N&&c()},[N,qt,J,c,a,$t.start]),Is=n.useRef(!0),Fa=n.useRef(a);Fa.current=a,n.useEffect(()=>(Is.current=!0,()=>{Is.current=!1}),[]);const lf=n.useCallback(e=>{bp.getState().enqueue(e,a??null,d||"/",async(s,l)=>{if(ns.current.contextDraftEnabled&&Is.current&&Fa.current===a){if(!await oi.current(ad(s,null),`path:${s}`,l))throw new Error(o("rightSidebar.uploadReferenceRejected"))}else return bd(s,a,l)})},[a,d,N,qt,o]),cf=n.useCallback(async(e,s)=>{const l=Ni(s),u=(await Wi("/tmp",[e])).files[0]?.path;if(!u)throw new Error("截图上传未返回文件路径");if(!l()||!Is.current||Fa.current!==a||ns.current.contextDraftEnabled!==N)throw new Error(o("rightSidebar.uploadReferenceRejected"));if(N&&Is.current&&Fa.current===a){if(!await qt(u,void 0,s))throw new Error(o("rightSidebar.uploadReferenceRejected"))}else await bd(u,a,s)},[N,qt,a,o]),$r=n.useCallback((e,s,l)=>{if(!e)return Promise.resolve(!1);const h=e.includes(`
|
|
1645
1645
|
`)?`
|
|
1646
1646
|
`:void 0;return rs(e.endsWith(`
|
|
1647
|
-
`)||e.endsWith(" ")?e:`${e} `,s,h,l)},[rs]),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 v=a??
|
|
1648
|
-
`,h):Promise.resolve(!1),[rs]),rc=
|
|
1647
|
+
`)||e.endsWith(" ")?e:`${e} `,s,h,l)},[rs]),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 v=a??Yr.getState().activeSessionId;return ii.current.add(s),Vp(e,s,l,{insert:(y,X)=>$r(y,X,h),upload:async(y,X)=>(await Wi("/tmp",[y],X)).files[0]?.path,isCurrent:()=>u()&&$s.current&&oi.current===$r&&v===Yr.getState().activeSessionId}).catch(()=>(ir(!0),!1)).finally(()=>ii.current.delete(s))},[$r,a]),Fr=n.useCallback((e,s,l,h)=>s?rs(s.endsWith(" ")?s:`${s} `,l??`context:${e}`,`
|
|
1648
|
+
`,h):Promise.resolve(!1),[rs]),rc=ym({text:kt,sessionId:a??Yr.getState().activeSessionId,active:r&&N,onAccepted:()=>{en(!1),St(""),ht&&Ye(!0)},onRejected:()=>{en(!0),Ye(!1)}}),Qe=n.useMemo(()=>d?gt(d):o("rightSidebar.workspace"),[d,o]),df=n.useMemo(()=>gt(re)||Qe,[re,Qe]),_a=n.useMemo(()=>lo(re),[re]),Ba=n.useMemo(()=>d?Nl[d]??[]:[],[Nl,d]),Rn=n.useMemo(()=>new Set(Ba.map(e=>e.path)),[Ba]),Fs=!!(re&&Rn.has(re)),li=!!(d&&re&&re!==d),uf=!!(d&&zn&&zn!==d),Ft=re?`path:${re}`:null,nc="context:change-audit",ff=n.useCallback(()=>{_a&&Lt(_a)},[_a,Lt]),sc=n.useCallback(()=>{Al()},[Al]),hf=n.useCallback(()=>{re&&(Ps(re,!0),Ll())},[Ll,re,Ps]),pf=n.useCallback(()=>{!re||!li||(Fs?bn(re):Gn(re,"directory"))},[li,re,Fs,Gn,bn]),ac=n.useCallback(e=>{Lt(e),he("")},[Lt]),oc=n.useCallback(e=>{re&&(we(og(re,e)),C(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[re,C]),ic=n.useCallback(e=>{!d||e===d||(Rn.has(e)?bn(e):Gn(e,"directory"))},[Gn,Rn,d,bn]),lc=n.useCallback(e=>{!d||!e||(Rn.has(e)?bn(e):Gn(e,"file"))},[Gn,Rn,d,bn]),cc=U(e=>e.expandedPaths),ci=n.useMemo(()=>{const e=new Set;if(Ir&&re){e.add(re);const s=`${re.replace(/\/+$/,"")}/`;for(const l of cc)l.startsWith(s)&&e.add(l)}if(Ir&&d&&et){const s=et.startsWith("/")?et:`${d}/${et}`,l=lo(s);l&&e.add(l)}return im(e).join(`
|
|
1649
1649
|
`)},[cc,Ir,re,d,et]),jn=n.useRef(new Map);n.useEffect(()=>{const e=ci?ci.split(`
|
|
1650
|
-
`):[];if(!r||e.length===0){Hn(null);return}const s=new AbortController;let l=!1,h=0,u=0;Hn(null);const v=async()=>{let y=0;for(;!l&&!s.signal.aborted;){let X=null;try{Hn(null),await Dh(e,de=>{const{applicableEvents:je,unavailableReason:Ke}=dm(de);je.length>0&&Tl(je);const z=new Set(je.filter(B=>B.type==="rescan-required").map(B=>B.path));if(Ca)for(const B of je){if(B.type==="created"||B.type==="updated"){const ie=lo(B.path);ie&&z.add(ie)}B.path.endsWith("/.gitignore")&&re&&Ps(re,!0)}for(const B of z){const ie={path:B},Ce=U.getState();if(!Ce.directoryCache.has(ie.path))continue;jn.current.get(ie.path)?.abort();const Le=new AbortController;jn.current.set(ie.path,Le);const Qc=`file-watch-rescan:${ie.path}`;yt(Qc),Qd(ie.path,Le.signal,Ce.showHiddenFiles,"watch_rescan",Qc,Ce.fileSortModes[ie.path]??"name",re??void 0).then(Gs=>{jn.current.get(ie.path)===Le&&Ml(ie.path,Gs.entries)}).catch(Gs=>{vr(Gs)||Hn(Gs instanceof Error?Gs.message:"File refresh unavailable")}).finally(()=>{jn.current.get(ie.path)===Le&&jn.current.delete(ie.path)})}Ke&&Hn(Ke)},s.signal),X=new Error("File watch stream ended")}catch(de){X=de}if(l||s.signal.aborted||vr(X))return;Hn(X instanceof Error?X.message:"File watching unavailable");const Z=Dd[Math.min(y,Dd.length-1)];y+=1,await new Promise(de=>{u=window.setTimeout(de,Z)})}};return h=window.setTimeout(()=>{l||v()},_i),()=>{l=!0,window.clearTimeout(h),window.clearTimeout(u),s.abort();for(const y of jn.current.values())y.abort();jn.current.clear()}},[Tl,r,Ml,ci,re,Ca,Ps]),n.useEffect(()=>{if(!d||Vo.current!==d)return;if(Yo.current===d){Yo.current=null;return}const e=Hd();ra(Su,{...e,[d]:{selectedRepoRoots:ha,repoTargetBranches:rr,repoBaseBranches:Rt,previewEntries:nn,selectedPreviewKey:fe&&Er?qe:null,selectedPreviewFileKey:fe&&Er?Eo:null,previewDetailOpen:!!(fe&&Er),previewScrollTops:vs,previewMobileSlideIndex:1,repoIncludeUncommitted:dn,updatedAt:Date.now()}},lg)},[Er,dn,fe,nn,vs,Rt,rr,ha,d,Eo,qe]);const it=n.useMemo(()=>Xd(Ee.values()),[Ee]),rt=n.useMemo(()=>{const e=new Map;for(const s of Be)e.set(s.root,s);return e},[Be]),Ds=n.useMemo(()=>{const e=new Map;for(const s of Be)s.deferred||e.set(s.root,s.files.length);return e},[Be]),Ua=n.useCallback(e=>{if(e){if(!e.deferred){As.current.delete(e.root);return}Ds.has(e.root)||As.current.has(e.root)||(As.current.add(e.root),It(e.root,{includeNested:!1,background:!0,replaceRepoRoot:e.root}).then(s=>{s||As.current.delete(e.root)}))}},[It,Ds]),or=n.useMemo(()=>me?Ue.find(e=>e.root===me)??null:null,[me,Ue]),Kt=n.useMemo(()=>et?Array.from(Ee.values()).find(e=>e.path===et||e.absolutePath===et)??null:null,[Ee,et]),Dt=n.useMemo(()=>{const e=new Map;for(const s of Be)s.available&&s.context?.available&&e.set(s.root,s);return e.size===0&&Ae?.available&&Ae.root&&e.set(Ae.root,{id:Ae.root,root:Ae.root,relativeRoot:".",name:Qe,depth:0,nested:!1,available:!0,files:Array.from(Ee.values()).filter(s=>ut(s,d)===Ae.root),context:Ae}),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==="."?Qe:s.relativeRoot||s.name||gt(s.root),h=Yd(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(" · ")}})},[Ee,Ae,Be,Qe,d,o]),ve=n.useMemo(()=>me&&Dt.some(e=>e.value===me)?me:Kt?.repoRoot&&Dt.some(e=>e.value===Kt.repoRoot)?Kt.repoRoot:Dt.length===1||Dt.length>1?Dt[0].value:null,[me,Dt,Kt?.repoRoot]),dc=ve?rt.get(ve)??null:null,se=dc?.context?.available?dc.context:ve===Ae?.root?Ae:null,Xe=Dt.length>0&&!ve,uc=n.useMemo(()=>Xe?[]:ve?Array.from(Ee.values()).filter(e=>ut(e,d)===ve):Array.from(Ee.values()),[ve,Ee,Xe,d]),Cn=n.useMemo(()=>Xd(uc),[uc]),di=!!(se?.available&&se.root&&ve&&se.root===ve),mf=ve?Dt.find(e=>e.value===ve)?.label??gt(ve):o("rightSidebar.gitRepositoryPlaceholder"),fc=di?se?.branch??"HEAD":Xe?o("rightSidebar.selectRepositoryForGitActions"):pn?o("rightSidebar.gitActionRunning"):"HEAD",Nn=!!(se?.available&&se.root===ve&&se.status);n.useEffect(()=>{dl.current={count:Tt.length,loading:da,loadingMore:ua,hasMore:Ro}},[Tt.length,Ro,da,ua]),n.useEffect(()=>{Wr.current+=1,ur.current?.abort(),yt("right-sidebar-recent-commits"),ur.current=null,cn(""),dr([]),ks(!1),Ss(!1),Dn(null),_n(!1)},[ve]);const _s=n.useCallback(async(e={})=>{if(!d||!ve||Xe)return;const s=e.reset??!1,l=dl.current,h=s?0:l.count;if(!s&&(l.loading||l.loadingMore||!l.hasMore))return;const u=Wr.current+1;Wr.current=u,ur.current?.abort(),yt("right-sidebar-recent-commits");const v=new AbortController;ur.current=v,s?ks(!0):Ss(!0),Dn(null);try{const y=await Eh({cwd:d,repoRoot:ve,limit:vg,skip:h,query:ws.trim(),requestSlotId:"right-sidebar-recent-commits"},v.signal);if(Wr.current!==u)return;if(!y.available){Dn(y.error??"Recent commits are unavailable"),s&&dr([]),_n(!1);return}We(X=>s?y.commitSyncStatus??{}:{...X,...y.commitSyncStatus}),dr(X=>s?y.commits:[...X,...y.commits]),_n(y.hasMore)}catch(y){if(Wr.current!==u||vr(y))return;Dn(y instanceof Error?y.message:"Failed to load recent commits"),s&&dr([]),_n(!1)}finally{ur.current===v&&(ur.current=null),Wr.current===u&&(ks(!1),Ss(!1))}},[ve,ws,Xe,d]);n.useEffect(()=>{on&&_s({reset:!0})},[ws,_s,on,se?.ahead,se?.behind,se?.upstream]);const gf=n.useCallback(e=>{const s=e.currentTarget;s.scrollTop+s.clientHeight<s.scrollHeight-48||_s({reset:!1})},[_s]);n.useEffect(()=>{!ve||!Ae?.available||!nt||!nr||Nn||pn||Xe||Zo(ve)},[ve,Ae?.available,Nn,pn,nt,nr,Zo,Xe]);const hc=r&&(Ct||nt);n.useEffect(()=>{!hc||!d||pr()},[hc,pr,d]),n.useEffect(()=>{!r||!nt||!nr||!Rs||!d||Ta(null)},[Rs,nt,nr,r,Ta,d]);const bf=n.useMemo(()=>{if(!me)return 0;const e=Ue.findIndex(s=>s.root===me);return e>=0?e+1:0},[me,Ue]),pc=n.useCallback(e=>{if(!e)return null;const s=Array.from(Ee.values()).filter(l=>ut(l,d)===e).sort((l,h)=>l.path.localeCompare(h.path))[0];return s?xr(s):null},[Ee,d]),Pn=Ue.length>1,Oa=n.useMemo(()=>[{root:null,label:o("rightSidebar.allRepositories"),count:Ee.size,branch:null,deferred:!1},...Ue.map(e=>({root:e.root,label:e.label,count:e.deferred?Ds.get(e.root)??0:e.count,branch:e.branch??null,deferred:!!e.deferred&&!Ds.has(e.root)}))],[Ee.size,Ue,Ds,o]),mc=Oa[bf]??Oa[0],Ha=!!me,gc=n.useMemo(()=>Cu(Ue,Be),[Ue,Be]);n.useEffect(()=>{Jo.current===d&&me&&!gc.has(me)&&dt(null),$n(e=>e.filter(s=>Ue.some(l=>l.root===s)))},[me,Ue,gc,d,dt]),n.useEffect(()=>{me&&Ua(rt.get(me))},[me,Ua,rt]);const xf=n.useMemo(()=>{const e=new Set;se?.branch&&e.add(se.branch);for(const s of se?.branches??[])e.add(s);return Array.from(e).map(s=>({value:s,label:s,meta:s===se?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0}))},[se?.branch,se?.branches,o]),bc=n.useMemo(()=>{const e=new Set;se?.upstreamRemote&&e.add(se.upstreamRemote);for(const s of se?.remotes??[])e.add(s);return Array.from(e).map(s=>({value:s,label:s,meta:s===se?.upstreamRemote?o("rightSidebar.pushUpstreamBadge"):void 0}))},[se?.remotes,se?.upstreamRemote,o]),xc=bc.length>1,vf=n.useMemo(()=>{const e=[],s=new Set,l=(u,v)=>{!u||s.has(u)||(s.add(u),e.push({value:u,label:u,meta:v}))};l(se?.upstreamBranch,se?.upstreamBranch?o("rightSidebar.pushUpstreamBadge"):void 0),l(se?.branch,se?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0);for(const u of se?.branches??[])l(u,u===se?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");const h=se?.upstreamRemote;for(const u of se?.remoteBranches??[]){const v=u.indexOf("/"),y=v>=0?u.slice(0,v):null,X=v>=0?u.slice(v+1):u;(!h||y===h)&&l(X,"remote")}return e},[se?.branch,se?.branches,se?.remoteBranches,se?.upstreamBranch,se?.upstreamRemote,o]),Vt=n.useMemo(()=>Dt.map(e=>{const s=rt.get(e.value);return{root:e.value,label:e.label,branch:s?.context?.branch??null}}),[Dt,rt]);n.useEffect(()=>{Vt.length!==0&&(pa(e=>{let s=!1;const l={...e},h=new Set(Vt.map(u=>u.root));for(const u of Object.keys(l))h.has(u)||(delete l[u],s=!0);for(const u of Vt)!l[u.root]&&u.branch&&(l[u.root]=u.branch,s=!0);return s?l:e}),ma(e=>{let s=!1;const l={...e},h=new Set(Vt.map(u=>u.root));for(const u of Object.keys(l))h.has(u)||(delete l[u],s=!0);for(const u of Vt){const v=rt.get(u.root)?.context;if(l[u.root]&&Nu(l[u.root],v?.branch)&&(delete l[u.root],s=!0),l[u.root])continue;const y=Wd(v);y&&(l[u.root]=y,s=!0)}return s?l:e}))},[Vt,rt]);const za=n.useMemo(()=>{const e=new Set(Vt.map(s=>s.root));return ha.filter(s=>e.has(s))},[ha,Vt]),Ga=za.length===0,gr=n.useMemo(()=>Ga?Vt:Vt.filter(e=>za.includes(e.root)),[Vt,za,Ga]),Bs=n.useMemo(()=>gr.filter(e=>!!Rt[e.root]?.trim()),[Rt,gr]),ss=n.useCallback((e,s)=>{const l=rt.get(e)?.context?.branch;return!!(l&&s&&s.replace(/^refs\/heads\//,"")===l)},[rt]),vc=n.useMemo(()=>gr.filter(e=>!Rt[e.root]?.trim()),[Rt,gr]),yc=n.useCallback(async e=>{if(!e||Ko.current.has(e))return;const s=rt.get(e)?.context;if((s?.branches?.length??0)>0||(s?.remoteBranches?.length??0)>0||s?.upstream)return;const l=d;Ko.current.add(e),hl(h=>new Set(h).add(e));try{const h=await nd(e,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${e}`);if(!h.available||!Re(l))return;ft(u=>u.map(v=>v.root===e?{...v,available:!0,context:{...v.context,...h},error:void 0}:v)),pa(u=>u[e]||!h.branch?u:{...u,[e]:h.branch}),ma(u=>{if(u[e])return u;const v=Wd(h);return v?{...u,[e]:v}:u})}catch(h){vr(h)||console.warn("[RightSidebar] Failed to load branch audit repo details",e,h)}finally{Ko.current.delete(e),hl(h=>{const u=new Set(h);return u.delete(e),u})}},[rt,Re,d]);n.useEffect(()=>{if(jo)for(const e of gr)yc(e.root)},[jo,gr,yc]),n.useEffect(()=>{!di||!se||(ya(se.branch||(se.branches?.[0]??"")),wa(se.upstreamRemote||(se.remotes?.includes("origin")?"origin":se.remotes?.[0]??"")),ka(se.upstreamBranch||se.branch||(se.branches?.[0]??"")))},[se,di]);const wc=n.useMemo(()=>{if(Xe)return{text:o("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!Nn||pn)return{text:o("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!se?.upstream)return{text:o("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const e=se.ahead??0,s=se.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"}},[se?.ahead,se?.behind,se?.upstream,Nn,pn,Xe,o]),yf=n.useCallback(e=>{if(e&&!J){const s=e.currentTarget.getBoundingClientRect();bt({x:Math.min(s.left,window.innerWidth-352),y:Math.min(s.bottom+6,window.innerHeight-64)})}else bt(null);P?.()},[J,P]),ui=n.useCallback(()=>{bt(null),$?.()},[$]);function kc(){if(!Pn)return null;const e=mc?.label??o("rightSidebar.allRepositories"),s=mc?.count??Ee.size,l=gt(e)||e;return t.jsxs("button",{type:"button",onClick:yf,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(br,{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(sa,{size:12,className:"shrink-0"})]})}function wf(){if(!b||!Pn||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(at?.x??e-368,e-352)),h=Math.max(12,Math.min(at?.y??80,s-420)),u=J?void 0:{left:l,top:h},v=t.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${J?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:ui,children:t.jsxs("div",{className:J?"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:y=>y.stopPropagation(),children:[t.jsxs("div",{className:J?"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:J?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:o("rightSidebar.repositories")}),!J&&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] ${Ee.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Ee.size})]})]}),t.jsx("button",{type:"button",onClick:ui,className:J?"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(Xt,{size:J?16:14})})]}),t.jsx("div",{className:J?"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(y=>{const X=(y.root??null)===me,Z=gt(y.label)||y.label;return t.jsxs("button",{type:"button",onClick:()=>{Hc(y.root),ui()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${J?"px-3 py-2":"px-2 py-1.5"} ${X?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:y.label,role:"option","aria-selected":X,children:[t.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${X?"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 ${X?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:t.jsx(br,{size:13})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:`${J?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:Z}),t.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:y.root===null?o("rightSidebar.allRepositories"):y.label})]}),y.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:y.branch}),y.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] ${y.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:y.count})]},y.root??"all")})})]})});return bu(v,J,document.body)}function kf(){return wf()}function Sc(e){const s=ut(e,d),l=e.absolutePath||(s?`${s}/${e.path}`:e.path),h=ho(l,s??d);return{key:xr(e),path:e.path,absolutePath:l,displayName:h.name,displayDir:h.dir,oldPath:e.oldPath,status:e.status,title:l}}function Rc(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=An(e,d),h=`path:${l}`,u=Oe===h,v=ye===h,y=u||v;return t.jsx("button",{type:"button",onClick:X=>{X.stopPropagation(),qt(l,h,X.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 ${y?"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"} ${y?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:s,children:t.jsx("span",{className:"whitespace-nowrap",children:o(v?"rightSidebar.copied":u?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function jc(e){const s=ut(e,d),l=e.absolutePath||(s?`${s}/${e.path}`:e.path),h=Xf(e),u=Hi(e);return t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Jg,{actions:h,running:$e,completed:Bn?.path===u?Bn:null}),Wa(l,o("rightSidebar.insertThisFile"))]})}function Cc(e,s){const l=s.root??d;if(!l)return null;const h=An(e,l);return Wa(h,o("fileTree.insertRefTitle"))}function Us(){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:()=>Fc("unified"),"aria-pressed":Ot==="unified",title:o("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Ot==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.unified")}),t.jsx("button",{type:"button",onClick:()=>Fc("split"),"aria-pressed":Ot==="split",title:o("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Ot==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.split")})]})}function Nc(){return Os.map(e=>{const s=Yd(e.files.map(([,v])=>v)),l=tl({activeGitRepoRoot:me,groupCount:Os.length,label:e.label,rootName:Qe}),h=!!(l&&e.root&&Sr.has(e.root));return{key:e.root??e.label,root:e.root,label:e.label,branch:e.branch,collapsed:h,files:e.files.map(([,v])=>Sc(v)),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:()=>Uf(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(ds,{size:13}):t.jsx(sa,{size:13})}),t.jsx(br,{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:v=>{v.stopPropagation(),Qa("stage-all",e.root,e.label)},disabled:!!$e,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:v=>{v.stopPropagation(),Qa("stash-all",e.root,e.label)},disabled:!!$e,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 En=n.useMemo(()=>new Map(Array.from(Ee.values(),e=>[xr(e),e])),[Ee]);function Pc(e){const s=En.get(e.key),l=s?ut(s,d):null,h=Jp(xt,l,s?.path??e.path);return t.jsx(Xi,{changeStatus:e.status,auditStatus:h,renderChangeBadge:u=>t.jsx(na,{status:u})})}const qa=n.useCallback(e=>{if(J)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,v=Number.POSITIVE_INFINITY;for(const X of s){const Z=X.getBoundingClientRect();if(Z.bottom<h)continue;const de=Math.abs(Z.top-h);de<v&&(u=X,v=de)}const y=u?.dataset.diffSelectionPath??u?.dataset.diffStreamItem??null;return y?(Ea.current===y&&U.getState().selectedFilePath===y||(Ea.current=y,tt(y)),y):null},[J,tt]),Sf=!!(!$e&&ve&&!Xe&&(se?.upstream||mn.trim()&&gn.trim())),Rf=!!(!$e&&ve&&!Xe&&(se?.upstream||mn.trim()&&gn.trim())),jf=!!(!$e&&ve&&!Xe&&On.trim()&&On.trim()!==se?.branch),Yt=n.useMemo(()=>{const e=Ve.trim().toLowerCase(),s=Array.from(Ee.entries()).filter(([,l])=>!me||ut(l,d)===me).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},[me,Ee,Ve,d]);n.useEffect(()=>{Qs("selected_file_state",{selectedFilePath:et,selectedChangedFilePath:Kt?.path??null,selectedChangedFileAbsolutePath:Kt?.absolutePath??null,selectedChangedFileRepoRoot:Kt?.repoRoot??null,rootPath:d,activeGitRepoRoot:me,rightTab:Uo,effectiveRightTab:jt,diffPaneActive:Ct,changedFiles:Ee.size,filteredChangedFiles:Yt.length,gitBundleLoading:fr,gitBundleLastLoadedAt:Wn})},[me,Ee.size,Ct,jt,Yt.length,Wn,fr,Uo,d,Kt?.absolutePath,Kt?.path,Kt?.repoRoot,et]);const Os=n.useMemo(()=>{const e=new Map;for(const s of Yt){const[,l]=s,h=ut(l,d),u=Yg(l)||Qe,v=h??u,y=h?rt.get(h):void 0,X=e.get(v)??{root:h,label:u,branch:y?.context?.branch,files:[]};X.files.push(s),e.set(v,X)}return Array.from(e.values()).sort((s,l)=>s.label===Qe?-1:l.label===Qe?1:s.label.localeCompare(l.label))},[Yt,rt,Qe,d]),Hs=n.useMemo(()=>{const e=[],s=new Map;for(const l of Yt)s.set(xr(l[1]),l);for(const l of Os){if(!!(l.root&&tl({activeGitRepoRoot:me,groupCount:Os.length,label:l.label,rootName:Qe})&&Sr.has(l.root)))continue;if(Cr!=="tree"){e.push(...l.files);continue}const u=l.files.map(([,v])=>Sc(v));for(const v of dp(u)){const y=s.get(v.key);y&&e.push(y)}}return e},[me,Sr,Cr,Os,Yt,Qe]),Ec=n.useMemo(()=>Ee.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:o("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Hs.map(([,e])=>{const s=ut(e,d),l=e.absolutePath||(s?`${s}/${e.path}`:e.path);return{key:xr(e),path:e.path,absolutePath:l,status:e.status,repoRoot:s,displayName:ho(l,s).name,displayDir:ho(l,s).dir,auditRecords:xt}}),[xt,Ee.size,Hs,d,o]);n.useEffect(()=>{if(!Ct||Hs.length===0||J)return;const e=[],s=()=>{const l=document.querySelector(".termdock-diff-stream-scroller");if(l&&qa(l))return;const h=document.querySelector("[data-diff-stream-item]"),u=h?.dataset.diffSelectionPath??h?.dataset.diffStreamItem??null;if(u){Ea.current=u,tt(u);return}const v=Hs[0]?.[1];if(!v)return;const y=xr(v);Ea.current=y,tt(y)};for(const l of[80,240,600,1200])e.push(window.setTimeout(s,l));return()=>e.forEach(l=>window.clearTimeout(l))},[Ct,J,Hs,tt,qa]);const fi=n.useMemo(()=>{const e=y=>`'${y.replace(/'/g,"'\\''")}'`,s=ar.length>0?wn:Be.filter(y=>y.files.length>0),l=s.length>0?s:d?[{root:d,relativeRoot:".",name:Qe}]:[],h=l.length>0?l.map(y=>`- ${y.relativeRoot==="."?".":y.relativeRoot} (${y.root})`).join(`
|
|
1650
|
+
`):[];if(!r||e.length===0){Hn(null);return}const s=new AbortController;let l=!1,h=0,u=0;Hn(null);const v=async()=>{let y=0;for(;!l&&!s.signal.aborted;){let X=null;try{Hn(null),await Dh(e,de=>{const{applicableEvents:je,unavailableReason:Ke}=cm(de);je.length>0&&Tl(je);const z=new Set(je.filter(B=>B.type==="rescan-required").map(B=>B.path));if(Ca)for(const B of je){if(B.type==="created"||B.type==="updated"){const ie=lo(B.path);ie&&z.add(ie)}B.path.endsWith("/.gitignore")&&re&&Ps(re,!0)}for(const B of z){const ie={path:B},Ce=U.getState();if(!Ce.directoryCache.has(ie.path))continue;jn.current.get(ie.path)?.abort();const Le=new AbortController;jn.current.set(ie.path,Le);const Qc=`file-watch-rescan:${ie.path}`;yt(Qc),Qd(ie.path,Le.signal,Ce.showHiddenFiles,"watch_rescan",Qc,Ce.fileSortModes[ie.path]??"name",re??void 0).then(Gs=>{jn.current.get(ie.path)===Le&&Ml(ie.path,Gs.entries)}).catch(Gs=>{vr(Gs)||Hn(Gs instanceof Error?Gs.message:"File refresh unavailable")}).finally(()=>{jn.current.get(ie.path)===Le&&jn.current.delete(ie.path)})}Ke&&Hn(Ke)},s.signal),X=new Error("File watch stream ended")}catch(de){X=de}if(l||s.signal.aborted||vr(X))return;Hn(X instanceof Error?X.message:"File watching unavailable");const Z=Dd[Math.min(y,Dd.length-1)];y+=1,await new Promise(de=>{u=window.setTimeout(de,Z)})}};return h=window.setTimeout(()=>{l||v()},_i),()=>{l=!0,window.clearTimeout(h),window.clearTimeout(u),s.abort();for(const y of jn.current.values())y.abort();jn.current.clear()}},[Tl,r,Ml,ci,re,Ca,Ps]),n.useEffect(()=>{if(!d||Vo.current!==d)return;if(Yo.current===d){Yo.current=null;return}const e=Hd();ra(Su,{...e,[d]:{selectedRepoRoots:ha,repoTargetBranches:rr,repoBaseBranches:Rt,previewEntries:nn,selectedPreviewKey:fe&&Er?qe:null,selectedPreviewFileKey:fe&&Er?Eo:null,previewDetailOpen:!!(fe&&Er),previewScrollTops:vs,previewMobileSlideIndex:1,repoIncludeUncommitted:dn,updatedAt:Date.now()}},ig)},[Er,dn,fe,nn,vs,Rt,rr,ha,d,Eo,qe]);const it=n.useMemo(()=>Xd(Ee.values()),[Ee]),rt=n.useMemo(()=>{const e=new Map;for(const s of Be)e.set(s.root,s);return e},[Be]),Ds=n.useMemo(()=>{const e=new Map;for(const s of Be)s.deferred||e.set(s.root,s.files.length);return e},[Be]),Ua=n.useCallback(e=>{if(e){if(!e.deferred){As.current.delete(e.root);return}Ds.has(e.root)||As.current.has(e.root)||(As.current.add(e.root),It(e.root,{includeNested:!1,background:!0,replaceRepoRoot:e.root}).then(s=>{s||As.current.delete(e.root)}))}},[It,Ds]),or=n.useMemo(()=>me?Ue.find(e=>e.root===me)??null:null,[me,Ue]),Kt=n.useMemo(()=>et?Array.from(Ee.values()).find(e=>e.path===et||e.absolutePath===et)??null:null,[Ee,et]),Dt=n.useMemo(()=>{const e=new Map;for(const s of Be)s.available&&s.context?.available&&e.set(s.root,s);return e.size===0&&Ae?.available&&Ae.root&&e.set(Ae.root,{id:Ae.root,root:Ae.root,relativeRoot:".",name:Qe,depth:0,nested:!1,available:!0,files:Array.from(Ee.values()).filter(s=>ut(s,d)===Ae.root),context:Ae}),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==="."?Qe:s.relativeRoot||s.name||gt(s.root),h=Yd(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(" · ")}})},[Ee,Ae,Be,Qe,d,o]),ve=n.useMemo(()=>me&&Dt.some(e=>e.value===me)?me:Kt?.repoRoot&&Dt.some(e=>e.value===Kt.repoRoot)?Kt.repoRoot:Dt.length===1||Dt.length>1?Dt[0].value:null,[me,Dt,Kt?.repoRoot]),dc=ve?rt.get(ve)??null:null,se=dc?.context?.available?dc.context:ve===Ae?.root?Ae:null,Xe=Dt.length>0&&!ve,uc=n.useMemo(()=>Xe?[]:ve?Array.from(Ee.values()).filter(e=>ut(e,d)===ve):Array.from(Ee.values()),[ve,Ee,Xe,d]),Cn=n.useMemo(()=>Xd(uc),[uc]),di=!!(se?.available&&se.root&&ve&&se.root===ve),mf=ve?Dt.find(e=>e.value===ve)?.label??gt(ve):o("rightSidebar.gitRepositoryPlaceholder"),fc=di?se?.branch??"HEAD":Xe?o("rightSidebar.selectRepositoryForGitActions"):pn?o("rightSidebar.gitActionRunning"):"HEAD",Nn=!!(se?.available&&se.root===ve&&se.status);n.useEffect(()=>{dl.current={count:Tt.length,loading:da,loadingMore:ua,hasMore:Ro}},[Tt.length,Ro,da,ua]),n.useEffect(()=>{Gr.current+=1,ur.current?.abort(),yt("right-sidebar-recent-commits"),ur.current=null,cn(""),dr([]),ks(!1),Ss(!1),Dn(null),_n(!1)},[ve]);const _s=n.useCallback(async(e={})=>{if(!d||!ve||Xe)return;const s=e.reset??!1,l=dl.current,h=s?0:l.count;if(!s&&(l.loading||l.loadingMore||!l.hasMore))return;const u=Gr.current+1;Gr.current=u,ur.current?.abort(),yt("right-sidebar-recent-commits");const v=new AbortController;ur.current=v,s?ks(!0):Ss(!0),Dn(null);try{const y=await Eh({cwd:d,repoRoot:ve,limit:xg,skip:h,query:ws.trim(),requestSlotId:"right-sidebar-recent-commits"},v.signal);if(Gr.current!==u)return;if(!y.available){Dn(y.error??"Recent commits are unavailable"),s&&dr([]),_n(!1);return}We(X=>s?y.commitSyncStatus??{}:{...X,...y.commitSyncStatus}),dr(X=>s?y.commits:[...X,...y.commits]),_n(y.hasMore)}catch(y){if(Gr.current!==u||vr(y))return;Dn(y instanceof Error?y.message:"Failed to load recent commits"),s&&dr([]),_n(!1)}finally{ur.current===v&&(ur.current=null),Gr.current===u&&(ks(!1),Ss(!1))}},[ve,ws,Xe,d]);n.useEffect(()=>{on&&_s({reset:!0})},[ws,_s,on,se?.ahead,se?.behind,se?.upstream]);const gf=n.useCallback(e=>{const s=e.currentTarget;s.scrollTop+s.clientHeight<s.scrollHeight-48||_s({reset:!1})},[_s]);n.useEffect(()=>{!ve||!Ae?.available||!nt||!nr||Nn||pn||Xe||Zo(ve)},[ve,Ae?.available,Nn,pn,nt,nr,Zo,Xe]);const hc=r&&(Ct||nt);n.useEffect(()=>{!hc||!d||pr()},[hc,pr,d]),n.useEffect(()=>{!r||!nt||!nr||!Rs||!d||Ta(null)},[Rs,nt,nr,r,Ta,d]);const bf=n.useMemo(()=>{if(!me)return 0;const e=Ue.findIndex(s=>s.root===me);return e>=0?e+1:0},[me,Ue]),pc=n.useCallback(e=>{if(!e)return null;const s=Array.from(Ee.values()).filter(l=>ut(l,d)===e).sort((l,h)=>l.path.localeCompare(h.path))[0];return s?xr(s):null},[Ee,d]),Pn=Ue.length>1,Oa=n.useMemo(()=>[{root:null,label:o("rightSidebar.allRepositories"),count:Ee.size,branch:null,deferred:!1},...Ue.map(e=>({root:e.root,label:e.label,count:e.deferred?Ds.get(e.root)??0:e.count,branch:e.branch??null,deferred:!!e.deferred&&!Ds.has(e.root)}))],[Ee.size,Ue,Ds,o]),mc=Oa[bf]??Oa[0],Ha=!!me,gc=n.useMemo(()=>Cu(Ue,Be),[Ue,Be]);n.useEffect(()=>{Jo.current===d&&me&&!gc.has(me)&&dt(null),$n(e=>e.filter(s=>Ue.some(l=>l.root===s)))},[me,Ue,gc,d,dt]),n.useEffect(()=>{me&&Ua(rt.get(me))},[me,Ua,rt]);const xf=n.useMemo(()=>{const e=new Set;se?.branch&&e.add(se.branch);for(const s of se?.branches??[])e.add(s);return Array.from(e).map(s=>({value:s,label:s,meta:s===se?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0}))},[se?.branch,se?.branches,o]),bc=n.useMemo(()=>{const e=new Set;se?.upstreamRemote&&e.add(se.upstreamRemote);for(const s of se?.remotes??[])e.add(s);return Array.from(e).map(s=>({value:s,label:s,meta:s===se?.upstreamRemote?o("rightSidebar.pushUpstreamBadge"):void 0}))},[se?.remotes,se?.upstreamRemote,o]),xc=bc.length>1,vf=n.useMemo(()=>{const e=[],s=new Set,l=(u,v)=>{!u||s.has(u)||(s.add(u),e.push({value:u,label:u,meta:v}))};l(se?.upstreamBranch,se?.upstreamBranch?o("rightSidebar.pushUpstreamBadge"):void 0),l(se?.branch,se?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0);for(const u of se?.branches??[])l(u,u===se?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");const h=se?.upstreamRemote;for(const u of se?.remoteBranches??[]){const v=u.indexOf("/"),y=v>=0?u.slice(0,v):null,X=v>=0?u.slice(v+1):u;(!h||y===h)&&l(X,"remote")}return e},[se?.branch,se?.branches,se?.remoteBranches,se?.upstreamBranch,se?.upstreamRemote,o]),Vt=n.useMemo(()=>Dt.map(e=>{const s=rt.get(e.value);return{root:e.value,label:e.label,branch:s?.context?.branch??null}}),[Dt,rt]);n.useEffect(()=>{Vt.length!==0&&(pa(e=>{let s=!1;const l={...e},h=new Set(Vt.map(u=>u.root));for(const u of Object.keys(l))h.has(u)||(delete l[u],s=!0);for(const u of Vt)!l[u.root]&&u.branch&&(l[u.root]=u.branch,s=!0);return s?l:e}),ma(e=>{let s=!1;const l={...e},h=new Set(Vt.map(u=>u.root));for(const u of Object.keys(l))h.has(u)||(delete l[u],s=!0);for(const u of Vt){const v=rt.get(u.root)?.context;if(l[u.root]&&Nu(l[u.root],v?.branch)&&(delete l[u.root],s=!0),l[u.root])continue;const y=Wd(v);y&&(l[u.root]=y,s=!0)}return s?l:e}))},[Vt,rt]);const za=n.useMemo(()=>{const e=new Set(Vt.map(s=>s.root));return ha.filter(s=>e.has(s))},[ha,Vt]),Ga=za.length===0,gr=n.useMemo(()=>Ga?Vt:Vt.filter(e=>za.includes(e.root)),[Vt,za,Ga]),Bs=n.useMemo(()=>gr.filter(e=>!!Rt[e.root]?.trim()),[Rt,gr]),ss=n.useCallback((e,s)=>{const l=rt.get(e)?.context?.branch;return!!(l&&s&&s.replace(/^refs\/heads\//,"")===l)},[rt]),vc=n.useMemo(()=>gr.filter(e=>!Rt[e.root]?.trim()),[Rt,gr]),yc=n.useCallback(async e=>{if(!e||Ko.current.has(e))return;const s=rt.get(e)?.context;if((s?.branches?.length??0)>0||(s?.remoteBranches?.length??0)>0||s?.upstream)return;const l=d;Ko.current.add(e),hl(h=>new Set(h).add(e));try{const h=await nd(e,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${e}`);if(!h.available||!Re(l))return;ft(u=>u.map(v=>v.root===e?{...v,available:!0,context:{...v.context,...h},error:void 0}:v)),pa(u=>u[e]||!h.branch?u:{...u,[e]:h.branch}),ma(u=>{if(u[e])return u;const v=Wd(h);return v?{...u,[e]:v}:u})}catch(h){vr(h)||console.warn("[RightSidebar] Failed to load branch audit repo details",e,h)}finally{Ko.current.delete(e),hl(h=>{const u=new Set(h);return u.delete(e),u})}},[rt,Re,d]);n.useEffect(()=>{if(jo)for(const e of gr)yc(e.root)},[jo,gr,yc]),n.useEffect(()=>{!di||!se||(ya(se.branch||(se.branches?.[0]??"")),wa(se.upstreamRemote||(se.remotes?.includes("origin")?"origin":se.remotes?.[0]??"")),ka(se.upstreamBranch||se.branch||(se.branches?.[0]??"")))},[se,di]);const wc=n.useMemo(()=>{if(Xe)return{text:o("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!Nn||pn)return{text:o("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!se?.upstream)return{text:o("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const e=se.ahead??0,s=se.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"}},[se?.ahead,se?.behind,se?.upstream,Nn,pn,Xe,o]),yf=n.useCallback(e=>{if(e&&!J){const s=e.currentTarget.getBoundingClientRect();bt({x:Math.min(s.left,window.innerWidth-352),y:Math.min(s.bottom+6,window.innerHeight-64)})}else bt(null);P?.()},[J,P]),ui=n.useCallback(()=>{bt(null),$?.()},[$]);function kc(){if(!Pn)return null;const e=mc?.label??o("rightSidebar.allRepositories"),s=mc?.count??Ee.size,l=gt(e)||e;return t.jsxs("button",{type:"button",onClick:yf,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(br,{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(aa,{size:12,className:"shrink-0"})]})}function wf(){if(!b||!Pn||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(at?.x??e-368,e-352)),h=Math.max(12,Math.min(at?.y??80,s-420)),u=J?void 0:{left:l,top:h},v=t.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${J?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:ui,children:t.jsxs("div",{className:J?"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:y=>y.stopPropagation(),children:[t.jsxs("div",{className:J?"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:J?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:o("rightSidebar.repositories")}),!J&&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] ${Ee.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Ee.size})]})]}),t.jsx("button",{type:"button",onClick:ui,className:J?"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(Xt,{size:J?16:14})})]}),t.jsx("div",{className:J?"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(y=>{const X=(y.root??null)===me,Z=gt(y.label)||y.label;return t.jsxs("button",{type:"button",onClick:()=>{Hc(y.root),ui()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${J?"px-3 py-2":"px-2 py-1.5"} ${X?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:y.label,role:"option","aria-selected":X,children:[t.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${X?"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 ${X?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:t.jsx(br,{size:13})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:`${J?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:Z}),t.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:y.root===null?o("rightSidebar.allRepositories"):y.label})]}),y.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:y.branch}),y.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] ${y.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:y.count})]},y.root??"all")})})]})});return bu(v,J,document.body)}function kf(){return wf()}function Sc(e){const s=ut(e,d),l=e.absolutePath||(s?`${s}/${e.path}`:e.path),h=ho(l,s??d);return{key:xr(e),path:e.path,absolutePath:l,displayName:h.name,displayDir:h.dir,oldPath:e.oldPath,status:e.status,title:l}}function Rc(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=An(e,d),h=`path:${l}`,u=Oe===h,v=ye===h,y=u||v;return t.jsx("button",{type:"button",onClick:X=>{X.stopPropagation(),qt(l,h,X.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 ${y?"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"} ${y?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:s,children:t.jsx("span",{className:"whitespace-nowrap",children:o(v?"rightSidebar.copied":u?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function jc(e){const s=ut(e,d),l=e.absolutePath||(s?`${s}/${e.path}`:e.path),h=Xf(e),u=Hi(e);return t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Xg,{actions:h,running:$e,completed:Bn?.path===u?Bn:null}),Wa(l,o("rightSidebar.insertThisFile"))]})}function Cc(e,s){const l=s.root??d;if(!l)return null;const h=An(e,l);return Wa(h,o("fileTree.insertRefTitle"))}function Us(){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:()=>Fc("unified"),"aria-pressed":Ot==="unified",title:o("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Ot==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.unified")}),t.jsx("button",{type:"button",onClick:()=>Fc("split"),"aria-pressed":Ot==="split",title:o("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Ot==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.split")})]})}function Nc(){return Os.map(e=>{const s=Yd(e.files.map(([,v])=>v)),l=tl({activeGitRepoRoot:me,groupCount:Os.length,label:e.label,rootName:Qe}),h=!!(l&&e.root&&Sr.has(e.root));return{key:e.root??e.label,root:e.root,label:e.label,branch:e.branch,collapsed:h,files:e.files.map(([,v])=>Sc(v)),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:()=>Uf(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(ds,{size:13}):t.jsx(aa,{size:13})}),t.jsx(br,{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:v=>{v.stopPropagation(),Qa("stage-all",e.root,e.label)},disabled:!!$e,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:v=>{v.stopPropagation(),Qa("stash-all",e.root,e.label)},disabled:!!$e,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 En=n.useMemo(()=>new Map(Array.from(Ee.values(),e=>[xr(e),e])),[Ee]);function Pc(e){const s=En.get(e.key),l=s?ut(s,d):null,h=Xp(xt,l,s?.path??e.path);return t.jsx(Xi,{changeStatus:e.status,auditStatus:h,renderChangeBadge:u=>t.jsx(na,{status:u})})}const qa=n.useCallback(e=>{if(J)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,v=Number.POSITIVE_INFINITY;for(const X of s){const Z=X.getBoundingClientRect();if(Z.bottom<h)continue;const de=Math.abs(Z.top-h);de<v&&(u=X,v=de)}const y=u?.dataset.diffSelectionPath??u?.dataset.diffStreamItem??null;return y?(Ea.current===y&&U.getState().selectedFilePath===y||(Ea.current=y,tt(y)),y):null},[J,tt]),Sf=!!(!$e&&ve&&!Xe&&(se?.upstream||mn.trim()&&gn.trim())),Rf=!!(!$e&&ve&&!Xe&&(se?.upstream||mn.trim()&&gn.trim())),jf=!!(!$e&&ve&&!Xe&&On.trim()&&On.trim()!==se?.branch),Yt=n.useMemo(()=>{const e=Ve.trim().toLowerCase(),s=Array.from(Ee.entries()).filter(([,l])=>!me||ut(l,d)===me).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},[me,Ee,Ve,d]);n.useEffect(()=>{Qs("selected_file_state",{selectedFilePath:et,selectedChangedFilePath:Kt?.path??null,selectedChangedFileAbsolutePath:Kt?.absolutePath??null,selectedChangedFileRepoRoot:Kt?.repoRoot??null,rootPath:d,activeGitRepoRoot:me,rightTab:Uo,effectiveRightTab:jt,diffPaneActive:Ct,changedFiles:Ee.size,filteredChangedFiles:Yt.length,gitBundleLoading:fr,gitBundleLastLoadedAt:Wn})},[me,Ee.size,Ct,jt,Yt.length,Wn,fr,Uo,d,Kt?.absolutePath,Kt?.path,Kt?.repoRoot,et]);const Os=n.useMemo(()=>{const e=new Map;for(const s of Yt){const[,l]=s,h=ut(l,d),u=Vg(l)||Qe,v=h??u,y=h?rt.get(h):void 0,X=e.get(v)??{root:h,label:u,branch:y?.context?.branch,files:[]};X.files.push(s),e.set(v,X)}return Array.from(e.values()).sort((s,l)=>s.label===Qe?-1:l.label===Qe?1:s.label.localeCompare(l.label))},[Yt,rt,Qe,d]),Hs=n.useMemo(()=>{const e=[],s=new Map;for(const l of Yt)s.set(xr(l[1]),l);for(const l of Os){if(!!(l.root&&tl({activeGitRepoRoot:me,groupCount:Os.length,label:l.label,rootName:Qe})&&Sr.has(l.root)))continue;if(Cr!=="tree"){e.push(...l.files);continue}const u=l.files.map(([,v])=>Sc(v));for(const v of dp(u)){const y=s.get(v.key);y&&e.push(y)}}return e},[me,Sr,Cr,Os,Yt,Qe]),Ec=n.useMemo(()=>Ee.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:o("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Hs.map(([,e])=>{const s=ut(e,d),l=e.absolutePath||(s?`${s}/${e.path}`:e.path);return{key:xr(e),path:e.path,absolutePath:l,status:e.status,repoRoot:s,displayName:ho(l,s).name,displayDir:ho(l,s).dir,auditRecords:xt}}),[xt,Ee.size,Hs,d,o]);n.useEffect(()=>{if(!Ct||Hs.length===0||J)return;const e=[],s=()=>{const l=document.querySelector(".termdock-diff-stream-scroller");if(l&&qa(l))return;const h=document.querySelector("[data-diff-stream-item]"),u=h?.dataset.diffSelectionPath??h?.dataset.diffStreamItem??null;if(u){Ea.current=u,tt(u);return}const v=Hs[0]?.[1];if(!v)return;const y=xr(v);Ea.current=y,tt(y)};for(const l of[80,240,600,1200])e.push(window.setTimeout(s,l));return()=>e.forEach(l=>window.clearTimeout(l))},[Ct,J,Hs,tt,qa]);const fi=n.useMemo(()=>{const e=y=>`'${y.replace(/'/g,"'\\''")}'`,s=ar.length>0?wn:Be.filter(y=>y.files.length>0),l=s.length>0?s:d?[{root:d,relativeRoot:".",name:Qe}]:[],h=l.length>0?l.map(y=>`- ${y.relativeRoot==="."?".":y.relativeRoot} (${y.root})`).join(`
|
|
1651
1651
|
`):`- ${d?".":""}`,u=l.length>0?l.map(y=>` td audit-export ${e(y.root)}`).join(`
|
|
1652
1652
|
`):" td audit-export",v=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 后批量注入:",v,'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,wn,Be,Qe,d]),Cf=n.useCallback(async(e="generate",s)=>{if(Pn&&
|
|
1654
|
-
`);return st("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,`${nc}:${e}`,s)?(pr(),p||c(),!0):!1},[me,fi,
|
|
1653
|
+
`)},[ar.length,wn,Be,Qe,d]),Cf=n.useCallback(async(e="generate",s)=>{if(Pn&&Or.length===0&&!me){rn(!0);return}const l=e==="generate"?fi:[e==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",fi].join(`
|
|
1654
|
+
`);return st("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,`${nc}:${e}`,s)?(pr(),p||c(),!0):!1},[me,fi,Or.length,ar,Fr,pr,c,p,d,Pn,o]),Ka=n.useCallback(async e=>{try{await od({ids:[e]}),tn(s=>s.filter(l=>l.id!==e))}catch{pr()}},[pr]),Nf=n.useCallback(async()=>{if(xt.length===0)return;const e=xt.map(s=>s.id);try{await od({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})),pr()}},[xt,pr,o]),Pf=n.useCallback(async e=>{if(e.records.length===0)return;const s=e.records.map(l=>l.id);try{await Ah({ids:s}),Hr(l=>l.filter(h=>!s.includes(h.id))),qe===e.key&&(un(null),lr(!1))}catch(l){zt(o("rightSidebar.branchAuditClearFailed",{message:l instanceof Error?l.message:"Failed to clear branch explanation"})),Ta(null)}},[Ta,qe,o]),Ef=n.useCallback(e=>{$n(s=>e===null?(rn(!1),[]):s.includes(e)?s.filter(l=>l!==e):[...s,e])},[]),Af=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 v of l.split(`
|
|
1655
1655
|
`))v.startsWith("+++")||v.startsWith("---")||(v.startsWith("+")&&(h+=1),v.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 fe?(fe.hunks??[]).map(s=>{const l=fe.comparisonRepos&&fe.comparisonRepos.length>1?[...fe.comparisonRepos].sort((u,v)=>v.label.length-u.label.length).find(u=>s.filePath.startsWith(`${u.label}/`)):void 0,h=er.find(u=>u.repoRoot===fe.repoRoot&&u.baseRef===fe.baseRef&&(u.branchName??null)===(fe.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??fe.repoRoot,repositoryPath:l?s.filePath.slice(l.label.length+1):s.filePath,hunk:s.previewRevert&&!ss(s.previewRevert.cwd,s.previewRevert.comparisonBranch)?{...s,previewRevert:void 0}:s,current:h,stale:null}}):qe?er.filter(s=>zd(s)===qe).map(s=>{const l=e(s);return{key:`${s.filePath}\0${s.hunkHeader}\0${s.hunkIndex??0}`,hunk:l,current:s,stale:null}}):[]},[fe,er,ss,nr,qe]),pi=er.length>0,as=n.useMemo(()=>{if(!nr)return[];const e=new Map;for(const s of er){const l=s.repoRoot,h=rt.get(l),u=h?.relativeRoot==="."?Qe:h?.relativeRoot||h?.name||gt(l),v=zd(s),y=e.get(v)??{key:v,repoRoot:l,repoLabel:u,baseRef:s.baseRef,branchName:s.branchName??null,headRef:s.headRef??null,diffFingerprint:s.diffFingerprint??null,records:[],latestInjectedAt:0};y.records.push(s),y.latestInjectedAt=Math.max(y.latestInjectedAt,s.injectedAt??0),e.set(v,y)}return Array.from(e.values()).sort((s,l)=>l.latestInjectedAt-s.latestInjectedAt)},[er,rt,nr,Qe]),mi=n.useMemo(()=>qe?as.find(e=>e.key===qe)??null:null,[as,qe]),zs=fe?{repoRoot:fe.repoRoot??"",repoLabel:fe.repoRoot?rt.get(fe.repoRoot)?.relativeRoot==="."?Qe:rt.get(fe.repoRoot)?.relativeRoot||rt.get(fe.repoRoot)?.name||gt(fe.repoRoot):Qe,baseRef:fe.baseRef??fe.baseBranch??"",branchName:fe.currentBranch??null,headRef:fe.headRef??null,diffFingerprint:fe.diffFingerprint??null}:mi,Tf=n.useMemo(()=>(Ge?.hunks??[]).map(e=>({key:`${e.filePath}\0${e.hunkHeader}\0${e.hunkIndex}`,repoRoot:Ge?.repoRoot,hunk:e,current:null,stale:null})),[Ge?.hunks,Ge?.repoRoot]),Mf=n.useMemo(()=>{if(fe)return[];const e=mi;return e?bs.filter(s=>s.repoRoot===e.repoRoot&&s.baseRef===e.baseRef&&(s.branchName??null)===e.branchName&&(!e.diffFingerprint||s.diffFingerprint===e.diffFingerprint)):[]},[fe,bs,mi]),Lf=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(()=>Tn(e),90),window.setTimeout(()=>Tn(e),320),window.setTimeout(()=>Tn(e),760))},[hi]),gi=n.useMemo(()=>{const e=u=>`'${u.replace(/'/g,"'\\''")}'`,s=Bs,l=s.length>0?s.map(u=>`- ${u.label} (${u.root}),目标分支:${rr[u.root]||u.branch||"(current branch)"},基线分支:${Rt[u.root]||"(not set)"},包含本地未提交更改:${ss(u.root,rr[u.root]||u.branch)&&(dn[u.root]??!0)?"是":"否"}`).join(`
|
|
1656
1656
|
`):`- ${d?".":""}`,h=s.length>0?s.map(u=>{const v=rr[u.root]||u.branch||"",y=Rt[u.root]||"",X=u.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[v?` git -C ${e(u.root)} switch ${e(v)}`:` # ${u.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${e(y)} ${e(u.root)} > ~/.termdock/branch-audit/branch-audit-export-${X}.json`].join(`
|
|
1657
1657
|
`)}).join(`
|
|
@@ -1659,4 +1659,4 @@ ${ce}
|
|
|
1659
1659
|
`)},[dn,ss,Bs,Rt,rr,d]),If=n.useCallback(async(e="generate",s)=>{const l=e==="generate"?gi:[e==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",gi].join(`
|
|
1660
1660
|
`);return await Fr(o("rightSidebar.branchAuditShort"),l,`context:branch-audit-scope:${e}`,s)?(p||c(),!0):!1},[gi,Fr,c,p,o]),bi=n.useCallback(async(e={})=>{const s=e.refresh===!0,l=s&&fe?.comparisonRepos?fe.comparisonRepos:Bs.map(y=>{const X=(rr[y.root]||y.branch||"").trim();return{repoRoot:y.root,label:y.label,base:Rt[y.root]?.trim()??"",head:X||null,includeUncommitted:dn[y.root]??!0}});if(!d||l.length===0)return;const h=++T.current,u=d,v=()=>Re(u)&&h===T.current;Te(!0),Me(null),s||(tr(null),ot(null));try{const y=await Promise.all(l.map(async z=>{if(!z.base)throw new Error(o("rightSidebar.branchAuditMissingBase",{repo:z.label}));return id({cwd:d,repoRoot:z.repoRoot,base:z.base,head:z.head,includeUncommitted:e.repoRoot===z.repoRoot?e.includeUncommitted??!1:z.includeUncommitted??fe?.includeUncommitted??!0,requestSlotId:`right-sidebar-branch-preview:${z.repoRoot}`})}));if(!v())return;const X=y.find(z=>!z.available);if(X){Me(X.error??"Branch diff is unavailable");return}const Z=y.length===1?y[0]:{available:!0,workspaceRoot:d,repoRoot:d,baseRef:y.map(z=>z.baseRef??z.baseBranch).filter(Boolean).join(", "),currentBranch:y.map(z=>z.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:y.map(z=>z.headRef).filter(Boolean).join(", "),diffFingerprint:y.map(z=>z.diffFingerprint).filter(Boolean).join("+"),stat:y.map(z=>z.stat).filter(Boolean).join(`
|
|
1661
1661
|
`),files:y.flatMap((z,B)=>{const ie=l[B];return(z.files??[]).map(Ce=>`${ie?.label??z.repoRoot??"repo"}/${Ce}`)}),hunks:y.flatMap((z,B)=>{const Ce=l[B]?.label??z.repoRoot??"repo";return(z.hunks??[]).map(_e=>({..._e,filePath:`${Ce}/${_e.filePath}`,oldPath:_e.oldPath?`${Ce}/${_e.oldPath}`:_e.oldPath,newPath:_e.newPath?`${Ce}/${_e.newPath}`:_e.newPath}))}),commits:y.flatMap(z=>z.commits??[]),commitCount:y.reduce((z,B)=>z+(B.commitCount??B.commits?.length??0),0),diff:y.map(z=>z.diff).filter(Boolean).join(`
|
|
1662
|
-
`),truncated:y.some(z=>z.truncated)};if(Z.comparisonRepos=l.map((z,B)=>({...z,head:z.head??y[B].currentBranch??null,includeUncommitted:y[B].includeUncommitted===!0,canIncludeUncommitted:y[B].canIncludeUncommitted})),Z.canIncludeUncommitted=y.every(z=>z.canIncludeUncommitted===!0),Z.includeUncommitted=y.some(z=>z.includeUncommitted===!0),Po(z=>({...z,...Object.fromEntries(Z.comparisonRepos.map(B=>[B.repoRoot,B.includeUncommitted??!1]))})),!s&&(Z.hunks??[]).length===0){Me(o("rightSidebar.branchAuditDiffEmpty"));return}const de=Date.now(),je=(s?qe:null)??["preview",Z.repoRoot??d,Z.baseRef??Z.baseBranch??"",Z.currentBranch??"",Z.headRef??"",Z.diffFingerprint??de].join("\0"),Ke=l.length===1?l[0].label:`${l.length} repos`;tr(Z),sn(z=>[{key:je,diff:Z,repoLabel:Ke,createdAt:de},...z.filter(B=>B.key!==je)].slice(0,8)),s||S(z=>z[je]===void 0?z:{...z,[je]:0}),un(je),fn(z=>{const B=Z.hunks?.[0],ie=B?`${B.filePath}\0${B.hunkHeader}\0${B.hunkIndex}`:null;return s&&z&&(Z.hunks??[]).some(Ce=>Ce.filePath===z.split("\0")[0])?z:ie}),lr(!0)}catch(y){if(!v()||vr(y))return;Me(y instanceof Error?y.message:"Failed to load branch diff")}finally{v()&&Te(!1)}},[dn,fe,qe,Bs,Rt,rr,Re,d,o]),$f=n.useCallback(e=>{++T.current,Te(!1),tr(e.diff),Me(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),lr(!0)},[]),Ff=n.useCallback(e=>{sn(s=>s.filter(l=>l.key!==e)),S(s=>{if(!(e in s))return s;const l={...s};return delete l[e],l}),qe===e&&(un(null),tr(null),lr(!1))},[qe]),Df=n.useCallback(e=>{++T.current,Te(!1);const s=as.find(l=>l.key===e);s&&(tr(null),Me(null),un(e),fn(s.records[0]?.filePath??null),lr(!0))},[as]),_f=n.useCallback(async e=>{if(!d||!ve)return;const[s]=e.split(/\s+/);if(s){cr(s),an(null),ot(null);try{const l=await Th({cwd:d,repoRoot:ve,commit:s,requestSlotId:"right-sidebar-commit-diff"});if(!l.available){an(l.error??"Commit diff is unavailable");return}ot(l);const h=l.hunks?.[0];fa(h?`${h.filePath}\0${h.hunkHeader}\0${h.hunkIndex}`:null)}catch(l){an(l instanceof Error?l.message:"Failed to load commit diff")}finally{cr(null)}}},[ve,d]),Bf=n.useCallback(e=>{if(!fe||!qe)return;const s=Math.max(0,Math.round(e));S(l=>Math.abs((l[qe]??0)-s)<24?l:{...l,[qe]:s})},[fe,qe]);n.useEffect(()=>{!fe||!qe||sn(e=>e.map(s=>s.key===qe&&s.diff!==fe?{...s,diff:fe}:s))},[fe,qe]);const Ac=!!fe;n.useEffect(()=>{if(!J||!Er||!Ac)return;const e=Gl.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)},[Er,Ac,J]);const Tc=n.useCallback(e=>{e&&Wu(s=>up(s,e))},[]),Mc=Sa.key===et?Sa.key:null,Va=n.useCallback(e=>{const s=U.getState(),l=ab();Qs("select_diff_file",{interactionId:l,path:e,previousSelectedFilePath:s.selectedFilePath,rootPath:s.rootPath,activeGitRepoRoot:me,changedFiles:s.changedFiles.size,gitBundleLoading:s.gitBundleLoading,gitBundleLastLoadedAt:s.gitBundleLastLoadedAt,rightTab:s.rightTab}),tt(e),Mt("diff"),J&&e&&Kl(1),Tc(e),queueMicrotask(()=>{const h=U.getState();Qs("select_diff_file_after",{interactionId:l,requestedPath:e,selectedFilePath:h.selectedFilePath,rootPath:h.rootPath,rightTab:h.rightTab,changedFiles:h.changedFiles.size,activeGitRepoRoot:me})})},[me,J,Tc,tt,Mt,Kl]),Lc=n.useCallback(e=>{const s=Array.from(Ee.values()).find(l=>{const h=ut(l,d),u=xr(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(xr(s)),window.setTimeout(()=>Tn(e),90),window.setTimeout(()=>Tn(e),320),window.setTimeout(()=>Tn(e),760);return}Tn(e)},[Ee,d,Va]),Ic=n.useCallback(({slideToDetail:e,fullscreen:s,toggleFullscreen:l}={})=>ms.length>0?t.jsx(su,{walkthroughs:ms,repoRoot:me,fullscreen:s,onToggleFullscreen:l,onNavigate:h=>{J&&window.requestAnimationFrame(()=>e?.()),Lc(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")]}),[me,ms,Lc,J,o]),Uf=n.useCallback(e=>{e&&Rr(s=>{const l=new Set(s);return l.has(e)?l.delete(e):l.add(e),Bi($i,l),l})},[]),$c=n.useCallback(e=>{jr(s=>{const l=new Set(s);return l.has(e)?l.delete(e):l.add(e),Bi(Ld,l),l})},[]),Ya=n.useCallback(e=>{ia(e),Pt(vu,e)},[]);n.useEffect(()=>{Ha||Cr!=="ai"||Ya("tree")},[Cr,Ya,Ha]);const Xa=n.useCallback(()=>{ps(e=>{const s=!e;return Pt(yu,s),s})},[]),Fc=n.useCallback(e=>{la(e),Pt(wu,e)},[]),{whitespace:Dc,context:_c}=vp(),Bc=n.useMemo(()=>({algorithm:"histogram",whitespace:Dc,context:_c}),[Dc,_c]),Uc=n.useCallback(e=>{pe(e),Pt(ku,e)},[]),Ja=n.useCallback(async(e,s,l,h)=>{let u=e;for(;u.ok&&u.status==="running";)await new Promise(y=>window.setTimeout(y,1500)),u=await ld({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 v={action:s.action,path:h,label:l};return Ns(v),window.setTimeout(()=>Ns(y=>y?.action===v.action&&y.path===v.path?null:y),1400),u},[]),mt=n.useCallback(async(e,s,l)=>{const h=d;d&&hr.current.delete(d),zt(null),Ns(null),Cs({action:e.action,path:l});try{const u=await Mh({...e,includeNested:Vs(d)}),v=await Ja(u,e,s,l);if(!Re(h))return!1;const y=d?await Ci(d,void 0,{includeNested:Vs(d),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Xs(d)}).catch(()=>v.bundle):v.bundle;return Re(h)?(y&&Xn(y,{reloadDiff:!0,cacheOnly:!0}),hn(null),!0):!1}catch(u){return Ns(null),zt(o("rightSidebar.gitActionFailed",{message:u instanceof Error?u.message:"Unknown error"})),!1}finally{Re(h)&&Cs(null)}},[Xn,Re,d,o,Ja]),Oc=n.useCallback(async e=>{const s=d;await cd({...e,includeNested:Vs(d)}),Re(s)&&It(d??void 0,{refresh:!0,background:!0})},[Re,It,d]),Of=n.useCallback(async e=>{const s=fe,l=T.current,h=s?.hunks?.find(v=>v.previewRevert?.cwd===e.cwd&&v.previewRevert.path===e.path);if(!s||!h||!e.comparisonBase)throw new Error(o("diffViewer.hunkActionUnavailable"));Se(v=>v+1),Me(null);try{await cd(e)}catch(v){throw Se(y=>y-1),v}if(l!==T.current||!Re(d)){Se(v=>v-1);return}const u=v=>{tr(y=>{if(!y||l!==T.current)return y;const X=y.hunks??[],Z=v===void 0?X.filter(je=>!(je.previewRevert?.cwd===e.cwd&&je.previewRevert.patch===e.patch)):[...X.filter(je=>je.filePath!==h.filePath),...v];return{...y,hunks:Z}})};u(),id({cwd:e.cwd,repoRoot:e.cwd,base:e.comparisonBase,comparisonBase:e.comparisonBase,filePath:e.path,requestSlotId:`branch-preview-file:${e.cwd}:${e.path}`}).then(v=>{if(l!==T.current||!Re(d))return;if(!v.available||v.truncated)throw new Error(v.error??o("diffViewer.hunkActionUnavailable"));const y=e.path.slice(e.cwd.length+1),X=h.filePath.slice(0,h.filePath.length-y.length);u((v.hunks??[]).map(Z=>({...Z,filePath:`${X}${Z.filePath}`,oldPath:Z.oldPath?`${X}${Z.oldPath}`:Z.oldPath,newPath:Z.newPath?`${X}${Z.newPath}`:Z.newPath})))}).catch(v=>{l===T.current&&Re(d)&&!vr(v)&&Me(`${o("diffViewer.hunkActionReverted")} · ${v instanceof Error?v.message:String(v)}`)}).finally(()=>Se(v=>v-1))},[fe,Re,d,o]),Qa=n.useCallback((e,s,l)=>{if(s){if(e==="stage-all"){mt({action:"stage-all",cwd:s},o("rightSidebar.stageAll"),`repo:${s}`);return}hn({kind:"stash-all",repoRoot:s,repoLabel:l})}},[mt,o]),Hc=n.useCallback(e=>{dt(e),ya(""),wa(""),ka(""),tt(pc(e)),nt||Mt("diff"),e&&Ua(rt.get(e))},[Ua,pc,nt,rt,tt,dt,Mt]),zc=n.useCallback(e=>{const s=new Set([...Wt.current.keys(),...vn.current,...hr.current]);for(const l of s)l!==e&&(Gt.current.delete(l),Wt.current.get(l)?.abort(),Wt.current.delete(l),yt(`right-sidebar-git-untracked:${l}`),vn.current.delete(l),hr.current.delete(l))},[]),Hf=n.useCallback(async e=>{const s=d;if(!s||(await U.getState().setNestedGitScanRoot(s,e),!Re(s)))return;if(e){await It(s,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}zc(s),ya(""),wa(""),ka(""),No(h=>h.filter(u=>u===s));const l=Kt;l&&ut(l,s)!==s&&tt(null),await It(s,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[zc,Re,It,d,tt,Kt]),zf=n.useCallback(async()=>{if(!ve||Xe){zt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=On.trim();!e||e===se?.branch||await mt({action:"switch-branch",cwd:ve,branch:e},o("rightSidebar.switchBranch"))},[se?.branch,ve,Xe,mt,On,o]),Gc=n.useCallback(async()=>{if(!ve||Xe){zt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=va.trim();if(!e)return;await mt({action:"commit",cwd:ve,message:e},o("rightSidebar.commitChanges"))&&yl("")},[ve,va,Xe,mt,o]),Gf=n.useCallback(async()=>{if(!ve||Xe){zt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=mn.trim(),s=gn.trim();await mt({action:"push",cwd:ve,...e?{remote:e}:{},...s?{branch:s}:{}},o("rightSidebar.pushChanges"))},[ve,gn,mn,Xe,mt,o]),Wf=n.useCallback(async()=>{if(!ve||Xe){zt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=mn.trim(),s=gn.trim();await mt({action:"pull",cwd:ve,...e?{remote:e}:{},...s?{branch:s}:{}},o("rightSidebar.pullChanges"))},[ve,gn,mn,Xe,mt,o]);n.useEffect(()=>{if(!nt||!ve||$e)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 ld({cwd:ve,action:l}).catch(()=>null);if(!h?.ok||h.status!=="running")continue;const u={action:l,cwd:ve},v=s[l]??l;Cs({action:l});try{const y=await Ja(h,u,v);if(e||!Re(d))return;const X=d?await Ci(d,void 0,{includeNested:Vs(d),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Xs(d)}).catch(()=>y.bundle):y.bundle;X&&Xn(X,{reloadDiff:!0,cacheOnly:!0})}catch(y){e||zt(o("rightSidebar.gitActionFailed",{message:y instanceof Error?y.message:"Unknown error"}))}finally{e||Cs(null)}return}})(),()=>{e=!0}},[ve,Xn,nt,Re,d,$e,o,Ja]);const xi=Bn?.action==="commit",vi=Bn?.action==="switch-branch",yi=Bn?.action==="pull",wi=Bn?.action==="push",Za=nt||zu,ki=Ga?o("rightSidebar.changeAuditScopeAll"):gr.length===1?gr[0].label:`${gr.length} repos`,qf=gr.length>0,Wc=Bs.length>0,Kf=d?t.jsx(qd,{open:jo,onOpenChange:Co,showScopePicker:!0,selectedAll:Ga,repos:Vt,selectedRoots:za,onToggleRepo:Af,onGenerate:e=>If(pi?"regenerate":"generate",e),disabled:!qf,generateDisabled:!Wc,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:!Wc||Je,secondaryLabel:o("rightSidebar.branchAuditViewDiff"),secondaryTitle:o("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:Je,loading:fl.size>0,statusTitle:fl.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(ae==="zh"?"、":", ")})})}),renderRepoExtra:e=>{const s=rt.get(e.root),l=ss(e.root,rr[e.root]||s?.context?.branch),h=[],u=new Set,v=(de,je)=>{!de||u.has(de)||(u.add(de),h.push({value:de,label:de,meta:je}))};v(rr[e.root]||s?.context?.branch,o("rightSidebar.pushCurrentBranchBadge"));for(const de of s?.context?.branches??[])v(de,de===s?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):o("rightSidebar.localBranch"));for(const de of s?.context?.remoteBranches??[])v(de,o("rightSidebar.remoteBranch"));const y=[],X=new Set,Z=(de,je)=>{!de||X.has(de)||(X.add(de),y.push({value:de,label:de,meta:je}))};Z(Rt[e.root],Rt[e.root]?o("rightSidebar.pushUpstreamBadge"):void 0),Z(s?.context?.upstream,s?.context?.upstream?o("rightSidebar.pushUpstreamBadge"):void 0);for(const de of s?.context?.remoteBranches??[])Z(de,"remote");for(const de of s?.context?.branches??[])Z(de,de===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(cs,{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:de=>{pa(je=>({...je,[e.root]:de}))}}),t.jsx(cs,{label:o("rightSidebar.branchAuditBaseLabel"),value:Rt[e.root]||"",options:y,placeholder:o("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:o("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:o("rightSidebar.branchAuditBaseEmpty"),onChange:de=>{ma(je=>({...je,[e.root]:de}))}}),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:de=>Po(je=>({...je,[e.root]:de.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,qc=Js(xt.reduce((e,s)=>Math.max(e,s.injectedAt??0),0),ae),Vf=()=>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:()=>ul(e=>{const s=!e;return Pt(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":Rs,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 ${Rs?"rotate-90":""}`,children:t.jsx(ds,{size:13})})]}),Rs&&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]}),Kf]}),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 ${qe===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),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")})]}),Js(e.createdAt,ae)&&t.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:Js(e.createdAt,ae)})]}),t.jsx("button",{type:"button",onClick:()=>Ff(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)),as.length>0?as.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 ${qe===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:()=>Df(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})]}),Js(e.latestInjectedAt,ae)&&t.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:o("rightSidebar.branchAuditGeneratedAt",{time:Js(e.latestInjectedAt,ae)??""})})]}),t.jsx("button",{type:"button",onClick:()=>{Pf(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,Yf=()=>nr&&d&&Nn?t.jsxs("div",{className:Za?"overflow-visible":"overflow-hidden",children:[Vf(),t.jsxs("button",{type:"button",onClick:()=>{nt||Gu(e=>{const s=!e;return s&&ve&&!Nn&&!pn&&Zo(ve),s})},"aria-expanded":Za,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${nt?"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(br,{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 ${Cn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[pn&&t.jsx(lt,{size:10,className:"animate-spin"}),Cn.staged>0?o("rightSidebar.stagedCount",{count:Cn.staged}):o("rightSidebar.noStagedChangesShort")]}),!nt&&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(ds,{size:13})})]})]}),Za&&t.jsxs("div",{className:"space-y-0",children:[Dt.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:mf})]})}),t.jsx(cs,{label:o("rightSidebar.gitRepositoryLabel"),value:ve??"",options:Dt,placeholder:o("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:o("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:o("rightSidebar.gitRepositoryEmpty"),disabled:!!$e,onChange:e=>{Hc(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:On!==fc?fc:null})]}),t.jsxs("button",{type:"button",onClick:()=>{zf()},disabled:!jf,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 ${vi?"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:$e?.action==="switch-branch"||vi?"opacity-0":"",children:o("rightSidebar.switchBranch")}),$e?.action==="switch-branch"&&t.jsx(lt,{size:12,className:"absolute animate-spin"}),vi&&$e?.action!=="switch-branch"&&t.jsx("span",{className:"absolute",children:"✓"})]})]}),t.jsx(cs,{label:o("rightSidebar.currentBranchLabel"),value:On,options:xf,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),disabled:!!$e,onChange:ya})]}),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"):Cn.staged>0?o("rightSidebar.commitReadyHint",{count:Cn.staged}):o("rightSidebar.commitNeedsStaged")})]}),t.jsxs("button",{type:"button",onClick:()=>{Gc()},disabled:!!$e||Xe||Cn.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"):Cn.staged===0?o("rightSidebar.commitNeedsStaged"):o("rightSidebar.commitChanges"),children:[t.jsx("span",{className:$e?.action==="commit"||xi?"opacity-0":"",children:o("rightSidebar.commitChanges")}),$e?.action==="commit"&&t.jsx(lt,{size:12,className:"absolute animate-spin"}),xi&&$e?.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(),Gc())},placeholder:o("rightSidebar.commitMessagePlaceholder"),disabled:!!$e,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:()=>Gr(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:[da&&t.jsx(lt,{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(ds,{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(us,{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(Xt,{size:12})})]}),t.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:gf,children:[Tt.length>0?Tt.map(e=>{const[s,...l]=e.split(/\s+/),h=l.join(" ")||e;return t.jsxs("button",{type:"button",onClick:()=>{_f(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}),K[s]&&t.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${K[s]==="ahead"?"bg-accent/10 text-accent":K[s]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:o(K[s]==="ahead"?"rightSidebar.commitAhead":K[s]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),Fn===s&&t.jsx(lt,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},e)}):da?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")}),ua&&t.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:t.jsx(lt,{size:12,className:"animate-spin"})}),Ro&&!ua&&Tt.length>0&&t.jsx("button",{type:"button",onClick:()=>{_s({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")})]})]}),ys&&t.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:ys}),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:()=>{Wf()},disabled:!Sf,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 ${yi?"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:$e?.action==="pull"||yi?"opacity-0":"",children:o("rightSidebar.pullChanges")}),$e?.action==="pull"&&t.jsx(lt,{size:12,className:"absolute animate-spin"}),yi&&$e?.action!=="pull"&&t.jsx("span",{className:"absolute",children:"✓"})]}),t.jsxs("button",{type:"button",onClick:()=>{Gf()},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 ${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:$e?.action==="push"||wi?"opacity-0":"",children:o("rightSidebar.pushChanges")}),$e?.action==="push"&&t.jsx(lt,{size:12,className:"absolute animate-spin"}),wi&&$e?.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] ${wc.className}`,title:se?.upstream??void 0,children:[t.jsx("span",{className:"truncate font-medium",children:wc.text}),t.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:se?.upstream??""})]}),t.jsxs("div",{className:`grid gap-1.5 ${xc?"grid-cols-2":"grid-cols-1"}`,children:[xc&&t.jsx(cs,{label:o("rightSidebar.pushRemoteLabel"),value:mn,options:bc,placeholder:o("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:o("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:o("rightSidebar.pushNoRemotes"),disabled:!!$e,onChange:wa}),t.jsx(cs,{label:o("rightSidebar.pushBranchLabel"),value:gn,options:vf,placeholder:o("rightSidebar.pushBranchPlaceholder",{branch:se?.branch??"HEAD"}),searchPlaceholder:o("rightSidebar.pushBranchSearchPlaceholder"),emptyText:o("rightSidebar.pushNoBranches"),disabled:!!$e,onChange:ka})]})]})]})]}):null,Xf=n.useCallback(e=>{const s=ut(e,d);if(!s)return[];const l=Hi(e),h=[];return e.canStage&&h.push({key:"stage-file",label:o("rightSidebar.stageFile"),onClick:()=>{mt({action:"stage-file",cwd:s,paths:[e.path]},o("rightSidebar.stageFile"),l)}}),e.canUnstage&&h.push({key:"unstage-file",label:o("rightSidebar.unstageFile"),onClick:()=>{mt({action:"unstage-file",cwd:s,paths:[e.path]},o("rightSidebar.unstageFile"),l)}}),e.canStash&&h.push({key:"stash-file",label:o("rightSidebar.stashFile"),onClick:()=>{mt({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,mt,o]),Jf=n.useCallback(()=>{if(m){R?.();return}Tr(0),Lr.current?.slideTo(0),Ar(!1),Ut(null)},[R,m]),Kc=n.useCallback(e=>{if(he(""),Lt(e),tt(null),Ut(null),j(null),J){m&&R?.(),Tr(0),Lr.current?.slideTo(0),Ar(!1);return}},[J,R,m,tt,Lt]);n.useEffect(()=>{if(!G||U.getState().pendingTerminalPath!==G)return;U.setState({pendingTerminalPath:null}),(()=>{const s=G,l=s.path;if(!l.startsWith("/"))return;he(""),Ut(null),Et(null);const h=!!(d&&(l===d||l.startsWith(`${d}/`)));if(s.kind==="file"){const u=lo(l);Ms(l),typeof s.line=="number"&&Number.isSafeInteger(s.line)&&s.line>0&&Et(s.line),Lt(h?null:u),j({path:l,nonce:++F.current});return}tt(null),h?(Lt(null),j({path:l,nonce:++F.current})):(j(null),Lt(l)),J&&(m&&R?.(),Tr(0),Lr.current?.slideTo(0),Ar(!1))})()},[G,Ms,J,R,m,d,tt,Lt]),n.useEffect(()=>{r||(Bt(!1),Zt(!1))},[r]),n.useEffect(()=>{if(!wr&&!Zr)return;const e=s=>{s instanceof globalThis.KeyboardEvent&&s.key!=="Escape"||s instanceof globalThis.MouseEvent&&s.target instanceof Node&&(Ln.current?.contains(s.target)||kr.current?.contains(s.target))||(Bt(!1),Zt(!1))};return window.addEventListener("mousedown",e),window.addEventListener("keydown",e),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("keydown",e)}},[Zr,wr]);const Vc=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("button",{type:"button",onClick:ff,disabled:!_a,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.parentFolder"),title:o("rightSidebar.parentFolder"),children:t.jsx(al,{size:14})}),t.jsx("button",{type:"button",onClick:sc,disabled:!d||zn===d,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.backToProjectRoot"),title:o("rightSidebar.backToProjectRoot"),children:t.jsx(xd,{size:14})}),t.jsx("button",{type:"button",onClick:hf,disabled:!re,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.refreshFiles"),title:wl?o("rightSidebar.fileWatchUnavailable",{message:wl}):o("rightSidebar.refreshFiles"),children:t.jsx(uo,{size:13})}),t.jsx("div",{className:"min-w-0 flex-1 px-1",title:re??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:df}),Na==="modified"&&t.jsx("span",{className:"inline-flex shrink-0 text-primary",title:o("fileTree.sortedByModified"),"aria-label":o("fileTree.sortedByModified"),children:t.jsx(dd,{size:11})})]})}),t.jsx("button",{type:"button",onClick:e=>re&&qt(re,Ft??void 0,e.currentTarget),disabled:!re,...re&&Ft?ai($a(re),Ft):{},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 ${Ft&&(Oe===Ft||ye===Ft)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":o(Ft&&ye===Ft?"rightSidebar.copied":Ft&&Oe===Ft?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:o("rightSidebar.insertCurrentFolder"),children:Ft&&(Oe===Ft||ye===Ft)?t.jsx(go,{size:13}):t.jsx(bo,{size:13})}),t.jsx(qp,{rootPath:re,disabled:!re||!Vu||Wo,pressed:Ca,saving:Wo,onToggle:()=>{if(!re||Wo)return;const e=re;_l(!0),qo(null),Yu(e,!Ca).catch(()=>{const s=U.getState();(s.explorerRoot??s.rootPath)===e&&qo(o("rightSidebar.gitIgnoreSaveFailed"))}).finally(()=>_l(!1))}}),t.jsxs("div",{ref:kr,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>{Bt(!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(po,{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),pf()},disabled:!li,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${Fs?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[Fs?t.jsx(Pi,{size:14}):t.jsx(ro,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(Fs?"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(Ap,{size:14}):t.jsx(Vi,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(Oo?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),t.jsxs("button",{type:"button",role:"menuitem",disabled:!re,onClick:()=>{re&&(Zt(!1),Ku(re,Na==="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:[Na==="modified"?t.jsx(Lh,{size:14}):t.jsx(dd,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(Na==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),Bl&&t.jsx("p",{role:"alert",className:"px-1 py-1 text-[11px] text-destructive",children:Bl}),d&&(Ba.length>0||uf)&&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:sc,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 ${re===d?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:d,children:[t.jsx(xd,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:Qe})]}),Ba.map(e=>{const s=e.path,l=e.kind==="file",h=l?et===s:re===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?Ms(s):Lt(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(Yi,{size:10,className:"shrink-0"}):t.jsx(ro,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:gt(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:gt(s)}),title:o("rightSidebar.unpinFolder",{name:gt(s)}),children:t.jsx(Xt,{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(Un===null)return null;const e=typeof navigator>"u"?void 0:navigator.language,s=Math.max(0,Math.floor(($o-Un)/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,Un]),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",Yc=d&&!Qn?t.jsxs("button",{type:"button",role:"menuitemcheckbox",tabIndex:-1,onClick:()=>{Hf(!Ho)},"aria-checked":Ho,title:o("rightSidebar.multiRepoScanTitle"),className:eo,children:[t.jsx(br,{size:15,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"min-w-0 flex-1",children:o("rightSidebar.multiRepoScan")}),Ho&&t.jsx(go,{size:14,className:"shrink-0 text-primary"})]}):null,Xc=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:()=>{Jn()},disabled:fr,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(uo,{size:13,className:fr?"animate-spin":""})})]}):null,Qf=ql?o("rightSidebar.changeAuditScopeAll"):wn.length===1?wn[0].relativeRoot==="."?Qe:wn[0].relativeRoot||wn[0].name:`${wn.length} repos`,Zf=e=>d?t.jsxs("div",{role:"none",children:[t.jsx(qd,{menuItem:!0,open:gs,onOpenChange:s=>{rn(s),s&&e()},showScopePicker:Pn,selectedAll:ql,repos:Xu,selectedRoots:ar,onToggleRepo:Ef,onGenerate:async s=>{const l=await Cf("generate",s);return l!==!1&&e(),l},disabled:!d,inserted:Oe===nc,buttonLabel:o("rightSidebar.changeAuditShort"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:o("rightSidebar.insertChangeAuditPrompt"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Qf,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o("rightSidebar.changeAuditShort"),loading:Ur,error:!!Pr,statusTitle:Pr??(Ur?o("rightSidebar.changeAuditLoading"):xt.length>0?`${o("rightSidebar.changeAuditLoaded",{count:xt.length})}${qc?` · ${o("rightSidebar.changeAuditLoadedAt",{time:qc})}`:""}`:void 0)}),xt.length>0&&t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{e(),Nf()},disabled:Ur||xt.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,os=or??(Ae?.available&&d&&Ee.size>0&&Be.length<=1?{root:d,label:Qe}:null),Jc=e=>t.jsxs(t.Fragment,{children:[os&&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",os.root,os.label)},disabled:!!$e,className:eo,children:[t.jsx(_h,{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",os.root,os.label)},disabled:!!$e,className:eo,children:[t.jsx(op,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stashAll")]})]}),os&&t.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Zf(e),Yc&&t.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Yc]}),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:[Ae?.available&&Ae.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:Ae.branch,children:[t.jsx(br,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:Ae.branch})]}),it.modified>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[it.modified,"M"]}),it.added>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",it.added]}),it.deleted>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",it.deleted]}),it.renamed>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[it.renamed,"R"]}),it.copied>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[it.copied,"C"]}),it.untracked>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[it.untracked,"U"]}),it.conflicted>0&&t.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[it.conflicted,"!"]}),it.other>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[it.other,"?"]}),it.staged>0&&t.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:o("rightSidebar.stagedCountShort",{count:it.staged})})]});return t.jsxs(lp,{side:"right",isOpen:r,drawerWidthPx:i,onClose:c,onOpen:f,push:p,pinned:g,children:[ai.popoverNode,t.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${nf?"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:Qe}),(!J||Mo)&&Ae?.available&&Ae.branch&&t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:Ae.branch,children:[t.jsx(br,{size:10,className:"shrink-0"}),t.jsx("span",{className:"max-w-[7rem] truncate",children:Ae.branch})]})]})}),t.jsx("button",{type:"button",onClick:()=>{const e=!ee;C(e),e?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):he("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${ee?"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(us,{size:14})}),t.jsxs("button",{type:"button",role:"switch","aria-checked":N,onClick:()=>{Q(e=>!e),Ye(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${N?"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(rp,{size:14}),!N&&kt.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:jl,type:"file",multiple:!0,className:"hidden",onChange:e=>{const s=e.target.files;!s||s.length===0||(Ls(Array.from(s)),e.target.value="")}}),t.jsx("input",{ref:Cl,type:"file",accept:"image/*",className:"hidden",onChange:e=>{const s=e.target.files?.[0];e.target.value="",s&&of(s,e.currentTarget.closest("[data-sidebar]")??void 0)}}),k&&t.jsx("button",{type:"button",onClick:k,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${g?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o(g?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:o(g?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:g?t.jsx(Pi,{size:14}):t.jsx(ro,{size:14})}),t.jsxs("div",{ref:Ln,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>{Zt(!1),Bt(e=>!e)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${wr?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":wr,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:t.jsx(po,{size:15})}),wr&&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:()=>af(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(pd,{size:14,className:"text-muted-foreground"}):t.jsx(ud,{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":qr,onClick:()=>Yl(!qr),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(fd,{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 ${qr?"bg-primary":"bg-surface-elevated"}`,children:t.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${qr?"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:()=>{Bt(!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(lt,{size:14,className:"animate-spin text-muted-foreground"}):t.jsx(cp,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o("rightSidebar.uploadFiles")})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Bt(!1),Cl.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(lt,{size:14,className:"animate-spin text-muted-foreground"}):t.jsx(Fp,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o("rightSidebar.insertLocalImage")})]}),k&&t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Bt(!1),k()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${g?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[g?t.jsx(Pi,{size:14}):t.jsx(ro,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(g?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),g&&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=L===e;return t.jsx("button",{type:"button",role:"menuitemradio","aria-checked":l,onClick:()=>{q(e),Bt(!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(Xt,{size:14})})]}),ee&&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(us,{size:12,className:"shrink-0"}),t.jsx("input",{"data-right-search":!0,type:"search",value:W,onChange:e=>he(e.target.value),placeholder:o(ne==="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 ${J?"text-[11px]":"text-[10px]"}`,children:[t.jsx("button",{type:"button",onClick:()=>Uc("name"),"aria-pressed":ne==="name",className:`rounded-full px-2 transition active:scale-95 ${J?"py-1":"py-0.5"} ${ne==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeName")}),t.jsx("button",{type:"button",onClick:()=>Uc("content"),"aria-pressed":ne==="content",className:`rounded-full px-2 transition active:scale-95 ${J?"py-1":"py-0.5"} ${ne==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeContent")})]}),W&&t.jsx("button",{type:"button",onClick:()=>he(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:t.jsx(Xt,{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(Ih,{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:Ne,onChange:e=>we(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}),Ne!=="."&&t.jsx("button",{type:"button",onClick:()=>we("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.resetSearchScope"),children:t.jsx(Xt,{size:11})})]}),t.jsxs("button",{type:"button",onClick:()=>oe(e=>!e),"aria-expanded":ue,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${ue||Es.length>0||Fe||E||ge?"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(np,{size:13}),Es.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:Es.length})]})]}),ue&&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:Pe,onChange:e=>O(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}),Pe&&t.jsx("button",{type:"button",onClick:()=>O(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.clearSearchExclude"),children:t.jsx(Xt,{size:11})})]}),ne==="content"&&t.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":o("rightSidebar.contentSearchOptions"),children:[[Fe,()=>Ie(e=>!e),Pp,o("rightSidebar.matchCase")],[E,()=>xe(e=>!e),Hp,o("rightSidebar.matchWholeWord")],[ge,()=>De(e=>!e),_p,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(${(Qn?1:3)+Number(sr.architecture)+Number(sr.computer)+Number(qr)}, minmax(0, 1fr))`},children:[!Qn&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:e=>ts("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] ${jt==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(br,{size:12}),o("rightSidebar.tabGit")]}),t.jsxs("button",{type:"button",onClick:e=>ts("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] ${jt==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(lu,{size:12}),o("rightSidebar.tabChanges"),Ee.size>0?t.jsx("span",{className:"text-[10px] text-accent",children:Ee.size}):null]})]}),t.jsxs("button",{type:"button",onClick:e=>ts("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] ${jt==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(Gi,{size:12}),o("rightSidebar.tabFiles")]}),sr.architecture&&t.jsxs("button",{type:"button",onClick:e=>ts("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] ${kn?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(pd,{size:12}),o("architecture.tab")]}),sr.computer&&t.jsxs("button",{type:"button",onClick:e=>ts("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] ${es?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(ud,{size:12}),o("rightSidebar.tabComputer")]}),qr&&t.jsxs("button",{type:"button",onClick:e=>ts("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] ${jt==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(fd,{size:12}),o("rightSidebar.tabAndroid")]})]}),t.jsx("div",{className:"h-2"}),xl&&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:xl})]}),t.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-surface",children:[t.jsx(is,{active:nt,mounted:nr,fallback:t.jsx(Oi,{slow:!1}),children:()=>Ge?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:t.jsx(jd,{items:Tf,diffViewType:Do,inlineMode:Ht,viewControls:g?Us():void 0,renderPathReference:(e,s)=>Wa(An(e,Ge.repoRoot??d),o(s==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle")),selectedKey:Fu,onSelect:fa,emptyText:o("rightSidebar.noChanges"),mobile:J,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o("rightSidebar.recentCommitsTitle"),headerMeta:`${Ge.headRef??""}${Ge.commits?.[0]?` · ${Ge.commits[0]}`:""}`,onClose:()=>{ot(null),fa(null)},closeLabel:o("common.back"),wrap:At,onToggleWrap:Xa,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:J?"stacked":"split",onInsertDiffReference:Fr,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onClearAuditRecord:Ka})}):Er?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:t.jsx(jd,{items:hi,diffViewType:Do,inlineMode:Ht,viewControls:g?Us():void 0,renderPathReference:(e,s)=>{const l=fe?.comparisonRepos,h=l&&l.length>1?[...l].sort((v,y)=>y.label.length-v.label.length).find(v=>e===v.label||e.startsWith(`${v.label}/`)):void 0,u=h?e===h.label?h.repoRoot:An(e.slice(h.label.length+1),h.repoRoot):An(e,zs?.repoRoot||d);return Wa(u,o(s==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle"))},selectedKey:Eo,onSelect:fn,emptyText:o(fe?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:J,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o(fe?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:zs?`${zs.repoLabel} · ${zs.branchName??"HEAD"} → ${zs.baseRef}`:void 0,onClose:()=>{++T.current,Te(!1),lr(!1),tr(null)},closeLabel:o("common.back"),wrap:At,onToggleWrap:Xa,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:J?"stacked":"split",onInsertDiffReference:Fr,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onClearAuditRecord:Ka,localOptions:fe?.comparisonRepos?.map(e=>({key:e.repoRoot,label:e.label,checked:e.includeUncommitted??fe.includeUncommitted??!1,disabled:!(e.canIncludeUncommitted??ss(e.repoRoot,e.head)),onChange:s=>{bi({refresh:!0,repoRoot:e.repoRoot,includeUncommitted:s})}})),onHunkGitAction:fe?.includeUncommitted?Of:void 0,error:ze,actionsBusy:ce>0,onRefresh:()=>{bi({refresh:!0})},refreshing:Je,refreshLabel:o("rightSidebar.branchAuditRefreshDiff"),refreshTitle:o("rightSidebar.branchAuditRefreshDiff"),walkthroughs:Mf,onWalkthroughNavigate:Lf,initialDetailScrollTop:fe&&qe?vs[qe]:void 0,onDetailScrollPositionChange:Bf,externalSwiperRef:J?Gl:void 0,onMobileSlideChange:J?To:void 0})}):t.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:nr&&d&&Nn?t.jsx("div",{className:"px-3",children:Yf()}):fr?t.jsx(Oi,{slow:Il}):xn?t.jsx(io,{message:xn,onRetry:()=>{Jn()}}):Jd(Ae)?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(d?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):Ae?.available===!1?t.jsx(io,{message:Ae.error??o("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{Jn()}}):d?t.jsx(Oi,{slow:Il}):t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(d?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),t.jsx(is,{active:Ir,mounted:_u||Ir,children:()=>J?t.jsxs(ip,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:e=>{Lr.current=e,e.slideTo(Ao,0)},onSlideChange:e=>{if(Tr(e.activeIndex),Ts.current===e.activeIndex){Ts.current=null;return}e.activeIndex===0&&(Ar(!1),Ut(null),R?.())},children:[t.jsx(md,{className:"h-full min-h-0",children:t.jsxs("div",{ref:qn,onScroll:Xl,onDragOver:La,onDragEnter:La,onDragLeave:Ql,onDrop:Zl,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[kl&&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()&&Vc,t.jsx(hd,{rootPath:re??"",onFileSelect:Ms,onPathReference:qt,getReferenceText:$a,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onDirectoryRoot:ac,onSearchFromDirectory:oc,onDirectoryPinToggle:ic,onFilePinToggle:lc,pinnedPaths:Rn,selectedFilePath:et,query:Ve,searchRootPath:Ul,searchOptions:Ol,searchMode:ne,onContentMatchSelect:ri,onDirectoryDropFiles:(e,s)=>Ls(s,e),revealDirectory:le,canOpenInFileBrowser:Sl,onOpenInFileBrowser:Jl})]})}),t.jsx(md,{className:"h-full min-h-0",children:t.jsx("div",{className:"h-full overflow-hidden bg-surface",children:t.jsx(yo,{filePath:Du||Ao===1?et:null,active:r&&Ir&&Ao===1,onInsertReference:qt,onInsertText:$r,onInsertFeature:Da,onReviewReference:Da,onReferenceCopied:mr,onClose:Jf,onDirectoryLinkOpen:Kc,isMobile:!0,lineRange:_r,onLineRangeChange:Ut,insertedReferenceKey:Oe,copiedReferenceKey:ye,scrollToLine:He,onScrollToLineHandled:()=>Et(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:te,onOpenMarkdownOutline:M,onCloseMarkdownOutline:I,markdownImageLightboxOpen:H,markdownImageLightboxCloseSignal:Y,onOpenMarkdownImageLightbox:be,onCloseMarkdownImageLightbox:_})})})]}):t.jsxs("div",{className:"flex h-full min-h-0",children:[t.jsxs("div",{ref:qn,onScroll:Xl,onDragOver:La,onDragEnter:La,onDragLeave:Ql,onDrop:Zl,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:_o},children:[kl&&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()&&Vc,t.jsx(hd,{rootPath:re??"",onFileSelect:Ms,onPathReference:qt,getReferenceText:$a,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onDirectoryRoot:ac,onSearchFromDirectory:oc,onDirectoryPinToggle:ic,onFilePinToggle:lc,pinnedPaths:Rn,selectedFilePath:et,query:Ve,searchRootPath:Ul,searchOptions:Ol,searchMode:ne,onContentMatchSelect:ri,onDirectoryDropFiles:(e,s)=>Ls(s,e),revealDirectory:le,canOpenInFileBrowser:Sl,onOpenInFileBrowser:Jl})]}),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:Ju,onPointerMove:Qu,onPointerUp:Vl,onPointerCancel:Vl,onDoubleClick:()=>{Bo(el),Pt(ea,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:et,active:r&&Ir,onInsertReference:qt,onInsertText:$r,onInsertFeature:Da,onReviewReference:Da,onReferenceCopied:mr,onDirectoryLinkOpen:Kc,isMobile:!1,lineRange:_r,onLineRangeChange:Ut,insertedReferenceKey:Oe,copiedReferenceKey:ye,scrollToLine:He,onScrollToLineHandled:()=>Et(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:te,onOpenMarkdownOutline:M,onCloseMarkdownOutline:I,markdownImageLightboxOpen:H,markdownImageLightboxCloseSignal:Y,onOpenMarkdownImageLightbox:be,onCloseMarkdownImageLightbox:_})})]})}),t.jsx(is,{active:Ct,mounted:Uu||Ct,children:()=>ei?t.jsx(sp,{}):J?t.jsx(qi,{mobile:!0,backLabel:o("rightSidebar.backToChangeList"),externalSwiperRef:Qo,onMobileSlideChange:To,groups:Yt.length>0?Nc():[],mode:Cr,onModeChange:Ya,selectedKey:et,scrollToKey:Mc,scrollToKeyNonce:Sa.nonce,compact:!1,collapsedDirectoryKeys:oa,onToggleDirectory:$c,onSelectFile:e=>{const s=En.get(e.key);s&&Va(xr(s))},renderLeading:Pc,renderTrailing:e=>{const s=En.get(e.key);return s?jc(s):null},renderDirectoryTrailing:Cc,renderSubtitle:e=>{const s=En.get(e.key);return s?Rc(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:[Yt.length,"/",Ee.size]})]}),t.jsxs(Sd,{actions:Jc,children:[kc(),e,g&&Us(),Xc]},d),or&&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:or.label}),or.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:or.branch})]}),!or&&Pn&&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(br,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:Ha?(e=>Ic(e)):void 0,emptyContent:ei?null:xn&&Ee.size===0?t.jsx(io,{message:xn,onRetry:()=>{Jn()}}):Ee.size===0?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Yt.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(mo,{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:[g&&Us(),t.jsxs("button",{type:"button",onClick:Xa,"aria-pressed":At,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 ${At?"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(At?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),d&&t.jsx("button",{type:"button",onClick:()=>{Jn()},disabled:fr,"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(uo,{size:14,className:fr?"animate-spin":""})})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:Ec,activePane:Ct,wrap:At,diffViewType:Do,inlineMode:Ht,diffOptions:Bc,reloadKey:ca,renderStreamBadge:e=>t.jsx(na,{status:e}),onHunkGitAction:Oc,onInsertDiffReference:Fr,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onClearAuditRecord:Ka,onDetailScroll:qa}):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:Yt.length>0?Nc():[],mode:Cr,onModeChange:Ya,selectedKey:et,scrollToKey:Mc,scrollToKeyNonce:Sa.nonce,compact:!0,collapsedDirectoryKeys:oa,onToggleDirectory:$c,onSelectFile:e=>{const s=En.get(e.key);s&&Va(xr(s))},renderLeading:Pc,renderTrailing:e=>{const s=En.get(e.key);return s?jc(s):null},renderDirectoryTrailing:Cc,renderSubtitle:e=>{const s=En.get(e.key);return s?Rc(s):null},aiContent:Ha?(e=>Ic(e)):void 0,emptyContent:ei?null:xn&&Ee.size===0?t.jsx(io,{message:xn,onRetry:()=>{Jn()}}):Ee.size===0?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Yt.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:[Yt.length,"/",Ee.size]})})]}),t.jsxs(Sd,{actions:Jc,children:[kc(),e,Us(),t.jsxs("button",{type:"button",onClick:Xa,"aria-pressed":At,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 ${At?"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(At?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),Xc]},d),or&&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:or.label}),or.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:or.branch})]}),!or&&Pn&&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(br,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),files:Ec,activePane:Ct,wrap:At,diffViewType:Ot,inlineMode:Ht,diffOptions:Bc,reloadKey:ca,renderStreamBadge:e=>t.jsx(na,{status:e}),onHunkGitAction:Oc,onInsertDiffReference:Fr,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onClearAuditRecord:Ka,onDetailScroll:qa})}),t.jsx(is,{active:kn,mounted:sr.architecture&&(tf||r&&kn),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(kg,{rootPath:d,active:r&&kn,onInsertPrompt:(e,s)=>$r(e,`architecture:${d}`,s),renderSource:e=>d&&t.jsx(lb,{rootPath:d,file:e,active:r&&kn,isMobile:J,onInsertReference:qt,onInsertText:$r,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye},`${e.path}:${e.line??1}`),onOpenFile:e=>{d&&(Mt("files"),Lt(null),ri(`${d.replace(/\/+$/,"")}/${e.path}`,e.line??1))}},d)})}),t.jsx(is,{active:r&&es,mounted:sr.computer&&(Zu||r&&es),children:t.jsx(n.Suspense,{fallback:t.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:o("computer.loading")}),children:t.jsx(Sg,{active:r&&es})})}),t.jsx(is,{active:Zn,mounted:Io&&qr,children:Ou?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),Zs({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:o("android.splitClose")})]}):t.jsx(xp,{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:cf,onRecordingComplete:lf})})]}),r&&wt&&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&&$t.task&&t.jsx(ym,{task:$t.task,onCancel:$t.cancel,onRetry:()=>{$t.retry()},onDismiss:$t.dismiss,labels:{uploading:o("rightSidebar.uploadPending"),inserting:o("rightSidebar.uploadInserting"),done:o($t.task.kind==="image"?"rightSidebar.uploadReferenceDone":"rightSidebar.uploadDone",{count:$t.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:$t.task.files.length})}}),r&&N&&t.jsx(mm,{value:kt,collapsed:ke,autoCollapseAfterSend:ht,focusRequest:Mn,insertError:In?o("rightSidebar.contextDraftInsertFailed"):null,onChange:e=>{en(!1),St(e)},onCollapsedChange:Ye,onAutoCollapseAfterSendChange:yr,onDisable:()=>Q(!1),onClear:()=>St(""),onInsert:e=>rc(!1,e),onInsertAndSend:e=>rc(!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})}}),kf(),pt&&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:pt.kind==="restore"?o("rightSidebar.confirmRestoreTitle"):o("rightSidebar.confirmStashAllTitle")}),t.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:pt.kind==="restore"?o("rightSidebar.confirmRestoreDescription",{path:ru(pt.file.absolutePath,d)}):o("rightSidebar.confirmStashAllDescription")}),pt.kind==="restore"&&t.jsx("input",{value:pt.phrase,onChange:e=>hn({...pt,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:!!$e||pt.kind==="restore"&&pt.phrase.trim()!==o("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(pt.kind==="restore"){const e=ut(pt.file,d);if(!e)return;mt({action:"restore-worktree-file",cwd:e,paths:[pt.file.path],confirm:{acknowledged:!0,phrase:pt.phrase}},o("rightSidebar.restoreFile"),Hi(pt.file))}else{const e=pt.repoRoot??d;if(!e)return;mt({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 ${pt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:o($e?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const Tb=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:yo,MarkdownImageLightbox:Hh,MarkdownPreview:nu,RightSidebar:cb,__testParseMarkdownListBlock:zh,buildMarkdownPreviewBlocks:Gh,buildMarkdownPreviewRenderResult:Wh,collectKnownGitRepoRoots:Cu,computeMarkdownImageDisplayBox:qh,getMarkdownHeadingOutline:Kh,getMarkdownHeadingPathAtLine:Vh,getNextMarkdownPreviewLineRange:Wg,isSvgImageSrc:Yh,mountRightSidebarRepoPickerOverlay:bu,replaceGitRepositorySnapshot:Iu,resolveMarkdownLocalLinkTarget:Xh,resolveRightSidebarDiffViewType:Ru,shouldCloseMarkdownImageLightboxDrag:Jh,showsGitRepoGroupHeader:tl},Symbol.toStringTag,{value:"Module"}));export{Vi as E,Tb as R,Up as S,Ap as a,Kp as c,Ab as m};
|
|
1662
|
+
`),truncated:y.some(z=>z.truncated)};if(Z.comparisonRepos=l.map((z,B)=>({...z,head:z.head??y[B].currentBranch??null,includeUncommitted:y[B].includeUncommitted===!0,canIncludeUncommitted:y[B].canIncludeUncommitted})),Z.canIncludeUncommitted=y.every(z=>z.canIncludeUncommitted===!0),Z.includeUncommitted=y.some(z=>z.includeUncommitted===!0),Po(z=>({...z,...Object.fromEntries(Z.comparisonRepos.map(B=>[B.repoRoot,B.includeUncommitted??!1]))})),!s&&(Z.hunks??[]).length===0){Me(o("rightSidebar.branchAuditDiffEmpty"));return}const de=Date.now(),je=(s?qe:null)??["preview",Z.repoRoot??d,Z.baseRef??Z.baseBranch??"",Z.currentBranch??"",Z.headRef??"",Z.diffFingerprint??de].join("\0"),Ke=l.length===1?l[0].label:`${l.length} repos`;tr(Z),sn(z=>[{key:je,diff:Z,repoLabel:Ke,createdAt:de},...z.filter(B=>B.key!==je)].slice(0,8)),s||S(z=>z[je]===void 0?z:{...z,[je]:0}),un(je),fn(z=>{const B=Z.hunks?.[0],ie=B?`${B.filePath}\0${B.hunkHeader}\0${B.hunkIndex}`:null;return s&&z&&(Z.hunks??[]).some(Ce=>Ce.filePath===z.split("\0")[0])?z:ie}),lr(!0)}catch(y){if(!v()||vr(y))return;Me(y instanceof Error?y.message:"Failed to load branch diff")}finally{v()&&Te(!1)}},[dn,fe,qe,Bs,Rt,rr,Re,d,o]),$f=n.useCallback(e=>{++T.current,Te(!1),tr(e.diff),Me(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),lr(!0)},[]),Ff=n.useCallback(e=>{sn(s=>s.filter(l=>l.key!==e)),S(s=>{if(!(e in s))return s;const l={...s};return delete l[e],l}),qe===e&&(un(null),tr(null),lr(!1))},[qe]),Df=n.useCallback(e=>{++T.current,Te(!1);const s=as.find(l=>l.key===e);s&&(tr(null),Me(null),un(e),fn(s.records[0]?.filePath??null),lr(!0))},[as]),_f=n.useCallback(async e=>{if(!d||!ve)return;const[s]=e.split(/\s+/);if(s){cr(s),an(null),ot(null);try{const l=await Th({cwd:d,repoRoot:ve,commit:s,requestSlotId:"right-sidebar-commit-diff"});if(!l.available){an(l.error??"Commit diff is unavailable");return}ot(l);const h=l.hunks?.[0];fa(h?`${h.filePath}\0${h.hunkHeader}\0${h.hunkIndex}`:null)}catch(l){an(l instanceof Error?l.message:"Failed to load commit diff")}finally{cr(null)}}},[ve,d]),Bf=n.useCallback(e=>{if(!fe||!qe)return;const s=Math.max(0,Math.round(e));S(l=>Math.abs((l[qe]??0)-s)<24?l:{...l,[qe]:s})},[fe,qe]);n.useEffect(()=>{!fe||!qe||sn(e=>e.map(s=>s.key===qe&&s.diff!==fe?{...s,diff:fe}:s))},[fe,qe]);const Ac=!!fe;n.useEffect(()=>{if(!J||!Er||!Ac)return;const e=Gl.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)},[Er,Ac,J]);const Tc=n.useCallback(e=>{e&&Wu(s=>up(s,e))},[]),Mc=Sa.key===et?Sa.key:null,Va=n.useCallback(e=>{const s=U.getState(),l=sb();Qs("select_diff_file",{interactionId:l,path:e,previousSelectedFilePath:s.selectedFilePath,rootPath:s.rootPath,activeGitRepoRoot:me,changedFiles:s.changedFiles.size,gitBundleLoading:s.gitBundleLoading,gitBundleLastLoadedAt:s.gitBundleLastLoadedAt,rightTab:s.rightTab}),tt(e),Mt("diff"),J&&e&&Kl(1),Tc(e),queueMicrotask(()=>{const h=U.getState();Qs("select_diff_file_after",{interactionId:l,requestedPath:e,selectedFilePath:h.selectedFilePath,rootPath:h.rootPath,rightTab:h.rightTab,changedFiles:h.changedFiles.size,activeGitRepoRoot:me})})},[me,J,Tc,tt,Mt,Kl]),Lc=n.useCallback(e=>{const s=Array.from(Ee.values()).find(l=>{const h=ut(l,d),u=xr(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(xr(s)),window.setTimeout(()=>Tn(e),90),window.setTimeout(()=>Tn(e),320),window.setTimeout(()=>Tn(e),760);return}Tn(e)},[Ee,d,Va]),Ic=n.useCallback(({slideToDetail:e,fullscreen:s,toggleFullscreen:l}={})=>ms.length>0?t.jsx(su,{walkthroughs:ms,repoRoot:me,fullscreen:s,onToggleFullscreen:l,onNavigate:h=>{J&&window.requestAnimationFrame(()=>e?.()),Lc(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(sa,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),o("rightSidebar.changeWalkthroughEmpty")]}),[me,ms,Lc,J,o]),Uf=n.useCallback(e=>{e&&Rr(s=>{const l=new Set(s);return l.has(e)?l.delete(e):l.add(e),Bi($i,l),l})},[]),$c=n.useCallback(e=>{jr(s=>{const l=new Set(s);return l.has(e)?l.delete(e):l.add(e),Bi(Ld,l),l})},[]),Ya=n.useCallback(e=>{ia(e),Pt(vu,e)},[]);n.useEffect(()=>{Ha||Cr!=="ai"||Ya("tree")},[Cr,Ya,Ha]);const Xa=n.useCallback(()=>{ps(e=>{const s=!e;return Pt(yu,s),s})},[]),Fc=n.useCallback(e=>{la(e),Pt(wu,e)},[]),{whitespace:Dc,context:_c}=vp(),Bc=n.useMemo(()=>({algorithm:"histogram",whitespace:Dc,context:_c}),[Dc,_c]),Uc=n.useCallback(e=>{pe(e),Pt(ku,e)},[]),Ja=n.useCallback(async(e,s,l,h)=>{let u=e;for(;u.ok&&u.status==="running";)await new Promise(y=>window.setTimeout(y,1500)),u=await ld({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 v={action:s.action,path:h,label:l};return Ns(v),window.setTimeout(()=>Ns(y=>y?.action===v.action&&y.path===v.path?null:y),1400),u},[]),mt=n.useCallback(async(e,s,l)=>{const h=d;d&&hr.current.delete(d),zt(null),Ns(null),Cs({action:e.action,path:l});try{const u=await Mh({...e,includeNested:Vs(d)}),v=await Ja(u,e,s,l);if(!Re(h))return!1;const y=d?await Ci(d,void 0,{includeNested:Vs(d),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Xs(d)}).catch(()=>v.bundle):v.bundle;return Re(h)?(y&&Xn(y,{reloadDiff:!0,cacheOnly:!0}),hn(null),!0):!1}catch(u){return Ns(null),zt(o("rightSidebar.gitActionFailed",{message:u instanceof Error?u.message:"Unknown error"})),!1}finally{Re(h)&&Cs(null)}},[Xn,Re,d,o,Ja]),Oc=n.useCallback(async e=>{const s=d;await cd({...e,includeNested:Vs(d)}),Re(s)&&It(d??void 0,{refresh:!0,background:!0})},[Re,It,d]),Of=n.useCallback(async e=>{const s=fe,l=T.current,h=s?.hunks?.find(v=>v.previewRevert?.cwd===e.cwd&&v.previewRevert.path===e.path);if(!s||!h||!e.comparisonBase)throw new Error(o("diffViewer.hunkActionUnavailable"));Se(v=>v+1),Me(null);try{await cd(e)}catch(v){throw Se(y=>y-1),v}if(l!==T.current||!Re(d)){Se(v=>v-1);return}const u=v=>{tr(y=>{if(!y||l!==T.current)return y;const X=y.hunks??[],Z=v===void 0?X.filter(je=>!(je.previewRevert?.cwd===e.cwd&&je.previewRevert.patch===e.patch)):[...X.filter(je=>je.filePath!==h.filePath),...v];return{...y,hunks:Z}})};u(),id({cwd:e.cwd,repoRoot:e.cwd,base:e.comparisonBase,comparisonBase:e.comparisonBase,filePath:e.path,requestSlotId:`branch-preview-file:${e.cwd}:${e.path}`}).then(v=>{if(l!==T.current||!Re(d))return;if(!v.available||v.truncated)throw new Error(v.error??o("diffViewer.hunkActionUnavailable"));const y=e.path.slice(e.cwd.length+1),X=h.filePath.slice(0,h.filePath.length-y.length);u((v.hunks??[]).map(Z=>({...Z,filePath:`${X}${Z.filePath}`,oldPath:Z.oldPath?`${X}${Z.oldPath}`:Z.oldPath,newPath:Z.newPath?`${X}${Z.newPath}`:Z.newPath})))}).catch(v=>{l===T.current&&Re(d)&&!vr(v)&&Me(`${o("diffViewer.hunkActionReverted")} · ${v instanceof Error?v.message:String(v)}`)}).finally(()=>Se(v=>v-1))},[fe,Re,d,o]),Qa=n.useCallback((e,s,l)=>{if(s){if(e==="stage-all"){mt({action:"stage-all",cwd:s},o("rightSidebar.stageAll"),`repo:${s}`);return}hn({kind:"stash-all",repoRoot:s,repoLabel:l})}},[mt,o]),Hc=n.useCallback(e=>{dt(e),ya(""),wa(""),ka(""),tt(pc(e)),nt||Mt("diff"),e&&Ua(rt.get(e))},[Ua,pc,nt,rt,tt,dt,Mt]),zc=n.useCallback(e=>{const s=new Set([...Wt.current.keys(),...vn.current,...hr.current]);for(const l of s)l!==e&&(Gt.current.delete(l),Wt.current.get(l)?.abort(),Wt.current.delete(l),yt(`right-sidebar-git-untracked:${l}`),vn.current.delete(l),hr.current.delete(l))},[]),Hf=n.useCallback(async e=>{const s=d;if(!s||(await U.getState().setNestedGitScanRoot(s,e),!Re(s)))return;if(e){await It(s,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}zc(s),ya(""),wa(""),ka(""),No(h=>h.filter(u=>u===s));const l=Kt;l&&ut(l,s)!==s&&tt(null),await It(s,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[zc,Re,It,d,tt,Kt]),zf=n.useCallback(async()=>{if(!ve||Xe){zt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=On.trim();!e||e===se?.branch||await mt({action:"switch-branch",cwd:ve,branch:e},o("rightSidebar.switchBranch"))},[se?.branch,ve,Xe,mt,On,o]),Gc=n.useCallback(async()=>{if(!ve||Xe){zt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=va.trim();if(!e)return;await mt({action:"commit",cwd:ve,message:e},o("rightSidebar.commitChanges"))&&yl("")},[ve,va,Xe,mt,o]),Gf=n.useCallback(async()=>{if(!ve||Xe){zt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=mn.trim(),s=gn.trim();await mt({action:"push",cwd:ve,...e?{remote:e}:{},...s?{branch:s}:{}},o("rightSidebar.pushChanges"))},[ve,gn,mn,Xe,mt,o]),Wf=n.useCallback(async()=>{if(!ve||Xe){zt(o("rightSidebar.selectRepositoryForGitActions"));return}const e=mn.trim(),s=gn.trim();await mt({action:"pull",cwd:ve,...e?{remote:e}:{},...s?{branch:s}:{}},o("rightSidebar.pullChanges"))},[ve,gn,mn,Xe,mt,o]);n.useEffect(()=>{if(!nt||!ve||$e)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 ld({cwd:ve,action:l}).catch(()=>null);if(!h?.ok||h.status!=="running")continue;const u={action:l,cwd:ve},v=s[l]??l;Cs({action:l});try{const y=await Ja(h,u,v);if(e||!Re(d))return;const X=d?await Ci(d,void 0,{includeNested:Vs(d),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Xs(d)}).catch(()=>y.bundle):y.bundle;X&&Xn(X,{reloadDiff:!0,cacheOnly:!0})}catch(y){e||zt(o("rightSidebar.gitActionFailed",{message:y instanceof Error?y.message:"Unknown error"}))}finally{e||Cs(null)}return}})(),()=>{e=!0}},[ve,Xn,nt,Re,d,$e,o,Ja]);const xi=Bn?.action==="commit",vi=Bn?.action==="switch-branch",yi=Bn?.action==="pull",wi=Bn?.action==="push",Za=nt||zu,ki=Ga?o("rightSidebar.changeAuditScopeAll"):gr.length===1?gr[0].label:`${gr.length} repos`,qf=gr.length>0,Wc=Bs.length>0,Kf=d?t.jsx(qd,{open:jo,onOpenChange:Co,showScopePicker:!0,selectedAll:Ga,repos:Vt,selectedRoots:za,onToggleRepo:Af,onGenerate:e=>If(pi?"regenerate":"generate",e),disabled:!qf,generateDisabled:!Wc,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:!Wc||Je,secondaryLabel:o("rightSidebar.branchAuditViewDiff"),secondaryTitle:o("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:Je,loading:fl.size>0,statusTitle:fl.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(ae==="zh"?"、":", ")})})}),renderRepoExtra:e=>{const s=rt.get(e.root),l=ss(e.root,rr[e.root]||s?.context?.branch),h=[],u=new Set,v=(de,je)=>{!de||u.has(de)||(u.add(de),h.push({value:de,label:de,meta:je}))};v(rr[e.root]||s?.context?.branch,o("rightSidebar.pushCurrentBranchBadge"));for(const de of s?.context?.branches??[])v(de,de===s?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):o("rightSidebar.localBranch"));for(const de of s?.context?.remoteBranches??[])v(de,o("rightSidebar.remoteBranch"));const y=[],X=new Set,Z=(de,je)=>{!de||X.has(de)||(X.add(de),y.push({value:de,label:de,meta:je}))};Z(Rt[e.root],Rt[e.root]?o("rightSidebar.pushUpstreamBadge"):void 0),Z(s?.context?.upstream,s?.context?.upstream?o("rightSidebar.pushUpstreamBadge"):void 0);for(const de of s?.context?.remoteBranches??[])Z(de,"remote");for(const de of s?.context?.branches??[])Z(de,de===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(cs,{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:de=>{pa(je=>({...je,[e.root]:de}))}}),t.jsx(cs,{label:o("rightSidebar.branchAuditBaseLabel"),value:Rt[e.root]||"",options:y,placeholder:o("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:o("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:o("rightSidebar.branchAuditBaseEmpty"),onChange:de=>{ma(je=>({...je,[e.root]:de}))}}),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:de=>Po(je=>({...je,[e.root]:de.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,qc=Js(xt.reduce((e,s)=>Math.max(e,s.injectedAt??0),0),ae),Vf=()=>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:()=>ul(e=>{const s=!e;return Pt(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":Rs,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(sa,{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 ${Rs?"rotate-90":""}`,children:t.jsx(ds,{size:13})})]}),Rs&&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]}),Kf]}),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 ${qe===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),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")})]}),Js(e.createdAt,ae)&&t.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:Js(e.createdAt,ae)})]}),t.jsx("button",{type:"button",onClick:()=>Ff(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)),as.length>0?as.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 ${qe===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:()=>Df(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})]}),Js(e.latestInjectedAt,ae)&&t.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:o("rightSidebar.branchAuditGeneratedAt",{time:Js(e.latestInjectedAt,ae)??""})})]}),t.jsx("button",{type:"button",onClick:()=>{Pf(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,Yf=()=>nr&&d&&Nn?t.jsxs("div",{className:Za?"overflow-visible":"overflow-hidden",children:[Vf(),t.jsxs("button",{type:"button",onClick:()=>{nt||Gu(e=>{const s=!e;return s&&ve&&!Nn&&!pn&&Zo(ve),s})},"aria-expanded":Za,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${nt?"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(br,{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 ${Cn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[pn&&t.jsx(lt,{size:10,className:"animate-spin"}),Cn.staged>0?o("rightSidebar.stagedCount",{count:Cn.staged}):o("rightSidebar.noStagedChangesShort")]}),!nt&&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(ds,{size:13})})]})]}),Za&&t.jsxs("div",{className:"space-y-0",children:[Dt.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:mf})]})}),t.jsx(cs,{label:o("rightSidebar.gitRepositoryLabel"),value:ve??"",options:Dt,placeholder:o("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:o("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:o("rightSidebar.gitRepositoryEmpty"),disabled:!!$e,onChange:e=>{Hc(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:On!==fc?fc:null})]}),t.jsxs("button",{type:"button",onClick:()=>{zf()},disabled:!jf,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 ${vi?"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:$e?.action==="switch-branch"||vi?"opacity-0":"",children:o("rightSidebar.switchBranch")}),$e?.action==="switch-branch"&&t.jsx(lt,{size:12,className:"absolute animate-spin"}),vi&&$e?.action!=="switch-branch"&&t.jsx("span",{className:"absolute",children:"✓"})]})]}),t.jsx(cs,{label:o("rightSidebar.currentBranchLabel"),value:On,options:xf,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),disabled:!!$e,onChange:ya})]}),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"):Cn.staged>0?o("rightSidebar.commitReadyHint",{count:Cn.staged}):o("rightSidebar.commitNeedsStaged")})]}),t.jsxs("button",{type:"button",onClick:()=>{Gc()},disabled:!!$e||Xe||Cn.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"):Cn.staged===0?o("rightSidebar.commitNeedsStaged"):o("rightSidebar.commitChanges"),children:[t.jsx("span",{className:$e?.action==="commit"||xi?"opacity-0":"",children:o("rightSidebar.commitChanges")}),$e?.action==="commit"&&t.jsx(lt,{size:12,className:"absolute animate-spin"}),xi&&$e?.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(),Gc())},placeholder:o("rightSidebar.commitMessagePlaceholder"),disabled:!!$e,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:[da&&t.jsx(lt,{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(ds,{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(us,{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(Xt,{size:12})})]}),t.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:gf,children:[Tt.length>0?Tt.map(e=>{const[s,...l]=e.split(/\s+/),h=l.join(" ")||e;return t.jsxs("button",{type:"button",onClick:()=>{_f(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}),K[s]&&t.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${K[s]==="ahead"?"bg-accent/10 text-accent":K[s]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:o(K[s]==="ahead"?"rightSidebar.commitAhead":K[s]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),Fn===s&&t.jsx(lt,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},e)}):da?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")}),ua&&t.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:t.jsx(lt,{size:12,className:"animate-spin"})}),Ro&&!ua&&Tt.length>0&&t.jsx("button",{type:"button",onClick:()=>{_s({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")})]})]}),ys&&t.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:ys}),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:()=>{Wf()},disabled:!Sf,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 ${yi?"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:$e?.action==="pull"||yi?"opacity-0":"",children:o("rightSidebar.pullChanges")}),$e?.action==="pull"&&t.jsx(lt,{size:12,className:"absolute animate-spin"}),yi&&$e?.action!=="pull"&&t.jsx("span",{className:"absolute",children:"✓"})]}),t.jsxs("button",{type:"button",onClick:()=>{Gf()},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 ${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:$e?.action==="push"||wi?"opacity-0":"",children:o("rightSidebar.pushChanges")}),$e?.action==="push"&&t.jsx(lt,{size:12,className:"absolute animate-spin"}),wi&&$e?.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] ${wc.className}`,title:se?.upstream??void 0,children:[t.jsx("span",{className:"truncate font-medium",children:wc.text}),t.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:se?.upstream??""})]}),t.jsxs("div",{className:`grid gap-1.5 ${xc?"grid-cols-2":"grid-cols-1"}`,children:[xc&&t.jsx(cs,{label:o("rightSidebar.pushRemoteLabel"),value:mn,options:bc,placeholder:o("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:o("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:o("rightSidebar.pushNoRemotes"),disabled:!!$e,onChange:wa}),t.jsx(cs,{label:o("rightSidebar.pushBranchLabel"),value:gn,options:vf,placeholder:o("rightSidebar.pushBranchPlaceholder",{branch:se?.branch??"HEAD"}),searchPlaceholder:o("rightSidebar.pushBranchSearchPlaceholder"),emptyText:o("rightSidebar.pushNoBranches"),disabled:!!$e,onChange:ka})]})]})]})]}):null,Xf=n.useCallback(e=>{const s=ut(e,d);if(!s)return[];const l=Hi(e),h=[];return e.canStage&&h.push({key:"stage-file",label:o("rightSidebar.stageFile"),onClick:()=>{mt({action:"stage-file",cwd:s,paths:[e.path]},o("rightSidebar.stageFile"),l)}}),e.canUnstage&&h.push({key:"unstage-file",label:o("rightSidebar.unstageFile"),onClick:()=>{mt({action:"unstage-file",cwd:s,paths:[e.path]},o("rightSidebar.unstageFile"),l)}}),e.canStash&&h.push({key:"stash-file",label:o("rightSidebar.stashFile"),onClick:()=>{mt({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,mt,o]),Jf=n.useCallback(()=>{if(m){R?.();return}Tr(0),Lr.current?.slideTo(0),Ar(!1),Ut(null)},[R,m]),Kc=n.useCallback(e=>{if(he(""),Lt(e),tt(null),Ut(null),j(null),J){m&&R?.(),Tr(0),Lr.current?.slideTo(0),Ar(!1);return}},[J,R,m,tt,Lt]);n.useEffect(()=>{if(!G||U.getState().pendingTerminalPath!==G)return;U.setState({pendingTerminalPath:null}),(()=>{const s=G,l=s.path;if(!l.startsWith("/"))return;he(""),Ut(null),Et(null);const h=!!(d&&(l===d||l.startsWith(`${d}/`)));if(s.kind==="file"){const u=lo(l);Ms(l),typeof s.line=="number"&&Number.isSafeInteger(s.line)&&s.line>0&&Et(s.line),Lt(h?null:u),j({path:l,nonce:++F.current});return}tt(null),h?(Lt(null),j({path:l,nonce:++F.current})):(j(null),Lt(l)),J&&(m&&R?.(),Tr(0),Lr.current?.slideTo(0),Ar(!1))})()},[G,Ms,J,R,m,d,tt,Lt]),n.useEffect(()=>{r||(Bt(!1),Zt(!1))},[r]),n.useEffect(()=>{if(!wr&&!Zr)return;const e=s=>{s instanceof globalThis.KeyboardEvent&&s.key!=="Escape"||s instanceof globalThis.MouseEvent&&s.target instanceof Node&&(Ln.current?.contains(s.target)||kr.current?.contains(s.target))||(Bt(!1),Zt(!1))};return window.addEventListener("mousedown",e),window.addEventListener("keydown",e),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("keydown",e)}},[Zr,wr]);const Vc=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("button",{type:"button",onClick:ff,disabled:!_a,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.parentFolder"),title:o("rightSidebar.parentFolder"),children:t.jsx(al,{size:14})}),t.jsx("button",{type:"button",onClick:sc,disabled:!d||zn===d,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.backToProjectRoot"),title:o("rightSidebar.backToProjectRoot"),children:t.jsx(xd,{size:14})}),t.jsx("button",{type:"button",onClick:hf,disabled:!re,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.refreshFiles"),title:wl?o("rightSidebar.fileWatchUnavailable",{message:wl}):o("rightSidebar.refreshFiles"),children:t.jsx(uo,{size:13})}),t.jsx("div",{className:"min-w-0 flex-1 px-1",title:re??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:df}),Na==="modified"&&t.jsx("span",{className:"inline-flex shrink-0 text-primary",title:o("fileTree.sortedByModified"),"aria-label":o("fileTree.sortedByModified"),children:t.jsx(dd,{size:11})})]})}),t.jsx("button",{type:"button",onClick:e=>re&&qt(re,Ft??void 0,e.currentTarget),disabled:!re,...re&&Ft?ai($a(re),Ft):{},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 ${Ft&&(Oe===Ft||ye===Ft)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":o(Ft&&ye===Ft?"rightSidebar.copied":Ft&&Oe===Ft?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:o("rightSidebar.insertCurrentFolder"),children:Ft&&(Oe===Ft||ye===Ft)?t.jsx(go,{size:13}):t.jsx(bo,{size:13})}),t.jsx(Wp,{rootPath:re,disabled:!re||!Vu||Wo,pressed:Ca,saving:Wo,onToggle:()=>{if(!re||Wo)return;const e=re;_l(!0),qo(null),Yu(e,!Ca).catch(()=>{const s=U.getState();(s.explorerRoot??s.rootPath)===e&&qo(o("rightSidebar.gitIgnoreSaveFailed"))}).finally(()=>_l(!1))}}),t.jsxs("div",{ref:kr,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>{Bt(!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(po,{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),pf()},disabled:!li,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${Fs?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[Fs?t.jsx(Pi,{size:14}):t.jsx(ro,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(Fs?"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(Ap,{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:!re,onClick:()=>{re&&(Zt(!1),Ku(re,Na==="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:[Na==="modified"?t.jsx(Lh,{size:14}):t.jsx(dd,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(Na==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),Bl&&t.jsx("p",{role:"alert",className:"px-1 py-1 text-[11px] text-destructive",children:Bl}),d&&(Ba.length>0||uf)&&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:sc,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 ${re===d?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:d,children:[t.jsx(xd,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:Qe})]}),Ba.map(e=>{const s=e.path,l=e.kind==="file",h=l?et===s:re===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?Ms(s):Lt(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(qi,{size:10,className:"shrink-0"}):t.jsx(ro,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:gt(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:gt(s)}),title:o("rightSidebar.unpinFolder",{name:gt(s)}),children:t.jsx(Xt,{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(Un===null)return null;const e=typeof navigator>"u"?void 0:navigator.language,s=Math.max(0,Math.floor(($o-Un)/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,Un]),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",Yc=d&&!Qn?t.jsxs("button",{type:"button",role:"menuitemcheckbox",tabIndex:-1,onClick:()=>{Hf(!Ho)},"aria-checked":Ho,title:o("rightSidebar.multiRepoScanTitle"),className:eo,children:[t.jsx(br,{size:15,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"min-w-0 flex-1",children:o("rightSidebar.multiRepoScan")}),Ho&&t.jsx(go,{size:14,className:"shrink-0 text-primary"})]}):null,Xc=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:()=>{Jn()},disabled:fr,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(uo,{size:13,className:fr?"animate-spin":""})})]}):null,Qf=ql?o("rightSidebar.changeAuditScopeAll"):wn.length===1?wn[0].relativeRoot==="."?Qe:wn[0].relativeRoot||wn[0].name:`${wn.length} repos`,Zf=e=>d?t.jsxs("div",{role:"none",children:[t.jsx(qd,{menuItem:!0,open:gs,onOpenChange:s=>{rn(s),s&&e()},showScopePicker:Pn,selectedAll:ql,repos:Xu,selectedRoots:ar,onToggleRepo:Ef,onGenerate:async s=>{const l=await Cf("generate",s);return l!==!1&&e(),l},disabled:!d,inserted:Oe===nc,buttonLabel:o("rightSidebar.changeAuditShort"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:o("rightSidebar.insertChangeAuditPrompt"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Qf,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o("rightSidebar.changeAuditShort"),loading:Br,error:!!Pr,statusTitle:Pr??(Br?o("rightSidebar.changeAuditLoading"):xt.length>0?`${o("rightSidebar.changeAuditLoaded",{count:xt.length})}${qc?` · ${o("rightSidebar.changeAuditLoadedAt",{time:qc})}`:""}`:void 0)}),xt.length>0&&t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{e(),Nf()},disabled:Br||xt.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,os=or??(Ae?.available&&d&&Ee.size>0&&Be.length<=1?{root:d,label:Qe}:null),Jc=e=>t.jsxs(t.Fragment,{children:[os&&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",os.root,os.label)},disabled:!!$e,className:eo,children:[t.jsx(_h,{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",os.root,os.label)},disabled:!!$e,className:eo,children:[t.jsx(op,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stashAll")]})]}),os&&t.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Zf(e),Yc&&t.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Yc]}),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:[Ae?.available&&Ae.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:Ae.branch,children:[t.jsx(br,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:Ae.branch})]}),it.modified>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[it.modified,"M"]}),it.added>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",it.added]}),it.deleted>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",it.deleted]}),it.renamed>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[it.renamed,"R"]}),it.copied>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[it.copied,"C"]}),it.untracked>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[it.untracked,"U"]}),it.conflicted>0&&t.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[it.conflicted,"!"]}),it.other>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[it.other,"?"]}),it.staged>0&&t.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:o("rightSidebar.stagedCountShort",{count:it.staged})})]});return t.jsxs(lp,{side:"right",isOpen:r,drawerWidthPx:i,onClose:c,onOpen:f,push:p,pinned:g,children:[ai.popoverNode,t.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${nf?"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:Qe}),(!J||Mo)&&Ae?.available&&Ae.branch&&t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:Ae.branch,children:[t.jsx(br,{size:10,className:"shrink-0"}),t.jsx("span",{className:"max-w-[7rem] truncate",children:Ae.branch})]})]})}),t.jsx("button",{type:"button",onClick:()=>{const e=!ee;C(e),e?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):he("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${ee?"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(us,{size:14})}),t.jsxs("button",{type:"button",role:"switch","aria-checked":N,onClick:()=>{Q(e=>!e),Ye(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${N?"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(rp,{size:14}),!N&&kt.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:jl,type:"file",multiple:!0,className:"hidden",onChange:e=>{const s=e.target.files;!s||s.length===0||(Ls(Array.from(s)),e.target.value="")}}),t.jsx("input",{ref:Cl,type:"file",accept:"image/*",className:"hidden",onChange:e=>{const s=e.target.files?.[0];e.target.value="",s&&of(s,e.currentTarget.closest("[data-sidebar]")??void 0)}}),k&&t.jsx("button",{type:"button",onClick:k,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${g?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o(g?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:o(g?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:g?t.jsx(Pi,{size:14}):t.jsx(ro,{size:14})}),t.jsxs("div",{ref:Ln,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>{Zt(!1),Bt(e=>!e)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${wr?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":wr,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:t.jsx(po,{size:15})}),wr&&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:()=>af(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(pd,{size:14,className:"text-muted-foreground"}):t.jsx(ud,{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(fd,{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:()=>{Bt(!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(lt,{size:14,className:"animate-spin text-muted-foreground"}):t.jsx(cp,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o("rightSidebar.uploadFiles")})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Bt(!1),Cl.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(lt,{size:14,className:"animate-spin text-muted-foreground"}):t.jsx($p,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o("rightSidebar.insertLocalImage")})]}),k&&t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Bt(!1),k()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${g?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[g?t.jsx(Pi,{size:14}):t.jsx(ro,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(g?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),g&&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=L===e;return t.jsx("button",{type:"button",role:"menuitemradio","aria-checked":l,onClick:()=>{q(e),Bt(!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(Xt,{size:14})})]}),ee&&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(us,{size:12,className:"shrink-0"}),t.jsx("input",{"data-right-search":!0,type:"search",value:W,onChange:e=>he(e.target.value),placeholder:o(ne==="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 ${J?"text-[11px]":"text-[10px]"}`,children:[t.jsx("button",{type:"button",onClick:()=>Uc("name"),"aria-pressed":ne==="name",className:`rounded-full px-2 transition active:scale-95 ${J?"py-1":"py-0.5"} ${ne==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeName")}),t.jsx("button",{type:"button",onClick:()=>Uc("content"),"aria-pressed":ne==="content",className:`rounded-full px-2 transition active:scale-95 ${J?"py-1":"py-0.5"} ${ne==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeContent")})]}),W&&t.jsx("button",{type:"button",onClick:()=>he(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:t.jsx(Xt,{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(Ih,{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:Ne,onChange:e=>we(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}),Ne!=="."&&t.jsx("button",{type:"button",onClick:()=>we("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.resetSearchScope"),children:t.jsx(Xt,{size:11})})]}),t.jsxs("button",{type:"button",onClick:()=>oe(e=>!e),"aria-expanded":ue,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${ue||Es.length>0||Fe||E||ge?"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(np,{size:13}),Es.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:Es.length})]})]}),ue&&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:Pe,onChange:e=>O(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}),Pe&&t.jsx("button",{type:"button",onClick:()=>O(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.clearSearchExclude"),children:t.jsx(Xt,{size:11})})]}),ne==="content"&&t.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":o("rightSidebar.contentSearchOptions"),children:[[Fe,()=>Ie(e=>!e),Pp,o("rightSidebar.matchCase")],[E,()=>xe(e=>!e),Op,o("rightSidebar.matchWholeWord")],[ge,()=>De(e=>!e),Dp,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(${(Qn?1:3)+Number(sr.architecture)+Number(sr.computer)+Number(Wr)}, minmax(0, 1fr))`},children:[!Qn&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:e=>ts("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] ${jt==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(br,{size:12}),o("rightSidebar.tabGit")]}),t.jsxs("button",{type:"button",onClick:e=>ts("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] ${jt==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(lu,{size:12}),o("rightSidebar.tabChanges"),Ee.size>0?t.jsx("span",{className:"text-[10px] text-accent",children:Ee.size}):null]})]}),t.jsxs("button",{type:"button",onClick:e=>ts("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] ${jt==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(Gi,{size:12}),o("rightSidebar.tabFiles")]}),sr.architecture&&t.jsxs("button",{type:"button",onClick:e=>ts("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] ${kn?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(pd,{size:12}),o("architecture.tab")]}),sr.computer&&t.jsxs("button",{type:"button",onClick:e=>ts("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] ${es?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(ud,{size:12}),o("rightSidebar.tabComputer")]}),Wr&&t.jsxs("button",{type:"button",onClick:e=>ts("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] ${jt==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(fd,{size:12}),o("rightSidebar.tabAndroid")]})]}),t.jsx("div",{className:"h-2"}),xl&&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:xl})]}),t.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-surface",children:[t.jsx(is,{active:nt,mounted:nr,fallback:t.jsx(Oi,{slow:!1}),children:()=>Ge?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:t.jsx(jd,{items:Tf,diffViewType:Do,inlineMode:Ht,viewControls:g?Us():void 0,renderPathReference:(e,s)=>Wa(An(e,Ge.repoRoot??d),o(s==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle")),selectedKey:Fu,onSelect:fa,emptyText:o("rightSidebar.noChanges"),mobile:J,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o("rightSidebar.recentCommitsTitle"),headerMeta:`${Ge.headRef??""}${Ge.commits?.[0]?` · ${Ge.commits[0]}`:""}`,onClose:()=>{ot(null),fa(null)},closeLabel:o("common.back"),wrap:At,onToggleWrap:Xa,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:J?"stacked":"split",onInsertDiffReference:Fr,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onClearAuditRecord:Ka})}):Er?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:t.jsx(jd,{items:hi,diffViewType:Do,inlineMode:Ht,viewControls:g?Us():void 0,renderPathReference:(e,s)=>{const l=fe?.comparisonRepos,h=l&&l.length>1?[...l].sort((v,y)=>y.label.length-v.label.length).find(v=>e===v.label||e.startsWith(`${v.label}/`)):void 0,u=h?e===h.label?h.repoRoot:An(e.slice(h.label.length+1),h.repoRoot):An(e,zs?.repoRoot||d);return Wa(u,o(s==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle"))},selectedKey:Eo,onSelect:fn,emptyText:o(fe?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:J,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o(fe?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:zs?`${zs.repoLabel} · ${zs.branchName??"HEAD"} → ${zs.baseRef}`:void 0,onClose:()=>{++T.current,Te(!1),lr(!1),tr(null)},closeLabel:o("common.back"),wrap:At,onToggleWrap:Xa,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:J?"stacked":"split",onInsertDiffReference:Fr,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onClearAuditRecord:Ka,localOptions:fe?.comparisonRepos?.map(e=>({key:e.repoRoot,label:e.label,checked:e.includeUncommitted??fe.includeUncommitted??!1,disabled:!(e.canIncludeUncommitted??ss(e.repoRoot,e.head)),onChange:s=>{bi({refresh:!0,repoRoot:e.repoRoot,includeUncommitted:s})}})),onHunkGitAction:fe?.includeUncommitted?Of:void 0,error:ze,actionsBusy:ce>0,onRefresh:()=>{bi({refresh:!0})},refreshing:Je,refreshLabel:o("rightSidebar.branchAuditRefreshDiff"),refreshTitle:o("rightSidebar.branchAuditRefreshDiff"),walkthroughs:Mf,onWalkthroughNavigate:Lf,initialDetailScrollTop:fe&&qe?vs[qe]:void 0,onDetailScrollPositionChange:Bf,externalSwiperRef:J?Gl:void 0,onMobileSlideChange:J?To:void 0})}):t.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:nr&&d&&Nn?t.jsx("div",{className:"px-3",children:Yf()}):fr?t.jsx(Oi,{slow:Il}):xn?t.jsx(io,{message:xn,onRetry:()=>{Jn()}}):Jd(Ae)?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(d?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):Ae?.available===!1?t.jsx(io,{message:Ae.error??o("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{Jn()}}):d?t.jsx(Oi,{slow:Il}):t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(d?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),t.jsx(is,{active:Ir,mounted:_u||Ir,children:()=>J?t.jsxs(ip,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:e=>{Lr.current=e,e.slideTo(Ao,0)},onSlideChange:e=>{if(Tr(e.activeIndex),Ts.current===e.activeIndex){Ts.current=null;return}e.activeIndex===0&&(Ar(!1),Ut(null),R?.())},children:[t.jsx(md,{className:"h-full min-h-0",children:t.jsxs("div",{ref:qn,onScroll:Xl,onDragOver:La,onDragEnter:La,onDragLeave:Ql,onDrop:Zl,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[kl&&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()&&Vc,t.jsx(hd,{rootPath:re??"",onFileSelect:Ms,onPathReference:qt,getReferenceText:$a,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onDirectoryRoot:ac,onSearchFromDirectory:oc,onDirectoryPinToggle:ic,onFilePinToggle:lc,pinnedPaths:Rn,selectedFilePath:et,query:Ve,searchRootPath:Ul,searchOptions:Ol,searchMode:ne,onContentMatchSelect:ri,onDirectoryDropFiles:(e,s)=>Ls(s,e),revealDirectory:le,canOpenInFileBrowser:Sl,onOpenInFileBrowser:Jl})]})}),t.jsx(md,{className:"h-full min-h-0",children:t.jsx("div",{className:"h-full overflow-hidden bg-surface",children:t.jsx(yo,{filePath:Du||Ao===1?et:null,active:r&&Ir&&Ao===1,onInsertReference:qt,onInsertText:$r,onInsertFeature:Da,onReviewReference:Da,onReferenceCopied:mr,onClose:Jf,onDirectoryLinkOpen:Kc,isMobile:!0,lineRange:Dr,onLineRangeChange:Ut,insertedReferenceKey:Oe,copiedReferenceKey:ye,scrollToLine:He,onScrollToLineHandled:()=>Et(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:te,onOpenMarkdownOutline:M,onCloseMarkdownOutline:I,markdownImageLightboxOpen:H,markdownImageLightboxCloseSignal:Y,onOpenMarkdownImageLightbox:be,onCloseMarkdownImageLightbox:_})})})]}):t.jsxs("div",{className:"flex h-full min-h-0",children:[t.jsxs("div",{ref:qn,onScroll:Xl,onDragOver:La,onDragEnter:La,onDragLeave:Ql,onDrop:Zl,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:_o},children:[kl&&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()&&Vc,t.jsx(hd,{rootPath:re??"",onFileSelect:Ms,onPathReference:qt,getReferenceText:$a,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onDirectoryRoot:ac,onSearchFromDirectory:oc,onDirectoryPinToggle:ic,onFilePinToggle:lc,pinnedPaths:Rn,selectedFilePath:et,query:Ve,searchRootPath:Ul,searchOptions:Ol,searchMode:ne,onContentMatchSelect:ri,onDirectoryDropFiles:(e,s)=>Ls(s,e),revealDirectory:le,canOpenInFileBrowser:Sl,onOpenInFileBrowser:Jl})]}),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:Ju,onPointerMove:Qu,onPointerUp:Vl,onPointerCancel:Vl,onDoubleClick:()=>{Bo(el),Pt(ea,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:et,active:r&&Ir,onInsertReference:qt,onInsertText:$r,onInsertFeature:Da,onReviewReference:Da,onReferenceCopied:mr,onDirectoryLinkOpen:Kc,isMobile:!1,lineRange:Dr,onLineRangeChange:Ut,insertedReferenceKey:Oe,copiedReferenceKey:ye,scrollToLine:He,onScrollToLineHandled:()=>Et(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:te,onOpenMarkdownOutline:M,onCloseMarkdownOutline:I,markdownImageLightboxOpen:H,markdownImageLightboxCloseSignal:Y,onOpenMarkdownImageLightbox:be,onCloseMarkdownImageLightbox:_})})]})}),t.jsx(is,{active:Ct,mounted:Uu||Ct,children:()=>ei?t.jsx(sp,{}):J?t.jsx(Ki,{mobile:!0,backLabel:o("rightSidebar.backToChangeList"),externalSwiperRef:Qo,onMobileSlideChange:To,groups:Yt.length>0?Nc():[],mode:Cr,onModeChange:Ya,selectedKey:et,scrollToKey:Mc,scrollToKeyNonce:Sa.nonce,compact:!1,collapsedDirectoryKeys:oa,onToggleDirectory:$c,onSelectFile:e=>{const s=En.get(e.key);s&&Va(xr(s))},renderLeading:Pc,renderTrailing:e=>{const s=En.get(e.key);return s?jc(s):null},renderDirectoryTrailing:Cc,renderSubtitle:e=>{const s=En.get(e.key);return s?Rc(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:[Yt.length,"/",Ee.size]})]}),t.jsxs(Sd,{actions:Jc,children:[kc(),e,g&&Us(),Xc]},d),or&&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:or.label}),or.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:or.branch})]}),!or&&Pn&&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(br,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:Ha?(e=>Ic(e)):void 0,emptyContent:ei?null:xn&&Ee.size===0?t.jsx(io,{message:xn,onRetry:()=>{Jn()}}):Ee.size===0?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Yt.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(mo,{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:[g&&Us(),t.jsxs("button",{type:"button",onClick:Xa,"aria-pressed":At,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 ${At?"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(At?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),d&&t.jsx("button",{type:"button",onClick:()=>{Jn()},disabled:fr,"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(uo,{size:14,className:fr?"animate-spin":""})})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:Ec,activePane:Ct,wrap:At,diffViewType:Do,inlineMode:Ht,diffOptions:Bc,reloadKey:ca,renderStreamBadge:e=>t.jsx(na,{status:e}),onHunkGitAction:Oc,onInsertDiffReference:Fr,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onClearAuditRecord:Ka,onDetailScroll:qa}):t.jsx(Ki,{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:Yt.length>0?Nc():[],mode:Cr,onModeChange:Ya,selectedKey:et,scrollToKey:Mc,scrollToKeyNonce:Sa.nonce,compact:!0,collapsedDirectoryKeys:oa,onToggleDirectory:$c,onSelectFile:e=>{const s=En.get(e.key);s&&Va(xr(s))},renderLeading:Pc,renderTrailing:e=>{const s=En.get(e.key);return s?jc(s):null},renderDirectoryTrailing:Cc,renderSubtitle:e=>{const s=En.get(e.key);return s?Rc(s):null},aiContent:Ha?(e=>Ic(e)):void 0,emptyContent:ei?null:xn&&Ee.size===0?t.jsx(io,{message:xn,onRetry:()=>{Jn()}}):Ee.size===0?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Yt.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:[Yt.length,"/",Ee.size]})})]}),t.jsxs(Sd,{actions:Jc,children:[kc(),e,Us(),t.jsxs("button",{type:"button",onClick:Xa,"aria-pressed":At,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 ${At?"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(At?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),Xc]},d),or&&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:or.label}),or.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:or.branch})]}),!or&&Pn&&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(br,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),files:Ec,activePane:Ct,wrap:At,diffViewType:Ot,inlineMode:Ht,diffOptions:Bc,reloadKey:ca,renderStreamBadge:e=>t.jsx(na,{status:e}),onHunkGitAction:Oc,onInsertDiffReference:Fr,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye,onClearAuditRecord:Ka,onDetailScroll:qa})}),t.jsx(is,{active:kn,mounted:sr.architecture&&(tf||r&&kn),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(wg,{rootPath:d,active:r&&kn,onInsertPrompt:(e,s)=>$r(e,`architecture:${d}`,s),renderSource:e=>d&&t.jsx(ib,{rootPath:d,file:e,active:r&&kn,isMobile:J,onInsertReference:qt,onInsertText:$r,onReferenceCopied:mr,insertedReferenceKey:Oe,copiedReferenceKey:ye},`${e.path}:${e.line??1}`),onOpenFile:e=>{d&&(Mt("files"),Lt(null),ri(`${d.replace(/\/+$/,"")}/${e.path}`,e.line??1))}},d)})}),t.jsx(is,{active:r&&es,mounted:sr.computer&&(Zu||r&&es),children:t.jsx(n.Suspense,{fallback:t.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:o("computer.loading")}),children:t.jsx(kg,{active:r&&es})})}),t.jsx(is,{active:Zn,mounted:Io&&Wr,children:Ou?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),Zs({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:o("android.splitClose")})]}):t.jsx(xp,{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:cf,onRecordingComplete:lf})})]}),r&&wt&&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&&$t.task&&t.jsx(vm,{task:$t.task,onCancel:$t.cancel,onRetry:()=>{$t.retry()},onDismiss:$t.dismiss,labels:{uploading:o("rightSidebar.uploadPending"),inserting:o("rightSidebar.uploadInserting"),done:o($t.task.kind==="image"?"rightSidebar.uploadReferenceDone":"rightSidebar.uploadDone",{count:$t.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:$t.task.files.length})}}),r&&N&&t.jsx(pm,{value:kt,collapsed:ke,autoCollapseAfterSend:ht,focusRequest:Mn,insertError:In?o("rightSidebar.contextDraftInsertFailed"):null,onChange:e=>{en(!1),St(e)},onCollapsedChange:Ye,onAutoCollapseAfterSendChange:yr,onDisable:()=>Q(!1),onClear:()=>St(""),onInsert:e=>rc(!1,e),onInsertAndSend:e=>rc(!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})}}),kf(),pt&&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:pt.kind==="restore"?o("rightSidebar.confirmRestoreTitle"):o("rightSidebar.confirmStashAllTitle")}),t.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:pt.kind==="restore"?o("rightSidebar.confirmRestoreDescription",{path:ru(pt.file.absolutePath,d)}):o("rightSidebar.confirmStashAllDescription")}),pt.kind==="restore"&&t.jsx("input",{value:pt.phrase,onChange:e=>hn({...pt,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:!!$e||pt.kind==="restore"&&pt.phrase.trim()!==o("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(pt.kind==="restore"){const e=ut(pt.file,d);if(!e)return;mt({action:"restore-worktree-file",cwd:e,paths:[pt.file.path],confirm:{acknowledged:!0,phrase:pt.phrase}},o("rightSidebar.restoreFile"),Hi(pt.file))}else{const e=pt.repoRoot??d;if(!e)return;mt({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 ${pt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:o($e?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const Ab=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:yo,MarkdownImageLightbox:Hh,MarkdownPreview:nu,RightSidebar:lb,__testParseMarkdownListBlock:zh,buildMarkdownPreviewBlocks:Gh,buildMarkdownPreviewRenderResult:Wh,collectKnownGitRepoRoots:Cu,computeMarkdownImageDisplayBox:qh,getMarkdownHeadingOutline:Kh,getMarkdownHeadingPathAtLine:Vh,getNextMarkdownPreviewLineRange:Gg,isSvgImageSrc:Yh,mountRightSidebarRepoPickerOverlay:bu,replaceGitRepositorySnapshot:Iu,resolveMarkdownLocalLinkTarget:Xh,resolveRightSidebarDiffViewType:Ru,shouldCloseMarkdownImageLightboxDrag:Jh,showsGitRepoGroupHeader:tl},Symbol.toStringTag,{value:"Module"}));export{Yi as E,Ab as R,Bp as S,Ap as a,qp as c,Eb as m};
|