termdock 1.4.299 → 1.4.301

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 (372) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +2 -1
  3. package/dist/client/assets/App-BziVLy1b.js +179 -0
  4. package/dist/client/assets/App-BziVLy1b.js.br +0 -0
  5. package/dist/client/assets/App-BziVLy1b.js.gz +0 -0
  6. package/dist/client/assets/ArchitecturePanel-CARNBEqQ.js +12 -0
  7. package/dist/client/assets/ArchitecturePanel-CARNBEqQ.js.br +0 -0
  8. package/dist/client/assets/ArchitecturePanel-CARNBEqQ.js.gz +0 -0
  9. package/dist/client/assets/{ChangeWalkthroughPanel-2lXfrgk4.js → ChangeWalkthroughPanel-00oa0z6w.js} +2 -2
  10. package/dist/client/assets/ChangeWalkthroughPanel-00oa0z6w.js.br +0 -0
  11. package/dist/client/assets/ChangeWalkthroughPanel-00oa0z6w.js.gz +0 -0
  12. package/dist/client/assets/CollaborationMainWorkspace-DuEeKQKZ.js +1 -0
  13. package/dist/client/assets/CollaborationMainWorkspace-DuEeKQKZ.js.br +0 -0
  14. package/dist/client/assets/CollaborationMainWorkspace-DuEeKQKZ.js.gz +0 -0
  15. package/dist/client/assets/CollaborationTaskContent-B_mzpNuw.js +2 -0
  16. package/dist/client/assets/ComputerControlView-C9v1Ooc9.js +5 -0
  17. package/dist/client/assets/ComputerControlView-C9v1Ooc9.js.br +0 -0
  18. package/dist/client/assets/ComputerControlView-C9v1Ooc9.js.gz +0 -0
  19. package/dist/client/assets/{DagPlayground-EFUb9S3u.js → DagPlayground-DfUpMALj.js} +1 -1
  20. package/dist/client/assets/DagPlayground-DfUpMALj.js.br +0 -0
  21. package/dist/client/assets/DagPlayground-DfUpMALj.js.gz +0 -0
  22. package/dist/client/assets/{DiffLab-CXWjSE2q.js → DiffLab-Cf_URhQt.js} +1 -1
  23. package/dist/client/assets/DiffLab-Cf_URhQt.js.br +0 -0
  24. package/dist/client/assets/DiffLab-Cf_URhQt.js.gz +0 -0
  25. package/dist/client/assets/{DiffReview-ByMkBaD9.js → DiffReview-DjG9vCpH.js} +1 -1
  26. package/dist/client/assets/DiffReview-DjG9vCpH.js.br +0 -0
  27. package/dist/client/assets/DiffReview-DjG9vCpH.js.gz +0 -0
  28. package/dist/client/assets/{DiffReviewLab-DoWaKm94.js → DiffReviewLab-BKOvHdJY.js} +2 -2
  29. package/dist/client/assets/DiffReviewLab-BKOvHdJY.js.br +0 -0
  30. package/dist/client/assets/DiffReviewLab-BKOvHdJY.js.gz +0 -0
  31. package/dist/client/assets/{DiffViewer-B4hn9z0k.js → DiffViewer-6n3tgsdc.js} +8 -8
  32. package/dist/client/assets/DiffViewer-6n3tgsdc.js.br +0 -0
  33. package/dist/client/assets/DiffViewer-6n3tgsdc.js.gz +0 -0
  34. package/dist/client/assets/{ModelPreview-C-LJZ8so.js → ModelPreview-BNs2sRct.js} +1 -1
  35. package/dist/client/assets/ModelPreview-BNs2sRct.js.br +0 -0
  36. package/dist/client/assets/ModelPreview-BNs2sRct.js.gz +0 -0
  37. package/dist/client/assets/RightSidebar-CcMSU1v8.js +1677 -0
  38. package/dist/client/assets/RightSidebar-CcMSU1v8.js.br +0 -0
  39. package/dist/client/assets/RightSidebar-CcMSU1v8.js.gz +0 -0
  40. package/dist/client/assets/{abnfDiagram-VCTEODGH-BY-pfYKk.js → abnfDiagram-VCTEODGH-DogjvRKp.js} +1 -1
  41. package/dist/client/assets/abnfDiagram-VCTEODGH-DogjvRKp.js.br +0 -0
  42. package/dist/client/assets/abnfDiagram-VCTEODGH-DogjvRKp.js.gz +0 -0
  43. package/dist/client/assets/app-D6vN8PW-.js +35 -0
  44. package/dist/client/assets/app-D6vN8PW-.js.br +0 -0
  45. package/dist/client/assets/app-D6vN8PW-.js.gz +0 -0
  46. package/dist/client/assets/{arc-DIENgCZn.js → arc-Cqel4Ted.js} +1 -1
  47. package/dist/client/assets/arc-Cqel4Ted.js.br +0 -0
  48. package/dist/client/assets/arc-Cqel4Ted.js.gz +0 -0
  49. package/dist/client/assets/{architectureDiagram-5GKGNRK7-C1h4e4az.js → architectureDiagram-5GKGNRK7-DgvPtgNb.js} +1 -1
  50. package/dist/client/assets/architectureDiagram-5GKGNRK7-DgvPtgNb.js.br +0 -0
  51. package/dist/client/assets/architectureDiagram-5GKGNRK7-DgvPtgNb.js.gz +0 -0
  52. package/dist/client/assets/{blockDiagram-I7D4REHJ-B_yOr54K.js → blockDiagram-I7D4REHJ-BxbWO4x4.js} +1 -1
  53. package/dist/client/assets/blockDiagram-I7D4REHJ-BxbWO4x4.js.br +0 -0
  54. package/dist/client/assets/blockDiagram-I7D4REHJ-BxbWO4x4.js.gz +0 -0
  55. package/dist/client/assets/{c4Diagram-7LVT6UL2-DRD4zxIo.js → c4Diagram-7LVT6UL2-gsA37gjL.js} +1 -1
  56. package/dist/client/assets/c4Diagram-7LVT6UL2-gsA37gjL.js.br +0 -0
  57. package/dist/client/assets/c4Diagram-7LVT6UL2-gsA37gjL.js.gz +0 -0
  58. package/dist/client/assets/channel-CBc8-n7y.js +1 -0
  59. package/dist/client/assets/{chunk-2Q5K7J3B-CXytnjmD.js → chunk-2Q5K7J3B-ChC9yYOd.js} +1 -1
  60. package/dist/client/assets/{chunk-5VM5RSS4-Bjmajkf7.js → chunk-5VM5RSS4-Bi4Hc8yL.js} +1 -1
  61. package/dist/client/assets/{chunk-F27PBJKO-CQCL8mJG.js → chunk-F27PBJKO-DvVWvQEk.js} +1 -1
  62. package/dist/client/assets/chunk-F27PBJKO-DvVWvQEk.js.br +0 -0
  63. package/dist/client/assets/chunk-F27PBJKO-DvVWvQEk.js.gz +0 -0
  64. package/dist/client/assets/{chunk-IMKFNOWR-ruHGCADe.js → chunk-IMKFNOWR-BnwQLR5S.js} +1 -1
  65. package/dist/client/assets/chunk-IMKFNOWR-BnwQLR5S.js.br +0 -0
  66. package/dist/client/assets/chunk-IMKFNOWR-BnwQLR5S.js.gz +0 -0
  67. package/dist/client/assets/{chunk-JWPE2WC7-U18S7rxZ.js → chunk-JWPE2WC7-BkNnaDiR.js} +1 -1
  68. package/dist/client/assets/{chunk-POPQ4Y6H-DWnwssfL.js → chunk-POPQ4Y6H-BRzm6Uzi.js} +1 -1
  69. package/dist/client/assets/{chunk-SVP7TREG-DMHj3NSq.js → chunk-SVP7TREG-CDYm-dzk.js} +1 -1
  70. package/dist/client/assets/chunk-SVP7TREG-CDYm-dzk.js.br +0 -0
  71. package/dist/client/assets/chunk-SVP7TREG-CDYm-dzk.js.gz +0 -0
  72. package/dist/client/assets/{chunk-TICWLB2K-Dh_ekvFW.js → chunk-TICWLB2K-BKaW9Z9i.js} +1 -1
  73. package/dist/client/assets/chunk-TICWLB2K-BKaW9Z9i.js.br +0 -0
  74. package/dist/client/assets/chunk-TICWLB2K-BKaW9Z9i.js.gz +0 -0
  75. package/dist/client/assets/{chunk-XXDRQBXY-Bq5wD6iJ.js → chunk-XXDRQBXY-DcHZ_FHb.js} +1 -1
  76. package/dist/client/assets/classDiagram-ZZMXUADV-CNFc2dOc.js +1 -0
  77. package/dist/client/assets/classDiagram-v2-VYDZK3BY-CNFc2dOc.js +1 -0
  78. package/dist/client/assets/{cose-bilkent-JH36ORCC-CsySWhYg.js → cose-bilkent-JH36ORCC-DCbbTNc6.js} +1 -1
  79. package/dist/client/assets/cose-bilkent-JH36ORCC-DCbbTNc6.js.br +0 -0
  80. package/dist/client/assets/cose-bilkent-JH36ORCC-DCbbTNc6.js.gz +0 -0
  81. package/dist/client/assets/{cynefin-OW5HDTMX-9DKE5wV7.js → cynefin-OW5HDTMX-i23hD0Z2.js} +1 -1
  82. package/dist/client/assets/cynefin-OW5HDTMX-i23hD0Z2.js.br +0 -0
  83. package/dist/client/assets/cynefin-OW5HDTMX-i23hD0Z2.js.gz +0 -0
  84. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-B_8fvr9c.js → cynefinDiagram-5FMLGOSQ-CbyLYcqc.js} +1 -1
  85. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CbyLYcqc.js.br +0 -0
  86. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CbyLYcqc.js.gz +0 -0
  87. package/dist/client/assets/{dagre-GXQ25YYZ-BOdsFNFT.js → dagre-GXQ25YYZ-iJ4VKzZm.js} +1 -1
  88. package/dist/client/assets/dagre-GXQ25YYZ-iJ4VKzZm.js.br +0 -0
  89. package/dist/client/assets/dagre-GXQ25YYZ-iJ4VKzZm.js.gz +0 -0
  90. package/dist/client/assets/{diagram-S7CK7UJ4-6v_qvAvi.js → diagram-S7CK7UJ4-BNVZcdsO.js} +1 -1
  91. package/dist/client/assets/diagram-S7CK7UJ4-BNVZcdsO.js.br +0 -0
  92. package/dist/client/assets/diagram-S7CK7UJ4-BNVZcdsO.js.gz +0 -0
  93. package/dist/client/assets/{diagram-UQ7AKVKN-c03oOGhD.js → diagram-UQ7AKVKN-1ghTvPiu.js} +1 -1
  94. package/dist/client/assets/diagram-UQ7AKVKN-1ghTvPiu.js.br +0 -0
  95. package/dist/client/assets/diagram-UQ7AKVKN-1ghTvPiu.js.gz +0 -0
  96. package/dist/client/assets/{diagram-VSXAHHWV-MMIhRYp_.js → diagram-VSXAHHWV-Ce_0nMd3.js} +1 -1
  97. package/dist/client/assets/diagram-VSXAHHWV-Ce_0nMd3.js.br +0 -0
  98. package/dist/client/assets/diagram-VSXAHHWV-Ce_0nMd3.js.gz +0 -0
  99. package/dist/client/assets/{diagram-VX7I27RA-B_l-uebl.js → diagram-VX7I27RA-CLHEkhUt.js} +1 -1
  100. package/dist/client/assets/diagram-VX7I27RA-CLHEkhUt.js.br +0 -0
  101. package/dist/client/assets/diagram-VX7I27RA-CLHEkhUt.js.gz +0 -0
  102. package/dist/client/assets/{diagram-Z3DM3KII-DKoBC5gn.js → diagram-Z3DM3KII-iyb5DkP6.js} +1 -1
  103. package/dist/client/assets/diagram-Z3DM3KII-iyb5DkP6.js.br +0 -0
  104. package/dist/client/assets/diagram-Z3DM3KII-iyb5DkP6.js.gz +0 -0
  105. package/dist/client/assets/{ebnfDiagram-PWID7BFC-Bs3wu8Az.js → ebnfDiagram-PWID7BFC-Dxh2TzXm.js} +1 -1
  106. package/dist/client/assets/ebnfDiagram-PWID7BFC-Dxh2TzXm.js.br +0 -0
  107. package/dist/client/assets/ebnfDiagram-PWID7BFC-Dxh2TzXm.js.gz +0 -0
  108. package/dist/client/assets/{erDiagram-RLTQ6QDP-mYnHYbKl.js → erDiagram-RLTQ6QDP-Cr8IkdCC.js} +1 -1
  109. package/dist/client/assets/erDiagram-RLTQ6QDP-Cr8IkdCC.js.br +0 -0
  110. package/dist/client/assets/erDiagram-RLTQ6QDP-Cr8IkdCC.js.gz +0 -0
  111. package/dist/client/assets/{flowDiagram-HODETNUW-CwCLWbib.js → flowDiagram-HODETNUW-B8ZF1bwr.js} +1 -1
  112. package/dist/client/assets/flowDiagram-HODETNUW-B8ZF1bwr.js.br +0 -0
  113. package/dist/client/assets/flowDiagram-HODETNUW-B8ZF1bwr.js.gz +0 -0
  114. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-mse8c-ni.js → ganttDiagram-EL5Y4UJY-zhdL10eM.js} +1 -1
  115. package/dist/client/assets/ganttDiagram-EL5Y4UJY-zhdL10eM.js.br +0 -0
  116. package/dist/client/assets/ganttDiagram-EL5Y4UJY-zhdL10eM.js.gz +0 -0
  117. package/dist/client/assets/{gestureArbiter-BviL29ps.js → gestureArbiter-CXYHfU__.js} +1 -1
  118. package/dist/client/assets/gestureArbiter-CXYHfU__.js.br +0 -0
  119. package/dist/client/assets/gestureArbiter-CXYHfU__.js.gz +0 -0
  120. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-BVUfLjAX.js → gitGraphDiagram-WWUBYQGX-BQf2fHBo.js} +1 -1
  121. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-BQf2fHBo.js.br +0 -0
  122. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-BQf2fHBo.js.gz +0 -0
  123. package/dist/client/assets/{index-C6ftfFlG.css → index-CNY7CTVa.css} +1 -1
  124. package/dist/client/assets/index-CNY7CTVa.css.br +0 -0
  125. package/dist/client/assets/index-CNY7CTVa.css.gz +0 -0
  126. package/dist/client/assets/{infoDiagram-27XIBGKW-XjoFF4BC.js → infoDiagram-27XIBGKW-BT8xey7S.js} +1 -1
  127. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-bH299bWL.js → ishikawaDiagram-5VMMS53U-DunPdwW9.js} +1 -1
  128. package/dist/client/assets/ishikawaDiagram-5VMMS53U-DunPdwW9.js.br +0 -0
  129. package/dist/client/assets/ishikawaDiagram-5VMMS53U-DunPdwW9.js.gz +0 -0
  130. package/dist/client/assets/{journeyDiagram-3NMN7TZE-BG0u_X1A.js → journeyDiagram-3NMN7TZE-B0y75iIg.js} +1 -1
  131. package/dist/client/assets/journeyDiagram-3NMN7TZE-B0y75iIg.js.br +0 -0
  132. package/dist/client/assets/journeyDiagram-3NMN7TZE-B0y75iIg.js.gz +0 -0
  133. package/dist/client/assets/{kanban-definition-UXKFOSKX-DRoc9N-i.js → kanban-definition-UXKFOSKX-BfgA5WLo.js} +1 -1
  134. package/dist/client/assets/kanban-definition-UXKFOSKX-BfgA5WLo.js.br +0 -0
  135. package/dist/client/assets/kanban-definition-UXKFOSKX-BfgA5WLo.js.gz +0 -0
  136. package/dist/client/assets/{layout-mh0t6JpE.js → layout-BvjABLff.js} +1 -1
  137. package/dist/client/assets/layout-BvjABLff.js.br +0 -0
  138. package/dist/client/assets/layout-BvjABLff.js.gz +0 -0
  139. package/dist/client/assets/{linear-B9KTRuUV.js → linear-DgeFRliF.js} +1 -1
  140. package/dist/client/assets/linear-DgeFRliF.js.br +0 -0
  141. package/dist/client/assets/linear-DgeFRliF.js.gz +0 -0
  142. package/dist/client/assets/{mermaid.core-Bu2G9zhK.js → mermaid.core-DM6Rlal9.js} +5 -5
  143. package/dist/client/assets/mermaid.core-DM6Rlal9.js.br +0 -0
  144. package/dist/client/assets/mermaid.core-DM6Rlal9.js.gz +0 -0
  145. package/dist/client/assets/{mindmap-definition-YA3MSWOX-Go6Bg5xm.js → mindmap-definition-YA3MSWOX-DhEiABv6.js} +1 -1
  146. package/dist/client/assets/mindmap-definition-YA3MSWOX-DhEiABv6.js.br +0 -0
  147. package/dist/client/assets/mindmap-definition-YA3MSWOX-DhEiABv6.js.gz +0 -0
  148. package/dist/client/assets/{passwordBootstrap-C7-MUAHQ.js → passwordBootstrap-Dxv0I4wM.js} +1 -1
  149. package/dist/client/assets/passwordBootstrap-Dxv0I4wM.js.br +0 -0
  150. package/dist/client/assets/passwordBootstrap-Dxv0I4wM.js.gz +0 -0
  151. package/dist/client/assets/{pegDiagram-XKGWAZYB-DKUIl_U6.js → pegDiagram-XKGWAZYB-LTlVaJfm.js} +1 -1
  152. package/dist/client/assets/pegDiagram-XKGWAZYB-LTlVaJfm.js.br +0 -0
  153. package/dist/client/assets/pegDiagram-XKGWAZYB-LTlVaJfm.js.gz +0 -0
  154. package/dist/client/assets/{pieDiagram-E7YTZNPT-aoDNlV7J.js → pieDiagram-E7YTZNPT-9bnryna3.js} +1 -1
  155. package/dist/client/assets/pieDiagram-E7YTZNPT-9bnryna3.js.br +0 -0
  156. package/dist/client/assets/pieDiagram-E7YTZNPT-9bnryna3.js.gz +0 -0
  157. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-BKuuaF2s.js → quadrantDiagram-AXDQQJYC-ZBmgIpsJ.js} +1 -1
  158. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-BKuuaF2s.js.br → quadrantDiagram-AXDQQJYC-ZBmgIpsJ.js.br} +0 -0
  159. package/dist/client/assets/quadrantDiagram-AXDQQJYC-ZBmgIpsJ.js.gz +0 -0
  160. package/dist/client/assets/{railroadDiagram-O6MQD6OU-BwfCW2bp.js → railroadDiagram-O6MQD6OU-DTtXvKOu.js} +1 -1
  161. package/dist/client/assets/railroadDiagram-O6MQD6OU-DTtXvKOu.js.br +0 -0
  162. package/dist/client/assets/railroadDiagram-O6MQD6OU-DTtXvKOu.js.gz +0 -0
  163. package/dist/client/assets/rdpSession-Ggo3N5s5.js +1 -0
  164. package/dist/client/assets/rdpSession-Ggo3N5s5.js.br +0 -0
  165. package/dist/client/assets/rdpSession-Ggo3N5s5.js.gz +0 -0
  166. package/dist/client/assets/referenceLongPress-Df8W2cyP.js +1 -0
  167. package/dist/client/assets/referenceLongPress-Df8W2cyP.js.br +0 -0
  168. package/dist/client/assets/referenceLongPress-Df8W2cyP.js.gz +0 -0
  169. package/dist/client/assets/{requirementDiagram-BXWQKSXE-DbpU9Uig.js → requirementDiagram-BXWQKSXE-BNia9zI0.js} +1 -1
  170. package/dist/client/assets/requirementDiagram-BXWQKSXE-BNia9zI0.js.br +0 -0
  171. package/dist/client/assets/requirementDiagram-BXWQKSXE-BNia9zI0.js.gz +0 -0
  172. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-Bxa22XVM.js → sankeyDiagram-P5KCCOFB-uvg5npfK.js} +1 -1
  173. package/dist/client/assets/sankeyDiagram-P5KCCOFB-uvg5npfK.js.br +0 -0
  174. package/dist/client/assets/sankeyDiagram-P5KCCOFB-uvg5npfK.js.gz +0 -0
  175. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-C4GvzT9z.js → sequenceDiagram-WJ2MYXX4-DpJNf2MD.js} +1 -1
  176. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DpJNf2MD.js.br +0 -0
  177. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DpJNf2MD.js.gz +0 -0
  178. package/dist/client/assets/{sizeCapture-INFHLROL-B9zJJwQw.js → sizeCapture-INFHLROL-CkWB2AnF.js} +1 -1
  179. package/dist/client/assets/sizeCapture-INFHLROL-CkWB2AnF.js.br +0 -0
  180. package/dist/client/assets/sizeCapture-INFHLROL-CkWB2AnF.js.gz +0 -0
  181. package/dist/client/assets/{sparkles-BJbfT-v-.js → sparkles-DOuEtn62.js} +1 -1
  182. package/dist/client/assets/{stateDiagram-D77RDMKH-fqbw6LZa.js → stateDiagram-D77RDMKH-CeMzMQq-.js} +1 -1
  183. package/dist/client/assets/stateDiagram-D77RDMKH-CeMzMQq-.js.br +0 -0
  184. package/dist/client/assets/stateDiagram-D77RDMKH-CeMzMQq-.js.gz +0 -0
  185. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CNYUpLxt.js +1 -0
  186. package/dist/client/assets/{swimlanes-42K2YHIH-Hpc28YZY.js → swimlanes-42K2YHIH-Bo9GejWo.js} +1 -1
  187. package/dist/client/assets/swimlanes-42K2YHIH-Bo9GejWo.js.br +0 -0
  188. package/dist/client/assets/swimlanes-42K2YHIH-Bo9GejWo.js.gz +0 -0
  189. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-EB7zBRFR.js +8 -0
  190. package/dist/client/assets/{timeline-definition-24CTP7MA-qDieK7Re.js → timeline-definition-24CTP7MA-cvWXYEZ4.js} +1 -1
  191. package/dist/client/assets/timeline-definition-24CTP7MA-cvWXYEZ4.js.br +0 -0
  192. package/dist/client/assets/timeline-definition-24CTP7MA-cvWXYEZ4.js.gz +0 -0
  193. package/dist/client/assets/{triangle-alert-YOCAWhtT.js → triangle-alert-DzV0gQXz.js} +1 -1
  194. package/dist/client/assets/{vennDiagram-4TSXK5OY-BJpZlHao.js → vennDiagram-4TSXK5OY-CzleWcmk.js} +1 -1
  195. package/dist/client/assets/{vennDiagram-4TSXK5OY-BJpZlHao.js.br → vennDiagram-4TSXK5OY-CzleWcmk.js.br} +0 -0
  196. package/dist/client/assets/vennDiagram-4TSXK5OY-CzleWcmk.js.gz +0 -0
  197. package/dist/client/assets/{videoCompression-DI9vP0dm.js → videoCompression-DCnzjEfU.js} +1 -1
  198. package/dist/client/assets/videoCompression-DCnzjEfU.js.br +0 -0
  199. package/dist/client/assets/videoCompression-DCnzjEfU.js.gz +0 -0
  200. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-CQJfj6Ns.js → wardleyDiagram-VM6X3IG4-Cir1iutR.js} +1 -1
  201. package/dist/client/assets/wardleyDiagram-VM6X3IG4-Cir1iutR.js.br +0 -0
  202. package/dist/client/assets/wardleyDiagram-VM6X3IG4-Cir1iutR.js.gz +0 -0
  203. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-Cy-lkWBX.js → xychartDiagram-S5SC5T6Z-pNPcVJ1C.js} +1 -1
  204. package/dist/client/assets/xychartDiagram-S5SC5T6Z-pNPcVJ1C.js.br +0 -0
  205. package/dist/client/assets/xychartDiagram-S5SC5T6Z-pNPcVJ1C.js.gz +0 -0
  206. package/dist/client/index.html +2 -2
  207. package/dist/client/index.html.br +0 -0
  208. package/dist/client/index.html.gz +0 -0
  209. package/dist/client/sw.js +1 -1
  210. package/dist/client/sw.js.br +0 -0
  211. package/dist/client/sw.js.gz +0 -0
  212. package/dist/server/agent/collaborationCli.js +56 -10
  213. package/dist/server/agent/collaborationGroupRoutes.js +10 -5
  214. package/dist/server/agent/collaborationLaunchProfiles.js +43 -0
  215. package/dist/server/agent/collaborationRoutes.js +6 -2
  216. package/dist/server/agent/collaborationService.js +8 -2
  217. package/dist/server/agent/collaborationStore.js +32 -1
  218. package/dist/server/agent/collaborationTaskCli.js +11 -3
  219. package/dist/server/agent/collaborationTaskService.js +16 -10
  220. package/dist/server/agent/collaborationTaskStore.js +70 -25
  221. package/dist/server/agent/collaborationTeam.js +3 -3
  222. package/dist/server/agent/integrationCli.js +243 -0
  223. package/dist/server/agent/integrationServer.js +331 -0
  224. package/dist/server/agent/integrationSessions.js +344 -0
  225. package/dist/server/agent/integrationStore.js +222 -0
  226. package/dist/server/cli.js +29 -0
  227. package/dist/server/entry.js +26 -7
  228. package/dist/server/routes/filesystem.js +120 -87
  229. package/dist/server/routes/terminal.js +196 -13
  230. package/dist/server/utils/localAccess.js +27 -7
  231. package/dist/server/utils/sessionDisplayName.js +53 -0
  232. package/docs/integrations.md +304 -0
  233. package/package.json +3 -2
  234. package/runtime-manifest.json +3 -3
  235. package/dist/client/assets/App-DzuUkEI_.js +0 -179
  236. package/dist/client/assets/App-DzuUkEI_.js.br +0 -0
  237. package/dist/client/assets/App-DzuUkEI_.js.gz +0 -0
  238. package/dist/client/assets/ArchitecturePanel-QodxiiCc.js +0 -7
  239. package/dist/client/assets/ArchitecturePanel-QodxiiCc.js.br +0 -0
  240. package/dist/client/assets/ArchitecturePanel-QodxiiCc.js.gz +0 -0
  241. package/dist/client/assets/ChangeWalkthroughPanel-2lXfrgk4.js.br +0 -0
  242. package/dist/client/assets/ChangeWalkthroughPanel-2lXfrgk4.js.gz +0 -0
  243. package/dist/client/assets/CollaborationMainWorkspace-05-Py9N8.js +0 -1
  244. package/dist/client/assets/CollaborationMainWorkspace-05-Py9N8.js.br +0 -0
  245. package/dist/client/assets/CollaborationMainWorkspace-05-Py9N8.js.gz +0 -0
  246. package/dist/client/assets/CollaborationTaskContent-BJe9TUtZ.js +0 -2
  247. package/dist/client/assets/ComputerControlView-B5vigCoW.js +0 -5
  248. package/dist/client/assets/ComputerControlView-B5vigCoW.js.br +0 -0
  249. package/dist/client/assets/ComputerControlView-B5vigCoW.js.gz +0 -0
  250. package/dist/client/assets/DagPlayground-EFUb9S3u.js.br +0 -0
  251. package/dist/client/assets/DagPlayground-EFUb9S3u.js.gz +0 -0
  252. package/dist/client/assets/DiffLab-CXWjSE2q.js.br +0 -0
  253. package/dist/client/assets/DiffLab-CXWjSE2q.js.gz +0 -0
  254. package/dist/client/assets/DiffReview-ByMkBaD9.js.br +0 -0
  255. package/dist/client/assets/DiffReview-ByMkBaD9.js.gz +0 -0
  256. package/dist/client/assets/DiffReviewLab-DoWaKm94.js.br +0 -0
  257. package/dist/client/assets/DiffReviewLab-DoWaKm94.js.gz +0 -0
  258. package/dist/client/assets/DiffViewer-B4hn9z0k.js.br +0 -0
  259. package/dist/client/assets/DiffViewer-B4hn9z0k.js.gz +0 -0
  260. package/dist/client/assets/ModelPreview-C-LJZ8so.js.br +0 -0
  261. package/dist/client/assets/ModelPreview-C-LJZ8so.js.gz +0 -0
  262. package/dist/client/assets/RightSidebar-EaMm4prW.js +0 -1678
  263. package/dist/client/assets/RightSidebar-EaMm4prW.js.br +0 -0
  264. package/dist/client/assets/RightSidebar-EaMm4prW.js.gz +0 -0
  265. package/dist/client/assets/abnfDiagram-VCTEODGH-BY-pfYKk.js.br +0 -0
  266. package/dist/client/assets/abnfDiagram-VCTEODGH-BY-pfYKk.js.gz +0 -0
  267. package/dist/client/assets/app-Ch0UDtJ-.js +0 -35
  268. package/dist/client/assets/app-Ch0UDtJ-.js.br +0 -0
  269. package/dist/client/assets/app-Ch0UDtJ-.js.gz +0 -0
  270. package/dist/client/assets/arc-DIENgCZn.js.br +0 -0
  271. package/dist/client/assets/arc-DIENgCZn.js.gz +0 -0
  272. package/dist/client/assets/architectureDiagram-5GKGNRK7-C1h4e4az.js.br +0 -0
  273. package/dist/client/assets/architectureDiagram-5GKGNRK7-C1h4e4az.js.gz +0 -0
  274. package/dist/client/assets/blockDiagram-I7D4REHJ-B_yOr54K.js.br +0 -0
  275. package/dist/client/assets/blockDiagram-I7D4REHJ-B_yOr54K.js.gz +0 -0
  276. package/dist/client/assets/c4Diagram-7LVT6UL2-DRD4zxIo.js.br +0 -0
  277. package/dist/client/assets/c4Diagram-7LVT6UL2-DRD4zxIo.js.gz +0 -0
  278. package/dist/client/assets/channel-MOXuUKM7.js +0 -1
  279. package/dist/client/assets/chunk-F27PBJKO-CQCL8mJG.js.br +0 -0
  280. package/dist/client/assets/chunk-F27PBJKO-CQCL8mJG.js.gz +0 -0
  281. package/dist/client/assets/chunk-IMKFNOWR-ruHGCADe.js.br +0 -0
  282. package/dist/client/assets/chunk-IMKFNOWR-ruHGCADe.js.gz +0 -0
  283. package/dist/client/assets/chunk-SVP7TREG-DMHj3NSq.js.br +0 -0
  284. package/dist/client/assets/chunk-SVP7TREG-DMHj3NSq.js.gz +0 -0
  285. package/dist/client/assets/chunk-TICWLB2K-Dh_ekvFW.js.br +0 -0
  286. package/dist/client/assets/chunk-TICWLB2K-Dh_ekvFW.js.gz +0 -0
  287. package/dist/client/assets/classDiagram-ZZMXUADV-CEXMdudw.js +0 -1
  288. package/dist/client/assets/classDiagram-v2-VYDZK3BY-CEXMdudw.js +0 -1
  289. package/dist/client/assets/cose-bilkent-JH36ORCC-CsySWhYg.js.br +0 -0
  290. package/dist/client/assets/cose-bilkent-JH36ORCC-CsySWhYg.js.gz +0 -0
  291. package/dist/client/assets/cynefin-OW5HDTMX-9DKE5wV7.js.br +0 -0
  292. package/dist/client/assets/cynefin-OW5HDTMX-9DKE5wV7.js.gz +0 -0
  293. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-B_8fvr9c.js.br +0 -0
  294. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-B_8fvr9c.js.gz +0 -0
  295. package/dist/client/assets/dagre-GXQ25YYZ-BOdsFNFT.js.br +0 -0
  296. package/dist/client/assets/dagre-GXQ25YYZ-BOdsFNFT.js.gz +0 -0
  297. package/dist/client/assets/diagram-S7CK7UJ4-6v_qvAvi.js.br +0 -0
  298. package/dist/client/assets/diagram-S7CK7UJ4-6v_qvAvi.js.gz +0 -0
  299. package/dist/client/assets/diagram-UQ7AKVKN-c03oOGhD.js.br +0 -0
  300. package/dist/client/assets/diagram-UQ7AKVKN-c03oOGhD.js.gz +0 -0
  301. package/dist/client/assets/diagram-VSXAHHWV-MMIhRYp_.js.br +0 -0
  302. package/dist/client/assets/diagram-VSXAHHWV-MMIhRYp_.js.gz +0 -0
  303. package/dist/client/assets/diagram-VX7I27RA-B_l-uebl.js.br +0 -0
  304. package/dist/client/assets/diagram-VX7I27RA-B_l-uebl.js.gz +0 -0
  305. package/dist/client/assets/diagram-Z3DM3KII-DKoBC5gn.js.br +0 -0
  306. package/dist/client/assets/diagram-Z3DM3KII-DKoBC5gn.js.gz +0 -0
  307. package/dist/client/assets/ebnfDiagram-PWID7BFC-Bs3wu8Az.js.br +0 -0
  308. package/dist/client/assets/ebnfDiagram-PWID7BFC-Bs3wu8Az.js.gz +0 -0
  309. package/dist/client/assets/erDiagram-RLTQ6QDP-mYnHYbKl.js.br +0 -0
  310. package/dist/client/assets/erDiagram-RLTQ6QDP-mYnHYbKl.js.gz +0 -0
  311. package/dist/client/assets/flowDiagram-HODETNUW-CwCLWbib.js.br +0 -0
  312. package/dist/client/assets/flowDiagram-HODETNUW-CwCLWbib.js.gz +0 -0
  313. package/dist/client/assets/ganttDiagram-EL5Y4UJY-mse8c-ni.js.br +0 -0
  314. package/dist/client/assets/ganttDiagram-EL5Y4UJY-mse8c-ni.js.gz +0 -0
  315. package/dist/client/assets/gestureArbiter-BviL29ps.js.br +0 -0
  316. package/dist/client/assets/gestureArbiter-BviL29ps.js.gz +0 -0
  317. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-BVUfLjAX.js.br +0 -0
  318. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-BVUfLjAX.js.gz +0 -0
  319. package/dist/client/assets/index-C6ftfFlG.css.br +0 -0
  320. package/dist/client/assets/index-C6ftfFlG.css.gz +0 -0
  321. package/dist/client/assets/ishikawaDiagram-5VMMS53U-bH299bWL.js.br +0 -0
  322. package/dist/client/assets/ishikawaDiagram-5VMMS53U-bH299bWL.js.gz +0 -0
  323. package/dist/client/assets/journeyDiagram-3NMN7TZE-BG0u_X1A.js.br +0 -0
  324. package/dist/client/assets/journeyDiagram-3NMN7TZE-BG0u_X1A.js.gz +0 -0
  325. package/dist/client/assets/kanban-definition-UXKFOSKX-DRoc9N-i.js.br +0 -0
  326. package/dist/client/assets/kanban-definition-UXKFOSKX-DRoc9N-i.js.gz +0 -0
  327. package/dist/client/assets/layout-mh0t6JpE.js.br +0 -0
  328. package/dist/client/assets/layout-mh0t6JpE.js.gz +0 -0
  329. package/dist/client/assets/linear-B9KTRuUV.js.br +0 -0
  330. package/dist/client/assets/linear-B9KTRuUV.js.gz +0 -0
  331. package/dist/client/assets/mermaid.core-Bu2G9zhK.js.br +0 -0
  332. package/dist/client/assets/mermaid.core-Bu2G9zhK.js.gz +0 -0
  333. package/dist/client/assets/mindmap-definition-YA3MSWOX-Go6Bg5xm.js.br +0 -0
  334. package/dist/client/assets/mindmap-definition-YA3MSWOX-Go6Bg5xm.js.gz +0 -0
  335. package/dist/client/assets/passwordBootstrap-C7-MUAHQ.js.br +0 -0
  336. package/dist/client/assets/passwordBootstrap-C7-MUAHQ.js.gz +0 -0
  337. package/dist/client/assets/pegDiagram-XKGWAZYB-DKUIl_U6.js.br +0 -0
  338. package/dist/client/assets/pegDiagram-XKGWAZYB-DKUIl_U6.js.gz +0 -0
  339. package/dist/client/assets/pieDiagram-E7YTZNPT-aoDNlV7J.js.br +0 -0
  340. package/dist/client/assets/pieDiagram-E7YTZNPT-aoDNlV7J.js.gz +0 -0
  341. package/dist/client/assets/quadrantDiagram-AXDQQJYC-BKuuaF2s.js.gz +0 -0
  342. package/dist/client/assets/railroadDiagram-O6MQD6OU-BwfCW2bp.js.br +0 -0
  343. package/dist/client/assets/railroadDiagram-O6MQD6OU-BwfCW2bp.js.gz +0 -0
  344. package/dist/client/assets/rdpSession--y6Q98uo.js +0 -1
  345. package/dist/client/assets/rdpSession--y6Q98uo.js.br +0 -0
  346. package/dist/client/assets/rdpSession--y6Q98uo.js.gz +0 -0
  347. package/dist/client/assets/referenceLongPress-BeG1PAdI.js +0 -1
  348. package/dist/client/assets/referenceLongPress-BeG1PAdI.js.br +0 -0
  349. package/dist/client/assets/referenceLongPress-BeG1PAdI.js.gz +0 -0
  350. package/dist/client/assets/requirementDiagram-BXWQKSXE-DbpU9Uig.js.br +0 -0
  351. package/dist/client/assets/requirementDiagram-BXWQKSXE-DbpU9Uig.js.gz +0 -0
  352. package/dist/client/assets/sankeyDiagram-P5KCCOFB-Bxa22XVM.js.br +0 -0
  353. package/dist/client/assets/sankeyDiagram-P5KCCOFB-Bxa22XVM.js.gz +0 -0
  354. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-C4GvzT9z.js.br +0 -0
  355. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-C4GvzT9z.js.gz +0 -0
  356. package/dist/client/assets/sizeCapture-INFHLROL-B9zJJwQw.js.br +0 -0
  357. package/dist/client/assets/sizeCapture-INFHLROL-B9zJJwQw.js.gz +0 -0
  358. package/dist/client/assets/stateDiagram-D77RDMKH-fqbw6LZa.js.br +0 -0
  359. package/dist/client/assets/stateDiagram-D77RDMKH-fqbw6LZa.js.gz +0 -0
  360. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-BO23Pbrn.js +0 -1
  361. package/dist/client/assets/swimlanes-42K2YHIH-Hpc28YZY.js.br +0 -0
  362. package/dist/client/assets/swimlanes-42K2YHIH-Hpc28YZY.js.gz +0 -0
  363. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-BLS7y4Di.js +0 -8
  364. package/dist/client/assets/timeline-definition-24CTP7MA-qDieK7Re.js.br +0 -0
  365. package/dist/client/assets/timeline-definition-24CTP7MA-qDieK7Re.js.gz +0 -0
  366. package/dist/client/assets/vennDiagram-4TSXK5OY-BJpZlHao.js.gz +0 -0
  367. package/dist/client/assets/videoCompression-DI9vP0dm.js.br +0 -0
  368. package/dist/client/assets/videoCompression-DI9vP0dm.js.gz +0 -0
  369. package/dist/client/assets/wardleyDiagram-VM6X3IG4-CQJfj6Ns.js.br +0 -0
  370. package/dist/client/assets/wardleyDiagram-VM6X3IG4-CQJfj6Ns.js.gz +0 -0
  371. package/dist/client/assets/xychartDiagram-S5SC5T6Z-Cy-lkWBX.js.br +0 -0
  372. package/dist/client/assets/xychartDiagram-S5SC5T6Z-Cy-lkWBX.js.gz +0 -0
@@ -1,1678 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-Bu2G9zhK.js","assets/app-Ch0UDtJ-.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-C6ftfFlG.css","assets/purify.es-4eNOHKSq.js","assets/ModelPreview-C-LJZ8so.js","assets/App-DzuUkEI_.js","assets/gestureArbiter-BviL29ps.js","assets/gestureArbiter-C2J0D0kV.css","assets/triangle-alert-YOCAWhtT.js","assets/referenceLongPress-BeG1PAdI.js","assets/DiffReview-ByMkBaD9.js","assets/sparkles-BJbfT-v-.js","assets/DiffViewer-B4hn9z0k.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-2lXfrgk4.js","assets/ArchitecturePanel-QodxiiCc.js","assets/ArchitecturePanel-Cmpmp6FS.css","assets/ComputerControlView-B5vigCoW.js","assets/katex-55ZPZeOF.css"])))=>i.map(i=>d[i]);
2
- import{ae as yr,da as mt,bx as e,h as yo,ct as Td,ao as Fu,_ as Cn,bF as _u,L as ft,e as cs,X as Ft,dg as J,dm as Dt,bS as gt,a as Zs,b0 as Bu,C as ko,d as ea,d6 as mo,bi as Em,O as Bs,ay as Mm,bp as $m,br as Ml,bs as Pm,bt as Ou,bq as Os,aN as Lm,E as Am,k as Tm,bm as Im,bU as Dm,bW as Fm,bX as _m,bd as Bm,bV as Id,N as Nt,g as Om,j as Bi,I as Um,b as Hm,d8 as Oi,bc as Dd,aI as Fd,aE as zm,aR as Ui,aS as _d,dn as Ys,au as Us,aT as Wm,d7 as eo,bL as Gm,cT as Bd,aL as Km,d4 as qm,co as Vm,dh as to,aW as Ym,a1 as Od,a0 as Xm,aF as Ud,aK as Jm,aP as Hd,cq as Qm,y as zd,r as Wd,l as Zm,J as Uu,as as Hu,cg as ep,dk as tp,n as rp}from"./app-Ch0UDtJ-.js";import{b as a,r as kr}from"./dnd-BCFAPC0L.js";import{f as $l,F as np,Z as sp,a0 as ap,x as zu,r as op,y as Gd,I as po,j as ip,V as lp,q as cp,v as dp,m as up,M as fp,R as go,J as Wu,O as hp,S as ds,D as Gu,d as mp,a6 as Ku,A as Hi,a3 as pp,a1 as Rn,Q as gp,X as bp,a2 as xp,a4 as vp,_ as Kd,T as qd,H as Vd,h as Yd,u as zi,t as ro,e as wp,z as yp,s as kp,l as Sp,B as jp,N as Rp,k as Xd,C as Np,a as Cp,G as Ep,c as Mp}from"./App-DzuUkEI_.js";import{F as ll,a as Jd,S as Qd,b as qu,c as cl}from"./gestureArbiter-BviL29ps.js";import{D as dl,C as Xs,L as Vu,f as $p,n as Pp}from"./DiffReview-ByMkBaD9.js";import{T as Lp,L as So,M as Yu,G as xr}from"./triangle-alert-YOCAWhtT.js";import{S as ta}from"./sparkles-BJbfT-v-.js";import{C as Xu,M as Ju}from"./ChangeWalkthroughPanel-2lXfrgk4.js";import{r as Qu,s as Zu,l as ef,a as Zd,h as ul,u as Ap,g as fl,b as tf}from"./DiffViewer-B4hn9z0k.js";import{u as rf,G as nf}from"./referenceLongPress-BeG1PAdI.js";const Tp=[["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"}]],Ip=yr("case-sensitive",Tp);const Dp=[["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"}]],Fp=yr("eye-off",Dp);const _p=[["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"}]],hl=yr("eye",_p);const Bp=[["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"}]],ml=yr("file-text",Bp);const Op=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Up=yr("funnel",Op);const Hp=[["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"}]],zp=yr("image-plus",Hp);const Wp=[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]],Gp=yr("regex",Wp);const Kp=[["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"}]],qp=yr("scan",Kp);const Vp=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Yp=yr("upload",Vp);const Xp=[["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"}]],Jp=yr("whole-word",Xp),Qp=100,Zp=5e5,eg=1e4,eu=16384,tg=32,rg=1e5;class as extends Error{constructor(n){super(`Markdown preview parsing stopped: ${n}`),this.reason=n,this.name="MarkdownParseError"}reason}class ng{startedAt=performance.now();operations=0;depth=0;check(){if(++this.operations>rg)throw new as("complexity");if(performance.now()-this.startedAt>=Qp)throw new as("timeout")}validateLines(n){if(n.length>eg)throw new as("size");let s=0;for(const l of n)if(this.check(),s+=l.length+1,s>Zp||l.length>eu)throw new as("size")}validateInline(n){if(this.check(),n.length>eu)throw new as("size")}nested(n){if(this.check(),this.depth>=tg)throw new as("depth");this.depth+=1;try{return n()}finally{this.depth-=1}}}const tu=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 sg(r,n,s){let l=n;for(;r[l]==="`";)l+=1;const u=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===u)return c}return null}function*ag(r,n){n.validateInline(r);const s=new RegExp(tu.source,tu.flags);let l=0;for(;l<r.length;){if(n.check(),r[l]==="`"){const c=sg(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 u=s.exec(r);n.check(),u?(yield{index:l,token:u[0]},l=s.lastIndex):l+=(r.codePointAt(l)??0)>65535?2:1}}function ru({children:r,actions:n}){const{t:s}=mt(),[l,u]=a.useState(!1),c=a.useId(),m=a.useRef(null),g=a.useRef(null),h=()=>{u(!1),m.current?.focus({preventScroll:!0})};return a.useLayoutEffect(()=>{if(!l)return;const p=m.current,b=g.current;if(!p||!b)return;const f=window.visualViewport,x=()=>{const P=p.getBoundingClientRect(),D=(f?.offsetLeft??0)+8,_=(f?.offsetTop??0)+8,U=Math.max(0,(f?.width??window.innerWidth)-16),C=_+(f?.height??window.innerHeight)-16,N=Math.min(240,U),E=Math.max(0,P.top-_-6),B=Math.max(0,C-P.bottom-6),q=b.scrollHeight>B&&E>B;Object.assign(b.style,{width:`${N}px`,left:`${Math.max(D,Math.min(P.right-N,D+U-N))}px`,top:`${q?P.top-6:P.bottom+6}px`,maxHeight:`${q?E:B}px`,transform:q?"translateY(-100%)":"none"})};x();const $=typeof ResizeObserver>"u"?null:new ResizeObserver(x);return $?.observe(p),$?.observe(b),window.addEventListener("resize",x),window.addEventListener("scroll",x,!0),f?.addEventListener("resize",x),f?.addEventListener("scroll",x),()=>{$?.disconnect(),window.removeEventListener("resize",x),window.removeEventListener("scroll",x,!0),f?.removeEventListener("resize",x),f?.removeEventListener("scroll",x)}},[l]),a.useEffect(()=>{if(!l)return;g.current?.querySelector("button:not(:disabled)")?.focus({preventScroll:!0});const p=b=>{b.target instanceof Node&&!m.current?.contains(b.target)&&!g.current?.contains(b.target)&&u(!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:()=>u(p=>!p),onKeyDown:p=>{(p.key==="ArrowDown"||p.key==="ArrowUp")&&(p.preventDefault(),u(!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(yo,{size:14}),s("sidebar.moreActions")]})]}),typeof document<"u"&&kr.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 b=[...p.currentTarget.querySelectorAll("button:not(:disabled)")],f=b.indexOf(document.activeElement);let x;if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),h();return}if(p.key==="Tab"){h();return}if(p.key==="ArrowDown")x=(f+1)%b.length;else if(p.key==="ArrowUp")x=(f-1+b.length)%b.length;else if(p.key==="Home")x=0;else if(p.key==="End")x=b.length-1;else return;p.preventDefault(),b[x]?.focus({preventScroll:!0})},children:n(h)}),document.body)]})}const Wi="a[href],button,input,select,textarea,[tabindex],[contenteditable],iframe,summary,audio[controls],video[controls]",os=a.memo(function({active:n,mounted:s=!0,fallback:l=null,children:u}){const c=a.useRef(null);return a.useLayoutEffect(()=>{const m=c.current;if(!m||n)return;const g=new Map,h=f=>{g.has(f)||(g.set(f,f.inert),f.inert=!0)},p=f=>{f instanceof HTMLElement&&f.matches(Wi)&&h(f),f.querySelectorAll(Wi).forEach(h)};p(m);const b=new MutationObserver(f=>{for(const x of f)x.type==="attributes"?x.target instanceof HTMLElement&&x.target.matches(Wi)&&h(x.target):x.addedNodes.forEach($=>{$ instanceof Element&&p($)})});return b.observe(m,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex","href","contenteditable","controls"]}),()=>{b.disconnect();for(const[f,x]of g)f.inert=x}},[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 u=="function"?u():u:l})},(r,n)=>!r.active&&!n.active&&r.mounted===n.mounted);async function og(r){let n;try{await Promise.race([r(),new Promise(s=>{n=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(n)}}function ig({active:r,rootPath:n,loading:s,delay:l,lastStartedRoot:u,load:c}){a.useEffect(()=>{if(!r||!n||s||u.current===n)return;const m=window.setTimeout(()=>{u.current=n,c(n)},l);return()=>window.clearTimeout(m)},[r,n,s,l,u,c])}async function lg(r){if(r.kind==="mermaid"){await Td(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 Fu(c);return}const s=await fetch(r.src);if(!s.ok)throw new Error(`HTTP ${s.status}`);const l=await s.blob(),u=decodeURIComponent(n.pathname.split("/").pop()||"")||`image.${{"image/svg+xml":"svg","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif"}[l.type]||"png"}`;await Td(l,u)}let no=null,nu=!1;function cg(){return no||(no=Cn(()=>import("./mermaid.core-Bu2G9zhK.js").then(r=>r.bl),__vite__mapDeps([0,1,2,3,4,5,6])).then(r=>r.default??r).catch(r=>{throw no=null,r})),no}function dg(r){nu||(r.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),nu=!0)}function ug({rootPath:r,paths:n,disabled:s,onChange:l}){const{t:u}=mt(),[c,m]=a.useState(""),[g,h]=a.useState(0),[p,b]=a.useState(null),[f,x]=a.useState(!1),[$,P]=a.useState(!1),D=`${r.replace(/[\\/]+$/,"")}/${c}`;a.useEffect(()=>{const N=new AbortController;return b(null),x(!1),_u(D,N.signal,!0,"pick_git_ignore_exception").then(E=>{N.signal.aborted||b({directory:c,entries:E.entries,truncated:!!E.truncated})}).catch(()=>{N.signal.aborted||x(!0)}),()=>N.abort()},[D,c,g]);const _=N=>{b(null),x(!1),m(N)},U=p?.directory===c,C=N=>{if(N.length>200){P(!0);return}P(!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:()=>_(c.slice(0,Math.max(0,c.lastIndexOf("/")))),"aria-label":u("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($l,{size:14})}),e.jsx("button",{type:"button",disabled:s||!c,onClick:()=>_(""),"aria-label":u("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(ll,{size:14})}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:D,children:c||"./"})]}),e.jsxs("div",{className:"h-56 overflow-y-auto overscroll-contain p-1",role:"group","aria-label":u("rightSidebar.gitIgnoreExceptionsPaths"),"aria-busy":!U&&!f,children:[f?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:u("rightSidebar.gitIgnoreExceptionsLoadFailed")}),e.jsx("button",{type:"button",disabled:s,onClick:()=>{x(!1),h(N=>N+1)},className:"rounded-md px-3 py-2 text-primary hover:bg-surface-elevated disabled:opacity-40",children:u("common.retry")})]}):U?p.entries.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-muted-foreground",children:u("rightSidebar.gitIgnoreExceptionsEmptyDirectory")}):p.entries.map(N=>{const E=c?`${c}/${N.name}`:N.name,B=E+(N.type==="directory"?"/":""),q=n.includes(B)||n.includes(E),S=n.some(F=>F.endsWith("/")&&E.startsWith(F)),o=N.type==="directory"?ll:np;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||S,disabled:s||S,onChange:()=>C(q?n.filter(F=>F!==B&&F!==E):[...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:()=>_(E),"aria-label":u("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(cs,{size:15})})]},N.name)}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(ft,{size:18})}),U&&p.truncated&&e.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:u("rightSidebar.gitIgnoreExceptionsTruncated")})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsx("span",{className:"font-medium",children:u("rightSidebar.gitIgnoreExceptionsSelected",{count:n.length})}),e.jsx("button",{type:"button",disabled:s||n.length===0,onClick:()=>C([]),className:"rounded-md px-2 py-1 text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",children:u("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:()=>C(n.filter(E=>E!==N)),"aria-label":u("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(Ft,{size:13})})]},N))}),$&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:u("rightSidebar.gitIgnoreExceptionsInvalid")})]})}function fg({rootPath:r,disabled:n,pressed:s,saving:l,onToggle:u}){const{t:c}=mt(),m=a.useId(),g=a.useRef(null),h=a.useRef(null),p=a.useRef(null),b=a.useRef(null),f=a.useRef(!1),[x,$]=a.useState(!1),[P,D]=a.useState([]),[_,U]=a.useState(!1),[C,N]=a.useState(null),E=J(I=>I.setGitIgnoreExceptions),B=()=>{p.current!==null&&clearTimeout(p.current),p.current=null,b.current=null},q=()=>{B(),!(n||_||!r)&&(D([...J.getState().gitIgnoreExceptions[r]??[]]),N(null),$(!0))},S=()=>{_||$(!1)},o=I=>{B(),f.current=!1,!(I.button!==0||!I.isPrimary||n)&&(I.currentTarget.setPointerCapture(I.pointerId),b.current={x:I.clientX,y:I.clientY},p.current=setTimeout(()=>{f.current=!0,q()},450))};a.useEffect(()=>($(!1),B(),B),[r]),a.useEffect(()=>{if(x)return h.current?.focus(),()=>g.current?.focus()},[x]);const F=c(s?"rightSidebar.showGitIgnoredFiles":"rightSidebar.hideGitIgnoredFiles");return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:g,type:"button",disabled:n||_,"aria-pressed":s,"aria-label":F,"aria-description":c("rightSidebar.gitIgnoreConfigureHint"),title:`${F} · ${c("rightSidebar.gitIgnoreConfigureHint")}`,onClick:I=>{if(f.current&&I.detail!==0){f.current=!1,I.preventDefault();return}u()},onContextMenu:I=>{I.preventDefault(),f.current=!0,x||q()},onPointerDown:o,onPointerMove:I=>{const V=b.current;V&&Math.hypot(I.clientX-V.x,I.clientY-V.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(Up,{size:14})}),x&&kr.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:S,children:e.jsxs("form",{ref:h,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(),S()),I.key==="Tab"){const V=Array.from(h.current?.querySelectorAll("button:not(:disabled), input:not(:disabled)")??[]);if(!V.length){I.preventDefault(),h.current?.focus();return}const G=V[0],H=V[V.length-1];I.shiftKey&&document.activeElement===G&&(I.preventDefault(),H?.focus()),document.activeElement===h.current?(I.preventDefault(),(I.shiftKey?H:G)?.focus()):!I.shiftKey&&document.activeElement===H&&(I.preventDefault(),G?.focus())}},onSubmit:I=>{if(I.preventDefault(),!(!r||_)){if(P.length>200){N(c("rightSidebar.gitIgnoreExceptionsInvalid"));return}U(!0),N(null),E(r,P).then(()=>$(!1)).catch(()=>N(c("rightSidebar.gitIgnoreExceptionsSaveFailed"))).finally(()=>U(!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:_,onClick:S,"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(Ft,{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(ug,{rootPath:r,paths:P,onChange:D,disabled:_}),C&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:C}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",disabled:_,onClick:S,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:_,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:[_&&e.jsx(ft,{size:13}),c("common.save")]})]})]})}),document.body)]})}function hg(r,n,s){try{const l=r instanceof HTMLImageElement?r.naturalWidth:r.width,u=r instanceof HTMLImageElement?r.naturalHeight:r.height;if(!l||!u)return Promise.resolve(null);const c=r instanceof HTMLImageElement?1400/Math.max(l,u):Math.min(1,1400/Math.max(l,u)),m=document.createElement("canvas");m.width=Math.max(1,Math.round(l*c)),m.height=Math.max(1,Math.round(u*c));const g=m.getContext("2d");if(!g)return Promise.resolve(null);const h=getComputedStyle(document.documentElement);if(g.fillStyle=h.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 b=[];let f="";for(const x of s.split(" "))f&&g.measureText(`${f} ${x}`).width>m.width-20?(b.push(f),f=x):f=f?`${f} ${x}`:x;f&&b.push(f),g.fillStyle=h.getPropertyValue("--surface").trim()||"white",g.fillRect(0,0,m.width,b.length*(p+4)+12),g.fillStyle=h.getPropertyValue("--foreground").trim()||"black",b.forEach((x,$)=>g.fillText(x,10,8+p+$*(p+4)))}if(n){const p=n.xPercent*m.width/100,b=n.yPercent*m.height/100,f=Math.max(4,Math.min(12,Math.min(m.width,m.height)*.015)),x=f*1.6;g.strokeStyle=h.getPropertyValue("--primary").trim()||"black",g.lineWidth=Math.max(1,f/3),g.beginPath(),g.arc(p,b,f,0,Math.PI*2),g.stroke(),g.beginPath(),g.moveTo(p-x,b),g.lineTo(p+x,b),g.moveTo(p,b-x),g.lineTo(p,b+x),g.stroke()}return new Promise(p=>m.toBlob(p,"image/png"))}catch{return Promise.resolve(null)}}function mg(r,n,s,l){return[r.trim(),n.trim(),l?`截图:${l}`:""].filter(Boolean).join(`
3
- `)}function g0(r,n,s){const l=n*Math.PI/360,u=Math.min(l,Math.atan(Math.tan(l)*Math.max(s,.05)));return Math.max(r,1e-6)/Math.sin(u)*1.15}async function pg(r,n,s,l){if(!s?.snapshot)return l.isCurrent()?await l.insert(r,n):!1;const u=new Date().toISOString(),c=new AbortController;let m,g;try{g=await Promise.race([(async()=>{const h=await s.snapshot;if(!(!h||c.signal.aborted||!l.isCurrent()))return l.upload(new File([h],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),c.signal)})(),new Promise(h=>{m=setTimeout(()=>{c.abort(),h(void 0)},3e3)})])}catch{}finally{clearTimeout(m),c.abort()}return l.isCurrent()?await l.insert(g?mg(r,"",u,g):r,n):!1}function gg(r,n,s,l){if(!r||!n||!s())return Promise.resolve(!1);const u=l?sp(l,n,r):null;if(l&&!u)return Promise.resolve(!1);const c=u?.nonce??`reference-${crypto.randomUUID()}`;return new Promise(m=>{let g=!1;const h=f=>{g||(g=!0,window.clearTimeout(b),window.removeEventListener("termdock-insert-reference-ack",p),u&&ap(c),m(f&&s()))},p=f=>{const x=f.detail;x?.nonce===c&&h(x.ok===!0)},b=window.setTimeout(()=>h(!1),1500);window.addEventListener("termdock-insert-reference-ack",p),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:u??{text:r,sessionId:n,nonce:c,focus:!1,paste:!0,submitAfterPaste:!1}}))})}function bg(r,n){return r===n||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function su(r,n){return`${r??""}\0${n}`}function xg(r,n,s){if(!r||r.length===0||!s)return{explained:0,stale:0};const l=su(n,s);let u=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=>su(m.repoRoot,p)===l)||g.some(p=>bg(p,s)))&&(u+=1)}return{explained:u,stale:c}}function vg({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(Lp,{size:10}):e.jsx(ta,{size:10})})}function pl({changeStatus:r,auditStatus:n,renderChangeBadge:s}){return e.jsxs("span",{className:"inline-flex items-center gap-1",children:[s(r),e.jsx(vg,{status:n})]})}const sf="termdock:right-sidebar:diff-change-list-mode:v1";function wg(r){return r==="list"||r==="tree"}function yg(){return gt(sf,wg)??"tree"}function kg(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 Sg(r){const n=new Map;for(const l of r){const u=n.get(l.hunk.filePath)??{key:l.hunk.filePath,filePath:l.hunk.filePath,items:[],additions:0,deletions:0,explained:0,stale:0,changeType:"modified"};u.items.push(l),u.additions+=l.hunk.additions,u.deletions+=l.hunk.deletions,l.current&&(u.explained+=1),l.stale&&(u.stale+=1),n.set(l.hunk.filePath,u)}const s=Array.from(n.values()).sort((l,u)=>l.filePath.localeCompare(u.filePath));for(const l of s)l.changeType=kg(l.items);return s}function jg(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 Rg(r,n){const s=r.filter(c=>c.trim().length>0);if(s.length<=1)return s[0]??"";const l=[],u=new Set;for(const[c,m]of s.entries()){const g=m.split(`
4
- `),h=g.findIndex(f=>f.startsWith("@@ "));if(h<0){l.push(...g);continue}c===0&&l.push(...g.slice(0,h));const p=n[c];let b=h;for(;b>=0&&b<g.length;){const f=g.findIndex((U,C)=>C>b&&U.startsWith("@@ ")),x=f>=0?f:g.length,$=g.slice(b,x),P=$[0]??"",D=p?P===p:!0,_=P||p||$.join(`
5
- `);D&&!u.has(_)&&(l.push(...$),u.add(_)),b=f}}return l.join(`
6
- `)}function Ng({groups:r,onInsertDiffReference:n}){return r.map(s=>{const l=Rg(s.items.map(h=>h.hunk.diff||h.current?.diff||h.stale?.diff||""),s.items.map(h=>h.hunk.hunkHeader)),u=s.items.map(h=>h.current??h.stale).filter(h=>!!h).map(h=>({id:h.id,repoRoot:h.repoRoot,filePath:h.filePath,oldPath:h.oldPath,newPath:h.newPath,hunkHeader:h.hunkHeader,hunkIndex:h.hunkIndex,fingerprint:h.fingerprint,diff:h.diff,explanation:h.explanation,summary:h.summary,workspaceRoot:h.workspaceRoot,generatedBy:h.generatedBy,injectedAt:h.injectedAt})),c=s.filePath.split("/").pop()??s.filePath,m=s.filePath.includes("/")?s.filePath.slice(0,-c.length-1):"",g=s.items[0]?.repoRoot??u[0]?.repoRoot??null;return{key:s.key,path:s.filePath,oldPath:s.items[0]?.hunk.oldPath??void 0,absolutePath:g?`${g}/${s.items[0]?.repositoryPath??s.filePath}`:s.filePath,status:s.changeType,repoRoot:g,displayName:c,displayDir:m,diffOverride:l,oldSourceRef:s.items[0]?.current?.headRef?`${s.items[0].current.baseRef}...${s.items[0].current.headRef}`:s.items[0]?.stale?.headRef?`${s.items[0].stale.baseRef}...${s.items[0].stale.headRef}`:void 0,previewReverts:Object.fromEntries(s.items.flatMap(h=>h.hunk.previewRevert?[[h.hunk.hunkHeader,h.hunk.previewRevert]]:[])),auditRecords:u,onInsertDiffReference:n}})}function Cg(r,n,s){const l=Array.from(r.querySelectorAll("[data-diff-stream-item]"));if(l.length===0)return null;const c=r.getBoundingClientRect().top+48;let m=null,g=Number.POSITIVE_INFINITY;for(const p of l){const b=p.getBoundingClientRect();if(b.bottom<c)continue;const f=Math.abs(b.top-c);f<g&&(m=p,g=f)}const h=m?.dataset.diffSelectionPath??m?.dataset.diffStreamItem??null;return!h||h===n||s(h),h}function au({items:r,selectedKey:n,onSelect:s,emptyText:l,mobile:u=!1,backLabel:c="Back",headerTitle:m,headerMeta:g,onClose:h,closeLabel:p="Back",wrap:b=!0,diffViewType:f,inlineMode:x,viewControls:$,onToggleWrap:P,wrapTitle:D,wrapOnLabel:_="Wrap on",wrapOffLabel:U="Wrap off",desktopLayout:C="split",onInsertDiffReference:N,onReferenceCopied:E,renderPathReference:B,insertedReferenceKey:q,copiedReferenceKey:S,onClearAuditRecord:o,onRefresh:F,localOptions:I,onHunkGitAction:V,error:G,refreshing:H,actionsBusy:R,refreshLabel:z,refreshTitle:Y,walkthroughs:A=[],onWalkthroughNavigate:O,initialDetailScrollTop:Q,onDetailScrollPositionChange:ce,scrollToKey:me,scrollToKeyNonce:je,externalSwiperRef:$e,onMobileSlideChange:Ce}){const{t:T}=mt(),ee=a.useMemo(()=>Sg(r),[r]),te=a.useMemo(()=>new Map(ee.map(le=>[le.key,le])),[ee]),[Le,De]=a.useState(()=>yg()),[Te,lt]=a.useState(()=>new Set),[Ie,we]=a.useState({key:null,nonce:0}),L=ee.find(le=>le.explained>0||le.stale>0)?.key??ee[0]?.key??null,ne=n&&ee.some(le=>le.key===n)?n:L,Re=a.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:ee.map(jg)}],[ee]),ve=a.useMemo(()=>Ng({groups:ee,onInsertDiffReference:N}),[ee,N]),Be=a.useRef(L),fe=a.useRef(s);Be.current=L,fe.current=s,a.useEffect(()=>{!n&&Be.current&&fe.current(Be.current)},[n]);const Ye=P?e.jsxs("button",{type:"button",onClick:P,"aria-pressed":b,title:D,className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 text-[11px] font-medium transition active:scale-95 ${b?"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:b?_:U})]}):null,Fe=I?.map(le=>e.jsxs("label",{title:le.disabled?T("rightSidebar.includeUncommittedCurrentBranchOnly"):le.key,className:"inline-flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx("input",{type:"checkbox",checked:le.checked,disabled:H||R||le.disabled&&!le.checked,onChange:Ee=>le.onChange(Ee.target.checked),className:"accent-primary"}),e.jsxs("span",{children:[le.label," · ",T("rightSidebar.includeUncommitted"),le.disabled&&e.jsx("span",{className:"block text-[10px]",children:T("rightSidebar.includeUncommittedCurrentBranchOnly")})]})]},le.key)),rt=G?e.jsx("div",{role:"alert",className:"w-full text-xs text-destructive",children:G}):null,be=F?e.jsxs("button",{type:"button",onClick:F,disabled:H||R,title:Y??z,"aria-label":Y??z,className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-full bg-surface-2 px-2.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:cursor-not-allowed disabled:opacity-60",children:[e.jsx(zu,{size:12,className:H?"animate-spin":""}),z&&e.jsx("span",{children:z})]}):null,Qe=le=>e.jsxs("div",{className:"px-0 py-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[m&&e.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:m}),g&&e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:g})]}),h&&e.jsxs("button",{type:"button",onClick:h,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:[e.jsx(Zs,{size:14}),p]})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[le,Fe,be,$,Ye,rt]})]});if(r.length===0){const le=e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l});return!m&&!h?le:e.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[Qe(null),le]})}const Ue=P||F?({slideToList:le})=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",onClick:le,children:[e.jsx(Zs,{size:14}),c]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[Fe,be,$,P&&e.jsxs("button",{type:"button",onClick:P,"aria-pressed":b,title:D,className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${b?"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:b?_:U})]})]}),rt]}):void 0;return e.jsx(dl,{mobile:u,preserveScrollOnUpdate:!!I?.length,desktopLayout:C,backLabel:c,groups:Re,selectedKey:ne,mode:Le,onModeChange:le=>{De(le),le!=="ai"&&Dt(sf,le)},compact:u,collapsedDirectoryKeys:Te,onToggleDirectory:le=>{lt(Ee=>{const He=new Set(Ee);return He.has(le)?He.delete(le):He.add(le),He})},onSelectFile:le=>{s(le.key),we(Ee=>({key:le.key,nonce:Ee.nonce+1}))},renderLeading:le=>{const Ee=te.get(le.key);return e.jsx(pl,{changeStatus:le.status,auditStatus:Ee,renderChangeBadge:He=>e.jsx(Xs,{status:He})})},renderTrailing:le=>{const Ee=te.get(le.key);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[Ee&&e.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",Ee.additions," -",Ee.deletions]}),B?.(le.path,"file")]})},renderDirectoryTrailing:le=>B?.(le,"directory"),renderListHeader:Qe,aiContent:({slideToDetail:le,fullscreen:Ee,toggleFullscreen:He})=>A.length>0&&O?e.jsx(Xu,{walkthroughs:A,repoRoot:A[0]?.repoRoot,fullscreen:Ee,onToggleFullscreen:He,onNavigate:qt=>{u&&window.requestAnimationFrame(le),O(qt)}}):e.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:T("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:Ue,externalSwiperRef:$e,onMobileSlideChange:Ce,detailContainerClassName:u?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:Q,scrollToKey:me??Ie.key,scrollToKeyNonce:me==null?Ie.nonce:je,onDetailScroll:le=>{Cg(le,ne,s),ce?.(le.scrollTop)},files:ve,activePane:!0,wrap:b,diffViewType:f,inlineMode:x,renderStreamBadge:(le,Ee)=>{const He=te.get(Ee.key);return e.jsx(pl,{changeStatus:le,auditStatus:He,renderChangeBadge:qt=>e.jsx(Xs,{status:qt})})},onInsertDiffReference:N,onReferenceCopied:E,insertedReferenceKey:q,copiedReferenceKey:S,onClearAuditRecord:o,onHunkGitAction:H?void 0:V,emptyContent:e.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:l})})}function Eg(r){return r.replace(/\/+$/,"")||"/"}function Mg(r){return[...new Set(Array.from(r,Eg))].sort((n,s)=>n.localeCompare(s))}function $g(r){return r==="event-storm"||r==="reconnected"||r==="directory-rescan"||r==="polling-fallback"}function Pg(r){let n=null;return{applicableEvents:r.filter(l=>{const u=l.type==="rescan-required"&&!$g(l.reason);return u&&l.reason&&!n&&(n=l.reason),!u}),unavailableReason:n}}const Lg=1400,Ag=1200,af=44,Tg=.7;function Gi(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function gl(r){return`termdock:right-sidebar:context-draft-height:${r}:v1`}function Ig(r){try{const n=window.localStorage.getItem(gl(r)),s=n===null?NaN:Number(n);return Number.isFinite(s)&&s>=af?s:null}catch{return null}}function ou(r,n){try{n===null?window.localStorage.removeItem(gl(r)):window.localStorage.setItem(gl(r),String(n))}catch{}}function so(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Dg({value:r,collapsed:n,labels:s,focusRequest:l,insertError:u,autoCollapseAfterSend:c,onChange:m,onCollapsedChange:g,onAutoCollapseAfterSendChange:h,onDisable:p,onClear:b,onInsert:f,onInsertAndSend:x}){const[$,P]=a.useState(null),[D,_]=a.useState(!1),[U,C]=a.useState(()=>Ig(Gi())),N=a.useRef(U),E=a.useRef(null),B=a.useRef(null),q=a.useRef(r),S=a.useRef(null),o=a.useRef(null),F=!!r.trim(),I=r.trim().split(`
7
- `)[0]??"",V=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";a.useEffect(()=>()=>{E.current!==null&&window.clearTimeout(E.current),B.current!==null&&window.clearTimeout(B.current)},[]),a.useEffect(()=>{let T=!1;const ee=Gi();return Bu().then(te=>{if(T)return;const Le=te.contextDraftHeight?.[ee]??null;ou(ee,Le),N.current=Le,C(Le)}).catch(()=>{}),()=>{T=!0}},[]),a.useEffect(()=>{if(l!==void 0&&l>0){const T=S.current;if(!T)return;so()||T.focus(),T.setSelectionRange(T.value.length,T.value.length),T.scrollTop=T.scrollHeight}},[l]),a.useEffect(()=>{const T=q.current;q.current=r,!(!n||r.length<=T.length)&&(_(!0),B.current!==null&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{B.current=null,_(!1)},Ag))},[r,n]),a.useEffect(()=>{if(n)return;const T=S.current;T&&(T.style.height=U!==null?`${U}px`:"")},[r,n,U]),a.useEffect(()=>{if(n)return;const T=S.current;!T||document.activeElement===T||(T.scrollTop=T.scrollHeight)},[r,n]),a.useEffect(()=>{if(n||so())return;const T=S.current;!T||document.activeElement===T||(T.focus(),T.setSelectionRange(T.value.length,T.value.length))},[n]);const G=a.useRef(null);a.useLayoutEffect(()=>{if(!so())return;const T=window.visualViewport;if(!T)return;const ee=()=>{const te=G.current;if(!te)return;if(T.height>=window.innerHeight*.75){te.style.transform="";return}const Le=te.getBoundingClientRect(),De=Math.round(T.height-Le.bottom);te.style.transform=De!==0?`translateY(${De}px)`:""};return ee(),T.addEventListener("resize",ee),T.addEventListener("scroll",ee),()=>{T.removeEventListener("resize",ee),T.removeEventListener("scroll",ee),G.current&&(G.current.style.transform="")}},[n]);const H=T=>{P(T),E.current!==null&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{E.current=null,P(null)},Lg)},R=T=>{g(!1),so()&&window.requestAnimationFrame(()=>{const ee=S.current;if(!ee)return;ee.focus();const te=ee.value.length;ee.setSelectionRange(te,te),window.requestAnimationFrame(()=>{ee.setSelectionRange(te,te)})})},z=()=>{f(),H("inserted")},Y=()=>{F&&(x(),H("sent"))},A=T=>{if(T.key==="Escape"){T.preventDefault(),g(!0);return}T.key!=="Enter"||!T.metaKey&&!T.ctrlKey||(T.preventDefault(),Y())},O=T=>{T.preventDefault()},Q=T=>{T.preventDefault();const ee=S.current;ee&&(o.current={startY:T.clientY,startHeight:ee.getBoundingClientRect().height},T.currentTarget.setPointerCapture?.(T.pointerId))},ce=T=>{const ee=o.current;if(!ee)return;const te=window.visualViewport?.height??window.innerHeight,Le=Math.round(Math.min(Math.max(ee.startHeight+(ee.startY-T.clientY),af),te*Tg));N.current=Le,C(Le)},me=T=>{const ee=Gi();ou(ee,T),mo({contextDraftHeight:{[ee]:T}}).catch(()=>{})},je=()=>{o.current&&(o.current=null,N.current!==null&&me(N.current))},$e=()=>{N.current=null,C(null),me(null)},Ce=r.length>0&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/50",children:s.characterCount(r.length)});return n?e.jsx("section",{ref:G,className:"shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:e.jsxs("div",{className:"flex h-8 items-center gap-1 px-2",children:[e.jsxs("button",{type:"button",onClick:()=>R(),className:"group flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1 py-1 text-left transition-colors hover:bg-surface/70","aria-expanded":!1,"aria-label":s.expand,title:s.expand,children:[e.jsx(op,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),e.jsx("span",{className:`truncate text-[11px] ${u?"text-destructive":D?"text-primary":F?"text-foreground/80":"text-muted-foreground/50"}`,children:u??(D?s.appended:F?I:s.title)})]}),Ce,e.jsx("button",{type:"button",onClick:Y,disabled:!F,className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-30 ${F?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground"}`,"aria-label":s.send,title:s.send,children:$==="sent"?e.jsx(ko,{size:12}):e.jsx(Gd,{size:12})})]})}):e.jsxs("section",{ref:G,className:"relative shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:[e.jsx("div",{className:"group absolute left-1/2 top-0 z-10 flex h-3 w-16 -translate-x-1/2 -translate-y-1/2 cursor-ns-resize touch-none items-center justify-center",onPointerDown:Q,onPointerMove:ce,onPointerUp:je,onPointerCancel:je,onDoubleClick:$e,title:s.resize,"aria-hidden":"true",children:e.jsx("span",{className:"h-1 w-8 rounded-full bg-border/50 transition group-hover:bg-border"})}),e.jsxs("div",{className:"flex h-7 items-center gap-0.5 px-2",children:[e.jsxs("button",{type:"button",onPointerDown:O,onClick:()=>g(!0),className:"group flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1 py-1 text-left transition-colors hover:bg-surface/70","aria-expanded":!0,"aria-label":s.collapse,title:s.collapse,children:[e.jsx(ea,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),e.jsx("span",{className:"truncate text-[10px] font-medium text-foreground/75",children:s.title}),Ce]}),e.jsx("button",{type:"button",role:"switch","aria-checked":c,onPointerDown:O,onClick:()=>h(!c),className:"inline-flex h-6 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:bg-surface/70 hover:text-foreground","aria-label":s.autoCollapseAfterSend,title:s.autoCollapseAfterSend,children:e.jsx("span",{"aria-hidden":"true",className:`relative h-3 w-5 rounded-full transition-colors ${c?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-primary-foreground transition-transform ${c?"translate-x-2.5":"translate-x-0.5"}`})})}),e.jsx("button",{type:"button",onPointerDown:O,onClick:p,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/50 transition hover:bg-surface/70 hover:text-foreground active:scale-95","aria-label":s.disable,title:s.disable,children:e.jsx(Ft,{size:11})})]}),e.jsx("div",{className:"px-2 pb-2",children:e.jsxs("div",{className:"overflow-hidden rounded-lg bg-surface/80 ring-1 ring-border/10 transition focus-within:ring-primary/35",children:[e.jsx("textarea",{ref:S,value:r,onChange:T=>m(T.target.value),onKeyDown:A,placeholder:s.title,rows:1,className:"block min-h-11 w-full resize-none bg-transparent px-2.5 py-2 font-mono text-[12px] leading-relaxed text-foreground placeholder:text-muted-foreground/30 focus:outline-none",autoCapitalize:"sentences",spellCheck:!0,"data-context-draft-input":!0}),e.jsxs("div",{className:"flex items-center gap-0.5 border-t border-border/10 px-1 py-1",children:[e.jsx("button",{type:"button",onPointerDown:O,onClick:b,disabled:!F,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/65 transition hover:bg-surface-2 hover:text-foreground active:scale-95 disabled:opacity-30","aria-label":s.clear,title:s.clear,children:e.jsx(po,{size:11})}),u?e.jsx("span",{className:"min-w-0 flex-1 truncate px-1 text-[10px] text-destructive",role:"alert",children:u}):e.jsx("span",{className:"flex-1"}),e.jsxs("button",{type:"button",onPointerDown:O,onClick:z,disabled:!F,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-[10px] font-medium text-foreground/75 transition hover:bg-surface-2 hover:text-foreground active:scale-[0.98] disabled:opacity-30",children:[e.jsx(ip,{size:11}),e.jsx("span",{children:$==="inserted"?s.inserted:s.insert})]}),e.jsxs("button",{type:"button",onPointerDown:O,onClick:Y,disabled:!F,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md bg-primary px-2 text-[10px] font-semibold text-primary-foreground transition hover:bg-primary/90 active:scale-[0.98] disabled:opacity-30",title:`${s.insertAndSend} · ${V}`,children:[$==="sent"?e.jsx(ko,{size:11}):e.jsx(Gd,{size:11}),e.jsx("span",{children:$==="sent"?s.sent:s.send})]})]})]})})]})}function Fg(r,n){const s=n.trim();if(!s)return r;if(!r.trim())return s;const l=r.endsWith(`
8
-
9
- `)?"":r.endsWith(`
10
- `)?`
11
- `:`
12
-
13
- `;return`${r}${l}${s}`}function _g(r,n){const s=r.trim();return s?n?`${s}\r`:/\s$/.test(r)?r:`${s} `:""}const bl="termdock:right-sidebar:html-view-mode-by-file:v1";function Bg(r){return r==="preview"||r==="source"}function of(r){return!r||typeof r!="object"||Array.isArray(r)?!1:Object.values(r).every(Bg)}function lf(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function iu(r,n){const s=lf(r,n);return s?gt(bl,of)?.[s]??"source":"source"}function Og(r,n,s){const l=lf(r,n);if(!l)return;const u=gt(bl,of)??{};Dt(bl,{...u,[l]:s})}function cf(r){try{return new URL(r,location.href).pathname.startsWith("/api/")}catch{return!1}}const Ug=1500,lu=256*1024*1024;async function Hg(r,n){const s=await fetch(r,{signal:n});if(!s.ok)throw new Error(`Media fallback failed: HTTP ${s.status}`);const l=s.headers.get("content-type")??"",u=s.body?.getReader();if(!u){const g=await s.blob();if(g.size>lu)throw new Error("Media too large for encrypted fallback");return URL.createObjectURL(g)}const c=[];let m=0;try{for(;;){const{done:g,value:h}=await u.read();if(g)break;if(m+=h.byteLength,m>lu)throw new Error("Media too large for encrypted fallback");c.push(h)}}catch(g){throw await u.cancel().catch(()=>{}),g}return URL.createObjectURL(new Blob(c,{type:l}))}function Ao(r,n){const s=cf(r),[l,u]=a.useState(()=>!!navigator.serviceWorker?.controller),[c,m]=a.useState(void 0),g=a.useRef(n);return g.current=n,a.useEffect(()=>{if(!s||l)return;const h=navigator.serviceWorker,p=()=>u(!!h?.controller);return h?.addEventListener("controllerchange",p),p(),()=>h?.removeEventListener("controllerchange",p)},[s,l]),a.useEffect(()=>{if(!s||l){m(void 0);return}let h=!1,p;const b=new AbortController,f=window.setTimeout(()=>{Hg(r,b.signal).then(x=>{if(h){URL.revokeObjectURL(x);return}p=x,m(x)}).catch(()=>{h||b.signal.aborted||g.current?.()})},Ug);return()=>{h=!0,window.clearTimeout(f),b.abort(),p&&URL.revokeObjectURL(p)}},[s,l,r]),!s||l?r:c}function Ki(r){const n=Number.isFinite(r)&&r>0?Math.floor(r):0,s=Math.floor(n/3600),l=Math.floor(n%3600/60),u=n%60,c=String(l).padStart(2,"0"),m=String(u).padStart(2,"0");return s>0?`${s}:${c}:${m}`:`${c}:${m}`}function zg(r,n,s){return!Number.isFinite(s)||s<=0||!n.width?0:Math.min(1,Math.max(0,(r-n.left)/n.width))*s}const qr=2,Wg=8,Gg=60,ao=5,cu=.05,Kg=900;function qg(r){return!Number.isFinite(r)||r<=0?qr:Math.min(Wg,qr+Math.floor(r/Gg))}const Vg=350,Yg=6,Xg=90;function Jg({url:r,onLoadError:n}){const s=Ao(r,n),{t:l}=mt(),u=a.useRef(null),c=a.useRef(null),m=a.useRef(null),g=a.useRef(null),h=a.useRef(!1),p=a.useRef(null),b=a.useRef(null),f=a.useRef(0),x=a.useRef(!1),$=a.useRef(!1),P=a.useRef(!1),D=a.useRef(null),_=a.useRef(null),U=a.useRef(!1),C=a.useRef(1),N=a.useRef(!1),[E,B]=a.useState(0),[q,S]=a.useState(0),[o,F]=a.useState(!1),[I,V]=a.useState(!1),[G,H]=a.useState(null),[R,z]=a.useState(!1),[Y,A]=a.useState(0),[O,Q]=a.useState(!1),[ce,me]=a.useState({width:0,height:0}),[je,$e]=a.useState(qr),[Ce,T]=a.useState(1),[ee,te]=a.useState(null),Le=a.useRef(qr),De=a.useRef(null),Te=a.useCallback(()=>{D.current!==null&&(clearTimeout(D.current),D.current=null)},[]),lt=a.useCallback(()=>{Te();const W=_.current;if(_.current=null,!U.current)return!1;const re=m.current;if(re&&(re.playbackRate=C.current,W))try{re.releasePointerCapture?.(W.id)}catch{}return U.current=!1,Le.current=qr,z(!1),!0},[Te]);a.useEffect(()=>()=>{p.current!==null&&cancelAnimationFrame(p.current),b.current!==null&&clearTimeout(b.current),De.current!==null&&clearTimeout(De.current),Te();const W=m.current;W&&U.current&&(W.playbackRate=C.current)},[Te]),a.useEffect(()=>{const W=c.current;if(!W||typeof ResizeObserver>"u")return;const re=new ResizeObserver(([ye])=>{ye&&me({width:ye.contentRect.width,height:ye.contentRect.height})});return re.observe(W),()=>re.disconnect()},[]),a.useEffect(()=>{const W=()=>Q(document.fullscreenElement===u.current);return document.addEventListener("fullscreenchange",W),()=>document.removeEventListener("fullscreenchange",W)},[]);const Ie=a.useCallback((W,re=!1)=>{const ye=m.current;if(!ye)return!1;const Xe=Number.isFinite(ye.duration)?ye.duration:W,Ct=Math.min(Math.max(W,0),Xe);if(S(Ct),Math.abs(ye.currentTime-Ct)<1/120)return!1;const Tr=ye.fastSeek;return re&&typeof Tr=="function"?Tr.call(ye,Ct):ye.currentTime=Ct,!0},[]),we=a.useCallback(()=>{p.current===null&&(p.current=requestAnimationFrame(()=>{p.current=null;const W=m.current;if(!W||!x.current||$.current||W.seeking)return;const re=P.current;P.current=!1,$.current=Ie(f.current,!re)}))},[Ie]),L=a.useCallback(W=>{const re=g.current,ye=m.current;if(!re||!ye)return;const Xe=re.getBoundingClientRect(),Ct=zg(W,Xe,ye.duration);f.current=Ct,H(Ct),P.current=!1,we(),b.current!==null&&clearTimeout(b.current),b.current=setTimeout(()=>{b.current=null,P.current=!0,we()},Xg)},[we]),ne=a.useCallback(()=>{p.current!==null&&(cancelAnimationFrame(p.current),p.current=null),b.current!==null&&(clearTimeout(b.current),b.current=null),P.current=!1,$.current=!1,Ie(f.current)},[Ie]),Re=a.useCallback(W=>{const re=m.current;if(!(!re||!Number.isFinite(re.duration)||re.duration<=0)){h.current=!re.paused,re.pause(),x.current=!0,V(!0);try{W.currentTarget.setPointerCapture(W.pointerId)}catch{}L(W.clientX)}},[L]),ve=a.useCallback(()=>{x.current=!1,ne(),V(!1),H(null);const W=m.current;W&&h.current&&!W.ended&&W.play().catch(()=>{}),h.current=!1},[ne]),Be=a.useCallback(()=>{const W=m.current;if(W){if(N.current){N.current=!1;return}W.paused?W.play().catch(()=>{}):W.pause()}},[]),fe=a.useCallback(W=>{const re=m.current;if(!re)return;const ye=Math.min(1,Math.max(0,Math.round((re.volume+W)*100)/100));re.volume=ye,ye>0&&(re.muted=!1),T(ye),te(ye),De.current!==null&&clearTimeout(De.current),De.current=setTimeout(()=>{De.current=null,te(null)},Kg)},[]),Ye=a.useCallback(W=>{const re=m.current;if(re){if(W.key==="ArrowLeft"){W.preventDefault(),Ie(re.currentTime-(W.shiftKey?ao*2:ao));return}if(W.key==="ArrowRight"){W.preventDefault(),Ie(re.currentTime+(W.shiftKey?ao*2:ao));return}if(W.key==="ArrowUp"){W.preventDefault(),fe(cu);return}if(W.key==="ArrowDown"){W.preventDefault(),fe(-cu);return}(W.key===" "||W.key==="Spacebar"||W.key==="k"||W.key==="K")&&(W.preventDefault(),re.paused?re.play().catch(()=>{}):re.pause())}},[Ie,fe]),Fe=a.useCallback(W=>{const re=m.current;!re||re.paused||W.button!==0||(Te(),_.current={id:W.pointerId,x:W.clientX,y:W.clientY},D.current=setTimeout(()=>{D.current=null;const ye=_.current;if(C.current=re.playbackRate,re.playbackRate=qr,Le.current=qr,$e(qr),U.current=!0,z(!0),ye)try{re.setPointerCapture?.(ye.id)}catch{}},Vg))},[Te]),rt=a.useCallback(W=>{const re=_.current;if(!re||re.id!==W.pointerId)return;if(!U.current){Math.hypot(W.clientX-re.x,W.clientY-re.y)>Yg&&(Te(),_.current=null);return}const ye=qg(W.clientX-re.x);if(ye===Le.current)return;Le.current=ye,$e(ye);const Xe=m.current;Xe&&(Xe.playbackRate=ye)},[Te]),be=a.useCallback(()=>{lt()&&(N.current=!0)},[lt]);a.useEffect(()=>(window.addEventListener("pointerup",be),window.addEventListener("pointercancel",be),window.addEventListener("blur",be),()=>{window.removeEventListener("pointerup",be),window.removeEventListener("pointercancel",be),window.removeEventListener("blur",be)}),[be]);const Qe=a.useCallback(async()=>{const W=u.current,re=m.current;if(!(!W||!re))try{document.fullscreenElement===W?await document.exitFullscreen():W.requestFullscreen?await W.requestFullscreen():re.webkitEnterFullscreen?.()}catch{re.webkitEnterFullscreen?.()}},[]),Ue=a.useCallback(()=>A(W=>(W+90)%360),[]),le=a.useCallback(W=>{const re=m.current;if(!re||!Number.isFinite(re.duration))return;const ye=W.shiftKey?10:5;let Xe=null;W.key==="ArrowLeft"?Xe=re.currentTime-ye:W.key==="ArrowRight"?Xe=re.currentTime+ye:W.key==="Home"?Xe=0:W.key==="End"&&(Xe=re.duration),Xe!==null&&(W.preventDefault(),Ie(Xe))},[Ie]),Ee=I&&G!==null?G:q,He=E>0?Math.min(1,Math.max(0,Ee/E)):0,jt=(Y===90||Y===270)&&ce.width>0&&ce.height>0?{width:`${ce.height}px`,height:`${ce.width}px`}:{width:"100%",height:"100%"};return e.jsxs("div",{ref:u,className:"flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-background fullscreen:h-screen fullscreen:w-screen fullscreen:rounded-none","data-testid":"file-preview-video-player","data-rotation":Y,children:[e.jsxs("div",{ref:c,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[e.jsx("video",{ref:m,"data-testid":"file-preview-video",className:`absolute left-1/2 top-1/2 max-w-none object-contain outline-none transition-transform duration-200 focus-visible:ring-2 focus-visible:ring-primary/60${R?` ${Jd}`:""}`,style:{...jt,transform:`translate(-50%, -50%) rotate(${Y}deg)`},src:s,preload:"auto",playsInline:!0,tabIndex:0,...R?{[Qd]:""}:{},onClick:Be,onKeyDown:Ye,onVolumeChange:W=>T(W.currentTarget.volume),onPointerDown:Fe,onPointerMove:rt,onPointerUp:be,onPointerCancel:be,onContextMenu:W=>{U.current&&W.preventDefault()},onPlay:()=>F(!0),onPause:()=>F(!1),onTimeUpdate:W=>S(W.currentTarget.currentTime),onSeeked:W=>{const re=W.currentTarget;if(S(re.currentTime),$.current=!1,!x.current)return;const ye=re.requestVideoFrameCallback;typeof ye=="function"?ye.call(re,()=>{x.current&&we()}):requestAnimationFrame(()=>{x.current&&we()})},onLoadedMetadata:W=>B(Number.isFinite(W.currentTarget.duration)?W.currentTarget.duration:0),onDurationChange:W=>B(Number.isFinite(W.currentTarget.duration)?W.currentTarget.duration:0),onError:n,children:l("rightSidebar.videoUnsupported")}),R&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-3 z-10 -translate-x-1/2 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md",children:l("rightSidebar.videoLongPressSpeed",{rate:String(je)})}),ee!==null&&e.jsxs("div",{className:"pointer-events-none absolute right-3 top-3 z-10 inline-flex items-center gap-1 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md","data-testid":"file-preview-video-volume",children:[e.jsx(lp,{size:13}),l("rightSidebar.videoVolume",{percent:Math.round(Ce*100)})]}),I&&G!==null&&e.jsx("div",{className:"pointer-events-none absolute bottom-1 z-10 -translate-x-1/2 rounded-md bg-surface-elevated px-2 py-1 text-[11px] font-medium text-foreground shadow-md",style:{left:`${He*100}%`},"data-testid":"file-preview-video-scrub-time",children:Ki(G)})]}),e.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${Jd}`,[Qd]:"",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:Be,"aria-label":l(o?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:l(o?"rightSidebar.videoPause":"rightSidebar.videoPlay"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-play",children:o?e.jsx(cp,{size:14}):e.jsx(dp,{size:14})}),e.jsxs("div",{ref:g,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(E),"aria-valuenow":Math.floor(Ee),tabIndex:0,className:"group relative h-5 min-w-0 flex-1 cursor-pointer touch-none py-2","data-testid":"file-preview-video-track",onPointerDown:Re,onPointerMove:W=>{I&&L(W.clientX)},onPointerUp:ve,onPointerCancel:ve,onKeyDown:le,children:[e.jsx("div",{className:"h-1 w-full rounded-full bg-surface-elevated"}),e.jsx("div",{className:"absolute inset-y-0 left-0 my-auto h-1 rounded-full bg-primary",style:{width:`${He*100}%`}}),e.jsx("div",{className:"absolute top-1/2 h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary shadow",style:{left:`${He*100}%`}})]}),e.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[Ki(Ee)," / ",Ki(E)]}),e.jsx("button",{type:"button",onClick:Ue,"aria-label":l("rightSidebar.videoRotate"),title:l("rightSidebar.videoRotate"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-rotate",children:e.jsx(zu,{size:14})}),e.jsx("button",{type:"button",onClick:()=>{Qe()},"aria-label":l(O?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:l(O?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-fullscreen",children:O?e.jsx(up,{size:14}):e.jsx(fp,{size:14})})]})})]})}function Qg(r){const n=Math.max(0,Math.min(100,r.xPercent)),s=Math.max(0,Math.min(100,r.yPercent));return{...n<=50?{left:`calc(${n}% + 8px)`}:{right:`calc(${100-n}% + 8px)`},...s<=50?{top:`calc(${s}% + 8px)`}:{bottom:`calc(${100-s}% + 8px)`}}}function To({anchor:r,children:n,disabled:s=!1,onClick:l,title:u}){return e.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:s,onClick:c=>{c.stopPropagation(),l()},title:u,style:Qg(r),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[e.jsx(So,{size:11}),n]})}function Zg(r,n,s,l){if(s.width<=0||s.height<=0||l.width<=0||l.height<=0)return null;const u=Math.min(s.width/l.width,s.height/l.height);if(!Number.isFinite(u)||u<=0)return null;const c=l.width*u,m=l.height*u,g=s.left+(s.width-c)/2,h=s.top+(s.height-m)/2,p=r-g,b=n-h;if(p<0||b<0||p>c||b>m)return null;const f=p/c*100,x=b/m*100;return{x:l.x+l.width*f/100,y:l.y+l.height*x/100,xPercent:f,yPercent:x}}function eb(r,n,s){const l=[`SVG标注: ${r}`,`视图: ${n}`,`SVG坐标: (${s.x.toFixed(2)},${s.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return s.nearestText&&l.push(`最近文字: ${s.nearestText}`),`"${l.join(" / ")}"`}function tb(r){const n=new DOMParser().parseFromString(r,"image/svg+xml"),s=n.documentElement;if(s.nodeName.toLowerCase()!=="svg"||n.querySelector("parsererror"))throw new Error("Invalid SVG document");return n.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(l=>l.remove()),n.querySelectorAll("*").forEach(l=>{for(const u of Array.from(l.attributes)){const c=u.name.toLowerCase(),m=u.value.trim();(c.startsWith("on")||(c==="href"||c.endsWith(":href"))&&m&&!m.startsWith("#"))&&l.removeAttribute(u.name)}}),s.removeAttribute("width"),s.removeAttribute("height"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(s)}function rb(r,n,s){let l=null;for(const u of Array.from(r.querySelectorAll("text"))){const c=(u.textContent??"").replace(/\s+/g," ").trim();if(!c)continue;const m=Number(u.getAttribute("x")),g=Number(u.getAttribute("y"));if(!Number.isFinite(m)||!Number.isFinite(g))continue;const h=Math.hypot(m-n,g-s);(!l||h<l.distance)&&(l={text:c,distance:h})}return l?.text.slice(0,120)}function df({blobUrl:r,filePath:n,viewLabel:s,onInsertAnnotation:l}){const u=a.useRef(null),c=a.useRef(null),[m,g]=a.useState(null),[h,p]=a.useState(null),[b,f]=a.useState(1),[x,$]=a.useState(!1),[P,D]=a.useState(null),_=a.useRef(new Map),U=a.useRef(null),C=a.useRef(!1),N=a.useRef(null),E=a.useRef(b);E.current=b,a.useEffect(()=>{const A=new AbortController;return g(null),p(null),D(null),f(1),fetch(r,{signal:A.signal}).then(O=>O.text()).then(O=>g(tb(O))).catch(O=>{A.signal.aborted||p(O instanceof Error?O.message:"SVG preview failed")}),()=>A.abort()},[r]),a.useEffect(()=>{if(!x)return;const A=O=>{O.key==="Escape"&&$(!1)};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[x]),a.useLayoutEffect(()=>{const A=c.current,O=A?.querySelector("[data-svg-document] > svg");if(!A||!O)return;let Q;try{Q=O.getBBox()}catch{return}if(!Q.width||!Q.height)return;const ce=Math.max(2,Math.min(Q.width,Q.height)*.025);O.setAttribute("viewBox",`${Q.x-ce} ${Q.y-ce} ${Q.width+2*ce} ${Q.height+2*ce}`),O.style.width=`${b*100}%`,O.style.height=`${b*100}%`,O.style.minWidth=`${b*100}%`,O.style.minHeight=`${b*100}%`,O.style.display="block"},[m,b]);const B=a.useMemo(()=>P?eb(n,s,P):null,[n,P,s]),q=A=>{if(C.current){C.current=!1;return}const O=c.current,Q=O?.querySelector("[data-svg-document] > svg"),ce=u.current;if(!O||!Q||!ce)return;const me=Q.viewBox.baseVal,je=Zg(A.clientX,A.clientY,Q.getBoundingClientRect(),me);if(!je)return;const $e=ce.getBoundingClientRect();D({...je,nearestText:rb(Q,je.x,je.y),stageX:A.clientX-$e.left,stageY:A.clientY-$e.top,stageXPercent:(A.clientX-$e.left)/$e.width*100,stageYPercent:(A.clientY-$e.top)/$e.height*100})},S=A=>Math.max(1,Math.min(12,A)),o=(A,O)=>{const Q=S(O),ce=A.querySelector("[data-svg-document] > svg");if(!ce)return Q;const me=`${Q*100}%`;return ce.style.width=me,ce.style.height=me,ce.style.minWidth=me,ce.style.minHeight=me,E.current=Q,Q},F=(A,O,Q,ce)=>{const me=E.current,je=A.getBoundingClientRect(),$e=Q-je.left,Ce=ce-je.top,T=(A.scrollLeft+$e)/me,ee=(A.scrollTop+Ce)/me,te=o(A,O);return A.scrollLeft=T*te-$e,A.scrollTop=ee*te-Ce,te},I=()=>{const A=Array.from(_.current.values());return A.length>=2?Math.hypot(A[0].x-A[1].x,A[0].y-A[1].y):0},V=A=>{if(A.pointerType==="mouse"&&A.button!==0)return;const O=c.current;O&&(_.current.set(A.pointerId,{x:A.clientX,y:A.clientY}),O.setPointerCapture?.(A.pointerId),_.current.size>=2?(U.current={kind:"pinch",startX:A.clientX,startY:A.clientY,startScrollLeft:O.scrollLeft,startScrollTop:O.scrollTop,startDistance:I(),startZoom:E.current,moved:!1},C.current=!0):E.current>1&&(U.current={kind:"pan",startX:A.clientX,startY:A.clientY,startScrollLeft:O.scrollLeft,startScrollTop:O.scrollTop,startZoom:E.current,moved:!1}))},G=A=>{if(!_.current.has(A.pointerId))return;_.current.set(A.pointerId,{x:A.clientX,y:A.clientY});const O=c.current,Q=U.current;if(!(!O||!Q)){if(_.current.size>=2&&Q.kind==="pinch"){const ce=I();if(!Q.startDistance||!ce)return;const me=S(Q.startZoom*ce/Q.startDistance);if(Math.abs(me-E.current)<.01)return;const je=Array.from(_.current.values()),$e=(je[0].x+je[1].x)/2,Ce=(je[0].y+je[1].y)/2;Q.moved=!0,C.current=!0,F(O,me,$e,Ce),A.preventDefault();return}if(Q.kind==="pan"&&_.current.size===1){const ce=A.clientX-Q.startX,me=A.clientY-Q.startY;if(!Q.moved&&Math.hypot(ce,me)<6)return;Q.moved=!0,C.current=!0,O.scrollLeft=Q.startScrollLeft-ce,O.scrollTop=Q.startScrollTop-me,A.preventDefault()}}},H=A=>{const O=c.current,Q=U.current,ce=_.current.size===1&&!Q?.moved;_.current.delete(A.pointerId);try{O?.releasePointerCapture?.(A.pointerId)}catch{}if(_.current.size===1&&Q?.kind==="pinch"){const $e=Array.from(_.current.values())[0];U.current=O?{kind:"pan",startX:$e.x,startY:$e.y,startScrollLeft:O.scrollLeft,startScrollTop:O.scrollTop,startZoom:E.current,moved:!1}:null;return}if(_.current.size>0||(U.current=null,Q?.kind==="pinch"&&f(E.current),!ce||C.current))return;const me=Date.now(),je=N.current;je&&me-je.time<350&&Math.hypot(A.clientX-je.x,A.clientY-je.y)<24?(N.current=null,C.current=!0,f($e=>$e>1?1:2.5)):N.current={time:me,x:A.clientX,y:A.clientY}},R=A=>{if(!A.ctrlKey&&!A.metaKey)return;const O=c.current;if(!O)return;A.preventDefault();const Q=F(O,E.current*Math.exp(-A.deltaY*.01),A.clientX,A.clientY);f(Q)},z=()=>{f(1),E.current=1,c.current&&(c.current.scrollLeft=0,c.current.scrollTop=0)},Y=e.jsxs("div",{className:x?"fixed inset-0 z-modal-panel flex min-h-0 flex-col bg-surface pt-[env(safe-area-inset-top,0px)]":"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{ref:u,className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:c,role:"button",tabIndex:0,onClick:q,onDoubleClick:A=>{A.preventDefault(),f(O=>O>1?1:2.5)},onPointerDown:V,onPointerMove:G,onPointerUp:H,onPointerCancel:H,onWheel:R,onScroll:()=>D(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:h?e.jsx("div",{className:"p-4 text-sm text-destructive",children:h}):m?e.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:m}}):e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),P&&e.jsx("span",{"data-svg-pick-marker":!0,className:"pointer-events-none absolute z-10 h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm",style:{left:P.stageX,top:P.stageY}}),P&&B&&e.jsx(To,{anchor:{xPercent:P.stageXPercent,yPercent:P.stageYPercent},title:"引用 SVG 标注",onClick:()=>{l?.(B,`svg:${P.x.toFixed(2)}:${P.y.toFixed(2)}`),D(null)},children:"引用 SVG 标注"}),e.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[b>1.001&&e.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:A=>{A.stopPropagation(),z()},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:e.jsx(qp,{size:14})}),e.jsx("button",{type:"button","aria-label":x?"退出全屏 SVG":"全屏 SVG",title:x?"退出全屏 SVG":"全屏 SVG",onClick:A=>{A.stopPropagation(),$(O=>!O)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:x?e.jsx(Ju,{size:14}):e.jsx(Yu,{size:14})})]})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:P?`SVG (${P.x.toFixed(2)}, ${P.y.toFixed(2)}) · ${P.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return x?kr.createPortal(Y,document.body):Y}function bo(r){switch(r){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function nb(r,n,s,l){const u=[`电子标注: ${r}`,`视图: ${bo(n)}`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(l?.available&&l.xMm!==void 0&&l.yMm!==void 0&&(u.push(`PCB坐标: (${l.xMm.toFixed(2)},${l.yMm.toFixed(2)})mm [KiCad板坐标]`),l.layer&&u.push(`显示层: ${l.layer}`),l.nearest)){const c=[l.nearest.net?`网络 ${l.nearest.net}`:null,`对象层 ${l.nearest.layer}`,`距离 ${l.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");u.push(`最近对象: ${l.nearest.label}${c?`(${c})`:""}`)}return`"${u.join(" / ")}"`}function sb({blobUrl:r,filePath:n,view:s,board:l,onViewChange:u,onInsertAnnotation:c,onRefresh:m,interactive3d:g}){const{t:h}=mt(),p=a.useRef(null),b=a.useRef(null),f=a.useRef(null),[x,$]=a.useState(null),[P,D]=a.useState(!1);a.useEffect(()=>(f.current?.abort(),$(null),D(!1),()=>f.current?.abort()),[r,s]);const _=a.useMemo(()=>x?nb(n,s,x,x.inspection):null,[n,x,s]),U=N=>{const E=p.current,B=b.current;if(!E||!B||!B.naturalWidth||!B.naturalHeight)return;const q=E.getBoundingClientRect(),S=B.getBoundingClientRect(),o=Math.min(S.width/B.naturalWidth,S.height/B.naturalHeight),F=B.naturalWidth*o,I=B.naturalHeight*o,V=S.left+(S.width-F)/2,G=S.top+(S.height-I)/2,H=N.clientX-V,R=N.clientY-G;if(H<0||R<0||H>F||R>I)return;const z={xPercent:Math.max(0,Math.min(100,H/F*100)),yPercent:Math.max(0,Math.min(100,R/I*100)),stageXPercent:(N.clientX-q.left)/q.width*100,stageYPercent:(N.clientY-q.top)/q.height*100,inspecting:l&&s!=="pcb-3d"};if($(z),f.current?.abort(),!z.inspecting)return;const Y=new AbortController;f.current=Y,Em(n,s,z.xPercent,z.yPercent,Y.signal).then(A=>$(O=>O===z?{...O,inspection:A,inspecting:!1}:O)).catch(()=>{Y.signal.aborted||$(A=>A===z?{...A,inspection:{available:!1},inspecting:!1}:A)})},C=l?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:C.map(N=>e.jsx("button",{type:"button",onClick:()=>u(N),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${N===s?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:bo(N)},N))}),e.jsx("button",{type:"button",onClick:m,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:h("rightSidebar.edaRefresh"),"aria-label":h("rightSidebar.edaRefresh"),children:e.jsx(go,{size:13})})]}),l&&g?e.jsx("div",{className:s==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:g}):null,l?s==="pcb-3d"?g?null:e.jsx("div",{className:"min-h-0 flex-1"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:p,role:"button",tabIndex:0,onClick:U,onKeyDown:N=>{N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),$({xPercent:50,yPercent:50,stageXPercent:50,stageYPercent:50}))},className:"relative min-h-0 flex-1 cursor-crosshair overflow-hidden bg-surface p-3 outline-none",title:h("rightSidebar.edaPickHint"),children:[e.jsx("img",{ref:b,src:r,alt:`${n} ${bo(s)}`,onLoad:()=>D(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${P?"opacity-100":"opacity-0"}`}),x&&e.jsx("span",{className:"pointer-events-none absolute h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-surface shadow-sm",style:{left:`${x.stageXPercent}%`,top:`${x.stageYPercent}%`}}),x&&_&&e.jsx(To,{anchor:{xPercent:x.stageXPercent,yPercent:x.stageYPercent},disabled:x.inspecting,title:h("rightSidebar.edaInsertAnnotation"),onClick:()=>{c?.(_,`eda:${s}:${x.xPercent.toFixed(1)}:${x.yPercent.toFixed(1)}`,{snapshot:b.current?hg(b.current,x):Promise.resolve(null)}),$(null)},children:h("rightSidebar.edaInsertAnnotation")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:x?x.inspecting?h("rightSidebar.edaInspecting"):x.inspection?.available?h("rightSidebar.edaPickedBoardPosition",{x:x.inspection.xMm?.toFixed(2)??"—",y:x.inspection.yMm?.toFixed(2)??"—",object:x.inspection.nearest?.label??h("rightSidebar.edaNoNearbyObject")}):h("rightSidebar.edaPickedPosition",{x:x.xPercent.toFixed(1),y:x.yPercent.toFixed(1)}):h("rightSidebar.edaPickHint")})})]}):e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(df,{blobUrl:r,filePath:n,viewLabel:bo(s),onInsertAnnotation:c})})]})}function ab(r){const n=[];let s=[],l="",u=!1;for(let c=0;c<r.length;c+=1){const m=r[c];u?m==='"'&&r[c+1]==='"'?(l+='"',c+=1):m==='"'?u=!1:l+=m:m==='"'?u=!0:m===","?(s.push(l),l=""):m===`
14
- `?(s.push(l.replace(/\r$/,"")),n.push(s),s=[],l=""):l+=m}return(l||s.length>0)&&(s.push(l.replace(/\r$/,"")),n.push(s)),n}function ob(r,n,s,l,u){const c=n[u]||`第${u+1}列`,m=s[u]??"",g=n.map((h,p)=>`${h||`第${p+1}列`}=${s[p]??""}`).join(";");return`"表格标注: ${r} / 数据行: ${l+1} / 列: ${c} / 值: ${m} / 记录: ${g}"`}function ib({content:r,filePath:n,onInsertAnnotation:s}){const{t:l}=mt(),u=a.useMemo(()=>ab(r),[r]),c=u[0]??[],m=u.slice(1),g=a.useRef(null),[h,p]=a.useState(null),b=h?m[h.row]:null,f=h&&b?ob(n,c,b,h.row+1,h.column):null;return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[e.jsxs("div",{ref:g,className:"relative min-h-0 flex-1",children:[e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("table",{className:"min-w-full border-separate border-spacing-0 text-left text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 top-0 z-20 border-b border-r border-border/20 bg-surface-elevated px-2 py-2 text-[10px] font-semibold text-muted-foreground",children:"#"}),c.map((x,$)=>e.jsx("th",{className:"sticky top-0 z-10 min-w-28 border-b border-r border-border/20 bg-surface-elevated px-3 py-2 font-semibold text-foreground",children:x||l("rightSidebar.csvUnnamedColumn",{index:$+1})},`${x}:${$}`))]})}),e.jsx("tbody",{children:m.map((x,$)=>e.jsxs("tr",{className:"hover:bg-surface-2",children:[e.jsx("th",{className:"sticky left-0 z-10 border-b border-r border-border/15 bg-surface px-2 py-2 text-right text-[10px] font-normal text-muted-foreground",children:$+1}),c.map((P,D)=>{const _=h?.row===$&&h.column===D;return e.jsx("td",{className:`border-b border-r border-border/15 p-0 ${_?"bg-primary/15":""}`,children:e.jsx("button",{type:"button",onClick:U=>{const C=g.current?.getBoundingClientRect(),N=U.currentTarget.getBoundingClientRect();if(!C?.width||!C.height)return;const E=U.clientX||N.left+N.width/2,B=U.clientY||N.top+N.height/2;p({row:$,column:D,xPercent:(E-C.left)/C.width*100,yPercent:(B-C.top)/C.height*100})},className:"block h-full min-h-9 w-full whitespace-pre-wrap px-3 py-2 text-left text-foreground outline-none hover:bg-primary/10 focus-visible:bg-primary/10",children:x[D]||" "})},`cell:${$}:${D}`)})]},`row:${$}`))})]})}),h&&f&&e.jsx(To,{anchor:{xPercent:h.xPercent,yPercent:h.yPercent},title:l("rightSidebar.csvInsertAnnotation"),onClick:()=>{s?.(f,`csv:${n}:${h.row+1}:${h.column+1}`),p(null)},children:l("rightSidebar.csvInsertAnnotation")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:h&&b?l("rightSidebar.csvSelectedCell",{row:h.row+1,column:c[h.column]||h.column+1}):l("rightSidebar.csvPickHint",{rows:m.length,columns:c.length})})})]})}function is(r,n){let s=r;for(const l of n){if(!s||typeof s!="object")return;s=s[l]}return s}function lb(r,n){const s=JSON.parse(r),l=is(s,["meta","version"]);if(n)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(l??"未知")},{label:"活动层编号",value:String(is(s,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(is(s,["board","visible_layers"])??"未知")},{label:"Git 集成",value:is(s,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const u=is(s,["net_settings","classes"]),c=Array.isArray(u)?u.find(g=>g&&typeof g=="object"&&g.name==="Default"):void 0,m=is(s,["board","design_settings","drc_exclusions"]);return[{label:"文件性质",value:"KiCad 工程配置"},{label:"格式版本",value:String(l??"未知")},{label:"网络类数量",value:String(Array.isArray(u)?u.length:0)},{label:"默认间距",value:c?.clearance!==void 0?`${c.clearance} mm`:"未设置"},{label:"默认线宽",value:c?.track_width!==void 0?`${c.track_width} mm`:"未设置"},{label:"默认过孔",value:c?.via_diameter!==void 0?`${c.via_diameter} / ${c.via_drill??"—"} mm(外径/钻孔)`:"未设置"},{label:"DRC 排除项",value:String(Array.isArray(m)?m.length:0)}]}function cb(r,n){return`"KiCad项目标注: ${r} / 项: ${n.label} / 值: ${n.value}"`}function db({content:r,filePath:n,localState:s,onInsertAnnotation:l}){const{t:u}=mt(),c=a.useRef(null),[m,g]=a.useState(null),h=a.useMemo(()=>{try{return{items:lb(r,s),error:null}}catch(b){return{items:[],error:b instanceof Error?b.message:String(b)}}},[r,s]),p=m===null?null:h.items[m.index];return h.error?e.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-3 font-mono text-xs text-foreground",children:r}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[s&&e.jsx("div",{className:"border-b border-[color:var(--warning)]/20 bg-[color:var(--warning)]/5 px-3 py-2 text-xs text-[color:var(--warning)]",children:u("rightSidebar.kicadLocalStateNotice")}),e.jsxs("div",{ref:c,className:"relative min-h-0 flex-1",children:[e.jsxs("div",{className:"h-full overflow-auto px-3 py-2",children:[e.jsx("div",{className:"divide-y divide-border/15",children:h.items.map((b,f)=>e.jsxs("button",{type:"button",onClick:x=>{const $=c.current?.getBoundingClientRect(),P=x.currentTarget.getBoundingClientRect();if(!$?.width||!$.height)return;const D=x.clientX||P.left+P.width/2,_=x.clientY||P.top+P.height/2;g({index:f,xPercent:(D-$.left)/$.width*100,yPercent:(_-$.top)/$.height*100})},className:`grid w-full grid-cols-[minmax(7rem,0.8fr)_minmax(0,1.4fr)] gap-3 px-2 py-3 text-left transition hover:bg-surface-2 ${m?.index===f?"bg-primary/10":""}`,children:[e.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:b.label}),e.jsx("span",{className:"break-words text-xs text-foreground",children:b.value})]},b.label))}),e.jsxs("details",{className:"mt-3 border-t border-border/15 pt-3",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-semibold text-muted-foreground",children:u("rightSidebar.kicadShowRawJson")}),e.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre p-2 font-mono text-[10px] leading-relaxed text-foreground",children:r})]})]}),p&&m&&e.jsx(To,{anchor:{xPercent:m.xPercent,yPercent:m.yPercent},title:u("rightSidebar.kicadInsertSetting"),onClick:()=>{l?.(cb(n,p),`kicad-project:${n}:${p.label}`),g(null)},children:u("rightSidebar.kicadInsertSetting")})]}),e.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:p?`${p.label}: ${p.value}`:u("rightSidebar.kicadProjectPickHint")})})]})}const ub=`/** ES Module Shims Wasm @version 2.8.4 */
15
- (function () {
16
-
17
- const self_ = typeof globalThis !== 'undefined' ? globalThis : self;
18
-
19
- let invalidate;
20
- const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
21
- const initHotReload = (topLevelLoad, importShim) => {
22
- let _importHook = importHook,
23
- _resolveHook = resolveHook,
24
- _metaHook = metaHook;
25
-
26
- let defaultResolve;
27
- let hotResolveHook = (id, parent, _defaultResolve) => {
28
- if (!defaultResolve) defaultResolve = _defaultResolve;
29
- const originalParent = stripVersion(parent);
30
- const url = stripVersion(defaultResolve(id, originalParent));
31
- const hotState = getHotState(url);
32
- const parents = hotState.p;
33
- if (!parents.includes(originalParent)) parents.push(originalParent);
34
- return toVersioned(url, hotState);
35
- };
36
- const hotImportHook = (url, _, __, source, sourceType) => {
37
- const hotState = getHotState(url);
38
- hotState.e = typeof source === 'string' ? source : true;
39
- hotState.t = sourceType;
40
- };
41
- const hotMetaHook = (metaObj, url) => (metaObj.hot = new Hot(url));
42
-
43
- const Hot = class Hot {
44
- constructor(url) {
45
- this.data = getHotState((this.url = stripVersion(url))).d;
46
- }
47
- accept(deps, cb) {
48
- if (typeof deps === 'function') {
49
- cb = deps;
50
- deps = null;
51
- }
52
- const hotState = getHotState(this.url);
53
- if (!hotState.A) return;
54
- (hotState.a = hotState.a || []).push([
55
- typeof deps === 'string' ? defaultResolve(deps, this.url)
56
- : deps ? deps.map(d => defaultResolve(d, this.url))
57
- : null,
58
- cb
59
- ]);
60
- }
61
- dispose(cb) {
62
- getHotState(this.url).u = cb;
63
- }
64
- invalidate() {
65
- const hotState = getHotState(this.url);
66
- hotState.a = hotState.A = null;
67
- const seen = [this.url];
68
- hotState.p.forEach(p => invalidate(p, this.url, seen));
69
- }
70
- };
71
-
72
- const versionedRegEx = /\\?v=\\d+$/;
73
- const stripVersion = url => {
74
- const versionMatch = url.match(versionedRegEx);
75
- return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
76
- };
77
-
78
- const toVersioned = (url, hotState) => {
79
- const { v } = hotState;
80
- return url + (v ? '?v=' + v : '');
81
- };
82
-
83
- let hotRegistry = {},
84
- curInvalidationRoots = new Set(),
85
- curInvalidationInterval;
86
- const getHotState = url =>
87
- hotRegistry[url] ||
88
- (hotRegistry[url] = {
89
- // version
90
- v: 0,
91
- // accept list ([deps, cb] pairs)
92
- a: null,
93
- // accepting acceptors
94
- A: true,
95
- // unload callback
96
- u: null,
97
- // entry point or inline script source
98
- e: false,
99
- // hot data
100
- d: {},
101
- // parents
102
- p: [],
103
- // source type
104
- t: undefined
105
- });
106
-
107
- invalidate = (url, fromUrl, seen = []) => {
108
- const hotState = hotRegistry[url];
109
- if (!hotState || seen.includes(url)) return false;
110
- seen.push(url);
111
- hotState.A = false;
112
- if (
113
- fromUrl &&
114
- hotState.a &&
115
- hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
116
- ) {
117
- curInvalidationRoots.add(fromUrl);
118
- } else {
119
- if (hotState.e || hotState.a) curInvalidationRoots.add(url);
120
- hotState.v++;
121
- if (!hotState.a) hotState.p.forEach(p => invalidate(p, url, seen));
122
- }
123
- if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
124
- return true;
125
- };
126
-
127
- const handleInvalidations = () => {
128
- curInvalidationInterval = null;
129
- const earlyRoots = new Set();
130
- for (const root of curInvalidationRoots) {
131
- const hotState = hotRegistry[root];
132
- topLevelLoad(
133
- toVersioned(root, hotState),
134
- baseUrl,
135
- defaultFetchOpts,
136
- typeof hotState.e === 'string' ? hotState.e : undefined,
137
- false,
138
- undefined,
139
- hotState.t
140
- ).then(m => {
141
- if (hotState.a) {
142
- hotState.a.forEach(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
143
- // unload should be the latest unload handler from the just loaded module
144
- if (hotState.u) {
145
- hotState.u(hotState.d);
146
- hotState.u = null;
147
- }
148
- }
149
- hotState.p.forEach(p => {
150
- const hotState = hotRegistry[p];
151
- if (hotState && hotState.a)
152
- hotState.a.forEach(
153
- async ([d, c]) =>
154
- d &&
155
- !earlyRoots.has(c) &&
156
- (typeof d === 'string' ?
157
- d === root && c(m)
158
- : c(await Promise.all(d.map(d => (earlyRoots.add(c), importShim(toVersioned(d, getHotState(d))))))))
159
- );
160
- });
161
- }, throwError);
162
- }
163
- curInvalidationRoots = new Set();
164
- };
165
-
166
- setHooks(
167
- _importHook ? chain(_importHook, hotImportHook) : hotImportHook,
168
- _resolveHook ?
169
- (id, parent, defaultResolve) =>
170
- hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
171
- : hotResolveHook,
172
- _metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
173
- );
174
- };
175
-
176
- const hasDocument = typeof document !== 'undefined';
177
-
178
- const noop = () => {};
179
-
180
- const chain = (a, b) =>
181
- function () {
182
- a.apply(this, arguments);
183
- b.apply(this, arguments);
184
- };
185
-
186
- const dynamicImport = (u, _errUrl) => import(u);
187
-
188
- const defineValue = (obj, prop, value) =>
189
- Object.defineProperty(obj, prop, { writable: false, configurable: false, value });
190
-
191
- const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
192
-
193
- const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
194
- Object.assign(esmsInitOptions, self_.esmsInitOptions || {});
195
-
196
- const version = "2.8.4";
197
-
198
- const r$1 = esmsInitOptions.version;
199
- if (self_.importShim || (r$1 && r$1 !== version)) {
200
- return;
201
- }
202
-
203
- // shim mode is determined on initialization, no late shim mode
204
- const shimMode =
205
- esmsInitOptions.shimMode ||
206
- (hasDocument ?
207
- document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
208
- .length > 0
209
- // Without a document, shim mode is always true as we cannot polyfill
210
- : true);
211
-
212
- let importHook,
213
- resolveHook,
214
- fetchHook = fetch,
215
- sourceHook,
216
- metaHook,
217
- tsTransform =
218
- esmsInitOptions.tsTransform ||
219
- (hasDocument && document.currentScript && document.currentScript.src.replace(/(\\.\\w+)?\\.js$/, '-typescript.js')) ||
220
- './es-module-shims-typescript.js';
221
-
222
- const defaultFetchOpts = { credentials: 'same-origin' };
223
-
224
- const globalHook = name => (typeof name === 'string' ? self_[name] : name);
225
-
226
- if (esmsInitOptions.onimport) importHook = globalHook(esmsInitOptions.onimport);
227
- if (esmsInitOptions.resolve) resolveHook = globalHook(esmsInitOptions.resolve);
228
- if (esmsInitOptions.fetch) fetchHook = globalHook(esmsInitOptions.fetch);
229
- if (esmsInitOptions.source) sourceHook = globalHook(esmsInitOptions.source);
230
- if (esmsInitOptions.meta) metaHook = globalHook(esmsInitOptions.meta);
231
-
232
- const hasCustomizationHooks = importHook || resolveHook || fetchHook !== fetch || sourceHook || metaHook;
233
-
234
- const {
235
- noLoadEventRetriggers,
236
- enforceIntegrity,
237
- hotReload,
238
- hotReloadInterval = 100,
239
- nativePassthrough = !hasCustomizationHooks && !hotReload
240
- } = esmsInitOptions;
241
-
242
- const setHooks = (importHook_, resolveHook_, metaHook_) => (
243
- (importHook = importHook_),
244
- (resolveHook = resolveHook_),
245
- (metaHook = metaHook_)
246
- );
247
-
248
- const mapOverrides = esmsInitOptions.mapOverrides;
249
-
250
- let nonce = esmsInitOptions.nonce;
251
- if (!nonce && hasDocument) {
252
- const nonceElement = document.querySelector('script[nonce]');
253
- if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
254
- }
255
-
256
- const onerror = globalHook(esmsInitOptions.onerror || console.error.bind(console));
257
-
258
- const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
259
- const disable = Array.isArray(esmsInitOptions.polyfillDisable) ? esmsInitOptions.polyfillDisable : [];
260
-
261
- const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
262
- const wasmInstancePhaseEnabled =
263
- enable.includes('wasm-modules') || enable.includes('wasm-module-instances') || enableAll;
264
- const wasmSourcePhaseEnabled =
265
- enable.includes('wasm-modules') || enable.includes('wasm-module-sources') || enableAll;
266
- const deferPhaseEnabled = enable.includes('import-defer') || enableAll;
267
- const cssModulesEnabled = !disable.includes('css-modules');
268
- const jsonModulesEnabled = !disable.includes('json-modules');
269
-
270
- const onpolyfill =
271
- esmsInitOptions.onpolyfill ?
272
- globalHook(esmsInitOptions.onpolyfill)
273
- : () => {
274
- console.log(\`%c^^ Module error above is polyfilled and can be ignored ^^\`, 'font-weight:900;color:#391');
275
- };
276
-
277
- const baseUrl =
278
- hasDocument ? document.baseURI
279
- : typeof location !== 'undefined' ?
280
- \`\${location.protocol}//\${location.host}\${
281
- location.pathname.includes('/') ?
282
- location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
283
- : location.pathname
284
- }\`
285
- : 'about:blank';
286
-
287
- const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
288
- let { skip } = esmsInitOptions;
289
- if (Array.isArray(skip)) {
290
- const l = skip.map(s => new URL(s, baseUrl).href);
291
- skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
292
- } else if (typeof skip === 'string') {
293
- const r = new RegExp(skip);
294
- skip = s => r.test(s);
295
- } else if (skip instanceof RegExp) {
296
- skip = s => skip.test(s);
297
- }
298
-
299
- const dispatchError = error => self_.dispatchEvent(Object.assign(new Event('error'), { error }));
300
-
301
- const throwError = err => {
302
- (self_.reportError || dispatchError)(err);
303
- onerror(err);
304
- };
305
-
306
- const fromParent = parent => (parent ? \` imported from \${parent}\` : '');
307
-
308
- const backslashRegEx = /\\\\/g;
309
-
310
- const asURL = url => {
311
- try {
312
- if (url.indexOf(':') !== -1) return new URL(url).href;
313
- } catch (_) {}
314
- };
315
-
316
- const resolveUrl = (relUrl, parentUrl) =>
317
- resolveIfNotPlainOrUrl(relUrl, parentUrl) || asURL(relUrl) || resolveIfNotPlainOrUrl('./' + relUrl, parentUrl);
318
-
319
- const resolveIfNotPlainOrUrl = (relUrl, parentUrl) => {
320
- const hIdx = parentUrl.indexOf('#'),
321
- qIdx = parentUrl.indexOf('?');
322
- if (hIdx + qIdx > -2)
323
- parentUrl = parentUrl.slice(
324
- 0,
325
- hIdx === -1 ? qIdx
326
- : qIdx === -1 || qIdx > hIdx ? hIdx
327
- : qIdx
328
- );
329
- if (relUrl.indexOf('\\\\') !== -1) relUrl = relUrl.replace(backslashRegEx, '/');
330
- // protocol-relative
331
- if (relUrl[0] === '/' && relUrl[1] === '/') {
332
- return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
333
- }
334
- // relative-url
335
- else if (
336
- (relUrl[0] === '.' &&
337
- (relUrl[1] === '/' ||
338
- (relUrl[1] === '.' && (relUrl[2] === '/' || (relUrl.length === 2 && (relUrl += '/')))) ||
339
- (relUrl.length === 1 && (relUrl += '/')))) ||
340
- relUrl[0] === '/'
341
- ) {
342
- const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
343
- if (parentProtocol === 'blob:') {
344
- throw new TypeError(
345
- \`Failed to resolve module specifier "\${relUrl}". Invalid relative url or base scheme isn't hierarchical.\`
346
- );
347
- }
348
- // Disabled, but these cases will give inconsistent results for deep backtracking
349
- //if (parentUrl[parentProtocol.length] !== '/')
350
- // throw new Error('Cannot resolve');
351
- // read pathname from parent URL
352
- // pathname taken to be part after leading "/"
353
- let pathname;
354
- if (parentUrl[parentProtocol.length + 1] === '/') {
355
- // resolving to a :// so we need to read out the auth and host
356
- if (parentProtocol !== 'file:') {
357
- pathname = parentUrl.slice(parentProtocol.length + 2);
358
- pathname = pathname.slice(pathname.indexOf('/') + 1);
359
- } else {
360
- pathname = parentUrl.slice(8);
361
- }
362
- } else {
363
- // resolving to :/ so pathname is the /... part
364
- pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
365
- }
366
-
367
- if (relUrl[0] === '/') return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
368
-
369
- // join together and split for removal of .. and . segments
370
- // looping the string instead of anything fancy for perf reasons
371
- // '../../../../../z' resolved to 'x/y' is just 'z'
372
- const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
373
-
374
- const output = [];
375
- let segmentIndex = -1;
376
- for (let i = 0; i < segmented.length; i++) {
377
- // busy reading a segment - only terminate on '/'
378
- if (segmentIndex !== -1) {
379
- if (segmented[i] === '/') {
380
- output.push(segmented.slice(segmentIndex, i + 1));
381
- segmentIndex = -1;
382
- }
383
- continue;
384
- }
385
- // new segment - check if it is relative
386
- else if (segmented[i] === '.') {
387
- // ../ segment
388
- if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
389
- output.pop();
390
- i += 2;
391
- continue;
392
- }
393
- // ./ segment
394
- else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
395
- i += 1;
396
- continue;
397
- }
398
- }
399
- // it is the start of a new segment
400
- while (segmented[i] === '/') i++;
401
- segmentIndex = i;
402
- }
403
- // finish reading out the last segment
404
- if (segmentIndex !== -1) output.push(segmented.slice(segmentIndex));
405
- return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
406
- }
407
- };
408
-
409
- const resolveAndComposeImportMap = (json, baseUrl, parentMap) => {
410
- const outMap = {
411
- imports: { ...parentMap.imports },
412
- scopes: { ...parentMap.scopes },
413
- integrity: { ...parentMap.integrity }
414
- };
415
-
416
- if (json.imports) resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
417
-
418
- if (json.scopes)
419
- for (let s in json.scopes) {
420
- const resolvedScope = resolveUrl(s, baseUrl);
421
- resolveAndComposePackages(
422
- json.scopes[s],
423
- outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}),
424
- baseUrl,
425
- parentMap
426
- );
427
- }
428
-
429
- if (json.integrity) resolveAndComposeIntegrity(json.integrity, outMap.integrity, baseUrl);
430
-
431
- return outMap;
432
- };
433
-
434
- const getMatch = (path, matchObj) => {
435
- if (matchObj[path]) return path;
436
- let sepIndex = path.length;
437
- do {
438
- const segment = path.slice(0, sepIndex + 1);
439
- if (segment in matchObj) return segment;
440
- } while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1);
441
- };
442
-
443
- const applyPackages = (id, packages) => {
444
- const pkgName = getMatch(id, packages);
445
- if (pkgName) {
446
- const pkg = packages[pkgName];
447
- if (pkg === null) return;
448
- return pkg + id.slice(pkgName.length);
449
- }
450
- };
451
-
452
- const resolveImportMap = (importMap, resolvedOrPlain, parentUrl) => {
453
- let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
454
- while (scopeUrl) {
455
- const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
456
- if (packageResolution) return packageResolution;
457
- scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
458
- }
459
- return applyPackages(resolvedOrPlain, importMap.imports) || (resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain);
460
- };
461
-
462
- const resolveAndComposePackages = (packages, outPackages, baseUrl, parentMap) => {
463
- for (let p in packages) {
464
- const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
465
- if (
466
- (!shimMode || !mapOverrides) &&
467
- outPackages[resolvedLhs] &&
468
- outPackages[resolvedLhs] !== packages[resolvedLhs]
469
- ) {
470
- console.warn(
471
- \`es-module-shims: Rejected map override "\${resolvedLhs}" from \${outPackages[resolvedLhs]} to \${packages[resolvedLhs]}.\`
472
- );
473
- continue;
474
- }
475
- let target = packages[p];
476
- if (typeof target !== 'string') continue;
477
- const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
478
- if (mapped) {
479
- outPackages[resolvedLhs] = mapped;
480
- continue;
481
- }
482
- console.warn(\`es-module-shims: Mapping "\${p}" -> "\${packages[p]}" does not resolve\`);
483
- }
484
- };
485
-
486
- const resolveAndComposeIntegrity = (integrity, outIntegrity, baseUrl) => {
487
- for (let p in integrity) {
488
- const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
489
- if (
490
- (!shimMode || !mapOverrides) &&
491
- outIntegrity[resolvedLhs] &&
492
- outIntegrity[resolvedLhs] !== integrity[resolvedLhs]
493
- ) {
494
- console.warn(
495
- \`es-module-shims: Rejected map integrity override "\${resolvedLhs}" from \${outIntegrity[resolvedLhs]} to \${integrity[resolvedLhs]}.\`
496
- );
497
- }
498
- outIntegrity[resolvedLhs] = integrity[p];
499
- }
500
- };
501
-
502
- let policy;
503
- if (
504
- typeof self !== 'undefined' &&
505
- (typeof self.trustedTypes !== 'undefined' || typeof self.TrustedTypes !== 'undefined')
506
- ) {
507
- try {
508
- policy = (self.trustedTypes || self.TrustedTypes).createPolicy('es-module-shims', {
509
- createHTML: html => html,
510
- createScript: script => script
511
- });
512
- } catch {}
513
- }
514
-
515
- function maybeTrustedInnerHTML(html) {
516
- return policy ? policy.createHTML(html) : html;
517
- }
518
-
519
- function maybeTrustedScript(script) {
520
- return policy ? policy.createScript(script) : script;
521
- }
522
-
523
- // support browsers without dynamic import support (eg Firefox 6x)
524
- let supportsJsonType = false;
525
- let supportsCssType = false;
526
-
527
- const supports = hasDocument && HTMLScriptElement.supports;
528
-
529
- let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
530
- let supportsWasmInstancePhase = false;
531
- let supportsWasmSourcePhase = false;
532
- let supportsMultipleImportMaps = false;
533
-
534
- const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
535
-
536
- let featureDetectionPromise = (async function () {
537
- // In shim mode, feature detection results are unused — skip the iframe overhead
538
- if (shimMode) return;
539
- if (!hasDocument)
540
- return Promise.all([
541
- import(createBlob(\`import"\${createBlob('{}', 'text/json')}"with{type:"json"}\`)).then(
542
- () => (
543
- (supportsJsonType = true),
544
- import(createBlob(\`import"\${createBlob('', 'text/css')}"with{type:"css"}\`)).then(
545
- () => (supportsCssType = true),
546
- noop
547
- )
548
- ),
549
- noop
550
- ),
551
- wasmInstancePhaseEnabled &&
552
- import(createBlob(\`import"\${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"\`)).then(
553
- () => (supportsWasmInstancePhase = true),
554
- noop
555
- ),
556
- wasmSourcePhaseEnabled &&
557
- import(createBlob(\`import source x from"\${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"\`)).then(
558
- () => (supportsWasmSourcePhase = true),
559
- noop
560
- )
561
- ]);
562
-
563
- const msgTag = \`s\${version}\`;
564
- return new Promise(resolve => {
565
- const iframe = document.createElement('iframe');
566
- iframe.style.display = 'none';
567
- iframe.setAttribute('nonce', nonce);
568
- function cb({ data }) {
569
- const isFeatureDetectionMessage = Array.isArray(data) && data[0] === msgTag;
570
- if (!isFeatureDetectionMessage) return;
571
- [
572
- ,
573
- supportsImportMaps,
574
- supportsMultipleImportMaps,
575
- supportsJsonType,
576
- supportsCssType,
577
- supportsWasmSourcePhase,
578
- supportsWasmInstancePhase
579
- ] = data;
580
- resolve();
581
- document.head.removeChild(iframe);
582
- window.removeEventListener('message', cb, false);
583
- }
584
- window.addEventListener('message', cb, false);
585
- // Feature checking with careful avoidance of unnecessary work - all gated on initial import map supports check. CSS gates on JSON feature check, Wasm instance phase gates on wasm source phase check.
586
- const importMapTest = \`<script nonce=\${nonce || ''}>\${
587
- policy ? 't=(window.trustedTypes||window.TrustedTypes).createPolicy("es-module-shims",{createScript:s=>s});' : ''
588
- }b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));c=u=>import(u).then(()=>true,()=>false);i=innerText=>document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"\${nonce}",text:\${
589
- policy ? 't.createScript(innerText)' : 'innerText'
590
- }}));i(\\\`{"imports":{"x":"\\\${b('')}"}}\\\`);i(\\\`{"imports":{"y":"\\\${b('')}"}}\\\`);cm=\${
591
- supportsImportMaps && jsonModulesEnabled ? \`c(b(\\\`import"\\\${b('{}','text/json')}"with{type:"json"}\\\`))\` : 'false'
592
- };sp=\${
593
- supportsImportMaps && wasmSourcePhaseEnabled ?
594
- \`c(b(\\\`import source x from "\\\${b(new Uint8Array(\${JSON.stringify(wasmBytes)}),'application/wasm')\\}"\\\`))\`
595
- : 'false'
596
- };Promise.all([\${supportsImportMaps ? 'true' : "c('x')"},\${supportsImportMaps ? "c('y')" : false},cm,\${
597
- supportsImportMaps && cssModulesEnabled ?
598
- \`cm.then(s=>s?c(b(\\\`import"\\\${b('','text/css')\\}"with{type:"css"}\\\`)):false)\`
599
- : 'false'
600
- },sp,\${
601
- supportsImportMaps && wasmInstancePhaseEnabled ?
602
- \`\${wasmSourcePhaseEnabled ? 'sp.then(s=>s?' : ''}c(b(\\\`import"\\\${b(new Uint8Array(\${JSON.stringify(wasmBytes)}),'application/wasm')\\}"\\\`))\${wasmSourcePhaseEnabled ? ':false)' : ''}\`
603
- : 'false'
604
- }]).then(a=>parent.postMessage(['\${msgTag}'].concat(a),'*'))<\${''}/script>\`;
605
-
606
- // Safari will call onload eagerly on head injection, but we don't want the Wechat
607
- // path to trigger before setting srcdoc, therefore we track the timing
608
- let readyForOnload = false,
609
- onloadCalledWhileNotReady = false;
610
- function doOnload() {
611
- if (!readyForOnload) {
612
- onloadCalledWhileNotReady = true;
613
- return;
614
- }
615
- // WeChat browser doesn't support setting srcdoc scripts
616
- // But iframe sandboxes don't support contentDocument so we do this as a fallback
617
- const doc = iframe.contentDocument;
618
- if (doc && doc.head.childNodes.length === 0) {
619
- const s = doc.createElement('script');
620
- if (nonce) s.setAttribute('nonce', nonce);
621
- s.innerText = maybeTrustedScript(importMapTest.slice(15 + (nonce ? nonce.length : 0), -9));
622
- doc.head.appendChild(s);
623
- }
624
- }
625
-
626
- iframe.onload = doOnload;
627
- // WeChat browser requires append before setting srcdoc
628
- document.head.appendChild(iframe);
629
-
630
- // setting srcdoc is not supported in React native webviews on iOS
631
- // setting src to a blob URL results in a navigation event in webviews
632
- // document.write gives usability warnings
633
- readyForOnload = true;
634
- if ('srcdoc' in iframe) iframe.srcdoc = maybeTrustedInnerHTML(importMapTest);
635
- else iframe.contentDocument.write(importMapTest);
636
- // retrigger onload for Safari only if necessary
637
- if (onloadCalledWhileNotReady) doOnload();
638
- });
639
- })();
640
-
641
- /* es-module-lexer (minimal) 2.3.1 */
642
- let e,a,r,i=2<<19;const s=1===new Uint8Array(new Uint16Array([1]).buffer)[0]?function(e,a){const r=e.length;let i=0;for(;i<r;)a[i]=e.charCodeAt(i++);}:function(e,a){const r=e.length;let i=0;for(;i<r;){const r=e.charCodeAt(i);a[i++]=(255&r)<<8|r>>>8;}},f="etaourceeferromsyncunctionlassvoyiedelecontininstantybreareturdebuggeawaithrwhileforifcatcfinallelsxportport";let c$1,t,n;function parse(k,l="@"){c$1=k,t=l;const u=2*c$1.length+(2<<18);if(u>i||!e){for(;u>i;)i*=2;a=new ArrayBuffer(i),s(f,new Uint16Array(a,16,108)),e=function(e,a,r){"use asm";var i=new e.Int8Array(r),s=new e.Int16Array(r),f=new e.Int32Array(r),c=new e.Uint8Array(r),t=new e.Uint16Array(r),n=1040;function b(e){e=e|0;var a=0,r=0,c=0,t=0,n=0,b=0,k=0,o=0,w=0,g=0,p=0,y=0,m=0,O=0,T=0;y=s[398]|0;a=f[71]|0;f[68]=a;k=a;p=a;o=y;g=0;e:while(1){r=f[72]|0;t=o<<16>>16==y<<16>>16;c=g&e;b=a;while(1){n=b+2|0;if(b>>>0>=r>>>0){a=0;w=100;break e}a=s[n>>1]|0;if(!(M(a)|0)){if(t){switch(a<<16>>16){case 125:case 93:case 41:case 59:case 44:{w=100;break e}default:{}}if(c?se(a)|0:0){w=100;break e}}if(!(se(a)|0))break}b=n;}f[71]=n;a:do{switch(a<<16>>16){case 101:{if((o<<16>>16==0?Q(n)|0:0)?(S(b+4|0,214,10)|0)==0:0){u();w=89;}else w=89;break}case 105:{if(((s[b+4>>1]|0)==109?Q(n)|0:0)?(S(b+6|0,224,8)|0)==0:0){l();w=89;}else w=89;break}case 99:{if((((s[b+4>>1]|0)==108?Q(n)|0:0)?(S(b+6|0,70,6)|0)==0:0)?L(s[b+12>>1]|0)|0:0){i[800]=1;w=89;}else w=89;break}case 40:{b=f[69]|0;w=o&65535;f[b+(w<<3)>>2]=1;s[398]=o+1<<16>>16;f[b+(w<<3)+4>>2]=k;w=89;break}case 91:{b=f[69]|0;w=o&65535;f[b+(w<<3)>>2]=8;s[398]=o+1<<16>>16;f[b+(w<<3)+4>>2]=k;w=89;break}case 93:if(!(o<<16>>16)){ee();break a}else {s[398]=o+-1<<16>>16;w=89;break a}case 44:{r=s[397]|0;if((!(o<<16>>16==0|r<<16>>16==0)?(f[(f[69]|0)+((o&65535)+-1<<3)>>2]|0)==5:0)?(m=f[(f[70]|0)+((r&65535)+-1<<2)>>2]|0,(f[m+4>>2]|0)==0):0){f[m+4>>2]=p+2;f[71]=b+4;v(1)|0;w=f[71]|0;f[m+16>>2]=w;f[71]=w+-2;w=89;}else w=89;break}case 41:{if(!(o<<16>>16)){ee();break a}w=o+-1<<16>>16;s[398]=w;r=s[397]|0;if(r<<16>>16!=0?(f[(f[69]|0)+((w&65535)<<3)>>2]|0)==5:0){c=f[(f[70]|0)+((r&65535)+-1<<2)>>2]|0;if(!(f[c+4>>2]|0))f[c+4>>2]=p+2;f[c+12>>2]=b+4;s[397]=r+-1<<16>>16;w=89;}else w=89;break}case 123:{w=f[62]|0;do{if((s[p>>1]|0)==41&(w|0)!=0?(f[w+12>>2]|0)==(p+2|0):0){r=f[63]|0;f[62]=r;if(!r){f[58]=0;break}else {f[r+32>>2]=0;break}}}while(0);b=f[69]|0;w=o&65535;f[b+(w<<3)>>2]=(i[800]|0)==0?2:6;s[398]=o+1<<16>>16;f[b+(w<<3)+4>>2]=k;i[800]=0;w=89;break}case 125:{if(!(o<<16>>16)){ee();break a}k=f[69]|0;w=o+-1<<16>>16;s[398]=w;if((f[k+((w&65535)<<3)>>2]|0)==4){d();w=89;}else w=89;break}case 34:case 39:{A(a);w=89;break}case 47:switch(s[b+4>>1]|0){case 47:{F();break a}case 42:{x(1);break a}default:{c=s[p>>1]|0;r:do{if(!($(c)|0)){if(!(c<<16>>16==41?K(f[(f[69]|0)+((o&65535)<<3)+4>>2]|0)|0:0))w=62;}else switch(c<<16>>16){case 46:if(((s[p+-2>>1]|0)+-48&65535)<10){w=62;break r}else break r;case 43:if((s[p+-2>>1]|0)==43){w=62;break r}else break r;case 45:if((s[p+-2>>1]|0)==45){w=62;break r}else break r;default:break r}}while(0);r:do{if((w|0)==62){w=0;if(o<<16>>16!=0?(O=f[69]|0,T=(o&65535)+-1|0,c<<16>>16==102?(f[O+(T<<3)>>2]|0)==1:0):0){if(((s[p+-2>>1]|0)==111?C(p+-4|0)|0:0)?B(f[O+(T<<3)+4>>2]|0,178,3)|0:0)break}else w=67;if((w|0)==67?(0,c<<16>>16==125):0){t=f[69]|0;r=o&65535;if(U(f[t+(r<<3)+4>>2]|0)|0)break;if((f[t+(r<<3)>>2]|0)==6)break}if(!(h(p)|0)){switch(c<<16>>16){case 0:break r;case 47:{if(i[799]|0)break r;break}default:{}}w=f[64]|0;if((w|0?p>>>0>=(f[w>>2]|0)>>>0:0)?p>>>0<=(f[w+4>>2]|0)>>>0:0){I();i[799]=0;w=89;break a}t=f[3]|0;r=p;do{if(r>>>0<=t>>>0)break;r=r+-2|0;f[68]=r;c=s[r>>1]|0;}while(!(D(c)|0));if(M(c)|0){do{if(r>>>0<=t>>>0)break;r=r+-2|0;f[68]=r;}while(M(s[r>>1]|0)|0);if(q(r)|0){I();i[799]=0;w=89;break a}}i[799]=1;w=89;break a}}}while(0);I();i[799]=0;w=89;break a}}case 96:{b=f[69]|0;w=o&65535;f[b+(w<<3)+4>>2]=k;s[398]=o+1<<16>>16;f[b+(w<<3)>>2]=3;d();w=89;break}default:w=89;}}while(0);if((w|0)==89){w=0;f[68]=f[71];}if(i[798]|0){a=0;break}r=f[68]|0;a:do{if((r|0)==(p|0))if(g&((s[398]|0)==y<<16>>16&e)){a=s[f[71]>>1]|0;if(se(a)|0)break e;else a=1;}else a=g;else {if(a<<16>>16==47){a=(i[799]|0)==0;break}if(G(a)|0)a=1;else {switch(a<<16>>16){case 96:case 34:case 39:case 41:case 93:case 125:{a=1;break a}default:{}}a=0;}}}while(0);k=r;p=r;o=s[398]|0;g=a;a=f[71]|0;}if((w|0)==100)f[71]=n;return a|0}function k(){var e=0,a=0,r=0,c=0,t=0,b=0,k=0,o=0,w=0;w=n;n=n+10240|0;s[397]=0;s[398]=0;f[68]=f[2];i[799]=0;f[67]=0;i[798]=0;f[69]=w+2048;f[70]=w;i[800]=0;r=(f[3]|0)+-2|0;f[71]=r;e=r+(f[65]<<1)|0;f[72]=e;e:while(1){a=r+2|0;f[71]=a;if(r>>>0>=e>>>0){c=85;break}e=s[a>>1]|0;a:do{switch(e<<16>>16){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((s[398]|0)==0?Q(a)|0:0)?(S(r+4|0,214,10)|0)==0:0){u();c=84;}else c=84;break}case 105:{if(((s[r+4>>1]|0)==109?Q(a)|0:0)?(S(r+6|0,224,8)|0)==0:0){l();c=84;}else c=84;break}case 99:{if((((s[r+4>>1]|0)==108?Q(a)|0:0)?(S(r+6|0,70,6)|0)==0:0)?L(s[r+12>>1]|0)|0:0){i[800]=1;c=84;}else c=84;break}case 40:{r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)>>2]=1;a=f[68]|0;s[398]=c+1<<16>>16;f[r+((c&65535)<<3)+4>>2]=a;c=84;break}case 91:{r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)>>2]=8;a=f[68]|0;s[398]=c+1<<16>>16;f[r+((c&65535)<<3)+4>>2]=a;c=84;break}case 93:{e=s[398]|0;if(!(e<<16>>16)){c=21;break e}s[398]=e+-1<<16>>16;c=84;break}case 44:{e=s[397]|0;if(((e<<16>>16!=0?(t=s[398]|0,t<<16>>16!=0):0)?(f[(f[69]|0)+((t&65535)+-1<<3)>>2]|0)==5:0)?(b=f[(f[70]|0)+((e&65535)+-1<<2)>>2]|0,(f[b+4>>2]|0)==0):0){f[b+4>>2]=(f[68]|0)+2;f[71]=r+4;v(1)|0;c=f[71]|0;f[b+16>>2]=c;f[71]=c+-2;c=84;}else c=84;break}case 41:{e=s[398]|0;if(!(e<<16>>16)){c=29;break e}s[398]=e+-1<<16>>16;a=s[397]|0;if(a<<16>>16!=0?(f[(f[69]|0)+((e+-1&65535)<<3)>>2]|0)==5:0){e=f[(f[70]|0)+((a&65535)+-1<<2)>>2]|0;if(!(f[e+4>>2]|0))f[e+4>>2]=(f[68]|0)+2;f[e+12>>2]=r+4;s[397]=a+-1<<16>>16;c=84;}else c=84;break}case 123:{e=f[68]|0;c=f[62]|0;do{if((s[e>>1]|0)==41&(c|0)!=0?(f[c+12>>2]|0)==(e+2|0):0){a=f[63]|0;f[62]=a;if(!a){f[58]=0;break}else {f[a+32>>2]=0;break}}}while(0);r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)>>2]=(i[800]|0)==0?2:6;s[398]=c+1<<16>>16;f[r+((c&65535)<<3)+4>>2]=e;i[800]=0;c=84;break}case 125:{e=s[398]|0;if(!(e<<16>>16)){c=42;break e}c=f[69]|0;s[398]=e+-1<<16>>16;if((f[c+((e+-1&65535)<<3)>>2]|0)==4){d();c=84;}else c=84;break}case 34:case 39:{A(e);c=84;break}case 47:switch(s[r+4>>1]|0){case 47:{F();break a}case 42:{x(1);break a}default:{e=f[68]|0;a=s[e>>1]|0;r:do{if(!($(a)|0))if(a<<16>>16==41){r=s[398]|0;if(!(K(f[(f[69]|0)+((r&65535)<<3)+4>>2]|0)|0))c=57;}else c=56;else switch(a<<16>>16){case 46:if(((s[e+-2>>1]|0)+-48&65535)<10){c=56;break r}else break r;case 43:if((s[e+-2>>1]|0)==43){c=56;break r}else break r;case 45:if((s[e+-2>>1]|0)==45){c=56;break r}else break r;default:break r}}while(0);if((c|0)==56){r=s[398]|0;c=57;}r:do{if((c|0)==57){c=0;if(r<<16>>16!=0?(k=f[69]|0,o=(r&65535)+-1|0,a<<16>>16==102?(f[k+(o<<3)>>2]|0)==1:0):0){if(((s[e+-2>>1]|0)==111?C(e+-4|0)|0:0)?B(f[k+(o<<3)+4>>2]|0,178,3)|0:0)break}else c=62;if((c|0)==62?(0,a<<16>>16==125):0){c=f[69]|0;r=r&65535;if(U(f[c+(r<<3)+4>>2]|0)|0)break;if((f[c+(r<<3)>>2]|0)==6)break}if(!(h(e)|0)){switch(a<<16>>16){case 0:break r;case 47:{if(i[799]|0)break r;break}default:{}}c=f[64]|0;if((c|0?e>>>0>=(f[c>>2]|0)>>>0:0)?e>>>0<=(f[c+4>>2]|0)>>>0:0){I();i[799]=0;c=84;break a}r=f[3]|0;do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[68]=e;a=s[e>>1]|0;}while(!(D(a)|0));if(M(a)|0){do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[68]=e;}while(M(s[e>>1]|0)|0);if(q(e)|0){I();i[799]=0;c=84;break a}}i[799]=1;c=84;break a}}}while(0);I();i[799]=0;c=84;break a}}case 96:{r=f[69]|0;c=s[398]|0;f[r+((c&65535)<<3)+4>>2]=f[68];s[398]=c+1<<16>>16;f[r+((c&65535)<<3)>>2]=3;d();c=84;break}default:c=84;}}while(0);if((c|0)==84){c=0;f[68]=f[71];}r=f[71]|0;e=f[72]|0;}if((c|0)==21){ee();e=0;}else if((c|0)==29){ee();e=0;}else if((c|0)==42){ee();e=0;}else if((c|0)==85)e=(i[798]|0)==0?(s[397]|s[398])<<16>>16==0:0;n=w;return e|0}function l(){var e=0,a=0,r=0,c=0,t=0,n=0;n=f[71]|0;f[71]=n+12;e=v(1)|0;r=f[71]|0;e:do{if(e<<16>>16!=46){if(!(e<<16>>16==115&r>>>0>(n+12|0)>>>0)){if(!(e<<16>>16==100&r>>>0>(n+10|0)>>>0)){r=0;t=28;break}if(S(r+2|0,32,8)|0){a=r;e=100;r=0;t=60;break}if(!(L(s[r+10>>1]|0)|0)){a=r;e=100;r=0;t=60;break}f[71]=r+10;e=v(1)|0;if(e<<16>>16==42){e=42;c=2;t=62;break}f[71]=r;r=0;t=28;break}if((S(r+2|0,22,10)|0)==0?L(s[r+12>>1]|0)|0:0){f[71]=r+12;e=v(1)|0;a=f[71]|0;if((a|0)!=(r+12|0)){if(e<<16>>16!=102){r=1;t=28;break}if(S(a+2|0,40,6)|0){e=102;r=1;t=60;break}if(!(D(s[a+8>>1]|0)|0)){e=102;r=1;t=60;break}}f[71]=r;r=0;t=28;}else {a=r;e=115;r=0;t=60;}}else {f[71]=r+2;switch((v(1)|0)<<16>>16){case 109:{e=f[71]|0;if(S(e+2|0,16,6)|0)break e;a=f[68]|0;if(!(N(a)|0)?(s[a>>1]|0)==46:0)break e;g(n,n,e+8|0,2);break e}case 115:{e=f[71]|0;if(S(e+2|0,22,10)|0)break e;a=f[68]|0;if(!(N(a)|0)?(s[a>>1]|0)==46:0)break e;f[71]=e+12;e=v(1)|0;r=1;t=28;break e}case 100:{e=f[71]|0;if(S(e+2|0,32,8)|0)break e;a=f[68]|0;if(!(N(a)|0)?(s[a>>1]|0)==46:0)break e;f[71]=e+10;e=v(1)|0;r=2;t=28;break e}default:break e}}}while(0);e:do{if((t|0)==28){if(e<<16>>16==40){a=f[69]|0;c=s[398]|0;f[a+((c&65535)<<3)>>2]=5;e=f[71]|0;s[398]=c+1<<16>>16;f[a+((c&65535)<<3)+4>>2]=e;if((s[f[68]>>1]|0)==46)break;f[71]=e+2;a=v(1)|0;g(n,f[71]|0,0,e);if(!r)e=f[62]|0;else {e=f[62]|0;f[e+28>>2]=(r|0)==1?5:7;}c=f[70]|0;n=s[397]|0;s[397]=n+1<<16>>16;f[c+((n&65535)<<2)>>2]=e;switch(a<<16>>16){case 39:{A(39);break}case 34:{A(34);break}case 96:{if(!(y()|0))t=37;break}default:t=37;}if((t|0)==37){f[71]=(f[71]|0)+-2;break}e=(f[71]|0)+2|0;f[71]=e;switch((v(1)|0)<<16>>16){case 44:{f[71]=(f[71]|0)+2;v(1)|0;c=f[62]|0;f[c+4>>2]=e;n=f[71]|0;f[c+16>>2]=n;i[c+24>>0]=1;f[71]=n+-2;break e}case 41:{s[398]=(s[398]|0)+-1<<16>>16;n=f[62]|0;f[n+4>>2]=e;f[n+12>>2]=(f[71]|0)+2;i[n+24>>0]=1;s[397]=(s[397]|0)+-1<<16>>16;break e}default:{f[71]=(f[71]|0)+-2;break e}}}if(!((r|0)==0&e<<16>>16==123)){switch(e<<16>>16){case 42:case 39:case 34:{c=r;t=62;break e}default:{}}a=f[71]|0;t=60;break}e=f[71]|0;if(s[398]|0){f[71]=e+-2;break}while(1){if(e>>>0>=(f[72]|0)>>>0)break;e=v(1)|0;if(!(ae(e)|0)){if(e<<16>>16==125){t=50;break}}else A(e);e=(f[71]|0)+2|0;f[71]=e;}if((t|0)==50)f[71]=(f[71]|0)+2;c=(v(1)|0)<<16>>16==102;e=f[71]|0;if(c?S(e+2|0,40,6)|0:0){ee();break}f[71]=e+8;e=v(1)|0;if(ae(e)|0){w(n,e,0);break}else {ee();break}}}while(0);if((t|0)==60)if((a|0)==(n+12|0))f[71]=n+10;else {c=r;t=62;}do{if((t|0)==62){if(!((e<<16>>16==42|(c|0)!=2)&(s[398]|0)==0)){f[71]=(f[71]|0)+-2;break}e=f[72]|0;a=f[71]|0;while(1){if(a>>>0>=e>>>0){t=69;break}r=s[a>>1]|0;if(ae(r)|0){t=67;break}t=a+2|0;f[71]=t;a=t;}if((t|0)==67){w(n,r,c);break}else if((t|0)==69){ee();break}}}while(0);return}function u(){var e=0,a=0,r=0,i=0,c=0,t=0,n=0,k=0,l=0,u=0;k=f[71]|0;l=f[64]|0;f[71]=k+12;a=v(1)|0;e=f[71]|0;if(!((e|0)==(k+12|0)?!(O(a)|0):0))u=3;e:do{if((u|0)==3){a:do{switch(a<<16>>16){case 123:{f[71]=e+2;e=v(1)|0;r=f[71]|0;while(1){if(ae(e)|0){A(e);e=(f[71]|0)+2|0;f[71]=e;}else {H(e)|0;e=f[71]|0;}v(1)|0;e=p(r,e)|0;if(e<<16>>16==44){f[71]=(f[71]|0)+2;e=v(1)|0;}a=r;r=f[71]|0;if(e<<16>>16==125){u=15;break}if((r|0)==(a|0)){u=12;break}if(r>>>0>(f[72]|0)>>>0){u=14;break}}if((u|0)==12){ee();break e}else if((u|0)==14){ee();break e}else if((u|0)==15){f[71]=r+2;u=49;break a}break}case 42:{f[71]=e+2;v(1)|0;u=f[71]|0;p(u,u)|0;u=49;break}case 100:{f[71]=e+14;switch((v(1)|0)<<16>>16){case 97:{a=f[71]|0;if((S(a+2|0,46,8)|0)==0?M(s[a+10>>1]|0)|0:0){f[71]=a+10;v(0)|0;u=21;}break}case 102:{u=21;break}case 99:{a=f[71]|0;if(((S(a+2|0,68,8)|0)==0?(l=s[a+10>>1]|0,L(l)|0|l<<16>>16==123):0)?(f[71]=a+10,r=v(1)|0,r<<16>>16!=123):0){n=r;u=30;}break}default:{}}r:do{if((u|0)==21?(i=f[71]|0,(S(i+2|0,54,14)|0)==0):0){a=s[i+16>>1]|0;if(!(L(a)|0))switch(a<<16>>16){case 40:case 42:break;default:break r}f[71]=i+16;a=v(1)|0;if(a<<16>>16==42){f[71]=(f[71]|0)+2;a=v(1)|0;}if(a<<16>>16!=40){n=a;u=30;}}}while(0);if((u|0)==30?(c=f[71]|0,H(n)|0,t=f[71]|0,t>>>0>c>>>0):0){E(e,e+14|0,c,t);f[71]=(f[71]|0)+-2;break e}E(e,e+14|0,0,0);f[71]=e+12;break e}case 97:{f[71]=e+10;v(0)|0;e=f[71]|0;u=34;break}case 102:{u=34;break}case 99:{if((S(e+2|0,68,8)|0)==0?D(s[e+10>>1]|0)|0:0){f[71]=e+10;u=v(1)|0;l=f[71]|0;H(u)|0;u=f[71]|0;E(l,u,l,u);f[71]=(f[71]|0)+-2;break e}f[71]=e+4;e=e+4|0;u=41;break}case 108:case 118:{u=41;break}default:break e}}while(0);if((u|0)==34){f[71]=e+16;e=v(1)|0;if(e<<16>>16==42){f[71]=(f[71]|0)+2;e=v(1)|0;}l=f[71]|0;H(e)|0;u=f[71]|0;E(l,u,l,u);f[71]=(f[71]|0)+-2;break}else if((u|0)==41){f[71]=e+6;while(1){a=v(1)|0;e=f[71]|0;if(e>>>0>(f[72]|0)>>>0)break;a=P(a)|0;if((f[71]|0)==(e|0))break;if(a<<16>>16==61)a=b(1)|0;e=f[71]|0;if(a<<16>>16!=44)break;f[71]=e+2;}f[71]=e+-2;break}else if((u|0)==49){u=(v(1)|0)<<16>>16==102;e=f[71]|0;if(u?(S(e+2|0,40,6)|0)==0:0){f[71]=e+8;w(k,v(1)|0,0);e=(l|0)==0?236:l+16|0;while(1){e=f[e>>2]|0;if(!e)break e;f[e+12>>2]=0;f[e+8>>2]=0;e=e+16|0;}}f[71]=e+-2;break}}}while(0);return}function o(){var e=0,a=0,r=0,i=0,c=0,t=0,n=0;e=f[71]|0;c=(s[e>>1]|0)==123;f[71]=e+2;e=v(1)|0;t=c?125:93;e:while(1){if((t|0)==(e&65535|0))break;i=f[71]|0;if(i>>>0>(f[72]|0)>>>0)break;if((e<<16>>16==46?(s[i+2>>1]|0)==46:0)?(s[i+4>>1]|0)==46:0){f[71]=i+6;e=P(v(1)|0)|0;}else n=9;a:do{if((n|0)==9){n=0;do{if(c){do{if(e<<16>>16==91){b(0)|0;f[71]=(f[71]|0)+2;a=i;}else {if(ae(e)|0){A(e);f[71]=(f[71]|0)+2;a=i;break}if((e+-48&65535)>=10){H(e)|0;a=f[71]|0;break}e=i;r:while(1){r=e+2|0;a=s[r>>1]|0;i:do{if((a+-48&65535)>=10){switch(a<<16>>16){case 67:case 68:case 70:case 97:case 65:case 99:case 100:case 102:case 46:case 66:case 69:case 79:case 88:case 95:case 98:case 101:case 110:case 111:case 120:break i;case 43:case 45:break;default:break r}switch(s[e>>1]|0){case 69:case 101:break;default:break r}}}while(0);e=r;}f[71]=r;a=i;}}while(0);e=v(1)|0;if(e<<16>>16==58){f[71]=(f[71]|0)+2;e=P(v(1)|0)|0;break}if(a>>>0>i>>>0)E(i,a,i,a);}else if(e<<16>>16==44){f[71]=i+2;e=v(1)|0;break a}else {e=P(e)|0;break}}while(0);if(e<<16>>16==61)e=b(0)|0;if(e<<16>>16!=44)break e;f[71]=(f[71]|0)+2;e=v(1)|0;}}while(0)}return}function h(e){e=e|0;e:do{switch(s[e>>1]|0){case 100:switch(s[e+-2>>1]|0){case 105:{e=B(e+-4|0,76,2)|0;break e}case 108:{e=B(e+-4|0,80,3)|0;break e}default:{e=0;break e}}case 101:switch(s[e+-2>>1]|0){case 115:switch(s[e+-4>>1]|0){case 108:{e=z(e+-6|0,101)|0;break e}case 97:{e=z(e+-6|0,99)|0;break e}default:{e=0;break e}}case 116:{e=B(e+-4|0,86,4)|0;break e}case 117:{e=B(e+-4|0,94,6)|0;break e}default:{e=0;break e}}case 102:{if((s[e+-2>>1]|0)==111?(s[e+-4>>1]|0)==101:0)switch(s[e+-6>>1]|0){case 99:{e=B(e+-8|0,106,6)|0;break e}case 112:{e=B(e+-8|0,118,2)|0;break e}default:{e=0;break e}}else e=0;break}case 107:{e=B(e+-2|0,122,4)|0;break}case 110:{if(z(e+-2|0,105)|0)e=1;else e=B(e+-2|0,130,5)|0;break}case 111:{e=z(e+-2|0,100)|0;break}case 114:{e=B(e+-2|0,140,7)|0;break}case 116:{e=B(e+-2|0,154,4)|0;break}case 119:switch(s[e+-2>>1]|0){case 101:{e=z(e+-4|0,110)|0;break e}case 111:{e=B(e+-4|0,162,3)|0;break e}default:{e=0;break e}}default:e=0;}}while(0);return e|0}function w(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,c=0;i=(f[71]|0)+2|0;switch(a<<16>>16){case 39:{A(39);c=5;break}case 34:{A(34);c=5;break}default:ee();}do{if((c|0)==5){g(e,i,f[71]|0,1);if((r|0)>0)f[(f[62]|0)+28>>2]=(r|0)==1?4:6;f[71]=(f[71]|0)+2;c=(v(0)|0)<<16>>16==119;a=f[71]|0;if(((c?(s[a+2>>1]|0)==105:0)?(s[a+4>>1]|0)==116:0)?(s[a+6>>1]|0)==104:0){f[71]=a+8;if((v(1)|0)<<16>>16!=123){f[71]=a;break}r=f[71]|0;i=r;e:while(1){f[71]=i+2;i=v(1)|0;switch(i<<16>>16){case 39:{A(39);f[71]=(f[71]|0)+2;i=v(1)|0;break}case 34:{A(34);f[71]=(f[71]|0)+2;i=v(1)|0;break}default:i=H(i)|0;}if(i<<16>>16!=58){c=20;break}f[71]=(f[71]|0)+2;switch((v(1)|0)<<16>>16){case 39:{A(39);break}case 34:{A(34);break}default:{c=24;break e}}f[71]=(f[71]|0)+2;switch((v(1)|0)<<16>>16){case 125:{c=28;break e}case 44:break;default:{c=26;break e}}i=(f[71]|0)+2|0;f[71]=i;}if((c|0)==20){f[71]=a;break}else if((c|0)==24){f[71]=a;break}else if((c|0)==26){f[71]=a;break}else if((c|0)==28){c=f[62]|0;f[c+16>>2]=r;f[c+12>>2]=(f[71]|0)+2;break}}f[71]=a+-2;}}while(0);return}function d(){var e=0,a=0,r=0;a=f[72]|0;r=f[71]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){a=10;break}switch(s[e>>1]|0){case 96:{a=7;break e}case 36:{if((s[r+4>>1]|0)==123){a=6;break e}break}case 92:{e=r+4|0;break}default:{}}r=e;}if((a|0)==6){e=r+4|0;f[71]=e;a=f[69]|0;r=s[398]|0;f[a+((r&65535)<<3)>>2]=4;s[398]=r+1<<16>>16;f[a+((r&65535)<<3)+4>>2]=e;}else if((a|0)==7){f[71]=e;a=f[69]|0;r=(s[398]|0)+-1<<16>>16;s[398]=r;if((f[a+((r&65535)<<3)>>2]|0)!=3)ee();}else if((a|0)==10){f[71]=e;ee();}return}function v(e){e=e|0;var a=0,r=0,i=0;r=f[71]|0;e:do{a=s[r>>1]|0;a:do{if(a<<16>>16!=47)if(e)if(L(a)|0)break;else break e;else if(M(a)|0)break;else break e;else switch(s[r+2>>1]|0){case 47:{F();break a}case 42:{x(e);break a}default:{a=47;break e}}}while(0);i=f[71]|0;r=i+2|0;f[71]=r;}while(i>>>0<(f[72]|0)>>>0);return a|0}function A(e){e=e|0;var a=0,r=0,i=0,c=0;c=f[72]|0;a=f[71]|0;while(1){i=a+2|0;if(a>>>0>=c>>>0){a=9;break}r=s[i>>1]|0;if(r<<16>>16==e<<16>>16){a=10;break}if(r<<16>>16==92){r=a+4|0;if((s[r>>1]|0)==13){a=a+6|0;a=(s[a>>1]|0)==10?a:r;}else a=r;}else if(se(r)|0){a=9;break}else a=i;}if((a|0)==9){f[71]=i;ee();}else if((a|0)==10)f[71]=i;return}function C(e){e=e|0;var a=0,r=0;a=s[e>>1]|0;if(L(a)|0)r=3;else switch(a<<16>>16){case 41:case 125:case 93:{r=3;break}default:e=0;}e:do{if((r|0)==3){r=f[3]|0;while(1){if(e>>>0<=r>>>0)break;e=e+-2|0;if(!(L(a)|0))break;a=s[e>>1]|0;}switch(a<<16>>16){case 41:case 125:case 93:{e=1;break e}default:{}}e=(O(a)|0)^1;}}while(0);return e|0}function g(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var c=0,t=0;t=f[66]|0;f[66]=t+36;c=f[62]|0;f[((c|0)==0?232:c+32|0)>>2]=t;f[63]=c;f[62]=t;f[t+8>>2]=e;if(2==(s|0)){e=3;c=r;}else {e=1==(s|0)?1:2;c=1==(s|0)?r+2|0:0;}f[t+12>>2]=c;f[t+28>>2]=e;f[t>>2]=a;f[t+4>>2]=r;f[t+16>>2]=0;f[t+20>>2]=s;i[t+24>>0]=1==(s|0)&1;f[t+32>>2]=0;return}function p(e,a){e=e|0;a=a|0;var r=0,i=0,c=0,t=0;r=f[71]|0;i=s[r>>1]|0;c=(e|0)==(a|0)?0:e;t=(e|0)==(a|0)?0:a;if(i<<16>>16==97){f[71]=r+4;r=v(1)|0;e=f[71]|0;if(ae(r)|0){A(r);a=(f[71]|0)+2|0;f[71]=a;}else {H(r)|0;a=f[71]|0;}i=v(1)|0;r=f[71]|0;}if((r|0)!=(e|0))E(e,a,c,t);return i|0}function y(){var e=0,a=0,r=0,i=0;i=f[71]|0;r=f[72]|0;a=i;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=7;break}switch(s[e>>1]|0){case 96:{a=8;break e}case 92:{e=a+4|0;break}case 36:{if((s[a+4>>1]|0)==123){a=7;break e}break}default:{}}a=e;}if((a|0)==7){f[71]=i;e=0;}else if((a|0)==8){f[71]=e;e=1;}return e|0}function m(){var e=0,a=0,r=0;r=f[72]|0;a=f[71]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=6;break}switch(s[e>>1]|0){case 13:case 10:{a=6;break e}case 93:{a=7;break e}case 92:{e=a+4|0;break}default:{}}a=e;}if((a|0)==6){f[71]=e;ee();e=0;}else if((a|0)==7){f[71]=e;e=93;}return e|0}function I(){var e=0,a=0;e:while(1){e=f[71]|0;f[71]=e+2;if(e>>>0>=(f[72]|0)>>>0){a=7;break}switch(s[e+2>>1]|0){case 13:case 10:{a=7;break e}case 47:break e;case 91:{m()|0;break}case 92:{f[71]=e+4;break}default:{}}}if((a|0)==7)ee();return}function U(e){e=e|0;switch(s[e>>1]|0){case 62:{e=(s[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=B(e+-2|0,188,4)|0;break}case 121:{e=B(e+-2|0,196,6)|0;break}case 101:{e=B(e+-2|0,208,3)|0;break}default:e=0;}return e|0}function x(e){e=e|0;var a=0,r=0,i=0,c=0,t=0;c=(f[71]|0)+2|0;f[71]=c;r=f[72]|0;while(1){a=c+2|0;if(c>>>0>=r>>>0)break;i=s[a>>1]|0;if(!e?se(i)|0:0)break;if(i<<16>>16==42?(s[c+4>>1]|0)==47:0){t=8;break}c=a;}if((t|0)==8){f[71]=a;a=c+4|0;}f[71]=a;return}function S(e,a,r){e=e|0;a=a|0;r=r|0;var s=0,f=0;e:do{if(!r)e=0;else {while(1){s=i[e>>0]|0;f=i[a>>0]|0;if(s<<24>>24!=f<<24>>24)break;r=r+-1|0;if(!r){e=0;break e}else {e=e+1|0;a=a+1|0;}}e=(s&255)-(f&255)|0;}}while(0);return e|0}function O(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:{e=1;break}default:if((e&-8)<<16>>16==40|(e+-58&65535)<6)e=1;else {switch(e<<16>>16){case 91:case 93:case 94:{e=1;break e}default:{}}e=(e+-123&65535)<4;}}}while(0);return e|0}function $(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:break;default:if(!((e+-58&65535)<6|(e+-40&65535)<7&e<<16>>16!=41)){switch(e<<16>>16){case 91:case 94:break e;default:{}}return e<<16>>16!=125&(e+-123&65535)<4|0}}}while(0);return 1}function T(e){e=e|0;var a=0;a=s[e>>1]|0;e:do{if((a+-9&65535)>=5){switch(a<<16>>16){case 160:case 32:{a=1;break e}default:{}}if(O(a)|0)return a<<16>>16!=46|(N(e)|0)|0;else a=0;}else a=1;}while(0);return a|0}function j(e){e=e|0;var a=0,r=0;r=n;n=n+16|0;f[r>>2]=0;f[65]=e;a=f[3]|0;s[a+(e<<1)>>1]=0;f[r>>2]=a+(e<<1)+2;f[66]=a+(e<<1)+2;f[58]=0;f[62]=0;f[60]=0;f[59]=0;f[64]=0;f[61]=0;n=r;return a|0}function B(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,s=0;s=e+(0-r<<1)+2|0;i=f[3]|0;if(s>>>0>=i>>>0?(S(s,a,r<<1)|0)==0:0)if((s|0)==(i|0))i=1;else i=T(e+(0-r<<1)|0)|0;else i=0;return i|0}function E(e,a,r,i){e=e|0;a=a|0;r=r|0;i=i|0;var s=0,c=0;s=f[66]|0;f[66]=s+20;c=f[64]|0;f[((c|0)==0?236:c+16|0)>>2]=s;f[64]=s;f[s>>2]=e;f[s+4>>2]=a;f[s+8>>2]=r;f[s+12>>2]=i;f[s+16>>2]=0;return}function P(e){e=e|0;var a=0;switch(e<<16>>16){case 91:case 123:{o();f[71]=(f[71]|0)+2;break}default:{a=f[71]|0;H(e)|0;e=f[71]|0;if(e>>>0>a>>>0)E(a,e,a,e);}}return v(1)|0}function q(e){e=e|0;switch(s[e>>1]|0){case 107:{e=B(e+-2|0,122,4)|0;break}case 101:{if((s[e+-2>>1]|0)==117)e=B(e+-4|0,94,6)|0;else e=0;break}default:e=0;}return e|0}function z(e,a){e=e|0;a=a|0;var r=0;r=f[3]|0;if(r>>>0<=e>>>0?(s[e>>1]|0)==a<<16>>16:0)if((r|0)==(e|0))r=1;else r=D(s[e+-2>>1]|0)|0;else r=0;return r|0}function D(e){e=e|0;e:do{if((e+-9&65535)<5)e=1;else {switch(e<<16>>16){case 32:case 160:{e=1;break e}default:{}}e=e<<16>>16!=46&(O(e)|0);}}while(0);return e|0}function F(){var e=0,a=0,r=0;e=f[72]|0;r=f[71]|0;e:while(1){a=r+2|0;if(r>>>0>=e>>>0)break;switch(s[a>>1]|0){case 13:case 10:break e;default:r=a;}}f[71]=a;return}function G(e){e=e|0;e:do{if(((e&-33)+-65&65535)<26|(e+-48&65535)<10)e=1;else {switch(e<<16>>16){case 36:case 95:{e=1;break e}default:{}}e=(e&65535)>127;}}while(0);return e|0}function H(e){e=e|0;while(1){if(L(e)|0)break;if(O(e)|0)break;e=(f[71]|0)+2|0;f[71]=e;e=s[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function J(){var e=0;e=f[(f[60]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(f[3]|0)>>1;}return e|0}function K(e){e=e|0;if(!(B(e,168,5)|0)?!(B(e,178,3)|0):0)e=B(e,184,2)|0;else e=1;return e|0}function L(e){e=e|0;switch(e<<16>>16){case 160:case 9:case 10:case 11:case 12:case 13:case 32:{e=1;break}default:e=0;}return e|0}function M(e){e=e|0;switch(e<<16>>16){case 160:case 32:case 12:case 11:case 9:{e=1;break}default:e=0;}return e|0}function N(e){e=e|0;if((s[e>>1]|0)==46?(s[e+-2>>1]|0)==46:0)e=(s[e+-4>>1]|0)==46;else e=0;return e|0}function Q(e){e=e|0;if((f[3]|0)==(e|0))e=1;else e=T(e+-2|0)|0;return e|0}function R(){var e=0;e=f[(f[61]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function V(){var e=0;e=f[(f[60]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function W(){var e=0;e=f[(f[61]|0)+8>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function X(){var e=0;e=f[(f[60]|0)+16>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function Y(){var e=0;e=f[(f[60]|0)+4>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function Z(){var e=0;e=f[60]|0;e=f[((e|0)==0?232:e+32|0)>>2]|0;f[60]=e;return (e|0)!=0|0}function _(){var e=0;e=f[61]|0;e=f[((e|0)==0?236:e+16|0)>>2]|0;f[61]=e;return (e|0)!=0|0}function ee(){i[798]=1;f[67]=(f[71]|0)-(f[3]|0)>>1;f[71]=(f[72]|0)+2;return}function ae(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function re(){return (f[(f[60]|0)+8>>2]|0)-(f[3]|0)>>1|0}function ie(){return (f[(f[61]|0)+4>>2]|0)-(f[3]|0)>>1|0}function se(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function fe(){return (f[f[60]>>2]|0)-(f[3]|0)>>1|0}function ce(){return (f[f[61]>>2]|0)-(f[3]|0)>>1|0}function te(){return c[(f[60]|0)+24>>0]|0|0}function ne(e){e=e|0;f[3]=e;return}function be(){return f[(f[60]|0)+28>>2]|0}function ke(){return f[67]|0}function le(e,a){e=e|0;a=a|0;n=e+a+15&-16;return a}return {su:le,ai:X,e:ke,ee:ie,ele:R,els:W,es:ce,id:J,ie:Y,ip:te,is:fe,it:be,p:k,re:_,ri:Z,sa:j,se:V,ses:ne,ss:re}}("undefined"!=typeof globalThis?globalThis:self,{},a),r=e.su(i-(2<<17),1040);}const h=c$1.length+1;e.ses(r),e.sa(h-1),s(c$1,new Uint16Array(a,r,h)),e.p()||(n=e.e(),o());const w=[],d=[];for(;e.ri();){const a=e.is(),r=e.ie(),i=e.ai(),s=e.id(),f=e.ss(),t=e.se(),n=e.it();let k;e.ip()&&(k=b(-1===s?a:a+1,c$1.charCodeAt(-1===s?a-1:a)));let l=null;w.push({t:n,n:k,s:a,e:r,ss:f,se:t,d:s,a:i,at:l});}for(;e.re();){const a=e.es(),r=e.ee(),i=e.els(),s=e.ele(),f=i<0?void 0:v(i,s),c=v(a,r);d.push({s:a,e:r,ls:i,le:s,n:c,ln:f});}return [w,d];function v(e,a){const r=c$1.charCodeAt(e);return 34===r||39===r?b(e+1,r):c$1.slice(e,a)}}function b(e,a){n=e;let r="",i=n;for(;;){n>=c$1.length&&o();const e=c$1.charCodeAt(n);if(e===a)break;92===e?(r+=c$1.slice(i,n),r+=k(),i=n):(8232===e||8233===e||u(e)&&96!==a&&o(),++n);}return r+=c$1.slice(i,n++),r}function k(){let e=c$1.charCodeAt(++n);switch(++n,e){case 110:return "\\n";case 114:return "\\r";case 120:return String.fromCharCode(l(2));case 117:return function(){const e=c$1.charCodeAt(n);let a;123===e?(++n,a=l(c$1.indexOf("}",n)-n),++n,a>1114111&&o()):a=l(4);return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode(55296+(a>>10),56320+(1023&a)))}();case 116:return "\\t";case 98:return "\\b";case 118:return "\\v";case 102:return "\\f";case 13:10===c$1.charCodeAt(n)&&++n;case 10:return "";case 56:case 57:o();default:if(e>=48&&e<=55){let a=c$1.substr(n-1,3).match(/^[0-7]+/)[0],r=parseInt(a,8);return r>255&&(a=a.slice(0,-1),r=parseInt(a,8)),n+=a.length-1,e=c$1.charCodeAt(n),"0"===a&&56!==e&&57!==e||o(),String.fromCharCode(r)}return u(e)?"":String.fromCharCode(e)}}function l(e){const a=n;let r=0,i=0;for(let a=0;a<e;++a,++n){let e,s=c$1.charCodeAt(n);if(95!==s){if(s>=97)e=s-97+10;else if(s>=65)e=s-65+10;else {if(!(s>=48&&s<=57))break;e=s-48;}if(e>=16)break;i=s,r=16*r+e;}else 95!==i&&0!==a||o(),i=s;}return 95!==i&&n-a===e||o(),r}function u(e){return 13===e||10===e}function o(){throw Object.assign(Error(\`Parse error \${t}:\${c$1.slice(0,n).split("\\n").length}:\${n-c$1.lastIndexOf("\\n",n-1)}\`),{idx:n})}
643
-
644
- const _resolve = (id, parentUrl = baseUrl) => {
645
- const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id);
646
- const firstResolved = firstImportMap && resolveImportMap(firstImportMap, urlResolved || id, parentUrl);
647
- const composedResolved =
648
- composedImportMap === firstImportMap ? firstResolved : (
649
- resolveImportMap(composedImportMap, urlResolved || id, parentUrl)
650
- );
651
- const resolved = composedResolved || firstResolved || throwUnresolved(id, parentUrl);
652
- // needsShim, shouldShim per load record to set on parent
653
- let n = false,
654
- N = false;
655
- if (!supportsImportMaps) {
656
- // bare specifier -> needs shim
657
- if (!urlResolved) n = true;
658
- // url mapping -> should shim
659
- else if (urlResolved !== resolved) N = true;
660
- } else if (!supportsMultipleImportMaps) {
661
- // bare specifier and not resolved by first import map -> needs shim
662
- if (!urlResolved && !firstResolved) n = true;
663
- // resolution doesn't match first import map -> should shim
664
- if (firstResolved && resolved !== firstResolved) N = true;
665
- }
666
- return { r: resolved, n, N };
667
- };
668
-
669
- const resolve = (id, parentUrl) => {
670
- if (!resolveHook) return _resolve(id, parentUrl);
671
- const result = resolveHook(id, parentUrl, defaultResolve);
672
-
673
- return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
674
- };
675
-
676
- // import()
677
- async function importShim(id, opts, parentUrl) {
678
- if (typeof opts === 'string') {
679
- parentUrl = opts;
680
- opts = undefined;
681
- }
682
- await initPromise; // needed for shim check
683
- if (shimMode || !baselineSupport) {
684
- if (hasDocument) processScriptsAndPreloads();
685
- legacyAcceptingImportMaps = false;
686
- }
687
- let sourceType = undefined;
688
- if (typeof opts === 'object') {
689
- if (opts.lang === 'ts') sourceType = 'ts';
690
- if (typeof opts.with === 'object' && typeof opts.with.type === 'string') {
691
- sourceType = opts.with.type;
692
- }
693
- }
694
- return topLevelLoad(id, parentUrl || baseUrl, defaultFetchOpts, undefined, undefined, undefined, sourceType);
695
- }
696
-
697
- // import.source()
698
- // (opts not currently supported as no use cases yet)
699
- if (shimMode || wasmSourcePhaseEnabled)
700
- importShim.source = async (id, opts, parentUrl) => {
701
- if (typeof opts === 'string') {
702
- parentUrl = opts;
703
- opts = undefined;
704
- }
705
- await initPromise; // needed for shim check
706
- if (shimMode || !baselineSupport) {
707
- if (hasDocument) processScriptsAndPreloads();
708
- legacyAcceptingImportMaps = false;
709
- }
710
- await importMapPromise;
711
- const url = resolve(id, parentUrl || baseUrl).r;
712
- const load = getOrCreateLoad(url, defaultFetchOpts, undefined, undefined);
713
- await load.f;
714
- return importShim._s[load.r];
715
- };
716
-
717
- // import.defer() is just a proxy for import(), since we can't actually defer
718
- if (shimMode || deferPhaseEnabled) importShim.defer = importShim;
719
-
720
- if (hotReload) {
721
- initHotReload(topLevelLoad, importShim);
722
- importShim.hotReload = hotReload$1;
723
- }
724
-
725
- const defaultResolve = (id, parentUrl) => {
726
- return (
727
- resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
728
- throwUnresolved(id, parentUrl)
729
- );
730
- };
731
-
732
- const throwUnresolved = (id, parentUrl) => {
733
- throw Error(\`Unable to resolve specifier '\${id}'\${fromParent(parentUrl)}\`);
734
- };
735
-
736
- const metaResolve = function (id, parentUrl = this.url) {
737
- return resolve(id, \`\${parentUrl}\`).r;
738
- };
739
-
740
- importShim.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
741
- importShim.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
742
- importShim.addImportMap = importMapIn => {
743
- if (!shimMode) throw new Error('Unsupported in polyfill mode.');
744
- composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
745
- };
746
- importShim.version = version;
747
-
748
- const registry = (importShim._r = {});
749
- // Wasm caches
750
- const sourceCache = (importShim._s = {});
751
- /* const instanceCache = */ importShim._i = new WeakMap();
752
-
753
- // Ensure this version is the only version
754
- defineValue(self_, 'importShim', Object.freeze(importShim));
755
- const shimModeOptions = { ...esmsInitOptions, shimMode: true };
756
- if (optionsScript) optionsScript.innerText = maybeTrustedScript(JSON.stringify(shimModeOptions));
757
- self_.esmsInitOptions = shimModeOptions;
758
-
759
- const loadAll = async (load, seen) => {
760
- seen[load.u] = 1;
761
- await load.L;
762
- await Promise.all(
763
- load.d.map(({ l: dep, s: sourcePhase }) => {
764
- if (dep.b || seen[dep.u]) return;
765
- if (sourcePhase) return dep.f;
766
- return loadAll(dep, seen);
767
- })
768
- );
769
- };
770
-
771
- let importMapSrc = false;
772
- let multipleImportMaps = false;
773
- let firstImportMap = null;
774
- // To support polyfilling multiple import maps, we separately track the composed import map from the first import map
775
- let composedImportMap = { imports: {}, scopes: {}, integrity: {} };
776
- let baselineSupport;
777
-
778
- const initPromise = featureDetectionPromise.then(() => {
779
- baselineSupport =
780
- supportsImportMaps &&
781
- (!jsonModulesEnabled || supportsJsonType) &&
782
- (!cssModulesEnabled || supportsCssType) &&
783
- (!wasmInstancePhaseEnabled || supportsWasmInstancePhase) &&
784
- (!wasmSourcePhaseEnabled || supportsWasmSourcePhase) &&
785
- !deferPhaseEnabled &&
786
- (!multipleImportMaps || supportsMultipleImportMaps) &&
787
- !importMapSrc &&
788
- !hasCustomizationHooks;
789
- if (!shimMode && typeof WebAssembly !== 'undefined') {
790
- if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
791
- const s = Symbol();
792
- const brand = m => defineValue(m, s, 'WebAssembly.Module');
793
- class AbstractModuleSource {
794
- get [Symbol.toStringTag]() {
795
- if (this[s]) return this[s];
796
- throw new TypeError('Not an AbstractModuleSource');
797
- }
798
- }
799
- const { Module: wasmModule, compile: wasmCompile, compileStreaming: wasmCompileStreaming } = WebAssembly;
800
- WebAssembly.Module = Object.setPrototypeOf(
801
- Object.assign(function Module(...args) {
802
- return brand(new wasmModule(...args));
803
- }, wasmModule),
804
- AbstractModuleSource
805
- );
806
- WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
807
- WebAssembly.compile = function compile(...args) {
808
- return wasmCompile(...args).then(brand);
809
- };
810
- WebAssembly.compileStreaming = function compileStreaming(...args) {
811
- return wasmCompileStreaming(...args).then(brand);
812
- };
813
- }
814
- }
815
- if (hasDocument) {
816
- if (!supportsImportMaps) {
817
- const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
818
- HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
819
- }
820
- if (shimMode || !baselineSupport) {
821
- attachMutationObserver();
822
- if (document.readyState === 'complete') {
823
- readyStateCompleteCheck();
824
- } else {
825
- document.addEventListener('readystatechange', readyListener);
826
- }
827
- }
828
- processScriptsAndPreloads();
829
- }
830
- return undefined;
831
- });
832
-
833
- const attachMutationObserver = () => {
834
- const observer = new MutationObserver(mutations => {
835
- for (const mutation of mutations) {
836
- if (mutation.type !== 'childList') continue;
837
- for (const node of mutation.addedNodes) {
838
- if (node.tagName === 'SCRIPT') {
839
- if (node.type === (shimMode ? 'module-shim' : 'module') && !node.ep) processScript(node, true);
840
- if (node.type === (shimMode ? 'importmap-shim' : 'importmap') && !node.ep) processImportMap(node, true);
841
- } else if (
842
- node.tagName === 'LINK' &&
843
- node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload') &&
844
- !node.ep
845
- ) {
846
- processPreload(node);
847
- }
848
- }
849
- }
850
- });
851
- observer.observe(document, { childList: true });
852
- observer.observe(document.head, { childList: true });
853
- processScriptsAndPreloads();
854
- };
855
-
856
- let importMapPromise = initPromise;
857
- let firstPolyfillLoad = true;
858
- let legacyAcceptingImportMaps = true;
859
-
860
- async function topLevelLoad(
861
- url,
862
- parentUrl,
863
- fetchOpts,
864
- source,
865
- nativelyLoaded,
866
- lastStaticLoadPromise,
867
- sourceType
868
- ) {
869
- await initPromise;
870
- await importMapPromise;
871
- url = (await resolve(url, parentUrl)).r;
872
-
873
- // we mock import('./x.css', { with: { type: 'css' }}) support via an inline static reexport
874
- // because we can't syntactically pass through to dynamic import with a second argument
875
- if (sourceType === 'css' || sourceType === 'json') {
876
- // Direct reexport for hot reloading skipped due to Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=1965620
877
- source = \`import m from'\${url}'with{type:"\${sourceType}"};export default m;\`;
878
- url += '?entry';
879
- }
880
-
881
- if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl, source, sourceType);
882
- // early analysis opt-out - no need to even fetch if we have feature support
883
- if (!shimMode && baselineSupport && nativePassthrough && sourceType !== 'ts') {
884
- // for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
885
- if (nativelyLoaded) return null;
886
- await lastStaticLoadPromise;
887
- return dynamicImport(source ? createBlob(source) : url);
888
- }
889
- const load = getOrCreateLoad(url, fetchOpts, undefined, source);
890
- linkLoad(load, fetchOpts);
891
- const seen = {};
892
- await loadAll(load, seen);
893
- resolveDeps(load, seen);
894
- await lastStaticLoadPromise;
895
- if (!shimMode && !load.n) {
896
- if (nativelyLoaded) {
897
- return;
898
- }
899
- if (source) {
900
- return await dynamicImport(createBlob(source));
901
- }
902
- }
903
- if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
904
- onpolyfill();
905
- firstPolyfillLoad = false;
906
- }
907
- const module = await (shimMode || load.n || load.N || !nativePassthrough || (!nativelyLoaded && source) ?
908
- dynamicImport(load.b, load.u)
909
- : import(load.u));
910
- // if the top-level load is a shell, run its update function
911
- if (load.s) (await dynamicImport(load.s, load.u)).u$_(module);
912
- revokeObjectURLs(Object.keys(seen));
913
- return module;
914
- }
915
-
916
- const revokeObjectURLs = registryKeys => {
917
- let curIdx = 0;
918
- const handler = self_.requestIdleCallback || self_.requestAnimationFrame || (fn => setTimeout(fn, 0));
919
- handler(cleanup);
920
- function cleanup() {
921
- for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
922
- const load = registry[key];
923
- if (load && load.b && load.b !== load.u) URL.revokeObjectURL(load.b);
924
- }
925
- if (curIdx < registryKeys.length) handler(cleanup);
926
- }
927
- };
928
-
929
- const urlJsString = url => \`'\${url.replace(/'/g, "\\\\'")}'\`;
930
-
931
- let resolvedSource, lastIndex;
932
- const pushStringTo = (load, originalIndex, dynamicImportEndStack) => {
933
- while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
934
- const dynamicImportEnd = dynamicImportEndStack.pop();
935
- resolvedSource += \`\${load.S.slice(lastIndex, dynamicImportEnd)}, \${urlJsString(load.r)}\`;
936
- lastIndex = dynamicImportEnd;
937
- }
938
- resolvedSource += load.S.slice(lastIndex, originalIndex);
939
- lastIndex = originalIndex;
940
- };
941
-
942
- const pushSourceURL = (load, commentPrefix, commentStart, dynamicImportEndStack) => {
943
- const urlStart = commentStart + commentPrefix.length;
944
- const commentEnd = load.S.indexOf('\\n', urlStart);
945
- const urlEnd = commentEnd !== -1 ? commentEnd : load.S.length;
946
- let sourceUrl = load.S.slice(urlStart, urlEnd);
947
- try {
948
- sourceUrl = new URL(sourceUrl, load.r).href;
949
- } catch (e) {}
950
- pushStringTo(load, urlStart, dynamicImportEndStack);
951
- resolvedSource += sourceUrl;
952
- lastIndex = urlEnd;
953
- };
954
-
955
- const resolveDeps = (load, seen) => {
956
- if (load.b || !seen[load.u]) return;
957
- seen[load.u] = 0;
958
-
959
- for (const { l: dep, s: sourcePhase } of load.d) {
960
- if (!sourcePhase) resolveDeps(dep, seen);
961
- }
962
-
963
- if (!load.n) load.n = load.d.some(dep => dep.l.n);
964
- if (!load.N) load.N = load.d.some(dep => dep.l.N);
965
-
966
- // use native loader whenever possible (n = needs shim) via executable subgraph passthrough
967
- // so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
968
- if (nativePassthrough && !shimMode && !load.n && !load.N) {
969
- load.b = load.u;
970
- load.S = undefined;
971
- return;
972
- }
973
-
974
- const [imports, exports] = load.a;
975
-
976
- // "execution"
977
- let source = load.S,
978
- depIndex = 0,
979
- dynamicImportEndStack = [];
980
-
981
- // once all deps have loaded we can inline the dependency resolution blobs
982
- // and define this blob
983
- resolvedSource = '';
984
- lastIndex = 0;
985
-
986
- for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a, at } of imports) {
987
- // source phase
988
- if (t === 4) {
989
- let { l: depLoad } = load.d[depIndex++];
990
- pushStringTo(load, statementStart, dynamicImportEndStack);
991
- resolvedSource += \`\${source.slice(statementStart, start - 1).replace('source', '')}/*\${source.slice(start - 1, end + 1)}*/'\${createBlob(\`export default importShim._s[\${urlJsString(depLoad.r)}]\`)}'\`;
992
- lastIndex = end + 1;
993
- }
994
- // dependency source replacements
995
- else if (dynamicImportIndex === -1) {
996
- let keepAssertion = false;
997
- if (a > 0 && !shimMode) {
998
- // strip assertions only when unsupported in polyfill mode
999
- // minimal lexer builds do not provide parsed attributes, so sniff the assertion source directly
1000
- const assertion = source.slice(a, statementEnd - 1);
1001
- keepAssertion =
1002
- nativePassthrough &&
1003
- ((supportsJsonType && assertion.includes('json')) || (supportsCssType && assertion.includes('css')));
1004
- }
1005
-
1006
- // defer phase stripping
1007
- if (t === 6) {
1008
- pushStringTo(load, statementStart, dynamicImportEndStack);
1009
- resolvedSource += source.slice(statementStart, start - 1).replace('defer', '');
1010
- lastIndex = start;
1011
- }
1012
- let { l: depLoad } = load.d[depIndex++],
1013
- blobUrl = depLoad.b,
1014
- cycleShell = !blobUrl;
1015
- if (cycleShell) {
1016
- // circular shell creation
1017
- if (!(blobUrl = depLoad.s)) {
1018
- blobUrl = depLoad.s = createBlob(
1019
- \`export function u$_(m){\${depLoad.a[1]
1020
- .map(({ s, e }, i) => {
1021
- const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
1022
- return \`e$_\${i}=m\${q ? \`[\` : '.'}\${depLoad.S.slice(s, e)}\${q ? \`]\` : ''}\`;
1023
- })
1024
- .join(',')}}\${
1025
- depLoad.a[1].length ? \`let \${depLoad.a[1].map((_, i) => \`e$_\${i}\`).join(',')};\` : ''
1026
- }export {\${depLoad.a[1]
1027
- .map(({ s, e }, i) => \`e$_\${i} as \${depLoad.S.slice(s, e)}\`)
1028
- .join(',')}}\\n//# sourceURL=\${depLoad.r}?cycle\`
1029
- );
1030
- }
1031
- }
1032
-
1033
- pushStringTo(load, start - 1, dynamicImportEndStack);
1034
- resolvedSource += \`/*\${source.slice(start - 1, end + 1)}*/'\${blobUrl}'\`;
1035
-
1036
- // circular shell execution
1037
- if (!cycleShell && depLoad.s) {
1038
- resolvedSource += \`;import*as m$_\${depIndex} from'\${depLoad.b}';import{u$_ as u$_\${depIndex}}from'\${depLoad.s}';u$_\${depIndex}(m$_\${depIndex})\`;
1039
- depLoad.s = undefined;
1040
- }
1041
- lastIndex = keepAssertion ? end + 1 : statementEnd;
1042
- }
1043
- // import.meta
1044
- else if (dynamicImportIndex === -2) {
1045
- load.m = { url: load.r, resolve: metaResolve };
1046
- if (metaHook) metaHook(load.m, load.u);
1047
- pushStringTo(load, start, dynamicImportEndStack);
1048
- resolvedSource += \`importShim._r[\${urlJsString(load.u)}].m\`;
1049
- lastIndex = statementEnd;
1050
- }
1051
- // dynamic import
1052
- else {
1053
- pushStringTo(load, statementStart + 6, dynamicImportEndStack);
1054
- resolvedSource += \`Shim\${t === 5 ? '.source' : ''}(\`;
1055
- dynamicImportEndStack.push(statementEnd - 1);
1056
- lastIndex = start;
1057
- }
1058
- }
1059
-
1060
- // support progressive cycle binding updates (try statement avoids tdz errors)
1061
- if (load.s && (imports.length === 0 || imports[imports.length - 1].d === -1))
1062
- resolvedSource += \`\\n;import{u$_}from'\${load.s}';try{u$_({\${exports
1063
- .filter(e => e.ln)
1064
- .map(({ s, e, ln }) => \`\${source.slice(s, e)}:\${ln}\`)
1065
- .join(',')}})}catch(_){};\\n\`;
1066
-
1067
- let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
1068
- let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
1069
-
1070
- // ignore sourceMap comments before already spliced code
1071
- if (sourceURLCommentStart < lastIndex) sourceURLCommentStart = -1;
1072
- if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
1073
-
1074
- // sourceURL first / only
1075
- if (
1076
- sourceURLCommentStart !== -1 &&
1077
- (sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)
1078
- ) {
1079
- pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
1080
- }
1081
- // sourceMappingURL
1082
- if (sourceMapURLCommentStart !== -1) {
1083
- pushSourceURL(load, sourceMapURLCommentPrefix, sourceMapURLCommentStart, dynamicImportEndStack);
1084
- // sourceURL last
1085
- if (sourceURLCommentStart !== -1 && sourceURLCommentStart > sourceMapURLCommentStart)
1086
- pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
1087
- }
1088
-
1089
- pushStringTo(load, source.length, dynamicImportEndStack);
1090
-
1091
- if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
1092
-
1093
- load.b = createBlob(resolvedSource);
1094
- load.S = resolvedSource = undefined;
1095
- };
1096
-
1097
- const sourceURLCommentPrefix = '\\n//# sourceURL=';
1098
- const sourceMapURLCommentPrefix = '\\n//# sourceMappingURL=';
1099
- const cssUrlRegEx = /url\\(\\s*(?:(["'])((?:\\\\.|[^\\n\\\\"'])+)\\1|((?:\\\\.|[^\\s,"'()\\\\])+))\\s*\\)/g;
1100
-
1101
- // restrict in-flight fetches to a pool of 100
1102
- let p = [];
1103
- let c = 0;
1104
- const pushFetchPool = () => {
1105
- if (++c > 100) return new Promise(r => p.push(r));
1106
- };
1107
- const popFetchPool = () => {
1108
- c--;
1109
- if (p.length) p.shift()();
1110
- };
1111
-
1112
- const doFetch = async (url, fetchOpts, parent) => {
1113
- if (enforceIntegrity && !fetchOpts.integrity) throw Error(\`No integrity for \${url}\${fromParent(parent)}.\`);
1114
- let res,
1115
- poolQueue = pushFetchPool();
1116
- if (poolQueue) await poolQueue;
1117
- try {
1118
- res = await fetchHook(url, fetchOpts);
1119
- } catch (e) {
1120
- e.message = \`Unable to fetch \${url}\${fromParent(parent)} - see network log for details.\\n\` + e.message;
1121
- throw e;
1122
- } finally {
1123
- popFetchPool();
1124
- }
1125
-
1126
- if (!res.ok) {
1127
- const error = new TypeError(\`\${res.status} \${res.statusText} \${res.url}\${fromParent(parent)}\`);
1128
- error.response = res;
1129
- throw error;
1130
- }
1131
- return res;
1132
- };
1133
-
1134
- let esmsTsTransform;
1135
- const initTs = async () => {
1136
- const m = await import(tsTransform);
1137
- if (!esmsTsTransform) esmsTsTransform = m.transform;
1138
- };
1139
-
1140
- async function defaultSourceHook(url, fetchOpts, parent) {
1141
- let res = await doFetch(url, fetchOpts, parent),
1142
- contentType,
1143
- [, json, type, jsts] =
1144
- (contentType = res.headers.get('content-type') || '').match(
1145
- /^(?:[^/;]+\\/(?:[^/+;]+\\+)?(json)|(?:text|application)\\/(?:x-)?((java|type)script|wasm|css))(?:;|$)/
1146
- ) || [];
1147
- if (!(type = json || (jsts ? jsts[0] + 's' : type || (/\\.m?ts(\\?|#|$)/.test(url) && 'ts')))) {
1148
- throw Error(
1149
- \`Unsupported Content-Type "\${contentType}" loading \${url}\${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.\`
1150
- );
1151
- }
1152
- return {
1153
- url: res.url,
1154
- source: await (type > 'v' ? WebAssembly.compileStreaming(res) : res.text()),
1155
- type
1156
- };
1157
- }
1158
-
1159
- const hotPrefix = 'var h=import.meta.hot,';
1160
- const fetchModule = async (reqUrl, fetchOpts, parent) => {
1161
- const mapIntegrity = composedImportMap.integrity[reqUrl];
1162
- fetchOpts = mapIntegrity && !fetchOpts.integrity ? { ...fetchOpts, integrity: mapIntegrity } : fetchOpts;
1163
- let {
1164
- url = reqUrl,
1165
- source,
1166
- type
1167
- } = (await (sourceHook || defaultSourceHook)(reqUrl, fetchOpts, parent, defaultSourceHook)) || {};
1168
- if (type === 'wasm') {
1169
- const exports = WebAssembly.Module.exports((sourceCache[url] = source));
1170
- const imports = WebAssembly.Module.imports(source);
1171
- const rStr = urlJsString(url);
1172
- source = \`import*as $_ns from\${rStr};\`;
1173
- let i = 0,
1174
- obj = '';
1175
- for (const { module, kind } of imports) {
1176
- const specifier = urlJsString(module);
1177
- source += \`import*as impt\${i} from\${specifier};\\n\`;
1178
- obj += \`\${specifier}:\${kind === 'global' ? \`importShim._i.get(impt\${i})||impt\${i++}\` : \`impt\${i++}\`},\`;
1179
- }
1180
- source += \`\${hotPrefix}i=await WebAssembly.instantiate(importShim._s[\${rStr}],{\${obj}});importShim._i.set($_ns,i);\`;
1181
- obj = '';
1182
- for (const { name, kind } of exports) {
1183
- source += \`export let \${name}=i.exports['\${name}'];\`;
1184
- if (kind === 'global') source += \`try{\${name}=\${name}.value}catch(_){\${name}=undefined}\`;
1185
- obj += \`\${name},\`;
1186
- }
1187
- source += \`if(h)h.accept(m=>({\${obj}}=m))\`;
1188
- } else if (type === 'json') {
1189
- source = \`\${hotPrefix}j=JSON.parse(\${JSON.stringify(source)});export{j as default};if(h)h.accept(m=>j=m.default)\`;
1190
- } else if (type === 'css') {
1191
- source = \`\${hotPrefix}s=h&&h.data.s||new CSSStyleSheet();s.replaceSync(\${JSON.stringify(
1192
- source.replace(
1193
- cssUrlRegEx,
1194
- (_match, quotes = '', relUrl1, relUrl2) => \`url(\${quotes}\${resolveUrl(relUrl1 || relUrl2, url)}\${quotes})\`
1195
- )
1196
- )});if(h){h.data.s=s;h.accept(()=>{})}export default s\`;
1197
- } else if (type === 'ts') {
1198
- if (!esmsTsTransform) await initTs();
1199
- const transformed = esmsTsTransform(source, url);
1200
- // even if the TypeScript is valid JavaScript, unless it was a top-level inline source, it wasn't served with
1201
- // a valid JS MIME here, so we must still polyfill it
1202
- source = transformed === undefined ? source : transformed;
1203
- }
1204
- return { url, source, type };
1205
- };
1206
-
1207
- const getOrCreateLoad = (url, fetchOpts, parent, source) => {
1208
- if (source && registry[url]) {
1209
- let i = 0;
1210
- while (registry[url + '#' + ++i]);
1211
- url += '#' + i;
1212
- }
1213
- let load = registry[url];
1214
- if (load) return load;
1215
- registry[url] = load = {
1216
- // url
1217
- u: url,
1218
- // response url
1219
- r: source ? url : undefined,
1220
- // fetchPromise
1221
- f: undefined,
1222
- // source
1223
- S: source,
1224
- // linkPromise
1225
- L: undefined,
1226
- // analysis
1227
- a: undefined,
1228
- // deps
1229
- d: undefined,
1230
- // blobUrl
1231
- b: undefined,
1232
- // shellUrl
1233
- s: undefined,
1234
- // needsShim: does it fail execution in the current native loader?
1235
- n: false,
1236
- // shouldShim: does it need to be loaded by the polyfill loader?
1237
- N: false,
1238
- // type
1239
- t: null,
1240
- // meta
1241
- m: null
1242
- };
1243
- load.f = (async () => {
1244
- if (load.S === undefined) {
1245
- // preload fetch options override fetch options (race)
1246
- ({ url: load.r, source: load.S, type: load.t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
1247
- if (
1248
- !load.n &&
1249
- load.t !== 'js' &&
1250
- !shimMode &&
1251
- ((load.t === 'css' && !supportsCssType) ||
1252
- (load.t === 'json' && !supportsJsonType) ||
1253
- (load.t === 'wasm' && !supportsWasmInstancePhase && !supportsWasmSourcePhase) ||
1254
- load.t === 'ts')
1255
- ) {
1256
- load.n = true;
1257
- }
1258
- }
1259
- try {
1260
- load.a = parse(load.S, load.u);
1261
- } catch (e) {
1262
- throwError(e);
1263
- load.a = [[], [], false];
1264
- }
1265
- return load;
1266
- })();
1267
- return load;
1268
- };
1269
-
1270
- const featErr = feat =>
1271
- Error(
1272
- \`\${feat} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["\${feat}"] }<\${''}/script>\`
1273
- );
1274
-
1275
- const linkLoad = (load, fetchOpts) => {
1276
- if (load.L) return;
1277
- load.L = load.f.then(() => {
1278
- let childFetchOpts = fetchOpts;
1279
- load.d = load.a[0]
1280
- .map(({ n, d, t, a, se }) => {
1281
- const phaseImport = t >= 4;
1282
- const sourcePhase = phaseImport && t < 6;
1283
- if (phaseImport) {
1284
- if (!shimMode && (sourcePhase ? !wasmSourcePhaseEnabled : !deferPhaseEnabled))
1285
- throw featErr(sourcePhase ? 'wasm-module-sources' : 'import-defer');
1286
- if (!sourcePhase || !supportsWasmSourcePhase) load.n = true;
1287
- }
1288
- let source = undefined;
1289
- if (a > 0 && !shimMode && nativePassthrough) {
1290
- const assertion = load.S.slice(a, se - 1);
1291
- // no need to fetch JSON/CSS if supported, since it's a leaf node, we'll just strip the assertion syntax
1292
- if (assertion.includes('json')) {
1293
- if (supportsJsonType) source = '';
1294
- else load.n = true;
1295
- } else if (assertion.includes('css')) {
1296
- if (supportsCssType) source = '';
1297
- else load.n = true;
1298
- }
1299
- }
1300
- if (d !== -1 || !n) return;
1301
- const resolved = resolve(n, load.r || load.u);
1302
- if (resolved.n || hasCustomizationHooks) load.n = true;
1303
- if (d >= 0 || resolved.N) load.N = true;
1304
- if (d !== -1) return;
1305
- if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
1306
- if (childFetchOpts.integrity) childFetchOpts = { ...childFetchOpts, integrity: undefined };
1307
- const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, source), s: sourcePhase };
1308
- // assertion case -> inline the CSS / JSON URL directly
1309
- if (source === '') child.l.b = child.l.u;
1310
- if (!child.s) linkLoad(child.l, fetchOpts);
1311
- // load, sourcePhase
1312
- return child;
1313
- })
1314
- .filter(l => l);
1315
- });
1316
- };
1317
-
1318
- const processScriptsAndPreloads = () => {
1319
- for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]')) {
1320
- if (!link.ep) processPreload(link);
1321
- }
1322
- for (const script of document.querySelectorAll('script[type]')) {
1323
- if (script.type === 'importmap' + (shimMode ? '-shim' : '')) {
1324
- if (!script.ep) processImportMap(script);
1325
- } else if (script.type === 'module' + (shimMode ? '-shim' : '')) {
1326
- legacyAcceptingImportMaps = false;
1327
- if (!script.ep) processScript(script);
1328
- }
1329
- }
1330
- };
1331
-
1332
- const getFetchOpts = script => {
1333
- const fetchOpts = {};
1334
- if (script.integrity) fetchOpts.integrity = script.integrity;
1335
- if (script.referrerPolicy) fetchOpts.referrerPolicy = script.referrerPolicy;
1336
- if (script.fetchPriority) fetchOpts.priority = script.fetchPriority;
1337
- if (script.crossOrigin === 'use-credentials') fetchOpts.credentials = 'include';
1338
- else if (script.crossOrigin === 'anonymous') fetchOpts.credentials = 'omit';
1339
- else fetchOpts.credentials = 'same-origin';
1340
- return fetchOpts;
1341
- };
1342
-
1343
- let lastStaticLoadPromise = Promise.resolve();
1344
-
1345
- let domContentLoaded = false;
1346
- let domContentLoadedCnt = 1;
1347
- const domContentLoadedCheck = m => {
1348
- if (m === undefined) {
1349
- if (domContentLoaded) return;
1350
- domContentLoaded = true;
1351
- domContentLoadedCnt--;
1352
- }
1353
- if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselineSupport)) {
1354
- document.removeEventListener('DOMContentLoaded', domContentLoadedEvent);
1355
- document.dispatchEvent(new Event('DOMContentLoaded'));
1356
- }
1357
- };
1358
- let loadCnt = 1;
1359
- const loadCheck = () => {
1360
- if (--loadCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselineSupport)) {
1361
- window.removeEventListener('load', loadEvent);
1362
- window.dispatchEvent(new Event('load'));
1363
- }
1364
- };
1365
-
1366
- const domContentLoadedEvent = async () => {
1367
- await initPromise;
1368
- domContentLoadedCheck();
1369
- };
1370
- const loadEvent = async () => {
1371
- await initPromise;
1372
- domContentLoadedCheck();
1373
- loadCheck();
1374
- };
1375
-
1376
- // this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
1377
- if (hasDocument) {
1378
- document.addEventListener('DOMContentLoaded', domContentLoadedEvent);
1379
- window.addEventListener('load', loadEvent);
1380
- }
1381
-
1382
- const readyListener = async () => {
1383
- await initPromise;
1384
- processScriptsAndPreloads();
1385
- if (document.readyState === 'complete') {
1386
- readyStateCompleteCheck();
1387
- }
1388
- };
1389
-
1390
- let readyStateCompleteCnt = 1;
1391
- const readyStateCompleteCheck = () => {
1392
- if (--readyStateCompleteCnt === 0) {
1393
- domContentLoadedCheck();
1394
- if (!noLoadEventRetriggers && (shimMode || !baselineSupport)) {
1395
- document.removeEventListener('readystatechange', readyListener);
1396
- document.dispatchEvent(new Event('readystatechange'));
1397
- }
1398
- }
1399
- };
1400
-
1401
- const hasNext = script => script.nextSibling || (script.parentNode && hasNext(script.parentNode));
1402
- const epCheck = (script, ready) =>
1403
- script.ep ||
1404
- (!ready && ((!script.src && !script.innerHTML) || !hasNext(script))) ||
1405
- script.getAttribute('noshim') !== null ||
1406
- !(script.ep = true);
1407
-
1408
- const processImportMap = (script, ready = readyStateCompleteCnt > 0) => {
1409
- if (epCheck(script, ready)) return;
1410
- // we dont currently support external import maps in polyfill mode to match native
1411
- if (script.src) {
1412
- if (!shimMode) return;
1413
- importMapSrc = true;
1414
- }
1415
- importMapPromise = importMapPromise
1416
- .then(async () => {
1417
- composedImportMap = resolveAndComposeImportMap(
1418
- script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML),
1419
- script.src || baseUrl,
1420
- composedImportMap
1421
- );
1422
- })
1423
- .catch(e => {
1424
- if (e instanceof SyntaxError)
1425
- e = new Error(\`Unable to parse import map \${e.message} in: \${script.src || script.innerHTML}\`);
1426
- throwError(e);
1427
- });
1428
- if (!firstImportMap && legacyAcceptingImportMaps) importMapPromise.then(() => (firstImportMap = composedImportMap));
1429
- if (!legacyAcceptingImportMaps && !multipleImportMaps) {
1430
- multipleImportMaps = true;
1431
- if (!shimMode && baselineSupport && !supportsMultipleImportMaps) {
1432
- baselineSupport = false;
1433
- if (hasDocument) attachMutationObserver();
1434
- }
1435
- }
1436
- legacyAcceptingImportMaps = false;
1437
- };
1438
-
1439
- const processScript = (script, ready = readyStateCompleteCnt > 0) => {
1440
- if (epCheck(script, ready)) return;
1441
- // does this load block readystate complete
1442
- const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
1443
- // does this load block DOMContentLoaded
1444
- const isDomContentLoadedScript = domContentLoadedCnt > 0;
1445
- const isLoadScript = loadCnt > 0;
1446
- if (isLoadScript) loadCnt++;
1447
- if (isBlockingReadyScript) readyStateCompleteCnt++;
1448
- if (isDomContentLoadedScript) domContentLoadedCnt++;
1449
- let loadPromise;
1450
- const ts = script.lang === 'ts';
1451
- if (ts && !script.src) {
1452
- loadPromise = Promise.resolve(esmsTsTransform || initTs())
1453
- .then(() => {
1454
- const transformed = esmsTsTransform(script.innerHTML, baseUrl);
1455
- if (transformed !== undefined) {
1456
- onpolyfill();
1457
- firstPolyfillLoad = false;
1458
- }
1459
- return topLevelLoad(
1460
- script.src || baseUrl,
1461
- baseUrl,
1462
- getFetchOpts(script),
1463
- transformed === undefined ? script.innerHTML : transformed,
1464
- !shimMode && transformed === undefined,
1465
- isBlockingReadyScript && lastStaticLoadPromise,
1466
- 'ts'
1467
- );
1468
- })
1469
- .catch(throwError);
1470
- } else {
1471
- loadPromise = topLevelLoad(
1472
- script.src || baseUrl,
1473
- baseUrl,
1474
- getFetchOpts(script),
1475
- !script.src ? script.innerHTML : undefined,
1476
- !shimMode,
1477
- isBlockingReadyScript && lastStaticLoadPromise,
1478
- ts ? 'ts' : undefined
1479
- ).catch(throwError);
1480
- }
1481
- if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
1482
- if (isBlockingReadyScript && !ts) {
1483
- lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
1484
- }
1485
- if (isDomContentLoadedScript) loadPromise.then(domContentLoadedCheck);
1486
- if (isLoadScript) loadPromise.then(loadCheck);
1487
- };
1488
-
1489
- const fetchCache = {};
1490
- const processPreload = link => {
1491
- link.ep = true;
1492
- initPromise.then(() => {
1493
- if (baselineSupport && !shimMode) return;
1494
- if (fetchCache[link.href]) return;
1495
- fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
1496
- });
1497
- };
1498
-
1499
- })();
1500
- `,fb=`/* Runs only in the opaque preview frame. All local reads use its directory capability. */
1501
- function installPreviewRuntime(capability, base, externalOrigins, shimUrl) {
1502
- const external = new Set(externalOrigins);
1503
- const report = () => parent.postMessage({ type: 'preview-error', capability }, '*');
1504
- const nativeFetch = window.fetch.bind(window);
1505
- const nativeWorker = window.Worker;
1506
- const externalUrl = value => {
1507
- const url = new URL(value, base);
1508
- const origin = url.protocol === 'wss:' ? 'https://' + url.host : url.origin;
1509
- if (!external.has(origin)) throw new Error('Outside preview network scope');
1510
- return url;
1511
- };
1512
- const bridgeFetch = async (input, init = {}) => {
1513
- const url = new URL(typeof input === 'string' ? input : input.url || String(input), base);
1514
- const method = String(init.method || (input && input.method) || 'GET').toUpperCase();
1515
- if (url.protocol === 'blob:' || url.protocol === 'data:') return nativeFetch(input, init);
1516
- if (url.origin !== new URL(base).origin) {
1517
- externalUrl(url.href);
1518
- return nativeFetch(url.href, { ...init, method, credentials: 'omit', referrerPolicy: 'no-referrer' });
1519
- }
1520
- if (!['GET', 'HEAD'].includes(method) || !url.pathname.startsWith(new URL(base).pathname)) throw new Error('Outside preview directory');
1521
- return new Promise((resolve, reject) => {
1522
- if (init.signal?.aborted) { reject(init.signal.reason); return; }
1523
- const channel = new MessageChannel();
1524
- const finish = () => { clearTimeout(timer); channel.port1.close(); init.signal?.removeEventListener('abort', abort); };
1525
- const abort = () => { finish(); reject(init.signal.reason); };
1526
- const timer = setTimeout(() => { finish(); report(); reject(new Error('Preview resource timeout')); }, 15000);
1527
- init.signal?.addEventListener('abort', abort, { once: true });
1528
- channel.port1.onmessage = event => {
1529
- finish();
1530
- if (event.data.error) { reject(new Error(event.data.error)); return; }
1531
- const response = new Response(method === 'HEAD' ? null : event.data.data, { status: event.data.status, headers: event.data.headers });
1532
- Object.defineProperty(response, 'url', { value: url.href }); resolve(response);
1533
- };
1534
- parent.postMessage({ type: 'preview-fetch', capability, url: url.href, method }, '*', [channel.port2]);
1535
- });
1536
- };
1537
- Object.defineProperty(window, 'fetch', { configurable: false, writable: false, value: bridgeFetch });
1538
- window.esmsInitOptions = { shimMode: true, nativePassthrough: false, fetch: bridgeFetch, onerror: report };
1539
- class PreviewXHR extends EventTarget {
1540
- readyState = 0; status = 0; statusText = ''; response = null; responseText = ''; responseURL = ''; responseType = ''; timeout = 0;
1541
- upload = new EventTarget(); withCredentials = false;
1542
- open(method, url, async = true) {
1543
- if (!async) throw new Error('Synchronous preview requests are unavailable');
1544
- this.abort(); this.method = method; this.url = new URL(url, base).href; this.headers = {}; this.readyState = 1; this.emit('readystatechange');
1545
- }
1546
- setRequestHeader(name, value) { this.headers[name] = value; }
1547
- getAllResponseHeaders() { return this.responseHeaders ? [...this.responseHeaders].map(([key, value]) => key + ': ' + value + '\\r\\n').join('') : ''; }
1548
- getResponseHeader(name) { return this.responseHeaders?.get(name) ?? null; }
1549
- overrideMimeType(value) { this.mime = value; }
1550
- emit(type, event = new Event(type)) { this.dispatchEvent(event); this['on' + type]?.call(this, event); }
1551
- abort() { if (this.controller) { this.controller.abort(); this.controller = null; this.readyState = 0; this.emit('abort'); this.emit('loadend'); } }
1552
- send(body = null) {
1553
- const controller = new AbortController(); this.controller = controller;
1554
- const timer = this.timeout > 0 ? setTimeout(() => { if (this.controller !== controller) return; controller.abort(); this.controller = null; this.emit('timeout'); this.emit('loadend'); }, this.timeout) : null;
1555
- this.emit('loadstart');
1556
- bridgeFetch(this.url, { method: this.method, headers: this.headers, body, signal: controller.signal }).then(async response => {
1557
- this.status = response.status; this.statusText = response.statusText; this.responseURL = response.url; this.responseHeaders = response.headers;
1558
- this.readyState = 2; this.emit('readystatechange'); this.readyState = 3; this.emit('readystatechange');
1559
- const bytes = await response.arrayBuffer();
1560
- if (this.controller !== controller) return;
1561
- this.responseText = new TextDecoder().decode(bytes);
1562
- this.response = this.responseType === 'arraybuffer' ? bytes : this.responseType === 'blob' ? new Blob([bytes], { type: this.mime || response.headers.get('content-type') || '' }) : this.responseType === 'json' ? (() => { try { return JSON.parse(this.responseText); } catch { return null; } })() : this.responseType === 'document' ? new DOMParser().parseFromString(this.responseText, 'text/html') : this.responseText;
1563
- this.readyState = 4; this.emit('readystatechange'); this.emit('progress', new ProgressEvent('progress', { lengthComputable: true, loaded: bytes.byteLength, total: bytes.byteLength })); this.emit('load'); this.emit('loadend'); this.controller = null;
1564
- }).catch(() => { if (this.controller !== controller) return; this.controller = null; this.status = 0; this.readyState = 4; this.emit('readystatechange'); this.emit('error'); this.emit('loadend'); }).finally(() => clearTimeout(timer));
1565
- }
1566
- }
1567
- for (const [key, value] of Object.entries({ UNSENT: 0, OPENED: 1, HEADERS_RECEIVED: 2, LOADING: 3, DONE: 4 })) { PreviewXHR[key] = value; PreviewXHR.prototype[key] = value; }
1568
- Object.defineProperty(window, 'XMLHttpRequest', { configurable: false, writable: false, value: PreviewXHR });
1569
- for (const name of ['WebSocket', 'EventSource']) {
1570
- const Native = window[name];
1571
- if (Native) Object.defineProperty(window, name, { configurable: false, writable: false, value: class extends Native {
1572
- constructor(url, options) { super(externalUrl(url).href, name === 'EventSource' ? { withCredentials: false } : options); }
1573
- } });
1574
- }
1575
- // A worker receives the same read-only bridge over a private MessagePort. Its
1576
- // module graph is loaded by the same shim, including computed dynamic imports.
1577
- class PreviewWorker extends EventTarget {
1578
- constructor(url, options = {}) {
1579
- super();
1580
- const entry = new URL(url, base).href;
1581
- const workerSource = \`(\${workerBootstrap.toString()})(\${JSON.stringify(entry)},\${JSON.stringify(options.type || 'classic')},\${JSON.stringify(shimUrl)});\`;
1582
- this.objectUrl = URL.createObjectURL(new Blob([workerSource], { type: 'text/javascript' }));
1583
- this.worker = new nativeWorker(this.objectUrl, { name: options.name });
1584
- const channel = new MessageChannel(); this.port = channel.port1;
1585
- this.port.onmessage = async event => {
1586
- const { id, url, init } = event.data;
1587
- try { const response = await bridgeFetch(url, init); const data = await response.arrayBuffer(); this.port.postMessage({ id, status: response.status, headers: [...response.headers], data }, [data]); }
1588
- catch (error) { this.port.postMessage({ id, error: String(error) }); }
1589
- };
1590
- this.worker.postMessage({ previewInit: true, base: entry, importMap: window.importShim?.getImportMap?.() }, [channel.port2]);
1591
- for (const type of ['message', 'messageerror', 'error']) this.worker.addEventListener(type, event => {
1592
- const forwarded = type === 'error' ? new ErrorEvent(type, { message: event.message }) : new MessageEvent(type, { data: event.data, ports: event.ports });
1593
- this.dispatchEvent(forwarded); this['on' + type]?.call(this, forwarded);
1594
- });
1595
- }
1596
- postMessage(value, transfer) { this.worker.postMessage(value, transfer); }
1597
- terminate() { this.worker.terminate(); this.port.close(); URL.revokeObjectURL(this.objectUrl); }
1598
- }
1599
- function workerBootstrap(entry, type, shim) {
1600
- const queued = []; let initialized = false, ready = false;
1601
- const receive = event => {
1602
- if (!event.data?.previewInit || initialized) { if (!ready) { event.stopImmediatePropagation(); queued.push(event); } return; }
1603
- initialized = true; event.stopImmediatePropagation();
1604
- const port = event.ports[0]; const pending = new Map(); let next = 0;
1605
- port.onmessage = message => { const done = pending.get(message.data.id); if (!done) return; pending.delete(message.data.id); message.data.error ? done.reject(new Error(message.data.error)) : done.resolve(new Response(message.data.data, { status: message.data.status, headers: message.data.headers })); };
1606
- self.fetch = (url, init = {}) => new Promise((resolve, reject) => { const id = ++next; pending.set(id, { resolve, reject }); port.postMessage({ id, url: new URL(typeof url === 'string' ? url : url.url || String(url), entry).href, init: { method: init.method || 'GET', headers: init.headers } }); });
1607
- self.esmsInitOptions = { shimMode: true, nativePassthrough: false, fetch: self.fetch };
1608
- const nativeImport = self.importScripts.bind(self);
1609
- nativeImport(shim);
1610
- if (event.data.importMap) self.importShim.addImportMap(event.data.importMap);
1611
- const load = type === 'module' ? self.importShim(entry) : self.fetch(entry).then(r => r.text()).then(source => { const blob = URL.createObjectURL(new Blob([source], { type: 'text/javascript' })); nativeImport(blob); URL.revokeObjectURL(blob); });
1612
- load.then(() => { ready = true; removeEventListener('message', receive); for (const message of queued) dispatchEvent(new MessageEvent('message', { data: message.data, ports: message.ports })); }).catch(error => setTimeout(() => { throw error; }));
1613
- };
1614
- addEventListener('message', receive);
1615
- }
1616
- Object.defineProperty(window, 'Worker', { configurable: false, writable: false, value: PreviewWorker });
1617
- const navigate = value => {
1618
- const url = new URL(value, base);
1619
- if (url.origin === new URL(base).origin && url.pathname.startsWith(new URL(base).pathname)) parent.postMessage({ type: 'preview-navigate', capability, url: url.href }, '*');
1620
- else { externalUrl(url.href); parent.postMessage({ type: 'preview-external', capability, url: url.href }, '*'); }
1621
- };
1622
- Object.defineProperty(window, 'open', { configurable: false, writable: false, value: value => { navigate(value); return null; } });
1623
- document.addEventListener('click', event => { const anchor = event.target.closest?.('a,area'); const href = anchor?.getAttribute('href'); if (href && !href.startsWith('#')) { event.preventDefault(); navigate(href); } }, true);
1624
- document.addEventListener('submit', event => {
1625
- event.preventDefault(); const form = event.target;
1626
- const url = new URL(form.getAttribute('action') || base, base);
1627
- if ((form.getAttribute('method') || 'get').toLowerCase() !== 'get') { report(); return; }
1628
- for (const [key, value] of new FormData(form)) if (typeof value === 'string') url.searchParams.append(key, value);
1629
- navigate(url.href);
1630
- }, true);
1631
- window.addEventListener('securitypolicyviolation', report);
1632
- window.addEventListener('error', report, true);
1633
- window.addEventListener('unhandledrejection', report);
1634
- }
1635
- `,oo="/api/terminal/fs/preview/",hb=8*1024*1024,mb=32*1024*1024,pb=128,gb="data:,";function It(r){throw new Error(r)}function bb(r){return JSON.stringify(r).replace(/</g,"\\u003c")}async function du(r,n,s){let l="",u=0;for(const c of r.matchAll(n))l+=r.slice(u,c.index)+await s(c),u=c.index+c[0].length;return l+r.slice(u)}async function uf(r,n){const s=n.origin??location.origin,l=new URL(r,s);(l.origin!==s||!Bs(l.pathname)?.startsWith(oo))&&It("预览地址不是有效的本地文件入口");const u=crypto.randomUUID(),c=`https://termdock-preview.invalid/${u}/`,m=[],g=z=>{!m.includes(z)&&m.length<20&&m.push(z)},h=new Set,p=[],b=new Set,f=new Map,x=new Map;let $=0,P=!1;const D=new Set,_=()=>{P=!0;for(const z of[...D])z();h.clear(),p.length=0};async function U(z){z.ok||It(`预览资源读取失败(${z.status})`);const Y=z.body?.getReader(),A=[];let O=0;try{if(Y)for(;;){const me=await Y.read();if(me.done)break;O+=me.value.byteLength,$+=me.value.byteLength,(O>hb||$>mb)&&It("预览资源超出大小限制"),A.push(me.value)}}catch(me){throw await Y?.cancel().catch(()=>{}),me}finally{Y?.releaseLock()}const Q=new Uint8Array(O);let ce=0;for(const me of A)Q.set(me,ce),ce+=me.length;return{bytes:Q,type:z.headers.get("content-type")??"application/octet-stream",status:z.status}}let C=l,N;for(let z=0;z<4;z++){const Y=await n.fetch(C.pathname+C.search,{signal:n.signal,redirect:"manual"});if(![301,302,303,307,308].includes(Y.status)){N=Y;break}const A=Y.headers.get("location");await Y.body?.cancel(),A||It("预览重定向缺少目标");const O=new URL(A,C);(O.origin!==s||!Bs(O.pathname)?.startsWith(oo))&&It("预览重定向越出文件范围"),C=O}N||It("预览重定向次数过多");const E=Bs(C.pathname),B=E.slice(oo.length).split("/");/^[a-f0-9]{32}$/.test(B[0])||It("服务未提供有效的预览资源授权");const q=Bs(l.pathname).slice(oo.length).split("/");/^[a-f0-9]{32}$/.test(q[0])&&q.shift(),q.join("/").replace(/\/$/,"")!==B.slice(1).join("/").replace(/\/$/,"")&&It("预览重定向改变了文件范围");const S=E.endsWith("/")?E:E.slice(0,E.lastIndexOf("/")+1),o=new URL(C.pathname.endsWith("/")?C.pathname:C.pathname.slice(0,C.pathname.lastIndexOf("/")+1),s);function F(z,Y){const A=new URL(z,Y);return A.origin!==s?null:(Bs(A.pathname)?.startsWith(S)||It("已阻止预览访问目录之外的资源"),A)}function I(z){const Y=new URL(z,c);(Y.origin!==new URL(c).origin||!Y.pathname.startsWith(new URL(c).pathname))&&It("已阻止预览访问服务接口或目录之外的资源");const A=Y.pathname.slice(new URL(c).pathname.length)+Y.search;return F(A,o)??It("预览资源无效")}function V(z){const Y=z.pathname+z.search,A=f.get(Y);if(A)return A;if(P||n.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(f.size>=pb)return Promise.reject(new Error("预览资源数量超出限制"));const O=n.fetch(Y,{signal:n.signal,redirect:"manual"}).then(U);return f.set(Y,O),O}function G(z,Y){P&&It("预览已关闭");const A=`termdock-resource-${u}-${p.length}`;return p.push({token:A,data:z,type:Y}),h.add(A),A}async function H(z,Y,A,O=new Set){if(!z||z.startsWith("#")||/^data:(?:image|font)\//i.test(z)&&A==="resource")return z;try{const Q=F(z,Y);if(!Q){const Ce=new URL(z,Y);return(Ce.protocol!=="https:"||Ce.username||Ce.password||Ce.origin===new URL(c).origin)&&It("已阻止不安全的外部资源"),b.add(Ce.origin),Ce.href}const ce=`${A}:${Q.href}`;(O.has(ce)||O.size>=8)&&It("预览资源存在循环或过深引用");const me=x.get(ce);if(me)return me;const je=new Set(O);je.add(ce);const $e=(async()=>{const Ce=await V(Q);return A==="css"?G(await R(new TextDecoder().decode(Ce.bytes),Q,je),"text/css"):A==="script"?G(Ce.bytes,"text/javascript"):G(Ce.bytes,Ce.type)})();return x.set(ce,$e),await $e}catch(Q){return g(Q instanceof Error?Q.message:"部分预览资源未能加载"),gb}}async function R(z,Y,A){return z=await du(z,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async O=>`@import url("${await H(O[1],Y,"css",A)}")${O[2]};`),du(z,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async O=>{const Q=(O[1]??O[2]??O[3]).trim();return h.has(Q)?O[0]:`url("${await H(Q,Y,"resource",A)}")`})}try{const z=await U(N),Y=G(ub,"text/javascript"),A=new DOMParser().parseFromString(new TextDecoder().decode(z.bytes),"text/html");A.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(T=>T.remove());for(const T of A.querySelectorAll("*")){if(T.removeAttribute("ping"),T.removeAttribute("srcdoc"),T.hasAttribute("style")&&T.setAttribute("style",await R(T.getAttribute("style"),C,new Set)),T.tagName==="STYLE"&&(T.textContent=await R(T.textContent??"",C,new Set)),T.tagName==="A"||T.tagName==="AREA"){const ee=T.getAttribute("href");try{if(ee&&!ee.startsWith("#")){const te=F(ee,C);if(te)T.setAttribute("href",new URL(te.pathname.slice(o.pathname.length)+te.search+te.hash,c).href);else{const Le=new URL(ee,C);if(Le.protocol!=="https:"){T.removeAttribute("href");continue}b.add(Le.origin),T.setAttribute("href",Le.href)}}}catch(te){T.removeAttribute("href"),g(te instanceof Error?te.message:"预览链接无法加载")}}for(const ee of["data","manifest"])T.removeAttribute(ee);if(T.tagName==="SCRIPT"&&T.getAttribute("type")==="module"){T.setAttribute("type","module-shim");const ee=T.getAttribute("src");if(ee){const te=F(ee,C);if(te)T.setAttribute("src",new URL(te.pathname.slice(o.pathname.length)+te.search,c).href);else{const Le=new URL(ee,C);if(Le.protocol!=="https:"){T.remove();continue}b.add(Le.origin),T.setAttribute("src",Le.href)}}continue}if(T.tagName==="SCRIPT"&&T.getAttribute("type")==="importmap"){T.setAttribute("type","importmap-shim");continue}if(T.tagName==="LINK"){const ee=(T.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(ee)){T.remove();continue}const te=T.getAttribute("href");te&&T.setAttribute("href",await H(te,C,ee==="stylesheet"?"css":"resource"))}if(T.hasAttribute("src")&&T.setAttribute("src",await H(T.getAttribute("src"),C,T.tagName==="SCRIPT"?"script":"resource")),T.hasAttribute("poster")&&T.setAttribute("poster",await H(T.getAttribute("poster"),C,"resource")),T.hasAttribute("srcset")){const ee=T.getAttribute("srcset");/data:/i.test(ee)?(T.removeAttribute("srcset"),g("混合内嵌图片候选暂不支持安全预览")):T.setAttribute("srcset",(await Promise.all(ee.split(",").map(async te=>{const[Le,...De]=te.trim().split(/\s+/);return`${await H(Le,C,"resource")} ${De.join(" ")}`}))).join(", "))}T.setAttribute("referrerpolicy","no-referrer"),T.removeAttribute("integrity"),T.removeAttribute("crossorigin")}const O=[...b].join(" "),Q=A.createElement("meta");Q.httpEquiv="Content-Security-Policy",Q.content=`default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${O}; style-src 'unsafe-inline' blob: ${O}; img-src blob: data: ${O}; font-src blob: data: ${O}; media-src blob: data: ${O}; connect-src blob: ${O} ${[...b].map(T=>T.replace(/^https:/,"wss:")).join(" ")}; worker-src blob:; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const ce=A.createElement("base");ce.href=c;const me=A.createElement("meta");me.name="referrer",me.content="no-referrer";const je=A.createElement("script");je.textContent=fb+`
1636
- installPreviewRuntime(`+[u,c,[...b],Y].map(bb).join(",")+");";const $e=A.createElement("script");$e.src=Y,A.head.prepend(Q,me,ce,je,$e);const Ce=`<!doctype html>
1637
- `+A.documentElement.outerHTML;return{html:Ce,shellUrl:`/preview-shell.html#${u}`,errors:m,attach(T,ee){const te=new Set,Le=Te=>{if(Te.source!==T.contentWindow||Te.data?.capability!==u)return;if(Te.data.type==="preview-ready"){T.contentWindow?.postMessage({type:"preview-init",capability:u,html:Ce,resources:p},"*");return}if(Te.data.type==="preview-error"){ee("部分动态内容被安全预览限制");return}if(Te.data.type==="preview-navigate"){(async()=>{const Ie=I(String(Te.data.url)),we=await uf(Ie.pathname+Ie.search,n);if(P){we.dispose();return}const L=we.attach(T,ee);D.add(()=>{L(),we.dispose()}),T.src=we.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(Ie=>ee(Ie instanceof Error?Ie.message:"无法打开预览页面"));return}if(Te.data.type==="preview-external"){try{const Ie=new URL(String(Te.data.url));Ie.protocol==="https:"&&b.has(Ie.origin)&&window.open(Ie.href,"_blank","noopener,noreferrer")}catch{}return}if(Te.data.type!=="preview-fetch"||Te.ports.length!==1)return;const lt=Te.ports[0];if(te.size>=8||!["GET","HEAD"].includes(Te.data.method)){lt.postMessage({error:"预览仅允许读取已授权目录资源"}),lt.close();return}te.add(lt),(async()=>{const Ie=I(String(Te.data.url)),we=await V(Ie);if(!te.has(lt)||P)return;const L=Te.data.method==="HEAD"?new Uint8Array:we.bytes.slice();lt.postMessage({status:we.status,headers:{"content-type":we.type},data:L.buffer},[L.buffer])})().catch(()=>{lt.postMessage({error:"预览资源不在授权范围或无法加载"}),ee("部分动态资源不可用或超出预览目录")}).finally(()=>{te.delete(lt),lt.close()})};window.addEventListener("message",Le);const De=()=>{window.removeEventListener("message",Le);for(const Te of te)Te.close();te.clear(),D.delete(De)};return D.add(De),De},dispose:_}}catch(z){throw _(),z}}const xb=a.forwardRef(function({src:n,title:s,exitFullscreenLabel:l,onFullscreenChange:u},c){const m=a.useRef(null),[g,h]=a.useState(null),[p,b]=a.useState(),[f,x]=a.useState("");a.useEffect(()=>{const E=new AbortController;let B;return b(void 0),x(""),(async()=>{const q=await Mm();if(B=await uf(n,{fetch:(S,o)=>q.fetch(S,o),signal:E.signal}),E.signal.aborted){B.dispose();return}b(B),B.errors.length&&x(B.errors.join(";"))})().catch(q=>{E.signal.aborted||x(q instanceof Error?q.message:"安全预览加载失败")}),()=>{E.abort(),B?.dispose()}},[n]),a.useEffect(()=>{if(!(!p||!g))return p.attach(g,x)},[p,g]);const[$,P]=a.useState(!1),[D,_]=a.useState(!1),U=$||D;a.useEffect(()=>{u?.(U)},[U,u]),a.useEffect(()=>{const E=()=>{P(document.fullscreenElement===m.current)};return document.addEventListener("fullscreenchange",E),()=>document.removeEventListener("fullscreenchange",E)},[]),a.useEffect(()=>{if(!D)return;const E=B=>{B.key==="Escape"&&_(!1)};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[D]);const C=a.useCallback(async()=>{const E=m.current;if(E){if(D){_(!1);return}if(document.fullscreenElement===E){await document.exitFullscreen();return}if(E.requestFullscreen&&document.fullscreenEnabled!==!1)try{await E.requestFullscreen();return}catch{}_(!0)}},[D]);a.useImperativeHandle(c,()=>({toggleFullscreen:C}),[C]);const N=e.jsxs("div",{ref:m,"data-html-preview-frame":!0,className:U?"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:[U&&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:()=>{C()},"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(Ju,{size:15})})]}),f&&e.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:f}),!p&&!f&&e.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),e.jsx("iframe",{ref:h,src:p?.shellUrl,referrerPolicy:"no-referrer",title:s,sandbox:"allow-scripts",className:"block min-h-0 w-full flex-1 border-0 bg-white"})]});return D?kr.createPortal(N,document.body):N}),ff="termdock-file-search-match",xl="termdock-file-search-current";function vb(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 wb(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 yb(r){return r.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function kb(r,n){const s=n.trim().toLocaleLowerCase();if(!s)return[];const l=[];let u="",c=null;const m=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);for(let b=m.nextNode();b;b=m.nextNode()){if(!(b instanceof Text)||!b.data)continue;const f=yb(b);if(!f)continue;c&&c!==f&&(u+=`
1638
- `);const x=u.length;u+=b.data,l.push({node:b,start:x,end:u.length,group:f}),c=f}const g=u.toLocaleLowerCase(),h=[];let p=0;for(;p<=g.length-s.length;){const b=g.indexOf(s,p);if(b<0)break;const f=b+s.length,x=l.find(P=>P.start<=b&&P.end>b),$=l.find(P=>P.start<f&&P.end>=f);if(x&&$&&x.group===$.group){const P=document.createRange();P.setStart(x.node,b-x.start),P.setEnd($.node,f-$.start),h.push(P)}p=b+Math.max(s.length,1)}return h}function hf(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}let jo;function uu(r){return jo===r}function io(r){if(r&&jo!==r)return;const n=hf();n?.delete(ff),n?.delete(xl),jo=void 0}function qi(r,n,s){const l=hf();if(!l||typeof Highlight>"u")return;jo=s,l.set(ff,new Highlight(...r));const u=r[n];u?l.set(xl,new Highlight(u)):l.delete(xl)}function fu(r){r?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function Sb(r){return Array.from(new Set(r.split(/[\n,]/).map(n=>n.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function jb(r,n){const s=n.trim();return!s||s==="."?r:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${r.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Rb(r,n){if(n===r)return".";const s=`${r.replace(/[\\/]+$/,"")}/`;return n.startsWith(s)?n.slice(s.length):n}function mf(r,n,s){return n?r:kr.createPortal(r,s)}const Pl="termdock:right-sidebar:file-tree-scroll:v1",Ll="termdock:right-sidebar:file-preview-reading-state:v1",qs="termdock:right-sidebar:file-tree-width:v1",pf="termdock:right-sidebar:markdown-view-mode:v1",gf="termdock:right-sidebar:diff-change-list-mode:v1",bf="termdock:right-sidebar:diff-wrap:v1",xf="termdock:diff-viewer:view-type:v1",vf="termdock:right-sidebar:file-search-mode:v1",Vi="termdock:right-sidebar:collapsed-git-repo-groups:v1",hu="termdock:right-sidebar:collapsed-diff-directories:v1",Yi="termdock:right-sidebar:branch-audit-module-open:v1",wf="termdock:right-sidebar:branch-audit-module:v1",Nb=150,mu="termdock:right-sidebar:context-draft-enabled:v1",pu="termdock:right-sidebar:context-draft-collapsed:v1",gu="termdock:right-sidebar:context-draft-auto-collapse:v1",Xi="termdock:right-sidebar:context-draft-text:v1",Cb=300,Eb=20,Mb=120,$b=250,Pb=250,Lb=120,Ab=700,Ji=600,Tb=6e4;function Hs(r){return!!(r&&J.getState().nestedGitScanRoots[r])}const bu=[2e3,5e3,15e3,3e4],Ib=320,Db=500,Fb=20,_b=12e3,vl=300,xu=240,Bb=560,yf="border-r px-2 py-1.5 sm:px-3 sm:py-2",Ro="min-w-full max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",kf=`${yf} border-b border-border/15 font-semibold last:border-r-0`,Sf=`${yf} border-border/10 align-top text-muted-foreground last:border-r-0`,Al="termdock-file-preview-horizontal-scroll",vu=a.lazy(()=>Cn(()=>import("./ModelPreview-C-LJZ8so.js"),__vite__mapDeps([7,1,2,3,4,5,8,9,10,11,12,13,14,15,16,17]))),Ob=a.lazy(()=>Cn(()=>import("./ArchitecturePanel-QodxiiCc.js"),__vite__mapDeps([18,1,2,3,4,5,6,8,9,10,11,12,14,13,15,16,17,19])).then(r=>({default:r.ArchitecturePanel}))),Ub=a.lazy(()=>Cn(()=>import("./ComputerControlView-B5vigCoW.js").then(r=>r.C),__vite__mapDeps([20,1,2,3,4,5,17,14,11,8,9,10,12]))),jf=`${Al} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function Rf(r,n,s){return r&&!n?"unified":s}const Hb=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function zb(r){return r==="preview"||r==="source"}function Wb(r){return r==="list"||r==="tree"||r==="ai"}function wu(){return gt(pf,zb)??"preview"}function Gb(){return gt(gf,Wb)??"tree"}function Vs(r){return typeof r=="boolean"}function Kb(r){return typeof r=="string"}function qb(){return gt(bf,Vs)??!0}function Vb(r){return r==="unified"||r==="split"}function Yb(){return gt(xf,Vb)??"unified"}function Xb(r){return r==="name"||r==="content"||r==="regex"}function Jb(){return gt(vf,Xb)??"name"}function Nf(r){return r.repositories??(r.context?.root?[{id:r.context.root,root:r.context.root,relativeRoot:".",name:St(r.context.root)||r.context.root,depth:0,nested:!1,available:r.available,files:r.files,context:r.context,error:r.error}]:[])}function Qb(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 wl(r){return!r.activeGitRepoRoot&&(r.groupCount>1||r.label!==r.rootName)}function Cf(...r){const n=new Set;for(const s of r)for(const l of s)n.add(l.root);return n}function yl(r){return Array.isArray(r)&&r.every(n=>typeof n=="string")}function yu(r){const n=gt(r,yl);return n?new Set(n):new Set}function Qi(r,n){Dt(r,[...n])}function Zb(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 ex(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||yl(n.files))&&(n.hunks===void 0||Array.isArray(n.hunks)&&n.hunks.every(Zb))&&(n.commits===void 0||yl(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 tx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.key=="string"&&ex(n.diff)&&typeof n.repoLabel=="string"&&typeof n.createdAt=="number"}function rx(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(tx))&&(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 ku(){return gt(wf,rx)??{}}function Su(r){return[r.repoRoot,r.baseRef,r.branchName??"",r.headRef??"",r.diffFingerprint??""].join("\0")}function ju(r){const n=r?.trim()??"",s=n.indexOf("/");return s>=0?n.slice(s+1):n}function Ef(r,n){const s=r?.trim(),l=n?.trim();return!s||!l?!1:s===l||ju(s)===ju(l)}function Ru(r){const n=r?.branch??null;return[r?.upstream,...r?.remoteBranches??[],...r?.branches??[]].find(l=>l&&!Ef(l,n))??""}function kl(r,n){const s=Math.max(xu,n-320),l=Math.min(Bb,s);return Math.min(l,Math.max(xu,r))}function nx(r){return typeof r=="number"&&Number.isFinite(r)}function sx(r){return kl(gt(qs,nx)??vl,r)}function Mf(r){const n=r.split(/[\\/]/).pop()??r,s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function zs(r){return Hb.has(Mf(r))}function $f(r){const n=r.trim().replace(/\s+/g,"");return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)}function Sl(r){const n=r.trim();return/^#{1,6}\s+/.test(n)||$f(r)||/^>\s?/.test(n)||/^(```|~~~)/.test(n)||/^(?:[-+*]|\d+[.)])\s+/.test(n)}function Pf(r){const n=r.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!/[<>]/.test(n)?n:null}const Lf=a.createContext(null);function xo(r){return r.trim().replace(/\s+/g," ").toLowerCase()}function Af(r){return r.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function Tf(r){return r.replace(/\s+#+\s*$/,"").trim()}function jl(r,n){const l=Af(r).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",u=n.headingSlugCounts.get(l)??0;return n.headingSlugCounts.set(l,u+1),u===0?l:`${l}-${u}`}function Nu(r){return Af(r)||r.trim()}function No(r){const n=r.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!n)return null;const s=Nl(n[2]);return s?{id:xo(n[1]),definition:{href:s.href,title:s.title}}:null}function ax(r){const n=new Map;for(const s of r){const l=No(s);l&&n.set(l.id,l.definition)}return n}function If(r){return r.trim().toLowerCase()}function Df(r){const n=r.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return n?{id:If(n[1]),text:n[2]}:null}function ox(r){const n=new Map;let s=null;for(const l of r){const u=Df(l);if(u){s=u.id,n.set(u.id,{id:u.id,text:u.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 Ff(r){const n=new Set;let s=!1;return r.forEach((l,u)=>{if(Df(l)){n.add(u),s=!0;return}if(s&&/^\s{4,}\S/.test(l)){n.add(u);return}l.trim()&&(s=!1)}),n}function ix(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 u=r[s].trim();if(u.startsWith("<!--")){if(n[s]="",!u.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 _f(r){const n=r.replace(/\/+$/,""),s=n.lastIndexOf("/");return s<=0?s===0?"/":"":n.slice(0,s)}function Js(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 Tl(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 u=l.indexOf("#"),c=u>=0?l.slice(0,u):l,m=u>=0?l.slice(u+1):"",g=c.split("?",1)[0];if(!g)return null;let h,p=null;try{h=decodeURIComponent(g),p=m?decodeURIComponent(m):null}catch{return null}const b=s?Js(s):null;let f;if(h.startsWith("/")){const x=b&&(h===b||h.startsWith(`${b}/`));f=Js(b&&!x?`${b}/${h.slice(1)}`:h)}else{if(!n)return null;f=Js(`${_f(n)}/${h}`)}return b&&f!==b&&!f.startsWith(`${b}/`)?null:{path:f,fragment:p,directory:/\/$/.test(g)}}function Il(r,n,s,l,u){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=Js(s&&!g?`${s}/${c.slice(1)}`:c)}else{if(!n)return null;m=Js(`${_f(n)}/${c}`)}return u(m)}function lx(r,n,s){return Il(r,n,s,Ml,l=>`/api/terminal/fs/blob?path=${encodeURIComponent(l)}`)}function cx(r,n,s){return Il(r,n,s,Ou,Uu)}const Rl=128,dx=360,Zi=480;function aa(r){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(r))}catch{return!1}}function Bf(r,n,s,l,u=0){if(!n||!s)return null;let c,m;return u>0?(c=l>0?Math.min(u,l):u,m=s*c/n):aa(r)?(m=Math.min(Math.max(s,Rl),dx),c=n*m/s):(c=n,m=s),l>0&&c>l&&(m=m*l/c,c=l),m>Zi&&(c=c*Zi/m,m=Zi),{width:Math.max(1,Math.round(c)),height:Math.max(1,Math.round(m))}}function ux(r){if(!r.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(r.slice(r.indexOf("?"))).get("path")}catch{return null}}function Of(r){const n=ux(r),s=J(l=>n?(l.fileChangeVersions.get(n)??0)+l.fileWatchEpoch:0);return n&&s>0?`${r}&v=${s}`:r}function fx({src:r,alt:n,title:s,requestedWidthPx:l}){const u=aa(r),c=Of(r),m=Ao(c),g=a.useRef(null),[h,p]=a.useState(!1),[b,f]=a.useState(0),[x,$]=a.useState({status:"loading"}),[P,D]=a.useState(null);a.useLayoutEffect(()=>{const C=g.current;let N=C?.parentElement?.parentElement??C?.parentElement;for(;N;){const S=window.getComputedStyle(N).display;if(S!=="inline"&&S!=="contents")break;N=N.parentElement}if(!N)return;const E=N,B=()=>{const S=window.getComputedStyle(E),o=(parseFloat(S.paddingLeft)||0)+(parseFloat(S.paddingRight)||0);f(Math.max(0,E.clientWidth-o))};if(B(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(B);return q.observe(E),()=>q.disconnect()},[]),a.useEffect(()=>{if(h)return;const C=g.current;if(!C||typeof IntersectionObserver>"u"){p(!0);return}const N=new IntersectionObserver(E=>{E.some(B=>B.isIntersecting)&&(p(!0),N.disconnect())},{rootMargin:"400px"});return N.observe(C),()=>N.disconnect()},[h]),a.useEffect(()=>{if(!h)return;const C=new AbortController;let N=null;$({status:"loading"});const E=window.setTimeout(()=>{C.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return Hu(c,{signal:C.signal}).then(async B=>{if(!B.ok)throw new Error(`HTTP ${B.status}`);const q=Number(B.headers.get("X-Image-Width"))||0,S=Number(B.headers.get("X-Image-Height"))||0;return{blob:await B.blob(),width:q,height:S}}).then(({blob:B,width:q,height:S})=>{C.signal.aborted||(N=URL.createObjectURL(B),q>0&&S>0&&D({width:q,height:S}),$({status:"ready",objectUrl:N}))}).catch(()=>{const B=C.signal.reason;C.signal.aborted&&!(B instanceof DOMException&&B.name==="TimeoutError")||$({status:"fallback"})}).finally(()=>{window.clearTimeout(E)}),()=>{window.clearTimeout(E),C.abort(),N&&URL.revokeObjectURL(N)}},[h,c]);const _=Bf(r,P?.width??0,P?.height??0,b,l??0),U=_??(l?{width:b>0?Math.min(l,b):l,height:Math.round(l*.75)}:{width:Rl*2,height:Rl});return e.jsx("div",{ref:g,className:"block max-w-full",style:_?{width:_.width,height:_.height}:void 0,children:x.status==="ready"?e.jsx("img",{src:x.objectUrl,alt:n,title:s,decoding:"async",className:`${u?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:_?{width:_.width,height:_.height}:void 0,onLoad:C=>{const N=C.currentTarget;N.naturalWidth>0&&N.naturalHeight>0&&(P?.width!==N.naturalWidth||P?.height!==N.naturalHeight)&&D({width:N.naturalWidth,height:N.naturalHeight})}}):x.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:_?{width:_.width,height:_.height}:void 0,onLoad:C=>{const N=C.currentTarget;N.naturalWidth>0&&N.naturalHeight>0&&(P?.width!==N.naturalWidth||P?.height!==N.naturalHeight)&&D({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:U.width,height:U.height},children:e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:n||"…"})})})}function Qs(r,n,s,l,u,c){const m=lx(s,u.markdownFilePath,u.rootPath);if(!m)return c?.fallbackText??`![${n}](${s})`;const g=u.images.length;u.images.push({kind:"image",src:m,alt:n,title:l});const h=e.jsx(fx,{src:m,alt:n,title:l,requestedWidthPx:c?.requestedWidthPx});return u.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(),u.onImageOpen?.(g)},children:h},r):e.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:h},r)}function el(r){let n=r,s="";for(;/[.,;:!?)]$/.test(n);)s=`${n.slice(-1)}${s}`,n=n.slice(0,-1);return{linkText:n,suffix:s}}function Cu(r){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(r)}function Nl(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 Uf="",hx=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function mx(r){return r.replace(hx,(n,s)=>`${Uf}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function Eu(r){return r.replace(new RegExp(`${Uf}([0-9a-f]{4})`,"g"),(n,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function px(r){const n=r.replace(/[\r\n]+/g," ");return/^ .+ $/.test(n)&&/[^ ]/.test(n.slice(1,-1))?n.slice(1,-1):n}const Hf={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 lo=null;function zf(){return lo||(lo=Cn(()=>import("./purify.es-4eNOHKSq.js"),[]).then(r=>r.default??r).catch(r=>{throw lo=null,r})),lo}function Wf({html:r}){const{t:n}=mt(),[s,l]=a.useState(null);return a.useEffect(()=>{let u=!1;return l(null),zf().then(c=>{u||l(c.sanitize(r,Hf))}).catch(()=>{u||l("")}),()=>{u=!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 gx({html:r}){const[n,s]=a.useState(null);return a.useEffect(()=>{let l=!1;return s(null),zf().then(u=>{l||s(u.sanitize(r,Hf))}).catch(()=>{l||s("")}),()=>{l=!0}},[r]),n===null?null:n?e.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):r}function Gf(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 co=null;function bx(){return co||(co=Promise.all([Cn(()=>import("./katex-DnlPpQZa.js"),[]),Cn(()=>Promise.resolve({}),__vite__mapDeps([21]))]).then(([r])=>r.default??r).catch(r=>{throw co=null,r})),co}function ra({tex:r,display:n=!1}){const[s,l]=a.useState(null),[u,c]=a.useState(!1);if(a.useEffect(()=>{let g=!1;return l(null),c(!1),bx().then(h=>{g||l(h.renderToString(r,{displayMode:n,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{g||c(!0)}),()=>{g=!0}},[n,r]),u)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 Dl(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 Mu(r){const n=Dl(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 xx(r){const n=r.indexOf(">"),s=n<0?r:r.slice(0,n+1),l=Dl(s),u=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:u,fallbackText:g,widthPx:c?Number(c[1]):void 0,controls:/\bcontrols\b/i.test(m)}}function vx({url:r,fallbackText:n,widthPx:s,hasControls:l}){const{t:u}=mt(),[c,m]=a.useState(!1),g=Ao(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()||u("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 wx(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=Dl(m).get("href")?.trim()??"",h=r.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:p,alt:b,title:f,widthPx:x}=Mu(h);if(!p)return null;const $=Il(p,s.markdownFilePath,s.rootPath,Ml,C=>C);if(!$)return null;const P=g?Tl(g,s.markdownFilePath,s.rootPath):null,_=!!!(P&&P.path===$)&&g?Pf(g):null,U=Qs(n,b??"",p,f,s,{requestedWidthPx:x,interactive:_?!1:void 0});return _?e.jsx("a",{href:_,target:"_blank",rel:"noreferrer",children:U},n):U}if(/^<\s*img\b[^>]*>$/i.test(r)){const{src:m,alt:g,title:h,widthPx:p}=Mu(r);return m?Qs(n,g??"",m,h,s,{fallbackText:r,requestedWidthPx:p}):null}if(/^<\s*video\b[^>]*>[\s\S]*?<\/video\s*>$/i.test(r)){const{src:m,fallbackText:g,widthPx:h,controls:p}=xx(r);if(!m)return null;const b=cx(m,s.markdownFilePath,s.rootPath);return b?e.jsx(vx,{url:b,fallbackText:g,widthPx:h,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(gx,{html:r},n):null;const u=l[1].toLowerCase(),c=ht(l[2],`${n}-${u}`,!0,s);return u==="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):u==="mark"?e.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:c},n):u==="sub"?e.jsx("sub",{children:c},n):e.jsx("sup",{children:c},n)}function ht(r,n,s=!0,l){return l.budget.nested(()=>yx(r,n,s,l))}function yx(r,n,s=!0,l){l.budget.validateInline(r);const u=mx(r),c=[];let m=0;for(const{index:g,token:h}of ag(u,l.budget)){g>m&&c.push(Eu(u.slice(m,g)));const p=`${n}-${g}`,b=h.startsWith("<")?wx(h,p,l):null;if(b)c.push(b);else if(h.startsWith("\\(")&&h.endsWith("\\)"))c.push(e.jsx(ra,{tex:h.slice(2,-2)},p));else if(h.startsWith("$")&&h.endsWith("$"))c.push(e.jsx(ra,{tex:h.slice(1,-1)},p));else if(h.startsWith("`")){const f=h.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:px(h.slice(f,-f))},p))}else if(h.startsWith("~~"))c.push(e.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:ht(h.slice(2,-2),`${p}-del`,s,l)},p));else if(h.startsWith("**")||h.startsWith("__"))c.push(e.jsx("strong",{className:"font-semibold text-foreground",children:ht(h.slice(2,-2),`${p}-strong`,s,l)},p));else if(h.startsWith("*")||h.startsWith("_"))c.push(e.jsx("em",{className:"italic",children:ht(h.slice(1,-1),`${p}-em`,s,l)},p));else if(h.startsWith("![")){const f=h.match(/^!\[([^\]]*)\]\((.*)\)$/),x=h.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),$=h.match(/^!\[([^\]]+)\]$/);if(f){const P=Nl(f[2]);c.push(P?Qs(p,f[1],P.href,P.title,l):h)}else if(x){const P=x[2]||x[1],D=l.referenceDefinitions.get(xo(P));c.push(D?Qs(p,x[1],D.href,D.title,l):h)}else if($){const P=l.referenceDefinitions.get(xo($[1]));c.push(P?Qs(p,$[1],P.href,P.title,l):h)}else c.push(h)}else if(h.startsWith("[^")){const f=If(h.slice(2,-1)),x=l.footnoteDefinitions.get(f);c.push(x?e.jsx("sup",{id:`fnref-${x.id}`,title:x.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:e.jsx("a",{href:`#fn-${x.id}`,className:"text-primary no-underline",children:x.index})},p):h)}else if(h.startsWith("<http")){const f=h.slice(1,-1);c.push(e.jsx("a",{href:f,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:f},p))}else if(h.startsWith("<")&&h.endsWith(">")&&Cu(h.slice(1,-1))){const f=h.slice(1,-1);c.push(e.jsx("a",{href:`mailto:${f}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:f},p))}else if(Cu(el(h).linkText)){const{linkText:f,suffix:x}=el(h);c.push(e.jsx("a",{href:`mailto:${f}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:f},p)),x&&c.push(x)}else if(h.startsWith("http")||h.startsWith("www.")){const{linkText:f,suffix:x}=el(h),$=f.startsWith("www.")?`https://${f}`:f;c.push(e.jsx("a",{href:$,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:f},p)),x&&c.push(x)}else{const f=h.match(/^\[([^\]]+)\]\((.*)\)$/),x=h.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),$=h.match(/^\[([^\]]+)\]$/),P=x?x[2]||x[1]:$?.[1]??null,D=P?l.referenceDefinitions.get(xo(P)):null,_=f?Nl(f[2]):null,U=_?.href??D?.href??null,C=U?Pf(U):null,N=f?.[1]??x?.[1]??$?.[1]??"";c.push(C?e.jsx("a",{href:C,title:_?.title??D?.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):h)}m=g+h.length}return m<u.length&&c.push(Eu(u.slice(m))),c.length>0?c:[r]}function Kf(r){return/(?: {2,}|\\)$/.test(r)}function qf(r){return r.replace(/(?: {2,}|\\)$/,"")}function Co(r){return/^(?: {4}|\t)/.test(r)}function Vf(r){return r.startsWith(" ")?r.slice(1):r.replace(/^ {4}/,"")}function Yf(r,n,s){const l=[];return r.forEach((u,c)=>{const m=Kf(u);l.push(...ht(qf(u),`${n}-${c}`,!0,s)),c<r.length-1&&l.push(m?e.jsx("br",{},`${n}-${c}-br`):" ")}),l}function Cl(r,n,s){const l=[],u=[];return r.forEach((c,m)=>{u.push(Kf(c)),l.push(ht(qf(c),`${n}-${m}`,!0,s))}),{perLine:l,hardBreaks:u}}function El(r,n,s,l,u){const c=[];return r.forEach((m,g)=>{const h=s[g]??0,p=!!(u&&h>=u.start&&h<=u.end);c.push(e.jsx("span",{"data-md-ref-start":h,"data-md-ref-end":h,"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 na(r){const n=r.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let l="",u=!1,c=0,m=0;for(let g=0;g<n.length;g+=1){const h=n[g];if(u){l+=h,u=!1;continue}if(h==="\\"){u=!0;continue}if(h==="`"){const p=g;for(;g+1<n.length&&n[g+1]==="`";)g+=1;const b=g-p+1;l+="`".repeat(b),c===0?c=b:c===b&&(c=0);continue}if(c===0&&h==="["?m+=1:c===0&&h==="]"&&m>0&&(m-=1),h==="|"&&c===0&&m===0){s.push(l.trim()),l="";continue}l+=h}return u&&(l+="\\"),s.push(l.trim()),s}function Xf(r){return na(r).map(n=>/^:-+:$/.test(n)?"center":/^-+:$/.test(n)?"right":/^:-+$/.test(n)?"left":null)}function Eo(r){return r==="center"?"text-center":r==="right"?"text-right":"text-left"}function Mo(r){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(r.trim())}function Jf(r,n){return r>96||r>44&&n>.35}function Io(r){return(r.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function sa(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 Fl(r,n,s,l,u,c=new Set){const m=[],g=[];let h=n;for(;h<r.length;){const p=r[h];if(u&&(No(p)||c.has(h))){h+=1;continue}const b=sa(p),f=Io(p);if(!b){if(f>s&&g.length>0){([...g].reverse().find(D=>D.indent<f)?.item??g[g.length-1].item).paragraphs.push(p.trim());for(const D of g)D.item.lineEnd=h+1;h+=1;continue}break}if(f<s||f===s&&b.ordered!==l)break;const x={content:b.content,ordered:b.ordered,start:b.start,children:[],paragraphs:[],lineStart:h+1,lineEnd:h+1};for(;g.length>0&&g[g.length-1].indent>=f;)g.pop();const $=g[g.length-1]?.item??null;$?$.children.push(x):m.push(x),g.push({indent:f,item:x});for(const P of g)P.item.lineEnd=h+1;h+=1}return{items:m,nextIndex:h}}function kx(r){const n=r.find(l=>sa(l));if(!n)return[];const s=sa(n);return s?Fl(r,0,Io(n),s.ordered,!0,Ff(r)).items:[]}function _l(r,n,s,l=0){return s.budget.nested(()=>Sx(r,n,s,l))}function Sx(r,n,s,l=0){return r.map((u,c)=>{const m=u.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${c}`,taskItem:!!m,refStart:u.lineStart+l,refEnd:u.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]??u.content,`li-${n}-${c}`,!0,s),u.paragraphs.length>0&&e.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:u.paragraphs.map((g,h)=>e.jsx("p",{children:ht(g,`li-${n}-${c}-p-${h}`,!0,s)},`paragraph-${h}`))})]}),groups:jx(u.children,`${n}-${c}`,s,l)}})}function jx(r,n,s,l=0){const u=[];for(const c of r){const m=u[u.length-1];m&&m.ordered===c.ordered?m.items.push(c):u.push({ordered:c.ordered,items:[c]})}return u.map((c,m)=>({ordered:c.ordered,start:c.ordered?c.items[0]?.start:void 0,items:_l(c.items,`${n}-g${m}`,s,l)}))}function Bl(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&&Rx(s.groups,n)]},s.key)})}function Rx(r,n){return r.map((s,l)=>{const u=s.ordered?"ol":"ul";return e.jsx(u,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:Bl(s.items,n)},`nested-${l}`)})}function Nx(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 Cx(r,n,s,l){const u=[];let c=0;const m=g=>l?.[g]??g+1;for(;c<r.length;){s.budget.check();const g=r[c],h=g.trim();if(!h){c+=1;continue}if(/^<details>\s*$/i.test(h)){const U=c;let C="Details";const N=[];for(c+=1;c<r.length&&!/^<\/details>\s*$/i.test(r[c].trim());){const E=r[c].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);E?C=E[1].trim()||C:N.push(r[c].trimStart()),c+=1}c<r.length&&(c+=1),u.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(C,`${n}-details-${U}-summary`,!0,s)}),N.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:Yf(N,`${n}-details-${U}`,s)})]},`${n}-details-${U}`)});continue}const p=Gf(g);if(p){const U=[g],C=c;for(c+=1;c<r.length&&!p.selfContained&&!new RegExp(`</${p.tag}>`,"i").test(r[c]);)U.push(r[c]),c+=1;c<r.length&&!p.selfContained&&(U.push(r[c]),c+=1),u.push({kind:"static",node:e.jsx(Wf,{html:U.join(`
1639
- `)},`${n}-html-${C}`)});continue}const b=h.match(/^(```|~~~)\s*(.*)$/);if(b){const U=[],C=b[1],N=b[2]?.trim(),E=c;for(c+=1;c<r.length&&!r[c].trim().startsWith(C);)U.push(r[c]),c+=1;c<r.length&&(c+=1),N.toLowerCase()==="mermaid"?u.push({kind:"static",node:e.jsx(Zf,{code:U.join(`
1640
- `),blockKey:`${n}-code-${E}`},`${n}-code-${E}`)}):["math","latex","tex"].includes(N.toLowerCase())?u.push({kind:"static",node:e.jsx(ra,{tex:U.join(`
1641
- `),display:!0},`${n}-code-${E}`)}):u.push({kind:"code",key:`${n}-code-${E}`,code:U.join(`
1642
- `),lang:N,blockKey:`${n}-code-${E}`,codeStartLine:m(E)+1});continue}if(Co(g)){const U=[],C=c;for(;c<r.length&&(Co(r[c])||!r[c].trim());)U.push(r[c].trim()?Vf(r[c]):""),c+=1;u.push({kind:"code",key:`${n}-indented-code-${C}`,code:U.join(`
1643
- `).replace(/\n+$/,""),lang:"",blockKey:`${n}-indented-code-${C}`,codeStartLine:m(C)});continue}const f=h.match(/^(#{1,6})\s+(.+)$/);if(f){const C=`h${Math.min(6,f[1].length+1)}`,N=Tf(f[2]),E=jl(N,s);u.push({kind:"static",node:e.jsx(C,{id:E,className:"scroll-mt-16 font-semibold text-foreground",children:ht(N,`${n}-heading-${c}`,!0,s)},`${n}-heading-${c}`)}),c+=1;continue}if(c+1<r.length&&g.includes("|")&&Mo(r[c+1])){const U=na(g),C=Xf(r[c+1]),N=[],E=c;for(c+=2;c<r.length&&r[c].includes("|")&&r[c].trim();)N.push(na(r[c])),c+=1;u.push({kind:"static",node:e.jsx("div",{className:jf,"data-markdown-table-scroll":!0,children:e.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[e.jsx("thead",{className:"bg-surface-2 text-foreground",children:e.jsx("tr",{children:U.map((B,q)=>e.jsx("th",{className:`${kf} ${Eo(C[q]??null)}`,children:e.jsx("div",{className:Ro,children:ht(B,`${n}-th-${E}-${q}`,!0,s)})},`h-${q}`))})}),e.jsx("tbody",{children:N.map((B,q)=>e.jsx("tr",{className:"border-t border-border/10",children:U.map((S,o)=>e.jsx("td",{className:`${Sf} ${Eo(C[o]??null)}`,children:e.jsx("div",{className:Ro,children:ht(B[o]??"",`${n}-td-${E}-${q}-${o}`,!0,s)})},`c-${o}`))},`r-${q}`))})]})},`${n}-table-${E}`)});continue}const x=sa(g);if(x){const U=x.ordered,C=Io(g),N=x.start,E=c,B=Fl(r,c,C,U,!1);c=B.nextIndex,u.push({kind:"list",keyPrefix:`${n}-list-${E}`,ordered:U,start:U?N:void 0,renders:_l(B.items,`${n}-list-${E}`,s,m(0)-1)});continue}const $=[g.trimStart()],P=[m(c)],D=c;for(c+=1;c<r.length&&r[c].trim()&&!Sl(r[c])&&!(c+1<r.length&&r[c].includes("|")&&Mo(r[c+1]));)$.push(r[c].trimStart()),P.push(m(c)),c+=1;const _=Cl($,`${n}-p-${D}`,s);u.push({kind:"paragraph",keyPrefix:`${n}-p-${D}`,perLine:_.perLine,hardBreaks:_.hardBreaks,lineNums:P})}return u}function Ex(r,n){return r.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return e.jsx("p",{children:El(s.perLine,s.hardBreaks,s.lineNums,s.keyPrefix,n)},s.keyPrefix);case"list":{const l=s.ordered?"ol":"ul";return e.jsx(l,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} space-y-0.5 pl-4 marker:text-muted-foreground/70`,children:Bl(s.renders,n)},s.keyPrefix)}case"code":return e.jsx($o,{code:s.code,lang:s.lang,blockKey:s.blockKey,codeStartLine:s.codeStartLine,lineRange:n},s.key)}})}const uo=16,Qf=192;function Mx(r){const n=r.match(/\sviewBox=(["'])([^"']+)\1/i);if(!n)return r;const[,,s]=n,l=s.trim().split(/[\s,]+/).map(Number),[,,u,c]=l;if(!Number.isFinite(u)||!Number.isFinite(c)||u<=0||c<=0)return r;const m=Math.max(Qf,Math.ceil(u)),g=Math.ceil(m/u*c);return r.replace(/<svg\b([^>]*)>/i,(h,p)=>`<svg${p.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${m}" height="${g}">`)}function $x(r){const n=r?.querySelector("svg");if(!n)return;let s;try{s=n.getBBox()}catch{return}if(!Number.isFinite(s.width)||!Number.isFinite(s.height)||s.width<=0||s.height<=0)return;const l=s.x-uo,u=s.y-uo,c=s.width+uo*2,m=s.height+uo*2,g=Math.max(Qf,Math.ceil(c)),h=Math.ceil(g/c*m);n.setAttribute("viewBox",`${l} ${u} ${c} ${m}`),n.setAttribute("width",String(g)),n.setAttribute("height",String(h)),n.removeAttribute("style")}function Px(r){const n=r.trim().split(/\s+/,1)[0]?.toLowerCase();if(!n)return null;const s=n.replace(/^language-/,"");return Qu(`code.${s}`)??s}function Zf({code:r,blockKey:n}){const{t:s}=mt(),[l,u]=a.useState(null),[c,m]=a.useState(!1),g=a.useRef(null),h=a.useContext(Lf);a.useEffect(()=>{let b=!1;return u(null),m(!1),cg().then(async f=>{dg(f);const x=`termdock-md-mermaid-${n.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:$}=await f.render(x,r);b||u(Mx($))}).catch(()=>{b||m(!0)}),()=>{b=!0}},[n,r]),a.useLayoutEffect(()=>{l&&$x(g.current)},[l]);const p=a.useCallback(()=>{const b=g.current?.querySelector("svg")?.outerHTML??l;b&&h?.(b)},[h,l]);return c?e.jsx($o,{code:r,lang:"mermaid",blockKey:`${n}-fallback`}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[e.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"mermaid"}),e.jsx("div",{className:"bg-surface p-3",children:l?e.jsx("button",{type:"button",className:"block max-w-full rounded text-left focus:outline-none focus:ring-2 focus:ring-ring/45",title:s("rightSidebar.openMermaidDiagram"),onClick:b=>{b.stopPropagation(),p()},children:e.jsx("span",{ref:g,role:"img","aria-label":s("rightSidebar.mermaidDiagram"),className:"block max-h-[70vh] max-w-full overflow-auto rounded bg-white p-2 text-slate-900 [&_svg]:block [&_svg]:h-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:l}})}):e.jsx("div",{className:"py-6 text-center text-xs text-muted-foreground",children:s("rightSidebar.renderingDiagram")})})]})}function $o({code:r,lang:n,blockKey:s,codeStartLine:l,lineRange:u}){const c=Px(n),[m,g]=a.useState(null);a.useEffect(()=>{if(!c||!Zu(r)){g(null);return}let p=!1;return ef().then(b=>{if(p||!b.registered(c)){p||g(null);return}try{g(tf(b,r,c))}catch{p||g(null)}}).catch(()=>{p||g(null)}),()=>{p=!0}},[s,r,c]);const h=m??(r||" ").split(`
1644
- `).map(p=>[p||" "]);return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[n&&e.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:n}),e.jsx("pre",{className:`${Al} termdock-code overflow-auto p-3 text-[11px] leading-relaxed text-foreground`,children:e.jsx("code",{children:h.map((p,b)=>{const f=l!=null?l+b:null,x=!!(u&&f!=null&&f>=u.start&&f<=u.end);return e.jsxs("span",{"data-md-ref-start":f??void 0,"data-md-ref-end":f??void 0,"data-selected":x?"true":void 0,children:[p,b<h.length-1?`
1645
- `:null]},`${s}-line-${b}`)})})})]})}function Ol(r,n,s,l,u){const c=new ng;c.validateLines(r),r=ix(r);const m=ax(r),g=Ff(r),h=[],p={budget:c,markdownFilePath:n,rootPath:s,referenceDefinitions:m,footnoteDefinitions:ox(r),headingSlugCounts:new Map,images:h,onImageOpen:l,footnotesLabel:u?.footnotes??"Footnotes",backToFootnoteLabel:u?.backToFootnote??($=>`Back to footnote ${$}`)},b=[];let f=0;for(;f<r.length;){p.budget.check();const $=r[f],P=$.trim();if(No($)||g.has(f)){f+=1;continue}if(!P){f+=1;continue}if(/^<details>\s*$/i.test(P)){const S=f;let o="Details";const F=[];for(f+=1;f<r.length&&!/^<\/details>\s*$/i.test(r[f].trim());){const I=r[f].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);I?o=I[1].trim()||o:F.push(r[f].trimStart()),f+=1}f<r.length&&(f+=1),b.push({key:`details-${S}`,startLine:S+1,endLine:f,content:e.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ht(o,`details-${S}-summary`,!0,p)}),F.length>0&&e.jsx("div",{className:"mt-2 text-sm leading-6",children:Yf(F,`details-${S}`,p)})]})});continue}const D=Gf($);if(D){const S=[$],o=f;for(f+=1;f<r.length&&!D.selfContained&&!new RegExp(`</${D.tag}>`,"i").test(r[f]);)S.push(r[f]),f+=1;f<r.length&&!D.selfContained&&(S.push(r[f]),f+=1),b.push({key:`html-${o}`,startLine:o+1,endLine:f,content:e.jsx(Wf,{html:S.join(`
1646
- `)})});continue}const _=P.match(/^(```|~~~)\s*(.*)$/);if(_){const S=[],o=_[1],F=_[2]?.trim(),I=f;for(f+=1;f<r.length&&!r[f].trim().startsWith(o);)S.push(r[f]),f+=1;f<r.length&&(f+=1),b.push({key:`code-${I}`,startLine:I+1,endLine:f,fineGrained:F.toLowerCase()!=="mermaid"&&!["math","latex","tex"].includes(F.toLowerCase()),content:F.toLowerCase()==="mermaid"?e.jsx(Zf,{code:S.join(`
1647
- `),blockKey:`code-${I}`}):["math","latex","tex"].includes(F.toLowerCase())?e.jsx(ra,{tex:S.join(`
1648
- `),display:!0}):V=>e.jsx($o,{code:S.join(`
1649
- `),lang:F,blockKey:`code-${I}`,codeStartLine:I+2,lineRange:V})});continue}if(Co($)){const S=[],o=f;for(f+=0;f<r.length&&(Co(r[f])||!r[f].trim());)S.push(r[f].trim()?Vf(r[f]):""),f+=1;b.push({key:`indented-code-${o}`,startLine:o+1,endLine:f,fineGrained:!0,content:F=>e.jsx($o,{code:S.join(`
1650
- `).replace(/\n+$/,""),lang:"",blockKey:`indented-code-${o}`,codeStartLine:o+1,lineRange:F})});continue}if(P.startsWith("$$")){const S=[],o=f,F=P.replace(/^\$\$\s*/,"");if(F.endsWith("$$")&&F.length>2)S.push(F.replace(/\s*\$\$$/,"")),f+=1;else{for(F&&S.push(F),f+=1;f<r.length&&!r[f].trim().endsWith("$$");)S.push(r[f]),f+=1;if(f<r.length){const I=r[f].trim().replace(/\s*\$\$$/,"");I&&S.push(I),f+=1}}b.push({key:`math-${o}`,startLine:o+1,endLine:f,content:e.jsx(ra,{tex:S.join(`
1651
- `),display:!0})});continue}if(f+1<r.length&&P&&!Sl($)&&/^(=+|-+)\s*$/.test(r[f+1].trim())){const S=r[f+1].trim().startsWith("=")?1:2,o=`h${S}`,F=jl(P,p),I={level:S,text:Nu(P),id:F};b.push({key:`setext-heading-${f}`,startLine:f+1,endLine:f+2,heading:I,content:e.jsx(o,{id:F,className:`scroll-mt-16 font-semibold text-foreground ${S===1?"mt-1 border-b border-border/20 pb-1.5 text-lg sm:pb-2 sm:text-xl":"mt-1 border-b border-border/15 pb-1 text-base sm:pb-1.5 sm:text-lg"}`,children:ht(P,`setext-heading-${f}`,!0,p)})}),f+=2;continue}const U=P.match(/^(#{1,6})\s+(.+)$/);if(U){const S=U[1].length,o=Tf(U[2]),F={1:"mt-1 border-b border-border/20 pb-1.5 text-lg sm:pb-2 sm:text-xl",2:"mt-1 border-b border-border/15 pb-1 text-base sm:pb-1.5 sm:text-lg",3:"text-sm sm:text-base",4:"text-[13px] sm:text-sm",5:"text-[11px] uppercase tracking-wide sm:text-xs",6:"text-[11px] uppercase tracking-wide text-muted-foreground"},I=`h${S}`,V=jl(o,p),G={level:S,text:Nu(o),id:V};b.push({key:`heading-${f}`,startLine:f+1,endLine:f+1,heading:G,content:e.jsx(I,{id:V,className:`scroll-mt-16 font-semibold text-foreground ${F[S]}`,children:ht(o,`heading-${f}`,!0,p)})}),f+=1;continue}if($f($)){b.push({key:`hr-${f}`,startLine:f+1,endLine:f+1,content:e.jsx("hr",{className:"border-border/20"})}),f+=1;continue}if(P.startsWith(">")){const S=[],o=[],F=f;for(;f<r.length&&/^>\s?/.test(r[f].trim());)S.push(r[f].trim().replace(/^>\s?/,"")),o.push(f+1),f+=1;const I=S[0]?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i);if(I){const G=I[1].toUpperCase(),H=I[2]?.trim(),R=[...H?[H]:[],...S.slice(1)],z=[...H?[o[0]]:[],...o.slice(1)],Y=Cl(R,`callout-${F}`,p);b.push({key:`callout-${F}`,startLine:F+1,endLine:f,fineGrained:!0,content:A=>e.jsxs("aside",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-primary",children:G}),R.length>0&&e.jsx("div",{children:El(Y.perLine,Y.hardBreaks,z,`callout-${F}`,A)})]})});continue}const V=Cx(S,`quote-${F}`,p,o);b.push({key:`quote-${F}`,startLine:F+1,endLine:f,fineGrained:!0,content:G=>e.jsx("blockquote",{className:"space-y-2 border-l-2 border-border-strong bg-surface-2/70 py-1.5 pl-2.5 pr-2 text-muted-foreground sm:py-2 sm:pl-3",children:Ex(V,G)})});continue}if(f+1<r.length&&$.includes("|")&&Mo(r[f+1])){const S=na($),o=Xf(r[f+1]),F=[],I=f;for(f+=2;f<r.length&&r[f].includes("|")&&r[f].trim();)F.push(na(r[f])),f+=1;const V=S.map((H,R)=>ht(H,`th-${I}-${R}`,!0,p)),G=F.map((H,R)=>S.map((z,Y)=>ht(H[Y]??"",`td-${I}-${R}-${Y}`,!0,p)));b.push({key:`table-${I}`,startLine:I+1,endLine:f,interactive:!1,kind:"table",content:H=>{const R=z=>!!(H&&z>=H.start&&z<=H.end);return e.jsx("div",{className:jf,"data-markdown-table-scroll":!0,children:e.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[e.jsx("thead",{className:"bg-surface-2 text-foreground",children:e.jsx("tr",{"data-markdown-table-row-line":I+1,"data-md-ref-start":I+1,"data-md-ref-end":I+1,"data-selected":R(I+1)?"true":void 0,children:V.map((z,Y)=>e.jsx("th",{className:`${kf} ${Eo(o[Y]??null)}`,children:e.jsx("div",{className:Ro,children:z})},`h-${Y}`))})}),e.jsx("tbody",{children:G.map((z,Y)=>{const A=I+Y+3;return e.jsx("tr",{className:"border-t border-border/10","data-markdown-table-row-line":A,"data-md-ref-start":A,"data-md-ref-end":A,"data-selected":R(A)?"true":void 0,children:S.map((O,Q)=>e.jsx("td",{className:`${Sf} ${Eo(o[Q]??null)}`,children:e.jsx("div",{className:Ro,children:z[Q]})},`c-${Q}`))},`r-${Y}`)})})]})})}});continue}const C=sa($);if(C){const S=C.ordered,o=Io($),F=C.start,I=f,V=Fl(r,f,o,S,!0,g);f=V.nextIndex;const G=S?"ol":"ul",H=_l(V.items,`list-${I}`,p);b.push({key:`list-${I}`,startLine:I+1,endLine:f,fineGrained:!0,content:R=>e.jsx(G,{start:S?F:void 0,className:`${S?"list-decimal":"list-disc"} space-y-0.5 pl-4 text-muted-foreground marker:text-muted-foreground/70 sm:space-y-1 sm:pl-5`,children:Bl(H,R)})});continue}const N=[$.trimStart()],E=[f+1],B=f;for(f+=1;f<r.length&&r[f].trim()&&!Sl(r[f])&&!(f+1<r.length&&r[f].includes("|")&&Mo(r[f+1]));){if(No(r[f])||g.has(f)){f+=1;continue}N.push(r[f].trimStart()),E.push(f+1),f+=1}const q=Cl(N,`p-${B}`,p);b.push({key:`p-${B}`,startLine:B+1,endLine:f,fineGrained:!0,content:S=>e.jsx("p",{className:"text-muted-foreground",children:El(q.perLine,q.hardBreaks,E,`p-${B}`,S)})})}const x=Nx(p);return x&&b.push({key:"footnotes",startLine:r.length,endLine:r.length,content:x}),c.check(),{blocks:b,images:h}}function Lx(r,n,s){return Ol(r,n,s).blocks}function eh(r,n){const s=[];for(const l of r){if(l.startLine>n)break;if(l.heading){for(;s.length>0&&s[s.length-1].level>=l.heading.level;)s.pop();s.push({...l.heading,startLine:l.startLine})}}return s}function th(r){return r.filter(n=>!!n.heading).map(n=>({...n.heading,startLine:n.startLine}))}function Ax({src:r,alt:n,onZoomChange:s,onDoubleTap:l}){const{t:u}=mt(),c=Of(r),m=cf(c),[g,h]=a.useState(null),[p,b]=a.useState(0);a.useEffect(()=>{if(!m)return;const x=new AbortController;let $;return h(null),Hu(c,{signal:x.signal}).then(async P=>{if(!P.ok)throw new Error(`HTTP ${P.status}`);const D=await P.blob();x.signal.aborted||($=URL.createObjectURL(D),h({src:c,objectUrl:$}))}).catch(()=>{x.signal.aborted||h({src:c,failed:!0})}),()=>{x.abort(),$&&URL.revokeObjectURL($)}},[m,c,p]);const f=g?.src===c?g:null;return m&&!f?.objectUrl?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",role:f?.failed?"alert":"status",children:f?.failed?e.jsxs("div",{className:"flex flex-col items-center gap-3",onClick:x=>x.stopPropagation(),children:[e.jsx("span",{children:u("rightSidebar.imageLoadFailed")}),e.jsx("button",{type:"button",className:"rounded bg-surface-2 px-3 py-2 hover:bg-surface-elevated",onClick:()=>b(x=>x+1),children:u("common.retry")})]}):u("rightSidebar.loadingImage")}):e.jsx(hh,{src:m?f.objectUrl:c,vector:aa(r),alt:n,onLoad:()=>{},onError:()=>{m&&h({src:c,failed:!0})},onZoomChange:s,onDoubleTap:l})}function rh({images:r,index:n,onChange:s,onClose:l}){const{t:u}=mt(),c=r[n],m=r.length>1,g=a.useRef(null),h=a.useRef(null),p=a.useRef(null),b=a.useRef(0),[f,x]=a.useState(!1),[$,P]=a.useState(0),[D,_]=a.useState(!1),[U,C]=a.useState(!1),[N,E]=a.useState(null),B=a.useRef(!1),q=async()=>{if(!(!c||B.current)){S(),B.current=!0,C(!0),E(null);try{await lg(c)}catch(H){E({image:c,message:H instanceof Error?H.message:u("rightSidebar.downloadFailed")})}finally{B.current=!1,C(!1)}}},S=a.useCallback(()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null)},[]),o=a.useCallback(()=>{f||Date.now()<b.current||(S(),p.current=window.setTimeout(()=>{p.current=null,l()},450))},[S,f,l]),F=a.useCallback(H=>{if(r.length===0)return;const R=(H+r.length)%r.length;g.current?.slideTo(R),s(R)},[r.length,s]),I=a.useCallback(()=>F(n-1),[F,n]),V=a.useCallback(()=>F(n+1),[F,n]);if(a.useEffect(()=>{S(),P(0),_(!1),x(!1)},[S,n]),a.useEffect(()=>{const H=g.current;H&&(H.allowTouchMove=m&&!f)},[m,f]),a.useEffect(()=>{const H=g.current;!H||H.activeIndex===n||H.slideTo(n,0)},[n]),a.useEffect(()=>S,[S]),a.useEffect(()=>{const H=R=>{if(R.key==="Escape"){R.preventDefault(),l();return}m&&(R.key==="ArrowLeft"?(R.preventDefault(),I()):R.key==="ArrowRight"&&(R.preventDefault(),V()))};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[m,V,I,l]),Ku({onDrag:({movement:[H,R],pinching:z})=>{z||f||Math.abs(R)<Math.abs(H)*1.15&&$===0||(_(!0),Math.abs(R)>8&&(b.current=Date.now()+300),P(Math.max(0,R)))},onDragEnd:({movement:[H,R],velocity:[,z],pinching:Y,canceled:A})=>{if(_(!1),Y||A||f||Math.abs(R)<Math.abs(H)*1.15){P(0);return}if(Math.abs(R)>8&&(b.current=Date.now()+300),Jf(R,z)){l();return}P(0)}},{target:h,drag:{filterTaps:!0,pointer:{touch:!0}}}),!c)return null;const G=c.title||c.alt||(c.kind==="mermaid"?u("rightSidebar.mermaidDiagram"):u("rightSidebar.image"));return typeof document>"u"?null:kr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:l}),e.jsxs("div",{className:"fixed inset-0 z-modal-panel flex flex-col bg-background-subtle/95 pt-[var(--safe-top-inset,env(safe-area-inset-top,0px))] text-foreground","data-markdown-image-lightbox":!0,"data-sidebar-gesture-ignore":!0,children:[e.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/20 bg-surface/80 px-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:G}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n+1," / ",r.length]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[m&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:I,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":u("rightSidebar.previousImage"),title:u("common.previous"),children:e.jsx(Zs,{size:17})}),e.jsx("button",{type:"button",onClick:V,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":u("rightSidebar.nextImage"),title:u("common.next"),children:e.jsx(Hm,{size:17})})]}),e.jsx("button",{type:"button",onClick:()=>{q()},disabled:U,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:opacity-50 disabled:active:scale-100","aria-label":u("rightSidebar.downloadFile"),title:u("rightSidebar.downloadFile"),"aria-busy":U,children:U?e.jsx(ft,{size:17,className:"animate-spin"}):e.jsx(Gu,{size:17})}),e.jsx("button",{type:"button",onClick:l,className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":u("rightSidebar.closeImagePreview"),title:u("common.close"),children:e.jsx(Ft,{size:18})})]})]}),N?.image===c&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-center justify-between gap-3 bg-surface px-3 py-2 text-xs text-destructive",children:[e.jsxs("span",{className:"min-w-0 break-words",children:[u("rightSidebar.downloadFailed"),": ",N.message]}),e.jsx("button",{type:"button",className:"shrink-0 rounded bg-surface-2 px-3 py-1 text-foreground hover:bg-surface-elevated",onClick:()=>{q()},disabled:U,children:u("common.retry")})]}),e.jsx("div",{ref:h,className:"relative min-h-0 flex-1 overflow-hidden","data-markdown-image-lightbox-stage":!0,"data-sidebar-gesture-ignore":!0,onClick:H=>{if(!(Date.now()<b.current)){if(H.target instanceof Element&&H.target.closest('img, [role="img"]')){o();return}S(),l()}},children:e.jsx("div",{className:"h-full w-full",style:{transform:`translate3d(0, ${$}px, 0) scale(${Math.max(.86,1-$/900)})`,opacity:Math.max(.35,1-$/360),transition:D?"none":"transform 0.2s ease-out, opacity 0.2s ease-out",willChange:"transform, opacity"},children:e.jsx(qu,{onSwiper:H=>{g.current=H,H.allowTouchMove=m&&!f},onSlideChange:H=>{H.activeIndex!==n&&s(H.activeIndex)},onSliderMove:()=>{S(),b.current=Date.now()+450},initialSlide:n,speed:260,slidesPerView:1,resistanceRatio:.82,threshold:6,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,className:"h-full",children:r.map((H,R)=>e.jsx(cl,{className:"h-full",children:e.jsx("div",{className:"h-full w-full px-3 py-4 sm:px-6 sm:py-6",children:H.kind==="image"?e.jsx(Ax,{src:H.src,alt:H.alt||H.title||u("rightSidebar.markdownImage"),onZoomChange:x,onDoubleTap:S}):e.jsx(Yx,{svg:H.svg,title:H.title||H.alt||u("rightSidebar.mermaidDiagram"),onZoomChange:x,onDoubleTap:S})})},`${H.kind}-${R}-${H.alt}`))})})})]})]}),document.body)}function nh({content:r,filePath:n,rootPath:s,lineRange:l,onLineRangeClick:u,onLineRangeDrag:c,scrollTop:m,outlineOpen:g,outlineCloseSignal:h,onOutlineOpen:p,onOutlineClose:b,lightboxOpen:f,lightboxCloseSignal:x,onLightboxOpen:$,onLightboxClose:P,onLocalLinkOpen:D}){const{t:_}=mt(),[U,C]=a.useState(null),[N,E]=a.useState(null),[B,q]=a.useState(1),[S,o]=a.useState(null),F=a.useRef(null),I=a.useRef(null),{blocks:V,images:G,parseError:H}=a.useMemo(()=>{try{return{...Ol(r.split(`
1652
- `),n,s,L=>{E(null),C(L),$?.()},{footnotes:_("rightSidebar.footnotes"),backToFootnote:L=>_("rightSidebar.backToFootnote",{index:L})}),parseError:null}}catch(L){return{blocks:[],images:[],parseError:L instanceof Error?L.message:String(L)}}},[r,n,s,$,_]);a.useEffect(()=>{H&&wo("markdown_error",{filePath:n,rootPath:s,error:H,fallback:"plain_text"})},[H,n,s]);const R=a.useMemo(()=>N?[...G,N]:G,[G,N]),z=a.useCallback(L=>{E({kind:"mermaid",svg:L,alt:"Mermaid diagram",title:"Mermaid diagram"}),C(G.length),$?.()},[G.length,$]);a.useEffect(()=>{C(null),E(null)},[r,n]),a.useEffect(()=>{C(null),E(null)},[x]),a.useEffect(()=>{f||(C(null),E(null))},[f]),a.useEffect(()=>{q(1)},[r,n]),a.useLayoutEffect(()=>{const L=F.current;if(!L||V.length===0)return;const ne=Array.from(L.querySelectorAll("[data-markdown-preview-block-start]"));let Re=1;const ve=28;for(const Be of ne)if(Be.offsetTop-m<=ve)Re=Number(Be.dataset.markdownPreviewBlockStart)||Re;else break;q(Be=>Be===Re?Be:Re)},[V,m]);const Y=a.useMemo(()=>eh(V,B),[B,V]),A=a.useMemo(()=>th(V),[V]),O=`${n??""}
1653
- ${r}`,Q=a.useRef(O),ce=a.useRef(null),me=a.useRef(null),je=a.useRef(!1);a.useEffect(()=>{Q.current!==O&&(Q.current=O,b?.())},[b,O]),a.useEffect(()=>{h!==void 0&&o(null)},[h]),a.useLayoutEffect(()=>{if(!g){o(null);return}const L=()=>{const ne=I.current;if(!ne)return;const Re=ne.getBoundingClientRect(),ve=window.innerWidth;o({top:Re.bottom+6,right:Math.max(8,ve-Re.right)})};return L(),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0),()=>{window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}},[g,m,Y]);const $e=a.useCallback(L=>{const ne=F.current,Re=ne?.closest("[data-markdown-preview-scroller]"),ve=ne?.querySelector(`[data-markdown-preview-block-start="${L.startLine}"]`);if(!Re||!ve)return;const Be=Re.getBoundingClientRect(),fe=ve.getBoundingClientRect(),Fe=ne?.querySelector("[data-markdown-heading-sticky]")?.getBoundingClientRect().height??0,rt=fe.top-Be.top+Re.scrollTop;Re.scrollTo({top:Math.max(0,rt-Fe-8),behavior:"smooth"}),q(L.startLine),b?.()},[b]),Ce=a.useCallback(L=>{L.pointerType==="mouse"&&L.button!==0||ol(L.target)||(ce.current={pointerId:L.pointerId,startX:L.clientX,startY:L.clientY})},[]),T=a.useCallback((L,ne,Re)=>{const ve=ce.current;if(ce.current=null,!ve||ve.pointerId!==L.pointerId)return;const Be=Math.abs(L.clientX-ve.startX),fe=Math.abs(L.clientY-ve.startY);if(Be>8||fe>8)return;const Ye=L.target;if(ol(Ye)||ul())return;const Fe=Du(Ye,ne,Re);u(L,Fe.start,Fe.end)},[u]),ee=a.useCallback(L=>{ce.current?.pointerId===L.pointerId&&(ce.current=null)},[]),te=a.useCallback((L,ne)=>{const Re=F.current;if(!Re||typeof document.elementFromPoint!="function")return null;const ve=document.elementFromPoint(L,ne);if(!(ve instanceof HTMLElement)||!Re.contains(ve))return null;const Be=ve.closest("[data-md-ref-start]");if(Be){const Qe=Number(Be.dataset.mdRefStart);if(Number.isFinite(Qe)&&Qe>0)return Qe}const fe=ve.closest("[data-markdown-preview-block-start]");if(!fe)return null;const Ye=Number(fe.dataset.markdownPreviewBlockStart),Fe=V.find(Qe=>Qe.startLine===Ye);if(!Fe)return Number.isFinite(Ye)&&Ye>0?Ye:null;if(Fe.endLine<=Fe.startLine)return Fe.startLine;const rt=fe.getBoundingClientRect(),be=rt.height>0?Math.min(1,Math.max(0,(ne-rt.top)/rt.height)):0;return Math.round(Fe.startLine+be*(Fe.endLine-Fe.startLine))},[V]),Le=a.useCallback(L=>{if(!c||L.pointerType==="mouse"&&L.button!==0)return;const ne=te(L.clientX+24,L.clientY);if(ne!=null){me.current={pointerId:L.pointerId,anchorLine:ne,moved:!1};try{L.currentTarget.setPointerCapture(L.pointerId)}catch{}}},[c,te]),De=a.useCallback(L=>{const ne=me.current;if(!ne||ne.pointerId!==L.pointerId||!c)return;const Re=te(L.clientX+16,L.clientY);Re!=null&&(!ne.moved&&Re===ne.anchorLine||(ne.moved=!0,je.current=!0,c(L,Math.min(ne.anchorLine,Re),Math.max(ne.anchorLine,Re),"move")))},[c,te]),Te=a.useCallback(L=>{const ne=me.current;if(me.current=null,!ne||ne.pointerId!==L.pointerId||!c||!ne.moved)return;const Re=te(L.clientX+16,L.clientY)??ne.anchorLine;c(L,Math.min(ne.anchorLine,Re),Math.max(ne.anchorLine,Re),"end")},[c,te]),lt=a.useCallback(L=>{me.current?.pointerId===L.pointerId&&(me.current=null)},[]),Ie={onPointerDown:Le,onPointerMove:De,onPointerUp:Te,onPointerCancel:lt},we=()=>je.current?(je.current=!1,!0):!1;return H?e.jsxs("div",{className:"min-w-0 max-w-full px-4 py-4 text-sm leading-6 text-foreground","data-markdown-preview-fallback":!0,children:[e.jsx("p",{role:"alert",className:"mb-3 text-destructive",children:_("rightSidebar.markdownParseFailed")}),e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs",children:r})]}):V.length===0?e.jsx("div",{className:"min-w-0 max-w-full px-4 py-4 text-sm leading-6 text-foreground",children:e.jsx("p",{className:"text-muted-foreground",children:_("rightSidebar.emptyFile")})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:F,className:"relative min-w-0 max-w-full",onClickCapture:L=>{const ne=L.target instanceof Element?L.target.closest("a[href]"):null;if(!ne||!D)return;const Re=ne.getAttribute("href");if(!Re)return;const ve=Tl(Re,n,s);ve&&(L.preventDefault(),D(ve))},children:[Y.length>0&&e.jsx("div",{className:"sticky top-0 z-10 border-b border-border/15 bg-surface px-2 py-1 shadow-sm sm:px-3","data-markdown-heading-sticky":!0,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",title:Y.map(L=>L.text).join(" / "),children:[e.jsx("span",{className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/70","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold leading-5 text-foreground sm:text-[13px]","data-markdown-heading-current":!0,children:Y[Y.length-1].text}),A.length>1&&e.jsxs("button",{ref:I,type:"button",onClick:()=>{g?b?.():p?.()},className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 ${g?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":g,"aria-label":_("rightSidebar.markdownOutline"),title:_("rightSidebar.markdownOutline"),children:[e.jsx(Vu,{size:12}),e.jsx("span",{children:_("rightSidebar.markdownOutlineShort")})]})]})}),g&&typeof document<"u"&&kr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-menu-backdrop bg-[rgb(var(--background-rgb)_/_0.18)] sm:hidden",onClick:b}),e.jsx("div",{className:"hidden fixed z-menu-panel w-80 max-w-[min(20rem,calc(100vw-2rem))] rounded-lg border border-border/20 bg-surface p-2 shadow-xl sm:block",style:S?{top:`${S.top}px`,right:`${S.right}px`}:{top:-9999,right:-9999},"data-markdown-heading-outline-desktop":!0,children:e.jsx("div",{className:"max-h-72 overflow-auto pr-1",children:A.map(L=>{const ne=Y[Y.length-1]?.startLine===L.startLine;return e.jsxs("button",{type:"button",onClick:()=>$e(L),className:`flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition active:scale-[0.995] ${ne?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(L.level-1,4)*12+8}px`},title:L.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${ne?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",L.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:L.text})]},`desktop-${L.id}-${L.startLine}`)})})}),e.jsxs("div",{className:"fixed inset-x-0 bottom-0 z-drawer-panel max-h-[min(74vh,34rem)] rounded-t-xl border border-border/20 bg-surface p-2 pb-[calc(0.5rem+env(safe-area-inset-bottom,0px))] shadow-[0_-18px_48px_var(--app-shadow-strong)] sm:hidden","data-markdown-heading-outline-mobile":!0,children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 px-1.5 py-1 sm:hidden",children:[e.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:_("rightSidebar.markdownOutlineShort")}),e.jsx("button",{type:"button",onClick:b,className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":_("rightSidebar.closeMarkdownOutline"),title:_("common.close"),children:e.jsx(Ft,{size:14})})]}),e.jsx("div",{className:"max-h-[calc(min(74vh,34rem)-3.25rem-env(safe-area-inset-bottom,0px))] overflow-auto overscroll-contain pr-1 sm:max-h-72",children:A.map(L=>{const ne=Y[Y.length-1]?.startLine===L.startLine;return e.jsxs("button",{type:"button",onClick:()=>$e(L),className:`flex min-h-10 w-full min-w-0 items-center gap-2 rounded-md px-2 py-2 text-left transition active:scale-[0.995] ${ne?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(L.level-1,4)*12+8}px`},title:L.text,children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${ne?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",L.level]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:L.text})]},`${L.id}-${L.startLine}`)})})]})]}),document.body),e.jsx("div",{className:"min-w-0 max-w-full space-y-1.5 overflow-x-hidden break-words px-1.5 py-3 text-[13px] leading-5 text-foreground sm:space-y-2 sm:px-2 sm:py-4 sm:text-sm sm:leading-6",children:e.jsx(Lf.Provider,{value:z,children:V.map(L=>{const ne=!!(l&&L.startLine<=l.end&&L.endLine>=l.start),Re=!!(l&&l.start<=L.startLine&&l.end>=L.endLine),ve=L.kind==="table"?!1:L.fineGrained?Re:ne,Be=L.kind==="table"&&l?.start===L.startLine&&l.end===L.endLine;let fe=null;if(L.kind!=="table"&&L.fineGrained&&ne&&!Re&&l){const be=L.endLine-L.startLine+1,Qe=Math.max(l.start,L.startLine),Ue=Math.min(l.end,L.endLine),le=(Qe-L.startLine)/be,Ee=(Ue-Qe+1)/be;fe=e.jsx("span",{"aria-hidden":"true","data-md-rail-segment":!0,className:"absolute left-1/2 w-0.5 -translate-x-1/2 rounded-full bg-primary transition sm:w-1",style:{top:`calc(0.25rem + (100% - 0.5rem) * ${le})`,height:`calc((100% - 0.5rem) * ${Ee})`}})}const Ye=typeof L.content=="function"?L.content(l):L.content,Fe=L.startLine===L.endLine?String(L.startLine):`${L.startLine}-${L.endLine}`,rt=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:nl(ve),"aria-hidden":"true",...Ie,children:[e.jsx("span",{className:sl(ve)}),fe]}),e.jsx("div",{className:"min-w-0","data-sidebar-selectable":!0,children:Ye})]});return L.interactive===!1?e.jsxs("div",{"data-markdown-preview-block-start":L.startLine,className:`group grid w-full grid-cols-[0.625rem_minmax(0,1fr)] gap-1.5 rounded-md py-0.5 pr-1.5 text-left outline-none transition sm:grid-cols-[0.875rem_minmax(0,1fr)] sm:gap-2 sm:pr-2 ${ve?"bg-primary/10":""}`,title:`Line ${Fe}`,"aria-label":`Line ${Fe}`,children:[L.kind==="table"?e.jsx("button",{type:"button",className:nl(Be,"self"),onClick:be=>{be.preventDefault(),!we()&&u(be,L.startLine,L.endLine)},title:`Reference table lines ${Fe}`,"aria-label":`Reference table lines ${Fe}`,...Ie,children:e.jsx("span",{className:sl(Be,"self")})}):e.jsxs("span",{className:nl(ve,"none"),"aria-hidden":"true",...Ie,children:[e.jsx("span",{className:sl(ve,"none")}),fe]}),e.jsx("div",{className:"min-w-0 cursor-text select-text","data-sidebar-selectable":!0,role:"button",tabIndex:0,onPointerDown:Ce,onPointerUp:be=>T(be,L.startLine,L.endLine),onPointerCancel:ee,onKeyDown:be=>{be.key!=="Enter"&&be.key!==" "||(be.preventDefault(),u(be,L.startLine,L.endLine))},title:`Reference line ${Fe}`,"aria-label":`Reference line ${Fe}`,children:Ye})]},L.key):e.jsx("div",{role:"button",tabIndex:0,"data-markdown-preview-block-start":L.startLine,onClick:be=>{const Qe=be.target;if(ol(Qe)||ul()||we())return;const Ue=Du(Qe,L.startLine,L.endLine);u(be,Ue.start,Ue.end)},onKeyDown:be=>{be.key!=="Enter"&&be.key!==" "||(be.preventDefault(),u(be,L.startLine,L.endLine))},className:`group grid w-full cursor-pointer grid-cols-[0.625rem_minmax(0,1fr)] gap-1.5 rounded-md py-0.5 pr-1.5 text-left outline-none transition active:scale-[0.998] sm:grid-cols-[0.875rem_minmax(0,1fr)] sm:gap-2 sm:pr-2 ${ve?"bg-primary/10":"hover:bg-[var(--surface-2)]"}`,title:`Reference line ${Fe}`,"aria-label":`Reference line ${Fe}`,children:rt},L.key)})})})]}),f&&U!==null&&R[U]&&e.jsx(rh,{images:R,index:U,onChange:C,onClose:()=>{C(null),E(null),P?.()}})]})}function ls({label:r,value:n,options:s,placeholder:l,searchPlaceholder:u,emptyText:c,disabled:m,onChange:g}){const{t:h}=mt(),[p,b]=a.useState(!1),[f,x]=a.useState(""),[$,P]=a.useState(null),D=a.useRef(null),_=a.useRef(null),U=f.trim().toLowerCase(),C=a.useMemo(()=>U?s.filter(S=>`${S.label} ${S.meta??""}`.toLowerCase().includes(U)):s,[U,s]),N=s.find(S=>S.value===n),E=()=>{const S=f.trim();S&&(g(S),b(!1),x(""))},B=a.useCallback(()=>{const S=D.current?.getBoundingClientRect();if(!S)return!1;const o=12,F=Math.max(220,Math.min(S.width,window.innerWidth-o*2)),I=Math.min(Math.max(o,S.left),window.innerWidth-F-o),V=window.innerHeight-S.bottom-o,G=S.top-o,H=V>=180||V>=G,R=Math.max(96,(H?V:G)-4),z=Math.min(320,R);return P({left:I,top:H?S.bottom+4:Math.max(o,S.top-z-4),width:F,maxHeight:z}),!0},[]),q=()=>{B(),b(!0)};return a.useEffect(()=>{if(!p)return;let S=0;const o=()=>{S||(S=window.requestAnimationFrame(()=>{S=0,B()}))},F=I=>{const V=I.target;V instanceof Node&&(D.current?.contains(V)||_.current?.contains(V)||(b(!1),x("")))};return window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),document.addEventListener("pointerdown",F,!0),()=>{S&&window.cancelAnimationFrame(S),window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0),document.removeEventListener("pointerdown",F,!0)}},[p,B]),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:D,type:"button",disabled:m,onClick:()=>{if(!m){if(x(""),p){b(!1);return}q()}},className:"group flex w-full items-center justify-between gap-2 min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-left transition hover:bg-surface-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:r}),e.jsx("span",{className:`min-w-0 flex-1 truncate text-[13px] ${n?"text-foreground":"text-muted-foreground/70"}`,children:N?.label??(n||l)})]}),e.jsx(ea,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${p?"rotate-180":""}`})]}),p&&!m&&typeof document<"u"&&kr.createPortal(e.jsxs("div",{ref:_,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:S=>S.stopPropagation(),style:{left:$?.left??12,top:$?.top??12,width:$?.width??260,maxHeight:$?.maxHeight??320},children:[e.jsx("div",{className:"border-b border-border/10 p-1.5",children:e.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5",children:[e.jsx(ds,{size:12,className:"shrink-0 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:f,onChange:S=>x(S.target.value),onKeyDown:S=>{if(S.key==="Escape"){S.preventDefault(),b(!1),x("");return}S.key==="Enter"&&(S.preventDefault(),E())},onBlur:()=>{f.trim()&&C.length===0&&E()},placeholder:u,className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground outline-none placeholder:text-muted-foreground/70"})]})}),e.jsxs("div",{className:"overflow-y-auto p-1",style:{maxHeight:Math.max(96,($?.maxHeight??320)-46)},children:[f.trim()&&!s.some(S=>S.value===f.trim())&&e.jsxs("button",{type:"button",onMouseDown:S=>S.preventDefault(),onClick:E,className:"mb-1 flex w-full items-center justify-between gap-2 rounded-md bg-primary/10 px-2 py-1.5 text-left text-[12px] font-medium text-primary transition hover:bg-primary/15",children:[e.jsx("span",{className:"min-w-0 truncate",children:f.trim()}),e.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:h("common.use")})]}),C.length>0?C.map(S=>e.jsxs("button",{type:"button",onClick:()=>{g(S.value),b(!1),x("")},className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left text-[12px] transition hover:bg-surface-2 ${S.value===n?"bg-accent/10 text-accent":"text-foreground"}`,children:[e.jsx("span",{className:"min-w-0 truncate font-medium",children:S.label}),S.meta&&e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:S.meta})]},S.value)):e.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:c})]})]}),document.body)]})}function $u({open:r,onOpenChange:n,showScopePicker:s,selectedAll:l,repos:u,selectedRoots:c,onToggleRepo:m,onGenerate:g,onSecondaryAction:h,disabled:p,generateDisabled:b,secondaryDisabled:f,inserted:x,buttonLabel:$,insertedLabel:P,title:D,ariaLabel:_,scopeTitle:U,scopeLabel:C,allLabel:N,generateLabel:E,secondaryLabel:B,secondaryTitle:q,secondaryLoading:S,loading:o,error:F,statusTitle:I,extraContent:V,renderRepoExtra:G,menuItem:H=!1}){return e.jsxs("div",{className:H?"relative w-full":"relative inline-flex shrink-0",children:[e.jsxs("button",{type:"button",role:H?"menuitem":void 0,tabIndex:H?-1:void 0,onClick:()=>{s?n(!r):b||g()},disabled:p,className:`relative flex items-center rounded-md transition disabled:cursor-not-allowed disabled:opacity-50 ${H?"min-h-10 w-full gap-2.5 px-2.5 text-left text-[12px] focus:bg-surface-2 focus:outline-none [@media(pointer:coarse)]:min-h-11":"h-7 shrink-0 justify-center gap-1 px-2 text-[11px] font-medium active:scale-95"} ${F?"text-destructive hover:bg-destructive/5":x?"bg-surface-elevated text-foreground":H?"text-foreground hover:bg-surface-2":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":_,title:I??(s?`${U}: ${C}`:D),children:[o?e.jsx(ft,{size:H?15:13,className:"shrink-0 animate-spin"}):e.jsx(ta,{size:H?15:13,className:H?"shrink-0 text-muted-foreground":void 0}),e.jsx("span",{className:H?"min-w-0 flex-1":void 0,children:x?P:$}),s&&(H?e.jsx(cs,{size:13,className:"shrink-0 text-muted-foreground"}):e.jsx(ea,{size:11,className:`shrink-0 transition ${r?"rotate-180":""}`})),F&&e.jsx("span",{className:"absolute right-0.5 top-0.5 size-1.5 rounded-full bg-destructive"})]}),s&&r&&typeof document<"u"&&kr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] px-3 py-6 backdrop-blur-sm animate-fade-in",onClick:()=>n(!1),children:e.jsxs("div",{className:"fixed left-1/2 top-1/2 z-modal-panel flex max-h-[min(82vh,36rem)] w-[calc(100vw-1.5rem)] max-w-[42rem] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/20 bg-surface text-[11px] shadow-2xl",onClick:R=>R.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border/15 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:U}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:C})]}),e.jsx("button",{type:"button",onClick:()=>n(!1),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":"Close",children:e.jsx(Ft,{size:14})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[V,e.jsxs("button",{type:"button",onClick:()=>m(null),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${l?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[e.jsx("span",{className:"truncate",children:N}),l&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),u.map(R=>{const z=c.includes(R.root);return e.jsxs("div",{className:`mt-1 rounded-md transition ${z?"bg-primary/15 text-primary":""}`,children:[e.jsxs("button",{type:"button",onClick:()=>m(R.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${z?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:R.root,children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate",children:R.label}),R.branch&&e.jsx("span",{className:"block truncate text-[9px] opacity-70",children:R.branch})]}),z&&e.jsx("span",{className:"text-[10px]",children:"✓"})]}),G&&(l||z)&&e.jsx("div",{className:"px-2 pb-2",children:G(R)})]},R.root)})]}),e.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${h&&B?"sm:grid-cols-2":""}`,children:[h&&B&&e.jsxs("button",{type:"button",onClick:()=>{f||(n(!1),h())},disabled:f,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-surface-2 px-2 text-[11px] font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:q,children:[S?e.jsx(ft,{size:12,className:"animate-spin"}):e.jsx(nf,{size:12}),B]}),e.jsxs("button",{type:"button",onClick:()=>{b||(n(!1),g())},disabled:b,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-primary/15 px-2 text-[11px] font-semibold text-primary transition hover:bg-primary/25 disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:D,children:[e.jsx(ta,{size:12}),E]})]})]})}),document.body)]})}function Tx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const n of Object.values(r)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function sh(){return gt(Pl,Tx)??{}}function Ix(r,n){const s=sh(),l=Object.entries({...s,[r]:{top:n,updatedAt:Date.now()}}).sort(([,u],[,c])=>c.updatedAt-u.updatedAt).slice(0,Eb);Ys(Pl,Object.fromEntries(l),$b)}function Dx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.start=="number"&&Number.isFinite(n.start)&&typeof n.end=="number"&&Number.isFinite(n.end)&&n.start>=1&&n.end>=n.start}function Fx(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;for(const n of Object.values(r)){if(!n||typeof n!="object"||Array.isArray(n))return!1;const s=n;if(typeof s.top!="number"||!Number.isFinite(s.top)||s.left!==void 0&&(typeof s.left!="number"||!Number.isFinite(s.left))||s.markdownTop!==void 0&&(typeof s.markdownTop!="number"||!Number.isFinite(s.markdownTop))||s.lineRange!==void 0&&s.lineRange!==null&&!Dx(s.lineRange)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function Ul(r,n){if(!n)return null;const s=r&&!n.startsWith("/")?`${r}/${n}`:n;return r?`${r}::${s}`:s}function ah(){return gt(Ll,Fx)??{}}function Pu(r,n){const s=Ul(r,n);return s?ah()[s]??null:null}function tl(r,n,s){const l=Ul(r,n);if(!l)return;const u=ah(),c=u[l]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},m=Object.entries({...u,[l]:{...c,...s,updatedAt:Date.now()}}).sort(([,g],[,h])=>h.updatedAt-g.updatedAt).slice(0,Mb);Ys(Ll,Object.fromEntries(m),Pb)}function rl({slow:r}){return e.jsx(Ep,{slow:r})}function fo({message:r,onRetry:n}){const{t:s}=mt();return e.jsxs("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-5 text-center text-sm text-destructive",children:[e.jsx("div",{className:"font-medium",children:s("rightSidebar.gitChangesLoadFailed")}),e.jsx("div",{className:"mt-1 break-words text-xs opacity-85",children:r}),e.jsx("button",{type:"button",onClick:n,className:"mt-3 rounded-full bg-destructive/10 px-3 py-1.5 text-xs font-semibold text-destructive transition hover:bg-destructive/15 active:scale-95",children:s("rightSidebar.retryGitChanges")})]})}function vo(r,n){const s=n&&r.startsWith(`${n}/`)?r.slice(n.length+1):r,l=s.split("/").filter(Boolean);return{name:l.pop()||s,dir:l.join("/")}}function St(r){if(!r)return"";const n=r.replace(/\/+$/,"");return n.split("/").pop()||n||"/"}function ho(r){if(!r)return null;const n=r.replace(/\/+$/,"")||"/";if(n==="/")return null;const s=n.slice(0,n.lastIndexOf("/"))||"/";return s===n?null:s}function _x(r,n,s){return fl(r,n,s)}function nl(r,n="group"){return`relative flex min-h-5 w-full touch-none select-none items-stretch justify-center rounded transition sm:min-h-6 ${r?"bg-primary/20":`bg-[var(--surface-2)] ${n==="group"?"group-hover:bg-[var(--surface-elevated)]":n==="self"?"hover:bg-[var(--surface-elevated)]":""}`}`}function sl(r,n="group"){return`my-1 w-0.5 rounded-full transition sm:w-1 ${r?"bg-primary":`bg-[var(--border-strong)] ${n==="group"?"group-hover:bg-[var(--muted-foreground)]":n==="self"?"hover:bg-[var(--muted-foreground)]":""}`}`}function oh(r){const n=new Map;for(const s of r)n.set(Hl(s),s);return n}function ih(r,n){const s=new Map(r);for(const l of n)s.set(Hl(l),l);return s}function Lu(r,n){let s=0;for(const l of r){const u=vt(l,n);u&&n&&u!==n&&(s+=1)}return s}function Bx(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function Ox(r,n){return Array.from(ih(oh(r),n).values()).sort((s,l)=>s.path.localeCompare(l.path))}function Ux(r,n){const s=r.relativeRoot==="."?St(n??r.root)||r.name||r.root:r.relativeRoot||r.name||St(r.root)||r.root;return{root:r.root,label:s,branch:r.context?.branch??null,count:r.files.length,staged:Bx(r.files)}}function lh(r,n){const s=St(n??"")||n||"";return r.map(l=>Ux(l,n)).sort((l,u)=>s&&l.label===s?-1:s&&u.label===s?1:l.label.localeCompare(u.label))}function ch(r,n,s,l,u){const c=Nf(s),m=c.find(D=>D.root===l)??c[0]??null,g=n.find(D=>D.root===l)??null,h=g?.relativeRoot??m?.relativeRoot??".",p=g?.name??m?.name??(St(l)||l),b=(m?.files??s.files).map(D=>({...D,repoRoot:l,repoRelativeRoot:h,repoName:p})),f=m?.context??s.context,x={...g??m??{id:l,root:l,relativeRoot:h,name:p,depth:0,nested:!!(u&&l!==u),available:s.available,files:[],context:null},...m??{},id:g?.id??m?.id??l,root:l,displayRoot:g?.displayRoot??m?.displayRoot,relativeRoot:h,name:p,depth:g?.depth??m?.depth??0,nested:g?.nested??m?.nested??!!(u&&l!==u),available:m?.available??s.available,deferred:m?.deferred??!1,files:b,context:f?{...f,root:l,changedFiles:b.map(D=>({path:D.path,absolutePath:D.absolutePath,status:D.status}))}:null,untrackedDeferred:m?.untrackedDeferred??s.untrackedDeferred,error:m?.error??s.error},$=g?n.map(D=>D.root===l?x:D):[...n,x];return{files:Array.from(r).filter(D=>vt(D,u)!==l).concat(b),repositories:$,repoFilters:lh($,u)}}function vt(r,n){return r.repoRoot??n}function Hl(r){return`${r.repoRoot??""}\0${r.path}`}function vr(r){return r.absolutePath||r.path}function al(r){return Hl(r)}function Hx(r){return r.repoRelativeRoot&&r.repoRelativeRoot!=="."?r.repoRelativeRoot:r.repoName??""}function Au(r){return r.reduce((n,s)=>n+(s.staged?1:0),0)}function Tu(r){const n={added:0,modified:0,deleted:0,renamed:0,copied:0,untracked:0,conflicted:0,staged:0,other:0};for(const s of r)s.status==="added"?n.added+=1:s.status==="modified"?n.modified+=1:s.status==="deleted"?n.deleted+=1:s.status==="renamed"?n.renamed+=1:s.status==="copied"?n.copied+=1:s.status==="untracked"?n.untracked+=1:s.status==="conflicted"?n.conflicted+=1:n.other+=1,s.staged&&(n.staged+=1);return n}function Ws(r){let n=0;const s=r??"root";for(let l=0;l<s.length;l+=1)n=Math.imul(n^s.charCodeAt(l),16777619);return`right-sidebar-git-bundle:${(n>>>0).toString(36)}`}function Gs(r,n){return typeof r!="number"||!Number.isFinite(r)||r<=0?null:new Intl.DateTimeFormat(n==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(r))}function wr(r){return r instanceof DOMException&&r.name==="AbortError"}function zx(r){const n=r.error??r.context?.error??"";return n.includes("request was cancelled")||n.includes("IO_REQUEST_CANCELLED")}function Iu(r){return r?.available===!1&&r.code==="NOT_GIT_REPOSITORY"}function ol(r){return r instanceof HTMLElement&&!!r.closest('a, button, input, textarea, select, label, [contenteditable="true"]')}function Du(r,n,s){const l=r instanceof HTMLElement?r.closest("[data-md-ref-start]"):null,u=Number(l?.dataset.mdRefStart),c=Number(l?.dataset.mdRefEnd??l?.dataset.mdRefStart);return Number.isFinite(u)&&u>0&&Number.isFinite(c)&&c>0?{start:Math.min(u,c),end:Math.max(u,c)}:{start:n,end:s}}function Wx({actions:r,running:n,completed:s}){const{t:l}=mt(),[u,c]=a.useState(!1),m=a.useRef(null),g=r.find(p=>n?.action===p.key),h=r.find(p=>s?.action===p.key);return r.length===0?null:(a.useEffect(()=>{if(!u)return;const p=f=>{const x=f.target;x instanceof Node&&m.current?.contains(x)||c(!1)},b=f=>{f.key==="Escape"&&c(!1)};return document.addEventListener("pointerdown",p),document.addEventListener("keydown",b),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("keydown",b)}},[u]),e.jsxs("div",{ref:m,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),c(b=>!b)},disabled:r.every(p=>p.disabled)&&!n&&!s,className:`inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md transition active:scale-95 disabled:opacity-50 ${u?"bg-surface-elevated text-foreground":h?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:g?.label??h?.label??l("rightSidebar.gitQuickActions"),children:g?e.jsx(ft,{size:13,className:"animate-spin"}):h?e.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):e.jsx(yo,{size:14})}),u&&e.jsx("div",{className:"absolute right-0 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:r.map(p=>{const b=n?.action===p.key,f=s?.action===p.key;return e.jsxs("button",{type:"button",onClick:x=>{x.stopPropagation(),p.onClick(),c(!1)},disabled:p.disabled||!!n,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] disabled:opacity-50 ${f?"bg-accent/10 text-accent":p.destructive?"text-destructive hover:bg-destructive/10":"text-foreground hover:bg-surface-2"}`,children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:b?e.jsx(ft,{size:13,className:"animate-spin"}):f?"✓":null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.label})]},p.key)})})]}))}function Gx(r){const n=window.getComputedStyle(r).overflowY;return(n==="auto"||n==="scroll")&&r.scrollHeight>r.clientHeight+1}function dh(r){let n=r;for(;n;){if(n.classList.contains("termdock-diff-stream-scroller")&&Gx(n))return n;n=n.parentElement}return r.closest(".termdock-diff-stream-scroller")}function us(r){return r.getClientRects().length>0&&window.getComputedStyle(r).visibility!=="hidden"}const il=new WeakMap;function Po(r){const n=il.get(r);n!==void 0&&window.clearTimeout(n),r.classList.remove("diff-walkthrough-target"),r.offsetWidth,r.classList.add("diff-walkthrough-target");const s=window.setTimeout(()=>{r.classList.remove("diff-walkthrough-target"),il.delete(r)},1700);il.set(r,s)}function Kx(r){const n=CSS.escape(r),s=[`[data-diff-stream-item="${n}"]`,`[data-diff-selection-path="${n}"]`,`[data-diff-absolute-path="${n}"]`].join(","),l=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let u=null;for(const g of l){if(!us(g))continue;const h=g.querySelector(s);if(h&&us(h)){u=h;break}}if(u??=Array.from(document.querySelectorAll(s)).find(us)??null,!u)return;const c=dh(u);if(!c){u.scrollIntoView({block:"start",behavior:"smooth"}),Po(u);return}const m=u.getBoundingClientRect().top-c.getBoundingClientRect().top+c.scrollTop;c.scrollTo({top:Math.max(0,m),behavior:"instant"}),Po(u)}function Nn(r){const n=CSS.escape(r.filePath),s=typeof r.sectionIndex=="number"?String(r.sectionIndex):null,l=typeof r.hunkIndex=="number"?String(r.hunkIndex):null,u=r.sectionFingerprint?CSS.escape(r.sectionFingerprint):null,c=r.hunkFingerprint?CSS.escape(r.hunkFingerprint):null,m=[s!==null&&u?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${u}"]`:null,s!==null&&u?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${u}"]`:null,s!==null?`[data-diff-section-audit="${n}"][data-diff-section-index="${s}"]`:null,s!==null?`[data-diff-section-anchor="${n}"][data-diff-section-index="${s}"]`:null,l!==null&&c?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"][data-diff-hunk-fingerprint="${c}"]`:null,l!==null?`[data-diff-hunk-anchor="${n}"][data-diff-hunk-index="${l}"]`:null,`[data-diff-file-path="${n}"]`].filter(P=>!!P),g=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let h=null;for(const P of g)if(us(P)){for(const D of m){const _=P.querySelector(D);if(_&&us(_)){h=_;break}}if(h)break}if(h??=m.flatMap(P=>Array.from(document.querySelectorAll(P))).find(us)??null,!h){Kx(r.filePath);return}const p=dh(h);if(!p){h.scrollIntoView({block:"center",behavior:"smooth"}),Po(h);return}const b=h.getBoundingClientRect(),f=p.getBoundingClientRect(),$=b.top-f.top+p.scrollTop-Math.max(24,(p.clientHeight-b.height)/2);p.scrollTo({top:Math.max(0,$),behavior:"instant"}),Po(h)}const uh=1,zl=8;function qx(r,n=zl){return Math.min(n,Math.max(uh,r))}function fh({resetKey:r,maxScale:n=zl,onZoomChange:s,onDoubleTap:l,children:u}){const c=a.useRef(null),[m,g]=a.useState({scale:1,x:0,y:0}),[h,p]=a.useState(!1),b=a.useRef(null),f=a.useRef(new Set),x=a.useRef(!1),$=a.useRef(null),P=a.useRef(0),D=a.useRef(m);D.current=m,a.useEffect(()=>{g({scale:1,x:0,y:0})},[r]);const _=a.useCallback((E,B,q)=>{const S=c.current;if(!S)return{x:B,y:q};const o=S.firstElementChild instanceof HTMLElement?S.firstElementChild:null,F=o?.clientWidth||S.clientWidth,I=o?.clientHeight||S.clientHeight,V=Math.max(0,(F*E-S.clientWidth)/2),G=Math.max(0,(I*E-S.clientHeight)/2);return{x:Math.min(V,Math.max(-V,B)),y:Math.min(G,Math.max(-G,q))}},[]),U=a.useCallback((E,B,q)=>{g(S=>{const o=qx(E,n),F=c.current;if(!F||o===1)return{scale:o,x:0,y:0};const I=F.getBoundingClientRect(),V=(B??I.left+I.width/2)-I.left-I.width/2,G=(q??I.top+I.height/2)-I.top-I.height/2,H=o/S.scale,R=V-(V-S.x)*H,z=G-(G-S.y)*H;return{scale:o,..._(o,R,z)}})},[_,n]),C=a.useCallback((E,B)=>{p(!0),D.current.scale>1?g({scale:1,x:0,y:0}):U(2.5,E,B),window.setTimeout(()=>p(!1),220)},[U]);a.useEffect(()=>{const E=c.current;if(!E)return;const B=o=>{if(o.pointerType==="mouse"&&o.button!==0)return;const F=f.current.size===0;if(f.current.add(o.pointerId),F){const I=Date.now(),V=$.current;if(V&&I-V.time<350&&Math.hypot(o.clientX-V.x,o.clientY-V.y)<24){$.current=null,P.current=I,l?.(),C(o.clientX,o.clientY);return}}if(f.current.size>1){x.current=!0,b.current=null;return}if(!(D.current.scale<=1)){o.preventDefault(),b.current={pointerId:o.pointerId,startX:o.clientX,startY:o.clientY,originX:D.current.x,originY:D.current.y,moved:!1};try{E.setPointerCapture?.(o.pointerId)}catch{}p(!1)}},q=o=>{const F=b.current;if(!F||F.pointerId!==o.pointerId)return;const I=o.clientX-F.startX,V=o.clientY-F.startY;if(!F.moved){if(Math.hypot(I,V)<6)return;F.moved=!0}o.stopPropagation(),o.preventDefault(),g(G=>({...G,..._(G.scale,F.originX+I,F.originY+V)}))},S=o=>{const F=b.current,I=F?.pointerId===o.pointerId&&F.moved;if(F?.pointerId===o.pointerId){F.moved&&o.stopPropagation(),b.current=null;try{E.releasePointerCapture?.(o.pointerId)}catch{}}f.current.delete(o.pointerId)&&f.current.size===0&&(!x.current&&!I&&($.current={time:Date.now(),x:o.clientX,y:o.clientY}),x.current=!1)};return E.addEventListener("pointerdown",B,{capture:!0,passive:!1}),window.addEventListener("pointermove",q,{capture:!0,passive:!1}),window.addEventListener("pointerup",S,{capture:!0}),window.addEventListener("pointercancel",S,{capture:!0}),()=>{E.removeEventListener("pointerdown",B,{capture:!0}),window.removeEventListener("pointermove",q,{capture:!0}),window.removeEventListener("pointerup",S,{capture:!0}),window.removeEventListener("pointercancel",S,{capture:!0})}},[_,l,C]),Ku({onPinch:({offset:[E],origin:[B,q]})=>{p(!1),U(E,B,q)},onWheel:({event:E,delta:[B,q],ctrlKey:S})=>{if(S){E.preventDefault(),E.stopPropagation(),p(!1),U(D.current.scale*(1-q*.01),E.clientX,E.clientY);return}D.current.scale<=1||(E.preventDefault(),E.stopPropagation(),p(!1),g(o=>({...o,..._(o.scale,o.x-B,o.y-q)})))}},{target:c,eventOptions:{passive:!1},pinch:{scaleBounds:{min:uh,max:n},from:()=>[D.current.scale,0],rubberband:!0}});const N=m.scale>1;return a.useEffect(()=>{s?.(N)},[s,N]),e.jsx("div",{ref:c,"data-sidebar-gesture-ignore":N?"":void 0,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden","data-image-zoom-viewport":!0,style:{cursor:N?"grab":"zoom-in"},onDoubleClick:E=>{E.stopPropagation(),!(Date.now()-P.current<500)&&(l?.(),C(E.clientX,E.clientY))},children:u({scale:m.scale,zoomed:N,animateTransform:h,transformStyle:{transform:`translate3d(${m.x}px, ${m.y}px, 0) scale(${m.scale})`,transformOrigin:"center center",transition:h?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none",willChange:"transform"},vectorTransformStyle:{transform:`translate3d(${m.x}px, ${m.y}px, 0)`,transformOrigin:"center center",transition:h?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}})})}function hh({src:r,alt:n,vector:s,onLoad:l,onError:u,onZoomChange:c,onDoubleTap:m}){const g=Ao(r,u),[h,p]=a.useState(null),b=s??aa(r);return a.useEffect(()=>{p(null)},[r]),e.jsx(fh,{resetKey:r,maxScale:Math.max(zl,h?.originalScale??1),onZoomChange:c,onDoubleTap:m,children:({vectorTransformStyle:f,scale:x,animateTransform:$})=>e.jsx("div",{"data-image-zoom-surface":!0,"data-vector-zoom-surface":b?"":void 0,className:"relative shrink-0 touch-none select-none",style:h?{...f,width:h.width,height:h.height}:{width:"100%",height:"100%"},children:e.jsx("img",{src:g,alt:n,draggable:!1,className:"touch-none select-none rounded border border-border/15 bg-surface object-contain shadow-sm",style:{position:"absolute",left:"50%",top:"50%",width:h?h.width*x:void 0,height:h?h.height*x:void 0,maxWidth:h?"none":"100%",maxHeight:h?"none":"100%",transform:"translate(-50%, -50%)",transition:$?"width 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"},onLoad:P=>{const D=P.currentTarget,_=D.closest("[data-image-zoom-viewport]");if(_&&D.naturalWidth>0&&D.naturalHeight>0){const U=Math.max(1,_.clientWidth-2),C=Math.max(1,_.clientHeight-2),N=Math.min(U/D.naturalWidth,C/D.naturalHeight),E=b?N:Math.min(N,1);p({width:D.naturalWidth*E,height:D.naturalHeight*E,originalScale:1/E})}l(P)},onError:u})})})}function Vx({svg:r,title:n,scale:s,vectorTransformStyle:l}){const u=a.useRef(null);return a.useLayoutEffect(()=>{const c=u.current,m=c?.querySelector("svg");if(!c||!m)return;const g=()=>{const b=m.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number)??[];let f=b[2],x=b[3];if((!Number.isFinite(f)||!Number.isFinite(x)||f<=0||x<=0)&&(f=Number(m.getAttribute("width")),x=Number(m.getAttribute("height"))),!Number.isFinite(f)||!Number.isFinite(x)||f<=0||x<=0)return;const $=Math.max(1,c.clientWidth-24),P=Math.max(1,c.clientHeight-24),D=Math.min($/f,P/x,1);m.style.width=`${Math.max(1,Math.floor(f*D*s))}px`,m.style.height=`${Math.max(1,Math.floor(x*D*s))}px`,m.style.maxWidth="none",m.style.maxHeight="none",m.style.transform=String(l.transform??""),m.style.transformOrigin="center center",m.style.transition=String(l.transition??"none")};g();const h=typeof ResizeObserver>"u"?null:new ResizeObserver(g);return h?.observe(c),()=>h?.disconnect()},[s,r,l]),e.jsx("div",{ref:u,role:"img","aria-label":n,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden rounded border border-border/15 bg-white p-3 text-slate-900 shadow-sm [&_svg]:block",dangerouslySetInnerHTML:{__html:r}})}function Yx({svg:r,title:n,onZoomChange:s,onDoubleTap:l}){return e.jsx(fh,{resetKey:r,onZoomChange:s,onDoubleTap:l,children:({vectorTransformStyle:u,scale:c})=>e.jsx(Vx,{svg:r,title:n,scale:c,vectorTransformStyle:u})})}let Xx=0,Jx=0,Qx=0,Zx=0,e0=0;function wo(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="still_active"?"warn":"info",message:`FILE_PREVIEW_LOADING ${r}`,data:{ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function dt(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:r==="error"||r==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${r}`,data:{seq:++Jx,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function Ks(r,n={}){if(typeof window>"u")return;const s=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${r}`,data:{seq:++Zx,ts:Date.now(),...n}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function t0(){return`diff-ui-${Date.now().toString(36)}-${(++e0).toString(36)}`}function r0(r){return r instanceof Element?r.closest("[data-diff-selection-path]"):null}function n0(r){const n=r.target instanceof HTMLElement?r.target:null;return{eventType:r.type,button:r.button,pointerType:r instanceof globalThis.PointerEvent?r.pointerType:void 0,targetTag:n?.tagName,targetClass:n?.className,targetText:n?.textContent?.slice(0,80)}}function Lo({onReviewReference:r,filePath:n,active:s=!0,onInsertReference:l,onInsertText:u,onInsertFeature:c,onReferenceCopied:m,onClose:g,onDirectoryLinkOpen:h,isMobile:p,markdownOutlineOpen:b,markdownOutlineCloseSignal:f,onOpenMarkdownOutline:x,onCloseMarkdownOutline:$,markdownImageLightboxOpen:P,markdownImageLightboxCloseSignal:D,onOpenMarkdownImageLightbox:_,onCloseMarkdownImageLightbox:U,lineRange:C,onLineRangeChange:N,insertedReferenceKey:E,copiedReferenceKey:B,scrollToLine:q,onScrollToLineHandled:S}){const{t:o}=mt(),F=a.useRef(null),I=a.useRef({}),V=a.useRef(s);V.current=s,a.useEffect(()=>{s||F.current?.querySelectorAll("video").forEach(M=>M.pause())},[s]);const G=J(M=>M.rootPath),H=J(M=>M.selectFile),[R,z]=a.useState({kind:"idle"}),[Y,A]=a.useState("schematic"),[O,Q]=a.useState(null),ce=a.useRef(null),[me,je]=a.useState(null),$e=a.useRef(new Map),Ce=a.useRef(null),[T,ee]=a.useState(null),[te,Le]=a.useState(()=>wu()),[De,Te]=a.useState(()=>iu(G,n)),lt=a.useRef(null),[Ie,we]=a.useState(!1),[L,ne]=a.useState(null),[Re,ve]=a.useState(0),[Be,fe]=a.useState([]),[Ye,Fe]=a.useState(null),rt=a.useRef(null),be=a.useRef(n),[Qe,Ue]=a.useState(null),[le,Ee]=a.useState({status:"idle"}),[He,qt]=a.useState(!1),[jt,W]=a.useState(""),[re,ye]=a.useState([]),[Xe,Ct]=a.useState(0),Tr=a.useRef(null),lr=rf(m),Et=Ul(G,n);a.useEffect(()=>{if(be.current===n)return;be.current=n;const M=n&&G&&!n.startsWith("/")?`${G}/${n}`:n;if(rt.current===M){rt.current=null;return}rt.current=null,fe([]),Fe(null),qt(!1),W("")},[n,G]);const _t=n?G&&!n.startsWith("/")?`${G}/${n}`:n:null,Vt=J(M=>_t?(M.fileChangeVersions.get(_t)??0)+M.fileWatchEpoch:M.fileWatchEpoch),En=a.useRef(null),Mn=a.useRef(null),[fs,$n]=a.useState(0),Pn=a.useCallback(()=>$n(M=>M+1),[]);a.useEffect(()=>{const M=ce.current;return ce.current=null,Q(null),M&&URL.revokeObjectURL(M.objectUrl),()=>{const K=ce.current;ce.current=null,K&&URL.revokeObjectURL(K.objectUrl)}},[_t,Vt,fs]),a.useEffect(()=>{if(!n){En.current=null,z({kind:"idle"});return}const M=G&&!n.startsWith("/")?`${G}/${n}`:n,K=new AbortController,de=++Xx,ke=`right-sidebar-file-preview:${de}`,Je=performance.now();let ze=!1;const qe=(se,We={})=>{ze||(ze=!0,wo("end",{loadingId:de,reason:se,durationMs:Math.round(performance.now()-Je),filePath:n,fullPath:M,rootPath:G,...We}))};let Ve=null;const st=$m(M),xt=st?M.toLowerCase().endsWith(".kicad_pcb")?Y==="schematic"?"pcb-front":Y:"schematic":Y,Br=!st&&Ml(M),Nr=!st&&!Br&&Pm(M),Or=!st&&!Br&&!Nr&&Ou(M),ys=zs(M),rn=Os(M),Tn=st?"eda":Br?"image":Nr?"model3d":Or?"video":"text",Cr=En.current!==M;if(En.current=M,Cr){wo("start",{loadingId:de,filePath:n,fullPath:M,rootPath:G,mode:Tn,externalVersion:Vt}),Ee({status:"idle"}),z({kind:"loading",mode:Tn}),Mn.current=null;const se=Pu(G,n);N(se?.lineRange??null),Le(ys?wu():"source"),Te(rn?iu(G,n):"source"),st&&A(Lm(M))}Cr||z(se=>se.kind==="error"?{kind:"loading",mode:Tn}:se);const Ur=window.setTimeout(()=>{ze||K.signal.aborted||wo("still_active",{loadingId:de,filePath:n,fullPath:M,rootPath:G,mode:Tn,durationMs:Math.round(performance.now()-Je),isPathChange:Cr})},3e3),In=window.setTimeout(()=>{if(ze||K.signal.aborted)return;const se=st?o("rightSidebar.edaTimeout"):Nr?o("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";K.abort(new DOMException(se,"TimeoutError")),z({kind:"error",message:se}),qe("stuck_timeout",{error:se})},st?Am+5e3:Nr?Tm+5e3:Im(M)?35e3:_b);if(st){const se=xt==="pcb-3d"?ce.current:null;se?(z(se),qe("eda_3d_client_cache_hit",{bytes:se.meta.size,view:se.view,mimeType:se.meta.mimeType})):Dm(M,xt,K.signal,"view_file",ke).then(We=>{if(K.signal.aborted)return;Ve=URL.createObjectURL(We.blob);const Ut={kind:"eda",sourcePath:We.path||M,objectUrl:Ve,view:We.view,meta:{size:We.size,mimeType:We.mimeType,modified:We.modified}};if(We.view==="pcb-3d"){const nn=ce.current;nn&&nn.objectUrl!==Ve&&URL.revokeObjectURL(nn.objectUrl),ce.current=Ut,Q(Ut),Ve=null}z(Ut),qe("eda_loaded",{bytes:We.size,view:We.view,mimeType:We.mimeType})}).catch(We=>{K.signal.aborted||(z({kind:"error",message:We instanceof Error&&/timed out/i.test(We.message)?o("rightSidebar.edaTimeout"):We instanceof Error?We.message:o("rightSidebar.edaLoadFailed")}),qe("error",{error:We instanceof Error?We.message:String(We)}))})}else if(Br)Fm(M,K.signal,"view_file",ke).then(se=>{Ve=URL.createObjectURL(se.blob),z({kind:"image",objectUrl:Ve,meta:{size:se.size,mimeType:se.mimeType,modified:se.modified}}),qe("image_loaded",{bytes:se.size,mimeType:se.mimeType})}).catch(se=>{K.signal.aborted||(z({kind:"error",message:se instanceof Error?se.message:o("rightSidebar.imageLoadFailed")}),qe("error",{error:se instanceof Error?se.message:String(se)}))});else if(Nr)_m(M,K.signal,"view_file",ke).then(se=>{K.signal.aborted||(Ve=URL.createObjectURL(se.blob),z({kind:"model3d",sourcePath:se.path||M,objectUrl:Ve,ext:se.ext,meta:{size:se.size,mimeType:se.mimeType,modified:se.modified}}),qe("model3d_loaded",{bytes:se.size,ext:se.ext}))}).catch(se=>{K.signal.aborted||(z({kind:"error",message:se instanceof Error&&(se.name==="TimeoutError"||/timed out/i.test(se.message))?o("rightSidebar.model3dTimeout"):se instanceof Error?se.message:o("rightSidebar.model3dLoadFailed")}),qe("error",{error:se instanceof Error?se.message:String(se)}))});else if(Or){const se=Bm(M)??"",We=Uu(M);z(Ut=>Ut.kind==="video"&&Ut.url===We?Ut:{kind:"video",url:We,meta:{size:null,mimeType:se,modified:null}}),qe("video_ready",{mimeType:se})}else Id(M,K.signal,"view_file",ke).then(se=>{if(!K.signal.aborted){if(se.binary){z({kind:"binary"});return}z({kind:"text",content:se.content,sourcePath:se.path||M,meta:{size:se.size,truncated:se.truncated}}),qe("text_loaded",{bytes:se.size,truncated:!!se.truncated})}}).catch(se=>{K.signal.aborted||(z({kind:"error",message:se instanceof Error?se.message:"Failed to read file"}),qe("error",{error:se instanceof Error?se.message:String(se)}))});return()=>{K.abort(),Nt(ke),window.clearTimeout(Ur),window.clearTimeout(In),Ve&&URL.revokeObjectURL(Ve),qe("cleanup")}},[n,G,Vt,fs,N,o,Y]),a.useEffect(()=>{if(R.kind!=="model3d"||!n){je(null);return}let M=!1;const K=n.lastIndexOf("/"),de=K>=0?n.slice(K+1):n,ke=K>=0?n.slice(0,K):"",Je=ke.lastIndexOf("/"),ze=Je>=0?ke.slice(0,Je):"",qe=de.replace(/\.(stl|glb|gltf)$/i,""),Ve=`${ze?`${ze}/`:""}features/${qe}.json`;return Id(Ve).then(st=>{if(!M)try{const xt=JSON.parse(st.content);je(xt.version===1&&Array.isArray(xt.features)&&xt.features.length>0?xt.features:null)}catch{je(null)}}).catch(()=>{M||je(null)}),()=>{M=!0}},[R,n]),a.useEffect(()=>{if(R.kind!=="text"){Ue(null);return}const M=G&&n&&!n.startsWith("/")?`${G}/${n}`:n,K=Qu(M),de=R.content,ke=zs(M??"")&&te==="preview",Je=Os(M??"")&&De==="preview";if(!K||ke||Je||!Zu(de)){Ue(null);return}let ze=!1;const qe=Ve=>{if(ze||!Ve.registered(K)){ze||Ue(null);return}try{Ue(tf(Ve,de,K))}catch{Ue(null)}};return L?qe(L):(Ue(null),ef().then(Ve=>{ze||(ne(Ve),qe(Ve))}).catch(()=>{})),()=>{ze=!0}},[R,L,n,G,te,De]),a.useLayoutEffect(()=>{if(!Et||R.kind!=="text")return;const M=`${Et}:${te}:${De}`;if(Mn.current===M)return;const K=Pu(G,n);if(Mn.current=M,!K)return;const de=requestAnimationFrame(()=>{const ke=Ce.current;if(!ke)return;const Je=te==="preview"?K.markdownTop??K.top:K.top;ke.scrollTo({top:Math.max(0,Je??0),left:Math.max(0,K.left??0)}),ve(te==="preview"?Math.max(0,Je??0):0)});return()=>cancelAnimationFrame(de)},[n,te,De,R.kind,Et,G]),a.useEffect(()=>{Et&&tl(G,n,{lineRange:C})},[n,C,Et,G]),a.useEffect(()=>{if(q==null||R.kind!=="text")return;ee(null),N({start:q,end:q});const M=q,K=requestAnimationFrame(()=>{const de=$e.current.get(M);de&&de.scrollIntoView({block:"center"}),S?.()});return()=>cancelAnimationFrame(K)},[q,R,N,S]);const Mt=a.useCallback(M=>{const K=Ce.current;if(!K)return!1;const de=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(M):M.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),ke=K.querySelector(`#${de}`);return ke?(ke.scrollIntoView({block:"start"}),!0):!1},[]);a.useEffect(()=>{const M=G&&n&&!n.startsWith("/")?`${G}/${n}`:n,K=R.kind==="text"&&zs(M??"")&&te==="preview";if(!Ye||!K)return;const de=requestAnimationFrame(()=>{Mt(Ye)&&Fe(null)});return()=>cancelAnimationFrame(de)},[n,Mt,te,Ye,R,G]),a.useLayoutEffect(()=>{const M=Ce.current;if(!M||!C){ee(null);return}if(T)return;const K=R.kind==="image"||R.kind==="loading"&&R.mode==="image",de=G&&n&&!n.startsWith("/")?`${G}/${n}`:n,ke=R.kind==="text"&&zs(de??"")&&te==="preview",Je=R.kind==="text"&&Os(de??"")&&De==="preview";if(R.kind!=="text"||K||ke||Je){ee(null);return}const ze=()=>{const Ve=$e.current.get(C.end);if(!Ve||!M){ee(null);return}const st=Ve.offsetTop+Ve.offsetHeight/2,xt=M.scrollLeft+Math.max(8,M.clientWidth-120);ee({top:st,left:xt})};ze();const qe=new ResizeObserver(()=>ze());return qe.observe(M),()=>qe.disconnect()},[C,T,R,te,De,n,G,Qe]);const Sr=R.kind==="text"&&!(Os(_t??"")&&De==="preview")&&!_t?.toLowerCase().endsWith(".csv")&&!_t?.toLowerCase().endsWith(".kicad_pro")&&!_t?.toLowerCase().endsWith(".kicad_prl"),cr=a.useCallback(()=>{qt(!1),W(""),ye([]),Ct(0),io(I.current)},[]),Vr=a.useCallback(()=>{!s||!Sr||(qt(!0),requestAnimationFrame(()=>{const M=F.current;!V.current||!M?.isConnected||M.closest('[inert], [aria-hidden="true"], [hidden]')||M.getClientRects().length===0||getComputedStyle(M).visibility==="hidden"||!M.contains(document.activeElement)||(Tr.current?.focus(),Tr.current?.select())}))},[s,Sr]),Ir=a.useCallback(M=>{Ct(K=>re.length===0?0:(K+M+re.length)%re.length)},[re.length]),oa=a.useCallback(M=>{if(M.nativeEvent.isComposing||!vb(F.current,s,M))return;const K=wb(M);if(K==="open"&&Sr){M.preventDefault(),Vr();return}He&&(K==="close"?(M.preventDefault(),cr()):(K==="next"||K==="previous")&&(M.preventDefault(),Ir(K==="previous"?-1:1)))},[s,cr,He,Ir,Vr,Sr]);if(a.useLayoutEffect(()=>{if(io(I.current),!s||!He||!jt.trim()||!Ce.current){ye([]),Ct(0);return}const M=kb(Ce.current,jt);return ye(M),Ct(0),(F.current?.contains(document.activeElement)||uu(I.current))&&(qi(M,0,I.current),fu(M[0])),()=>io(I.current)},[s,He,jt,Qe,te,R]),a.useEffect(()=>{!s||!He||!jt.trim()||!F.current?.contains(document.activeElement)&&!uu(I.current)||(qi(re,Xe,I.current),fu(re[Xe]))},[s,Xe,re,He,jt]),a.useEffect(()=>()=>io(I.current),[]),!n)return e.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:o("rightSidebar.selectFilePrompt")});const Ke=G&&!n.startsWith("/")?`${G}/${n}`:n,$t=vo(Ke,G),Yr=Wu(Ke,G),bt=R.kind==="text"&&R.content?R.content.split(`
1654
- `):[],Do=Math.max(2,String(bt.length).length)+1,Pt=R.kind==="text"||R.kind==="image"||R.kind==="model3d"||R.kind==="video"||R.kind==="eda"?R.meta:null,ia=zs(Ke),Xr=Ke.toLowerCase().endsWith(".csv"),hs=Ke.toLowerCase().endsWith(".kicad_pro"),ms=Ke.toLowerCase().endsWith(".kicad_prl"),ut=R.kind==="text"&&ia&&te==="preview",Dr=Os(Ke),tr=R.kind==="text"&&Dr&&De==="preview",ps=R.kind==="image"||R.kind==="loading"&&R.mode==="image",gs=R.kind==="model3d"||R.kind==="loading"&&R.mode==="model3d",bs=R.kind==="video"||R.kind==="loading"&&R.mode==="video",la=R.kind==="eda"||R.kind==="loading"&&R.mode==="eda",Jr=R.kind==="text"?R.sourcePath:Ke,jr=hp(Jr,G,C),Fr=(()=>{if(!C||R.kind!=="text"||bt.length===0)return jr;const M=[];for(let ke=C.start;ke<=C.end;ke+=1)M.push(`${ke} ${bt[ke-1]??""}`);const K=Mf(Ke).replace(/^\./,""),de="```";return`${jr}
1655
- ${de}${K}
1656
- ${M.join(`
1657
- `)}
1658
- ${de}
1659
- `})(),Qr=`path:${Ke}`,rr=C?`path:${Ke}:${C.start}-${C.end}`:Qr,Rr=E===Qr,_r=E===rr,xs=B===Qr,Zr=B===rr,dr=_r||Zr,Bt=C?C.start===C.end?`L${C.start}`:`L${C.start}-${C.end}`:null,xe=M=>{const K=Ce.current;if(!K)return;const de=K.getBoundingClientRect(),ke=M.currentTarget.getBoundingClientRect(),Je=M.clientX||ke.left+ke.width/2,qe=(M.clientY||ke.top+ke.height/2)-de.top+K.scrollTop,Ve=p?116:132,st=K.scrollLeft+Math.max(8,K.clientWidth-Ve),xt=Math.min(Math.max(8,Je-de.left+K.scrollLeft+10),st);ee({top:qe,left:xt})},Yt=(M,K)=>{ul()||(xe(M),N(de=>{const ke=fl(de,K,K);return ke||ee(null),ke}))},en=(M,K,de)=>{xe(M),N(ke=>{const Je=fl(ke,K,de);return Je||ee(null),Je})},Ln=(M,K,de,ke)=>{ke==="end"&&xe(M),N({start:K,end:de})},vs=M=>{const{scrollTop:K,scrollLeft:de}=M.currentTarget;ve(K),tl(G,n,{top:K,left:de,markdownTop:K})},An=M=>{if(M.directory){h?.(M.path);return}if(M.path===Ke||R.kind==="text"&&M.path===R.sourcePath){M.fragment&&Mt(M.fragment);return}fe(K=>[...K,Ke]),rt.current=M.path,Fe(M.fragment),N(null),H(M.path)},Ot=()=>{const M=Be[Be.length-1];M&&(fe(K=>K.slice(0,-1)),rt.current=M,Fe(null),N(null),H(M))},Fo=M=>{const{scrollTop:K,scrollLeft:de}=M.currentTarget;tl(G,n,{top:K,left:de})},tn=M=>{if(r){r(Fr,rr);return}C&&u(Fr,rr,M.currentTarget)},ws=async()=>{if(!(!Ke||le.status==="pending")&&!(R.kind==="loading"||R.kind==="error")){Ee({status:"pending"});try{await Fu(Ke),Ee({status:"idle"})}catch(M){Ee({status:"error",message:M instanceof Error?M.message:o("rightSidebar.downloadFailed")})}}};return e.jsxs("div",{ref:F,tabIndex:-1,onKeyDown:oa,onFocusCapture:()=>{s&&He&&jt.trim()&&qi(re,Xe,I.current)},onPointerDownCapture:M=>{M.target instanceof Element&&!M.target.closest('button, input, textarea, select, a, [tabindex]:not([tabindex="-1"])')&&M.currentTarget.focus({preventScroll:!0})},className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[lr.popoverNode,e.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${p&&(ut||tr)?"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(Vu,{size:16})}),Be.length>0&&e.jsxs("button",{type:"button",onClick:Ot,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(Zs,{size:15}),!p&&e.jsx("span",{className:"text-[11px] font-medium",children:o("rightSidebar.backToPreviousPreview")})]}),e.jsxs("div",{className:"min-w-0",title:Ke,children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:$t.name}),$t.dir&&e.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:$t.dir})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Sr&&e.jsx("button",{type:"button",onClick:He?cr:Vr,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 ${He?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":o("rightSidebar.findInFile"),title:`${o("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:e.jsx(ds,{size:14})}),ia&&R.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{b&&$?.(),Le(M=>{const K=M==="preview"?"source":"preview";return Dt(pf,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(te==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:o(te==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:p?te==="preview"?e.jsx(ml,{size:14}):e.jsx(hl,{size:14}):o(te==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),Dr&&R.kind==="text"&&e.jsx("button",{type:"button",onClick:()=>{Te(M=>{const K=M==="preview"?"source":"preview";return Og(G,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(De==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:o(De==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:p?De==="preview"?e.jsx(ml,{size:14}):e.jsx(hl,{size:14}):o(De==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),tr&&e.jsx("button",{type:"button",onClick:()=>{lt.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(Ie?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:o(Ie?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:e.jsx(Yu,{size:15})}),!p&&e.jsx("button",{type:"button",onClick:M=>l(Ke,Qr,M.currentTarget),...lr(Yr,Qr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${Rr||xs?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:o("rightSidebar.insertReference",{reference:Yr}),children:o(xs?"rightSidebar.copied":Rr?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Yr)},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:Yr}),"aria-label":o("rightSidebar.copyFileRef"),children:e.jsx(Om,{size:13})}),e.jsx("button",{type:"button",onClick:()=>{ws()},disabled:le.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:le.status==="error"?le.message??o("rightSidebar.downloadFailed"):o("rightSidebar.downloadFile"),"aria-label":o("rightSidebar.downloadFile"),children:le.status==="pending"?e.jsx(ft,{size:13,className:"animate-spin"}):e.jsx(Gu,{size:14})})]})]}),He&&Sr&&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(ds,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("input",{ref:Tr,type:"search",value:jt,onChange:M=>W(M.target.value),onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),Ir(M.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:re.length>0?`${Xe+1}/${re.length}`:"0/0"})]}),e.jsx("button",{type:"button",onClick:()=>Ir(-1),disabled:re.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($l,{size:13})}),e.jsx("button",{type:"button",onClick:()=>Ir(1),disabled:re.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(mp,{size:13})}),e.jsx("button",{type:"button",onClick:cr,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(Ft,{size:13})})]}),Pt&&!(p&&(ut||tr))&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[Pt.size!==null&&e.jsx("span",{children:o("rightSidebar.byteCount",{count:Pt.size.toLocaleString()})}),"truncated"in Pt&&Pt.truncated&&e.jsx("span",{className:"text-[color:var(--warning)]",children:o("rightSidebar.previewTruncated")}),"mimeType"in Pt&&e.jsx("span",{children:Pt.mimeType}),"dimensions"in R&&R.dimensions&&e.jsxs("span",{children:[R.dimensions.width," × ",R.dimensions.height]})]}),!(p&&(ut||tr))&&!gs&&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:la?o("rightSidebar.edaPickHint"):Xr?o("rightSidebar.csvTablePreview"):hs||ms?o("rightSidebar.kicadProjectPickHint"):bs?o("rightSidebar.videoPreviewHint"):ps?o("rightSidebar.imagePreviewHint"):ut?C?o("rightSidebar.selectedLineHint",{lineLabel:Bt??""}):o("rightSidebar.markdownPreviewHint"):tr?o("rightSidebar.htmlPreviewHint"):C?o("rightSidebar.selectedLineHint",{lineLabel:Bt??""}):o("rightSidebar.multiLineHint")})})]}),!s&&(R.kind==="video"||R.kind==="model3d"||R.kind==="eda"||tr)?null:R.kind==="loading"?e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8",children:e.jsx(Bi,{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:Pn,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(df,{blobUrl:R.objectUrl,filePath:Ke,viewLabel:"SVG 文件",onInsertAnnotation:c}):e.jsx(hh,{src:R.objectUrl,alt:$t.name,vector:!1,onLoad:M=>{const K=M.currentTarget;z(de=>de.kind==="image"?{...de,dimensions:{width:K.naturalWidth,height:K.naturalHeight}}:de)},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(Jg,{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(sb,{blobUrl:R.objectUrl,filePath:R.sourcePath,view:R.view,board:Ke.toLowerCase().endsWith(".kicad_pcb"),onViewChange:A,onInsertAnnotation:r??c,onRefresh:Pn,interactive3d:O?e.jsx(a.Suspense,{fallback:e.jsx(Bi,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:e.jsx(vu,{blobUrl:O.objectUrl,ext:".glb",fileName:$t.name,filePath:O.sourcePath,features:null,onInsertFeature:r??c,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:M=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(M)?M:"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(Bi,{label:o("rightSidebar.model3dLoading"),className:"min-h-0 flex-1 px-3 py-8"}),children:e.jsx(vu,{blobUrl:R.objectUrl,ext:R.ext,fileName:$t.name,filePath:R.sourcePath,features:me,onInsertFeature:r??c,onRefresh:Pn})})}):R.kind==="text"&&Xr?e.jsx(ib,{content:R.content,filePath:Ke,onInsertAnnotation:r??c},Ke):R.kind==="text"&&(hs||ms)?e.jsx(db,{content:R.content,filePath:Ke,localState:ms,onInsertAnnotation:r??c},Ke):ut?e.jsxs("div",{ref:Ce,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:vs,style:{touchAction:"pan-x pan-y"},children:[e.jsx(nh,{content:R.content,filePath:R.sourcePath,rootPath:G,lineRange:C,onLineRangeClick:en,onLineRangeDrag:Ln,scrollTop:Re,outlineOpen:b,outlineCloseSignal:f,onOutlineOpen:x,onOutlineClose:$,lightboxOpen:P,lightboxCloseSignal:D,onLightboxOpen:_,onLightboxClose:U,onLocalLinkOpen:An}),C&&T&&e.jsxs("button",{type:"button",onClick:tn,...lr(Fr,rr),style:{top:T.top,left:T.left,transform:"translateY(-50%)"},className:Zd(p,dr),title:`Insert markdown reference: ${jr}`,children:[e.jsx(So,{size:p?13:11}),Zr?o("rightSidebar.copied"):_r?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:Bt??""})]})]}):tr?e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:e.jsx(xb,{ref:lt,src:Um(Ke),title:`${$t.name} preview`,exitFullscreenLabel:o("rightSidebar.htmlFullscreenExit"),onFullscreenChange:we},`${Ke}:${Vt}:${fs}`)}):R.kind==="text"?e.jsxs("div",{ref:Ce,onScroll:Fo,className:`${Al} 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:[bt.length>0?e.jsx("div",{className:"min-w-full",children:bt.map((M,K)=>{const de=K+1,ke=!!(C&&de>=C.start&&de<=C.end),Je=Qe&&Qe.length===bt.length?Qe[K]:null;return e.jsxs("div",{ref:ze=>{ze?$e.current.set(de,ze):$e.current.delete(de)},role:"button","data-file-preview-line":de,tabIndex:0,onClick:ze=>Yt(ze,de),onKeyDown:ze=>{ze.key!=="Enter"&&ze.key!==" "||(ze.preventDefault(),Yt(ze,de))},style:{gridTemplateColumns:`${Do}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 ${Yr}:${de}`,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:de}),e.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Je??(M||" ")})]},K)})}):"Empty file.",C&&T&&e.jsxs("button",{type:"button",onClick:tn,...lr(Fr,rr),style:{top:T.top,left:T.left,transform:"translateY(-50%)"},className:Zd(p,dr),title:`Insert code reference: ${jr}`,children:[e.jsx(So,{size:p?13:11}),Zr?o("rightSidebar.copied"):_r?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:Bt??""})]})]}):null]})}function s0({rootPath:r,file:n,active:s,...l}){const[u,c]=a.useState(null),[m,g]=a.useState(n.line??1),h=a.useCallback(()=>g(null),[]);return e.jsx("div",{"data-architecture-source":!0,className:"h-full min-h-0",children:e.jsx(Lo,{...l,filePath:`${r.replace(/\/+$/,"")}/${n.path}`,active:s,lineRange:u,onLineRangeChange:c,scrollToLine:m,onScrollToLineHandled:h,markdownOutlineOpen:!1,markdownImageLightboxOpen:!1})})}function a0({isOpen:r,sessionId:n,drawerWidthPx:s,onClose:l,onOpen:u,push:c,pinned:m=!1,onTogglePinned:g,rightSidebarFilePreviewOpen:h=!1,rightSidebarFilePreviewCloseSignal:p,onOpenRightSidebarFilePreview:b,onCloseRightSidebarFilePreview:f,rightSidebarRepoPickerOpen:x=!1,rightSidebarRepoPickerCloseSignal:$,onOpenRightSidebarRepoPicker:P,onCloseRightSidebarRepoPicker:D,markdownOutlineOpen:_=!1,markdownOutlineCloseSignal:U,onOpenMarkdownOutline:C,onCloseMarkdownOutline:N,markdownImageLightboxOpen:E=!1,markdownImageLightboxCloseSignal:B,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:S}){const{t:o,locale:F}=mt(),[I,V]=a.useState(""),[G,H]=a.useState(null),R=J(t=>t.rightSearchOpen),z=J(t=>t.setRightSearchOpen),Y=J(t=>t.rightSidebarLayoutPreference),A=J(t=>t.setRightSidebarLayoutPreference),[O,Q]=a.useState(()=>Jb()),[ce,me]=a.useState("."),[je,$e]=a.useState(""),[Ce,T]=a.useState(!1),[ee,te]=a.useState(!1),[Le,De]=a.useState(!1),[Te,lt]=a.useState(!1),Ie=a.useDeferredValue(I),[we,L]=a.useState(null),[ne,Re]=a.useState([]),[ve,Be]=a.useState([]),fe=J(t=>t.contextKey?t.activeGitRepos[t.contextKey]??null:null),Ye=J(t=>t.setActiveGitRepo),[Fe,rt]=a.useState(null),[be,Qe]=a.useState(null),[Ue,le]=a.useState(null),[Ee,He]=a.useState(()=>gt(mu,Vs)??!1),[qt,jt]=a.useState(()=>gt(pu,Vs)??!1),[W,re]=a.useState(()=>gt(gu,Vs)??!1),[ye,Xe]=a.useState(()=>gt(Xi,Kb)??""),[Ct,Tr]=a.useState(0),[lr,Et]=a.useState(!1),[_t,Vt]=a.useState(!1),En=a.useRef(null),Mn=a.useRef(null),[fs,$n]=a.useState(!1),[Pn,Mt]=a.useState(null),[Sr,cr]=a.useState(null),[Vr,Ir]=a.useState(()=>yu(Vi)),[oa,Ke]=a.useState(()=>yu(hu)),[$t,Yr]=a.useState(()=>Gb()),[bt,Do]=a.useState(()=>qb()),[Pt,ia]=a.useState(()=>Yb()),Xr="words",[hs,ms]=a.useState(0),[ut,Dr]=a.useState([]),[tr,ps]=a.useState([]),[gs,bs]=a.useState(!1),[la,Jr]=a.useState(null),[jr,Fr]=a.useState([]),[Qr,rr]=a.useState(!1),[Rr,_r]=a.useState([]),[xs,Zr]=a.useState([]),[dr,Bt]=a.useState(!1),[xe,Yt]=a.useState(null),[en,Ln]=a.useState([]),[vs,An]=a.useState({}),Ot=a.useRef(0),[Fo,tn]=a.useState(0),[ws,M]=a.useState(!1),[K,de]=a.useState(null),[ke,Je]=a.useState(null),[ze,qe]=a.useState(null),[Ve,st]=a.useState(null),[xt,Br]=a.useState(!1),[Nr,Or]=a.useState(""),ys=a.useDeferredValue(Nr),[rn,Tn]=a.useState({}),[Cr,Ur]=a.useState([]),[In,se]=a.useState(!1),[We,Ut]=a.useState(!1),[nn,Dn]=a.useState(null),[_o,Fn]=a.useState(!1),ur=a.useRef(null),Hr=a.useRef(0),Wl=a.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[mh,ca]=a.useState(null),[ks,Gl]=a.useState(()=>gt(Yi,Vs)??!1),[Bo,Oo]=a.useState(!1),[da,Uo]=a.useState([]),[nr,ua]=a.useState({}),[Lt,fa]=a.useState({}),[sn,Ho]=a.useState({}),[Kl,ql]=a.useState(()=>new Set),[Ze,an]=a.useState(null),[zo,on]=a.useState(null),[ph,Er]=a.useState(!1),[Wo,Mr]=a.useState(0),[,Go]=a.useState(0),[Ko,ha]=a.useState(!1),[gh,bh]=a.useState(()=>J.getState().rightTab==="files"),[sr,qo]=a.useState(!1),[xh,Vl]=a.useState(()=>J.getState().rightTab==="diff"),[Vo,Yl]=a.useState(()=>J.getState().rightTab==="android"),[zr,Xl]=a.useState(!1),ma=Oi(t=>t.docks[Hi]),vh=!!ma,[Oe,Ss]=a.useState(null),[_n,js]=a.useState(null),[wt,ln]=a.useState(null),[Jl,yt]=a.useState(null),[Bn,Ql]=a.useState(null),[Yo,wh]=a.useState(()=>Date.now()),[yh,kh]=a.useState(!1),[cn,pa]=a.useState(!1),[ga,Zl]=a.useState(""),[On,ba]=a.useState(""),[dn,xa]=a.useState(""),[un,va]=a.useState(""),[ec,Un]=a.useState(null),[wa,ya]=a.useState(!1),[tc,Xo]=a.useState(!1),[rc,nc]=a.useState(!1),[ka,Sh]=a.useState({key:null,nonce:0}),sc=a.useRef(null),ac=a.useRef(null),oe=ep(s,m,Y),Jo=Rf(oe,m,Pt),[Qo,Zo]=a.useState(()=>sx(s)),ei=J(t=>t.rightTab),fr=J(t=>t.setRightTab),v=J(t=>t.rootPath),Hn=J(t=>t.explorerRoot),oc=J(t=>t.pinnedExplorerRootsCache),ic=J(t=>t.hydratePinnedExplorerRoots),lc=J(t=>t.syncPinnedExplorerRoots),Ht=J(t=>t.setExplorerRoot),cc=J(t=>t.resetExplorerToProject),zn=J(t=>t.pinExplorerRoot),fn=J(t=>t.unpinExplorerRoot),at=J(t=>t.selectedFilePath),ot=J(t=>t.selectFile),ti=J(t=>t.showHiddenFiles),jh=J(t=>t.toggleShowHiddenFiles),ri=J(t=>!!(v&&t.nestedGitScanRoots[v])),Ae=J(t=>t.changedFiles),Sa=J(t=>t.setChangedFiles),Wn=J(t=>t.invalidateDirectoryCache),Rh=J(t=>t.setDirectorySortMode),dc=J(t=>t.applyFileWatchEvents),uc=J(t=>t.reconcileDirectoryCache),fc=J(t=>t.bumpFileWatchEpoch),hr=J(t=>t.gitBundleLoading),hc=J(t=>t.gitBundleSlow),hn=J(t=>t.gitBundleError),Gn=J(t=>t.gitBundleLastLoadedAt),mc=J(t=>t.beginGitBundleLoading),pc=J(t=>t.setGitBundleSlowFor),ni=J(t=>t.finishGitBundleLoading),ja=J(t=>t.resetGitBundleLoading),si=J(t=>t.setGitBundleError),gc=J(t=>t.markGitBundleLoaded),ue=Hn??v,Ra=J(t=>!!(ue&&t.hideGitIgnoredRoots[ue])),Nh=J(t=>t.hideGitIgnoredRootsHydrated),Ch=J(t=>t.setHideGitIgnoredRoot),[ai,bc]=a.useState(!1),[xc,oi]=a.useState(null);a.useEffect(()=>{oi(null)},[ue]);const vc=a.useMemo(()=>ue?jb(ue,ce):"",[ue,ce]),Rs=a.useMemo(()=>Sb(je),[je]),wc=a.useMemo(()=>({excludePatterns:Rs,caseSensitive:ee,wholeWord:Le,regex:Te}),[ee,Rs,Te,Le]),Na=J(t=>ue?t.fileSortModes[ue]??"name":"name"),yc=J(t=>!!(ue&&t.directoryCache.has(ue))),Kn=a.useRef(null),Rt=a.useRef(0),[kc]=a.useState(()=>++Qx),$r=a.useRef(null),Wr=a.useRef(null),Ca=a.useRef(0),Xt=a.useRef(new Map),Jt=a.useRef(new Map),mr=a.useRef(new Set),mn=a.useRef(new Set),pn=a.useRef(0),Gr=a.useRef(null),qn=a.useRef(0),Vn=a.useRef(null),Yn=a.useRef(0),Kr=a.useRef(null),ii=a.useRef(new Set),li=a.useRef(null),ci=a.useRef(null),Ea=a.useRef(null),di=a.useRef(null),ui=a.useRef(null),Ns=a.useRef(new Set);a.useEffect(()=>{if(Bn===null)return;const t=Math.max(0,Date.now()-Bn),i=t<6e4?1e3:t<36e5?6e4:t<864e5?36e5:864e5,d=Math.max(50,i-t%i),y=window.setTimeout(()=>wh(Date.now()),d);return()=>window.clearTimeout(y)},[Yo,Bn]);const Ma=a.useRef(null),Pr=a.useRef(null),fi=a.useRef(null),Sc=a.useRef(null),Cs=a.useRef(null),Ne=a.useCallback(t=>J.getState().rootPath===t,[]);a.useEffect(()=>{if(!r||typeof window>"u")return;const t=i=>{const d=r0(i.target);d&&Ks("global_change_row_event",{...n0(i),selectionPath:d.dataset.diffSelectionPath,filePath:d.dataset.diffFilePath,absolutePath:d.dataset.diffAbsolutePath,repoRoot:d.dataset.diffRepoRoot,status:d.dataset.diffStatus,selectedFilePath:J.getState().selectedFilePath,rightTab:J.getState().rightTab,activeGitRepoRoot:fe,changedFiles:J.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})}},[fe,r]);const jc=a.useCallback(async(t=v??void 0)=>{if(!t)return null;if(mr.current.has(t)||mn.current.has(t))return dt("untracked_skip_cached",{cwd:t,rootPath:v,completed:mr.current.has(t),running:mn.current.has(t)}),null;const i=v,d=Ca.current+1;Ca.current=d,Xt.current.set(t,d);const y=`right-sidebar-git-untracked:${t}`,w=new AbortController;Jt.current.set(t,w),mn.current.add(t),dt("untracked_start",{requestId:d,cwd:t,rootPath:v});try{let k=await Dd(t,w.signal,y),j=0;for(;k.status==="running"&&j<120;){if(Xt.current.get(t)!==d||w.signal.aborted)return dt("untracked_stale_result",{requestId:d,activeRequestId:Xt.current.get(t),cwd:t,status:k.status}),null;if(!Ne(i))return dt("untracked_root_changed",{requestId:d,cwd:t,expectedRootPath:i,currentRootPath:J.getState().rootPath}),null;await new Promise(ae=>window.setTimeout(ae,j<10?1e3:3e3)),j+=1,k=await Dd(t,w.signal,y)}if(Xt.current.get(t)!==d||!Ne(i))return dt("untracked_stale_result",{requestId:d,activeRequestId:Xt.current.get(t),cwd:t,expectedRootPath:i,currentRootPath:J.getState().rootPath,files:k.files.length,status:k.status}),null;if(k.status==="done")return Sa(ih(J.getState().changedFiles,k.files)),k.files.length>0&&Re(ae=>{const Me=new Map(ae.map(pe=>[pe.root,pe])).get(t);if(!Me)return ae;const et=Ox(Me.files,k.files),Z=ae.map(pe=>pe.root===t?{...pe,files:et,context:pe.context?{...pe.context,changedFiles:et.map(Pe=>({path:Pe.path,absolutePath:Pe.absolutePath,status:Pe.status})),truncated:!1}:pe.context,untrackedDeferred:!1}:pe);Be(lh(Z,v));const X=Z.find(pe=>pe.root===v);return X?.context&&L(pe=>pe?.root===X.root?{...pe,...X.context}:pe),Z}),mr.current.add(t),dt("untracked_apply",{requestId:d,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 mr.current.add(t),dt("untracked_error",{requestId:d,cwd:t,message:ie,code:k.code,status:k.status}),null}catch(k){if(Xt.current.get(t)!==d||!Ne(i)||wr(k))return dt("untracked_aborted",{requestId:d,activeRequestId:Xt.current.get(t),cwd:t,expectedRootPath:i,currentRootPath:J.getState().rootPath,message:k instanceof Error?k.message:String(k)}),null;const j=k instanceof Error?k.message:"Failed to scan untracked files";return mr.current.add(t),dt("untracked_error",{requestId:d,cwd:t,message:j}),null}finally{Jt.current.get(t)===w&&Jt.current.delete(t),Xt.current.get(t)===d&&Xt.current.delete(t),mn.current.delete(t)}},[we,Ne,v,Sa]),ar=a.useMemo(()=>{const t=new Set(ve.map(d=>d.root)),i=jr.filter(d=>t.has(d));return i.length>0?i:fe?[fe]:[]},[fe,jr,ve]),Rc=ar.length===0,gn=a.useMemo(()=>ar.map(t=>ne.find(i=>i.root===t)).filter(t=>!!t),[ar,ne]),Eh=a.useMemo(()=>ve.map(t=>({root:t.root,label:t.label,branch:t.branch??null})),[ve]),pr=a.useCallback(async()=>{if(!v){Dr([]),ps([]);return}const t=v,i=qn.current+1;qn.current=i,Vn.current?.abort();const d=new AbortController;Vn.current=d,bs(ut.length===0),Jr(null);try{const y=ar.length>0?await Promise.all(ar.map(w=>Fd({workspaceRoot:v,repoRoot:w},d.signal))).then(w=>({records:w.flatMap(k=>k.records),walkthroughs:w.flatMap(k=>k.walkthroughs??[])})):await Fd({workspaceRoot:v},d.signal);if(qn.current!==i||!Ne(t))return;Dr(y.records),ps(y.walkthroughs??[])}catch(y){if(qn.current!==i||!Ne(t)||wr(y))return;Jr(y instanceof Error?y.message:"Failed to load change audit explanations")}finally{Vn.current===d&&(Vn.current=null),qn.current===i&&Ne(t)&&bs(!1)}},[ut.length,ar,Ne,v]),$a=a.useCallback(async(t,i,d)=>{if(!t&&!v){_r([]),Zr([]);return}const y=v,w=Yn.current+1;Yn.current=w,Kr.current?.abort();const k=new AbortController;Kr.current=k;try{const j=t?[t]:Array.from(new Set([v,...ne.map(ae=>ae.root)].filter(ae=>!!ae))),ie=await Promise.all(j.map(ae=>zm({repoRoot:ae,baseRef:i,branchName:d},k.signal))).then(ae=>{const ge=new Map,Me=new Map;for(const et of ae){for(const Z of et.records)ge.set(Z.id,Z);for(const Z of et.walkthroughs??[])Me.set(Z.id,Z)}return{records:Array.from(ge.values()),walkthroughs:Array.from(Me.values())}});if(Yn.current!==w||!Ne(y))return;_r(ie.records),Zr(ie.walkthroughs??[])}catch(j){if(Yn.current!==w||!Ne(y)||wr(j))return;console.warn("[RightSidebar] Failed to load branch explanations",j)}finally{Kr.current===k&&(Kr.current=null)}},[ne,Ne,v]),Xn=a.useCallback((t,i={})=>{if(!Ne(v)){dt("apply_skipped_root_changed",{expectedRootPath:v,currentRootPath:J.getState().rootPath,bundleRoot:t.context?.root,files:t.files.length});return}dt(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 d=Nf(t),y=t.repoFilters??[],w=t.files;const k=J.getState().changedFiles;if(!!(i.cacheOnly&&!t.cached&&t.files.length===0&&d.length===0)&&(k.size>0||ne.length>0||we)){dt("cache_only_apply_skipped_empty_backend_cache",{rootPath:v,currentFiles:k.size,currentRepositories:ne.length});return}const ie=d.some(X=>X.deferred);if(ie&&!i.replaceWorkspace){const X=new Set(d.filter(Pe=>!Pe.deferred||Pe.root===v).map(Pe=>Pe.root));w=[...Array.from(k.values()).filter(Pe=>!X.has(vt(Pe,v)??"")),...t.files]}const ae=Lu(k.values(),v),ge=Lu(t.files,v),Me=d.some(X=>X.root!==v);if(!!(i.background&&!ie&&!i.replaceWorkspace&&k.size>0&&(t.files.length===0&&!t.error||ae>0&&ge===0&&!Me))){dt("background_apply_skipped_degraded_bundle",{rootPath:v,currentFiles:k.size,nextFiles:t.files.length,currentNestedCount:ae,nextNestedCount:ge,nextRepositories:d.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=ch(k.values(),ne,t,i.replaceRepoRoot,v);w=X.files,d=X.repositories,y=X.repoFilters}if(Sa(oh(w)),Re(X=>{if(!ie||i.replaceWorkspace)return d;const pe=new Map(X.map(Pe=>[Pe.root,Pe]));return d.map(Pe=>{const Ge=pe.get(Pe.root);return!Pe.deferred||!Ge?Pe:{...Pe,available:Ge.available,files:Ge.files,context:Ge.context,deferred:Ge.deferred,untrackedDeferred:Ge.untrackedDeferred,error:Ge.error}})}),Be(y),ui.current=v,i.syncActiveRepo!==!1){const{contextKey:X,activeGitRepos:pe}=J.getState(),Pe=X?pe[X]??null:null,Ge=i.activeRepoRoot!==void 0?i.activeRepoRoot:Pe,_e=Qb({...t,repositories:d,repoFilters:y},Ge);Ye(_e)}typeof t.cacheUpdatedAt=="number"&&Ql(t.cacheUpdatedAt),L(X=>{if(i.replaceRepoRoot&&i.replaceRepoRoot!==v)return X;if(!t.context)return null;const pe=X?.root??v;return!X?.available||pe!==(t.context.root??v)?t.context:{...X,...t.context}}),i.reloadDiff&&ms(X=>X+1);const Z=J.getState().selectedFilePath;if(Z&&!Z.startsWith("/")&&!w.some(X=>X.path===Z||X.absolutePath===Z)&&ot(null),Ir(X=>{const pe=new Set(w.map(Ge=>vt(Ge,v)).filter(Boolean)),Pe=new Set;for(const Ge of X)pe.has(Ge)&&Pe.add(Ge);return Qi(Vi,Pe),Pe}),i.loadDeferred!==!1){const X=d.filter(pe=>pe.untrackedDeferred&&pe.root).map(pe=>pe.root);for(const pe of X)jc(pe)}i.loadAudit!==!1&&pr()},[Ne,pr,jc,v,ot,Ye,Sa]);a.useEffect(()=>{ja(),li.current=null,ci.current=v;const t=[],i=[];Rt.current+=1,pn.current+=1,Ca.current+=1,$r.current?.abort(),Nt(Ws(Wr.current?.cwd??v??void 0)),Wr.current=null,$r.current=null,Gr.current?.abort(),Nt("right-sidebar-git-details"),Gr.current=null;for(const j of Jt.current.values())j.abort();for(const j of Jt.current.keys())Nt(`right-sidebar-git-untracked:${j}`);Jt.current.clear(),Xt.current.clear(),qn.current+=1,Vn.current?.abort(),Vn.current=null,Yn.current+=1,Kr.current?.abort(),Kr.current=null,Hr.current+=1,ur.current?.abort(),Nt("right-sidebar-recent-commits"),ur.current=null,Dr([]),ps([]),bs(!1),Jr(null),Fr([]),rr(!1),_r([]),Zr([]),Bt(!1),Yt(null),M(!1),de(null),Je(null),qe(null),st(null),Br(!1),Or(""),Ur([]),se(!1),Ut(!1),Dn(null),Fn(!1),ca(null),an(null),on(null),Gl(!1),Dt(Yi,!1),Oo(!1);const d=v?ku()[v]:null,y=d?.previewEntries??[],w=d?.selectedPreviewKey??null,k=w?y.find(j=>j.key===w)??null:null;++Ot.current,M(!1),Uo(d?.selectedRepoRoots??[]),ua(d?.repoTargetBranches??{}),fa(d?.repoBaseBranches??{}),Ln(y),An(d?.previewScrollTops??{}),k&&d?.previewDetailOpen&&(k.diff.hunks?.length??0)>0&&(Yt(k.diff),an(k.key),on(d.selectedPreviewFileKey??(k.diff.hunks?.[0]?`${k.diff.hunks[0].filePath}\0${k.diff.hunks[0].hunkHeader}\0${k.diff.hunks[0].hunkIndex}`:null)),Bt(!0)),Ho(d?.repoIncludeUncommitted??Object.fromEntries(Object.keys(d?.repoTargetBranches??{}).map(j=>[j,d?.includeUncommitted??!0]))),li.current=v,pa(!1),mr.current.clear(),mn.current.clear(),Ss(null),js(null),ln(null),yt(null),Ql(null),Re(t),Be(i),L(null),di.current=null,ui.current=null,Ns.current.clear()},[ja,v]);const zt=a.useCallback(async(t=v??void 0,i={})=>{if(!t)return null;const d=v,y=Rt.current;if(await og(()=>Promise.all([J.getState().hydrateNestedGitScanRoots(),J.getState().hydrateActiveGitRepos()]).then(()=>{})),Rt.current!==y||!Ne(d))return null;const w=t===v&&Hs(v),k=i.includeNested??w,j=i.refresh??i.reloadDiff??!1,ie=i.cacheOnly??!1,ae=i.background??!1,ge=k&&(i.discoverOnly??!1);j&&mr.current.clear();const Me=Wr.current;if(Me&&Me.cwd===t&&Me.includeNested===k&&Me.refresh===j&&Me.cacheOnly===ie&&Me.discoverOnly===ge)return dt("reuse_pending",{cwd:t,includeNested:k,refresh:j,cacheOnly:ie,discoverOnly:ge}),Me.promise;const et=Rt.current+1;Rt.current=et;const Z=`right-sidebar:${kc}:${et}`;$r.current?.abort();const X=Ws(t);Nt(X);const pe=new AbortController;$r.current=pe;let Pe=null;ae||mc(Z),si(null),dt("start",{requestId:et,cwd:t,rootPath:v,requestSlotId:X,includeNested:k,refresh:j,cacheOnly:ie,background:ae,existingChanges:Ae.size,lastLoadedAt:Gn}),!ae&&typeof window<"u"&&(Pe=window.setTimeout(()=>{Rt.current===et&&pc(Z,!0)},Ab));const Ge=(async()=>{const _e=await Ui(t,pe.signal,{includeNested:k,refresh:j,cacheOnly:ie,discoverOnly:ge,action:j?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:X,requestTimeoutMs:j?null:void 0});if(zx(_e)){if(dt("cancelled_result_ignored",{requestId:et,activeRequestId:Rt.current,cwd:t,error:_e.error??_e.context?.error}),pe.signal.aborted)return null;throw new Error(_e.error??_e.context?.error??"Failed to load Git changes")}return Rt.current!==et||!Ne(d)?(dt("stale_result",{requestId:et,activeRequestId:Rt.current,cwd:t,expectedRootPath:d,currentRootPath:J.getState().rootPath,files:_e.files.length,repositories:_e.repositories?.length??0}),null):(Xn(_e,{reloadDiff:i.reloadDiff,syncActiveRepo:i.replaceWorkspace?!0:k,background:ae,cacheOnly:ie,replaceRepoRoot:i.replaceRepoRoot,replaceWorkspace:i.replaceWorkspace}),_e)})();Wr.current={cwd:t,includeNested:k,refresh:j,cacheOnly:ie,discoverOnly:ge,promise:Ge};try{const _e=await Ge;return Rt.current===et&&_e&&Ne(d)?gc({cached:_e.cached,stale:_e.stale,cacheAgeMs:_e.cacheAgeMs,nestedDeferred:!k||_e.nestedDeferred,untrackedDeferred:_e.untrackedDeferred}):Rt.current===et&&Ne(d)&&ni(Z),_e}catch(_e){return Rt.current!==et||!Ne(d)||pe.signal.aborted?(dt("aborted",{requestId:et,activeRequestId:Rt.current,cwd:t,expectedRootPath:d,currentRootPath:J.getState().rootPath,message:_e instanceof Error?_e.message:String(_e)}),null):(dt("error",{requestId:et,cwd:t,includeNested:k,refresh:j,background:ae,message:_e instanceof Error?_e.message:String(_e)}),ae||(L(null),si(_e instanceof Error?_e.message:"Failed to load Git changes")),null)}finally{Pe!==null&&window.clearTimeout(Pe),$r.current===pe&&($r.current=null),Wr.current?.promise===Ge&&(Wr.current=null),!ae&&Rt.current===et&&Ne(d)&&ni(Z)}},[Xn,mc,Ae.size,ni,kc,Gn,Ne,gc,v,si,pc]),Jn=a.useCallback(async()=>{v&&await zt(v,{reloadDiff:!0,refresh:!0})},[zt,v]),hi=a.useCallback(async(t=v??void 0)=>{if(!t)return null;const i=v,d=pn.current+1;pn.current=d,Gr.current?.abort(),Nt("right-sidebar-git-details");const y=new AbortController;Gr.current=y,pa(!0);try{const w=await _d(t,y.signal,"load_git_details","right-sidebar-git-details");return pn.current!==d||!Ne(i)?null:(Re(k=>k.map(j=>j.root===w.root?{...j,available:w.available,context:w,error:w.error}:j)),L(k=>k?.root&&w.root&&k.root!==w.root?k:!k?.available||!w.available?w:{...k,...w}),w)}catch(w){return wr(w)||!Ne(i)||pn.current===d&&yt(w instanceof Error?w.message:"Failed to load Git details"),null}finally{Gr.current===y&&(Gr.current=null),pn.current===d&&Ne(i)&&pa(!1)}},[Ne,v]);a.useEffect(()=>{if(!r){Rt.current+=1,ja(),di.current=null,pn.current+=1,Ca.current+=1,$r.current?.abort(),Nt(Ws(Wr.current?.cwd??v??void 0)),Wr.current=null,$r.current=null,Gr.current?.abort(),Nt("right-sidebar-git-details"),Gr.current=null;for(const t of Jt.current.values())t.abort();for(const t of Jt.current.keys())Nt(`right-sidebar-git-untracked:${t}`);Jt.current.clear(),Xt.current.clear(),Yn.current+=1,Kr.current?.abort(),Kr.current=null,Hr.current+=1,ur.current?.abort(),Nt("right-sidebar-recent-commits"),ur.current=null,pa(!1),M(!1),de(null),Je(null),qe(null),st(null),Br(!1),Or(""),Ur([]),se(!1),Ut(!1),Dn(null),Fn(!1),V(""),z(!1),Mt(null),qo(!1),oe&&Vl(!1)}},[oe,r,ja,z]),a.useEffect(()=>{if(!R)return;const t=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(t)},[R]),a.useEffect(()=>{oe||Er(!1)},[oe]);const Nc=a.useCallback(t=>{Go(t);const i=fi.current;i&&(i.update(),i.slideTo(t,0),window.requestAnimationFrame(()=>{i.update(),i.slideTo(t,0)}))},[]);a.useEffect(()=>{if(oe)if(Er(h),h&&at){Mr(1);const t=Pr.current;t&&(t.update(),t.activeIndex!==1&&(Cs.current=1,t.slideTo(1,0)))}else{Mr(0);const t=Pr.current;t&&t.activeIndex!==0&&(Cs.current=0,t.slideTo(0,0)),Mt(null)}},[oe,h,v,at]),a.useEffect(()=>{if(p!==void 0&&!h){Mr(0);const t=Pr.current;t&&t.activeIndex!==0&&(Cs.current=0,t.slideTo(0,0)),Er(!1),Mt(null)}},[p,h]),a.useEffect(()=>{$!==void 0&&rt(null)},[$]),a.useEffect(()=>{!oe&&h&&f?.()},[oe,f,h]),a.useEffect(()=>{Zo(t=>kl(t,s))},[s]);const Mh=a.useCallback(t=>{oe||(t.preventDefault(),Ma.current={startX:t.clientX,startWidth:Qo,pointerId:t.pointerId},t.currentTarget.setPointerCapture(t.pointerId))},[Qo,oe]),$h=a.useCallback(t=>{const i=Ma.current;if(!i||i.pointerId!==t.pointerId)return;const d=kl(i.startWidth+t.clientX-i.startX,s);Zo(d),Ys(qs,d,Lb)},[s]),Cc=a.useCallback(t=>{const i=Ma.current;if(!(!i||i.pointerId!==t.pointerId)){Ma.current=null,Us(qs);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}},[]),Qn=!!(v&&Gn!==null&&Iu(we)),mi=!!(v&&!hn&&Ae.size===0&&Gn===null),At=(()=>{let t=ei;return t==="android"&&!zr&&(t="files"),Qn&&(t==="git"||t==="diff")&&(t="files"),t})(),ct=At==="git",Lr=At==="files",Tt=At==="diff",Zn=At==="android",pi=At==="computer",bn=At==="architecture",[Ph,Lh]=a.useState(!1);a.useEffect(()=>{r&&bn&&Lh(!0)},[r,bn]);const gi=a.useRef(null),es=a.useCallback((t,i)=>{const d=J.getState().rightTab;if(d===t)return;const y=performance.now(),w=y-i.timeStamp;gi.current={from:d,to:t,startedAt:y,inputDelayMs:w>=0&&w<6e4?Math.round(w):null},fr(t)},[fr]);a.useEffect(()=>{const t=gi.current;if(!t||t.to!==At)return;gi.current=null;const i=Math.round(performance.now()-t.startedAt);let d=window.requestAnimationFrame(()=>{d=window.requestAnimationFrame(()=>{Ks("tab_switch_presented",{from:t.from,to:t.to,inputDelayMs:t.inputDelayMs,commitMs:i,frameMs:Math.round(performance.now()-t.startedAt)})})});return()=>window.cancelAnimationFrame(d)},[At]);const Ah=pp(t=>t.overlay==="sidebar")&&Zn;a.useEffect(()=>{if(!oe){ha(!0);return}if(!r){const i=window.setTimeout(()=>{ha(!1)},Db);return()=>window.clearTimeout(i)}ha(!1);const t=window.setTimeout(()=>{ha(!0)},Ib);return()=>window.clearTimeout(t)},[oe,r]),a.useEffect(()=>{if(!oe||!Tt)return;const t=fi.current;if(!t)return;const i=window.requestAnimationFrame(()=>{t.update()});return()=>window.cancelAnimationFrame(i)},[Tt,oe]),a.useEffect(()=>{if(!Qn||!v||hr)return;const t=window.setTimeout(()=>{zt(v,{background:!0})},3e3);return()=>window.clearTimeout(t)},[Qn,v,hr,zt]);const Th=a.useCallback(t=>{zt(t,{discoverOnly:!0})},[zt]);ig({active:r&&(ct||Tt),rootPath:v,loading:hr,delay:ct&&!oe?0:Ji,lastStartedRoot:di,load:Th}),a.useEffect(()=>{!r||!ct||(!oe||Ko)&&qo(!0)},[ct,oe,r,Ko]),a.useEffect(()=>{if(!r||ct)return;const t=window.setTimeout(()=>{qo(!0)},Ji);return()=>window.clearTimeout(t)},[ct,r]),a.useEffect(()=>{Lr&&bh(!0)},[Lr]),a.useEffect(()=>{Tt&&Vl(!0)},[Tt]),a.useEffect(()=>{!r||!Zn||(n&&ma&&ma.sessionId!==n&&(Oi.getState().setDock(Hi,null),mo({androidPanel:{docked:null}}).catch(()=>{})),Yl(!0))},[Zn,r,n,ma]),a.useEffect(()=>{if(r&&Zn||!Vo)return;const t=window.setTimeout(()=>Yl(!1),Tb);return()=>window.clearTimeout(t)},[r,Zn,Vo]),a.useEffect(()=>{let t=!1;return Bu().then(i=>{!t&&i.androidPanel&&Xl(i.androidPanel.enabled===!0)}).catch(()=>{}),()=>{t=!0}},[]);const Ec=a.useCallback(t=>{Xl(t),t?fr("android"):J.getState().rightTab==="android"&&fr("files"),mo({androidPanel:{enabled:t}}).catch(()=>{})},[fr]),Mc=a.useCallback(t=>{ue&&Ix(ue,t.currentTarget.scrollTop)},[ue]);a.useEffect(()=>()=>{$r.current?.abort(),Us(Pl),Us(Ll),Us(qs),Us(Xi)},[]),a.useEffect(()=>{if(!ue||!yc)return;const t=sh()[ue]?.top;if(typeof t!="number")return;let i=window.requestAnimationFrame(()=>{Kn.current&&(Kn.current.scrollTop=t),i=window.requestAnimationFrame(()=>{Kn.current&&(Kn.current.scrollTop=t)})});return()=>window.cancelAnimationFrame(i)},[ue,yc]),a.useEffect(()=>{if(!r)return;const t=new AbortController;return Wm(t.signal).then(i=>nc(!!i.available)).catch(()=>nc(!1)),()=>t.abort()},[r]);const Es=a.useCallback(t=>{if(H(null),ot(t),Mt(null),oe){Er(!0),Mr(1),Pr.current?.slideTo(1),b?.();return}},[oe,b,ot]),bi=a.useCallback((t,i)=>{if(H(null),ot(t),cr(i),oe){Er(!0),Mr(1),Pr.current?.slideTo(1),b?.();return}},[oe,b,ot]),Ms=a.useCallback(async(t,i)=>{const d=i||Hn||v;if(!(!d||t.length===0)){ya(!0);try{await eo(d,t),Wn(d,!1)}catch(y){yt(y instanceof Error?y.message:o("rightSidebar.uploadFailed")),window.setTimeout(()=>yt(null),4e3)}finally{ya(!1)}}},[Hn,v,Wn,o]),$c=a.useCallback(async t=>{try{await Gm(t)}catch(i){yt(i instanceof Error?i.message:o("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>yt(null),4e3)}},[o]),Pa=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes("Files")&&Xo(!0)},[]),Pc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),Xo(!1)},[]),Lc=a.useCallback(t=>{t.preventDefault(),t.stopPropagation(),Xo(!1);const i=t.dataTransfer.files;i.length>0&&Ms(Array.from(i))},[Ms]),xi=a.useCallback(t=>{Qe(t),window.setTimeout(()=>Qe(i=>i===t?null:i),1400)},[]),gr=a.useCallback(t=>{le(t),window.setTimeout(()=>le(i=>i===t?null:i),1400)},[]);a.useEffect(()=>{Dt(mu,Ee)},[Ee]),a.useEffect(()=>{Dt(pu,qt)},[qt]),a.useEffect(()=>{Dt(gu,W)},[W]),a.useEffect(()=>{Ys(Xi,ye,Cb)},[ye]),a.useEffect(()=>(ic().catch(()=>{}),Bd(t=>{t.type==="pinned-explorer-roots"&&lc(t.pinnedExplorerRoots)})),[ic,lc]);const Ac=a.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),La=a.useRef(null),xn=a.useRef(null),[Tc,vi]=a.useState(!1);a.useEffect(()=>{if(!r)return;vi(!1);let t=!1;Km().then(d=>{t||(La.current=d.text,Xe(y=>d.text&&d.text!==y?d.text:y),vi(!0))}).catch(()=>{t||vi(!0)});const i=Bd(d=>{d.type==="context-draft"&&d.origin!==Ac.current&&(La.current=d.text,Xe(d.text))});return()=>{t=!0,i(),xn.current!==null&&(window.clearTimeout(xn.current),xn.current=null)}},[r]),a.useEffect(()=>{if(!Tc||La.current===ye)return;xn.current!==null&&window.clearTimeout(xn.current);const t=ye;xn.current=window.setTimeout(()=>{xn.current=null,qm(t,Ac.current).then(()=>{La.current=t}).catch(()=>{})},500)},[ye,Tc]);const ts=a.useCallback(async(t,i,d,y)=>{if(!t)return!1;if(Vm(d?t+d:t))return xi(i),!0;if(Ee)Xe(w=>Fg(w,t)+(d??"")),window.matchMedia("(pointer: coarse)").matches||(jt(!1),Tr(w=>w+1));else{const w=n??to.getState().activeSessionId;if(!await gg(d?t+d:t,w,()=>Ia.current&&w===to.getState().activeSessionId,y))return!1}return xi(i),!0},[Ee,xi,n]),Aa=a.useCallback(t=>{const i=Rn(t,v);return gp(i,v)},[v]),wi=rf(gr),Wt=a.useCallback((t,i,d)=>{const y=Rn(t,v);return ts(bp(y,v),i??`path:${y}`,void 0,d)},[v,ts]),Ih=a.useCallback(async t=>{ya(!0);try{await xp(t,eo,i=>{Wt(i,`path:${i}`)}),oe&&!Ee&&l()}catch(i){yt(i instanceof Error?i.message:o("rightSidebar.uploadFailed")),window.setTimeout(()=>yt(null),4e3)}finally{ya(!1)}},[Ee,Wt,oe,l,o]),Ta=a.useRef(!0),yi=a.useRef(n);yi.current=n,a.useEffect(()=>(Ta.current=!0,()=>{Ta.current=!1}),[]);const Dh=a.useCallback(t=>{vp.getState().enqueue(t,n??null,v||"/",i=>{if(Ee&&Ta.current&&yi.current===n)Wt(i);else return Kd(i,n)})},[n,v,Ee,Wt]),Fh=a.useCallback(async t=>{const d=(await eo("/tmp",[t])).files[0]?.path;if(!d)throw new Error("截图上传未返回文件路径");Ee&&Ta.current&&yi.current===n?Wt(d):await Kd(d,n)},[Ee,Wt,n]),or=a.useCallback((t,i,d)=>{if(!t)return Promise.resolve(!1);const y=t.includes(`
1660
- `)?`
1661
- `:void 0;return ts(t.endsWith(`
1662
- `)||t.endsWith(" ")?t:`${t} `,i,y,d)},[ts]),Ic=a.useRef(or);Ic.current=or;const Ia=a.useRef(!0);a.useEffect(()=>(Ia.current=!0,()=>{Ia.current=!1}),[]);const ki=a.useRef(new Set),Dc=a.useCallback((t,i,d)=>{if(ki.current.has(i))return;const y=n??to.getState().activeSessionId;ki.current.add(i),pg(t,i,d,{insert:or,upload:async(w,k)=>(await eo("/tmp",[w],k)).files[0]?.path,isCurrent:()=>Ia.current&&Ic.current===or&&y===to.getState().activeSessionId}).catch(()=>{}).finally(()=>ki.current.delete(i))},[or,n]),Ar=a.useCallback((t,i,d)=>{i&&ts(i.endsWith(" ")?i:`${i} `,d??`context:${t}`,`
1663
- `)},[ts]),Fc=a.useCallback(t=>{const i=_g(ye,t);if(!i)return;const d=t&&ye.trim().includes(`
1664
- `),y=`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`;let w=!1;const k=ae=>{w||(w=!0,window.removeEventListener("termdock-insert-reference-ack",j),window.clearTimeout(ie),ae?($n(!1),Xe(""),W&&jt(!0)):($n(!0),jt(!1)))},j=ae=>{const ge=ae.detail;ge?.nonce===y&&k(ge.ok===!0)},ie=window.setTimeout(()=>k(!1),1500);window.addEventListener("termdock-insert-reference-ack",j),$n(!1),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:i,focus:!0,paste:d,nonce:y}}))},[W,ye]),nt=a.useMemo(()=>v?St(v):o("rightSidebar.workspace"),[v,o]),_h=a.useMemo(()=>St(ue)||nt,[ue,nt]),Da=a.useMemo(()=>ho(ue),[ue]),Fa=a.useMemo(()=>v?oc[v]??[]:[],[oc,v]),vn=a.useMemo(()=>new Set(Fa.map(t=>t.path)),[Fa]),$s=!!(ue&&vn.has(ue)),Si=!!(v&&ue&&ue!==v),Bh=!!(v&&Hn&&Hn!==v),Gt=ue?`path:${ue}`:null,_c="context:change-audit",Oh=a.useCallback(()=>{Da&&Ht(Da)},[Da,Ht]),Bc=a.useCallback(()=>{cc()},[cc]),Uh=a.useCallback(()=>{ue&&(Wn(ue,!0),fc())},[fc,ue,Wn]),Hh=a.useCallback(()=>{!ue||!Si||($s?fn(ue):zn(ue,"directory"))},[Si,ue,$s,zn,fn]),Oc=a.useCallback(t=>{Ht(t),V("")},[Ht]),Uc=a.useCallback(t=>{ue&&(me(Rb(ue,t)),z(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[ue,z]),Hc=a.useCallback(t=>{!v||t===v||(vn.has(t)?fn(t):zn(t,"directory"))},[zn,vn,v,fn]),zc=a.useCallback(t=>{!v||!t||(vn.has(t)?fn(t):zn(t,"file"))},[zn,vn,v,fn]),Wc=J(t=>t.expandedPaths),ji=a.useMemo(()=>{const t=new Set;if(Lr&&ue){t.add(ue);const i=`${ue.replace(/\/+$/,"")}/`;for(const d of Wc)d.startsWith(i)&&t.add(d)}if(Lr&&v&&at){const i=at.startsWith("/")?at:`${v}/${at}`,d=ho(i);d&&t.add(d)}return Mg(t).join(`
1665
- `)},[Wc,Lr,ue,v,at]),wn=a.useRef(new Map);a.useEffect(()=>{const t=ji?ji.split(`
1666
- `):[];if(!r||t.length===0){Un(null);return}const i=new AbortController;let d=!1,y=0,w=0;Un(null);const k=async()=>{let j=0;for(;!d&&!i.signal.aborted;){let ie=null;try{Un(null),await tp(t,ge=>{const{applicableEvents:Me,unavailableReason:et}=Pg(ge);Me.length>0&&dc(Me);const Z=new Set(Me.filter(X=>X.type==="rescan-required").map(X=>X.path));if(Ra)for(const X of Me){if(X.type==="created"||X.type==="updated"){const pe=ho(X.path);pe&&Z.add(pe)}X.path.endsWith("/.gitignore")&&ue&&Wn(ue,!0)}for(const X of Z){const pe={path:X},Pe=J.getState();if(!Pe.directoryCache.has(pe.path))continue;wn.current.get(pe.path)?.abort();const _e=new AbortController;wn.current.set(pe.path,_e);const Ad=`file-watch-rescan:${pe.path}`;Nt(Ad),_u(pe.path,_e.signal,Pe.showHiddenFiles,"watch_rescan",Ad,Pe.fileSortModes[pe.path]??"name",ue??void 0).then(_s=>{wn.current.get(pe.path)===_e&&uc(pe.path,_s.entries)}).catch(_s=>{wr(_s)||Un(_s instanceof Error?_s.message:"File refresh unavailable")}).finally(()=>{wn.current.get(pe.path)===_e&&wn.current.delete(pe.path)})}et&&Un(et)},i.signal),ie=new Error("File watch stream ended")}catch(ge){ie=ge}if(d||i.signal.aborted||wr(ie))return;Un(ie instanceof Error?ie.message:"File watching unavailable");const ae=bu[Math.min(j,bu.length-1)];j+=1,await new Promise(ge=>{w=window.setTimeout(ge,ae)})}};return y=window.setTimeout(()=>{d||k()},Ji),()=>{d=!0,window.clearTimeout(y),window.clearTimeout(w),i.abort();for(const j of wn.current.values())j.abort();wn.current.clear()}},[dc,r,uc,ji,ue,Ra,Wn]),a.useEffect(()=>{if(!v||li.current!==v)return;if(ci.current===v){ci.current=null;return}const t=ku();Ys(wf,{...t,[v]:{selectedRepoRoots:da,repoTargetBranches:nr,repoBaseBranches:Lt,previewEntries:en,selectedPreviewKey:xe&&dr?Ze:null,selectedPreviewFileKey:xe&&dr?zo:null,previewDetailOpen:!!(xe&&dr),previewScrollTops:vs,previewMobileSlideIndex:1,repoIncludeUncommitted:sn,updatedAt:Date.now()}},Nb)},[dr,sn,xe,en,vs,Lt,nr,da,v,zo,Ze]);const pt=a.useMemo(()=>Tu(Ae.values()),[Ae]),it=a.useMemo(()=>{const t=new Map;for(const i of ne)t.set(i.root,i);return t},[ne]),Ps=a.useMemo(()=>{const t=new Map;for(const i of ne)i.deferred||t.set(i.root,i.files.length);return t},[ne]),_a=a.useCallback(t=>{if(t){if(!t.deferred){Ns.current.delete(t.root);return}Ps.has(t.root)||Ns.current.has(t.root)||(Ns.current.add(t.root),zt(t.root,{includeNested:!1,background:!0,replaceRepoRoot:t.root}).then(i=>{i||Ns.current.delete(t.root)}))}},[zt,Ps]),ir=a.useMemo(()=>fe?ve.find(t=>t.root===fe)??null:null,[fe,ve]),Qt=a.useMemo(()=>at?Array.from(Ae.values()).find(t=>t.path===at||t.absolutePath===at)??null:null,[Ae,at]),Kt=a.useMemo(()=>{const t=new Map;for(const i of ne)i.available&&i.context?.available&&t.set(i.root,i);return t.size===0&&we?.available&&we.root&&t.set(we.root,{id:we.root,root:we.root,relativeRoot:".",name:nt,depth:0,nested:!1,available:!0,files:Array.from(Ae.values()).filter(i=>vt(i,v)===we.root),context:we}),Array.from(t.values()).sort((i,d)=>i.root===v?-1:d.root===v?1:(i.relativeRoot||i.name).localeCompare(d.relativeRoot||d.name)).map(i=>{const d=i.relativeRoot==="."?nt:i.relativeRoot||i.name||St(i.root),y=Au(i.files),w=i.files.length;return{value:i.root,label:d,meta:[i.context?.branch,w>0?o("rightSidebar.repoChangedCount",{count:w}):null,y>0?o("rightSidebar.repoStagedCount",{count:y}):null].filter(Boolean).join(" · ")}})},[Ae,we,ne,nt,v,o]),Se=a.useMemo(()=>fe&&Kt.some(t=>t.value===fe)?fe:Qt?.repoRoot&&Kt.some(t=>t.value===Qt.repoRoot)?Qt.repoRoot:Kt.length===1||Kt.length>1?Kt[0].value:null,[fe,Kt,Qt?.repoRoot]),Gc=Se?it.get(Se)??null:null,he=Gc?.context?.available?Gc.context:Se===we?.root?we:null,tt=Kt.length>0&&!Se,Kc=a.useMemo(()=>tt?[]:Se?Array.from(Ae.values()).filter(t=>vt(t,v)===Se):Array.from(Ae.values()),[Se,Ae,tt,v]),yn=a.useMemo(()=>Tu(Kc),[Kc]),Ri=!!(he?.available&&he.root&&Se&&he.root===Se),zh=Se?Kt.find(t=>t.value===Se)?.label??St(Se):o("rightSidebar.gitRepositoryPlaceholder"),qc=Ri?he?.branch??"HEAD":tt?o("rightSidebar.selectRepositoryForGitActions"):cn?o("rightSidebar.gitActionRunning"):"HEAD",kn=!!(he?.available&&he.root===Se&&he.status);a.useEffect(()=>{Wl.current={count:Cr.length,loading:In,loadingMore:We,hasMore:_o}},[Cr.length,_o,In,We]),a.useEffect(()=>{Hr.current+=1,ur.current?.abort(),Nt("right-sidebar-recent-commits"),ur.current=null,Or(""),Ur([]),se(!1),Ut(!1),Dn(null),Fn(!1)},[Se]);const Ls=a.useCallback(async(t={})=>{if(!v||!Se||tt)return;const i=t.reset??!1,d=Wl.current,y=i?0:d.count;if(!i&&(d.loading||d.loadingMore||!d.hasMore))return;const w=Hr.current+1;Hr.current=w,ur.current?.abort(),Nt("right-sidebar-recent-commits");const k=new AbortController;ur.current=k,i?se(!0):Ut(!0),Dn(null);try{const j=await Ym({cwd:v,repoRoot:Se,limit:Fb,skip:y,query:ys.trim(),requestSlotId:"right-sidebar-recent-commits"},k.signal);if(Hr.current!==w)return;if(!j.available){Dn(j.error??"Recent commits are unavailable"),i&&Ur([]),Fn(!1);return}Tn(ie=>i?j.commitSyncStatus??{}:{...ie,...j.commitSyncStatus}),Ur(ie=>i?j.commits:[...ie,...j.commits]),Fn(j.hasMore)}catch(j){if(Hr.current!==w||wr(j))return;Dn(j instanceof Error?j.message:"Failed to load recent commits"),i&&Ur([]),Fn(!1)}finally{ur.current===k&&(ur.current=null),Hr.current===w&&(se(!1),Ut(!1))}},[Se,ys,tt,v]);a.useEffect(()=>{xt&&Ls({reset:!0})},[ys,Ls,xt,he?.ahead,he?.behind,he?.upstream]);const Wh=a.useCallback(t=>{const i=t.currentTarget;i.scrollTop+i.clientHeight<i.scrollHeight-48||Ls({reset:!1})},[Ls]);a.useEffect(()=>{!Se||!we?.available||!ct||!sr||kn||cn||tt||hi(Se)},[Se,we?.available,kn,cn,ct,sr,hi,tt]);const Vc=r&&(Tt||ct);a.useEffect(()=>{!Vc||!v||pr()},[Vc,pr,v]),a.useEffect(()=>{!r||!ct||!sr||!ks||!v||$a(null)},[ks,ct,sr,r,$a,v]);const Gh=a.useMemo(()=>{if(!fe)return 0;const t=ve.findIndex(i=>i.root===fe);return t>=0?t+1:0},[fe,ve]),Yc=a.useCallback(t=>{if(!t)return null;const i=Array.from(Ae.values()).filter(d=>vt(d,v)===t).sort((d,y)=>d.path.localeCompare(y.path))[0];return i?vr(i):null},[Ae,v]),Sn=ve.length>1,Ba=a.useMemo(()=>[{root:null,label:o("rightSidebar.allRepositories"),count:Ae.size,branch:null,deferred:!1},...ve.map(t=>({root:t.root,label:t.label,count:t.deferred?Ps.get(t.root)??0:t.count,branch:t.branch??null,deferred:!!t.deferred&&!Ps.has(t.root)}))],[Ae.size,ve,Ps,o]),Xc=Ba[Gh]??Ba[0],Oa=!!fe,Jc=a.useMemo(()=>Cf(ve,ne),[ve,ne]);a.useEffect(()=>{ui.current===v&&fe&&!Jc.has(fe)&&Ye(null),Fr(t=>t.filter(i=>ve.some(d=>d.root===i)))},[fe,ve,Jc,v,Ye]),a.useEffect(()=>{fe&&_a(it.get(fe))},[fe,_a,it]);const Kh=a.useMemo(()=>{const t=new Set;he?.branch&&t.add(he.branch);for(const i of he?.branches??[])t.add(i);return Array.from(t).map(i=>({value:i,label:i,meta:i===he?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0}))},[he?.branch,he?.branches,o]),Qc=a.useMemo(()=>{const t=new Set;he?.upstreamRemote&&t.add(he.upstreamRemote);for(const i of he?.remotes??[])t.add(i);return Array.from(t).map(i=>({value:i,label:i,meta:i===he?.upstreamRemote?o("rightSidebar.pushUpstreamBadge"):void 0}))},[he?.remotes,he?.upstreamRemote,o]),Zc=Qc.length>1,qh=a.useMemo(()=>{const t=[],i=new Set,d=(w,k)=>{!w||i.has(w)||(i.add(w),t.push({value:w,label:w,meta:k}))};d(he?.upstreamBranch,he?.upstreamBranch?o("rightSidebar.pushUpstreamBadge"):void 0),d(he?.branch,he?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0);for(const w of he?.branches??[])d(w,w===he?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");const y=he?.upstreamRemote;for(const w of he?.remoteBranches??[]){const k=w.indexOf("/"),j=k>=0?w.slice(0,k):null,ie=k>=0?w.slice(k+1):w;(!y||j===y)&&d(ie,"remote")}return t},[he?.branch,he?.branches,he?.remoteBranches,he?.upstreamBranch,he?.upstreamRemote,o]),Zt=a.useMemo(()=>Kt.map(t=>{const i=it.get(t.value);return{root:t.value,label:t.label,branch:i?.context?.branch??null}}),[Kt,it]);a.useEffect(()=>{Zt.length!==0&&(ua(t=>{let i=!1;const d={...t},y=new Set(Zt.map(w=>w.root));for(const w of Object.keys(d))y.has(w)||(delete d[w],i=!0);for(const w of Zt)!d[w.root]&&w.branch&&(d[w.root]=w.branch,i=!0);return i?d:t}),fa(t=>{let i=!1;const d={...t},y=new Set(Zt.map(w=>w.root));for(const w of Object.keys(d))y.has(w)||(delete d[w],i=!0);for(const w of Zt){const k=it.get(w.root)?.context;if(d[w.root]&&Ef(d[w.root],k?.branch)&&(delete d[w.root],i=!0),d[w.root])continue;const j=Ru(k);j&&(d[w.root]=j,i=!0)}return i?d:t}))},[Zt,it]);const Ua=a.useMemo(()=>{const t=new Set(Zt.map(i=>i.root));return da.filter(i=>t.has(i))},[da,Zt]),Ha=Ua.length===0,br=a.useMemo(()=>Ha?Zt:Zt.filter(t=>Ua.includes(t.root)),[Zt,Ua,Ha]),As=a.useMemo(()=>br.filter(t=>!!Lt[t.root]?.trim()),[Lt,br]),rs=a.useCallback((t,i)=>{const d=it.get(t)?.context?.branch;return!!(d&&i&&i.replace(/^refs\/heads\//,"")===d)},[it]),ed=a.useMemo(()=>br.filter(t=>!Lt[t.root]?.trim()),[Lt,br]),td=a.useCallback(async t=>{if(!t||ii.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 d=v;ii.current.add(t),ql(y=>new Set(y).add(t));try{const y=await _d(t,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${t}`);if(!y.available||!Ne(d))return;Re(w=>w.map(k=>k.root===t?{...k,available:!0,context:{...k.context,...y},error:void 0}:k)),ua(w=>w[t]||!y.branch?w:{...w,[t]:y.branch}),fa(w=>{if(w[t])return w;const k=Ru(y);return k?{...w,[t]:k}:w})}catch(y){wr(y)||console.warn("[RightSidebar] Failed to load branch audit repo details",t,y)}finally{ii.current.delete(t),ql(y=>{const w=new Set(y);return w.delete(t),w})}},[it,Ne,v]);a.useEffect(()=>{if(Bo)for(const t of br)td(t.root)},[Bo,br,td]),a.useEffect(()=>{!Ri||!he||(ba(he.branch||(he.branches?.[0]??"")),xa(he.upstreamRemote||(he.remotes?.includes("origin")?"origin":he.remotes?.[0]??"")),va(he.upstreamBranch||he.branch||(he.branches?.[0]??"")))},[he,Ri]);const rd=a.useMemo(()=>{if(tt)return{text:o("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!kn||cn)return{text:o("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!he?.upstream)return{text:o("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const t=he.ahead??0,i=he.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"}},[he?.ahead,he?.behind,he?.upstream,kn,cn,tt,o]),Vh=a.useCallback(t=>{if(t&&!oe){const i=t.currentTarget.getBoundingClientRect();rt({x:Math.min(i.left,window.innerWidth-352),y:Math.min(i.bottom+6,window.innerHeight-64)})}else rt(null);P?.()},[oe,P]),Ni=a.useCallback(()=>{rt(null),D?.()},[D]);function nd(){if(!Sn)return null;const t=Xc?.label??o("rightSidebar.allRepositories"),i=Xc?.count??Ae.size,d=St(t)||t;return e.jsxs("button",{type:"button",onClick:Vh,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 ${x?"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":x,title:t,children:[e.jsx(xr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:d}),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(ea,{size:12,className:"shrink-0"})]})}function Yh(){if(!x||!Sn||typeof document>"u")return null;const t=typeof window>"u"?1024:window.innerWidth,i=typeof window>"u"?768:window.innerHeight,d=Math.max(12,Math.min(Fe?.x??t-368,t-352)),y=Math.max(12,Math.min(Fe?.y??80,i-420)),w=oe?void 0:{left:d,top:y},k=e.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${oe?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:Ni,children:e.jsxs("div",{className:oe?"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:w,onClick:j=>j.stopPropagation(),children:[e.jsxs("div",{className:oe?"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:oe?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:o("rightSidebar.repositories")}),!oe&&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:Ba.length}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${Ae.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Ae.size})]})]}),e.jsx("button",{type:"button",onClick:Ni,className:oe?"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(Ft,{size:oe?16:14})})]}),e.jsx("div",{className:oe?"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:Ba.map(j=>{const ie=(j.root??null)===fe,ae=St(j.label)||j.label;return e.jsxs("button",{type:"button",onClick:()=>{Sd(j.root),Ni()},className:`group mb-0.5 flex w-full items-center gap-2 rounded-md text-left transition active:scale-[0.99] ${oe?"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:j.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(xr,{size:13})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:`${oe?"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:j.root===null?o("rightSidebar.allRepositories"):j.label})]}),j.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:j.branch}),j.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] ${j.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:j.count})]},j.root??"all")})})]})});return mf(k,oe,document.body)}function Xh(){return Yh()}function sd(t){const i=vt(t,v),d=t.absolutePath||(i?`${i}/${t.path}`:t.path),y=vo(d,i??v);return{key:vr(t),path:t.path,absolutePath:d,displayName:y.name,displayDir:y.dir,oldPath:t.oldPath,status:t.status,title:d}}function ad(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 za(t,i){const d=Rn(t,v),y=`path:${d}`,w=be===y,k=Ue===y,j=w||k;return e.jsx("button",{type:"button",onClick:ie=>{ie.stopPropagation(),Wt(d,y)},...wi(Aa(d),y),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 ${j?"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"} ${j?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:i,children:e.jsx("span",{className:"whitespace-nowrap",children:o(k?"rightSidebar.copied":w?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function od(t){const i=vt(t,v),d=t.absolutePath||(i?`${i}/${t.path}`:t.path),y=jm(t),w=al(t);return e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(Wx,{actions:y,running:Oe,completed:_n?.path===w?_n:null}),za(d,o("rightSidebar.insertThisFile"))]})}function id(t,i){const d=i.root??v;if(!d)return null;const y=Rn(t,d);return za(y,o("fileTree.insertRefTitle"))}function Ts(){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:()=>bd("unified"),"aria-pressed":Pt==="unified",title:o("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Pt==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.unified")}),e.jsx("button",{type:"button",onClick:()=>bd("split"),"aria-pressed":Pt==="split",title:o("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Pt==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.split")})]})}function ld(){return Is.map(t=>{const i=Au(t.files.map(([,k])=>k)),d=wl({activeGitRepoRoot:fe,groupCount:Is.length,label:t.label,rootName:nt}),y=!!(d&&t.root&&Vr.has(t.root));return{key:t.root??t.label,root:t.root,label:t.label,branch:t.branch,collapsed:y,files:t.files.map(([,k])=>sd(k)),header:d?e.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${y?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[e.jsxs("button",{type:"button",onClick:()=>mm(t.root),"aria-expanded":!y,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:y?e.jsx(cs,{size:13}):e.jsx(ea,{size:13})}),e.jsx(xr,{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(),Xa("stage-all",t.root,t.label)},disabled:!!Oe,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(),Xa("stash-all",t.root,t.label)},disabled:!!Oe,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 jn=a.useMemo(()=>new Map(Array.from(Ae.values(),t=>[vr(t),t])),[Ae]);function cd(t){const i=jn.get(t.key),d=i?vt(i,v):null,y=xg(ut,d,i?.path??t.path);return e.jsx(pl,{changeStatus:t.status,auditStatus:y,renderChangeBadge:w=>e.jsx(Xs,{status:w})})}const Wa=a.useCallback(t=>{if(oe)return null;const i=Array.from(t.querySelectorAll("[data-diff-stream-item]"));if(i.length===0)return null;const y=t.getBoundingClientRect().top+48;let w=null,k=Number.POSITIVE_INFINITY;for(const ie of i){const ae=ie.getBoundingClientRect();if(ae.bottom<y)continue;const ge=Math.abs(ae.top-y);ge<k&&(w=ie,k=ge)}const j=w?.dataset.diffSelectionPath??w?.dataset.diffStreamItem??null;return j?(Ea.current===j&&J.getState().selectedFilePath===j||(Ea.current=j,ot(j)),j):null},[oe,ot]),Jh=!!(!Oe&&Se&&!tt&&(he?.upstream||dn.trim()&&un.trim())),Qh=!!(!Oe&&Se&&!tt&&(he?.upstream||dn.trim()&&un.trim())),Zh=!!(!Oe&&Se&&!tt&&On.trim()&&On.trim()!==he?.branch),er=a.useMemo(()=>{const t=Ie.trim().toLowerCase(),i=Array.from(Ae.entries()).filter(([,d])=>!fe||vt(d,v)===fe).sort(([d],[y])=>d.localeCompare(y));return t?i.filter(([d,y])=>`${d} ${y.path} ${y.status} ${y.repoRelativeRoot??""} ${y.repoName??""}`.toLowerCase().includes(t)):i},[fe,Ae,Ie,v]);a.useEffect(()=>{Ks("selected_file_state",{selectedFilePath:at,selectedChangedFilePath:Qt?.path??null,selectedChangedFileAbsolutePath:Qt?.absolutePath??null,selectedChangedFileRepoRoot:Qt?.repoRoot??null,rootPath:v,activeGitRepoRoot:fe,rightTab:ei,effectiveRightTab:At,diffPaneActive:Tt,changedFiles:Ae.size,filteredChangedFiles:er.length,gitBundleLoading:hr,gitBundleLastLoadedAt:Gn})},[fe,Ae.size,Tt,At,er.length,Gn,hr,ei,v,Qt?.absolutePath,Qt?.path,Qt?.repoRoot,at]);const Is=a.useMemo(()=>{const t=new Map;for(const i of er){const[,d]=i,y=vt(d,v),w=Hx(d)||nt,k=y??w,j=y?it.get(y):void 0,ie=t.get(k)??{root:y,label:w,branch:j?.context?.branch,files:[]};ie.files.push(i),t.set(k,ie)}return Array.from(t.values()).sort((i,d)=>i.label===nt?-1:d.label===nt?1:i.label.localeCompare(d.label))},[er,it,nt,v]),Ds=a.useMemo(()=>{const t=[],i=new Map;for(const d of er)i.set(vr(d[1]),d);for(const d of Is){if(!!(d.root&&wl({activeGitRepoRoot:fe,groupCount:Is.length,label:d.label,rootName:nt})&&Vr.has(d.root)))continue;if($t!=="tree"){t.push(...d.files);continue}const w=d.files.map(([,k])=>sd(k));for(const k of $p(w)){const j=i.get(k.key);j&&t.push(j)}}return t},[fe,Vr,$t,Is,er,nt]),dd=a.useMemo(()=>Ae.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:o("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:Ds.map(([,t])=>{const i=vt(t,v),d=t.absolutePath||(i?`${i}/${t.path}`:t.path);return{key:vr(t),path:t.path,absolutePath:d,status:t.status,repoRoot:i,displayName:vo(d,i).name,displayDir:vo(d,i).dir,auditRecords:ut}}),[ut,Ae.size,Ds,v,o]);a.useEffect(()=>{if(!Tt||Ds.length===0||oe)return;const t=[],i=()=>{const d=document.querySelector(".termdock-diff-stream-scroller");if(d&&Wa(d))return;const y=document.querySelector("[data-diff-stream-item]"),w=y?.dataset.diffSelectionPath??y?.dataset.diffStreamItem??null;if(w){Ea.current=w,ot(w);return}const k=Ds[0]?.[1];if(!k)return;const j=vr(k);Ea.current=j,ot(j)};for(const d of[80,240,600,1200])t.push(window.setTimeout(i,d));return()=>t.forEach(d=>window.clearTimeout(d))},[Tt,oe,Ds,ot,Wa]);const Ci=a.useMemo(()=>{const t=j=>`'${j.replace(/'/g,"'\\''")}'`,i=ar.length>0?gn:ne.filter(j=>j.files.length>0),d=i.length>0?i:v?[{root:v,relativeRoot:".",name:nt}]:[],y=d.length>0?d.map(j=>`- ${j.relativeRoot==="."?".":j.relativeRoot} (${j.root})`).join(`
1667
- `):`- ${v?".":""}`,w=d.length>0?d.map(j=>` td audit-export ${t(j.root)}`).join(`
1668
- `):" td audit-export",k=d.length>0?" td audit ~/.termdock/change-audit/payload-<repo>.json":" td audit ~/.termdock/change-audit/payload.json";return["任务:为目标仓库的 Git diff hunk 生成自包含审计解释,并通过 Termdock CLI 注入。","",`当前工作区:${v??""}`,"目标仓库:",y,"","执行步骤:","1. 仅对“目标仓库”逐个执行 audit-export。嵌套子仓使用括号内 repo 绝对路径作为命令参数。",w,"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(`
1669
- `)},[ar.length,gn,ne,nt,v]),em=a.useCallback((t="generate")=>{if(Sn&&jr.length===0&&!fe){rr(!0);return}const i=t==="generate"?Ci:[t==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",Ci].join(`
1670
- `);dt("insert_change_audit_prompt",{rootPath:v,activeGitRepoRoots:ar,mode:t,hasAuditListCommand:i.includes("td audit-list"),promptLength:i.length}),Ar(o("rightSidebar.insertChangeAuditPrompt"),i,`${_c}:${t}`),pr(),c||l()},[fe,Ci,jr.length,ar,Ar,pr,l,c,v,Sn,o]),Ga=a.useCallback(async t=>{try{await Od({ids:[t]}),Dr(i=>i.filter(d=>d.id!==t))}catch{pr()}},[pr]),tm=a.useCallback(async()=>{if(ut.length===0)return;const t=ut.map(i=>i.id);try{await Od({ids:t}),Dr(i=>i.filter(d=>!t.includes(d.id))),Jr(null)}catch(i){const d=i instanceof Error?i.message:"Failed to clear change audit explanations";Jr(o("rightSidebar.changeAuditClearFailed",{message:d})),pr()}},[ut,pr,o]),rm=a.useCallback(async t=>{if(t.records.length===0)return;const i=t.records.map(d=>d.id);try{await Xm({ids:i}),_r(d=>d.filter(y=>!i.includes(y.id))),Ze===t.key&&(an(null),Bt(!1))}catch(d){yt(o("rightSidebar.branchAuditClearFailed",{message:d instanceof Error?d.message:"Failed to clear branch explanation"})),$a(null)}},[$a,Ze,o]),nm=a.useCallback(t=>{Fr(i=>t===null?(rr(!1),[]):i.includes(t)?i.filter(d=>d!==t):[...i,t])},[]),sm=a.useCallback(t=>{Uo(i=>t===null?(Oo(!1),[]):i.includes(t)?i.filter(d=>d!==t):[...i,t])},[]),Ei=a.useMemo(()=>{if(!sr)return[];const t=i=>{const d=i.diff??"";let y=0,w=0;for(const k of d.split(`
1671
- `))k.startsWith("+++")||k.startsWith("---")||(k.startsWith("+")&&(y+=1),k.startsWith("-")&&(w+=1));return{filePath:i.filePath,oldPath:i.oldPath,newPath:i.newPath,hunkHeader:i.hunkHeader,hunkIndex:i.hunkIndex??0,fingerprint:i.fingerprint,additions:y,deletions:w,diff:d}};return xe?(xe.hunks??[]).map(i=>{const d=xe.comparisonRepos&&xe.comparisonRepos.length>1?[...xe.comparisonRepos].sort((w,k)=>k.label.length-w.label.length).find(w=>i.filePath.startsWith(`${w.label}/`)):void 0,y=Rr.find(w=>w.repoRoot===xe.repoRoot&&w.baseRef===xe.baseRef&&(w.branchName??null)===(xe.currentBranch??null)&&w.filePath===i.filePath&&w.hunkHeader===i.hunkHeader&&(w.hunkIndex??0)===i.hunkIndex&&w.fingerprint===i.fingerprint)??null;return{key:`${i.filePath}\0${i.hunkHeader}\0${i.hunkIndex}`,repoRoot:d?.repoRoot??xe.repoRoot,repositoryPath:d?i.filePath.slice(d.label.length+1):i.filePath,hunk:i.previewRevert&&!rs(i.previewRevert.cwd,i.previewRevert.comparisonBranch)?{...i,previewRevert:void 0}:i,current:y,stale:null}}):Ze?Rr.filter(i=>Su(i)===Ze).map(i=>{const d=t(i);return{key:`${i.filePath}\0${i.hunkHeader}\0${i.hunkIndex??0}`,hunk:d,current:i,stale:null}}):[]},[xe,Rr,rs,sr,Ze]),Mi=Rr.length>0,ns=a.useMemo(()=>{if(!sr)return[];const t=new Map;for(const i of Rr){const d=i.repoRoot,y=it.get(d),w=y?.relativeRoot==="."?nt:y?.relativeRoot||y?.name||St(d),k=Su(i),j=t.get(k)??{key:k,repoRoot:d,repoLabel:w,baseRef:i.baseRef,branchName:i.branchName??null,headRef:i.headRef??null,diffFingerprint:i.diffFingerprint??null,records:[],latestInjectedAt:0};j.records.push(i),j.latestInjectedAt=Math.max(j.latestInjectedAt,i.injectedAt??0),t.set(k,j)}return Array.from(t.values()).sort((i,d)=>d.latestInjectedAt-i.latestInjectedAt)},[Rr,it,sr,nt]),$i=a.useMemo(()=>Ze?ns.find(t=>t.key===Ze)??null:null,[ns,Ze]),Fs=xe?{repoRoot:xe.repoRoot??"",repoLabel:xe.repoRoot?it.get(xe.repoRoot)?.relativeRoot==="."?nt:it.get(xe.repoRoot)?.relativeRoot||it.get(xe.repoRoot)?.name||St(xe.repoRoot):nt,baseRef:xe.baseRef??xe.baseBranch??"",branchName:xe.currentBranch??null,headRef:xe.headRef??null,diffFingerprint:xe.diffFingerprint??null}:$i,am=a.useMemo(()=>(ke?.hunks??[]).map(t=>({key:`${t.filePath}\0${t.hunkHeader}\0${t.hunkIndex}`,repoRoot:ke?.repoRoot,hunk:t,current:null,stale:null})),[ke?.hunks,ke?.repoRoot]),om=a.useMemo(()=>{if(xe)return[];const t=$i;return t?xs.filter(i=>i.repoRoot===t.repoRoot&&i.baseRef===t.baseRef&&(i.branchName??null)===t.branchName&&(!t.diffFingerprint||i.diffFingerprint===t.diffFingerprint)):[]},[xe,xs,$i]),im=a.useCallback(t=>{const i=Ei.find(d=>d.hunk.filePath===t.filePath||(t.repoRoot?`${t.repoRoot}/${d.hunk.filePath}`===t.filePath:!1));i&&(on(i.key),window.setTimeout(()=>Nn(t),90),window.setTimeout(()=>Nn(t),320),window.setTimeout(()=>Nn(t),760))},[Ei]),Pi=a.useMemo(()=>{const t=w=>`'${w.replace(/'/g,"'\\''")}'`,i=As,d=i.length>0?i.map(w=>`- ${w.label} (${w.root}),目标分支:${nr[w.root]||w.branch||"(current branch)"},基线分支:${Lt[w.root]||"(not set)"},包含本地未提交更改:${rs(w.root,nr[w.root]||w.branch)&&(sn[w.root]??!0)?"是":"否"}`).join(`
1672
- `):`- ${v?".":""}`,y=i.length>0?i.map(w=>{const k=nr[w.root]||w.branch||"",j=Lt[w.root]||"",ie=w.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[k?` git -C ${t(w.root)} switch ${t(k)}`:` # ${w.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${t(j)} ${t(w.root)} > ~/.termdock/branch-audit/branch-audit-export-${ie}.json`].join(`
1673
- `)}).join(`
1674
- `):" td branch-audit-export <base-branch>";return["解释目标仓库当前分支相对于基线分支的改动,并把解释写回 Termdock。","",`当前工作区:${v??""}`,"每个仓库分别遵循下面列出的本地未提交更改选项。","目标仓库:",d,"","操作指令:","1. 只针对上面列出的目标仓库导出分支 hunk,按各仓库所选目标分支与基线对比。本地未提交更改标记为是的仓库纳入 staged/unstaged/untracked 改动;标记为否的仓库只解释提交改动,忽略导出中混入的本地改动。嵌套子仓或软链接子仓使用括号内的仓库绝对路径。示例:",y,"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(`
1675
- `)},[sn,rs,As,Lt,nr,v]),lm=a.useCallback((t="generate")=>{const i=t==="generate"?Pi:[t==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",Pi].join(`
1676
- `);Ar(o("rightSidebar.branchAuditShort"),i,`context:branch-audit-scope:${t}`),c||l()},[Pi,Ar,l,c,o]),Li=a.useCallback(async(t={})=>{const i=t.refresh===!0,d=i&&xe?.comparisonRepos?xe.comparisonRepos:As.map(j=>{const ie=(nr[j.root]||j.branch||"").trim();return{repoRoot:j.root,label:j.label,base:Lt[j.root]?.trim()??"",head:ie||null,includeUncommitted:sn[j.root]??!0}});if(!v||d.length===0)return;const y=++Ot.current,w=v,k=()=>Ne(w)&&y===Ot.current;M(!0),de(null),i||(Yt(null),Je(null));try{const j=await Promise.all(d.map(async Z=>{if(!Z.base)throw new Error(o("rightSidebar.branchAuditMissingBase",{repo:Z.label}));return Ud({cwd:v,repoRoot:Z.repoRoot,base:Z.base,head:Z.head,includeUncommitted:t.repoRoot===Z.repoRoot?t.includeUncommitted??!1:Z.includeUncommitted??xe?.includeUncommitted??!0,requestSlotId:`right-sidebar-branch-preview:${Z.repoRoot}`})}));if(!k())return;const ie=j.find(Z=>!Z.available);if(ie){de(ie.error??"Branch diff is unavailable");return}const ae=j.length===1?j[0]:{available:!0,workspaceRoot:v,repoRoot:v,baseRef:j.map(Z=>Z.baseRef??Z.baseBranch).filter(Boolean).join(", "),currentBranch:j.map(Z=>Z.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:j.map(Z=>Z.headRef).filter(Boolean).join(", "),diffFingerprint:j.map(Z=>Z.diffFingerprint).filter(Boolean).join("+"),stat:j.map(Z=>Z.stat).filter(Boolean).join(`
1677
- `),files:j.flatMap((Z,X)=>{const pe=d[X];return(Z.files??[]).map(Pe=>`${pe?.label??Z.repoRoot??"repo"}/${Pe}`)}),hunks:j.flatMap((Z,X)=>{const Pe=d[X]?.label??Z.repoRoot??"repo";return(Z.hunks??[]).map(Ge=>({...Ge,filePath:`${Pe}/${Ge.filePath}`,oldPath:Ge.oldPath?`${Pe}/${Ge.oldPath}`:Ge.oldPath,newPath:Ge.newPath?`${Pe}/${Ge.newPath}`:Ge.newPath}))}),commits:j.flatMap(Z=>Z.commits??[]),commitCount:j.reduce((Z,X)=>Z+(X.commitCount??X.commits?.length??0),0),diff:j.map(Z=>Z.diff).filter(Boolean).join(`
1678
- `),truncated:j.some(Z=>Z.truncated)};if(ae.comparisonRepos=d.map((Z,X)=>({...Z,head:Z.head??j[X].currentBranch??null,includeUncommitted:j[X].includeUncommitted===!0,canIncludeUncommitted:j[X].canIncludeUncommitted})),ae.canIncludeUncommitted=j.every(Z=>Z.canIncludeUncommitted===!0),ae.includeUncommitted=j.some(Z=>Z.includeUncommitted===!0),Ho(Z=>({...Z,...Object.fromEntries(ae.comparisonRepos.map(X=>[X.repoRoot,X.includeUncommitted??!1]))})),!i&&(ae.hunks??[]).length===0){de(o("rightSidebar.branchAuditDiffEmpty"));return}const ge=Date.now(),Me=(i?Ze:null)??["preview",ae.repoRoot??v,ae.baseRef??ae.baseBranch??"",ae.currentBranch??"",ae.headRef??"",ae.diffFingerprint??ge].join("\0"),et=d.length===1?d[0].label:`${d.length} repos`;Yt(ae),Ln(Z=>[{key:Me,diff:ae,repoLabel:et,createdAt:ge},...Z.filter(X=>X.key!==Me)].slice(0,8)),i||An(Z=>Z[Me]===void 0?Z:{...Z,[Me]:0}),an(Me),on(Z=>{const X=ae.hunks?.[0],pe=X?`${X.filePath}\0${X.hunkHeader}\0${X.hunkIndex}`:null;return i&&Z&&(ae.hunks??[]).some(Pe=>Pe.filePath===Z.split("\0")[0])?Z:pe}),Bt(!0)}catch(j){if(!k()||wr(j))return;de(j instanceof Error?j.message:"Failed to load branch diff")}finally{k()&&M(!1)}},[sn,xe,Ze,As,Lt,nr,Ne,v,o]),cm=a.useCallback(t=>{++Ot.current,M(!1),Yt(t.diff),de(null),an(t.key),on(t.diff.hunks?.[0]?`${t.diff.hunks[0].filePath}\0${t.diff.hunks[0].hunkHeader}\0${t.diff.hunks[0].hunkIndex}`:null),Bt(!0)},[]),dm=a.useCallback(t=>{Ln(i=>i.filter(d=>d.key!==t)),An(i=>{if(!(t in i))return i;const d={...i};return delete d[t],d}),Ze===t&&(an(null),Yt(null),Bt(!1))},[Ze]),um=a.useCallback(t=>{++Ot.current,M(!1);const i=ns.find(d=>d.key===t);i&&(Yt(null),de(null),an(t),on(i.records[0]?.filePath??null),Bt(!0))},[ns]),fm=a.useCallback(async t=>{if(!v||!Se)return;const[i]=t.split(/\s+/);if(i){qe(i),st(null),Je(null);try{const d=await Jm({cwd:v,repoRoot:Se,commit:i,requestSlotId:"right-sidebar-commit-diff"});if(!d.available){st(d.error??"Commit diff is unavailable");return}Je(d);const y=d.hunks?.[0];ca(y?`${y.filePath}\0${y.hunkHeader}\0${y.hunkIndex}`:null)}catch(d){st(d instanceof Error?d.message:"Failed to load commit diff")}finally{qe(null)}}},[Se,v]),hm=a.useCallback(t=>{if(!xe||!Ze)return;const i=Math.max(0,Math.round(t));An(d=>Math.abs((d[Ze]??0)-i)<24?d:{...d,[Ze]:i})},[xe,Ze]);a.useEffect(()=>{!xe||!Ze||Ln(t=>t.map(i=>i.key===Ze&&i.diff!==xe?{...i,diff:xe}:i))},[xe,Ze]);const ud=!!xe;a.useEffect(()=>{if(!oe||!dr||!ud)return;const t=Sc.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)},[dr,ud,oe]);const fd=a.useCallback(t=>{t&&Sh(i=>Pp(i,t))},[]),hd=ka.key===at?ka.key:null,Ka=a.useCallback(t=>{const i=J.getState(),d=t0();Ks("select_diff_file",{interactionId:d,path:t,previousSelectedFilePath:i.selectedFilePath,rootPath:i.rootPath,activeGitRepoRoot:fe,changedFiles:i.changedFiles.size,gitBundleLoading:i.gitBundleLoading,gitBundleLastLoadedAt:i.gitBundleLastLoadedAt,rightTab:i.rightTab}),ot(t),fr("diff"),oe&&t&&Nc(1),fd(t),queueMicrotask(()=>{const y=J.getState();Ks("select_diff_file_after",{interactionId:d,requestedPath:t,selectedFilePath:y.selectedFilePath,rootPath:y.rootPath,rightTab:y.rightTab,changedFiles:y.changedFiles.size,activeGitRepoRoot:fe})})},[fe,oe,fd,ot,fr,Nc]),md=a.useCallback(t=>{const i=Array.from(Ae.values()).find(d=>{const y=vt(d,v),w=vr(d);return d.path===t.filePath||w===t.filePath||d.absolutePath===t.filePath||(y?`${y}/${d.path}`===t.filePath:!1)||t.repoRoot&&y===t.repoRoot&&d.path===t.filePath});if(i){Ka(vr(i)),window.setTimeout(()=>Nn(t),90),window.setTimeout(()=>Nn(t),320),window.setTimeout(()=>Nn(t),760);return}Nn(t)},[Ae,v,Ka]),pd=a.useCallback(({slideToDetail:t,fullscreen:i,toggleFullscreen:d}={})=>tr.length>0?e.jsx(Xu,{walkthroughs:tr,repoRoot:fe,fullscreen:i,onToggleFullscreen:d,onNavigate:y=>{oe&&window.requestAnimationFrame(()=>t?.()),md(y)}}):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(ta,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),o("rightSidebar.changeWalkthroughEmpty")]}),[fe,tr,md,oe,o]),mm=a.useCallback(t=>{t&&Ir(i=>{const d=new Set(i);return d.has(t)?d.delete(t):d.add(t),Qi(Vi,d),d})},[]),gd=a.useCallback(t=>{Ke(i=>{const d=new Set(i);return d.has(t)?d.delete(t):d.add(t),Qi(hu,d),d})},[]),qa=a.useCallback(t=>{Yr(t),Dt(gf,t)},[]);a.useEffect(()=>{Oa||$t!=="ai"||qa("tree")},[$t,qa,Oa]);const Va=a.useCallback(()=>{Do(t=>{const i=!t;return Dt(bf,i),i})},[]),bd=a.useCallback(t=>{ia(t),Dt(xf,t)},[]),{whitespace:xd,context:vd}=Ap(),wd=a.useMemo(()=>({algorithm:"histogram",whitespace:xd,context:vd}),[xd,vd]),yd=a.useCallback(t=>{Q(t),Dt(vf,t)},[]),Ya=a.useCallback(async(t,i,d,y)=>{let w=t;for(;w.ok&&w.status==="running";)await new Promise(j=>window.setTimeout(j,1500)),w=await Hd({jobId:w.jobId,cwd:i.cwd,action:i.action});if(!w.ok)throw new Error("Git action status is unavailable");if(w.status==="error")throw new Error(w.error||w.message||"Git action failed");const k={action:i.action,path:y,label:d};return js(k),window.setTimeout(()=>js(j=>j?.action===k.action&&j.path===k.path?null:j),1400),w},[]),kt=a.useCallback(async(t,i,d)=>{const y=v;v&&mr.current.delete(v),yt(null),js(null),Ss({action:t.action,path:d});try{const w=await Qm({...t,includeNested:Hs(v)}),k=await Ya(w,t,i,d);if(!Ne(y))return!1;const j=v?await Ui(v,void 0,{includeNested:Hs(v),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Ws(v)}).catch(()=>k.bundle):k.bundle;return Ne(y)?(j&&Xn(j,{reloadDiff:!0,cacheOnly:!0}),ln(null),!0):!1}catch(w){return js(null),yt(o("rightSidebar.gitActionFailed",{message:w instanceof Error?w.message:"Unknown error"})),!1}finally{Ne(y)&&Ss(null)}},[Xn,Ne,v,o,Ya]),kd=a.useCallback(async t=>{const i=v;await zd({...t,includeNested:Hs(v)}),Ne(i)&&zt(v??void 0,{refresh:!0,background:!0})},[Ne,zt,v]),pm=a.useCallback(async t=>{const i=xe,d=Ot.current,y=i?.hunks?.find(k=>k.previewRevert?.cwd===t.cwd&&k.previewRevert.path===t.path);if(!i||!y||!t.comparisonBase)throw new Error(o("diffViewer.hunkActionUnavailable"));tn(k=>k+1),de(null);try{await zd(t)}catch(k){throw tn(j=>j-1),k}if(d!==Ot.current||!Ne(v)){tn(k=>k-1);return}const w=k=>{Yt(j=>{if(!j||d!==Ot.current)return j;const ie=j.hunks??[],ae=k===void 0?ie.filter(Me=>!(Me.previewRevert?.cwd===t.cwd&&Me.previewRevert.patch===t.patch)):[...ie.filter(Me=>Me.filePath!==y.filePath),...k];return{...j,hunks:ae}})};w(),Ud({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(d!==Ot.current||!Ne(v))return;if(!k.available||k.truncated)throw new Error(k.error??o("diffViewer.hunkActionUnavailable"));const j=t.path.slice(t.cwd.length+1),ie=y.filePath.slice(0,y.filePath.length-j.length);w((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=>{d===Ot.current&&Ne(v)&&!wr(k)&&de(`${o("diffViewer.hunkActionReverted")} · ${k instanceof Error?k.message:String(k)}`)}).finally(()=>tn(k=>k-1))},[xe,Ne,v,o]),Xa=a.useCallback((t,i,d)=>{if(i){if(t==="stage-all"){kt({action:"stage-all",cwd:i},o("rightSidebar.stageAll"),`repo:${i}`);return}ln({kind:"stash-all",repoRoot:i,repoLabel:d})}},[kt,o]),Sd=a.useCallback(t=>{Ye(t),ba(""),xa(""),va(""),ot(Yc(t)),ct||fr("diff"),t&&_a(it.get(t))},[_a,Yc,ct,it,ot,Ye,fr]),jd=a.useCallback(t=>{const i=new Set([...Jt.current.keys(),...mn.current,...mr.current]);for(const d of i)d!==t&&(Xt.current.delete(d),Jt.current.get(d)?.abort(),Jt.current.delete(d),Nt(`right-sidebar-git-untracked:${d}`),mn.current.delete(d),mr.current.delete(d))},[]),gm=a.useCallback(async t=>{const i=v;if(!i||(await J.getState().setNestedGitScanRoot(i,t),!Ne(i)))return;if(t){await zt(i,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}jd(i),ba(""),xa(""),va(""),Uo(y=>y.filter(w=>w===i));const d=Qt;d&&vt(d,i)!==i&&ot(null),await zt(i,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[jd,Ne,zt,v,ot,Qt]),bm=a.useCallback(async()=>{if(!Se||tt){yt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=On.trim();!t||t===he?.branch||await kt({action:"switch-branch",cwd:Se,branch:t},o("rightSidebar.switchBranch"))},[he?.branch,Se,tt,kt,On,o]),Rd=a.useCallback(async()=>{if(!Se||tt){yt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=ga.trim();if(!t)return;await kt({action:"commit",cwd:Se,message:t},o("rightSidebar.commitChanges"))&&Zl("")},[Se,ga,tt,kt,o]),xm=a.useCallback(async()=>{if(!Se||tt){yt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=dn.trim(),i=un.trim();await kt({action:"push",cwd:Se,...t?{remote:t}:{},...i?{branch:i}:{}},o("rightSidebar.pushChanges"))},[Se,un,dn,tt,kt,o]),vm=a.useCallback(async()=>{if(!Se||tt){yt(o("rightSidebar.selectRepositoryForGitActions"));return}const t=dn.trim(),i=un.trim();await kt({action:"pull",cwd:Se,...t?{remote:t}:{},...i?{branch:i}:{}},o("rightSidebar.pullChanges"))},[Se,un,dn,tt,kt,o]);a.useEffect(()=>{if(!ct||!Se||Oe)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 d of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(t)return;const y=await Hd({cwd:Se,action:d}).catch(()=>null);if(!y?.ok||y.status!=="running")continue;const w={action:d,cwd:Se},k=i[d]??d;Ss({action:d});try{const j=await Ya(y,w,k);if(t||!Ne(v))return;const ie=v?await Ui(v,void 0,{includeNested:Hs(v),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:Ws(v)}).catch(()=>j.bundle):j.bundle;ie&&Xn(ie,{reloadDiff:!0,cacheOnly:!0})}catch(j){t||yt(o("rightSidebar.gitActionFailed",{message:j instanceof Error?j.message:"Unknown error"}))}finally{t||Ss(null)}return}})(),()=>{t=!0}},[Se,Xn,ct,Ne,v,Oe,o,Ya]);const Ai=_n?.action==="commit",Ti=_n?.action==="switch-branch",Ii=_n?.action==="pull",Di=_n?.action==="push",Ja=ct||yh,Fi=Ha?o("rightSidebar.changeAuditScopeAll"):br.length===1?br[0].label:`${br.length} repos`,wm=br.length>0,Nd=As.length>0,ym=v?e.jsx($u,{open:Bo,onOpenChange:Oo,showScopePicker:!0,selectedAll:Ha,repos:Zt,selectedRoots:Ua,onToggleRepo:sm,onGenerate:()=>lm(Mi?"regenerate":"generate"),disabled:!wm,generateDisabled:!Nd,inserted:be?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:o(Mi?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.branchAuditGenerateTitle"),ariaLabel:o("rightSidebar.branchAuditShort"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Fi,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o(Mi?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{Li()},secondaryDisabled:!Nd||ws,secondaryLabel:o("rightSidebar.branchAuditViewDiff"),secondaryTitle:o("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:ws,loading:Kl.size>0,statusTitle:Kl.size>0?o("rightSidebar.branchCandidatesLoading"):void 0,extraContent:e.jsx("div",{className:"mb-2 space-y-1.5",children:ed.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:ed.map(t=>t.label).join(F==="zh"?"、":", ")})})}),renderRepoExtra:t=>{const i=it.get(t.root),d=rs(t.root,nr[t.root]||i?.context?.branch),y=[],w=new Set,k=(ge,Me)=>{!ge||w.has(ge)||(w.add(ge),y.push({value:ge,label:ge,meta:Me}))};k(nr[t.root]||i?.context?.branch,o("rightSidebar.pushCurrentBranchBadge"));for(const ge of i?.context?.branches??[])k(ge,ge===i?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):o("rightSidebar.localBranch"));for(const ge of i?.context?.remoteBranches??[])k(ge,o("rightSidebar.remoteBranch"));const j=[],ie=new Set,ae=(ge,Me)=>{!ge||ie.has(ge)||(ie.add(ge),j.push({value:ge,label:ge,meta:Me}))};ae(Lt[t.root],Lt[t.root]?o("rightSidebar.pushUpstreamBadge"):void 0),ae(i?.context?.upstream,i?.context?.upstream?o("rightSidebar.pushUpstreamBadge"):void 0);for(const ge of i?.context?.remoteBranches??[])ae(ge,"remote");for(const ge of i?.context?.branches??[])ae(ge,ge===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(ls,{label:o("rightSidebar.currentBranchLabel"),value:nr[t.root]||i?.context?.branch||"",options:y,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),onChange:ge=>{ua(Me=>({...Me,[t.root]:ge}))}}),e.jsx(ls,{label:o("rightSidebar.branchAuditBaseLabel"),value:Lt[t.root]||"",options:j,placeholder:o("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:o("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:o("rightSidebar.branchAuditBaseEmpty"),onChange:ge=>{fa(Me=>({...Me,[t.root]:ge}))}}),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(d?"rightSidebar.includeUncommittedHint":"rightSidebar.includeUncommittedCurrentBranchOnly")})]}),e.jsx("input",{type:"checkbox",checked:d&&(sn[t.root]??!0),disabled:!d,onChange:ge=>Ho(Me=>({...Me,[t.root]:ge.target.checked})),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]})]})}}):null,Cd=Gs(ut.reduce((t,i)=>Math.max(t,i.injectedAt??0),0),F),km=()=>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:()=>Gl(t=>{const i=!t;return Dt(Yi,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":ks,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(ta,{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:Fi})]}),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 ${ks?"rotate-90":""}`,children:e.jsx(cs,{size:13})})]}),ks&&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"),": ",Fi]}),ym]}),K&&e.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:K}),e.jsxs("div",{className:"mt-2 space-y-1.5",children:[en.map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ze===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:()=>cm(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")})]}),Gs(t.createdAt,F)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:Gs(t.createdAt,F)})]}),e.jsx("button",{type:"button",onClick:()=>dm(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(po,{size:12})})]},t.key)),ns.length>0?ns.slice(0,Math.max(0,8-en.length)).map(t=>e.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${Ze===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:()=>um(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})]}),Gs(t.latestInjectedAt,F)&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:o("rightSidebar.branchAuditGeneratedAt",{time:Gs(t.latestInjectedAt,F)??""})})]}),e.jsx("button",{type:"button",onClick:()=>{rm(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(po,{size:12})})]},t.key)):en.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,Sm=()=>sr&&v&&kn?e.jsxs("div",{className:Ja?"overflow-visible":"overflow-hidden",children:[km(),e.jsxs("button",{type:"button",onClick:()=>{ct||kh(t=>{const i=!t;return i&&Se&&!kn&&!cn&&hi(Se),i})},"aria-expanded":Ja,className:`group flex w-full items-center gap-2 px-1 pb-1 pt-4 text-left transition ${ct?"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(xr,{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 ${yn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[cn&&e.jsx(ft,{size:10,className:"animate-spin"}),yn.staged>0?o("rightSidebar.stagedCount",{count:yn.staged}):o("rightSidebar.noStagedChangesShort")]}),!ct&&e.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${Ja?"rotate-90":""}`,children:e.jsx(cs,{size:13})})]})]}),Ja&&e.jsxs("div",{className:"space-y-0",children:[Kt.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:zh})]})}),e.jsx(ls,{label:o("rightSidebar.gitRepositoryLabel"),value:Se??"",options:Kt,placeholder:o("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:o("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:o("rightSidebar.gitRepositoryEmpty"),disabled:!!Oe,onChange:t=>{Sd(t||null)}}),tt&&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:On!==qc?qc:null})]}),e.jsxs("button",{type:"button",onClick:()=>{bm()},disabled:!Zh,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 ${Ti?"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:Oe?.action==="switch-branch"||Ti?"opacity-0":"",children:o("rightSidebar.switchBranch")}),Oe?.action==="switch-branch"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Ti&&Oe?.action!=="switch-branch"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx(ls,{label:o("rightSidebar.currentBranchLabel"),value:On,options:Kh,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),disabled:!!Oe,onChange:ba})]}),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:tt?o("rightSidebar.selectRepositoryForGitActions"):yn.staged>0?o("rightSidebar.commitReadyHint",{count:yn.staged}):o("rightSidebar.commitNeedsStaged")})]}),e.jsxs("button",{type:"button",onClick:()=>{Rd()},disabled:!!Oe||tt||yn.staged===0||!ga.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 ${Ai?"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:tt?o("rightSidebar.selectRepositoryForGitActions"):yn.staged===0?o("rightSidebar.commitNeedsStaged"):o("rightSidebar.commitChanges"),children:[e.jsx("span",{className:Oe?.action==="commit"||Ai?"opacity-0":"",children:o("rightSidebar.commitChanges")}),Oe?.action==="commit"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Ai&&Oe?.action!=="commit"&&e.jsx("span",{className:"absolute",children:"✓"})]})]}),e.jsx("input",{value:ga,onChange:t=>Zl(t.target.value),onKeyDown:t=>{(t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),Rd())},placeholder:o("rightSidebar.commitMessagePlaceholder"),disabled:!!Oe,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:()=>Br(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":xt,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:[In&&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 ${xt?"rotate-90":""}`,children:e.jsx(cs,{size:13})})]})]}),xt&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[e.jsx(ds,{size:12,className:"shrink-0"}),e.jsx("input",{value:Nr,onChange:t=>Or(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}),Nr&&e.jsx("button",{type:"button",onClick:()=>Or(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:e.jsx(Ft,{size:12})})]}),e.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:Wh,children:[Cr.length>0?Cr.map(t=>{const[i,...d]=t.split(/\s+/),y=d.join(" ")||t;return e.jsxs("button",{type:"button",onClick:()=>{fm(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:y,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:y,children:y}),rn[i]&&e.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${rn[i]==="ahead"?"bg-accent/10 text-accent":rn[i]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:o(rn[i]==="ahead"?"rightSidebar.commitAhead":rn[i]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),ze===i&&e.jsx(ft,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},t)}):In?e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:o("common.loading")}):nn?null:e.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.recentCommitsEmpty")}),We&&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"})}),_o&&!We&&Cr.length>0&&e.jsx("button",{type:"button",onClick:()=>{Ls({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")})]})]}),Ve&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Ve}),nn&&e.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:nn})]}),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:()=>{vm()},disabled:!Jh,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 ${Ii?"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:Oe?.action==="pull"||Ii?"opacity-0":"",children:o("rightSidebar.pullChanges")}),Oe?.action==="pull"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Ii&&Oe?.action!=="pull"&&e.jsx("span",{className:"absolute",children:"✓"})]}),e.jsxs("button",{type:"button",onClick:()=>{xm()},disabled:!Qh,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 ${Di?"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:Oe?.action==="push"||Di?"opacity-0":"",children:o("rightSidebar.pushChanges")}),Oe?.action==="push"&&e.jsx(ft,{size:12,className:"absolute animate-spin"}),Di&&Oe?.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] ${rd.className}`,title:he?.upstream??void 0,children:[e.jsx("span",{className:"truncate font-medium",children:rd.text}),e.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:he?.upstream??""})]}),e.jsxs("div",{className:`grid gap-1.5 ${Zc?"grid-cols-2":"grid-cols-1"}`,children:[Zc&&e.jsx(ls,{label:o("rightSidebar.pushRemoteLabel"),value:dn,options:Qc,placeholder:o("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:o("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:o("rightSidebar.pushNoRemotes"),disabled:!!Oe,onChange:xa}),e.jsx(ls,{label:o("rightSidebar.pushBranchLabel"),value:un,options:qh,placeholder:o("rightSidebar.pushBranchPlaceholder",{branch:he?.branch??"HEAD"}),searchPlaceholder:o("rightSidebar.pushBranchSearchPlaceholder"),emptyText:o("rightSidebar.pushNoBranches"),disabled:!!Oe,onChange:va})]})]})]})]}):null,jm=a.useCallback(t=>{const i=vt(t,v);if(!i)return[];const d=al(t),y=[];return t.canStage&&y.push({key:"stage-file",label:o("rightSidebar.stageFile"),onClick:()=>{kt({action:"stage-file",cwd:i,paths:[t.path]},o("rightSidebar.stageFile"),d)}}),t.canUnstage&&y.push({key:"unstage-file",label:o("rightSidebar.unstageFile"),onClick:()=>{kt({action:"unstage-file",cwd:i,paths:[t.path]},o("rightSidebar.unstageFile"),d)}}),t.canStash&&y.push({key:"stash-file",label:o("rightSidebar.stashFile"),onClick:()=>{kt({action:"stash-file",cwd:i,paths:[t.path]},o("rightSidebar.stashFile"),d)}}),t.canRestoreWorktree&&y.push({key:"restore-worktree-file",label:o("rightSidebar.restoreFile"),destructive:!0,onClick:()=>ln({kind:"restore",file:t,phrase:""})}),y},[v,kt,o]),Rm=a.useCallback(()=>{if(h){f?.();return}Mr(0),Pr.current?.slideTo(0),Er(!1),Mt(null)},[f,h]),Ed=a.useCallback(t=>{if(V(""),Ht(t),ot(null),Mt(null),H(null),oe){h&&f?.(),Mr(0),Pr.current?.slideTo(0),Er(!1);return}},[oe,f,h,ot,Ht]);a.useEffect(()=>{const t=i=>{const d=i.detail,y=d?.path;if(typeof y!="string"||!y.startsWith("/"))return;V(""),Mt(null),cr(null);const w=!!(v&&(y===v||y.startsWith(`${v}/`)));if(d.kind==="file"){const k=ho(y);Es(y),typeof d.line=="number"&&Number.isSafeInteger(d.line)&&d.line>0&&cr(d.line),Ht(w?null:k),H(j=>({path:y,nonce:(j?.nonce??0)+1}));return}ot(null),w?(Ht(null),H(k=>({path:y,nonce:(k?.nonce??0)+1}))):(H(null),Ht(y)),oe&&(h&&f?.(),Mr(0),Pr.current?.slideTo(0),Er(!1))};return window.addEventListener(qd,t),()=>window.removeEventListener(qd,t)},[Es,oe,f,h,v,ot,Ht]),a.useEffect(()=>{r||(Et(!1),Vt(!1))},[r]),a.useEffect(()=>{if(!lr&&!_t)return;const t=i=>{i instanceof globalThis.KeyboardEvent&&i.key!=="Escape"||i instanceof globalThis.MouseEvent&&i.target instanceof Node&&(En.current?.contains(i.target)||Mn.current?.contains(i.target))||(Et(!1),Vt(!1))};return window.addEventListener("mousedown",t),window.addEventListener("keydown",t),()=>{window.removeEventListener("mousedown",t),window.removeEventListener("keydown",t)}},[_t,lr]);const Md=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:Oh,disabled:!Da,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($l,{size:14})}),e.jsx("button",{type:"button",onClick:Bc,disabled:!v||Hn===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(Vd,{size:14})}),e.jsx("button",{type:"button",onClick:Uh,disabled:!ue,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:ec?o("rightSidebar.fileWatchUnavailable",{message:ec}):o("rightSidebar.refreshFiles"),children:e.jsx(go,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1 px-1",title:ue??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:_h}),Na==="modified"&&e.jsx("span",{className:"inline-flex shrink-0 text-primary",title:o("fileTree.sortedByModified"),"aria-label":o("fileTree.sortedByModified"),children:e.jsx(Yd,{size:11})})]})}),e.jsx("button",{type:"button",onClick:()=>ue&&Wt(ue,Gt??void 0),disabled:!ue,...ue&&Gt?wi(Aa(ue),Gt):{},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 ${Gt&&(be===Gt||Ue===Gt)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":o(Gt&&Ue===Gt?"rightSidebar.copied":Gt&&be===Gt?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:o("rightSidebar.insertCurrentFolder"),children:Gt&&(be===Gt||Ue===Gt)?e.jsx(ko,{size:13}):e.jsx(So,{size:13})}),e.jsx(fg,{rootPath:ue,disabled:!ue||!Nh||ai,pressed:Ra,saving:ai,onToggle:()=>{if(!ue||ai)return;const t=ue;bc(!0),oi(null),Ch(t,!Ra).catch(()=>{const i=J.getState();(i.explorerRoot??i.rootPath)===t&&oi(o("rightSidebar.gitIgnoreSaveFailed"))}).finally(()=>bc(!1))}}),e.jsxs("div",{ref:Mn,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{Et(!1),Vt(t=>!t)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${_t?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":_t,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:e.jsx(yo,{size:14})}),_t&&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:()=>{Vt(!1),Hh()},disabled:!Si,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(zi,{size:14}):e.jsx(ro,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o($s?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Vt(!1),jh()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${ti?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[ti?e.jsx(Fp,{size:14}):e.jsx(hl,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(ti?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!ue,onClick:()=>{ue&&(Vt(!1),Rh(ue,Na==="modified"?"name":"modified"))},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-40",children:[Na==="modified"?e.jsx(wp,{size:14}):e.jsx(Yd,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o(Na==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),xc&&e.jsx("p",{role:"alert",className:"px-1 py-1 text-[11px] text-destructive",children:xc}),v&&(Fa.length>0||Bh)&&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:Bc,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 ${ue===v?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:v,children:[e.jsx(Vd,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:nt})]}),Fa.map(t=>{const i=t.path,d=t.kind==="file",y=d?at===i:ue===i;return e.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${y?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:i,children:[e.jsxs("button",{type:"button",onClick:()=>d?Es(i):Ht(i),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[d?e.jsx(ml,{size:10,className:"shrink-0"}):e.jsx(ro,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:St(i)})]}),e.jsx("button",{type:"button",onClick:()=>fn(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:St(i)}),title:o("rightSidebar.unpinFolder",{name:St(i)}),children:e.jsx(Ft,{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"})]}),_i=a.useMemo(()=>{if(Bn===null)return null;const t=typeof navigator>"u"?void 0:navigator.language,i=Math.max(0,Math.floor((Yo-Bn)/1e3)),d=new Intl.RelativeTimeFormat(t,{numeric:"auto"}),[y,w]=i<60?[-i,"second"]:i<3600?[-Math.floor(i/60),"minute"]:i<86400?[-Math.floor(i/3600),"hour"]:[-Math.floor(i/86400),"day"];return d.format(y,w)},[Yo,Bn]),Qa="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",$d=v&&!Qn?e.jsxs("button",{type:"button",role:"menuitemcheckbox",tabIndex:-1,onClick:()=>{gm(!ri)},"aria-checked":ri,title:o("rightSidebar.multiRepoScanTitle"),className:Qa,children:[e.jsx(xr,{size:15,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1",children:o("rightSidebar.multiRepoScan")}),ri&&e.jsx(ko,{size:14,className:"shrink-0 text-primary"})]}):null,Pd=v?e.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[_i?e.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:o("rightSidebar.gitLastUpdated",{time:_i}),children:_i}):null,e.jsx("button",{type:"button",onClick:()=>{Jn()},disabled:hr,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95","aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),children:e.jsx(go,{size:13,className:hr?"animate-spin":""})})]}):null,Nm=Rc?o("rightSidebar.changeAuditScopeAll"):gn.length===1?gn[0].relativeRoot==="."?nt:gn[0].relativeRoot||gn[0].name:`${gn.length} repos`,Cm=t=>v?e.jsxs("div",{role:"none",children:[e.jsx($u,{menuItem:!0,open:Qr,onOpenChange:i=>{rr(i),i&&t()},showScopePicker:Sn,selectedAll:Rc,repos:Eh,selectedRoots:ar,onToggleRepo:nm,onGenerate:()=>{t(),em()},disabled:!v,inserted:be===_c,buttonLabel:o("rightSidebar.changeAuditShort"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:o("rightSidebar.insertChangeAuditPrompt"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Nm,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o("rightSidebar.changeAuditShort"),loading:gs,error:!!la,statusTitle:la??(gs?o("rightSidebar.changeAuditLoading"):ut.length>0?`${o("rightSidebar.changeAuditLoaded",{count:ut.length})}${Cd?` · ${o("rightSidebar.changeAuditLoadedAt",{time:Cd})}`:""}`:void 0)}),ut.length>0&&e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),tm()},disabled:gs||ut.length===0,className:Qa,title:o("rightSidebar.clearChangeAuditTitle"),"aria-label":o("rightSidebar.clearChangeAudit"),children:[e.jsx(po,{size:15,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.clearChangeAudit")})]})]}):null,ss=ir??(we?.available&&v&&Ae.size>0&&ne.length<=1?{root:v,label:nt}:null),Ld=t=>e.jsxs(e.Fragment,{children:[ss&&e.jsxs("div",{role:"group","aria-label":o("rightSidebar.gitQuickActions"),children:[e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),Xa("stage-all",ss.root,ss.label)},disabled:!!Oe,className:Qa,children:[e.jsx(rp,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stageAll")]}),e.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{t(),Xa("stash-all",ss.root,ss.label)},disabled:!!Oe,className:Qa,children:[e.jsx(Mp,{size:15,className:"shrink-0 text-muted-foreground"}),o("rightSidebar.stashAll")]})]}),ss&&e.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),Cm(t),$d&&e.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/30"}),$d]}),Za=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:[we?.available&&we.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:we.branch,children:[e.jsx(xr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:we.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(yp,{side:"right",isOpen:r,drawerWidthPx:s,onClose:l,onOpen:u,push:c,pinned:m,children:[wi.popoverNode,e.jsxs("div",{className:`relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2 ${Ah?"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:nt}),(!oe||Ko)&&we?.available&&we.branch&&e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:we.branch,children:[e.jsx(xr,{size:10,className:"shrink-0"}),e.jsx("span",{className:"max-w-[7rem] truncate",children:we.branch})]})]})}),e.jsx("button",{type:"button",onClick:()=>{const t=!R;z(t),t?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):V("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${R?"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(ds,{size:14})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":Ee,onClick:()=>{He(t=>!t),jt(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Ee?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleContextDraft"),title:o("rightSidebar.contextDraftTitle"),children:[e.jsx(kp,{size:14}),!Ee&&ye.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:sc,type:"file",multiple:!0,className:"hidden",onChange:t=>{const i=t.target.files;!i||i.length===0||(Ms(Array.from(i)),t.target.value="")}}),e.jsx("input",{ref:ac,type:"file",accept:"image/*",className:"hidden",onChange:t=>{const i=t.target.files?.[0];t.target.value="",i&&Ih(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(zi,{size:14}):e.jsx(ro,{size:14})}),e.jsxs("div",{ref:En,className:"relative shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{Vt(!1),Et(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(yo,{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:[e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":zr,onClick:()=>Ec(!zr),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(Wd,{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 ${zr?"bg-primary":"bg-surface-elevated"}`,children:e.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${zr?"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:()=>{Et(!1),sc.current?.click()},disabled:wa,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:[wa?e.jsx(ft,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(Yp,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.uploadFiles")})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Et(!1),ac.current?.click()},disabled:wa,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:[wa?e.jsx(ft,{size:14,className:"animate-spin text-muted-foreground"}):e.jsx(zp,{size:14,className:"text-muted-foreground"}),e.jsx("span",{children:o("rightSidebar.insertLocalImage")})]}),g&&e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Et(!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(zi,{size:14}):e.jsx(ro,{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 d=Y===t;return e.jsx("button",{type:"button",role:"menuitemradio","aria-checked":d,onClick:()=>{A(t),Et(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${d?"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(Ft,{size:14})})]}),R&&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(ds,{size:12,className:"shrink-0"}),e.jsx("input",{"data-right-search":!0,type:"search",value:I,onChange:t=>V(t.target.value),placeholder:o(O==="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 ${oe?"text-[11px]":"text-[10px]"}`,children:[e.jsx("button",{type:"button",onClick:()=>yd("name"),"aria-pressed":O==="name",className:`rounded-full px-2 transition active:scale-95 ${oe?"py-1":"py-0.5"} ${O==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeName")}),e.jsx("button",{type:"button",onClick:()=>yd("content"),"aria-pressed":O==="content",className:`rounded-full px-2 transition active:scale-95 ${oe?"py-1":"py-0.5"} ${O==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeContent")})]}),I&&e.jsx("button",{type:"button",onClick:()=>V(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:e.jsx(Ft,{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(Sp,{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:ce,onChange:t=>me(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}),ce!=="."&&e.jsx("button",{type:"button",onClick:()=>me("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.resetSearchScope"),children:e.jsx(Ft,{size:11})})]}),e.jsxs("button",{type:"button",onClick:()=>T(t=>!t),"aria-expanded":Ce,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${Ce||Rs.length>0||ee||Le||Te?"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(jp,{size:13}),Rs.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:Rs.length})]})]}),Ce&&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:je,onChange:t=>$e(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}),je&&e.jsx("button",{type:"button",onClick:()=>$e(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.clearSearchExclude"),children:e.jsx(Ft,{size:11})})]}),O==="content"&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":o("rightSidebar.contentSearchOptions"),children:[[ee,()=>te(t=>!t),Ip,o("rightSidebar.matchCase")],[Le,()=>De(t=>!t),Jp,o("rightSidebar.matchWholeWord")],[Te,()=>lt(t=>!t),Gp,o("rightSidebar.useRegex")]].map(([t,i,d,y])=>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(d,{size:12}),y]},y))})]})]}),e.jsxs("div",{className:"mt-2 grid gap-0.5 rounded-md bg-surface-2 p-0.5",style:{gridTemplateColumns:`repeat(${(Qn?3:5)+(zr?1:0)}, minmax(0, 1fr))`},children:[!Qn&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:t=>es("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] ${At==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(xr,{size:12}),o("rightSidebar.tabGit")]}),e.jsxs("button",{type:"button",onClick:t=>es("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] ${At==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(nf,{size:12}),o("rightSidebar.tabChanges"),Ae.size>0?e.jsx("span",{className:"text-[10px] text-accent",children:Ae.size}):null]})]}),e.jsxs("button",{type:"button",onClick:t=>es("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] ${At==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(ll,{size:12}),o("rightSidebar.tabFiles")]}),e.jsxs("button",{type:"button",onClick:t=>es("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] ${bn?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Rp,{size:12}),o("architecture.tab")]}),e.jsxs("button",{type:"button",onClick:t=>es("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] ${pi?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Zm,{size:12}),o("rightSidebar.tabComputer")]}),zr&&e.jsxs("button",{type:"button",onClick:t=>es("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] ${At==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[e.jsx(Wd,{size:12}),o("rightSidebar.tabAndroid")]})]}),e.jsx("div",{className:"h-2"}),Jl&&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:Jl})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-surface",children:[e.jsx(os,{active:ct,mounted:sr,fallback:e.jsx(rl,{slow:!1}),children:()=>ke?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(au,{items:am,diffViewType:Jo,inlineMode:Xr,viewControls:m?Ts():void 0,renderPathReference:(t,i)=>za(Rn(t,ke.repoRoot??v),o(i==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle")),selectedKey:mh,onSelect:ca,emptyText:o("rightSidebar.noChanges"),mobile:oe,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o("rightSidebar.recentCommitsTitle"),headerMeta:`${ke.headRef??""}${ke.commits?.[0]?` · ${ke.commits[0]}`:""}`,onClose:()=>{Je(null),ca(null)},closeLabel:o("common.back"),wrap:bt,onToggleWrap:Va,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:oe?"stacked":"split",onInsertDiffReference:Ar,onReferenceCopied:gr,insertedReferenceKey:be,copiedReferenceKey:Ue,onClearAuditRecord:Ga})}):dr?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(au,{items:Ei,diffViewType:Jo,inlineMode:Xr,viewControls:m?Ts():void 0,renderPathReference:(t,i)=>{const d=xe?.comparisonRepos,y=d&&d.length>1?[...d].sort((k,j)=>j.label.length-k.label.length).find(k=>t===k.label||t.startsWith(`${k.label}/`)):void 0,w=y?t===y.label?y.repoRoot:Rn(t.slice(y.label.length+1),y.repoRoot):Rn(t,Fs?.repoRoot||v);return za(w,o(i==="file"?"rightSidebar.insertThisFile":"fileTree.insertRefTitle"))},selectedKey:zo,onSelect:on,emptyText:o(xe?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:oe,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o(xe?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:Fs?`${Fs.repoLabel} · ${Fs.branchName??"HEAD"} → ${Fs.baseRef}`:void 0,onClose:()=>{++Ot.current,M(!1),Bt(!1),Yt(null)},closeLabel:o("common.back"),wrap:bt,onToggleWrap:Va,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:oe?"stacked":"split",onInsertDiffReference:Ar,onReferenceCopied:gr,insertedReferenceKey:be,copiedReferenceKey:Ue,onClearAuditRecord:Ga,localOptions:xe?.comparisonRepos?.map(t=>({key:t.repoRoot,label:t.label,checked:t.includeUncommitted??xe.includeUncommitted??!1,disabled:!(t.canIncludeUncommitted??rs(t.repoRoot,t.head)),onChange:i=>{Li({refresh:!0,repoRoot:t.repoRoot,includeUncommitted:i})}})),onHunkGitAction:xe?.includeUncommitted?pm:void 0,error:K,actionsBusy:Fo>0,onRefresh:()=>{Li({refresh:!0})},refreshing:ws,refreshLabel:o("rightSidebar.branchAuditRefreshDiff"),refreshTitle:o("rightSidebar.branchAuditRefreshDiff"),walkthroughs:om,onWalkthroughNavigate:im,initialDetailScrollTop:xe&&Ze?vs[Ze]:void 0,onDetailScrollPositionChange:hm,externalSwiperRef:oe?Sc:void 0,onMobileSlideChange:oe?Go:void 0})}):e.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:sr&&v&&kn?e.jsx("div",{className:"px-3",children:Sm()}):hr?e.jsx(rl,{slow:hc}):hn?e.jsx(fo,{message:hn,onRetry:()=>{Jn()}}):Iu(we)?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):we?.available===!1?e.jsx(fo,{message:we.error??o("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{Jn()}}):v?e.jsx(rl,{slow:hc}):e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(v?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),e.jsx(os,{active:Lr,mounted:gh||Lr,children:()=>oe?e.jsxs(qu,{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=>{Pr.current=t,t.slideTo(Wo,0)},onSlideChange:t=>{if(Mr(t.activeIndex),Cs.current===t.activeIndex){Cs.current=null;return}t.activeIndex===0&&(Er(!1),Mt(null),f?.())},children:[e.jsx(cl,{className:"h-full min-h-0",children:e.jsxs("div",{ref:Kn,onScroll:Mc,onDragOver:Pa,onDragEnter:Pa,onDragLeave:Pc,onDrop:Lc,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[tc&&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()&&Md,e.jsx(Xd,{rootPath:ue??"",onFileSelect:Es,onPathReference:Wt,getReferenceText:Aa,onReferenceCopied:gr,insertedReferenceKey:be,copiedReferenceKey:Ue,onDirectoryRoot:Oc,onSearchFromDirectory:Uc,onDirectoryPinToggle:Hc,onFilePinToggle:zc,pinnedPaths:vn,selectedFilePath:at,query:Ie,searchRootPath:vc,searchOptions:wc,searchMode:O,onContentMatchSelect:bi,onDirectoryDropFiles:(t,i)=>Ms(i,t),revealDirectory:G,canOpenInFileBrowser:rc,onOpenInFileBrowser:$c})]})}),e.jsx(cl,{className:"h-full min-h-0",children:e.jsx("div",{className:"h-full overflow-hidden bg-surface",children:e.jsx(Lo,{filePath:ph||Wo===1?at:null,active:r&&Lr&&Wo===1,onInsertReference:Wt,onInsertText:or,onInsertFeature:or,onReviewReference:Dc,onReferenceCopied:gr,onClose:Rm,onDirectoryLinkOpen:Ed,isMobile:!0,lineRange:Pn,onLineRangeChange:Mt,insertedReferenceKey:be,copiedReferenceKey:Ue,scrollToLine:Sr,onScrollToLineHandled:()=>cr(null),markdownOutlineOpen:_,markdownOutlineCloseSignal:U,onOpenMarkdownOutline:C,onCloseMarkdownOutline:N,markdownImageLightboxOpen:E,markdownImageLightboxCloseSignal:B,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:S})})})]}):e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{ref:Kn,onScroll:Mc,onDragOver:Pa,onDragEnter:Pa,onDragLeave:Pc,onDrop:Lc,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:Qo},children:[tc&&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()&&Md,e.jsx(Xd,{rootPath:ue??"",onFileSelect:Es,onPathReference:Wt,getReferenceText:Aa,onReferenceCopied:gr,insertedReferenceKey:be,copiedReferenceKey:Ue,onDirectoryRoot:Oc,onSearchFromDirectory:Uc,onDirectoryPinToggle:Hc,onFilePinToggle:zc,pinnedPaths:vn,selectedFilePath:at,query:Ie,searchRootPath:vc,searchOptions:wc,searchMode:O,onContentMatchSelect:bi,onDirectoryDropFiles:(t,i)=>Ms(i,t),revealDirectory:G,canOpenInFileBrowser:rc,onOpenInFileBrowser:$c})]}),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:Mh,onPointerMove:$h,onPointerUp:Cc,onPointerCancel:Cc,onDoubleClick:()=>{Zo(vl),Dt(qs,vl)},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(Lo,{filePath:at,active:r&&Lr,onInsertReference:Wt,onInsertText:or,onInsertFeature:or,onReviewReference:Dc,onReferenceCopied:gr,onDirectoryLinkOpen:Ed,isMobile:!1,lineRange:Pn,onLineRangeChange:Mt,insertedReferenceKey:be,copiedReferenceKey:Ue,scrollToLine:Sr,onScrollToLineHandled:()=>cr(null),markdownOutlineOpen:_,markdownOutlineCloseSignal:U,onOpenMarkdownOutline:C,onCloseMarkdownOutline:N,markdownImageLightboxOpen:E,markdownImageLightboxCloseSignal:B,onOpenMarkdownImageLightbox:q,onCloseMarkdownImageLightbox:S})})]})}),e.jsx(os,{active:Tt,mounted:xh||Tt,children:()=>mi?e.jsx(Np,{}):oe?e.jsx(dl,{mobile:!0,backLabel:o("rightSidebar.backToChangeList"),externalSwiperRef:fi,onMobileSlideChange:Go,groups:er.length>0?ld():[],mode:$t,onModeChange:qa,selectedKey:at,scrollToKey:hd,scrollToKeyNonce:ka.nonce,compact:!1,collapsedDirectoryKeys:oa,onToggleDirectory:gd,onSelectFile:t=>{const i=jn.get(t.key);i&&Ka(vr(i))},renderLeading:cd,renderTrailing:t=>{const i=jn.get(t.key);return i?od(i):null},renderDirectoryTrailing:id,renderSubtitle:t=>{const i=jn.get(t.key);return i?ad(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:[Za&&e.jsx("div",{className:"mb-2",children:Za}),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:[er.length,"/",Ae.size]})]}),e.jsxs(ru,{actions:Ld,children:[nd(),t,m&&Ts(),Pd]},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&&Sn&&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(xr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:Oa?(t=>pd(t)):void 0,emptyContent:mi?null:hn&&Ae.size===0?e.jsx(fo,{message:hn,onRetry:()=>{Jn()}}):Ae.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):er.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(Zs,{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&&Ts(),e.jsxs("button",{type:"button",onClick:Va,"aria-pressed":bt,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 ${bt?"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(bt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),v&&e.jsx("button",{type:"button",onClick:()=>{Jn()},disabled:hr,"aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",children:e.jsx(go,{size:14,className:hr?"animate-spin":""})})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:dd,activePane:Tt,wrap:bt,diffViewType:Jo,inlineMode:Xr,diffOptions:wd,reloadKey:hs,renderStreamBadge:t=>e.jsx(Xs,{status:t}),onHunkGitAction:kd,onInsertDiffReference:Ar,onReferenceCopied:gr,insertedReferenceKey:be,copiedReferenceKey:Ue,onClearAuditRecord:Ga,onDetailScroll:Wa}):e.jsx(dl,{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:er.length>0?ld():[],mode:$t,onModeChange:qa,selectedKey:at,scrollToKey:hd,scrollToKeyNonce:ka.nonce,compact:!0,collapsedDirectoryKeys:oa,onToggleDirectory:gd,onSelectFile:t=>{const i=jn.get(t.key);i&&Ka(vr(i))},renderLeading:cd,renderTrailing:t=>{const i=jn.get(t.key);return i?od(i):null},renderDirectoryTrailing:id,renderSubtitle:t=>{const i=jn.get(t.key);return i?ad(i):null},aiContent:Oa?(t=>pd(t)):void 0,emptyContent:mi?null:hn&&Ae.size===0?e.jsx(fo,{message:hn,onRetry:()=>{Jn()}}):Ae.size===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):er.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:[Za&&e.jsx("div",{className:"mb-2",children:Za}),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:[er.length,"/",Ae.size]})})]}),e.jsxs(ru,{actions:Ld,children:[nd(),t,Ts(),e.jsxs("button",{type:"button",onClick:Va,"aria-pressed":bt,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 ${bt?"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(bt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),Pd]},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&&Sn&&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(xr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),files:dd,activePane:Tt,wrap:bt,diffViewType:Pt,inlineMode:Xr,diffOptions:wd,reloadKey:hs,renderStreamBadge:t=>e.jsx(Xs,{status:t}),onHunkGitAction:kd,onInsertDiffReference:Ar,onReferenceCopied:gr,insertedReferenceKey:be,copiedReferenceKey:Ue,onClearAuditRecord:Ga,onDetailScroll:Wa})}),e.jsx(os,{active:bn,mounted:Ph||r&&bn,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(Ob,{rootPath:v,active:r&&bn,onInsertPrompt:(t,i)=>or(t,`architecture:${v}`,i),renderSource:t=>v&&e.jsx(s0,{rootPath:v,file:t,active:r&&bn,isMobile:oe,onInsertReference:Wt,onInsertText:or,onReferenceCopied:gr,insertedReferenceKey:be,copiedReferenceKey:Ue},`${t.path}:${t.line??1}`),onOpenFile:t=>{v&&(fr("files"),Ht(null),bi(`${v.replace(/\/+$/,"")}/${t.path}`,t.line??1))}},v)})}),e.jsx(os,{active:pi,mounted:r&&pi,children:e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:o("computer.loading")}),children:e.jsx(Ub,{})})}),e.jsx(os,{active:Zn,mounted:Vo&&zr,children:vh?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:()=>{Oi.getState().setDock(Hi,null),mo({androidPanel:{docked:null}}).catch(()=>{})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:o("android.splitClose")})]}):e.jsx(Cp,{sessionId:n??null,onCloseTab:()=>Ec(!1),onInsertPrompt:t=>Ar("android-deps",t),onInsertFile:Fh,onRecordingComplete:Dh})})]}),r&&Ee&&e.jsx(Dg,{value:ye,collapsed:qt,autoCollapseAfterSend:W,focusRequest:Ct,insertError:fs?o("rightSidebar.contextDraftInsertFailed"):null,onChange:t=>{$n(!1),Xe(t)},onCollapsedChange:jt,onAutoCollapseAfterSendChange:re,onDisable:()=>He(!1),onClear:()=>Xe(""),onInsert:()=>Fc(!1),onInsertAndSend:()=>Fc(!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"),send:o("rightSidebar.contextDraftSend"),appended:o("rightSidebar.contextDraftAppended"),resize:o("rightSidebar.contextDraftResize"),autoCollapseAfterSend:o("rightSidebar.contextDraftAutoCollapseAfterSend"),characterCount:t=>o("rightSidebar.contextDraftCharacterCount",{count:t})}}),Xh(),wt&&typeof document<"u"&&kr.createPortal(e.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>ln(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:wt.kind==="restore"?o("rightSidebar.confirmRestoreTitle"):o("rightSidebar.confirmStashAllTitle")}),e.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:wt.kind==="restore"?o("rightSidebar.confirmRestoreDescription",{path:Wu(wt.file.absolutePath,v)}):o("rightSidebar.confirmStashAllDescription")}),wt.kind==="restore"&&e.jsx("input",{value:wt.phrase,onChange:t=>ln({...wt,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:()=>ln(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:!!Oe||wt.kind==="restore"&&wt.phrase.trim()!==o("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(wt.kind==="restore"){const t=vt(wt.file,v);if(!t)return;kt({action:"restore-worktree-file",cwd:t,paths:[wt.file.path],confirm:{acknowledged:!0,phrase:wt.phrase}},o("rightSidebar.restoreFile"),al(wt.file))}else{const t=wt.repoRoot??v;if(!t)return;kt({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 ${wt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:o(Oe?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const b0=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:Lo,MarkdownImageLightbox:rh,MarkdownPreview:nh,RightSidebar:a0,__testParseMarkdownListBlock:kx,buildMarkdownPreviewBlocks:Lx,buildMarkdownPreviewRenderResult:Ol,collectKnownGitRepoRoots:Cf,computeMarkdownImageDisplayBox:Bf,getMarkdownHeadingOutline:th,getMarkdownHeadingPathAtLine:eh,getNextMarkdownPreviewLineRange:_x,isSvgImageSrc:aa,mountRightSidebarRepoPickerOverlay:mf,replaceGitRepositorySnapshot:ch,resolveMarkdownLocalLinkTarget:Tl,resolveRightSidebarDiffViewType:Rf,shouldCloseMarkdownImageLightboxDrag:Jf,showsGitRepoGroupHeader:wl},Symbol.toStringTag,{value:"Module"}));export{hl as E,b0 as R,qp as S,Fp as a,Lx as b,hg as c,dg as i,cg as l,g0 as m};