termdock 1.4.336 → 1.4.337

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 (337) hide show
  1. package/dist/client/assets/App-DhHRFEY2.js +187 -0
  2. package/dist/client/assets/App-DhHRFEY2.js.br +0 -0
  3. package/dist/client/assets/App-DhHRFEY2.js.gz +0 -0
  4. package/dist/client/assets/{ArchitecturePanel-BOq2FG6t.js → ArchitecturePanel-DeMEq2Yq.js} +2 -2
  5. package/dist/client/assets/ArchitecturePanel-DeMEq2Yq.js.br +0 -0
  6. package/dist/client/assets/ArchitecturePanel-DeMEq2Yq.js.gz +0 -0
  7. package/dist/client/assets/{ChangeWalkthroughPanel-CxqwQxYc.js → ChangeWalkthroughPanel-DG4TnQvn.js} +1 -1
  8. package/dist/client/assets/ChangeWalkthroughPanel-DG4TnQvn.js.br +0 -0
  9. package/dist/client/assets/ChangeWalkthroughPanel-DG4TnQvn.js.gz +0 -0
  10. package/dist/client/assets/{CollaborationMainWorkspace-vvAVjIlQ.js → CollaborationMainWorkspace-D_yEJJy_.js} +1 -1
  11. package/dist/client/assets/CollaborationMainWorkspace-D_yEJJy_.js.br +0 -0
  12. package/dist/client/assets/CollaborationMainWorkspace-D_yEJJy_.js.gz +0 -0
  13. package/dist/client/assets/CollaborationTaskContent-BtFTzMVY.js +2 -0
  14. package/dist/client/assets/{ComputerControlView-mR6vlp9k.js → ComputerControlView-DGoBNNRA.js} +3 -3
  15. package/dist/client/assets/ComputerControlView-DGoBNNRA.js.br +0 -0
  16. package/dist/client/assets/ComputerControlView-DGoBNNRA.js.gz +0 -0
  17. package/dist/client/assets/{DagPlayground-nUK9xIql.js → DagPlayground-CiCwopwo.js} +1 -1
  18. package/dist/client/assets/DagPlayground-CiCwopwo.js.br +0 -0
  19. package/dist/client/assets/DagPlayground-CiCwopwo.js.gz +0 -0
  20. package/dist/client/assets/{DiffLab-D6XhZtPW.js → DiffLab-C8ItelM8.js} +1 -1
  21. package/dist/client/assets/DiffLab-C8ItelM8.js.br +0 -0
  22. package/dist/client/assets/DiffLab-C8ItelM8.js.gz +0 -0
  23. package/dist/client/assets/{DiffReview-BhyYqkD4.js → DiffReview-riYMjjAA.js} +1 -1
  24. package/dist/client/assets/DiffReview-riYMjjAA.js.br +0 -0
  25. package/dist/client/assets/DiffReview-riYMjjAA.js.gz +0 -0
  26. package/dist/client/assets/{DiffReviewLab-CvNWVrbl.js → DiffReviewLab-CXlrQWLJ.js} +1 -1
  27. package/dist/client/assets/DiffReviewLab-CXlrQWLJ.js.br +0 -0
  28. package/dist/client/assets/DiffReviewLab-CXlrQWLJ.js.gz +0 -0
  29. package/dist/client/assets/{DiffViewer-BSbMa2mq.js → DiffViewer-BxcK2w41.js} +1 -1
  30. package/dist/client/assets/DiffViewer-BxcK2w41.js.br +0 -0
  31. package/dist/client/assets/DiffViewer-BxcK2w41.js.gz +0 -0
  32. package/dist/client/assets/{ModelPreview-B_VPlNYr.js → ModelPreview-HzxWwmh4.js} +1 -1
  33. package/dist/client/assets/ModelPreview-HzxWwmh4.js.br +0 -0
  34. package/dist/client/assets/ModelPreview-HzxWwmh4.js.gz +0 -0
  35. package/dist/client/assets/{RightSidebar-Cakd9qUZ.js → RightSidebar-ChmJQUxz.js} +10 -10
  36. package/dist/client/assets/RightSidebar-ChmJQUxz.js.br +0 -0
  37. package/dist/client/assets/RightSidebar-ChmJQUxz.js.gz +0 -0
  38. package/dist/client/assets/{abnfDiagram-VCTEODGH-vWK7F-r_.js → abnfDiagram-VCTEODGH-BUDaRwTy.js} +1 -1
  39. package/dist/client/assets/abnfDiagram-VCTEODGH-BUDaRwTy.js.br +0 -0
  40. package/dist/client/assets/abnfDiagram-VCTEODGH-BUDaRwTy.js.gz +0 -0
  41. package/dist/client/assets/{app-BZBIr89q.js → app-D2M53LZx.js} +3 -3
  42. package/dist/client/assets/app-D2M53LZx.js.br +0 -0
  43. package/dist/client/assets/app-D2M53LZx.js.gz +0 -0
  44. package/dist/client/assets/{arc-Bdjvby9b.js → arc-DO-aRhWz.js} +1 -1
  45. package/dist/client/assets/arc-DO-aRhWz.js.br +0 -0
  46. package/dist/client/assets/arc-DO-aRhWz.js.gz +0 -0
  47. package/dist/client/assets/{architectureDiagram-5GKGNRK7-DTR5hJkG.js → architectureDiagram-5GKGNRK7-CMImzZR-.js} +1 -1
  48. package/dist/client/assets/architectureDiagram-5GKGNRK7-CMImzZR-.js.br +0 -0
  49. package/dist/client/assets/architectureDiagram-5GKGNRK7-CMImzZR-.js.gz +0 -0
  50. package/dist/client/assets/{blockDiagram-I7D4REHJ-DPz3axsu.js → blockDiagram-I7D4REHJ-DPC_EssA.js} +1 -1
  51. package/dist/client/assets/blockDiagram-I7D4REHJ-DPC_EssA.js.br +0 -0
  52. package/dist/client/assets/blockDiagram-I7D4REHJ-DPC_EssA.js.gz +0 -0
  53. package/dist/client/assets/{c4Diagram-7LVT6UL2-d5ZwPpcN.js → c4Diagram-7LVT6UL2-DJazaM0T.js} +1 -1
  54. package/dist/client/assets/c4Diagram-7LVT6UL2-DJazaM0T.js.br +0 -0
  55. package/dist/client/assets/c4Diagram-7LVT6UL2-DJazaM0T.js.gz +0 -0
  56. package/dist/client/assets/channel-BKGmfJ01.js +1 -0
  57. package/dist/client/assets/{chunk-2Q5K7J3B-BpEmNpto.js → chunk-2Q5K7J3B-BxDoppAq.js} +1 -1
  58. package/dist/client/assets/{chunk-5VM5RSS4-CXDCiEbN.js → chunk-5VM5RSS4-DFunSKh5.js} +1 -1
  59. package/dist/client/assets/{chunk-F27PBJKO-C1L__gXc.js → chunk-F27PBJKO-bLBUcK9l.js} +1 -1
  60. package/dist/client/assets/chunk-F27PBJKO-bLBUcK9l.js.br +0 -0
  61. package/dist/client/assets/chunk-F27PBJKO-bLBUcK9l.js.gz +0 -0
  62. package/dist/client/assets/{chunk-IMKFNOWR-CX0r7pV5.js → chunk-IMKFNOWR-CQzRDG_F.js} +1 -1
  63. package/dist/client/assets/chunk-IMKFNOWR-CQzRDG_F.js.br +0 -0
  64. package/dist/client/assets/chunk-IMKFNOWR-CQzRDG_F.js.gz +0 -0
  65. package/dist/client/assets/{chunk-JWPE2WC7-DkbhnrKh.js → chunk-JWPE2WC7-oYEx3lo8.js} +1 -1
  66. package/dist/client/assets/{chunk-POPQ4Y6H-CH-o5PVe.js → chunk-POPQ4Y6H-DiElQN3B.js} +1 -1
  67. package/dist/client/assets/{chunk-SVP7TREG-C1x5c5cy.js → chunk-SVP7TREG-Cf1eK48Z.js} +1 -1
  68. package/dist/client/assets/chunk-SVP7TREG-Cf1eK48Z.js.br +0 -0
  69. package/dist/client/assets/chunk-SVP7TREG-Cf1eK48Z.js.gz +0 -0
  70. package/dist/client/assets/{chunk-TICWLB2K-DAktkamN.js → chunk-TICWLB2K-CAsKSnF3.js} +1 -1
  71. package/dist/client/assets/chunk-TICWLB2K-CAsKSnF3.js.br +0 -0
  72. package/dist/client/assets/chunk-TICWLB2K-CAsKSnF3.js.gz +0 -0
  73. package/dist/client/assets/{chunk-XXDRQBXY-emNetBN1.js → chunk-XXDRQBXY-CnELf36-.js} +1 -1
  74. package/dist/client/assets/classDiagram-ZZMXUADV-M1OSgOBU.js +1 -0
  75. package/dist/client/assets/classDiagram-v2-VYDZK3BY-M1OSgOBU.js +1 -0
  76. package/dist/client/assets/{cose-bilkent-JH36ORCC-kBGroiho.js → cose-bilkent-JH36ORCC-BjkkSzWB.js} +1 -1
  77. package/dist/client/assets/cose-bilkent-JH36ORCC-BjkkSzWB.js.br +0 -0
  78. package/dist/client/assets/cose-bilkent-JH36ORCC-BjkkSzWB.js.gz +0 -0
  79. package/dist/client/assets/{cynefin-OW5HDTMX-C0TjwB46.js → cynefin-OW5HDTMX-DL9YtN7p.js} +1 -1
  80. package/dist/client/assets/cynefin-OW5HDTMX-DL9YtN7p.js.br +0 -0
  81. package/dist/client/assets/cynefin-OW5HDTMX-DL9YtN7p.js.gz +0 -0
  82. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-CbLSUTuV.js → cynefinDiagram-5FMLGOSQ-vSIBJhoT.js} +1 -1
  83. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-vSIBJhoT.js.br +0 -0
  84. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-vSIBJhoT.js.gz +0 -0
  85. package/dist/client/assets/{dagre-GXQ25YYZ-BoznXKfa.js → dagre-GXQ25YYZ-CJ8Milln.js} +1 -1
  86. package/dist/client/assets/dagre-GXQ25YYZ-CJ8Milln.js.br +0 -0
  87. package/dist/client/assets/dagre-GXQ25YYZ-CJ8Milln.js.gz +0 -0
  88. package/dist/client/assets/{diagram-S7CK7UJ4-iY9ia7F5.js → diagram-S7CK7UJ4-Ci6Vle0S.js} +1 -1
  89. package/dist/client/assets/diagram-S7CK7UJ4-Ci6Vle0S.js.br +0 -0
  90. package/dist/client/assets/diagram-S7CK7UJ4-Ci6Vle0S.js.gz +0 -0
  91. package/dist/client/assets/{diagram-UQ7AKVKN-DhnC8gBw.js → diagram-UQ7AKVKN-Cf1bxglx.js} +1 -1
  92. package/dist/client/assets/diagram-UQ7AKVKN-Cf1bxglx.js.br +0 -0
  93. package/dist/client/assets/diagram-UQ7AKVKN-Cf1bxglx.js.gz +0 -0
  94. package/dist/client/assets/{diagram-VSXAHHWV-JFg8cbqX.js → diagram-VSXAHHWV-MPVKDZTF.js} +1 -1
  95. package/dist/client/assets/diagram-VSXAHHWV-MPVKDZTF.js.br +0 -0
  96. package/dist/client/assets/diagram-VSXAHHWV-MPVKDZTF.js.gz +0 -0
  97. package/dist/client/assets/{diagram-VX7I27RA-dvyXUTpo.js → diagram-VX7I27RA-C9VznNFM.js} +1 -1
  98. package/dist/client/assets/diagram-VX7I27RA-C9VznNFM.js.br +0 -0
  99. package/dist/client/assets/diagram-VX7I27RA-C9VznNFM.js.gz +0 -0
  100. package/dist/client/assets/{diagram-Z3DM3KII-DmjwsCUU.js → diagram-Z3DM3KII-D3Z39FXB.js} +1 -1
  101. package/dist/client/assets/diagram-Z3DM3KII-D3Z39FXB.js.br +0 -0
  102. package/dist/client/assets/diagram-Z3DM3KII-D3Z39FXB.js.gz +0 -0
  103. package/dist/client/assets/{ebnfDiagram-PWID7BFC-BxCdDL0c.js → ebnfDiagram-PWID7BFC-CB6iYj5F.js} +1 -1
  104. package/dist/client/assets/ebnfDiagram-PWID7BFC-CB6iYj5F.js.br +0 -0
  105. package/dist/client/assets/ebnfDiagram-PWID7BFC-CB6iYj5F.js.gz +0 -0
  106. package/dist/client/assets/{erDiagram-RLTQ6QDP-BWvvnoz1.js → erDiagram-RLTQ6QDP-BbywGzIs.js} +1 -1
  107. package/dist/client/assets/erDiagram-RLTQ6QDP-BbywGzIs.js.br +0 -0
  108. package/dist/client/assets/erDiagram-RLTQ6QDP-BbywGzIs.js.gz +0 -0
  109. package/dist/client/assets/{flowDiagram-HODETNUW-CVU0l_6c.js → flowDiagram-HODETNUW-BIhsRkKW.js} +1 -1
  110. package/dist/client/assets/flowDiagram-HODETNUW-BIhsRkKW.js.br +0 -0
  111. package/dist/client/assets/flowDiagram-HODETNUW-BIhsRkKW.js.gz +0 -0
  112. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-CjO521RP.js → ganttDiagram-EL5Y4UJY-0ov1Ht5f.js} +1 -1
  113. package/dist/client/assets/ganttDiagram-EL5Y4UJY-0ov1Ht5f.js.br +0 -0
  114. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-CjO521RP.js.gz → ganttDiagram-EL5Y4UJY-0ov1Ht5f.js.gz} +0 -0
  115. package/dist/client/assets/{gestureArbiter-D_fs_PXp.js → gestureArbiter-DPFs4a-w.js} +1 -1
  116. package/dist/client/assets/gestureArbiter-DPFs4a-w.js.br +0 -0
  117. package/dist/client/assets/{gestureArbiter-D_fs_PXp.js.gz → gestureArbiter-DPFs4a-w.js.gz} +0 -0
  118. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-DbxNhHiO.js → gitGraphDiagram-WWUBYQGX-DPmWc8PK.js} +1 -1
  119. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DPmWc8PK.js.br +0 -0
  120. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DPmWc8PK.js.gz +0 -0
  121. package/dist/client/assets/{infoDiagram-27XIBGKW-DRcGAFqT.js → infoDiagram-27XIBGKW-CiGxOtMe.js} +1 -1
  122. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-BPbgDJUg.js → ishikawaDiagram-5VMMS53U-CVQw2h65.js} +1 -1
  123. package/dist/client/assets/ishikawaDiagram-5VMMS53U-CVQw2h65.js.br +0 -0
  124. package/dist/client/assets/ishikawaDiagram-5VMMS53U-CVQw2h65.js.gz +0 -0
  125. package/dist/client/assets/{journeyDiagram-3NMN7TZE-D1nSzyjD.js → journeyDiagram-3NMN7TZE-CWyQl9rp.js} +1 -1
  126. package/dist/client/assets/journeyDiagram-3NMN7TZE-CWyQl9rp.js.br +0 -0
  127. package/dist/client/assets/journeyDiagram-3NMN7TZE-CWyQl9rp.js.gz +0 -0
  128. package/dist/client/assets/{kanban-definition-UXKFOSKX-CSCXZnir.js → kanban-definition-UXKFOSKX-QYWm-bRz.js} +1 -1
  129. package/dist/client/assets/kanban-definition-UXKFOSKX-QYWm-bRz.js.br +0 -0
  130. package/dist/client/assets/kanban-definition-UXKFOSKX-QYWm-bRz.js.gz +0 -0
  131. package/dist/client/assets/{layout-DTNe7C08.js → layout-wWwHCqP-.js} +1 -1
  132. package/dist/client/assets/layout-wWwHCqP-.js.br +0 -0
  133. package/dist/client/assets/layout-wWwHCqP-.js.gz +0 -0
  134. package/dist/client/assets/{linear-DELStaU_.js → linear-CxAeiA5o.js} +1 -1
  135. package/dist/client/assets/linear-CxAeiA5o.js.br +0 -0
  136. package/dist/client/assets/linear-CxAeiA5o.js.gz +0 -0
  137. package/dist/client/assets/{mermaid.core-D7uvx0E2.js → mermaid.core-Dy-VIGNi.js} +5 -5
  138. package/dist/client/assets/mermaid.core-Dy-VIGNi.js.br +0 -0
  139. package/dist/client/assets/mermaid.core-Dy-VIGNi.js.gz +0 -0
  140. package/dist/client/assets/{mindmap-definition-YA3MSWOX-C_fF6Gnh.js → mindmap-definition-YA3MSWOX-CaOlKAQP.js} +1 -1
  141. package/dist/client/assets/mindmap-definition-YA3MSWOX-CaOlKAQP.js.br +0 -0
  142. package/dist/client/assets/mindmap-definition-YA3MSWOX-CaOlKAQP.js.gz +0 -0
  143. package/dist/client/assets/{passwordBootstrap-Co17Xh3M.js → passwordBootstrap-DADiddYD.js} +1 -1
  144. package/dist/client/assets/passwordBootstrap-DADiddYD.js.br +0 -0
  145. package/dist/client/assets/passwordBootstrap-DADiddYD.js.gz +0 -0
  146. package/dist/client/assets/{pegDiagram-XKGWAZYB-BFOfbHg1.js → pegDiagram-XKGWAZYB-DbMiTSC0.js} +1 -1
  147. package/dist/client/assets/pegDiagram-XKGWAZYB-DbMiTSC0.js.br +0 -0
  148. package/dist/client/assets/pegDiagram-XKGWAZYB-DbMiTSC0.js.gz +0 -0
  149. package/dist/client/assets/{pieDiagram-E7YTZNPT-BkLXgY2Y.js → pieDiagram-E7YTZNPT-DHsbRsqO.js} +1 -1
  150. package/dist/client/assets/pieDiagram-E7YTZNPT-DHsbRsqO.js.br +0 -0
  151. package/dist/client/assets/pieDiagram-E7YTZNPT-DHsbRsqO.js.gz +0 -0
  152. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-DIF7ynjD.js → quadrantDiagram-AXDQQJYC-ivXNY01m.js} +1 -1
  153. package/dist/client/assets/quadrantDiagram-AXDQQJYC-ivXNY01m.js.br +0 -0
  154. package/dist/client/assets/quadrantDiagram-AXDQQJYC-ivXNY01m.js.gz +0 -0
  155. package/dist/client/assets/{railroadDiagram-O6MQD6OU-DGeuv8o1.js → railroadDiagram-O6MQD6OU-B6XiBJ2p.js} +1 -1
  156. package/dist/client/assets/railroadDiagram-O6MQD6OU-B6XiBJ2p.js.br +0 -0
  157. package/dist/client/assets/railroadDiagram-O6MQD6OU-B6XiBJ2p.js.gz +0 -0
  158. package/dist/client/assets/{rdpSession-DZCrSxpu.js → rdpSession-tZqbe3lc.js} +1 -1
  159. package/dist/client/assets/rdpSession-tZqbe3lc.js.br +0 -0
  160. package/dist/client/assets/rdpSession-tZqbe3lc.js.gz +0 -0
  161. package/dist/client/assets/{referenceLongPress-DrY73BHe.js → referenceLongPress-l-iC26Y4.js} +1 -1
  162. package/dist/client/assets/referenceLongPress-l-iC26Y4.js.br +0 -0
  163. package/dist/client/assets/referenceLongPress-l-iC26Y4.js.gz +0 -0
  164. package/dist/client/assets/{requirementDiagram-BXWQKSXE-CoVdyMn3.js → requirementDiagram-BXWQKSXE-BVuulzR5.js} +1 -1
  165. package/dist/client/assets/requirementDiagram-BXWQKSXE-BVuulzR5.js.br +0 -0
  166. package/dist/client/assets/requirementDiagram-BXWQKSXE-BVuulzR5.js.gz +0 -0
  167. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-BF-YvoEZ.js → sankeyDiagram-P5KCCOFB-DCiS6hhT.js} +1 -1
  168. package/dist/client/assets/sankeyDiagram-P5KCCOFB-DCiS6hhT.js.br +0 -0
  169. package/dist/client/assets/sankeyDiagram-P5KCCOFB-DCiS6hhT.js.gz +0 -0
  170. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-CMkePZOj.js → sequenceDiagram-WJ2MYXX4-vobocfD-.js} +1 -1
  171. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-vobocfD-.js.br +0 -0
  172. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-vobocfD-.js.gz +0 -0
  173. package/dist/client/assets/{sizeCapture-INFHLROL-C9N9vqvo.js → sizeCapture-INFHLROL-DY_P3bTc.js} +1 -1
  174. package/dist/client/assets/sizeCapture-INFHLROL-DY_P3bTc.js.br +0 -0
  175. package/dist/client/assets/sizeCapture-INFHLROL-DY_P3bTc.js.gz +0 -0
  176. package/dist/client/assets/{sparkles-DQ-Y24Kv.js → sparkles-iFcvD4yM.js} +1 -1
  177. package/dist/client/assets/{stateDiagram-D77RDMKH-DFk62G9u.js → stateDiagram-D77RDMKH-g9dDzGJR.js} +1 -1
  178. package/dist/client/assets/stateDiagram-D77RDMKH-g9dDzGJR.js.br +0 -0
  179. package/dist/client/assets/stateDiagram-D77RDMKH-g9dDzGJR.js.gz +0 -0
  180. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-Bxp20Ww7.js +1 -0
  181. package/dist/client/assets/{swimlanes-42K2YHIH-CNpYAR3d.js → swimlanes-42K2YHIH-CC39tzCY.js} +1 -1
  182. package/dist/client/assets/swimlanes-42K2YHIH-CC39tzCY.js.br +0 -0
  183. package/dist/client/assets/swimlanes-42K2YHIH-CC39tzCY.js.gz +0 -0
  184. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-bz2A714u.js +8 -0
  185. package/dist/client/assets/{timeline-definition-24CTP7MA-BVEhKc3h.js → timeline-definition-24CTP7MA-Bf-Np1KC.js} +1 -1
  186. package/dist/client/assets/timeline-definition-24CTP7MA-Bf-Np1KC.js.br +0 -0
  187. package/dist/client/assets/timeline-definition-24CTP7MA-Bf-Np1KC.js.gz +0 -0
  188. package/dist/client/assets/{triangle-alert-BIwj1bIH.js → triangle-alert-BeIpvW9N.js} +1 -1
  189. package/dist/client/assets/{vennDiagram-4TSXK5OY-DqKMbCx0.js → vennDiagram-4TSXK5OY-BA9Lil5m.js} +1 -1
  190. package/dist/client/assets/vennDiagram-4TSXK5OY-BA9Lil5m.js.br +0 -0
  191. package/dist/client/assets/vennDiagram-4TSXK5OY-BA9Lil5m.js.gz +0 -0
  192. package/dist/client/assets/{videoCompression-DhppheEu.js → videoCompression-ESn5rZIR.js} +1 -1
  193. package/dist/client/assets/videoCompression-ESn5rZIR.js.br +0 -0
  194. package/dist/client/assets/videoCompression-ESn5rZIR.js.gz +0 -0
  195. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-Bnhg0vB7.js → wardleyDiagram-VM6X3IG4-BCDzPgJu.js} +1 -1
  196. package/dist/client/assets/wardleyDiagram-VM6X3IG4-BCDzPgJu.js.br +0 -0
  197. package/dist/client/assets/wardleyDiagram-VM6X3IG4-BCDzPgJu.js.gz +0 -0
  198. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-BBRqvRXj.js → xychartDiagram-S5SC5T6Z-CXvxPVbT.js} +1 -1
  199. package/dist/client/assets/xychartDiagram-S5SC5T6Z-CXvxPVbT.js.br +0 -0
  200. package/dist/client/assets/xychartDiagram-S5SC5T6Z-CXvxPVbT.js.gz +0 -0
  201. package/dist/client/index.html +1 -1
  202. package/dist/client/index.html.br +0 -0
  203. package/dist/client/index.html.gz +0 -0
  204. package/dist/client/sw.js +1 -1
  205. package/dist/client/sw.js.br +0 -0
  206. package/dist/client/sw.js.gz +0 -0
  207. package/package.json +1 -1
  208. package/runtime-manifest.json +2 -2
  209. package/dist/client/assets/App-B1lqBSPB.js +0 -187
  210. package/dist/client/assets/App-B1lqBSPB.js.br +0 -0
  211. package/dist/client/assets/App-B1lqBSPB.js.gz +0 -0
  212. package/dist/client/assets/ArchitecturePanel-BOq2FG6t.js.br +0 -0
  213. package/dist/client/assets/ArchitecturePanel-BOq2FG6t.js.gz +0 -0
  214. package/dist/client/assets/ChangeWalkthroughPanel-CxqwQxYc.js.br +0 -0
  215. package/dist/client/assets/ChangeWalkthroughPanel-CxqwQxYc.js.gz +0 -0
  216. package/dist/client/assets/CollaborationMainWorkspace-vvAVjIlQ.js.br +0 -0
  217. package/dist/client/assets/CollaborationMainWorkspace-vvAVjIlQ.js.gz +0 -0
  218. package/dist/client/assets/CollaborationTaskContent-Bx6Z5gEL.js +0 -2
  219. package/dist/client/assets/ComputerControlView-mR6vlp9k.js.br +0 -0
  220. package/dist/client/assets/ComputerControlView-mR6vlp9k.js.gz +0 -0
  221. package/dist/client/assets/DagPlayground-nUK9xIql.js.br +0 -0
  222. package/dist/client/assets/DagPlayground-nUK9xIql.js.gz +0 -0
  223. package/dist/client/assets/DiffLab-D6XhZtPW.js.br +0 -0
  224. package/dist/client/assets/DiffLab-D6XhZtPW.js.gz +0 -0
  225. package/dist/client/assets/DiffReview-BhyYqkD4.js.br +0 -0
  226. package/dist/client/assets/DiffReview-BhyYqkD4.js.gz +0 -0
  227. package/dist/client/assets/DiffReviewLab-CvNWVrbl.js.br +0 -0
  228. package/dist/client/assets/DiffReviewLab-CvNWVrbl.js.gz +0 -0
  229. package/dist/client/assets/DiffViewer-BSbMa2mq.js.br +0 -0
  230. package/dist/client/assets/DiffViewer-BSbMa2mq.js.gz +0 -0
  231. package/dist/client/assets/ModelPreview-B_VPlNYr.js.br +0 -0
  232. package/dist/client/assets/ModelPreview-B_VPlNYr.js.gz +0 -0
  233. package/dist/client/assets/RightSidebar-Cakd9qUZ.js.br +0 -0
  234. package/dist/client/assets/RightSidebar-Cakd9qUZ.js.gz +0 -0
  235. package/dist/client/assets/abnfDiagram-VCTEODGH-vWK7F-r_.js.br +0 -0
  236. package/dist/client/assets/abnfDiagram-VCTEODGH-vWK7F-r_.js.gz +0 -0
  237. package/dist/client/assets/app-BZBIr89q.js.br +0 -0
  238. package/dist/client/assets/app-BZBIr89q.js.gz +0 -0
  239. package/dist/client/assets/arc-Bdjvby9b.js.br +0 -0
  240. package/dist/client/assets/arc-Bdjvby9b.js.gz +0 -0
  241. package/dist/client/assets/architectureDiagram-5GKGNRK7-DTR5hJkG.js.br +0 -0
  242. package/dist/client/assets/architectureDiagram-5GKGNRK7-DTR5hJkG.js.gz +0 -0
  243. package/dist/client/assets/blockDiagram-I7D4REHJ-DPz3axsu.js.br +0 -0
  244. package/dist/client/assets/blockDiagram-I7D4REHJ-DPz3axsu.js.gz +0 -0
  245. package/dist/client/assets/c4Diagram-7LVT6UL2-d5ZwPpcN.js.br +0 -0
  246. package/dist/client/assets/c4Diagram-7LVT6UL2-d5ZwPpcN.js.gz +0 -0
  247. package/dist/client/assets/channel-M_h_h55d.js +0 -1
  248. package/dist/client/assets/chunk-F27PBJKO-C1L__gXc.js.br +0 -0
  249. package/dist/client/assets/chunk-F27PBJKO-C1L__gXc.js.gz +0 -0
  250. package/dist/client/assets/chunk-IMKFNOWR-CX0r7pV5.js.br +0 -0
  251. package/dist/client/assets/chunk-IMKFNOWR-CX0r7pV5.js.gz +0 -0
  252. package/dist/client/assets/chunk-SVP7TREG-C1x5c5cy.js.br +0 -0
  253. package/dist/client/assets/chunk-SVP7TREG-C1x5c5cy.js.gz +0 -0
  254. package/dist/client/assets/chunk-TICWLB2K-DAktkamN.js.br +0 -0
  255. package/dist/client/assets/chunk-TICWLB2K-DAktkamN.js.gz +0 -0
  256. package/dist/client/assets/classDiagram-ZZMXUADV-BVuw_2Ox.js +0 -1
  257. package/dist/client/assets/classDiagram-v2-VYDZK3BY-BVuw_2Ox.js +0 -1
  258. package/dist/client/assets/cose-bilkent-JH36ORCC-kBGroiho.js.br +0 -0
  259. package/dist/client/assets/cose-bilkent-JH36ORCC-kBGroiho.js.gz +0 -0
  260. package/dist/client/assets/cynefin-OW5HDTMX-C0TjwB46.js.br +0 -0
  261. package/dist/client/assets/cynefin-OW5HDTMX-C0TjwB46.js.gz +0 -0
  262. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CbLSUTuV.js.br +0 -0
  263. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CbLSUTuV.js.gz +0 -0
  264. package/dist/client/assets/dagre-GXQ25YYZ-BoznXKfa.js.br +0 -0
  265. package/dist/client/assets/dagre-GXQ25YYZ-BoznXKfa.js.gz +0 -0
  266. package/dist/client/assets/diagram-S7CK7UJ4-iY9ia7F5.js.br +0 -0
  267. package/dist/client/assets/diagram-S7CK7UJ4-iY9ia7F5.js.gz +0 -0
  268. package/dist/client/assets/diagram-UQ7AKVKN-DhnC8gBw.js.br +0 -0
  269. package/dist/client/assets/diagram-UQ7AKVKN-DhnC8gBw.js.gz +0 -0
  270. package/dist/client/assets/diagram-VSXAHHWV-JFg8cbqX.js.br +0 -0
  271. package/dist/client/assets/diagram-VSXAHHWV-JFg8cbqX.js.gz +0 -0
  272. package/dist/client/assets/diagram-VX7I27RA-dvyXUTpo.js.br +0 -0
  273. package/dist/client/assets/diagram-VX7I27RA-dvyXUTpo.js.gz +0 -0
  274. package/dist/client/assets/diagram-Z3DM3KII-DmjwsCUU.js.br +0 -0
  275. package/dist/client/assets/diagram-Z3DM3KII-DmjwsCUU.js.gz +0 -0
  276. package/dist/client/assets/ebnfDiagram-PWID7BFC-BxCdDL0c.js.br +0 -0
  277. package/dist/client/assets/ebnfDiagram-PWID7BFC-BxCdDL0c.js.gz +0 -0
  278. package/dist/client/assets/erDiagram-RLTQ6QDP-BWvvnoz1.js.br +0 -0
  279. package/dist/client/assets/erDiagram-RLTQ6QDP-BWvvnoz1.js.gz +0 -0
  280. package/dist/client/assets/flowDiagram-HODETNUW-CVU0l_6c.js.br +0 -0
  281. package/dist/client/assets/flowDiagram-HODETNUW-CVU0l_6c.js.gz +0 -0
  282. package/dist/client/assets/ganttDiagram-EL5Y4UJY-CjO521RP.js.br +0 -0
  283. package/dist/client/assets/gestureArbiter-D_fs_PXp.js.br +0 -0
  284. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DbxNhHiO.js.br +0 -0
  285. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DbxNhHiO.js.gz +0 -0
  286. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BPbgDJUg.js.br +0 -0
  287. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BPbgDJUg.js.gz +0 -0
  288. package/dist/client/assets/journeyDiagram-3NMN7TZE-D1nSzyjD.js.br +0 -0
  289. package/dist/client/assets/journeyDiagram-3NMN7TZE-D1nSzyjD.js.gz +0 -0
  290. package/dist/client/assets/kanban-definition-UXKFOSKX-CSCXZnir.js.br +0 -0
  291. package/dist/client/assets/kanban-definition-UXKFOSKX-CSCXZnir.js.gz +0 -0
  292. package/dist/client/assets/layout-DTNe7C08.js.br +0 -0
  293. package/dist/client/assets/layout-DTNe7C08.js.gz +0 -0
  294. package/dist/client/assets/linear-DELStaU_.js.br +0 -0
  295. package/dist/client/assets/linear-DELStaU_.js.gz +0 -0
  296. package/dist/client/assets/mermaid.core-D7uvx0E2.js.br +0 -0
  297. package/dist/client/assets/mermaid.core-D7uvx0E2.js.gz +0 -0
  298. package/dist/client/assets/mindmap-definition-YA3MSWOX-C_fF6Gnh.js.br +0 -0
  299. package/dist/client/assets/mindmap-definition-YA3MSWOX-C_fF6Gnh.js.gz +0 -0
  300. package/dist/client/assets/passwordBootstrap-Co17Xh3M.js.br +0 -0
  301. package/dist/client/assets/passwordBootstrap-Co17Xh3M.js.gz +0 -0
  302. package/dist/client/assets/pegDiagram-XKGWAZYB-BFOfbHg1.js.br +0 -0
  303. package/dist/client/assets/pegDiagram-XKGWAZYB-BFOfbHg1.js.gz +0 -0
  304. package/dist/client/assets/pieDiagram-E7YTZNPT-BkLXgY2Y.js.br +0 -0
  305. package/dist/client/assets/pieDiagram-E7YTZNPT-BkLXgY2Y.js.gz +0 -0
  306. package/dist/client/assets/quadrantDiagram-AXDQQJYC-DIF7ynjD.js.br +0 -0
  307. package/dist/client/assets/quadrantDiagram-AXDQQJYC-DIF7ynjD.js.gz +0 -0
  308. package/dist/client/assets/railroadDiagram-O6MQD6OU-DGeuv8o1.js.br +0 -0
  309. package/dist/client/assets/railroadDiagram-O6MQD6OU-DGeuv8o1.js.gz +0 -0
  310. package/dist/client/assets/rdpSession-DZCrSxpu.js.br +0 -0
  311. package/dist/client/assets/rdpSession-DZCrSxpu.js.gz +0 -0
  312. package/dist/client/assets/referenceLongPress-DrY73BHe.js.br +0 -0
  313. package/dist/client/assets/referenceLongPress-DrY73BHe.js.gz +0 -0
  314. package/dist/client/assets/requirementDiagram-BXWQKSXE-CoVdyMn3.js.br +0 -0
  315. package/dist/client/assets/requirementDiagram-BXWQKSXE-CoVdyMn3.js.gz +0 -0
  316. package/dist/client/assets/sankeyDiagram-P5KCCOFB-BF-YvoEZ.js.br +0 -0
  317. package/dist/client/assets/sankeyDiagram-P5KCCOFB-BF-YvoEZ.js.gz +0 -0
  318. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-CMkePZOj.js.br +0 -0
  319. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-CMkePZOj.js.gz +0 -0
  320. package/dist/client/assets/sizeCapture-INFHLROL-C9N9vqvo.js.br +0 -0
  321. package/dist/client/assets/sizeCapture-INFHLROL-C9N9vqvo.js.gz +0 -0
  322. package/dist/client/assets/stateDiagram-D77RDMKH-DFk62G9u.js.br +0 -0
  323. package/dist/client/assets/stateDiagram-D77RDMKH-DFk62G9u.js.gz +0 -0
  324. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-Bnyl10vy.js +0 -1
  325. package/dist/client/assets/swimlanes-42K2YHIH-CNpYAR3d.js.br +0 -0
  326. package/dist/client/assets/swimlanes-42K2YHIH-CNpYAR3d.js.gz +0 -0
  327. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-BwjcVbFS.js +0 -8
  328. package/dist/client/assets/timeline-definition-24CTP7MA-BVEhKc3h.js.br +0 -0
  329. package/dist/client/assets/timeline-definition-24CTP7MA-BVEhKc3h.js.gz +0 -0
  330. package/dist/client/assets/vennDiagram-4TSXK5OY-DqKMbCx0.js.br +0 -0
  331. package/dist/client/assets/vennDiagram-4TSXK5OY-DqKMbCx0.js.gz +0 -0
  332. package/dist/client/assets/videoCompression-DhppheEu.js.br +0 -0
  333. package/dist/client/assets/videoCompression-DhppheEu.js.gz +0 -0
  334. package/dist/client/assets/wardleyDiagram-VM6X3IG4-Bnhg0vB7.js.br +0 -0
  335. package/dist/client/assets/wardleyDiagram-VM6X3IG4-Bnhg0vB7.js.gz +0 -0
  336. package/dist/client/assets/xychartDiagram-S5SC5T6Z-BBRqvRXj.js.br +0 -0
  337. package/dist/client/assets/xychartDiagram-S5SC5T6Z-BBRqvRXj.js.gz +0 -0
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-D7uvx0E2.js","assets/app-BZBIr89q.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-CLjn9_01.css","assets/purify.es-4eNOHKSq.js","assets/ModelPreview-B_VPlNYr.js","assets/App-B1lqBSPB.js","assets/gestureArbiter-D_fs_PXp.js","assets/gestureArbiter-C2J0D0kV.css","assets/triangle-alert-BIwj1bIH.js","assets/referenceLongPress-DrY73BHe.js","assets/DiffReview-BhyYqkD4.js","assets/sparkles-DQ-Y24Kv.js","assets/DiffViewer-BSbMa2mq.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-CxqwQxYc.js","assets/ArchitecturePanel-BOq2FG6t.js","assets/ArchitecturePanel-B_BDrrfR.css","assets/ComputerControlView-mR6vlp9k.js","assets/katex-55ZPZeOF.css"])))=>i.map(i=>d[i]);
2
- import{ah as _r,df as mt,bA as e,h as No,cv as Od,ar as qu,_ as Dn,bI as Vu,L as ft,e as hs,X as Lt,dl as V,dt as At,bV as gt,a as la,b3 as Yu,C as Co,d as ca,db as ta,dc as fl,U as Ud,c_ as Hm,cA as zm,bl as Wm,O as qs,aA as Gm,bs as Km,bu as Tl,bv as qm,bw as Xu,bt as Vs,aQ as Vm,E as Ym,k as Xm,bp as Jm,bX as Qm,bZ as Zm,b_ as ep,bg as tp,bY as Hd,N as Rt,g as rp,j as zi,I as np,b as sp,dd as Wi,bf as zd,aK as Wd,aG as ap,aU as Gi,aV as Gd,du as sa,ax as Ys,aW as op,bN as ip,cX as Kd,aN as lp,d9 as cp,cq as dp,dm as Jr,aZ as up,a2 as qd,a1 as fp,aH as Vd,aM as hp,aS as Yd,cs as mp,z as Xd,l as Jd,r as Qd,J as Ju,av as Qu,ci as pp,dr as gp,n as bp}from"./app-BZBIr89q.js";import{b as a,r as Rr}from"./dnd-BCFAPC0L.js";import{i as Il,F as xp,O as Zu,y as vp,s as Zd,Q as eu,W as yo,m as yp,ai as ef,Z as wp,x as kp,I as Sp,t as jp,M as Rp,R as wo,a6 as tf,a7 as Np,S as ms,n as rf,g as Cp,ao as nf,A as Ki,al as Ep,aj as Tn,a8 as Mp,a9 as $p,am as Pp,ab as tu,r as ru,k as nu,E as qi,B as lo,h as Ap,T as Lp,z as Tp,N as su,Y as Ip,q as Dp,U as Fp,o as au,C as _p,c as Bp,G as Op,f as Up}from"./App-B1lqBSPB.js";import{F as hl,a as ou,S as iu,b as sf,c as ml}from"./gestureArbiter-D_fs_PXp.js";import{D as pl,C as aa,L as af,f as Hp,n as zp}from"./DiffReview-BhyYqkD4.js";import{T as Wp,L as Eo,M as of,G as kr}from"./triangle-alert-BIwj1bIH.js";import{S as da}from"./sparkles-DQ-Y24Kv.js";import{C as lf,M as cf}from"./ChangeWalkthroughPanel-CxqwQxYc.js";import{r as df,s as uf,l as ff,a as lu,h as gl,u as Gp,g as bl,b as hf}from"./DiffViewer-BSbMa2mq.js";import{u as mf,G as pf}from"./referenceLongPress-DrY73BHe.js";const Kp=[["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"}]],qp=_r("case-sensitive",Kp);const Vp=[["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"}]],Yp=_r("eye-off",Vp);const Xp=[["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"}]],xl=_r("eye",Xp);const Jp=[["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"}]],vl=_r("file-text",Jp);const Qp=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Zp=_r("funnel",Qp);const eg=[["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"}]],tg=_r("image-plus",eg);const rg=[["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"}]],ng=_r("regex",rg);const sg=[["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"}]],ag=_r("scan",sg);const og=[["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"}]],ig=_r("whole-word",og),lg=100,cg=5e5,dg=1e4,cu=16384,ug=32,fg=1e5;class cs extends Error{constructor(n){super(`Markdown preview parsing stopped: ${n}`),this.reason=n,this.name="MarkdownParseError"}reason}class hg{startedAt=performance.now();operations=0;depth=0;check(){if(++this.operations>fg)throw new cs("complexity");if(performance.now()-this.startedAt>=lg)throw new cs("timeout")}validateLines(n){if(n.length>dg)throw new cs("size");let s=0;for(const l of n)if(this.check(),s+=l.length+1,s>cg||l.length>cu)throw new cs("size")}validateInline(n){if(this.check(),n.length>cu)throw new cs("size")}nested(n){if(this.check(),this.depth>=ug)throw new cs("depth");this.depth+=1;try{return n()}finally{this.depth-=1}}}const du=new RegExp(`(\\\\\\([^)]*\\\\\\)|\\$[^$\\n]+\\$|<br\\s*\\/?>|<\\s*img\\b[^>]*>|<\\s*video\\b[^>]*>[\\s\\S]*?<\\/video\\s*>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\\b[\\s\\S]*?<\\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\\[[^\\]]*\\]\\((?:<[^>]+>|(?:[^\\s()]|\\([^()\\s]*\\))+)(?:\\s+(?:"[^"]*"|'[^']*'|\\([^)]*\\)))?\\)|!?\\[[^\\]]+\\]\\[[^\\]]*\\]|!?\\[[^\\]]+\\]|\\[\\^[^\\]]+\\]|~~[^~]+~~|\\*\\*[^*]+\\*\\*|(?<![\\p{L}\\p{N}_])__[^_]+__(?![\\p{L}\\p{N}_])|\\*[^*\\s][^*]*\\*|(?<![\\p{L}\\p{N}_])_[^_\\s][^_]*_(?![\\p{L}\\p{N}_])|<https?:\\/\\/[^>\\s]+>|<[^\\s@<>]+@[^\\s@<>]+\\.[^\\s@<>]+>|https?:\\/\\/[^\\s<]+|www\\.[^\\s<]+|[^\\s@<>]+@[^\\s@<>]+\\.[^\\s@<>]+)`,"iyu");function mg(r,n,s){let l=n;for(;r[l]==="`";)l+=1;const d=l-n;let c=l;for(;c<r.length;){s.check();const m=r.indexOf("`",c);if(m<0)return null;for(c=m;r[c]==="`";)c+=1;if(c-m===d)return c}return null}function*pg(r,n){n.validateInline(r);const s=new RegExp(du.source,du.flags);let l=0;for(;l<r.length;){if(n.check(),r[l]==="`"){const c=mg(r,l,n);if(c!==null)yield{index:l,token:r.slice(l,c)},l=c;else for(;r[l]==="`";)l+=1;continue}s.lastIndex=l;const d=s.exec(r);n.check(),d?(yield{index:l,token:d[0]},l=s.lastIndex):l+=(r.codePointAt(l)??0)>65535?2:1}}function uu({children:r,actions:n}){const{t:s}=mt(),[l,d]=a.useState(!1),c=a.useId(),m=a.useRef(null),g=a.useRef(null),f=()=>{d(!1),m.current?.focus({preventScroll:!0})};return a.useLayoutEffect(()=>{if(!l)return;const p=m.current,x=g.current;if(!p||!x)return;const h=window.visualViewport,b=()=>{const S=p.getBoundingClientRect(),L=(h?.offsetLeft??0)+8,D=(h?.offsetTop??0)+8,F=Math.max(0,(h?.width??window.innerWidth)-16),$=D+(h?.height??window.innerHeight)-16,N=Math.min(240,F),A=Math.max(0,S.top-D-6),B=Math.max(0,$-S.bottom-6),q=x.scrollHeight>B&&A>B;Object.assign(x.style,{width:`${N}px`,left:`${Math.max(L,Math.min(S.right-N,L+F-N))}px`,top:`${q?S.top-6:S.bottom+6}px`,maxHeight:`${q?A:B}px`,transform:q?"translateY(-100%)":"none"})};b();const E=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return E?.observe(p),E?.observe(x),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),h?.addEventListener("resize",b),h?.addEventListener("scroll",b),()=>{E?.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0),h?.removeEventListener("resize",b),h?.removeEventListener("scroll",b)}},[l]),a.useEffect(()=>{if(!l)return;g.current?.querySelector("button:not(:disabled)")?.focus({preventScroll:!0});const p=x=>{x.target instanceof Node&&!m.current?.contains(x.target)&&!g.current?.contains(x.target)&&d(!1)};return document.addEventListener("pointerdown",p),()=>document.removeEventListener("pointerdown",p)},[l]),e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[r,e.jsxs("button",{ref:m,type:"button","aria-haspopup":"menu","aria-expanded":l,"aria-controls":l?c:void 0,onClick:()=>d(p=>!p),onKeyDown:p=>{(p.key==="ArrowDown"||p.key==="ArrowUp")&&(p.preventDefault(),d(!0))},className:`ml-auto inline-flex h-8 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md px-2 text-[11px] font-medium transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${l?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[e.jsx(No,{size:14}),s("sidebar.moreActions")]})]}),typeof document<"u"&&Rr.createPortal(e.jsx("div",{ref:g,id:c,hidden:!l,role:"menu","data-sidebar-gesture-ignore":!0,"aria-label":s("sidebar.moreActions"),className:"fixed z-menu-panel overflow-y-auto overscroll-contain rounded-lg border border-border/30 bg-surface p-1 shadow-[0_8px_24px_var(--app-shadow-soft)]",onKeyDown:p=>{if(!p.currentTarget.contains(p.target))return;const x=[...p.currentTarget.querySelectorAll("button:not(:disabled)")],h=x.indexOf(document.activeElement);let b;if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),f();return}if(p.key==="Tab"){f();return}if(p.key==="ArrowDown")b=(h+1)%x.length;else if(p.key==="ArrowUp")b=(h-1+x.length)%x.length;else if(p.key==="Home")b=0;else if(p.key==="End")b=x.length-1;else return;p.preventDefault(),x[b]?.focus({preventScroll:!0})},children:n(f)}),document.body)]})}const Vi="a[href],button,input,select,textarea,[tabindex],[contenteditable],iframe,summary,audio[controls],video[controls]",ds=a.memo(function({active:n,mounted:s=!0,fallback:l=null,children:d}){const c=a.useRef(null);return a.useLayoutEffect(()=>{const m=c.current;if(!m||n)return;const g=new Map,f=h=>{g.has(h)||(g.set(h,h.inert),h.inert=!0)},p=h=>{h instanceof HTMLElement&&h.matches(Vi)&&f(h),h.querySelectorAll(Vi).forEach(f)};p(m);const x=new MutationObserver(h=>{for(const b of h)b.type==="attributes"?b.target instanceof HTMLElement&&b.target.matches(Vi)&&f(b.target):b.addedNodes.forEach(E=>{E instanceof Element&&p(E)})});return x.observe(m,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex","href","contenteditable","controls"]}),()=>{x.disconnect();for(const[h,b]of g)h.inert=b}},[n,s]),e.jsx("div",{ref:c,className:"absolute inset-0 min-h-0 overflow-hidden bg-surface text-foreground",style:n?void 0:{clipPath:"inset(100%)"},"aria-hidden":!n,children:s?typeof d=="function"?d():d:l})},(r,n)=>!r.active&&!n.active&&r.mounted===n.mounted);async function gg(r){let n;try{await Promise.race([r(),new Promise(s=>{n=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(n)}}function bg({active:r,rootPath:n,loading:s,delay:l,lastStartedRoot:d,load:c}){a.useEffect(()=>{if(!r||!n||s||d.current===n)return;const m=window.setTimeout(()=>{d.current=n,c(n)},l);return()=>window.clearTimeout(m)},[r,n,s,l,d,c])}async function xg(r){if(r.kind==="mermaid"){await Od(new Blob([r.svg],{type:"image/svg+xml"}),"mermaid.svg");return}const n=new URL(r.src,window.location.href);if(n.origin===window.location.origin&&n.pathname==="/api/terminal/fs/blob"){const c=n.searchParams.get("path");if(!c)throw new Error("Missing image path");await qu(c);return}const s=await fetch(r.src);if(!s.ok)throw new Error(`HTTP ${s.status}`);const l=await s.blob(),d=decodeURIComponent(n.pathname.split("/").pop()||"")||`image.${{"image/svg+xml":"svg","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif"}[l.type]||"png"}`;await Od(l,d)}let co=null,fu=!1;function vg(){return co||(co=Dn(()=>import("./mermaid.core-D7uvx0E2.js").then(r=>r.bl),__vite__mapDeps([0,1,2,3,4,5,6])).then(r=>r.default??r).catch(r=>{throw co=null,r})),co}function yg(r){fu||(r.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),fu=!0)}function wg({rootPath:r,paths:n,disabled:s,onChange:l}){const{t:d}=mt(),[c,m]=a.useState(""),[g,f]=a.useState(0),[p,x]=a.useState(null),[h,b]=a.useState(!1),[E,S]=a.useState(!1),L=`${r.replace(/[\\/]+$/,"")}/${c}`;a.useEffect(()=>{const N=new AbortController;return x(null),b(!1),Vu(L,N.signal,!0,"pick_git_ignore_exception").then(A=>{N.signal.aborted||x({directory:c,entries:A.entries,truncated:!!A.truncated})}).catch(()=>{N.signal.aborted||b(!0)}),()=>N.abort()},[L,c,g]);const D=N=>{x(null),b(!1),m(N)},F=p?.directory===c,$=N=>{if(N.length>200){S(!0);return}S(!1),l(N)};return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/30 bg-surface-2",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/20 p-2",children:[e.jsx("button",{type:"button",disabled:s||!c,onClick:()=>D(c.slice(0,Math.max(0,c.lastIndexOf("/")))),"aria-label":d("rightSidebar.parentFolder"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-30",children:e.jsx(Il,{size:14})}),e.jsx("button",{type:"button",disabled:s||!c,onClick:()=>D(""),"aria-label":d("rightSidebar.backToProjectRoot"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-30",children:e.jsx(hl,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:L,children:c||"./"})]}),e.jsxs("div",{className:"h-56 overflow-y-auto overscroll-contain p-1",role:"group","aria-label":d("rightSidebar.gitIgnoreExceptionsPaths"),"aria-busy":!F&&!h,children:[h?e.jsxs("div",{className:"flex flex-col items-center gap-2 p-4 text-center text-xs",children:[e.jsx("p",{role:"alert",className:"text-destructive",children:d("rightSidebar.gitIgnoreExceptionsLoadFailed")}),e.jsx("button",{type:"button",disabled:s,onClick:()=>{b(!1),f(N=>N+1)},className:"rounded-md px-3 py-2 text-primary hover:bg-surface-elevated disabled:opacity-40",children:d("common.retry")})]}):F?p.entries.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-muted-foreground",children:d("rightSidebar.gitIgnoreExceptionsEmptyDirectory")}):p.entries.map(N=>{const A=c?`${c}/${N.name}`:N.name,B=A+(N.type==="directory"?"/":""),q=n.includes(B)||n.includes(A),j=n.some(_=>_.endsWith("/")&&A.startsWith(_)),o=N.type==="directory"?hl:xp;return e.jsxs("div",{className:"flex items-center gap-1 rounded-md hover:bg-surface-elevated",children:[e.jsxs("label",{className:"flex min-h-10 min-w-0 flex-1 cursor-pointer items-center gap-2 px-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:q||j,disabled:s||j,onChange:()=>$(q?n.filter(_=>_!==B&&_!==A):[...n,B]),className:"h-4 w-4 shrink-0 accent-[var(--primary)] disabled:opacity-40"}),e.jsx(o,{size:14,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",title:N.name,children:N.name})]}),N.type==="directory"&&e.jsx("button",{type:"button",disabled:s,onClick:()=>D(A),"aria-label":d("rightSidebar.gitIgnoreExceptionsOpenDirectory",{name:N.name}),className:"inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface hover:text-foreground disabled:opacity-40",children:e.jsx(hs,{size:15})})]},N.name)}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(ft,{size:18})}),F&&p.truncated&&e.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:d("rightSidebar.gitIgnoreExceptionsTruncated")})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsx("span",{className:"font-medium",children:d("rightSidebar.gitIgnoreExceptionsSelected",{count:n.length})}),e.jsx("button",{type:"button",disabled:s||n.length===0,onClick:()=>$([]),className:"rounded-md px-2 py-1 text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:d("rightSidebar.gitIgnoreExceptionsClear")})]}),n.length>0&&e.jsx("ul",{className:"max-h-24 overflow-y-auto overscroll-contain",children:n.map(N=>e.jsxs("li",{className:"flex items-center gap-2 rounded-md pl-2 text-xs hover:bg-surface-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",title:N,children:N}),e.jsx("button",{type:"button",disabled:s,onClick:()=>$(n.filter(A=>A!==N)),"aria-label":d("rightSidebar.gitIgnoreExceptionsRemove",{path:N}),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-40",children:e.jsx(Lt,{size:13})})]},N))}),E&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:d("rightSidebar.gitIgnoreExceptionsInvalid")})]})}function kg({rootPath:r,disabled:n,pressed:s,saving:l,onToggle:d}){const{t:c}=mt(),m=a.useId(),g=a.useRef(null),f=a.useRef(null),p=a.useRef(null),x=a.useRef(null),h=a.useRef(!1),[b,E]=a.useState(!1),[S,L]=a.useState([]),[D,F]=a.useState(!1),[$,N]=a.useState(null),A=V(I=>I.setGitIgnoreExceptions),B=()=>{p.current!==null&&clearTimeout(p.current),p.current=null,x.current=null},q=()=>{B(),!(n||D||!r)&&(L([...V.getState().gitIgnoreExceptions[r]??[]]),N(null),E(!0))},j=()=>{D||E(!1)},o=I=>{B(),h.current=!1,!(I.button!==0||!I.isPrimary||n)&&(I.currentTarget.setPointerCapture(I.pointerId),x.current={x:I.clientX,y:I.clientY},p.current=setTimeout(()=>{h.current=!0,q()},450))};a.useEffect(()=>(E(!1),B(),B),[r]),a.useEffect(()=>{if(b)return f.current?.focus(),()=>g.current?.focus()},[b]);const _=c(s?"rightSidebar.showGitIgnoredFiles":"rightSidebar.hideGitIgnoredFiles");return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:g,type:"button",disabled:n||D,"aria-pressed":s,"aria-label":_,"aria-description":c("rightSidebar.gitIgnoreConfigureHint"),title:`${_} · ${c("rightSidebar.gitIgnoreConfigureHint")}`,onClick:I=>{if(h.current&&I.detail!==0){h.current=!1,I.preventDefault();return}d()},onContextMenu:I=>{I.preventDefault(),h.current=!0,b||q()},onPointerDown:o,onPointerMove:I=>{const Y=x.current;Y&&Math.hypot(I.clientX-Y.x,I.clientY-Y.y)>10&&B()},onPointerUp:B,onPointerCancel:B,onLostPointerCapture:B,className:`inline-flex h-7 w-7 shrink-0 select-none items-center justify-center rounded-md transition active:scale-95 disabled:cursor-not-allowed disabled:opacity-35 [-webkit-touch-callout:none] ${s?"bg-surface-2 text-primary hover:bg-surface-elevated":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:l?e.jsx(ft,{size:14}):e.jsx(Zp,{size:14})}),b&&Rr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop flex items-center justify-center bg-[var(--app-backdrop)] p-3 backdrop-blur-sm",onClick:j,children:e.jsxs("form",{ref:f,role:"dialog",tabIndex:-1,"aria-modal":"true","aria-labelledby":`${m}-title`,"aria-describedby":`${m}-hint`,className:"relative z-modal-panel flex max-h-[80dvh] w-full max-w-lg flex-col gap-3 overflow-y-auto rounded-xl border border-border/20 bg-surface p-4 text-foreground shadow-2xl",onClick:I=>I.stopPropagation(),onKeyDown:I=>{if(I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),j()),I.key==="Tab"){const Y=Array.from(f.current?.querySelectorAll("button:not(:disabled), input:not(:disabled)")??[]);if(!Y.length){I.preventDefault(),f.current?.focus();return}const U=Y[0],O=Y[Y.length-1];I.shiftKey&&document.activeElement===U&&(I.preventDefault(),O?.focus()),document.activeElement===f.current?(I.preventDefault(),(I.shiftKey?O:U)?.focus()):!I.shiftKey&&document.activeElement===O&&(I.preventDefault(),U?.focus())}},onSubmit:I=>{if(I.preventDefault(),!(!r||D)){if(S.length>200){N(c("rightSidebar.gitIgnoreExceptionsInvalid"));return}F(!0),N(null),A(r,S).then(()=>E(!1)).catch(()=>N(c("rightSidebar.gitIgnoreExceptionsSaveFailed"))).finally(()=>F(!1))}},children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h2",{id:`${m}-title`,className:"text-sm font-medium",children:c("rightSidebar.gitIgnoreExceptionsTitle")}),e.jsx("button",{type:"button",disabled:D,onClick:j,"aria-label":c("common.close"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:e.jsx(Lt,{size:16})})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:r??void 0,children:r}),e.jsx("p",{id:`${m}-hint`,className:"text-xs leading-relaxed text-muted-foreground",children:c("rightSidebar.gitIgnoreExceptionsHint")}),e.jsx("p",{className:"text-xs font-medium",children:c("rightSidebar.gitIgnoreExceptionsPaths")}),r&&e.jsx(wg,{rootPath:r,paths:S,onChange:L,disabled:D}),$&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:$}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",disabled:D,onClick:j,className:"rounded-lg px-3 py-2 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40",children:c("common.cancel")}),e.jsxs("button",{type:"submit",disabled:D,className:"inline-flex items-center gap-2 rounded-lg bg-primary px-3 py-2 text-xs font-medium text-primary-foreground disabled:opacity-50",children:[D&&e.jsx(ft,{size:13}),c("common.save")]})]})]})}),document.body)]})}function Sg(r,n,s){try{const l=r instanceof HTMLImageElement?r.naturalWidth:r.width,d=r instanceof HTMLImageElement?r.naturalHeight:r.height;if(!l||!d)return Promise.resolve(null);const c=r instanceof HTMLImageElement?1400/Math.max(l,d):Math.min(1,1400/Math.max(l,d)),m=document.createElement("canvas");m.width=Math.max(1,Math.round(l*c)),m.height=Math.max(1,Math.round(d*c));const g=m.getContext("2d");if(!g)return Promise.resolve(null);const f=getComputedStyle(document.documentElement);if(g.fillStyle=f.getPropertyValue("--surface").trim()||"white",g.fillRect(0,0,m.width,m.height),g.drawImage(r,0,0,m.width,m.height),s){const p=Math.max(10,Math.min(16,m.width/35));g.font=`${p}px sans-serif`;const x=[];let h="";for(const b of s.split(" "))h&&g.measureText(`${h} ${b}`).width>m.width-20?(x.push(h),h=b):h=h?`${h} ${b}`:b;h&&x.push(h),g.fillStyle=f.getPropertyValue("--surface").trim()||"white",g.fillRect(0,0,m.width,x.length*(p+4)+12),g.fillStyle=f.getPropertyValue("--foreground").trim()||"black",x.forEach((b,E)=>g.fillText(b,10,8+p+E*(p+4)))}if(n){const p=n.xPercent*m.width/100,x=n.yPercent*m.height/100,h=Math.max(4,Math.min(12,Math.min(m.width,m.height)*.015)),b=h*1.6;g.strokeStyle=f.getPropertyValue("--primary").trim()||"black",g.lineWidth=Math.max(1,h/3),g.beginPath(),g.arc(p,x,h,0,Math.PI*2),g.stroke(),g.beginPath(),g.moveTo(p-b,x),g.lineTo(p+b,x),g.moveTo(p,x-b),g.lineTo(p,x+b),g.stroke()}return new Promise(p=>m.toBlob(p,"image/png"))}catch{return Promise.resolve(null)}}function jg(r,n,s,l){return[r.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-Dy-VIGNi.js","assets/app-D2M53LZx.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-CLjn9_01.css","assets/purify.es-4eNOHKSq.js","assets/ModelPreview-HzxWwmh4.js","assets/App-DhHRFEY2.js","assets/gestureArbiter-DPFs4a-w.js","assets/gestureArbiter-C2J0D0kV.css","assets/triangle-alert-BeIpvW9N.js","assets/referenceLongPress-l-iC26Y4.js","assets/DiffReview-riYMjjAA.js","assets/sparkles-iFcvD4yM.js","assets/DiffViewer-BxcK2w41.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-DG4TnQvn.js","assets/ArchitecturePanel-DeMEq2Yq.js","assets/ArchitecturePanel-B_BDrrfR.css","assets/ComputerControlView-DGoBNNRA.js","assets/katex-55ZPZeOF.css"])))=>i.map(i=>d[i]);
2
+ import{ah as _r,df as mt,bA as e,h as No,cv as Od,ar as qu,_ as Dn,bI as Vu,L as ft,e as hs,X as Lt,dl as V,dt as At,bV as gt,a as la,b3 as Yu,C as Co,d as ca,db as ta,dc as fl,U as Ud,c_ as Hm,cA as zm,bl as Wm,O as qs,aA as Gm,bs as Km,bu as Tl,bv as qm,bw as Xu,bt as Vs,aQ as Vm,E as Ym,k as Xm,bp as Jm,bX as Qm,bZ as Zm,b_ as ep,bg as tp,bY as Hd,N as Rt,g as rp,j as zi,I as np,b as sp,dd as Wi,bf as zd,aK as Wd,aG as ap,aU as Gi,aV as Gd,du as sa,ax as Ys,aW as op,bN as ip,cX as Kd,aN as lp,d9 as cp,cq as dp,dm as Jr,aZ as up,a2 as qd,a1 as fp,aH as Vd,aM as hp,aS as Yd,cs as mp,z as Xd,l as Jd,r as Qd,J as Ju,av as Qu,ci as pp,dr as gp,n as bp}from"./app-D2M53LZx.js";import{b as a,r as Rr}from"./dnd-BCFAPC0L.js";import{i as Il,F as xp,O as Zu,y as vp,s as Zd,Q as eu,W as yo,m as yp,ai as ef,Z as wp,x as kp,I as Sp,t as jp,M as Rp,R as wo,a6 as tf,a7 as Np,S as ms,n as rf,g as Cp,ao as nf,A as Ki,al as Ep,aj as Tn,a8 as Mp,a9 as $p,am as Pp,ab as tu,r as ru,k as nu,E as qi,B as lo,h as Ap,T as Lp,z as Tp,N as su,Y as Ip,q as Dp,U as Fp,o as au,C as _p,c as Bp,G as Op,f as Up}from"./App-DhHRFEY2.js";import{F as hl,a as ou,S as iu,b as sf,c as ml}from"./gestureArbiter-DPFs4a-w.js";import{D as pl,C as aa,L as af,f as Hp,n as zp}from"./DiffReview-riYMjjAA.js";import{T as Wp,L as Eo,M as of,G as kr}from"./triangle-alert-BeIpvW9N.js";import{S as da}from"./sparkles-iFcvD4yM.js";import{C as lf,M as cf}from"./ChangeWalkthroughPanel-DG4TnQvn.js";import{r as df,s as uf,l as ff,a as lu,h as gl,u as Gp,g as bl,b as hf}from"./DiffViewer-BxcK2w41.js";import{u as mf,G as pf}from"./referenceLongPress-l-iC26Y4.js";const Kp=[["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"}]],qp=_r("case-sensitive",Kp);const Vp=[["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"}]],Yp=_r("eye-off",Vp);const Xp=[["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"}]],xl=_r("eye",Xp);const Jp=[["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"}]],vl=_r("file-text",Jp);const Qp=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Zp=_r("funnel",Qp);const eg=[["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"}]],tg=_r("image-plus",eg);const rg=[["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"}]],ng=_r("regex",rg);const sg=[["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"}]],ag=_r("scan",sg);const og=[["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"}]],ig=_r("whole-word",og),lg=100,cg=5e5,dg=1e4,cu=16384,ug=32,fg=1e5;class cs extends Error{constructor(n){super(`Markdown preview parsing stopped: ${n}`),this.reason=n,this.name="MarkdownParseError"}reason}class hg{startedAt=performance.now();operations=0;depth=0;check(){if(++this.operations>fg)throw new cs("complexity");if(performance.now()-this.startedAt>=lg)throw new cs("timeout")}validateLines(n){if(n.length>dg)throw new cs("size");let s=0;for(const l of n)if(this.check(),s+=l.length+1,s>cg||l.length>cu)throw new cs("size")}validateInline(n){if(this.check(),n.length>cu)throw new cs("size")}nested(n){if(this.check(),this.depth>=ug)throw new cs("depth");this.depth+=1;try{return n()}finally{this.depth-=1}}}const du=new RegExp(`(\\\\\\([^)]*\\\\\\)|\\$[^$\\n]+\\$|<br\\s*\\/?>|<\\s*img\\b[^>]*>|<\\s*video\\b[^>]*>[\\s\\S]*?<\\/video\\s*>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\\b[\\s\\S]*?<\\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\\[[^\\]]*\\]\\((?:<[^>]+>|(?:[^\\s()]|\\([^()\\s]*\\))+)(?:\\s+(?:"[^"]*"|'[^']*'|\\([^)]*\\)))?\\)|!?\\[[^\\]]+\\]\\[[^\\]]*\\]|!?\\[[^\\]]+\\]|\\[\\^[^\\]]+\\]|~~[^~]+~~|\\*\\*[^*]+\\*\\*|(?<![\\p{L}\\p{N}_])__[^_]+__(?![\\p{L}\\p{N}_])|\\*[^*\\s][^*]*\\*|(?<![\\p{L}\\p{N}_])_[^_\\s][^_]*_(?![\\p{L}\\p{N}_])|<https?:\\/\\/[^>\\s]+>|<[^\\s@<>]+@[^\\s@<>]+\\.[^\\s@<>]+>|https?:\\/\\/[^\\s<]+|www\\.[^\\s<]+|[^\\s@<>]+@[^\\s@<>]+\\.[^\\s@<>]+)`,"iyu");function mg(r,n,s){let l=n;for(;r[l]==="`";)l+=1;const d=l-n;let c=l;for(;c<r.length;){s.check();const m=r.indexOf("`",c);if(m<0)return null;for(c=m;r[c]==="`";)c+=1;if(c-m===d)return c}return null}function*pg(r,n){n.validateInline(r);const s=new RegExp(du.source,du.flags);let l=0;for(;l<r.length;){if(n.check(),r[l]==="`"){const c=mg(r,l,n);if(c!==null)yield{index:l,token:r.slice(l,c)},l=c;else for(;r[l]==="`";)l+=1;continue}s.lastIndex=l;const d=s.exec(r);n.check(),d?(yield{index:l,token:d[0]},l=s.lastIndex):l+=(r.codePointAt(l)??0)>65535?2:1}}function uu({children:r,actions:n}){const{t:s}=mt(),[l,d]=a.useState(!1),c=a.useId(),m=a.useRef(null),g=a.useRef(null),f=()=>{d(!1),m.current?.focus({preventScroll:!0})};return a.useLayoutEffect(()=>{if(!l)return;const p=m.current,x=g.current;if(!p||!x)return;const h=window.visualViewport,b=()=>{const S=p.getBoundingClientRect(),L=(h?.offsetLeft??0)+8,D=(h?.offsetTop??0)+8,F=Math.max(0,(h?.width??window.innerWidth)-16),$=D+(h?.height??window.innerHeight)-16,N=Math.min(240,F),A=Math.max(0,S.top-D-6),B=Math.max(0,$-S.bottom-6),q=x.scrollHeight>B&&A>B;Object.assign(x.style,{width:`${N}px`,left:`${Math.max(L,Math.min(S.right-N,L+F-N))}px`,top:`${q?S.top-6:S.bottom+6}px`,maxHeight:`${q?A:B}px`,transform:q?"translateY(-100%)":"none"})};b();const E=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return E?.observe(p),E?.observe(x),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),h?.addEventListener("resize",b),h?.addEventListener("scroll",b),()=>{E?.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0),h?.removeEventListener("resize",b),h?.removeEventListener("scroll",b)}},[l]),a.useEffect(()=>{if(!l)return;g.current?.querySelector("button:not(:disabled)")?.focus({preventScroll:!0});const p=x=>{x.target instanceof Node&&!m.current?.contains(x.target)&&!g.current?.contains(x.target)&&d(!1)};return document.addEventListener("pointerdown",p),()=>document.removeEventListener("pointerdown",p)},[l]),e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[r,e.jsxs("button",{ref:m,type:"button","aria-haspopup":"menu","aria-expanded":l,"aria-controls":l?c:void 0,onClick:()=>d(p=>!p),onKeyDown:p=>{(p.key==="ArrowDown"||p.key==="ArrowUp")&&(p.preventDefault(),d(!0))},className:`ml-auto inline-flex h-8 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md px-2 text-[11px] font-medium transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${l?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[e.jsx(No,{size:14}),s("sidebar.moreActions")]})]}),typeof document<"u"&&Rr.createPortal(e.jsx("div",{ref:g,id:c,hidden:!l,role:"menu","data-sidebar-gesture-ignore":!0,"aria-label":s("sidebar.moreActions"),className:"fixed z-menu-panel overflow-y-auto overscroll-contain rounded-lg border border-border/30 bg-surface p-1 shadow-[0_8px_24px_var(--app-shadow-soft)]",onKeyDown:p=>{if(!p.currentTarget.contains(p.target))return;const x=[...p.currentTarget.querySelectorAll("button:not(:disabled)")],h=x.indexOf(document.activeElement);let b;if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),f();return}if(p.key==="Tab"){f();return}if(p.key==="ArrowDown")b=(h+1)%x.length;else if(p.key==="ArrowUp")b=(h-1+x.length)%x.length;else if(p.key==="Home")b=0;else if(p.key==="End")b=x.length-1;else return;p.preventDefault(),x[b]?.focus({preventScroll:!0})},children:n(f)}),document.body)]})}const Vi="a[href],button,input,select,textarea,[tabindex],[contenteditable],iframe,summary,audio[controls],video[controls]",ds=a.memo(function({active:n,mounted:s=!0,fallback:l=null,children:d}){const c=a.useRef(null);return a.useLayoutEffect(()=>{const m=c.current;if(!m||n)return;const g=new Map,f=h=>{g.has(h)||(g.set(h,h.inert),h.inert=!0)},p=h=>{h instanceof HTMLElement&&h.matches(Vi)&&f(h),h.querySelectorAll(Vi).forEach(f)};p(m);const x=new MutationObserver(h=>{for(const b of h)b.type==="attributes"?b.target instanceof HTMLElement&&b.target.matches(Vi)&&f(b.target):b.addedNodes.forEach(E=>{E instanceof Element&&p(E)})});return x.observe(m,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex","href","contenteditable","controls"]}),()=>{x.disconnect();for(const[h,b]of g)h.inert=b}},[n,s]),e.jsx("div",{ref:c,className:"absolute inset-0 min-h-0 overflow-hidden bg-surface text-foreground",style:n?void 0:{clipPath:"inset(100%)"},"aria-hidden":!n,children:s?typeof d=="function"?d():d:l})},(r,n)=>!r.active&&!n.active&&r.mounted===n.mounted);async function gg(r){let n;try{await Promise.race([r(),new Promise(s=>{n=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(n)}}function bg({active:r,rootPath:n,loading:s,delay:l,lastStartedRoot:d,load:c}){a.useEffect(()=>{if(!r||!n||s||d.current===n)return;const m=window.setTimeout(()=>{d.current=n,c(n)},l);return()=>window.clearTimeout(m)},[r,n,s,l,d,c])}async function xg(r){if(r.kind==="mermaid"){await Od(new Blob([r.svg],{type:"image/svg+xml"}),"mermaid.svg");return}const n=new URL(r.src,window.location.href);if(n.origin===window.location.origin&&n.pathname==="/api/terminal/fs/blob"){const c=n.searchParams.get("path");if(!c)throw new Error("Missing image path");await qu(c);return}const s=await fetch(r.src);if(!s.ok)throw new Error(`HTTP ${s.status}`);const l=await s.blob(),d=decodeURIComponent(n.pathname.split("/").pop()||"")||`image.${{"image/svg+xml":"svg","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif"}[l.type]||"png"}`;await Od(l,d)}let co=null,fu=!1;function vg(){return co||(co=Dn(()=>import("./mermaid.core-Dy-VIGNi.js").then(r=>r.bl),__vite__mapDeps([0,1,2,3,4,5,6])).then(r=>r.default??r).catch(r=>{throw co=null,r})),co}function yg(r){fu||(r.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),fu=!0)}function wg({rootPath:r,paths:n,disabled:s,onChange:l}){const{t:d}=mt(),[c,m]=a.useState(""),[g,f]=a.useState(0),[p,x]=a.useState(null),[h,b]=a.useState(!1),[E,S]=a.useState(!1),L=`${r.replace(/[\\/]+$/,"")}/${c}`;a.useEffect(()=>{const N=new AbortController;return x(null),b(!1),Vu(L,N.signal,!0,"pick_git_ignore_exception").then(A=>{N.signal.aborted||x({directory:c,entries:A.entries,truncated:!!A.truncated})}).catch(()=>{N.signal.aborted||b(!0)}),()=>N.abort()},[L,c,g]);const D=N=>{x(null),b(!1),m(N)},F=p?.directory===c,$=N=>{if(N.length>200){S(!0);return}S(!1),l(N)};return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/30 bg-surface-2",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/20 p-2",children:[e.jsx("button",{type:"button",disabled:s||!c,onClick:()=>D(c.slice(0,Math.max(0,c.lastIndexOf("/")))),"aria-label":d("rightSidebar.parentFolder"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-30",children:e.jsx(Il,{size:14})}),e.jsx("button",{type:"button",disabled:s||!c,onClick:()=>D(""),"aria-label":d("rightSidebar.backToProjectRoot"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-30",children:e.jsx(hl,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:L,children:c||"./"})]}),e.jsxs("div",{className:"h-56 overflow-y-auto overscroll-contain p-1",role:"group","aria-label":d("rightSidebar.gitIgnoreExceptionsPaths"),"aria-busy":!F&&!h,children:[h?e.jsxs("div",{className:"flex flex-col items-center gap-2 p-4 text-center text-xs",children:[e.jsx("p",{role:"alert",className:"text-destructive",children:d("rightSidebar.gitIgnoreExceptionsLoadFailed")}),e.jsx("button",{type:"button",disabled:s,onClick:()=>{b(!1),f(N=>N+1)},className:"rounded-md px-3 py-2 text-primary hover:bg-surface-elevated disabled:opacity-40",children:d("common.retry")})]}):F?p.entries.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-muted-foreground",children:d("rightSidebar.gitIgnoreExceptionsEmptyDirectory")}):p.entries.map(N=>{const A=c?`${c}/${N.name}`:N.name,B=A+(N.type==="directory"?"/":""),q=n.includes(B)||n.includes(A),j=n.some(_=>_.endsWith("/")&&A.startsWith(_)),o=N.type==="directory"?hl:xp;return e.jsxs("div",{className:"flex items-center gap-1 rounded-md hover:bg-surface-elevated",children:[e.jsxs("label",{className:"flex min-h-10 min-w-0 flex-1 cursor-pointer items-center gap-2 px-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:q||j,disabled:s||j,onChange:()=>$(q?n.filter(_=>_!==B&&_!==A):[...n,B]),className:"h-4 w-4 shrink-0 accent-[var(--primary)] disabled:opacity-40"}),e.jsx(o,{size:14,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",title:N.name,children:N.name})]}),N.type==="directory"&&e.jsx("button",{type:"button",disabled:s,onClick:()=>D(A),"aria-label":d("rightSidebar.gitIgnoreExceptionsOpenDirectory",{name:N.name}),className:"inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface hover:text-foreground disabled:opacity-40",children:e.jsx(hs,{size:15})})]},N.name)}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(ft,{size:18})}),F&&p.truncated&&e.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:d("rightSidebar.gitIgnoreExceptionsTruncated")})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsx("span",{className:"font-medium",children:d("rightSidebar.gitIgnoreExceptionsSelected",{count:n.length})}),e.jsx("button",{type:"button",disabled:s||n.length===0,onClick:()=>$([]),className:"rounded-md px-2 py-1 text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:d("rightSidebar.gitIgnoreExceptionsClear")})]}),n.length>0&&e.jsx("ul",{className:"max-h-24 overflow-y-auto overscroll-contain",children:n.map(N=>e.jsxs("li",{className:"flex items-center gap-2 rounded-md pl-2 text-xs hover:bg-surface-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",title:N,children:N}),e.jsx("button",{type:"button",disabled:s,onClick:()=>$(n.filter(A=>A!==N)),"aria-label":d("rightSidebar.gitIgnoreExceptionsRemove",{path:N}),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-elevated hover:text-foreground disabled:opacity-40",children:e.jsx(Lt,{size:13})})]},N))}),E&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:d("rightSidebar.gitIgnoreExceptionsInvalid")})]})}function kg({rootPath:r,disabled:n,pressed:s,saving:l,onToggle:d}){const{t:c}=mt(),m=a.useId(),g=a.useRef(null),f=a.useRef(null),p=a.useRef(null),x=a.useRef(null),h=a.useRef(!1),[b,E]=a.useState(!1),[S,L]=a.useState([]),[D,F]=a.useState(!1),[$,N]=a.useState(null),A=V(I=>I.setGitIgnoreExceptions),B=()=>{p.current!==null&&clearTimeout(p.current),p.current=null,x.current=null},q=()=>{B(),!(n||D||!r)&&(L([...V.getState().gitIgnoreExceptions[r]??[]]),N(null),E(!0))},j=()=>{D||E(!1)},o=I=>{B(),h.current=!1,!(I.button!==0||!I.isPrimary||n)&&(I.currentTarget.setPointerCapture(I.pointerId),x.current={x:I.clientX,y:I.clientY},p.current=setTimeout(()=>{h.current=!0,q()},450))};a.useEffect(()=>(E(!1),B(),B),[r]),a.useEffect(()=>{if(b)return f.current?.focus(),()=>g.current?.focus()},[b]);const _=c(s?"rightSidebar.showGitIgnoredFiles":"rightSidebar.hideGitIgnoredFiles");return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:g,type:"button",disabled:n||D,"aria-pressed":s,"aria-label":_,"aria-description":c("rightSidebar.gitIgnoreConfigureHint"),title:`${_} · ${c("rightSidebar.gitIgnoreConfigureHint")}`,onClick:I=>{if(h.current&&I.detail!==0){h.current=!1,I.preventDefault();return}d()},onContextMenu:I=>{I.preventDefault(),h.current=!0,b||q()},onPointerDown:o,onPointerMove:I=>{const Y=x.current;Y&&Math.hypot(I.clientX-Y.x,I.clientY-Y.y)>10&&B()},onPointerUp:B,onPointerCancel:B,onLostPointerCapture:B,className:`inline-flex h-7 w-7 shrink-0 select-none items-center justify-center rounded-md transition active:scale-95 disabled:cursor-not-allowed disabled:opacity-35 [-webkit-touch-callout:none] ${s?"bg-surface-2 text-primary hover:bg-surface-elevated":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:l?e.jsx(ft,{size:14}):e.jsx(Zp,{size:14})}),b&&Rr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop flex items-center justify-center bg-[var(--app-backdrop)] p-3 backdrop-blur-sm",onClick:j,children:e.jsxs("form",{ref:f,role:"dialog",tabIndex:-1,"aria-modal":"true","aria-labelledby":`${m}-title`,"aria-describedby":`${m}-hint`,className:"relative z-modal-panel flex max-h-[80dvh] w-full max-w-lg flex-col gap-3 overflow-y-auto rounded-xl border border-border/20 bg-surface p-4 text-foreground shadow-2xl",onClick:I=>I.stopPropagation(),onKeyDown:I=>{if(I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),j()),I.key==="Tab"){const Y=Array.from(f.current?.querySelectorAll("button:not(:disabled), input:not(:disabled)")??[]);if(!Y.length){I.preventDefault(),f.current?.focus();return}const U=Y[0],O=Y[Y.length-1];I.shiftKey&&document.activeElement===U&&(I.preventDefault(),O?.focus()),document.activeElement===f.current?(I.preventDefault(),(I.shiftKey?O:U)?.focus()):!I.shiftKey&&document.activeElement===O&&(I.preventDefault(),U?.focus())}},onSubmit:I=>{if(I.preventDefault(),!(!r||D)){if(S.length>200){N(c("rightSidebar.gitIgnoreExceptionsInvalid"));return}F(!0),N(null),A(r,S).then(()=>E(!1)).catch(()=>N(c("rightSidebar.gitIgnoreExceptionsSaveFailed"))).finally(()=>F(!1))}},children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h2",{id:`${m}-title`,className:"text-sm font-medium",children:c("rightSidebar.gitIgnoreExceptionsTitle")}),e.jsx("button",{type:"button",disabled:D,onClick:j,"aria-label":c("common.close"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:e.jsx(Lt,{size:16})})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:r??void 0,children:r}),e.jsx("p",{id:`${m}-hint`,className:"text-xs leading-relaxed text-muted-foreground",children:c("rightSidebar.gitIgnoreExceptionsHint")}),e.jsx("p",{className:"text-xs font-medium",children:c("rightSidebar.gitIgnoreExceptionsPaths")}),r&&e.jsx(wg,{rootPath:r,paths:S,onChange:L,disabled:D}),$&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:$}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",disabled:D,onClick:j,className:"rounded-lg px-3 py-2 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40",children:c("common.cancel")}),e.jsxs("button",{type:"submit",disabled:D,className:"inline-flex items-center gap-2 rounded-lg bg-primary px-3 py-2 text-xs font-medium text-primary-foreground disabled:opacity-50",children:[D&&e.jsx(ft,{size:13}),c("common.save")]})]})]})}),document.body)]})}function Sg(r,n,s){try{const l=r instanceof HTMLImageElement?r.naturalWidth:r.width,d=r instanceof HTMLImageElement?r.naturalHeight:r.height;if(!l||!d)return Promise.resolve(null);const c=r instanceof HTMLImageElement?1400/Math.max(l,d):Math.min(1,1400/Math.max(l,d)),m=document.createElement("canvas");m.width=Math.max(1,Math.round(l*c)),m.height=Math.max(1,Math.round(d*c));const g=m.getContext("2d");if(!g)return Promise.resolve(null);const f=getComputedStyle(document.documentElement);if(g.fillStyle=f.getPropertyValue("--surface").trim()||"white",g.fillRect(0,0,m.width,m.height),g.drawImage(r,0,0,m.width,m.height),s){const p=Math.max(10,Math.min(16,m.width/35));g.font=`${p}px sans-serif`;const x=[];let h="";for(const b of s.split(" "))h&&g.measureText(`${h} ${b}`).width>m.width-20?(x.push(h),h=b):h=h?`${h} ${b}`:b;h&&x.push(h),g.fillStyle=f.getPropertyValue("--surface").trim()||"white",g.fillRect(0,0,m.width,x.length*(p+4)+12),g.fillStyle=f.getPropertyValue("--foreground").trim()||"black",x.forEach((b,E)=>g.fillText(b,10,8+p+E*(p+4)))}if(n){const p=n.xPercent*m.width/100,x=n.yPercent*m.height/100,h=Math.max(4,Math.min(12,Math.min(m.width,m.height)*.015)),b=h*1.6;g.strokeStyle=f.getPropertyValue("--primary").trim()||"black",g.lineWidth=Math.max(1,h/3),g.beginPath(),g.arc(p,x,h,0,Math.PI*2),g.stroke(),g.beginPath(),g.moveTo(p-b,x),g.lineTo(p+b,x),g.moveTo(p,x-b),g.lineTo(p,x+b),g.stroke()}return new Promise(p=>m.toBlob(p,"image/png"))}catch{return Promise.resolve(null)}}function jg(r,n,s,l){return[r.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
3
3
  `)}function $0(r,n,s){const l=n*Math.PI/360,d=Math.min(l,Math.atan(Math.tan(l)*Math.max(s,.05)));return Math.max(r,1e-6)/Math.sin(d)*1.15}async function Rg(r,n,s,l){if(!s?.snapshot)return l.isCurrent()?await l.insert(r,n):!1;const d=new Date().toISOString(),c=new AbortController;let m,g;try{g=await Promise.race([(async()=>{const f=await s.snapshot;if(!(!f||c.signal.aborted||!l.isCurrent()))return l.upload(new File([f],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),c.signal)})(),new Promise(f=>{m=setTimeout(()=>{c.abort(),f(void 0)},3e3)})])}catch{}finally{clearTimeout(m),c.abort()}return l.isCurrent()?await l.insert(g?jg(r,"",d,g):r,n):!1}function Ng(r,n){return r===n||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function hu(r,n){return`${r??""}\0${n}`}function Cg(r,n,s){if(!r||r.length===0||!s)return{explained:0,stale:0};const l=hu(n,s);let d=0,c=0;for(const m of r){const g=[m.filePath,m.newPath,m.oldPath].filter(p=>typeof p=="string"&&p.length>0);(g.some(p=>hu(m.repoRoot,p)===l)||g.some(p=>Ng(p,s)))&&(d+=1)}return{explained:d,stale:c}}function Eg({status:r}){if(!r)return null;const n=r.stale>0&&r.explained===0;if(!(r.explained>0||r.stale>0))return null;const l=n?"AI audit explanation is stale":"AI audit explanation available";return e.jsx("span",{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full ${n?"bg-[color:var(--warning)]/15 text-[color:var(--warning)]":"bg-accent/10 text-accent"}`,title:l,"aria-label":l,children:n?e.jsx(Wp,{size:10}):e.jsx(da,{size:10})})}function yl({changeStatus:r,auditStatus:n,renderChangeBadge:s}){return e.jsxs("span",{className:"inline-flex items-center gap-1",children:[s(r),e.jsx(Eg,{status:n})]})}const gf="termdock:right-sidebar:diff-change-list-mode:v1";function Mg(r){return r==="list"||r==="tree"}function $g(){return gt(gf,Mg)??"tree"}function Pg(r){for(const n of r){const s=n.hunk;if(s.oldPath&&s.newPath&&s.oldPath!==s.newPath)return"renamed";if(s.oldPath===null&&s.newPath)return"added";if(s.oldPath&&s.newPath===null)return"deleted"}return"modified"}function Ag(r){const n=new Map;for(const l of r){const d=n.get(l.hunk.filePath)??{key:l.hunk.filePath,filePath:l.hunk.filePath,items:[],additions:0,deletions:0,explained:0,stale:0,changeType:"modified"};d.items.push(l),d.additions+=l.hunk.additions,d.deletions+=l.hunk.deletions,l.current&&(d.explained+=1),l.stale&&(d.stale+=1),n.set(l.hunk.filePath,d)}const s=Array.from(n.values()).sort((l,d)=>l.filePath.localeCompare(d.filePath));for(const l of s)l.changeType=Pg(l.items);return s}function Lg(r){const n=r.filePath.split("/").pop()??r.filePath;return{key:r.key,path:r.filePath,displayName:n,displayDir:r.filePath.includes("/")?r.filePath.slice(0,-n.length-1):"",status:r.changeType,title:r.filePath}}function Tg(r,n){const s=r.filter(c=>c.trim().length>0);if(s.length<=1)return s[0]??"";const l=[],d=new Set;for(const[c,m]of s.entries()){const g=m.split(`
4
4
  `),f=g.findIndex(h=>h.startsWith("@@ "));if(f<0){l.push(...g);continue}c===0&&l.push(...g.slice(0,f));const p=n[c];let x=f;for(;x>=0&&x<g.length;){const h=g.findIndex((F,$)=>$>x&&F.startsWith("@@ ")),b=h>=0?h:g.length,E=g.slice(x,b),S=E[0]??"",L=p?S===p:!0,D=S||p||E.join(`
5
5
  `);L&&!d.has(D)&&(l.push(...E),d.add(D)),x=h}}return l.join(`
@@ -1635,7 +1635,7 @@ function installPreviewRuntime(capability, base, externalOrigins, shimUrl) {
1635
1635
  `,ho="/api/terminal/fs/preview/",Cb=8*1024*1024,Eb=32*1024*1024,Mb=128,$b="data:,";function Pt(r){throw new Error(r)}function Pb(r){return JSON.stringify(r).replace(/</g,"\\u003c")}async function yu(r,n,s){let l="",d=0;for(const c of r.matchAll(n))l+=r.slice(d,c.index)+await s(c),d=c.index+c[0].length;return l+r.slice(d)}async function kf(r,n){const s=n.origin??location.origin,l=new URL(r,s);(l.origin!==s||!qs(l.pathname)?.startsWith(ho))&&Pt("预览地址不是有效的本地文件入口");const d=crypto.randomUUID(),c=`https://termdock-preview.invalid/${d}/`,m=[],g=z=>{!m.includes(z)&&m.length<20&&m.push(z)},f=new Set,p=[],x=new Set,h=new Map,b=new Map;let E=0,S=!1;const L=new Set,D=()=>{S=!0;for(const z of[...L])z();f.clear(),p.length=0};async function F(z){z.ok||Pt(`预览资源读取失败(${z.status})`);const Z=z.body?.getReader(),P=[];let W=0;try{if(Z)for(;;){const pe=await Z.read();if(pe.done)break;W+=pe.value.byteLength,E+=pe.value.byteLength,(W>Cb||E>Eb)&&Pt("预览资源超出大小限制"),P.push(pe.value)}}catch(pe){throw await Z?.cancel().catch(()=>{}),pe}finally{Z?.releaseLock()}const J=new Uint8Array(W);let oe=0;for(const pe of P)J.set(pe,oe),oe+=pe.length;return{bytes:J,type:z.headers.get("content-type")??"application/octet-stream",status:z.status}}let $=l,N;for(let z=0;z<4;z++){const Z=await n.fetch($.pathname+$.search,{signal:n.signal,redirect:"manual"});if(![301,302,303,307,308].includes(Z.status)){N=Z;break}const P=Z.headers.get("location");await Z.body?.cancel(),P||Pt("预览重定向缺少目标");const W=new URL(P,$);(W.origin!==s||!qs(W.pathname)?.startsWith(ho))&&Pt("预览重定向越出文件范围"),$=W}N||Pt("预览重定向次数过多");const A=qs($.pathname),B=A.slice(ho.length).split("/");/^[a-f0-9]{32}$/.test(B[0])||Pt("服务未提供有效的预览资源授权");const q=qs(l.pathname).slice(ho.length).split("/");/^[a-f0-9]{32}$/.test(q[0])&&q.shift(),q.join("/").replace(/\/$/,"")!==B.slice(1).join("/").replace(/\/$/,"")&&Pt("预览重定向改变了文件范围");const j=A.endsWith("/")?A:A.slice(0,A.lastIndexOf("/")+1),o=new URL($.pathname.endsWith("/")?$.pathname:$.pathname.slice(0,$.pathname.lastIndexOf("/")+1),s);function _(z,Z){const P=new URL(z,Z);return P.origin!==s?null:(qs(P.pathname)?.startsWith(j)||Pt("已阻止预览访问目录之外的资源"),P)}function I(z){const Z=new URL(z,c);(Z.origin!==new URL(c).origin||!Z.pathname.startsWith(new URL(c).pathname))&&Pt("已阻止预览访问服务接口或目录之外的资源");const P=Z.pathname.slice(new URL(c).pathname.length)+Z.search;return _(P,o)??Pt("预览资源无效")}function Y(z){const Z=z.pathname+z.search,P=h.get(Z);if(P)return P;if(S||n.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(h.size>=Mb)return Promise.reject(new Error("预览资源数量超出限制"));const W=n.fetch(Z,{signal:n.signal,redirect:"manual"}).then(F);return h.set(Z,W),W}function U(z,Z){S&&Pt("预览已关闭");const P=`termdock-resource-${d}-${p.length}`;return p.push({token:P,data:z,type:Z}),f.add(P),P}async function O(z,Z,P,W=new Set){if(!z||z.startsWith("#")||/^data:(?:image|font)\//i.test(z)&&P==="resource")return z;try{const J=_(z,Z);if(!J){const Me=new URL(z,Z);return(Me.protocol!=="https:"||Me.username||Me.password||Me.origin===new URL(c).origin)&&Pt("已阻止不安全的外部资源"),x.add(Me.origin),Me.href}const oe=`${P}:${J.href}`;(W.has(oe)||W.size>=8)&&Pt("预览资源存在循环或过深引用");const pe=b.get(oe);if(pe)return pe;const Se=new Set(W);Se.add(oe);const we=(async()=>{const Me=await Y(J);return P==="css"?U(await R(new TextDecoder().decode(Me.bytes),J,Se),"text/css"):P==="script"?U(Me.bytes,"text/javascript"):U(Me.bytes,Me.type)})();return b.set(oe,we),await we}catch(J){return g(J instanceof Error?J.message:"部分预览资源未能加载"),$b}}async function R(z,Z,P){return z=await yu(z,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async W=>`@import url("${await O(W[1],Z,"css",P)}")${W[2]};`),yu(z,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async W=>{const J=(W[1]??W[2]??W[3]).trim();return f.has(J)?W[0]:`url("${await O(J,Z,"resource",P)}")`})}try{const z=await F(N),Z=U(Rb,"text/javascript"),P=new DOMParser().parseFromString(new TextDecoder().decode(z.bytes),"text/html");P.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(Q=>Q.remove());for(const Q of P.querySelectorAll("*")){if(Q.removeAttribute("ping"),Q.removeAttribute("srcdoc"),Q.hasAttribute("style")&&Q.setAttribute("style",await R(Q.getAttribute("style"),$,new Set)),Q.tagName==="STYLE"&&(Q.textContent=await R(Q.textContent??"",$,new Set)),Q.tagName==="A"||Q.tagName==="AREA"){const be=Q.getAttribute("href");try{if(be&&!be.startsWith("#")){const ue=_(be,$);if(ue)Q.setAttribute("href",new URL(ue.pathname.slice(o.pathname.length)+ue.search+ue.hash,c).href);else{const Be=new URL(be,$);if(Be.protocol!=="https:"){Q.removeAttribute("href");continue}x.add(Be.origin),Q.setAttribute("href",Be.href)}}}catch(ue){Q.removeAttribute("href"),g(ue instanceof Error?ue.message:"预览链接无法加载")}}for(const be of["data","manifest"])Q.removeAttribute(be);if(Q.tagName==="SCRIPT"&&Q.getAttribute("type")==="module"){Q.setAttribute("type","module-shim");const be=Q.getAttribute("src");if(be){const ue=_(be,$);if(ue)Q.setAttribute("src",new URL(ue.pathname.slice(o.pathname.length)+ue.search,c).href);else{const Be=new URL(be,$);if(Be.protocol!=="https:"){Q.remove();continue}x.add(Be.origin),Q.setAttribute("src",Be.href)}}continue}if(Q.tagName==="SCRIPT"&&Q.getAttribute("type")==="importmap"){Q.setAttribute("type","importmap-shim");continue}if(Q.tagName==="LINK"){const be=(Q.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(be)){Q.remove();continue}const ue=Q.getAttribute("href");ue&&Q.setAttribute("href",await O(ue,$,be==="stylesheet"?"css":"resource"))}if(Q.hasAttribute("src")&&Q.setAttribute("src",await O(Q.getAttribute("src"),$,Q.tagName==="SCRIPT"?"script":"resource")),Q.hasAttribute("poster")&&Q.setAttribute("poster",await O(Q.getAttribute("poster"),$,"resource")),Q.hasAttribute("srcset")){const be=Q.getAttribute("srcset");/data:/i.test(be)?(Q.removeAttribute("srcset"),g("混合内嵌图片候选暂不支持安全预览")):Q.setAttribute("srcset",(await Promise.all(be.split(",").map(async ue=>{const[Be,...Oe]=ue.trim().split(/\s+/);return`${await O(Be,$,"resource")} ${Oe.join(" ")}`}))).join(", "))}Q.setAttribute("referrerpolicy","no-referrer"),Q.removeAttribute("integrity"),Q.removeAttribute("crossorigin")}const W=[...x].join(" "),J=P.createElement("meta");J.httpEquiv="Content-Security-Policy",J.content=`default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${W}; style-src 'unsafe-inline' blob: ${W}; img-src blob: data: ${W}; font-src blob: data: ${W}; media-src blob: data: ${W}; connect-src blob: ${W} ${[...x].map(Q=>Q.replace(/^https:/,"wss:")).join(" ")}; worker-src blob:; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const oe=P.createElement("base");oe.href=c;const pe=P.createElement("meta");pe.name="referrer",pe.content="no-referrer";const Se=P.createElement("script");Se.textContent=Nb+`
1636
1636
  installPreviewRuntime(`+[d,c,[...x],Z].map(Pb).join(",")+");";const we=P.createElement("script");we.src=Z,P.head.prepend(J,pe,oe,Se,we);const Me=`<!doctype html>
1637
1637
  `+P.documentElement.outerHTML;return{html:Me,shellUrl:`/preview-shell.html#${d}`,errors:m,attach(Q,be){const ue=new Set,Be=G=>{if(G.source!==Q.contentWindow||G.data?.capability!==d)return;if(G.data.type==="preview-ready"){Q.contentWindow?.postMessage({type:"preview-init",capability:d,html:Me,resources:p},"*");return}if(G.data.type==="preview-error"){be("部分动态内容被安全预览限制");return}if(G.data.type==="preview-navigate"){(async()=>{const ye=I(String(G.data.url)),Ue=await kf(ye.pathname+ye.search,n);if(S){Ue.dispose();return}const Ye=Ue.attach(Q,be);L.add(()=>{Ye(),Ue.dispose()}),Q.src=Ue.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(ye=>be(ye instanceof Error?ye.message:"无法打开预览页面"));return}if(G.data.type==="preview-external"){try{const ye=new URL(String(G.data.url));ye.protocol==="https:"&&x.has(ye.origin)&&window.open(ye.href,"_blank","noopener,noreferrer")}catch{}return}if(G.data.type!=="preview-fetch"||G.ports.length!==1)return;const je=G.ports[0];if(ue.size>=8||!["GET","HEAD"].includes(G.data.method)){je.postMessage({error:"预览仅允许读取已授权目录资源"}),je.close();return}ue.add(je),(async()=>{const ye=I(String(G.data.url)),Ue=await Y(ye);if(!ue.has(je)||S)return;const Ye=G.data.method==="HEAD"?new Uint8Array:Ue.bytes.slice();je.postMessage({status:Ue.status,headers:{"content-type":Ue.type},data:Ye.buffer},[Ye.buffer])})().catch(()=>{je.postMessage({error:"预览资源不在授权范围或无法加载"}),be("部分动态资源不可用或超出预览目录")}).finally(()=>{ue.delete(je),je.close()})};window.addEventListener("message",Be);const Oe=()=>{window.removeEventListener("message",Be);for(const G of ue)G.close();ue.clear(),L.delete(Oe)};return L.add(Oe),Oe},dispose:D}}catch(z){throw D(),z}}const Ab=a.forwardRef(function({src:n,title:s,exitFullscreenLabel:l,onFullscreenChange:d},c){const m=a.useRef(null),[g,f]=a.useState(null),[p,x]=a.useState(),[h,b]=a.useState("");a.useEffect(()=>{const A=new AbortController;let B;return x(void 0),b(""),(async()=>{const q=await Gm();if(B=await kf(n,{fetch:(j,o)=>q.fetch(j,o),signal:A.signal}),A.signal.aborted){B.dispose();return}x(B),B.errors.length&&b(B.errors.join(";"))})().catch(q=>{A.signal.aborted||b(q instanceof Error?q.message:"安全预览加载失败")}),()=>{A.abort(),B?.dispose()}},[n]),a.useEffect(()=>{if(!(!p||!g))return p.attach(g,b)},[p,g]);const[E,S]=a.useState(!1),[L,D]=a.useState(!1),F=E||L;a.useEffect(()=>{d?.(F)},[F,d]),a.useEffect(()=>{const A=()=>{S(document.fullscreenElement===m.current)};return document.addEventListener("fullscreenchange",A),()=>document.removeEventListener("fullscreenchange",A)},[]),a.useEffect(()=>{if(!L)return;const A=B=>{B.key==="Escape"&&D(!1)};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[L]);const $=a.useCallback(async()=>{const A=m.current;if(A){if(L){D(!1);return}if(document.fullscreenElement===A){await document.exitFullscreen();return}if(A.requestFullscreen&&document.fullscreenEnabled!==!1)try{await A.requestFullscreen();return}catch{}D(!0)}},[L]);a.useImperativeHandle(c,()=>({toggleFullscreen:$}),[$]);const N=e.jsxs("div",{ref:m,"data-html-preview-frame":!0,className:F?"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:[F&&e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/15 bg-[var(--chrome-bg)] px-3",children:[e.jsx("span",{className:"min-w-0 truncate text-[12px] font-semibold",children:s}),e.jsx("button",{type:"button",onClick:()=>{$()},"aria-label":l,title:`${l} (Esc)`,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:e.jsx(cf,{size:15})})]}),h&&e.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:h}),!p&&!h&&e.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),e.jsx("iframe",{ref:f,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 L?Rr.createPortal(N,document.body):N}),Sf="termdock-file-search-match",Sl="termdock-file-search-current";function Lb(r,n,s){return!!(n&&r?.isConnected&&!s.defaultPrevented&&!r.closest('[inert], [aria-hidden="true"], [hidden]')&&s.target instanceof Node&&r.contains(s.target))}function Tb(r){const n=r.metaKey||r.ctrlKey,s=r.key.toLocaleLowerCase();return n&&s==="f"?"open":n&&s==="g"||r.key==="F3"?r.shiftKey?"previous":"next":r.key==="Escape"?"close":null}function Ib(r){return r.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function Db(r,n){const s=n.trim().toLocaleLowerCase();if(!s)return[];const l=[];let d="",c=null;const m=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);for(let x=m.nextNode();x;x=m.nextNode()){if(!(x instanceof Text)||!x.data)continue;const h=Ib(x);if(!h)continue;c&&c!==h&&(d+=`
1638
- `);const b=d.length;d+=x.data,l.push({node:x,start:b,end:d.length,group:h}),c=h}const g=d.toLocaleLowerCase(),f=[];let p=0;for(;p<=g.length-s.length;){const x=g.indexOf(s,p);if(x<0)break;const h=x+s.length,b=l.find(S=>S.start<=x&&S.end>x),E=l.find(S=>S.start<h&&S.end>=h);if(b&&E&&b.group===E.group){const S=document.createRange();S.setStart(b.node,x-b.start),S.setEnd(E.node,h-E.start),f.push(S)}p=x+Math.max(s.length,1)}return f}function jf(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}let Mo;function wu(r){return Mo===r}function mo(r){if(r&&Mo!==r)return;const n=jf();n?.delete(Sf),n?.delete(Sl),Mo=void 0}function Ji(r,n,s){const l=jf();if(!l||typeof Highlight>"u")return;Mo=s,l.set(Sf,new Highlight(...r));const d=r[n];d?l.set(Sl,new Highlight(d)):l.delete(Sl)}function ku(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function Fb(r){return Array.from(new Set(r.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function _b(r,n){const s=n.trim();return!s||s==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Bb(r,n){if(n===r)return".";const s=`${r.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function Rf(r,n,s){return n?r:Rr.createPortal(r,s)}const Dl="termdock:right-sidebar:file-tree-scroll:v1",Fl="termdock:right-sidebar:file-preview-reading-state:v1",ra="termdock:right-sidebar:file-tree-width:v1",Nf="termdock:right-sidebar:markdown-view-mode:v1",Cf="termdock:right-sidebar:diff-change-list-mode:v1",Ef="termdock:right-sidebar:diff-wrap:v1",Mf="termdock:diff-viewer:view-type:v1",$f="termdock:right-sidebar:file-search-mode:v1",Qi="termdock:right-sidebar:collapsed-git-repo-groups:v1",Su="termdock:right-sidebar:collapsed-diff-directories:v1",Zi="termdock:right-sidebar:branch-audit-module-open:v1",Pf="termdock:right-sidebar:branch-audit-module:v1",Ob=150,ju="termdock:right-sidebar:context-draft-enabled:v1",Ru="termdock:right-sidebar:context-draft-collapsed:v1",Nu="termdock:right-sidebar:context-draft-auto-collapse:v1",el="termdock:right-sidebar:context-draft-text:v1",Ub=300,Hb=20,zb=120,Wb=250,Gb=250,Kb=120,qb=700,tl=600,Vb=6e4;function Xs(r){return!!(r&&V.getState().nestedGitScanRoots[r])}const Cu=[2e3,5e3,15e3,3e4],Yb=320,Xb=500,Jb=20,Qb=12e3,jl=300,Eu=240,Zb=560,Af="border-r px-2 py-1.5 sm:px-3 sm:py-2",$o="min-w-full max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",Lf=`${Af} border-b border-border/15 font-semibold last:border-r-0`,Tf=`${Af} border-border/10 align-top text-muted-foreground last:border-r-0`,_l="termdock-file-preview-horizontal-scroll",Mu=a.lazy(()=>Dn(()=>import("./ModelPreview-B_VPlNYr.js"),__vite__mapDeps([7,1,2,3,4,5,8,9,10,11,12,13,14,15,16,17]))),ex=a.lazy(()=>Dn(()=>import("./ArchitecturePanel-BOq2FG6t.js"),__vite__mapDeps([18,1,2,3,4,5,8,9,10,11,12,15,16,6,14,13,17,19])).then(r=>({default:r.ArchitecturePanel}))),tx=a.lazy(()=>Dn(()=>import("./ComputerControlView-mR6vlp9k.js").then(r=>r.a),__vite__mapDeps([20,1,2,3,4,5,17,14,11,8,9,10,12]))),If=`${_l} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function Df(r,n,s){return r&&!n?"unified":s}const rx=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function nx(r){return r==="preview"||r==="source"}function sx(r){return r==="list"||r==="tree"||r==="ai"}function $u(){return gt(Nf,nx)??"preview"}function ax(){return gt(Cf,sx)??"tree"}function na(r){return typeof r=="boolean"}function ox(r){return typeof r=="string"}function ix(){return gt(Ef,na)??!0}function lx(r){return r==="unified"||r==="split"}function cx(){return gt(Mf,lx)??"unified"}function dx(r){return r==="name"||r==="content"||r==="regex"}function ux(){return gt($f,dx)??"name"}function Ff(r){return r.repositories??(r.context?.root?[{id:r.context.root,root:r.context.root,relativeRoot:".",name:kt(r.context.root)||r.context.root,depth:0,nested:!1,available:r.available,files:r.files,context:r.context,error:r.error}]:[])}function fx(r,n){if(!n)return null;const s=new Set((r.repoFilters??[]).map(l=>l.root));return s.has(n)?n:s.size>0?null:(r.repositories??[]).some(l=>l.root===n)?n:null}function Rl(r){return!r.activeGitRepoRoot&&(r.groupCount>1||r.label!==r.rootName)}function _f(...r){const n=new Set;for(const s of r)for(const l of s)n.add(l.root);return n}function Nl(r){return Array.isArray(r)&&r.every(n=>typeof n=="string")}function Pu(r){const n=gt(r,Nl);return n?new Set(n):new Set}function rl(r,n){At(r,[...n])}function hx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.filePath=="string"&&typeof n.hunkHeader=="string"&&typeof n.hunkIndex=="number"&&typeof n.fingerprint=="string"&&typeof n.additions=="number"&&typeof n.deletions=="number"&&typeof n.diff=="string"&&(n.oldPath===void 0||n.oldPath===null||typeof n.oldPath=="string")&&(n.newPath===void 0||n.newPath===null||typeof n.newPath=="string")&&(n.source===void 0||n.source==="committed"||n.source==="uncommitted"||n.source==="unknown")&&(n.commit===void 0||n.commit===null||typeof n.commit=="string")}function mx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.available=="boolean"&&(n.repoRoot===void 0||typeof n.repoRoot=="string")&&(n.workspaceRoot===void 0||typeof n.workspaceRoot=="string")&&(n.baseRef===void 0||typeof n.baseRef=="string")&&(n.baseBranch===void 0||typeof n.baseBranch=="string")&&(n.currentBranch===void 0||n.currentBranch===null||typeof n.currentBranch=="string")&&(n.headRef===void 0||n.headRef===null||typeof n.headRef=="string")&&(n.diffFingerprint===void 0||typeof n.diffFingerprint=="string")&&(n.stat===void 0||typeof n.stat=="string")&&(n.files===void 0||Nl(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(hx))&&(n.commits===void 0||Nl(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 px(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.key=="string"&&mx(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function gx(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(n=>{if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;return Array.isArray(s.selectedRepoRoots)&&s.selectedRepoRoots.every(l=>typeof l=="string")&&!!s.repoTargetBranches&&typeof s.repoTargetBranches=="object"&&!Array.isArray(s.repoTargetBranches)&&Object.values(s.repoTargetBranches).every(l=>typeof l=="string")&&(s.repoBaseBranches===void 0||!!s.repoBaseBranches&&typeof s.repoBaseBranches=="object"&&!Array.isArray(s.repoBaseBranches)&&Object.values(s.repoBaseBranches).every(l=>typeof l=="string"))&&(s.previewEntries===void 0||Array.isArray(s.previewEntries)&&s.previewEntries.every(px))&&(s.selectedPreviewKey===void 0||s.selectedPreviewKey===null||typeof s.selectedPreviewKey=="string")&&(s.selectedPreviewFileKey===void 0||s.selectedPreviewFileKey===null||typeof s.selectedPreviewFileKey=="string")&&(s.previewDetailOpen===void 0||typeof s.previewDetailOpen=="boolean")&&(s.previewScrollTops===void 0||!!s.previewScrollTops&&typeof s.previewScrollTops=="object"&&!Array.isArray(s.previewScrollTops)&&Object.values(s.previewScrollTops).every(l=>typeof l=="number"))&&(s.previewMobileSlideIndex===void 0||typeof s.previewMobileSlideIndex=="number")&&(s.repoIncludeUncommitted===void 0||!!s.repoIncludeUncommitted&&typeof s.repoIncludeUncommitted=="object"&&!Array.isArray(s.repoIncludeUncommitted)&&Object.values(s.repoIncludeUncommitted).every(l=>typeof l=="boolean"))&&(s.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function Au(){return gt(Pf,gx)??{}}function Lu(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function Tu(r){const n=r?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function Bf(r,n){const s=r?.trim(),l=n?.trim();return!s||!l?!1:s===l||Tu(s)===Tu(l)}function Iu(r){const n=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(l=>l&&!Bf(l,n))??""}function Cl(r,n){const s=Math.max(Eu,n-320),l=Math.min(Zb,s);return Math.min(l,Math.max(Eu,r))}function bx(r){return typeof r=="number"&&Number.isFinite(r)}function xx(r){return Cl(gt(ra,bx)??jl,r)}function Of(r){const n=r.split(/[\\/]/).pop()??r,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function Js(r){return rx.has(Of(r))}function Uf(r){const n=r.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function El(r){const n=r.trim();return/^#{1,6}\s+/.test(n)||Uf(r)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function Hf(r){const n=r.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const zf=a.createContext(null);function So(r){return r.trim().replace(/\s+/g," ").toLowerCase()}function Wf(r){return r.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function Gf(r){return r.replace(/\s+#+\s*$/,"").trim()}function Ml(r,n){const l=Wf(r).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",d=n.headingSlugCounts.get(l)??0;return n.headingSlugCounts.set(l,d+1),d===0?l:`${l}-${d}`}function Du(r){return Wf(r)||r.trim()}function Po(r){const n=r.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=Pl(n[2]);return s?{id:So(n[1]),definition:{href:s.href,title:s.title}}:null}function vx(r){const n=new Map;for(const s of r){const l=Po(s);l&&n.set(l.id,l.definition)}return n}function Kf(r){return r.trim().toLowerCase()}function qf(r){const n=r.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:Kf(n[1]),text:n[2]}:null}function yx(r){const n=new Map;let s=null;for(const l of r){const d=qf(l);if(d){s=d.id,n.set(d.id,{id:d.id,text:d.text,index:n.size+1});continue}if(s&&/^\s{4,}\S/.test(l)){const c=n.get(s);c&&(c.text=`${c.text} ${l.trim()}`);continue}l.trim()&&(s=null)}return n}function Vf(r){const n=new Set;let s=!1;return r.forEach((l,d)=>{if(qf(l)){n.add(d),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(d);return}l.trim()&&(s=!1)}),n}function wx(r){const n=[...r];let s=0;const l=r[0]?.trim();if(l==="---"||l==="+++"){for(n[0]="",s=1;s<r.length&&r[s].trim()!==l;)n[s]="",s+=1;s<r.length&&(n[s]="",s+=1)}for(;s<r.length;){const d=r[s].trim();if(d.startsWith("<!--")){if(n[s]="",!d.includes("-->")){for(s+=1;s<r.length&&!r[s].includes("-->");)n[s]="",s+=1;s<r.length&&(n[s]="")}s+=1;continue}s+=1}return n}function Yf(r){const n=r.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function oa(r){const n=r.split(/[?#]/,1)[0],s=n.startsWith("/"),l=[];for(const c of n.split("/"))if(!(!c||c===".")){if(c===".."){l.length>0&&l.pop();continue}l.push(c)}return`${s?"/":""}${l.join("/")}`||(s?"/":".")}function Bl(r,n,s){const l=r.trim();if(!l||/^(?:https?:|mailto:|javascript:|data:)/i.test(l)||/^[a-z][a-z0-9+.-]*:/i.test(l))return null;if(l.startsWith("#")){if(!n)return null;try{return{path:n,fragment:decodeURIComponent(l.slice(1))||null,directory:!1}}catch{return null}}const d=l.indexOf("#"),c=d>=0?l.slice(0,d):l,m=d>=0?l.slice(d+1):"",g=c.split("?",1)[0];if(!g)return null;let f,p=null;try{f=decodeURIComponent(g),p=m?decodeURIComponent(m):null}catch{return null}const x=s?oa(s):null;let h;if(f.startsWith("/")){const b=x&&(f===x||f.startsWith(`${x}/`));h=oa(x&&!b?`${x}/${f.slice(1)}`:f)}else{if(!n)return null;h=oa(`${Yf(n)}/${f}`)}return x&&h!==x&&!h.startsWith(`${x}/`)?null:{path:h,fragment:p,directory:/\/$/.test(g)}}function Ol(r,n,s,l,d){const c=r.trim();if(!c||/^(?:javascript|data):/i.test(c))return null;if(/^https?:\/\//i.test(c))return c;if(!l(c.split(/[?#]/,1)[0]))return null;let m;if(c.startsWith("/")){const g=s&&(c===s||c.startsWith(`${s}/`));m=oa(s&&!g?`${s}/${c.slice(1)}`:c)}else{if(!n)return null;m=oa(`${Yf(n)}/${c}`)}return d(m)}function kx(r,n,s){return Ol(r,n,s,Tl,l=>`/api/terminal/fs/blob?path=${encodeURIComponent(l)}`)}function Sx(r,n,s){return Ol(r,n,s,Xu,Ju)}const $l=128,jx=360,nl=480;function ma(r){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(r))}catch{return!1}}function Xf(r,n,s,l,d=0){if(!n||!s)return null;let c,m;return d>0?(c=l>0?Math.min(d,l):d,m=s*c/n):ma(r)?(m=Math.min(Math.max(s,$l),jx),c=n*m/s):(c=n,m=s),l>0&&c>l&&(m=m*l/c,c=l),m>nl&&(c=c*nl/m,m=nl),{width:Math.max(1,Math.round(c)),height:Math.max(1,Math.round(m))}}function Rx(r){if(!r.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(r.slice(r.indexOf("?"))).get("path")}catch{return null}}function Jf(r){const n=Rx(r),s=V(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${r}&v=${s}`:r}function Nx({src:r,alt:n,title:s,requestedWidthPx:l}){const d=ma(r),c=Jf(r),m=_o(c),g=a.useRef(null),[f,p]=a.useState(!1),[x,h]=a.useState(0),[b,E]=a.useState({status:"loading"}),[S,L]=a.useState(null);a.useLayoutEffect(()=>{const $=g.current;let N=$?.parentElement?.parentElement??$?.parentElement;for(;N;){const j=window.getComputedStyle(N).display;if(j!=="inline"&&j!=="contents")break;N=N.parentElement}if(!N)return;const A=N,B=()=>{const j=window.getComputedStyle(A),o=(parseFloat(j.paddingLeft)||0)+(parseFloat(j.paddingRight)||0);h(Math.max(0,A.clientWidth-o))};if(B(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(B);return q.observe(A),()=>q.disconnect()},[]),a.useEffect(()=>{if(f)return;const $=g.current;if(!$||typeof IntersectionObserver>"u"){p(!0);return}const N=new IntersectionObserver(A=>{A.some(B=>B.isIntersecting)&&(p(!0),N.disconnect())},{rootMargin:"400px"});return N.observe($),()=>N.disconnect()},[f]),a.useEffect(()=>{if(!f)return;const $=new AbortController;let N=null;E({status:"loading"});const A=window.setTimeout(()=>{$.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return Qu(c,{signal:$.signal}).then(async B=>{if(!B.ok)throw new Error(`HTTP ${B.status}`);const q=Number(B.headers.get("X-Image-Width"))||0,j=Number(B.headers.get("X-Image-Height"))||0;return{blob:await B.blob(),width:q,height:j}}).then(({blob:B,width:q,height:j})=>{$.signal.aborted||(N=URL.createObjectURL(B),q>0&&j>0&&L({width:q,height:j}),E({status:"ready",objectUrl:N}))}).catch(()=>{const B=$.signal.reason;$.signal.aborted&&!(B instanceof DOMException&&B.name==="TimeoutError")||E({status:"fallback"})}).finally(()=>{window.clearTimeout(A)}),()=>{window.clearTimeout(A),$.abort(),N&&URL.revokeObjectURL(N)}},[f,c]);const D=Xf(r,S?.width??0,S?.height??0,x,l??0),F=D??(l?{width:x>0?Math.min(l,x):l,height:Math.round(l*.75)}:{width:$l*2,height:$l});return e.jsx("div",{ref:g,className:"block max-w-full",style:D?{width:D.width,height:D.height}:void 0,children:b.status==="ready"?e.jsx("img",{src:b.objectUrl,alt:n,title:s,decoding:"async",className:`${d?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:D?{width:D.width,height:D.height}:void 0,onLoad:$=>{const N=$.currentTarget;N.naturalWidth>0&&N.naturalHeight>0&&(S?.width!==N.naturalWidth||S?.height!==N.naturalHeight)&&L({width:N.naturalWidth,height:N.naturalHeight})}}):b.status==="fallback"?e.jsx("img",{src:m,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:$=>{const N=$.currentTarget;N.naturalWidth>0&&N.naturalHeight>0&&(S?.width!==N.naturalWidth||S?.height!==N.naturalHeight)&&L({width:N.naturalWidth,height:N.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:F.width,height:F.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function ia(r,n,s,l,d,c){const m=kx(s,d.markdownFilePath,d.rootPath);if(!m)return c?.fallbackText??`![${n}](${s})`;const g=d.images.length;d.images.push({kind:"image",src:m,alt:n,title:l});const f=e.jsx(Nx,{src:m,alt:n,title:l,requestedWidthPx:c?.requestedWidthPx});return d.onImageOpen&&c?.interactive!==!1?e.jsx("button",{type:"button",className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2 text-left transition hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-ring/45",title:l||n||"Open image",onClick:p=>{p.stopPropagation(),d.onImageOpen?.(g)},children:f},r):e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:f},r)}function sl(r){let n=r,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function Fu(r){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(r)}function Pl(r){const n=r.trim(),s=n.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(s)return{href:s[1],title:s[2]??s[3]??s[4]};const l=n.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return l?{href:l[1],title:l[2]??l[3]??l[4]}:null}const Qf="",Cx=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function Ex(r){return r.replace(Cx,(n,s)=>`${Qf}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function _u(r){return r.replace(new RegExp(`${Qf}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function Mx(r){const n=r.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const Zf={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 po=null;function eh(){return po||(po=Dn(()=>import("./purify.es-4eNOHKSq.js"),[]).then(r=>r.default??r).catch(r=>{throw po=null,r})),po}function th({html:r}){const{t:n}=mt(),[s,l]=a.useState(null);return a.useEffect(()=>{let d=!1;return l(null),eh().then(c=>{d||l(c.sanitize(r,Zf))}).catch(()=>{d||l("")}),()=>{d=!0}},[r]),s===null?e.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:n("rightSidebar.renderingHtml")}):s?e.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:s}}):null}function $x({html:r}){const[n,s]=a.useState(null);return a.useEffect(()=>{let l=!1;return s(null),eh().then(d=>{l||s(d.sanitize(r,Zf))}).catch(()=>{l||s("")}),()=>{l=!0}},[r]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):r}function rh(r){const n=r.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!n)return null;const s=n[1].toLowerCase();return{tag:s,selfContained:new RegExp(`</${s}>`,"i").test(r)}}let go=null;function Px(){return go||(go=Promise.all([Dn(()=>import("./katex-DnlPpQZa.js"),[]),Dn(()=>Promise.resolve({}),__vite__mapDeps([21]))]).then(([r])=>r.default??r).catch(r=>{throw go=null,r})),go}function ua({tex:r,display:n=!1}){const[s,l]=a.useState(null),[d,c]=a.useState(!1);if(a.useEffect(()=>{let g=!1;return l(null),c(!1),Px().then(f=>{g||l(f.renderToString(r,{displayMode:n,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{g||c(!0)}),()=>{g=!0}},[n,r]),d)return e.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:n?`$$${r}$$`:`$${r}$`});if(!s)return e.jsx("span",{className:"text-muted-foreground/70",children:n?"Rendering formula...":r});const m=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:m,dangerouslySetInnerHTML:{__html:s}})}function Ul(r){const n=new Map;for(const s of r.matchAll(/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/gi))n.set(s[1].toLowerCase(),s[2]??s[3]??s[4]);return n}function Bu(r){const n=Ul(r),s=n.get("src")?.trim()??"",l=n.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i);return{src:s,alt:n.get("alt"),title:n.get("title"),widthPx:l?Number(l[1]):void 0}}function Ax(r){const n=r.indexOf(">"),s=n<0?r:r.slice(0,n+1),l=Ul(s),d=l.get("src")?.trim()??"",c=l.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i),m=s.replace(/=\s*(?:"[^"]*"|'[^']*')/g," "),g=n<0?"":r.slice(n+1).replace(/<\/video\s*>$/i,"").replace(/<[^>]*>/g,"").trim();return{src:d,fallbackText:g,widthPx:c?Number(c[1]):void 0,controls:/\bcontrols\b/i.test(m)}}function Lx({url:r,fallbackText:n,widthPx:s,hasControls:l}){const{t:d}=mt(),[c,m]=a.useState(!1),g=_o(r,()=>m(!0));return g?e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:c?e.jsx("span",{className:"block px-3 py-2 text-xs text-muted-foreground",children:n?.trim()||d("rightSidebar.videoUnsupported")}):e.jsx("video",{className:"block max-w-full",src:g,style:s?{width:`${s}px`}:void 0,controls:l,preload:"metadata",playsInline:!0,onError:()=>m(!0)})}):null}function Tx(r,n,s){if(/^<a\b[^>]*>\s*<\s*img\b[^>]*>\s*<\/a\s*>$/i.test(r)){const m=r.slice(0,r.indexOf(">")+1),g=Ul(m).get("href")?.trim()??"",f=r.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:p,alt:x,title:h,widthPx:b}=Bu(f);if(!p)return null;const E=Ol(p,s.markdownFilePath,s.rootPath,Tl,$=>$);if(!E)return null;const S=g?Bl(g,s.markdownFilePath,s.rootPath):null,D=!!!(S&&S.path===E)&&g?Hf(g):null,F=ia(n,x??"",p,h,s,{requestedWidthPx:b,interactive:D?!1:void 0});return D?e.jsx("a",{href:D,target:"_blank",rel:"noreferrer",children:F},n):F}if(/^<\s*img\b[^>]*>$/i.test(r)){const{src:m,alt:g,title:f,widthPx:p}=Bu(r);return m?ia(n,g??"",m,f,s,{fallbackText:r,requestedWidthPx:p}):null}if(/^<\s*video\b[^>]*>[\s\S]*?<\/video\s*>$/i.test(r)){const{src:m,fallbackText:g,widthPx:f,controls:p}=Ax(r);if(!m)return null;const x=Sx(m,s.markdownFilePath,s.rootPath);return x?e.jsx(Lx,{url:x,fallbackText:g,widthPx:f,hasControls:p},n):null}if(/^<br\s*\/?>$/i.test(r))return e.jsx("br",{},n);const l=r.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!l)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(r)?e.jsx($x,{html:r},n):null;const d=l[1].toLowerCase(),c=ht(l[2],`${n}-${d}`,!0,s);return d==="kbd"?e.jsx("kbd",{className:"rounded border border-border/30 bg-surface-2 px-1.5 py-0.5 font-mono text-[0.85em] text-foreground shadow-sm",children:c},n):d==="mark"?e.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:c},n):d==="sub"?e.jsx("sub",{children:c},n):e.jsx("sup",{children:c},n)}function ht(r,n,s=!0,l){return l.budget.nested(()=>Ix(r,n,s,l))}function Ix(r,n,s=!0,l){l.budget.validateInline(r);const d=Ex(r),c=[];let m=0;for(const{index:g,token:f}of pg(d,l.budget)){g>m&&c.push(_u(d.slice(m,g)));const p=`${n}-${g}`,x=f.startsWith("<")?Tx(f,p,l):null;if(x)c.push(x);else if(f.startsWith("\\(")&&f.endsWith("\\)"))c.push(e.jsx(ua,{tex:f.slice(2,-2)},p));else if(f.startsWith("$")&&f.endsWith("$"))c.push(e.jsx(ua,{tex:f.slice(1,-1)},p));else if(f.startsWith("`")){const h=f.match(/^`+/)?.[0].length??1;c.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:Mx(f.slice(h,-h))},p))}else if(f.startsWith("~~"))c.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:ht(f.slice(2,-2),`${p}-del`,s,l)},p));else if(f.startsWith("**")||f.startsWith("__"))c.push(e.jsx("strong",{className:"font-semibold text-foreground",children:ht(f.slice(2,-2),`${p}-strong`,s,l)},p));else if(f.startsWith("*")||f.startsWith("_"))c.push(e.jsx("em",{className:"italic",children:ht(f.slice(1,-1),`${p}-em`,s,l)},p));else if(f.startsWith("![")){const h=f.match(/^!\[([^\]]*)\]\((.*)\)$/),b=f.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),E=f.match(/^!\[([^\]]+)\]$/);if(h){const S=Pl(h[2]);c.push(S?ia(p,h[1],S.href,S.title,l):f)}else if(b){const S=b[2]||b[1],L=l.referenceDefinitions.get(So(S));c.push(L?ia(p,b[1],L.href,L.title,l):f)}else if(E){const S=l.referenceDefinitions.get(So(E[1]));c.push(S?ia(p,E[1],S.href,S.title,l):f)}else c.push(f)}else if(f.startsWith("[^")){const h=Kf(f.slice(2,-1)),b=l.footnoteDefinitions.get(h);c.push(b?e.jsx("sup",{id:`fnref-${b.id}`,title:b.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:e.jsx("a",{href:`#fn-${b.id}`,className:"text-primary no-underline",children:b.index})},p):f)}else if(f.startsWith("<http")){const h=f.slice(1,-1);c.push(e.jsx("a",{href:h,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p))}else if(f.startsWith("<")&&f.endsWith(">")&&Fu(f.slice(1,-1))){const h=f.slice(1,-1);c.push(e.jsx("a",{href:`mailto:${h}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p))}else if(Fu(sl(f).linkText)){const{linkText:h,suffix:b}=sl(f);c.push(e.jsx("a",{href:`mailto:${h}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p)),b&&c.push(b)}else if(f.startsWith("http")||f.startsWith("www.")){const{linkText:h,suffix:b}=sl(f),E=h.startsWith("www.")?`https://${h}`:h;c.push(e.jsx("a",{href:E,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p)),b&&c.push(b)}else{const h=f.match(/^\[([^\]]+)\]\((.*)\)$/),b=f.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),E=f.match(/^\[([^\]]+)\]$/),S=b?b[2]||b[1]:E?.[1]??null,L=S?l.referenceDefinitions.get(So(S)):null,D=h?Pl(h[2]):null,F=D?.href??L?.href??null,$=F?Hf(F):null,N=h?.[1]??b?.[1]??E?.[1]??"";c.push($?e.jsx("a",{href:$,title:D?.title??L?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:ht(N,`${p}-link`,s,l)},p):f)}m=g+f.length}return m<d.length&&c.push(_u(d.slice(m))),c.length>0?c:[r]}function nh(r){return/(?: {2,}|\\)$/.test(r)}function sh(r){return r.replace(/(?: {2,}|\\)$/,"")}function Ao(r){return/^(?: {4}|\t)/.test(r)}function ah(r){return r.startsWith(" ")?r.slice(1):r.replace(/^ {4}/,"")}function oh(r,n,s){const l=[];return r.forEach((d,c)=>{const m=nh(d);l.push(...ht(sh(d),`${n}-${c}`,!0,s)),c<r.length-1&&l.push(m?e.jsx("br",{},`${n}-${c}-br`):" ")}),l}function Al(r,n,s){const l=[],d=[];return r.forEach((c,m)=>{d.push(nh(c)),l.push(ht(sh(c),`${n}-${m}`,!0,s))}),{perLine:l,hardBreaks:d}}function Ll(r,n,s,l,d){const c=[];return r.forEach((m,g)=>{const f=s[g]??0,p=!!(d&&f>=d.start&&f<=d.end);c.push(e.jsx("span",{"data-md-ref-start":f,"data-md-ref-end":f,"data-selected":p?"true":void 0,children:m},`${l}-ref-${g}`)),g<r.length-1&&c.push(n[g]?e.jsx("br",{},`${l}-${g}-br`):" ")}),c}function fa(r){const n=r.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let l="",d=!1,c=0,m=0;for(let g=0;g<n.length;g+=1){const f=n[g];if(d){l+=f,d=!1;continue}if(f==="\\"){d=!0;continue}if(f==="`"){const p=g;for(;g+1<n.length&&n[g+1]==="`";)g+=1;const x=g-p+1;l+="`".repeat(x),c===0?c=x:c===x&&(c=0);continue}if(c===0&&f==="["?m+=1:c===0&&f==="]"&&m>0&&(m-=1),f==="|"&&c===0&&m===0){s.push(l.trim()),l="";continue}l+=f}return d&&(l+="\\"),s.push(l.trim()),s}function ih(r){return fa(r).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function Lo(r){return r==="center"?"text-center":r==="right"?"text-right":"text-left"}function To(r){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(r.trim())}function lh(r,n){return r>96||r>44&&n>.35}function Oo(r){return(r.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function ha(r){const n=r.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!n)return null;const s=/^\d+[.)]$/.test(n[1]);return{ordered:s,start:s?Number.parseInt(n[1],10):void 0,content:n[2]}}function Hl(r,n,s,l,d,c=new Set){const m=[],g=[];let f=n;for(;f<r.length;){const p=r[f];if(d&&(Po(p)||c.has(f))){f+=1;continue}const x=ha(p),h=Oo(p);if(!x){if(h>s&&g.length>0){([...g].reverse().find(L=>L.indent<h)?.item??g[g.length-1].item).paragraphs.push(p.trim());for(const L of g)L.item.lineEnd=f+1;f+=1;continue}break}if(h<s||h===s&&x.ordered!==l)break;const b={content:x.content,ordered:x.ordered,start:x.start,children:[],paragraphs:[],lineStart:f+1,lineEnd:f+1};for(;g.length>0&&g[g.length-1].indent>=h;)g.pop();const E=g[g.length-1]?.item??null;E?E.children.push(b):m.push(b),g.push({indent:h,item:b});for(const S of g)S.item.lineEnd=f+1;f+=1}return{items:m,nextIndex:f}}function Dx(r){const n=r.find(l=>ha(l));if(!n)return[];const s=ha(n);return s?Hl(r,0,Oo(n),s.ordered,!0,Vf(r)).items:[]}function zl(r,n,s,l=0){return s.budget.nested(()=>Fx(r,n,s,l))}function Fx(r,n,s,l=0){return r.map((d,c)=>{const m=d.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${c}`,taskItem:!!m,refStart:d.lineStart+l,refEnd:d.lineEnd+l,content:e.jsxs(e.Fragment,{children:[m?e.jsx("input",{type:"checkbox",checked:m[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,ht(m?.[2]??d.content,`li-${n}-${c}`,!0,s),d.paragraphs.length>0&&e.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:d.paragraphs.map((g,f)=>e.jsx("p",{children:ht(g,`li-${n}-${c}-p-${f}`,!0,s)},`paragraph-${f}`))})]}),groups:_x(d.children,`${n}-${c}`,s,l)}})}function _x(r,n,s,l=0){const d=[];for(const c of r){const m=d[d.length-1];m&&m.ordered===c.ordered?m.items.push(c):d.push({ordered:c.ordered,items:[c]})}return d.map((c,m)=>({ordered:c.ordered,start:c.ordered?c.items[0]?.start:void 0,items:zl(c.items,`${n}-g${m}`,s,l)}))}function Wl(r,n){return r.map(s=>{const l=!!(n&&s.refStart<=n.end&&s.refEnd>=n.start);return e.jsxs("li",{className:s.taskItem?"list-none":void 0,"data-md-ref-start":s.refStart,"data-md-ref-end":s.refEnd,"data-selected":l?"true":void 0,children:[s.content,s.groups.length>0&&Bx(s.groups,n)]},s.key)})}function Bx(r,n){return r.map((s,l)=>{const d=s.ordered?"ol":"ul";return e.jsx(d,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:Wl(s.items,n)},`nested-${l}`)})}function Ox(r){const n=Array.from(r.footnoteDefinitions.values()).sort((s,l)=>s.index-l.index);return n.length===0?null:e.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:r.footnotesLabel}),e.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:n.map(s=>e.jsxs("li",{id:`fn-${s.id}`,children:[ht(s.text,`footnote-${s.id}`,!0,r)," ",e.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":r.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function Ux(r,n,s,l){const d=[];let c=0;const m=g=>l?.[g]??g+1;for(;c<r.length;){s.budget.check();const g=r[c],f=g.trim();if(!f){c+=1;continue}if(/^<details>\s*$/i.test(f)){const F=c;let $="Details";const N=[];for(c+=1;c<r.length&&!/^<\/details>\s*$/i.test(r[c].trim());){const A=r[c].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);A?$=A[1].trim()||$:N.push(r[c].trimStart()),c+=1}c<r.length&&(c+=1),d.push({kind:"static",node:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ht($,`${n}-details-${F}-summary`,!0,s)}),N.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:oh(N,`${n}-details-${F}`,s)})]},`${n}-details-${F}`)});continue}const p=rh(g);if(p){const F=[g],$=c;for(c+=1;c<r.length&&!p.selfContained&&!new RegExp(`</${p.tag}>`,"i").test(r[c]);)F.push(r[c]),c+=1;c<r.length&&!p.selfContained&&(F.push(r[c]),c+=1),d.push({kind:"static",node:e.jsx(th,{html:F.join(`
1638
+ `);const b=d.length;d+=x.data,l.push({node:x,start:b,end:d.length,group:h}),c=h}const g=d.toLocaleLowerCase(),f=[];let p=0;for(;p<=g.length-s.length;){const x=g.indexOf(s,p);if(x<0)break;const h=x+s.length,b=l.find(S=>S.start<=x&&S.end>x),E=l.find(S=>S.start<h&&S.end>=h);if(b&&E&&b.group===E.group){const S=document.createRange();S.setStart(b.node,x-b.start),S.setEnd(E.node,h-E.start),f.push(S)}p=x+Math.max(s.length,1)}return f}function jf(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}let Mo;function wu(r){return Mo===r}function mo(r){if(r&&Mo!==r)return;const n=jf();n?.delete(Sf),n?.delete(Sl),Mo=void 0}function Ji(r,n,s){const l=jf();if(!l||typeof Highlight>"u")return;Mo=s,l.set(Sf,new Highlight(...r));const d=r[n];d?l.set(Sl,new Highlight(d)):l.delete(Sl)}function ku(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function Fb(r){return Array.from(new Set(r.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function _b(r,n){const s=n.trim();return!s||s==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Bb(r,n){if(n===r)return".";const s=`${r.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function Rf(r,n,s){return n?r:Rr.createPortal(r,s)}const Dl="termdock:right-sidebar:file-tree-scroll:v1",Fl="termdock:right-sidebar:file-preview-reading-state:v1",ra="termdock:right-sidebar:file-tree-width:v1",Nf="termdock:right-sidebar:markdown-view-mode:v1",Cf="termdock:right-sidebar:diff-change-list-mode:v1",Ef="termdock:right-sidebar:diff-wrap:v1",Mf="termdock:diff-viewer:view-type:v1",$f="termdock:right-sidebar:file-search-mode:v1",Qi="termdock:right-sidebar:collapsed-git-repo-groups:v1",Su="termdock:right-sidebar:collapsed-diff-directories:v1",Zi="termdock:right-sidebar:branch-audit-module-open:v1",Pf="termdock:right-sidebar:branch-audit-module:v1",Ob=150,ju="termdock:right-sidebar:context-draft-enabled:v1",Ru="termdock:right-sidebar:context-draft-collapsed:v1",Nu="termdock:right-sidebar:context-draft-auto-collapse:v1",el="termdock:right-sidebar:context-draft-text:v1",Ub=300,Hb=20,zb=120,Wb=250,Gb=250,Kb=120,qb=700,tl=600,Vb=6e4;function Xs(r){return!!(r&&V.getState().nestedGitScanRoots[r])}const Cu=[2e3,5e3,15e3,3e4],Yb=320,Xb=500,Jb=20,Qb=12e3,jl=300,Eu=240,Zb=560,Af="border-r px-2 py-1.5 sm:px-3 sm:py-2",$o="min-w-full max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",Lf=`${Af} border-b border-border/15 font-semibold last:border-r-0`,Tf=`${Af} border-border/10 align-top text-muted-foreground last:border-r-0`,_l="termdock-file-preview-horizontal-scroll",Mu=a.lazy(()=>Dn(()=>import("./ModelPreview-HzxWwmh4.js"),__vite__mapDeps([7,1,2,3,4,5,8,9,10,11,12,13,14,15,16,17]))),ex=a.lazy(()=>Dn(()=>import("./ArchitecturePanel-DeMEq2Yq.js"),__vite__mapDeps([18,1,2,3,4,5,8,9,10,11,12,15,16,6,14,13,17,19])).then(r=>({default:r.ArchitecturePanel}))),tx=a.lazy(()=>Dn(()=>import("./ComputerControlView-DGoBNNRA.js").then(r=>r.a),__vite__mapDeps([20,1,2,3,4,5,17,14,11,8,9,10,12]))),If=`${_l} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function Df(r,n,s){return r&&!n?"unified":s}const rx=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function nx(r){return r==="preview"||r==="source"}function sx(r){return r==="list"||r==="tree"||r==="ai"}function $u(){return gt(Nf,nx)??"preview"}function ax(){return gt(Cf,sx)??"tree"}function na(r){return typeof r=="boolean"}function ox(r){return typeof r=="string"}function ix(){return gt(Ef,na)??!0}function lx(r){return r==="unified"||r==="split"}function cx(){return gt(Mf,lx)??"unified"}function dx(r){return r==="name"||r==="content"||r==="regex"}function ux(){return gt($f,dx)??"name"}function Ff(r){return r.repositories??(r.context?.root?[{id:r.context.root,root:r.context.root,relativeRoot:".",name:kt(r.context.root)||r.context.root,depth:0,nested:!1,available:r.available,files:r.files,context:r.context,error:r.error}]:[])}function fx(r,n){if(!n)return null;const s=new Set((r.repoFilters??[]).map(l=>l.root));return s.has(n)?n:s.size>0?null:(r.repositories??[]).some(l=>l.root===n)?n:null}function Rl(r){return!r.activeGitRepoRoot&&(r.groupCount>1||r.label!==r.rootName)}function _f(...r){const n=new Set;for(const s of r)for(const l of s)n.add(l.root);return n}function Nl(r){return Array.isArray(r)&&r.every(n=>typeof n=="string")}function Pu(r){const n=gt(r,Nl);return n?new Set(n):new Set}function rl(r,n){At(r,[...n])}function hx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.filePath=="string"&&typeof n.hunkHeader=="string"&&typeof n.hunkIndex=="number"&&typeof n.fingerprint=="string"&&typeof n.additions=="number"&&typeof n.deletions=="number"&&typeof n.diff=="string"&&(n.oldPath===void 0||n.oldPath===null||typeof n.oldPath=="string")&&(n.newPath===void 0||n.newPath===null||typeof n.newPath=="string")&&(n.source===void 0||n.source==="committed"||n.source==="uncommitted"||n.source==="unknown")&&(n.commit===void 0||n.commit===null||typeof n.commit=="string")}function mx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.available=="boolean"&&(n.repoRoot===void 0||typeof n.repoRoot=="string")&&(n.workspaceRoot===void 0||typeof n.workspaceRoot=="string")&&(n.baseRef===void 0||typeof n.baseRef=="string")&&(n.baseBranch===void 0||typeof n.baseBranch=="string")&&(n.currentBranch===void 0||n.currentBranch===null||typeof n.currentBranch=="string")&&(n.headRef===void 0||n.headRef===null||typeof n.headRef=="string")&&(n.diffFingerprint===void 0||typeof n.diffFingerprint=="string")&&(n.stat===void 0||typeof n.stat=="string")&&(n.files===void 0||Nl(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(hx))&&(n.commits===void 0||Nl(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 px(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.key=="string"&&mx(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function gx(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(n=>{if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;return Array.isArray(s.selectedRepoRoots)&&s.selectedRepoRoots.every(l=>typeof l=="string")&&!!s.repoTargetBranches&&typeof s.repoTargetBranches=="object"&&!Array.isArray(s.repoTargetBranches)&&Object.values(s.repoTargetBranches).every(l=>typeof l=="string")&&(s.repoBaseBranches===void 0||!!s.repoBaseBranches&&typeof s.repoBaseBranches=="object"&&!Array.isArray(s.repoBaseBranches)&&Object.values(s.repoBaseBranches).every(l=>typeof l=="string"))&&(s.previewEntries===void 0||Array.isArray(s.previewEntries)&&s.previewEntries.every(px))&&(s.selectedPreviewKey===void 0||s.selectedPreviewKey===null||typeof s.selectedPreviewKey=="string")&&(s.selectedPreviewFileKey===void 0||s.selectedPreviewFileKey===null||typeof s.selectedPreviewFileKey=="string")&&(s.previewDetailOpen===void 0||typeof s.previewDetailOpen=="boolean")&&(s.previewScrollTops===void 0||!!s.previewScrollTops&&typeof s.previewScrollTops=="object"&&!Array.isArray(s.previewScrollTops)&&Object.values(s.previewScrollTops).every(l=>typeof l=="number"))&&(s.previewMobileSlideIndex===void 0||typeof s.previewMobileSlideIndex=="number")&&(s.repoIncludeUncommitted===void 0||!!s.repoIncludeUncommitted&&typeof s.repoIncludeUncommitted=="object"&&!Array.isArray(s.repoIncludeUncommitted)&&Object.values(s.repoIncludeUncommitted).every(l=>typeof l=="boolean"))&&(s.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function Au(){return gt(Pf,gx)??{}}function Lu(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function Tu(r){const n=r?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function Bf(r,n){const s=r?.trim(),l=n?.trim();return!s||!l?!1:s===l||Tu(s)===Tu(l)}function Iu(r){const n=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(l=>l&&!Bf(l,n))??""}function Cl(r,n){const s=Math.max(Eu,n-320),l=Math.min(Zb,s);return Math.min(l,Math.max(Eu,r))}function bx(r){return typeof r=="number"&&Number.isFinite(r)}function xx(r){return Cl(gt(ra,bx)??jl,r)}function Of(r){const n=r.split(/[\\/]/).pop()??r,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function Js(r){return rx.has(Of(r))}function Uf(r){const n=r.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function El(r){const n=r.trim();return/^#{1,6}\s+/.test(n)||Uf(r)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function Hf(r){const n=r.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const zf=a.createContext(null);function So(r){return r.trim().replace(/\s+/g," ").toLowerCase()}function Wf(r){return r.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function Gf(r){return r.replace(/\s+#+\s*$/,"").trim()}function Ml(r,n){const l=Wf(r).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",d=n.headingSlugCounts.get(l)??0;return n.headingSlugCounts.set(l,d+1),d===0?l:`${l}-${d}`}function Du(r){return Wf(r)||r.trim()}function Po(r){const n=r.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=Pl(n[2]);return s?{id:So(n[1]),definition:{href:s.href,title:s.title}}:null}function vx(r){const n=new Map;for(const s of r){const l=Po(s);l&&n.set(l.id,l.definition)}return n}function Kf(r){return r.trim().toLowerCase()}function qf(r){const n=r.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:Kf(n[1]),text:n[2]}:null}function yx(r){const n=new Map;let s=null;for(const l of r){const d=qf(l);if(d){s=d.id,n.set(d.id,{id:d.id,text:d.text,index:n.size+1});continue}if(s&&/^\s{4,}\S/.test(l)){const c=n.get(s);c&&(c.text=`${c.text} ${l.trim()}`);continue}l.trim()&&(s=null)}return n}function Vf(r){const n=new Set;let s=!1;return r.forEach((l,d)=>{if(qf(l)){n.add(d),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(d);return}l.trim()&&(s=!1)}),n}function wx(r){const n=[...r];let s=0;const l=r[0]?.trim();if(l==="---"||l==="+++"){for(n[0]="",s=1;s<r.length&&r[s].trim()!==l;)n[s]="",s+=1;s<r.length&&(n[s]="",s+=1)}for(;s<r.length;){const d=r[s].trim();if(d.startsWith("<!--")){if(n[s]="",!d.includes("-->")){for(s+=1;s<r.length&&!r[s].includes("-->");)n[s]="",s+=1;s<r.length&&(n[s]="")}s+=1;continue}s+=1}return n}function Yf(r){const n=r.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function oa(r){const n=r.split(/[?#]/,1)[0],s=n.startsWith("/"),l=[];for(const c of n.split("/"))if(!(!c||c===".")){if(c===".."){l.length>0&&l.pop();continue}l.push(c)}return`${s?"/":""}${l.join("/")}`||(s?"/":".")}function Bl(r,n,s){const l=r.trim();if(!l||/^(?:https?:|mailto:|javascript:|data:)/i.test(l)||/^[a-z][a-z0-9+.-]*:/i.test(l))return null;if(l.startsWith("#")){if(!n)return null;try{return{path:n,fragment:decodeURIComponent(l.slice(1))||null,directory:!1}}catch{return null}}const d=l.indexOf("#"),c=d>=0?l.slice(0,d):l,m=d>=0?l.slice(d+1):"",g=c.split("?",1)[0];if(!g)return null;let f,p=null;try{f=decodeURIComponent(g),p=m?decodeURIComponent(m):null}catch{return null}const x=s?oa(s):null;let h;if(f.startsWith("/")){const b=x&&(f===x||f.startsWith(`${x}/`));h=oa(x&&!b?`${x}/${f.slice(1)}`:f)}else{if(!n)return null;h=oa(`${Yf(n)}/${f}`)}return x&&h!==x&&!h.startsWith(`${x}/`)?null:{path:h,fragment:p,directory:/\/$/.test(g)}}function Ol(r,n,s,l,d){const c=r.trim();if(!c||/^(?:javascript|data):/i.test(c))return null;if(/^https?:\/\//i.test(c))return c;if(!l(c.split(/[?#]/,1)[0]))return null;let m;if(c.startsWith("/")){const g=s&&(c===s||c.startsWith(`${s}/`));m=oa(s&&!g?`${s}/${c.slice(1)}`:c)}else{if(!n)return null;m=oa(`${Yf(n)}/${c}`)}return d(m)}function kx(r,n,s){return Ol(r,n,s,Tl,l=>`/api/terminal/fs/blob?path=${encodeURIComponent(l)}`)}function Sx(r,n,s){return Ol(r,n,s,Xu,Ju)}const $l=128,jx=360,nl=480;function ma(r){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(r))}catch{return!1}}function Xf(r,n,s,l,d=0){if(!n||!s)return null;let c,m;return d>0?(c=l>0?Math.min(d,l):d,m=s*c/n):ma(r)?(m=Math.min(Math.max(s,$l),jx),c=n*m/s):(c=n,m=s),l>0&&c>l&&(m=m*l/c,c=l),m>nl&&(c=c*nl/m,m=nl),{width:Math.max(1,Math.round(c)),height:Math.max(1,Math.round(m))}}function Rx(r){if(!r.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(r.slice(r.indexOf("?"))).get("path")}catch{return null}}function Jf(r){const n=Rx(r),s=V(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${r}&v=${s}`:r}function Nx({src:r,alt:n,title:s,requestedWidthPx:l}){const d=ma(r),c=Jf(r),m=_o(c),g=a.useRef(null),[f,p]=a.useState(!1),[x,h]=a.useState(0),[b,E]=a.useState({status:"loading"}),[S,L]=a.useState(null);a.useLayoutEffect(()=>{const $=g.current;let N=$?.parentElement?.parentElement??$?.parentElement;for(;N;){const j=window.getComputedStyle(N).display;if(j!=="inline"&&j!=="contents")break;N=N.parentElement}if(!N)return;const A=N,B=()=>{const j=window.getComputedStyle(A),o=(parseFloat(j.paddingLeft)||0)+(parseFloat(j.paddingRight)||0);h(Math.max(0,A.clientWidth-o))};if(B(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(B);return q.observe(A),()=>q.disconnect()},[]),a.useEffect(()=>{if(f)return;const $=g.current;if(!$||typeof IntersectionObserver>"u"){p(!0);return}const N=new IntersectionObserver(A=>{A.some(B=>B.isIntersecting)&&(p(!0),N.disconnect())},{rootMargin:"400px"});return N.observe($),()=>N.disconnect()},[f]),a.useEffect(()=>{if(!f)return;const $=new AbortController;let N=null;E({status:"loading"});const A=window.setTimeout(()=>{$.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return Qu(c,{signal:$.signal}).then(async B=>{if(!B.ok)throw new Error(`HTTP ${B.status}`);const q=Number(B.headers.get("X-Image-Width"))||0,j=Number(B.headers.get("X-Image-Height"))||0;return{blob:await B.blob(),width:q,height:j}}).then(({blob:B,width:q,height:j})=>{$.signal.aborted||(N=URL.createObjectURL(B),q>0&&j>0&&L({width:q,height:j}),E({status:"ready",objectUrl:N}))}).catch(()=>{const B=$.signal.reason;$.signal.aborted&&!(B instanceof DOMException&&B.name==="TimeoutError")||E({status:"fallback"})}).finally(()=>{window.clearTimeout(A)}),()=>{window.clearTimeout(A),$.abort(),N&&URL.revokeObjectURL(N)}},[f,c]);const D=Xf(r,S?.width??0,S?.height??0,x,l??0),F=D??(l?{width:x>0?Math.min(l,x):l,height:Math.round(l*.75)}:{width:$l*2,height:$l});return e.jsx("div",{ref:g,className:"block max-w-full",style:D?{width:D.width,height:D.height}:void 0,children:b.status==="ready"?e.jsx("img",{src:b.objectUrl,alt:n,title:s,decoding:"async",className:`${d?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:D?{width:D.width,height:D.height}:void 0,onLoad:$=>{const N=$.currentTarget;N.naturalWidth>0&&N.naturalHeight>0&&(S?.width!==N.naturalWidth||S?.height!==N.naturalHeight)&&L({width:N.naturalWidth,height:N.naturalHeight})}}):b.status==="fallback"?e.jsx("img",{src:m,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:$=>{const N=$.currentTarget;N.naturalWidth>0&&N.naturalHeight>0&&(S?.width!==N.naturalWidth||S?.height!==N.naturalHeight)&&L({width:N.naturalWidth,height:N.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:F.width,height:F.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function ia(r,n,s,l,d,c){const m=kx(s,d.markdownFilePath,d.rootPath);if(!m)return c?.fallbackText??`![${n}](${s})`;const g=d.images.length;d.images.push({kind:"image",src:m,alt:n,title:l});const f=e.jsx(Nx,{src:m,alt:n,title:l,requestedWidthPx:c?.requestedWidthPx});return d.onImageOpen&&c?.interactive!==!1?e.jsx("button",{type:"button",className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2 text-left transition hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-ring/45",title:l||n||"Open image",onClick:p=>{p.stopPropagation(),d.onImageOpen?.(g)},children:f},r):e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:f},r)}function sl(r){let n=r,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function Fu(r){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(r)}function Pl(r){const n=r.trim(),s=n.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(s)return{href:s[1],title:s[2]??s[3]??s[4]};const l=n.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return l?{href:l[1],title:l[2]??l[3]??l[4]}:null}const Qf="",Cx=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function Ex(r){return r.replace(Cx,(n,s)=>`${Qf}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function _u(r){return r.replace(new RegExp(`${Qf}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function Mx(r){const n=r.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const Zf={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 po=null;function eh(){return po||(po=Dn(()=>import("./purify.es-4eNOHKSq.js"),[]).then(r=>r.default??r).catch(r=>{throw po=null,r})),po}function th({html:r}){const{t:n}=mt(),[s,l]=a.useState(null);return a.useEffect(()=>{let d=!1;return l(null),eh().then(c=>{d||l(c.sanitize(r,Zf))}).catch(()=>{d||l("")}),()=>{d=!0}},[r]),s===null?e.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:n("rightSidebar.renderingHtml")}):s?e.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:s}}):null}function $x({html:r}){const[n,s]=a.useState(null);return a.useEffect(()=>{let l=!1;return s(null),eh().then(d=>{l||s(d.sanitize(r,Zf))}).catch(()=>{l||s("")}),()=>{l=!0}},[r]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):r}function rh(r){const n=r.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!n)return null;const s=n[1].toLowerCase();return{tag:s,selfContained:new RegExp(`</${s}>`,"i").test(r)}}let go=null;function Px(){return go||(go=Promise.all([Dn(()=>import("./katex-DnlPpQZa.js"),[]),Dn(()=>Promise.resolve({}),__vite__mapDeps([21]))]).then(([r])=>r.default??r).catch(r=>{throw go=null,r})),go}function ua({tex:r,display:n=!1}){const[s,l]=a.useState(null),[d,c]=a.useState(!1);if(a.useEffect(()=>{let g=!1;return l(null),c(!1),Px().then(f=>{g||l(f.renderToString(r,{displayMode:n,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{g||c(!0)}),()=>{g=!0}},[n,r]),d)return e.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:n?`$$${r}$$`:`$${r}$`});if(!s)return e.jsx("span",{className:"text-muted-foreground/70",children:n?"Rendering formula...":r});const m=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:m,dangerouslySetInnerHTML:{__html:s}})}function Ul(r){const n=new Map;for(const s of r.matchAll(/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/gi))n.set(s[1].toLowerCase(),s[2]??s[3]??s[4]);return n}function Bu(r){const n=Ul(r),s=n.get("src")?.trim()??"",l=n.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i);return{src:s,alt:n.get("alt"),title:n.get("title"),widthPx:l?Number(l[1]):void 0}}function Ax(r){const n=r.indexOf(">"),s=n<0?r:r.slice(0,n+1),l=Ul(s),d=l.get("src")?.trim()??"",c=l.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i),m=s.replace(/=\s*(?:"[^"]*"|'[^']*')/g," "),g=n<0?"":r.slice(n+1).replace(/<\/video\s*>$/i,"").replace(/<[^>]*>/g,"").trim();return{src:d,fallbackText:g,widthPx:c?Number(c[1]):void 0,controls:/\bcontrols\b/i.test(m)}}function Lx({url:r,fallbackText:n,widthPx:s,hasControls:l}){const{t:d}=mt(),[c,m]=a.useState(!1),g=_o(r,()=>m(!0));return g?e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:c?e.jsx("span",{className:"block px-3 py-2 text-xs text-muted-foreground",children:n?.trim()||d("rightSidebar.videoUnsupported")}):e.jsx("video",{className:"block max-w-full",src:g,style:s?{width:`${s}px`}:void 0,controls:l,preload:"metadata",playsInline:!0,onError:()=>m(!0)})}):null}function Tx(r,n,s){if(/^<a\b[^>]*>\s*<\s*img\b[^>]*>\s*<\/a\s*>$/i.test(r)){const m=r.slice(0,r.indexOf(">")+1),g=Ul(m).get("href")?.trim()??"",f=r.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:p,alt:x,title:h,widthPx:b}=Bu(f);if(!p)return null;const E=Ol(p,s.markdownFilePath,s.rootPath,Tl,$=>$);if(!E)return null;const S=g?Bl(g,s.markdownFilePath,s.rootPath):null,D=!!!(S&&S.path===E)&&g?Hf(g):null,F=ia(n,x??"",p,h,s,{requestedWidthPx:b,interactive:D?!1:void 0});return D?e.jsx("a",{href:D,target:"_blank",rel:"noreferrer",children:F},n):F}if(/^<\s*img\b[^>]*>$/i.test(r)){const{src:m,alt:g,title:f,widthPx:p}=Bu(r);return m?ia(n,g??"",m,f,s,{fallbackText:r,requestedWidthPx:p}):null}if(/^<\s*video\b[^>]*>[\s\S]*?<\/video\s*>$/i.test(r)){const{src:m,fallbackText:g,widthPx:f,controls:p}=Ax(r);if(!m)return null;const x=Sx(m,s.markdownFilePath,s.rootPath);return x?e.jsx(Lx,{url:x,fallbackText:g,widthPx:f,hasControls:p},n):null}if(/^<br\s*\/?>$/i.test(r))return e.jsx("br",{},n);const l=r.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!l)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(r)?e.jsx($x,{html:r},n):null;const d=l[1].toLowerCase(),c=ht(l[2],`${n}-${d}`,!0,s);return d==="kbd"?e.jsx("kbd",{className:"rounded border border-border/30 bg-surface-2 px-1.5 py-0.5 font-mono text-[0.85em] text-foreground shadow-sm",children:c},n):d==="mark"?e.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:c},n):d==="sub"?e.jsx("sub",{children:c},n):e.jsx("sup",{children:c},n)}function ht(r,n,s=!0,l){return l.budget.nested(()=>Ix(r,n,s,l))}function Ix(r,n,s=!0,l){l.budget.validateInline(r);const d=Ex(r),c=[];let m=0;for(const{index:g,token:f}of pg(d,l.budget)){g>m&&c.push(_u(d.slice(m,g)));const p=`${n}-${g}`,x=f.startsWith("<")?Tx(f,p,l):null;if(x)c.push(x);else if(f.startsWith("\\(")&&f.endsWith("\\)"))c.push(e.jsx(ua,{tex:f.slice(2,-2)},p));else if(f.startsWith("$")&&f.endsWith("$"))c.push(e.jsx(ua,{tex:f.slice(1,-1)},p));else if(f.startsWith("`")){const h=f.match(/^`+/)?.[0].length??1;c.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:Mx(f.slice(h,-h))},p))}else if(f.startsWith("~~"))c.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:ht(f.slice(2,-2),`${p}-del`,s,l)},p));else if(f.startsWith("**")||f.startsWith("__"))c.push(e.jsx("strong",{className:"font-semibold text-foreground",children:ht(f.slice(2,-2),`${p}-strong`,s,l)},p));else if(f.startsWith("*")||f.startsWith("_"))c.push(e.jsx("em",{className:"italic",children:ht(f.slice(1,-1),`${p}-em`,s,l)},p));else if(f.startsWith("![")){const h=f.match(/^!\[([^\]]*)\]\((.*)\)$/),b=f.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),E=f.match(/^!\[([^\]]+)\]$/);if(h){const S=Pl(h[2]);c.push(S?ia(p,h[1],S.href,S.title,l):f)}else if(b){const S=b[2]||b[1],L=l.referenceDefinitions.get(So(S));c.push(L?ia(p,b[1],L.href,L.title,l):f)}else if(E){const S=l.referenceDefinitions.get(So(E[1]));c.push(S?ia(p,E[1],S.href,S.title,l):f)}else c.push(f)}else if(f.startsWith("[^")){const h=Kf(f.slice(2,-1)),b=l.footnoteDefinitions.get(h);c.push(b?e.jsx("sup",{id:`fnref-${b.id}`,title:b.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:e.jsx("a",{href:`#fn-${b.id}`,className:"text-primary no-underline",children:b.index})},p):f)}else if(f.startsWith("<http")){const h=f.slice(1,-1);c.push(e.jsx("a",{href:h,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p))}else if(f.startsWith("<")&&f.endsWith(">")&&Fu(f.slice(1,-1))){const h=f.slice(1,-1);c.push(e.jsx("a",{href:`mailto:${h}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p))}else if(Fu(sl(f).linkText)){const{linkText:h,suffix:b}=sl(f);c.push(e.jsx("a",{href:`mailto:${h}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p)),b&&c.push(b)}else if(f.startsWith("http")||f.startsWith("www.")){const{linkText:h,suffix:b}=sl(f),E=h.startsWith("www.")?`https://${h}`:h;c.push(e.jsx("a",{href:E,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:h},p)),b&&c.push(b)}else{const h=f.match(/^\[([^\]]+)\]\((.*)\)$/),b=f.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),E=f.match(/^\[([^\]]+)\]$/),S=b?b[2]||b[1]:E?.[1]??null,L=S?l.referenceDefinitions.get(So(S)):null,D=h?Pl(h[2]):null,F=D?.href??L?.href??null,$=F?Hf(F):null,N=h?.[1]??b?.[1]??E?.[1]??"";c.push($?e.jsx("a",{href:$,title:D?.title??L?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:ht(N,`${p}-link`,s,l)},p):f)}m=g+f.length}return m<d.length&&c.push(_u(d.slice(m))),c.length>0?c:[r]}function nh(r){return/(?: {2,}|\\)$/.test(r)}function sh(r){return r.replace(/(?: {2,}|\\)$/,"")}function Ao(r){return/^(?: {4}|\t)/.test(r)}function ah(r){return r.startsWith(" ")?r.slice(1):r.replace(/^ {4}/,"")}function oh(r,n,s){const l=[];return r.forEach((d,c)=>{const m=nh(d);l.push(...ht(sh(d),`${n}-${c}`,!0,s)),c<r.length-1&&l.push(m?e.jsx("br",{},`${n}-${c}-br`):" ")}),l}function Al(r,n,s){const l=[],d=[];return r.forEach((c,m)=>{d.push(nh(c)),l.push(ht(sh(c),`${n}-${m}`,!0,s))}),{perLine:l,hardBreaks:d}}function Ll(r,n,s,l,d){const c=[];return r.forEach((m,g)=>{const f=s[g]??0,p=!!(d&&f>=d.start&&f<=d.end);c.push(e.jsx("span",{"data-md-ref-start":f,"data-md-ref-end":f,"data-selected":p?"true":void 0,children:m},`${l}-ref-${g}`)),g<r.length-1&&c.push(n[g]?e.jsx("br",{},`${l}-${g}-br`):" ")}),c}function fa(r){const n=r.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let l="",d=!1,c=0,m=0;for(let g=0;g<n.length;g+=1){const f=n[g];if(d){l+=f,d=!1;continue}if(f==="\\"){d=!0;continue}if(f==="`"){const p=g;for(;g+1<n.length&&n[g+1]==="`";)g+=1;const x=g-p+1;l+="`".repeat(x),c===0?c=x:c===x&&(c=0);continue}if(c===0&&f==="["?m+=1:c===0&&f==="]"&&m>0&&(m-=1),f==="|"&&c===0&&m===0){s.push(l.trim()),l="";continue}l+=f}return d&&(l+="\\"),s.push(l.trim()),s}function ih(r){return fa(r).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function Lo(r){return r==="center"?"text-center":r==="right"?"text-right":"text-left"}function To(r){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(r.trim())}function lh(r,n){return r>96||r>44&&n>.35}function Oo(r){return(r.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function ha(r){const n=r.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!n)return null;const s=/^\d+[.)]$/.test(n[1]);return{ordered:s,start:s?Number.parseInt(n[1],10):void 0,content:n[2]}}function Hl(r,n,s,l,d,c=new Set){const m=[],g=[];let f=n;for(;f<r.length;){const p=r[f];if(d&&(Po(p)||c.has(f))){f+=1;continue}const x=ha(p),h=Oo(p);if(!x){if(h>s&&g.length>0){([...g].reverse().find(L=>L.indent<h)?.item??g[g.length-1].item).paragraphs.push(p.trim());for(const L of g)L.item.lineEnd=f+1;f+=1;continue}break}if(h<s||h===s&&x.ordered!==l)break;const b={content:x.content,ordered:x.ordered,start:x.start,children:[],paragraphs:[],lineStart:f+1,lineEnd:f+1};for(;g.length>0&&g[g.length-1].indent>=h;)g.pop();const E=g[g.length-1]?.item??null;E?E.children.push(b):m.push(b),g.push({indent:h,item:b});for(const S of g)S.item.lineEnd=f+1;f+=1}return{items:m,nextIndex:f}}function Dx(r){const n=r.find(l=>ha(l));if(!n)return[];const s=ha(n);return s?Hl(r,0,Oo(n),s.ordered,!0,Vf(r)).items:[]}function zl(r,n,s,l=0){return s.budget.nested(()=>Fx(r,n,s,l))}function Fx(r,n,s,l=0){return r.map((d,c)=>{const m=d.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${c}`,taskItem:!!m,refStart:d.lineStart+l,refEnd:d.lineEnd+l,content:e.jsxs(e.Fragment,{children:[m?e.jsx("input",{type:"checkbox",checked:m[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,ht(m?.[2]??d.content,`li-${n}-${c}`,!0,s),d.paragraphs.length>0&&e.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:d.paragraphs.map((g,f)=>e.jsx("p",{children:ht(g,`li-${n}-${c}-p-${f}`,!0,s)},`paragraph-${f}`))})]}),groups:_x(d.children,`${n}-${c}`,s,l)}})}function _x(r,n,s,l=0){const d=[];for(const c of r){const m=d[d.length-1];m&&m.ordered===c.ordered?m.items.push(c):d.push({ordered:c.ordered,items:[c]})}return d.map((c,m)=>({ordered:c.ordered,start:c.ordered?c.items[0]?.start:void 0,items:zl(c.items,`${n}-g${m}`,s,l)}))}function Wl(r,n){return r.map(s=>{const l=!!(n&&s.refStart<=n.end&&s.refEnd>=n.start);return e.jsxs("li",{className:s.taskItem?"list-none":void 0,"data-md-ref-start":s.refStart,"data-md-ref-end":s.refEnd,"data-selected":l?"true":void 0,children:[s.content,s.groups.length>0&&Bx(s.groups,n)]},s.key)})}function Bx(r,n){return r.map((s,l)=>{const d=s.ordered?"ol":"ul";return e.jsx(d,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:Wl(s.items,n)},`nested-${l}`)})}function Ox(r){const n=Array.from(r.footnoteDefinitions.values()).sort((s,l)=>s.index-l.index);return n.length===0?null:e.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:r.footnotesLabel}),e.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:n.map(s=>e.jsxs("li",{id:`fn-${s.id}`,children:[ht(s.text,`footnote-${s.id}`,!0,r)," ",e.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":r.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function Ux(r,n,s,l){const d=[];let c=0;const m=g=>l?.[g]??g+1;for(;c<r.length;){s.budget.check();const g=r[c],f=g.trim();if(!f){c+=1;continue}if(/^<details>\s*$/i.test(f)){const F=c;let $="Details";const N=[];for(c+=1;c<r.length&&!/^<\/details>\s*$/i.test(r[c].trim());){const A=r[c].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);A?$=A[1].trim()||$:N.push(r[c].trimStart()),c+=1}c<r.length&&(c+=1),d.push({kind:"static",node:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ht($,`${n}-details-${F}-summary`,!0,s)}),N.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:oh(N,`${n}-details-${F}`,s)})]},`${n}-details-${F}`)});continue}const p=rh(g);if(p){const F=[g],$=c;for(c+=1;c<r.length&&!p.selfContained&&!new RegExp(`</${p.tag}>`,"i").test(r[c]);)F.push(r[c]),c+=1;c<r.length&&!p.selfContained&&(F.push(r[c]),c+=1),d.push({kind:"static",node:e.jsx(th,{html:F.join(`
1639
1639
  `)},`${n}-html-${$}`)});continue}const x=f.match(/^(```|~~~)\s*(.*)$/);if(x){const F=[],$=x[1],N=x[2]?.trim(),A=c;for(c+=1;c<r.length&&!r[c].trim().startsWith($);)F.push(r[c]),c+=1;c<r.length&&(c+=1),N.toLowerCase()==="mermaid"?d.push({kind:"static",node:e.jsx(dh,{code:F.join(`
1640
1640
  `),blockKey:`${n}-code-${A}`},`${n}-code-${A}`)}):["math","latex","tex"].includes(N.toLowerCase())?d.push({kind:"static",node:e.jsx(ua,{tex:F.join(`
1641
1641
  `),display:!0},`${n}-code-${A}`)}):d.push({kind:"code",key:`${n}-code-${A}`,code:F.join(`
@@ -1656,22 +1656,22 @@ ${ge}${K}
1656
1656
  ${T.join(`
1657
1657
  `)}
1658
1658
  ${ge}
1659
- `})(),Qt=`path:${Xe}`,Zt=$?`path:${Xe}:${$.start}-${$.end}`:Qt,_n=A===Qt,ks=A===Zt,sn=B===Qt,fr=B===Zt,an=ks||fr,on=$?$.start===$.end?`L${$.start}`:`L${$.start}-${$.end}`:null,ln=T=>{const K=Me.current;if(!K)return;const ge=K.getBoundingClientRect(),ke=T.currentTarget.getBoundingClientRect(),nt=T.clientX||ke.left+ke.width/2,ze=(T.clientY||ke.top+ke.height/2)-ge.top+K.scrollTop,Ge=p?116:132,bt=K.scrollLeft+Math.max(8,K.clientWidth-Ge),vt=Math.min(Math.max(8,nt-ge.left+K.scrollLeft+10),bt);be({top:ze,left:vt})},hr=(T,K)=>{gl()||(ln(T),N(ge=>{const ke=bl(ge,K,K);return ke||be(null),ke}))},mr=(T,K,ge)=>{ln(T),N(ke=>{const nt=bl(ke,K,ge);return nt||be(null),nt})},ve=(T,K,ge,ke)=>{ke==="end"&&ln(T),N({start:K,end:ge})},er=T=>{const{scrollTop:K,scrollLeft:ge}=T.currentTarget;fe(K),al(U,n,{top:K,left:ge,markdownTop:K})},cn=T=>{if(T.directory){f?.(T.path);return}if(T.path===Xe||R.kind==="text"&&T.path===R.sourcePath){T.fragment&&gs(T.fragment);return}$e(K=>[...K,Xe]),Te.current=T.path,ce(T.fragment),N(null),O(T.path)},Bn=()=>{const T=Ee[Ee.length-1];T&&($e(K=>K.slice(0,-1)),Te.current=T,ce(null),N(null),O(T))},Ss=T=>{const{scrollTop:K,scrollLeft:ge}=T.currentTarget;al(U,n,{top:K,left:ge})},dn=T=>{if(r){r(nn,Zt);return}$&&d(nn,Zt,T.currentTarget)},It=()=>{if(!(R.kind==="loading"||R.kind==="error"))return te.start()};return e.jsxs("div",{ref:_,tabIndex:-1,onKeyDown:tn,onFocusCapture:()=>{s&&Re&&We.trim()&&Ji(H,Ce,I.current)},onPointerDownCapture:T=>{T.target instanceof Element&&!T.target.closest('button, input, textarea, select, a, [tabindex]:not([tabindex="-1"])')&&T.currentTarget.focus({preventScroll:!0})},className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[Nt.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${p&&(ur||$r)?"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&&g&&e.jsx("button",{type:"button",onClick:g,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":o("rightSidebar.backToFileList"),title:o("rightSidebar.backToFileList"),children:e.jsx(af,{size:16})}),Ee.length>0&&e.jsxs("button",{type:"button",onClick:Bn,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":o("rightSidebar.backToPreviousPreview"),title:o("rightSidebar.backToPreviousPreview"),children:[e.jsx(la,{size:15}),!p&&e.jsx("span",{className:"text-[11px] font-medium",children:o("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:Xe,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:dr.name}),dr.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:dr.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[cr&&e.jsx("button",{type:"button",onClick:Re?en:Ct,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":o("rightSidebar.findInFile"),title:`${o("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(ms,{size:14})}),Tt&&R.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{x&&E?.(),Be(T=>{const K=T==="preview"?"source":"preview";return At(Nf,K),K}),N(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":o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:p?ue==="preview"?e.jsx(vl,{size:14}):e.jsx(xl,{size:14}):o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),xs&&R.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{G(T=>{const K=T==="preview"?"source":"preview";return eb(U,n,K),K}),N(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":o(Oe==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:o(Oe==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:p?Oe==="preview"?e.jsx(vl,{size:14}):e.jsx(xl,{size:14}):o(Oe==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),$r&&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":o(ye?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:o(ye?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(of,{size:15})}),!p&&e.jsx("button",{type:"button",onClick:T=>l(Xe,Qt,T.currentTarget),...Nt(Ur,Qt),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${_n||sn?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:o("rightSidebar.insertReference",{reference:Ur}),children:o(sn?"rightSidebar.copied":_n?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Ur)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:o("rightSidebar.copyReference",{reference:Ur}),"aria-label":o("rightSidebar.copyFileRef"),children:e.jsx(rp,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{It()},disabled:te.status==="pending"||R.kind==="loading"||R.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:te.status==="error"?te.error??o("rightSidebar.downloadFailed"):o("rightSidebar.downloadFile"),"aria-label":o("rightSidebar.downloadFile"),children:te.status==="pending"?e.jsx(ft,{size:13,className:"animate-spin"}):e.jsx(rf,{size:14})}),te.status==="pending"&&e.jsx("button",{type:"button",onClick:te.cancel,className:"inline-flex h-9 shrink-0 items-center rounded-full bg-surface-2 px-2 text-xs text-foreground hover:bg-surface-elevated",children:o("common.cancel")})]})]}),te.status==="error"&&e.jsxs("div",{role:"alert",className:"mt-2 text-xs text-destructive",children:[o("rightSidebar.downloadFailed"),": ",te.error]}),te.status==="canceled"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadCanceled")}),te.status==="saved"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadSaved")}),te.status==="started"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadStarted")}),Re&&cr&&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(ms,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:ct,type:"search",value:We,onChange:T=>Br(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),Or(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:o("rightSidebar.findInFilePlaceholder"),"aria-label":o("rightSidebar.findInFile")}),e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:H.length>0?`${Ce+1}/${H.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>Or(-1),disabled:H.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":o("rightSidebar.previousSearchMatch"),title:`${o("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:e.jsx(Il,{size:13})}),e.jsx("button",{type:"button",onClick:()=>Or(1),disabled:H.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":o("rightSidebar.nextSearchMatch"),title:`${o("rightSidebar.nextSearchMatch")} (Enter)`,children:e.jsx(Cp,{size:13})}),e.jsx("button",{type:"button",onClick:en,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":o("rightSidebar.closeFileSearch"),title:`${o("rightSidebar.closeFileSearch")} (Esc)`,children:e.jsx(Lt,{size:13})})]}),Er&&!(p&&(ur||$r))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[Er.size!==null&&e.jsx("span",{children:o("rightSidebar.byteCount",{count:Er.size.toLocaleString()})}),"truncated"in Er&&Er.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:o("rightSidebar.previewTruncated")}),"mimeType"in Er&&e.jsx("span",{children:Er.mimeType}),"dimensions"in R&&R.dimensions&&e.jsxs("span",{children:[R.dimensions.width," × ",R.dimensions.height]})]}),!(p&&(ur||$r))&&!rn&&R.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:ys?o("rightSidebar.edaPickHint"):ga?o("rightSidebar.csvTablePreview"):Mr||bs?o("rightSidebar.kicadProjectPickHint"):vs?o("rightSidebar.videoPreviewHint"):St?o("rightSidebar.imagePreviewHint"):ur?$?o("rightSidebar.selectedLineHint",{lineLabel:on??""}):o("rightSidebar.markdownPreviewHint"):$r?o("rightSidebar.htmlPreviewHint"):$?o("rightSidebar.selectedLineHint",{lineLabel:on??""}):o("rightSidebar.multiLineHint")})})]}),!s&&(R.kind==="video"||R.kind==="model3d"||R.kind==="eda"||$r)?null:R.kind==="loading"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8",children:e.jsx(zi,{label:R.mode==="eda"?o("rightSidebar.edaLoading"):R.mode==="image"?o("rightSidebar.loadingImage"):R.mode==="model3d"?o("rightSidebar.model3dLoading"):R.mode==="video"?o("rightSidebar.loadingVideo"):o("common.loading")})}):R.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:R.message}),e.jsx("button",{type:"button",onClick:Fn,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:o("common.retry")})]}):R.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:o("rightSidebar.binaryPreviewHint")})}):R.kind==="image"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:R.meta.mimeType==="image/svg+xml"?e.jsx(wf,{blobUrl:R.objectUrl,filePath:Xe,viewLabel:"SVG 文件",onInsertAnnotation:c}):e.jsx(jh,{src:R.objectUrl,alt:dr.name,vector:!1,onLoad:T=>{const K=T.currentTarget;z(ge=>ge.kind==="image"?{...ge,dimensions:{width:K.naturalWidth,height:K.naturalHeight}}:ge)},onError:()=>z({kind:"error",message:o("rightSidebar.imageLoadFailed")})})}):R.kind==="video"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:e.jsx(ub,{url:R.url,onLoadError:()=>z({kind:"error",message:o("rightSidebar.videoLoadFailed")})})}):R.kind==="eda"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(xb,{blobUrl:R.objectUrl,filePath:R.sourcePath,view:R.view,board:Xe.toLowerCase().endsWith(".kicad_pcb"),onViewChange:P,onInsertAnnotation:r??c,onRefresh:Fn,interactive3d:W?e.jsx(a.Suspense,{fallback:e.jsx(zi,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:e.jsx(Mu,{blobUrl:W.objectUrl,ext:".glb",fileName:dr.name,filePath:W.sourcePath,features:null,onInsertFeature:r??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:R.view==="pcb-3d"})}):void 0})}):R.kind==="model3d"?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:e.jsx(a.Suspense,{fallback:e.jsx(zi,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:e.jsx(Mu,{blobUrl:R.objectUrl,ext:R.ext,fileName:dr.name,filePath:R.sourcePath,features:pe,onInsertFeature:r??c,onRefresh:Fn})})}):R.kind==="text"&&ga?e.jsx(wb,{content:R.content,filePath:Xe,onInsertAnnotation:r??c},Xe):R.kind==="text"&&(Mr||bs)?e.jsx(jb,{content:R.content,filePath:Xe,localState:bs,onInsertAnnotation:r??c},Xe):ur?e.jsxs("div",{ref:Me,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:er,style:{touchAction:"pan-x pan-y"},children:[e.jsx(mh,{content:R.content,filePath:R.sourcePath,rootPath:U,lineRange:$,onLineRangeClick:mr,onLineRangeDrag:ve,scrollTop:he,outlineOpen:x,outlineCloseSignal:h,onOutlineOpen:b,onOutlineClose:E,lightboxOpen:S,lightboxCloseSignal:L,onLightboxOpen:D,onLightboxClose:F,onLocalLinkOpen:cn}),$&&Q&&e.jsxs("button",{type:"button",onClick:dn,...Nt(nn,Zt),style:{top:Q.top,left:Q.left,transform:"translateY(-50%)"},className:lu(p,an),title:`Insert markdown reference: ${Wr}`,children:[e.jsx(Eo,{size:p?13:11}),fr?o("rightSidebar.copied"):ks?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:on??""})]})]}):$r?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Ab,{ref:je,src:np(Xe),title:`${dr.name} preview`,exitFullscreenLabel:o("rightSidebar.htmlFullscreenExit"),onFullscreenChange:Ue},`${Xe}:${lr}:${Jt}`)}):R.kind==="text"?e.jsxs("div",{ref:Me,onScroll:Ss,className:`${_l} 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:[Hr.length>0?e.jsx("div",{className:"min-w-full",children:Hr.map((T,K)=>{const ge=K+1,ke=!!($&&ge>=$.start&&ge<=$.end),nt=Ie&&Ie.length===Hr.length?Ie[K]:null;return e.jsxs("div",{ref:_e=>{_e?we.current.set(ge,_e):we.current.delete(ge)},role:"button","data-file-preview-line":ge,tabIndex:0,onClick:_e=>hr(_e,ge),onKeyDown:_e=>{_e.key!=="Enter"&&_e.key!==" "||(_e.preventDefault(),hr(_e,ge))},style:{gridTemplateColumns:`${zr}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${ke?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Ur}:${ge}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${ke?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:ge}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:nt??(T||" ")})]},K)})}):"Empty file.",$&&Q&&e.jsxs("button",{type:"button",onClick:dn,...Nt(nn,Zt),style:{top:Q.top,left:Q.left,transform:"translateY(-50%)"},className:lu(p,an),title:`Insert code reference: ${Wr}`,children:[e.jsx(Eo,{size:p?13:11}),fr?o("rightSidebar.copied"):ks?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:on??""})]})]}):null]})}function x0({rootPath:r,file:n,active:s,...l}){const[d,c]=a.useState(null),[m,g]=a.useState(n.line??1),f=a.useCallback(()=>g(null),[]);return e.jsx("div",{"data-architecture-source":!0,className:"h-full min-h-0",children:e.jsx(Fo,{...l,filePath:`${r.replace(/\/+$/,"")}/${n.path}`,active:s,lineRange:d,onLineRangeChange:c,scrollToLine:m,onScrollToLineHandled:f,markdownOutlineOpen:!1,markdownImageLightboxOpen:!1})})}function v0({isOpen:r,sessionId:n,drawerWidthPx:s,onClose:l,onOpen:d,push:c,pinned:m=!1,onTogglePinned:g,rightSidebarFilePreviewOpen:f=!1,rightSidebarFilePreviewCloseSignal:p,onOpenRightSidebarFilePreview:x,onCloseRightSidebarFilePreview:h,rightSidebarRepoPickerOpen:b=!1,rightSidebarRepoPickerCloseSignal:E,onOpenRightSidebarRepoPicker:S,onCloseRightSidebarRepoPicker:L,markdownOutlineOpen:D=!1,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:N,markdownImageLightboxOpen:A=!1,markdownImageLightboxCloseSignal:B,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j}){const{t:o,locale:_}=mt(),[I,Y]=a.useState(""),U=V(t=>t.pendingTerminalPath),[O,R]=a.useState(null),z=a.useRef(0),Z=V(t=>t.rightSearchOpen),P=V(t=>t.setRightSearchOpen),W=V(t=>t.rightSidebarLayoutPreference),J=V(t=>t.setRightSidebarLayoutPreference),[oe,pe]=a.useState(()=>ux()),[Se,we]=a.useState("."),[Me,Q]=a.useState(""),[be,ue]=a.useState(!1),[Be,Oe]=a.useState(!1),[G,je]=a.useState(!1),[ye,Ue]=a.useState(!1),Ye=a.useDeferredValue(I),[M,he]=a.useState(null),[fe,Ee]=a.useState([]),[$e,tt]=a.useState([]),ce=V(t=>t.contextKey?t.activeGitRepos[t.contextKey]??null:null),Te=V(t=>t.setActiveGitRepo),[Je,Ie]=a.useState(null),[De,te]=a.useState(null),[Re,rt]=a.useState(null),[We,Br]=a.useState(()=>gt(ju,na)??!1),[H,ne]=a.useState(()=>gt(Ru,na)??!1),[Ce,lt]=a.useState(()=>gt(Nu,na)??!1),[ct,Nt]=a.useState(()=>gt(el,ox)??""),[Zr,Nr]=a.useState(0),[lr,zt]=a.useState(!1),[Cr,Jt]=a.useState(!1),pa=a.useRef(null),Fn=a.useRef(null),[gs,cr]=a.useState(!1),[en,Ct]=a.useState(null),[Or,tn]=a.useState(null),[Xe,dr]=a.useState(()=>Pu(Qi)),[Ur,Hr]=a.useState(()=>Pu(Su)),[zr,Er]=a.useState(()=>ax()),[Tt,ga]=a.useState(()=>ix()),[Mr,bs]=a.useState(()=>cx()),ur="words",[xs,$r]=a.useState(0),[St,rn]=a.useState([]),[vs,ys]=a.useState([]),[ws,Wr]=a.useState(!1),[nn,Qt]=a.useState(null),[Zt,_n]=a.useState([]),[ks,sn]=a.useState(!1),[fr,an]=a.useState([]),[on,ln]=a.useState([]),[hr,mr]=a.useState(!1),[ve,er]=a.useState(null),[cn,Bn]=a.useState([]),[Ss,dn]=a.useState({}),It=a.useRef(0),[T,K]=a.useState(0),[ge,ke]=a.useState(!1),[nt,_e]=a.useState(null),[ze,Ge]=a.useState(null),[bt,vt]=a.useState(null),[un,tr]=a.useState(null),[Gr,js]=a.useState(!1),[Rs,pr]=a.useState(""),fn=a.useDeferredValue(Rs),[hn,Uo]=a.useState({}),[re,Ke]=a.useState([]),[Wt,Pr]=a.useState(!1),[ba,Ns]=a.useState(!1),[Ho,On]=a.useState(null),[zo,Un]=a.useState(!1),gr=a.useRef(null),Kr=a.useRef(0),Yl=a.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Rh,xa]=a.useState(null),[Cs,Xl]=a.useState(()=>gt(Zi,na)??!1),[Wo,Go]=a.useState(!1),[va,Ko]=a.useState([]),[rr,ya]=a.useState({}),[Et,wa]=a.useState({}),[mn,qo]=a.useState({}),[Jl,Ql]=a.useState(()=>new Set),[Qe,pn]=a.useState(null),[Vo,gn]=a.useState(null),[Nh,Ar]=a.useState(!1),[Yo,Lr]=a.useState(0),[,Xo]=a.useState(0),[Jo,ka]=a.useState(!1),[Ch,Eh]=a.useState(()=>V.getState().rightTab==="files"),[nr,Qo]=a.useState(!1),[Mh,Zl]=a.useState(()=>V.getState().rightTab==="diff"),[Zo,ec]=a.useState(()=>V.getState().rightTab==="android"),[qr,tc]=a.useState(!1),[sr,rc]=a.useState({architecture:!1,computer:!1}),Es=a.useRef(new Set),Sa=Wi(t=>t.docks[Ki]),$h=!!Sa,[qe,Ms]=a.useState(null),[Hn,$s]=a.useState(null),[yt,bn]=a.useState(null),[nc,Gt]=a.useState(null),[zn,sc]=a.useState(null),[ei,Ph]=a.useState(()=>Date.now()),[Ah,Lh]=a.useState(!1),[xn,ja]=a.useState(!1),[Ra,ac]=a.useState(""),[Wn,Na]=a.useState(""),[vn,Ca]=a.useState(""),[yn,Ea]=a.useState(""),[oc,Gn]=a.useState(null),[ic,ti]=a.useState(!1),[lc,cc]=a.useState(!1),[Ma,Th]=a.useState({key:null,nonce:0}),dc=a.useRef(null),uc=a.useRef(null),se=pp(s,m,W),ri=Df(se,m,Mr),[ni,si]=a.useState(()=>xx(s)),ai=V(t=>t.rightTab),Dt=V(t=>t.setRightTab),v=V(t=>t.rootPath),Kn=V(t=>t.explorerRoot),fc=V(t=>t.pinnedExplorerRootsCache),hc=V(t=>t.hydratePinnedExplorerRoots),mc=V(t=>t.syncPinnedExplorerRoots),Ft=V(t=>t.setExplorerRoot),pc=V(t=>t.resetExplorerToProject),qn=V(t=>t.pinExplorerRoot),wn=V(t=>t.unpinExplorerRoot),at=V(t=>t.selectedFilePath),ot=V(t=>t.selectFile),oi=V(t=>t.showHiddenFiles),Ih=V(t=>t.toggleShowHiddenFiles),ii=V(t=>!!(v&&t.nestedGitScanRoots[v])),Fe=V(t=>t.changedFiles),$a=V(t=>t.setChangedFiles),Ps=V(t=>t.invalidateDirectoryCache),Dh=V(t=>t.setDirectorySortMode),gc=V(t=>t.applyFileWatchEvents),bc=V(t=>t.reconcileDirectoryCache),xc=V(t=>t.bumpFileWatchEpoch),br=V(t=>t.gitBundleLoading),vc=V(t=>t.gitBundleSlow),kn=V(t=>t.gitBundleError),Vn=V(t=>t.gitBundleLastLoadedAt),yc=V(t=>t.beginGitBundleLoading),wc=V(t=>t.setGitBundleSlowFor),li=V(t=>t.finishGitBundleLoading),Pa=V(t=>t.resetGitBundleLoading),ci=V(t=>t.setGitBundleError),kc=V(t=>t.markGitBundleLoaded),ie=Kn??v,Aa=V(t=>!!(ie&&t.hideGitIgnoredRoots[ie])),Fh=V(t=>t.hideGitIgnoredRootsHydrated),_h=V(t=>t.setHideGitIgnoredRoot),[di,Sc]=a.useState(!1),[jc,ui]=a.useState(null);a.useEffect(()=>{ui(null)},[ie]);const Rc=a.useMemo(()=>ie?_b(ie,Se):"",[ie,Se]),As=a.useMemo(()=>Fb(Me),[Me]),Nc=a.useMemo(()=>({excludePatterns:As,caseSensitive:Be,wholeWord:G,regex:ye}),[Be,As,ye,G]),La=V(t=>ie?t.fileSortModes[ie]??"name":"name"),Cc=V(t=>!!(ie&&t.directoryCache.has(ie))),Yn=a.useRef(null),jt=a.useRef(0),[Ec]=a.useState(()=>++f0),Tr=a.useRef(null),Vr=a.useRef(null),Ta=a.useRef(0),Kt=a.useRef(new Map),qt=a.useRef(new Map),xr=a.useRef(new Set),Sn=a.useRef(new Set),jn=a.useRef(0),Yr=a.useRef(null),Xn=a.useRef(0),Jn=a.useRef(null),Qn=a.useRef(0),Xr=a.useRef(null),fi=a.useRef(new Set),hi=a.useRef(null),mi=a.useRef(null),Ia=a.useRef(null),pi=a.useRef(null),gi=a.useRef(null),Ls=a.useRef(new Set);a.useEffect(()=>{if(zn===null)return;const t=Math.max(0,Date.now()-zn),i=t<6e4?1e3:t<36e5?6e4:t<864e5?36e5:864e5,u=Math.max(50,i-t%i),w=window.setTimeout(()=>Ph(Date.now()),u);return()=>window.clearTimeout(w)},[ei,zn]);const Da=a.useRef(null),Ir=a.useRef(null),bi=a.useRef(null),Mc=a.useRef(null),Ts=a.useRef(null),Pe=a.useCallback(t=>V.getState().rootPath===t,[]);a.useEffect(()=>{if(!r||typeof window>"u")return;const t=i=>{const u=g0(i.target);u&&ea("global_change_row_event",{...b0(i),selectionPath:u.dataset.diffSelectionPath,filePath:u.dataset.diffFilePath,absolutePath:u.dataset.diffAbsolutePath,repoRoot:u.dataset.diffRepoRoot,status:u.dataset.diffStatus,selectedFilePath:V.getState().selectedFilePath,rightTab:V.getState().rightTab,activeGitRepoRoot:ce,changedFiles:V.getState().changedFiles.size})};return window.addEventListener("pointerdown",t,{capture:!0}),window.addEventListener("click",t,{capture:!0}),()=>{window.removeEventListener("pointerdown",t,{capture:!0}),window.removeEventListener("click",t,{capture:!0})}},[ce,r]);const $c=a.useCallback(async(t=v??void 0)=>{if(!t)return null;if(xr.current.has(t)||Sn.current.has(t))return ut("untracked_skip_cached",{cwd:t,rootPath:v,completed:xr.current.has(t),running:Sn.current.has(t)}),null;const i=v,u=Ta.current+1;Ta.current=u,Kt.current.set(t,u);const w=`right-sidebar-git-untracked:${t}`,y=new AbortController;qt.current.set(t,y),Sn.current.add(t),ut("untracked_start",{requestId:u,cwd:t,rootPath:v});try{let k=await zd(t,y.signal,w),C=0;for(;k.status==="running"&&C<120;){if(Kt.current.get(t)!==u||y.signal.aborted)return ut("untracked_stale_result",{requestId:u,activeRequestId:Kt.current.get(t),cwd:t,status:k.status}),null;if(!Pe(i))return ut("untracked_root_changed",{requestId:u,cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath}),null;await new Promise(ae=>window.setTimeout(ae,C<10?1e3:3e3)),C+=1,k=await zd(t,y.signal,w)}if(Kt.current.get(t)!==u||!Pe(i))return ut("untracked_stale_result",{requestId:u,activeRequestId:Kt.current.get(t),cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath,files:k.files.length,status:k.status}),null;if(k.status==="done")return $a(xh(V.getState().changedFiles,k.files)),k.files.length>0&&Ee(ae=>{const Ae=new Map(ae.map(me=>[me.root,me])).get(t);if(!Ae)return ae;const Ze=e0(Ae.files,k.files),ee=ae.map(me=>me.root===t?{...me,files:Ze,context:me.context?{...me.context,changedFiles:Ze.map(Le=>({path:Le.path,absolutePath:Le.absolutePath,status:Le.status})),truncated:!1}:me.context,untrackedDeferred:!1}:me);tt(vh(ee,v));const X=ee.find(me=>me.root===v);return X?.context&&he(me=>me?.root===X.root?{...me,...X.context}:me),ee}),xr.current.add(t),ut("untracked_apply",{requestId:u,cwd:t,files:k.files.length}),k;const le=k.error||(k.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return xr.current.add(t),ut("untracked_error",{requestId:u,cwd:t,message:le,code:k.code,status:k.status}),null}catch(k){if(Kt.current.get(t)!==u||!Pe(i)||jr(k))return ut("untracked_aborted",{requestId:u,activeRequestId:Kt.current.get(t),cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath,message:k instanceof Error?k.message:String(k)}),null;const C=k instanceof Error?k.message:"Failed to scan untracked files";return xr.current.add(t),ut("untracked_error",{requestId:u,cwd:t,message:C}),null}finally{qt.current.get(t)===y&&qt.current.delete(t),Kt.current.get(t)===u&&Kt.current.delete(t),Sn.current.delete(t)}},[M,Pe,v,$a]),ar=a.useMemo(()=>{const t=new Set($e.map(u=>u.root)),i=Zt.filter(u=>t.has(u));return i.length>0?i:ce?[ce]:[]},[ce,Zt,$e]),Pc=ar.length===0,Rn=a.useMemo(()=>ar.map(t=>fe.find(i=>i.root===t)).filter(t=>!!t),[ar,fe]),Bh=a.useMemo(()=>$e.map(t=>({root:t.root,label:t.label,branch:t.branch??null})),[$e]),vr=a.useCallback(async()=>{if(!v){rn([]),ys([]);return}const t=v,i=Xn.current+1;Xn.current=i,Jn.current?.abort();const u=new AbortController;Jn.current=u,Wr(St.length===0),Qt(null);try{const w=ar.length>0?await Promise.all(ar.map(y=>Wd({workspaceRoot:v,repoRoot:y},u.signal))).then(y=>({records:y.flatMap(k=>k.records),walkthroughs:y.flatMap(k=>k.walkthroughs??[])})):await Wd({workspaceRoot:v},u.signal);if(Xn.current!==i||!Pe(t))return;rn(w.records),ys(w.walkthroughs??[])}catch(w){if(Xn.current!==i||!Pe(t)||jr(w))return;Qt(w instanceof Error?w.message:"Failed to load change audit explanations")}finally{Jn.current===u&&(Jn.current=null),Xn.current===i&&Pe(t)&&Wr(!1)}},[St.length,ar,Pe,v]),Fa=a.useCallback(async(t,i,u)=>{if(!t&&!v){an([]),ln([]);return}const w=v,y=Qn.current+1;Qn.current=y,Xr.current?.abort();const k=new AbortController;Xr.current=k;try{const C=t?[t]:Array.from(new Set([v,...fe.map(ae=>ae.root)].filter(ae=>!!ae))),le=await Promise.all(C.map(ae=>ap({repoRoot:ae,baseRef:i,branchName:u},k.signal))).then(ae=>{const xe=new Map,Ae=new Map;for(const Ze of ae){for(const ee of Ze.records)xe.set(ee.id,ee);for(const ee of Ze.walkthroughs??[])Ae.set(ee.id,ee)}return{records:Array.from(xe.values()),walkthroughs:Array.from(Ae.values())}});if(Qn.current!==y||!Pe(w))return;an(le.records),ln(le.walkthroughs??[])}catch(C){if(Qn.current!==y||!Pe(w)||jr(C))return;console.warn("[RightSidebar] Failed to load branch explanations",C)}finally{Xr.current===k&&(Xr.current=null)}},[fe,Pe,v]),Zn=a.useCallback((t,i={})=>{if(!Pe(v)){ut("apply_skipped_root_changed",{expectedRootPath:v,currentRootPath:V.getState().rootPath,bundleRoot:t.context?.root,files:t.files.length});return}ut(t.files.length===0?"empty_bundle":"apply",{rootPath:v,available:t.available,files:t.files.length,repositories:t.repositories?.map(X=>({root:X.root,relativeRoot:X.relativeRoot,files:X.files.length,available:X.available,error:X.error})),repoFilters:t.repoFilters?.map(X=>({root:X.root,label:X.label,count:X.count})),cached:t.cached,stale:t.stale,cacheAgeMs:t.cacheAgeMs,untrackedDeferred:t.untrackedDeferred,error:t.error});let u=Ff(t),w=t.repoFilters??[],y=t.files;const k=V.getState().changedFiles;if(!!(i.cacheOnly&&!t.cached&&t.files.length===0&&u.length===0)&&(k.size>0||fe.length>0||M)){ut("cache_only_apply_skipped_empty_backend_cache",{rootPath:v,currentFiles:k.size,currentRepositories:fe.length});return}const le=u.some(X=>X.deferred);if(le&&!i.replaceWorkspace){const X=new Set(u.filter(Le=>!Le.deferred||Le.root===v).map(Le=>Le.root));y=[...Array.from(k.values()).filter(Le=>!X.has(xt(Le,v)??"")),...t.files]}const ae=Hu(k.values(),v),xe=Hu(t.files,v),Ae=u.some(X=>X.root!==v);if(!!(i.background&&!le&&!i.replaceWorkspace&&k.size>0&&(t.files.length===0&&!t.error||ae>0&&xe===0&&!Ae))){ut("background_apply_skipped_degraded_bundle",{rootPath:v,currentFiles:k.size,nextFiles:t.files.length,currentNestedCount:ae,nextNestedCount:xe,nextRepositories:u.map(X=>({root:X.root,relativeRoot:X.relativeRoot,files:X.files.length})),cached:t.cached,stale:t.stale,error:t.error});return}if(i.replaceRepoRoot){const X=yh(k.values(),fe,t,i.replaceRepoRoot,v);y=X.files,u=X.repositories,w=X.repoFilters}if($a(bh(y)),Ee(X=>{if(!le||i.replaceWorkspace)return u;const me=new Map(X.map(Le=>[Le.root,Le]));return u.map(Le=>{const Ve=me.get(Le.root);return!Le.deferred||!Ve?Le:{...Le,available:Ve.available,files:Ve.files,context:Ve.context,deferred:Ve.deferred,untrackedDeferred:Ve.untrackedDeferred,error:Ve.error}})}),tt(w),gi.current=v,i.syncActiveRepo!==!1){const{contextKey:X,activeGitRepos:me}=V.getState(),Le=X?me[X]??null:null,Ve=i.activeRepoRoot!==void 0?i.activeRepoRoot:Le,He=fx({...t,repositories:u,repoFilters:w},Ve);Te(He)}typeof t.cacheUpdatedAt=="number"&&sc(t.cacheUpdatedAt),he(X=>{if(i.replaceRepoRoot&&i.replaceRepoRoot!==v)return X;if(!t.context)return null;const me=X?.root??v;return!X?.available||me!==(t.context.root??v)?t.context:{...X,...t.context}}),i.reloadDiff&&$r(X=>X+1);const ee=V.getState().selectedFilePath;if(ee&&!ee.startsWith("/")&&!y.some(X=>X.path===ee||X.absolutePath===ee)&&ot(null),dr(X=>{const me=new Set(y.map(Ve=>xt(Ve,v)).filter(Boolean)),Le=new Set;for(const Ve of X)me.has(Ve)&&Le.add(Ve);return rl(Qi,Le),Le}),i.loadDeferred!==!1){const X=u.filter(me=>me.untrackedDeferred&&me.root).map(me=>me.root);for(const me of X)$c(me)}i.loadAudit!==!1&&vr()},[Pe,vr,$c,v,ot,Te,$a]);a.useEffect(()=>{Pa(),hi.current=null,mi.current=v;const t=[],i=[];jt.current+=1,jn.current+=1,Ta.current+=1,Tr.current?.abort(),Rt(Qs(Vr.current?.cwd??v??void 0)),Vr.current=null,Tr.current=null,Yr.current?.abort(),Rt("right-sidebar-git-details"),Yr.current=null;for(const C of qt.current.values())C.abort();for(const C of qt.current.keys())Rt(`right-sidebar-git-untracked:${C}`);qt.current.clear(),Kt.current.clear(),Xn.current+=1,Jn.current?.abort(),Jn.current=null,Qn.current+=1,Xr.current?.abort(),Xr.current=null,Kr.current+=1,gr.current?.abort(),Rt("right-sidebar-recent-commits"),gr.current=null,rn([]),ys([]),Wr(!1),Qt(null),_n([]),sn(!1),an([]),ln([]),mr(!1),er(null),ke(!1),_e(null),Ge(null),vt(null),tr(null),js(!1),pr(""),Ke([]),Pr(!1),Ns(!1),On(null),Un(!1),xa(null),pn(null),gn(null),Xl(!1),At(Zi,!1),Go(!1);const u=v?Au()[v]:null,w=u?.previewEntries??[],y=u?.selectedPreviewKey??null,k=y?w.find(C=>C.key===y)??null:null;++It.current,ke(!1),Ko(u?.selectedRepoRoots??[]),ya(u?.repoTargetBranches??{}),wa(u?.repoBaseBranches??{}),Bn(w),dn(u?.previewScrollTops??{}),k&&u?.previewDetailOpen&&(k.diff.hunks?.length??0)>0&&(er(k.diff),pn(k.key),gn(u.selectedPreviewFileKey??(k.diff.hunks?.[0]?`${k.diff.hunks[0].filePath}\0${k.diff.hunks[0].hunkHeader}\0${k.diff.hunks[0].hunkIndex}`:null)),mr(!0)),qo(u?.repoIncludeUncommitted??Object.fromEntries(Object.keys(u?.repoTargetBranches??{}).map(C=>[C,u?.includeUncommitted??!0]))),hi.current=v,ja(!1),xr.current.clear(),Sn.current.clear(),Ms(null),$s(null),bn(null),Gt(null),sc(null),Ee(t),tt(i),he(null),pi.current=null,gi.current=null,Ls.current.clear()},[Pa,v]);const _t=a.useCallback(async(t=v??void 0,i={})=>{if(!t)return null;const u=v,w=jt.current;if(await gg(()=>Promise.all([V.getState().hydrateNestedGitScanRoots(),V.getState().hydrateActiveGitRepos()]).then(()=>{})),jt.current!==w||!Pe(u))return null;const y=t===v&&Xs(v),k=i.includeNested??y,C=i.refresh??i.reloadDiff??!1,le=i.cacheOnly??!1,ae=i.background??!1,xe=k&&(i.discoverOnly??!1);C&&xr.current.clear();const Ae=Vr.current;if(Ae&&Ae.cwd===t&&Ae.includeNested===k&&Ae.refresh===C&&Ae.cacheOnly===le&&Ae.discoverOnly===xe)return ut("reuse_pending",{cwd:t,includeNested:k,refresh:C,cacheOnly:le,discoverOnly:xe}),Ae.promise;const Ze=jt.current+1;jt.current=Ze;const ee=`right-sidebar:${Ec}:${Ze}`;Tr.current?.abort();const X=Qs(t);Rt(X);const me=new AbortController;Tr.current=me;let Le=null;ae||yc(ee),ci(null),ut("start",{requestId:Ze,cwd:t,rootPath:v,requestSlotId:X,includeNested:k,refresh:C,cacheOnly:le,background:ae,existingChanges:Fe.size,lastLoadedAt:Vn}),!ae&&typeof window<"u"&&(Le=window.setTimeout(()=>{jt.current===Ze&&wc(ee,!0)},qb));const Ve=(async()=>{const He=await Gi(t,me.signal,{includeNested:k,refresh:C,cacheOnly:le,discoverOnly:xe,action:C?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:X,requestTimeoutMs:C?null:void 0});if(n0(He)){if(ut("cancelled_result_ignored",{requestId:Ze,activeRequestId:jt.current,cwd:t,error:He.error??He.context?.error}),me.signal.aborted)return null;throw new Error(He.error??He.context?.error??"Failed to load Git changes")}return jt.current!==Ze||!Pe(u)?(ut("stale_result",{requestId:Ze,activeRequestId:jt.current,cwd:t,expectedRootPath:u,currentRootPath:V.getState().rootPath,files:He.files.length,repositories:He.repositories?.length??0}),null):(Zn(He,{reloadDiff:i.reloadDiff,syncActiveRepo:i.replaceWorkspace?!0:k,background:ae,cacheOnly:le,replaceRepoRoot:i.replaceRepoRoot,replaceWorkspace:i.replaceWorkspace}),He)})();Vr.current={cwd:t,includeNested:k,refresh:C,cacheOnly:le,discoverOnly:xe,promise:Ve};try{const He=await Ve;return jt.current===Ze&&He&&Pe(u)?kc({cached:He.cached,stale:He.stale,cacheAgeMs:He.cacheAgeMs,nestedDeferred:!k||He.nestedDeferred,untrackedDeferred:He.untrackedDeferred}):jt.current===Ze&&Pe(u)&&li(ee),He}catch(He){return jt.current!==Ze||!Pe(u)||me.signal.aborted?(ut("aborted",{requestId:Ze,activeRequestId:jt.current,cwd:t,expectedRootPath:u,currentRootPath:V.getState().rootPath,message:He instanceof Error?He.message:String(He)}),null):(ut("error",{requestId:Ze,cwd:t,includeNested:k,refresh:C,background:ae,message:He instanceof Error?He.message:String(He)}),ae||(he(null),ci(He instanceof Error?He.message:"Failed to load Git changes")),null)}finally{Le!==null&&window.clearTimeout(Le),Tr.current===me&&(Tr.current=null),Vr.current?.promise===Ve&&(Vr.current=null),!ae&&jt.current===Ze&&Pe(u)&&li(ee)}},[Zn,yc,Fe.size,li,Ec,Vn,Pe,kc,v,ci,wc]),es=a.useCallback(async()=>{v&&await _t(v,{reloadDiff:!0,refresh:!0})},[_t,v]),xi=a.useCallback(async(t=v??void 0)=>{if(!t)return null;const i=v,u=jn.current+1;jn.current=u,Yr.current?.abort(),Rt("right-sidebar-git-details");const w=new AbortController;Yr.current=w,ja(!0);try{const y=await Gd(t,w.signal,"load_git_details","right-sidebar-git-details");return jn.current!==u||!Pe(i)?null:(Ee(k=>k.map(C=>C.root===y.root?{...C,available:y.available,context:y,error:y.error}:C)),he(k=>k?.root&&y.root&&k.root!==y.root?k:!k?.available||!y.available?y:{...k,...y}),y)}catch(y){return jr(y)||!Pe(i)||jn.current===u&&Gt(y instanceof Error?y.message:"Failed to load Git details"),null}finally{Yr.current===w&&(Yr.current=null),jn.current===u&&Pe(i)&&ja(!1)}},[Pe,v]);a.useEffect(()=>{if(!r){jt.current+=1,Pa(),pi.current=null,jn.current+=1,Ta.current+=1,Tr.current?.abort(),Rt(Qs(Vr.current?.cwd??v??void 0)),Vr.current=null,Tr.current=null,Yr.current?.abort(),Rt("right-sidebar-git-details"),Yr.current=null;for(const t of qt.current.values())t.abort();for(const t of qt.current.keys())Rt(`right-sidebar-git-untracked:${t}`);qt.current.clear(),Kt.current.clear(),Qn.current+=1,Xr.current?.abort(),Xr.current=null,Kr.current+=1,gr.current?.abort(),Rt("right-sidebar-recent-commits"),gr.current=null,ja(!1),ke(!1),_e(null),Ge(null),vt(null),tr(null),js(!1),pr(""),Ke([]),Pr(!1),Ns(!1),On(null),Un(!1),Y(""),P(!1),Ct(null),Qo(!1),se&&Zl(!1)}},[se,r,Pa,P]),a.useEffect(()=>{if(!Z)return;const t=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(t)},[Z]),a.useEffect(()=>{se||Ar(!1)},[se]);const Ac=a.useCallback(t=>{Xo(t);const i=bi.current;i&&(i.update(),i.slideTo(t,0),window.requestAnimationFrame(()=>{i.update(),i.slideTo(t,0)}))},[]);a.useEffect(()=>{if(se)if(Ar(f),f&&at){Lr(1);const t=Ir.current;t&&(t.update(),t.activeIndex!==1&&(Ts.current=1,t.slideTo(1,0)))}else{Lr(0);const t=Ir.current;t&&t.activeIndex!==0&&(Ts.current=0,t.slideTo(0,0)),Ct(null)}},[se,f,v,at]),a.useEffect(()=>{if(p!==void 0&&!f){Lr(0);const t=Ir.current;t&&t.activeIndex!==0&&(Ts.current=0,t.slideTo(0,0)),Ar(!1),Ct(null)}},[p,f]),a.useEffect(()=>{E!==void 0&&Ie(null)},[E]),a.useEffect(()=>{!se&&f&&h?.()},[se,h,f]),a.useEffect(()=>{si(t=>Cl(t,s))},[s]);const Oh=a.useCallback(t=>{se||(t.preventDefault(),Da.current={startX:t.clientX,startWidth:ni,pointerId:t.pointerId},t.currentTarget.setPointerCapture(t.pointerId))},[ni,se]),Uh=a.useCallback(t=>{const i=Da.current;if(!i||i.pointerId!==t.pointerId)return;const u=Cl(i.startWidth+t.clientX-i.startX,s);si(u),sa(ra,u,Kb)},[s]),Lc=a.useCallback(t=>{const i=Da.current;if(!(!i||i.pointerId!==t.pointerId)){Da.current=null,Ys(ra);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}},[]),ts=!!(v&&Vn!==null&&Gu(M)),vi=!!(v&&!kn&&Fe.size===0&&Vn===null),Mt=(()=>{let t=ai;return t==="android"&&!qr&&(t="files"),(t==="architecture"||t==="computer")&&!sr[t]&&(t="files"),ts&&(t==="git"||t==="diff")&&(t="files"),t})(),dt=Mt==="git",Dr=Mt==="files",$t=Mt==="diff",rs=Mt==="android",ns=Mt==="computer",Nn=Mt==="architecture",[Hh,zh]=a.useState(!1);a.useEffect(()=>{r&&ns&&zh(!0)},[r,ns]);const[Wh,Gh]=a.useState(!1);a.useEffect(()=>{r&&Nn&&Gh(!0)},[r,Nn]);const yi=a.useRef(null),ss=a.useCallback((t,i)=>{const u=V.getState().rightTab;if(u===t)return;const w=performance.now(),y=w-i.timeStamp;yi.current={from:u,to:t,startedAt:w,inputDelayMs:y>=0&&y<6e4?Math.round(y):null},Dt(t)},[Dt]);a.useEffect(()=>{const t=yi.current;if(!t||t.to!==Mt)return;yi.current=null;const i=Math.round(performance.now()-t.startedAt);let u=window.requestAnimationFrame(()=>{u=window.requestAnimationFrame(()=>{ea("tab_switch_presented",{from:t.from,to:t.to,inputDelayMs:t.inputDelayMs,commitMs:i,frameMs:Math.round(performance.now()-t.startedAt)})})});return()=>window.cancelAnimationFrame(u)},[Mt]);const Kh=Ep(t=>t.overlay==="sidebar")&&rs;a.useEffect(()=>{if(!se){ka(!0);return}if(!r){const i=window.setTimeout(()=>{ka(!1)},Xb);return()=>window.clearTimeout(i)}ka(!1);const t=window.setTimeout(()=>{ka(!0)},Yb);return()=>window.clearTimeout(t)},[se,r]),a.useEffect(()=>{if(!se||!$t)return;const t=bi.current;if(!t)return;const i=window.requestAnimationFrame(()=>{t.update()});return()=>window.cancelAnimationFrame(i)},[$t,se]),a.useEffect(()=>{if(!ts||!v||br)return;const t=window.setTimeout(()=>{_t(v,{background:!0})},3e3);return()=>window.clearTimeout(t)},[ts,v,br,_t]);const qh=a.useCallback(t=>{_t(t,{discoverOnly:!0})},[_t]);bg({active:r&&(dt||$t),rootPath:v,loading:br,delay:dt&&!se?0:tl,lastStartedRoot:pi,load:qh}),a.useEffect(()=>{!r||!dt||(!se||Jo)&&Qo(!0)},[dt,se,r,Jo]),a.useEffect(()=>{if(!r||dt)return;const t=window.setTimeout(()=>{Qo(!0)},tl);return()=>window.clearTimeout(t)},[dt,r]),a.useEffect(()=>{Dr&&Eh(!0)},[Dr]),a.useEffect(()=>{$t&&Zl(!0)},[$t]),a.useEffect(()=>{!r||!rs||(n&&Sa&&Sa.sessionId!==n&&(Wi.getState().setDock(Ki,null),ta({androidPanel:{docked:null}}).catch(()=>{})),ec(!0))},[rs,r,n,Sa]),a.useEffect(()=>{if(r&&rs||!Zo)return;const t=window.setTimeout(()=>ec(!1),Vb);return()=>window.clearTimeout(t)},[r,rs,Zo]),a.useEffect(()=>{let t=!1;return Yu().then(i=>{t||(Es.current.has("android")||tc(i.androidPanel?.enabled===!0),rc(u=>({architecture:Es.current.has("architecture")?u.architecture:i.rightSidebarTabs?.architecture===!0,computer:Es.current.has("computer")?u.computer:i.rightSidebarTabs?.computer===!0})))}).catch(()=>{}),()=>{t=!0}},[]);const Tc=a.useCallback(t=>{Es.current.add("android"),tc(t),t?Dt("android"):V.getState().rightTab==="android"&&Dt("files"),ta({androidPanel:{enabled:t}}).catch(()=>{})},[Dt]),Vh=a.useCallback((t,i)=>{Es.current.add(t),rc(u=>({...u,[t]:i})),i?Dt(t):V.getState().rightTab===t&&Dt("files"),ta({rightSidebarTabs:{[t]:i}}).catch(()=>{})},[Dt]),Ic=a.useCallback(t=>{ie&&Yx(ie,t.currentTarget.scrollTop)},[ie]);a.useEffect(()=>()=>{Tr.current?.abort(),Ys(Dl),Ys(Fl),Ys(ra),Ys(el)},[]),a.useEffect(()=>{if(!ie||!Cc)return;const t=ph()[ie]?.top;if(typeof t!="number")return;let i=window.requestAnimationFrame(()=>{Yn.current&&(Yn.current.scrollTop=t),i=window.requestAnimationFrame(()=>{Yn.current&&(Yn.current.scrollTop=t)})});return()=>window.cancelAnimationFrame(i)},[ie,Cc]),a.useEffect(()=>{if(!r)return;const t=new AbortController;return op(t.signal).then(i=>cc(!!i.available)).catch(()=>cc(!1)),()=>t.abort()},[r]);const Is=a.useCallback(t=>{if(R(null),ot(t),Ct(null),se){Ar(!0),Lr(1),Ir.current?.slideTo(1),x?.();return}},[se,x,ot]),wi=a.useCallback((t,i)=>{if(R(null),ot(t),tn(i),se){Ar(!0),Lr(1),Ir.current?.slideTo(1),x?.();return}},[se,x,ot]),Bt=Yg(t=>Ps(t,!1)),_a=Bt.busy,Ds=a.useCallback(async(t,i)=>{const u=i||Kn||v;!u||!t.length||await Bt.start(u,t)},[Kn,v,Bt.start]),Dc=a.useCallback(async t=>{try{await ip(t)}catch(i){Gt(i instanceof Error?i.message:o("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>Gt(null),4e3)}},[o]),Ba=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes("Files")&&ti(!0)},[]),Fc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),ti(!1)},[]),_c=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),ti(!1);const i=t.dataTransfer.files;i.length>0&&Ds(Array.from(i))},[Ds]),ki=a.useCallback(t=>{te(t),window.setTimeout(()=>te(i=>i===t?null:i),1400)},[]),yr=a.useCallback(t=>{rt(t),window.setTimeout(()=>rt(i=>i===t?null:i),1400)},[]);a.useEffect(()=>{At(ju,We)},[We]),a.useEffect(()=>{At(Ru,H)},[H]),a.useEffect(()=>{At(Nu,Ce)},[Ce]),a.useEffect(()=>{sa(el,ct,Ub)},[ct]),a.useEffect(()=>(hc().catch(()=>{}),Kd(t=>{t.type==="pinned-explorer-roots"&&mc(t.pinnedExplorerRoots)})),[hc,mc]);const Bc=a.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),Oa=a.useRef(null),Cn=a.useRef(null),[Oc,Si]=a.useState(!1);a.useEffect(()=>{if(!r)return;Si(!1);let t=!1;lp().then(u=>{t||(Oa.current=u.text,Nt(w=>u.text&&u.text!==w?u.text:w),Si(!0))}).catch(()=>{t||Si(!0)});const i=Kd(u=>{u.type==="context-draft"&&u.origin!==Bc.current&&(Oa.current=u.text,Nt(u.text))});return()=>{t=!0,i(),Cn.current!==null&&(window.clearTimeout(Cn.current),Cn.current=null)}},[r]),a.useEffect(()=>{if(!Oc||Oa.current===ct)return;Cn.current!==null&&window.clearTimeout(Cn.current);const t=ct;Cn.current=window.setTimeout(()=>{Cn.current=null,cp(t,Bc.current).then(()=>{Oa.current=t}).catch(()=>{})},500)},[ct,Oc]);const as=a.useCallback(async(t,i,u,w)=>{if(!t)return!1;if(dp(u?t+u:t))return ki(i),!0;if(We)Nt(y=>Kg(y,t)+(u??"")),window.matchMedia("(pointer: coarse)").matches||(ne(!1),Nr(y=>y+1));else{const y=n??Jr.getState().activeSessionId;if(!await ef(u?t+u:t,y,()=>Fs.current&&y===Jr.getState().activeSessionId,w))return!1}return ki(i),!0},[We,ki,n]),Ua=a.useCallback(t=>{const i=Tn(t,v);return Mp(i,v)},[v]),ji=mf(yr),Ot=a.useCallback((t,i,u)=>{const w=Tn(t,v);return as($p(w,v),i??`path:${w}`,void 0,u)},[v,as]),Ha=a.useRef({sessionId:n,contextDraftEnabled:We,isOpen:r});Ha.current={sessionId:n,contextDraftEnabled:We,isOpen:r};const Yh=a.useCallback(async t=>{const i=n??Jr.getState().activeSessionId,u=()=>Fs.current&&Ha.current.isOpen&&(Ha.current.sessionId??Jr.getState().activeSessionId)===i&&Jr.getState().activeSessionId===i&&Ha.current.contextDraftEnabled===We;await Bt.start("/tmp",[t],y=>Ot(y,`path:${y}`),u)&&u()&&se&&!We&&l()},[We,Ot,se,l,n,Bt.start]),za=a.useRef(!0),Ri=a.useRef(n);Ri.current=n,a.useEffect(()=>(za.current=!0,()=>{za.current=!1}),[]);const Xh=a.useCallback(t=>{Pp.getState().enqueue(t,n??null,v||"/",i=>{if(We&&za.current&&Ri.current===n)Ot(i);else return tu(i,n)})},[n,v,We,Ot]),Jh=a.useCallback(async t=>{const u=(await fl("/tmp",[t])).files[0]?.path;if(!u)throw new Error("截图上传未返回文件路径");We&&za.current&&Ri.current===n?Ot(u):await tu(u,n)},[We,Ot,n]),or=a.useCallback((t,i,u)=>{if(!t)return Promise.resolve(!1);const w=t.includes(`
1659
+ `})(),Qt=`path:${Xe}`,Zt=$?`path:${Xe}:${$.start}-${$.end}`:Qt,_n=A===Qt,ks=A===Zt,sn=B===Qt,fr=B===Zt,an=ks||fr,on=$?$.start===$.end?`L${$.start}`:`L${$.start}-${$.end}`:null,ln=T=>{const K=Me.current;if(!K)return;const ge=K.getBoundingClientRect(),ke=T.currentTarget.getBoundingClientRect(),nt=T.clientX||ke.left+ke.width/2,ze=(T.clientY||ke.top+ke.height/2)-ge.top+K.scrollTop,Ge=p?116:132,bt=K.scrollLeft+Math.max(8,K.clientWidth-Ge),vt=Math.min(Math.max(8,nt-ge.left+K.scrollLeft+10),bt);be({top:ze,left:vt})},hr=(T,K)=>{gl()||(ln(T),N(ge=>{const ke=bl(ge,K,K);return ke||be(null),ke}))},mr=(T,K,ge)=>{ln(T),N(ke=>{const nt=bl(ke,K,ge);return nt||be(null),nt})},ve=(T,K,ge,ke)=>{ke==="end"&&ln(T),N({start:K,end:ge})},er=T=>{const{scrollTop:K,scrollLeft:ge}=T.currentTarget;fe(K),al(U,n,{top:K,left:ge,markdownTop:K})},cn=T=>{if(T.directory){f?.(T.path);return}if(T.path===Xe||R.kind==="text"&&T.path===R.sourcePath){T.fragment&&gs(T.fragment);return}$e(K=>[...K,Xe]),Te.current=T.path,ce(T.fragment),N(null),O(T.path)},Bn=()=>{const T=Ee[Ee.length-1];T&&($e(K=>K.slice(0,-1)),Te.current=T,ce(null),N(null),O(T))},Ss=T=>{const{scrollTop:K,scrollLeft:ge}=T.currentTarget;al(U,n,{top:K,left:ge})},dn=T=>{if(r){r(nn,Zt);return}$&&d(nn,Zt,T.currentTarget)},It=()=>{if(!(R.kind==="loading"||R.kind==="error"))return te.start()};return e.jsxs("div",{ref:_,tabIndex:-1,onKeyDown:tn,onFocusCapture:()=>{s&&Re&&We.trim()&&Ji(H,Ce,I.current)},onPointerDownCapture:T=>{T.target instanceof Element&&!T.target.closest('button, input, textarea, select, a, [tabindex]:not([tabindex="-1"])')&&T.currentTarget.focus({preventScroll:!0})},className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[Nt.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${p&&(ur||$r)?"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&&g&&e.jsx("button",{type:"button",onClick:g,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":o("rightSidebar.backToFileList"),title:o("rightSidebar.backToFileList"),children:e.jsx(af,{size:16})}),Ee.length>0&&e.jsxs("button",{type:"button",onClick:Bn,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":o("rightSidebar.backToPreviousPreview"),title:o("rightSidebar.backToPreviousPreview"),children:[e.jsx(la,{size:15}),!p&&e.jsx("span",{className:"text-[11px] font-medium",children:o("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:Xe,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:dr.name}),dr.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:dr.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[cr&&e.jsx("button",{type:"button",onClick:Re?en:Ct,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":o("rightSidebar.findInFile"),title:`${o("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(ms,{size:14})}),Tt&&R.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{x&&E?.(),Be(T=>{const K=T==="preview"?"source":"preview";return At(Nf,K),K}),N(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":o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:p?ue==="preview"?e.jsx(vl,{size:14}):e.jsx(xl,{size:14}):o(ue==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),xs&&R.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{G(T=>{const K=T==="preview"?"source":"preview";return eb(U,n,K),K}),N(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":o(Oe==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:o(Oe==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:p?Oe==="preview"?e.jsx(vl,{size:14}):e.jsx(xl,{size:14}):o(Oe==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),$r&&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":o(ye?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:o(ye?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(of,{size:15})}),!p&&e.jsx("button",{type:"button",onClick:T=>l(Xe,Qt,T.currentTarget),...Nt(Ur,Qt),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${_n||sn?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:o("rightSidebar.insertReference",{reference:Ur}),children:o(sn?"rightSidebar.copied":_n?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Ur)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:o("rightSidebar.copyReference",{reference:Ur}),"aria-label":o("rightSidebar.copyFileRef"),children:e.jsx(rp,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{It()},disabled:te.status==="pending"||R.kind==="loading"||R.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:te.status==="error"?te.error??o("rightSidebar.downloadFailed"):o("rightSidebar.downloadFile"),"aria-label":o("rightSidebar.downloadFile"),children:te.status==="pending"?e.jsx(ft,{size:13,className:"animate-spin"}):e.jsx(rf,{size:14})}),te.status==="pending"&&e.jsx("button",{type:"button",onClick:te.cancel,className:"inline-flex h-9 shrink-0 items-center rounded-full bg-surface-2 px-2 text-xs text-foreground hover:bg-surface-elevated",children:o("common.cancel")})]})]}),te.status==="error"&&e.jsxs("div",{role:"alert",className:"mt-2 text-xs text-destructive",children:[o("rightSidebar.downloadFailed"),": ",te.error]}),te.status==="canceled"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadCanceled")}),te.status==="saved"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadSaved")}),te.status==="started"&&e.jsx("div",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:o("rightSidebar.downloadStarted")}),Re&&cr&&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(ms,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:ct,type:"search",value:We,onChange:T=>Br(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),Or(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:o("rightSidebar.findInFilePlaceholder"),"aria-label":o("rightSidebar.findInFile")}),e.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:H.length>0?`${Ce+1}/${H.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>Or(-1),disabled:H.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":o("rightSidebar.previousSearchMatch"),title:`${o("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:e.jsx(Il,{size:13})}),e.jsx("button",{type:"button",onClick:()=>Or(1),disabled:H.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":o("rightSidebar.nextSearchMatch"),title:`${o("rightSidebar.nextSearchMatch")} (Enter)`,children:e.jsx(Cp,{size:13})}),e.jsx("button",{type:"button",onClick:en,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":o("rightSidebar.closeFileSearch"),title:`${o("rightSidebar.closeFileSearch")} (Esc)`,children:e.jsx(Lt,{size:13})})]}),Er&&!(p&&(ur||$r))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[Er.size!==null&&e.jsx("span",{children:o("rightSidebar.byteCount",{count:Er.size.toLocaleString()})}),"truncated"in Er&&Er.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:o("rightSidebar.previewTruncated")}),"mimeType"in Er&&e.jsx("span",{children:Er.mimeType}),"dimensions"in R&&R.dimensions&&e.jsxs("span",{children:[R.dimensions.width," × ",R.dimensions.height]})]}),!(p&&(ur||$r))&&!rn&&R.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:ys?o("rightSidebar.edaPickHint"):ga?o("rightSidebar.csvTablePreview"):Mr||bs?o("rightSidebar.kicadProjectPickHint"):vs?o("rightSidebar.videoPreviewHint"):St?o("rightSidebar.imagePreviewHint"):ur?$?o("rightSidebar.selectedLineHint",{lineLabel:on??""}):o("rightSidebar.markdownPreviewHint"):$r?o("rightSidebar.htmlPreviewHint"):$?o("rightSidebar.selectedLineHint",{lineLabel:on??""}):o("rightSidebar.multiLineHint")})})]}),!s&&(R.kind==="video"||R.kind==="model3d"||R.kind==="eda"||$r)?null:R.kind==="loading"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8",children:e.jsx(zi,{label:R.mode==="eda"?o("rightSidebar.edaLoading"):R.mode==="image"?o("rightSidebar.loadingImage"):R.mode==="model3d"?o("rightSidebar.model3dLoading"):R.mode==="video"?o("rightSidebar.loadingVideo"):o("common.loading")})}):R.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:R.message}),e.jsx("button",{type:"button",onClick:Fn,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:o("common.retry")})]}):R.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:o("rightSidebar.binaryPreviewHint")})}):R.kind==="image"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:R.meta.mimeType==="image/svg+xml"?e.jsx(wf,{blobUrl:R.objectUrl,filePath:Xe,viewLabel:"SVG 文件",onInsertAnnotation:c}):e.jsx(jh,{src:R.objectUrl,alt:dr.name,vector:!1,onLoad:T=>{const K=T.currentTarget;z(ge=>ge.kind==="image"?{...ge,dimensions:{width:K.naturalWidth,height:K.naturalHeight}}:ge)},onError:()=>z({kind:"error",message:o("rightSidebar.imageLoadFailed")})})}):R.kind==="video"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:e.jsx(ub,{url:R.url,onLoadError:()=>z({kind:"error",message:o("rightSidebar.videoLoadFailed")})})}):R.kind==="eda"?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(xb,{blobUrl:R.objectUrl,filePath:R.sourcePath,view:R.view,board:Xe.toLowerCase().endsWith(".kicad_pcb"),onViewChange:P,onInsertAnnotation:r??c,onRefresh:Fn,interactive3d:W?e.jsx(a.Suspense,{fallback:e.jsx(zi,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:e.jsx(Mu,{blobUrl:W.objectUrl,ext:".glb",fileName:dr.name,filePath:W.sourcePath,features:null,onInsertFeature:r??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:R.view==="pcb-3d"})}):void 0})}):R.kind==="model3d"?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:e.jsx(a.Suspense,{fallback:e.jsx(zi,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:e.jsx(Mu,{blobUrl:R.objectUrl,ext:R.ext,fileName:dr.name,filePath:R.sourcePath,features:pe,onInsertFeature:r??c,onRefresh:Fn})})}):R.kind==="text"&&ga?e.jsx(wb,{content:R.content,filePath:Xe,onInsertAnnotation:r??c},Xe):R.kind==="text"&&(Mr||bs)?e.jsx(jb,{content:R.content,filePath:Xe,localState:bs,onInsertAnnotation:r??c},Xe):ur?e.jsxs("div",{ref:Me,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:er,style:{touchAction:"pan-x pan-y"},children:[e.jsx(mh,{content:R.content,filePath:R.sourcePath,rootPath:U,lineRange:$,onLineRangeClick:mr,onLineRangeDrag:ve,scrollTop:he,outlineOpen:x,outlineCloseSignal:h,onOutlineOpen:b,onOutlineClose:E,lightboxOpen:S,lightboxCloseSignal:L,onLightboxOpen:D,onLightboxClose:F,onLocalLinkOpen:cn}),$&&Q&&e.jsxs("button",{type:"button",onClick:dn,...Nt(nn,Zt),style:{top:Q.top,left:Q.left,transform:"translateY(-50%)"},className:lu(p,an),title:`Insert markdown reference: ${Wr}`,children:[e.jsx(Eo,{size:p?13:11}),fr?o("rightSidebar.copied"):ks?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:on??""})]})]}):$r?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(Ab,{ref:je,src:np(Xe),title:`${dr.name} preview`,exitFullscreenLabel:o("rightSidebar.htmlFullscreenExit"),onFullscreenChange:Ue},`${Xe}:${lr}:${Jt}`)}):R.kind==="text"?e.jsxs("div",{ref:Me,onScroll:Ss,className:`${_l} 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:[Hr.length>0?e.jsx("div",{className:"min-w-full",children:Hr.map((T,K)=>{const ge=K+1,ke=!!($&&ge>=$.start&&ge<=$.end),nt=Ie&&Ie.length===Hr.length?Ie[K]:null;return e.jsxs("div",{ref:_e=>{_e?we.current.set(ge,_e):we.current.delete(ge)},role:"button","data-file-preview-line":ge,tabIndex:0,onClick:_e=>hr(_e,ge),onKeyDown:_e=>{_e.key!=="Enter"&&_e.key!==" "||(_e.preventDefault(),hr(_e,ge))},style:{gridTemplateColumns:`${zr}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${ke?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${Ur}:${ge}`,children:[e.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${ke?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:ge}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:nt??(T||" ")})]},K)})}):"Empty file.",$&&Q&&e.jsxs("button",{type:"button",onClick:dn,...Nt(nn,Zt),style:{top:Q.top,left:Q.left,transform:"translateY(-50%)"},className:lu(p,an),title:`Insert code reference: ${Wr}`,children:[e.jsx(Eo,{size:p?13:11}),fr?o("rightSidebar.copied"):ks?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:on??""})]})]}):null]})}function x0({rootPath:r,file:n,active:s,...l}){const[d,c]=a.useState(null),[m,g]=a.useState(n.line??1),f=a.useCallback(()=>g(null),[]);return e.jsx("div",{"data-architecture-source":!0,className:"h-full min-h-0",children:e.jsx(Fo,{...l,filePath:`${r.replace(/\/+$/,"")}/${n.path}`,active:s,lineRange:d,onLineRangeChange:c,scrollToLine:m,onScrollToLineHandled:f,markdownOutlineOpen:!1,markdownImageLightboxOpen:!1})})}function v0({isOpen:r,sessionId:n,drawerWidthPx:s,onClose:l,onOpen:d,push:c,pinned:m=!1,onTogglePinned:g,rightSidebarFilePreviewOpen:f=!1,rightSidebarFilePreviewCloseSignal:p,onOpenRightSidebarFilePreview:x,onCloseRightSidebarFilePreview:h,rightSidebarRepoPickerOpen:b=!1,rightSidebarRepoPickerCloseSignal:E,onOpenRightSidebarRepoPicker:S,onCloseRightSidebarRepoPicker:L,markdownOutlineOpen:D=!1,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:N,markdownImageLightboxOpen:A=!1,markdownImageLightboxCloseSignal:B,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j}){const{t:o,locale:_}=mt(),[I,Y]=a.useState(""),U=V(t=>t.pendingTerminalPath),[O,R]=a.useState(null),z=a.useRef(0),Z=V(t=>t.rightSearchOpen),P=V(t=>t.setRightSearchOpen),W=V(t=>t.rightSidebarLayoutPreference),J=V(t=>t.setRightSidebarLayoutPreference),[oe,pe]=a.useState(()=>ux()),[Se,we]=a.useState("."),[Me,Q]=a.useState(""),[be,ue]=a.useState(!1),[Be,Oe]=a.useState(!1),[G,je]=a.useState(!1),[ye,Ue]=a.useState(!1),Ye=a.useDeferredValue(I),[M,he]=a.useState(null),[fe,Ee]=a.useState([]),[$e,tt]=a.useState([]),ce=V(t=>t.contextKey?t.activeGitRepos[t.contextKey]??null:null),Te=V(t=>t.setActiveGitRepo),[Je,Ie]=a.useState(null),[De,te]=a.useState(null),[Re,rt]=a.useState(null),[We,Br]=a.useState(()=>gt(ju,na)??!1),[H,ne]=a.useState(()=>gt(Ru,na)??!1),[Ce,lt]=a.useState(()=>gt(Nu,na)??!1),[ct,Nt]=a.useState(()=>gt(el,ox)??""),[Zr,Nr]=a.useState(0),[lr,zt]=a.useState(!1),[Cr,Jt]=a.useState(!1),pa=a.useRef(null),Fn=a.useRef(null),[gs,cr]=a.useState(!1),[en,Ct]=a.useState(null),[Or,tn]=a.useState(null),[Xe,dr]=a.useState(()=>Pu(Qi)),[Ur,Hr]=a.useState(()=>Pu(Su)),[zr,Er]=a.useState(()=>ax()),[Tt,ga]=a.useState(()=>ix()),[Mr,bs]=a.useState(()=>cx()),ur="words",[xs,$r]=a.useState(0),[St,rn]=a.useState([]),[vs,ys]=a.useState([]),[ws,Wr]=a.useState(!1),[nn,Qt]=a.useState(null),[Zt,_n]=a.useState([]),[ks,sn]=a.useState(!1),[fr,an]=a.useState([]),[on,ln]=a.useState([]),[hr,mr]=a.useState(!1),[ve,er]=a.useState(null),[cn,Bn]=a.useState([]),[Ss,dn]=a.useState({}),It=a.useRef(0),[T,K]=a.useState(0),[ge,ke]=a.useState(!1),[nt,_e]=a.useState(null),[ze,Ge]=a.useState(null),[bt,vt]=a.useState(null),[un,tr]=a.useState(null),[Gr,js]=a.useState(!1),[Rs,pr]=a.useState(""),fn=a.useDeferredValue(Rs),[hn,Uo]=a.useState({}),[re,Ke]=a.useState([]),[Wt,Pr]=a.useState(!1),[ba,Ns]=a.useState(!1),[Ho,On]=a.useState(null),[zo,Un]=a.useState(!1),gr=a.useRef(null),Kr=a.useRef(0),Yl=a.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Rh,xa]=a.useState(null),[Cs,Xl]=a.useState(()=>gt(Zi,na)??!1),[Wo,Go]=a.useState(!1),[va,Ko]=a.useState([]),[rr,ya]=a.useState({}),[Et,wa]=a.useState({}),[mn,qo]=a.useState({}),[Jl,Ql]=a.useState(()=>new Set),[Qe,pn]=a.useState(null),[Vo,gn]=a.useState(null),[Nh,Ar]=a.useState(!1),[Yo,Lr]=a.useState(0),[,Xo]=a.useState(0),[Jo,ka]=a.useState(!1),[Ch,Eh]=a.useState(()=>V.getState().rightTab==="files"),[nr,Qo]=a.useState(!1),[Mh,Zl]=a.useState(()=>V.getState().rightTab==="diff"),[Zo,ec]=a.useState(()=>V.getState().rightTab==="android"),[qr,tc]=a.useState(!1),[sr,rc]=a.useState({architecture:!1,computer:!1}),Es=a.useRef(new Set),Sa=Wi(t=>t.docks[Ki]),$h=!!Sa,[qe,Ms]=a.useState(null),[Hn,$s]=a.useState(null),[yt,bn]=a.useState(null),[nc,Gt]=a.useState(null),[zn,sc]=a.useState(null),[ei,Ph]=a.useState(()=>Date.now()),[Ah,Lh]=a.useState(!1),[xn,ja]=a.useState(!1),[Ra,ac]=a.useState(""),[Wn,Na]=a.useState(""),[vn,Ca]=a.useState(""),[yn,Ea]=a.useState(""),[oc,Gn]=a.useState(null),[ic,ti]=a.useState(!1),[lc,cc]=a.useState(!1),[Ma,Th]=a.useState({key:null,nonce:0}),dc=a.useRef(null),uc=a.useRef(null),se=pp(s,m,W),ri=Df(se,m,Mr),[ni,si]=a.useState(()=>xx(s)),ai=V(t=>t.rightTab),Dt=V(t=>t.setRightTab),v=V(t=>t.rootPath),Kn=V(t=>t.explorerRoot),fc=V(t=>t.pinnedExplorerRootsCache),hc=V(t=>t.hydratePinnedExplorerRoots),mc=V(t=>t.syncPinnedExplorerRoots),Ft=V(t=>t.setExplorerRoot),pc=V(t=>t.resetExplorerToProject),qn=V(t=>t.pinExplorerRoot),wn=V(t=>t.unpinExplorerRoot),at=V(t=>t.selectedFilePath),ot=V(t=>t.selectFile),oi=V(t=>t.showHiddenFiles),Ih=V(t=>t.toggleShowHiddenFiles),ii=V(t=>!!(v&&t.nestedGitScanRoots[v])),Fe=V(t=>t.changedFiles),$a=V(t=>t.setChangedFiles),Ps=V(t=>t.invalidateDirectoryCache),Dh=V(t=>t.setDirectorySortMode),gc=V(t=>t.applyFileWatchEvents),bc=V(t=>t.reconcileDirectoryCache),xc=V(t=>t.bumpFileWatchEpoch),br=V(t=>t.gitBundleLoading),vc=V(t=>t.gitBundleSlow),kn=V(t=>t.gitBundleError),Vn=V(t=>t.gitBundleLastLoadedAt),yc=V(t=>t.beginGitBundleLoading),wc=V(t=>t.setGitBundleSlowFor),li=V(t=>t.finishGitBundleLoading),Pa=V(t=>t.resetGitBundleLoading),ci=V(t=>t.setGitBundleError),kc=V(t=>t.markGitBundleLoaded),le=Kn??v,Aa=V(t=>!!(le&&t.hideGitIgnoredRoots[le])),Fh=V(t=>t.hideGitIgnoredRootsHydrated),_h=V(t=>t.setHideGitIgnoredRoot),[di,Sc]=a.useState(!1),[jc,ui]=a.useState(null);a.useEffect(()=>{ui(null)},[le]);const Rc=a.useMemo(()=>le?_b(le,Se):"",[le,Se]),As=a.useMemo(()=>Fb(Me),[Me]),Nc=a.useMemo(()=>({excludePatterns:As,caseSensitive:Be,wholeWord:G,regex:ye}),[Be,As,ye,G]),La=V(t=>le?t.fileSortModes[le]??"name":"name"),Cc=V(t=>!!(le&&t.directoryCache.has(le))),Yn=a.useRef(null),jt=a.useRef(0),[Ec]=a.useState(()=>++f0),Tr=a.useRef(null),Vr=a.useRef(null),Ta=a.useRef(0),Kt=a.useRef(new Map),qt=a.useRef(new Map),xr=a.useRef(new Set),Sn=a.useRef(new Set),jn=a.useRef(0),Yr=a.useRef(null),Xn=a.useRef(0),Jn=a.useRef(null),Qn=a.useRef(0),Xr=a.useRef(null),fi=a.useRef(new Set),hi=a.useRef(null),mi=a.useRef(null),Ia=a.useRef(null),pi=a.useRef(null),gi=a.useRef(null),Ls=a.useRef(new Set);a.useEffect(()=>{if(zn===null)return;const t=Math.max(0,Date.now()-zn),i=t<6e4?1e3:t<36e5?6e4:t<864e5?36e5:864e5,u=Math.max(50,i-t%i),w=window.setTimeout(()=>Ph(Date.now()),u);return()=>window.clearTimeout(w)},[ei,zn]);const Da=a.useRef(null),Ir=a.useRef(null),bi=a.useRef(null),Mc=a.useRef(null),Ts=a.useRef(null),Pe=a.useCallback(t=>V.getState().rootPath===t,[]);a.useEffect(()=>{if(!r||typeof window>"u")return;const t=i=>{const u=g0(i.target);u&&ea("global_change_row_event",{...b0(i),selectionPath:u.dataset.diffSelectionPath,filePath:u.dataset.diffFilePath,absolutePath:u.dataset.diffAbsolutePath,repoRoot:u.dataset.diffRepoRoot,status:u.dataset.diffStatus,selectedFilePath:V.getState().selectedFilePath,rightTab:V.getState().rightTab,activeGitRepoRoot:ce,changedFiles:V.getState().changedFiles.size})};return window.addEventListener("pointerdown",t,{capture:!0}),window.addEventListener("click",t,{capture:!0}),()=>{window.removeEventListener("pointerdown",t,{capture:!0}),window.removeEventListener("click",t,{capture:!0})}},[ce,r]);const $c=a.useCallback(async(t=v??void 0)=>{if(!t)return null;if(xr.current.has(t)||Sn.current.has(t))return ut("untracked_skip_cached",{cwd:t,rootPath:v,completed:xr.current.has(t),running:Sn.current.has(t)}),null;const i=v,u=Ta.current+1;Ta.current=u,Kt.current.set(t,u);const w=`right-sidebar-git-untracked:${t}`,y=new AbortController;qt.current.set(t,y),Sn.current.add(t),ut("untracked_start",{requestId:u,cwd:t,rootPath:v});try{let k=await zd(t,y.signal,w),C=0;for(;k.status==="running"&&C<120;){if(Kt.current.get(t)!==u||y.signal.aborted)return ut("untracked_stale_result",{requestId:u,activeRequestId:Kt.current.get(t),cwd:t,status:k.status}),null;if(!Pe(i))return ut("untracked_root_changed",{requestId:u,cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath}),null;await new Promise(ae=>window.setTimeout(ae,C<10?1e3:3e3)),C+=1,k=await zd(t,y.signal,w)}if(Kt.current.get(t)!==u||!Pe(i))return ut("untracked_stale_result",{requestId:u,activeRequestId:Kt.current.get(t),cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath,files:k.files.length,status:k.status}),null;if(k.status==="done")return $a(xh(V.getState().changedFiles,k.files)),k.files.length>0&&Ee(ae=>{const Ae=new Map(ae.map(me=>[me.root,me])).get(t);if(!Ae)return ae;const Ze=e0(Ae.files,k.files),ee=ae.map(me=>me.root===t?{...me,files:Ze,context:me.context?{...me.context,changedFiles:Ze.map(Le=>({path:Le.path,absolutePath:Le.absolutePath,status:Le.status})),truncated:!1}:me.context,untrackedDeferred:!1}:me);tt(vh(ee,v));const X=ee.find(me=>me.root===v);return X?.context&&he(me=>me?.root===X.root?{...me,...X.context}:me),ee}),xr.current.add(t),ut("untracked_apply",{requestId:u,cwd:t,files:k.files.length}),k;const ie=k.error||(k.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return xr.current.add(t),ut("untracked_error",{requestId:u,cwd:t,message:ie,code:k.code,status:k.status}),null}catch(k){if(Kt.current.get(t)!==u||!Pe(i)||jr(k))return ut("untracked_aborted",{requestId:u,activeRequestId:Kt.current.get(t),cwd:t,expectedRootPath:i,currentRootPath:V.getState().rootPath,message:k instanceof Error?k.message:String(k)}),null;const C=k instanceof Error?k.message:"Failed to scan untracked files";return xr.current.add(t),ut("untracked_error",{requestId:u,cwd:t,message:C}),null}finally{qt.current.get(t)===y&&qt.current.delete(t),Kt.current.get(t)===u&&Kt.current.delete(t),Sn.current.delete(t)}},[M,Pe,v,$a]),ar=a.useMemo(()=>{const t=new Set($e.map(u=>u.root)),i=Zt.filter(u=>t.has(u));return i.length>0?i:ce?[ce]:[]},[ce,Zt,$e]),Pc=ar.length===0,Rn=a.useMemo(()=>ar.map(t=>fe.find(i=>i.root===t)).filter(t=>!!t),[ar,fe]),Bh=a.useMemo(()=>$e.map(t=>({root:t.root,label:t.label,branch:t.branch??null})),[$e]),vr=a.useCallback(async()=>{if(!v){rn([]),ys([]);return}const t=v,i=Xn.current+1;Xn.current=i,Jn.current?.abort();const u=new AbortController;Jn.current=u,Wr(St.length===0),Qt(null);try{const w=ar.length>0?await Promise.all(ar.map(y=>Wd({workspaceRoot:v,repoRoot:y},u.signal))).then(y=>({records:y.flatMap(k=>k.records),walkthroughs:y.flatMap(k=>k.walkthroughs??[])})):await Wd({workspaceRoot:v},u.signal);if(Xn.current!==i||!Pe(t))return;rn(w.records),ys(w.walkthroughs??[])}catch(w){if(Xn.current!==i||!Pe(t)||jr(w))return;Qt(w instanceof Error?w.message:"Failed to load change audit explanations")}finally{Jn.current===u&&(Jn.current=null),Xn.current===i&&Pe(t)&&Wr(!1)}},[St.length,ar,Pe,v]),Fa=a.useCallback(async(t,i,u)=>{if(!t&&!v){an([]),ln([]);return}const w=v,y=Qn.current+1;Qn.current=y,Xr.current?.abort();const k=new AbortController;Xr.current=k;try{const C=t?[t]:Array.from(new Set([v,...fe.map(ae=>ae.root)].filter(ae=>!!ae))),ie=await Promise.all(C.map(ae=>ap({repoRoot:ae,baseRef:i,branchName:u},k.signal))).then(ae=>{const xe=new Map,Ae=new Map;for(const Ze of ae){for(const ee of Ze.records)xe.set(ee.id,ee);for(const ee of Ze.walkthroughs??[])Ae.set(ee.id,ee)}return{records:Array.from(xe.values()),walkthroughs:Array.from(Ae.values())}});if(Qn.current!==y||!Pe(w))return;an(ie.records),ln(ie.walkthroughs??[])}catch(C){if(Qn.current!==y||!Pe(w)||jr(C))return;console.warn("[RightSidebar] Failed to load branch explanations",C)}finally{Xr.current===k&&(Xr.current=null)}},[fe,Pe,v]),Zn=a.useCallback((t,i={})=>{if(!Pe(v)){ut("apply_skipped_root_changed",{expectedRootPath:v,currentRootPath:V.getState().rootPath,bundleRoot:t.context?.root,files:t.files.length});return}ut(t.files.length===0?"empty_bundle":"apply",{rootPath:v,available:t.available,files:t.files.length,repositories:t.repositories?.map(X=>({root:X.root,relativeRoot:X.relativeRoot,files:X.files.length,available:X.available,error:X.error})),repoFilters:t.repoFilters?.map(X=>({root:X.root,label:X.label,count:X.count})),cached:t.cached,stale:t.stale,cacheAgeMs:t.cacheAgeMs,untrackedDeferred:t.untrackedDeferred,error:t.error});let u=Ff(t),w=t.repoFilters??[],y=t.files;const k=V.getState().changedFiles;if(!!(i.cacheOnly&&!t.cached&&t.files.length===0&&u.length===0)&&(k.size>0||fe.length>0||M)){ut("cache_only_apply_skipped_empty_backend_cache",{rootPath:v,currentFiles:k.size,currentRepositories:fe.length});return}const ie=u.some(X=>X.deferred);if(ie&&!i.replaceWorkspace){const X=new Set(u.filter(Le=>!Le.deferred||Le.root===v).map(Le=>Le.root));y=[...Array.from(k.values()).filter(Le=>!X.has(xt(Le,v)??"")),...t.files]}const ae=Hu(k.values(),v),xe=Hu(t.files,v),Ae=u.some(X=>X.root!==v);if(!!(i.background&&!ie&&!i.replaceWorkspace&&k.size>0&&(t.files.length===0&&!t.error||ae>0&&xe===0&&!Ae))){ut("background_apply_skipped_degraded_bundle",{rootPath:v,currentFiles:k.size,nextFiles:t.files.length,currentNestedCount:ae,nextNestedCount:xe,nextRepositories:u.map(X=>({root:X.root,relativeRoot:X.relativeRoot,files:X.files.length})),cached:t.cached,stale:t.stale,error:t.error});return}if(i.replaceRepoRoot){const X=yh(k.values(),fe,t,i.replaceRepoRoot,v);y=X.files,u=X.repositories,w=X.repoFilters}if($a(bh(y)),Ee(X=>{if(!ie||i.replaceWorkspace)return u;const me=new Map(X.map(Le=>[Le.root,Le]));return u.map(Le=>{const Ve=me.get(Le.root);return!Le.deferred||!Ve?Le:{...Le,available:Ve.available,files:Ve.files,context:Ve.context,deferred:Ve.deferred,untrackedDeferred:Ve.untrackedDeferred,error:Ve.error}})}),tt(w),gi.current=v,i.syncActiveRepo!==!1){const{contextKey:X,activeGitRepos:me}=V.getState(),Le=X?me[X]??null:null,Ve=i.activeRepoRoot!==void 0?i.activeRepoRoot:Le,He=fx({...t,repositories:u,repoFilters:w},Ve);Te(He)}typeof t.cacheUpdatedAt=="number"&&sc(t.cacheUpdatedAt),he(X=>{if(i.replaceRepoRoot&&i.replaceRepoRoot!==v)return X;if(!t.context)return null;const me=X?.root??v;return!X?.available||me!==(t.context.root??v)?t.context:{...X,...t.context}}),i.reloadDiff&&$r(X=>X+1);const ee=V.getState().selectedFilePath;if(ee&&!ee.startsWith("/")&&!y.some(X=>X.path===ee||X.absolutePath===ee)&&ot(null),dr(X=>{const me=new Set(y.map(Ve=>xt(Ve,v)).filter(Boolean)),Le=new Set;for(const Ve of X)me.has(Ve)&&Le.add(Ve);return rl(Qi,Le),Le}),i.loadDeferred!==!1){const X=u.filter(me=>me.untrackedDeferred&&me.root).map(me=>me.root);for(const me of X)$c(me)}i.loadAudit!==!1&&vr()},[Pe,vr,$c,v,ot,Te,$a]);a.useEffect(()=>{Pa(),hi.current=null,mi.current=v;const t=[],i=[];jt.current+=1,jn.current+=1,Ta.current+=1,Tr.current?.abort(),Rt(Qs(Vr.current?.cwd??v??void 0)),Vr.current=null,Tr.current=null,Yr.current?.abort(),Rt("right-sidebar-git-details"),Yr.current=null;for(const C of qt.current.values())C.abort();for(const C of qt.current.keys())Rt(`right-sidebar-git-untracked:${C}`);qt.current.clear(),Kt.current.clear(),Xn.current+=1,Jn.current?.abort(),Jn.current=null,Qn.current+=1,Xr.current?.abort(),Xr.current=null,Kr.current+=1,gr.current?.abort(),Rt("right-sidebar-recent-commits"),gr.current=null,rn([]),ys([]),Wr(!1),Qt(null),_n([]),sn(!1),an([]),ln([]),mr(!1),er(null),ke(!1),_e(null),Ge(null),vt(null),tr(null),js(!1),pr(""),Ke([]),Pr(!1),Ns(!1),On(null),Un(!1),xa(null),pn(null),gn(null),Xl(!1),At(Zi,!1),Go(!1);const u=v?Au()[v]:null,w=u?.previewEntries??[],y=u?.selectedPreviewKey??null,k=y?w.find(C=>C.key===y)??null:null;++It.current,ke(!1),Ko(u?.selectedRepoRoots??[]),ya(u?.repoTargetBranches??{}),wa(u?.repoBaseBranches??{}),Bn(w),dn(u?.previewScrollTops??{}),k&&u?.previewDetailOpen&&(k.diff.hunks?.length??0)>0&&(er(k.diff),pn(k.key),gn(u.selectedPreviewFileKey??(k.diff.hunks?.[0]?`${k.diff.hunks[0].filePath}\0${k.diff.hunks[0].hunkHeader}\0${k.diff.hunks[0].hunkIndex}`:null)),mr(!0)),qo(u?.repoIncludeUncommitted??Object.fromEntries(Object.keys(u?.repoTargetBranches??{}).map(C=>[C,u?.includeUncommitted??!0]))),hi.current=v,ja(!1),xr.current.clear(),Sn.current.clear(),Ms(null),$s(null),bn(null),Gt(null),sc(null),Ee(t),tt(i),he(null),pi.current=null,gi.current=null,Ls.current.clear()},[Pa,v]);const _t=a.useCallback(async(t=v??void 0,i={})=>{if(!t)return null;const u=v,w=jt.current;if(await gg(()=>Promise.all([V.getState().hydrateNestedGitScanRoots(),V.getState().hydrateActiveGitRepos()]).then(()=>{})),jt.current!==w||!Pe(u))return null;const y=t===v&&Xs(v),k=i.includeNested??y,C=i.refresh??i.reloadDiff??!1,ie=i.cacheOnly??!1,ae=i.background??!1,xe=k&&(i.discoverOnly??!1);C&&xr.current.clear();const Ae=Vr.current;if(Ae&&Ae.cwd===t&&Ae.includeNested===k&&Ae.refresh===C&&Ae.cacheOnly===ie&&Ae.discoverOnly===xe)return ut("reuse_pending",{cwd:t,includeNested:k,refresh:C,cacheOnly:ie,discoverOnly:xe}),Ae.promise;const Ze=jt.current+1;jt.current=Ze;const ee=`right-sidebar:${Ec}:${Ze}`;Tr.current?.abort();const X=Qs(t);Rt(X);const me=new AbortController;Tr.current=me;let Le=null;ae||yc(ee),ci(null),ut("start",{requestId:Ze,cwd:t,rootPath:v,requestSlotId:X,includeNested:k,refresh:C,cacheOnly:ie,background:ae,existingChanges:Fe.size,lastLoadedAt:Vn}),!ae&&typeof window<"u"&&(Le=window.setTimeout(()=>{jt.current===Ze&&wc(ee,!0)},qb));const Ve=(async()=>{const He=await Gi(t,me.signal,{includeNested:k,refresh:C,cacheOnly:ie,discoverOnly:xe,action:C?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:X,requestTimeoutMs:C?null:void 0});if(n0(He)){if(ut("cancelled_result_ignored",{requestId:Ze,activeRequestId:jt.current,cwd:t,error:He.error??He.context?.error}),me.signal.aborted)return null;throw new Error(He.error??He.context?.error??"Failed to load Git changes")}return jt.current!==Ze||!Pe(u)?(ut("stale_result",{requestId:Ze,activeRequestId:jt.current,cwd:t,expectedRootPath:u,currentRootPath:V.getState().rootPath,files:He.files.length,repositories:He.repositories?.length??0}),null):(Zn(He,{reloadDiff:i.reloadDiff,syncActiveRepo:i.replaceWorkspace?!0:k,background:ae,cacheOnly:ie,replaceRepoRoot:i.replaceRepoRoot,replaceWorkspace:i.replaceWorkspace}),He)})();Vr.current={cwd:t,includeNested:k,refresh:C,cacheOnly:ie,discoverOnly:xe,promise:Ve};try{const He=await Ve;return jt.current===Ze&&He&&Pe(u)?kc({cached:He.cached,stale:He.stale,cacheAgeMs:He.cacheAgeMs,nestedDeferred:!k||He.nestedDeferred,untrackedDeferred:He.untrackedDeferred}):jt.current===Ze&&Pe(u)&&li(ee),He}catch(He){return jt.current!==Ze||!Pe(u)||me.signal.aborted?(ut("aborted",{requestId:Ze,activeRequestId:jt.current,cwd:t,expectedRootPath:u,currentRootPath:V.getState().rootPath,message:He instanceof Error?He.message:String(He)}),null):(ut("error",{requestId:Ze,cwd:t,includeNested:k,refresh:C,background:ae,message:He instanceof Error?He.message:String(He)}),ae||(he(null),ci(He instanceof Error?He.message:"Failed to load Git changes")),null)}finally{Le!==null&&window.clearTimeout(Le),Tr.current===me&&(Tr.current=null),Vr.current?.promise===Ve&&(Vr.current=null),!ae&&jt.current===Ze&&Pe(u)&&li(ee)}},[Zn,yc,Fe.size,li,Ec,Vn,Pe,kc,v,ci,wc]),es=a.useCallback(async()=>{v&&await _t(v,{reloadDiff:!0,refresh:!0})},[_t,v]),xi=a.useCallback(async(t=v??void 0)=>{if(!t)return null;const i=v,u=jn.current+1;jn.current=u,Yr.current?.abort(),Rt("right-sidebar-git-details");const w=new AbortController;Yr.current=w,ja(!0);try{const y=await Gd(t,w.signal,"load_git_details","right-sidebar-git-details");return jn.current!==u||!Pe(i)?null:(Ee(k=>k.map(C=>C.root===y.root?{...C,available:y.available,context:y,error:y.error}:C)),he(k=>k?.root&&y.root&&k.root!==y.root?k:!k?.available||!y.available?y:{...k,...y}),y)}catch(y){return jr(y)||!Pe(i)||jn.current===u&&Gt(y instanceof Error?y.message:"Failed to load Git details"),null}finally{Yr.current===w&&(Yr.current=null),jn.current===u&&Pe(i)&&ja(!1)}},[Pe,v]);a.useEffect(()=>{if(!r){jt.current+=1,Pa(),pi.current=null,jn.current+=1,Ta.current+=1,Tr.current?.abort(),Rt(Qs(Vr.current?.cwd??v??void 0)),Vr.current=null,Tr.current=null,Yr.current?.abort(),Rt("right-sidebar-git-details"),Yr.current=null;for(const t of qt.current.values())t.abort();for(const t of qt.current.keys())Rt(`right-sidebar-git-untracked:${t}`);qt.current.clear(),Kt.current.clear(),Qn.current+=1,Xr.current?.abort(),Xr.current=null,Kr.current+=1,gr.current?.abort(),Rt("right-sidebar-recent-commits"),gr.current=null,ja(!1),ke(!1),_e(null),Ge(null),vt(null),tr(null),js(!1),pr(""),Ke([]),Pr(!1),Ns(!1),On(null),Un(!1),Y(""),P(!1),Ct(null),Qo(!1),se&&Zl(!1)}},[se,r,Pa,P]),a.useEffect(()=>{if(!Z)return;const t=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(t)},[Z]),a.useEffect(()=>{se||Ar(!1)},[se]);const Ac=a.useCallback(t=>{Xo(t);const i=bi.current;i&&(i.update(),i.slideTo(t,0),window.requestAnimationFrame(()=>{i.update(),i.slideTo(t,0)}))},[]);a.useEffect(()=>{if(se)if(Ar(f),f&&at){Lr(1);const t=Ir.current;t&&(t.update(),t.activeIndex!==1&&(Ts.current=1,t.slideTo(1,0)))}else{Lr(0);const t=Ir.current;t&&t.activeIndex!==0&&(Ts.current=0,t.slideTo(0,0)),Ct(null)}},[se,f,v,at]),a.useEffect(()=>{if(p!==void 0&&!f){Lr(0);const t=Ir.current;t&&t.activeIndex!==0&&(Ts.current=0,t.slideTo(0,0)),Ar(!1),Ct(null)}},[p,f]),a.useEffect(()=>{E!==void 0&&Ie(null)},[E]),a.useEffect(()=>{!se&&f&&h?.()},[se,h,f]),a.useEffect(()=>{si(t=>Cl(t,s))},[s]);const Oh=a.useCallback(t=>{se||(t.preventDefault(),Da.current={startX:t.clientX,startWidth:ni,pointerId:t.pointerId},t.currentTarget.setPointerCapture(t.pointerId))},[ni,se]),Uh=a.useCallback(t=>{const i=Da.current;if(!i||i.pointerId!==t.pointerId)return;const u=Cl(i.startWidth+t.clientX-i.startX,s);si(u),sa(ra,u,Kb)},[s]),Lc=a.useCallback(t=>{const i=Da.current;if(!(!i||i.pointerId!==t.pointerId)){Da.current=null,Ys(ra);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}},[]),ts=!!(v&&Vn!==null&&Gu(M)),vi=!!(v&&!kn&&Fe.size===0&&Vn===null),Mt=(()=>{let t=ai;return t==="android"&&!qr&&(t="files"),(t==="architecture"||t==="computer")&&!sr[t]&&(t="files"),ts&&(t==="git"||t==="diff")&&(t="files"),t})(),dt=Mt==="git",Dr=Mt==="files",$t=Mt==="diff",rs=Mt==="android",ns=Mt==="computer",Nn=Mt==="architecture",[Hh,zh]=a.useState(!1);a.useEffect(()=>{r&&ns&&zh(!0)},[r,ns]);const[Wh,Gh]=a.useState(!1);a.useEffect(()=>{r&&Nn&&Gh(!0)},[r,Nn]);const yi=a.useRef(null),ss=a.useCallback((t,i)=>{const u=V.getState().rightTab;if(u===t)return;const w=performance.now(),y=w-i.timeStamp;yi.current={from:u,to:t,startedAt:w,inputDelayMs:y>=0&&y<6e4?Math.round(y):null},Dt(t)},[Dt]);a.useEffect(()=>{const t=yi.current;if(!t||t.to!==Mt)return;yi.current=null;const i=Math.round(performance.now()-t.startedAt);let u=window.requestAnimationFrame(()=>{u=window.requestAnimationFrame(()=>{ea("tab_switch_presented",{from:t.from,to:t.to,inputDelayMs:t.inputDelayMs,commitMs:i,frameMs:Math.round(performance.now()-t.startedAt)})})});return()=>window.cancelAnimationFrame(u)},[Mt]);const Kh=Ep(t=>t.overlay==="sidebar")&&rs;a.useEffect(()=>{if(!se){ka(!0);return}if(!r){const i=window.setTimeout(()=>{ka(!1)},Xb);return()=>window.clearTimeout(i)}ka(!1);const t=window.setTimeout(()=>{ka(!0)},Yb);return()=>window.clearTimeout(t)},[se,r]),a.useEffect(()=>{if(!se||!$t)return;const t=bi.current;if(!t)return;const i=window.requestAnimationFrame(()=>{t.update()});return()=>window.cancelAnimationFrame(i)},[$t,se]),a.useEffect(()=>{if(!ts||!v||br)return;const t=window.setTimeout(()=>{_t(v,{background:!0})},3e3);return()=>window.clearTimeout(t)},[ts,v,br,_t]);const qh=a.useCallback(t=>{_t(t,{discoverOnly:!0})},[_t]);bg({active:r&&(dt||$t),rootPath:v,loading:br,delay:dt&&!se?0:tl,lastStartedRoot:pi,load:qh}),a.useEffect(()=>{!r||!dt||(!se||Jo)&&Qo(!0)},[dt,se,r,Jo]),a.useEffect(()=>{if(!r||dt)return;const t=window.setTimeout(()=>{Qo(!0)},tl);return()=>window.clearTimeout(t)},[dt,r]),a.useEffect(()=>{Dr&&Eh(!0)},[Dr]),a.useEffect(()=>{$t&&Zl(!0)},[$t]),a.useEffect(()=>{!r||!rs||(n&&Sa&&Sa.sessionId!==n&&(Wi.getState().setDock(Ki,null),ta({androidPanel:{docked:null}}).catch(()=>{})),ec(!0))},[rs,r,n,Sa]),a.useEffect(()=>{if(r&&rs||!Zo)return;const t=window.setTimeout(()=>ec(!1),Vb);return()=>window.clearTimeout(t)},[r,rs,Zo]),a.useEffect(()=>{let t=!1;return Yu().then(i=>{t||(Es.current.has("android")||tc(i.androidPanel?.enabled===!0),rc(u=>({architecture:Es.current.has("architecture")?u.architecture:i.rightSidebarTabs?.architecture===!0,computer:Es.current.has("computer")?u.computer:i.rightSidebarTabs?.computer===!0})))}).catch(()=>{}),()=>{t=!0}},[]);const Tc=a.useCallback(t=>{Es.current.add("android"),tc(t),t?Dt("android"):V.getState().rightTab==="android"&&Dt("files"),ta({androidPanel:{enabled:t}}).catch(()=>{})},[Dt]),Vh=a.useCallback((t,i)=>{Es.current.add(t),rc(u=>({...u,[t]:i})),i?Dt(t):V.getState().rightTab===t&&Dt("files"),ta({rightSidebarTabs:{[t]:i}}).catch(()=>{})},[Dt]),Ic=a.useCallback(t=>{le&&Yx(le,t.currentTarget.scrollTop)},[le]);a.useEffect(()=>()=>{Tr.current?.abort(),Ys(Dl),Ys(Fl),Ys(ra),Ys(el)},[]),a.useEffect(()=>{if(!le||!Cc)return;const t=ph()[le]?.top;if(typeof t!="number")return;let i=window.requestAnimationFrame(()=>{Yn.current&&(Yn.current.scrollTop=t),i=window.requestAnimationFrame(()=>{Yn.current&&(Yn.current.scrollTop=t)})});return()=>window.cancelAnimationFrame(i)},[le,Cc]),a.useEffect(()=>{if(!r)return;const t=new AbortController;return op(t.signal).then(i=>cc(!!i.available)).catch(()=>cc(!1)),()=>t.abort()},[r]);const Is=a.useCallback(t=>{if(R(null),ot(t),Ct(null),se){Ar(!0),Lr(1),Ir.current?.slideTo(1),x?.();return}},[se,x,ot]),wi=a.useCallback((t,i)=>{if(R(null),ot(t),tn(i),se){Ar(!0),Lr(1),Ir.current?.slideTo(1),x?.();return}},[se,x,ot]),Bt=Yg(t=>Ps(t,!1)),_a=Bt.busy,Ds=a.useCallback(async(t,i)=>{const u=i||Kn||v;!u||!t.length||await Bt.start(u,t)},[Kn,v,Bt.start]),Dc=a.useCallback(async t=>{try{await ip(t)}catch(i){Gt(i instanceof Error?i.message:o("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>Gt(null),4e3)}},[o]),Ba=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes("Files")&&ti(!0)},[]),Fc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),ti(!1)},[]),_c=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),ti(!1);const i=t.dataTransfer.files;i.length>0&&Ds(Array.from(i))},[Ds]),ki=a.useCallback(t=>{te(t),window.setTimeout(()=>te(i=>i===t?null:i),1400)},[]),yr=a.useCallback(t=>{rt(t),window.setTimeout(()=>rt(i=>i===t?null:i),1400)},[]);a.useEffect(()=>{At(ju,We)},[We]),a.useEffect(()=>{At(Ru,H)},[H]),a.useEffect(()=>{At(Nu,Ce)},[Ce]),a.useEffect(()=>{sa(el,ct,Ub)},[ct]),a.useEffect(()=>(hc().catch(()=>{}),Kd(t=>{t.type==="pinned-explorer-roots"&&mc(t.pinnedExplorerRoots)})),[hc,mc]);const Bc=a.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),Oa=a.useRef(null),Cn=a.useRef(null),[Oc,Si]=a.useState(!1);a.useEffect(()=>{if(!r)return;Si(!1);let t=!1;lp().then(u=>{t||(Oa.current=u.text,Nt(w=>u.text&&u.text!==w?u.text:w),Si(!0))}).catch(()=>{t||Si(!0)});const i=Kd(u=>{u.type==="context-draft"&&u.origin!==Bc.current&&(Oa.current=u.text,Nt(u.text))});return()=>{t=!0,i(),Cn.current!==null&&(window.clearTimeout(Cn.current),Cn.current=null)}},[r]),a.useEffect(()=>{if(!Oc||Oa.current===ct)return;Cn.current!==null&&window.clearTimeout(Cn.current);const t=ct;Cn.current=window.setTimeout(()=>{Cn.current=null,cp(t,Bc.current).then(()=>{Oa.current=t}).catch(()=>{})},500)},[ct,Oc]);const as=a.useCallback(async(t,i,u,w)=>{if(!t)return!1;if(dp(u?t+u:t))return ki(i),!0;if(We)Nt(y=>Kg(y,t)+(u??"")),window.matchMedia("(pointer: coarse)").matches||(ne(!1),Nr(y=>y+1));else{const y=n??Jr.getState().activeSessionId;if(!await ef(u?t+u:t,y,()=>Fs.current&&y===Jr.getState().activeSessionId,w))return!1}return ki(i),!0},[We,ki,n]),Ua=a.useCallback(t=>{const i=Tn(t,v);return Mp(i,v)},[v]),ji=mf(yr),Ot=a.useCallback((t,i,u)=>{const w=Tn(t,v);return as($p(w,v),i??`path:${w}`,void 0,u)},[v,as]),Ha=a.useRef({sessionId:n,contextDraftEnabled:We,isOpen:r});Ha.current={sessionId:n,contextDraftEnabled:We,isOpen:r};const Yh=a.useCallback(async t=>{const i=n??Jr.getState().activeSessionId,u=()=>Fs.current&&Ha.current.isOpen&&(Ha.current.sessionId??Jr.getState().activeSessionId)===i&&Jr.getState().activeSessionId===i&&Ha.current.contextDraftEnabled===We;await Bt.start("/tmp",[t],y=>Ot(y,`path:${y}`),u)&&u()&&se&&!We&&l()},[We,Ot,se,l,n,Bt.start]),za=a.useRef(!0),Ri=a.useRef(n);Ri.current=n,a.useEffect(()=>(za.current=!0,()=>{za.current=!1}),[]);const Xh=a.useCallback(t=>{Pp.getState().enqueue(t,n??null,v||"/",i=>{if(We&&za.current&&Ri.current===n)Ot(i);else return tu(i,n)})},[n,v,We,Ot]),Jh=a.useCallback(async t=>{const u=(await fl("/tmp",[t])).files[0]?.path;if(!u)throw new Error("截图上传未返回文件路径");We&&za.current&&Ri.current===n?Ot(u):await tu(u,n)},[We,Ot,n]),or=a.useCallback((t,i,u)=>{if(!t)return Promise.resolve(!1);const w=t.includes(`
1660
1660
  `)?`
1661
1661
  `:void 0;return as(t.endsWith(`
1662
1662
  `)||t.endsWith(" ")?t:`${t} `,i,w,u)},[as]),Uc=a.useRef(or);Uc.current=or;const Fs=a.useRef(!0);a.useEffect(()=>(Fs.current=!0,()=>{Fs.current=!1}),[]);const Ni=a.useRef(new Set),Hc=a.useCallback((t,i,u)=>{if(Ni.current.has(i))return;const w=n??Jr.getState().activeSessionId;Ni.current.add(i),Rg(t,i,u,{insert:or,upload:async(y,k)=>(await fl("/tmp",[y],k)).files[0]?.path,isCurrent:()=>Fs.current&&Uc.current===or&&w===Jr.getState().activeSessionId}).catch(()=>{}).finally(()=>Ni.current.delete(i))},[or,n]),Fr=a.useCallback((t,i,u)=>{i&&as(i.endsWith(" ")?i:`${i} `,u??`context:${t}`,`
1663
- `)},[as]),zc=Jg({text:ct,sessionId:n??Jr.getState().activeSessionId,active:r&&We,onAccepted:()=>{cr(!1),Nt(""),Ce&&ne(!0)},onRejected:()=>{cr(!0),ne(!1)}}),st=a.useMemo(()=>v?kt(v):o("rightSidebar.workspace"),[v,o]),Qh=a.useMemo(()=>kt(ie)||st,[ie,st]),Wa=a.useMemo(()=>vo(ie),[ie]),Ga=a.useMemo(()=>v?fc[v]??[]:[],[fc,v]),En=a.useMemo(()=>new Set(Ga.map(t=>t.path)),[Ga]),_s=!!(ie&&En.has(ie)),Ci=!!(v&&ie&&ie!==v),Zh=!!(v&&Kn&&Kn!==v),Ut=ie?`path:${ie}`:null,Wc="context:change-audit",em=a.useCallback(()=>{Wa&&Ft(Wa)},[Wa,Ft]),Gc=a.useCallback(()=>{pc()},[pc]),tm=a.useCallback(()=>{ie&&(Ps(ie,!0),xc())},[xc,ie,Ps]),rm=a.useCallback(()=>{!ie||!Ci||(_s?wn(ie):qn(ie,"directory"))},[Ci,ie,_s,qn,wn]),Kc=a.useCallback(t=>{Ft(t),Y("")},[Ft]),qc=a.useCallback(t=>{ie&&(we(Bb(ie,t)),P(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[ie,P]),Vc=a.useCallback(t=>{!v||t===v||(En.has(t)?wn(t):qn(t,"directory"))},[qn,En,v,wn]),Yc=a.useCallback(t=>{!v||!t||(En.has(t)?wn(t):qn(t,"file"))},[qn,En,v,wn]),Xc=V(t=>t.expandedPaths),Ei=a.useMemo(()=>{const t=new Set;if(Dr&&ie){t.add(ie);const i=`${ie.replace(/\/+$/,"")}/`;for(const u of Xc)u.startsWith(i)&&t.add(u)}if(Dr&&v&&at){const i=at.startsWith("/")?at:`${v}/${at}`,u=vo(i);u&&t.add(u)}return _g(t).join(`
1664
- `)},[Xc,Dr,ie,v,at]),Mn=a.useRef(new Map);a.useEffect(()=>{const t=Ei?Ei.split(`
1665
- `):[];if(!r||t.length===0){Gn(null);return}const i=new AbortController;let u=!1,w=0,y=0;Gn(null);const k=async()=>{let C=0;for(;!u&&!i.signal.aborted;){let le=null;try{Gn(null),await gp(t,xe=>{const{applicableEvents:Ae,unavailableReason:Ze}=Og(xe);Ae.length>0&&gc(Ae);const ee=new Set(Ae.filter(X=>X.type==="rescan-required").map(X=>X.path));if(Aa)for(const X of Ae){if(X.type==="created"||X.type==="updated"){const me=vo(X.path);me&&ee.add(me)}X.path.endsWith("/.gitignore")&&ie&&Ps(ie,!0)}for(const X of ee){const me={path:X},Le=V.getState();if(!Le.directoryCache.has(me.path))continue;Mn.current.get(me.path)?.abort();const He=new AbortController;Mn.current.set(me.path,He);const Bd=`file-watch-rescan:${me.path}`;Rt(Bd),Vu(me.path,He.signal,Le.showHiddenFiles,"watch_rescan",Bd,Le.fileSortModes[me.path]??"name",ie??void 0).then(Ks=>{Mn.current.get(me.path)===He&&bc(me.path,Ks.entries)}).catch(Ks=>{jr(Ks)||Gn(Ks instanceof Error?Ks.message:"File refresh unavailable")}).finally(()=>{Mn.current.get(me.path)===He&&Mn.current.delete(me.path)})}Ze&&Gn(Ze)},i.signal),le=new Error("File watch stream ended")}catch(xe){le=xe}if(u||i.signal.aborted||jr(le))return;Gn(le instanceof Error?le.message:"File watching unavailable");const ae=Cu[Math.min(C,Cu.length-1)];C+=1,await new Promise(xe=>{y=window.setTimeout(xe,ae)})}};return w=window.setTimeout(()=>{u||k()},tl),()=>{u=!0,window.clearTimeout(w),window.clearTimeout(y),i.abort();for(const C of Mn.current.values())C.abort();Mn.current.clear()}},[gc,r,bc,Ei,ie,Aa,Ps]),a.useEffect(()=>{if(!v||hi.current!==v)return;if(mi.current===v){mi.current=null;return}const t=Au();sa(Pf,{...t,[v]:{selectedRepoRoots:va,repoTargetBranches:rr,repoBaseBranches:Et,previewEntries:cn,selectedPreviewKey:ve&&hr?Qe:null,selectedPreviewFileKey:ve&&hr?Vo:null,previewDetailOpen:!!(ve&&hr),previewScrollTops:Ss,previewMobileSlideIndex:1,repoIncludeUncommitted:mn,updatedAt:Date.now()}},Ob)},[hr,mn,ve,cn,Ss,Et,rr,va,v,Vo,Qe]);const pt=a.useMemo(()=>Wu(Fe.values()),[Fe]),it=a.useMemo(()=>{const t=new Map;for(const i of fe)t.set(i.root,i);return t},[fe]),Bs=a.useMemo(()=>{const t=new Map;for(const i of fe)i.deferred||t.set(i.root,i.files.length);return t},[fe]),Ka=a.useCallback(t=>{if(t){if(!t.deferred){Ls.current.delete(t.root);return}Bs.has(t.root)||Ls.current.has(t.root)||(Ls.current.add(t.root),_t(t.root,{includeNested:!1,background:!0,replaceRepoRoot:t.root}).then(i=>{i||Ls.current.delete(t.root)}))}},[_t,Bs]),ir=a.useMemo(()=>ce?$e.find(t=>t.root===ce)??null:null,[ce,$e]),Vt=a.useMemo(()=>at?Array.from(Fe.values()).find(t=>t.path===at||t.absolutePath===at)??null:null,[Fe,at]),Ht=a.useMemo(()=>{const t=new Map;for(const i of fe)i.available&&i.context?.available&&t.set(i.root,i);return t.size===0&&M?.available&&M.root&&t.set(M.root,{id:M.root,root:M.root,relativeRoot:".",name:st,depth:0,nested:!1,available:!0,files:Array.from(Fe.values()).filter(i=>xt(i,v)===M.root),context:M}),Array.from(t.values()).sort((i,u)=>i.root===v?-1:u.root===v?1:(i.relativeRoot||i.name).localeCompare(u.relativeRoot||u.name)).map(i=>{const u=i.relativeRoot==="."?st:i.relativeRoot||i.name||kt(i.root),w=zu(i.files),y=i.files.length;return{value:i.root,label:u,meta:[i.context?.branch,y>0?o("rightSidebar.repoChangedCount",{count:y}):null,w>0?o("rightSidebar.repoStagedCount",{count:w}):null].filter(Boolean).join(" · ")}})},[Fe,M,fe,st,v,o]),Ne=a.useMemo(()=>ce&&Ht.some(t=>t.value===ce)?ce:Vt?.repoRoot&&Ht.some(t=>t.value===Vt.repoRoot)?Vt.repoRoot:Ht.length===1||Ht.length>1?Ht[0].value:null,[ce,Ht,Vt?.repoRoot]),Jc=Ne?it.get(Ne)??null:null,de=Jc?.context?.available?Jc.context:Ne===M?.root?M:null,et=Ht.length>0&&!Ne,Qc=a.useMemo(()=>et?[]:Ne?Array.from(Fe.values()).filter(t=>xt(t,v)===Ne):Array.from(Fe.values()),[Ne,Fe,et,v]),$n=a.useMemo(()=>Wu(Qc),[Qc]),Mi=!!(de?.available&&de.root&&Ne&&de.root===Ne),nm=Ne?Ht.find(t=>t.value===Ne)?.label??kt(Ne):o("rightSidebar.gitRepositoryPlaceholder"),Zc=Mi?de?.branch??"HEAD":et?o("rightSidebar.selectRepositoryForGitActions"):xn?o("rightSidebar.gitActionRunning"):"HEAD",Pn=!!(de?.available&&de.root===Ne&&de.status);a.useEffect(()=>{Yl.current={count:re.length,loading:Wt,loadingMore:ba,hasMore:zo}},[re.length,zo,Wt,ba]),a.useEffect(()=>{Kr.current+=1,gr.current?.abort(),Rt("right-sidebar-recent-commits"),gr.current=null,pr(""),Ke([]),Pr(!1),Ns(!1),On(null),Un(!1)},[Ne]);const Os=a.useCallback(async(t={})=>{if(!v||!Ne||et)return;const i=t.reset??!1,u=Yl.current,w=i?0:u.count;if(!i&&(u.loading||u.loadingMore||!u.hasMore))return;const y=Kr.current+1;Kr.current=y,gr.current?.abort(),Rt("right-sidebar-recent-commits");const k=new AbortController;gr.current=k,i?Pr(!0):Ns(!0),On(null);try{const C=await up({cwd:v,repoRoot:Ne,limit:Jb,skip:w,query:fn.trim(),requestSlotId:"right-sidebar-recent-commits"},k.signal);if(Kr.current!==y)return;if(!C.available){On(C.error??"Recent commits are unavailable"),i&&Ke([]),Un(!1);return}Uo(le=>i?C.commitSyncStatus??{}:{...le,...C.commitSyncStatus}),Ke(le=>i?C.commits:[...le,...C.commits]),Un(C.hasMore)}catch(C){if(Kr.current!==y||jr(C))return;On(C instanceof Error?C.message:"Failed to load recent commits"),i&&Ke([]),Un(!1)}finally{gr.current===k&&(gr.current=null),Kr.current===y&&(Pr(!1),Ns(!1))}},[Ne,fn,et,v]);a.useEffect(()=>{Gr&&Os({reset:!0})},[fn,Os,Gr,de?.ahead,de?.behind,de?.upstream]);const sm=a.useCallback(t=>{const i=t.currentTarget;i.scrollTop+i.clientHeight<i.scrollHeight-48||Os({reset:!1})},[Os]);a.useEffect(()=>{!Ne||!M?.available||!dt||!nr||Pn||xn||et||xi(Ne)},[Ne,M?.available,Pn,xn,dt,nr,xi,et]);const ed=r&&($t||dt);a.useEffect(()=>{!ed||!v||vr()},[ed,vr,v]),a.useEffect(()=>{!r||!dt||!nr||!Cs||!v||Fa(null)},[Cs,dt,nr,r,Fa,v]);const am=a.useMemo(()=>{if(!ce)return 0;const t=$e.findIndex(i=>i.root===ce);return t>=0?t+1:0},[ce,$e]),td=a.useCallback(t=>{if(!t)return null;const i=Array.from(Fe.values()).filter(u=>xt(u,v)===t).sort((u,w)=>u.path.localeCompare(w.path))[0];return i?Sr(i):null},[Fe,v]),An=$e.length>1,qa=a.useMemo(()=>[{root:null,label:o("rightSidebar.allRepositories"),count:Fe.size,branch:null,deferred:!1},...$e.map(t=>({root:t.root,label:t.label,count:t.deferred?Bs.get(t.root)??0:t.count,branch:t.branch??null,deferred:!!t.deferred&&!Bs.has(t.root)}))],[Fe.size,$e,Bs,o]),rd=qa[am]??qa[0],Va=!!ce,nd=a.useMemo(()=>_f($e,fe),[$e,fe]);a.useEffect(()=>{gi.current===v&&ce&&!nd.has(ce)&&Te(null),_n(t=>t.filter(i=>$e.some(u=>u.root===i)))},[ce,$e,nd,v,Te]),a.useEffect(()=>{ce&&Ka(it.get(ce))},[ce,Ka,it]);const om=a.useMemo(()=>{const t=new Set;de?.branch&&t.add(de.branch);for(const i of de?.branches??[])t.add(i);return Array.from(t).map(i=>({value:i,label:i,meta:i===de?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0}))},[de?.branch,de?.branches,o]),sd=a.useMemo(()=>{const t=new Set;de?.upstreamRemote&&t.add(de.upstreamRemote);for(const i of de?.remotes??[])t.add(i);return Array.from(t).map(i=>({value:i,label:i,meta:i===de?.upstreamRemote?o("rightSidebar.pushUpstreamBadge"):void 0}))},[de?.remotes,de?.upstreamRemote,o]),ad=sd.length>1,im=a.useMemo(()=>{const t=[],i=new Set,u=(y,k)=>{!y||i.has(y)||(i.add(y),t.push({value:y,label:y,meta:k}))};u(de?.upstreamBranch,de?.upstreamBranch?o("rightSidebar.pushUpstreamBadge"):void 0),u(de?.branch,de?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0);for(const y of de?.branches??[])u(y,y===de?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");const w=de?.upstreamRemote;for(const y of de?.remoteBranches??[]){const k=y.indexOf("/"),C=k>=0?y.slice(0,k):null,le=k>=0?y.slice(k+1):y;(!w||C===w)&&u(le,"remote")}return t},[de?.branch,de?.branches,de?.remoteBranches,de?.upstreamBranch,de?.upstreamRemote,o]),Yt=a.useMemo(()=>Ht.map(t=>{const i=it.get(t.value);return{root:t.value,label:t.label,branch:i?.context?.branch??null}}),[Ht,it]);a.useEffect(()=>{Yt.length!==0&&(ya(t=>{let i=!1;const u={...t},w=new Set(Yt.map(y=>y.root));for(const y of Object.keys(u))w.has(y)||(delete u[y],i=!0);for(const y of Yt)!u[y.root]&&y.branch&&(u[y.root]=y.branch,i=!0);return i?u:t}),wa(t=>{let i=!1;const u={...t},w=new Set(Yt.map(y=>y.root));for(const y of Object.keys(u))w.has(y)||(delete u[y],i=!0);for(const y of Yt){const k=it.get(y.root)?.context;if(u[y.root]&&Bf(u[y.root],k?.branch)&&(delete u[y.root],i=!0),u[y.root])continue;const C=Iu(k);C&&(u[y.root]=C,i=!0)}return i?u:t}))},[Yt,it]);const Ya=a.useMemo(()=>{const t=new Set(Yt.map(i=>i.root));return va.filter(i=>t.has(i))},[va,Yt]),Xa=Ya.length===0,wr=a.useMemo(()=>Xa?Yt:Yt.filter(t=>Ya.includes(t.root)),[Yt,Ya,Xa]),Us=a.useMemo(()=>wr.filter(t=>!!Et[t.root]?.trim()),[Et,wr]),os=a.useCallback((t,i)=>{const u=it.get(t)?.context?.branch;return!!(u&&i&&i.replace(/^refs\/heads\//,"")===u)},[it]),od=a.useMemo(()=>wr.filter(t=>!Et[t.root]?.trim()),[Et,wr]),id=a.useCallback(async t=>{if(!t||fi.current.has(t))return;const i=it.get(t)?.context;if((i?.branches?.length??0)>0||(i?.remoteBranches?.length??0)>0||i?.upstream)return;const u=v;fi.current.add(t),Ql(w=>new Set(w).add(t));try{const w=await Gd(t,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${t}`);if(!w.available||!Pe(u))return;Ee(y=>y.map(k=>k.root===t?{...k,available:!0,context:{...k.context,...w},error:void 0}:k)),ya(y=>y[t]||!w.branch?y:{...y,[t]:w.branch}),wa(y=>{if(y[t])return y;const k=Iu(w);return k?{...y,[t]:k}:y})}catch(w){jr(w)||console.warn("[RightSidebar] Failed to load branch audit repo details",t,w)}finally{fi.current.delete(t),Ql(w=>{const y=new Set(w);return y.delete(t),y})}},[it,Pe,v]);a.useEffect(()=>{if(Wo)for(const t of wr)id(t.root)},[Wo,wr,id]),a.useEffect(()=>{!Mi||!de||(Na(de.branch||(de.branches?.[0]??"")),Ca(de.upstreamRemote||(de.remotes?.includes("origin")?"origin":de.remotes?.[0]??"")),Ea(de.upstreamBranch||de.branch||(de.branches?.[0]??"")))},[de,Mi]);const ld=a.useMemo(()=>{if(et)return{text:o("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!Pn||xn)return{text:o("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!de?.upstream)return{text:o("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const t=de.ahead??0,i=de.behind??0;return t>0&&i>0?{text:o("rightSidebar.pushDivergedCount",{ahead:t,behind:i}),className:"bg-destructive/10 text-destructive"}:t>0?{text:o("rightSidebar.pushAheadCount",{count:t}),className:"bg-accent/10 text-accent"}:i>0?{text:o("rightSidebar.pushBehindCount",{count:i}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:o("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[de?.ahead,de?.behind,de?.upstream,Pn,xn,et,o]),lm=a.useCallback(t=>{if(t&&!se){const i=t.currentTarget.getBoundingClientRect();Ie({x:Math.min(i.left,window.innerWidth-352),y:Math.min(i.bottom+6,window.innerHeight-64)})}else Ie(null);S?.()},[se,S]),$i=a.useCallback(()=>{Ie(null),L?.()},[L]);function cd(){if(!An)return null;const t=rd?.label??o("rightSidebar.allRepositories"),i=rd?.count??Fe.size,u=kt(t)||t;return e.jsxs("button",{type:"button",onClick:lm,className:`inline-flex h-7 min-w-0 max-w-[13rem] shrink-0 items-center gap-1.5 rounded-md border px-2 text-[11px] font-medium transition active:scale-95 ${b?"border-primary/25 bg-primary/10 text-primary":"border-border/10 bg-surface-2 text-muted-foreground hover:border-border/25 hover:bg-surface-elevated hover:text-foreground"}`,"aria-haspopup":"listbox","aria-expanded":b,title:t,children:[e.jsx(kr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:u}),e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${i>0?"bg-accent/10 text-accent":"bg-surface text-muted-foreground"}`,children:i}),e.jsx(ca,{size:12,className:"shrink-0"})]})}function cm(){if(!b||!An||typeof document>"u")return null;const t=typeof window>"u"?1024:window.innerWidth,i=typeof window>"u"?768:window.innerHeight,u=Math.max(12,Math.min(Je?.x??t-368,t-352)),w=Math.max(12,Math.min(Je?.y??80,i-420)),y=se?void 0:{left:u,top:w},k=e.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${se?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:$i,children:e.jsxs("div",{className:se?"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:y,onClick:C=>C.stopPropagation(),children:[e.jsxs("div",{className:se?"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:se?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:o("rightSidebar.repositories")}),!se&&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:qa.length}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${Fe.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Fe.size})]})]}),e.jsx("button",{type:"button",onClick:$i,className:se?"rounded-full bg-surface-2 p-1.5 text-muted-foreground hover:bg-surface hover:text-foreground":"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.close"),children:e.jsx(Lt,{size:se?16:14})})]}),e.jsx("div",{className:se?"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:qa.map(C=>{const le=(C.root??null)===ce,ae=kt(C.label)||C.label;return e.jsxs("button",{type:"button",onClick:()=>{Md(C.root),$i()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${se?"px-3 py-2":"px-2 py-1.5"} ${le?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:C.label,role:"option","aria-selected":le,children:[e.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${le?"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 ${le?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:e.jsx(kr,{size:13})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:`${se?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:ae}),e.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:C.root===null?o("rightSidebar.allRepositories"):C.label})]}),C.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:C.branch}),C.deferred?e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/70",children:o("rightSidebar.repoNotLoaded")}):e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${C.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:C.count})]},C.root??"all")})})]})});return Rf(k,se,document.body)}function dm(){return cm()}function dd(t){const i=xt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path),w=jo(u,i??v);return{key:Sr(t),path:t.path,absolutePath:u,displayName:w.name,displayDir:w.dir,oldPath:t.oldPath,status:t.status,title:u}}function ud(t){return t.oldPath?e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:o("rightSidebar.changedFromPath",{path:t.oldPath})}):null}function Ja(t,i){const u=Tn(t,v),w=`path:${u}`,y=De===w,k=Re===w,C=y||k;return e.jsx("button",{type:"button",onClick:le=>{le.stopPropagation(),Ot(u,w)},...ji(Ua(u),w),className:`inline-flex h-6 shrink-0 items-center justify-center overflow-hidden rounded-md text-[11px] font-semibold opacity-100 transition-[max-width,padding,opacity,transform,background-color,color] active:scale-95 ${C?"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"} ${C?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:i,children:e.jsx("span",{className:"whitespace-nowrap",children:o(k?"rightSidebar.copied":y?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function fd(t){const i=xt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path),w=_m(t),y=cl(t);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(s0,{actions:w,running:qe,completed:Hn?.path===y?Hn:null}),Ja(u,o("rightSidebar.insertThisFile"))]})}function hd(t,i){const u=i.root??v;if(!u)return null;const w=Tn(t,u);return Ja(w,o("fileTree.insertRefTitle"))}function Hs(){return e.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5","aria-label":o("diffViewer.view"),children:[e.jsx("button",{type:"button",onClick:()=>Sd("unified"),"aria-pressed":Mr==="unified",title:o("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Mr==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.unified")}),e.jsx("button",{type:"button",onClick:()=>Sd("split"),"aria-pressed":Mr==="split",title:o("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Mr==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.split")})]})}function md(){return zs.map(t=>{const i=zu(t.files.map(([,k])=>k)),u=Rl({activeGitRepoRoot:ce,groupCount:zs.length,label:t.label,rootName:st}),w=!!(u&&t.root&&Xe.has(t.root));return{key:t.root??t.label,root:t.root,label:t.label,branch:t.branch,collapsed:w,files:t.files.map(([,k])=>dd(k)),header:u?e.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${w?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Em(t.root),"aria-expanded":!w,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:w?e.jsx(hs,{size:13}):e.jsx(ca,{size:13})}),e.jsx(kr,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:t.label}),t.branch&&e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:t.branch})]}),e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.files.length}),i>0&&e.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:i})]}),t.root&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),so("stage-all",t.root,t.label)},disabled:!!qe,className:"rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:o("rightSidebar.stageAll"),children:o("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),so("stash-all",t.root,t.label)},disabled:!!qe,className:"rounded-full bg-surface-2 px-2 py-0.5 text-[10px] font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:o("rightSidebar.stashAll"),children:o("rightSidebar.stashAll")})]})]}):null}})}const Ln=a.useMemo(()=>new Map(Array.from(Fe.values(),t=>[Sr(t),t])),[Fe]);function pd(t){const i=Ln.get(t.key),u=i?xt(i,v):null,w=Cg(St,u,i?.path??t.path);return e.jsx(yl,{changeStatus:t.status,auditStatus:w,renderChangeBadge:y=>e.jsx(aa,{status:y})})}const Qa=a.useCallback(t=>{if(se)return null;const i=Array.from(t.querySelectorAll("[data-diff-stream-item]"));if(i.length===0)return null;const w=t.getBoundingClientRect().top+48;let y=null,k=Number.POSITIVE_INFINITY;for(const le of i){const ae=le.getBoundingClientRect();if(ae.bottom<w)continue;const xe=Math.abs(ae.top-w);xe<k&&(y=le,k=xe)}const C=y?.dataset.diffSelectionPath??y?.dataset.diffStreamItem??null;return C?(Ia.current===C&&V.getState().selectedFilePath===C||(Ia.current=C,ot(C)),C):null},[se,ot]),um=!!(!qe&&Ne&&!et&&(de?.upstream||vn.trim()&&yn.trim())),fm=!!(!qe&&Ne&&!et&&(de?.upstream||vn.trim()&&yn.trim())),hm=!!(!qe&&Ne&&!et&&Wn.trim()&&Wn.trim()!==de?.branch),Xt=a.useMemo(()=>{const t=Ye.trim().toLowerCase(),i=Array.from(Fe.entries()).filter(([,u])=>!ce||xt(u,v)===ce).sort(([u],[w])=>u.localeCompare(w));return t?i.filter(([u,w])=>`${u} ${w.path} ${w.status} ${w.repoRelativeRoot??""} ${w.repoName??""}`.toLowerCase().includes(t)):i},[ce,Fe,Ye,v]);a.useEffect(()=>{ea("selected_file_state",{selectedFilePath:at,selectedChangedFilePath:Vt?.path??null,selectedChangedFileAbsolutePath:Vt?.absolutePath??null,selectedChangedFileRepoRoot:Vt?.repoRoot??null,rootPath:v,activeGitRepoRoot:ce,rightTab:ai,effectiveRightTab:Mt,diffPaneActive:$t,changedFiles:Fe.size,filteredChangedFiles:Xt.length,gitBundleLoading:br,gitBundleLastLoadedAt:Vn})},[ce,Fe.size,$t,Mt,Xt.length,Vn,br,ai,v,Vt?.absolutePath,Vt?.path,Vt?.repoRoot,at]);const zs=a.useMemo(()=>{const t=new Map;for(const i of Xt){const[,u]=i,w=xt(u,v),y=r0(u)||st,k=w??y,C=w?it.get(w):void 0,le=t.get(k)??{root:w,label:y,branch:C?.context?.branch,files:[]};le.files.push(i),t.set(k,le)}return Array.from(t.values()).sort((i,u)=>i.label===st?-1:u.label===st?1:i.label.localeCompare(u.label))},[Xt,it,st,v]),Ws=a.useMemo(()=>{const t=[],i=new Map;for(const u of Xt)i.set(Sr(u[1]),u);for(const u of zs){if(!!(u.root&&Rl({activeGitRepoRoot:ce,groupCount:zs.length,label:u.label,rootName:st})&&Xe.has(u.root)))continue;if(zr!=="tree"){t.push(...u.files);continue}const y=u.files.map(([,k])=>dd(k));for(const k of Hp(y)){const C=i.get(k.key);C&&t.push(C)}}return t},[ce,Xe,zr,zs,Xt,st]),gd=a.useMemo(()=>Fe.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:o("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Ws.map(([,t])=>{const i=xt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path);return{key:Sr(t),path:t.path,absolutePath:u,status:t.status,repoRoot:i,displayName:jo(u,i).name,displayDir:jo(u,i).dir,auditRecords:St}}),[St,Fe.size,Ws,v,o]);a.useEffect(()=>{if(!$t||Ws.length===0||se)return;const t=[],i=()=>{const u=document.querySelector(".termdock-diff-stream-scroller");if(u&&Qa(u))return;const w=document.querySelector("[data-diff-stream-item]"),y=w?.dataset.diffSelectionPath??w?.dataset.diffStreamItem??null;if(y){Ia.current=y,ot(y);return}const k=Ws[0]?.[1];if(!k)return;const C=Sr(k);Ia.current=C,ot(C)};for(const u of[80,240,600,1200])t.push(window.setTimeout(i,u));return()=>t.forEach(u=>window.clearTimeout(u))},[$t,se,Ws,ot,Qa]);const Pi=a.useMemo(()=>{const t=C=>`'${C.replace(/'/g,"'\\''")}'`,i=ar.length>0?Rn:fe.filter(C=>C.files.length>0),u=i.length>0?i:v?[{root:v,relativeRoot:".",name:st}]:[],w=u.length>0?u.map(C=>`- ${C.relativeRoot==="."?".":C.relativeRoot} (${C.root})`).join(`
1663
+ `)},[as]),zc=Jg({text:ct,sessionId:n??Jr.getState().activeSessionId,active:r&&We,onAccepted:()=>{cr(!1),Nt(""),Ce&&ne(!0)},onRejected:()=>{cr(!0),ne(!1)}}),st=a.useMemo(()=>v?kt(v):o("rightSidebar.workspace"),[v,o]),Qh=a.useMemo(()=>kt(le)||st,[le,st]),Wa=a.useMemo(()=>vo(le),[le]),Ga=a.useMemo(()=>v?fc[v]??[]:[],[fc,v]),En=a.useMemo(()=>new Set(Ga.map(t=>t.path)),[Ga]),_s=!!(le&&En.has(le)),Ci=!!(v&&le&&le!==v),Zh=!!(v&&Kn&&Kn!==v),Ut=le?`path:${le}`:null,Wc="context:change-audit",em=a.useCallback(()=>{Wa&&Ft(Wa)},[Wa,Ft]),Gc=a.useCallback(()=>{pc()},[pc]),tm=a.useCallback(()=>{le&&(Ps(le,!0),xc())},[xc,le,Ps]),rm=a.useCallback(()=>{!le||!Ci||(_s?wn(le):qn(le,"directory"))},[Ci,le,_s,qn,wn]),Kc=a.useCallback(t=>{Ft(t),Y("")},[Ft]),qc=a.useCallback(t=>{le&&(we(Bb(le,t)),P(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[le,P]),Vc=a.useCallback(t=>{!v||t===v||(En.has(t)?wn(t):qn(t,"directory"))},[qn,En,v,wn]),Yc=a.useCallback(t=>{!v||!t||(En.has(t)?wn(t):qn(t,"file"))},[qn,En,v,wn]),Xc=V(t=>t.expandedPaths),Ei=a.useMemo(()=>{const t=new Set;if(Dr&&le){t.add(le);const i=`${le.replace(/\/+$/,"")}/`;for(const u of Xc)u.startsWith(i)&&t.add(u)}if(Dr&&v&&at){const i=at.startsWith("/")?at:`${v}/${at}`,u=vo(i);u&&t.add(u)}return _g(t).join(`
1664
+ `)},[Xc,Dr,le,v,at]),Mn=a.useRef(new Map);a.useEffect(()=>{const t=Ei?Ei.split(`
1665
+ `):[];if(!r||t.length===0){Gn(null);return}const i=new AbortController;let u=!1,w=0,y=0;Gn(null);const k=async()=>{let C=0;for(;!u&&!i.signal.aborted;){let ie=null;try{Gn(null),await gp(t,xe=>{const{applicableEvents:Ae,unavailableReason:Ze}=Og(xe);Ae.length>0&&gc(Ae);const ee=new Set(Ae.filter(X=>X.type==="rescan-required").map(X=>X.path));if(Aa)for(const X of Ae){if(X.type==="created"||X.type==="updated"){const me=vo(X.path);me&&ee.add(me)}X.path.endsWith("/.gitignore")&&le&&Ps(le,!0)}for(const X of ee){const me={path:X},Le=V.getState();if(!Le.directoryCache.has(me.path))continue;Mn.current.get(me.path)?.abort();const He=new AbortController;Mn.current.set(me.path,He);const Bd=`file-watch-rescan:${me.path}`;Rt(Bd),Vu(me.path,He.signal,Le.showHiddenFiles,"watch_rescan",Bd,Le.fileSortModes[me.path]??"name",le??void 0).then(Ks=>{Mn.current.get(me.path)===He&&bc(me.path,Ks.entries)}).catch(Ks=>{jr(Ks)||Gn(Ks instanceof Error?Ks.message:"File refresh unavailable")}).finally(()=>{Mn.current.get(me.path)===He&&Mn.current.delete(me.path)})}Ze&&Gn(Ze)},i.signal),ie=new Error("File watch stream ended")}catch(xe){ie=xe}if(u||i.signal.aborted||jr(ie))return;Gn(ie instanceof Error?ie.message:"File watching unavailable");const ae=Cu[Math.min(C,Cu.length-1)];C+=1,await new Promise(xe=>{y=window.setTimeout(xe,ae)})}};return w=window.setTimeout(()=>{u||k()},tl),()=>{u=!0,window.clearTimeout(w),window.clearTimeout(y),i.abort();for(const C of Mn.current.values())C.abort();Mn.current.clear()}},[gc,r,bc,Ei,le,Aa,Ps]),a.useEffect(()=>{if(!v||hi.current!==v)return;if(mi.current===v){mi.current=null;return}const t=Au();sa(Pf,{...t,[v]:{selectedRepoRoots:va,repoTargetBranches:rr,repoBaseBranches:Et,previewEntries:cn,selectedPreviewKey:ve&&hr?Qe:null,selectedPreviewFileKey:ve&&hr?Vo:null,previewDetailOpen:!!(ve&&hr),previewScrollTops:Ss,previewMobileSlideIndex:1,repoIncludeUncommitted:mn,updatedAt:Date.now()}},Ob)},[hr,mn,ve,cn,Ss,Et,rr,va,v,Vo,Qe]);const pt=a.useMemo(()=>Wu(Fe.values()),[Fe]),it=a.useMemo(()=>{const t=new Map;for(const i of fe)t.set(i.root,i);return t},[fe]),Bs=a.useMemo(()=>{const t=new Map;for(const i of fe)i.deferred||t.set(i.root,i.files.length);return t},[fe]),Ka=a.useCallback(t=>{if(t){if(!t.deferred){Ls.current.delete(t.root);return}Bs.has(t.root)||Ls.current.has(t.root)||(Ls.current.add(t.root),_t(t.root,{includeNested:!1,background:!0,replaceRepoRoot:t.root}).then(i=>{i||Ls.current.delete(t.root)}))}},[_t,Bs]),ir=a.useMemo(()=>ce?$e.find(t=>t.root===ce)??null:null,[ce,$e]),Vt=a.useMemo(()=>at?Array.from(Fe.values()).find(t=>t.path===at||t.absolutePath===at)??null:null,[Fe,at]),Ht=a.useMemo(()=>{const t=new Map;for(const i of fe)i.available&&i.context?.available&&t.set(i.root,i);return t.size===0&&M?.available&&M.root&&t.set(M.root,{id:M.root,root:M.root,relativeRoot:".",name:st,depth:0,nested:!1,available:!0,files:Array.from(Fe.values()).filter(i=>xt(i,v)===M.root),context:M}),Array.from(t.values()).sort((i,u)=>i.root===v?-1:u.root===v?1:(i.relativeRoot||i.name).localeCompare(u.relativeRoot||u.name)).map(i=>{const u=i.relativeRoot==="."?st:i.relativeRoot||i.name||kt(i.root),w=zu(i.files),y=i.files.length;return{value:i.root,label:u,meta:[i.context?.branch,y>0?o("rightSidebar.repoChangedCount",{count:y}):null,w>0?o("rightSidebar.repoStagedCount",{count:w}):null].filter(Boolean).join(" · ")}})},[Fe,M,fe,st,v,o]),Ne=a.useMemo(()=>ce&&Ht.some(t=>t.value===ce)?ce:Vt?.repoRoot&&Ht.some(t=>t.value===Vt.repoRoot)?Vt.repoRoot:Ht.length===1||Ht.length>1?Ht[0].value:null,[ce,Ht,Vt?.repoRoot]),Jc=Ne?it.get(Ne)??null:null,de=Jc?.context?.available?Jc.context:Ne===M?.root?M:null,et=Ht.length>0&&!Ne,Qc=a.useMemo(()=>et?[]:Ne?Array.from(Fe.values()).filter(t=>xt(t,v)===Ne):Array.from(Fe.values()),[Ne,Fe,et,v]),$n=a.useMemo(()=>Wu(Qc),[Qc]),Mi=!!(de?.available&&de.root&&Ne&&de.root===Ne),nm=Ne?Ht.find(t=>t.value===Ne)?.label??kt(Ne):o("rightSidebar.gitRepositoryPlaceholder"),Zc=Mi?de?.branch??"HEAD":et?o("rightSidebar.selectRepositoryForGitActions"):xn?o("rightSidebar.gitActionRunning"):"HEAD",Pn=!!(de?.available&&de.root===Ne&&de.status);a.useEffect(()=>{Yl.current={count:re.length,loading:Wt,loadingMore:ba,hasMore:zo}},[re.length,zo,Wt,ba]),a.useEffect(()=>{Kr.current+=1,gr.current?.abort(),Rt("right-sidebar-recent-commits"),gr.current=null,pr(""),Ke([]),Pr(!1),Ns(!1),On(null),Un(!1)},[Ne]);const Os=a.useCallback(async(t={})=>{if(!v||!Ne||et)return;const i=t.reset??!1,u=Yl.current,w=i?0:u.count;if(!i&&(u.loading||u.loadingMore||!u.hasMore))return;const y=Kr.current+1;Kr.current=y,gr.current?.abort(),Rt("right-sidebar-recent-commits");const k=new AbortController;gr.current=k,i?Pr(!0):Ns(!0),On(null);try{const C=await up({cwd:v,repoRoot:Ne,limit:Jb,skip:w,query:fn.trim(),requestSlotId:"right-sidebar-recent-commits"},k.signal);if(Kr.current!==y)return;if(!C.available){On(C.error??"Recent commits are unavailable"),i&&Ke([]),Un(!1);return}Uo(ie=>i?C.commitSyncStatus??{}:{...ie,...C.commitSyncStatus}),Ke(ie=>i?C.commits:[...ie,...C.commits]),Un(C.hasMore)}catch(C){if(Kr.current!==y||jr(C))return;On(C instanceof Error?C.message:"Failed to load recent commits"),i&&Ke([]),Un(!1)}finally{gr.current===k&&(gr.current=null),Kr.current===y&&(Pr(!1),Ns(!1))}},[Ne,fn,et,v]);a.useEffect(()=>{Gr&&Os({reset:!0})},[fn,Os,Gr,de?.ahead,de?.behind,de?.upstream]);const sm=a.useCallback(t=>{const i=t.currentTarget;i.scrollTop+i.clientHeight<i.scrollHeight-48||Os({reset:!1})},[Os]);a.useEffect(()=>{!Ne||!M?.available||!dt||!nr||Pn||xn||et||xi(Ne)},[Ne,M?.available,Pn,xn,dt,nr,xi,et]);const ed=r&&($t||dt);a.useEffect(()=>{!ed||!v||vr()},[ed,vr,v]),a.useEffect(()=>{!r||!dt||!nr||!Cs||!v||Fa(null)},[Cs,dt,nr,r,Fa,v]);const am=a.useMemo(()=>{if(!ce)return 0;const t=$e.findIndex(i=>i.root===ce);return t>=0?t+1:0},[ce,$e]),td=a.useCallback(t=>{if(!t)return null;const i=Array.from(Fe.values()).filter(u=>xt(u,v)===t).sort((u,w)=>u.path.localeCompare(w.path))[0];return i?Sr(i):null},[Fe,v]),An=$e.length>1,qa=a.useMemo(()=>[{root:null,label:o("rightSidebar.allRepositories"),count:Fe.size,branch:null,deferred:!1},...$e.map(t=>({root:t.root,label:t.label,count:t.deferred?Bs.get(t.root)??0:t.count,branch:t.branch??null,deferred:!!t.deferred&&!Bs.has(t.root)}))],[Fe.size,$e,Bs,o]),rd=qa[am]??qa[0],Va=!!ce,nd=a.useMemo(()=>_f($e,fe),[$e,fe]);a.useEffect(()=>{gi.current===v&&ce&&!nd.has(ce)&&Te(null),_n(t=>t.filter(i=>$e.some(u=>u.root===i)))},[ce,$e,nd,v,Te]),a.useEffect(()=>{ce&&Ka(it.get(ce))},[ce,Ka,it]);const om=a.useMemo(()=>{const t=new Set;de?.branch&&t.add(de.branch);for(const i of de?.branches??[])t.add(i);return Array.from(t).map(i=>({value:i,label:i,meta:i===de?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0}))},[de?.branch,de?.branches,o]),sd=a.useMemo(()=>{const t=new Set;de?.upstreamRemote&&t.add(de.upstreamRemote);for(const i of de?.remotes??[])t.add(i);return Array.from(t).map(i=>({value:i,label:i,meta:i===de?.upstreamRemote?o("rightSidebar.pushUpstreamBadge"):void 0}))},[de?.remotes,de?.upstreamRemote,o]),ad=sd.length>1,im=a.useMemo(()=>{const t=[],i=new Set,u=(y,k)=>{!y||i.has(y)||(i.add(y),t.push({value:y,label:y,meta:k}))};u(de?.upstreamBranch,de?.upstreamBranch?o("rightSidebar.pushUpstreamBadge"):void 0),u(de?.branch,de?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0);for(const y of de?.branches??[])u(y,y===de?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");const w=de?.upstreamRemote;for(const y of de?.remoteBranches??[]){const k=y.indexOf("/"),C=k>=0?y.slice(0,k):null,ie=k>=0?y.slice(k+1):y;(!w||C===w)&&u(ie,"remote")}return t},[de?.branch,de?.branches,de?.remoteBranches,de?.upstreamBranch,de?.upstreamRemote,o]),Yt=a.useMemo(()=>Ht.map(t=>{const i=it.get(t.value);return{root:t.value,label:t.label,branch:i?.context?.branch??null}}),[Ht,it]);a.useEffect(()=>{Yt.length!==0&&(ya(t=>{let i=!1;const u={...t},w=new Set(Yt.map(y=>y.root));for(const y of Object.keys(u))w.has(y)||(delete u[y],i=!0);for(const y of Yt)!u[y.root]&&y.branch&&(u[y.root]=y.branch,i=!0);return i?u:t}),wa(t=>{let i=!1;const u={...t},w=new Set(Yt.map(y=>y.root));for(const y of Object.keys(u))w.has(y)||(delete u[y],i=!0);for(const y of Yt){const k=it.get(y.root)?.context;if(u[y.root]&&Bf(u[y.root],k?.branch)&&(delete u[y.root],i=!0),u[y.root])continue;const C=Iu(k);C&&(u[y.root]=C,i=!0)}return i?u:t}))},[Yt,it]);const Ya=a.useMemo(()=>{const t=new Set(Yt.map(i=>i.root));return va.filter(i=>t.has(i))},[va,Yt]),Xa=Ya.length===0,wr=a.useMemo(()=>Xa?Yt:Yt.filter(t=>Ya.includes(t.root)),[Yt,Ya,Xa]),Us=a.useMemo(()=>wr.filter(t=>!!Et[t.root]?.trim()),[Et,wr]),os=a.useCallback((t,i)=>{const u=it.get(t)?.context?.branch;return!!(u&&i&&i.replace(/^refs\/heads\//,"")===u)},[it]),od=a.useMemo(()=>wr.filter(t=>!Et[t.root]?.trim()),[Et,wr]),id=a.useCallback(async t=>{if(!t||fi.current.has(t))return;const i=it.get(t)?.context;if((i?.branches?.length??0)>0||(i?.remoteBranches?.length??0)>0||i?.upstream)return;const u=v;fi.current.add(t),Ql(w=>new Set(w).add(t));try{const w=await Gd(t,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${t}`);if(!w.available||!Pe(u))return;Ee(y=>y.map(k=>k.root===t?{...k,available:!0,context:{...k.context,...w},error:void 0}:k)),ya(y=>y[t]||!w.branch?y:{...y,[t]:w.branch}),wa(y=>{if(y[t])return y;const k=Iu(w);return k?{...y,[t]:k}:y})}catch(w){jr(w)||console.warn("[RightSidebar] Failed to load branch audit repo details",t,w)}finally{fi.current.delete(t),Ql(w=>{const y=new Set(w);return y.delete(t),y})}},[it,Pe,v]);a.useEffect(()=>{if(Wo)for(const t of wr)id(t.root)},[Wo,wr,id]),a.useEffect(()=>{!Mi||!de||(Na(de.branch||(de.branches?.[0]??"")),Ca(de.upstreamRemote||(de.remotes?.includes("origin")?"origin":de.remotes?.[0]??"")),Ea(de.upstreamBranch||de.branch||(de.branches?.[0]??"")))},[de,Mi]);const ld=a.useMemo(()=>{if(et)return{text:o("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!Pn||xn)return{text:o("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!de?.upstream)return{text:o("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const t=de.ahead??0,i=de.behind??0;return t>0&&i>0?{text:o("rightSidebar.pushDivergedCount",{ahead:t,behind:i}),className:"bg-destructive/10 text-destructive"}:t>0?{text:o("rightSidebar.pushAheadCount",{count:t}),className:"bg-accent/10 text-accent"}:i>0?{text:o("rightSidebar.pushBehindCount",{count:i}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:o("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[de?.ahead,de?.behind,de?.upstream,Pn,xn,et,o]),lm=a.useCallback(t=>{if(t&&!se){const i=t.currentTarget.getBoundingClientRect();Ie({x:Math.min(i.left,window.innerWidth-352),y:Math.min(i.bottom+6,window.innerHeight-64)})}else Ie(null);S?.()},[se,S]),$i=a.useCallback(()=>{Ie(null),L?.()},[L]);function cd(){if(!An)return null;const t=rd?.label??o("rightSidebar.allRepositories"),i=rd?.count??Fe.size,u=kt(t)||t;return e.jsxs("button",{type:"button",onClick:lm,className:`inline-flex h-7 min-w-0 max-w-[13rem] shrink-0 items-center gap-1.5 rounded-md border px-2 text-[11px] font-medium transition active:scale-95 ${b?"border-primary/25 bg-primary/10 text-primary":"border-border/10 bg-surface-2 text-muted-foreground hover:border-border/25 hover:bg-surface-elevated hover:text-foreground"}`,"aria-haspopup":"listbox","aria-expanded":b,title:t,children:[e.jsx(kr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:u}),e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${i>0?"bg-accent/10 text-accent":"bg-surface text-muted-foreground"}`,children:i}),e.jsx(ca,{size:12,className:"shrink-0"})]})}function cm(){if(!b||!An||typeof document>"u")return null;const t=typeof window>"u"?1024:window.innerWidth,i=typeof window>"u"?768:window.innerHeight,u=Math.max(12,Math.min(Je?.x??t-368,t-352)),w=Math.max(12,Math.min(Je?.y??80,i-420)),y=se?void 0:{left:u,top:w},k=e.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${se?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:$i,children:e.jsxs("div",{className:se?"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:y,onClick:C=>C.stopPropagation(),children:[e.jsxs("div",{className:se?"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:se?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:o("rightSidebar.repositories")}),!se&&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:qa.length}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${Fe.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Fe.size})]})]}),e.jsx("button",{type:"button",onClick:$i,className:se?"rounded-full bg-surface-2 p-1.5 text-muted-foreground hover:bg-surface hover:text-foreground":"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.close"),children:e.jsx(Lt,{size:se?16:14})})]}),e.jsx("div",{className:se?"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:qa.map(C=>{const ie=(C.root??null)===ce,ae=kt(C.label)||C.label;return e.jsxs("button",{type:"button",onClick:()=>{Md(C.root),$i()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${se?"px-3 py-2":"px-2 py-1.5"} ${ie?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:C.label,role:"option","aria-selected":ie,children:[e.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${ie?"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 ${ie?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:e.jsx(kr,{size:13})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:`${se?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:ae}),e.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:C.root===null?o("rightSidebar.allRepositories"):C.label})]}),C.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:C.branch}),C.deferred?e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/70",children:o("rightSidebar.repoNotLoaded")}):e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${C.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:C.count})]},C.root??"all")})})]})});return Rf(k,se,document.body)}function dm(){return cm()}function dd(t){const i=xt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path),w=jo(u,i??v);return{key:Sr(t),path:t.path,absolutePath:u,displayName:w.name,displayDir:w.dir,oldPath:t.oldPath,status:t.status,title:u}}function ud(t){return t.oldPath?e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:o("rightSidebar.changedFromPath",{path:t.oldPath})}):null}function Ja(t,i){const u=Tn(t,v),w=`path:${u}`,y=De===w,k=Re===w,C=y||k;return e.jsx("button",{type:"button",onClick:ie=>{ie.stopPropagation(),Ot(u,w,ie.currentTarget)},...ji(Ua(u),w),className:`inline-flex h-6 shrink-0 items-center justify-center overflow-hidden rounded-md text-[11px] font-semibold opacity-100 transition-[max-width,padding,opacity,transform,background-color,color] active:scale-95 ${C?"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"} ${C?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:i,children:e.jsx("span",{className:"whitespace-nowrap",children:o(k?"rightSidebar.copied":y?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function fd(t){const i=xt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path),w=_m(t),y=cl(t);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(s0,{actions:w,running:qe,completed:Hn?.path===y?Hn:null}),Ja(u,o("rightSidebar.insertThisFile"))]})}function hd(t,i){const u=i.root??v;if(!u)return null;const w=Tn(t,u);return Ja(w,o("fileTree.insertRefTitle"))}function Hs(){return e.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5","aria-label":o("diffViewer.view"),children:[e.jsx("button",{type:"button",onClick:()=>Sd("unified"),"aria-pressed":Mr==="unified",title:o("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Mr==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.unified")}),e.jsx("button",{type:"button",onClick:()=>Sd("split"),"aria-pressed":Mr==="split",title:o("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Mr==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.split")})]})}function md(){return zs.map(t=>{const i=zu(t.files.map(([,k])=>k)),u=Rl({activeGitRepoRoot:ce,groupCount:zs.length,label:t.label,rootName:st}),w=!!(u&&t.root&&Xe.has(t.root));return{key:t.root??t.label,root:t.root,label:t.label,branch:t.branch,collapsed:w,files:t.files.map(([,k])=>dd(k)),header:u?e.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${w?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Em(t.root),"aria-expanded":!w,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:w?e.jsx(hs,{size:13}):e.jsx(ca,{size:13})}),e.jsx(kr,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:t.label}),t.branch&&e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:t.branch})]}),e.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.files.length}),i>0&&e.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:i})]}),t.root&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),so("stage-all",t.root,t.label)},disabled:!!qe,className:"rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:o("rightSidebar.stageAll"),children:o("rightSidebar.stageAll")}),e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),so("stash-all",t.root,t.label)},disabled:!!qe,className:"rounded-full bg-surface-2 px-2 py-0.5 text-[10px] font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:o("rightSidebar.stashAll"),children:o("rightSidebar.stashAll")})]})]}):null}})}const Ln=a.useMemo(()=>new Map(Array.from(Fe.values(),t=>[Sr(t),t])),[Fe]);function pd(t){const i=Ln.get(t.key),u=i?xt(i,v):null,w=Cg(St,u,i?.path??t.path);return e.jsx(yl,{changeStatus:t.status,auditStatus:w,renderChangeBadge:y=>e.jsx(aa,{status:y})})}const Qa=a.useCallback(t=>{if(se)return null;const i=Array.from(t.querySelectorAll("[data-diff-stream-item]"));if(i.length===0)return null;const w=t.getBoundingClientRect().top+48;let y=null,k=Number.POSITIVE_INFINITY;for(const ie of i){const ae=ie.getBoundingClientRect();if(ae.bottom<w)continue;const xe=Math.abs(ae.top-w);xe<k&&(y=ie,k=xe)}const C=y?.dataset.diffSelectionPath??y?.dataset.diffStreamItem??null;return C?(Ia.current===C&&V.getState().selectedFilePath===C||(Ia.current=C,ot(C)),C):null},[se,ot]),um=!!(!qe&&Ne&&!et&&(de?.upstream||vn.trim()&&yn.trim())),fm=!!(!qe&&Ne&&!et&&(de?.upstream||vn.trim()&&yn.trim())),hm=!!(!qe&&Ne&&!et&&Wn.trim()&&Wn.trim()!==de?.branch),Xt=a.useMemo(()=>{const t=Ye.trim().toLowerCase(),i=Array.from(Fe.entries()).filter(([,u])=>!ce||xt(u,v)===ce).sort(([u],[w])=>u.localeCompare(w));return t?i.filter(([u,w])=>`${u} ${w.path} ${w.status} ${w.repoRelativeRoot??""} ${w.repoName??""}`.toLowerCase().includes(t)):i},[ce,Fe,Ye,v]);a.useEffect(()=>{ea("selected_file_state",{selectedFilePath:at,selectedChangedFilePath:Vt?.path??null,selectedChangedFileAbsolutePath:Vt?.absolutePath??null,selectedChangedFileRepoRoot:Vt?.repoRoot??null,rootPath:v,activeGitRepoRoot:ce,rightTab:ai,effectiveRightTab:Mt,diffPaneActive:$t,changedFiles:Fe.size,filteredChangedFiles:Xt.length,gitBundleLoading:br,gitBundleLastLoadedAt:Vn})},[ce,Fe.size,$t,Mt,Xt.length,Vn,br,ai,v,Vt?.absolutePath,Vt?.path,Vt?.repoRoot,at]);const zs=a.useMemo(()=>{const t=new Map;for(const i of Xt){const[,u]=i,w=xt(u,v),y=r0(u)||st,k=w??y,C=w?it.get(w):void 0,ie=t.get(k)??{root:w,label:y,branch:C?.context?.branch,files:[]};ie.files.push(i),t.set(k,ie)}return Array.from(t.values()).sort((i,u)=>i.label===st?-1:u.label===st?1:i.label.localeCompare(u.label))},[Xt,it,st,v]),Ws=a.useMemo(()=>{const t=[],i=new Map;for(const u of Xt)i.set(Sr(u[1]),u);for(const u of zs){if(!!(u.root&&Rl({activeGitRepoRoot:ce,groupCount:zs.length,label:u.label,rootName:st})&&Xe.has(u.root)))continue;if(zr!=="tree"){t.push(...u.files);continue}const y=u.files.map(([,k])=>dd(k));for(const k of Hp(y)){const C=i.get(k.key);C&&t.push(C)}}return t},[ce,Xe,zr,zs,Xt,st]),gd=a.useMemo(()=>Fe.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:o("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Ws.map(([,t])=>{const i=xt(t,v),u=t.absolutePath||(i?`${i}/${t.path}`:t.path);return{key:Sr(t),path:t.path,absolutePath:u,status:t.status,repoRoot:i,displayName:jo(u,i).name,displayDir:jo(u,i).dir,auditRecords:St}}),[St,Fe.size,Ws,v,o]);a.useEffect(()=>{if(!$t||Ws.length===0||se)return;const t=[],i=()=>{const u=document.querySelector(".termdock-diff-stream-scroller");if(u&&Qa(u))return;const w=document.querySelector("[data-diff-stream-item]"),y=w?.dataset.diffSelectionPath??w?.dataset.diffStreamItem??null;if(y){Ia.current=y,ot(y);return}const k=Ws[0]?.[1];if(!k)return;const C=Sr(k);Ia.current=C,ot(C)};for(const u of[80,240,600,1200])t.push(window.setTimeout(i,u));return()=>t.forEach(u=>window.clearTimeout(u))},[$t,se,Ws,ot,Qa]);const Pi=a.useMemo(()=>{const t=C=>`'${C.replace(/'/g,"'\\''")}'`,i=ar.length>0?Rn:fe.filter(C=>C.files.length>0),u=i.length>0?i:v?[{root:v,relativeRoot:".",name:st}]:[],w=u.length>0?u.map(C=>`- ${C.relativeRoot==="."?".":C.relativeRoot} (${C.root})`).join(`
1666
1666
  `):`- ${v?".":""}`,y=u.length>0?u.map(C=>` td audit-export ${t(C.root)}`).join(`
1667
1667
  `):" td audit-export",k=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??""}`,"目标仓库:",w,"","执行步骤:","1. 仅对“目标仓库”逐个执行 audit-export。嵌套子仓使用括号内 repo 绝对路径作为命令参数。",y,"2. 先检查 audit-export 输出的 coverage[]:确认 untrackedFiles 是否为空、未跟踪文件是否已经出现在 hunks[].filePath 中;如果 coverage 显示存在未跟踪文件但 hunks[] 未包含对应文件,必须汇报导出异常,不要假装已解释。","3. 读取 audit-export 输出的全部 hunks[].diff,包含 tracked 与 untracked hunks;先理解整批改动的业务目标、行为变化、文件分工和跨 hunk 依赖。","4. 以 audit-export 内置 diff 为分析依据。仅在单个 hunk 信息不足时执行:td audit-show <hunkId> <对应仓库绝对路径>","5. 在 ~/.termdock/change-audit/ 生成批量 payload JSON。"," mkdir -p ~/.termdock/change-audit","6. payload 顶层字段:workspaceRoot、repoRoot、generatedBy、walkthrough、records[]。","7. walkthrough 必须先生成,用三层结构说明整批改动:highlights[] 面向不了解代码的人讲“改了什么/带来什么效果”;nodes[]/edges[] 表达关键链路;risks[]/checks[] 写真实风险和验证。节点可带 anchor,点击后会跳到对应 diff。","8. records[] 必须覆盖每个 hunk 内的多个 section,而不是只写 hunk 总结;从 audit-export hunk 原样复制 filePath、oldPath、newPath、hunkHeader、hunkIndex、fingerprint;如果解释的是 section,额外填写 sectionIndex 和 sectionFingerprint;补充 summary、explanation。","9. 写入 payload 后批量注入:",k,'10. 少量 hunk 或临时补单条时使用:printf "%s\\n" "这里写该 hunk 的改动意义" | td audit-explain <hunkId> <对应仓库绝对路径>',"11. 注入成功后清理本次 payload:rm -f ~/.termdock/change-audit/payload*.json","","payload.walkthrough 示例字段:","{",' "title": "一句话标题",',' "summary": "整批改动的目的和结果",',' "highlights": [{ "what": "改了什么", "effect": "用户或系统得到什么", "tag": "体验" }],',' "nodes": [{ "id": "n1", "title": "节点标题", "kind": "ui", "business": "零上下文业务解释", "anchor": { "repoRoot": "<repoRoot>", "filePath": "<filePath>", "hunkIndex": 0, "hunkFingerprint": "<fingerprint>", "sectionIndex": 0, "sectionFingerprint": "<sectionFingerprint>" } }],',' "edges": [{ "from": "n1", "to": "n2", "label": "调用/传递/消费", "desc": "这条关系的业务含义" }],',' "risks": [{ "title": "真实风险或口径疑问", "anchor": { "filePath": "<filePath>" } }],',' "checks": ["可执行验证动作"]',"}","","写作标准:","- summary:一句话概括该 hunk 在整批改动中的职责。","- explanation:自包含说明业务链路、该 hunk 的作用、解决的问题、与其它 hunk 的关系。","- walkthrough.highlights 必须大白话,不要堆文件名/函数名;只看 highlights 应该知道这次改动干嘛。","- walkthrough.nodes 优先对应方法、关键业务步骤或关键 section;每个有 anchor 的节点必须能跳回真实 diff。","- 面向不了解本轮对话的 AI 编写,补足必要上下文。","- 输出高信息量结论;避免铺垫、套话、流程复述、泛泛风险、逐行翻译 diff。","","完成条件:汇报每个目标仓库已注入的 hunk 数和总数。"].join(`
1668
1668
  `)},[ar.length,Rn,fe,st,v]),mm=a.useCallback((t="generate")=>{if(An&&Zt.length===0&&!ce){sn(!0);return}const i=t==="generate"?Pi:[t==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",Pi].join(`
1669
1669
  `);ut("insert_change_audit_prompt",{rootPath:v,activeGitRepoRoots:ar,mode:t,hasAuditListCommand:i.includes("td audit-list"),promptLength:i.length}),Fr(o("rightSidebar.insertChangeAuditPrompt"),i,`${Wc}:${t}`),vr(),c||l()},[ce,Pi,Zt.length,ar,Fr,vr,l,c,v,An,o]),Za=a.useCallback(async t=>{try{await qd({ids:[t]}),rn(i=>i.filter(u=>u.id!==t))}catch{vr()}},[vr]),pm=a.useCallback(async()=>{if(St.length===0)return;const t=St.map(i=>i.id);try{await qd({ids:t}),rn(i=>i.filter(u=>!t.includes(u.id))),Qt(null)}catch(i){const u=i instanceof Error?i.message:"Failed to clear change audit explanations";Qt(o("rightSidebar.changeAuditClearFailed",{message:u})),vr()}},[St,vr,o]),gm=a.useCallback(async t=>{if(t.records.length===0)return;const i=t.records.map(u=>u.id);try{await fp({ids:i}),an(u=>u.filter(w=>!i.includes(w.id))),Qe===t.key&&(pn(null),mr(!1))}catch(u){Gt(o("rightSidebar.branchAuditClearFailed",{message:u instanceof Error?u.message:"Failed to clear branch explanation"})),Fa(null)}},[Fa,Qe,o]),bm=a.useCallback(t=>{_n(i=>t===null?(sn(!1),[]):i.includes(t)?i.filter(u=>u!==t):[...i,t])},[]),xm=a.useCallback(t=>{Ko(i=>t===null?(Go(!1),[]):i.includes(t)?i.filter(u=>u!==t):[...i,t])},[]),Ai=a.useMemo(()=>{if(!nr)return[];const t=i=>{const u=i.diff??"";let w=0,y=0;for(const k of u.split(`
1670
1670
  `))k.startsWith("+++")||k.startsWith("---")||(k.startsWith("+")&&(w+=1),k.startsWith("-")&&(y+=1));return{filePath:i.filePath,oldPath:i.oldPath,newPath:i.newPath,hunkHeader:i.hunkHeader,hunkIndex:i.hunkIndex??0,fingerprint:i.fingerprint,additions:w,deletions:y,diff:u}};return ve?(ve.hunks??[]).map(i=>{const u=ve.comparisonRepos&&ve.comparisonRepos.length>1?[...ve.comparisonRepos].sort((y,k)=>k.label.length-y.label.length).find(y=>i.filePath.startsWith(`${y.label}/`)):void 0,w=fr.find(y=>y.repoRoot===ve.repoRoot&&y.baseRef===ve.baseRef&&(y.branchName??null)===(ve.currentBranch??null)&&y.filePath===i.filePath&&y.hunkHeader===i.hunkHeader&&(y.hunkIndex??0)===i.hunkIndex&&y.fingerprint===i.fingerprint)??null;return{key:`${i.filePath}\0${i.hunkHeader}\0${i.hunkIndex}`,repoRoot:u?.repoRoot??ve.repoRoot,repositoryPath:u?i.filePath.slice(u.label.length+1):i.filePath,hunk:i.previewRevert&&!os(i.previewRevert.cwd,i.previewRevert.comparisonBranch)?{...i,previewRevert:void 0}:i,current:w,stale:null}}):Qe?fr.filter(i=>Lu(i)===Qe).map(i=>{const u=t(i);return{key:`${i.filePath}\0${i.hunkHeader}\0${i.hunkIndex??0}`,hunk:u,current:i,stale:null}}):[]},[ve,fr,os,nr,Qe]),Li=fr.length>0,is=a.useMemo(()=>{if(!nr)return[];const t=new Map;for(const i of fr){const u=i.repoRoot,w=it.get(u),y=w?.relativeRoot==="."?st:w?.relativeRoot||w?.name||kt(u),k=Lu(i),C=t.get(k)??{key:k,repoRoot:u,repoLabel:y,baseRef:i.baseRef,branchName:i.branchName??null,headRef:i.headRef??null,diffFingerprint:i.diffFingerprint??null,records:[],latestInjectedAt:0};C.records.push(i),C.latestInjectedAt=Math.max(C.latestInjectedAt,i.injectedAt??0),t.set(k,C)}return Array.from(t.values()).sort((i,u)=>u.latestInjectedAt-i.latestInjectedAt)},[fr,it,nr,st]),Ti=a.useMemo(()=>Qe?is.find(t=>t.key===Qe)??null:null,[is,Qe]),Gs=ve?{repoRoot:ve.repoRoot??"",repoLabel:ve.repoRoot?it.get(ve.repoRoot)?.relativeRoot==="."?st:it.get(ve.repoRoot)?.relativeRoot||it.get(ve.repoRoot)?.name||kt(ve.repoRoot):st,baseRef:ve.baseRef??ve.baseBranch??"",branchName:ve.currentBranch??null,headRef:ve.headRef??null,diffFingerprint:ve.diffFingerprint??null}:Ti,vm=a.useMemo(()=>(ze?.hunks??[]).map(t=>({key:`${t.filePath}\0${t.hunkHeader}\0${t.hunkIndex}`,repoRoot:ze?.repoRoot,hunk:t,current:null,stale:null})),[ze?.hunks,ze?.repoRoot]),ym=a.useMemo(()=>{if(ve)return[];const t=Ti;return t?on.filter(i=>i.repoRoot===t.repoRoot&&i.baseRef===t.baseRef&&(i.branchName??null)===t.branchName&&(!t.diffFingerprint||i.diffFingerprint===t.diffFingerprint)):[]},[ve,on,Ti]),wm=a.useCallback(t=>{const i=Ai.find(u=>u.hunk.filePath===t.filePath||(t.repoRoot?`${t.repoRoot}/${u.hunk.filePath}`===t.filePath:!1));i&&(gn(i.key),window.setTimeout(()=>In(t),90),window.setTimeout(()=>In(t),320),window.setTimeout(()=>In(t),760))},[Ai]),Ii=a.useMemo(()=>{const t=y=>`'${y.replace(/'/g,"'\\''")}'`,i=Us,u=i.length>0?i.map(y=>`- ${y.label} (${y.root}),目标分支:${rr[y.root]||y.branch||"(current branch)"},基线分支:${Et[y.root]||"(not set)"},包含本地未提交更改:${os(y.root,rr[y.root]||y.branch)&&(mn[y.root]??!0)?"是":"否"}`).join(`
1671
- `):`- ${v?".":""}`,w=i.length>0?i.map(y=>{const k=rr[y.root]||y.branch||"",C=Et[y.root]||"",le=y.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[k?` git -C ${t(y.root)} switch ${t(k)}`:` # ${y.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${t(C)} ${t(y.root)} > ~/.termdock/branch-audit/branch-audit-export-${le}.json`].join(`
1671
+ `):`- ${v?".":""}`,w=i.length>0?i.map(y=>{const k=rr[y.root]||y.branch||"",C=Et[y.root]||"",ie=y.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[k?` git -C ${t(y.root)} switch ${t(k)}`:` # ${y.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${t(C)} ${t(y.root)} > ~/.termdock/branch-audit/branch-audit-export-${ie}.json`].join(`
1672
1672
  `)}).join(`
1673
1673
  `):" td branch-audit-export <base-branch>";return["解释目标仓库当前分支相对于基线分支的改动,并把解释写回 Termdock。","",`当前工作区:${v??""}`,"每个仓库分别遵循下面列出的本地未提交更改选项。","目标仓库:",u,"","操作指令:","1. 只针对上面列出的目标仓库导出分支 hunk,按各仓库所选目标分支与基线对比。本地未提交更改标记为是的仓库纳入 staged/unstaged/untracked 改动;标记为否的仓库只解释提交改动,忽略导出中混入的本地改动。嵌套子仓或软链接子仓使用括号内的仓库绝对路径。示例:",w,"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(`
1674
1674
  `)},[mn,os,Us,Et,rr,v]),km=a.useCallback((t="generate")=>{const i=t==="generate"?Ii:[t==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",Ii].join(`
1675
- `);Fr(o("rightSidebar.branchAuditShort"),i,`context:branch-audit-scope:${t}`),c||l()},[Ii,Fr,l,c,o]),Di=a.useCallback(async(t={})=>{const i=t.refresh===!0,u=i&&ve?.comparisonRepos?ve.comparisonRepos:Us.map(C=>{const le=(rr[C.root]||C.branch||"").trim();return{repoRoot:C.root,label:C.label,base:Et[C.root]?.trim()??"",head:le||null,includeUncommitted:mn[C.root]??!0}});if(!v||u.length===0)return;const w=++It.current,y=v,k=()=>Pe(y)&&w===It.current;ke(!0),_e(null),i||(er(null),Ge(null));try{const C=await Promise.all(u.map(async ee=>{if(!ee.base)throw new Error(o("rightSidebar.branchAuditMissingBase",{repo:ee.label}));return Vd({cwd:v,repoRoot:ee.repoRoot,base:ee.base,head:ee.head,includeUncommitted:t.repoRoot===ee.repoRoot?t.includeUncommitted??!1:ee.includeUncommitted??ve?.includeUncommitted??!0,requestSlotId:`right-sidebar-branch-preview:${ee.repoRoot}`})}));if(!k())return;const le=C.find(ee=>!ee.available);if(le){_e(le.error??"Branch diff is unavailable");return}const ae=C.length===1?C[0]:{available:!0,workspaceRoot:v,repoRoot:v,baseRef:C.map(ee=>ee.baseRef??ee.baseBranch).filter(Boolean).join(", "),currentBranch:C.map(ee=>ee.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:C.map(ee=>ee.headRef).filter(Boolean).join(", "),diffFingerprint:C.map(ee=>ee.diffFingerprint).filter(Boolean).join("+"),stat:C.map(ee=>ee.stat).filter(Boolean).join(`
1675
+ `);Fr(o("rightSidebar.branchAuditShort"),i,`context:branch-audit-scope:${t}`),c||l()},[Ii,Fr,l,c,o]),Di=a.useCallback(async(t={})=>{const i=t.refresh===!0,u=i&&ve?.comparisonRepos?ve.comparisonRepos:Us.map(C=>{const ie=(rr[C.root]||C.branch||"").trim();return{repoRoot:C.root,label:C.label,base:Et[C.root]?.trim()??"",head:ie||null,includeUncommitted:mn[C.root]??!0}});if(!v||u.length===0)return;const w=++It.current,y=v,k=()=>Pe(y)&&w===It.current;ke(!0),_e(null),i||(er(null),Ge(null));try{const C=await Promise.all(u.map(async ee=>{if(!ee.base)throw new Error(o("rightSidebar.branchAuditMissingBase",{repo:ee.label}));return Vd({cwd:v,repoRoot:ee.repoRoot,base:ee.base,head:ee.head,includeUncommitted:t.repoRoot===ee.repoRoot?t.includeUncommitted??!1:ee.includeUncommitted??ve?.includeUncommitted??!0,requestSlotId:`right-sidebar-branch-preview:${ee.repoRoot}`})}));if(!k())return;const ie=C.find(ee=>!ee.available);if(ie){_e(ie.error??"Branch diff is unavailable");return}const ae=C.length===1?C[0]:{available:!0,workspaceRoot:v,repoRoot:v,baseRef:C.map(ee=>ee.baseRef??ee.baseBranch).filter(Boolean).join(", "),currentBranch:C.map(ee=>ee.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:C.map(ee=>ee.headRef).filter(Boolean).join(", "),diffFingerprint:C.map(ee=>ee.diffFingerprint).filter(Boolean).join("+"),stat:C.map(ee=>ee.stat).filter(Boolean).join(`
1676
1676
  `),files:C.flatMap((ee,X)=>{const me=u[X];return(ee.files??[]).map(Le=>`${me?.label??ee.repoRoot??"repo"}/${Le}`)}),hunks:C.flatMap((ee,X)=>{const Le=u[X]?.label??ee.repoRoot??"repo";return(ee.hunks??[]).map(Ve=>({...Ve,filePath:`${Le}/${Ve.filePath}`,oldPath:Ve.oldPath?`${Le}/${Ve.oldPath}`:Ve.oldPath,newPath:Ve.newPath?`${Le}/${Ve.newPath}`:Ve.newPath}))}),commits:C.flatMap(ee=>ee.commits??[]),commitCount:C.reduce((ee,X)=>ee+(X.commitCount??X.commits?.length??0),0),diff:C.map(ee=>ee.diff).filter(Boolean).join(`
1677
- `),truncated:C.some(ee=>ee.truncated)};if(ae.comparisonRepos=u.map((ee,X)=>({...ee,head:ee.head??C[X].currentBranch??null,includeUncommitted:C[X].includeUncommitted===!0,canIncludeUncommitted:C[X].canIncludeUncommitted})),ae.canIncludeUncommitted=C.every(ee=>ee.canIncludeUncommitted===!0),ae.includeUncommitted=C.some(ee=>ee.includeUncommitted===!0),qo(ee=>({...ee,...Object.fromEntries(ae.comparisonRepos.map(X=>[X.repoRoot,X.includeUncommitted??!1]))})),!i&&(ae.hunks??[]).length===0){_e(o("rightSidebar.branchAuditDiffEmpty"));return}const xe=Date.now(),Ae=(i?Qe:null)??["preview",ae.repoRoot??v,ae.baseRef??ae.baseBranch??"",ae.currentBranch??"",ae.headRef??"",ae.diffFingerprint??xe].join("\0"),Ze=u.length===1?u[0].label:`${u.length} repos`;er(ae),Bn(ee=>[{key:Ae,diff:ae,repoLabel:Ze,createdAt:xe},...ee.filter(X=>X.key!==Ae)].slice(0,8)),i||dn(ee=>ee[Ae]===void 0?ee:{...ee,[Ae]:0}),pn(Ae),gn(ee=>{const X=ae.hunks?.[0],me=X?`${X.filePath}\0${X.hunkHeader}\0${X.hunkIndex}`:null;return i&&ee&&(ae.hunks??[]).some(Le=>Le.filePath===ee.split("\0")[0])?ee:me}),mr(!0)}catch(C){if(!k()||jr(C))return;_e(C instanceof Error?C.message:"Failed to load branch diff")}finally{k()&&ke(!1)}},[mn,ve,Qe,Us,Et,rr,Pe,v,o]),Sm=a.useCallback(t=>{++It.current,ke(!1),er(t.diff),_e(null),pn(t.key),gn(t.diff.hunks?.[0]?`${t.diff.hunks[0].filePath}\0${t.diff.hunks[0].hunkHeader}\0${t.diff.hunks[0].hunkIndex}`:null),mr(!0)},[]),jm=a.useCallback(t=>{Bn(i=>i.filter(u=>u.key!==t)),dn(i=>{if(!(t in i))return i;const u={...i};return delete u[t],u}),Qe===t&&(pn(null),er(null),mr(!1))},[Qe]),Rm=a.useCallback(t=>{++It.current,ke(!1);const i=is.find(u=>u.key===t);i&&(er(null),_e(null),pn(t),gn(i.records[0]?.filePath??null),mr(!0))},[is]),Nm=a.useCallback(async t=>{if(!v||!Ne)return;const[i]=t.split(/\s+/);if(i){vt(i),tr(null),Ge(null);try{const u=await hp({cwd:v,repoRoot:Ne,commit:i,requestSlotId:"right-sidebar-commit-diff"});if(!u.available){tr(u.error??"Commit diff is unavailable");return}Ge(u);const w=u.hunks?.[0];xa(w?`${w.filePath}\0${w.hunkHeader}\0${w.hunkIndex}`:null)}catch(u){tr(u instanceof Error?u.message:"Failed to load commit diff")}finally{vt(null)}}},[Ne,v]),Cm=a.useCallback(t=>{if(!ve||!Qe)return;const i=Math.max(0,Math.round(t));dn(u=>Math.abs((u[Qe]??0)-i)<24?u:{...u,[Qe]:i})},[ve,Qe]);a.useEffect(()=>{!ve||!Qe||Bn(t=>t.map(i=>i.key===Qe&&i.diff!==ve?{...i,diff:ve}:i))},[ve,Qe]);const bd=!!ve;a.useEffect(()=>{if(!se||!hr||!bd)return;const t=Mc.current;if(!t||t.destroyed)return;t.update(),t.slideTo(1,0);const i=window.requestAnimationFrame(()=>{t.destroyed||(t.update(),t.slideTo(1,0))});return()=>window.cancelAnimationFrame(i)},[hr,bd,se]);const xd=a.useCallback(t=>{t&&Th(i=>zp(i,t))},[]),vd=Ma.key===at?Ma.key:null,eo=a.useCallback(t=>{const i=V.getState(),u=p0();ea("select_diff_file",{interactionId:u,path:t,previousSelectedFilePath:i.selectedFilePath,rootPath:i.rootPath,activeGitRepoRoot:ce,changedFiles:i.changedFiles.size,gitBundleLoading:i.gitBundleLoading,gitBundleLastLoadedAt:i.gitBundleLastLoadedAt,rightTab:i.rightTab}),ot(t),Dt("diff"),se&&t&&Ac(1),xd(t),queueMicrotask(()=>{const w=V.getState();ea("select_diff_file_after",{interactionId:u,requestedPath:t,selectedFilePath:w.selectedFilePath,rootPath:w.rootPath,rightTab:w.rightTab,changedFiles:w.changedFiles.size,activeGitRepoRoot:ce})})},[ce,se,xd,ot,Dt,Ac]),yd=a.useCallback(t=>{const i=Array.from(Fe.values()).find(u=>{const w=xt(u,v),y=Sr(u);return u.path===t.filePath||y===t.filePath||u.absolutePath===t.filePath||(w?`${w}/${u.path}`===t.filePath:!1)||t.repoRoot&&w===t.repoRoot&&u.path===t.filePath});if(i){eo(Sr(i)),window.setTimeout(()=>In(t),90),window.setTimeout(()=>In(t),320),window.setTimeout(()=>In(t),760);return}In(t)},[Fe,v,eo]),wd=a.useCallback(({slideToDetail:t,fullscreen:i,toggleFullscreen:u}={})=>vs.length>0?e.jsx(lf,{walkthroughs:vs,repoRoot:ce,fullscreen:i,onToggleFullscreen:u,onNavigate:w=>{se&&window.requestAnimationFrame(()=>t?.()),yd(w)}}):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(da,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),o("rightSidebar.changeWalkthroughEmpty")]}),[ce,vs,yd,se,o]),Em=a.useCallback(t=>{t&&dr(i=>{const u=new Set(i);return u.has(t)?u.delete(t):u.add(t),rl(Qi,u),u})},[]),kd=a.useCallback(t=>{Hr(i=>{const u=new Set(i);return u.has(t)?u.delete(t):u.add(t),rl(Su,u),u})},[]),to=a.useCallback(t=>{Er(t),At(Cf,t)},[]);a.useEffect(()=>{Va||zr!=="ai"||to("tree")},[zr,to,Va]);const ro=a.useCallback(()=>{ga(t=>{const i=!t;return At(Ef,i),i})},[]),Sd=a.useCallback(t=>{bs(t),At(Mf,t)},[]),{whitespace:jd,context:Rd}=Gp(),Nd=a.useMemo(()=>({algorithm:"histogram",whitespace:jd,context:Rd}),[jd,Rd]),Cd=a.useCallback(t=>{pe(t),At($f,t)},[]),no=a.useCallback(async(t,i,u,w)=>{let y=t;for(;y.ok&&y.status==="running";)await new Promise(C=>window.setTimeout(C,1500)),y=await Yd({jobId:y.jobId,cwd:i.cwd,action:i.action});if(!y.ok)throw new Error("Git action status is unavailable");if(y.status==="error")throw new Error(y.error||y.message||"Git action failed");const k={action:i.action,path:w,label:u};return $s(k),window.setTimeout(()=>$s(C=>C?.action===k.action&&C.path===k.path?null:C),1400),y},[]),wt=a.useCallback(async(t,i,u)=>{const w=v;v&&xr.current.delete(v),Gt(null),$s(null),Ms({action:t.action,path:u});try{const y=await mp({...t,includeNested:Xs(v)}),k=await no(y,t,i,u);if(!Pe(w))return!1;const C=v?await Gi(v,void 0,{includeNested:Xs(v),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Qs(v)}).catch(()=>k.bundle):k.bundle;return Pe(w)?(C&&Zn(C,{reloadDiff:!0,cacheOnly:!0}),bn(null),!0):!1}catch(y){return $s(null),Gt(o("rightSidebar.gitActionFailed",{message:y instanceof Error?y.message:"Unknown error"})),!1}finally{Pe(w)&&Ms(null)}},[Zn,Pe,v,o,no]),Ed=a.useCallback(async t=>{const i=v;await Xd({...t,includeNested:Xs(v)}),Pe(i)&&_t(v??void 0,{refresh:!0,background:!0})},[Pe,_t,v]),Mm=a.useCallback(async t=>{const i=ve,u=It.current,w=i?.hunks?.find(k=>k.previewRevert?.cwd===t.cwd&&k.previewRevert.path===t.path);if(!i||!w||!t.comparisonBase)throw new Error(o("diffViewer.hunkActionUnavailable"));K(k=>k+1),_e(null);try{await Xd(t)}catch(k){throw K(C=>C-1),k}if(u!==It.current||!Pe(v)){K(k=>k-1);return}const y=k=>{er(C=>{if(!C||u!==It.current)return C;const le=C.hunks??[],ae=k===void 0?le.filter(Ae=>!(Ae.previewRevert?.cwd===t.cwd&&Ae.previewRevert.patch===t.patch)):[...le.filter(Ae=>Ae.filePath!==w.filePath),...k];return{...C,hunks:ae}})};y(),Vd({cwd:t.cwd,repoRoot:t.cwd,base:t.comparisonBase,comparisonBase:t.comparisonBase,filePath:t.path,requestSlotId:`branch-preview-file:${t.cwd}:${t.path}`}).then(k=>{if(u!==It.current||!Pe(v))return;if(!k.available||k.truncated)throw new Error(k.error??o("diffViewer.hunkActionUnavailable"));const C=t.path.slice(t.cwd.length+1),le=w.filePath.slice(0,w.filePath.length-C.length);y((k.hunks??[]).map(ae=>({...ae,filePath:`${le}${ae.filePath}`,oldPath:ae.oldPath?`${le}${ae.oldPath}`:ae.oldPath,newPath:ae.newPath?`${le}${ae.newPath}`:ae.newPath})))}).catch(k=>{u===It.current&&Pe(v)&&!jr(k)&&_e(`${o("diffViewer.hunkActionReverted")} · ${k instanceof Error?k.message:String(k)}`)}).finally(()=>K(k=>k-1))},[ve,Pe,v,o]),so=a.useCallback((t,i,u)=>{if(i){if(t==="stage-all"){wt({action:"stage-all",cwd:i},o("rightSidebar.stageAll"),`repo:${i}`);return}bn({kind:"stash-all",repoRoot:i,repoLabel:u})}},[wt,o]),Md=a.useCallback(t=>{Te(t),Na(""),Ca(""),Ea(""),ot(td(t)),dt||Dt("diff"),t&&Ka(it.get(t))},[Ka,td,dt,it,ot,Te,Dt]),$d=a.useCallback(t=>{const i=new Set([...qt.current.keys(),...Sn.current,...xr.current]);for(const u of i)u!==t&&(Kt.current.delete(u),qt.current.get(u)?.abort(),qt.current.delete(u),Rt(`right-sidebar-git-untracked:${u}`),Sn.current.delete(u),xr.current.delete(u))},[]),$m=a.useCallback(async t=>{const i=v;if(!i||(await V.getState().setNestedGitScanRoot(i,t),!Pe(i)))return;if(t){await _t(i,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}$d(i),Na(""),Ca(""),Ea(""),Ko(w=>w.filter(y=>y===i));const u=Vt;u&&xt(u,i)!==i&&ot(null),await _t(i,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[$d,Pe,_t,v,ot,Vt]),Pm=a.useCallback(async()=>{if(!Ne||et){Gt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=Wn.trim();!t||t===de?.branch||await wt({action:"switch-branch",cwd:Ne,branch:t},o("rightSidebar.switchBranch"))},[de?.branch,Ne,et,wt,Wn,o]),Pd=a.useCallback(async()=>{if(!Ne||et){Gt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=Ra.trim();if(!t)return;await wt({action:"commit",cwd:Ne,message:t},o("rightSidebar.commitChanges"))&&ac("")},[Ne,Ra,et,wt,o]),Am=a.useCallback(async()=>{if(!Ne||et){Gt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=vn.trim(),i=yn.trim();await wt({action:"push",cwd:Ne,...t?{remote:t}:{},...i?{branch:i}:{}},o("rightSidebar.pushChanges"))},[Ne,yn,vn,et,wt,o]),Lm=a.useCallback(async()=>{if(!Ne||et){Gt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=vn.trim(),i=yn.trim();await wt({action:"pull",cwd:Ne,...t?{remote:t}:{},...i?{branch:i}:{}},o("rightSidebar.pullChanges"))},[Ne,yn,vn,et,wt,o]);a.useEffect(()=>{if(!dt||!Ne||qe)return;let t=!1;const i={push:o("rightSidebar.pushChanges"),pull:o("rightSidebar.pullChanges"),commit:o("rightSidebar.commitChanges"),"switch-branch":o("rightSidebar.switchBranch"),"stage-all":o("rightSidebar.stageAll"),"stash-all":o("rightSidebar.stashAll")};return(async()=>{for(const u of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(t)return;const w=await Yd({cwd:Ne,action:u}).catch(()=>null);if(!w?.ok||w.status!=="running")continue;const y={action:u,cwd:Ne},k=i[u]??u;Ms({action:u});try{const C=await no(w,y,k);if(t||!Pe(v))return;const le=v?await Gi(v,void 0,{includeNested:Xs(v),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Qs(v)}).catch(()=>C.bundle):C.bundle;le&&Zn(le,{reloadDiff:!0,cacheOnly:!0})}catch(C){t||Gt(o("rightSidebar.gitActionFailed",{message:C instanceof Error?C.message:"Unknown error"}))}finally{t||Ms(null)}return}})(),()=>{t=!0}},[Ne,Zn,dt,Pe,v,qe,o,no]);const Fi=Hn?.action==="commit",_i=Hn?.action==="switch-branch",Bi=Hn?.action==="pull",Oi=Hn?.action==="push",ao=dt||Ah,Ui=Xa?o("rightSidebar.changeAuditScopeAll"):wr.length===1?wr[0].label:`${wr.length} repos`,Tm=wr.length>0,Ad=Us.length>0,Im=v?e.jsx(Ou,{open:Wo,onOpenChange:Go,showScopePicker:!0,selectedAll:Xa,repos:Yt,selectedRoots:Ya,onToggleRepo:xm,onGenerate:()=>km(Li?"regenerate":"generate"),disabled:!Tm,generateDisabled:!Ad,inserted:De?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:o(Li?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.branchAuditGenerateTitle"),ariaLabel:o("rightSidebar.branchAuditShort"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Ui,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o(Li?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{Di()},secondaryDisabled:!Ad||ge,secondaryLabel:o("rightSidebar.branchAuditViewDiff"),secondaryTitle:o("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:ge,loading:Jl.size>0,statusTitle:Jl.size>0?o("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsx("div",{className:"mb-2 space-y-1.5",children:od.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:o("rightSidebar.missingBaseReposSkipped",{repositories:od.map(t=>t.label).join(_==="zh"?"、":", ")})})}),renderRepoExtra:t=>{const i=it.get(t.root),u=os(t.root,rr[t.root]||i?.context?.branch),w=[],y=new Set,k=(xe,Ae)=>{!xe||y.has(xe)||(y.add(xe),w.push({value:xe,label:xe,meta:Ae}))};k(rr[t.root]||i?.context?.branch,o("rightSidebar.pushCurrentBranchBadge"));for(const xe of i?.context?.branches??[])k(xe,xe===i?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):o("rightSidebar.localBranch"));for(const xe of i?.context?.remoteBranches??[])k(xe,o("rightSidebar.remoteBranch"));const C=[],le=new Set,ae=(xe,Ae)=>{!xe||le.has(xe)||(le.add(xe),C.push({value:xe,label:xe,meta:Ae}))};ae(Et[t.root],Et[t.root]?o("rightSidebar.pushUpstreamBadge"):void 0),ae(i?.context?.upstream,i?.context?.upstream?o("rightSidebar.pushUpstreamBadge"):void 0);for(const xe of i?.context?.remoteBranches??[])ae(xe,"remote");for(const xe of i?.context?.branches??[])ae(xe,xe===i?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");return e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsx(fs,{label:o("rightSidebar.currentBranchLabel"),value:rr[t.root]||i?.context?.branch||"",options:w,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),onChange:xe=>{ya(Ae=>({...Ae,[t.root]:xe}))}}),e.jsx(fs,{label:o("rightSidebar.branchAuditBaseLabel"),value:Et[t.root]||"",options:C,placeholder:o("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:o("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:o("rightSidebar.branchAuditBaseEmpty"),onChange:xe=>{wa(Ae=>({...Ae,[t.root]:xe}))}}),e.jsxs("label",{className:"sm:col-span-2 flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium",children:o("rightSidebar.includeUncommitted")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:o(u?"rightSidebar.includeUncommittedHint":"rightSidebar.includeUncommittedCurrentBranchOnly")})]}),e.jsx("input",{type:"checkbox",checked:u&&(mn[t.root]??!0),disabled:!u,onChange:xe=>qo(Ae=>({...Ae,[t.root]:xe.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,Ld=Zs(St.reduce((t,i)=>Math.max(t,i.injectedAt??0),0),_),Dm=()=>v?e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>Xl(t=>{const i=!t;return At(Zi,i),i}),className:"group flex w-full items-center gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":Cs,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(da,{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:o("rightSidebar.branchAuditTitle")}),e.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:Ui})]}),e.jsx("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${Cs?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]}),Cs&&e.jsxs("div",{className:"mt-2 rounded-lg border border-border/10 bg-surface/60 p-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 text-[11px] text-muted-foreground",children:[o("rightSidebar.changeAuditScopeLabel"),": ",Ui]}),Im]}),nt&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:nt}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[cn.map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Qe===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Sm(t),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.diff.hunks?.length??0," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.currentBranch??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.baseRef??t.diff.baseBranch}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:o("rightSidebar.branchAuditViewDiff")})]}),Zs(t.createdAt,_)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:Zs(t.createdAt,_)})]}),e.jsx("button",{type:"button",onClick:()=>jm(t.key),className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:o("common.delete"),"aria-label":o("common.delete"),children:e.jsx(yo,{size:12})})]},t.key)),is.length>0?is.slice(0,Math.max(0,8-cn.length)).map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Qe===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Rm(t.key),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.records.length," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.branchName??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.baseRef}),t.diffFingerprint&&e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diffFingerprint})]}),Zs(t.latestInjectedAt,_)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:o("rightSidebar.branchAuditGeneratedAt",{time:Zs(t.latestInjectedAt,_)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{gm(t)},className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:o("rightSidebar.branchAuditClearTitle"),"aria-label":o("rightSidebar.branchAuditClearTitle"),children:e.jsx(yo,{size:12})})]},t.key)):cn.length===0?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,Fm=()=>nr&&v&&Pn?e.jsxs("div",{className:ao?"overflow-visible":"overflow-hidden",children:[Dm(),e.jsxs("button",{type:"button",onClick:()=>{dt||Lh(t=>{const i=!t;return i&&Ne&&!Pn&&!xn&&xi(Ne),i})},"aria-expanded":ao,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${dt?"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(kr,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:o("rightSidebar.gitQuickActions")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs("span",{className:`inline-flex items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${$n.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[xn&&e.jsx(ft,{size:10,className:"animate-spin"}),$n.staged>0?o("rightSidebar.stagedCount",{count:$n.staged}):o("rightSidebar.noStagedChangesShort")]}),!dt&&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 ${ao?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]})]}),ao&&e.jsxs("div",{className:"space-y-0",children:[Ht.length>1&&e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsx("div",{className:"mb-2 flex items-center justify-between gap-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.gitRepositorySectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:nm})]})}),e.jsx(fs,{label:o("rightSidebar.gitRepositoryLabel"),value:Ne??"",options:Ht,placeholder:o("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:o("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:o("rightSidebar.gitRepositoryEmpty"),disabled:!!qe,onChange:t=>{Md(t||null)}}),et&&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:o("rightSidebar.selectRepositoryForGitActions")})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.branchSectionTitle")}),e.jsx("div",{className:"mt-0.5 h-4 truncate text-[11px] leading-4 text-muted-foreground",children:Wn!==Zc?Zc:null})]}),e.jsxs("button",{type:"button",onClick:()=>{Pm()},disabled:!hm,className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${_i?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.switchBranch"),children:[e.jsx("span",{className:qe?.action==="switch-branch"||_i?"opacity-0":"",children:o("rightSidebar.switchBranch")}),qe?.action==="switch-branch"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),_i&&qe?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(fs,{label:o("rightSidebar.currentBranchLabel"),value:Wn,options:om,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),disabled:!!qe,onChange:Na})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.commitSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:et?o("rightSidebar.selectRepositoryForGitActions"):$n.staged>0?o("rightSidebar.commitReadyHint",{count:$n.staged}):o("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{Pd()},disabled:!!qe||et||$n.staged===0||!Ra.trim(),className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition active:scale-95 ${Fi?"bg-accent/10 text-accent disabled:bg-accent/10 disabled:text-accent":"bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-surface-2 disabled:text-muted-foreground"} disabled:cursor-not-allowed`,title:et?o("rightSidebar.selectRepositoryForGitActions"):$n.staged===0?o("rightSidebar.commitNeedsStaged"):o("rightSidebar.commitChanges"),children:[e.jsx("span",{className:qe?.action==="commit"||Fi?"opacity-0":"",children:o("rightSidebar.commitChanges")}),qe?.action==="commit"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Fi&&qe?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:Ra,onChange:t=>ac(t.target.value),onKeyDown:t=>{(t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),Pd())},placeholder:o("rightSidebar.commitMessagePlaceholder"),disabled:!!qe,className:"w-full min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-[13px] placeholder:text-[13px] text-foreground outline-none transition placeholder:text-muted-foreground/70 focus:border-primary focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-60",maxLength:300})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>js(t=>!t),className:"group flex w-full items-center justify-between gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":Gr,children:[e.jsx("span",{className:"min-w-0 text-[12px] font-medium text-foreground",children:o("rightSidebar.recentCommitsTitle")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[Wt&&e.jsx(ft,{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 ${Gr?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]})]}),Gr&&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(ms,{size:12,className:"shrink-0"}),e.jsx("input",{value:Rs,onChange:t=>pr(t.target.value),placeholder:o("rightSidebar.recentCommitsSearchPlaceholder"),className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1}),Rs&&e.jsx("button",{type:"button",onClick:()=>pr(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:e.jsx(Lt,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:sm,children:[re.length>0?re.map(t=>{const[i,...u]=t.split(/\s+/),w=u.join(" ")||t;return e.jsxs("button",{type:"button",onClick:()=>{Nm(t)},className:"flex w-full min-w-0 items-start gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-left font-mono text-[10px] transition hover:bg-surface-elevated active:scale-[0.99]",title:w,children:[e.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:w,children:w}),hn[i]&&e.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${hn[i]==="ahead"?"bg-accent/10 text-accent":hn[i]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:o(hn[i]==="ahead"?"rightSidebar.commitAhead":hn[i]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),bt===i&&e.jsx(ft,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},t)}):Wt?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:o("common.loading")}):Ho?null:e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.recentCommitsEmpty")}),ba&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(ft,{size:12,className:"animate-spin"})}),zo&&!ba&&re.length>0&&e.jsx("button",{type:"button",onClick:()=>{Os({reset:!1})},className:"w-full rounded-md bg-surface-2 px-2 py-1.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:o("rightSidebar.recentCommitsLoadMore")})]})]}),un&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:un}),Ho&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Ho})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.pushSectionTitle")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>{Lm()},disabled:!um,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Bi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pullChanges"),children:[e.jsx("span",{className:qe?.action==="pull"||Bi?"opacity-0":"",children:o("rightSidebar.pullChanges")}),qe?.action==="pull"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Bi&&qe?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{Am()},disabled:!fm,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Oi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pushChanges"),children:[e.jsx("span",{className:qe?.action==="push"||Oi?"opacity-0":"",children:o("rightSidebar.pushChanges")}),qe?.action==="push"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Oi&&qe?.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] ${ld.className}`,title:de?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:ld.text}),e.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:de?.upstream??""})]}),e.jsxs("div",{className:`grid gap-1.5 ${ad?"grid-cols-2":"grid-cols-1"}`,children:[ad&&e.jsx(fs,{label:o("rightSidebar.pushRemoteLabel"),value:vn,options:sd,placeholder:o("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:o("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:o("rightSidebar.pushNoRemotes"),disabled:!!qe,onChange:Ca}),e.jsx(fs,{label:o("rightSidebar.pushBranchLabel"),value:yn,options:im,placeholder:o("rightSidebar.pushBranchPlaceholder",{branch:de?.branch??"HEAD"}),searchPlaceholder:o("rightSidebar.pushBranchSearchPlaceholder"),emptyText:o("rightSidebar.pushNoBranches"),disabled:!!qe,onChange:Ea})]})]})]})]}):null,_m=a.useCallback(t=>{const i=xt(t,v);if(!i)return[];const u=cl(t),w=[];return t.canStage&&w.push({key:"stage-file",label:o("rightSidebar.stageFile"),onClick:()=>{wt({action:"stage-file",cwd:i,paths:[t.path]},o("rightSidebar.stageFile"),u)}}),t.canUnstage&&w.push({key:"unstage-file",label:o("rightSidebar.unstageFile"),onClick:()=>{wt({action:"unstage-file",cwd:i,paths:[t.path]},o("rightSidebar.unstageFile"),u)}}),t.canStash&&w.push({key:"stash-file",label:o("rightSidebar.stashFile"),onClick:()=>{wt({action:"stash-file",cwd:i,paths:[t.path]},o("rightSidebar.stashFile"),u)}}),t.canRestoreWorktree&&w.push({key:"restore-worktree-file",label:o("rightSidebar.restoreFile"),destructive:!0,onClick:()=>bn({kind:"restore",file:t,phrase:""})}),w},[v,wt,o]),Bm=a.useCallback(()=>{if(f){h?.();return}Lr(0),Ir.current?.slideTo(0),Ar(!1),Ct(null)},[h,f]),Td=a.useCallback(t=>{if(Y(""),Ft(t),ot(null),Ct(null),R(null),se){f&&h?.(),Lr(0),Ir.current?.slideTo(0),Ar(!1);return}},[se,h,f,ot,Ft]);a.useEffect(()=>{if(!U||V.getState().pendingTerminalPath!==U)return;V.setState({pendingTerminalPath:null}),(()=>{const i=U,u=i.path;if(!u.startsWith("/"))return;Y(""),Ct(null),tn(null);const w=!!(v&&(u===v||u.startsWith(`${v}/`)));if(i.kind==="file"){const y=vo(u);Is(u),typeof i.line=="number"&&Number.isSafeInteger(i.line)&&i.line>0&&tn(i.line),Ft(w?null:y),R({path:u,nonce:++z.current});return}ot(null),w?(Ft(null),R({path:u,nonce:++z.current})):(R(null),Ft(u)),se&&(f&&h?.(),Lr(0),Ir.current?.slideTo(0),Ar(!1))})()},[U,Is,se,h,f,v,ot,Ft]),a.useEffect(()=>{r||(zt(!1),Jt(!1))},[r]),a.useEffect(()=>{if(!lr&&!Cr)return;const t=i=>{i instanceof globalThis.KeyboardEvent&&i.key!=="Escape"||i instanceof globalThis.MouseEvent&&i.target instanceof Node&&(pa.current?.contains(i.target)||Fn.current?.contains(i.target))||(zt(!1),Jt(!1))};return window.addEventListener("mousedown",t),window.addEventListener("keydown",t),()=>{window.removeEventListener("mousedown",t),window.removeEventListener("keydown",t)}},[Cr,lr]);const Id=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:em,disabled:!Wa,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.parentFolder"),title:o("rightSidebar.parentFolder"),children:e.jsx(Il,{size:14})}),e.jsx("button",{type:"button",onClick:Gc,disabled:!v||Kn===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":o("rightSidebar.backToProjectRoot"),title:o("rightSidebar.backToProjectRoot"),children:e.jsx(ru,{size:14})}),e.jsx("button",{type:"button",onClick:tm,disabled:!ie,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.refreshFiles"),title:oc?o("rightSidebar.fileWatchUnavailable",{message:oc}):o("rightSidebar.refreshFiles"),children:e.jsx(wo,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:ie??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:Qh}),La==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:o("fileTree.sortedByModified"),"aria-label":o("fileTree.sortedByModified"),children:e.jsx(nu,{size:11})})]})}),e.jsx("button",{type:"button",onClick:()=>ie&&Ot(ie,Ut??void 0),disabled:!ie,...ie&&Ut?ji(Ua(ie),Ut):{},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 ${Ut&&(De===Ut||Re===Ut)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":o(Ut&&Re===Ut?"rightSidebar.copied":Ut&&De===Ut?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:o("rightSidebar.insertCurrentFolder"),children:Ut&&(De===Ut||Re===Ut)?e.jsx(Co,{size:13}):e.jsx(Eo,{size:13})}),e.jsx(kg,{rootPath:ie,disabled:!ie||!Fh||di,pressed:Aa,saving:di,onToggle:()=>{if(!ie||di)return;const t=ie;Sc(!0),ui(null),_h(t,!Aa).catch(()=>{const i=V.getState();(i.explorerRoot??i.rootPath)===t&&ui(o("rightSidebar.gitIgnoreSaveFailed"))}).finally(()=>Sc(!1))}}),e.jsxs("div",{ref:Fn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{zt(!1),Jt(t=>!t)},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":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:e.jsx(No,{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:()=>{Jt(!1),rm()},disabled:!Ci,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${_s?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[_s?e.jsx(qi,{size:14}):e.jsx(lo,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(_s?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Jt(!1),Ih()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${oi?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[oi?e.jsx(Yp,{size:14}):e.jsx(xl,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(oi?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!ie,onClick:()=>{ie&&(Jt(!1),Dh(ie,La==="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:[La==="modified"?e.jsx(Ap,{size:14}):e.jsx(nu,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(La==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),jc&&e.jsx("p",{role:"alert",className:"px-1 py-1 text-[11px] text-destructive",children:jc}),v&&(Ga.length>0||Zh)&&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:o("rightSidebar.pinnedFolders")}),e.jsxs("button",{type:"button",onClick:Gc,className:`inline-flex max-w-[9rem] shrink-0 items-center gap-1 rounded-md px-2 py-0.5 font-medium transition active:scale-95 ${ie===v?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:v,children:[e.jsx(ru,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:st})]}),Ga.map(t=>{const i=t.path,u=t.kind==="file",w=u?at===i:ie===i;return e.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${w?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i,children:[e.jsxs("button",{type:"button",onClick:()=>u?Is(i):Ft(i),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[u?e.jsx(vl,{size:10,className:"shrink-0"}):e.jsx(lo,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:kt(i)})]}),e.jsx("button",{type:"button",onClick:()=>wn(i),className:"mr-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":o("rightSidebar.unpinFolder",{name:kt(i)}),title:o("rightSidebar.unpinFolder",{name:kt(i)}),children:e.jsx(Lt,{size:9})})]},i)})]}),e.jsx("span",{"data-local-layer":"file-explorer-divider",className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-px bg-border/15","aria-hidden":"true"})]}),Hi=a.useMemo(()=>{if(zn===null)return null;const t=typeof navigator>"u"?void 0:navigator.language,i=Math.max(0,Math.floor((ei-zn)/1e3)),u=new Intl.RelativeTimeFormat(t,{numeric:"auto"}),[w,y]=i<60?[-i,"second"]:i<3600?[-Math.floor(i/60),"minute"]:i<86400?[-Math.floor(i/3600),"hour"]:[-Math.floor(i/86400),"day"];return u.format(w,y)},[ei,zn]),oo="flex min-h-10 w-full items-center gap-2.5 rounded-md px-2.5 text-left text-[12px] text-foreground transition hover:bg-surface-2 focus:bg-surface-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [@media(pointer:coarse)]:min-h-11",Dd=v&&!ts?e.jsxs("button",{type:"button",role:"menuitemcheckbox",tabIndex:-1,onClick:()=>{$m(!ii)},"aria-checked":ii,title:o("rightSidebar.multiRepoScanTitle"),className:oo,children:[e.jsx(kr,{size:15,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1",children:o("rightSidebar.multiRepoScan")}),ii&&e.jsx(Co,{size:14,className:"shrink-0 text-primary"})]}):null,Fd=v?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[Hi?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:o("rightSidebar.gitLastUpdated",{time:Hi}),children:Hi}):null,e.jsx("button",{type:"button",onClick:()=>{es()},disabled:br,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95","aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),children:e.jsx(wo,{size:13,className:br?"animate-spin":""})})]}):null,Om=Pc?o("rightSidebar.changeAuditScopeAll"):Rn.length===1?Rn[0].relativeRoot==="."?st:Rn[0].relativeRoot||Rn[0].name:`${Rn.length} repos`,Um=t=>v?e.jsxs("div",{role:"none",children:[e.jsx(Ou,{menuItem:!0,open:ks,onOpenChange:i=>{sn(i),i&&t()},showScopePicker:An,selectedAll:Pc,repos:Bh,selectedRoots:ar,onToggleRepo:bm,onGenerate:()=>{t(),mm()},disabled:!v,inserted:De===Wc,buttonLabel:o("rightSidebar.changeAuditShort"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:o("rightSidebar.insertChangeAuditPrompt"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Om,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o("rightSidebar.changeAuditShort"),loading:ws,error:!!nn,statusTitle:nn??(ws?o("rightSidebar.changeAuditLoading"):St.length>0?`${o("rightSidebar.changeAuditLoaded",{count:St.length})}${Ld?` · ${o("rightSidebar.changeAuditLoadedAt",{time:Ld})}`:""}`:void 0)}),St.length>0&&e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),pm()},disabled:ws||St.length===0,className:oo,title:o("rightSidebar.clearChangeAuditTitle"),"aria-label":o("rightSidebar.clearChangeAudit"),children:[e.jsx(yo,{size:15,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.clearChangeAudit")})]})]}):null,ls=ir??(M?.available&&v&&Fe.size>0&&fe.length<=1?{root:v,label:st}:null),_d=t=>e.jsxs(e.Fragment,{children:[ls&&e.jsxs("div",{role:"group","aria-label":o("rightSidebar.gitQuickActions"),children:[e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),so("stage-all",ls.root,ls.label)},disabled:!!qe,className:oo,children:[e.jsx(bp,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stageAll")]}),e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),so("stash-all",ls.root,ls.label)},disabled:!!qe,className:oo,children:[e.jsx(Up,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stashAll")]})]}),ls&&e.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Um(t),Dd&&e.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Dd]}),io=e.jsxs("div",{className:"flex h-5 flex-nowrap items-center gap-1 overflow-x-auto whitespace-nowrap text-[10px] font-medium [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&>*]:shrink-0",children:[M?.available&&M.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:M.branch,children:[e.jsx(kr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:M.branch})]}),pt.modified>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[pt.modified,"M"]}),pt.added>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",pt.added]}),pt.deleted>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",pt.deleted]}),pt.renamed>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[pt.renamed,"R"]}),pt.copied>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[pt.copied,"C"]}),pt.untracked>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[pt.untracked,"U"]}),pt.conflicted>0&&e.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[pt.conflicted,"!"]}),pt.other>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[pt.other,"?"]}),pt.staged>0&&e.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:o("rightSidebar.stagedCountShort",{count:pt.staged})})]});return e.jsxs(Lp,{side:"right",isOpen:r,drawerWidthPx:s,onClose:l,onOpen:d,push:c,pinned:m,children:[ji.popoverNode,e.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${Kh?"hidden":""}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"min-w-0 flex-1 px-1",children:e.jsxs("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",title:v??void 0,children:st}),(!se||Jo)&&M?.available&&M.branch&&e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:M.branch,children:[e.jsx(kr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"max-w-[7rem] truncate",children:M.branch})]})]})}),e.jsx("button",{type:"button",onClick:()=>{const t=!Z;P(t),t?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):Y("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Z?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleSearch"),title:o("common.search"),children:e.jsx(ms,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":We,onClick:()=>{Br(t=>!t),ne(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${We?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleContextDraft"),title:o("rightSidebar.contextDraftTitle"),children:[e.jsx(Tp,{size:14}),!We&&ct.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:dc,type:"file",multiple:!0,className:"hidden",onChange:t=>{const i=t.target.files;!i||i.length===0||(Ds(Array.from(i)),t.target.value="")}}),e.jsx("input",{ref:uc,type:"file",accept:"image/*",className:"hidden",onChange:t=>{const i=t.target.files?.[0];t.target.value="",i&&Yh(i)}}),g&&e.jsx("button",{type:"button",onClick:g,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${m?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:m?e.jsx(qi,{size:14}):e.jsx(lo,{size:14})}),e.jsxs("div",{ref:pa,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{Jt(!1),zt(t=>!t)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${lr?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":lr,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:e.jsx(No,{size:15})}),lr&&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:[["architecture","computer"].map(t=>e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":sr[t],onClick:()=>Vh(t,!sr[t]),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[t==="architecture"?e.jsx(su,{size:14,className:"text-muted-foreground"}):e.jsx(Jd,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"flex-1",children:o(t==="architecture"?"rightSidebar.showArchitectureTab":"rightSidebar.showComputerTab")}),e.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${sr[t]?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${sr[t]?"left-3.5":"left-0.5"}`})})]},t)),e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":qr,onClick:()=>Tc(!qr),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[e.jsx(Qd,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"flex-1",children:o("rightSidebar.showAndroidTab")}),e.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${qr?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${qr?"left-3.5":"left-0.5"}`})})]}),e.jsx("div",{className:"my-1 h-px bg-border/15",role:"separator"}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),dc.current?.click()},disabled:_a,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:[_a?e.jsx(ft,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(Ip,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),uc.current?.click()},disabled:_a,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:[_a?e.jsx(ft,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(tg,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.insertLocalImage")})]}),g&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),g()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${m?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[m?e.jsx(qi,{size:14}):e.jsx(lo,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),m&&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":o("rightSidebar.layoutMode"),children:[e.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:o("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",o("rightSidebar.layoutModeAuto")],["narrow",o("rightSidebar.layoutModeNarrow")],["wide",o("rightSidebar.layoutModeWide")]].map(([t,i])=>{const u=W===t;return e.jsx("button",{type:"button",role:"menuitemradio","aria-checked":u,onClick:()=>{J(t),zt(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${u?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:i},t)})})]})]})]}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":o("rightSidebar.close"),children:e.jsx(Lt,{size:14})})]}),Z&&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(ms,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:I,onChange:t=>Y(t.target.value),placeholder:o(oe==="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 ${se?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>Cd("name"),"aria-pressed":oe==="name",className:`rounded-full px-2 transition active:scale-95 ${se?"py-1":"py-0.5"} ${oe==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>Cd("content"),"aria-pressed":oe==="content",className:`rounded-full px-2 transition active:scale-95 ${se?"py-1":"py-0.5"} ${oe==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeContent")})]}),I&&e.jsx("button",{type:"button",onClick:()=>Y(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:e.jsx(Lt,{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(Dp,{size:12,className:"shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:o("rightSidebar.searchScope")}),e.jsx("input",{"data-search-scope":!0,value:Se,onChange:t=>we(t.target.value),onKeyDown:t=>{t.key==="Enter"&&document.querySelector("[data-right-search]")?.focus()},className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:o("rightSidebar.searchScopePlaceholder"),"aria-label":o("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),Se!=="."&&e.jsx("button",{type:"button",onClick:()=>we("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.resetSearchScope"),children:e.jsx(Lt,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>ue(t=>!t),"aria-expanded":be,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${be||As.length>0||Be||G||ye?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:o("rightSidebar.searchOptions"),"aria-label":o("rightSidebar.searchOptions"),children:[e.jsx(Fp,{size:13}),As.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:As.length})]})]}),be&&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:o("rightSidebar.searchExclude")}),e.jsx("input",{"data-search-exclude":!0,value:Me,onChange:t=>Q(t.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:o("rightSidebar.searchExcludePlaceholder"),"aria-label":o("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),Me&&e.jsx("button",{type:"button",onClick:()=>Q(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.clearSearchExclude"),children:e.jsx(Lt,{size:11})})]}),oe==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":o("rightSidebar.contentSearchOptions"),children:[[Be,()=>Oe(t=>!t),qp,o("rightSidebar.matchCase")],[G,()=>je(t=>!t),ig,o("rightSidebar.matchWholeWord")],[ye,()=>Ue(t=>!t),ng,o("rightSidebar.useRegex")]].map(([t,i,u,w])=>e.jsxs("button",{type:"button",onClick:i,"aria-pressed":t,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${t?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsx(u,{size:12}),w]},w))})]})]}),e.jsxs("div",{className:"mt-2 grid gap-0.5 rounded-md bg-surface-2 p-0.5",style:{gridTemplateColumns:`repeat(${(ts?1:3)+Number(sr.architecture)+Number(sr.computer)+Number(qr)}, minmax(0, 1fr))`},children:[!ts&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:t=>ss("git",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(kr,{size:12}),o("rightSidebar.tabGit")]}),e.jsxs("button",{type:"button",onClick:t=>ss("diff",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(pf,{size:12}),o("rightSidebar.tabChanges"),Fe.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:Fe.size}):null]})]}),e.jsxs("button",{type:"button",onClick:t=>ss("files",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(hl,{size:12}),o("rightSidebar.tabFiles")]}),sr.architecture&&e.jsxs("button",{type:"button",onClick:t=>ss("architecture",t),className:`flex items-center justify-center gap-1 rounded px-1 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Nn?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(su,{size:12}),o("architecture.tab")]}),sr.computer&&e.jsxs("button",{type:"button",onClick:t=>ss("computer",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${ns?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Jd,{size:12}),o("rightSidebar.tabComputer")]}),qr&&e.jsxs("button",{type:"button",onClick:t=>ss("android",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Qd,{size:12}),o("rightSidebar.tabAndroid")]})]}),e.jsx("div",{className:"h-2"}),nc&&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:nc})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(ds,{active:dt,mounted:nr,fallback:e.jsx(ol,{slow:!1}),children:()=>ze?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(mu,{items:vm,diffViewType:ri,inlineMode:ur,viewControls:m?Hs():void 0,renderPathReference:(t,i)=>Ja(Tn(t,ze.repoRoot??v),o(i==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle")),selectedKey:Rh,onSelect:xa,emptyText:o("rightSidebar.noChanges"),mobile:se,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o("rightSidebar.recentCommitsTitle"),headerMeta:`${ze.headRef??""}${ze.commits?.[0]?` · ${ze.commits[0]}`:""}`,onClose:()=>{Ge(null),xa(null)},closeLabel:o("common.back"),wrap:Tt,onToggleWrap:ro,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:se?"stacked":"split",onInsertDiffReference:Fr,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onClearAuditRecord:Za})}):hr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(mu,{items:Ai,diffViewType:ri,inlineMode:ur,viewControls:m?Hs():void 0,renderPathReference:(t,i)=>{const u=ve?.comparisonRepos,w=u&&u.length>1?[...u].sort((k,C)=>C.label.length-k.label.length).find(k=>t===k.label||t.startsWith(`${k.label}/`)):void 0,y=w?t===w.label?w.repoRoot:Tn(t.slice(w.label.length+1),w.repoRoot):Tn(t,Gs?.repoRoot||v);return Ja(y,o(i==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle"))},selectedKey:Vo,onSelect:gn,emptyText:o(ve?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:se,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o(ve?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:Gs?`${Gs.repoLabel} · ${Gs.branchName??"HEAD"} → ${Gs.baseRef}`:void 0,onClose:()=>{++It.current,ke(!1),mr(!1),er(null)},closeLabel:o("common.back"),wrap:Tt,onToggleWrap:ro,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:se?"stacked":"split",onInsertDiffReference:Fr,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onClearAuditRecord:Za,localOptions:ve?.comparisonRepos?.map(t=>({key:t.repoRoot,label:t.label,checked:t.includeUncommitted??ve.includeUncommitted??!1,disabled:!(t.canIncludeUncommitted??os(t.repoRoot,t.head)),onChange:i=>{Di({refresh:!0,repoRoot:t.repoRoot,includeUncommitted:i})}})),onHunkGitAction:ve?.includeUncommitted?Mm:void 0,error:nt,actionsBusy:T>0,onRefresh:()=>{Di({refresh:!0})},refreshing:ge,refreshLabel:o("rightSidebar.branchAuditRefreshDiff"),refreshTitle:o("rightSidebar.branchAuditRefreshDiff"),walkthroughs:ym,onWalkthroughNavigate:wm,initialDetailScrollTop:ve&&Qe?Ss[Qe]:void 0,onDetailScrollPositionChange:Cm,externalSwiperRef:se?Mc:void 0,onMobileSlideChange:se?Xo:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:nr&&v&&Pn?e.jsx("div",{className:"px-3",children:Fm()}):br?e.jsx(ol,{slow:vc}):kn?e.jsx(xo,{message:kn,onRetry:()=>{es()}}):Gu(M)?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):M?.available===!1?e.jsx(xo,{message:M.error??o("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{es()}}):v?e.jsx(ol,{slow:vc}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),e.jsx(ds,{active:Dr,mounted:Ch||Dr,children:()=>se?e.jsxs(sf,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:t=>{Ir.current=t,t.slideTo(Yo,0)},onSlideChange:t=>{if(Lr(t.activeIndex),Ts.current===t.activeIndex){Ts.current=null;return}t.activeIndex===0&&(Ar(!1),Ct(null),h?.())},children:[e.jsx(ml,{className:"h-full min-h-0",children:e.jsxs("div",{ref:Yn,onScroll:Ic,onDragOver:Ba,onDragEnter:Ba,onDragLeave:Fc,onDrop:_c,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[ic&&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:o("rightSidebar.dropToUpload")})}),!I.trim()&&Id,e.jsx(au,{rootPath:ie??"",onFileSelect:Is,onPathReference:Ot,getReferenceText:Ua,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onDirectoryRoot:Kc,onSearchFromDirectory:qc,onDirectoryPinToggle:Vc,onFilePinToggle:Yc,pinnedPaths:En,selectedFilePath:at,query:Ye,searchRootPath:Rc,searchOptions:Nc,searchMode:oe,onContentMatchSelect:wi,onDirectoryDropFiles:(t,i)=>Ds(i,t),revealDirectory:O,canOpenInFileBrowser:lc,onOpenInFileBrowser:Dc})]})}),e.jsx(ml,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(Fo,{filePath:Nh||Yo===1?at:null,active:r&&Dr&&Yo===1,onInsertReference:Ot,onInsertText:or,onInsertFeature:or,onReviewReference:Hc,onReferenceCopied:yr,onClose:Bm,onDirectoryLinkOpen:Td,isMobile:!0,lineRange:en,onLineRangeChange:Ct,insertedReferenceKey:De,copiedReferenceKey:Re,scrollToLine:Or,onScrollToLineHandled:()=>tn(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:N,markdownImageLightboxOpen:A,markdownImageLightboxCloseSignal:B,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:Yn,onScroll:Ic,onDragOver:Ba,onDragEnter:Ba,onDragLeave:Fc,onDrop:_c,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:ni},children:[ic&&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:o("rightSidebar.dropToUpload")})}),!I.trim()&&Id,e.jsx(au,{rootPath:ie??"",onFileSelect:Is,onPathReference:Ot,getReferenceText:Ua,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onDirectoryRoot:Kc,onSearchFromDirectory:qc,onDirectoryPinToggle:Vc,onFilePinToggle:Yc,pinnedPaths:En,selectedFilePath:at,query:Ye,searchRootPath:Rc,searchOptions:Nc,searchMode:oe,onContentMatchSelect:wi,onDirectoryDropFiles:(t,i)=>Ds(i,t),revealDirectory:O,canOpenInFileBrowser:lc,onOpenInFileBrowser:Dc})]}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":o("rightSidebar.resizeFileTree"),title:o("rightSidebar.resizeFileTree"),"data-local-layer":"file-preview-separator",className:"group relative z-10 w-2 shrink-0 cursor-col-resize touch-none border-l border-border/15 bg-surface",onPointerDown:Oh,onPointerMove:Uh,onPointerUp:Lc,onPointerCancel:Lc,onDoubleClick:()=>{si(jl),At(ra,jl)},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(Fo,{filePath:at,active:r&&Dr,onInsertReference:Ot,onInsertText:or,onInsertFeature:or,onReviewReference:Hc,onReferenceCopied:yr,onDirectoryLinkOpen:Td,isMobile:!1,lineRange:en,onLineRangeChange:Ct,insertedReferenceKey:De,copiedReferenceKey:Re,scrollToLine:Or,onScrollToLineHandled:()=>tn(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:N,markdownImageLightboxOpen:A,markdownImageLightboxCloseSignal:B,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j})})]})}),e.jsx(ds,{active:$t,mounted:Mh||$t,children:()=>vi?e.jsx(_p,{}):se?e.jsx(pl,{mobile:!0,backLabel:o("rightSidebar.backToChangeList"),externalSwiperRef:bi,onMobileSlideChange:Xo,groups:Xt.length>0?md():[],mode:zr,onModeChange:to,selectedKey:at,scrollToKey:vd,scrollToKeyNonce:Ma.nonce,compact:!1,collapsedDirectoryKeys:Ur,onToggleDirectory:kd,onSelectFile:t=>{const i=Ln.get(t.key);i&&eo(Sr(i))},renderLeading:pd,renderTrailing:t=>{const i=Ln.get(t.key);return i?fd(i):null},renderDirectoryTrailing:hd,renderSubtitle:t=>{const i=Ln.get(t.key);return i?ud(i):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:t=>v&&e.jsxs("div",{className:"px-0 py-0",children:[io&&e.jsx("div",{className:"mb-2",children:io}),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:o("rightSidebar.allChanges")})}),e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[Xt.length,"/",Fe.size]})]}),e.jsxs(uu,{actions:_d,children:[cd(),t,m&&Hs(),Fd]},v),ir&&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:ir.label}),ir.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:ir.branch})]}),!ir&&An&&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(kr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:Va?(t=>wd(t)):void 0,emptyContent:vi?null:kn&&Fe.size===0?e.jsx(xo,{message:kn,onRetry:()=>{es()}}):Fe.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Xt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:({slideToList:t})=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:t,className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:o("rightSidebar.backToChangeList"),children:[e.jsx(la,{size:14}),o("rightSidebar.backToChangeList")]}),e.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-1.5",children:[m&&Hs(),e.jsxs("button",{type:"button",onClick:ro,"aria-pressed":Tt,title:o("rightSidebar.wrapLongLines"),className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${Tt?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:o(Tt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),v&&e.jsx("button",{type:"button",onClick:()=>{es()},disabled:br,"aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",children:e.jsx(wo,{size:14,className:br?"animate-spin":""})})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:gd,activePane:$t,wrap:Tt,diffViewType:ri,inlineMode:ur,diffOptions:Nd,reloadKey:xs,renderStreamBadge:t=>e.jsx(aa,{status:t}),onHunkGitAction:Ed,onInsertDiffReference:Fr,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onClearAuditRecord:Za,onDetailScroll:Qa}):e.jsx(pl,{mobile:!1,desktopLayout:"split",desktopSidePanel:null,desktopListClassName:"w-[320px] min-w-[260px] shrink-0 overflow-y-auto overscroll-contain border-r border-border/15 bg-surface",backLabel:o("rightSidebar.backToChangeList"),groups:Xt.length>0?md():[],mode:zr,onModeChange:to,selectedKey:at,scrollToKey:vd,scrollToKeyNonce:Ma.nonce,compact:!0,collapsedDirectoryKeys:Ur,onToggleDirectory:kd,onSelectFile:t=>{const i=Ln.get(t.key);i&&eo(Sr(i))},renderLeading:pd,renderTrailing:t=>{const i=Ln.get(t.key);return i?fd(i):null},renderDirectoryTrailing:hd,renderSubtitle:t=>{const i=Ln.get(t.key);return i?ud(i):null},aiContent:Va?(t=>wd(t)):void 0,emptyContent:vi?null:kn&&Fe.size===0?e.jsx(xo,{message:kn,onRetry:()=>{es()}}):Fe.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Xt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderListHeader:t=>v&&e.jsxs("div",{className:"px-0 py-0",children:[io&&e.jsx("div",{className:"mb-2",children:io}),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:o("rightSidebar.allChanges")}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[Xt.length,"/",Fe.size]})})]}),e.jsxs(uu,{actions:_d,children:[cd(),t,Hs(),e.jsxs("button",{type:"button",onClick:ro,"aria-pressed":Tt,title:o("rightSidebar.wrapLongLines"),className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Tt?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:o(Tt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),Fd]},v),ir&&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:ir.label}),ir.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:ir.branch})]}),!ir&&An&&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(kr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),files:gd,activePane:$t,wrap:Tt,diffViewType:Mr,inlineMode:ur,diffOptions:Nd,reloadKey:xs,renderStreamBadge:t=>e.jsx(aa,{status:t}),onHunkGitAction:Ed,onInsertDiffReference:Fr,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onClearAuditRecord:Za,onDetailScroll:Qa})}),e.jsx(ds,{active:Nn,mounted:sr.architecture&&(Wh||r&&Nn),children:e.jsx(a.Suspense,{fallback:e.jsx("p",{role:"status",className:"p-4 text-sm text-muted-foreground",children:o("architecture.loading")}),children:e.jsx(ex,{rootPath:v,active:r&&Nn,onInsertPrompt:(t,i)=>or(t,`architecture:${v}`,i),renderSource:t=>v&&e.jsx(x0,{rootPath:v,file:t,active:r&&Nn,isMobile:se,onInsertReference:Ot,onInsertText:or,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re},`${t.path}:${t.line??1}`),onOpenFile:t=>{v&&(Dt("files"),Ft(null),wi(`${v.replace(/\/+$/,"")}/${t.path}`,t.line??1))}},v)})}),e.jsx(ds,{active:r&&ns,mounted:sr.computer&&(Hh||r&&ns),children:e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:o("computer.loading")}),children:e.jsx(tx,{active:r&&ns})})}),e.jsx(ds,{active:rs,mounted:Zo&&qr,children:$h?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[e.jsx("span",{children:o("android.splitDockedHint")}),e.jsx("button",{type:"button",onClick:()=>{Wi.getState().setDock(Ki,null),ta({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:o("android.splitClose")})]}):e.jsx(Bp,{sessionId:n??null,onCloseTab:()=>Tc(!1),onInsertPrompt:t=>Fr("android-deps",t),onInsertFile:Jh,onRecordingComplete:Xh})})]}),r&&Bt.task&&e.jsx(Xg,{task:Bt.task,onCancel:Bt.cancel,onRetry:()=>{Bt.retry()},onDismiss:Bt.dismiss,labels:{uploading:o("rightSidebar.uploadPending"),inserting:o("rightSidebar.uploadInserting"),done:o(Bt.task.kind==="image"?"rightSidebar.uploadReferenceDone":"rightSidebar.uploadDone",{count:Bt.task.uploaded.length}),failed:o("rightSidebar.uploadFailed"),canceled:o("rightSidebar.uploadCanceled"),referenceRejected:o("rightSidebar.uploadReferenceRejected"),limit:o("rightSidebar.uploadLimit"),cancel:o("common.cancel"),retry:o("common.retry"),dismiss:o("common.close"),files:o("rightSidebar.uploadFileCount",{count:Bt.task.files.length})}}),r&&We&&e.jsx(Gg,{value:ct,collapsed:H,autoCollapseAfterSend:Ce,focusRequest:Zr,insertError:gs?o("rightSidebar.contextDraftInsertFailed"):null,onChange:t=>{cr(!1),Nt(t)},onCollapsedChange:ne,onAutoCollapseAfterSendChange:lt,onDisable:()=>Br(!1),onClear:()=>Nt(""),onInsert:()=>zc(!1),onInsertAndSend:()=>zc(!0),labels:{title:o("rightSidebar.contextDraftTitle"),hint:o("rightSidebar.contextDraftHint"),placeholder:o("rightSidebar.contextDraftPlaceholder"),collapse:o("rightSidebar.contextDraftCollapse"),expand:o("rightSidebar.contextDraftExpand"),disable:o("rightSidebar.contextDraftDisable"),clear:o("rightSidebar.contextDraftClear"),insert:o("rightSidebar.contextDraftInsert"),insertAndSend:o("rightSidebar.contextDraftInsertAndSend"),inserted:o("rightSidebar.contextDraftInserted"),sent:o("rightSidebar.contextDraftSent"),pending:o("rightSidebar.contextDraftPending"),send:o("rightSidebar.contextDraftSend"),appended:o("rightSidebar.contextDraftAppended"),resize:o("rightSidebar.contextDraftResize"),autoCollapseAfterSend:o("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:t=>o("rightSidebar.contextDraftCharacterCount",{count:t})}}),dm(),yt&&typeof document<"u"&&Rr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>bn(null),children:e.jsxs("div",{className:"fixed inset-x-3 bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto max-w-md rounded-2xl border border-border/20 bg-surface-elevated p-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:yt.kind==="restore"?o("rightSidebar.confirmRestoreTitle"):o("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:yt.kind==="restore"?o("rightSidebar.confirmRestoreDescription",{path:tf(yt.file.absolutePath,v)}):o("rightSidebar.confirmStashAllDescription")}),yt.kind==="restore"&&e.jsx("input",{value:yt.phrase,onChange:t=>bn({...yt,phrase:t.target.value}),placeholder:o("rightSidebar.confirmRestorePlaceholder"),className:"mt-3 w-full rounded-xl border border-border/20 bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground",autoFocus:!0}),e.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>bn(null),className:"rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:o("common.cancel")}),e.jsx("button",{type:"button",disabled:!!qe||yt.kind==="restore"&&yt.phrase.trim()!==o("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(yt.kind==="restore"){const t=xt(yt.file,v);if(!t)return;wt({action:"restore-worktree-file",cwd:t,paths:[yt.file.path],confirm:{acknowledged:!0,phrase:yt.phrase}},o("rightSidebar.restoreFile"),cl(yt.file))}else{const t=yt.repoRoot??v;if(!t)return;wt({action:"stash-all",cwd:t},o("rightSidebar.stashAll"),`repo:${t}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${yt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:o(qe?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const P0=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:Fo,MarkdownImageLightbox:hh,MarkdownPreview:mh,RightSidebar:v0,__testParseMarkdownListBlock:Dx,buildMarkdownPreviewBlocks:Kx,buildMarkdownPreviewRenderResult:Gl,collectKnownGitRepoRoots:_f,computeMarkdownImageDisplayBox:Xf,getMarkdownHeadingOutline:fh,getMarkdownHeadingPathAtLine:uh,getNextMarkdownPreviewLineRange:Qx,isSvgImageSrc:ma,mountRightSidebarRepoPickerOverlay:Rf,replaceGitRepositorySnapshot:yh,resolveMarkdownLocalLinkTarget:Bl,resolveRightSidebarDiffViewType:Df,shouldCloseMarkdownImageLightboxDrag:lh,showsGitRepoGroupHeader:Rl},Symbol.toStringTag,{value:"Module"}));export{xl as E,P0 as R,ag as S,Yp as a,Kx as b,Sg as c,yg as i,vg as l,$0 as m};
1677
+ `),truncated:C.some(ee=>ee.truncated)};if(ae.comparisonRepos=u.map((ee,X)=>({...ee,head:ee.head??C[X].currentBranch??null,includeUncommitted:C[X].includeUncommitted===!0,canIncludeUncommitted:C[X].canIncludeUncommitted})),ae.canIncludeUncommitted=C.every(ee=>ee.canIncludeUncommitted===!0),ae.includeUncommitted=C.some(ee=>ee.includeUncommitted===!0),qo(ee=>({...ee,...Object.fromEntries(ae.comparisonRepos.map(X=>[X.repoRoot,X.includeUncommitted??!1]))})),!i&&(ae.hunks??[]).length===0){_e(o("rightSidebar.branchAuditDiffEmpty"));return}const xe=Date.now(),Ae=(i?Qe:null)??["preview",ae.repoRoot??v,ae.baseRef??ae.baseBranch??"",ae.currentBranch??"",ae.headRef??"",ae.diffFingerprint??xe].join("\0"),Ze=u.length===1?u[0].label:`${u.length} repos`;er(ae),Bn(ee=>[{key:Ae,diff:ae,repoLabel:Ze,createdAt:xe},...ee.filter(X=>X.key!==Ae)].slice(0,8)),i||dn(ee=>ee[Ae]===void 0?ee:{...ee,[Ae]:0}),pn(Ae),gn(ee=>{const X=ae.hunks?.[0],me=X?`${X.filePath}\0${X.hunkHeader}\0${X.hunkIndex}`:null;return i&&ee&&(ae.hunks??[]).some(Le=>Le.filePath===ee.split("\0")[0])?ee:me}),mr(!0)}catch(C){if(!k()||jr(C))return;_e(C instanceof Error?C.message:"Failed to load branch diff")}finally{k()&&ke(!1)}},[mn,ve,Qe,Us,Et,rr,Pe,v,o]),Sm=a.useCallback(t=>{++It.current,ke(!1),er(t.diff),_e(null),pn(t.key),gn(t.diff.hunks?.[0]?`${t.diff.hunks[0].filePath}\0${t.diff.hunks[0].hunkHeader}\0${t.diff.hunks[0].hunkIndex}`:null),mr(!0)},[]),jm=a.useCallback(t=>{Bn(i=>i.filter(u=>u.key!==t)),dn(i=>{if(!(t in i))return i;const u={...i};return delete u[t],u}),Qe===t&&(pn(null),er(null),mr(!1))},[Qe]),Rm=a.useCallback(t=>{++It.current,ke(!1);const i=is.find(u=>u.key===t);i&&(er(null),_e(null),pn(t),gn(i.records[0]?.filePath??null),mr(!0))},[is]),Nm=a.useCallback(async t=>{if(!v||!Ne)return;const[i]=t.split(/\s+/);if(i){vt(i),tr(null),Ge(null);try{const u=await hp({cwd:v,repoRoot:Ne,commit:i,requestSlotId:"right-sidebar-commit-diff"});if(!u.available){tr(u.error??"Commit diff is unavailable");return}Ge(u);const w=u.hunks?.[0];xa(w?`${w.filePath}\0${w.hunkHeader}\0${w.hunkIndex}`:null)}catch(u){tr(u instanceof Error?u.message:"Failed to load commit diff")}finally{vt(null)}}},[Ne,v]),Cm=a.useCallback(t=>{if(!ve||!Qe)return;const i=Math.max(0,Math.round(t));dn(u=>Math.abs((u[Qe]??0)-i)<24?u:{...u,[Qe]:i})},[ve,Qe]);a.useEffect(()=>{!ve||!Qe||Bn(t=>t.map(i=>i.key===Qe&&i.diff!==ve?{...i,diff:ve}:i))},[ve,Qe]);const bd=!!ve;a.useEffect(()=>{if(!se||!hr||!bd)return;const t=Mc.current;if(!t||t.destroyed)return;t.update(),t.slideTo(1,0);const i=window.requestAnimationFrame(()=>{t.destroyed||(t.update(),t.slideTo(1,0))});return()=>window.cancelAnimationFrame(i)},[hr,bd,se]);const xd=a.useCallback(t=>{t&&Th(i=>zp(i,t))},[]),vd=Ma.key===at?Ma.key:null,eo=a.useCallback(t=>{const i=V.getState(),u=p0();ea("select_diff_file",{interactionId:u,path:t,previousSelectedFilePath:i.selectedFilePath,rootPath:i.rootPath,activeGitRepoRoot:ce,changedFiles:i.changedFiles.size,gitBundleLoading:i.gitBundleLoading,gitBundleLastLoadedAt:i.gitBundleLastLoadedAt,rightTab:i.rightTab}),ot(t),Dt("diff"),se&&t&&Ac(1),xd(t),queueMicrotask(()=>{const w=V.getState();ea("select_diff_file_after",{interactionId:u,requestedPath:t,selectedFilePath:w.selectedFilePath,rootPath:w.rootPath,rightTab:w.rightTab,changedFiles:w.changedFiles.size,activeGitRepoRoot:ce})})},[ce,se,xd,ot,Dt,Ac]),yd=a.useCallback(t=>{const i=Array.from(Fe.values()).find(u=>{const w=xt(u,v),y=Sr(u);return u.path===t.filePath||y===t.filePath||u.absolutePath===t.filePath||(w?`${w}/${u.path}`===t.filePath:!1)||t.repoRoot&&w===t.repoRoot&&u.path===t.filePath});if(i){eo(Sr(i)),window.setTimeout(()=>In(t),90),window.setTimeout(()=>In(t),320),window.setTimeout(()=>In(t),760);return}In(t)},[Fe,v,eo]),wd=a.useCallback(({slideToDetail:t,fullscreen:i,toggleFullscreen:u}={})=>vs.length>0?e.jsx(lf,{walkthroughs:vs,repoRoot:ce,fullscreen:i,onToggleFullscreen:u,onNavigate:w=>{se&&window.requestAnimationFrame(()=>t?.()),yd(w)}}):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(da,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),o("rightSidebar.changeWalkthroughEmpty")]}),[ce,vs,yd,se,o]),Em=a.useCallback(t=>{t&&dr(i=>{const u=new Set(i);return u.has(t)?u.delete(t):u.add(t),rl(Qi,u),u})},[]),kd=a.useCallback(t=>{Hr(i=>{const u=new Set(i);return u.has(t)?u.delete(t):u.add(t),rl(Su,u),u})},[]),to=a.useCallback(t=>{Er(t),At(Cf,t)},[]);a.useEffect(()=>{Va||zr!=="ai"||to("tree")},[zr,to,Va]);const ro=a.useCallback(()=>{ga(t=>{const i=!t;return At(Ef,i),i})},[]),Sd=a.useCallback(t=>{bs(t),At(Mf,t)},[]),{whitespace:jd,context:Rd}=Gp(),Nd=a.useMemo(()=>({algorithm:"histogram",whitespace:jd,context:Rd}),[jd,Rd]),Cd=a.useCallback(t=>{pe(t),At($f,t)},[]),no=a.useCallback(async(t,i,u,w)=>{let y=t;for(;y.ok&&y.status==="running";)await new Promise(C=>window.setTimeout(C,1500)),y=await Yd({jobId:y.jobId,cwd:i.cwd,action:i.action});if(!y.ok)throw new Error("Git action status is unavailable");if(y.status==="error")throw new Error(y.error||y.message||"Git action failed");const k={action:i.action,path:w,label:u};return $s(k),window.setTimeout(()=>$s(C=>C?.action===k.action&&C.path===k.path?null:C),1400),y},[]),wt=a.useCallback(async(t,i,u)=>{const w=v;v&&xr.current.delete(v),Gt(null),$s(null),Ms({action:t.action,path:u});try{const y=await mp({...t,includeNested:Xs(v)}),k=await no(y,t,i,u);if(!Pe(w))return!1;const C=v?await Gi(v,void 0,{includeNested:Xs(v),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Qs(v)}).catch(()=>k.bundle):k.bundle;return Pe(w)?(C&&Zn(C,{reloadDiff:!0,cacheOnly:!0}),bn(null),!0):!1}catch(y){return $s(null),Gt(o("rightSidebar.gitActionFailed",{message:y instanceof Error?y.message:"Unknown error"})),!1}finally{Pe(w)&&Ms(null)}},[Zn,Pe,v,o,no]),Ed=a.useCallback(async t=>{const i=v;await Xd({...t,includeNested:Xs(v)}),Pe(i)&&_t(v??void 0,{refresh:!0,background:!0})},[Pe,_t,v]),Mm=a.useCallback(async t=>{const i=ve,u=It.current,w=i?.hunks?.find(k=>k.previewRevert?.cwd===t.cwd&&k.previewRevert.path===t.path);if(!i||!w||!t.comparisonBase)throw new Error(o("diffViewer.hunkActionUnavailable"));K(k=>k+1),_e(null);try{await Xd(t)}catch(k){throw K(C=>C-1),k}if(u!==It.current||!Pe(v)){K(k=>k-1);return}const y=k=>{er(C=>{if(!C||u!==It.current)return C;const ie=C.hunks??[],ae=k===void 0?ie.filter(Ae=>!(Ae.previewRevert?.cwd===t.cwd&&Ae.previewRevert.patch===t.patch)):[...ie.filter(Ae=>Ae.filePath!==w.filePath),...k];return{...C,hunks:ae}})};y(),Vd({cwd:t.cwd,repoRoot:t.cwd,base:t.comparisonBase,comparisonBase:t.comparisonBase,filePath:t.path,requestSlotId:`branch-preview-file:${t.cwd}:${t.path}`}).then(k=>{if(u!==It.current||!Pe(v))return;if(!k.available||k.truncated)throw new Error(k.error??o("diffViewer.hunkActionUnavailable"));const C=t.path.slice(t.cwd.length+1),ie=w.filePath.slice(0,w.filePath.length-C.length);y((k.hunks??[]).map(ae=>({...ae,filePath:`${ie}${ae.filePath}`,oldPath:ae.oldPath?`${ie}${ae.oldPath}`:ae.oldPath,newPath:ae.newPath?`${ie}${ae.newPath}`:ae.newPath})))}).catch(k=>{u===It.current&&Pe(v)&&!jr(k)&&_e(`${o("diffViewer.hunkActionReverted")} · ${k instanceof Error?k.message:String(k)}`)}).finally(()=>K(k=>k-1))},[ve,Pe,v,o]),so=a.useCallback((t,i,u)=>{if(i){if(t==="stage-all"){wt({action:"stage-all",cwd:i},o("rightSidebar.stageAll"),`repo:${i}`);return}bn({kind:"stash-all",repoRoot:i,repoLabel:u})}},[wt,o]),Md=a.useCallback(t=>{Te(t),Na(""),Ca(""),Ea(""),ot(td(t)),dt||Dt("diff"),t&&Ka(it.get(t))},[Ka,td,dt,it,ot,Te,Dt]),$d=a.useCallback(t=>{const i=new Set([...qt.current.keys(),...Sn.current,...xr.current]);for(const u of i)u!==t&&(Kt.current.delete(u),qt.current.get(u)?.abort(),qt.current.delete(u),Rt(`right-sidebar-git-untracked:${u}`),Sn.current.delete(u),xr.current.delete(u))},[]),$m=a.useCallback(async t=>{const i=v;if(!i||(await V.getState().setNestedGitScanRoot(i,t),!Pe(i)))return;if(t){await _t(i,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}$d(i),Na(""),Ca(""),Ea(""),Ko(w=>w.filter(y=>y===i));const u=Vt;u&&xt(u,i)!==i&&ot(null),await _t(i,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[$d,Pe,_t,v,ot,Vt]),Pm=a.useCallback(async()=>{if(!Ne||et){Gt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=Wn.trim();!t||t===de?.branch||await wt({action:"switch-branch",cwd:Ne,branch:t},o("rightSidebar.switchBranch"))},[de?.branch,Ne,et,wt,Wn,o]),Pd=a.useCallback(async()=>{if(!Ne||et){Gt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=Ra.trim();if(!t)return;await wt({action:"commit",cwd:Ne,message:t},o("rightSidebar.commitChanges"))&&ac("")},[Ne,Ra,et,wt,o]),Am=a.useCallback(async()=>{if(!Ne||et){Gt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=vn.trim(),i=yn.trim();await wt({action:"push",cwd:Ne,...t?{remote:t}:{},...i?{branch:i}:{}},o("rightSidebar.pushChanges"))},[Ne,yn,vn,et,wt,o]),Lm=a.useCallback(async()=>{if(!Ne||et){Gt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=vn.trim(),i=yn.trim();await wt({action:"pull",cwd:Ne,...t?{remote:t}:{},...i?{branch:i}:{}},o("rightSidebar.pullChanges"))},[Ne,yn,vn,et,wt,o]);a.useEffect(()=>{if(!dt||!Ne||qe)return;let t=!1;const i={push:o("rightSidebar.pushChanges"),pull:o("rightSidebar.pullChanges"),commit:o("rightSidebar.commitChanges"),"switch-branch":o("rightSidebar.switchBranch"),"stage-all":o("rightSidebar.stageAll"),"stash-all":o("rightSidebar.stashAll")};return(async()=>{for(const u of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(t)return;const w=await Yd({cwd:Ne,action:u}).catch(()=>null);if(!w?.ok||w.status!=="running")continue;const y={action:u,cwd:Ne},k=i[u]??u;Ms({action:u});try{const C=await no(w,y,k);if(t||!Pe(v))return;const ie=v?await Gi(v,void 0,{includeNested:Xs(v),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Qs(v)}).catch(()=>C.bundle):C.bundle;ie&&Zn(ie,{reloadDiff:!0,cacheOnly:!0})}catch(C){t||Gt(o("rightSidebar.gitActionFailed",{message:C instanceof Error?C.message:"Unknown error"}))}finally{t||Ms(null)}return}})(),()=>{t=!0}},[Ne,Zn,dt,Pe,v,qe,o,no]);const Fi=Hn?.action==="commit",_i=Hn?.action==="switch-branch",Bi=Hn?.action==="pull",Oi=Hn?.action==="push",ao=dt||Ah,Ui=Xa?o("rightSidebar.changeAuditScopeAll"):wr.length===1?wr[0].label:`${wr.length} repos`,Tm=wr.length>0,Ad=Us.length>0,Im=v?e.jsx(Ou,{open:Wo,onOpenChange:Go,showScopePicker:!0,selectedAll:Xa,repos:Yt,selectedRoots:Ya,onToggleRepo:xm,onGenerate:()=>km(Li?"regenerate":"generate"),disabled:!Tm,generateDisabled:!Ad,inserted:De?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:o(Li?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.branchAuditGenerateTitle"),ariaLabel:o("rightSidebar.branchAuditShort"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Ui,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o(Li?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{Di()},secondaryDisabled:!Ad||ge,secondaryLabel:o("rightSidebar.branchAuditViewDiff"),secondaryTitle:o("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:ge,loading:Jl.size>0,statusTitle:Jl.size>0?o("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsx("div",{className:"mb-2 space-y-1.5",children:od.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:o("rightSidebar.missingBaseReposSkipped",{repositories:od.map(t=>t.label).join(_==="zh"?"、":", ")})})}),renderRepoExtra:t=>{const i=it.get(t.root),u=os(t.root,rr[t.root]||i?.context?.branch),w=[],y=new Set,k=(xe,Ae)=>{!xe||y.has(xe)||(y.add(xe),w.push({value:xe,label:xe,meta:Ae}))};k(rr[t.root]||i?.context?.branch,o("rightSidebar.pushCurrentBranchBadge"));for(const xe of i?.context?.branches??[])k(xe,xe===i?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):o("rightSidebar.localBranch"));for(const xe of i?.context?.remoteBranches??[])k(xe,o("rightSidebar.remoteBranch"));const C=[],ie=new Set,ae=(xe,Ae)=>{!xe||ie.has(xe)||(ie.add(xe),C.push({value:xe,label:xe,meta:Ae}))};ae(Et[t.root],Et[t.root]?o("rightSidebar.pushUpstreamBadge"):void 0),ae(i?.context?.upstream,i?.context?.upstream?o("rightSidebar.pushUpstreamBadge"):void 0);for(const xe of i?.context?.remoteBranches??[])ae(xe,"remote");for(const xe of i?.context?.branches??[])ae(xe,xe===i?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");return e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsx(fs,{label:o("rightSidebar.currentBranchLabel"),value:rr[t.root]||i?.context?.branch||"",options:w,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),onChange:xe=>{ya(Ae=>({...Ae,[t.root]:xe}))}}),e.jsx(fs,{label:o("rightSidebar.branchAuditBaseLabel"),value:Et[t.root]||"",options:C,placeholder:o("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:o("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:o("rightSidebar.branchAuditBaseEmpty"),onChange:xe=>{wa(Ae=>({...Ae,[t.root]:xe}))}}),e.jsxs("label",{className:"sm:col-span-2 flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium",children:o("rightSidebar.includeUncommitted")}),e.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:o(u?"rightSidebar.includeUncommittedHint":"rightSidebar.includeUncommittedCurrentBranchOnly")})]}),e.jsx("input",{type:"checkbox",checked:u&&(mn[t.root]??!0),disabled:!u,onChange:xe=>qo(Ae=>({...Ae,[t.root]:xe.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,Ld=Zs(St.reduce((t,i)=>Math.max(t,i.injectedAt??0),0),_),Dm=()=>v?e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>Xl(t=>{const i=!t;return At(Zi,i),i}),className:"group flex w-full items-center gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":Cs,children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:e.jsx(da,{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:o("rightSidebar.branchAuditTitle")}),e.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:Ui})]}),e.jsx("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${Cs?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]}),Cs&&e.jsxs("div",{className:"mt-2 rounded-lg border border-border/10 bg-surface/60 p-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 text-[11px] text-muted-foreground",children:[o("rightSidebar.changeAuditScopeLabel"),": ",Ui]}),Im]}),nt&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:nt}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[cn.map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Qe===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Sm(t),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.diff.hunks?.length??0," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.currentBranch??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diff.baseRef??t.diff.baseBranch}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:o("rightSidebar.branchAuditViewDiff")})]}),Zs(t.createdAt,_)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:Zs(t.createdAt,_)})]}),e.jsx("button",{type:"button",onClick:()=>jm(t.key),className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:o("common.delete"),"aria-label":o("common.delete"),children:e.jsx(yo,{size:12})})]},t.key)),is.length>0?is.slice(0,Math.max(0,8-cn.length)).map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Qe===t.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsxs("button",{type:"button",onClick:()=>Rm(t.key),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:t.repoLabel}),e.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[t.records.length," hunk"]})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.branchName??"HEAD"}),e.jsx("span",{className:"text-muted-foreground/60",children:"→"}),e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.baseRef}),t.diffFingerprint&&e.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:t.diffFingerprint})]}),Zs(t.latestInjectedAt,_)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:o("rightSidebar.branchAuditGeneratedAt",{time:Zs(t.latestInjectedAt,_)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{gm(t)},className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:o("rightSidebar.branchAuditClearTitle"),"aria-label":o("rightSidebar.branchAuditClearTitle"),children:e.jsx(yo,{size:12})})]},t.key)):cn.length===0?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,Fm=()=>nr&&v&&Pn?e.jsxs("div",{className:ao?"overflow-visible":"overflow-hidden",children:[Dm(),e.jsxs("button",{type:"button",onClick:()=>{dt||Lh(t=>{const i=!t;return i&&Ne&&!Pn&&!xn&&xi(Ne),i})},"aria-expanded":ao,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${dt?"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(kr,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:o("rightSidebar.gitQuickActions")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs("span",{className:`inline-flex items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${$n.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[xn&&e.jsx(ft,{size:10,className:"animate-spin"}),$n.staged>0?o("rightSidebar.stagedCount",{count:$n.staged}):o("rightSidebar.noStagedChangesShort")]}),!dt&&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 ${ao?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]})]}),ao&&e.jsxs("div",{className:"space-y-0",children:[Ht.length>1&&e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsx("div",{className:"mb-2 flex items-center justify-between gap-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.gitRepositorySectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:nm})]})}),e.jsx(fs,{label:o("rightSidebar.gitRepositoryLabel"),value:Ne??"",options:Ht,placeholder:o("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:o("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:o("rightSidebar.gitRepositoryEmpty"),disabled:!!qe,onChange:t=>{Md(t||null)}}),et&&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:o("rightSidebar.selectRepositoryForGitActions")})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.branchSectionTitle")}),e.jsx("div",{className:"mt-0.5 h-4 truncate text-[11px] leading-4 text-muted-foreground",children:Wn!==Zc?Zc:null})]}),e.jsxs("button",{type:"button",onClick:()=>{Pm()},disabled:!hm,className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${_i?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.switchBranch"),children:[e.jsx("span",{className:qe?.action==="switch-branch"||_i?"opacity-0":"",children:o("rightSidebar.switchBranch")}),qe?.action==="switch-branch"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),_i&&qe?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(fs,{label:o("rightSidebar.currentBranchLabel"),value:Wn,options:om,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),disabled:!!qe,onChange:Na})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.commitSectionTitle")}),e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:et?o("rightSidebar.selectRepositoryForGitActions"):$n.staged>0?o("rightSidebar.commitReadyHint",{count:$n.staged}):o("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{Pd()},disabled:!!qe||et||$n.staged===0||!Ra.trim(),className:`relative inline-flex h-8 shrink-0 items-center justify-center rounded-md px-3 text-[12px] font-medium transition active:scale-95 ${Fi?"bg-accent/10 text-accent disabled:bg-accent/10 disabled:text-accent":"bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-surface-2 disabled:text-muted-foreground"} disabled:cursor-not-allowed`,title:et?o("rightSidebar.selectRepositoryForGitActions"):$n.staged===0?o("rightSidebar.commitNeedsStaged"):o("rightSidebar.commitChanges"),children:[e.jsx("span",{className:qe?.action==="commit"||Fi?"opacity-0":"",children:o("rightSidebar.commitChanges")}),qe?.action==="commit"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Fi&&qe?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:Ra,onChange:t=>ac(t.target.value),onKeyDown:t=>{(t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),Pd())},placeholder:o("rightSidebar.commitMessagePlaceholder"),disabled:!!qe,className:"w-full min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-[13px] placeholder:text-[13px] text-foreground outline-none transition placeholder:text-muted-foreground/70 focus:border-primary focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-60",maxLength:300})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>js(t=>!t),className:"group flex w-full items-center justify-between gap-2 rounded-lg px-1 py-1.5 text-left transition hover:bg-surface-2 active:scale-[0.99]","aria-expanded":Gr,children:[e.jsx("span",{className:"min-w-0 text-[12px] font-medium text-foreground",children:o("rightSidebar.recentCommitsTitle")}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[Wt&&e.jsx(ft,{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 ${Gr?"rotate-90":""}`,children:e.jsx(hs,{size:13})})]})]}),Gr&&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(ms,{size:12,className:"shrink-0"}),e.jsx("input",{value:Rs,onChange:t=>pr(t.target.value),placeholder:o("rightSidebar.recentCommitsSearchPlaceholder"),className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1}),Rs&&e.jsx("button",{type:"button",onClick:()=>pr(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:e.jsx(Lt,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:sm,children:[re.length>0?re.map(t=>{const[i,...u]=t.split(/\s+/),w=u.join(" ")||t;return e.jsxs("button",{type:"button",onClick:()=>{Nm(t)},className:"flex w-full min-w-0 items-start gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-left font-mono text-[10px] transition hover:bg-surface-elevated active:scale-[0.99]",title:w,children:[e.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:w,children:w}),hn[i]&&e.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${hn[i]==="ahead"?"bg-accent/10 text-accent":hn[i]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:o(hn[i]==="ahead"?"rightSidebar.commitAhead":hn[i]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),bt===i&&e.jsx(ft,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},t)}):Wt?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:o("common.loading")}):Ho?null:e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.recentCommitsEmpty")}),ba&&e.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:e.jsx(ft,{size:12,className:"animate-spin"})}),zo&&!ba&&re.length>0&&e.jsx("button",{type:"button",onClick:()=>{Os({reset:!1})},className:"w-full rounded-md bg-surface-2 px-2 py-1.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:o("rightSidebar.recentCommitsLoadMore")})]})]}),un&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:un}),Ho&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Ho})]}),e.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.pushSectionTitle")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>{Lm()},disabled:!um,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Bi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pullChanges"),children:[e.jsx("span",{className:qe?.action==="pull"||Bi?"opacity-0":"",children:o("rightSidebar.pullChanges")}),qe?.action==="pull"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Bi&&qe?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{Am()},disabled:!fm,className:`relative inline-flex h-8 min-w-[3.25rem] items-center justify-center rounded-md px-3 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-50 active:scale-95 ${Oi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pushChanges"),children:[e.jsx("span",{className:qe?.action==="push"||Oi?"opacity-0":"",children:o("rightSidebar.pushChanges")}),qe?.action==="push"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Oi&&qe?.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] ${ld.className}`,title:de?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:ld.text}),e.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:de?.upstream??""})]}),e.jsxs("div",{className:`grid gap-1.5 ${ad?"grid-cols-2":"grid-cols-1"}`,children:[ad&&e.jsx(fs,{label:o("rightSidebar.pushRemoteLabel"),value:vn,options:sd,placeholder:o("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:o("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:o("rightSidebar.pushNoRemotes"),disabled:!!qe,onChange:Ca}),e.jsx(fs,{label:o("rightSidebar.pushBranchLabel"),value:yn,options:im,placeholder:o("rightSidebar.pushBranchPlaceholder",{branch:de?.branch??"HEAD"}),searchPlaceholder:o("rightSidebar.pushBranchSearchPlaceholder"),emptyText:o("rightSidebar.pushNoBranches"),disabled:!!qe,onChange:Ea})]})]})]})]}):null,_m=a.useCallback(t=>{const i=xt(t,v);if(!i)return[];const u=cl(t),w=[];return t.canStage&&w.push({key:"stage-file",label:o("rightSidebar.stageFile"),onClick:()=>{wt({action:"stage-file",cwd:i,paths:[t.path]},o("rightSidebar.stageFile"),u)}}),t.canUnstage&&w.push({key:"unstage-file",label:o("rightSidebar.unstageFile"),onClick:()=>{wt({action:"unstage-file",cwd:i,paths:[t.path]},o("rightSidebar.unstageFile"),u)}}),t.canStash&&w.push({key:"stash-file",label:o("rightSidebar.stashFile"),onClick:()=>{wt({action:"stash-file",cwd:i,paths:[t.path]},o("rightSidebar.stashFile"),u)}}),t.canRestoreWorktree&&w.push({key:"restore-worktree-file",label:o("rightSidebar.restoreFile"),destructive:!0,onClick:()=>bn({kind:"restore",file:t,phrase:""})}),w},[v,wt,o]),Bm=a.useCallback(()=>{if(f){h?.();return}Lr(0),Ir.current?.slideTo(0),Ar(!1),Ct(null)},[h,f]),Td=a.useCallback(t=>{if(Y(""),Ft(t),ot(null),Ct(null),R(null),se){f&&h?.(),Lr(0),Ir.current?.slideTo(0),Ar(!1);return}},[se,h,f,ot,Ft]);a.useEffect(()=>{if(!U||V.getState().pendingTerminalPath!==U)return;V.setState({pendingTerminalPath:null}),(()=>{const i=U,u=i.path;if(!u.startsWith("/"))return;Y(""),Ct(null),tn(null);const w=!!(v&&(u===v||u.startsWith(`${v}/`)));if(i.kind==="file"){const y=vo(u);Is(u),typeof i.line=="number"&&Number.isSafeInteger(i.line)&&i.line>0&&tn(i.line),Ft(w?null:y),R({path:u,nonce:++z.current});return}ot(null),w?(Ft(null),R({path:u,nonce:++z.current})):(R(null),Ft(u)),se&&(f&&h?.(),Lr(0),Ir.current?.slideTo(0),Ar(!1))})()},[U,Is,se,h,f,v,ot,Ft]),a.useEffect(()=>{r||(zt(!1),Jt(!1))},[r]),a.useEffect(()=>{if(!lr&&!Cr)return;const t=i=>{i instanceof globalThis.KeyboardEvent&&i.key!=="Escape"||i instanceof globalThis.MouseEvent&&i.target instanceof Node&&(pa.current?.contains(i.target)||Fn.current?.contains(i.target))||(zt(!1),Jt(!1))};return window.addEventListener("mousedown",t),window.addEventListener("keydown",t),()=>{window.removeEventListener("mousedown",t),window.removeEventListener("keydown",t)}},[Cr,lr]);const Id=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:em,disabled:!Wa,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.parentFolder"),title:o("rightSidebar.parentFolder"),children:e.jsx(Il,{size:14})}),e.jsx("button",{type:"button",onClick:Gc,disabled:!v||Kn===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":o("rightSidebar.backToProjectRoot"),title:o("rightSidebar.backToProjectRoot"),children:e.jsx(ru,{size:14})}),e.jsx("button",{type:"button",onClick:tm,disabled:!le,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.refreshFiles"),title:oc?o("rightSidebar.fileWatchUnavailable",{message:oc}):o("rightSidebar.refreshFiles"),children:e.jsx(wo,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:le??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:Qh}),La==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:o("fileTree.sortedByModified"),"aria-label":o("fileTree.sortedByModified"),children:e.jsx(nu,{size:11})})]})}),e.jsx("button",{type:"button",onClick:t=>le&&Ot(le,Ut??void 0,t.currentTarget),disabled:!le,...le&&Ut?ji(Ua(le),Ut):{},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 ${Ut&&(De===Ut||Re===Ut)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":o(Ut&&Re===Ut?"rightSidebar.copied":Ut&&De===Ut?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:o("rightSidebar.insertCurrentFolder"),children:Ut&&(De===Ut||Re===Ut)?e.jsx(Co,{size:13}):e.jsx(Eo,{size:13})}),e.jsx(kg,{rootPath:le,disabled:!le||!Fh||di,pressed:Aa,saving:di,onToggle:()=>{if(!le||di)return;const t=le;Sc(!0),ui(null),_h(t,!Aa).catch(()=>{const i=V.getState();(i.explorerRoot??i.rootPath)===t&&ui(o("rightSidebar.gitIgnoreSaveFailed"))}).finally(()=>Sc(!1))}}),e.jsxs("div",{ref:Fn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{zt(!1),Jt(t=>!t)},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":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:e.jsx(No,{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:()=>{Jt(!1),rm()},disabled:!Ci,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${_s?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[_s?e.jsx(qi,{size:14}):e.jsx(lo,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(_s?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Jt(!1),Ih()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${oi?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[oi?e.jsx(Yp,{size:14}):e.jsx(xl,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(oi?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!le,onClick:()=>{le&&(Jt(!1),Dh(le,La==="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:[La==="modified"?e.jsx(Ap,{size:14}):e.jsx(nu,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(La==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),jc&&e.jsx("p",{role:"alert",className:"px-1 py-1 text-[11px] text-destructive",children:jc}),v&&(Ga.length>0||Zh)&&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:o("rightSidebar.pinnedFolders")}),e.jsxs("button",{type:"button",onClick:Gc,className:`inline-flex max-w-[9rem] shrink-0 items-center gap-1 rounded-md px-2 py-0.5 font-medium transition active:scale-95 ${le===v?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:v,children:[e.jsx(ru,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:st})]}),Ga.map(t=>{const i=t.path,u=t.kind==="file",w=u?at===i:le===i;return e.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${w?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i,children:[e.jsxs("button",{type:"button",onClick:()=>u?Is(i):Ft(i),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[u?e.jsx(vl,{size:10,className:"shrink-0"}):e.jsx(lo,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:kt(i)})]}),e.jsx("button",{type:"button",onClick:()=>wn(i),className:"mr-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":o("rightSidebar.unpinFolder",{name:kt(i)}),title:o("rightSidebar.unpinFolder",{name:kt(i)}),children:e.jsx(Lt,{size:9})})]},i)})]}),e.jsx("span",{"data-local-layer":"file-explorer-divider",className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-px bg-border/15","aria-hidden":"true"})]}),Hi=a.useMemo(()=>{if(zn===null)return null;const t=typeof navigator>"u"?void 0:navigator.language,i=Math.max(0,Math.floor((ei-zn)/1e3)),u=new Intl.RelativeTimeFormat(t,{numeric:"auto"}),[w,y]=i<60?[-i,"second"]:i<3600?[-Math.floor(i/60),"minute"]:i<86400?[-Math.floor(i/3600),"hour"]:[-Math.floor(i/86400),"day"];return u.format(w,y)},[ei,zn]),oo="flex min-h-10 w-full items-center gap-2.5 rounded-md px-2.5 text-left text-[12px] text-foreground transition hover:bg-surface-2 focus:bg-surface-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [@media(pointer:coarse)]:min-h-11",Dd=v&&!ts?e.jsxs("button",{type:"button",role:"menuitemcheckbox",tabIndex:-1,onClick:()=>{$m(!ii)},"aria-checked":ii,title:o("rightSidebar.multiRepoScanTitle"),className:oo,children:[e.jsx(kr,{size:15,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1",children:o("rightSidebar.multiRepoScan")}),ii&&e.jsx(Co,{size:14,className:"shrink-0 text-primary"})]}):null,Fd=v?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[Hi?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:o("rightSidebar.gitLastUpdated",{time:Hi}),children:Hi}):null,e.jsx("button",{type:"button",onClick:()=>{es()},disabled:br,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95","aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),children:e.jsx(wo,{size:13,className:br?"animate-spin":""})})]}):null,Om=Pc?o("rightSidebar.changeAuditScopeAll"):Rn.length===1?Rn[0].relativeRoot==="."?st:Rn[0].relativeRoot||Rn[0].name:`${Rn.length} repos`,Um=t=>v?e.jsxs("div",{role:"none",children:[e.jsx(Ou,{menuItem:!0,open:ks,onOpenChange:i=>{sn(i),i&&t()},showScopePicker:An,selectedAll:Pc,repos:Bh,selectedRoots:ar,onToggleRepo:bm,onGenerate:()=>{t(),mm()},disabled:!v,inserted:De===Wc,buttonLabel:o("rightSidebar.changeAuditShort"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:o("rightSidebar.insertChangeAuditPrompt"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Om,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o("rightSidebar.changeAuditShort"),loading:ws,error:!!nn,statusTitle:nn??(ws?o("rightSidebar.changeAuditLoading"):St.length>0?`${o("rightSidebar.changeAuditLoaded",{count:St.length})}${Ld?` · ${o("rightSidebar.changeAuditLoadedAt",{time:Ld})}`:""}`:void 0)}),St.length>0&&e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),pm()},disabled:ws||St.length===0,className:oo,title:o("rightSidebar.clearChangeAuditTitle"),"aria-label":o("rightSidebar.clearChangeAudit"),children:[e.jsx(yo,{size:15,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.clearChangeAudit")})]})]}):null,ls=ir??(M?.available&&v&&Fe.size>0&&fe.length<=1?{root:v,label:st}:null),_d=t=>e.jsxs(e.Fragment,{children:[ls&&e.jsxs("div",{role:"group","aria-label":o("rightSidebar.gitQuickActions"),children:[e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),so("stage-all",ls.root,ls.label)},disabled:!!qe,className:oo,children:[e.jsx(bp,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stageAll")]}),e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),so("stash-all",ls.root,ls.label)},disabled:!!qe,className:oo,children:[e.jsx(Up,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stashAll")]})]}),ls&&e.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Um(t),Dd&&e.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Dd]}),io=e.jsxs("div",{className:"flex h-5 flex-nowrap items-center gap-1 overflow-x-auto whitespace-nowrap text-[10px] font-medium [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&>*]:shrink-0",children:[M?.available&&M.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:M.branch,children:[e.jsx(kr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:M.branch})]}),pt.modified>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[pt.modified,"M"]}),pt.added>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",pt.added]}),pt.deleted>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",pt.deleted]}),pt.renamed>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[pt.renamed,"R"]}),pt.copied>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[pt.copied,"C"]}),pt.untracked>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[pt.untracked,"U"]}),pt.conflicted>0&&e.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[pt.conflicted,"!"]}),pt.other>0&&e.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[pt.other,"?"]}),pt.staged>0&&e.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:o("rightSidebar.stagedCountShort",{count:pt.staged})})]});return e.jsxs(Lp,{side:"right",isOpen:r,drawerWidthPx:s,onClose:l,onOpen:d,push:c,pinned:m,children:[ji.popoverNode,e.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${Kh?"hidden":""}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"min-w-0 flex-1 px-1",children:e.jsxs("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",title:v??void 0,children:st}),(!se||Jo)&&M?.available&&M.branch&&e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:M.branch,children:[e.jsx(kr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"max-w-[7rem] truncate",children:M.branch})]})]})}),e.jsx("button",{type:"button",onClick:()=>{const t=!Z;P(t),t?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):Y("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Z?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleSearch"),title:o("common.search"),children:e.jsx(ms,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":We,onClick:()=>{Br(t=>!t),ne(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${We?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleContextDraft"),title:o("rightSidebar.contextDraftTitle"),children:[e.jsx(Tp,{size:14}),!We&&ct.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:dc,type:"file",multiple:!0,className:"hidden",onChange:t=>{const i=t.target.files;!i||i.length===0||(Ds(Array.from(i)),t.target.value="")}}),e.jsx("input",{ref:uc,type:"file",accept:"image/*",className:"hidden",onChange:t=>{const i=t.target.files?.[0];t.target.value="",i&&Yh(i)}}),g&&e.jsx("button",{type:"button",onClick:g,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${m?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:m?e.jsx(qi,{size:14}):e.jsx(lo,{size:14})}),e.jsxs("div",{ref:pa,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{Jt(!1),zt(t=>!t)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${lr?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":lr,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:e.jsx(No,{size:15})}),lr&&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:[["architecture","computer"].map(t=>e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":sr[t],onClick:()=>Vh(t,!sr[t]),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[t==="architecture"?e.jsx(su,{size:14,className:"text-muted-foreground"}):e.jsx(Jd,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"flex-1",children:o(t==="architecture"?"rightSidebar.showArchitectureTab":"rightSidebar.showComputerTab")}),e.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${sr[t]?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${sr[t]?"left-3.5":"left-0.5"}`})})]},t)),e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":qr,onClick:()=>Tc(!qr),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[e.jsx(Qd,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"flex-1",children:o("rightSidebar.showAndroidTab")}),e.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${qr?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${qr?"left-3.5":"left-0.5"}`})})]}),e.jsx("div",{className:"my-1 h-px bg-border/15",role:"separator"}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),dc.current?.click()},disabled:_a,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:[_a?e.jsx(ft,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(Ip,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),uc.current?.click()},disabled:_a,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:[_a?e.jsx(ft,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(tg,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.insertLocalImage")})]}),g&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{zt(!1),g()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${m?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[m?e.jsx(qi,{size:14}):e.jsx(lo,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(m?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),m&&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":o("rightSidebar.layoutMode"),children:[e.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:o("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",o("rightSidebar.layoutModeAuto")],["narrow",o("rightSidebar.layoutModeNarrow")],["wide",o("rightSidebar.layoutModeWide")]].map(([t,i])=>{const u=W===t;return e.jsx("button",{type:"button",role:"menuitemradio","aria-checked":u,onClick:()=>{J(t),zt(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${u?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:i},t)})})]})]})]}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":o("rightSidebar.close"),children:e.jsx(Lt,{size:14})})]}),Z&&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(ms,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:I,onChange:t=>Y(t.target.value),placeholder:o(oe==="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 ${se?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>Cd("name"),"aria-pressed":oe==="name",className:`rounded-full px-2 transition active:scale-95 ${se?"py-1":"py-0.5"} ${oe==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>Cd("content"),"aria-pressed":oe==="content",className:`rounded-full px-2 transition active:scale-95 ${se?"py-1":"py-0.5"} ${oe==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeContent")})]}),I&&e.jsx("button",{type:"button",onClick:()=>Y(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:e.jsx(Lt,{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(Dp,{size:12,className:"shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:o("rightSidebar.searchScope")}),e.jsx("input",{"data-search-scope":!0,value:Se,onChange:t=>we(t.target.value),onKeyDown:t=>{t.key==="Enter"&&document.querySelector("[data-right-search]")?.focus()},className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:o("rightSidebar.searchScopePlaceholder"),"aria-label":o("rightSidebar.searchScope"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),Se!=="."&&e.jsx("button",{type:"button",onClick:()=>we("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.resetSearchScope"),children:e.jsx(Lt,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>ue(t=>!t),"aria-expanded":be,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${be||As.length>0||Be||G||ye?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:o("rightSidebar.searchOptions"),"aria-label":o("rightSidebar.searchOptions"),children:[e.jsx(Fp,{size:13}),As.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:As.length})]})]}),be&&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:o("rightSidebar.searchExclude")}),e.jsx("input",{"data-search-exclude":!0,value:Me,onChange:t=>Q(t.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-foreground placeholder:text-muted-foreground",placeholder:o("rightSidebar.searchExcludePlaceholder"),"aria-label":o("rightSidebar.searchExclude"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),Me&&e.jsx("button",{type:"button",onClick:()=>Q(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.clearSearchExclude"),children:e.jsx(Lt,{size:11})})]}),oe==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":o("rightSidebar.contentSearchOptions"),children:[[Be,()=>Oe(t=>!t),qp,o("rightSidebar.matchCase")],[G,()=>je(t=>!t),ig,o("rightSidebar.matchWholeWord")],[ye,()=>Ue(t=>!t),ng,o("rightSidebar.useRegex")]].map(([t,i,u,w])=>e.jsxs("button",{type:"button",onClick:i,"aria-pressed":t,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${t?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[e.jsx(u,{size:12}),w]},w))})]})]}),e.jsxs("div",{className:"mt-2 grid gap-0.5 rounded-md bg-surface-2 p-0.5",style:{gridTemplateColumns:`repeat(${(ts?1:3)+Number(sr.architecture)+Number(sr.computer)+Number(qr)}, minmax(0, 1fr))`},children:[!ts&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:t=>ss("git",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(kr,{size:12}),o("rightSidebar.tabGit")]}),e.jsxs("button",{type:"button",onClick:t=>ss("diff",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(pf,{size:12}),o("rightSidebar.tabChanges"),Fe.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:Fe.size}):null]})]}),e.jsxs("button",{type:"button",onClick:t=>ss("files",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(hl,{size:12}),o("rightSidebar.tabFiles")]}),sr.architecture&&e.jsxs("button",{type:"button",onClick:t=>ss("architecture",t),className:`flex items-center justify-center gap-1 rounded px-1 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Nn?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(su,{size:12}),o("architecture.tab")]}),sr.computer&&e.jsxs("button",{type:"button",onClick:t=>ss("computer",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${ns?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Jd,{size:12}),o("rightSidebar.tabComputer")]}),qr&&e.jsxs("button",{type:"button",onClick:t=>ss("android",t),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${Mt==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Qd,{size:12}),o("rightSidebar.tabAndroid")]})]}),e.jsx("div",{className:"h-2"}),nc&&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:nc})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(ds,{active:dt,mounted:nr,fallback:e.jsx(ol,{slow:!1}),children:()=>ze?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(mu,{items:vm,diffViewType:ri,inlineMode:ur,viewControls:m?Hs():void 0,renderPathReference:(t,i)=>Ja(Tn(t,ze.repoRoot??v),o(i==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle")),selectedKey:Rh,onSelect:xa,emptyText:o("rightSidebar.noChanges"),mobile:se,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o("rightSidebar.recentCommitsTitle"),headerMeta:`${ze.headRef??""}${ze.commits?.[0]?` · ${ze.commits[0]}`:""}`,onClose:()=>{Ge(null),xa(null)},closeLabel:o("common.back"),wrap:Tt,onToggleWrap:ro,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:se?"stacked":"split",onInsertDiffReference:Fr,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onClearAuditRecord:Za})}):hr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(mu,{items:Ai,diffViewType:ri,inlineMode:ur,viewControls:m?Hs():void 0,renderPathReference:(t,i)=>{const u=ve?.comparisonRepos,w=u&&u.length>1?[...u].sort((k,C)=>C.label.length-k.label.length).find(k=>t===k.label||t.startsWith(`${k.label}/`)):void 0,y=w?t===w.label?w.repoRoot:Tn(t.slice(w.label.length+1),w.repoRoot):Tn(t,Gs?.repoRoot||v);return Ja(y,o(i==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle"))},selectedKey:Vo,onSelect:gn,emptyText:o(ve?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:se,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o(ve?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:Gs?`${Gs.repoLabel} · ${Gs.branchName??"HEAD"} → ${Gs.baseRef}`:void 0,onClose:()=>{++It.current,ke(!1),mr(!1),er(null)},closeLabel:o("common.back"),wrap:Tt,onToggleWrap:ro,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:se?"stacked":"split",onInsertDiffReference:Fr,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onClearAuditRecord:Za,localOptions:ve?.comparisonRepos?.map(t=>({key:t.repoRoot,label:t.label,checked:t.includeUncommitted??ve.includeUncommitted??!1,disabled:!(t.canIncludeUncommitted??os(t.repoRoot,t.head)),onChange:i=>{Di({refresh:!0,repoRoot:t.repoRoot,includeUncommitted:i})}})),onHunkGitAction:ve?.includeUncommitted?Mm:void 0,error:nt,actionsBusy:T>0,onRefresh:()=>{Di({refresh:!0})},refreshing:ge,refreshLabel:o("rightSidebar.branchAuditRefreshDiff"),refreshTitle:o("rightSidebar.branchAuditRefreshDiff"),walkthroughs:ym,onWalkthroughNavigate:wm,initialDetailScrollTop:ve&&Qe?Ss[Qe]:void 0,onDetailScrollPositionChange:Cm,externalSwiperRef:se?Mc:void 0,onMobileSlideChange:se?Xo:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:nr&&v&&Pn?e.jsx("div",{className:"px-3",children:Fm()}):br?e.jsx(ol,{slow:vc}):kn?e.jsx(xo,{message:kn,onRetry:()=>{es()}}):Gu(M)?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):M?.available===!1?e.jsx(xo,{message:M.error??o("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{es()}}):v?e.jsx(ol,{slow:vc}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),e.jsx(ds,{active:Dr,mounted:Ch||Dr,children:()=>se?e.jsxs(sf,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:t=>{Ir.current=t,t.slideTo(Yo,0)},onSlideChange:t=>{if(Lr(t.activeIndex),Ts.current===t.activeIndex){Ts.current=null;return}t.activeIndex===0&&(Ar(!1),Ct(null),h?.())},children:[e.jsx(ml,{className:"h-full min-h-0",children:e.jsxs("div",{ref:Yn,onScroll:Ic,onDragOver:Ba,onDragEnter:Ba,onDragLeave:Fc,onDrop:_c,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[ic&&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:o("rightSidebar.dropToUpload")})}),!I.trim()&&Id,e.jsx(au,{rootPath:le??"",onFileSelect:Is,onPathReference:Ot,getReferenceText:Ua,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onDirectoryRoot:Kc,onSearchFromDirectory:qc,onDirectoryPinToggle:Vc,onFilePinToggle:Yc,pinnedPaths:En,selectedFilePath:at,query:Ye,searchRootPath:Rc,searchOptions:Nc,searchMode:oe,onContentMatchSelect:wi,onDirectoryDropFiles:(t,i)=>Ds(i,t),revealDirectory:O,canOpenInFileBrowser:lc,onOpenInFileBrowser:Dc})]})}),e.jsx(ml,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(Fo,{filePath:Nh||Yo===1?at:null,active:r&&Dr&&Yo===1,onInsertReference:Ot,onInsertText:or,onInsertFeature:or,onReviewReference:Hc,onReferenceCopied:yr,onClose:Bm,onDirectoryLinkOpen:Td,isMobile:!0,lineRange:en,onLineRangeChange:Ct,insertedReferenceKey:De,copiedReferenceKey:Re,scrollToLine:Or,onScrollToLineHandled:()=>tn(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:N,markdownImageLightboxOpen:A,markdownImageLightboxCloseSignal:B,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:Yn,onScroll:Ic,onDragOver:Ba,onDragEnter:Ba,onDragLeave:Fc,onDrop:_c,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:ni},children:[ic&&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:o("rightSidebar.dropToUpload")})}),!I.trim()&&Id,e.jsx(au,{rootPath:le??"",onFileSelect:Is,onPathReference:Ot,getReferenceText:Ua,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onDirectoryRoot:Kc,onSearchFromDirectory:qc,onDirectoryPinToggle:Vc,onFilePinToggle:Yc,pinnedPaths:En,selectedFilePath:at,query:Ye,searchRootPath:Rc,searchOptions:Nc,searchMode:oe,onContentMatchSelect:wi,onDirectoryDropFiles:(t,i)=>Ds(i,t),revealDirectory:O,canOpenInFileBrowser:lc,onOpenInFileBrowser:Dc})]}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":o("rightSidebar.resizeFileTree"),title:o("rightSidebar.resizeFileTree"),"data-local-layer":"file-preview-separator",className:"group relative z-10 w-2 shrink-0 cursor-col-resize touch-none border-l border-border/15 bg-surface",onPointerDown:Oh,onPointerMove:Uh,onPointerUp:Lc,onPointerCancel:Lc,onDoubleClick:()=>{si(jl),At(ra,jl)},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(Fo,{filePath:at,active:r&&Dr,onInsertReference:Ot,onInsertText:or,onInsertFeature:or,onReviewReference:Hc,onReferenceCopied:yr,onDirectoryLinkOpen:Td,isMobile:!1,lineRange:en,onLineRangeChange:Ct,insertedReferenceKey:De,copiedReferenceKey:Re,scrollToLine:Or,onScrollToLineHandled:()=>tn(null),markdownOutlineOpen:D,markdownOutlineCloseSignal:F,onOpenMarkdownOutline:$,onCloseMarkdownOutline:N,markdownImageLightboxOpen:A,markdownImageLightboxCloseSignal:B,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:j})})]})}),e.jsx(ds,{active:$t,mounted:Mh||$t,children:()=>vi?e.jsx(_p,{}):se?e.jsx(pl,{mobile:!0,backLabel:o("rightSidebar.backToChangeList"),externalSwiperRef:bi,onMobileSlideChange:Xo,groups:Xt.length>0?md():[],mode:zr,onModeChange:to,selectedKey:at,scrollToKey:vd,scrollToKeyNonce:Ma.nonce,compact:!1,collapsedDirectoryKeys:Ur,onToggleDirectory:kd,onSelectFile:t=>{const i=Ln.get(t.key);i&&eo(Sr(i))},renderLeading:pd,renderTrailing:t=>{const i=Ln.get(t.key);return i?fd(i):null},renderDirectoryTrailing:hd,renderSubtitle:t=>{const i=Ln.get(t.key);return i?ud(i):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:t=>v&&e.jsxs("div",{className:"px-0 py-0",children:[io&&e.jsx("div",{className:"mb-2",children:io}),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:o("rightSidebar.allChanges")})}),e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[Xt.length,"/",Fe.size]})]}),e.jsxs(uu,{actions:_d,children:[cd(),t,m&&Hs(),Fd]},v),ir&&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:ir.label}),ir.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:ir.branch})]}),!ir&&An&&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(kr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:Va?(t=>wd(t)):void 0,emptyContent:vi?null:kn&&Fe.size===0?e.jsx(xo,{message:kn,onRetry:()=>{es()}}):Fe.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Xt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:({slideToList:t})=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:t,className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:o("rightSidebar.backToChangeList"),children:[e.jsx(la,{size:14}),o("rightSidebar.backToChangeList")]}),e.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-1.5",children:[m&&Hs(),e.jsxs("button",{type:"button",onClick:ro,"aria-pressed":Tt,title:o("rightSidebar.wrapLongLines"),className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${Tt?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:o(Tt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),v&&e.jsx("button",{type:"button",onClick:()=>{es()},disabled:br,"aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",children:e.jsx(wo,{size:14,className:br?"animate-spin":""})})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:gd,activePane:$t,wrap:Tt,diffViewType:ri,inlineMode:ur,diffOptions:Nd,reloadKey:xs,renderStreamBadge:t=>e.jsx(aa,{status:t}),onHunkGitAction:Ed,onInsertDiffReference:Fr,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onClearAuditRecord:Za,onDetailScroll:Qa}):e.jsx(pl,{mobile:!1,desktopLayout:"split",desktopSidePanel:null,desktopListClassName:"w-[320px] min-w-[260px] shrink-0 overflow-y-auto overscroll-contain border-r border-border/15 bg-surface",backLabel:o("rightSidebar.backToChangeList"),groups:Xt.length>0?md():[],mode:zr,onModeChange:to,selectedKey:at,scrollToKey:vd,scrollToKeyNonce:Ma.nonce,compact:!0,collapsedDirectoryKeys:Ur,onToggleDirectory:kd,onSelectFile:t=>{const i=Ln.get(t.key);i&&eo(Sr(i))},renderLeading:pd,renderTrailing:t=>{const i=Ln.get(t.key);return i?fd(i):null},renderDirectoryTrailing:hd,renderSubtitle:t=>{const i=Ln.get(t.key);return i?ud(i):null},aiContent:Va?(t=>wd(t)):void 0,emptyContent:vi?null:kn&&Fe.size===0?e.jsx(xo,{message:kn,onRetry:()=>{es()}}):Fe.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):Xt.length===0?e.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderListHeader:t=>v&&e.jsxs("div",{className:"px-0 py-0",children:[io&&e.jsx("div",{className:"mb-2",children:io}),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:o("rightSidebar.allChanges")}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[Xt.length,"/",Fe.size]})})]}),e.jsxs(uu,{actions:_d,children:[cd(),t,Hs(),e.jsxs("button",{type:"button",onClick:ro,"aria-pressed":Tt,title:o("rightSidebar.wrapLongLines"),className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Tt?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[e.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),e.jsx("span",{children:o(Tt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),Fd]},v),ir&&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:ir.label}),ir.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:ir.branch})]}),!ir&&An&&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(kr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),files:gd,activePane:$t,wrap:Tt,diffViewType:Mr,inlineMode:ur,diffOptions:Nd,reloadKey:xs,renderStreamBadge:t=>e.jsx(aa,{status:t}),onHunkGitAction:Ed,onInsertDiffReference:Fr,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re,onClearAuditRecord:Za,onDetailScroll:Qa})}),e.jsx(ds,{active:Nn,mounted:sr.architecture&&(Wh||r&&Nn),children:e.jsx(a.Suspense,{fallback:e.jsx("p",{role:"status",className:"p-4 text-sm text-muted-foreground",children:o("architecture.loading")}),children:e.jsx(ex,{rootPath:v,active:r&&Nn,onInsertPrompt:(t,i)=>or(t,`architecture:${v}`,i),renderSource:t=>v&&e.jsx(x0,{rootPath:v,file:t,active:r&&Nn,isMobile:se,onInsertReference:Ot,onInsertText:or,onReferenceCopied:yr,insertedReferenceKey:De,copiedReferenceKey:Re},`${t.path}:${t.line??1}`),onOpenFile:t=>{v&&(Dt("files"),Ft(null),wi(`${v.replace(/\/+$/,"")}/${t.path}`,t.line??1))}},v)})}),e.jsx(ds,{active:r&&ns,mounted:sr.computer&&(Hh||r&&ns),children:e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:o("computer.loading")}),children:e.jsx(tx,{active:r&&ns})})}),e.jsx(ds,{active:rs,mounted:Zo&&qr,children:$h?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[e.jsx("span",{children:o("android.splitDockedHint")}),e.jsx("button",{type:"button",onClick:()=>{Wi.getState().setDock(Ki,null),ta({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:o("android.splitClose")})]}):e.jsx(Bp,{sessionId:n??null,onCloseTab:()=>Tc(!1),onInsertPrompt:t=>Fr("android-deps",t),onInsertFile:Jh,onRecordingComplete:Xh})})]}),r&&Bt.task&&e.jsx(Xg,{task:Bt.task,onCancel:Bt.cancel,onRetry:()=>{Bt.retry()},onDismiss:Bt.dismiss,labels:{uploading:o("rightSidebar.uploadPending"),inserting:o("rightSidebar.uploadInserting"),done:o(Bt.task.kind==="image"?"rightSidebar.uploadReferenceDone":"rightSidebar.uploadDone",{count:Bt.task.uploaded.length}),failed:o("rightSidebar.uploadFailed"),canceled:o("rightSidebar.uploadCanceled"),referenceRejected:o("rightSidebar.uploadReferenceRejected"),limit:o("rightSidebar.uploadLimit"),cancel:o("common.cancel"),retry:o("common.retry"),dismiss:o("common.close"),files:o("rightSidebar.uploadFileCount",{count:Bt.task.files.length})}}),r&&We&&e.jsx(Gg,{value:ct,collapsed:H,autoCollapseAfterSend:Ce,focusRequest:Zr,insertError:gs?o("rightSidebar.contextDraftInsertFailed"):null,onChange:t=>{cr(!1),Nt(t)},onCollapsedChange:ne,onAutoCollapseAfterSendChange:lt,onDisable:()=>Br(!1),onClear:()=>Nt(""),onInsert:()=>zc(!1),onInsertAndSend:()=>zc(!0),labels:{title:o("rightSidebar.contextDraftTitle"),hint:o("rightSidebar.contextDraftHint"),placeholder:o("rightSidebar.contextDraftPlaceholder"),collapse:o("rightSidebar.contextDraftCollapse"),expand:o("rightSidebar.contextDraftExpand"),disable:o("rightSidebar.contextDraftDisable"),clear:o("rightSidebar.contextDraftClear"),insert:o("rightSidebar.contextDraftInsert"),insertAndSend:o("rightSidebar.contextDraftInsertAndSend"),inserted:o("rightSidebar.contextDraftInserted"),sent:o("rightSidebar.contextDraftSent"),pending:o("rightSidebar.contextDraftPending"),send:o("rightSidebar.contextDraftSend"),appended:o("rightSidebar.contextDraftAppended"),resize:o("rightSidebar.contextDraftResize"),autoCollapseAfterSend:o("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:t=>o("rightSidebar.contextDraftCharacterCount",{count:t})}}),dm(),yt&&typeof document<"u"&&Rr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>bn(null),children:e.jsxs("div",{className:"fixed inset-x-3 bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto max-w-md rounded-2xl border border-border/20 bg-surface-elevated p-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:yt.kind==="restore"?o("rightSidebar.confirmRestoreTitle"):o("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:yt.kind==="restore"?o("rightSidebar.confirmRestoreDescription",{path:tf(yt.file.absolutePath,v)}):o("rightSidebar.confirmStashAllDescription")}),yt.kind==="restore"&&e.jsx("input",{value:yt.phrase,onChange:t=>bn({...yt,phrase:t.target.value}),placeholder:o("rightSidebar.confirmRestorePlaceholder"),className:"mt-3 w-full rounded-xl border border-border/20 bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground",autoFocus:!0}),e.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>bn(null),className:"rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:o("common.cancel")}),e.jsx("button",{type:"button",disabled:!!qe||yt.kind==="restore"&&yt.phrase.trim()!==o("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(yt.kind==="restore"){const t=xt(yt.file,v);if(!t)return;wt({action:"restore-worktree-file",cwd:t,paths:[yt.file.path],confirm:{acknowledged:!0,phrase:yt.phrase}},o("rightSidebar.restoreFile"),cl(yt.file))}else{const t=yt.repoRoot??v;if(!t)return;wt({action:"stash-all",cwd:t},o("rightSidebar.stashAll"),`repo:${t}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${yt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:o(qe?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const P0=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:Fo,MarkdownImageLightbox:hh,MarkdownPreview:mh,RightSidebar:v0,__testParseMarkdownListBlock:Dx,buildMarkdownPreviewBlocks:Kx,buildMarkdownPreviewRenderResult:Gl,collectKnownGitRepoRoots:_f,computeMarkdownImageDisplayBox:Xf,getMarkdownHeadingOutline:fh,getMarkdownHeadingPathAtLine:uh,getNextMarkdownPreviewLineRange:Qx,isSvgImageSrc:ma,mountRightSidebarRepoPickerOverlay:Rf,replaceGitRepositorySnapshot:yh,resolveMarkdownLocalLinkTarget:Bl,resolveRightSidebarDiffViewType:Df,shouldCloseMarkdownImageLightboxDrag:lh,showsGitRepoGroupHeader:Rl},Symbol.toStringTag,{value:"Module"}));export{xl as E,P0 as R,ag as S,Yp as a,Kx as b,Sg as c,yg as i,vg as l,$0 as m};