termdock 1.4.178 → 1.4.179

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.
Files changed (333) hide show
  1. package/dist/client/assets/App-DXq9kwY5.js +150 -0
  2. package/dist/client/assets/App-DXq9kwY5.js.br +0 -0
  3. package/dist/client/assets/App-DXq9kwY5.js.gz +0 -0
  4. package/dist/client/assets/{ChangeWalkthroughPanel-BNWqAnqc.js → ChangeWalkthroughPanel-DWUBYx6Q.js} +2 -2
  5. package/dist/client/assets/ChangeWalkthroughPanel-DWUBYx6Q.js.br +0 -0
  6. package/dist/client/assets/ChangeWalkthroughPanel-DWUBYx6Q.js.gz +0 -0
  7. package/dist/client/assets/{DagPlayground-IlTGwr-I.js → DagPlayground-DyczrcHM.js} +1 -1
  8. package/dist/client/assets/DagPlayground-DyczrcHM.js.br +0 -0
  9. package/dist/client/assets/DagPlayground-DyczrcHM.js.gz +0 -0
  10. package/dist/client/assets/{DiffLab-CwhNpJvo.js → DiffLab-D5wb-H7y.js} +1 -1
  11. package/dist/client/assets/DiffLab-D5wb-H7y.js.br +0 -0
  12. package/dist/client/assets/DiffLab-D5wb-H7y.js.gz +0 -0
  13. package/dist/client/assets/{DiffReview-DyhINv0F.js → DiffReview-CVIz-B5T.js} +1 -1
  14. package/dist/client/assets/DiffReview-CVIz-B5T.js.br +0 -0
  15. package/dist/client/assets/DiffReview-CVIz-B5T.js.gz +0 -0
  16. package/dist/client/assets/{DiffReviewLab-D9Kt5VwB.js → DiffReviewLab-99hTNRaj.js} +1 -1
  17. package/dist/client/assets/DiffReviewLab-99hTNRaj.js.br +0 -0
  18. package/dist/client/assets/DiffReviewLab-99hTNRaj.js.gz +0 -0
  19. package/dist/client/assets/{DiffViewer-3zz2PI-8.js → DiffViewer-BPor2_7o.js} +1 -1
  20. package/dist/client/assets/DiffViewer-BPor2_7o.js.br +0 -0
  21. package/dist/client/assets/DiffViewer-BPor2_7o.js.gz +0 -0
  22. package/dist/client/assets/{ModelPreview-CN8xsiGC.js → ModelPreview-DpImj4vY.js} +1 -1
  23. package/dist/client/assets/ModelPreview-DpImj4vY.js.br +0 -0
  24. package/dist/client/assets/ModelPreview-DpImj4vY.js.gz +0 -0
  25. package/dist/client/assets/RightSidebar-BW8SSsoA.js +79 -0
  26. package/dist/client/assets/RightSidebar-BW8SSsoA.js.br +0 -0
  27. package/dist/client/assets/RightSidebar-BW8SSsoA.js.gz +0 -0
  28. package/dist/client/assets/{abnfDiagram-VCTEODGH-DkdoJ2ZH.js → abnfDiagram-VCTEODGH-CNWmFVMh.js} +1 -1
  29. package/dist/client/assets/abnfDiagram-VCTEODGH-CNWmFVMh.js.br +0 -0
  30. package/dist/client/assets/abnfDiagram-VCTEODGH-CNWmFVMh.js.gz +0 -0
  31. package/dist/client/assets/app-Pl7tV8Be.js +34 -0
  32. package/dist/client/assets/app-Pl7tV8Be.js.br +0 -0
  33. package/dist/client/assets/app-Pl7tV8Be.js.gz +0 -0
  34. package/dist/client/assets/{arc-ctzz5PcK.js → arc-Z8mcHjh7.js} +1 -1
  35. package/dist/client/assets/arc-Z8mcHjh7.js.br +0 -0
  36. package/dist/client/assets/arc-Z8mcHjh7.js.gz +0 -0
  37. package/dist/client/assets/{architectureDiagram-5GKGNRK7-DNLcYfGQ.js → architectureDiagram-5GKGNRK7-DuxbAeFP.js} +1 -1
  38. package/dist/client/assets/architectureDiagram-5GKGNRK7-DuxbAeFP.js.br +0 -0
  39. package/dist/client/assets/architectureDiagram-5GKGNRK7-DuxbAeFP.js.gz +0 -0
  40. package/dist/client/assets/{blockDiagram-I7D4REHJ-Coye1ou5.js → blockDiagram-I7D4REHJ-SxAFw0An.js} +1 -1
  41. package/dist/client/assets/blockDiagram-I7D4REHJ-SxAFw0An.js.br +0 -0
  42. package/dist/client/assets/blockDiagram-I7D4REHJ-SxAFw0An.js.gz +0 -0
  43. package/dist/client/assets/{c4Diagram-7LVT6UL2-DTa8jyPp.js → c4Diagram-7LVT6UL2-CcRdiWo7.js} +1 -1
  44. package/dist/client/assets/{c4Diagram-7LVT6UL2-DTa8jyPp.js.br → c4Diagram-7LVT6UL2-CcRdiWo7.js.br} +0 -0
  45. package/dist/client/assets/c4Diagram-7LVT6UL2-CcRdiWo7.js.gz +0 -0
  46. package/dist/client/assets/channel-nXn0ntBk.js +1 -0
  47. package/dist/client/assets/{chunk-2Q5K7J3B-BpDyjNfs.js → chunk-2Q5K7J3B-DJ_qzvZZ.js} +1 -1
  48. package/dist/client/assets/{chunk-5VM5RSS4-DgwdqXKl.js → chunk-5VM5RSS4-l3H0C2ci.js} +1 -1
  49. package/dist/client/assets/{chunk-F27PBJKO-DWf2gZ96.js → chunk-F27PBJKO-B7xASv8n.js} +1 -1
  50. package/dist/client/assets/chunk-F27PBJKO-B7xASv8n.js.br +0 -0
  51. package/dist/client/assets/chunk-F27PBJKO-B7xASv8n.js.gz +0 -0
  52. package/dist/client/assets/{chunk-IMKFNOWR-l42o_E2c.js → chunk-IMKFNOWR-Wg5gR7sZ.js} +1 -1
  53. package/dist/client/assets/chunk-IMKFNOWR-Wg5gR7sZ.js.br +0 -0
  54. package/dist/client/assets/chunk-IMKFNOWR-Wg5gR7sZ.js.gz +0 -0
  55. package/dist/client/assets/{chunk-JWPE2WC7-8CkEf05l.js → chunk-JWPE2WC7-BlXUS79m.js} +1 -1
  56. package/dist/client/assets/{chunk-POPQ4Y6H-BKKOfbdg.js → chunk-POPQ4Y6H-CU38G8hb.js} +1 -1
  57. package/dist/client/assets/{chunk-SVP7TREG-RORrf2aM.js → chunk-SVP7TREG-D-yZlXqX.js} +1 -1
  58. package/dist/client/assets/chunk-SVP7TREG-D-yZlXqX.js.br +0 -0
  59. package/dist/client/assets/chunk-SVP7TREG-D-yZlXqX.js.gz +0 -0
  60. package/dist/client/assets/{chunk-TICWLB2K-hPqafEtC.js → chunk-TICWLB2K-DrOYmcBB.js} +1 -1
  61. package/dist/client/assets/{chunk-TICWLB2K-hPqafEtC.js.br → chunk-TICWLB2K-DrOYmcBB.js.br} +0 -0
  62. package/dist/client/assets/chunk-TICWLB2K-DrOYmcBB.js.gz +0 -0
  63. package/dist/client/assets/{chunk-XXDRQBXY-CrvjJwms.js → chunk-XXDRQBXY-BbsHtVFa.js} +1 -1
  64. package/dist/client/assets/classDiagram-ZZMXUADV-DxqN38m7.js +1 -0
  65. package/dist/client/assets/classDiagram-v2-VYDZK3BY-DxqN38m7.js +1 -0
  66. package/dist/client/assets/{cose-bilkent-JH36ORCC-CwRSiQLa.js → cose-bilkent-JH36ORCC-_wKUNL8T.js} +1 -1
  67. package/dist/client/assets/cose-bilkent-JH36ORCC-_wKUNL8T.js.br +0 -0
  68. package/dist/client/assets/cose-bilkent-JH36ORCC-_wKUNL8T.js.gz +0 -0
  69. package/dist/client/assets/{cynefin-OW5HDTMX-CXnppZ8I.js → cynefin-OW5HDTMX-CPr--Wnc.js} +1 -1
  70. package/dist/client/assets/cynefin-OW5HDTMX-CPr--Wnc.js.br +0 -0
  71. package/dist/client/assets/cynefin-OW5HDTMX-CPr--Wnc.js.gz +0 -0
  72. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-BSDrHSIA.js → cynefinDiagram-5FMLGOSQ-5ygpPOWT.js} +1 -1
  73. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-5ygpPOWT.js.br +0 -0
  74. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-5ygpPOWT.js.gz +0 -0
  75. package/dist/client/assets/{dagre-GXQ25YYZ-d-5j4vkq.js → dagre-GXQ25YYZ-Cvx65nHO.js} +1 -1
  76. package/dist/client/assets/dagre-GXQ25YYZ-Cvx65nHO.js.br +0 -0
  77. package/dist/client/assets/dagre-GXQ25YYZ-Cvx65nHO.js.gz +0 -0
  78. package/dist/client/assets/{diagram-S7CK7UJ4-DizMBpGW.js → diagram-S7CK7UJ4-Dw5cp_BA.js} +1 -1
  79. package/dist/client/assets/diagram-S7CK7UJ4-Dw5cp_BA.js.br +0 -0
  80. package/dist/client/assets/diagram-S7CK7UJ4-Dw5cp_BA.js.gz +0 -0
  81. package/dist/client/assets/{diagram-UQ7AKVKN-CNQK26rH.js → diagram-UQ7AKVKN-D8BZ5Tp3.js} +1 -1
  82. package/dist/client/assets/diagram-UQ7AKVKN-D8BZ5Tp3.js.br +0 -0
  83. package/dist/client/assets/diagram-UQ7AKVKN-D8BZ5Tp3.js.gz +0 -0
  84. package/dist/client/assets/{diagram-VSXAHHWV-Dua-2_46.js → diagram-VSXAHHWV-BxJD7ZWH.js} +1 -1
  85. package/dist/client/assets/diagram-VSXAHHWV-BxJD7ZWH.js.br +0 -0
  86. package/dist/client/assets/diagram-VSXAHHWV-BxJD7ZWH.js.gz +0 -0
  87. package/dist/client/assets/{diagram-VX7I27RA-CIq-4729.js → diagram-VX7I27RA-CvzlU0bI.js} +1 -1
  88. package/dist/client/assets/diagram-VX7I27RA-CvzlU0bI.js.br +0 -0
  89. package/dist/client/assets/diagram-VX7I27RA-CvzlU0bI.js.gz +0 -0
  90. package/dist/client/assets/{diagram-Z3DM3KII-BukQ0u-x.js → diagram-Z3DM3KII-Be4HdFlL.js} +1 -1
  91. package/dist/client/assets/diagram-Z3DM3KII-Be4HdFlL.js.br +0 -0
  92. package/dist/client/assets/diagram-Z3DM3KII-Be4HdFlL.js.gz +0 -0
  93. package/dist/client/assets/{ebnfDiagram-PWID7BFC-D2zRkRBI.js → ebnfDiagram-PWID7BFC-C_wrrPjF.js} +1 -1
  94. package/dist/client/assets/ebnfDiagram-PWID7BFC-C_wrrPjF.js.br +0 -0
  95. package/dist/client/assets/ebnfDiagram-PWID7BFC-C_wrrPjF.js.gz +0 -0
  96. package/dist/client/assets/{erDiagram-RLTQ6QDP-DbX6A3ls.js → erDiagram-RLTQ6QDP-IHyLgV6M.js} +1 -1
  97. package/dist/client/assets/erDiagram-RLTQ6QDP-IHyLgV6M.js.br +0 -0
  98. package/dist/client/assets/erDiagram-RLTQ6QDP-IHyLgV6M.js.gz +0 -0
  99. package/dist/client/assets/{flowDiagram-HODETNUW-YECDWA2G.js → flowDiagram-HODETNUW-CpfW88Uc.js} +1 -1
  100. package/dist/client/assets/flowDiagram-HODETNUW-CpfW88Uc.js.br +0 -0
  101. package/dist/client/assets/flowDiagram-HODETNUW-CpfW88Uc.js.gz +0 -0
  102. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-D3EJdUov.js → ganttDiagram-EL5Y4UJY-CsbQ6KLb.js} +1 -1
  103. package/dist/client/assets/ganttDiagram-EL5Y4UJY-CsbQ6KLb.js.br +0 -0
  104. package/dist/client/assets/ganttDiagram-EL5Y4UJY-CsbQ6KLb.js.gz +0 -0
  105. package/dist/client/assets/{gestureArbiter-D3IZpZS7.js → gestureArbiter-CJQ8K48V.js} +1 -1
  106. package/dist/client/assets/gestureArbiter-CJQ8K48V.js.br +0 -0
  107. package/dist/client/assets/gestureArbiter-CJQ8K48V.js.gz +0 -0
  108. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-tr_HKoQK.js → gitGraphDiagram-WWUBYQGX-DJZqSGtH.js} +1 -1
  109. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DJZqSGtH.js.br +0 -0
  110. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DJZqSGtH.js.gz +0 -0
  111. package/dist/client/assets/{index-C4Ny0NDQ.css → index-PWu1VEN_.css} +1 -1
  112. package/dist/client/assets/index-PWu1VEN_.css.br +0 -0
  113. package/dist/client/assets/index-PWu1VEN_.css.gz +0 -0
  114. package/dist/client/assets/{infoDiagram-27XIBGKW-xBV63YYg.js → infoDiagram-27XIBGKW-D6sSgR2Y.js} +1 -1
  115. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-BrYSZu1R.js → ishikawaDiagram-5VMMS53U-BJJSUXep.js} +1 -1
  116. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BJJSUXep.js.br +0 -0
  117. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BJJSUXep.js.gz +0 -0
  118. package/dist/client/assets/{journeyDiagram-3NMN7TZE-C9Ft--aA.js → journeyDiagram-3NMN7TZE-ou1XS2DP.js} +1 -1
  119. package/dist/client/assets/journeyDiagram-3NMN7TZE-ou1XS2DP.js.br +0 -0
  120. package/dist/client/assets/journeyDiagram-3NMN7TZE-ou1XS2DP.js.gz +0 -0
  121. package/dist/client/assets/{kanban-definition-UXKFOSKX-FCxqSu11.js → kanban-definition-UXKFOSKX-BFQGYQzd.js} +1 -1
  122. package/dist/client/assets/kanban-definition-UXKFOSKX-BFQGYQzd.js.br +0 -0
  123. package/dist/client/assets/kanban-definition-UXKFOSKX-BFQGYQzd.js.gz +0 -0
  124. package/dist/client/assets/{layout-BqjIyPqO.js → layout-zUU3xcam.js} +1 -1
  125. package/dist/client/assets/layout-zUU3xcam.js.br +0 -0
  126. package/dist/client/assets/layout-zUU3xcam.js.gz +0 -0
  127. package/dist/client/assets/{linear-CEAGQX5N.js → linear-CYwYQI2I.js} +1 -1
  128. package/dist/client/assets/linear-CYwYQI2I.js.br +0 -0
  129. package/dist/client/assets/linear-CYwYQI2I.js.gz +0 -0
  130. package/dist/client/assets/{mermaid.core-DvAY78t_.js → mermaid.core-91Llsw5j.js} +5 -5
  131. package/dist/client/assets/mermaid.core-91Llsw5j.js.br +0 -0
  132. package/dist/client/assets/mermaid.core-91Llsw5j.js.gz +0 -0
  133. package/dist/client/assets/{mindmap-definition-YA3MSWOX-D7_qIQ9H.js → mindmap-definition-YA3MSWOX-RWG074lb.js} +1 -1
  134. package/dist/client/assets/mindmap-definition-YA3MSWOX-RWG074lb.js.br +0 -0
  135. package/dist/client/assets/mindmap-definition-YA3MSWOX-RWG074lb.js.gz +0 -0
  136. package/dist/client/assets/{passwordBootstrap-Dksfdvk3.js → passwordBootstrap-DRknuNUN.js} +1 -1
  137. package/dist/client/assets/passwordBootstrap-DRknuNUN.js.br +0 -0
  138. package/dist/client/assets/passwordBootstrap-DRknuNUN.js.gz +0 -0
  139. package/dist/client/assets/{pegDiagram-XKGWAZYB-DeTIBKGC.js → pegDiagram-XKGWAZYB-Dyh2rzGS.js} +1 -1
  140. package/dist/client/assets/pegDiagram-XKGWAZYB-Dyh2rzGS.js.br +0 -0
  141. package/dist/client/assets/pegDiagram-XKGWAZYB-Dyh2rzGS.js.gz +0 -0
  142. package/dist/client/assets/{pieDiagram-E7YTZNPT-z5IcoVwx.js → pieDiagram-E7YTZNPT-CL3UcUfh.js} +1 -1
  143. package/dist/client/assets/pieDiagram-E7YTZNPT-CL3UcUfh.js.br +0 -0
  144. package/dist/client/assets/pieDiagram-E7YTZNPT-CL3UcUfh.js.gz +0 -0
  145. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-B-zCZvES.js → quadrantDiagram-AXDQQJYC-DOkejMel.js} +1 -1
  146. package/dist/client/assets/quadrantDiagram-AXDQQJYC-DOkejMel.js.br +0 -0
  147. package/dist/client/assets/quadrantDiagram-AXDQQJYC-DOkejMel.js.gz +0 -0
  148. package/dist/client/assets/{railroadDiagram-O6MQD6OU-DbpeB7P2.js → railroadDiagram-O6MQD6OU-BC780Uh3.js} +1 -1
  149. package/dist/client/assets/railroadDiagram-O6MQD6OU-BC780Uh3.js.br +0 -0
  150. package/dist/client/assets/railroadDiagram-O6MQD6OU-BC780Uh3.js.gz +0 -0
  151. package/dist/client/assets/{referenceLongPress-p56g9xFb.js → referenceLongPress-Dlc0425_.js} +1 -1
  152. package/dist/client/assets/referenceLongPress-Dlc0425_.js.br +0 -0
  153. package/dist/client/assets/referenceLongPress-Dlc0425_.js.gz +0 -0
  154. package/dist/client/assets/{requirementDiagram-BXWQKSXE-UhJYMJ_U.js → requirementDiagram-BXWQKSXE-CwCGr0qR.js} +1 -1
  155. package/dist/client/assets/requirementDiagram-BXWQKSXE-CwCGr0qR.js.br +0 -0
  156. package/dist/client/assets/requirementDiagram-BXWQKSXE-CwCGr0qR.js.gz +0 -0
  157. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-xKsuFR17.js → sankeyDiagram-P5KCCOFB-CYDYBwJQ.js} +1 -1
  158. package/dist/client/assets/sankeyDiagram-P5KCCOFB-CYDYBwJQ.js.br +0 -0
  159. package/dist/client/assets/sankeyDiagram-P5KCCOFB-CYDYBwJQ.js.gz +0 -0
  160. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-DrjBl65C.js → sequenceDiagram-WJ2MYXX4-DhHsZi3K.js} +1 -1
  161. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DhHsZi3K.js.br +0 -0
  162. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DhHsZi3K.js.gz +0 -0
  163. package/dist/client/assets/{sizeCapture-INFHLROL-BIlGJ9tm.js → sizeCapture-INFHLROL-4oUXWvYA.js} +1 -1
  164. package/dist/client/assets/sizeCapture-INFHLROL-4oUXWvYA.js.br +0 -0
  165. package/dist/client/assets/sizeCapture-INFHLROL-4oUXWvYA.js.gz +0 -0
  166. package/dist/client/assets/{sparkles-B-uEi0Pa.js → sparkles-gqiuBkfP.js} +1 -1
  167. package/dist/client/assets/{stateDiagram-D77RDMKH-C3k9XvA6.js → stateDiagram-D77RDMKH-7hUELZGo.js} +1 -1
  168. package/dist/client/assets/stateDiagram-D77RDMKH-7hUELZGo.js.br +0 -0
  169. package/dist/client/assets/stateDiagram-D77RDMKH-7hUELZGo.js.gz +0 -0
  170. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-MO84Jqt6.js +1 -0
  171. package/dist/client/assets/{swimlanes-42K2YHIH-BN-x1rXp.js → swimlanes-42K2YHIH-E1qoordP.js} +1 -1
  172. package/dist/client/assets/swimlanes-42K2YHIH-E1qoordP.js.br +0 -0
  173. package/dist/client/assets/swimlanes-42K2YHIH-E1qoordP.js.gz +0 -0
  174. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-DnSXMnZQ.js +8 -0
  175. package/dist/client/assets/{timeline-definition-24CTP7MA-Dcedjtic.js → timeline-definition-24CTP7MA-CTYyCnUW.js} +1 -1
  176. package/dist/client/assets/timeline-definition-24CTP7MA-CTYyCnUW.js.br +0 -0
  177. package/dist/client/assets/timeline-definition-24CTP7MA-CTYyCnUW.js.gz +0 -0
  178. package/dist/client/assets/{triangle-alert-BSNAwyll.js → triangle-alert-DrBuMUPw.js} +1 -1
  179. package/dist/client/assets/{vennDiagram-4TSXK5OY-DAIk-5Rt.js → vennDiagram-4TSXK5OY-DVWbhWsS.js} +1 -1
  180. package/dist/client/assets/vennDiagram-4TSXK5OY-DVWbhWsS.js.br +0 -0
  181. package/dist/client/assets/vennDiagram-4TSXK5OY-DVWbhWsS.js.gz +0 -0
  182. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-3iXOTpAg.js → wardleyDiagram-VM6X3IG4-BFAwOxhc.js} +1 -1
  183. package/dist/client/assets/wardleyDiagram-VM6X3IG4-BFAwOxhc.js.br +0 -0
  184. package/dist/client/assets/wardleyDiagram-VM6X3IG4-BFAwOxhc.js.gz +0 -0
  185. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-OD1a_9Qg.js → xychartDiagram-S5SC5T6Z-DYXOiBiX.js} +1 -1
  186. package/dist/client/assets/xychartDiagram-S5SC5T6Z-DYXOiBiX.js.br +0 -0
  187. package/dist/client/assets/xychartDiagram-S5SC5T6Z-DYXOiBiX.js.gz +0 -0
  188. package/dist/client/index.html +2 -2
  189. package/dist/client/index.html.br +0 -0
  190. package/dist/client/index.html.gz +0 -0
  191. package/dist/client/sw-notifications.js +5 -45
  192. package/dist/client/sw-notifications.js.br +0 -0
  193. package/dist/client/sw-notifications.js.gz +0 -0
  194. package/dist/client/sw.js +1 -1
  195. package/dist/client/sw.js.br +0 -0
  196. package/dist/client/sw.js.gz +0 -0
  197. package/dist/server/agent/collaborationCli.js +10 -3
  198. package/dist/server/agent/collaborationDeliveryWorker.js +154 -0
  199. package/dist/server/agent/collaborationRoutes.js +15 -4
  200. package/dist/server/agent/collaborationRouting.js +94 -0
  201. package/dist/server/agent/collaborationStore.js +6 -1
  202. package/dist/server/agent/collaborationTmuxDelivery.js +10 -0
  203. package/dist/server/agent/sessionBindingRecovery.js +59 -0
  204. package/dist/server/entry.js +30 -13
  205. package/dist/server/federation/desktopTargets.js +64 -0
  206. package/dist/server/federation/directRoutes.js +27 -19
  207. package/dist/server/federation/routeAccess.js +14 -7
  208. package/dist/server/federation/trustedCa.js +55 -0
  209. package/dist/server/routes/terminal.js +242 -67
  210. package/package.json +1 -1
  211. package/runtime-manifest.json +3 -3
  212. package/dist/client/assets/App-CAEtVL8Z.js +0 -150
  213. package/dist/client/assets/App-CAEtVL8Z.js.br +0 -0
  214. package/dist/client/assets/App-CAEtVL8Z.js.gz +0 -0
  215. package/dist/client/assets/ChangeWalkthroughPanel-BNWqAnqc.js.br +0 -0
  216. package/dist/client/assets/ChangeWalkthroughPanel-BNWqAnqc.js.gz +0 -0
  217. package/dist/client/assets/DagPlayground-IlTGwr-I.js.br +0 -0
  218. package/dist/client/assets/DagPlayground-IlTGwr-I.js.gz +0 -0
  219. package/dist/client/assets/DiffLab-CwhNpJvo.js.br +0 -0
  220. package/dist/client/assets/DiffLab-CwhNpJvo.js.gz +0 -0
  221. package/dist/client/assets/DiffReview-DyhINv0F.js.br +0 -0
  222. package/dist/client/assets/DiffReview-DyhINv0F.js.gz +0 -0
  223. package/dist/client/assets/DiffReviewLab-D9Kt5VwB.js.br +0 -0
  224. package/dist/client/assets/DiffReviewLab-D9Kt5VwB.js.gz +0 -0
  225. package/dist/client/assets/DiffViewer-3zz2PI-8.js.br +0 -0
  226. package/dist/client/assets/DiffViewer-3zz2PI-8.js.gz +0 -0
  227. package/dist/client/assets/ModelPreview-CN8xsiGC.js.br +0 -0
  228. package/dist/client/assets/ModelPreview-CN8xsiGC.js.gz +0 -0
  229. package/dist/client/assets/RightSidebar-DQk1cwKH.js +0 -79
  230. package/dist/client/assets/RightSidebar-DQk1cwKH.js.br +0 -0
  231. package/dist/client/assets/RightSidebar-DQk1cwKH.js.gz +0 -0
  232. package/dist/client/assets/abnfDiagram-VCTEODGH-DkdoJ2ZH.js.br +0 -0
  233. package/dist/client/assets/abnfDiagram-VCTEODGH-DkdoJ2ZH.js.gz +0 -0
  234. package/dist/client/assets/app-B42CoF1r.js +0 -34
  235. package/dist/client/assets/app-B42CoF1r.js.br +0 -0
  236. package/dist/client/assets/app-B42CoF1r.js.gz +0 -0
  237. package/dist/client/assets/arc-ctzz5PcK.js.br +0 -0
  238. package/dist/client/assets/arc-ctzz5PcK.js.gz +0 -0
  239. package/dist/client/assets/architectureDiagram-5GKGNRK7-DNLcYfGQ.js.br +0 -0
  240. package/dist/client/assets/architectureDiagram-5GKGNRK7-DNLcYfGQ.js.gz +0 -0
  241. package/dist/client/assets/blockDiagram-I7D4REHJ-Coye1ou5.js.br +0 -0
  242. package/dist/client/assets/blockDiagram-I7D4REHJ-Coye1ou5.js.gz +0 -0
  243. package/dist/client/assets/c4Diagram-7LVT6UL2-DTa8jyPp.js.gz +0 -0
  244. package/dist/client/assets/channel-CzvSDv06.js +0 -1
  245. package/dist/client/assets/chunk-F27PBJKO-DWf2gZ96.js.br +0 -0
  246. package/dist/client/assets/chunk-F27PBJKO-DWf2gZ96.js.gz +0 -0
  247. package/dist/client/assets/chunk-IMKFNOWR-l42o_E2c.js.br +0 -0
  248. package/dist/client/assets/chunk-IMKFNOWR-l42o_E2c.js.gz +0 -0
  249. package/dist/client/assets/chunk-SVP7TREG-RORrf2aM.js.br +0 -0
  250. package/dist/client/assets/chunk-SVP7TREG-RORrf2aM.js.gz +0 -0
  251. package/dist/client/assets/chunk-TICWLB2K-hPqafEtC.js.gz +0 -0
  252. package/dist/client/assets/classDiagram-ZZMXUADV-CDknJfE0.js +0 -1
  253. package/dist/client/assets/classDiagram-v2-VYDZK3BY-CDknJfE0.js +0 -1
  254. package/dist/client/assets/cose-bilkent-JH36ORCC-CwRSiQLa.js.br +0 -0
  255. package/dist/client/assets/cose-bilkent-JH36ORCC-CwRSiQLa.js.gz +0 -0
  256. package/dist/client/assets/cynefin-OW5HDTMX-CXnppZ8I.js.br +0 -0
  257. package/dist/client/assets/cynefin-OW5HDTMX-CXnppZ8I.js.gz +0 -0
  258. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-BSDrHSIA.js.br +0 -0
  259. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-BSDrHSIA.js.gz +0 -0
  260. package/dist/client/assets/dagre-GXQ25YYZ-d-5j4vkq.js.br +0 -0
  261. package/dist/client/assets/dagre-GXQ25YYZ-d-5j4vkq.js.gz +0 -0
  262. package/dist/client/assets/diagram-S7CK7UJ4-DizMBpGW.js.br +0 -0
  263. package/dist/client/assets/diagram-S7CK7UJ4-DizMBpGW.js.gz +0 -0
  264. package/dist/client/assets/diagram-UQ7AKVKN-CNQK26rH.js.br +0 -0
  265. package/dist/client/assets/diagram-UQ7AKVKN-CNQK26rH.js.gz +0 -0
  266. package/dist/client/assets/diagram-VSXAHHWV-Dua-2_46.js.br +0 -0
  267. package/dist/client/assets/diagram-VSXAHHWV-Dua-2_46.js.gz +0 -0
  268. package/dist/client/assets/diagram-VX7I27RA-CIq-4729.js.br +0 -0
  269. package/dist/client/assets/diagram-VX7I27RA-CIq-4729.js.gz +0 -0
  270. package/dist/client/assets/diagram-Z3DM3KII-BukQ0u-x.js.br +0 -0
  271. package/dist/client/assets/diagram-Z3DM3KII-BukQ0u-x.js.gz +0 -0
  272. package/dist/client/assets/ebnfDiagram-PWID7BFC-D2zRkRBI.js.br +0 -0
  273. package/dist/client/assets/ebnfDiagram-PWID7BFC-D2zRkRBI.js.gz +0 -0
  274. package/dist/client/assets/erDiagram-RLTQ6QDP-DbX6A3ls.js.br +0 -0
  275. package/dist/client/assets/erDiagram-RLTQ6QDP-DbX6A3ls.js.gz +0 -0
  276. package/dist/client/assets/flowDiagram-HODETNUW-YECDWA2G.js.br +0 -0
  277. package/dist/client/assets/flowDiagram-HODETNUW-YECDWA2G.js.gz +0 -0
  278. package/dist/client/assets/ganttDiagram-EL5Y4UJY-D3EJdUov.js.br +0 -0
  279. package/dist/client/assets/ganttDiagram-EL5Y4UJY-D3EJdUov.js.gz +0 -0
  280. package/dist/client/assets/gestureArbiter-D3IZpZS7.js.br +0 -0
  281. package/dist/client/assets/gestureArbiter-D3IZpZS7.js.gz +0 -0
  282. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-tr_HKoQK.js.br +0 -0
  283. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-tr_HKoQK.js.gz +0 -0
  284. package/dist/client/assets/index-C4Ny0NDQ.css.br +0 -0
  285. package/dist/client/assets/index-C4Ny0NDQ.css.gz +0 -0
  286. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BrYSZu1R.js.br +0 -0
  287. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BrYSZu1R.js.gz +0 -0
  288. package/dist/client/assets/journeyDiagram-3NMN7TZE-C9Ft--aA.js.br +0 -0
  289. package/dist/client/assets/journeyDiagram-3NMN7TZE-C9Ft--aA.js.gz +0 -0
  290. package/dist/client/assets/kanban-definition-UXKFOSKX-FCxqSu11.js.br +0 -0
  291. package/dist/client/assets/kanban-definition-UXKFOSKX-FCxqSu11.js.gz +0 -0
  292. package/dist/client/assets/layout-BqjIyPqO.js.br +0 -0
  293. package/dist/client/assets/layout-BqjIyPqO.js.gz +0 -0
  294. package/dist/client/assets/linear-CEAGQX5N.js.br +0 -0
  295. package/dist/client/assets/linear-CEAGQX5N.js.gz +0 -0
  296. package/dist/client/assets/mermaid.core-DvAY78t_.js.br +0 -0
  297. package/dist/client/assets/mermaid.core-DvAY78t_.js.gz +0 -0
  298. package/dist/client/assets/mindmap-definition-YA3MSWOX-D7_qIQ9H.js.br +0 -0
  299. package/dist/client/assets/mindmap-definition-YA3MSWOX-D7_qIQ9H.js.gz +0 -0
  300. package/dist/client/assets/passwordBootstrap-Dksfdvk3.js.br +0 -0
  301. package/dist/client/assets/passwordBootstrap-Dksfdvk3.js.gz +0 -0
  302. package/dist/client/assets/pegDiagram-XKGWAZYB-DeTIBKGC.js.br +0 -0
  303. package/dist/client/assets/pegDiagram-XKGWAZYB-DeTIBKGC.js.gz +0 -0
  304. package/dist/client/assets/pieDiagram-E7YTZNPT-z5IcoVwx.js.br +0 -0
  305. package/dist/client/assets/pieDiagram-E7YTZNPT-z5IcoVwx.js.gz +0 -0
  306. package/dist/client/assets/quadrantDiagram-AXDQQJYC-B-zCZvES.js.br +0 -0
  307. package/dist/client/assets/quadrantDiagram-AXDQQJYC-B-zCZvES.js.gz +0 -0
  308. package/dist/client/assets/railroadDiagram-O6MQD6OU-DbpeB7P2.js.br +0 -0
  309. package/dist/client/assets/railroadDiagram-O6MQD6OU-DbpeB7P2.js.gz +0 -0
  310. package/dist/client/assets/referenceLongPress-p56g9xFb.js.br +0 -0
  311. package/dist/client/assets/referenceLongPress-p56g9xFb.js.gz +0 -0
  312. package/dist/client/assets/requirementDiagram-BXWQKSXE-UhJYMJ_U.js.br +0 -0
  313. package/dist/client/assets/requirementDiagram-BXWQKSXE-UhJYMJ_U.js.gz +0 -0
  314. package/dist/client/assets/sankeyDiagram-P5KCCOFB-xKsuFR17.js.br +0 -0
  315. package/dist/client/assets/sankeyDiagram-P5KCCOFB-xKsuFR17.js.gz +0 -0
  316. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DrjBl65C.js.br +0 -0
  317. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DrjBl65C.js.gz +0 -0
  318. package/dist/client/assets/sizeCapture-INFHLROL-BIlGJ9tm.js.br +0 -0
  319. package/dist/client/assets/sizeCapture-INFHLROL-BIlGJ9tm.js.gz +0 -0
  320. package/dist/client/assets/stateDiagram-D77RDMKH-C3k9XvA6.js.br +0 -0
  321. package/dist/client/assets/stateDiagram-D77RDMKH-C3k9XvA6.js.gz +0 -0
  322. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-B7GnCu2o.js +0 -1
  323. package/dist/client/assets/swimlanes-42K2YHIH-BN-x1rXp.js.br +0 -0
  324. package/dist/client/assets/swimlanes-42K2YHIH-BN-x1rXp.js.gz +0 -0
  325. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-BH_gm34Y.js +0 -8
  326. package/dist/client/assets/timeline-definition-24CTP7MA-Dcedjtic.js.br +0 -0
  327. package/dist/client/assets/timeline-definition-24CTP7MA-Dcedjtic.js.gz +0 -0
  328. package/dist/client/assets/vennDiagram-4TSXK5OY-DAIk-5Rt.js.br +0 -0
  329. package/dist/client/assets/vennDiagram-4TSXK5OY-DAIk-5Rt.js.gz +0 -0
  330. package/dist/client/assets/wardleyDiagram-VM6X3IG4-3iXOTpAg.js.br +0 -0
  331. package/dist/client/assets/wardleyDiagram-VM6X3IG4-3iXOTpAg.js.gz +0 -0
  332. package/dist/client/assets/xychartDiagram-S5SC5T6Z-OD1a_9Qg.js.br +0 -0
  333. package/dist/client/assets/xychartDiagram-S5SC5T6Z-OD1a_9Qg.js.gz +0 -0
@@ -0,0 +1,79 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-DpImj4vY.js","assets/app-Pl7tV8Be.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-PWu1VEN_.css","assets/App-DXq9kwY5.js","assets/gestureArbiter-CJQ8K48V.js","assets/gestureArbiter-C2J0D0kV.css","assets/referenceLongPress-Dlc0425_.js","assets/triangle-alert-DrBuMUPw.js","assets/DiffReview-CVIz-B5T.js","assets/sparkles-gqiuBkfP.js","assets/DiffViewer-BPor2_7o.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-DWUBYx6Q.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-91Llsw5j.js","assets/purify.es-4eNOHKSq.js"])))=>i.map(i=>d[i]);
2
+ import{J as gt,aE as e,bH as xt,a as ks,ak as Kf,C as co,c as Ss,X as _t,bF as qf,av as Vf,s as us,a0 as Yf,az as Xf,aB as vd,aC as Zf,aD as Qf,aA as fs,aa as Jf,E as eh,M as th,ay as rh,aT as nh,aV as sh,aW as ah,ar as ih,aU as Nc,r as Nt,e as oh,L as rt,o as lh,b as ch,aq as Cc,a7 as Ac,a5 as dh,ae as wa,af as $c,ag as uh,bG as zi,aO as fh,a9 as hh,bD as mh,ai as ph,z as Ec,y as gh,a6 as xh,a8 as bh,ac as Mc,be as vh,m as wh,d as ya,f as uo,p as yh,W as kh,_ as js,bJ as Sh,aL as jh,Y as Rh}from"./app-Pl7tV8Be.js";import{b as i,r as Wr}from"./dnd-BCFAPC0L.js";import{w as Nh,f as Ch,n as Pa,d as Ah,P as $h,i as Eh,R as fo,o as wd,p as Mh,S as Wn,D as Th,c as yd,a as Ph,v as kd,t as Tc,s as ka,q as Lh,r as Fh,u as Dh,T as Pc,C as Lc,h as Hi,g as Sa,b as _h,k as Ih,e as Bh,l as zh,F as Fc}from"./App-DXq9kwY5.js";import{a as Hh,S as Oh,b as Sd,c as ho,F as Wh}from"./gestureArbiter-CJQ8K48V.js";import{a as Gh,w as pt,r as Qe,e as ae,u as jd,g as vs,f as hs,d as Uh}from"./referenceLongPress-Dlc0425_.js";import{D as mo,C as ws,L as Rd,f as Kh,n as qh}from"./DiffReview-CVIz-B5T.js";import{T as Vh,L as _a}from"./triangle-alert-DrBuMUPw.js";import{S as Rs}from"./sparkles-gqiuBkfP.js";import{C as Nd,a as Cd,M as Ad,G as Rr}from"./ChangeWalkthroughPanel-DWUBYx6Q.js";import{r as $d,s as Ed,l as Md,u as Yh,G as Td,h as Pd}from"./DiffViewer-BPor2_7o.js";const Xh=[["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"}]],Zh=gt("case-sensitive",Xh);const Qh=[["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"}]],Jh=gt("eye-off",Qh);const em=[["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"}]],po=gt("eye",em);const tm=[["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"}]],go=gt("file-text",tm);const rm=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Dc=gt("house",rm);const nm=[["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"}]],sm=gt("image-plus",nm);const am=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],im=gt("maximize",am);const om=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],lm=gt("minimize",om);const cm=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],dm=gt("pencil-line",cm);const um=[["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"}]],fm=gt("regex",um);const hm=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],mm=gt("rotate-cw",hm);const pm=[["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"}]],gm=gt("scan",pm);const xm=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],_c=gt("send",xm);const bm=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],vm=gt("upload",bm);const wm=[["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"}]],ym=gt("whole-word",wm);function km(t,n,s){try{const l=t instanceof HTMLImageElement?t.naturalWidth:t.width,c=t instanceof HTMLImageElement?t.naturalHeight:t.height;if(!l||!c)return Promise.resolve(null);const d=t instanceof HTMLImageElement?1400/Math.max(l,c):Math.min(1,1400/Math.max(l,c)),h=document.createElement("canvas");h.width=Math.max(1,Math.round(l*d)),h.height=Math.max(1,Math.round(c*d));const m=h.getContext("2d");if(!m)return Promise.resolve(null);const p=getComputedStyle(document.documentElement);if(m.fillStyle=p.getPropertyValue("--surface").trim()||"white",m.fillRect(0,0,h.width,h.height),m.drawImage(t,0,0,h.width,h.height),s){const g=Math.max(10,Math.min(16,h.width/35));m.font=`${g}px sans-serif`;const f=[];let y="";for(const w of s.split(" "))y&&m.measureText(`${y} ${w}`).width>h.width-20?(f.push(y),y=w):y=y?`${y} ${w}`:w;y&&f.push(y),m.fillStyle=p.getPropertyValue("--surface").trim()||"white",m.fillRect(0,0,h.width,f.length*(g+4)+12),m.fillStyle=p.getPropertyValue("--foreground").trim()||"black",f.forEach((w,C)=>m.fillText(w,10,8+g+C*(g+4)))}if(n){const g=n.xPercent*h.width/100,f=n.yPercent*h.height/100,y=Math.max(4,Math.min(12,Math.min(h.width,h.height)*.015)),w=y*1.6;m.strokeStyle=p.getPropertyValue("--primary").trim()||"black",m.lineWidth=Math.max(1,y/3),m.beginPath(),m.arc(g,f,y,0,Math.PI*2),m.stroke(),m.beginPath(),m.moveTo(g-w,f),m.lineTo(g+w,f),m.moveTo(g,f-w),m.lineTo(g,f+w),m.stroke()}return new Promise(g=>h.toBlob(g,"image/png"))}catch{return Promise.resolve(null)}}function Sm(t,n,s,l){return[t.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
3
+ `)}function fx(t,n,s){const l=n*Math.PI/360,c=Math.min(l,Math.atan(Math.tan(l)*Math.max(s,.05)));return Math.max(t,1e-6)/Math.sin(c)*1.15}async function jm(t,n,s,l){if(!s?.snapshot){l.isCurrent()&&l.insert(t,n);return}const c=new Date().toISOString(),d=new AbortController;let h,m;try{m=await Promise.race([(async()=>{const p=await s.snapshot;if(!(!p||d.signal.aborted||!l.isCurrent()))return l.upload(new File([p],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),d.signal)})(),new Promise(p=>{h=setTimeout(()=>{d.abort(),p(void 0)},3e3)})])}catch{}finally{clearTimeout(h),d.abort()}l.isCurrent()&&l.insert(m?Sm(t,"",c,m):t,n)}function Rm(t){let n=1,s="terminal";for(;;){let l=!1;for(const c of t.values())if(c.name===s){l=!0;break}if(!l)break;s=`terminal-${n}`,n++}return s}const Ic=Gh((t,n)=>({sessions:new Map,activeSessionId:null,nextSessionNumber:1,createSession:s=>{const l=Nh(),c=Date.now(),d=n().sessions,h=Rm(d),m={id:l,cwd:s,sessionId:null,name:h,customName:!1,createdAt:c,lastActivity:c};return t(p=>{const g=new Map(p.sessions);return g.set(l,m),{sessions:g,activeSessionId:p.activeSessionId??l,nextSessionNumber:p.nextSessionNumber+1}}),l},closeSession:s=>{t(l=>{const c=new Map(l.sessions),d=l.activeSessionId===s;c.delete(s);let h=l.activeSessionId;if(d){const m=Array.from(c.keys());h=m.length>0?m[0]:null}return{sessions:c,activeSessionId:h}})},switchSession:s=>{t(l=>l.sessions.has(s)?{activeSessionId:s}:l)},updateSession:(s,l)=>{t(c=>{const d=c.sessions.get(s);if(!d)return c;const h=new Map(c.sessions);return h.set(s,{...d,...l,lastActivity:Date.now()}),{sessions:h}})},setTerminalSession:(s,l)=>{n().updateSession(s,{sessionId:l.sessionId})},getActiveSession:()=>{const s=n();if(s.activeSessionId)return s.sessions.get(s.activeSessionId)},getSessionCount:()=>n().sessions.size,clearAllSessions:()=>{t({sessions:new Map,activeSessionId:null,nextSessionNumber:1})}}));function Nm(t,n){return t===n||n.endsWith(`/${t}`)||t.endsWith(`/${n}`)}function Bc(t,n){return`${t??""}\0${n}`}function Cm(t,n,s){if(!t||t.length===0||!s)return{explained:0,stale:0};const l=Bc(n,s);let c=0,d=0;for(const h of t){const m=[h.filePath,h.newPath,h.oldPath].filter(g=>typeof g=="string"&&g.length>0);(m.some(g=>Bc(h.repoRoot,g)===l)||m.some(g=>Nm(g,s)))&&(c+=1)}return{explained:c,stale:d}}function Am({status:t}){if(!t)return null;const n=t.stale>0&&t.explained===0;if(!(t.explained>0||t.stale>0))return null;const l=n?"AI audit explanation is stale":"AI audit explanation available";return e.jsx("span",{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full ${n?"bg-[color:var(--warning)]/15 text-[color:var(--warning)]":"bg-accent/10 text-accent"}`,title:l,"aria-label":l,children:n?e.jsx(Vh,{size:10}):e.jsx(Rs,{size:10})})}function xo({changeStatus:t,auditStatus:n,renderChangeBadge:s}){return e.jsxs("span",{className:"inline-flex items-center gap-1",children:[s(t),e.jsx(Am,{status:n})]})}const Ld="termdock:right-sidebar:diff-change-list-mode:v1";function $m(t){return t==="list"||t==="tree"}function Em(){return Qe(Ld,$m)??"tree"}function Mm(t){for(const l of t){const c=l.hunk;if(c.oldPath&&c.newPath&&c.oldPath!==c.newPath)return"renamed";if(!c.oldPath&&c.newPath)return"added";if(c.oldPath&&!c.newPath)return"deleted"}const n=t.some(l=>l.hunk.additions>0),s=t.some(l=>l.hunk.deletions>0);return n&&!s?"added":!n&&s?"deleted":"modified"}function Tm(t){const n=new Map;for(const l of t){const c=n.get(l.hunk.filePath)??{key:l.hunk.filePath,filePath:l.hunk.filePath,items:[],additions:0,deletions:0,explained:0,stale:0,changeType:"modified"};c.items.push(l),c.additions+=l.hunk.additions,c.deletions+=l.hunk.deletions,l.current&&(c.explained+=1),l.stale&&(c.stale+=1),n.set(l.hunk.filePath,c)}const s=Array.from(n.values()).sort((l,c)=>l.filePath.localeCompare(c.filePath));for(const l of s)l.changeType=Mm(l.items);return s}function Pm(t){const n=t.filePath.split("/").pop()??t.filePath;return{key:t.key,path:t.filePath,displayName:n,displayDir:t.filePath.includes("/")?t.filePath.slice(0,-n.length-1):"",status:t.changeType,title:t.filePath}}function Lm(t,n){const s=t.filter(d=>d.trim().length>0);if(s.length<=1)return s[0]??"";const l=[],c=new Set;for(const[d,h]of s.entries()){const m=h.split(`
4
+ `),p=m.findIndex(y=>y.startsWith("@@ "));if(p<0){l.push(...m);continue}d===0&&l.push(...m.slice(0,p));const g=n[d];let f=p;for(;f>=0&&f<m.length;){const y=m.findIndex((R,A)=>A>f&&R.startsWith("@@ ")),w=y>=0?y:m.length,C=m.slice(f,w),P=C[0]??"",D=g?P===g:!0,H=P||g||C.join(`
5
+ `);D&&!c.has(H)&&(l.push(...C),c.add(H)),f=y}}return l.join(`
6
+ `)}function Fm({groups:t,onInsertDiffReference:n}){return t.map(s=>{const l=Lm(s.items.map(m=>m.hunk.diff||m.current?.diff||m.stale?.diff||""),s.items.map(m=>m.hunk.hunkHeader)),c=s.items.map(m=>m.current??m.stale).filter(m=>!!m).map(m=>({id:m.id,repoRoot:m.repoRoot,filePath:m.filePath,oldPath:m.oldPath,newPath:m.newPath,hunkHeader:m.hunkHeader,hunkIndex:m.hunkIndex,fingerprint:m.fingerprint,diff:m.diff,explanation:m.explanation,summary:m.summary,workspaceRoot:m.workspaceRoot,generatedBy:m.generatedBy,injectedAt:m.injectedAt})),d=s.filePath.split("/").pop()??s.filePath,h=s.filePath.includes("/")?s.filePath.slice(0,-d.length-1):"";return{key:s.key,path:s.filePath,absolutePath:c[0]?.repoRoot?`${c[0].repoRoot}/${s.filePath}`:s.filePath,status:s.changeType,repoRoot:c[0]?.repoRoot??null,displayName:d,displayDir:h,diffOverride:l,auditRecords:c,onInsertDiffReference:n}})}function Dm(t,n,s){const l=Array.from(t.querySelectorAll("[data-diff-stream-item]"));if(l.length===0)return null;const d=t.getBoundingClientRect().top+48;let h=null,m=Number.POSITIVE_INFINITY;for(const g of l){const f=g.getBoundingClientRect();if(f.bottom<d)continue;const y=Math.abs(f.top-d);y<m&&(h=g,m=y)}const p=h?.dataset.diffSelectionPath??h?.dataset.diffStreamItem??null;return!p||p===n||s(p),p}function zc({items:t,selectedKey:n,onSelect:s,emptyText:l,mobile:c=!1,backLabel:d="Back",headerTitle:h,headerMeta:m,onClose:p,closeLabel:g="Back",wrap:f=!0,onToggleWrap:y,wrapTitle:w,wrapOnLabel:C="Wrap on",wrapOffLabel:P="Wrap off",desktopLayout:D="split",onInsertDiffReference:H,onReferenceCopied:R,insertedReferenceKey:A,copiedReferenceKey:E,onClearAuditRecord:M,walkthroughs:G=[],onWalkthroughNavigate:F,initialDetailScrollTop:a,onDetailScrollPositionChange:k,scrollToKey:I,scrollToKeyNonce:S,externalSwiperRef:Z,onMobileSlideChange:re}){const{t:ne}=xt(),de=i.useMemo(()=>Tm(t),[t]),K=i.useMemo(()=>new Map(de.map(fe=>[fe.key,fe])),[de]),[X,$]=i.useState(()=>Em()),[_,Y]=i.useState(()=>new Set),[te,oe]=i.useState({key:null,nonce:0}),ue=de.find(fe=>fe.explained>0||fe.stale>0)?.key??de[0]?.key??null,O=n&&de.some(fe=>fe.key===n)?n:ue,ge=i.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:de.map(Pm)}],[de]),B=i.useMemo(()=>Fm({groups:de,onInsertDiffReference:H}),[de,H]),me=i.useRef(ue),je=i.useRef(s);me.current=ue,je.current=s,i.useEffect(()=>{!n&&me.current&&je.current(me.current)},[n]);const Ee=y?e.jsxs("button",{type:"button",onClick:y,"aria-pressed":f,title:w,className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 text-[11px] font-medium transition active:scale-95 ${f?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:f?C:P})]}):null,_e=fe=>e.jsxs("div",{className:"px-0 py-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[h&&e.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:h}),m&&e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:m})]}),p&&e.jsxs("button",{type:"button",onClick:p,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:[e.jsx(ks,{size:14}),g]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[fe,Ee]})]});if(t.length===0){const fe=e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l});return!h&&!p?fe:e.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[_e(null),fe]})}const bt=y?({slideToList:fe})=>e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",onClick:fe,children:[e.jsx(ks,{size:14}),d]}),e.jsxs("button",{type:"button",onClick:y,"aria-pressed":f,title:w,className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${f?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:f?C:P})]})]}):void 0;return e.jsx(mo,{mobile:c,desktopLayout:D,backLabel:d,groups:ge,selectedKey:O,mode:X,onModeChange:fe=>{$(fe),fe!=="ai"&&pt(Ld,fe)},compact:c,collapsedDirectoryKeys:_,onToggleDirectory:fe=>{Y(he=>{const j=new Set(he);return j.has(fe)?j.delete(fe):j.add(fe),j})},onSelectFile:fe=>{s(fe.key),oe(he=>({key:fe.key,nonce:he.nonce+1}))},renderLeading:fe=>{const he=K.get(fe.key);return e.jsx(xo,{changeStatus:fe.status,auditStatus:he,renderChangeBadge:j=>e.jsx(ws,{status:j})})},renderTrailing:fe=>{const he=K.get(fe.key);return he?e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",he.additions," -",he.deletions]}):null},renderListHeader:_e,aiContent:({slideToDetail:fe,fullscreen:he,toggleFullscreen:j})=>G.length>0&&F?e.jsx(Nd,{walkthroughs:G,repoRoot:G[0]?.repoRoot,fullscreen:he,onToggleFullscreen:j,onNavigate:Q=>{c&&window.requestAnimationFrame(fe),F(Q)}}):e.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:ne("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:bt,externalSwiperRef:Z,onMobileSlideChange:re,detailContainerClassName:c?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:a,scrollToKey:I??te.key,scrollToKeyNonce:I==null?te.nonce:S,onDetailScroll:fe=>{Dm(fe,O,s),k?.(fe.scrollTop)},files:B,activePane:!0,wrap:f,showScrollHint:!f,renderStreamBadge:(fe,he)=>{const j=K.get(he.key);return e.jsx(xo,{changeStatus:fe,auditStatus:j,renderChangeBadge:Q=>e.jsx(ws,{status:Q})})},onInsertDiffReference:H,onReferenceCopied:R,insertedReferenceKey:A,copiedReferenceKey:E,onClearAuditRecord:M,emptyContent:e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l})})}function _m(t){return t.replace(/\/+$/,"")||"/"}function Im(t){return[...new Set(Array.from(t,_m))].sort((n,s)=>n.localeCompare(s))}function Bm(t){return t==="event-storm"||t==="reconnected"||t==="directory-rescan"||t==="polling-fallback"}function zm(t){let n=null;return{applicableEvents:t.filter(l=>{const c=l.type==="rescan-required"&&!Bm(l.reason);return c&&l.reason&&!n&&(n=l.reason),!c}),unavailableReason:n}}const Hm=1400,Om=1200,Fd=44,Wm=.7;function Oi(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function bo(t){return`termdock:right-sidebar:context-draft-height:${t}:v1`}function Gm(t){try{const n=window.localStorage.getItem(bo(t)),s=n===null?NaN:Number(n);return Number.isFinite(s)&&s>=Fd?s:null}catch{return null}}function Hc(t,n){try{n===null?window.localStorage.removeItem(bo(t)):window.localStorage.setItem(bo(t),String(n))}catch{}}function ja(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Um({value:t,collapsed:n,labels:s,focusRequest:l,insertError:c,autoCollapseAfterSend:d,onChange:h,onCollapsedChange:m,onAutoCollapseAfterSendChange:p,onDisable:g,onClear:f,onInsert:y,onInsertAndSend:w}){const[C,P]=i.useState(null),[D,H]=i.useState(!1),[R,A]=i.useState(()=>Gm(Oi())),E=i.useRef(R),M=i.useRef(null),G=i.useRef(null),F=i.useRef(t),a=i.useRef(null),k=i.useRef(null),I=!!t.trim(),S=t.trim().split(`
7
+ `)[0]??"",Z=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";i.useEffect(()=>()=>{M.current!==null&&window.clearTimeout(M.current),G.current!==null&&window.clearTimeout(G.current)},[]),i.useEffect(()=>{let B=!1;const me=Oi();return Kf().then(je=>{if(B)return;const Ee=je.contextDraftHeight?.[me]??null;Hc(me,Ee),E.current=Ee,A(Ee)}).catch(()=>{}),()=>{B=!0}},[]),i.useEffect(()=>{if(l!==void 0&&l>0){const B=a.current;if(!B)return;ja()||B.focus(),B.setSelectionRange(B.value.length,B.value.length),B.scrollTop=B.scrollHeight}},[l]),i.useEffect(()=>{const B=F.current;F.current=t,!(!n||t.length<=B.length)&&(H(!0),G.current!==null&&window.clearTimeout(G.current),G.current=window.setTimeout(()=>{G.current=null,H(!1)},Om))},[t,n]),i.useEffect(()=>{if(n)return;const B=a.current;B&&(B.style.height=R!==null?`${R}px`:"")},[t,n,R]),i.useEffect(()=>{if(n)return;const B=a.current;!B||document.activeElement===B||(B.scrollTop=B.scrollHeight)},[t,n]),i.useEffect(()=>{if(n||ja())return;const B=a.current;!B||document.activeElement===B||(B.focus(),B.setSelectionRange(B.value.length,B.value.length))},[n]);const re=i.useRef(null);i.useLayoutEffect(()=>{if(!ja())return;const B=window.visualViewport;if(!B)return;const me=()=>{const je=re.current;if(!je)return;if(B.height>=window.innerHeight*.75){je.style.transform="";return}const Ee=je.getBoundingClientRect(),_e=Math.round(B.height-Ee.bottom);je.style.transform=_e!==0?`translateY(${_e}px)`:""};return me(),B.addEventListener("resize",me),B.addEventListener("scroll",me),()=>{B.removeEventListener("resize",me),B.removeEventListener("scroll",me),re.current&&(re.current.style.transform="")}},[n]);const ne=B=>{P(B),M.current!==null&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{M.current=null,P(null)},Hm)},de=B=>{m(!1),ja()&&window.requestAnimationFrame(()=>{const me=a.current;if(!me)return;me.focus();const je=me.value.length;me.setSelectionRange(je,je),window.requestAnimationFrame(()=>{me.setSelectionRange(je,je)})})},K=()=>{y(),ne("inserted")},X=()=>{I&&(w(),ne("sent"))},$=B=>{if(B.key==="Escape"){B.preventDefault(),m(!0);return}B.key!=="Enter"||!B.metaKey&&!B.ctrlKey||(B.preventDefault(),X())},_=B=>{B.preventDefault()},Y=B=>{B.preventDefault();const me=a.current;me&&(k.current={startY:B.clientY,startHeight:me.getBoundingClientRect().height},B.currentTarget.setPointerCapture?.(B.pointerId))},te=B=>{const me=k.current;if(!me)return;const je=window.visualViewport?.height??window.innerHeight,Ee=Math.round(Math.min(Math.max(me.startHeight+(me.startY-B.clientY),Fd),je*Wm));E.current=Ee,A(Ee)},oe=B=>{const me=Oi();Hc(me,B),qf({contextDraftHeight:{[me]:B}}).catch(()=>{})},ue=()=>{k.current&&(k.current=null,E.current!==null&&oe(E.current))},O=()=>{E.current=null,A(null),oe(null)},ge=t.length>0&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/50",children:s.characterCount(t.length)});return n?e.jsx("section",{ref:re,className:"shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:e.jsxs("div",{className:"flex h-8 items-center gap-1 px-2",children:[e.jsxs("button",{type:"button",onClick:()=>de(),className:"group flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1 py-1 text-left transition-colors hover:bg-surface/70","aria-expanded":!1,"aria-label":s.expand,title:s.expand,children:[e.jsx(Ch,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),e.jsx("span",{className:`truncate text-[11px] ${c?"text-destructive":D?"text-primary":I?"text-foreground/80":"text-muted-foreground/50"}`,children:c??(D?s.appended:I?S:s.title)})]}),ge,e.jsx("button",{type:"button",onClick:X,disabled:!I,className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-30 ${I?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground"}`,"aria-label":s.send,title:s.send,children:C==="sent"?e.jsx(co,{size:12}):e.jsx(_c,{size:12})})]})}):e.jsxs("section",{ref:re,className:"relative shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:[e.jsx("div",{className:"group absolute left-1/2 top-0 z-10 flex h-3 w-16 -translate-x-1/2 -translate-y-1/2 cursor-ns-resize touch-none items-center justify-center",onPointerDown:Y,onPointerMove:te,onPointerUp:ue,onPointerCancel:ue,onDoubleClick:O,title:s.resize,"aria-hidden":"true",children:e.jsx("span",{className:"h-1 w-8 rounded-full bg-border/50 transition group-hover:bg-border"})}),e.jsxs("div",{className:"flex h-7 items-center gap-0.5 px-2",children:[e.jsxs("button",{type:"button",onPointerDown:_,onClick:()=>m(!0),className:"group flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1 py-1 text-left transition-colors hover:bg-surface/70","aria-expanded":!0,"aria-label":s.collapse,title:s.collapse,children:[e.jsx(Ss,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),e.jsx("span",{className:"truncate text-[10px] font-medium text-foreground/75",children:s.title}),ge]}),e.jsx("button",{type:"button",role:"switch","aria-checked":d,onPointerDown:_,onClick:()=>p(!d),className:"inline-flex h-6 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:bg-surface/70 hover:text-foreground","aria-label":s.autoCollapseAfterSend,title:s.autoCollapseAfterSend,children:e.jsx("span",{"aria-hidden":"true",className:`relative h-3 w-5 rounded-full transition-colors ${d?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-primary-foreground transition-transform ${d?"translate-x-2.5":"translate-x-0.5"}`})})}),e.jsx("button",{type:"button",onPointerDown:_,onClick:g,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/50 transition hover:bg-surface/70 hover:text-foreground active:scale-95","aria-label":s.disable,title:s.disable,children:e.jsx(_t,{size:11})})]}),e.jsx("div",{className:"px-2 pb-2",children:e.jsxs("div",{className:"overflow-hidden rounded-lg bg-surface/80 ring-1 ring-border/10 transition focus-within:ring-primary/35",children:[e.jsx("textarea",{ref:a,value:t,onChange:B=>h(B.target.value),onKeyDown:$,placeholder:s.title,rows:1,className:"block min-h-11 w-full resize-none bg-transparent px-2.5 py-2 font-mono text-[12px] leading-relaxed text-foreground placeholder:text-muted-foreground/30 focus:outline-none",autoCapitalize:"sentences",spellCheck:!0,"data-context-draft-input":!0}),e.jsxs("div",{className:"flex items-center gap-0.5 border-t border-border/10 px-1 py-1",children:[e.jsx("button",{type:"button",onPointerDown:_,onClick:f,disabled:!I,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/65 transition hover:bg-surface-2 hover:text-foreground active:scale-95 disabled:opacity-30","aria-label":s.clear,title:s.clear,children:e.jsx(Pa,{size:11})}),c?e.jsx("span",{className:"min-w-0 flex-1 truncate px-1 text-[10px] text-destructive",role:"alert",children:c}):e.jsx("span",{className:"flex-1"}),e.jsxs("button",{type:"button",onPointerDown:_,onClick:K,disabled:!I,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-[10px] font-medium text-foreground/75 transition hover:bg-surface-2 hover:text-foreground active:scale-[0.98] disabled:opacity-30",children:[e.jsx(Ah,{size:11}),e.jsx("span",{children:C==="inserted"?s.inserted:s.insert})]}),e.jsxs("button",{type:"button",onPointerDown:_,onClick:X,disabled:!I,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md bg-primary px-2 text-[10px] font-semibold text-primary-foreground transition hover:bg-primary/90 active:scale-[0.98] disabled:opacity-30",title:`${s.insertAndSend} · ${Z}`,children:[C==="sent"?e.jsx(co,{size:11}):e.jsx(_c,{size:11}),e.jsx("span",{children:C==="sent"?s.sent:s.send})]})]})]})})]})}function Km(t,n){const s=n.trim();if(!s)return t;if(!t.trim())return s;const l=t.endsWith(`
8
+
9
+ `)?"":t.endsWith(`
10
+ `)?`
11
+ `:`
12
+
13
+ `;return`${t}${l}${s}`}function qm(t,n){const s=t.trim();return s?n?`${s}\r`:/\s$/.test(t)?t:`${s} `:""}const vo="termdock:right-sidebar:html-view-mode-by-file:v1";function Vm(t){return t==="preview"||t==="source"}function Dd(t){return!t||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(Vm)}function _d(t,n){if(!n)return null;const s=t&&!n.startsWith("/")?`${t}/${n}`:n;return t?`${t}::${s}`:s}function Oc(t,n){const s=_d(t,n);return s?Qe(vo,Dd)?.[s]??"source":"source"}function Ym(t,n,s){const l=_d(t,n);if(!l)return;const c=Qe(vo,Dd)??{};pt(vo,{...c,[l]:s})}function Wc(t){try{return new URL(t,location.href).pathname.startsWith("/api/")}catch{return!1}}function Po(t,n){const[s,l]=i.useState(()=>!!navigator.serviceWorker?.controller);return i.useEffect(()=>{if(!Wc(t)||s)return;const c=navigator.serviceWorker,d=()=>l(!!c?.controller);c?.addEventListener("controllerchange",d),d();const h=window.setTimeout(()=>{c?.controller||n?.()},1e4);return()=>{c?.removeEventListener("controllerchange",d),window.clearTimeout(h)}},[t,s,n]),Wc(t)&&!s?void 0:t}function Wi(t){const n=Number.isFinite(t)&&t>0?Math.floor(t):0,s=Math.floor(n/3600),l=Math.floor(n%3600/60),c=n%60,d=String(l).padStart(2,"0"),h=String(c).padStart(2,"0");return s>0?`${s}:${d}:${h}`:`${d}:${h}`}function Xm(t,n,s){return!Number.isFinite(s)||s<=0||!n.width?0:Math.min(1,Math.max(0,(t-n.left)/n.width))*s}const Zm=350,Qm=12,Jm=90;function ep({url:t,onLoadError:n}){const s=Po(t,n),{t:l}=xt(),c=i.useRef(null),d=i.useRef(null),h=i.useRef(null),m=i.useRef(null),p=i.useRef(!1),g=i.useRef(null),f=i.useRef(null),y=i.useRef(0),w=i.useRef(!1),C=i.useRef(!1),P=i.useRef(!1),D=i.useRef(null),H=i.useRef(null),R=i.useRef(!1),A=i.useRef(1),E=i.useRef(!1),[M,G]=i.useState(0),[F,a]=i.useState(0),[k,I]=i.useState(!1),[S,Z]=i.useState(!1),[re,ne]=i.useState(null),[de,K]=i.useState(!1),[X,$]=i.useState(0),[_,Y]=i.useState(!1),[te,oe]=i.useState({width:0,height:0}),ue=i.useCallback(()=>{D.current!==null&&(clearTimeout(D.current),D.current=null)},[]),O=i.useCallback(()=>{if(ue(),H.current=null,!R.current)return!1;const U=h.current;return U&&(U.playbackRate=A.current),R.current=!1,K(!1),!0},[ue]);i.useEffect(()=>()=>{g.current!==null&&cancelAnimationFrame(g.current),f.current!==null&&clearTimeout(f.current),ue();const U=h.current;U&&R.current&&(U.playbackRate=A.current)},[ue]),i.useEffect(()=>{const U=d.current;if(!U||typeof ResizeObserver>"u")return;const V=new ResizeObserver(([Se])=>{Se&&oe({width:Se.contentRect.width,height:Se.contentRect.height})});return V.observe(U),()=>V.disconnect()},[]),i.useEffect(()=>{const U=()=>Y(document.fullscreenElement===c.current);return document.addEventListener("fullscreenchange",U),()=>document.removeEventListener("fullscreenchange",U)},[]);const ge=i.useCallback((U,V=!1)=>{const Se=h.current;if(!Se)return!1;const Re=Number.isFinite(Se.duration)?Se.duration:U,at=Math.min(Math.max(U,0),Re);if(a(at),Math.abs(Se.currentTime-at)<1/120)return!1;const Ke=Se.fastSeek;return V&&typeof Ke=="function"?Ke.call(Se,at):Se.currentTime=at,!0},[]),B=i.useCallback(()=>{g.current===null&&(g.current=requestAnimationFrame(()=>{g.current=null;const U=h.current;if(!U||!w.current||C.current||U.seeking)return;const V=P.current;P.current=!1,C.current=ge(y.current,!V)}))},[ge]),me=i.useCallback(U=>{const V=m.current,Se=h.current;if(!V||!Se)return;const Re=V.getBoundingClientRect(),at=Xm(U,Re,Se.duration);y.current=at,ne(at),P.current=!1,B(),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,P.current=!0,B()},Jm)},[B]),je=i.useCallback(()=>{g.current!==null&&(cancelAnimationFrame(g.current),g.current=null),f.current!==null&&(clearTimeout(f.current),f.current=null),P.current=!1,C.current=!1,ge(y.current)},[ge]),Ee=i.useCallback(U=>{const V=h.current;if(!(!V||!Number.isFinite(V.duration)||V.duration<=0)){p.current=!V.paused,V.pause(),w.current=!0,Z(!0);try{U.currentTarget.setPointerCapture(U.pointerId)}catch{}me(U.clientX)}},[me]),_e=i.useCallback(()=>{w.current=!1,je(),Z(!1),ne(null);const U=h.current;U&&p.current&&!U.ended&&U.play().catch(()=>{}),p.current=!1},[je]),bt=i.useCallback(()=>{const U=h.current;if(U){if(E.current){E.current=!1;return}U.paused?U.play().catch(()=>{}):U.pause()}},[]),fe=i.useCallback(U=>{const V=h.current;!V||V.paused||U.button!==0||(ue(),H.current={id:U.pointerId,x:U.clientX,y:U.clientY},D.current=setTimeout(()=>{D.current=null,A.current=V.playbackRate,V.playbackRate=2,R.current=!0,K(!0)},Zm))},[ue]),he=i.useCallback(U=>{const V=H.current;!V||V.id!==U.pointerId||R.current||Math.hypot(U.clientX-V.x,U.clientY-V.y)>Qm&&(ue(),H.current=null)},[ue]),j=i.useCallback(()=>{O()&&(E.current=!0)},[O]);i.useEffect(()=>(window.addEventListener("pointerup",j),window.addEventListener("pointercancel",j),window.addEventListener("blur",j),()=>{window.removeEventListener("pointerup",j),window.removeEventListener("pointercancel",j),window.removeEventListener("blur",j)}),[j]);const Q=i.useCallback(async()=>{const U=c.current,V=h.current;if(!(!U||!V))try{document.fullscreenElement===U?await document.exitFullscreen():U.requestFullscreen?await U.requestFullscreen():V.webkitEnterFullscreen?.()}catch{V.webkitEnterFullscreen?.()}},[]),ke=i.useCallback(()=>$(U=>(U+90)%360),[]),be=i.useCallback(U=>{const V=h.current;if(!V||!Number.isFinite(V.duration))return;const Se=U.shiftKey?10:5;let Re=null;U.key==="ArrowLeft"?Re=V.currentTime-Se:U.key==="ArrowRight"?Re=V.currentTime+Se:U.key==="Home"?Re=0:U.key==="End"&&(Re=V.duration),Re!==null&&(U.preventDefault(),ge(Re))},[ge]),De=S&&re!==null?re:F,le=M>0?Math.min(1,Math.max(0,De/M)):0,Me=(X===90||X===270)&&te.width>0&&te.height>0?{width:`${te.height}px`,height:`${te.width}px`}:{width:"100%",height:"100%"};return e.jsxs("div",{ref:c,className:"flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-background fullscreen:h-screen fullscreen:w-screen fullscreen:rounded-none","data-testid":"file-preview-video-player","data-rotation":X,children:[e.jsxs("div",{ref:d,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[e.jsx("video",{ref:h,"data-testid":"file-preview-video",className:"absolute left-1/2 top-1/2 max-w-none object-contain transition-transform duration-200",style:{...Me,transform:`translate(-50%, -50%) rotate(${X}deg)`},src:s,preload:"auto",playsInline:!0,onClick:bt,onPointerDown:fe,onPointerMove:he,onPointerUp:j,onPointerCancel:j,onContextMenu:U=>{R.current&&U.preventDefault()},onPlay:()=>I(!0),onPause:()=>I(!1),onTimeUpdate:U=>a(U.currentTarget.currentTime),onSeeked:U=>{const V=U.currentTarget;if(a(V.currentTime),C.current=!1,!w.current)return;const Se=V.requestVideoFrameCallback;typeof Se=="function"?Se.call(V,()=>{w.current&&B()}):requestAnimationFrame(()=>{w.current&&B()})},onLoadedMetadata:U=>G(Number.isFinite(U.currentTarget.duration)?U.currentTarget.duration:0),onDurationChange:U=>G(Number.isFinite(U.currentTarget.duration)?U.currentTarget.duration:0),onError:n,children:l("rightSidebar.videoUnsupported")}),de&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-3 z-10 -translate-x-1/2 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md",children:l("rightSidebar.videoLongPressSpeed")}),S&&re!==null&&e.jsx("div",{className:"pointer-events-none absolute bottom-1 z-10 -translate-x-1/2 rounded-md bg-surface-elevated px-2 py-1 text-[11px] font-medium text-foreground shadow-md",style:{left:`${le*100}%`},"data-testid":"file-preview-video-scrub-time",children:Wi(re)})]}),e.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${Hh}`,[Oh]:"",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:bt,"aria-label":l(k?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:l(k?"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:k?e.jsx($h,{size:14}):e.jsx(Eh,{size:14})}),e.jsxs("div",{ref:m,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(M),"aria-valuenow":Math.floor(De),tabIndex:0,className:"group relative h-5 min-w-0 flex-1 cursor-pointer touch-none py-2","data-testid":"file-preview-video-track",onPointerDown:Ee,onPointerMove:U=>{S&&me(U.clientX)},onPointerUp:_e,onPointerCancel:_e,onKeyDown:be,children:[e.jsx("div",{className:"h-1 w-full rounded-full bg-surface-elevated"}),e.jsx("div",{className:"absolute inset-y-0 left-0 my-auto h-1 rounded-full bg-primary",style:{width:`${le*100}%`}}),e.jsx("div",{className:"absolute top-1/2 h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary shadow",style:{left:`${le*100}%`}})]}),e.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[Wi(De)," / ",Wi(M)]}),e.jsx("button",{type:"button",onClick:ke,"aria-label":l("rightSidebar.videoRotate"),title:l("rightSidebar.videoRotate"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-rotate",children:e.jsx(mm,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{Q()},"aria-label":l(_?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:l(_?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-fullscreen",children:_?e.jsx(lm,{size:14}):e.jsx(im,{size:14})})]})})]})}function tp(t){const n=Math.max(0,Math.min(100,t.xPercent)),s=Math.max(0,Math.min(100,t.yPercent));return{...n<=50?{left:`calc(${n}% + 8px)`}:{right:`calc(${100-n}% + 8px)`},...s<=50?{top:`calc(${s}% + 8px)`}:{bottom:`calc(${100-s}% + 8px)`}}}function Ua({anchor:t,children:n,disabled:s=!1,onClick:l,title:c}){return e.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:s,onClick:d=>{d.stopPropagation(),l()},title:c,style:tp(t),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[e.jsx(_a,{size:11}),n]})}function rp(t,n,s,l){if(s.width<=0||s.height<=0||l.width<=0||l.height<=0)return null;const c=Math.min(s.width/l.width,s.height/l.height);if(!Number.isFinite(c)||c<=0)return null;const d=l.width*c,h=l.height*c,m=s.left+(s.width-d)/2,p=s.top+(s.height-h)/2,g=t-m,f=n-p;if(g<0||f<0||g>d||f>h)return null;const y=g/d*100,w=f/h*100;return{x:l.x+l.width*y/100,y:l.y+l.height*w/100,xPercent:y,yPercent:w}}function np(t,n,s){const l=[`SVG标注: ${t}`,`视图: ${n}`,`SVG坐标: (${s.x.toFixed(2)},${s.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return s.nearestText&&l.push(`最近文字: ${s.nearestText}`),`"${l.join(" / ")}"`}function sp(t){const n=new DOMParser().parseFromString(t,"image/svg+xml"),s=n.documentElement;if(s.nodeName.toLowerCase()!=="svg"||n.querySelector("parsererror"))throw new Error("Invalid SVG document");return n.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(l=>l.remove()),n.querySelectorAll("*").forEach(l=>{for(const c of Array.from(l.attributes)){const d=c.name.toLowerCase(),h=c.value.trim();(d.startsWith("on")||(d==="href"||d.endsWith(":href"))&&h&&!h.startsWith("#"))&&l.removeAttribute(c.name)}}),s.removeAttribute("width"),s.removeAttribute("height"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(s)}function ap(t,n,s){let l=null;for(const c of Array.from(t.querySelectorAll("text"))){const d=(c.textContent??"").replace(/\s+/g," ").trim();if(!d)continue;const h=Number(c.getAttribute("x")),m=Number(c.getAttribute("y"));if(!Number.isFinite(h)||!Number.isFinite(m))continue;const p=Math.hypot(h-n,m-s);(!l||p<l.distance)&&(l={text:d,distance:p})}return l?.text.slice(0,120)}function Id({blobUrl:t,filePath:n,viewLabel:s,onInsertAnnotation:l}){const c=i.useRef(null),d=i.useRef(null),[h,m]=i.useState(null),[p,g]=i.useState(null),[f,y]=i.useState(1),[w,C]=i.useState(!1),[P,D]=i.useState(null),H=i.useRef(new Map),R=i.useRef(null),A=i.useRef(!1),E=i.useRef(null),M=i.useRef(f);M.current=f,i.useEffect(()=>{const $=new AbortController;return m(null),g(null),D(null),y(1),fetch(t,{signal:$.signal}).then(_=>_.text()).then(_=>m(sp(_))).catch(_=>{$.signal.aborted||g(_ instanceof Error?_.message:"SVG preview failed")}),()=>$.abort()},[t]),i.useEffect(()=>{if(!w)return;const $=_=>{_.key==="Escape"&&C(!1)};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[w]),i.useLayoutEffect(()=>{const $=d.current,_=$?.querySelector("[data-svg-document] > svg");if(!$||!_)return;let Y;try{Y=_.getBBox()}catch{return}if(!Y.width||!Y.height)return;const te=Math.max(2,Math.min(Y.width,Y.height)*.025);_.setAttribute("viewBox",`${Y.x-te} ${Y.y-te} ${Y.width+2*te} ${Y.height+2*te}`),_.style.width=`${f*100}%`,_.style.height=`${f*100}%`,_.style.minWidth=`${f*100}%`,_.style.minHeight=`${f*100}%`,_.style.display="block"},[h,f]);const G=i.useMemo(()=>P?np(n,s,P):null,[n,P,s]),F=$=>{if(A.current){A.current=!1;return}const _=d.current,Y=_?.querySelector("[data-svg-document] > svg"),te=c.current;if(!_||!Y||!te)return;const oe=Y.viewBox.baseVal,ue=rp($.clientX,$.clientY,Y.getBoundingClientRect(),oe);if(!ue)return;const O=te.getBoundingClientRect();D({...ue,nearestText:ap(Y,ue.x,ue.y),stageX:$.clientX-O.left,stageY:$.clientY-O.top,stageXPercent:($.clientX-O.left)/O.width*100,stageYPercent:($.clientY-O.top)/O.height*100})},a=$=>Math.max(1,Math.min(12,$)),k=($,_)=>{const Y=a(_),te=$.querySelector("[data-svg-document] > svg");if(!te)return Y;const oe=`${Y*100}%`;return te.style.width=oe,te.style.height=oe,te.style.minWidth=oe,te.style.minHeight=oe,M.current=Y,Y},I=($,_,Y,te)=>{const oe=M.current,ue=$.getBoundingClientRect(),O=Y-ue.left,ge=te-ue.top,B=($.scrollLeft+O)/oe,me=($.scrollTop+ge)/oe,je=k($,_);return $.scrollLeft=B*je-O,$.scrollTop=me*je-ge,je},S=()=>{const $=Array.from(H.current.values());return $.length>=2?Math.hypot($[0].x-$[1].x,$[0].y-$[1].y):0},Z=$=>{if($.pointerType==="mouse"&&$.button!==0)return;const _=d.current;_&&(H.current.set($.pointerId,{x:$.clientX,y:$.clientY}),_.setPointerCapture?.($.pointerId),H.current.size>=2?(R.current={kind:"pinch",startX:$.clientX,startY:$.clientY,startScrollLeft:_.scrollLeft,startScrollTop:_.scrollTop,startDistance:S(),startZoom:M.current,moved:!1},A.current=!0):M.current>1&&(R.current={kind:"pan",startX:$.clientX,startY:$.clientY,startScrollLeft:_.scrollLeft,startScrollTop:_.scrollTop,startZoom:M.current,moved:!1}))},re=$=>{if(!H.current.has($.pointerId))return;H.current.set($.pointerId,{x:$.clientX,y:$.clientY});const _=d.current,Y=R.current;if(!(!_||!Y)){if(H.current.size>=2&&Y.kind==="pinch"){const te=S();if(!Y.startDistance||!te)return;const oe=a(Y.startZoom*te/Y.startDistance);if(Math.abs(oe-M.current)<.01)return;const ue=Array.from(H.current.values()),O=(ue[0].x+ue[1].x)/2,ge=(ue[0].y+ue[1].y)/2;Y.moved=!0,A.current=!0,I(_,oe,O,ge),$.preventDefault();return}if(Y.kind==="pan"&&H.current.size===1){const te=$.clientX-Y.startX,oe=$.clientY-Y.startY;if(!Y.moved&&Math.hypot(te,oe)<6)return;Y.moved=!0,A.current=!0,_.scrollLeft=Y.startScrollLeft-te,_.scrollTop=Y.startScrollTop-oe,$.preventDefault()}}},ne=$=>{const _=d.current,Y=R.current,te=H.current.size===1&&!Y?.moved;H.current.delete($.pointerId);try{_?.releasePointerCapture?.($.pointerId)}catch{}if(H.current.size===1&&Y?.kind==="pinch"){const O=Array.from(H.current.values())[0];R.current=_?{kind:"pan",startX:O.x,startY:O.y,startScrollLeft:_.scrollLeft,startScrollTop:_.scrollTop,startZoom:M.current,moved:!1}:null;return}if(H.current.size>0||(R.current=null,Y?.kind==="pinch"&&y(M.current),!te||A.current))return;const oe=Date.now(),ue=E.current;ue&&oe-ue.time<350&&Math.hypot($.clientX-ue.x,$.clientY-ue.y)<24?(E.current=null,A.current=!0,y(O=>O>1?1:2.5)):E.current={time:oe,x:$.clientX,y:$.clientY}},de=$=>{if(!$.ctrlKey&&!$.metaKey)return;const _=d.current;if(!_)return;$.preventDefault();const Y=I(_,M.current*Math.exp(-$.deltaY*.01),$.clientX,$.clientY);y(Y)},K=()=>{y(1),M.current=1,d.current&&(d.current.scrollLeft=0,d.current.scrollTop=0)},X=e.jsxs("div",{className:w?"fixed inset-0 z-modal-panel flex min-h-0 flex-col bg-surface pt-[env(safe-area-inset-top,0px)]":"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{ref:c,className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:d,role:"button",tabIndex:0,onClick:F,onDoubleClick:$=>{$.preventDefault(),y(_=>_>1?1:2.5)},onPointerDown:Z,onPointerMove:re,onPointerUp:ne,onPointerCancel:ne,onWheel:de,onScroll:()=>D(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:p?e.jsx("div",{className:"p-4 text-sm text-destructive",children:p}):h?e.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:h}}):e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),P&&e.jsx("span",{"data-svg-pick-marker":!0,className:"pointer-events-none absolute z-10 h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm",style:{left:P.stageX,top:P.stageY}}),P&&G&&e.jsx(Ua,{anchor:{xPercent:P.stageXPercent,yPercent:P.stageYPercent},title:"引用 SVG 标注",onClick:()=>{l?.(G,`svg:${P.x.toFixed(2)}:${P.y.toFixed(2)}`),D(null)},children:"引用 SVG 标注"}),e.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[f>1.001&&e.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:$=>{$.stopPropagation(),K()},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:e.jsx(gm,{size:14})}),e.jsx("button",{type:"button","aria-label":w?"退出全屏 SVG":"全屏 SVG",title:w?"退出全屏 SVG":"全屏 SVG",onClick:$=>{$.stopPropagation(),C(_=>!_)},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:w?e.jsx(Cd,{size:14}):e.jsx(Ad,{size:14})})]})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:P?`SVG (${P.x.toFixed(2)}, ${P.y.toFixed(2)}) · ${P.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return w?Wr.createPortal(X,document.body):X}function La(t){switch(t){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function ip(t,n,s,l){const c=[`电子标注: ${t}`,`视图: ${La(n)}`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(l?.available&&l.xMm!==void 0&&l.yMm!==void 0&&(c.push(`PCB坐标: (${l.xMm.toFixed(2)},${l.yMm.toFixed(2)})mm [KiCad板坐标]`),l.layer&&c.push(`显示层: ${l.layer}`),l.nearest)){const d=[l.nearest.net?`网络 ${l.nearest.net}`:null,`对象层 ${l.nearest.layer}`,`距离 ${l.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");c.push(`最近对象: ${l.nearest.label}${d?`(${d})`:""}`)}return`"${c.join(" / ")}"`}function op({blobUrl:t,filePath:n,view:s,board:l,onViewChange:c,onInsertAnnotation:d,onRefresh:h,interactive3d:m}){const{t:p}=xt(),g=i.useRef(null),f=i.useRef(null),y=i.useRef(null),[w,C]=i.useState(null),[P,D]=i.useState(!1);i.useEffect(()=>(y.current?.abort(),C(null),D(!1),()=>y.current?.abort()),[t,s]);const H=i.useMemo(()=>w?ip(n,s,w,w.inspection):null,[n,w,s]),R=E=>{const M=g.current,G=f.current;if(!M||!G||!G.naturalWidth||!G.naturalHeight)return;const F=M.getBoundingClientRect(),a=G.getBoundingClientRect(),k=Math.min(a.width/G.naturalWidth,a.height/G.naturalHeight),I=G.naturalWidth*k,S=G.naturalHeight*k,Z=a.left+(a.width-I)/2,re=a.top+(a.height-S)/2,ne=E.clientX-Z,de=E.clientY-re;if(ne<0||de<0||ne>I||de>S)return;const K={xPercent:Math.max(0,Math.min(100,ne/I*100)),yPercent:Math.max(0,Math.min(100,de/S*100)),stageXPercent:(E.clientX-F.left)/F.width*100,stageYPercent:(E.clientY-F.top)/F.height*100,inspecting:l&&s!=="pcb-3d"};if(C(K),y.current?.abort(),!K.inspecting)return;const X=new AbortController;y.current=X,Vf(n,s,K.xPercent,K.yPercent,X.signal).then($=>C(_=>_===K?{..._,inspection:$,inspecting:!1}:_)).catch(()=>{X.signal.aborted||C($=>$===K?{...$,inspection:{available:!1},inspecting:!1}:$)})},A=l?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:A.map(E=>e.jsx("button",{type:"button",onClick:()=>c(E),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${E===s?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:La(E)},E))}),e.jsx("button",{type:"button",onClick:h,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:p("rightSidebar.edaRefresh"),"aria-label":p("rightSidebar.edaRefresh"),children:e.jsx(fo,{size:13})})]}),l&&m?e.jsx("div",{className:s==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:m}):null,l?s==="pcb-3d"?m?null:e.jsx("div",{className:"min-h-0 flex-1"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:g,role:"button",tabIndex:0,onClick:R,onKeyDown:E=>{E.key!=="Enter"&&E.key!==" "||(E.preventDefault(),C({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:p("rightSidebar.edaPickHint"),children:[e.jsx("img",{ref:f,src:t,alt:`${n} ${La(s)}`,onLoad:()=>D(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${P?"opacity-100":"opacity-0"}`}),w&&e.jsx("span",{className:"pointer-events-none absolute h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-surface shadow-sm",style:{left:`${w.stageXPercent}%`,top:`${w.stageYPercent}%`}}),w&&H&&e.jsx(Ua,{anchor:{xPercent:w.stageXPercent,yPercent:w.stageYPercent},disabled:w.inspecting,title:p("rightSidebar.edaInsertAnnotation"),onClick:()=>{d?.(H,`eda:${s}:${w.xPercent.toFixed(1)}:${w.yPercent.toFixed(1)}`,{snapshot:f.current?km(f.current,w):Promise.resolve(null)}),C(null)},children:p("rightSidebar.edaInsertAnnotation")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:w?w.inspecting?p("rightSidebar.edaInspecting"):w.inspection?.available?p("rightSidebar.edaPickedBoardPosition",{x:w.inspection.xMm?.toFixed(2)??"—",y:w.inspection.yMm?.toFixed(2)??"—",object:w.inspection.nearest?.label??p("rightSidebar.edaNoNearbyObject")}):p("rightSidebar.edaPickedPosition",{x:w.xPercent.toFixed(1),y:w.yPercent.toFixed(1)}):p("rightSidebar.edaPickHint")})})]}):e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(Id,{blobUrl:t,filePath:n,viewLabel:La(s),onInsertAnnotation:d})})]})}function lp(t){const n=[];let s=[],l="",c=!1;for(let d=0;d<t.length;d+=1){const h=t[d];c?h==='"'&&t[d+1]==='"'?(l+='"',d+=1):h==='"'?c=!1:l+=h:h==='"'?c=!0:h===","?(s.push(l),l=""):h===`
14
+ `?(s.push(l.replace(/\r$/,"")),n.push(s),s=[],l=""):l+=h}return(l||s.length>0)&&(s.push(l.replace(/\r$/,"")),n.push(s)),n}function cp(t,n,s,l,c){const d=n[c]||`第${c+1}列`,h=s[c]??"",m=n.map((p,g)=>`${p||`第${g+1}列`}=${s[g]??""}`).join(";");return`"表格标注: ${t} / 数据行: ${l+1} / 列: ${d} / 值: ${h} / 记录: ${m}"`}function dp({content:t,filePath:n,onInsertAnnotation:s}){const{t:l}=xt(),c=i.useMemo(()=>lp(t),[t]),d=c[0]??[],h=c.slice(1),m=i.useRef(null),[p,g]=i.useState(null),f=p?h[p.row]:null,y=p&&f?cp(n,d,f,p.row+1,p.column):null;return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[e.jsxs("div",{ref:m,className:"relative min-h-0 flex-1",children:[e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("table",{className:"min-w-full border-separate border-spacing-0 text-left text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 top-0 z-20 border-b border-r border-border/20 bg-surface-elevated px-2 py-2 text-[10px] font-semibold text-muted-foreground",children:"#"}),d.map((w,C)=>e.jsx("th",{className:"sticky top-0 z-10 min-w-28 border-b border-r border-border/20 bg-surface-elevated px-3 py-2 font-semibold text-foreground",children:w||l("rightSidebar.csvUnnamedColumn",{index:C+1})},`${w}:${C}`))]})}),e.jsx("tbody",{children:h.map((w,C)=>e.jsxs("tr",{className:"hover:bg-surface-2",children:[e.jsx("th",{className:"sticky left-0 z-10 border-b border-r border-border/15 bg-surface px-2 py-2 text-right text-[10px] font-normal text-muted-foreground",children:C+1}),d.map((P,D)=>{const H=p?.row===C&&p.column===D;return e.jsx("td",{className:`border-b border-r border-border/15 p-0 ${H?"bg-primary/15":""}`,children:e.jsx("button",{type:"button",onClick:R=>{const A=m.current?.getBoundingClientRect(),E=R.currentTarget.getBoundingClientRect();if(!A?.width||!A.height)return;const M=R.clientX||E.left+E.width/2,G=R.clientY||E.top+E.height/2;g({row:C,column:D,xPercent:(M-A.left)/A.width*100,yPercent:(G-A.top)/A.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:w[D]||" "})},`cell:${C}:${D}`)})]},`row:${C}`))})]})}),p&&y&&e.jsx(Ua,{anchor:{xPercent:p.xPercent,yPercent:p.yPercent},title:l("rightSidebar.csvInsertAnnotation"),onClick:()=>{s?.(y,`csv:${n}:${p.row+1}:${p.column+1}`),g(null)},children:l("rightSidebar.csvInsertAnnotation")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:p&&f?l("rightSidebar.csvSelectedCell",{row:p.row+1,column:d[p.column]||p.column+1}):l("rightSidebar.csvPickHint",{rows:h.length,columns:d.length})})})]})}function zn(t,n){let s=t;for(const l of n){if(!s||typeof s!="object")return;s=s[l]}return s}function up(t,n){const s=JSON.parse(t),l=zn(s,["meta","version"]);if(n)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(l??"未知")},{label:"活动层编号",value:String(zn(s,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(zn(s,["board","visible_layers"])??"未知")},{label:"Git 集成",value:zn(s,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const c=zn(s,["net_settings","classes"]),d=Array.isArray(c)?c.find(m=>m&&typeof m=="object"&&m.name==="Default"):void 0,h=zn(s,["board","design_settings","drc_exclusions"]);return[{label:"文件性质",value:"KiCad 工程配置"},{label:"格式版本",value:String(l??"未知")},{label:"网络类数量",value:String(Array.isArray(c)?c.length:0)},{label:"默认间距",value:d?.clearance!==void 0?`${d.clearance} mm`:"未设置"},{label:"默认线宽",value:d?.track_width!==void 0?`${d.track_width} mm`:"未设置"},{label:"默认过孔",value:d?.via_diameter!==void 0?`${d.via_diameter} / ${d.via_drill??"—"} mm(外径/钻孔)`:"未设置"},{label:"DRC 排除项",value:String(Array.isArray(h)?h.length:0)}]}function fp(t,n){return`"KiCad项目标注: ${t} / 项: ${n.label} / 值: ${n.value}"`}function hp({content:t,filePath:n,localState:s,onInsertAnnotation:l}){const{t:c}=xt(),d=i.useRef(null),[h,m]=i.useState(null),p=i.useMemo(()=>{try{return{items:up(t,s),error:null}}catch(f){return{items:[],error:f instanceof Error?f.message:String(f)}}},[t,s]),g=h===null?null:p.items[h.index];return p.error?e.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-3 font-mono text-xs text-foreground",children:t}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[s&&e.jsx("div",{className:"border-b border-[color:var(--warning)]/20 bg-[color:var(--warning)]/5 px-3 py-2 text-xs text-[color:var(--warning)]",children:c("rightSidebar.kicadLocalStateNotice")}),e.jsxs("div",{ref:d,className:"relative min-h-0 flex-1",children:[e.jsxs("div",{className:"h-full overflow-auto px-3 py-2",children:[e.jsx("div",{className:"divide-y divide-border/15",children:p.items.map((f,y)=>e.jsxs("button",{type:"button",onClick:w=>{const C=d.current?.getBoundingClientRect(),P=w.currentTarget.getBoundingClientRect();if(!C?.width||!C.height)return;const D=w.clientX||P.left+P.width/2,H=w.clientY||P.top+P.height/2;m({index:y,xPercent:(D-C.left)/C.width*100,yPercent:(H-C.top)/C.height*100})},className:`grid w-full grid-cols-[minmax(7rem,0.8fr)_minmax(0,1.4fr)] gap-3 px-2 py-3 text-left transition hover:bg-surface-2 ${h?.index===y?"bg-primary/10":""}`,children:[e.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:f.label}),e.jsx("span",{className:"break-words text-xs text-foreground",children:f.value})]},f.label))}),e.jsxs("details",{className:"mt-3 border-t border-border/15 pt-3",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-semibold text-muted-foreground",children:c("rightSidebar.kicadShowRawJson")}),e.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre p-2 font-mono text-[10px] leading-relaxed text-foreground",children:t})]})]}),g&&h&&e.jsx(Ua,{anchor:{xPercent:h.xPercent,yPercent:h.yPercent},title:c("rightSidebar.kicadInsertSetting"),onClick:()=>{l?.(fp(n,g),`kicad-project:${n}:${g.label}`),m(null)},children:c("rightSidebar.kicadInsertSetting")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:g?`${g.label}: ${g.value}`:c("rightSidebar.kicadProjectPickHint")})})]})}const Ra="/api/terminal/fs/preview/",mp=8*1024*1024,pp=32*1024*1024,gp=128,xp="data:,";function Rt(t){throw new Error(t)}function Gi(t){return JSON.stringify(t).replace(/</g,"\\u003c")}async function Gc(t,n,s){let l="",c=0;for(const d of t.matchAll(n))l+=t.slice(c,d.index)+await s(d),c=d.index+d[0].length;return l+t.slice(c)}async function bp(t,n){const s=n.origin??location.origin,l=new URL(t,s);(l.origin!==s||!us(l.pathname)?.startsWith(Ra))&&Rt("预览地址不是有效的本地文件入口");const c=crypto.randomUUID(),d=`https://termdock-preview.invalid/${c}/`,h=[],m=K=>{!h.includes(K)&&h.length<20&&h.push(K)},p=new Set,g=[],f=new Set,y=new Map,w=new Map;let C=0,P=!1;const D=new Set,H=()=>{P=!0;for(const K of[...D])K();p.clear(),g.length=0};async function R(K){K.ok||Rt(`预览资源读取失败(${K.status})`);const X=K.body?.getReader(),$=[];let _=0;try{if(X)for(;;){const oe=await X.read();if(oe.done)break;_+=oe.value.byteLength,C+=oe.value.byteLength,(_>mp||C>pp)&&Rt("预览资源超出大小限制"),$.push(oe.value)}}catch(oe){throw await X?.cancel().catch(()=>{}),oe}finally{X?.releaseLock()}const Y=new Uint8Array(_);let te=0;for(const oe of $)Y.set(oe,te),te+=oe.length;return{bytes:Y,type:K.headers.get("content-type")??"application/octet-stream",status:K.status}}let A=l,E;for(let K=0;K<4;K++){const X=await n.fetch(A.pathname+A.search,{signal:n.signal,redirect:"manual"});if(![301,302,303,307,308].includes(X.status)){E=X;break}const $=X.headers.get("location");await X.body?.cancel(),$||Rt("预览重定向缺少目标");const _=new URL($,A);(_.origin!==s||!us(_.pathname)?.startsWith(Ra))&&Rt("预览重定向越出文件范围"),A=_}E||Rt("预览重定向次数过多");const M=us(A.pathname),G=M.slice(Ra.length).split("/");/^[a-f0-9]{32}$/.test(G[0])||Rt("服务未提供有效的预览资源授权");const F=us(l.pathname).slice(Ra.length).split("/");/^[a-f0-9]{32}$/.test(F[0])&&F.shift(),F.join("/").replace(/\/$/,"")!==G.slice(1).join("/").replace(/\/$/,"")&&Rt("预览重定向改变了文件范围");const a=M.endsWith("/")?M:M.slice(0,M.lastIndexOf("/")+1),k=new URL(A.pathname.endsWith("/")?A.pathname:A.pathname.slice(0,A.pathname.lastIndexOf("/")+1),s);function I(K,X){const $=new URL(K,X);return $.origin!==s?null:(us($.pathname)?.startsWith(a)||Rt("已阻止预览访问目录之外的资源"),$)}function S(K){const X=new URL(K,d);(X.origin!==new URL(d).origin||!X.pathname.startsWith(new URL(d).pathname))&&Rt("已阻止预览访问服务接口或目录之外的资源");const $=X.pathname.slice(new URL(d).pathname.length)+X.search;return I($,k)??Rt("预览资源无效")}function Z(K){const X=K.pathname+K.search,$=y.get(X);if($)return $;if(P||n.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(y.size>=gp)return Promise.reject(new Error("预览资源数量超出限制"));const _=n.fetch(X,{signal:n.signal,redirect:"manual"}).then(R);return y.set(X,_),_}function re(K,X){P&&Rt("预览已关闭");const $=`termdock-resource-${c}-${g.length}`;return g.push({token:$,data:K,type:X}),p.add($),$}async function ne(K,X,$,_=new Set){if(!K||K.startsWith("#")||/^data:(?:image|font)\//i.test(K)&&$==="resource")return K;try{const Y=I(K,X);if(!Y){const ge=new URL(K,X);return(ge.protocol!=="https:"||ge.username||ge.password||ge.origin===new URL(d).origin)&&Rt("已阻止不安全的外部资源"),f.add(ge.origin),ge.href}const te=`${$}:${Y.href}`;(_.has(te)||_.size>=8)&&Rt("预览资源存在循环或过深引用");const oe=w.get(te);if(oe)return oe;const ue=new Set(_);ue.add(te);const O=(async()=>{const ge=await Z(Y);return $==="css"?re(await de(new TextDecoder().decode(ge.bytes),Y,ue),"text/css"):$==="script"?re(ge.bytes,"text/javascript"):re(ge.bytes,ge.type)})();return w.set(te,O),await O}catch(Y){return m(Y instanceof Error?Y.message:"部分预览资源未能加载"),xp}}async function de(K,X,$){return K=await Gc(K,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async _=>`@import url("${await ne(_[1],X,"css",$)}")${_[2]};`),Gc(K,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async _=>{const Y=(_[1]??_[2]??_[3]).trim();return p.has(Y)?_[0]:`url("${await ne(Y,X,"resource",$)}")`})}try{const K=await R(E),X=new DOMParser().parseFromString(new TextDecoder().decode(K.bytes),"text/html");X.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(O=>O.remove());for(const O of X.querySelectorAll("*")){if(O.removeAttribute("ping"),O.removeAttribute("srcdoc"),O.hasAttribute("style")&&O.setAttribute("style",await de(O.getAttribute("style"),A,new Set)),O.tagName==="STYLE"&&(O.textContent=await de(O.textContent??"",A,new Set)),O.tagName==="FORM"&&(O.removeAttribute("action"),O.removeAttribute("method")),O.tagName==="A"||O.tagName==="AREA"){const ge=O.getAttribute("href");ge&&!ge.startsWith("#")&&(O.removeAttribute("href"),O.setAttribute("title","预览中的页面跳转已禁用"))}for(const ge of["action","formaction","data","manifest"])O.removeAttribute(ge);if(O.tagName==="SCRIPT"&&O.getAttribute("type")==="module"){O.remove(),m("模块脚本的动态依赖暂不支持安全预览");continue}if(O.tagName==="LINK"){const ge=(O.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(ge)){O.remove();continue}const B=O.getAttribute("href");B&&O.setAttribute("href",await ne(B,A,ge==="stylesheet"?"css":"resource"))}if(O.hasAttribute("src")&&O.setAttribute("src",await ne(O.getAttribute("src"),A,O.tagName==="SCRIPT"?"script":"resource")),O.hasAttribute("poster")&&O.setAttribute("poster",await ne(O.getAttribute("poster"),A,"resource")),O.hasAttribute("srcset")){const ge=O.getAttribute("srcset");/data:/i.test(ge)?(O.removeAttribute("srcset"),m("混合内嵌图片候选暂不支持安全预览")):O.setAttribute("srcset",(await Promise.all(ge.split(",").map(async B=>{const[me,...je]=B.trim().split(/\s+/);return`${await ne(me,A,"resource")} ${je.join(" ")}`}))).join(", "))}O.setAttribute("referrerpolicy","no-referrer"),O.removeAttribute("integrity"),O.removeAttribute("crossorigin")}const $=[...f].join(" "),_=X.createElement("meta");_.httpEquiv="Content-Security-Policy",_.content=`default-src 'none'; script-src 'unsafe-inline' blob: ${$}; style-src 'unsafe-inline' blob: ${$}; img-src blob: data: ${$}; font-src blob: data: ${$}; media-src blob: data: ${$}; connect-src ${$||"'none'"}; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const Y=X.createElement("base");Y.href=d;const te=X.createElement("meta");te.name="referrer",te.content="no-referrer";const oe=X.createElement("script");oe.textContent=vp(c,d,[...f]),X.head.prepend(_,te,Y,oe);const ue=`<!doctype html>
15
+ `+X.documentElement.outerHTML;return{html:ue,shellUrl:`/preview-shell.html#${c}`,errors:h,attach(O,ge){const B=new Set,me=Ee=>{if(Ee.source!==O.contentWindow||Ee.data?.capability!==c)return;if(Ee.data.type==="preview-ready"){O.contentWindow?.postMessage({type:"preview-init",capability:c,html:ue,resources:g},"*");return}if(Ee.data.type==="preview-error"){ge("部分动态内容被安全预览限制");return}if(Ee.data.type!=="preview-fetch"||Ee.ports.length!==1)return;const _e=Ee.ports[0];if(B.size>=8||!["GET","HEAD"].includes(Ee.data.method)){_e.postMessage({error:"预览仅允许读取已授权目录资源"}),_e.close();return}B.add(_e),(async()=>{const bt=S(String(Ee.data.url)),fe=await Z(bt);if(!B.has(_e)||P)return;const he=Ee.data.method==="HEAD"?new Uint8Array:fe.bytes.slice();_e.postMessage({status:fe.status,headers:{"content-type":fe.type},data:he.buffer},[he.buffer])})().catch(()=>{_e.postMessage({error:"预览资源不在授权范围或无法加载"}),ge("部分动态资源不可用或超出预览目录")}).finally(()=>{B.delete(_e),_e.close()})};window.addEventListener("message",me);const je=()=>{window.removeEventListener("message",me);for(const Ee of B)Ee.close();B.clear(),D.delete(je)};return D.add(je),je},dispose:H}}catch(K){throw H(),K}}function vp(t,n,s){return`(() => {
16
+ const capability=${Gi(t)}, base=${Gi(n)}, external=new Set(${Gi(s)});
17
+ const report=()=>parent.postMessage({type:'preview-error',capability},'*');
18
+ const nativeFetch=window.fetch.bind(window);
19
+ Object.defineProperty(window,'fetch',{configurable:false,writable:false,value:async(input,init={})=>{
20
+ const url=new URL(typeof input==='string'?input:input.url||String(input),base);
21
+ const method=String(init.method||(input&&input.method)||'GET').toUpperCase();
22
+ if(!['GET','HEAD'].includes(method)){report();throw new Error('Preview is read-only');}
23
+ if(external.has(url.origin))return nativeFetch(url.href,{...init,method,credentials:'omit',referrerPolicy:'no-referrer'});
24
+ if(url.origin!==new URL(base).origin||!url.pathname.startsWith(new URL(base).pathname)){report();throw new Error('Outside preview scope');}
25
+ return new Promise((resolve,reject)=>{
26
+ const channel=new MessageChannel();const timer=setTimeout(()=>{channel.port1.close();report();reject(new Error('Preview resource timeout'));},15000);
27
+ channel.port1.onmessage=e=>{clearTimeout(timer);channel.port1.close();if(e.data.error){report();reject(new Error(e.data.error));}else resolve(new Response(method==='HEAD'?null:e.data.data,{status:e.data.status,headers:e.data.headers}));};
28
+ parent.postMessage({type:'preview-fetch',capability,url:url.href,method},'*',[channel.port2]);
29
+ });
30
+ }});
31
+ for(const name of ['XMLHttpRequest','WebSocket','EventSource','Worker','SharedWorker'])Object.defineProperty(window,name,{configurable:false,writable:false,value:function(){report();throw new Error(name+' is unavailable in secure preview');}});
32
+ Object.defineProperty(window,'open',{configurable:false,writable:false,value:()=>{report();return null;}});
33
+ document.addEventListener('submit',e=>{e.preventDefault();report();},true);
34
+ document.addEventListener('click',e=>{const a=e.target.closest&&e.target.closest('a,area');if(a&&a.getAttribute('href')&&!a.getAttribute('href').startsWith('#')){e.preventDefault();report();}},true);
35
+ window.addEventListener('securitypolicyviolation',report);
36
+ window.addEventListener('error',report,true);
37
+ window.addEventListener('unhandledrejection',report);
38
+ })();`}const wp=i.forwardRef(function({src:n,title:s,exitFullscreenLabel:l,onFullscreenChange:c},d){const h=i.useRef(null),m=i.useRef(null),[p,g]=i.useState(),[f,y]=i.useState("");i.useEffect(()=>{const E=new AbortController;let M;return g(void 0),y(""),(async()=>{const G=await Yf();if(M=await bp(n,{fetch:(F,a)=>G.fetch(F,a),signal:E.signal}),E.signal.aborted){M.dispose();return}g(M),M.errors.length&&y(M.errors.join(";"))})().catch(G=>{E.signal.aborted||y(G instanceof Error?G.message:"安全预览加载失败")}),()=>{E.abort(),M?.dispose()}},[n]),i.useEffect(()=>{if(!(!p||!m.current))return p.attach(m.current,y)},[p]);const[w,C]=i.useState(!1),[P,D]=i.useState(!1),H=w||P;i.useEffect(()=>{c?.(H)},[H,c]),i.useEffect(()=>{const E=()=>{C(document.fullscreenElement===h.current)};return document.addEventListener("fullscreenchange",E),()=>document.removeEventListener("fullscreenchange",E)},[]),i.useEffect(()=>{if(!P)return;const E=M=>{M.key==="Escape"&&D(!1)};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[P]);const R=i.useCallback(async()=>{const E=h.current;if(E){if(P){D(!1);return}if(document.fullscreenElement===E){await document.exitFullscreen();return}if(E.requestFullscreen&&document.fullscreenEnabled!==!1)try{await E.requestFullscreen();return}catch{}D(!0)}},[P]);i.useImperativeHandle(d,()=>({toggleFullscreen:R}),[R]);const A=e.jsxs("div",{ref:h,"data-html-preview-frame":!0,className:H?"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:[H&&e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/15 bg-[var(--chrome-bg)] px-3",children:[e.jsx("span",{className:"min-w-0 truncate text-[12px] font-semibold",children:s}),e.jsx("button",{type:"button",onClick:()=>{R()},"aria-label":l,title:`${l} (Esc)`,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:e.jsx(Cd,{size:15})})]}),f&&e.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:f}),!p&&!f&&e.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),e.jsx("iframe",{ref:m,src:p?.shellUrl,referrerPolicy:"no-referrer",title:s,sandbox:"allow-scripts",className:"block min-h-0 w-full flex-1 border-0 bg-white"})]});return P?Wr.createPortal(A,document.body):A}),Bd="termdock-file-search-match",wo="termdock-file-search-current";function yp(t){const n=t.metaKey||t.ctrlKey,s=t.key.toLocaleLowerCase();return n&&s==="f"?"open":n&&s==="g"||t.key==="F3"?t.shiftKey?"previous":"next":t.key==="Escape"?"close":null}function kp(t){return t.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function Sp(t,n){const s=n.trim().toLocaleLowerCase();if(!s)return[];const l=[];let c="",d=null;const h=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let f=h.nextNode();f;f=h.nextNode()){if(!(f instanceof Text)||!f.data)continue;const y=kp(f);if(!y)continue;d&&d!==y&&(c+=`
39
+ `);const w=c.length;c+=f.data,l.push({node:f,start:w,end:c.length,group:y}),d=y}const m=c.toLocaleLowerCase(),p=[];let g=0;for(;g<=m.length-s.length;){const f=m.indexOf(s,g);if(f<0)break;const y=f+s.length,w=l.find(P=>P.start<=f&&P.end>f),C=l.find(P=>P.start<y&&P.end>=y);if(w&&C&&w.group===C.group){const P=document.createRange();P.setStart(w.node,f-w.start),P.setEnd(C.node,y-C.start),p.push(P)}g=f+Math.max(s.length,1)}return p}function zd(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function Na(){const t=zd();t?.delete(Bd),t?.delete(wo)}function Uc(t,n){const s=zd();if(!s||typeof Highlight>"u")return;s.set(Bd,new Highlight(...t));const l=t[n];l?s.set(wo,new Highlight(l)):s.delete(wo)}function Kc(t){t?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function jp(t){return Array.from(new Set(t.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Rp(t,n){const s=n.trim();return!s||s==="."?t:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${t.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Np(t,n){if(n===t)return".";const s=`${t.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function Hd(t,n,s){return n?t:Wr.createPortal(t,s)}const Lo="termdock:right-sidebar:file-tree-scroll:v1",Fo="termdock:right-sidebar:file-preview-reading-state:v1",xs="termdock:right-sidebar:file-tree-width:v1",Od="termdock:right-sidebar:markdown-view-mode:v1",Wd="termdock:right-sidebar:diff-change-list-mode:v1",Gd="termdock:right-sidebar:diff-wrap:v1",Ud="termdock:diff-viewer:view-type:v1",Kd="termdock:right-sidebar:file-search-mode:v1",Ui="termdock:right-sidebar:collapsed-git-repo-groups:v1",qc="termdock:right-sidebar:collapsed-diff-directories:v1",Ki="termdock:right-sidebar:branch-audit-module-open:v1",qd="termdock:right-sidebar:branch-audit-module:v1",Cp=150,Vd="termdock:right-sidebar:active-git-repo:v1",Vc="termdock:right-sidebar:context-draft-enabled:v1",Yc="termdock:right-sidebar:context-draft-collapsed:v1",Xc="termdock:right-sidebar:context-draft-auto-collapse:v1",qi="termdock:right-sidebar:context-draft-text:v1",Ap=300,$p=20,Ep=120,Mp=250,Tp=250,Pp=120,Lp=700,Vi=600,Zc=[2e3,5e3,15e3,3e4],Fp=320,Dp=500,_p=20,Ip=12e3,yo=300,Qc=240,Bp=560,Yd="border-r px-2 py-1.5 sm:px-3 sm:py-2",Ia="max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",Xd=`${Yd} border-b border-border/15 font-semibold last:border-r-0`,Zd=`${Yd} border-border/10 align-top text-muted-foreground last:border-r-0`,Do="termdock-file-preview-horizontal-scroll",Jc=i.lazy(()=>js(()=>import("./ModelPreview-DpImj4vY.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Qd=`${Do} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function Jd(t,n,s){return t&&!n?"unified":s}const zp=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function Hp(t){return t==="preview"||t==="source"}function Op(t){return t==="list"||t==="tree"||t==="ai"}function ed(){return Qe(Od,Hp)??"preview"}function Wp(){return Qe(Wd,Op)??"tree"}function bs(t){return typeof t=="boolean"}function Gp(t){return typeof t=="string"}function Up(){return Qe(Gd,bs)??!0}function Kp(t){return t==="unified"||t==="split"}function qp(){return Qe(Ud,Kp)??"unified"}function Vp(t){return t==="name"||t==="content"||t==="regex"}function Yp(){return Qe(Kd,Vp)??"name"}function eu(t){return t.repositories??(t.context?.root?[{id:t.context.root,root:t.context.root,relativeRoot:".",name:dt(t.context.root)||t.context.root,depth:0,nested:!1,available:t.available,files:t.files,context:t.context,error:t.error}]:[])}function Xp(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(n=>n===null||typeof n=="string")}function tu(){return Qe(Vd,Xp)??{}}function td(t){if(!t)return;const n=tu();return Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0}function Yi(t,n){t&&pt(Vd,{...tu(),[t]:n})}function Zp(t,n){if(!n)return null;const s=new Set((t.repoFilters??[]).map(l=>l.root));return s.has(n)?n:s.size>0?null:(t.repositories??[]).some(l=>l.root===n)?n:null}function ko(t){return Array.isArray(t)&&t.every(n=>typeof n=="string")}function rd(t){const n=Qe(t,ko);return n?new Set(n):new Set}function Xi(t,n){pt(t,[...n])}function Qp(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return typeof n.filePath=="string"&&typeof n.hunkHeader=="string"&&typeof n.hunkIndex=="number"&&typeof n.fingerprint=="string"&&typeof n.additions=="number"&&typeof n.deletions=="number"&&typeof n.diff=="string"&&(n.oldPath===void 0||n.oldPath===null||typeof n.oldPath=="string")&&(n.newPath===void 0||n.newPath===null||typeof n.newPath=="string")&&(n.source===void 0||n.source==="committed"||n.source==="uncommitted"||n.source==="unknown")&&(n.commit===void 0||n.commit===null||typeof n.commit=="string")}function Jp(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return typeof n.available=="boolean"&&(n.repoRoot===void 0||typeof n.repoRoot=="string")&&(n.workspaceRoot===void 0||typeof n.workspaceRoot=="string")&&(n.baseRef===void 0||typeof n.baseRef=="string")&&(n.baseBranch===void 0||typeof n.baseBranch=="string")&&(n.currentBranch===void 0||n.currentBranch===null||typeof n.currentBranch=="string")&&(n.headRef===void 0||n.headRef===null||typeof n.headRef=="string")&&(n.diffFingerprint===void 0||typeof n.diffFingerprint=="string")&&(n.stat===void 0||typeof n.stat=="string")&&(n.files===void 0||ko(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(Qp))&&(n.commits===void 0||ko(n.commits))&&(n.commitCount===void 0||typeof n.commitCount=="number")&&(n.diff===void 0||typeof n.diff=="string")&&(n.truncated===void 0||typeof n.truncated=="boolean")&&(n.error===void 0||typeof n.error=="string")}function eg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return typeof n.key=="string"&&Jp(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function tg(t){return!t||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(n=>{if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;return Array.isArray(s.selectedRepoRoots)&&s.selectedRepoRoots.every(l=>typeof l=="string")&&!!s.repoTargetBranches&&typeof s.repoTargetBranches=="object"&&!Array.isArray(s.repoTargetBranches)&&Object.values(s.repoTargetBranches).every(l=>typeof l=="string")&&(s.repoBaseBranches===void 0||!!s.repoBaseBranches&&typeof s.repoBaseBranches=="object"&&!Array.isArray(s.repoBaseBranches)&&Object.values(s.repoBaseBranches).every(l=>typeof l=="string"))&&(s.previewEntries===void 0||Array.isArray(s.previewEntries)&&s.previewEntries.every(eg))&&(s.selectedPreviewKey===void 0||s.selectedPreviewKey===null||typeof s.selectedPreviewKey=="string")&&(s.selectedPreviewFileKey===void 0||s.selectedPreviewFileKey===null||typeof s.selectedPreviewFileKey=="string")&&(s.previewDetailOpen===void 0||typeof s.previewDetailOpen=="boolean")&&(s.previewScrollTops===void 0||!!s.previewScrollTops&&typeof s.previewScrollTops=="object"&&!Array.isArray(s.previewScrollTops)&&Object.values(s.previewScrollTops).every(l=>typeof l=="number"))&&(s.previewMobileSlideIndex===void 0||typeof s.previewMobileSlideIndex=="number")&&(s.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function nd(){return Qe(qd,tg)??{}}function sd(t){return[t.repoRoot,t.baseRef,t.branchName??"",t.headRef??"",t.diffFingerprint??""].join("\0")}function ad(t){const n=t?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function ru(t,n){const s=t?.trim(),l=n?.trim();return!s||!l?!1:s===l||ad(s)===ad(l)}function id(t){const n=t?.branch??null;return[t?.upstream,...t?.remoteBranches??[],...t?.branches??[]].find(l=>l&&!ru(l,n))??""}function So(t,n){const s=Math.max(Qc,n-320),l=Math.min(Bp,s);return Math.min(l,Math.max(Qc,t))}function rg(t){return typeof t=="number"&&Number.isFinite(t)}function ng(t){return So(Qe(xs,rg)??yo,t)}function nu(t){const n=t.split(/[\\/]/).pop()??t,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function ms(t){return zp.has(nu(t))}function su(t){const n=t.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function jo(t){const n=t.trim();return/^#{1,6}\s+/.test(n)||su(t)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function sg(t){const n=t.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const au=i.createContext(null);function Fa(t){return t.trim().replace(/\s+/g," ").toLowerCase()}function iu(t){return t.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function ou(t){return t.replace(/\s+#+\s*$/,"").trim()}function Ro(t,n){const l=iu(t).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",c=n.headingSlugCounts.get(l)??0;return n.headingSlugCounts.set(l,c+1),c===0?l:`${l}-${c}`}function od(t){return iu(t)||t.trim()}function Ba(t){const n=t.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=Co(n[2]);return s?{id:Fa(n[1]),definition:{href:s.href,title:s.title}}:null}function ag(t){const n=new Map;for(const s of t){const l=Ba(s);l&&n.set(l.id,l.definition)}return n}function lu(t){return t.trim().toLowerCase()}function cu(t){const n=t.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:lu(n[1]),text:n[2]}:null}function ig(t){const n=new Map;let s=null;for(const l of t){const c=cu(l);if(c){s=c.id,n.set(c.id,{id:c.id,text:c.text,index:n.size+1});continue}if(s&&/^\s{4,}\S/.test(l)){const d=n.get(s);d&&(d.text=`${d.text} ${l.trim()}`);continue}l.trim()&&(s=null)}return n}function du(t){const n=new Set;let s=!1;return t.forEach((l,c)=>{if(cu(l)){n.add(c),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(c);return}l.trim()&&(s=!1)}),n}function og(t){const n=[...t];let s=0;const l=t[0]?.trim();if(l==="---"||l==="+++"){for(n[0]="",s=1;s<t.length&&t[s].trim()!==l;)n[s]="",s+=1;s<t.length&&(n[s]="",s+=1)}for(;s<t.length;){const c=t[s].trim();if(c.startsWith("<!--")){if(n[s]="",!c.includes("-->")){for(s+=1;s<t.length&&!t[s].includes("-->");)n[s]="",s+=1;s<t.length&&(n[s]="")}s+=1;continue}s+=1}return n}function uu(t){const n=t.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function ys(t){const n=t.split(/[?#]/,1)[0],s=n.startsWith("/"),l=[];for(const d of n.split("/"))if(!(!d||d===".")){if(d===".."){l.length>0&&l.pop();continue}l.push(d)}return`${s?"/":""}${l.join("/")}`||(s?"/":".")}function fu(t,n,s){const l=t.trim();if(!l||/^(?:https?:|mailto:|javascript:|data:)/i.test(l)||/^[a-z][a-z0-9+.-]*:/i.test(l))return null;if(l.startsWith("#")){if(!n)return null;try{return{path:n,fragment:decodeURIComponent(l.slice(1))||null,directory:!1}}catch{return null}}const c=l.indexOf("#"),d=c>=0?l.slice(0,c):l,h=c>=0?l.slice(c+1):"",m=d.split("?",1)[0];if(!m)return null;let p,g=null;try{p=decodeURIComponent(m),g=h?decodeURIComponent(h):null}catch{return null}const f=s?ys(s):null;let y;if(p.startsWith("/")){const w=f&&(p===f||p.startsWith(`${f}/`));y=ys(f&&!w?`${f}/${p.slice(1)}`:p)}else{if(!n)return null;y=ys(`${uu(n)}/${p}`)}return f&&y!==f&&!y.startsWith(`${f}/`)?null:{path:y,fragment:g,directory:/\/$/.test(m)}}function lg(t,n,s){const l=t.trim();if(!l||/^(?:javascript|data):/i.test(l))return null;if(/^https?:\/\//i.test(l))return l;if(!vd(l.split(/[?#]/,1)[0]))return null;let c;if(l.startsWith("/")){const d=s&&(l===s||l.startsWith(`${s}/`));c=ys(s&&!d?`${s}/${l.slice(1)}`:l)}else{if(!n)return null;c=ys(`${uu(n)}/${l}`)}return`/api/terminal/fs/blob?path=${encodeURIComponent(c)}`}const No=128,cg=360,Zi=480;function Ka(t){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(t))}catch{return!1}}function hu(t,n,s,l){if(!n||!s)return null;let c,d;return Ka(t)?(d=Math.min(Math.max(s,No),cg),c=n*d/s):(c=n,d=s),l>0&&c>l&&(d=d*l/c,c=l),d>Zi&&(c=c*Zi/d,d=Zi),{width:Math.max(1,Math.round(c)),height:Math.max(1,Math.round(d))}}function dg(t){if(!t.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(t.slice(t.indexOf("?"))).get("path")}catch{return null}}function mu(t){const n=dg(t),s=ae(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${t}&v=${s}`:t}function ug({src:t,alt:n,title:s}){const l=Ka(t),c=mu(t),d=Po(c),h=i.useRef(null),[m,p]=i.useState(!1),[g,f]=i.useState(0),[y,w]=i.useState({status:"loading"}),[C,P]=i.useState(null);i.useLayoutEffect(()=>{const R=h.current,A=R?.parentElement?.parentElement??R?.parentElement;if(!A)return;const E=()=>f(A.clientWidth);if(E(),typeof ResizeObserver>"u")return;const M=new ResizeObserver(E);return M.observe(A),()=>M.disconnect()},[]),i.useEffect(()=>{if(m)return;const R=h.current;if(!R||typeof IntersectionObserver>"u"){p(!0);return}const A=new IntersectionObserver(E=>{E.some(M=>M.isIntersecting)&&(p(!0),A.disconnect())},{rootMargin:"400px"});return A.observe(R),()=>A.disconnect()},[m]),i.useEffect(()=>{if(!m)return;const R=new AbortController;let A=null;w({status:"loading"});const E=window.setTimeout(()=>{R.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return Rh(c,{signal:R.signal}).then(async M=>{if(!M.ok)throw new Error(`HTTP ${M.status}`);const G=Number(M.headers.get("X-Image-Width"))||0,F=Number(M.headers.get("X-Image-Height"))||0;return{blob:await M.blob(),width:G,height:F}}).then(({blob:M,width:G,height:F})=>{R.signal.aborted||(A=URL.createObjectURL(M),G>0&&F>0&&P({width:G,height:F}),w({status:"ready",objectUrl:A}))}).catch(()=>{const M=R.signal.reason;R.signal.aborted&&!(M instanceof DOMException&&M.name==="TimeoutError")||w({status:"fallback"})}).finally(()=>{window.clearTimeout(E)}),()=>{window.clearTimeout(E),R.abort(),A&&URL.revokeObjectURL(A)}},[m,c]);const D=hu(t,C?.width??0,C?.height??0,g),H=D??{width:No*2,height:No};return e.jsx("div",{ref:h,className:"block max-w-full",style:D?{width:D.width,height:D.height}:void 0,children:y.status==="ready"?e.jsx("img",{src:y.objectUrl,alt:n,title:s,decoding:"async",className:`${l?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:D?{width:D.width,height:D.height}:void 0,onLoad:R=>{if(C)return;const A=R.currentTarget;A.naturalWidth>0&&A.naturalHeight>0&&P({width:A.naturalWidth,height:A.naturalHeight})}}):y.status==="fallback"?e.jsx("img",{src:d,alt:n,title:s,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:D?{width:D.width,height:D.height}:void 0,onLoad:R=>{if(C)return;const A=R.currentTarget;A.naturalWidth>0&&A.naturalHeight>0&&P({width:A.naturalWidth,height:A.naturalHeight})}}):e.jsx("div",{"aria-hidden":!0,className:"flex max-w-full animate-pulse items-center justify-center rounded bg-surface-elevated/60",style:{width:H.width,height:H.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function Qi(t,n,s,l,c){const d=lg(s,c.markdownFilePath,c.rootPath);if(!d)return`![${n}](${s})`;const h=c.images.length;c.images.push({kind:"image",src:d,alt:n,title:l});const m=e.jsx(ug,{src:d,alt:n,title:l});return c.onImageOpen?e.jsx("button",{type:"button",className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2 text-left transition hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-ring/45",title:l||n||"Open image",onClick:p=>{p.stopPropagation(),c.onImageOpen?.(h)},children:m},t):e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:m},t)}function Ji(t){let n=t,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function ld(t){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(t)}function Co(t){const n=t.trim(),s=n.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(s)return{href:s[1],title:s[2]??s[3]??s[4]};const l=n.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return l?{href:l[1],title:l[2]??l[3]??l[4]}:null}const pu="",fg=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function hg(t){return t.replace(fg,(n,s)=>`${pu}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function cd(t){return t.replace(new RegExp(`${pu}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function mg(t){const n=t.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const gu={ALLOWED_TAGS:["a","abbr","b","blockquote","br","code","del","details","div","em","i","kbd","li","mark","ol","p","pre","s","span","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],ALLOWED_ATTR:["href","title","class","id","colspan","rowspan"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0};let Ca=null;function xu(){return Ca||(Ca=js(()=>import("./purify.es-4eNOHKSq.js"),[]).then(t=>t.default??t).catch(t=>{throw Ca=null,t})),Ca}function bu({html:t}){const{t:n}=xt(),[s,l]=i.useState(null);return i.useEffect(()=>{let c=!1;return l(null),xu().then(d=>{c||l(d.sanitize(t,gu))}).catch(()=>{c||l("")}),()=>{c=!0}},[t]),s===null?e.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:n("rightSidebar.renderingHtml")}):s?e.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:s}}):null}function pg({html:t}){const[n,s]=i.useState(null);return i.useEffect(()=>{let l=!1;return s(null),xu().then(c=>{l||s(c.sanitize(t,gu))}).catch(()=>{l||s("")}),()=>{l=!0}},[t]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):t}function vu(t){const n=t.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!n)return null;const s=n[1].toLowerCase();return{tag:s,selfContained:new RegExp(`</${s}>`,"i").test(t)}}let Aa=null;function gg(){return Aa||(Aa=Promise.all([js(()=>import("./katex-DnlPpQZa.js"),[]),js(()=>Promise.resolve({}),__vite__mapDeps([16]))]).then(([t])=>t.default??t).catch(t=>{throw Aa=null,t})),Aa}function Ns({tex:t,display:n=!1}){const[s,l]=i.useState(null),[c,d]=i.useState(!1);if(i.useEffect(()=>{let m=!1;return l(null),d(!1),gg().then(p=>{m||l(p.renderToString(t,{displayMode:n,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{m||d(!0)}),()=>{m=!0}},[n,t]),c)return e.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:n?`$$${t}$$`:`$${t}$`});if(!s)return e.jsx("span",{className:"text-muted-foreground/70",children:n?"Rendering formula...":t});const h=n?"my-2 overflow-auto rounded-md bg-surface-2 px-3 py-2 text-center":"inline-block align-middle";return e.jsx("span",{className:h,dangerouslySetInnerHTML:{__html:s}})}function xg(t,n,s){if(/^<br\s*\/?>$/i.test(t))return e.jsx("br",{},n);const l=t.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!l)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(t)?e.jsx(pg,{html:t},n):null;const c=l[1].toLowerCase(),d=Je(l[2],`${n}-${c}`,!0,s);return c==="kbd"?e.jsx("kbd",{className:"rounded border border-border/30 bg-surface-2 px-1.5 py-0.5 font-mono text-[0.85em] text-foreground shadow-sm",children:d},n):c==="mark"?e.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:d},n):c==="sub"?e.jsx("sub",{children:d},n):e.jsx("sup",{children:d},n)}function Je(t,n,s=!0,l){const c=hg(t),d=/(\\\([^)]*\\\)|\$[^$\n]+\$|<br\s*\/?>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\b[\s\S]*?<\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\[[^\]]*\]\((?:<[^>]+>|(?:[^\s()]+|\([^()\s]*\))+)(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\)|!?\[[^\]]+\]\[[^\]]*\]|!?\[[^\]]+\]|\[\^[^\]]+\]|(`+)([\s\S]*?)\2|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|\*[^*\s][^*]*\*|_[^_\s][^_]*_|<https?:\/\/[^>\s]+>|<[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+>|https?:\/\/[^\s<]+|www\.[^\s<]+|[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+)/gi,h=[];let m=0,p;for(;(p=d.exec(c))!==null;){p.index>m&&h.push(cd(c.slice(m,p.index)));const g=p[0],f=`${n}-${p.index}`,y=g.startsWith("<")?xg(g,f,l):null;if(y)h.push(y);else if(g.startsWith("\\(")&&g.endsWith("\\)"))h.push(e.jsx(Ns,{tex:g.slice(2,-2)},f));else if(g.startsWith("$")&&g.endsWith("$"))h.push(e.jsx(Ns,{tex:g.slice(1,-1)},f));else if(g.startsWith("`")){const w=g.match(/^`+/)?.[0].length??1;h.push(e.jsx("code",{className:`${s?"break-all":"whitespace-nowrap"} rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground`,children:mg(g.slice(w,-w))},f))}else if(g.startsWith("~~"))h.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:Je(g.slice(2,-2),`${f}-del`,s,l)},f));else if(g.startsWith("**")||g.startsWith("__"))h.push(e.jsx("strong",{className:"font-semibold text-foreground",children:Je(g.slice(2,-2),`${f}-strong`,s,l)},f));else if(g.startsWith("*")||g.startsWith("_"))h.push(e.jsx("em",{className:"italic",children:Je(g.slice(1,-1),`${f}-em`,s,l)},f));else if(g.startsWith("![")){const w=g.match(/^!\[([^\]]*)\]\((.*)\)$/),C=g.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),P=g.match(/^!\[([^\]]+)\]$/);if(w){const D=Co(w[2]);h.push(D?Qi(f,w[1],D.href,D.title,l):g)}else if(C){const D=C[2]||C[1],H=l.referenceDefinitions.get(Fa(D));h.push(H?Qi(f,C[1],H.href,H.title,l):g)}else if(P){const D=l.referenceDefinitions.get(Fa(P[1]));h.push(D?Qi(f,P[1],D.href,D.title,l):g)}else h.push(g)}else if(g.startsWith("[^")){const w=lu(g.slice(2,-1)),C=l.footnoteDefinitions.get(w);h.push(C?e.jsx("sup",{id:`fnref-${C.id}`,title:C.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:e.jsx("a",{href:`#fn-${C.id}`,className:"text-primary no-underline",children:C.index})},f):g)}else if(g.startsWith("<http")){const w=g.slice(1,-1);h.push(e.jsx("a",{href:w,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:w},f))}else if(g.startsWith("<")&&g.endsWith(">")&&ld(g.slice(1,-1))){const w=g.slice(1,-1);h.push(e.jsx("a",{href:`mailto:${w}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:w},f))}else if(ld(Ji(g).linkText)){const{linkText:w,suffix:C}=Ji(g);h.push(e.jsx("a",{href:`mailto:${w}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:w},f)),C&&h.push(C)}else if(g.startsWith("http")||g.startsWith("www.")){const{linkText:w,suffix:C}=Ji(g),P=w.startsWith("www.")?`https://${w}`:w;h.push(e.jsx("a",{href:P,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:w},f)),C&&h.push(C)}else{const w=g.match(/^\[([^\]]+)\]\((.*)\)$/),C=g.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),P=g.match(/^\[([^\]]+)\]$/),D=C?C[2]||C[1]:P?.[1]??null,H=D?l.referenceDefinitions.get(Fa(D)):null,R=w?Co(w[2]):null,A=R?.href??H?.href??null,E=A?sg(A):null,M=w?.[1]??C?.[1]??P?.[1]??"";h.push(E?e.jsx("a",{href:E,title:R?.title??H?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:Je(M,`${f}-link`,s,l)},f):g)}m=d.lastIndex}return m<c.length&&h.push(cd(c.slice(m))),h.length>0?h:[t]}function wu(t){return/(?: {2,}|\\)$/.test(t)}function yu(t){return t.replace(/(?: {2,}|\\)$/,"")}function za(t){return/^(?: {4}|\t)/.test(t)}function ku(t){return t.startsWith(" ")?t.slice(1):t.replace(/^ {4}/,"")}function Su(t,n,s){const l=[];return t.forEach((c,d)=>{const h=wu(c);l.push(...Je(yu(c),`${n}-${d}`,!0,s)),d<t.length-1&&l.push(h?e.jsx("br",{},`${n}-${d}-br`):" ")}),l}function Ao(t,n,s){const l=[],c=[];return t.forEach((d,h)=>{c.push(wu(d)),l.push(Je(yu(d),`${n}-${h}`,!0,s))}),{perLine:l,hardBreaks:c}}function $o(t,n,s,l,c){const d=[];return t.forEach((h,m)=>{const p=s[m]??0,g=!!(c&&p>=c.start&&p<=c.end);d.push(e.jsx("span",{"data-md-ref-start":p,"data-md-ref-end":p,"data-selected":g?"true":void 0,children:h},`${l}-ref-${m}`)),m<t.length-1&&d.push(n[m]?e.jsx("br",{},`${l}-${m}-br`):" ")}),d}function Cs(t){const n=t.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let l="",c=!1,d=0,h=0;for(let m=0;m<n.length;m+=1){const p=n[m];if(c){l+=p,c=!1;continue}if(p==="\\"){c=!0;continue}if(p==="`"){const g=m;for(;m+1<n.length&&n[m+1]==="`";)m+=1;const f=m-g+1;l+="`".repeat(f),d===0?d=f:d===f&&(d=0);continue}if(d===0&&p==="["?h+=1:d===0&&p==="]"&&h>0&&(h-=1),p==="|"&&d===0&&h===0){s.push(l.trim()),l="";continue}l+=p}return c&&(l+="\\"),s.push(l.trim()),s}function ju(t){return Cs(t).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function Ha(t){return t==="center"?"text-center":t==="right"?"text-right":"text-left"}function Oa(t){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(t.trim())}function Ru(t,n){return t>96||t>44&&n>.35}function qa(t){return(t.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function As(t){const n=t.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!n)return null;const s=/^\d+[.)]$/.test(n[1]);return{ordered:s,start:s?Number.parseInt(n[1],10):void 0,content:n[2]}}function _o(t,n,s,l,c,d=new Set){const h=[],m=[];let p=n;for(;p<t.length;){const g=t[p];if(c&&(Ba(g)||d.has(p))){p+=1;continue}const f=As(g),y=qa(g);if(!f){if(y>s&&m.length>0){([...m].reverse().find(D=>D.indent<y)?.item??m[m.length-1].item).paragraphs.push(g.trim());for(const D of m)D.item.lineEnd=p+1;p+=1;continue}break}if(y<s||y===s&&f.ordered!==l)break;const w={content:f.content,ordered:f.ordered,start:f.start,children:[],paragraphs:[],lineStart:p+1,lineEnd:p+1};for(;m.length>0&&m[m.length-1].indent>=y;)m.pop();const C=m[m.length-1]?.item??null;C?C.children.push(w):h.push(w),m.push({indent:y,item:w});for(const P of m)P.item.lineEnd=p+1;p+=1}return{items:h,nextIndex:p}}function bg(t){const n=t.find(l=>As(l));if(!n)return[];const s=As(n);return s?_o(t,0,qa(n),s.ordered,!0,du(t)).items:[]}function Io(t,n,s,l=0){return t.map((c,d)=>{const h=c.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${d}`,taskItem:!!h,refStart:c.lineStart+l,refEnd:c.lineEnd+l,content:e.jsxs(e.Fragment,{children:[h?e.jsx("input",{type:"checkbox",checked:h[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,Je(h?.[2]??c.content,`li-${n}-${d}`,!0,s),c.paragraphs.length>0&&e.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:c.paragraphs.map((m,p)=>e.jsx("p",{children:Je(m,`li-${n}-${d}-p-${p}`,!0,s)},`paragraph-${p}`))})]}),groups:vg(c.children,`${n}-${d}`,s,l)}})}function vg(t,n,s,l=0){const c=[];for(const d of t){const h=c[c.length-1];h&&h.ordered===d.ordered?h.items.push(d):c.push({ordered:d.ordered,items:[d]})}return c.map((d,h)=>({ordered:d.ordered,start:d.ordered?d.items[0]?.start:void 0,items:Io(d.items,`${n}-g${h}`,s,l)}))}function Bo(t,n){return t.map(s=>{const l=!!(n&&s.refStart<=n.end&&s.refEnd>=n.start);return e.jsxs("li",{className:s.taskItem?"list-none":void 0,"data-md-ref-start":s.refStart,"data-md-ref-end":s.refEnd,"data-selected":l?"true":void 0,children:[s.content,s.groups.length>0&&wg(s.groups,n)]},s.key)})}function wg(t,n){return t.map((s,l)=>{const c=s.ordered?"ol":"ul";return e.jsx(c,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:Bo(s.items,n)},`nested-${l}`)})}function yg(t){const n=Array.from(t.footnoteDefinitions.values()).sort((s,l)=>s.index-l.index);return n.length===0?null:e.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:t.footnotesLabel}),e.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:n.map(s=>e.jsxs("li",{id:`fn-${s.id}`,children:[Je(s.text,`footnote-${s.id}`,!0,t)," ",e.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":t.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function kg(t,n,s,l){const c=[];let d=0;const h=m=>l?.[m]??m+1;for(;d<t.length;){const m=t[d],p=m.trim();if(!p){d+=1;continue}if(/^<details>\s*$/i.test(p)){const R=d;let A="Details";const E=[];for(d+=1;d<t.length&&!/^<\/details>\s*$/i.test(t[d].trim());){const M=t[d].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);M?A=M[1].trim()||A:E.push(t[d].trimStart()),d+=1}d<t.length&&(d+=1),c.push({kind:"static",node:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:Je(A,`${n}-details-${R}-summary`,!0,s)}),E.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:Su(E,`${n}-details-${R}`,s)})]},`${n}-details-${R}`)});continue}const g=vu(m);if(g){const R=[m],A=d;for(d+=1;d<t.length&&!g.selfContained&&!new RegExp(`</${g.tag}>`,"i").test(t[d]);)R.push(t[d]),d+=1;d<t.length&&!g.selfContained&&(R.push(t[d]),d+=1),c.push({kind:"static",node:e.jsx(bu,{html:R.join(`
40
+ `)},`${n}-html-${A}`)});continue}const f=p.match(/^(```|~~~)\s*(.*)$/);if(f){const R=[],A=f[1],E=f[2]?.trim(),M=d;for(d+=1;d<t.length&&!t[d].trim().startsWith(A);)R.push(t[d]),d+=1;d<t.length&&(d+=1),E.toLowerCase()==="mermaid"?c.push({kind:"static",node:e.jsx(Cu,{code:R.join(`
41
+ `),blockKey:`${n}-code-${M}`},`${n}-code-${M}`)}):["math","latex","tex"].includes(E.toLowerCase())?c.push({kind:"static",node:e.jsx(Ns,{tex:R.join(`
42
+ `),display:!0},`${n}-code-${M}`)}):c.push({kind:"code",key:`${n}-code-${M}`,code:R.join(`
43
+ `),lang:E,blockKey:`${n}-code-${M}`,codeStartLine:h(M)+1});continue}if(za(m)){const R=[],A=d;for(;d<t.length&&(za(t[d])||!t[d].trim());)R.push(t[d].trim()?ku(t[d]):""),d+=1;c.push({kind:"code",key:`${n}-indented-code-${A}`,code:R.join(`
44
+ `).replace(/\n+$/,""),lang:"",blockKey:`${n}-indented-code-${A}`,codeStartLine:h(A)});continue}const y=p.match(/^(#{1,6})\s+(.+)$/);if(y){const A=`h${Math.min(6,y[1].length+1)}`,E=ou(y[2]),M=Ro(E,s);c.push({kind:"static",node:e.jsx(A,{id:M,className:"scroll-mt-16 font-semibold text-foreground",children:Je(E,`${n}-heading-${d}`,!0,s)},`${n}-heading-${d}`)}),d+=1;continue}if(d+1<t.length&&m.includes("|")&&Oa(t[d+1])){const R=Cs(m),A=ju(t[d+1]),E=[],M=d;for(d+=2;d<t.length&&t[d].includes("|")&&t[d].trim();)E.push(Cs(t[d])),d+=1;c.push({kind:"static",node:e.jsx("div",{className:Qd,"data-markdown-table-scroll":!0,children:e.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[e.jsx("thead",{className:"bg-surface-2 text-foreground",children:e.jsx("tr",{children:R.map((G,F)=>e.jsx("th",{className:`${Xd} ${Ha(A[F]??null)}`,children:e.jsx("div",{className:Ia,children:Je(G,`${n}-th-${M}-${F}`,!0,s)})},`h-${F}`))})}),e.jsx("tbody",{children:E.map((G,F)=>e.jsx("tr",{className:"border-t border-border/10",children:R.map((a,k)=>e.jsx("td",{className:`${Zd} ${Ha(A[k]??null)}`,children:e.jsx("div",{className:Ia,children:Je(G[k]??"",`${n}-td-${M}-${F}-${k}`,!0,s)})},`c-${k}`))},`r-${F}`))})]})},`${n}-table-${M}`)});continue}const w=As(m);if(w){const R=w.ordered,A=qa(m),E=w.start,M=d,G=_o(t,d,A,R,!1);d=G.nextIndex,c.push({kind:"list",keyPrefix:`${n}-list-${M}`,ordered:R,start:R?E:void 0,renders:Io(G.items,`${n}-list-${M}`,s,h(0)-1)});continue}const C=[m.trimStart()],P=[h(d)],D=d;for(d+=1;d<t.length&&t[d].trim()&&!jo(t[d])&&!(d+1<t.length&&t[d].includes("|")&&Oa(t[d+1]));)C.push(t[d].trimStart()),P.push(h(d)),d+=1;const H=Ao(C,`${n}-p-${D}`,s);c.push({kind:"paragraph",keyPrefix:`${n}-p-${D}`,perLine:H.perLine,hardBreaks:H.hardBreaks,lineNums:P})}return c}function Sg(t,n){return t.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return e.jsx("p",{children:$o(s.perLine,s.hardBreaks,s.lineNums,s.keyPrefix,n)},s.keyPrefix);case"list":{const l=s.ordered?"ol":"ul";return e.jsx(l,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} space-y-0.5 pl-4 marker:text-muted-foreground/70`,children:Bo(s.renders,n)},s.keyPrefix)}case"code":return e.jsx(Wa,{code:s.code,lang:s.lang,blockKey:s.blockKey,codeStartLine:s.codeStartLine,lineRange:n},s.key)}})}let $a=null,dd=!1;const Ea=16,Nu=192;function jg(){return $a||($a=js(()=>import("./mermaid.core-91Llsw5j.js").then(t=>t.bl),__vite__mapDeps([17,1,2,3,4,5,18])).then(t=>t.default??t).catch(t=>{throw $a=null,t})),$a}function Rg(t){dd||(t.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),dd=!0)}function Ng(t){const n=t.match(/\sviewBox=(["'])([^"']+)\1/i);if(!n)return t;const[,,s]=n,l=s.trim().split(/[\s,]+/).map(Number),[,,c,d]=l;if(!Number.isFinite(c)||!Number.isFinite(d)||c<=0||d<=0)return t;const h=Math.max(Nu,Math.ceil(c)),m=Math.ceil(h/c*d);return t.replace(/<svg\b([^>]*)>/i,(p,g)=>`<svg${g.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${h}" height="${m}">`)}function Cg(t){const n=t?.querySelector("svg");if(!n)return;let s;try{s=n.getBBox()}catch{return}if(!Number.isFinite(s.width)||!Number.isFinite(s.height)||s.width<=0||s.height<=0)return;const l=s.x-Ea,c=s.y-Ea,d=s.width+Ea*2,h=s.height+Ea*2,m=Math.max(Nu,Math.ceil(d)),p=Math.ceil(m/d*h);n.setAttribute("viewBox",`${l} ${c} ${d} ${h}`),n.setAttribute("width",String(m)),n.setAttribute("height",String(p)),n.removeAttribute("style")}function Ag(t){const n=t.trim().split(/\s+/,1)[0]?.toLowerCase();if(!n)return null;const s=n.replace(/^language-/,"");return $d(`code.${s}`)??s}function Cu({code:t,blockKey:n}){const{t:s}=xt(),[l,c]=i.useState(null),[d,h]=i.useState(!1),m=i.useRef(null),p=i.useContext(au);i.useEffect(()=>{let f=!1;return c(null),h(!1),jg().then(async y=>{Rg(y);const w=`termdock-md-mermaid-${n.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:C}=await y.render(w,t);f||c(Ng(C))}).catch(()=>{f||h(!0)}),()=>{f=!0}},[n,t]),i.useLayoutEffect(()=>{l&&Cg(m.current)},[l]);const g=i.useCallback(()=>{const f=m.current?.querySelector("svg")?.outerHTML??l;f&&p?.(f)},[p,l]);return d?e.jsx(Wa,{code:t,lang:"mermaid",blockKey:`${n}-fallback`}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[e.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"mermaid"}),e.jsx("div",{className:"bg-surface p-3",children:l?e.jsx("button",{type:"button",className:"block max-w-full rounded text-left focus:outline-none focus:ring-2 focus:ring-ring/45",title:s("rightSidebar.openMermaidDiagram"),onClick:f=>{f.stopPropagation(),g()},children:e.jsx("span",{ref:m,role:"img","aria-label":s("rightSidebar.mermaidDiagram"),className:"block max-h-[70vh] max-w-full overflow-auto rounded bg-white p-2 text-slate-900 [&_svg]:block [&_svg]:h-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:l}})}):e.jsx("div",{className:"py-6 text-center text-xs text-muted-foreground",children:s("rightSidebar.renderingDiagram")})})]})}function Wa({code:t,lang:n,blockKey:s,codeStartLine:l,lineRange:c}){const d=Ag(n),[h,m]=i.useState(null);i.useEffect(()=>{if(!d||!Ed(t)){m(null);return}let g=!1;return Md().then(f=>{if(g||!f.registered(d)){g||m(null);return}try{m(Pd(f,t,d))}catch{g||m(null)}}).catch(()=>{g||m(null)}),()=>{g=!0}},[s,t,d]);const p=h??(t||" ").split(`
45
+ `).map(g=>[g||" "]);return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[n&&e.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:n}),e.jsx("pre",{className:`${Do} termdock-code overflow-auto p-3 text-[11px] leading-relaxed text-foreground`,children:e.jsx("code",{children:p.map((g,f)=>{const y=l!=null?l+f:null,w=!!(c&&y!=null&&y>=c.start&&y<=c.end);return e.jsxs("span",{"data-md-ref-start":y??void 0,"data-md-ref-end":y??void 0,"data-selected":w?"true":void 0,children:[g,f<p.length-1?`
46
+ `:null]},`${s}-line-${f}`)})})})]})}function zo(t,n,s,l,c){t=og(t);const d=ag(t),h=du(t),m=[],p={markdownFilePath:n,rootPath:s,referenceDefinitions:d,footnoteDefinitions:ig(t),headingSlugCounts:new Map,images:m,onImageOpen:l,footnotesLabel:c?.footnotes??"Footnotes",backToFootnoteLabel:c?.backToFootnote??(w=>`Back to footnote ${w}`)},g=[];let f=0;for(;f<t.length;){const w=t[f],C=w.trim();if(Ba(w)||h.has(f)){f+=1;continue}if(!C){f+=1;continue}if(/^<details>\s*$/i.test(C)){const F=f;let a="Details";const k=[];for(f+=1;f<t.length&&!/^<\/details>\s*$/i.test(t[f].trim());){const I=t[f].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);I?a=I[1].trim()||a:k.push(t[f].trimStart()),f+=1}f<t.length&&(f+=1),g.push({key:`details-${F}`,startLine:F+1,endLine:f,content:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:Je(a,`details-${F}-summary`,!0,p)}),k.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:Su(k,`details-${F}`,p)})]})});continue}const P=vu(w);if(P){const F=[w],a=f;for(f+=1;f<t.length&&!P.selfContained&&!new RegExp(`</${P.tag}>`,"i").test(t[f]);)F.push(t[f]),f+=1;f<t.length&&!P.selfContained&&(F.push(t[f]),f+=1),g.push({key:`html-${a}`,startLine:a+1,endLine:f,content:e.jsx(bu,{html:F.join(`
47
+ `)})});continue}const D=C.match(/^(```|~~~)\s*(.*)$/);if(D){const F=[],a=D[1],k=D[2]?.trim(),I=f;for(f+=1;f<t.length&&!t[f].trim().startsWith(a);)F.push(t[f]),f+=1;f<t.length&&(f+=1),g.push({key:`code-${I}`,startLine:I+1,endLine:f,fineGrained:k.toLowerCase()!=="mermaid"&&!["math","latex","tex"].includes(k.toLowerCase()),content:k.toLowerCase()==="mermaid"?e.jsx(Cu,{code:F.join(`
48
+ `),blockKey:`code-${I}`}):["math","latex","tex"].includes(k.toLowerCase())?e.jsx(Ns,{tex:F.join(`
49
+ `),display:!0}):S=>e.jsx(Wa,{code:F.join(`
50
+ `),lang:k,blockKey:`code-${I}`,codeStartLine:I+2,lineRange:S})});continue}if(za(w)){const F=[],a=f;for(f+=0;f<t.length&&(za(t[f])||!t[f].trim());)F.push(t[f].trim()?ku(t[f]):""),f+=1;g.push({key:`indented-code-${a}`,startLine:a+1,endLine:f,fineGrained:!0,content:k=>e.jsx(Wa,{code:F.join(`
51
+ `).replace(/\n+$/,""),lang:"",blockKey:`indented-code-${a}`,codeStartLine:a+1,lineRange:k})});continue}if(C.startsWith("$$")){const F=[],a=f,k=C.replace(/^\$\$\s*/,"");if(k.endsWith("$$")&&k.length>2)F.push(k.replace(/\s*\$\$$/,"")),f+=1;else{for(k&&F.push(k),f+=1;f<t.length&&!t[f].trim().endsWith("$$");)F.push(t[f]),f+=1;if(f<t.length){const I=t[f].trim().replace(/\s*\$\$$/,"");I&&F.push(I),f+=1}}g.push({key:`math-${a}`,startLine:a+1,endLine:f,content:e.jsx(Ns,{tex:F.join(`
52
+ `),display:!0})});continue}if(f+1<t.length&&C&&!jo(w)&&/^(=+|-+)\s*$/.test(t[f+1].trim())){const F=t[f+1].trim().startsWith("=")?1:2,a=`h${F}`,k=Ro(C,p),I={level:F,text:od(C),id:k};g.push({key:`setext-heading-${f}`,startLine:f+1,endLine:f+2,heading:I,content:e.jsx(a,{id:k,className:`scroll-mt-16 font-semibold text-foreground ${F===1?"mt-1 border-b border-border/20 pb-1.5 text-lg sm:pb-2 sm:text-xl":"mt-1 border-b border-border/15 pb-1 text-base sm:pb-1.5 sm:text-lg"}`,children:Je(C,`setext-heading-${f}`,!0,p)})}),f+=2;continue}const H=C.match(/^(#{1,6})\s+(.+)$/);if(H){const F=H[1].length,a=ou(H[2]),k={1:"mt-1 border-b border-border/20 pb-1.5 text-lg sm:pb-2 sm:text-xl",2:"mt-1 border-b border-border/15 pb-1 text-base sm:pb-1.5 sm:text-lg",3:"text-sm sm:text-base",4:"text-[13px] sm:text-sm",5:"text-[11px] uppercase tracking-wide sm:text-xs",6:"text-[11px] uppercase tracking-wide text-muted-foreground"},I=`h${F}`,S=Ro(a,p),Z={level:F,text:od(a),id:S};g.push({key:`heading-${f}`,startLine:f+1,endLine:f+1,heading:Z,content:e.jsx(I,{id:S,className:`scroll-mt-16 font-semibold text-foreground ${k[F]}`,children:Je(a,`heading-${f}`,!0,p)})}),f+=1;continue}if(su(w)){g.push({key:`hr-${f}`,startLine:f+1,endLine:f+1,content:e.jsx("hr",{className:"border-border/20"})}),f+=1;continue}if(C.startsWith(">")){const F=[],a=[],k=f;for(;f<t.length&&/^>\s?/.test(t[f].trim());)F.push(t[f].trim().replace(/^>\s?/,"")),a.push(f+1),f+=1;const I=F[0]?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i);if(I){const Z=I[1].toUpperCase(),re=I[2]?.trim(),ne=[...re?[re]:[],...F.slice(1)],de=[...re?[a[0]]:[],...a.slice(1)],K=Ao(ne,`callout-${k}`,p);g.push({key:`callout-${k}`,startLine:k+1,endLine:f,fineGrained:!0,content:X=>e.jsxs("aside",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-primary",children:Z}),ne.length>0&&e.jsx("div",{children:$o(K.perLine,K.hardBreaks,de,`callout-${k}`,X)})]})});continue}const S=kg(F,`quote-${k}`,p,a);g.push({key:`quote-${k}`,startLine:k+1,endLine:f,fineGrained:!0,content:Z=>e.jsx("blockquote",{className:"space-y-2 border-l-2 border-border-strong bg-surface-2/70 py-1.5 pl-2.5 pr-2 text-muted-foreground sm:py-2 sm:pl-3",children:Sg(S,Z)})});continue}if(f+1<t.length&&w.includes("|")&&Oa(t[f+1])){const F=Cs(w),a=ju(t[f+1]),k=[],I=f;for(f+=2;f<t.length&&t[f].includes("|")&&t[f].trim();)k.push(Cs(t[f])),f+=1;const S=F.map((re,ne)=>Je(re,`th-${I}-${ne}`,!0,p)),Z=k.map((re,ne)=>F.map((de,K)=>Je(re[K]??"",`td-${I}-${ne}-${K}`,!0,p)));g.push({key:`table-${I}`,startLine:I+1,endLine:f,interactive:!1,kind:"table",content:re=>{const ne=de=>!!(re&&de>=re.start&&de<=re.end);return e.jsx("div",{className:Qd,"data-markdown-table-scroll":!0,children:e.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[e.jsx("thead",{className:"bg-surface-2 text-foreground",children:e.jsx("tr",{"data-markdown-table-row-line":I+1,"data-md-ref-start":I+1,"data-md-ref-end":I+1,"data-selected":ne(I+1)?"true":void 0,children:S.map((de,K)=>e.jsx("th",{className:`${Xd} ${Ha(a[K]??null)}`,children:e.jsx("div",{className:Ia,children:de})},`h-${K}`))})}),e.jsx("tbody",{children:Z.map((de,K)=>{const X=I+K+3;return e.jsx("tr",{className:"border-t border-border/10","data-markdown-table-row-line":X,"data-md-ref-start":X,"data-md-ref-end":X,"data-selected":ne(X)?"true":void 0,children:F.map(($,_)=>e.jsx("td",{className:`${Zd} ${Ha(a[_]??null)}`,children:e.jsx("div",{className:Ia,children:de[_]})},`c-${_}`))},`r-${K}`)})})]})})}});continue}const R=As(w);if(R){const F=R.ordered,a=qa(w),k=R.start,I=f,S=_o(t,f,a,F,!0,h);f=S.nextIndex;const Z=F?"ol":"ul",re=Io(S.items,`list-${I}`,p);g.push({key:`list-${I}`,startLine:I+1,endLine:f,fineGrained:!0,content:ne=>e.jsx(Z,{start:F?k:void 0,className:`${F?"list-decimal":"list-disc"} space-y-0.5 pl-4 text-muted-foreground marker:text-muted-foreground/70 sm:space-y-1 sm:pl-5`,children:Bo(re,ne)})});continue}const A=[w.trimStart()],E=[f+1],M=f;for(f+=1;f<t.length&&t[f].trim()&&!jo(t[f])&&!(f+1<t.length&&t[f].includes("|")&&Oa(t[f+1]));){if(Ba(t[f])||h.has(f)){f+=1;continue}A.push(t[f].trimStart()),E.push(f+1),f+=1}const G=Ao(A,`p-${M}`,p);g.push({key:`p-${M}`,startLine:M+1,endLine:f,fineGrained:!0,content:F=>e.jsx("p",{className:"text-muted-foreground",children:$o(G.perLine,G.hardBreaks,E,`p-${M}`,F)})})}const y=yg(p);return y&&g.push({key:"footnotes",startLine:t.length,endLine:t.length,content:y}),{blocks:g,images:m}}function $g(t,n,s){return zo(t,n,s).blocks}function Au(t,n){const s=[];for(const l of t){if(l.startLine>n)break;if(l.heading){for(;s.length>0&&s[s.length-1].level>=l.heading.level;)s.pop();s.push({...l.heading,startLine:l.startLine})}}return s}function $u(t){return t.filter(n=>!!n.heading).map(n=>({...n.heading,startLine:n.startLine}))}function Eg({src:t,alt:n,onZoomChange:s,onDoubleTap:l}){const c=mu(t);return e.jsx(Ou,{src:c,alt:n,onLoad:()=>{},onError:()=>{},onZoomChange:s,onDoubleTap:l})}function Eu({images:t,index:n,onChange:s,onClose:l}){const{t:c}=xt(),d=t[n],h=t.length>1,m=i.useRef(null),p=i.useRef(null),g=i.useRef(null),f=i.useRef(0),[y,w]=i.useState(!1),[C,P]=i.useState(0),[D,H]=i.useState(!1),R=i.useCallback(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),A=i.useCallback(()=>{y||Date.now()<f.current||(R(),g.current=window.setTimeout(()=>{g.current=null,l()},450))},[R,y,l]),E=i.useCallback(a=>{if(t.length===0)return;const k=(a+t.length)%t.length;m.current?.slideTo(k),s(k)},[t.length,s]),M=i.useCallback(()=>E(n-1),[E,n]),G=i.useCallback(()=>E(n+1),[E,n]);if(i.useEffect(()=>{R(),P(0),H(!1),w(!1)},[R,n]),i.useEffect(()=>{const a=m.current;a&&(a.allowTouchMove=h&&!y)},[h,y]),i.useEffect(()=>{const a=m.current;!a||a.activeIndex===n||a.slideTo(n,0)},[n]),i.useEffect(()=>R,[R]),i.useEffect(()=>{const a=k=>{if(k.key==="Escape"){k.preventDefault(),l();return}h&&(k.key==="ArrowLeft"?(k.preventDefault(),M()):k.key==="ArrowRight"&&(k.preventDefault(),G()))};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[h,G,M,l]),kd({onDrag:({movement:[a,k],pinching:I})=>{I||y||Math.abs(k)<Math.abs(a)*1.15&&C===0||(H(!0),Math.abs(k)>8&&(f.current=Date.now()+300),P(Math.max(0,k)))},onDragEnd:({movement:[,a],velocity:[,k]})=>{if(!y){if(H(!1),Math.abs(a)>8&&(f.current=Date.now()+300),Ru(a,k)){l();return}P(0)}}},{target:p,drag:{filterTaps:!0,pointer:{touch:!0}}}),!d)return null;const F=d.title||d.alt||(d.kind==="mermaid"?c("rightSidebar.mermaidDiagram"):c("rightSidebar.image"));return typeof document>"u"?null:Wr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:l}),e.jsxs("div",{className:"fixed inset-0 z-modal-panel flex flex-col bg-background-subtle/95 pt-[var(--safe-top-inset,env(safe-area-inset-top,0px))] text-foreground","data-markdown-image-lightbox":!0,"data-sidebar-gesture-ignore":!0,children:[e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/20 bg-surface/80 px-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:F}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n+1," / ",t.length]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[h&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:M,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":c("rightSidebar.previousImage"),title:c("common.previous"),children:e.jsx(ks,{size:17})}),e.jsx("button",{type:"button",onClick:G,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":c("rightSidebar.nextImage"),title:c("common.next"),children:e.jsx(ch,{size:17})})]}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":c("rightSidebar.closeImagePreview"),title:c("common.close"),children:e.jsx(_t,{size:18})})]})]}),e.jsx("div",{ref:p,className:"relative min-h-0 flex-1 overflow-hidden","data-markdown-image-lightbox-stage":!0,"data-sidebar-gesture-ignore":!0,onPointerDown:a=>a.stopPropagation(),onPointerMove:a=>a.stopPropagation(),onTouchStart:a=>a.stopPropagation(),onTouchMove:a=>a.stopPropagation(),onClick:A,children:e.jsx("div",{className:"h-full w-full",style:{transform:`translate3d(0, ${C}px, 0) scale(${Math.max(.86,1-C/900)})`,opacity:Math.max(.35,1-C/360),transition:D?"none":"transform 0.2s ease-out, opacity 0.2s ease-out",willChange:"transform, opacity"},children:e.jsx(Sd,{onSwiper:a=>{m.current=a,a.allowTouchMove=h&&!y},onSlideChange:a=>{a.activeIndex!==n&&s(a.activeIndex)},initialSlide:n,speed:260,slidesPerView:1,resistanceRatio:.82,threshold:6,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,className:"h-full",children:t.map((a,k)=>e.jsx(ho,{className:"h-full",children:e.jsx("div",{className:"h-full w-full px-3 py-4 sm:px-6 sm:py-6",children:a.kind==="image"?e.jsx(Eg,{src:a.src,alt:a.alt||a.title||c("rightSidebar.markdownImage"),onZoomChange:w,onDoubleTap:R}):e.jsx(Kg,{svg:a.svg,title:a.title||a.alt||c("rightSidebar.mermaidDiagram"),onZoomChange:w,onDoubleTap:R})})},`${a.kind}-${k}-${a.alt}`))})})})]})]}),document.body)}function Mu({content:t,filePath:n,rootPath:s,lineRange:l,onLineRangeClick:c,onLineRangeDrag:d,scrollTop:h,outlineOpen:m,outlineCloseSignal:p,onOutlineOpen:g,onOutlineClose:f,lightboxOpen:y,lightboxCloseSignal:w,onLightboxOpen:C,onLightboxClose:P,onLocalLinkOpen:D}){const{t:H}=xt(),[R,A]=i.useState(null),[E,M]=i.useState(null),[G,F]=i.useState(1),[a,k]=i.useState(null),I=i.useRef(null),S=i.useRef(null),{blocks:Z,images:re}=i.useMemo(()=>zo(t.split(`
53
+ `),n,s,j=>{M(null),A(j),C?.()},{footnotes:H("rightSidebar.footnotes"),backToFootnote:j=>H("rightSidebar.backToFootnote",{index:j})}),[t,n,s,C,H]),ne=i.useMemo(()=>E?[...re,E]:re,[re,E]),de=i.useCallback(j=>{M({kind:"mermaid",svg:j,alt:"Mermaid diagram",title:"Mermaid diagram"}),A(re.length),C?.()},[re.length,C]);i.useEffect(()=>{A(null),M(null)},[t,n]),i.useEffect(()=>{A(null),M(null)},[w]),i.useEffect(()=>{y||(A(null),M(null))},[y]),i.useEffect(()=>{F(1)},[t,n]),i.useLayoutEffect(()=>{const j=I.current;if(!j||Z.length===0)return;const Q=Array.from(j.querySelectorAll("[data-markdown-preview-block-start]"));let ke=1;const be=28;for(const De of Q)if(De.offsetTop-h<=be)ke=Number(De.dataset.markdownPreviewBlockStart)||ke;else break;F(De=>De===ke?De:ke)},[Z,h]);const K=i.useMemo(()=>Au(Z,G),[G,Z]),X=i.useMemo(()=>$u(Z),[Z]),$=`${n??""}
54
+ ${t}`,_=i.useRef($),Y=i.useRef(null),te=i.useRef(null),oe=i.useRef(!1);i.useEffect(()=>{_.current!==$&&(_.current=$,f?.())},[f,$]),i.useEffect(()=>{p!==void 0&&k(null)},[p]),i.useLayoutEffect(()=>{if(!m){k(null);return}const j=()=>{const Q=S.current;if(!Q)return;const ke=Q.getBoundingClientRect(),be=window.innerWidth;k({top:ke.bottom+6,right:Math.max(8,be-ke.right)})};return j(),window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[m,h,K]);const ue=i.useCallback(j=>{const Q=I.current,ke=Q?.closest("[data-markdown-preview-scroller]"),be=Q?.querySelector(`[data-markdown-preview-block-start="${j.startLine}"]`);if(!ke||!be)return;const De=ke.getBoundingClientRect(),le=be.getBoundingClientRect(),Me=Q?.querySelector("[data-markdown-heading-sticky]")?.getBoundingClientRect().height??0,U=le.top-De.top+ke.scrollTop;ke.scrollTo({top:Math.max(0,U-Me-8),behavior:"smooth"}),F(j.startLine),f?.()},[f]),O=i.useCallback(j=>{j.pointerType==="mouse"&&j.button!==0||io(j.target)||(Y.current={pointerId:j.pointerId,startX:j.clientX,startY:j.clientY})},[]),ge=i.useCallback((j,Q,ke)=>{const be=Y.current;if(Y.current=null,!be||be.pointerId!==j.pointerId)return;const De=Math.abs(j.clientX-be.startX),le=Math.abs(j.clientY-be.startY);if(De>8||le>8)return;const Ue=j.target;if(io(Ue)||Mo())return;const Me=bd(Ue,Q,ke);c(j,Me.start,Me.end)},[c]),B=i.useCallback(j=>{Y.current?.pointerId===j.pointerId&&(Y.current=null)},[]),me=i.useCallback((j,Q)=>{const ke=I.current;if(!ke||typeof document.elementFromPoint!="function")return null;const be=document.elementFromPoint(j,Q);if(!(be instanceof HTMLElement)||!ke.contains(be))return null;const De=be.closest("[data-md-ref-start]");if(De){const Se=Number(De.dataset.mdRefStart);if(Number.isFinite(Se)&&Se>0)return Se}const le=be.closest("[data-markdown-preview-block-start]");if(!le)return null;const Ue=Number(le.dataset.markdownPreviewBlockStart),Me=Z.find(Se=>Se.startLine===Ue);if(!Me)return Number.isFinite(Ue)&&Ue>0?Ue:null;if(Me.endLine<=Me.startLine)return Me.startLine;const U=le.getBoundingClientRect(),V=U.height>0?Math.min(1,Math.max(0,(Q-U.top)/U.height)):0;return Math.round(Me.startLine+V*(Me.endLine-Me.startLine))},[Z]),je=i.useCallback(j=>{if(!d||j.pointerType==="mouse"&&j.button!==0)return;const Q=me(j.clientX+24,j.clientY);if(Q!=null){te.current={pointerId:j.pointerId,anchorLine:Q,moved:!1};try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}}},[d,me]),Ee=i.useCallback(j=>{const Q=te.current;if(!Q||Q.pointerId!==j.pointerId||!d)return;const ke=me(j.clientX+16,j.clientY);ke!=null&&(!Q.moved&&ke===Q.anchorLine||(Q.moved=!0,oe.current=!0,d(j,Math.min(Q.anchorLine,ke),Math.max(Q.anchorLine,ke),"move")))},[d,me]),_e=i.useCallback(j=>{const Q=te.current;if(te.current=null,!Q||Q.pointerId!==j.pointerId||!d||!Q.moved)return;const ke=me(j.clientX+16,j.clientY)??Q.anchorLine;d(j,Math.min(Q.anchorLine,ke),Math.max(Q.anchorLine,ke),"end")},[d,me]),bt=i.useCallback(j=>{te.current?.pointerId===j.pointerId&&(te.current=null)},[]),fe={onPointerDown:je,onPointerMove:Ee,onPointerUp:_e,onPointerCancel:bt},he=()=>oe.current?(oe.current=!1,!0):!1;return Z.length===0?e.jsx("div",{className:"min-w-0 max-w-full px-4 py-4 text-sm leading-6 text-foreground",children:e.jsx("p",{className:"text-muted-foreground",children:H("rightSidebar.emptyFile")})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:I,className:"relative min-w-0 max-w-full",onClickCapture:j=>{const Q=j.target instanceof Element?j.target.closest("a[href]"):null;if(!Q||!D)return;const ke=Q.getAttribute("href");if(!ke)return;const be=fu(ke,n,s);be&&(j.preventDefault(),D(be))},children:[K.length>0&&e.jsx("div",{className:"sticky top-0 z-10 border-b border-border/15 bg-surface px-2 py-1 shadow-sm sm:px-3","data-markdown-heading-sticky":!0,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",title:K.map(j=>j.text).join(" / "),children:[e.jsx("span",{className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/70","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold leading-5 text-foreground sm:text-[13px]","data-markdown-heading-current":!0,children:K[K.length-1].text}),X.length>1&&e.jsxs("button",{ref:S,type:"button",onClick:()=>{m?f?.():g?.()},className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 ${m?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":m,"aria-label":H("rightSidebar.markdownOutline"),title:H("rightSidebar.markdownOutline"),children:[e.jsx(Rd,{size:12}),e.jsx("span",{children:H("rightSidebar.markdownOutlineShort")})]})]})}),m&&typeof document<"u"&&Wr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-menu-backdrop bg-[rgb(var(--background-rgb)_/_0.18)] sm:hidden",onClick:f}),e.jsx("div",{className:"hidden fixed z-menu-panel w-80 max-w-[min(20rem,calc(100vw-2rem))] rounded-lg border border-border/20 bg-surface p-2 shadow-xl sm:block",style:a?{top:`${a.top}px`,right:`${a.right}px`}:{top:-9999,right:-9999},"data-markdown-heading-outline-desktop":!0,children:e.jsx("div",{className:"max-h-72 overflow-auto pr-1",children:X.map(j=>{const Q=K[K.length-1]?.startLine===j.startLine;return e.jsxs("button",{type:"button",onClick:()=>ue(j),className:`flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition active:scale-[0.995] ${Q?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(j.level-1,4)*12+8}px`},title:j.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${Q?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",j.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:j.text})]},`desktop-${j.id}-${j.startLine}`)})})}),e.jsxs("div",{className:"fixed inset-x-0 bottom-0 z-drawer-panel max-h-[min(74vh,34rem)] rounded-t-xl border border-border/20 bg-surface p-2 pb-[calc(0.5rem+env(safe-area-inset-bottom,0px))] shadow-[0_-18px_48px_var(--app-shadow-strong)] sm:hidden","data-markdown-heading-outline-mobile":!0,children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 px-1.5 py-1 sm:hidden",children:[e.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:H("rightSidebar.markdownOutlineShort")}),e.jsx("button",{type:"button",onClick:f,className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":H("rightSidebar.closeMarkdownOutline"),title:H("common.close"),children:e.jsx(_t,{size:14})})]}),e.jsx("div",{className:"max-h-[calc(min(74vh,34rem)-3.25rem-env(safe-area-inset-bottom,0px))] overflow-auto overscroll-contain pr-1 sm:max-h-72",children:X.map(j=>{const Q=K[K.length-1]?.startLine===j.startLine;return e.jsxs("button",{type:"button",onClick:()=>ue(j),className:`flex min-h-10 w-full min-w-0 items-center gap-2 rounded-md px-2 py-2 text-left transition active:scale-[0.995] ${Q?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(j.level-1,4)*12+8}px`},title:j.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${Q?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",j.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:j.text})]},`${j.id}-${j.startLine}`)})})]})]}),document.body),e.jsx("div",{className:"min-w-0 max-w-full space-y-1.5 overflow-x-hidden break-words px-1.5 py-3 text-[13px] leading-5 text-foreground sm:space-y-2 sm:px-2 sm:py-4 sm:text-sm sm:leading-6",children:e.jsx(au.Provider,{value:de,children:Z.map(j=>{const Q=!!(l&&j.startLine<=l.end&&j.endLine>=l.start),ke=!!(l&&l.start<=j.startLine&&l.end>=j.endLine),be=j.kind==="table"?!1:j.fineGrained?ke:Q,De=j.kind==="table"&&l?.start===j.startLine&&l.end===j.endLine;let le=null;if(j.kind!=="table"&&j.fineGrained&&Q&&!ke&&l){const V=j.endLine-j.startLine+1,Se=Math.max(l.start,j.startLine),Re=Math.min(l.end,j.endLine),at=(Se-j.startLine)/V,Ke=(Re-Se+1)/V;le=e.jsx("span",{"aria-hidden":"true","data-md-rail-segment":!0,className:"absolute left-1/2 w-0.5 -translate-x-1/2 rounded-full bg-primary transition sm:w-1",style:{top:`calc(0.25rem + (100% - 0.5rem) * ${at})`,height:`calc((100% - 0.5rem) * ${Ke})`}})}const Ue=typeof j.content=="function"?j.content(l):j.content,Me=j.startLine===j.endLine?String(j.startLine):`${j.startLine}-${j.endLine}`,U=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:no(be),"aria-hidden":"true",...fe,children:[e.jsx("span",{className:so(be)}),le]}),e.jsx("div",{className:"min-w-0","data-sidebar-selectable":!0,children:Ue})]});return j.interactive===!1?e.jsxs("div",{"data-markdown-preview-block-start":j.startLine,className:`group grid w-full grid-cols-[0.625rem_minmax(0,1fr)] gap-1.5 rounded-md py-0.5 pr-1.5 text-left outline-none transition sm:grid-cols-[0.875rem_minmax(0,1fr)] sm:gap-2 sm:pr-2 ${be?"bg-primary/10":""}`,title:`Line ${Me}`,"aria-label":`Line ${Me}`,children:[j.kind==="table"?e.jsx("button",{type:"button",className:no(De,"self"),onClick:V=>{V.preventDefault(),!he()&&c(V,j.startLine,j.endLine)},title:`Reference table lines ${Me}`,"aria-label":`Reference table lines ${Me}`,...fe,children:e.jsx("span",{className:so(De,"self")})}):e.jsxs("span",{className:no(be,"none"),"aria-hidden":"true",...fe,children:[e.jsx("span",{className:so(be,"none")}),le]}),e.jsx("div",{className:"min-w-0 cursor-text select-text","data-sidebar-selectable":!0,role:"button",tabIndex:0,onPointerDown:O,onPointerUp:V=>ge(V,j.startLine,j.endLine),onPointerCancel:B,onKeyDown:V=>{V.key!=="Enter"&&V.key!==" "||(V.preventDefault(),c(V,j.startLine,j.endLine))},title:`Reference line ${Me}`,"aria-label":`Reference line ${Me}`,children:Ue})]},j.key):e.jsx("div",{role:"button",tabIndex:0,"data-markdown-preview-block-start":j.startLine,onClick:V=>{const Se=V.target;if(io(Se)||Mo()||he())return;const Re=bd(Se,j.startLine,j.endLine);c(V,Re.start,Re.end)},onKeyDown:V=>{V.key!=="Enter"&&V.key!==" "||(V.preventDefault(),c(V,j.startLine,j.endLine))},className:`group grid w-full cursor-pointer grid-cols-[0.625rem_minmax(0,1fr)] gap-1.5 rounded-md py-0.5 pr-1.5 text-left outline-none transition active:scale-[0.998] sm:grid-cols-[0.875rem_minmax(0,1fr)] sm:gap-2 sm:pr-2 ${be?"bg-primary/10":"hover:bg-[var(--surface-2)]"}`,title:`Reference line ${Me}`,"aria-label":`Reference line ${Me}`,children:U},j.key)})})})]}),y&&R!==null&&ne[R]&&e.jsx(Eu,{images:ne,index:R,onChange:A,onClose:()=>{A(null),M(null),P?.()}})]})}function Hn({label:t,value:n,options:s,placeholder:l,searchPlaceholder:c,emptyText:d,disabled:h,onChange:m}){const{t:p}=xt(),[g,f]=i.useState(!1),[y,w]=i.useState(""),[C,P]=i.useState(null),D=i.useRef(null),H=i.useRef(null),R=y.trim().toLowerCase(),A=i.useMemo(()=>R?s.filter(a=>`${a.label} ${a.meta??""}`.toLowerCase().includes(R)):s,[R,s]),E=s.find(a=>a.value===n),M=()=>{const a=y.trim();a&&(m(a),f(!1),w(""))},G=i.useCallback(()=>{const a=D.current?.getBoundingClientRect();if(!a)return!1;const k=12,I=Math.max(220,Math.min(a.width,window.innerWidth-k*2)),S=Math.min(Math.max(k,a.left),window.innerWidth-I-k),Z=window.innerHeight-a.bottom-k,re=a.top-k,ne=Z>=180||Z>=re,de=Math.max(96,(ne?Z:re)-4),K=Math.min(320,de);return P({left:S,top:ne?a.bottom+4:Math.max(k,a.top-K-4),width:I,maxHeight:K}),!0},[]),F=()=>{G(),f(!0)};return i.useEffect(()=>{if(!g)return;let a=0;const k=()=>{a||(a=window.requestAnimationFrame(()=>{a=0,G()}))},I=S=>{const Z=S.target;Z instanceof Node&&(D.current?.contains(Z)||H.current?.contains(Z)||(f(!1),w("")))};return window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),document.addEventListener("pointerdown",I,!0),()=>{a&&window.cancelAnimationFrame(a),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0),document.removeEventListener("pointerdown",I,!0)}},[g,G]),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:D,type:"button",disabled:h,onClick:()=>{if(!h){if(w(""),g){f(!1);return}F()}},className:"group flex w-full items-center justify-between gap-2 rounded-md border border-border/15 bg-surface-2 px-2.5 py-1.5 text-left transition hover:bg-surface-elevated disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[9px] font-medium uppercase tracking-wide text-muted-foreground",children:t}),e.jsx("span",{className:`block truncate text-[12px] ${n?"text-foreground":"text-muted-foreground/70"}`,children:E?.label??(n||l)})]}),e.jsx(Ss,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${g?"rotate-180":""}`})]}),g&&!h&&typeof document<"u"&&Wr.createPortal(e.jsxs("div",{ref:H,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:a=>a.stopPropagation(),style:{left:C?.left??12,top:C?.top??12,width:C?.width??260,maxHeight:C?.maxHeight??320},children:[e.jsx("div",{className:"border-b border-border/10 p-1.5",children:e.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5",children:[e.jsx(Wn,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:y,onChange:a=>w(a.target.value),onKeyDown:a=>{if(a.key==="Escape"){a.preventDefault(),f(!1),w("");return}a.key==="Enter"&&(a.preventDefault(),M())},onBlur:()=>{y.trim()&&A.length===0&&M()},placeholder:c,className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground outline-none placeholder:text-muted-foreground/70"})]})}),e.jsxs("div",{className:"overflow-y-auto p-1",style:{maxHeight:Math.max(96,(C?.maxHeight??320)-46)},children:[y.trim()&&!s.some(a=>a.value===y.trim())&&e.jsxs("button",{type:"button",onMouseDown:a=>a.preventDefault(),onClick:M,className:"mb-1 flex w-full items-center justify-between gap-2 rounded-md bg-primary/10 px-2 py-1.5 text-left text-[12px] font-medium text-primary transition hover:bg-primary/15",children:[e.jsx("span",{className:"min-w-0 truncate",children:y.trim()}),e.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:p("common.use")})]}),A.length>0?A.map(a=>e.jsxs("button",{type:"button",onClick:()=>{m(a.value),f(!1),w("")},className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left text-[12px] transition hover:bg-surface-2 ${a.value===n?"bg-accent/10 text-accent":"text-foreground"}`,children:[e.jsx("span",{className:"min-w-0 truncate font-medium",children:a.label}),a.meta&&e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:a.meta})]},a.value)):e.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:d})]})]}),document.body)]})}function ud({open:t,onOpenChange:n,showScopePicker:s,selectedAll:l,repos:c,selectedRoots:d,onToggleRepo:h,onGenerate:m,onSecondaryAction:p,disabled:g,generateDisabled:f,secondaryDisabled:y,inserted:w,buttonLabel:C,insertedLabel:P,title:D,ariaLabel:H,scopeTitle:R,scopeLabel:A,allLabel:E,generateLabel:M,secondaryLabel:G,secondaryTitle:F,secondaryLoading:a,loading:k,error:I,statusTitle:S,extraContent:Z,renderRepoExtra:re}){return e.jsxs("div",{className:"relative inline-flex shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>{s?n(!t):f||m()},disabled:g,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 disabled:cursor-not-allowed disabled:opacity-50 ${I?"text-destructive hover:bg-destructive/5":w?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":H,title:S??(s?`${R}: ${A}`:D),children:[k?e.jsx(rt,{size:13,className:"animate-spin"}):e.jsx(Rs,{size:13}),e.jsx("span",{children:w?P:C}),s&&e.jsx(Ss,{size:11,className:`shrink-0 transition ${t?"rotate-180":""}`}),I&&e.jsx("span",{className:"absolute right-0.5 top-0.5 size-1.5 rounded-full bg-destructive"})]}),s&&t&&typeof document<"u"&&Wr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] px-3 py-6 backdrop-blur-sm animate-fade-in",onClick:()=>n(!1),children:e.jsxs("div",{className:"fixed left-1/2 top-1/2 z-modal-panel flex max-h-[min(82vh,36rem)] w-[calc(100vw-1.5rem)] max-w-[42rem] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/20 bg-surface text-[11px] shadow-2xl",onClick:ne=>ne.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border/15 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:R}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:A})]}),e.jsx("button",{type:"button",onClick:()=>n(!1),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":"Close",children:e.jsx(_t,{size:14})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[Z,e.jsxs("button",{type:"button",onClick:()=>h(null),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${l?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[e.jsx("span",{className:"truncate",children:E}),l&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),c.map(ne=>{const de=d.includes(ne.root);return e.jsxs("div",{className:`mt-1 rounded-md transition ${de?"bg-primary/15 text-primary":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>h(ne.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${de?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:ne.root,children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate",children:ne.label}),ne.branch&&e.jsx("span",{className:"block truncate text-[9px] opacity-70",children:ne.branch})]}),de&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),re&&(l||de)&&e.jsx("div",{className:"px-2 pb-2",children:re(ne)})]},ne.root)})]}),e.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${p&&G?"sm:grid-cols-2":""}`,children:[p&&G&&e.jsxs("button",{type:"button",onClick:()=>{y||(n(!1),p())},disabled:y,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-surface-2 px-2 text-[11px] font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:F,children:[a?e.jsx(rt,{size:12,className:"animate-spin"}):e.jsx(Td,{size:12}),G]}),e.jsxs("button",{type:"button",onClick:()=>{f||(n(!1),m())},disabled:f,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-primary/15 px-2 text-[11px] font-semibold text-primary transition hover:bg-primary/25 disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:D,children:[e.jsx(Rs,{size:12}),M]})]})]})}),document.body)]})}function Mg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;for(const n of Object.values(t)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function Tu(){return Qe(Lo,Mg)??{}}function Tg(t,n){const s=Tu(),l=Object.entries({...s,[t]:{top:n,updatedAt:Date.now()}}).sort(([,c],[,d])=>d.updatedAt-c.updatedAt).slice(0,$p);vs(Lo,Object.fromEntries(l),Mp)}function Pg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return typeof n.start=="number"&&Number.isFinite(n.start)&&typeof n.end=="number"&&Number.isFinite(n.end)&&n.start>=1&&n.end>=n.start}function Lg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;for(const n of Object.values(t)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||s.left!==void 0&&(typeof s.left!="number"||!Number.isFinite(s.left))||s.markdownTop!==void 0&&(typeof s.markdownTop!="number"||!Number.isFinite(s.markdownTop))||s.lineRange!==void 0&&s.lineRange!==null&&!Pg(s.lineRange)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function Ho(t,n){if(!n)return null;const s=t&&!n.startsWith("/")?`${t}/${n}`:n;return t?`${t}::${s}`:s}function Pu(){return Qe(Fo,Lg)??{}}function fd(t,n){const s=Ho(t,n);return s?Pu()[s]??null:null}function eo(t,n,s){const l=Ho(t,n);if(!l)return;const c=Pu(),d=c[l]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},h=Object.entries({...c,[l]:{...d,...s,updatedAt:Date.now()}}).sort(([,m],[,p])=>p.updatedAt-m.updatedAt).slice(0,Ep);vs(Fo,Object.fromEntries(h),Tp)}function to({active:t,mounted:n=!0,fallback:s=null,children:l}){return e.jsx("div",{className:`h-full min-h-0 overflow-hidden bg-surface text-foreground ${t?"block":"hidden"}`,"aria-hidden":!t,children:n?typeof l=="function"?l():l:s})}function ps({slow:t}){const{t:n}=xt();return e.jsxs("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:[e.jsx(rt,{size:20,className:"mx-auto mb-2 animate-spin text-muted-foreground/80"}),e.jsx("div",{children:n("rightSidebar.loadingGitChanges")}),t&&e.jsx("div",{className:"mt-1 text-xs text-muted-foreground/75",children:n("rightSidebar.loadingGitChangesSlow")})]})}function Ma({message:t,onRetry:n}){const{t:s}=xt();return e.jsxs("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-5 text-center text-sm text-destructive",children:[e.jsx("div",{className:"font-medium",children:s("rightSidebar.gitChangesLoadFailed")}),e.jsx("div",{className:"mt-1 break-words text-xs opacity-85",children:t}),e.jsx("button",{type:"button",onClick:n,className:"mt-3 rounded-full bg-destructive/10 px-3 py-1.5 text-xs font-semibold text-destructive transition hover:bg-destructive/15 active:scale-95",children:s("rightSidebar.retryGitChanges")})]})}function Da(t,n){const s=n&&t.startsWith(`${n}/`)?t.slice(n.length+1):t,l=s.split("/").filter(Boolean);return{name:l.pop()||s,dir:l.join("/")}}function dt(t){if(!t)return"";const n=t.replace(/\/+$/,"");return n.split("/").pop()||n||"/"}function ro(t){if(!t)return null;const n=t.replace(/\/+$/,"")||"/";if(n==="/")return null;const s=n.slice(0,n.lastIndexOf("/"))||"/";return s===n?null:s}function Eo(t,n,s){const l=Math.min(n,s),c=Math.max(n,s);return t?.start===l&&t.end===c?null:t&&t.start===t.end?{start:Math.min(t.start,l),end:Math.max(t.end,c)}:{start:l,end:c}}function Fg(t,n,s){return Eo(t,n,s)}function no(t,n="group"){return`relative flex min-h-5 w-full touch-none select-none items-stretch justify-center rounded transition sm:min-h-6 ${t?"bg-primary/20":`bg-[var(--surface-2)] ${n==="group"?"group-hover:bg-[var(--surface-elevated)]":n==="self"?"hover:bg-[var(--surface-elevated)]":""}`}`}function so(t,n="group"){return`my-1 w-0.5 rounded-full transition sm:w-1 ${t?"bg-primary":`bg-[var(--border-strong)] ${n==="group"?"group-hover:bg-[var(--muted-foreground)]":n==="self"?"hover:bg-[var(--muted-foreground)]":""}`}`}function hd(t,n){return`pointer-events-auto absolute z-30 inline-flex items-center gap-1 rounded-full font-semibold shadow-lg ring-1 transition active:scale-95 ${t?"h-9 px-4 text-[12px]":"h-7 px-3 text-[11px]"} ${n?"bg-surface-elevated text-foreground ring-border-strong/40 hover:bg-surface-2":"bg-primary text-primary-foreground ring-primary/30 hover:bg-primary/90"}`}function Lu(t){const n=new Map;for(const s of t)n.set(Oo(s),s);return n}function Fu(t,n){const s=new Map(t);for(const l of n)s.set(Oo(l),l);return s}function md(t,n){let s=0;for(const l of t){const c=mt(l,n);c&&n&&c!==n&&(s+=1)}return s}function Dg(t){return t.reduce((n,s)=>n+(s.staged?1:0),0)}function _g(t,n){return Array.from(Fu(Lu(t),n).values()).sort((s,l)=>s.path.localeCompare(l.path))}function Ig(t,n){const s=t.relativeRoot==="."?dt(n??t.root)||t.name||t.root:t.relativeRoot||t.name||dt(t.root)||t.root;return{root:t.root,label:s,branch:t.context?.branch??null,count:t.files.length,staged:Dg(t.files)}}function Du(t,n){const s=dt(n??"")||n||"";return t.map(l=>Ig(l,n)).sort((l,c)=>s&&l.label===s?-1:s&&c.label===s?1:l.label.localeCompare(c.label))}function _u(t,n,s,l,c){const d=eu(s),h=d.find(D=>D.root===l)??d[0]??null,m=n.find(D=>D.root===l)??null,p=m?.relativeRoot??h?.relativeRoot??".",g=m?.name??h?.name??(dt(l)||l),f=(h?.files??s.files).map(D=>({...D,repoRoot:l,repoRelativeRoot:p,repoName:g})),y=h?.context??s.context,w={...m??h??{id:l,root:l,relativeRoot:p,name:g,depth:0,nested:!!(c&&l!==c),available:s.available,files:[],context:null},...h??{},id:m?.id??h?.id??l,root:l,displayRoot:m?.displayRoot??h?.displayRoot,relativeRoot:p,name:g,depth:m?.depth??h?.depth??0,nested:m?.nested??h?.nested??!!(c&&l!==c),available:h?.available??s.available,files:f,context:y?{...y,root:l,changedFiles:f.map(D=>({path:D.path,absolutePath:D.absolutePath,status:D.status}))}:null,untrackedDeferred:h?.untrackedDeferred??s.untrackedDeferred,error:h?.error??s.error},C=m?n.map(D=>D.root===l?w:D):[...n,w];return{files:Array.from(t).filter(D=>mt(D,c)!==l).concat(f),repositories:C,repoFilters:Du(C,c)}}function mt(t,n){return t.repoRoot??n}function Oo(t){return`${t.repoRoot??""}\0${t.path}`}function ct(t){return t.absolutePath||t.path}function ao(t){return Oo(t)}function Bg(t){return t.repoRelativeRoot&&t.repoRelativeRoot!=="."?t.repoRelativeRoot:t.repoName??""}function pd(t){return t.reduce((n,s)=>n+(s.staged?1:0),0)}function gd(t){const n={added:0,modified:0,deleted:0,renamed:0,copied:0,untracked:0,conflicted:0,staged:0,other:0};for(const s of t)s.status==="added"?n.added+=1:s.status==="modified"?n.modified+=1:s.status==="deleted"?n.deleted+=1:s.status==="renamed"?n.renamed+=1:s.status==="copied"?n.copied+=1:s.status==="untracked"?n.untracked+=1:s.status==="conflicted"?n.conflicted+=1:n.other+=1,s.staged&&(n.staged+=1);return n}function On(t){let n=0;const s=t??"root";for(let l=0;l<s.length;l+=1)n=Math.imul(n^s.charCodeAt(l),16777619);return`right-sidebar-git-bundle:${(n>>>0).toString(36)}`}function gs(t,n){return typeof t!="number"||!Number.isFinite(t)||t<=0?null:new Intl.DateTimeFormat(n==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}function ir(t){return t instanceof DOMException&&t.name==="AbortError"}function zg(t){const n=t.error??t.context?.error??"";return n.includes("request was cancelled")||n.includes("IO_REQUEST_CANCELLED")}function xd(t){return t?.available===!1&&t.code==="NOT_GIT_REPOSITORY"}function Mo(){if(typeof window>"u")return!1;const t=window.getSelection();return!!(t&&!t.isCollapsed&&t.toString().trim())}function io(t){return t instanceof HTMLElement&&!!t.closest('a, button, input, textarea, select, label, [contenteditable="true"]')}function bd(t,n,s){const l=t instanceof HTMLElement?t.closest("[data-md-ref-start]"):null,c=Number(l?.dataset.mdRefStart),d=Number(l?.dataset.mdRefEnd??l?.dataset.mdRefStart);return Number.isFinite(c)&&c>0&&Number.isFinite(d)&&d>0?{start:Math.min(c,d),end:Math.max(c,d)}:{start:n,end:s}}function Hg({actions:t,running:n,completed:s}){const{t:l}=xt(),[c,d]=i.useState(!1),h=i.useRef(null),m=t.find(g=>n?.action===g.key),p=t.find(g=>s?.action===g.key);return t.length===0?null:(i.useEffect(()=>{if(!c)return;const g=y=>{const w=y.target;w instanceof Node&&h.current?.contains(w)||d(!1)},f=y=>{y.key==="Escape"&&d(!1)};return document.addEventListener("pointerdown",g),document.addEventListener("keydown",f),()=>{document.removeEventListener("pointerdown",g),document.removeEventListener("keydown",f)}},[c]),e.jsxs("div",{ref:h,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),d(f=>!f)},disabled:t.every(g=>g.disabled)&&!n&&!s,className:`inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-50 ${c?"bg-surface-elevated text-foreground":p?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:m?.label??p?.label??l("rightSidebar.gitQuickActions"),children:m?e.jsx(rt,{size:13,className:"animate-spin"}):p?e.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):e.jsx(uo,{size:14})}),c&&e.jsx("div",{className:"absolute right-0 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:t.map(g=>{const f=n?.action===g.key,y=s?.action===g.key;return e.jsxs("button",{type:"button",onClick:w=>{w.stopPropagation(),g.onClick(),d(!1)},disabled:g.disabled||!!n,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] disabled:opacity-50 ${y?"bg-accent/10 text-accent":g.destructive?"text-destructive hover:bg-destructive/10":"text-foreground hover:bg-surface-2"}`,children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:f?e.jsx(rt,{size:13,className:"animate-spin"}):y?"✓":null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.label})]},g.key)})})]}))}function Og(t){const n=window.getComputedStyle(t).overflowY;return(n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight+1}function Iu(t){let n=t;for(;n;){if(n.classList.contains("termdock-diff-stream-scroller")&&Og(n))return n;n=n.parentElement}return t.closest(".termdock-diff-stream-scroller")}function Gn(t){return t.getClientRects().length>0&&window.getComputedStyle(t).visibility!=="hidden"}const oo=new WeakMap;function Ga(t){const n=oo.get(t);n!==void 0&&window.clearTimeout(n),t.classList.remove("diff-walkthrough-target"),t.offsetWidth,t.classList.add("diff-walkthrough-target");const s=window.setTimeout(()=>{t.classList.remove("diff-walkthrough-target"),oo.delete(t)},1700);oo.set(t,s)}function Wg(t){const n=CSS.escape(t),s=[`[data-diff-stream-item="${n}"]`,`[data-diff-selection-path="${n}"]`,`[data-diff-absolute-path="${n}"]`].join(","),l=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let c=null;for(const m of l){if(!Gn(m))continue;const p=m.querySelector(s);if(p&&Gn(p)){c=p;break}}if(c??=Array.from(document.querySelectorAll(s)).find(Gn)??null,!c)return;const d=Iu(c);if(!d){c.scrollIntoView({block:"start",behavior:"smooth"}),Ga(c);return}const h=c.getBoundingClientRect().top-d.getBoundingClientRect().top+d.scrollTop;d.scrollTo({top:Math.max(0,h),behavior:"instant"}),Ga(c)}function mn(t){const n=CSS.escape(t.filePath),s=typeof t.sectionIndex=="number"?String(t.sectionIndex):null,l=typeof t.hunkIndex=="number"?String(t.hunkIndex):null,c=t.sectionFingerprint?CSS.escape(t.sectionFingerprint):null,d=t.hunkFingerprint?CSS.escape(t.hunkFingerprint):null,h=[s!==null&&c?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${c}"]`:null,s!==null&&c?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${c}"]`:null,s!==null?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"]`:null,s!==null?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"]`:null,l!==null&&d?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"][data-diff-hunk-fingerprint="${d}"]`:null,l!==null?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"]`:null,`[data-diff-file-path="${n}"]`].filter(P=>!!P),m=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let p=null;for(const P of m)if(Gn(P)){for(const D of h){const H=P.querySelector(D);if(H&&Gn(H)){p=H;break}}if(p)break}if(p??=h.flatMap(P=>Array.from(document.querySelectorAll(P))).find(Gn)??null,!p){Wg(t.filePath);return}const g=Iu(p);if(!g){p.scrollIntoView({block:"center",behavior:"smooth"}),Ga(p);return}const f=p.getBoundingClientRect(),y=g.getBoundingClientRect(),C=f.top-y.top+g.scrollTop-Math.max(24,(g.clientHeight-f.height)/2);g.scrollTo({top:Math.max(0,C),behavior:"instant"}),Ga(p)}const Bu=1,zu=8;function Gg(t){return Math.min(zu,Math.max(Bu,t))}function Hu({resetKey:t,onZoomChange:n,onDoubleTap:s,children:l}){const c=i.useRef(null),[d,h]=i.useState({scale:1,x:0,y:0}),[m,p]=i.useState(!1),g=i.useRef(null),f=i.useRef(new Set),y=i.useRef(!1),w=i.useRef(null),C=i.useRef(0),P=i.useRef(d);P.current=d,i.useEffect(()=>{h({scale:1,x:0,y:0})},[t]);const D=i.useCallback((E,M,G)=>{const F=c.current;if(!F)return{x:M,y:G};const a=F.firstElementChild instanceof HTMLElement?F.firstElementChild:null,k=a?.clientWidth||F.clientWidth,I=a?.clientHeight||F.clientHeight,S=Math.max(0,(k*E-F.clientWidth)/2),Z=Math.max(0,(I*E-F.clientHeight)/2);return{x:Math.min(S,Math.max(-S,M)),y:Math.min(Z,Math.max(-Z,G))}},[]),H=i.useCallback((E,M,G)=>{h(F=>{const a=Gg(E),k=c.current;if(!k||a===1)return{scale:a,x:0,y:0};const I=k.getBoundingClientRect(),S=(M??I.left+I.width/2)-I.left-I.width/2,Z=(G??I.top+I.height/2)-I.top-I.height/2,re=a/F.scale,ne=S-(S-F.x)*re,de=Z-(Z-F.y)*re;return{scale:a,...D(a,ne,de)}})},[D]),R=i.useCallback((E,M)=>{p(!0),P.current.scale>1?h({scale:1,x:0,y:0}):H(2.5,E,M),window.setTimeout(()=>p(!1),220)},[H]);i.useEffect(()=>{const E=c.current;if(!E)return;const M=a=>{if(a.pointerType==="mouse"&&a.button!==0)return;const k=f.current.size===0;if(f.current.add(a.pointerId),k){const I=Date.now(),S=w.current;if(S&&I-S.time<350&&Math.hypot(a.clientX-S.x,a.clientY-S.y)<24){w.current=null,C.current=I,s?.(),R(a.clientX,a.clientY);return}}if(f.current.size>1){y.current=!0,g.current=null;return}if(!(P.current.scale<=1)){a.preventDefault(),g.current={pointerId:a.pointerId,startX:a.clientX,startY:a.clientY,originX:P.current.x,originY:P.current.y,moved:!1};try{E.setPointerCapture?.(a.pointerId)}catch{}p(!1)}},G=a=>{const k=g.current;if(!k||k.pointerId!==a.pointerId)return;const I=a.clientX-k.startX,S=a.clientY-k.startY;if(!k.moved){if(Math.hypot(I,S)<6)return;k.moved=!0}a.stopPropagation(),a.preventDefault(),h(Z=>({...Z,...D(Z.scale,k.originX+I,k.originY+S)}))},F=a=>{const k=g.current,I=k?.pointerId===a.pointerId&&k.moved;if(k?.pointerId===a.pointerId){k.moved&&a.stopPropagation(),g.current=null;try{E.releasePointerCapture?.(a.pointerId)}catch{}}f.current.delete(a.pointerId)&&f.current.size===0&&(!y.current&&!I&&(w.current={time:Date.now(),x:a.clientX,y:a.clientY}),y.current=!1)};return E.addEventListener("pointerdown",M,{capture:!0,passive:!1}),window.addEventListener("pointermove",G,{capture:!0,passive:!1}),window.addEventListener("pointerup",F,{capture:!0}),window.addEventListener("pointercancel",F,{capture:!0}),()=>{E.removeEventListener("pointerdown",M,{capture:!0}),window.removeEventListener("pointermove",G,{capture:!0}),window.removeEventListener("pointerup",F,{capture:!0}),window.removeEventListener("pointercancel",F,{capture:!0})}},[D,s,R]),kd({onPinch:({offset:[E],origin:[M,G]})=>{p(!1),H(E,M,G)},onWheel:({event:E,delta:[M,G],ctrlKey:F})=>{if(F){E.preventDefault(),E.stopPropagation(),p(!1),H(P.current.scale*(1-G*.01),E.clientX,E.clientY);return}P.current.scale<=1||(E.preventDefault(),E.stopPropagation(),p(!1),h(a=>({...a,...D(a.scale,a.x-M,a.y-G)})))}},{target:c,eventOptions:{passive:!1},pinch:{scaleBounds:{min:Bu,max:zu},from:()=>[P.current.scale,0],rubberband:!0}});const A=d.scale>1;return i.useEffect(()=>{n?.(A)},[n,A]),e.jsx("div",{ref:c,"data-sidebar-gesture-ignore":A?"":void 0,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden",style:{cursor:A?"grab":"zoom-in"},onDoubleClick:E=>{E.stopPropagation(),!(Date.now()-C.current<500)&&(s?.(),R(E.clientX,E.clientY))},children:l({scale:d.scale,zoomed:A,animateTransform:m,transformStyle:{transform:`translate3d(${d.x}px, ${d.y}px, 0) scale(${d.scale})`,transformOrigin:"center center",transition:m?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none",willChange:"transform"},vectorTransformStyle:{transform:`translate3d(${d.x}px, ${d.y}px, 0)`,transformOrigin:"center center",transition:m?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}})})}function Ou({src:t,alt:n,vector:s,onLoad:l,onError:c,onZoomChange:d,onDoubleTap:h}){const m=Po(t,c),[p,g]=i.useState(null),f=s??Ka(t);return i.useEffect(()=>{g(null)},[t]),e.jsx(Hu,{resetKey:t,onZoomChange:d,onDoubleTap:h,children:({transformStyle:y,vectorTransformStyle:w,scale:C,animateTransform:P})=>{const D=e.jsx("img",{src:m,alt:n,draggable:!1,className:"max-h-full max-w-full touch-none select-none rounded border border-border/15 bg-surface object-contain shadow-sm",style:f&&p?{position:"absolute",left:"50%",top:"50%",width:p.width*C,height:p.height*C,maxWidth:"none",maxHeight:"none",transform:"translate3d(-50%, -50%, 0)",transition:P?"width 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}:p?{...y,width:p.width,height:p.height}:f?w:y,onLoad:H=>{const R=H.currentTarget,A=R.parentElement;if(A&&R.naturalWidth>0&&R.naturalHeight>0){const E=Math.max(1,A.clientWidth-2),M=Math.max(1,A.clientHeight-2),G=Math.min(E/R.naturalWidth,M/R.naturalHeight),F=f?G:Math.min(G,1);g({width:Math.max(1,Math.round(R.naturalWidth*F)),height:Math.max(1,Math.round(R.naturalHeight*F))})}l(H)},onError:c});return!f||!p?D:e.jsx("div",{"data-vector-zoom-surface":!0,className:"relative shrink-0 touch-none select-none",style:{...w,width:p.width,height:p.height},children:D})}})}function Ug({svg:t,title:n,scale:s,vectorTransformStyle:l}){const c=i.useRef(null);return i.useLayoutEffect(()=>{const d=c.current,h=d?.querySelector("svg");if(!d||!h)return;const m=()=>{const f=h.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number)??[];let y=f[2],w=f[3];if((!Number.isFinite(y)||!Number.isFinite(w)||y<=0||w<=0)&&(y=Number(h.getAttribute("width")),w=Number(h.getAttribute("height"))),!Number.isFinite(y)||!Number.isFinite(w)||y<=0||w<=0)return;const C=Math.max(1,d.clientWidth-24),P=Math.max(1,d.clientHeight-24),D=Math.min(C/y,P/w,1);h.style.width=`${Math.max(1,Math.floor(y*D*s))}px`,h.style.height=`${Math.max(1,Math.floor(w*D*s))}px`,h.style.maxWidth="none",h.style.maxHeight="none",h.style.transform=String(l.transform??""),h.style.transformOrigin="center center",h.style.transition=String(l.transition??"none")};m();const p=typeof ResizeObserver>"u"?null:new ResizeObserver(m);return p?.observe(d),()=>p?.disconnect()},[s,t,l]),e.jsx("div",{ref:c,role:"img","aria-label":n,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden rounded border border-border/15 bg-white p-3 text-slate-900 shadow-sm [&_svg]:block",dangerouslySetInnerHTML:{__html:t}})}function Kg({svg:t,title:n,onZoomChange:s,onDoubleTap:l}){return e.jsx(Hu,{resetKey:t,onZoomChange:s,onDoubleTap:l,children:({vectorTransformStyle:c,scale:d})=>e.jsx(Ug,{svg:t,title:n,scale:d,vectorTransformStyle:c})})}let qg=0,Vg=0,Yg=0,Xg=0,Zg=0;function lo(t,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:t==="still_active"?"warn":"info",message:`FILE_PREVIEW_LOADING ${t}`,data:{ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function Xe(t,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:t==="error"||t==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${t}`,data:{seq:++Vg,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function Ta(t,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${t}`,data:{seq:++Xg,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function Qg(){return`diff-ui-${Date.now().toString(36)}-${(++Zg).toString(36)}`}function Jg(t){return t instanceof Element?t.closest("[data-diff-selection-path]"):null}function ex(t){const n=t.target instanceof HTMLElement?t.target:null;return{eventType:t.type,button:t.button,pointerType:t instanceof globalThis.PointerEvent?t.pointerType:void 0,targetTag:n?.tagName,targetClass:n?.className,targetText:n?.textContent?.slice(0,80)}}function To({onReviewReference:t,filePath:n,onInsertReference:s,onInsertText:l,onInsertFeature:c,onReferenceCopied:d,onClose:h,onDirectoryLinkOpen:m,isMobile:p,markdownOutlineOpen:g,markdownOutlineCloseSignal:f,onOpenMarkdownOutline:y,onCloseMarkdownOutline:w,markdownImageLightboxOpen:C,markdownImageLightboxCloseSignal:P,onOpenMarkdownImageLightbox:D,onCloseMarkdownImageLightbox:H,lineRange:R,onLineRangeChange:A,insertedReferenceKey:E,copiedReferenceKey:M,scrollToLine:G,onScrollToLineHandled:F}){const{t:a}=xt(),k=ae(T=>T.rootPath),I=ae(T=>T.selectFile),[S,Z]=i.useState({kind:"idle"}),[re,ne]=i.useState("schematic"),[de,K]=i.useState(null),X=i.useRef(null),[$,_]=i.useState(null),Y=i.useRef(new Map),te=i.useRef(null),[oe,ue]=i.useState(null),[O,ge]=i.useState(()=>ed()),[B,me]=i.useState(()=>Oc(k,n)),je=i.useRef(null),[Ee,_e]=i.useState(!1),[bt,fe]=i.useState(null),[he,j]=i.useState(0),[Q,ke]=i.useState([]),[be,De]=i.useState(null),le=i.useRef(null),Ue=i.useRef(n),[Me,U]=i.useState(null),[V,Se]=i.useState({status:"idle"}),[Re,at]=i.useState(!1),[Ke,pn]=i.useState(""),[ut,or]=i.useState([]),[Ut,gn]=i.useState(0),vt=i.useRef(null),It=jd(d),Gr=Ho(k,n);i.useEffect(()=>{if(Ue.current===n)return;Ue.current=n;const T=n&&k&&!n.startsWith("/")?`${k}/${n}`:n;if(le.current===T){le.current=null;return}le.current=null,ke([]),De(null),at(!1),pn("")},[n,k]);const lr=n?k&&!n.startsWith("/")?`${k}/${n}`:n:null,Kt=ae(T=>lr?(T.fileChangeVersions.get(lr)??0)+T.fileWatchEpoch:T.fileWatchEpoch),Mt=i.useRef(null),cr=i.useRef(null),[Bt,$s]=i.useState(0),xn=i.useCallback(()=>$s(T=>T+1),[]);i.useEffect(()=>{const T=X.current;return X.current=null,K(null),T&&URL.revokeObjectURL(T.objectUrl),()=>{const W=X.current;X.current=null,W&&URL.revokeObjectURL(W.objectUrl)}},[lr,Kt,Bt]),i.useEffect(()=>{if(!n){Mt.current=null,Z({kind:"idle"});return}const T=k&&!n.startsWith("/")?`${k}/${n}`:n,W=new AbortController,ie=++qg,xe=`right-sidebar-file-preview:${ie}`,Ie=performance.now();let $e=!1;const He=(J,Fe={})=>{$e||($e=!0,lo("end",{loadingId:ie,reason:J,durationMs:Math.round(performance.now()-Ie),filePath:n,fullPath:T,rootPath:k,...Fe}))};let Le=null;const et=Xf(T),nt=et?T.toLowerCase().endsWith(".kicad_pcb")?re==="schematic"?"pcb-front":re:"schematic":re,Xt=!et&&vd(T),pr=!et&&!Xt&&Zf(T),kn=!et&&!Xt&&!pr&&Qf(T),Zr=ms(T),Xn=fs(T),Zt=et?"eda":Xt?"image":pr?"model3d":kn?"video":"text",Qt=Mt.current!==T;if(Mt.current=T,Qt){lo("start",{loadingId:ie,filePath:n,fullPath:T,rootPath:k,mode:Zt,externalVersion:Kt}),Se({status:"idle"}),Z({kind:"loading",mode:Zt}),cr.current=null;const J=fd(k,n);A(J?.lineRange??null),ge(Zr?ed():"source"),me(Xn?Oc(k,n):"source"),et&&ne(Jf(T))}Qt||Z(J=>J.kind==="error"?{kind:"loading",mode:Zt}:J);const Sn=window.setTimeout(()=>{$e||W.signal.aborted||lo("still_active",{loadingId:ie,filePath:n,fullPath:T,rootPath:k,mode:Zt,durationMs:Math.round(performance.now()-Ie),isPathChange:Qt})},3e3),Qr=window.setTimeout(()=>{if($e||W.signal.aborted)return;const J=et?a("rightSidebar.edaTimeout"):pr?a("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";W.abort(new DOMException(J,"TimeoutError")),Z({kind:"error",message:J}),He("stuck_timeout",{error:J})},et?eh+5e3:pr?th+5e3:rh(T)?35e3:Ip);if(et){const J=nt==="pcb-3d"?X.current:null;J?(Z(J),He("eda_3d_client_cache_hit",{bytes:J.meta.size,view:J.view,mimeType:J.meta.mimeType})):nh(T,nt,W.signal,"view_file",xe).then(Fe=>{if(W.signal.aborted)return;Le=URL.createObjectURL(Fe.blob);const Jt={kind:"eda",sourcePath:Fe.path||T,objectUrl:Le,view:Fe.view,meta:{size:Fe.size,mimeType:Fe.mimeType,modified:Fe.modified}};if(Fe.view==="pcb-3d"){const er=X.current;er&&er.objectUrl!==Le&&URL.revokeObjectURL(er.objectUrl),X.current=Jt,K(Jt),Le=null}Z(Jt),He("eda_loaded",{bytes:Fe.size,view:Fe.view,mimeType:Fe.mimeType})}).catch(Fe=>{W.signal.aborted||(Z({kind:"error",message:Fe instanceof Error&&/timed out/i.test(Fe.message)?a("rightSidebar.edaTimeout"):Fe instanceof Error?Fe.message:a("rightSidebar.edaLoadFailed")}),He("error",{error:Fe instanceof Error?Fe.message:String(Fe)}))})}else if(Xt)sh(T,W.signal,"view_file",xe).then(J=>{Le=URL.createObjectURL(J.blob),Z({kind:"image",objectUrl:Le,meta:{size:J.size,mimeType:J.mimeType,modified:J.modified}}),He("image_loaded",{bytes:J.size,mimeType:J.mimeType})}).catch(J=>{W.signal.aborted||(Z({kind:"error",message:J instanceof Error?J.message:a("rightSidebar.imageLoadFailed")}),He("error",{error:J instanceof Error?J.message:String(J)}))});else if(pr)ah(T,W.signal,"view_file",xe).then(J=>{W.signal.aborted||(Le=URL.createObjectURL(J.blob),Z({kind:"model3d",sourcePath:J.path||T,objectUrl:Le,ext:J.ext,meta:{size:J.size,mimeType:J.mimeType,modified:J.modified}}),He("model3d_loaded",{bytes:J.size,ext:J.ext}))}).catch(J=>{W.signal.aborted||(Z({kind:"error",message:J instanceof Error&&(J.name==="TimeoutError"||/timed out/i.test(J.message))?a("rightSidebar.model3dTimeout"):J instanceof Error?J.message:a("rightSidebar.model3dLoadFailed")}),He("error",{error:J instanceof Error?J.message:String(J)}))});else if(kn){const J=ih(T)??"",Fe=yh(T);Z(Jt=>Jt.kind==="video"&&Jt.url===Fe?Jt:{kind:"video",url:Fe,meta:{size:null,mimeType:J,modified:null}}),He("video_ready",{mimeType:J})}else Nc(T,W.signal,"view_file",xe).then(J=>{if(!W.signal.aborted){if(J.binary){Z({kind:"binary"});return}Z({kind:"text",content:J.content,sourcePath:J.path||T,meta:{size:J.size,truncated:J.truncated}}),He("text_loaded",{bytes:J.size,truncated:!!J.truncated})}}).catch(J=>{W.signal.aborted||(Z({kind:"error",message:J instanceof Error?J.message:"Failed to read file"}),He("error",{error:J instanceof Error?J.message:String(J)}))});return()=>{W.abort(),Nt(xe),window.clearTimeout(Sn),window.clearTimeout(Qr),Le&&URL.revokeObjectURL(Le),He("cleanup")}},[n,k,Kt,Bt,A,a,re]),i.useEffect(()=>{if(S.kind!=="model3d"||!n){_(null);return}let T=!1;const W=n.lastIndexOf("/"),ie=W>=0?n.slice(W+1):n,xe=W>=0?n.slice(0,W):"",Ie=xe.lastIndexOf("/"),$e=Ie>=0?xe.slice(0,Ie):"",He=ie.replace(/\.(stl|glb|gltf)$/i,""),Le=`${$e?`${$e}/`:""}features/${He}.json`;return Nc(Le).then(et=>{if(!T)try{const nt=JSON.parse(et.content);_(nt.version===1&&Array.isArray(nt.features)&&nt.features.length>0?nt.features:null)}catch{_(null)}}).catch(()=>{T||_(null)}),()=>{T=!0}},[S,n]),i.useEffect(()=>{if(S.kind!=="text"){U(null);return}const T=k&&n&&!n.startsWith("/")?`${k}/${n}`:n,W=$d(T),ie=S.content,xe=ms(T??"")&&O==="preview",Ie=fs(T??"")&&B==="preview";if(!W||xe||Ie||!Ed(ie)){U(null);return}let $e=!1;const He=Le=>{if($e||!Le.registered(W)){$e||U(null);return}try{U(Pd(Le,ie,W))}catch{U(null)}};return bt?He(bt):(U(null),Md().then(Le=>{$e||(fe(Le),He(Le))}).catch(()=>{})),()=>{$e=!0}},[S,bt,n,k,O,B]),i.useLayoutEffect(()=>{if(!Gr||S.kind!=="text")return;const T=`${Gr}:${O}:${B}`;if(cr.current===T)return;const W=fd(k,n);if(cr.current=T,!W)return;const ie=requestAnimationFrame(()=>{const xe=te.current;if(!xe)return;const Ie=O==="preview"?W.markdownTop??W.top:W.top;xe.scrollTo({top:Math.max(0,Ie??0),left:Math.max(0,W.left??0)}),j(O==="preview"?Math.max(0,Ie??0):0)});return()=>cancelAnimationFrame(ie)},[n,O,B,S.kind,Gr,k]),i.useEffect(()=>{Gr&&eo(k,n,{lineRange:R})},[n,R,Gr,k]),i.useEffect(()=>{if(G==null||S.kind!=="text")return;ue(null),A({start:G,end:G});const T=G,W=requestAnimationFrame(()=>{const ie=Y.current.get(T);ie&&ie.scrollIntoView({block:"center"}),F?.()});return()=>cancelAnimationFrame(W)},[G,S,A,F]);const Un=i.useCallback(T=>{const W=te.current;if(!W)return!1;const ie=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(T):T.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),xe=W.querySelector(`#${ie}`);return xe?(xe.scrollIntoView({block:"start"}),!0):!1},[]);i.useEffect(()=>{const T=k&&n&&!n.startsWith("/")?`${k}/${n}`:n,W=S.kind==="text"&&ms(T??"")&&O==="preview";if(!be||!W)return;const ie=requestAnimationFrame(()=>{Un(be)&&De(null)});return()=>cancelAnimationFrame(ie)},[n,Un,O,be,S,k]),i.useLayoutEffect(()=>{const T=te.current;if(!T||!R){ue(null);return}if(oe)return;const W=S.kind==="image"||S.kind==="loading"&&S.mode==="image",ie=k&&n&&!n.startsWith("/")?`${k}/${n}`:n,xe=S.kind==="text"&&ms(ie??"")&&O==="preview",Ie=S.kind==="text"&&fs(ie??"")&&B==="preview";if(S.kind!=="text"||W||xe||Ie){ue(null);return}const $e=()=>{const Le=Y.current.get(R.end);if(!Le||!T){ue(null);return}const et=Le.offsetTop+Le.offsetHeight/2,nt=T.scrollLeft+Math.max(8,T.clientWidth-120);ue({top:et,left:nt})};$e();const He=new ResizeObserver(()=>$e());return He.observe(T),()=>He.disconnect()},[R,oe,S,O,B,n,k,Me]);const zt=S.kind==="text"&&!(fs(lr??"")&&B==="preview")&&!lr?.toLowerCase().endsWith(".csv")&&!lr?.toLowerCase().endsWith(".kicad_pro")&&!lr?.toLowerCase().endsWith(".kicad_prl"),Ur=i.useCallback(()=>{at(!1),pn(""),or([]),gn(0),Na()},[]),wt=i.useCallback(()=>{zt&&(at(!0),requestAnimationFrame(()=>{vt.current?.focus(),vt.current?.select()}))},[zt]),Nr=i.useCallback(T=>{gn(W=>ut.length===0?0:(W+T+ut.length)%ut.length)},[ut.length]);if(i.useEffect(()=>{const T=W=>{const ie=yp(W);if(ie==="open"&&zt){W.preventDefault(),wt();return}Re&&(ie==="close"?(W.preventDefault(),Ur()):(ie==="next"||ie==="previous")&&(W.preventDefault(),Nr(ie==="previous"?-1:1)))};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[Ur,Re,Nr,wt,zt]),i.useLayoutEffect(()=>{if(Na(),!Re||!Ke.trim()||!te.current){or([]),gn(0);return}const T=Sp(te.current,Ke);return or(T),gn(0),Uc(T,0),Kc(T[0]),Na},[Re,Ke,Me,O,S]),i.useEffect(()=>{Re&&(Uc(ut,Ut),Kc(ut[Ut]))},[Ut,ut,Re]),i.useEffect(()=>Na,[]),!n)return e.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:a("rightSidebar.selectFilePrompt")});const Pe=k&&!n.startsWith("/")?`${k}/${n}`:n,Ht=Da(Pe,k),Cr=wd(Pe,k),dr=S.kind==="text"&&S.content?S.content.split(`
55
+ `):[],Va=Math.max(2,String(dr.length).length)+1,yt=S.kind==="text"||S.kind==="image"||S.kind==="model3d"||S.kind==="video"||S.kind==="eda"?S.meta:null,Es=ms(Pe),Tt=Pe.toLowerCase().endsWith(".csv"),Ms=Pe.toLowerCase().endsWith(".kicad_pro"),qt=Pe.toLowerCase().endsWith(".kicad_prl"),Kr=S.kind==="text"&&Es&&O==="preview",Kn=fs(Pe),ur=S.kind==="text"&&Kn&&B==="preview",Ya=S.kind==="image"||S.kind==="loading"&&S.mode==="image",kt=S.kind==="model3d"||S.kind==="loading"&&S.mode==="model3d",qr=S.kind==="video"||S.kind==="loading"&&S.mode==="video",qn=S.kind==="eda"||S.kind==="loading"&&S.mode==="eda",Vn=S.kind==="text"?S.sourcePath:Pe,Ar=Mh(Vn,k,R),$r=(()=>{if(!R||S.kind!=="text"||dr.length===0)return Ar;const T=[];for(let xe=R.start;xe<=R.end;xe+=1)T.push(`${xe} ${dr[xe-1]??""}`);const W=nu(Pe).replace(/^\./,""),ie="```";return`${Ar}
56
+ ${ie}${W}
57
+ ${T.join(`
58
+ `)}
59
+ ${ie}
60
+ `})(),Er=`path:${Pe}`,Pt=R?`path:${Pe}:${R.start}-${R.end}`:Er,Vr=E===Er,Yr=E===Pt,Ts=M===Er,Mr=M===Pt,fr=Yr||Mr,hr=R?R.start===R.end?`L${R.start}`:`L${R.start}-${R.end}`:null,bn=T=>{const W=te.current;if(!W)return;const ie=W.getBoundingClientRect(),xe=T.currentTarget.getBoundingClientRect(),Ie=T.clientX||xe.left+xe.width/2,He=(T.clientY||xe.top+xe.height/2)-ie.top+W.scrollTop,Le=p?116:132,et=W.scrollLeft+Math.max(8,W.clientWidth-Le),nt=Math.min(Math.max(8,Ie-ie.left+W.scrollLeft+10),et);ue({top:He,left:nt})},vn=(T,W)=>{Mo()||(bn(T),A(ie=>{const xe=Eo(ie,W,W);return xe||ue(null),xe}))},mr=(T,W,ie)=>{bn(T),A(xe=>{const Ie=Eo(xe,W,ie);return Ie||ue(null),Ie})},Vt=(T,W,ie,xe)=>{xe==="end"&&bn(T),A({start:W,end:ie})},Ae=T=>{const{scrollTop:W,scrollLeft:ie}=T.currentTarget;j(W),eo(k,n,{top:W,left:ie,markdownTop:W})},Yt=T=>{if(T.directory){m?.(T.path);return}if(T.path===Pe||S.kind==="text"&&T.path===S.sourcePath){T.fragment&&Un(T.fragment);return}ke(W=>[...W,Pe]),le.current=T.path,De(T.fragment),A(null),I(T.path)},Xr=()=>{const T=Q[Q.length-1];T&&(ke(W=>W.slice(0,-1)),le.current=T,De(null),A(null),I(T))},Yn=T=>{const{scrollTop:W,scrollLeft:ie}=T.currentTarget;eo(k,n,{top:W,left:ie})},wn=()=>{if(t){t($r,Pt);return}R&&l($r,Pt)},yn=async()=>{if(!(!Pe||V.status==="pending")&&!(S.kind==="loading"||S.kind==="error")){Se({status:"pending"});try{await kh(Pe),Se({status:"idle"})}catch(T){Se({status:"error",message:T instanceof Error?T.message:a("rightSidebar.downloadFailed")})}}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[It.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${p&&(Kr||ur)?"py-1.5":"py-2"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[p&&h&&e.jsx("button",{type:"button",onClick:h,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":a("rightSidebar.backToFileList"),title:a("rightSidebar.backToFileList"),children:e.jsx(Rd,{size:16})}),Q.length>0&&e.jsxs("button",{type:"button",onClick:Xr,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 ${p?"w-9":"px-2.5"}`,"aria-label":a("rightSidebar.backToPreviousPreview"),title:a("rightSidebar.backToPreviousPreview"),children:[e.jsx(ks,{size:15}),!p&&e.jsx("span",{className:"text-[11px] font-medium",children:a("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:Pe,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Ht.name}),Ht.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Ht.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[zt&&e.jsx("button",{type:"button",onClick:Re?Ur:wt,className:`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${Re?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":a("rightSidebar.findInFile"),title:`${a("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(Wn,{size:14})}),Es&&S.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{g&&w?.(),ge(T=>{const W=T==="preview"?"source":"preview";return pt(Od,W),W}),A(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 ${p?"w-9 px-0":"px-3"}`,"aria-label":a(O==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:a(O==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:p?O==="preview"?e.jsx(go,{size:14}):e.jsx(po,{size:14}):a(O==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),Kn&&S.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{me(T=>{const W=T==="preview"?"source":"preview";return Ym(k,n,W),W}),A(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 ${p?"w-9 px-0":"px-3"}`,"aria-label":a(B==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:a(B==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:p?B==="preview"?e.jsx(go,{size:14}):e.jsx(po,{size:14}):a(B==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),ur&&e.jsx("button",{type:"button",onClick:()=>{je.current?.toggleFullscreen()},className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":a(Ee?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:a(Ee?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(Ad,{size:15})}),!p&&e.jsx("button",{type:"button",onClick:()=>s(Pe,Er),...It(Cr,Er),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${Vr||Ts?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:a("rightSidebar.insertReference",{reference:Cr}),children:a(Ts?"rightSidebar.copied":Vr?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Cr)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:a("rightSidebar.copyReference",{reference:Cr}),"aria-label":a("rightSidebar.copyFileRef"),children:e.jsx(oh,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{yn()},disabled:V.status==="pending"||S.kind==="loading"||S.kind==="error",className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:opacity-50 disabled:active:scale-100",title:V.status==="error"?V.message??a("rightSidebar.downloadFailed"):a("rightSidebar.downloadFile"),"aria-label":a("rightSidebar.downloadFile"),children:V.status==="pending"?e.jsx(rt,{size:13,className:"animate-spin"}):e.jsx(Th,{size:14})})]})]}),Re&&zt&&e.jsxs("div",{className:"mt-2 flex min-w-0 items-center gap-1.5","data-file-preview-search":!0,children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center rounded-lg bg-surface-2 px-2 focus-within:bg-surface-elevated",children:[e.jsx(Wn,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:vt,type:"search",value:Ke,onChange:T=>pn(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),Nr(T.shiftKey?-1:1))},className:"h-8 min-w-0 flex-1 bg-transparent px-2 text-xs text-foreground outline-none placeholder:text-muted-foreground/70",placeholder:a("rightSidebar.findInFilePlaceholder"),"aria-label":a("rightSidebar.findInFile")}),e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:ut.length>0?`${Ut+1}/${ut.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>Nr(-1),disabled:ut.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":a("rightSidebar.previousSearchMatch"),title:`${a("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:e.jsx(yd,{size:13})}),e.jsx("button",{type:"button",onClick:()=>Nr(1),disabled:ut.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":a("rightSidebar.nextSearchMatch"),title:`${a("rightSidebar.nextSearchMatch")} (Enter)`,children:e.jsx(Ph,{size:13})}),e.jsx("button",{type:"button",onClick:Ur,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":a("rightSidebar.closeFileSearch"),title:`${a("rightSidebar.closeFileSearch")} (Esc)`,children:e.jsx(_t,{size:13})})]}),yt&&!(p&&(Kr||ur))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[yt.size!==null&&e.jsx("span",{children:a("rightSidebar.byteCount",{count:yt.size.toLocaleString()})}),"truncated"in yt&&yt.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:a("rightSidebar.previewTruncated")}),"mimeType"in yt&&e.jsx("span",{children:yt.mimeType}),"dimensions"in S&&S.dimensions&&e.jsxs("span",{children:[S.dimensions.width," × ",S.dimensions.height]})]}),!(p&&(Kr||ur))&&!kt&&S.kind!=="binary"&&e.jsx("div",{className:"mt-1 flex h-4 items-center gap-2 text-[10px] text-muted-foreground/75",children:e.jsx("span",{className:"truncate",children:qn?a("rightSidebar.edaPickHint"):Tt?a("rightSidebar.csvTablePreview"):Ms||qt?a("rightSidebar.kicadProjectPickHint"):qr?a("rightSidebar.videoPreviewHint"):Ya?a("rightSidebar.imagePreviewHint"):Kr?R?a("rightSidebar.selectedLineHint",{lineLabel:hr??""}):a("rightSidebar.markdownPreviewHint"):ur?a("rightSidebar.htmlPreviewHint"):R?a("rightSidebar.selectedLineHint",{lineLabel:hr??""}):a("rightSidebar.multiLineHint")})})]}),S.kind==="loading"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8 text-center text-sm text-muted-foreground",children:S.mode==="eda"?a("rightSidebar.edaLoading"):S.mode==="image"?a("rightSidebar.loadingImage"):S.mode==="model3d"?a("rightSidebar.model3dLoading"):S.mode==="video"?a("rightSidebar.loadingVideo"):"Loading file…"}):S.kind==="error"?e.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[e.jsx("div",{className:"mx-3 mt-3 border border-destructive/20 bg-destructive/5 px-4 py-4 text-sm text-destructive",children:S.message}),e.jsx("button",{type:"button",onClick:xn,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:a("common.retry")})]}):S.kind==="binary"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsx("div",{className:"mx-3 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-6 text-center text-sm text-muted-foreground",children:a("rightSidebar.binaryPreviewHint")})}):S.kind==="image"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:S.meta.mimeType==="image/svg+xml"?e.jsx(Id,{blobUrl:S.objectUrl,filePath:Pe,viewLabel:"SVG 文件",onInsertAnnotation:c}):e.jsx(Ou,{src:S.objectUrl,alt:Ht.name,vector:!1,onLoad:T=>{const W=T.currentTarget;Z(ie=>ie.kind==="image"?{...ie,dimensions:{width:W.naturalWidth,height:W.naturalHeight}}:ie)},onError:()=>Z({kind:"error",message:a("rightSidebar.imageLoadFailed")})})}):S.kind==="video"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:e.jsx(ep,{url:S.url,onLoadError:()=>Z({kind:"error",message:a("rightSidebar.videoLoadFailed")})})}):S.kind==="eda"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(op,{blobUrl:S.objectUrl,filePath:S.sourcePath,view:S.view,board:Pe.toLowerCase().endsWith(".kicad_pcb"),onViewChange:ne,onInsertAnnotation:t??c,onRefresh:xn,interactive3d:de?e.jsx(i.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:a("rightSidebar.model3dLoading")}),children:e.jsx(Jc,{blobUrl:de.objectUrl,ext:".glb",fileName:Ht.name,filePath:de.sourcePath,features:null,onInsertFeature:t??c,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:T=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(T)?T:"PCB板体/铜箔/丝印",active:S.view==="pcb-3d"})}):void 0})}):S.kind==="model3d"?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:e.jsx(i.Suspense,{fallback:e.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:a("rightSidebar.model3dLoading")}),children:e.jsx(Jc,{blobUrl:S.objectUrl,ext:S.ext,fileName:Ht.name,filePath:S.sourcePath,features:$,onInsertFeature:t??c,onRefresh:xn})})}):S.kind==="text"&&Tt?e.jsx(dp,{content:S.content,filePath:Pe,onInsertAnnotation:t??c},Pe):S.kind==="text"&&(Ms||qt)?e.jsx(hp,{content:S.content,filePath:Pe,localState:qt,onInsertAnnotation:t??c},Pe):Kr?e.jsxs("div",{ref:te,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:Ae,style:{touchAction:"pan-x pan-y"},children:[e.jsx(Mu,{content:S.content,filePath:S.sourcePath,rootPath:k,lineRange:R,onLineRangeClick:mr,onLineRangeDrag:Vt,scrollTop:he,outlineOpen:g,outlineCloseSignal:f,onOutlineOpen:y,onOutlineClose:w,lightboxOpen:C,lightboxCloseSignal:P,onLightboxOpen:D,onLightboxClose:H,onLocalLinkOpen:Yt}),R&&oe&&e.jsxs("button",{type:"button",onClick:wn,...It($r,Pt),style:{top:oe.top,left:oe.left,transform:"translateY(-50%)"},className:hd(p,fr),title:`Insert markdown reference: ${Ar}`,children:[e.jsx(_a,{size:p?13:11}),Mr?a("rightSidebar.copied"):Yr?a("rightSidebar.inserted"):a("rightSidebar.insertLineRef",{lineLabel:hr??""})]})]}):ur?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(wp,{ref:je,src:lh(Pe),title:`${Ht.name} preview`,exitFullscreenLabel:a("rightSidebar.htmlFullscreenExit"),onFullscreenChange:_e},`${Pe}:${Kt}:${Bt}`)}):S.kind==="text"?e.jsxs("div",{ref:te,onScroll:Yn,className:`${Do} 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:[dr.length>0?e.jsx("div",{className:"min-w-full",children:dr.map((T,W)=>{const ie=W+1,xe=!!(R&&ie>=R.start&&ie<=R.end),Ie=Me&&Me.length===dr.length?Me[W]:null;return e.jsxs("div",{ref:$e=>{$e?Y.current.set(ie,$e):Y.current.delete(ie)},role:"button","data-file-preview-line":ie,tabIndex:0,onClick:$e=>vn($e,ie),onKeyDown:$e=>{$e.key!=="Enter"&&$e.key!==" "||($e.preventDefault(),vn($e,ie))},style:{gridTemplateColumns:`${Va}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${xe?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Cr}:${ie}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${xe?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:ie}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Ie??(T||" ")})]},W)})}):"Empty file.",R&&oe&&e.jsxs("button",{type:"button",onClick:wn,...It($r,Pt),style:{top:oe.top,left:oe.left,transform:"translateY(-50%)"},className:hd(p,fr),title:`Insert code reference: ${Ar}`,children:[e.jsx(_a,{size:p?13:11}),Mr?a("rightSidebar.copied"):Yr?a("rightSidebar.inserted"):a("rightSidebar.insertLineRef",{lineLabel:hr??""})]})]}):null]})}function tx({isOpen:t,drawerWidthPx:n,onClose:s,onOpen:l,push:c,pinned:d=!1,onTogglePinned:h,rightSidebarFilePreviewOpen:m=!1,rightSidebarFilePreviewCloseSignal:p,onOpenRightSidebarFilePreview:g,onCloseRightSidebarFilePreview:f,rightSidebarRepoPickerOpen:y=!1,rightSidebarRepoPickerCloseSignal:w,onOpenRightSidebarRepoPicker:C,onCloseRightSidebarRepoPicker:P,markdownOutlineOpen:D=!1,markdownOutlineCloseSignal:H,onOpenMarkdownOutline:R,onCloseMarkdownOutline:A,markdownImageLightboxOpen:E=!1,markdownImageLightboxCloseSignal:M,onOpenMarkdownImageLightbox:G,onCloseMarkdownImageLightbox:F}){const{t:a,locale:k}=xt(),[I,S]=i.useState(""),[Z,re]=i.useState(null),ne=ae(r=>r.rightSearchOpen),de=ae(r=>r.setRightSearchOpen),K=ae(r=>r.rightSidebarLayoutPreference),X=ae(r=>r.setRightSidebarLayoutPreference),[$,_]=i.useState(()=>Yp()),[Y,te]=i.useState("."),[oe,ue]=i.useState(""),[O,ge]=i.useState(!1),[B,me]=i.useState(!1),[je,Ee]=i.useState(!1),[_e,bt]=i.useState(!1),fe=i.useDeferredValue(I),[he,j]=i.useState(null),[Q,ke]=i.useState([]),[be,De]=i.useState([]),[le,Ue]=i.useState(null),[Me,U]=i.useState(null),[V,Se]=i.useState(null),[Re,at]=i.useState(null),[Ke,pn]=i.useState(()=>Qe(Vc,bs)??!1),[ut,or]=i.useState(()=>Qe(Yc,bs)??!1),[Ut,gn]=i.useState(()=>Qe(Xc,bs)??!1),[vt,It]=i.useState(()=>Qe(qi,Gp)??""),[Gr,lr]=i.useState(0),[Kt,Mt]=i.useState(!1),[cr,Bt]=i.useState(!1),$s=i.useRef(null),xn=i.useRef(null),[Un,zt]=i.useState(!1),[Ur,wt]=i.useState(null),[Nr,Pe]=i.useState(null),[Ht,Cr]=i.useState(()=>rd(Ui)),[dr,Va]=i.useState(()=>rd(qc)),[yt,Es]=i.useState(()=>Wp()),[Tt,Ms]=i.useState(()=>Up()),[qt,Kr]=i.useState(()=>qp()),Kn="words",[ur,Ya]=i.useState(0),[kt,qr]=i.useState([]),[qn,Vn]=i.useState([]),[Ar,$r]=i.useState(!1),[Er,Pt]=i.useState(null),[Vr,Yr]=i.useState([]),[Ts,Mr]=i.useState(!1),[fr,hr]=i.useState([]),[bn,vn]=i.useState([]),[mr,Vt]=i.useState(!1),[Ae,Yt]=i.useState(null),[Xr,Yn]=i.useState([]),[wn,yn]=i.useState({}),[T,W]=i.useState(!1),[ie,xe]=i.useState(null),[Ie,$e]=i.useState(null),[He,Le]=i.useState(null),[et,nt]=i.useState(null),[Xt,pr]=i.useState(!1),[kn,Zr]=i.useState(""),Xn=i.useDeferredValue(kn),[Zt,Qt]=i.useState([]),[Sn,Qr]=i.useState(!1),[J,Fe]=i.useState(!1),[Jt,er]=i.useState(null),[Xa,jn]=i.useState(!1),tr=i.useRef(null),Tr=i.useRef(0),Wo=i.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Wu,Ps]=i.useState(null),[Zn,Go]=i.useState(()=>Qe(Ki,bs)??!1),[Za,Qa]=i.useState(!1),[Ls,Uo]=i.useState([]),[gr,Fs]=i.useState({}),[St,Ds]=i.useState({}),[Pr,Ko]=i.useState(!0),[qo,Vo]=i.useState(()=>new Set),[qe,Jr]=i.useState(null),[Ja,en]=i.useState(null),[Gu,xr]=i.useState(!1),[Yo,br]=i.useState(0),[,ei]=i.useState(0),[ti,_s]=i.useState(!1),[rr,ri]=i.useState(!1),[Uu,Xo]=i.useState(()=>ae.getState().rightTab==="diff"),[Te,Qn]=i.useState(null),[Rn,Jn]=i.useState(null),[it,Lr]=i.useState(null),[Zo,ot]=i.useState(null),[Nn,Qo]=i.useState(null),[ni,Ku]=i.useState(()=>Date.now()),[qu,Vu]=i.useState(!1),[tn,Is]=i.useState(!1),[Bs,Jo]=i.useState(""),[es,si]=i.useState(""),[rn,ai]=i.useState(""),[nn,ii]=i.useState(""),[el,Cn]=i.useState(null),[zs,Hs]=i.useState(!1),[tl,oi]=i.useState(!1),[rl,nl]=i.useState(!1),[Os,Yu]=i.useState({key:null,nonce:0}),sl=i.useRef(null),al=i.useRef(null),ee=Uh(n,d,K),Xu=Jd(ee,d,qt),[li,ci]=i.useState(()=>ng(n)),di=ae(r=>r.rightTab),sn=ae(r=>r.setRightTab),v=ae(r=>r.rootPath),An=ae(r=>r.explorerRoot),il=ae(r=>r.pinnedExplorerRootsCache),ol=ae(r=>r.hydratePinnedExplorerRoots),ll=ae(r=>r.syncPinnedExplorerRoots),Lt=ae(r=>r.setExplorerRoot),cl=ae(r=>r.resetExplorerToProject),$n=ae(r=>r.pinExplorerRoot),an=ae(r=>r.unpinExplorerRoot),Ge=ae(r=>r.selectedFilePath),Ze=ae(r=>r.selectFile),ui=ae(r=>r.showHiddenFiles),Zu=ae(r=>r.toggleShowHiddenFiles),we=ae(r=>r.changedFiles),Ws=ae(r=>r.setChangedFiles),Gs=ae(r=>r.invalidateDirectoryCache),Qu=ae(r=>r.setDirectorySortMode),dl=ae(r=>r.applyFileWatchEvents),ul=ae(r=>r.reconcileDirectoryCache),fl=ae(r=>r.bumpFileWatchEpoch),Ct=ae(r=>r.gitBundleLoading),Us=ae(r=>r.gitBundleSlow),En=ae(r=>r.gitBundleError),Fr=ae(r=>r.gitBundleLastLoadedAt),hl=ae(r=>r.beginGitBundleLoading),ml=ae(r=>r.setGitBundleSlowFor),fi=ae(r=>r.finishGitBundleLoading),pl=ae(r=>r.resetGitBundleLoading),hi=ae(r=>r.setGitBundleError),gl=ae(r=>r.markGitBundleLoaded),pe=An??v,xl=i.useMemo(()=>pe?Rp(pe,Y):"",[pe,Y]),ts=i.useMemo(()=>jp(oe),[oe]),bl=i.useMemo(()=>({excludePatterns:ts,caseSensitive:B,wholeWord:je,regex:_e}),[B,ts,_e,je]),Ks=ae(r=>pe?r.fileSortModes[pe]??"name":"name"),qs=ae(r=>!!(pe&&r.directoryCache.has(pe))),Mn=i.useRef(null),At=i.useRef(0),[vl]=i.useState(()=>++Yg),vr=i.useRef(null),Dr=i.useRef(null),Vs=i.useRef(0),Ot=i.useRef(new Map),wr=i.useRef(new Map),_r=i.useRef(new Set),rs=i.useRef(new Set),on=i.useRef(0),Ir=i.useRef(null),Tn=i.useRef(0),Pn=i.useRef(null),Ln=i.useRef(0),Br=i.useRef(null),mi=i.useRef(new Set),pi=i.useRef(null),gi=i.useRef(null),Ys=i.useRef(null),xi=i.useRef(null);i.useEffect(()=>{if(Nn===null)return;const r=Math.max(0,Date.now()-Nn),o=r<6e4?1e3:r<36e5?6e4:r<864e5?36e5:864e5,u=Math.max(50,o-r%o),x=window.setTimeout(()=>Ku(Date.now()),u);return()=>window.clearTimeout(x)},[ni,Nn]);const Xs=i.useRef(null),yr=i.useRef(null),Zs=i.useRef(null),ns=i.useRef(null),Ne=i.useCallback(r=>ae.getState().rootPath===r,[]);i.useEffect(()=>{if(!t||typeof window>"u")return;const r=o=>{const u=Jg(o.target);u&&Ta("global_change_row_event",{...ex(o),selectionPath:u.dataset.diffSelectionPath,filePath:u.dataset.diffFilePath,absolutePath:u.dataset.diffAbsolutePath,repoRoot:u.dataset.diffRepoRoot,status:u.dataset.diffStatus,selectedFilePath:ae.getState().selectedFilePath,rightTab:ae.getState().rightTab,activeGitRepoRoot:le,changedFiles:ae.getState().changedFiles.size})};return window.addEventListener("pointerdown",r,{capture:!0}),window.addEventListener("click",r,{capture:!0}),()=>{window.removeEventListener("pointerdown",r,{capture:!0}),window.removeEventListener("click",r,{capture:!0})}},[le,t]);const wl=i.useCallback(async(r=v??void 0)=>{if(!r)return null;if(_r.current.has(r)||rs.current.has(r))return Xe("untracked_skip_cached",{cwd:r,rootPath:v,completed:_r.current.has(r),running:rs.current.has(r)}),null;const o=v,u=Vs.current+1;Vs.current=u,Ot.current.set(r,u);const x=`right-sidebar-git-untracked:${r}`,b=new AbortController;wr.current.set(r,b),rs.current.add(r),Xe("untracked_start",{requestId:u,cwd:r,rootPath:v});try{let N=await Cc(r,b.signal,x),L=0;for(;N.status==="running"&&L<120;){if(Ot.current.get(r)!==u||b.signal.aborted)return Xe("untracked_stale_result",{requestId:u,activeRequestId:Ot.current.get(r),cwd:r,status:N.status}),null;if(!Ne(o))return Xe("untracked_root_changed",{requestId:u,cwd:r,expectedRootPath:o,currentRootPath:ae.getState().rootPath}),null;await new Promise(q=>window.setTimeout(q,L<10?1e3:3e3)),L+=1,N=await Cc(r,b.signal,x)}if(Ot.current.get(r)!==u||!Ne(o))return Xe("untracked_stale_result",{requestId:u,activeRequestId:Ot.current.get(r),cwd:r,expectedRootPath:o,currentRootPath:ae.getState().rootPath,files:N.files.length,status:N.status}),null;if(N.status==="done")return Ws(Fu(ae.getState().changedFiles,N.files)),N.files.length>0&&ke(q=>{const Ye=new Map(q.map(ve=>[ve.root,ve])).get(r);if(!Ye)return q;const Be=_g(Ye.files,N.files),se=q.map(ve=>ve.root===r?{...ve,files:Be,context:ve.context?{...ve.context,changedFiles:Be.map(Et=>({path:Et.path,absolutePath:Et.absolutePath,status:Et.status})),truncated:!1}:ve.context,untrackedDeferred:!1}:ve);De(Du(se,v));const ze=se.find(ve=>ve.root===v);return ze?.context&&j(ve=>ve?.root===ze.root?{...ve,...ze.context}:ve),se}),_r.current.add(r),Xe("untracked_apply",{requestId:u,cwd:r,files:N.files.length}),N;const z=N.error||(N.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return _r.current.add(r),Xe("untracked_error",{requestId:u,cwd:r,message:z,code:N.code,status:N.status}),null}catch(N){if(Ot.current.get(r)!==u||!Ne(o)||ir(N))return Xe("untracked_aborted",{requestId:u,activeRequestId:Ot.current.get(r),cwd:r,expectedRootPath:o,currentRootPath:ae.getState().rootPath,message:N instanceof Error?N.message:String(N)}),null;const L=N instanceof Error?N.message:"Failed to scan untracked files";return _r.current.add(r),Xe("untracked_error",{requestId:u,cwd:r,message:L}),null}finally{wr.current.get(r)===b&&wr.current.delete(r),Ot.current.get(r)===u&&Ot.current.delete(r),rs.current.delete(r)}},[he,Ne,v,Ws]),Wt=i.useMemo(()=>{const r=new Set(be.map(u=>u.root)),o=Vr.filter(u=>r.has(u));return o.length>0?o:le?[le]:[]},[le,Vr,be]),yl=Wt.length===0,ln=i.useMemo(()=>Wt.map(r=>Q.find(o=>o.root===r)).filter(r=>!!r),[Wt,Q]),Ju=i.useMemo(()=>be.map(r=>({root:r.root,label:r.label,branch:r.branch??null})),[be]),nr=i.useCallback(async()=>{if(!v){qr([]),Vn([]);return}const r=v,o=Tn.current+1;Tn.current=o,Pn.current?.abort();const u=new AbortController;Pn.current=u,$r(kt.length===0),Pt(null);try{const x=Wt.length>0?await Promise.all(Wt.map(b=>Ac({workspaceRoot:v,repoRoot:b},u.signal))).then(b=>({records:b.flatMap(N=>N.records),walkthroughs:b.flatMap(N=>N.walkthroughs??[])})):await Ac({workspaceRoot:v},u.signal);if(Tn.current!==o||!Ne(r))return;qr(x.records),Vn(x.walkthroughs??[])}catch(x){if(Tn.current!==o||!Ne(r)||ir(x))return;Pt(x instanceof Error?x.message:"Failed to load change audit explanations")}finally{Pn.current===u&&(Pn.current=null),Tn.current===o&&Ne(r)&&$r(!1)}},[kt.length,Wt,Ne,v]),Qs=i.useCallback(async(r,o,u)=>{if(!r&&!v){hr([]),vn([]);return}const x=v,b=Ln.current+1;Ln.current=b,Br.current?.abort();const N=new AbortController;Br.current=N;try{const L=r?[r]:Array.from(new Set([v,...Q.map(q=>q.root)].filter(q=>!!q))),z=await Promise.all(L.map(q=>dh({repoRoot:q,baseRef:o,branchName:u},N.signal))).then(q=>{const Ce=new Map,Ye=new Map;for(const Be of q){for(const se of Be.records)Ce.set(se.id,se);for(const se of Be.walkthroughs??[])Ye.set(se.id,se)}return{records:Array.from(Ce.values()),walkthroughs:Array.from(Ye.values())}});if(Ln.current!==b||!Ne(x))return;hr(z.records),vn(z.walkthroughs??[])}catch(L){if(Ln.current!==b||!Ne(x)||ir(L))return;console.warn("[RightSidebar] Failed to load branch explanations",L)}finally{Br.current===N&&(Br.current=null)}},[Q,Ne,v]),zr=i.useCallback((r,o={})=>{if(!Ne(v)){Xe("apply_skipped_root_changed",{expectedRootPath:v,currentRootPath:ae.getState().rootPath,bundleRoot:r.context?.root,files:r.files.length});return}Xe(r.files.length===0?"empty_bundle":"apply",{rootPath:v,available:r.available,files:r.files.length,repositories:r.repositories?.map(se=>({root:se.root,relativeRoot:se.relativeRoot,files:se.files.length,available:se.available,error:se.error})),repoFilters:r.repoFilters?.map(se=>({root:se.root,label:se.label,count:se.count})),cached:r.cached,stale:r.stale,cacheAgeMs:r.cacheAgeMs,untrackedDeferred:r.untrackedDeferred,error:r.error});let u=eu(r),x=r.repoFilters??[],b=r.files;const N=ae.getState().changedFiles;if(!!(o.cacheOnly&&!r.cached&&r.files.length===0&&u.length===0)&&(N.size>0||Q.length>0||he)){Xe("cache_only_apply_skipped_empty_backend_cache",{rootPath:v,currentFiles:N.size,currentRepositories:Q.length});return}const z=md(N.values(),v),q=md(r.files,v),Ce=u.some(se=>se.root!==v);if(!!(o.background&&N.size>0&&(r.files.length===0&&!r.error||z>0&&q===0&&!Ce))){Xe("background_apply_skipped_degraded_bundle",{rootPath:v,currentFiles:N.size,nextFiles:r.files.length,currentNestedCount:z,nextNestedCount:q,nextRepositories:u.map(se=>({root:se.root,relativeRoot:se.relativeRoot,files:se.files.length})),cached:r.cached,stale:r.stale,error:r.error});return}if(o.replaceRepoRoot){const se=_u(N.values(),Q,r,o.replaceRepoRoot,v);b=se.files,u=se.repositories,x=se.repoFilters}if(Ws(Lu(b)),ke(u),De(x),o.syncActiveRepo!==!1){const se=o.activeRepoRoot!==void 0?o.activeRepoRoot:le??td(v),ze=Zp({...r,repositories:u,repoFilters:x},se);Ue(ze),Yi(v,ze)}typeof r.cacheUpdatedAt=="number"&&Qo(r.cacheUpdatedAt),j(se=>{if(o.replaceRepoRoot&&o.replaceRepoRoot!==v)return se;if(!r.context)return null;const ze=se?.root??v;return!se?.available||ze!==(r.context.root??v)?r.context:{...se,...r.context}}),o.reloadDiff&&Ya(se=>se+1);const Be=ae.getState().selectedFilePath;if(Be&&!Be.startsWith("/")&&!b.some(se=>se.path===Be||se.absolutePath===Be)&&Ze(null),Cr(se=>{const ze=new Set(b.map(Et=>mt(Et,v)).filter(Boolean)),ve=new Set;for(const Et of se)ze.has(Et)&&ve.add(Et);return Xi(Ui,ve),ve}),o.loadDeferred!==!1){const se=u.filter(ze=>ze.untrackedDeferred&&ze.root).map(ze=>ze.root);for(const ze of se)wl(ze)}o.loadAudit!==!1&&nr()},[le,Ne,nr,wl,v,Ze,Ws]);i.useEffect(()=>{pl(),pi.current=null,gi.current=v;const r=[],o=[],x=td(v);At.current+=1,on.current+=1,Vs.current+=1,vr.current?.abort(),Nt(On(Dr.current?.cwd??v??void 0)),Dr.current=null,vr.current=null,Ir.current?.abort(),Nt("right-sidebar-git-details"),Ir.current=null;for(const q of wr.current.values())q.abort();for(const q of wr.current.keys())Nt(`right-sidebar-git-untracked:${q}`);wr.current.clear(),Ot.current.clear(),Tn.current+=1,Pn.current?.abort(),Pn.current=null,Ln.current+=1,Br.current?.abort(),Br.current=null,Tr.current+=1,tr.current?.abort(),Nt("right-sidebar-recent-commits"),tr.current=null,qr([]),Vn([]),$r(!1),Pt(null),Yr([]),Mr(!1),hr([]),vn([]),Vt(!1),Yt(null),W(!1),xe(null),$e(null),Le(null),nt(null),pr(!1),Zr(""),Qt([]),Qr(!1),Fe(!1),er(null),jn(!1),Ps(null),Jr(null),en(null),Go(!1),pt(Ki,!1),Qa(!1);const b=v?nd()[v]:null,N=b?.previewEntries??[],L=b?.selectedPreviewKey??null,z=L?N.find(q=>q.key===L)??null:null;Uo(b?.selectedRepoRoots??[]),Fs(b?.repoTargetBranches??{}),Ds(b?.repoBaseBranches??{}),Yn(N),yn(b?.previewScrollTops??{}),z&&b?.previewDetailOpen&&(z.diff.hunks?.length??0)>0&&(Yt(z.diff),Jr(z.key),en(b.selectedPreviewFileKey??(z.diff.hunks?.[0]?`${z.diff.hunks[0].filePath}\0${z.diff.hunks[0].hunkHeader}\0${z.diff.hunks[0].hunkIndex}`:null)),Vt(!0)),Ko(b?.includeUncommitted??!0),pi.current=v,Is(!1),Ue(x??null),_r.current.clear(),rs.current.clear(),Qn(null),Jn(null),Lr(null),ot(null),Qo(null),ke(r),De(o),j(null),xi.current=null},[pl,v]);const Fn=i.useCallback(async(r=v??void 0,o={})=>{if(!r)return null;const u=v,x=o.includeNested??!0,b=o.refresh??o.reloadDiff??!1,N=o.cacheOnly??!1,L=o.background??!1;b&&_r.current.clear();const z=Dr.current;if(z&&z.cwd===r&&z.includeNested===x&&z.refresh===b&&z.cacheOnly===N)return Xe("reuse_pending",{cwd:r,includeNested:x,refresh:b,cacheOnly:N}),z.promise;const q=At.current+1;At.current=q;const Ce=`right-sidebar:${vl}:${q}`;vr.current?.abort();const Ye=On(r);Nt(Ye);const Be=new AbortController;vr.current=Be;let se=null;L||hl(Ce),hi(null),Xe("start",{requestId:q,cwd:r,rootPath:v,requestSlotId:Ye,includeNested:x,refresh:b,cacheOnly:N,background:L,existingChanges:we.size,lastLoadedAt:Fr}),!L&&typeof window<"u"&&(se=window.setTimeout(()=>{At.current===q&&ml(Ce,!0)},Lp));const ze=(async()=>{const ve=await wa(r,Be.signal,{includeNested:x,refresh:b,cacheOnly:N,action:b?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:Ye,requestTimeoutMs:b?null:void 0});return zg(ve)?(Xe("cancelled_result_ignored",{requestId:q,activeRequestId:At.current,cwd:r,error:ve.error??ve.context?.error}),null):At.current!==q||!Ne(u)?(Xe("stale_result",{requestId:q,activeRequestId:At.current,cwd:r,expectedRootPath:u,currentRootPath:ae.getState().rootPath,files:ve.files.length,repositories:ve.repositories?.length??0}),null):(zr(ve,{reloadDiff:o.reloadDiff,syncActiveRepo:x,background:L,cacheOnly:N,replaceRepoRoot:o.replaceRepoRoot}),ve)})();Dr.current={cwd:r,includeNested:x,refresh:b,cacheOnly:N,promise:ze};try{const ve=await ze;return At.current===q&&ve&&Ne(u)?gl({cached:ve.cached,stale:ve.stale,cacheAgeMs:ve.cacheAgeMs,nestedDeferred:!x||ve.nestedDeferred,untrackedDeferred:ve.untrackedDeferred}):At.current===q&&Ne(u)&&fi(Ce),ve}catch(ve){return At.current!==q||!Ne(u)||ir(ve)?(Xe("aborted",{requestId:q,activeRequestId:At.current,cwd:r,expectedRootPath:u,currentRootPath:ae.getState().rootPath,message:ve instanceof Error?ve.message:String(ve)}),null):(Xe("error",{requestId:q,cwd:r,includeNested:x,refresh:b,background:L,message:ve instanceof Error?ve.message:String(ve)}),L||(j(null),hi(ve instanceof Error?ve.message:"Failed to load Git changes")),null)}finally{se!==null&&window.clearTimeout(se),vr.current===Be&&(vr.current=null),Dr.current?.promise===ze&&(Dr.current=null),!L&&At.current===q&&Ne(u)&&fi(Ce)}},[zr,hl,we.size,fi,vl,Fr,Ne,gl,v,hi,ml]),ss=i.useCallback(async()=>{v&&await Fn(v,{reloadDiff:!0,includeNested:!0,refresh:!0})},[Fn,v]),bi=i.useCallback(async(r=v??void 0)=>{if(!r)return null;const o=v,u=on.current+1;on.current=u,Ir.current?.abort(),Nt("right-sidebar-git-details");const x=new AbortController;Ir.current=x,Is(!0);try{const b=await $c(r,x.signal,"load_git_details","right-sidebar-git-details");return on.current!==u||!Ne(o)?null:(ke(N=>N.map(L=>L.root===b.root?{...L,available:b.available,context:b,error:b.error}:L)),j(N=>N?.root&&b.root&&N.root!==b.root?N:!N?.available||!b.available?b:{...N,...b}),b)}catch(b){return ir(b)||!Ne(o)||on.current===u&&ot(b instanceof Error?b.message:"Failed to load Git details"),null}finally{Ir.current===x&&(Ir.current=null),on.current===u&&Ne(o)&&Is(!1)}},[Ne,v]);i.useEffect(()=>{if(!t){At.current+=1,on.current+=1,Vs.current+=1,vr.current?.abort(),Nt(On(Dr.current?.cwd??v??void 0)),Dr.current=null,vr.current=null,Ir.current?.abort(),Nt("right-sidebar-git-details"),Ir.current=null;for(const r of wr.current.values())r.abort();for(const r of wr.current.keys())Nt(`right-sidebar-git-untracked:${r}`);wr.current.clear(),Ot.current.clear(),Ln.current+=1,Br.current?.abort(),Br.current=null,Tr.current+=1,tr.current?.abort(),Nt("right-sidebar-recent-commits"),tr.current=null,Is(!1),W(!1),xe(null),$e(null),Le(null),nt(null),pr(!1),Zr(""),Qt([]),Qr(!1),Fe(!1),er(null),jn(!1),S(""),de(!1),wt(null),ri(!1),ee&&Xo(!1)}},[ee,t,de]),i.useEffect(()=>{if(!ne)return;const r=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(r)},[ne]),i.useEffect(()=>{ee||xr(!1)},[ee]);const as=i.useCallback(r=>{ei(r);const o=Zs.current;o&&(o.update(),o.slideTo(r,0),window.requestAnimationFrame(()=>{o.update(),o.slideTo(r,0)}))},[]);i.useEffect(()=>{if(ee)if(xr(m),m&&Ge){br(1);const r=yr.current;r&&(r.update(),r.activeIndex!==1&&(ns.current=1,r.slideTo(1,0)))}else{br(0);const r=yr.current;r&&r.activeIndex!==0&&(ns.current=0,r.slideTo(0,0)),wt(null)}},[ee,m,v,Ge]),i.useEffect(()=>{if(p!==void 0&&!m){br(0);const r=yr.current;r&&r.activeIndex!==0&&(ns.current=0,r.slideTo(0,0)),xr(!1),wt(null)}},[p,m]),i.useEffect(()=>{w!==void 0&&U(null)},[w]),i.useEffect(()=>{!ee&&m&&f?.()},[ee,f,m]),i.useEffect(()=>{ci(r=>So(r,n))},[n]);const ef=i.useCallback(r=>{ee||(r.preventDefault(),Xs.current={startX:r.clientX,startWidth:li,pointerId:r.pointerId},r.currentTarget.setPointerCapture(r.pointerId))},[li,ee]),tf=i.useCallback(r=>{const o=Xs.current;if(!o||o.pointerId!==r.pointerId)return;const u=So(o.startWidth+r.clientX-o.startX,n);ci(u),vs(xs,u,Pp)},[n]),kl=i.useCallback(r=>{const o=Xs.current;if(!(!o||o.pointerId!==r.pointerId)){Xs.current=null,hs(xs);try{r.currentTarget.releasePointerCapture(r.pointerId)}catch{}}},[]),Js=!!(v&&Fr!==null&&xd(he)),kr=Js?"files":di,We=kr==="git",Dn=kr==="files",lt=kr==="diff";i.useEffect(()=>{if(!ee){_s(!0);return}if(!t){const o=window.setTimeout(()=>{_s(!1)},Dp);return()=>window.clearTimeout(o)}_s(!1);const r=window.setTimeout(()=>{_s(!0)},Fp);return()=>window.clearTimeout(r)},[ee,t]),i.useEffect(()=>{if(!ee||!lt)return;const r=Zs.current;if(!r)return;const o=window.requestAnimationFrame(()=>{r.update()});return()=>window.cancelAnimationFrame(o)},[lt,ee]),i.useEffect(()=>{if(!Js||!v||Ct)return;const r=window.setTimeout(()=>{Fn(v,{includeNested:!0,background:!0})},3e3);return()=>window.clearTimeout(r)},[Js,v,Ct,Fn]),i.useEffect(()=>{if(!(t&&(We||lt))||!v||Ct||!qs||xi.current===v)return;xi.current=v;const o=We&&!ee?0:Vi,u=window.setTimeout(()=>{Fn(v,{includeNested:!0,background:!0})},o);return()=>{window.clearTimeout(u)}},[lt,Ct,We,ee,t,Fn,qs,v]),i.useEffect(()=>{!t||!We||(!ee||ti)&&ri(!0)},[We,ee,t,ti]),i.useEffect(()=>{if(!t||We)return;const r=window.setTimeout(()=>{ri(!0)},Vi);return()=>window.clearTimeout(r)},[We,t]),i.useEffect(()=>{lt&&Xo(!0)},[lt]);const Sl=i.useCallback(r=>{pe&&Tg(pe,r.currentTarget.scrollTop)},[pe]);i.useEffect(()=>()=>{vr.current?.abort(),hs(Lo),hs(Fo),hs(xs),hs(qi)},[]),i.useEffect(()=>{if(!pe||!qs)return;const r=Tu()[pe]?.top;if(typeof r!="number")return;let o=window.requestAnimationFrame(()=>{Mn.current&&(Mn.current.scrollTop=r),o=window.requestAnimationFrame(()=>{Mn.current&&(Mn.current.scrollTop=r)})});return()=>window.cancelAnimationFrame(o)},[pe,qs]),i.useEffect(()=>{if(!t)return;const r=new AbortController;return uh(r.signal).then(o=>nl(!!o.available)).catch(()=>nl(!1)),()=>r.abort()},[t]);const is=i.useCallback(r=>{if(re(null),Ze(r),wt(null),ee){xr(!0),br(1),yr.current?.slideTo(1),g?.();return}},[ee,g,Ze]),jl=i.useCallback((r,o)=>{if(re(null),Ze(r),Pe(o),ee){xr(!0),br(1),yr.current?.slideTo(1),g?.();return}},[ee,g,Ze]),os=i.useCallback(async(r,o)=>{const u=o||An||v;if(!(!u||r.length===0)){Hs(!0);try{await zi(u,r),Gs(u,!1)}catch(x){ot(x instanceof Error?x.message:a("rightSidebar.uploadFailed")),window.setTimeout(()=>ot(null),4e3)}finally{Hs(!1)}}},[An,v,Gs,a]),Rl=i.useCallback(async r=>{try{await fh(r)}catch(o){ot(o instanceof Error?o.message:a("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>ot(null),4e3)}},[a]),ea=i.useCallback(r=>{r.preventDefault(),r.stopPropagation(),r.dataTransfer.types.includes("Files")&&oi(!0)},[]),Nl=i.useCallback(r=>{r.preventDefault(),r.stopPropagation(),oi(!1)},[]),Cl=i.useCallback(r=>{r.preventDefault(),r.stopPropagation(),oi(!1);const o=r.dataTransfer.files;o.length>0&&os(Array.from(o))},[os]),Al=i.useCallback(r=>{Se(r),window.setTimeout(()=>Se(o=>o===r?null:o),1400)},[]),Sr=i.useCallback(r=>{at(r),window.setTimeout(()=>at(o=>o===r?null:o),1400)},[]);i.useEffect(()=>{pt(Vc,Ke)},[Ke]),i.useEffect(()=>{pt(Yc,ut)},[ut]),i.useEffect(()=>{pt(Xc,Ut)},[Ut]),i.useEffect(()=>{vs(qi,vt,Ap)},[vt]),i.useEffect(()=>(ol().catch(()=>{}),Tc(r=>{r.type==="pinned-explorer-roots"&&ll(r.pinnedExplorerRoots)})),[ol,ll]);const $l=i.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),ta=i.useRef(null),cn=i.useRef(null),[El,vi]=i.useState(!1);i.useEffect(()=>{if(!t)return;vi(!1);let r=!1;hh().then(u=>{r||(ta.current=u.text,It(x=>u.text&&u.text!==x?u.text:x),vi(!0))}).catch(()=>{r||vi(!0)});const o=Tc(u=>{u.type==="context-draft"&&u.origin!==$l.current&&(ta.current=u.text,It(u.text))});return()=>{r=!0,o(),cn.current!==null&&(window.clearTimeout(cn.current),cn.current=null)}},[t]),i.useEffect(()=>{if(!El||ta.current===vt)return;cn.current!==null&&window.clearTimeout(cn.current);const r=vt;cn.current=window.setTimeout(()=>{cn.current=null,mh(r,$l.current).then(()=>{ta.current=r}).catch(()=>{})},500)},[vt,El]);const _n=i.useCallback((r,o,u)=>{r&&(Ke?(It(x=>Km(x,r)+(u??"")),window.matchMedia("(pointer: coarse)").matches||(or(!1),lr(x=>x+1))):window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:u?r+u:r,focus:!0}})),Al(o))},[Ke,Al]),ra=i.useCallback(r=>{const o=ka(r,v);return Lh(o,v)},[v]),wi=jd(Sr),Hr=i.useCallback((r,o)=>{const u=ka(r,v);_n(Fh(u,v),o??`path:${u}`)},[v,_n]),rf=i.useCallback(async r=>{Hs(!0);try{await Dh(r,zi,o=>{Hr(o,`path:${o}`)}),ee&&!Ke&&s()}catch(o){ot(o instanceof Error?o.message:a("rightSidebar.uploadFailed")),window.setTimeout(()=>ot(null),4e3)}finally{Hs(!1)}},[Ke,Hr,ee,s,a]),jr=i.useCallback((r,o)=>{if(!r)return;const u=r.includes(`
61
+ `)?`
62
+ `:void 0;_n(r.endsWith(`
63
+ `)||r.endsWith(" ")?r:`${r} `,o,u)},[_n]),Ml=i.useRef(jr);Ml.current=jr;const yi=i.useRef(!0);i.useEffect(()=>(yi.current=!0,()=>{yi.current=!1}),[]);const ki=i.useRef(new Set),Tl=i.useCallback((r,o,u)=>{if(ki.current.has(o))return;const x=Ic.getState().activeSessionId;ki.current.add(o),jm(r,o,u,{insert:jr,upload:async(b,N)=>(await zi("/tmp",[b],N)).files[0]?.path,isCurrent:()=>yi.current&&Ml.current===jr&&x===Ic.getState().activeSessionId}).finally(()=>ki.current.delete(o))},[jr]),Or=i.useCallback((r,o,u)=>{o&&_n(o.endsWith(" ")?o:`${o} `,u??`context:${r}`,`
64
+ `)},[_n]),Pl=i.useCallback(r=>{const o=qm(vt,r);if(!o)return;const u=r&&vt.trim().includes(`
65
+ `),x=`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`;let b=!1;const N=q=>{b||(b=!0,window.removeEventListener("termdock-insert-reference-ack",L),window.clearTimeout(z),q?(zt(!1),It(""),Ut&&or(!0)):(zt(!0),or(!1)))},L=q=>{const Ce=q.detail;Ce?.nonce===x&&N(Ce.ok===!0)},z=window.setTimeout(()=>N(!1),1500);window.addEventListener("termdock-insert-reference-ack",L),zt(!1),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:o,focus:!0,paste:u,nonce:x}}))},[Ut,vt]),Ve=i.useMemo(()=>v?dt(v):a("rightSidebar.workspace"),[v,a]),nf=i.useMemo(()=>dt(pe)||Ve,[pe,Ve]),na=i.useMemo(()=>ro(pe),[pe]),sa=i.useMemo(()=>v?il[v]??[]:[],[il,v]),dn=i.useMemo(()=>new Set(sa.map(r=>r.path)),[sa]),ls=!!(pe&&dn.has(pe)),Si=!!(v&&pe&&pe!==v),sf=!!(v&&An&&An!==v),$t=pe?`path:${pe}`:null,Ll="context:change-audit",af=i.useCallback(()=>{na&&Lt(na)},[na,Lt]),Fl=i.useCallback(()=>{cl()},[cl]),of=i.useCallback(()=>{pe&&(Gs(pe,!0),fl())},[fl,pe,Gs]),lf=i.useCallback(()=>{!pe||!Si||(ls?an(pe):$n(pe,"directory"))},[Si,pe,ls,$n,an]),Dl=i.useCallback(r=>{Lt(r),S("")},[Lt]),_l=i.useCallback(r=>{pe&&(te(Np(pe,r)),de(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[pe,de]),Il=i.useCallback(r=>{!v||r===v||(dn.has(r)?an(r):$n(r,"directory"))},[$n,dn,v,an]),Bl=i.useCallback(r=>{!v||!r||(dn.has(r)?an(r):$n(r,"file"))},[$n,dn,v,an]),zl=ae(r=>r.expandedPaths),ji=i.useMemo(()=>{const r=new Set;if(Dn&&pe){r.add(pe);const o=`${pe.replace(/\/+$/,"")}/`;for(const u of zl)u.startsWith(o)&&r.add(u)}if(Dn&&v&&Ge){const o=Ge.startsWith("/")?Ge:`${v}/${Ge}`,u=ro(o);u&&r.add(u)}return Im(r).join(`
66
+ `)},[zl,Dn,pe,v,Ge]),un=i.useRef(new Map);i.useEffect(()=>{const r=ji?ji.split(`
67
+ `):[];if(!t||r.length===0){Cn(null);return}const o=new AbortController;let u=!1,x=0,b=0;Cn(null);const N=async()=>{let L=0;for(;!u&&!o.signal.aborted;){let z=null;try{Cn(null),await Sh(r,Ce=>{const{applicableEvents:Ye,unavailableReason:Be}=zm(Ce);Ye.length>0&&dl(Ye);for(const se of Ye){if(se.type!=="rescan-required")continue;const ze=ae.getState();if(!ze.directoryCache.has(se.path))continue;un.current.get(se.path)?.abort();const Et=new AbortController;un.current.set(se.path,Et);const Rc=`file-watch-rescan:${se.path}`;Nt(Rc),jh(se.path,Et.signal,ze.showHiddenFiles,"watch_rescan",Rc,ze.fileSortModes[se.path]??"name").then(ds=>{un.current.get(se.path)===Et&&ul(se.path,ds.entries)}).catch(ds=>{ir(ds)||Cn(ds instanceof Error?ds.message:"File refresh unavailable")}).finally(()=>{un.current.get(se.path)===Et&&un.current.delete(se.path)})}Be&&Cn(Be)},o.signal),z=new Error("File watch stream ended")}catch(Ce){z=Ce}if(u||o.signal.aborted||ir(z))return;Cn(z instanceof Error?z.message:"File watching unavailable");const q=Zc[Math.min(L,Zc.length-1)];L+=1,await new Promise(Ce=>{b=window.setTimeout(Ce,q)})}};return x=window.setTimeout(()=>{u||N()},Vi),()=>{u=!0,window.clearTimeout(x),window.clearTimeout(b),o.abort();for(const L of un.current.values())L.abort();un.current.clear()}},[dl,t,ul,ji]),i.useEffect(()=>{if(!v||pi.current!==v)return;if(gi.current===v){gi.current=null;return}const r=nd();vs(qd,{...r,[v]:{selectedRepoRoots:Ls,repoTargetBranches:gr,repoBaseBranches:St,previewEntries:Xr,selectedPreviewKey:Ae&&mr?qe:null,selectedPreviewFileKey:Ae&&mr?Ja:null,previewDetailOpen:!!(Ae&&mr),previewScrollTops:wn,previewMobileSlideIndex:1,includeUncommitted:Pr,updatedAt:Date.now()}},Cp)},[mr,Pr,Ae,Xr,wn,St,gr,Ls,v,Ja,qe]);const tt=i.useMemo(()=>gd(we.values()),[we]),ft=i.useMemo(()=>{const r=new Map;for(const o of Q)r.set(o.root,o);return r},[Q]),jt=i.useMemo(()=>le?be.find(r=>r.root===le)??null:null,[le,be]),sr=i.useMemo(()=>Ge?Array.from(we.values()).find(r=>r.path===Ge||r.absolutePath===Ge)??null:null,[we,Ge]),ht=i.useMemo(()=>{const r=new Map;for(const o of Q)o.available&&o.context?.available&&r.set(o.root,o);return r.size===0&&he?.available&&he.root&&r.set(he.root,{id:he.root,root:he.root,relativeRoot:".",name:Ve,depth:0,nested:!1,available:!0,files:Array.from(we.values()).filter(o=>mt(o,v)===he.root),context:he}),Array.from(r.values()).sort((o,u)=>o.root===v?-1:u.root===v?1:(o.relativeRoot||o.name).localeCompare(u.relativeRoot||u.name)).map(o=>{const u=o.relativeRoot==="."?Ve:o.relativeRoot||o.name||dt(o.root),x=pd(o.files),b=o.files.length;return{value:o.root,label:u,meta:[o.context?.branch,b>0?a("rightSidebar.repoChangedCount",{count:b}):null,x>0?a("rightSidebar.repoStagedCount",{count:x}):null].filter(Boolean).join(" · ")}})},[we,he,Q,Ve,v,a]),ye=i.useMemo(()=>le&&ht.some(r=>r.value===le)?le:sr?.repoRoot&&ht.some(r=>r.value===sr.repoRoot)?sr.repoRoot:ht.length===1||ht.length>1?ht[0].value:null,[le,ht,sr?.repoRoot]),Hl=ye?ft.get(ye)??null:null,ce=Hl?.context?.available?Hl.context:ye===he?.root?he:null,Oe=ht.length>0&&!ye,Ol=i.useMemo(()=>Oe?[]:ye?Array.from(we.values()).filter(r=>mt(r,v)===ye):Array.from(we.values()),[ye,we,Oe,v]),fn=i.useMemo(()=>gd(Ol),[Ol]),Ri=!!(ce?.available&&ce.root&&ye&&ce.root===ye),cf=ye?ht.find(r=>r.value===ye)?.label??dt(ye):a("rightSidebar.gitRepositoryPlaceholder"),df=Ri?ce?.branch??"HEAD":Oe?a("rightSidebar.selectRepositoryForGitActions"):tn?a("rightSidebar.gitActionRunning"):"HEAD",In=!!(ce?.available&&ce.root===ye&&ce.status);i.useEffect(()=>{Wo.current={count:Zt.length,loading:Sn,loadingMore:J,hasMore:Xa}},[Zt.length,Xa,Sn,J]),i.useEffect(()=>{Tr.current+=1,tr.current?.abort(),Nt("right-sidebar-recent-commits"),tr.current=null,Zr(""),Qt([]),Qr(!1),Fe(!1),er(null),jn(!1)},[ye]);const cs=i.useCallback(async(r={})=>{if(!v||!ye||Oe)return;const o=r.reset??!1,u=Wo.current,x=o?0:u.count;if(!o&&(u.loading||u.loadingMore||!u.hasMore))return;const b=Tr.current+1;Tr.current=b,tr.current?.abort(),Nt("right-sidebar-recent-commits");const N=new AbortController;tr.current=N,o?Qr(!0):Fe(!0),er(null);try{const L=await ph({cwd:v,repoRoot:ye,limit:_p,skip:x,query:Xn.trim(),requestSlotId:"right-sidebar-recent-commits"},N.signal);if(Tr.current!==b)return;if(!L.available){er(L.error??"Recent commits are unavailable"),o&&Qt([]),jn(!1);return}Qt(z=>o?L.commits:[...z,...L.commits]),jn(L.hasMore)}catch(L){if(Tr.current!==b||ir(L))return;er(L instanceof Error?L.message:"Failed to load recent commits"),o&&Qt([]),jn(!1)}finally{tr.current===N&&(tr.current=null),Tr.current===b&&(Qr(!1),Fe(!1))}},[ye,Xn,Oe,v]);i.useEffect(()=>{Xt&&cs({reset:!0})},[Xn,cs,Xt]);const uf=i.useCallback(r=>{const o=r.currentTarget;o.scrollTop+o.clientHeight<o.scrollHeight-48||cs({reset:!1})},[cs]);i.useEffect(()=>{!ye||!he?.available||!We||!rr||In||tn||Oe||bi(ye)},[ye,he?.available,In,tn,We,rr,bi,Oe]),i.useEffect(()=>{!t||!lt&&!We||!v||nr()},[lt,We,t,nr,v]),i.useEffect(()=>{!t||!We||!rr||!Zn||!v||Qs(null)},[Zn,We,rr,t,Qs,v]);const ff=i.useMemo(()=>{if(!le)return 0;const r=be.findIndex(o=>o.root===le);return r>=0?r+1:0},[le,be]),Wl=i.useCallback(r=>{if(!r)return null;const o=Array.from(we.values()).filter(u=>mt(u,v)===r).sort((u,x)=>u.path.localeCompare(x.path))[0];return o?ct(o):null},[we,v]),hn=be.length>1,aa=i.useMemo(()=>[{root:null,label:a("rightSidebar.allRepositories"),count:we.size,branch:null},...be.map(r=>({root:r.root,label:r.label,count:r.count,branch:r.branch??null}))],[we.size,be,a]),Gl=aa[ff]??aa[0],ia=!!le;i.useEffect(()=>{le&&!ht.some(r=>r.value===le)&&(Ue(null),Yi(v,null)),Yr(r=>r.filter(o=>be.some(u=>u.root===o)))},[le,ht,be,v]);const hf=i.useMemo(()=>{const r=new Set;ce?.branch&&r.add(ce.branch);for(const o of ce?.branches??[])r.add(o);return Array.from(r).map(o=>({value:o,label:o,meta:o===ce?.branch?a("rightSidebar.pushCurrentBranchBadge"):void 0}))},[ce?.branch,ce?.branches,a]),Ul=i.useMemo(()=>{const r=new Set;ce?.upstreamRemote&&r.add(ce.upstreamRemote);for(const o of ce?.remotes??[])r.add(o);return Array.from(r).map(o=>({value:o,label:o,meta:o===ce?.upstreamRemote?a("rightSidebar.pushUpstreamBadge"):void 0}))},[ce?.remotes,ce?.upstreamRemote,a]),Kl=Ul.length>1,mf=i.useMemo(()=>{const r=[],o=new Set,u=(b,N)=>{!b||o.has(b)||(o.add(b),r.push({value:b,label:b,meta:N}))};u(ce?.upstreamBranch,ce?.upstreamBranch?a("rightSidebar.pushUpstreamBadge"):void 0),u(ce?.branch,ce?.branch?a("rightSidebar.pushCurrentBranchBadge"):void 0);for(const b of ce?.branches??[])u(b,b===ce?.branch?a("rightSidebar.pushCurrentBranchBadge"):"local");const x=ce?.upstreamRemote;for(const b of ce?.remoteBranches??[]){const N=b.indexOf("/"),L=N>=0?b.slice(0,N):null,z=N>=0?b.slice(N+1):b;(!x||L===x)&&u(z,"remote")}return r},[ce?.branch,ce?.branches,ce?.remoteBranches,ce?.upstreamBranch,ce?.upstreamRemote,a]),Ft=i.useMemo(()=>ht.map(r=>{const o=ft.get(r.value);return{root:r.value,label:r.label,branch:o?.context?.branch??null}}),[ht,ft]);i.useEffect(()=>{Ft.length!==0&&(Fs(r=>{let o=!1;const u={...r},x=new Set(Ft.map(b=>b.root));for(const b of Object.keys(u))x.has(b)||(delete u[b],o=!0);for(const b of Ft)!u[b.root]&&b.branch&&(u[b.root]=b.branch,o=!0);return o?u:r}),Ds(r=>{let o=!1;const u={...r},x=new Set(Ft.map(b=>b.root));for(const b of Object.keys(u))x.has(b)||(delete u[b],o=!0);for(const b of Ft){const N=ft.get(b.root)?.context;if(u[b.root]&&ru(u[b.root],N?.branch)&&(delete u[b.root],o=!0),u[b.root])continue;const L=id(N);L&&(u[b.root]=L,o=!0)}return o?u:r}))},[Ft,ft]);const oa=i.useMemo(()=>{const r=new Set(Ft.map(o=>o.root));return Ls.filter(o=>r.has(o))},[Ls,Ft]),la=oa.length===0,ar=i.useMemo(()=>la?Ft:Ft.filter(r=>oa.includes(r.root)),[Ft,oa,la]),Gt=i.useMemo(()=>ar.filter(r=>!!St[r.root]?.trim()),[St,ar]),ql=i.useMemo(()=>ar.filter(r=>!St[r.root]?.trim()),[St,ar]),Vl=i.useCallback(async r=>{if(!r||mi.current.has(r))return;const o=ft.get(r)?.context;if((o?.branches?.length??0)>0||(o?.remoteBranches?.length??0)>0||o?.upstream)return;const u=v;mi.current.add(r),Vo(x=>new Set(x).add(r));try{const x=await $c(r,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${r}`);if(!x.available||!Ne(u))return;ke(b=>b.map(N=>N.root===r?{...N,available:!0,context:{...N.context,...x},error:void 0}:N)),Fs(b=>b[r]||!x.branch?b:{...b,[r]:x.branch}),Ds(b=>{if(b[r])return b;const N=id(x);return N?{...b,[r]:N}:b})}catch(x){ir(x)||console.warn("[RightSidebar] Failed to load branch audit repo details",r,x)}finally{mi.current.delete(r),Vo(x=>{const b=new Set(x);return b.delete(r),b})}},[ft,Ne,v]);i.useEffect(()=>{if(Za)for(const r of ar)Vl(r.root)},[Za,ar,Vl]),i.useEffect(()=>{!Ri||!ce||(si(ce.branch||(ce.branches?.[0]??"")),ai(ce.upstreamRemote||(ce.remotes?.includes("origin")?"origin":ce.remotes?.[0]??"")),ii(ce.upstreamBranch||ce.branch||(ce.branches?.[0]??"")))},[ce,Ri]);const Yl=i.useMemo(()=>{if(Oe)return{text:a("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!In||tn)return{text:a("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!ce?.upstream)return{text:a("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const r=ce.ahead??0,o=ce.behind??0;return r>0&&o>0?{text:a("rightSidebar.pushDivergedCount",{ahead:r,behind:o}),className:"bg-destructive/10 text-destructive"}:r>0?{text:a("rightSidebar.pushAheadCount",{count:r}),className:"bg-accent/10 text-accent"}:o>0?{text:a("rightSidebar.pushBehindCount",{count:o}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:a("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[ce?.ahead,ce?.behind,ce?.upstream,In,tn,Oe,a]),pf=i.useCallback(r=>{if(r&&!ee){const o=r.currentTarget.getBoundingClientRect();U({x:Math.min(o.left,window.innerWidth-352),y:Math.min(o.bottom+6,window.innerHeight-64)})}else U(null);C?.()},[ee,C]),Ni=i.useCallback(()=>{U(null),P?.()},[P]);function Xl(){if(!hn)return null;const r=Gl?.label??a("rightSidebar.allRepositories"),o=Gl?.count??we.size,u=dt(r)||r;return e.jsxs("button",{type:"button",onClick:pf,className:`inline-flex h-7 min-w-0 max-w-[13rem] shrink-0 items-center gap-1.5 rounded-md border px-2 text-[11px] font-medium transition active:scale-95 ${y?"border-primary/25 bg-primary/10 text-primary":"border-border/10 bg-surface-2 text-muted-foreground hover:border-border/25 hover:bg-surface-elevated hover:text-foreground"}`,"aria-haspopup":"listbox","aria-expanded":y,title:r,children:[e.jsx(Rr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:u}),e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${o>0?"bg-accent/10 text-accent":"bg-surface text-muted-foreground"}`,children:o}),e.jsx(Ss,{size:12,className:"shrink-0"})]})}function gf(){if(!y||!hn||typeof document>"u")return null;const r=typeof window>"u"?1024:window.innerWidth,o=typeof window>"u"?768:window.innerHeight,u=Math.max(12,Math.min(Me?.x??r-368,r-352)),x=Math.max(12,Math.min(Me?.y??80,o-420)),b=ee?void 0:{left:u,top:x},N=e.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${ee?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:Ni,children:e.jsxs("div",{className:ee?"fixed inset-x-0 bottom-0 z-drawer-panel max-h-[72vh] overflow-hidden rounded-t-2xl border-t border-border/20 bg-surface-elevated shadow-2xl":"fixed z-drawer-panel w-[21rem] max-w-[calc(100vw-1.5rem)] max-h-[min(26rem,calc(100vh-1.5rem))] overflow-hidden rounded-lg border border-border/20 bg-surface-elevated shadow-xl ring-1 ring-black/5",style:b,onClick:L=>L.stopPropagation(),children:[e.jsxs("div",{className:ee?"flex items-center justify-between border-b border-border/15 px-4 py-3":"flex items-center justify-between border-b border-border/12 px-3 py-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:ee?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:a("rightSidebar.repositories")}),!ee&&e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:aa.length}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${we.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:we.size})]})]}),e.jsx("button",{type:"button",onClick:Ni,className:ee?"rounded-full bg-surface-2 p-1.5 text-muted-foreground hover:bg-surface hover:text-foreground":"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground","aria-label":a("rightSidebar.close"),children:e.jsx(_t,{size:ee?16:14})})]}),e.jsx("div",{className:ee?"max-h-[calc(72vh-3.25rem)] overflow-y-auto overscroll-contain px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+5.5rem)]":"max-h-[calc(min(26rem,100vh-1.5rem)-3.5rem)] overflow-y-auto overscroll-contain p-1.5",children:aa.map(L=>{const z=(L.root??null)===le,q=dt(L.label)||L.label;return e.jsxs("button",{type:"button",onClick:()=>{gc(L.root),Ni()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${ee?"px-3 py-2":"px-2 py-1.5"} ${z?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:L.label,role:"option","aria-selected":z,children:[e.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${z?"bg-primary":"bg-transparent group-hover:bg-border/40"}`}),e.jsx("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${z?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:e.jsx(Rr,{size:13})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:`${ee?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:q}),e.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:L.root===null?a("rightSidebar.allRepositories"):L.label})]}),L.branch&&e.jsx("span",{className:"hidden max-w-[5.5rem] shrink min-w-0 truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground sm:inline",children:L.branch}),e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${L.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:L.count})]},L.root??"all")})})]})});return Hd(N,ee,document.body)}function xf(){return gf()}function Zl(r){const o=mt(r,v),u=r.absolutePath||(o?`${o}/${r.path}`:r.path),x=Da(u,o??v);return{key:ct(r),path:r.path,absolutePath:u,displayName:x.name,displayDir:x.dir,oldPath:r.oldPath,status:r.status,title:u}}function Ql(r){return r.oldPath?e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:a("rightSidebar.changedFromPath",{path:r.oldPath})}):null}function Jl(r,o){const u=ka(r,v),x=`path:${u}`,b=V===x,N=Re===x,L=b||N;return e.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),Hr(u,x)},...wi(ra(u),x),className:`inline-flex h-6 shrink-0 items-center justify-center overflow-hidden rounded-full text-[11px] font-semibold opacity-100 transition-[max-width,padding,opacity,transform,background-color,color] active:scale-95 ${L?"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"} ${L?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:o,children:e.jsx("span",{className:"whitespace-nowrap",children:a(N?"rightSidebar.copied":b?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function ec(r){const o=mt(r,v),u=r.absolutePath||(o?`${o}/${r.path}`:r.path),x=Wf(r),b=ao(r);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(Hg,{actions:x,running:Te,completed:Rn?.path===b?Rn:null}),Jl(u,a("rightSidebar.insertThisFile"))]})}function tc(r,o){const u=o.root??v;if(!u)return null;const x=ka(r,u);return Jl(x,a("fileTree.insertRefTitle"))}function Ci(){return e.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5","aria-label":a("diffViewer.view"),children:[e.jsx("button",{type:"button",onClick:()=>dc("unified"),"aria-pressed":qt==="unified",title:a("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${qt==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:a("diffViewer.unified")}),e.jsx("button",{type:"button",onClick:()=>dc("split"),"aria-pressed":qt==="split",title:a("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${qt==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:a("diffViewer.split")})]})}function rc(){return da.map(r=>{const o=pd(r.files.map(([,N])=>N)),u=!le&&(da.length>1||r.label!==Ve),x=!!(r.root&&Ht.has(r.root));return{key:r.root??r.label,root:r.root,label:r.label,branch:r.branch,collapsed:x,files:r.files.map(([,N])=>Zl(N)),header:u?e.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${x?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Df(r.root),"aria-expanded":!x,className:"flex min-w-0 flex-1 items-center gap-2 text-left active:scale-[0.99]",children:[e.jsx("span",{className:"shrink-0 text-muted-foreground",children:x?e.jsx(ya,{size:13}):e.jsx(Ss,{size:13})}),e.jsx(Rr,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:r.label}),r.branch&&e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:r.branch})]}),e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:r.files.length}),o>0&&e.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:o})]}),r.root&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),xa("stage-all",r.root,r.label)},disabled:!!Te,className:"rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:a("rightSidebar.stageAll"),children:a("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),xa("stash-all",r.root,r.label)},disabled:!!Te,className:"rounded-full bg-surface-2 px-2 py-0.5 text-[10px] font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:a("rightSidebar.stashAll"),children:a("rightSidebar.stashAll")})]})]}):null}})}function nc(){return we.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:a("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:ua.map(([,r])=>{const o=mt(r,v),u=r.absolutePath||(o?`${o}/${r.path}`:r.path);return{key:ct(r),path:r.path,absolutePath:u,status:r.status,repoRoot:o,displayName:Da(u,o).name,displayDir:Da(u,o).dir,auditRecords:kt}})}function sc(r){const o=Array.from(we.values()).find(b=>ct(b)===r.key),u=o?mt(o,v):null,x=Cm(kt,u,o?.path??r.path);return e.jsx(xo,{changeStatus:r.status,auditStatus:x,renderChangeBadge:b=>e.jsx(ws,{status:b})})}const ca=i.useCallback(r=>{if(ee)return null;const o=Array.from(r.querySelectorAll("[data-diff-stream-item]"));if(o.length===0)return null;const x=r.getBoundingClientRect().top+48;let b=null,N=Number.POSITIVE_INFINITY;for(const z of o){const q=z.getBoundingClientRect();if(q.bottom<x)continue;const Ce=Math.abs(q.top-x);Ce<N&&(b=z,N=Ce)}const L=b?.dataset.diffSelectionPath??b?.dataset.diffStreamItem??null;return L?(Ys.current===L&&ae.getState().selectedFilePath===L||(Ys.current=L,Ze(L)),L):null},[ee,Ze]),bf=!!(!Te&&ye&&!Oe&&(ce?.upstream||rn.trim()&&nn.trim())),vf=!!(!Te&&ye&&!Oe&&(ce?.upstream||rn.trim()&&nn.trim())),wf=!!(!Te&&ye&&!Oe&&es.trim()&&es.trim()!==ce?.branch),Dt=i.useMemo(()=>{const r=fe.trim().toLowerCase(),o=Array.from(we.entries()).filter(([,u])=>!le||mt(u,v)===le).sort(([u],[x])=>u.localeCompare(x));return r?o.filter(([u,x])=>`${u} ${x.path} ${x.status} ${x.repoRelativeRoot??""} ${x.repoName??""}`.toLowerCase().includes(r)):o},[le,we,fe,v]);i.useEffect(()=>{Ta("selected_file_state",{selectedFilePath:Ge,selectedChangedFilePath:sr?.path??null,selectedChangedFileAbsolutePath:sr?.absolutePath??null,selectedChangedFileRepoRoot:sr?.repoRoot??null,rootPath:v,activeGitRepoRoot:le,rightTab:di,effectiveRightTab:kr,diffPaneActive:lt,changedFiles:we.size,filteredChangedFiles:Dt.length,gitBundleLoading:Ct,gitBundleLastLoadedAt:Fr})},[le,we.size,lt,kr,Dt.length,Fr,Ct,di,v,sr?.absolutePath,sr?.path,sr?.repoRoot,Ge]);const da=i.useMemo(()=>{const r=new Map;for(const o of Dt){const[,u]=o,x=mt(u,v),b=Bg(u)||Ve,N=x??b,L=x?ft.get(x):void 0,z=r.get(N)??{root:x,label:b,branch:L?.context?.branch,files:[]};z.files.push(o),r.set(N,z)}return Array.from(r.values()).sort((o,u)=>o.label===Ve?-1:u.label===Ve?1:o.label.localeCompare(u.label))},[Dt,ft,Ve,v]),ua=i.useMemo(()=>{const r=[],o=new Map;for(const u of Dt)o.set(ct(u[1]),u);for(const u of da){if(u.root&&Ht.has(u.root))continue;if(yt!=="tree"){r.push(...u.files);continue}const x=u.files.map(([,b])=>Zl(b));for(const b of Kh(x)){const N=o.get(b.key);N&&r.push(N)}}return r},[Ht,yt,da,Dt]);i.useEffect(()=>{if(!lt||ua.length===0||ee)return;const r=[],o=()=>{const u=document.querySelector(".termdock-diff-stream-scroller");if(u&&ca(u))return;const x=document.querySelector("[data-diff-stream-item]"),b=x?.dataset.diffSelectionPath??x?.dataset.diffStreamItem??null;if(b){Ys.current=b,Ze(b);return}const N=ua[0]?.[1];if(!N)return;const L=ct(N);Ys.current=L,Ze(L)};for(const u of[80,240,600,1200])r.push(window.setTimeout(o,u));return()=>r.forEach(u=>window.clearTimeout(u))},[lt,ee,ua,Ze,ca]);const Ai=i.useMemo(()=>{const r=L=>`'${L.replace(/'/g,"'\\''")}'`,o=Wt.length>0?ln:Q.filter(L=>L.files.length>0),u=o.length>0?o:v?[{root:v,relativeRoot:".",name:Ve}]:[],x=u.length>0?u.map(L=>`- ${L.relativeRoot==="."?".":L.relativeRoot} (${L.root})`).join(`
68
+ `):`- ${v?".":""}`,b=u.length>0?u.map(L=>` td audit-export ${r(L.root)}`).join(`
69
+ `):" td audit-export",N=u.length>0?" td audit ~/.termdock/change-audit/payload-<repo>.json":" td audit ~/.termdock/change-audit/payload.json";return["任务:为目标仓库的 Git diff hunk 生成自包含审计解释,并通过 Termdock CLI 注入。","",`当前工作区:${v??""}`,"目标仓库:",x,"","执行步骤:","1. 仅对“目标仓库”逐个执行 audit-export。嵌套子仓使用括号内 repo 绝对路径作为命令参数。",b,"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 后批量注入:",N,'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(`
70
+ `)},[Wt.length,ln,Q,Ve,v]),yf=i.useCallback((r="generate")=>{if(hn&&Vr.length===0&&!le){Mr(!0);return}const o=r==="generate"?Ai:[r==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",Ai].join(`
71
+ `);Xe("insert_change_audit_prompt",{rootPath:v,activeGitRepoRoots:Wt,mode:r,hasAuditListCommand:o.includes("td audit-list"),promptLength:o.length}),Or(a("rightSidebar.insertChangeAuditPrompt"),o,`${Ll}:${r}`),nr(),c||s()},[le,Ai,Vr.length,Wt,Or,nr,s,c,v,hn,a]),fa=i.useCallback(async r=>{try{await Ec({ids:[r]}),qr(o=>o.filter(u=>u.id!==r))}catch{nr()}},[nr]),kf=i.useCallback(async()=>{if(kt.length===0)return;const r=kt.map(o=>o.id);try{await Ec({ids:r}),qr(o=>o.filter(u=>!r.includes(u.id))),Pt(null)}catch(o){const u=o instanceof Error?o.message:"Failed to clear change audit explanations";Pt(a("rightSidebar.changeAuditClearFailed",{message:u})),nr()}},[kt,nr,a]),Sf=i.useCallback(async r=>{if(r.records.length===0)return;const o=r.records.map(u=>u.id);try{await gh({ids:o}),hr(u=>u.filter(x=>!o.includes(x.id))),qe===r.key&&(Jr(null),Vt(!1))}catch(u){ot(a("rightSidebar.branchAuditClearFailed",{message:u instanceof Error?u.message:"Failed to clear branch explanation"})),Qs(null)}},[Qs,qe,a]),jf=i.useCallback(r=>{Yr(o=>r===null?(Mr(!1),[]):o.includes(r)?o.filter(u=>u!==r):[...o,r])},[]),Rf=i.useCallback(r=>{Uo(o=>r===null?(Qa(!1),[]):o.includes(r)?o.filter(u=>u!==r):[...o,r])},[]),$i=i.useMemo(()=>{if(!rr)return[];const r=o=>{const u=o.diff??"";let x=0,b=0;for(const N of u.split(`
72
+ `))N.startsWith("+++")||N.startsWith("---")||(N.startsWith("+")&&(x+=1),N.startsWith("-")&&(b+=1));return{filePath:o.filePath,oldPath:o.oldPath,newPath:o.newPath,hunkHeader:o.hunkHeader,hunkIndex:o.hunkIndex??0,fingerprint:o.fingerprint,additions:x,deletions:b,diff:u}};return Ae?(Ae.hunks??[]).map(o=>{const u=fr.find(x=>x.repoRoot===Ae.repoRoot&&x.baseRef===Ae.baseRef&&(x.branchName??null)===(Ae.currentBranch??null)&&x.filePath===o.filePath&&x.hunkHeader===o.hunkHeader&&(x.hunkIndex??0)===o.hunkIndex&&x.fingerprint===o.fingerprint)??null;return{key:`${o.filePath}\0${o.hunkHeader}\0${o.hunkIndex}`,hunk:o,current:u,stale:null}}):qe?fr.filter(o=>sd(o)===qe).map(o=>{const u=r(o);return{key:`${o.filePath}\0${o.hunkHeader}\0${o.hunkIndex??0}`,hunk:u,current:o,stale:null}}):[]},[Ae,fr,rr,qe]),Ei=fr.length>0,Bn=i.useMemo(()=>{if(!rr)return[];const r=new Map;for(const o of fr){const u=o.repoRoot,x=ft.get(u),b=x?.relativeRoot==="."?Ve:x?.relativeRoot||x?.name||dt(u),N=sd(o),L=r.get(N)??{key:N,repoRoot:u,repoLabel:b,baseRef:o.baseRef,branchName:o.branchName??null,headRef:o.headRef??null,diffFingerprint:o.diffFingerprint??null,records:[],latestInjectedAt:0};L.records.push(o),L.latestInjectedAt=Math.max(L.latestInjectedAt,o.injectedAt??0),r.set(N,L)}return Array.from(r.values()).sort((o,u)=>u.latestInjectedAt-o.latestInjectedAt)},[fr,ft,rr,Ve]),Mi=i.useMemo(()=>qe?Bn.find(r=>r.key===qe)??null:null,[Bn,qe]),ha=Ae?{repoRoot:Ae.repoRoot??"",repoLabel:Ae.repoRoot?ft.get(Ae.repoRoot)?.relativeRoot==="."?Ve:ft.get(Ae.repoRoot)?.relativeRoot||ft.get(Ae.repoRoot)?.name||dt(Ae.repoRoot):Ve,baseRef:Ae.baseRef??Ae.baseBranch??"",branchName:Ae.currentBranch??null,headRef:Ae.headRef??null,diffFingerprint:Ae.diffFingerprint??null}:Mi,Nf=i.useMemo(()=>(Ie?.hunks??[]).map(r=>({key:`${r.filePath}\0${r.hunkHeader}\0${r.hunkIndex}`,hunk:r,current:null,stale:null})),[Ie?.hunks]),Cf=i.useMemo(()=>{if(Ae)return[];const r=Mi;return r?bn.filter(o=>o.repoRoot===r.repoRoot&&o.baseRef===r.baseRef&&(o.branchName??null)===r.branchName&&(!r.diffFingerprint||o.diffFingerprint===r.diffFingerprint)):[]},[Ae,bn,Mi]),Af=i.useCallback(r=>{const o=$i.find(u=>u.hunk.filePath===r.filePath||(r.repoRoot?`${r.repoRoot}/${u.hunk.filePath}`===r.filePath:!1));o&&(en(o.key),window.setTimeout(()=>mn(r),90),window.setTimeout(()=>mn(r),320),window.setTimeout(()=>mn(r),760))},[$i]),Ti=i.useMemo(()=>{const r=b=>`'${b.replace(/'/g,"'\\''")}'`,o=Gt,u=o.length>0?o.map(b=>`- ${b.label} (${b.root}),目标分支:${gr[b.root]||b.branch||"(current branch)"},基线分支:${St[b.root]||"(not set)"}`).join(`
73
+ `):`- ${v?".":""}`,x=o.length>0?o.map(b=>{const N=gr[b.root]||b.branch||"",L=St[b.root]||"",z=b.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[N?` git -C ${r(b.root)} switch ${r(N)}`:` # ${b.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${r(L)} ${r(b.root)} > ~/.termdock/branch-audit/branch-audit-export-${z}.json`].join(`
74
+ `)}).join(`
75
+ `):" td branch-audit-export <base-branch>";return["解释目标仓库当前分支相对于基线分支的改动,并把解释写回 Termdock。","",`当前工作区:${v??""}`,`包含本地未提交更改:${Pr?"是":"否"}`,"目标仓库:",u,"","操作指令:",Pr?"1. 只针对上面列出的目标仓库导出分支 hunk;如果指定了目标分支,先在对应仓库切到目标分支。导出内容需要包含目标分支相对基线分支的提交改动,以及当前工作区 staged/unstaged/untracked 改动。嵌套子仓或软链接子仓必须使用括号里的仓库绝对路径,不要改用当前工作区根目录。示例:":"1. 只针对上面列出的目标仓库导出分支 hunk;如果指定了目标分支,先在对应仓库切到目标分支。不要包含本地 staged/unstaged/untracked 改动;如果导出结果里混入了本地工作区改动,生成解释时必须忽略这些本地改动,只解释目标分支相对基线分支的提交改动。嵌套子仓或软链接子仓必须使用括号里的仓库绝对路径,不要改用当前工作区根目录。示例:",x,"2. 读取导出的 ~/.termdock/branch-audit/branch-audit-export*.json 中的 hunks[],不要把临时 JSON 放到业务仓目录,也不要把整份 JSON 粘贴回输入框。导出工具使用 base...HEAD(三点)生成 diff,只表示当前分支独有改动;提交列表使用 base..HEAD(两点)。","3. 先生成 walkthrough,用 highlights[] 说明整批分支改动目的和影响,用 nodes[]/edges[] 画出主链路、分支链路和验证链路;节点可带 anchor,点击后会跳到对应 diff。","4. 逐个 hunk 写解释。解释要说明该 hunk 的意图、解决的问题、影响、风险,以及它和其它 hunk 的关系;不要逐行复述 diff。","5. 每个仓库分别生成 ~/.termdock/branch-audit/payload-<repo>.json,payload 必须包含 workspaceRoot、repoRoot、baseRef、branchName、headRef、diffFingerprint、walkthrough 和 records[];records[] 每条 record 对应一个 hunk,diff 字段必须从 hunk.diff 原样复制。","6. 把解释写入 payload 后执行:td branch-audit ~/.termdock/branch-audit/payload-<repo>.json","7. 注入成功后删除本次生成的临时 JSON:rm -f ~/.termdock/branch-audit/branch-audit-export-*.json ~/.termdock/branch-audit/payload-*.json","","payload 示例:","```json",JSON.stringify({workspaceRoot:v??null,repoRoot:"<target repo root>",baseRef:"<target repo base branch>",branchName:"<from export currentBranch>",headRef:"<from export headRef>",diffFingerprint:"<from export diffFingerprint>",generatedBy:"termdock-branch-audit",walkthrough:{title:"<one-line branch change title>",summary:"<branch change goal and effect>",highlights:[{what:"<what changed>",effect:"<user/system effect>",tag:"<category>"}],nodes:[{id:"n1",title:"<node title>",kind:"process",business:"<zero-context business explanation>",anchor:{repoRoot:"<target repo root>",filePath:"<from hunk.filePath>",hunkIndex:0,hunkFingerprint:"<from hunk.fingerprint>"}}],edges:[{from:"n1",to:"n2",label:"<relationship>",desc:"<business meaning>"}],risks:[{title:"<real risk or validation gap>"}],checks:["<executable validation step>"]},records:[{filePath:"<from hunk.filePath>",oldPath:"<from hunk.oldPath or null>",newPath:"<from hunk.newPath or null>",hunkHeader:"<from hunk.hunkHeader>",hunkIndex:0,fingerprint:"<from hunk.fingerprint>",diff:"<copy from hunk.diff exactly>",explanation:"<replace with hunk explanation>",summary:""}]},null,2),"```"].join(`
76
+ `)},[Pr,Gt,St,gr,v]),$f=i.useCallback((r="generate")=>{const o=r==="generate"?Ti:[r==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",Ti].join(`
77
+ `);Or(a("rightSidebar.branchAuditShort"),o,`context:branch-audit-scope:${r}`),c||s()},[Ti,Or,s,c,a]),Ef=i.useCallback(async()=>{if(!v||Gt.length===0)return;const r=v;W(!0),xe(null),Yt(null),$e(null);try{const o=await Promise.all(Gt.map(async z=>{const q=St[z.root]?.trim();if(!q)throw new Error(a("rightSidebar.branchAuditMissingBase",{repo:z.label}));const Ce=(gr[z.root]||z.branch||"").trim();return xh({cwd:v,repoRoot:z.root,base:q,head:Ce&&Ce!==z.branch?Ce:null,includeUncommitted:Pr,requestSlotId:`right-sidebar-branch-preview:${z.root}`})}));if(!Ne(r))return;const u=o.find(z=>!z.available);if(u){xe(u.error??"Branch diff is unavailable");return}const x=o.length===1?o[0]:{available:!0,workspaceRoot:v,repoRoot:v,baseRef:o.map(z=>z.baseRef??z.baseBranch).filter(Boolean).join(", "),currentBranch:o.map(z=>z.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:o.map(z=>z.headRef).filter(Boolean).join(", "),diffFingerprint:o.map(z=>z.diffFingerprint).filter(Boolean).join("+"),stat:o.map(z=>z.stat).filter(Boolean).join(`
78
+ `),files:o.flatMap((z,q)=>{const Ce=Gt[q];return(z.files??[]).map(Ye=>`${Ce?.label??z.repoRoot??"repo"}/${Ye}`)}),hunks:o.flatMap((z,q)=>{const Ye=Gt[q]?.label??z.repoRoot??"repo";return(z.hunks??[]).map(Be=>({...Be,filePath:`${Ye}/${Be.filePath}`,oldPath:Be.oldPath?`${Ye}/${Be.oldPath}`:Be.oldPath,newPath:Be.newPath?`${Ye}/${Be.newPath}`:Be.newPath}))}),commits:o.flatMap(z=>z.commits??[]),commitCount:o.reduce((z,q)=>z+(q.commitCount??q.commits?.length??0),0),diff:o.map(z=>z.diff).filter(Boolean).join(`
79
+ `),truncated:o.some(z=>z.truncated)};if((x.hunks??[]).length===0){xe(a("rightSidebar.branchAuditDiffEmpty"));return}const b=Date.now(),N=["preview",x.repoRoot??v,x.baseRef??x.baseBranch??"",x.currentBranch??"",x.headRef??"",x.diffFingerprint??b].join("\0"),L=Gt.length===1?Gt[0].label:`${Gt.length} repos`;Yt(x),Yn(z=>[{key:N,diff:x,repoLabel:L,createdAt:b},...z.filter(q=>q.key!==N)].slice(0,8)),yn(z=>z[N]===void 0?z:{...z,[N]:0}),Jr(N),en(x.hunks?.[0]?`${x.hunks[0].filePath}\0${x.hunks[0].hunkHeader}\0${x.hunks[0].hunkIndex}`:null),Vt(!0)}catch(o){if(!Ne(r)||ir(o))return;xe(o instanceof Error?o.message:"Failed to load branch diff")}finally{Ne(r)&&W(!1)}},[Pr,Gt,St,gr,Ne,v,a]),Mf=i.useCallback(r=>{Yt(r.diff),xe(null),Jr(r.key),en(r.diff.hunks?.[0]?`${r.diff.hunks[0].filePath}\0${r.diff.hunks[0].hunkHeader}\0${r.diff.hunks[0].hunkIndex}`:null),Vt(!0)},[]),Tf=i.useCallback(r=>{Yn(o=>o.filter(u=>u.key!==r)),yn(o=>{if(!(r in o))return o;const u={...o};return delete u[r],u}),qe===r&&(Jr(null),Yt(null),Vt(!1))},[qe]),Pf=i.useCallback(r=>{const o=Bn.find(u=>u.key===r);o&&(Yt(null),xe(null),Jr(r),en(o.records[0]?.filePath??null),Vt(!0))},[Bn]),Lf=i.useCallback(async r=>{if(!v||!ye)return;const[o]=r.split(/\s+/);if(o){Le(o),nt(null),$e(null);try{const u=await bh({cwd:v,repoRoot:ye,commit:o,requestSlotId:"right-sidebar-commit-diff"});if(!u.available){nt(u.error??"Commit diff is unavailable");return}$e(u);const x=u.hunks?.[0];Ps(x?`${x.filePath}\0${x.hunkHeader}\0${x.hunkIndex}`:null)}catch(u){nt(u instanceof Error?u.message:"Failed to load commit diff")}finally{Le(null)}}},[ye,v]),Ff=i.useCallback(r=>{if(!Ae||!qe)return;const o=Math.max(0,Math.round(r));yn(u=>Math.abs((u[qe]??0)-o)<24?u:{...u,[qe]:o})},[Ae,qe]);i.useEffect(()=>{!ee||!mr||!Ae||as(1)},[mr,Ae,ee,as]);const ac=i.useCallback(r=>{r&&Yu(o=>qh(o,r))},[]),ic=Os.key===Ge?Os.key:null,ma=i.useCallback(r=>{const o=ae.getState(),u=Qg();Ta("select_diff_file",{interactionId:u,path:r,previousSelectedFilePath:o.selectedFilePath,rootPath:o.rootPath,activeGitRepoRoot:le,changedFiles:o.changedFiles.size,gitBundleLoading:o.gitBundleLoading,gitBundleLastLoadedAt:o.gitBundleLastLoadedAt,rightTab:o.rightTab}),Ze(r),sn("diff"),ee&&r&&as(1),ac(r),queueMicrotask(()=>{const x=ae.getState();Ta("select_diff_file_after",{interactionId:u,requestedPath:r,selectedFilePath:x.selectedFilePath,rootPath:x.rootPath,rightTab:x.rightTab,changedFiles:x.changedFiles.size,activeGitRepoRoot:le})})},[le,ee,ac,Ze,sn,as]),oc=i.useCallback(r=>{const o=Array.from(we.values()).find(u=>{const x=mt(u,v),b=ct(u);return u.path===r.filePath||b===r.filePath||u.absolutePath===r.filePath||(x?`${x}/${u.path}`===r.filePath:!1)||r.repoRoot&&x===r.repoRoot&&u.path===r.filePath});if(o){ma(ct(o)),window.setTimeout(()=>mn(r),90),window.setTimeout(()=>mn(r),320),window.setTimeout(()=>mn(r),760);return}mn(r)},[we,v,ma]),lc=i.useCallback(({slideToDetail:r,fullscreen:o,toggleFullscreen:u}={})=>qn.length>0?e.jsx(Nd,{walkthroughs:qn,repoRoot:le,fullscreen:o,onToggleFullscreen:u,onNavigate:x=>{ee&&window.requestAnimationFrame(()=>r?.()),oc(x)}}):e.jsxs("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:[e.jsx(Rs,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),a("rightSidebar.changeWalkthroughEmpty")]}),[le,qn,oc,ee,a]),Df=i.useCallback(r=>{r&&Cr(o=>{const u=new Set(o);return u.has(r)?u.delete(r):u.add(r),Xi(Ui,u),u})},[]),cc=i.useCallback(r=>{Va(o=>{const u=new Set(o);return u.has(r)?u.delete(r):u.add(r),Xi(qc,u),u})},[]),pa=i.useCallback(r=>{Es(r),pt(Wd,r)},[]);i.useEffect(()=>{ia||yt!=="ai"||pa("tree")},[yt,pa,ia]);const Pi=i.useCallback(()=>{Ms(r=>{const o=!r;return pt(Gd,o),o})},[]),dc=i.useCallback(r=>{Kr(r),pt(Ud,r)},[]),{whitespace:uc,context:fc}=Yh(),hc=i.useMemo(()=>({algorithm:"histogram",whitespace:uc,context:fc}),[uc,fc]),mc=i.useCallback(r=>{_(r),pt(Kd,r)},[]),ga=i.useCallback(async(r,o,u,x)=>{let b=r;for(;b.ok&&b.status==="running";)await new Promise(L=>window.setTimeout(L,1500)),b=await Mc({jobId:b.jobId,cwd:o.cwd,action:o.action});if(!b.ok)throw new Error("Git action status is unavailable");if(b.status==="error")throw new Error(b.error||b.message||"Git action failed");const N={action:o.action,path:x,label:u};return Jn(N),window.setTimeout(()=>Jn(L=>L?.action===N.action&&L.path===N.path?null:L),1400),b},[]),st=i.useCallback(async(r,o,u)=>{const x=v;v&&_r.current.delete(v),ot(null),Jn(null),Qn({action:r.action,path:u});try{const b=await vh(r),N=await ga(b,r,o,u);if(!Ne(x))return!1;const L=v?await wa(v,void 0,{includeNested:!0,cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:On(v)}).catch(()=>N.bundle):N.bundle;return Ne(x)?(L&&zr(L,{reloadDiff:!0,cacheOnly:!0}),Lr(null),!0):!1}catch(b){return Jn(null),ot(a("rightSidebar.gitActionFailed",{message:b instanceof Error?b.message:"Unknown error"})),!1}finally{Ne(x)&&Qn(null)}},[zr,Ne,v,a,ga]),pc=i.useCallback(async r=>{const o=v,u=await wh(r);if(!Ne(o))return;const x=v?await wa(v,void 0,{includeNested:!0,cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:On(v)}).catch(()=>u.bundle):u.bundle;Ne(o)&&x&&zr(x,{reloadDiff:!0,cacheOnly:!0})},[zr,Ne,v]),xa=i.useCallback((r,o,u)=>{if(o){if(r==="stage-all"){st({action:"stage-all",cwd:o},a("rightSidebar.stageAll"),`repo:${o}`);return}Lr({kind:"stash-all",repoRoot:o,repoLabel:u})}},[st,a]),gc=i.useCallback(r=>{Ue(r),Yi(v,r),si(""),ai(""),ii(""),Ze(Wl(r)),We||sn("diff")},[Wl,We,v,Ze,sn]),_f=i.useCallback(async()=>{if(!ye||Oe){ot(a("rightSidebar.selectRepositoryForGitActions"));return}const r=es.trim();!r||r===ce?.branch||await st({action:"switch-branch",cwd:ye,branch:r},a("rightSidebar.switchBranch"))},[ce?.branch,ye,Oe,st,es,a]),xc=i.useCallback(async()=>{if(!ye||Oe){ot(a("rightSidebar.selectRepositoryForGitActions"));return}const r=Bs.trim();if(!r)return;await st({action:"commit",cwd:ye,message:r},a("rightSidebar.commitChanges"))&&Jo("")},[ye,Bs,Oe,st,a]),If=i.useCallback(async()=>{if(!ye||Oe){ot(a("rightSidebar.selectRepositoryForGitActions"));return}const r=rn.trim(),o=nn.trim();await st({action:"push",cwd:ye,...r?{remote:r}:{},...o?{branch:o}:{}},a("rightSidebar.pushChanges"))},[ye,nn,rn,Oe,st,a]),Bf=i.useCallback(async()=>{if(!ye||Oe){ot(a("rightSidebar.selectRepositoryForGitActions"));return}const r=rn.trim(),o=nn.trim();await st({action:"pull",cwd:ye,...r?{remote:r}:{},...o?{branch:o}:{}},a("rightSidebar.pullChanges"))},[ye,nn,rn,Oe,st,a]);i.useEffect(()=>{if(!We||!ye||Te)return;let r=!1;const o={push:a("rightSidebar.pushChanges"),pull:a("rightSidebar.pullChanges"),commit:a("rightSidebar.commitChanges"),"switch-branch":a("rightSidebar.switchBranch"),"stage-all":a("rightSidebar.stageAll"),"stash-all":a("rightSidebar.stashAll")};return(async()=>{for(const u of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(r)return;const x=await Mc({cwd:ye,action:u}).catch(()=>null);if(!x?.ok||x.status!=="running")continue;const b={action:u,cwd:ye},N=o[u]??u;Qn({action:u});try{const L=await ga(x,b,N);if(r||!Ne(v))return;const z=v?await wa(v,void 0,{includeNested:!0,cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:On(v)}).catch(()=>L.bundle):L.bundle;z&&zr(z,{reloadDiff:!0,cacheOnly:!0})}catch(L){r||ot(a("rightSidebar.gitActionFailed",{message:L instanceof Error?L.message:"Unknown error"}))}finally{r||Qn(null)}return}})(),()=>{r=!0}},[ye,zr,We,Ne,v,Te,a,ga]);const Li=Rn?.action==="commit",Fi=Rn?.action==="switch-branch",Di=Rn?.action==="pull",_i=Rn?.action==="push",ba=We||qu,Ii=la?a("rightSidebar.changeAuditScopeAll"):ar.length===1?ar[0].label:`${ar.length} repos`,zf=ar.length>0,bc=Gt.length>0,Hf=v?e.jsx(ud,{open:Za,onOpenChange:Qa,showScopePicker:!0,selectedAll:la,repos:Ft,selectedRoots:oa,onToggleRepo:Rf,onGenerate:()=>$f(Ei?"regenerate":"generate"),disabled:!zf,generateDisabled:!bc,inserted:V?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:a(Ei?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:a("rightSidebar.inserted"),title:a("rightSidebar.branchAuditGenerateTitle"),ariaLabel:a("rightSidebar.branchAuditShort"),scopeTitle:a("rightSidebar.changeAuditScopeLabel"),scopeLabel:Ii,allLabel:a("rightSidebar.changeAuditScopeAll"),generateLabel:a(Ei?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{Ef()},secondaryDisabled:!bc||T,secondaryLabel:a("rightSidebar.branchAuditViewDiff"),secondaryTitle:a("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:T,loading:qo.size>0,statusTitle:qo.size>0?a("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsxs("div",{className:"mb-2 space-y-1.5",children:[e.jsxs("label",{className:"flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium",children:a("rightSidebar.includeUncommitted")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:a("rightSidebar.includeUncommittedHint")})]}),e.jsx("input",{type:"checkbox",checked:Pr,onChange:r=>Ko(r.target.checked),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]}),ql.length>0&&e.jsx("div",{className:"rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[10px] text-[color:var(--warning)]",children:a("rightSidebar.missingBaseReposSkipped",{repositories:ql.map(r=>r.label).join(k==="zh"?"、":", ")})})]}),renderRepoExtra:r=>{const o=ft.get(r.root),u=[],x=new Set,b=(q,Ce)=>{!q||x.has(q)||(x.add(q),u.push({value:q,label:q,meta:Ce}))};b(gr[r.root]||o?.context?.branch,a("rightSidebar.pushCurrentBranchBadge"));for(const q of o?.context?.branches??[])b(q,q===o?.context?.branch?a("rightSidebar.pushCurrentBranchBadge"):a("rightSidebar.localBranch"));for(const q of o?.context?.remoteBranches??[])b(q,a("rightSidebar.remoteBranch"));const N=[],L=new Set,z=(q,Ce)=>{!q||L.has(q)||(L.add(q),N.push({value:q,label:q,meta:Ce}))};z(St[r.root],St[r.root]?a("rightSidebar.pushUpstreamBadge"):void 0),z(o?.context?.upstream,o?.context?.upstream?a("rightSidebar.pushUpstreamBadge"):void 0);for(const q of o?.context?.remoteBranches??[])z(q,"remote");for(const q of o?.context?.branches??[])z(q,q===o?.context?.branch?a("rightSidebar.pushCurrentBranchBadge"):"local");return e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsx(Hn,{label:a("rightSidebar.currentBranchLabel"),value:gr[r.root]||o?.context?.branch||"",options:u,placeholder:a("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:a("rightSidebar.switchBranchSearchPlaceholder"),emptyText:a("rightSidebar.switchNoBranches"),onChange:q=>{Fs(Ce=>({...Ce,[r.root]:q}))}}),e.jsx(Hn,{label:a("rightSidebar.branchAuditBaseLabel"),value:St[r.root]||"",options:N,placeholder:a("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:a("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:a("rightSidebar.branchAuditBaseEmpty"),onChange:q=>{Ds(Ce=>({...Ce,[r.root]:q}))}})]})}}):null,vc=gs(kt.reduce((r,o)=>Math.max(r,o.injectedAt??0),0),k),Of=v?e.jsxs("div",{className:"border-b border-border/10 px-1 py-3",children:[e.jsxs("button",{type:"button",onClick:()=>Go(r=>{const o=!r;return pt(Ki,o),o}),className:"group flex w-full items-center gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":Zn,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(Rs,{size:14})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[12px] font-semibold text-foreground",children:a("rightSidebar.branchAuditTitle")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:Ii})]}),e.jsx("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${Zn?"rotate-90":""}`,children:e.jsx(ya,{size:13})})]}),Zn&&e.jsxs("div",{className:"mt-2 rounded-lg border border-border/10 bg-surface/60 p-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 text-[11px] text-muted-foreground",children:[a("rightSidebar.changeAuditScopeLabel"),": ",Ii]}),Hf]}),ie&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:ie}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[Xr.map(r=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${qe===r.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Mf(r),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:r.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[10px] text-muted-foreground",children:[r.diff.hunks?.length??0," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.diff.currentBranch??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.diff.baseRef??r.diff.baseBranch}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:a("rightSidebar.branchAuditViewDiff")})]}),gs(r.createdAt,k)&&e.jsx("div",{className:"mt-1 truncate text-[10px] text-muted-foreground/70",children:gs(r.createdAt,k)})]}),e.jsx("button",{type:"button",onClick:()=>Tf(r.key),className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:a("common.delete"),"aria-label":a("common.delete"),children:e.jsx(Pa,{size:12})})]},r.key)),Bn.length>0?Bn.slice(0,Math.max(0,8-Xr.length)).map(r=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${qe===r.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Pf(r.key),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:r.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[10px] text-muted-foreground",children:[r.records.length," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.branchName??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.baseRef}),r.diffFingerprint&&e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:r.diffFingerprint})]}),gs(r.latestInjectedAt,k)&&e.jsx("div",{className:"mt-1 truncate text-[10px] text-muted-foreground/70",children:a("rightSidebar.branchAuditGeneratedAt",{time:gs(r.latestInjectedAt,k)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{Sf(r)},className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:a("rightSidebar.branchAuditClearTitle"),"aria-label":a("rightSidebar.branchAuditClearTitle"),children:e.jsx(Pa,{size:12})})]},r.key)):Xr.length===0?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:a("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,wc=rr&&v&&In?e.jsxs("div",{className:ba?"overflow-visible":"overflow-hidden",children:[Of,e.jsxs("button",{type:"button",onClick:()=>{We||Vu(r=>{const o=!r;return o&&ye&&!In&&!tn&&bi(ye),o})},"aria-expanded":ba,className:`group flex w-full items-center gap-2 px-1 py-1.5 text-left transition ${We?"cursor-default":"rounded-lg hover:bg-surface-2 active:scale-[0.99]"}`,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(Rr,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:a("rightSidebar.gitQuickActions")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs("span",{className:`inline-flex min-w-[4.5rem] items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${fn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[tn&&e.jsx(rt,{size:10,className:"animate-spin"}),fn.staged>0?a("rightSidebar.stagedCount",{count:fn.staged}):a("rightSidebar.noStagedChangesShort")]}),!We&&e.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${ba?"rotate-90":""}`,children:e.jsx(ya,{size:13})})]})]}),ba&&e.jsxs("div",{className:"space-y-0",children:[ht.length>1&&e.jsxs("div",{className:"border-b border-border/10 px-1 py-3",children:[e.jsx("div",{className:"mb-2 flex items-center justify-between gap-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-semibold text-foreground",children:a("rightSidebar.gitRepositorySectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:cf})]})}),e.jsx(Hn,{label:a("rightSidebar.gitRepositoryLabel"),value:ye??"",options:ht,placeholder:a("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:a("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:a("rightSidebar.gitRepositoryEmpty"),disabled:!!Te,onChange:r=>{gc(r||null)}}),Oe&&e.jsx("div",{className:"mt-2 rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[11px] text-[color:var(--warning)]",children:a("rightSidebar.selectRepositoryForGitActions")})]}),e.jsxs("div",{className:"border-b border-border/10 px-1 py-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-semibold text-foreground",children:a("rightSidebar.branchSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:df})]}),e.jsxs("button",{type:"button",onClick:()=>{_f()},disabled:!wf,className:`relative inline-flex h-7 shrink-0 items-center justify-center rounded-md px-2.5 text-[11px] font-semibold transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Fi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.switchBranch"),children:[e.jsx("span",{className:Te?.action==="switch-branch"||Fi?"opacity-0":"",children:a("rightSidebar.switchBranch")}),Te?.action==="switch-branch"&&e.jsx(rt,{size:12,className:"absolute animate-spin"}),Fi&&Te?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(Hn,{label:a("rightSidebar.currentBranchLabel"),value:es,options:hf,placeholder:a("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:a("rightSidebar.switchBranchSearchPlaceholder"),emptyText:a("rightSidebar.switchNoBranches"),disabled:!!Te,onChange:si})]}),e.jsxs("div",{className:"border-b border-border/10 px-1 py-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-semibold text-foreground",children:a("rightSidebar.commitSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:Oe?a("rightSidebar.selectRepositoryForGitActions"):fn.staged>0?a("rightSidebar.commitReadyHint",{count:fn.staged}):a("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{xc()},disabled:!!Te||Oe||fn.staged===0||!Bs.trim(),className:`relative inline-flex h-7 shrink-0 items-center justify-center rounded-md px-2.5 text-[11px] font-semibold transition active:scale-95 ${Li?"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:Oe?a("rightSidebar.selectRepositoryForGitActions"):fn.staged===0?a("rightSidebar.commitNeedsStaged"):a("rightSidebar.commitChanges"),children:[e.jsx("span",{className:Te?.action==="commit"||Li?"opacity-0":"",children:a("rightSidebar.commitChanges")}),Te?.action==="commit"&&e.jsx(rt,{size:12,className:"absolute animate-spin"}),Li&&Te?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:Bs,onChange:r=>Jo(r.target.value),onKeyDown:r=>{(r.metaKey||r.ctrlKey)&&r.key==="Enter"&&(r.preventDefault(),xc())},placeholder:a("rightSidebar.commitMessagePlaceholder"),disabled:!!Te,className:"w-full rounded-md border border-border/15 bg-surface-2 px-2.5 py-1.5 text-[12px] text-foreground outline-none transition placeholder:text-muted-foreground/70 focus:border-primary/35 focus:ring-1 focus:ring-primary/25 disabled:cursor-not-allowed disabled:opacity-60",maxLength:300})]}),e.jsxs("div",{className:"border-b border-border/10 px-1 py-3",children:[e.jsxs("button",{type:"button",onClick:()=>pr(r=>!r),className:"group flex w-full items-center justify-between gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":Xt,children:[e.jsx("span",{className:"min-w-0 text-[11px] font-semibold text-foreground",children:a("rightSidebar.recentCommitsTitle")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[Sn&&e.jsx(rt,{size:12,className:"animate-spin text-muted-foreground"}),e.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${Xt?"rotate-90":""}`,children:e.jsx(ya,{size:13})})]})]}),Xt&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[e.jsx(Wn,{size:12,className:"shrink-0"}),e.jsx("input",{value:kn,onChange:r=>Zr(r.target.value),placeholder:a("rightSidebar.recentCommitsSearchPlaceholder"),className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1}),kn&&e.jsx("button",{type:"button",onClick:()=>Zr(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.clearSearch"),children:e.jsx(_t,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:uf,children:[Zt.length>0?Zt.map(r=>{const[o,...u]=r.split(/\s+/),x=u.join(" ")||r;return e.jsxs("button",{type:"button",onClick:()=>{Lf(r)},className:"flex w-full min-w-0 items-start gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-left font-mono text-[10px] transition hover:bg-surface-elevated active:scale-[0.99]",title:x,children:[e.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:o}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:x,children:x}),He===o&&e.jsx(rt,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},r)}):Sn?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:a("common.loading")}):e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:a("rightSidebar.recentCommitsEmpty")}),J&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(rt,{size:12,className:"animate-spin"})}),Xa&&!J&&Zt.length>0&&e.jsx("button",{type:"button",onClick:()=>{cs({reset:!1})},className:"w-full rounded-md bg-surface-2 px-2 py-1.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:a("rightSidebar.recentCommitsLoadMore")})]})]}),et&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:et}),Jt&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Jt})]}),e.jsxs("div",{className:"px-1 py-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[11px] font-semibold text-foreground",children:a("rightSidebar.pushSectionTitle")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>{Bf()},disabled:!bf,className:`relative inline-flex h-7 min-w-[3.25rem] items-center justify-center rounded-md px-2.5 text-[11px] font-semibold transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Di?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.pullChanges"),children:[e.jsx("span",{className:Te?.action==="pull"||Di?"opacity-0":"",children:a("rightSidebar.pullChanges")}),Te?.action==="pull"&&e.jsx(rt,{size:12,className:"absolute animate-spin"}),Di&&Te?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{If()},disabled:!vf,className:`relative inline-flex h-7 min-w-[3.25rem] items-center justify-center rounded-md px-2.5 text-[11px] font-semibold transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${_i?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:a("rightSidebar.pushChanges"),children:[e.jsx("span",{className:Te?.action==="push"||_i?"opacity-0":"",children:a("rightSidebar.pushChanges")}),Te?.action==="push"&&e.jsx(rt,{size:12,className:"absolute animate-spin"}),_i&&Te?.action!=="push"&&e.jsx("span",{className:"absolute",children:"✓"})]})]})]}),e.jsxs("div",{className:`mb-2 flex min-w-0 items-center justify-between gap-2 rounded-md px-2 py-1.5 text-[11px] ${Yl.className}`,title:ce?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:Yl.text}),e.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:ce?.upstream??""})]}),e.jsxs("div",{className:`grid gap-1.5 ${Kl?"grid-cols-2":"grid-cols-1"}`,children:[Kl&&e.jsx(Hn,{label:a("rightSidebar.pushRemoteLabel"),value:rn,options:Ul,placeholder:a("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:a("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:a("rightSidebar.pushNoRemotes"),disabled:!!Te,onChange:ai}),e.jsx(Hn,{label:a("rightSidebar.pushBranchLabel"),value:nn,options:mf,placeholder:a("rightSidebar.pushBranchPlaceholder",{branch:ce?.branch??"HEAD"}),searchPlaceholder:a("rightSidebar.pushBranchSearchPlaceholder"),emptyText:a("rightSidebar.pushNoBranches"),disabled:!!Te,onChange:ii})]})]})]})]}):null,Wf=i.useCallback(r=>{const o=mt(r,v);if(!o)return[];const u=ao(r),x=[];return r.canStage&&x.push({key:"stage-file",label:a("rightSidebar.stageFile"),onClick:()=>{st({action:"stage-file",cwd:o,paths:[r.path]},a("rightSidebar.stageFile"),u)}}),r.canUnstage&&x.push({key:"unstage-file",label:a("rightSidebar.unstageFile"),onClick:()=>{st({action:"unstage-file",cwd:o,paths:[r.path]},a("rightSidebar.unstageFile"),u)}}),r.canStash&&x.push({key:"stash-file",label:a("rightSidebar.stashFile"),onClick:()=>{st({action:"stash-file",cwd:o,paths:[r.path]},a("rightSidebar.stashFile"),u)}}),r.canRestoreWorktree&&x.push({key:"restore-worktree-file",label:a("rightSidebar.restoreFile"),destructive:!0,onClick:()=>Lr({kind:"restore",file:r,phrase:""})}),x},[v,st,a]),Gf=i.useCallback(()=>{if(m){f?.();return}br(0),yr.current?.slideTo(0),xr(!1),wt(null)},[f,m]),yc=i.useCallback(r=>{if(S(""),Lt(r),Ze(null),wt(null),re(null),ee){m&&f?.(),br(0),yr.current?.slideTo(0),xr(!1);return}},[ee,f,m,Ze,Lt]);i.useEffect(()=>{const r=o=>{const u=o.detail,x=u?.path;if(typeof x!="string"||!x.startsWith("/"))return;S(""),wt(null);const b=!!(v&&(x===v||x.startsWith(`${v}/`)));if(u.kind==="file"){const N=ro(x);is(x),Lt(b?null:N),re(L=>({path:x,nonce:(L?.nonce??0)+1}));return}Ze(null),b?(Lt(null),re(N=>({path:x,nonce:(N?.nonce??0)+1}))):(re(null),Lt(x)),ee&&(m&&f?.(),br(0),yr.current?.slideTo(0),xr(!1))};return window.addEventListener(Pc,r),()=>window.removeEventListener(Pc,r)},[is,ee,f,m,v,Ze,Lt]),i.useEffect(()=>{t||(Mt(!1),Bt(!1))},[t]),i.useEffect(()=>{if(!Kt&&!cr)return;const r=o=>{o instanceof globalThis.KeyboardEvent&&o.key!=="Escape"||o instanceof globalThis.MouseEvent&&o.target instanceof Node&&($s.current?.contains(o.target)||xn.current?.contains(o.target))||(Mt(!1),Bt(!1))};return window.addEventListener("mousedown",r),window.addEventListener("keydown",r),()=>{window.removeEventListener("mousedown",r),window.removeEventListener("keydown",r)}},[cr,Kt]);const kc=e.jsxs("div",{"data-local-layer":"file-explorer-menu-host",className:"sticky top-0 z-20 bg-surface/95 px-2.5 py-1.5 backdrop-blur",children:[e.jsxs("div",{className:"flex min-h-9 min-w-0 items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:af,disabled:!na,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":a("rightSidebar.parentFolder"),title:a("rightSidebar.parentFolder"),children:e.jsx(yd,{size:14})}),e.jsx("button",{type:"button",onClick:Fl,disabled:!v||An===v,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":a("rightSidebar.backToProjectRoot"),title:a("rightSidebar.backToProjectRoot"),children:e.jsx(Dc,{size:14})}),e.jsx("button",{type:"button",onClick:of,disabled:!pe,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":a("rightSidebar.refreshFiles"),title:el?a("rightSidebar.fileWatchUnavailable",{message:el}):a("rightSidebar.refreshFiles"),children:e.jsx(fo,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:pe??void 0,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[12px] font-medium text-foreground",children:[e.jsx("span",{className:"truncate",children:nf}),Ks==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:a("fileTree.sortedByModified"),"aria-label":a("fileTree.sortedByModified"),children:e.jsx(Lc,{size:11})})]})}),e.jsx("button",{type:"button",onClick:()=>pe&&Hr(pe,$t??void 0),disabled:!pe,...pe&&$t?wi(ra(pe),$t):{},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 ${$t&&(V===$t||Re===$t)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":a($t&&Re===$t?"rightSidebar.copied":$t&&V===$t?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:a("rightSidebar.insertCurrentFolder"),children:$t&&(V===$t||Re===$t)?e.jsx(co,{size:13}):e.jsx(_a,{size:13})}),e.jsxs("div",{ref:xn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{Mt(!1),Bt(r=>!r)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${cr?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":cr,"aria-haspopup":"menu","aria-label":a("sidebar.moreActions"),title:a("sidebar.moreActions"),children:e.jsx(uo,{size:14})}),cr&&e.jsxs("div",{role:"menu","data-local-layer":"file-explorer-menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-48 overflow-hidden rounded-xl border border-border/15 bg-surface p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in",children:[e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Bt(!1),lf()},disabled:!Si,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${ls?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[ls?e.jsx(Hi,{size:14}):e.jsx(Sa,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(ls?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Bt(!1),Zu()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${ui?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[ui?e.jsx(Jh,{size:14}):e.jsx(po,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(ui?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!pe,onClick:()=>{pe&&(Bt(!1),Qu(pe,Ks==="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:[Ks==="modified"?e.jsx(_h,{size:14}):e.jsx(Lc,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(Ks==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),v&&(sa.length>0||sf)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 pb-0.5 text-[11px]",children:[e.jsx("span",{className:"shrink-0 px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:a("rightSidebar.pinnedFolders")}),e.jsxs("button",{type:"button",onClick:Fl,className:`inline-flex max-w-[9rem] shrink-0 items-center gap-1 rounded-full px-2 py-0.5 font-medium transition active:scale-95 ${pe===v?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:v,children:[e.jsx(Dc,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:Ve})]}),sa.map(r=>{const o=r.path,u=r.kind==="file",x=u?Ge===o:pe===o;return e.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-full transition ${x?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o,children:[e.jsxs("button",{type:"button",onClick:()=>u?is(o):Lt(o),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[u?e.jsx(go,{size:10,className:"shrink-0"}):e.jsx(Sa,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:dt(o)})]}),e.jsx("button",{type:"button",onClick:()=>an(o),className:"mr-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":a("rightSidebar.unpinFolder",{name:dt(o)}),title:a("rightSidebar.unpinFolder",{name:dt(o)}),children:e.jsx(_t,{size:9})})]},o)})]}),e.jsx("span",{"data-local-layer":"file-explorer-divider",className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-px bg-border/15","aria-hidden":"true"})]}),Bi=i.useMemo(()=>{if(Nn===null)return null;const r=typeof navigator>"u"?void 0:navigator.language,o=Math.max(0,Math.floor((ni-Nn)/1e3)),u=new Intl.RelativeTimeFormat(r,{numeric:"auto"}),[x,b]=o<60?[-o,"second"]:o<3600?[-Math.floor(o/60),"minute"]:o<86400?[-Math.floor(o/3600),"hour"]:[-Math.floor(o/86400),"day"];return u.format(x,b)},[ni,Nn]),Sc=v?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[Bi?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:a("rightSidebar.gitLastUpdated",{time:Bi}),children:Bi}):null,e.jsx("button",{type:"button",onClick:()=>{ss()},disabled:Ct,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95","aria-label":a("rightSidebar.refreshGit"),title:a("rightSidebar.refreshGit"),children:e.jsx(fo,{size:13,className:Ct?"animate-spin":""})})]}):null,Uf=yl?a("rightSidebar.changeAuditScopeAll"):ln.length===1?ln[0].relativeRoot==="."?Ve:ln[0].relativeRoot||ln[0].name:`${ln.length} repos`,jc=v?e.jsxs("div",{className:"inline-flex h-7 shrink-0 items-center",children:[e.jsx(ud,{open:Ts,onOpenChange:Mr,showScopePicker:hn,selectedAll:yl,repos:Ju,selectedRoots:Wt,onToggleRepo:jf,onGenerate:()=>yf(),disabled:!v,inserted:V===Ll,buttonLabel:a("rightSidebar.changeAuditShort"),insertedLabel:a("rightSidebar.inserted"),title:a("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:a("rightSidebar.insertChangeAuditPrompt"),scopeTitle:a("rightSidebar.changeAuditScopeLabel"),scopeLabel:Uf,allLabel:a("rightSidebar.changeAuditScopeAll"),generateLabel:a("rightSidebar.changeAuditShort"),loading:Ar,error:!!Er,statusTitle:Er??(Ar?a("rightSidebar.changeAuditLoading"):kt.length>0?`${a("rightSidebar.changeAuditLoaded",{count:kt.length})}${vc?` · ${a("rightSidebar.changeAuditLoadedAt",{time:vc})}`:""}`:void 0)}),e.jsx("button",{type:"button",onClick:()=>{kf()},disabled:Ar||kt.length===0,className:`inline-flex h-7 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:pointer-events-none active:scale-95 ${kt.length>0?"":"invisible"}`,title:a("rightSidebar.clearChangeAuditTitle"),"aria-label":a("rightSidebar.clearChangeAudit"),children:e.jsx(Pa,{size:12})})]}):null,va=we.size>0||he?.available||Fr?e.jsxs("div",{className:"flex flex-wrap items-center gap-1 text-[10px] font-medium",children:[he?.available&&he.branch&&e.jsxs("span",{className:"inline-flex min-w-0 max-w-[8rem] items-center gap-0.5 truncate rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",title:he.branch,children:[e.jsx(Rr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:he.branch})]}),tt.modified>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[tt.modified,"M"]}),tt.added>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",tt.added]}),tt.deleted>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",tt.deleted]}),tt.renamed>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[tt.renamed,"R"]}),tt.copied>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[tt.copied,"C"]}),tt.untracked>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[tt.untracked,"U"]}),tt.conflicted>0&&e.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[tt.conflicted,"!"]}),tt.other>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[tt.other,"?"]}),tt.staged>0&&e.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:a("rightSidebar.stagedCountShort",{count:tt.staged})}),he?.available&&v&&we.size>0&&Q.length<=1&&e.jsx("button",{type:"button",onClick:()=>{st({action:"stage-all",cwd:v},a("rightSidebar.stageAll"))},disabled:!!Te,className:"rounded-full bg-accent/10 px-2 py-0.5 font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:a("rightSidebar.stageAll"),children:a("rightSidebar.stageAll")}),he?.available&&v&&we.size>0&&Q.length<=1&&e.jsx("button",{type:"button",onClick:()=>Lr({kind:"stash-all",repoRoot:v,repoLabel:Ve}),disabled:!!Te,className:"rounded-full bg-surface-2 px-2 py-0.5 font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:a("rightSidebar.stashAll"),children:a("rightSidebar.stashAll")})]}):null;return e.jsxs(Ih,{side:"right",isOpen:t,drawerWidthPx:n,onClose:s,onOpen:l,push:c,pinned:d,children:[wi.popoverNode,e.jsxs("div",{className:"relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"min-w-0 flex-1 px-1",children:e.jsxs("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",title:v??void 0,children:Ve}),(!ee||ti)&&he?.available&&he.branch&&e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:he.branch,children:[e.jsx(Rr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"max-w-[7rem] truncate",children:he.branch})]})]})}),e.jsx("button",{type:"button",onClick:()=>{const r=!ne;de(r),r?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):S("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${ne?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a("rightSidebar.toggleSearch"),title:a("common.search"),children:e.jsx(Wn,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":Ke,onClick:()=>{pn(r=>!r),or(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Ke?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a("rightSidebar.toggleContextDraft"),title:a("rightSidebar.contextDraftTitle"),children:[e.jsx(dm,{size:14}),!Ke&&vt.trim()&&e.jsx("span",{className:"absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-primary","aria-hidden":"true"})]}),e.jsx("input",{ref:sl,type:"file",multiple:!0,className:"hidden",onChange:r=>{const o=r.target.files;!o||o.length===0||(os(Array.from(o)),r.target.value="")}}),e.jsx("input",{ref:al,type:"file",accept:"image/*",className:"hidden",onChange:r=>{const o=r.target.files?.[0];r.target.value="",o&&rf(o)}}),h&&e.jsx("button",{type:"button",onClick:h,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${d?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":a(d?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:a(d?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:d?e.jsx(Hi,{size:14}):e.jsx(Sa,{size:14})}),e.jsxs("div",{ref:$s,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{Bt(!1),Mt(r=>!r)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${Kt?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":Kt,"aria-haspopup":"menu","aria-label":a("sidebar.moreActions"),title:a("sidebar.moreActions"),children:e.jsx(uo,{size:15})}),Kt&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-56 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Mt(!1),sl.current?.click()},disabled:zs,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:[zs?e.jsx(rt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(vm,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Mt(!1),al.current?.click()},disabled:zs,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:[zs?e.jsx(rt,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(sm,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a("rightSidebar.insertLocalImage")})]}),h&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Mt(!1),h()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${d?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[d?e.jsx(Hi,{size:14}):e.jsx(Sa,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:a(d?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),d&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 border-t border-border/15 px-1.5 pt-1.5",role:"group","aria-label":a("rightSidebar.layoutMode"),children:[e.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:a("rightSidebar.layoutMode")}),e.jsx("div",{className:"grid min-w-0 flex-1 grid-cols-3 gap-0.5 rounded-lg bg-surface-2 p-0.5",children:[["auto",a("rightSidebar.layoutModeAuto")],["narrow",a("rightSidebar.layoutModeNarrow")],["wide",a("rightSidebar.layoutModeWide")]].map(([r,o])=>{const u=K===r;return e.jsx("button",{type:"button",role:"menuitemradio","aria-checked":u,onClick:()=>{X(r),Mt(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${u?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:o},r)})})]})]})]}),e.jsx("button",{type:"button",onClick:s,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":a("rightSidebar.close"),children:e.jsx(_t,{size:14})})]}),ne&&e.jsxs("div",{className:"mt-2 space-y-1.5 pb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-surface-2 px-3 py-1.5 text-muted-foreground transition focus-within:bg-surface-elevated",children:[e.jsx(Wn,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:I,onChange:r=>S(r.target.value),placeholder:a($==="content"?"rightSidebar.searchPlaceholderContent":"rightSidebar.filterChanges"),className:"min-w-0 flex-1 bg-transparent text-[13px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",enterKeyHint:"search",spellCheck:!1}),e.jsxs("div",{className:`flex shrink-0 items-center gap-0.5 rounded-full bg-surface/70 p-0.5 font-medium ${ee?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>mc("name"),"aria-pressed":$==="name",className:`rounded-full px-2 transition active:scale-95 ${ee?"py-1":"py-0.5"} ${$==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:a("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>mc("content"),"aria-pressed":$==="content",className:`rounded-full px-2 transition active:scale-95 ${ee?"py-1":"py-0.5"} ${$==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:a("rightSidebar.searchModeContent")})]}),I&&e.jsx("button",{type:"button",onClick:()=>S(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.clearSearch"),children:e.jsx(_t,{size:12})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg bg-surface-2 px-2.5 py-1.5 text-muted-foreground transition focus-within:bg-surface-elevated",children:[e.jsx(Bh,{size:12,className:"shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:a("rightSidebar.searchScope")}),e.jsx("input",{"data-search-scope":!0,value:Y,onChange:r=>te(r.target.value),onKeyDown:r=>{r.key==="Enter"&&document.querySelector("[data-right-search]")?.focus()},className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:a("rightSidebar.searchScopePlaceholder"),"aria-label":a("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),Y!=="."&&e.jsx("button",{type:"button",onClick:()=>te("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":a("rightSidebar.resetSearchScope"),children:e.jsx(_t,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>ge(r=>!r),"aria-expanded":O,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${O||ts.length>0||B||je||_e?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:a("rightSidebar.searchOptions"),"aria-label":a("rightSidebar.searchOptions"),children:[e.jsx(zh,{size:13}),ts.length>0&&e.jsx("span",{className:"absolute -right-1 -top-1 min-w-4 rounded-full bg-primary px-1 text-[8px] font-bold leading-4 text-primary-foreground",children:ts.length})]})]}),O&&e.jsxs("div",{className:"animate-fade-in rounded-xl bg-surface-2 p-2",children:[e.jsxs("label",{className:"flex items-center gap-2 rounded-lg bg-surface px-2.5 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:a("rightSidebar.searchExclude")}),e.jsx("input",{"data-search-exclude":!0,value:oe,onChange:r=>ue(r.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:a("rightSidebar.searchExcludePlaceholder"),"aria-label":a("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),oe&&e.jsx("button",{type:"button",onClick:()=>ue(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":a("rightSidebar.clearSearchExclude"),children:e.jsx(_t,{size:11})})]}),$==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":a("rightSidebar.contentSearchOptions"),children:[[B,()=>me(r=>!r),Zh,a("rightSidebar.matchCase")],[je,()=>Ee(r=>!r),ym,a("rightSidebar.matchWholeWord")],[_e,()=>bt(r=>!r),fm,a("rightSidebar.useRegex")]].map(([r,o,u,x])=>e.jsxs("button",{type:"button",onClick:o,"aria-pressed":r,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${r?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsx(u,{size:12}),x]},x))})]})]}),Js?null:e.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-0.5 rounded-md bg-surface-2 p-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>sn("git"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${kr==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Rr,{size:12}),a("rightSidebar.tabGit"),Ct&&kr==="git"?e.jsx(rt,{size:12,className:"animate-spin text-muted-foreground"}):null]}),e.jsxs("button",{type:"button",onClick:()=>sn("diff"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${kr==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Td,{size:12}),a("rightSidebar.tabChanges"),Ct?e.jsx(rt,{size:12,className:"animate-spin text-muted-foreground"}):we.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:we.size}):null]}),e.jsxs("button",{type:"button",onClick:()=>sn("files"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${kr==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Wh,{size:12}),a("rightSidebar.tabFiles")]})]}),e.jsx("div",{className:"h-2"}),Zo&&e.jsx("div",{className:"pointer-events-none absolute right-3 top-10 z-20 max-w-[72%] rounded-lg bg-destructive/95 px-3 py-2 text-[11px] font-medium text-destructive-foreground shadow-md animate-fade-in",children:Zo})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(to,{active:We,mounted:rr,fallback:e.jsx(ps,{slow:!1}),children:Ie?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(zc,{items:Nf,selectedKey:Wu,onSelect:Ps,emptyText:a("rightSidebar.noChanges"),mobile:ee,backLabel:a("rightSidebar.backToChangeList"),headerTitle:a("rightSidebar.recentCommitsTitle"),headerMeta:`${Ie.headRef??""}${Ie.commits?.[0]?` · ${Ie.commits[0]}`:""}`,onClose:()=>{$e(null),Ps(null)},closeLabel:a("common.back"),wrap:Tt,onToggleWrap:ee?Pi:void 0,wrapTitle:a("rightSidebar.wrapLongLines"),wrapOnLabel:a("rightSidebar.wrapOn"),wrapOffLabel:a("rightSidebar.wrapOff"),desktopLayout:ee?"stacked":"split",onInsertDiffReference:Or,onReferenceCopied:Sr,insertedReferenceKey:V,copiedReferenceKey:Re,onClearAuditRecord:fa})}):mr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(zc,{items:$i,selectedKey:Ja,onSelect:en,emptyText:a(Ae?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:ee,backLabel:a("rightSidebar.backToChangeList"),headerTitle:a(Ae?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:ha?`${ha.repoLabel} · ${ha.branchName??"HEAD"} → ${ha.baseRef}`:void 0,onClose:()=>{Vt(!1),Yt(null)},closeLabel:a("common.back"),wrap:Tt,onToggleWrap:ee?Pi:void 0,wrapTitle:a("rightSidebar.wrapLongLines"),wrapOnLabel:a("rightSidebar.wrapOn"),wrapOffLabel:a("rightSidebar.wrapOff"),desktopLayout:ee?"stacked":"split",onInsertDiffReference:Or,onReferenceCopied:Sr,insertedReferenceKey:V,copiedReferenceKey:Re,onClearAuditRecord:fa,walkthroughs:Cf,onWalkthroughNavigate:Af,initialDetailScrollTop:Ae&&qe?wn[qe]:void 0,onDetailScrollPositionChange:Ff,externalSwiperRef:ee?Zs:void 0,onMobileSlideChange:ee?ei:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain px-2 py-2",children:wc||(Ct?e.jsx(ps,{slow:Us}):En?e.jsx(Ma,{message:En,onRetry:()=>{ss()}}):xd(he)?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):he?.available===!1?e.jsx(Ma,{message:he.error??a("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{ss()}}):v?e.jsx(ps,{slow:Us}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}))})}),e.jsx(to,{active:Dn,children:ee?e.jsxs(Sd,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:r=>{yr.current=r,r.slideTo(Yo,0)},onSlideChange:r=>{if(br(r.activeIndex),ns.current===r.activeIndex){ns.current=null;return}r.activeIndex===0&&(xr(!1),wt(null),f?.())},children:[e.jsx(ho,{className:"h-full min-h-0",children:e.jsxs("div",{ref:Mn,onScroll:Sl,onDragOver:ea,onDragEnter:ea,onDragLeave:Nl,onDrop:Cl,className:"h-full overflow-y-auto overscroll-contain bg-surface relative",children:[tl&&e.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:e.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:a("rightSidebar.dropToUpload")})}),!I.trim()&&kc,e.jsx(Fc,{rootPath:pe??"",onFileSelect:is,onPathReference:Hr,getReferenceText:ra,onReferenceCopied:Sr,insertedReferenceKey:V,copiedReferenceKey:Re,onDirectoryRoot:Dl,onSearchFromDirectory:_l,onDirectoryPinToggle:Il,onFilePinToggle:Bl,pinnedPaths:dn,selectedFilePath:Ge,query:fe,searchRootPath:xl,searchOptions:bl,searchMode:$,onContentMatchSelect:jl,onDirectoryDropFiles:(r,o)=>os(o,r),revealDirectory:Z,canOpenInFileBrowser:rl,onOpenInFileBrowser:Rl})]})}),e.jsx(ho,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(To,{filePath:Dn&&(Gu||Yo===1)?Ge:null,onInsertReference:Hr,onInsertText:jr,onInsertFeature:jr,onReviewReference:Tl,onReferenceCopied:Sr,onClose:Gf,onDirectoryLinkOpen:yc,isMobile:!0,lineRange:Ur,onLineRangeChange:wt,insertedReferenceKey:V,copiedReferenceKey:Re,scrollToLine:Nr,onScrollToLineHandled:()=>Pe(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:H,onOpenMarkdownOutline:R,onCloseMarkdownOutline:A,markdownImageLightboxOpen:E,markdownImageLightboxCloseSignal:M,onOpenMarkdownImageLightbox:G,onCloseMarkdownImageLightbox:F})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:Mn,onScroll:Sl,onDragOver:ea,onDragEnter:ea,onDragLeave:Nl,onDrop:Cl,className:"shrink-0 overflow-y-auto overscroll-contain bg-surface relative",style:{width:li},children:[tl&&e.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:e.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:a("rightSidebar.dropToUpload")})}),!I.trim()&&kc,e.jsx(Fc,{rootPath:pe??"",onFileSelect:is,onPathReference:Hr,getReferenceText:ra,onReferenceCopied:Sr,insertedReferenceKey:V,copiedReferenceKey:Re,onDirectoryRoot:Dl,onSearchFromDirectory:_l,onDirectoryPinToggle:Il,onFilePinToggle:Bl,pinnedPaths:dn,selectedFilePath:Ge,query:fe,searchRootPath:xl,searchOptions:bl,searchMode:$,onContentMatchSelect:jl,onDirectoryDropFiles:(r,o)=>os(o,r),revealDirectory:Z,canOpenInFileBrowser:rl,onOpenInFileBrowser:Rl})]}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":a("rightSidebar.resizeFileTree"),title:a("rightSidebar.resizeFileTree"),"data-local-layer":"file-preview-separator",className:"group relative z-10 w-2 shrink-0 cursor-col-resize touch-none border-l border-border/15 bg-surface",onPointerDown:ef,onPointerMove:tf,onPointerUp:kl,onPointerCancel:kl,onDoubleClick:()=>{ci(yo),pt(xs,yo)},children:e.jsx("span",{className:"absolute left-1/2 top-0 h-full w-px -translate-x-1/2 bg-border/20 transition group-hover:bg-primary/45"})}),e.jsx("div",{className:"min-w-0 flex-1 overflow-hidden bg-surface",children:e.jsx(To,{filePath:Dn?Ge:null,onInsertReference:Hr,onInsertText:jr,onInsertFeature:jr,onReviewReference:Tl,onReferenceCopied:Sr,onDirectoryLinkOpen:yc,isMobile:!1,lineRange:Ur,onLineRangeChange:wt,insertedReferenceKey:V,copiedReferenceKey:Re,scrollToLine:Nr,onScrollToLineHandled:()=>Pe(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:H,onOpenMarkdownOutline:R,onCloseMarkdownOutline:A,markdownImageLightboxOpen:E,markdownImageLightboxCloseSignal:M,onOpenMarkdownImageLightbox:G,onCloseMarkdownImageLightbox:F})})]})}),e.jsx(to,{active:lt,mounted:Uu||lt,children:()=>ee?e.jsx(mo,{mobile:!0,backLabel:a("rightSidebar.backToChangeList"),externalSwiperRef:Zs,onMobileSlideChange:ei,groups:Dt.length>0?rc():[],mode:yt,onModeChange:pa,selectedKey:Ge,scrollToKey:ic,scrollToKeyNonce:Os.nonce,compact:!1,collapsedDirectoryKeys:dr,onToggleDirectory:cc,onSelectFile:r=>{const o=Array.from(we.values()).find(u=>ct(u)===r.key);o&&ma(ct(o))},renderLeading:sc,renderTrailing:r=>{const o=Array.from(we.values()).find(u=>ct(u)===r.key);return o?ec(o):null},renderDirectoryTrailing:tc,renderSubtitle:r=>{const o=Array.from(we.values()).find(u=>ct(u)===r.key);return o?Ql(o):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:r=>v&&e.jsxs("div",{className:"px-0 py-0",children:[va&&e.jsx("div",{className:"mb-2",children:va}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:a("rightSidebar.allChanges")})}),e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[Dt.length,"/",we.size]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[Xl(),r,d&&Ci(),jc,Sc]}),jt&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:jt.label}),jt.branch&&e.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:jt.branch})]}),!jt&&hn&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[e.jsx(Rr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:a("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:ia?(r=>lc(r)):void 0,emptyContent:Ct&&we.size===0&&Fr===null?e.jsx(ps,{slow:Us}):En&&we.size===0?e.jsx(Ma,{message:En,onRetry:()=>{ss()}}):we.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a("rightSidebar.noChanges")}):Dt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:a("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>as(0),className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:a("rightSidebar.backToChangeList"),children:[e.jsx(ks,{size:14}),a("rightSidebar.backToChangeList")]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-1.5",children:[d&&Ci(),e.jsxs("button",{type:"button",onClick:Pi,"aria-pressed":Tt,title:a("rightSidebar.wrapLongLines"),className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${Tt?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:a(Tt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:nc(),activePane:lt,wrap:Tt,showScrollHint:!Tt,diffViewType:Xu,inlineMode:Kn,diffOptions:hc,reloadKey:ur,renderStreamBadge:r=>e.jsx(ws,{status:r}),onHunkGitAction:pc,onInsertDiffReference:Or,onReferenceCopied:Sr,insertedReferenceKey:V,copiedReferenceKey:Re,onClearAuditRecord:fa,onDetailScroll:ca}):e.jsx(mo,{mobile:!1,desktopLayout:"split",desktopSidePanel:null,desktopListClassName:"w-[320px] min-w-[260px] shrink-0 overflow-y-auto overscroll-contain border-r border-border/15 bg-surface",backLabel:a("rightSidebar.backToChangeList"),groups:Dt.length>0?rc():[],mode:yt,onModeChange:pa,selectedKey:Ge,scrollToKey:ic,scrollToKeyNonce:Os.nonce,compact:!0,collapsedDirectoryKeys:dr,onToggleDirectory:cc,onSelectFile:r=>{const o=Array.from(we.values()).find(u=>ct(u)===r.key);o&&ma(ct(o))},renderLeading:sc,renderTrailing:r=>{const o=Array.from(we.values()).find(u=>ct(u)===r.key);return o?ec(o):null},renderDirectoryTrailing:tc,renderSubtitle:r=>{const o=Array.from(we.values()).find(u=>ct(u)===r.key);return o?Ql(o):null},aiContent:ia?(r=>lc(r)):void 0,emptyContent:Ct&&we.size===0&&Fr===null?e.jsx(ps,{slow:Us}):En&&we.size===0?e.jsx(Ma,{message:En,onRetry:()=>{ss()}}):we.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:a("rightSidebar.noChanges")}):Dt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:a("rightSidebar.noMatchingChanges")}):null,renderListHeader:r=>v&&e.jsxs("div",{className:"px-0 py-0",children:[va&&e.jsx("div",{className:"mb-2",children:va}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:a("rightSidebar.allChanges")}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[Dt.length,"/",we.size]})})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[Xl(),r,Ci(),jc,Sc]}),jt&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:jt.label}),jt.branch&&e.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:jt.branch}),e.jsx("button",{type:"button",onClick:()=>xa("stage-all",jt.root,jt.label),disabled:!!Te,className:"rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:a("rightSidebar.stageAll"),children:a("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:()=>xa("stash-all",jt.root,jt.label),disabled:!!Te,className:"rounded-full bg-surface-2 px-2 py-0.5 text-[10px] font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:a("rightSidebar.stashAll"),children:a("rightSidebar.stashAll")})]}),!jt&&hn&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[e.jsx(Rr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:a("rightSidebar.selectRepositoryForDiff")})]})]}),files:nc(),activePane:lt,wrap:Tt,showScrollHint:!Tt,diffViewType:qt,inlineMode:Kn,diffOptions:hc,reloadKey:ur,renderStreamBadge:r=>e.jsx(ws,{status:r}),onHunkGitAction:pc,onInsertDiffReference:Or,onReferenceCopied:Sr,insertedReferenceKey:V,copiedReferenceKey:Re,onClearAuditRecord:fa,onDetailScroll:ca})})]}),t&&Ke&&e.jsx(Um,{value:vt,collapsed:ut,autoCollapseAfterSend:Ut,focusRequest:Gr,insertError:Un?a("rightSidebar.contextDraftInsertFailed"):null,onChange:r=>{zt(!1),It(r)},onCollapsedChange:or,onAutoCollapseAfterSendChange:gn,onDisable:()=>pn(!1),onClear:()=>It(""),onInsert:()=>Pl(!1),onInsertAndSend:()=>Pl(!0),labels:{title:a("rightSidebar.contextDraftTitle"),hint:a("rightSidebar.contextDraftHint"),placeholder:a("rightSidebar.contextDraftPlaceholder"),collapse:a("rightSidebar.contextDraftCollapse"),expand:a("rightSidebar.contextDraftExpand"),disable:a("rightSidebar.contextDraftDisable"),clear:a("rightSidebar.contextDraftClear"),insert:a("rightSidebar.contextDraftInsert"),insertAndSend:a("rightSidebar.contextDraftInsertAndSend"),inserted:a("rightSidebar.contextDraftInserted"),sent:a("rightSidebar.contextDraftSent"),send:a("rightSidebar.contextDraftSend"),appended:a("rightSidebar.contextDraftAppended"),resize:a("rightSidebar.contextDraftResize"),autoCollapseAfterSend:a("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:r=>a("rightSidebar.contextDraftCharacterCount",{count:r})}}),xf(),it&&typeof document<"u"&&Wr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>Lr(null),children:e.jsxs("div",{className:"fixed inset-x-3 bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto max-w-md rounded-2xl border border-border/20 bg-surface-elevated p-4 shadow-2xl",onClick:r=>r.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:it.kind==="restore"?a("rightSidebar.confirmRestoreTitle"):a("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:it.kind==="restore"?a("rightSidebar.confirmRestoreDescription",{path:wd(it.file.absolutePath,v)}):a("rightSidebar.confirmStashAllDescription")}),it.kind==="restore"&&e.jsx("input",{value:it.phrase,onChange:r=>Lr({...it,phrase:r.target.value}),placeholder:a("rightSidebar.confirmRestorePlaceholder"),className:"mt-3 w-full rounded-xl border border-border/20 bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground",autoFocus:!0}),e.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Lr(null),className:"rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:a("common.cancel")}),e.jsx("button",{type:"button",disabled:!!Te||it.kind==="restore"&&it.phrase.trim()!==a("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(it.kind==="restore"){const r=mt(it.file,v);if(!r)return;st({action:"restore-worktree-file",cwd:r,paths:[it.file.path],confirm:{acknowledged:!0,phrase:it.phrase}},a("rightSidebar.restoreFile"),ao(it.file))}else{const r=it.repoRoot??v;if(!r)return;st({action:"stash-all",cwd:r},a("rightSidebar.stashAll"),`repo:${r}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${it.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:a(Te?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const hx=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:To,MarkdownImageLightbox:Eu,MarkdownPreview:Mu,RightSidebar:tx,__testParseMarkdownListBlock:bg,buildMarkdownPreviewBlocks:$g,buildMarkdownPreviewRenderResult:zo,computeMarkdownImageDisplayBox:hu,getMarkdownHeadingOutline:$u,getMarkdownHeadingPathAtLine:Au,getNextMarkdownPreviewLineRange:Fg,isSvgImageSrc:Ka,mountRightSidebarRepoPickerOverlay:Hd,replaceGitRepositorySnapshot:_u,resolveMarkdownLocalLinkTarget:fu,resolveRightSidebarDiffViewType:Jd,shouldCloseMarkdownImageLightboxDrag:Ru},Symbol.toStringTag,{value:"Module"}));export{po as E,Dc as H,im as M,hx as R,Jh as a,lm as b,km as c,fx as m};