termdock 1.4.251 → 1.4.253

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 (312) hide show
  1. package/dist/client/assets/App-DrWO8SzR.js +155 -0
  2. package/dist/client/assets/App-DrWO8SzR.js.br +0 -0
  3. package/dist/client/assets/App-DrWO8SzR.js.gz +0 -0
  4. package/dist/client/assets/{ChangeWalkthroughPanel-CFp8sYSs.js → ChangeWalkthroughPanel-SRnHOVxr.js} +1 -1
  5. package/dist/client/assets/ChangeWalkthroughPanel-SRnHOVxr.js.br +0 -0
  6. package/dist/client/assets/ChangeWalkthroughPanel-SRnHOVxr.js.gz +0 -0
  7. package/dist/client/assets/{DagPlayground-DXCPvHTB.js → DagPlayground-BSK1bSvc.js} +1 -1
  8. package/dist/client/assets/DagPlayground-BSK1bSvc.js.br +0 -0
  9. package/dist/client/assets/DagPlayground-BSK1bSvc.js.gz +0 -0
  10. package/dist/client/assets/{DiffLab-D1ZKqZCI.js → DiffLab-Hhz9a7cN.js} +1 -1
  11. package/dist/client/assets/DiffLab-Hhz9a7cN.js.br +0 -0
  12. package/dist/client/assets/DiffLab-Hhz9a7cN.js.gz +0 -0
  13. package/dist/client/assets/{DiffReview-CxN2B2DZ.js → DiffReview-oF67NnEG.js} +1 -1
  14. package/dist/client/assets/DiffReview-oF67NnEG.js.br +0 -0
  15. package/dist/client/assets/DiffReview-oF67NnEG.js.gz +0 -0
  16. package/dist/client/assets/{DiffReviewLab-CqDEDM38.js → DiffReviewLab-BeOhsid3.js} +1 -1
  17. package/dist/client/assets/DiffReviewLab-BeOhsid3.js.br +0 -0
  18. package/dist/client/assets/DiffReviewLab-BeOhsid3.js.gz +0 -0
  19. package/dist/client/assets/{DiffViewer-CMl5zjR1.js → DiffViewer-CF9Hk9Y7.js} +1 -1
  20. package/dist/client/assets/DiffViewer-CF9Hk9Y7.js.br +0 -0
  21. package/dist/client/assets/DiffViewer-CF9Hk9Y7.js.gz +0 -0
  22. package/dist/client/assets/{ModelPreview-8jvTuVib.js → ModelPreview-BeLucwvr.js} +2 -2
  23. package/dist/client/assets/ModelPreview-BeLucwvr.js.br +0 -0
  24. package/dist/client/assets/ModelPreview-BeLucwvr.js.gz +0 -0
  25. package/dist/client/assets/RightSidebar-BRiyLLAy.js +1678 -0
  26. package/dist/client/assets/RightSidebar-BRiyLLAy.js.br +0 -0
  27. package/dist/client/assets/RightSidebar-BRiyLLAy.js.gz +0 -0
  28. package/dist/client/assets/{abnfDiagram-VCTEODGH-CzKfPUbe.js → abnfDiagram-VCTEODGH-Fp1hQumv.js} +1 -1
  29. package/dist/client/assets/abnfDiagram-VCTEODGH-Fp1hQumv.js.br +0 -0
  30. package/dist/client/assets/abnfDiagram-VCTEODGH-Fp1hQumv.js.gz +0 -0
  31. package/dist/client/assets/{app-CB-4opkv.js → app-DpE58n6W.js} +3 -3
  32. package/dist/client/assets/app-DpE58n6W.js.br +0 -0
  33. package/dist/client/assets/app-DpE58n6W.js.gz +0 -0
  34. package/dist/client/assets/{arc-CQ5ZaMf3.js → arc-BzaUU0ea.js} +1 -1
  35. package/dist/client/assets/arc-BzaUU0ea.js.br +0 -0
  36. package/dist/client/assets/arc-BzaUU0ea.js.gz +0 -0
  37. package/dist/client/assets/{architectureDiagram-5GKGNRK7-Bb7-cZNm.js → architectureDiagram-5GKGNRK7-CfI7xMq8.js} +1 -1
  38. package/dist/client/assets/architectureDiagram-5GKGNRK7-CfI7xMq8.js.br +0 -0
  39. package/dist/client/assets/architectureDiagram-5GKGNRK7-CfI7xMq8.js.gz +0 -0
  40. package/dist/client/assets/{blockDiagram-I7D4REHJ-CHY89PgO.js → blockDiagram-I7D4REHJ-CrAZc61A.js} +1 -1
  41. package/dist/client/assets/blockDiagram-I7D4REHJ-CrAZc61A.js.br +0 -0
  42. package/dist/client/assets/blockDiagram-I7D4REHJ-CrAZc61A.js.gz +0 -0
  43. package/dist/client/assets/{c4Diagram-7LVT6UL2-ByK6qNMq.js → c4Diagram-7LVT6UL2-c3TdWrwZ.js} +1 -1
  44. package/dist/client/assets/c4Diagram-7LVT6UL2-c3TdWrwZ.js.br +0 -0
  45. package/dist/client/assets/c4Diagram-7LVT6UL2-c3TdWrwZ.js.gz +0 -0
  46. package/dist/client/assets/channel-Cxh4b1ue.js +1 -0
  47. package/dist/client/assets/{chunk-2Q5K7J3B-C4WoozYw.js → chunk-2Q5K7J3B-BcGDXOIq.js} +1 -1
  48. package/dist/client/assets/{chunk-5VM5RSS4-BG6aVzv5.js → chunk-5VM5RSS4-Mi1YBwXL.js} +1 -1
  49. package/dist/client/assets/{chunk-F27PBJKO-DjGX-4Gg.js → chunk-F27PBJKO-C_Hun79O.js} +1 -1
  50. package/dist/client/assets/chunk-F27PBJKO-C_Hun79O.js.br +0 -0
  51. package/dist/client/assets/chunk-F27PBJKO-C_Hun79O.js.gz +0 -0
  52. package/dist/client/assets/{chunk-IMKFNOWR-CX-L3gr_.js → chunk-IMKFNOWR-zihn5TZV.js} +1 -1
  53. package/dist/client/assets/chunk-IMKFNOWR-zihn5TZV.js.br +0 -0
  54. package/dist/client/assets/chunk-IMKFNOWR-zihn5TZV.js.gz +0 -0
  55. package/dist/client/assets/{chunk-JWPE2WC7-CO-_w1y_.js → chunk-JWPE2WC7-4AidUYVs.js} +1 -1
  56. package/dist/client/assets/{chunk-POPQ4Y6H-DeUXTlEW.js → chunk-POPQ4Y6H-Cv17ZtgL.js} +1 -1
  57. package/dist/client/assets/{chunk-SVP7TREG-BG8K-s3k.js → chunk-SVP7TREG-TiFSufum.js} +1 -1
  58. package/dist/client/assets/chunk-SVP7TREG-TiFSufum.js.br +0 -0
  59. package/dist/client/assets/chunk-SVP7TREG-TiFSufum.js.gz +0 -0
  60. package/dist/client/assets/{chunk-TICWLB2K-BVRmzepH.js → chunk-TICWLB2K-cenYcmKy.js} +1 -1
  61. package/dist/client/assets/chunk-TICWLB2K-cenYcmKy.js.br +0 -0
  62. package/dist/client/assets/chunk-TICWLB2K-cenYcmKy.js.gz +0 -0
  63. package/dist/client/assets/{chunk-XXDRQBXY-Dfp9NPuM.js → chunk-XXDRQBXY-AiZKK-65.js} +1 -1
  64. package/dist/client/assets/classDiagram-ZZMXUADV-DoFIvEq6.js +1 -0
  65. package/dist/client/assets/classDiagram-v2-VYDZK3BY-DoFIvEq6.js +1 -0
  66. package/dist/client/assets/{cose-bilkent-JH36ORCC-VpaNog3Q.js → cose-bilkent-JH36ORCC-DlGbpz7J.js} +1 -1
  67. package/dist/client/assets/cose-bilkent-JH36ORCC-DlGbpz7J.js.br +0 -0
  68. package/dist/client/assets/cose-bilkent-JH36ORCC-DlGbpz7J.js.gz +0 -0
  69. package/dist/client/assets/{cynefin-OW5HDTMX-Rn84lmSY.js → cynefin-OW5HDTMX-B9fOxJps.js} +1 -1
  70. package/dist/client/assets/cynefin-OW5HDTMX-B9fOxJps.js.br +0 -0
  71. package/dist/client/assets/{cynefin-OW5HDTMX-Rn84lmSY.js.gz → cynefin-OW5HDTMX-B9fOxJps.js.gz} +0 -0
  72. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-Cc6tlVT4.js → cynefinDiagram-5FMLGOSQ-Zz7LC4Uc.js} +1 -1
  73. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Zz7LC4Uc.js.br +0 -0
  74. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Zz7LC4Uc.js.gz +0 -0
  75. package/dist/client/assets/{dagre-GXQ25YYZ-BhYis7tJ.js → dagre-GXQ25YYZ-BByZb3WY.js} +1 -1
  76. package/dist/client/assets/dagre-GXQ25YYZ-BByZb3WY.js.br +0 -0
  77. package/dist/client/assets/dagre-GXQ25YYZ-BByZb3WY.js.gz +0 -0
  78. package/dist/client/assets/{diagram-S7CK7UJ4-BQ_ItPfn.js → diagram-S7CK7UJ4-Cf-1vPRf.js} +1 -1
  79. package/dist/client/assets/diagram-S7CK7UJ4-Cf-1vPRf.js.br +0 -0
  80. package/dist/client/assets/diagram-S7CK7UJ4-Cf-1vPRf.js.gz +0 -0
  81. package/dist/client/assets/{diagram-UQ7AKVKN-ByOkVSHb.js → diagram-UQ7AKVKN-BLZCEBZS.js} +1 -1
  82. package/dist/client/assets/diagram-UQ7AKVKN-BLZCEBZS.js.br +0 -0
  83. package/dist/client/assets/diagram-UQ7AKVKN-BLZCEBZS.js.gz +0 -0
  84. package/dist/client/assets/{diagram-VSXAHHWV-DJKyc2g9.js → diagram-VSXAHHWV-DQD7sWkb.js} +1 -1
  85. package/dist/client/assets/diagram-VSXAHHWV-DQD7sWkb.js.br +0 -0
  86. package/dist/client/assets/diagram-VSXAHHWV-DQD7sWkb.js.gz +0 -0
  87. package/dist/client/assets/{diagram-VX7I27RA-C7cMtNzB.js → diagram-VX7I27RA-CUz-JS6A.js} +1 -1
  88. package/dist/client/assets/diagram-VX7I27RA-CUz-JS6A.js.br +0 -0
  89. package/dist/client/assets/diagram-VX7I27RA-CUz-JS6A.js.gz +0 -0
  90. package/dist/client/assets/{diagram-Z3DM3KII-D1gqtHda.js → diagram-Z3DM3KII-EzoT--tH.js} +1 -1
  91. package/dist/client/assets/diagram-Z3DM3KII-EzoT--tH.js.br +0 -0
  92. package/dist/client/assets/diagram-Z3DM3KII-EzoT--tH.js.gz +0 -0
  93. package/dist/client/assets/{ebnfDiagram-PWID7BFC-CLa1XwOf.js → ebnfDiagram-PWID7BFC-YHI9eQCj.js} +1 -1
  94. package/dist/client/assets/ebnfDiagram-PWID7BFC-YHI9eQCj.js.br +0 -0
  95. package/dist/client/assets/ebnfDiagram-PWID7BFC-YHI9eQCj.js.gz +0 -0
  96. package/dist/client/assets/{erDiagram-RLTQ6QDP-DGHXAzSZ.js → erDiagram-RLTQ6QDP-CMi1dEG0.js} +1 -1
  97. package/dist/client/assets/erDiagram-RLTQ6QDP-CMi1dEG0.js.br +0 -0
  98. package/dist/client/assets/erDiagram-RLTQ6QDP-CMi1dEG0.js.gz +0 -0
  99. package/dist/client/assets/{flowDiagram-HODETNUW-BU-t-gVI.js → flowDiagram-HODETNUW-BIBnA6do.js} +1 -1
  100. package/dist/client/assets/flowDiagram-HODETNUW-BIBnA6do.js.br +0 -0
  101. package/dist/client/assets/flowDiagram-HODETNUW-BIBnA6do.js.gz +0 -0
  102. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-C-rci8Re.js → ganttDiagram-EL5Y4UJY-Brtjaq_D.js} +1 -1
  103. package/dist/client/assets/ganttDiagram-EL5Y4UJY-Brtjaq_D.js.br +0 -0
  104. package/dist/client/assets/ganttDiagram-EL5Y4UJY-Brtjaq_D.js.gz +0 -0
  105. package/dist/client/assets/{gestureArbiter-DMxqtqCP.js → gestureArbiter-D1QRbbkp.js} +1 -1
  106. package/dist/client/assets/gestureArbiter-D1QRbbkp.js.br +0 -0
  107. package/dist/client/assets/gestureArbiter-D1QRbbkp.js.gz +0 -0
  108. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-D76ERESf.js → gitGraphDiagram-WWUBYQGX-DnljfTHY.js} +1 -1
  109. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DnljfTHY.js.br +0 -0
  110. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-DnljfTHY.js.gz +0 -0
  111. package/dist/client/assets/{infoDiagram-27XIBGKW-CFdGqdko.js → infoDiagram-27XIBGKW-DShVF244.js} +1 -1
  112. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-CvHg03mP.js → ishikawaDiagram-5VMMS53U-CnFoW17W.js} +1 -1
  113. package/dist/client/assets/ishikawaDiagram-5VMMS53U-CnFoW17W.js.br +0 -0
  114. package/dist/client/assets/ishikawaDiagram-5VMMS53U-CnFoW17W.js.gz +0 -0
  115. package/dist/client/assets/{journeyDiagram-3NMN7TZE-DsL7RkLK.js → journeyDiagram-3NMN7TZE-BrSncxhh.js} +1 -1
  116. package/dist/client/assets/journeyDiagram-3NMN7TZE-BrSncxhh.js.br +0 -0
  117. package/dist/client/assets/journeyDiagram-3NMN7TZE-BrSncxhh.js.gz +0 -0
  118. package/dist/client/assets/{kanban-definition-UXKFOSKX-DR2rrFHd.js → kanban-definition-UXKFOSKX-C8VCZRjq.js} +1 -1
  119. package/dist/client/assets/kanban-definition-UXKFOSKX-C8VCZRjq.js.br +0 -0
  120. package/dist/client/assets/kanban-definition-UXKFOSKX-C8VCZRjq.js.gz +0 -0
  121. package/dist/client/assets/{layout-D1xpvIio.js → layout-6u43xk0y.js} +1 -1
  122. package/dist/client/assets/layout-6u43xk0y.js.br +0 -0
  123. package/dist/client/assets/layout-6u43xk0y.js.gz +0 -0
  124. package/dist/client/assets/{linear-DjMx7fRX.js → linear-C305stEx.js} +1 -1
  125. package/dist/client/assets/linear-C305stEx.js.br +0 -0
  126. package/dist/client/assets/linear-C305stEx.js.gz +0 -0
  127. package/dist/client/assets/{mermaid.core-CUDRfRRW.js → mermaid.core-CucJbLGB.js} +5 -5
  128. package/dist/client/assets/mermaid.core-CucJbLGB.js.br +0 -0
  129. package/dist/client/assets/mermaid.core-CucJbLGB.js.gz +0 -0
  130. package/dist/client/assets/{mindmap-definition-YA3MSWOX-Bpt6bCgS.js → mindmap-definition-YA3MSWOX-MAODSSZq.js} +1 -1
  131. package/dist/client/assets/mindmap-definition-YA3MSWOX-MAODSSZq.js.br +0 -0
  132. package/dist/client/assets/mindmap-definition-YA3MSWOX-MAODSSZq.js.gz +0 -0
  133. package/dist/client/assets/{passwordBootstrap-DBbCwJf8.js → passwordBootstrap-BgfczIXq.js} +1 -1
  134. package/dist/client/assets/passwordBootstrap-BgfczIXq.js.br +0 -0
  135. package/dist/client/assets/passwordBootstrap-BgfczIXq.js.gz +0 -0
  136. package/dist/client/assets/{pegDiagram-XKGWAZYB-Du3LaHYA.js → pegDiagram-XKGWAZYB-Dnt1-5zP.js} +1 -1
  137. package/dist/client/assets/pegDiagram-XKGWAZYB-Dnt1-5zP.js.br +0 -0
  138. package/dist/client/assets/pegDiagram-XKGWAZYB-Dnt1-5zP.js.gz +0 -0
  139. package/dist/client/assets/{pieDiagram-E7YTZNPT-Km9TCk2S.js → pieDiagram-E7YTZNPT-Do8VLG4J.js} +1 -1
  140. package/dist/client/assets/pieDiagram-E7YTZNPT-Do8VLG4J.js.br +0 -0
  141. package/dist/client/assets/pieDiagram-E7YTZNPT-Do8VLG4J.js.gz +0 -0
  142. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-DtfTmhmo.js → quadrantDiagram-AXDQQJYC-CeN87cKo.js} +1 -1
  143. package/dist/client/assets/quadrantDiagram-AXDQQJYC-CeN87cKo.js.br +0 -0
  144. package/dist/client/assets/quadrantDiagram-AXDQQJYC-CeN87cKo.js.gz +0 -0
  145. package/dist/client/assets/{railroadDiagram-O6MQD6OU-DE-Be_FD.js → railroadDiagram-O6MQD6OU-Cpu7senu.js} +1 -1
  146. package/dist/client/assets/railroadDiagram-O6MQD6OU-Cpu7senu.js.br +0 -0
  147. package/dist/client/assets/railroadDiagram-O6MQD6OU-Cpu7senu.js.gz +0 -0
  148. package/dist/client/assets/{referenceLongPress-Cy1D2tMf.js → referenceLongPress-_PnWpmfH.js} +1 -1
  149. package/dist/client/assets/referenceLongPress-_PnWpmfH.js.br +0 -0
  150. package/dist/client/assets/referenceLongPress-_PnWpmfH.js.gz +0 -0
  151. package/dist/client/assets/{requirementDiagram-BXWQKSXE-Jww6CTln.js → requirementDiagram-BXWQKSXE-DXks9Yy3.js} +1 -1
  152. package/dist/client/assets/requirementDiagram-BXWQKSXE-DXks9Yy3.js.br +0 -0
  153. package/dist/client/assets/requirementDiagram-BXWQKSXE-DXks9Yy3.js.gz +0 -0
  154. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-BMTOO0qr.js → sankeyDiagram-P5KCCOFB-DLmZWZmg.js} +1 -1
  155. package/dist/client/assets/sankeyDiagram-P5KCCOFB-DLmZWZmg.js.br +0 -0
  156. package/dist/client/assets/sankeyDiagram-P5KCCOFB-DLmZWZmg.js.gz +0 -0
  157. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-DEKQAuYp.js → sequenceDiagram-WJ2MYXX4-BzuivggV.js} +1 -1
  158. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BzuivggV.js.br +0 -0
  159. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BzuivggV.js.gz +0 -0
  160. package/dist/client/assets/{sizeCapture-INFHLROL-CQmsOE8y.js → sizeCapture-INFHLROL-BpJOGCIF.js} +1 -1
  161. package/dist/client/assets/sizeCapture-INFHLROL-BpJOGCIF.js.br +0 -0
  162. package/dist/client/assets/sizeCapture-INFHLROL-BpJOGCIF.js.gz +0 -0
  163. package/dist/client/assets/{sparkles-AeZLuPvn.js → sparkles-IHI8pmlf.js} +1 -1
  164. package/dist/client/assets/{stateDiagram-D77RDMKH-C9Us69am.js → stateDiagram-D77RDMKH-2PXIVDNy.js} +1 -1
  165. package/dist/client/assets/stateDiagram-D77RDMKH-2PXIVDNy.js.br +0 -0
  166. package/dist/client/assets/stateDiagram-D77RDMKH-2PXIVDNy.js.gz +0 -0
  167. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-D_Wa3SgS.js +1 -0
  168. package/dist/client/assets/{swimlanes-42K2YHIH-B2Ipm5e0.js → swimlanes-42K2YHIH-DthmCguM.js} +1 -1
  169. package/dist/client/assets/swimlanes-42K2YHIH-DthmCguM.js.br +0 -0
  170. package/dist/client/assets/swimlanes-42K2YHIH-DthmCguM.js.gz +0 -0
  171. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-BxXQu6ea.js +8 -0
  172. package/dist/client/assets/{timeline-definition-24CTP7MA-BBifYxL0.js → timeline-definition-24CTP7MA-CryKpzi1.js} +1 -1
  173. package/dist/client/assets/timeline-definition-24CTP7MA-CryKpzi1.js.br +0 -0
  174. package/dist/client/assets/timeline-definition-24CTP7MA-CryKpzi1.js.gz +0 -0
  175. package/dist/client/assets/{triangle-alert-CeTsz1ro.js → triangle-alert-B6E8JrsV.js} +1 -1
  176. package/dist/client/assets/{vennDiagram-4TSXK5OY-S4M20P5A.js → vennDiagram-4TSXK5OY-DAvB7awf.js} +1 -1
  177. package/dist/client/assets/vennDiagram-4TSXK5OY-DAvB7awf.js.br +0 -0
  178. package/dist/client/assets/vennDiagram-4TSXK5OY-DAvB7awf.js.gz +0 -0
  179. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-xbeBkQY_.js → wardleyDiagram-VM6X3IG4-Cph9cg0D.js} +1 -1
  180. package/dist/client/assets/wardleyDiagram-VM6X3IG4-Cph9cg0D.js.br +0 -0
  181. package/dist/client/assets/wardleyDiagram-VM6X3IG4-Cph9cg0D.js.gz +0 -0
  182. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-tgPDPocq.js → xychartDiagram-S5SC5T6Z-CWvKdhp_.js} +1 -1
  183. package/dist/client/assets/xychartDiagram-S5SC5T6Z-CWvKdhp_.js.br +0 -0
  184. package/dist/client/assets/xychartDiagram-S5SC5T6Z-CWvKdhp_.js.gz +0 -0
  185. package/dist/client/index.html +1 -1
  186. package/dist/client/index.html.br +0 -0
  187. package/dist/client/index.html.gz +0 -0
  188. package/dist/client/sw.js +1 -1
  189. package/dist/client/sw.js.br +0 -0
  190. package/dist/client/sw.js.gz +0 -0
  191. package/package.json +1 -1
  192. package/runtime-manifest.json +2 -2
  193. package/dist/client/assets/App-SGauuiZa.js +0 -155
  194. package/dist/client/assets/App-SGauuiZa.js.br +0 -0
  195. package/dist/client/assets/App-SGauuiZa.js.gz +0 -0
  196. package/dist/client/assets/ChangeWalkthroughPanel-CFp8sYSs.js.br +0 -0
  197. package/dist/client/assets/ChangeWalkthroughPanel-CFp8sYSs.js.gz +0 -0
  198. package/dist/client/assets/DagPlayground-DXCPvHTB.js.br +0 -0
  199. package/dist/client/assets/DagPlayground-DXCPvHTB.js.gz +0 -0
  200. package/dist/client/assets/DiffLab-D1ZKqZCI.js.br +0 -0
  201. package/dist/client/assets/DiffLab-D1ZKqZCI.js.gz +0 -0
  202. package/dist/client/assets/DiffReview-CxN2B2DZ.js.br +0 -0
  203. package/dist/client/assets/DiffReview-CxN2B2DZ.js.gz +0 -0
  204. package/dist/client/assets/DiffReviewLab-CqDEDM38.js.br +0 -0
  205. package/dist/client/assets/DiffReviewLab-CqDEDM38.js.gz +0 -0
  206. package/dist/client/assets/DiffViewer-CMl5zjR1.js.br +0 -0
  207. package/dist/client/assets/DiffViewer-CMl5zjR1.js.gz +0 -0
  208. package/dist/client/assets/ModelPreview-8jvTuVib.js.br +0 -0
  209. package/dist/client/assets/ModelPreview-8jvTuVib.js.gz +0 -0
  210. package/dist/client/assets/RightSidebar-gcOKWecr.js +0 -1678
  211. package/dist/client/assets/RightSidebar-gcOKWecr.js.br +0 -0
  212. package/dist/client/assets/RightSidebar-gcOKWecr.js.gz +0 -0
  213. package/dist/client/assets/abnfDiagram-VCTEODGH-CzKfPUbe.js.br +0 -0
  214. package/dist/client/assets/abnfDiagram-VCTEODGH-CzKfPUbe.js.gz +0 -0
  215. package/dist/client/assets/app-CB-4opkv.js.br +0 -0
  216. package/dist/client/assets/app-CB-4opkv.js.gz +0 -0
  217. package/dist/client/assets/arc-CQ5ZaMf3.js.br +0 -0
  218. package/dist/client/assets/arc-CQ5ZaMf3.js.gz +0 -0
  219. package/dist/client/assets/architectureDiagram-5GKGNRK7-Bb7-cZNm.js.br +0 -0
  220. package/dist/client/assets/architectureDiagram-5GKGNRK7-Bb7-cZNm.js.gz +0 -0
  221. package/dist/client/assets/blockDiagram-I7D4REHJ-CHY89PgO.js.br +0 -0
  222. package/dist/client/assets/blockDiagram-I7D4REHJ-CHY89PgO.js.gz +0 -0
  223. package/dist/client/assets/c4Diagram-7LVT6UL2-ByK6qNMq.js.br +0 -0
  224. package/dist/client/assets/c4Diagram-7LVT6UL2-ByK6qNMq.js.gz +0 -0
  225. package/dist/client/assets/channel-DWlrrXR3.js +0 -1
  226. package/dist/client/assets/chunk-F27PBJKO-DjGX-4Gg.js.br +0 -0
  227. package/dist/client/assets/chunk-F27PBJKO-DjGX-4Gg.js.gz +0 -0
  228. package/dist/client/assets/chunk-IMKFNOWR-CX-L3gr_.js.br +0 -0
  229. package/dist/client/assets/chunk-IMKFNOWR-CX-L3gr_.js.gz +0 -0
  230. package/dist/client/assets/chunk-SVP7TREG-BG8K-s3k.js.br +0 -0
  231. package/dist/client/assets/chunk-SVP7TREG-BG8K-s3k.js.gz +0 -0
  232. package/dist/client/assets/chunk-TICWLB2K-BVRmzepH.js.br +0 -0
  233. package/dist/client/assets/chunk-TICWLB2K-BVRmzepH.js.gz +0 -0
  234. package/dist/client/assets/classDiagram-ZZMXUADV-CM4F5RCF.js +0 -1
  235. package/dist/client/assets/classDiagram-v2-VYDZK3BY-CM4F5RCF.js +0 -1
  236. package/dist/client/assets/cose-bilkent-JH36ORCC-VpaNog3Q.js.br +0 -0
  237. package/dist/client/assets/cose-bilkent-JH36ORCC-VpaNog3Q.js.gz +0 -0
  238. package/dist/client/assets/cynefin-OW5HDTMX-Rn84lmSY.js.br +0 -0
  239. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Cc6tlVT4.js.br +0 -0
  240. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Cc6tlVT4.js.gz +0 -0
  241. package/dist/client/assets/dagre-GXQ25YYZ-BhYis7tJ.js.br +0 -0
  242. package/dist/client/assets/dagre-GXQ25YYZ-BhYis7tJ.js.gz +0 -0
  243. package/dist/client/assets/diagram-S7CK7UJ4-BQ_ItPfn.js.br +0 -0
  244. package/dist/client/assets/diagram-S7CK7UJ4-BQ_ItPfn.js.gz +0 -0
  245. package/dist/client/assets/diagram-UQ7AKVKN-ByOkVSHb.js.br +0 -0
  246. package/dist/client/assets/diagram-UQ7AKVKN-ByOkVSHb.js.gz +0 -0
  247. package/dist/client/assets/diagram-VSXAHHWV-DJKyc2g9.js.br +0 -0
  248. package/dist/client/assets/diagram-VSXAHHWV-DJKyc2g9.js.gz +0 -0
  249. package/dist/client/assets/diagram-VX7I27RA-C7cMtNzB.js.br +0 -0
  250. package/dist/client/assets/diagram-VX7I27RA-C7cMtNzB.js.gz +0 -0
  251. package/dist/client/assets/diagram-Z3DM3KII-D1gqtHda.js.br +0 -0
  252. package/dist/client/assets/diagram-Z3DM3KII-D1gqtHda.js.gz +0 -0
  253. package/dist/client/assets/ebnfDiagram-PWID7BFC-CLa1XwOf.js.br +0 -0
  254. package/dist/client/assets/ebnfDiagram-PWID7BFC-CLa1XwOf.js.gz +0 -0
  255. package/dist/client/assets/erDiagram-RLTQ6QDP-DGHXAzSZ.js.br +0 -0
  256. package/dist/client/assets/erDiagram-RLTQ6QDP-DGHXAzSZ.js.gz +0 -0
  257. package/dist/client/assets/flowDiagram-HODETNUW-BU-t-gVI.js.br +0 -0
  258. package/dist/client/assets/flowDiagram-HODETNUW-BU-t-gVI.js.gz +0 -0
  259. package/dist/client/assets/ganttDiagram-EL5Y4UJY-C-rci8Re.js.br +0 -0
  260. package/dist/client/assets/ganttDiagram-EL5Y4UJY-C-rci8Re.js.gz +0 -0
  261. package/dist/client/assets/gestureArbiter-DMxqtqCP.js.br +0 -0
  262. package/dist/client/assets/gestureArbiter-DMxqtqCP.js.gz +0 -0
  263. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-D76ERESf.js.br +0 -0
  264. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-D76ERESf.js.gz +0 -0
  265. package/dist/client/assets/ishikawaDiagram-5VMMS53U-CvHg03mP.js.br +0 -0
  266. package/dist/client/assets/ishikawaDiagram-5VMMS53U-CvHg03mP.js.gz +0 -0
  267. package/dist/client/assets/journeyDiagram-3NMN7TZE-DsL7RkLK.js.br +0 -0
  268. package/dist/client/assets/journeyDiagram-3NMN7TZE-DsL7RkLK.js.gz +0 -0
  269. package/dist/client/assets/kanban-definition-UXKFOSKX-DR2rrFHd.js.br +0 -0
  270. package/dist/client/assets/kanban-definition-UXKFOSKX-DR2rrFHd.js.gz +0 -0
  271. package/dist/client/assets/layout-D1xpvIio.js.br +0 -0
  272. package/dist/client/assets/layout-D1xpvIio.js.gz +0 -0
  273. package/dist/client/assets/linear-DjMx7fRX.js.br +0 -0
  274. package/dist/client/assets/linear-DjMx7fRX.js.gz +0 -0
  275. package/dist/client/assets/mermaid.core-CUDRfRRW.js.br +0 -0
  276. package/dist/client/assets/mermaid.core-CUDRfRRW.js.gz +0 -0
  277. package/dist/client/assets/mindmap-definition-YA3MSWOX-Bpt6bCgS.js.br +0 -0
  278. package/dist/client/assets/mindmap-definition-YA3MSWOX-Bpt6bCgS.js.gz +0 -0
  279. package/dist/client/assets/passwordBootstrap-DBbCwJf8.js.br +0 -0
  280. package/dist/client/assets/passwordBootstrap-DBbCwJf8.js.gz +0 -0
  281. package/dist/client/assets/pegDiagram-XKGWAZYB-Du3LaHYA.js.br +0 -0
  282. package/dist/client/assets/pegDiagram-XKGWAZYB-Du3LaHYA.js.gz +0 -0
  283. package/dist/client/assets/pieDiagram-E7YTZNPT-Km9TCk2S.js.br +0 -0
  284. package/dist/client/assets/pieDiagram-E7YTZNPT-Km9TCk2S.js.gz +0 -0
  285. package/dist/client/assets/quadrantDiagram-AXDQQJYC-DtfTmhmo.js.br +0 -0
  286. package/dist/client/assets/quadrantDiagram-AXDQQJYC-DtfTmhmo.js.gz +0 -0
  287. package/dist/client/assets/railroadDiagram-O6MQD6OU-DE-Be_FD.js.br +0 -0
  288. package/dist/client/assets/railroadDiagram-O6MQD6OU-DE-Be_FD.js.gz +0 -0
  289. package/dist/client/assets/referenceLongPress-Cy1D2tMf.js.br +0 -0
  290. package/dist/client/assets/referenceLongPress-Cy1D2tMf.js.gz +0 -0
  291. package/dist/client/assets/requirementDiagram-BXWQKSXE-Jww6CTln.js.br +0 -0
  292. package/dist/client/assets/requirementDiagram-BXWQKSXE-Jww6CTln.js.gz +0 -0
  293. package/dist/client/assets/sankeyDiagram-P5KCCOFB-BMTOO0qr.js.br +0 -0
  294. package/dist/client/assets/sankeyDiagram-P5KCCOFB-BMTOO0qr.js.gz +0 -0
  295. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DEKQAuYp.js.br +0 -0
  296. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DEKQAuYp.js.gz +0 -0
  297. package/dist/client/assets/sizeCapture-INFHLROL-CQmsOE8y.js.br +0 -0
  298. package/dist/client/assets/sizeCapture-INFHLROL-CQmsOE8y.js.gz +0 -0
  299. package/dist/client/assets/stateDiagram-D77RDMKH-C9Us69am.js.br +0 -0
  300. package/dist/client/assets/stateDiagram-D77RDMKH-C9Us69am.js.gz +0 -0
  301. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CFQnEkit.js +0 -1
  302. package/dist/client/assets/swimlanes-42K2YHIH-B2Ipm5e0.js.br +0 -0
  303. package/dist/client/assets/swimlanes-42K2YHIH-B2Ipm5e0.js.gz +0 -0
  304. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-CT7Br4E0.js +0 -8
  305. package/dist/client/assets/timeline-definition-24CTP7MA-BBifYxL0.js.br +0 -0
  306. package/dist/client/assets/timeline-definition-24CTP7MA-BBifYxL0.js.gz +0 -0
  307. package/dist/client/assets/vennDiagram-4TSXK5OY-S4M20P5A.js.br +0 -0
  308. package/dist/client/assets/vennDiagram-4TSXK5OY-S4M20P5A.js.gz +0 -0
  309. package/dist/client/assets/wardleyDiagram-VM6X3IG4-xbeBkQY_.js.br +0 -0
  310. package/dist/client/assets/wardleyDiagram-VM6X3IG4-xbeBkQY_.js.gz +0 -0
  311. package/dist/client/assets/xychartDiagram-S5SC5T6Z-tgPDPocq.js.br +0 -0
  312. package/dist/client/assets/xychartDiagram-S5SC5T6Z-tgPDPocq.js.gz +0 -0
@@ -1,1678 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelPreview-8jvTuVib.js","assets/app-CB-4opkv.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-mZxreyvP.css","assets/App-SGauuiZa.js","assets/gestureArbiter-DMxqtqCP.js","assets/gestureArbiter-C2J0D0kV.css","assets/triangle-alert-CeTsz1ro.js","assets/referenceLongPress-Cy1D2tMf.js","assets/DiffReview-CxN2B2DZ.js","assets/sparkles-AeZLuPvn.js","assets/DiffViewer-CMl5zjR1.js","assets/DiffViewer-T3uj2-aP.css","assets/ChangeWalkthroughPanel-CFp8sYSs.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-CUDRfRRW.js","assets/purify.es-4eNOHKSq.js"])))=>i.map(i=>d[i]);
2
- import{a4 as ft,a1 as Zh,bd as t,cH as Mt,cR as Dt,bv as mt,a as as,aM as dl,C as Di,c as os,X as sr,cE as ul,c6 as em,cG as di,m as Fi,L as yt,b1 as tm,z as Rs,al as rm,cL as ne,b5 as nm,b7 as fl,b8 as sm,b9 as mu,b6 as Cs,ay as am,E as om,i as im,b4 as lm,bx as cm,bz as dm,bA as um,aY as fm,by as md,y as _t,f as hm,v as mm,b as pm,aX as pd,au as gd,aq as gm,aC as $a,aD as bd,cS as Is,ah as Ns,aE as bm,cF as ui,bp as xm,cq as xd,aw as ym,cC as vm,b_ as wm,aH as km,O as yd,N as Sm,ar as jm,av as Rm,aA as vd,c0 as Cm,s as Nm,d as Ia,g as Oi,w as pu,ad as Em,_ as Os,bU as Mm,cP as Am,bk as Pm,af as Tm}from"./app-CB-4opkv.js";import{y as Lm,h as $m,q as Qa,e as Im,R as ro,U as _m,P as Dm,L as Fm,B as Om,K as Bm,g as Um,l as zm,r as gu,s as Hm,S as ns,D as Wm,c as bu,a as Gm,x as xu,v as _a,t as qm,u as Vm,w as Km,T as wd,d as kd,k as fi,j as Da,b as Ym,n as Xm,i as Jm,f as Qm,o as Zm,F as Sd,C as ep,G as tp}from"./App-SGauuiZa.js";import{b as a,r as Fr}from"./dnd-BCFAPC0L.js";import{a as rp,S as np,b as yu,c as Bi,F as sp}from"./gestureArbiter-DMxqtqCP.js";import{D as Ui,C as _s,L as vu,f as ap,n as op}from"./DiffReview-CxN2B2DZ.js";import{T as ip,M as hl,L as no,G as Ir}from"./triangle-alert-CeTsz1ro.js";import{S as Bs}from"./sparkles-AeZLuPvn.js";import{C as wu,M as ku}from"./ChangeWalkthroughPanel-CFp8sYSs.js";import{r as Su,s as ju,l as Ru,u as lp,h as Cu}from"./DiffViewer-CMl5zjR1.js";import{u as Nu,G as Eu}from"./referenceLongPress-Cy1D2tMf.js";const cp=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],dp=ft("case-sensitive",cp);const up=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],fp=ft("circle",up);const hp=[["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"}]],mp=ft("eye-off",hp);const pp=[["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"}]],zi=ft("eye",pp);const gp=[["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"}]],Hi=ft("file-text",gp);const bp=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Wi=ft("house",bp);const xp=[["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"}]],yp=ft("image-plus",xp);const vp=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],wp=ft("maximize",vp);const kp=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],Sp=ft("minimize",kp);const jp=[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]],Rp=ft("monitor-smartphone",jp);const Cp=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],Np=ft("plug",Cp);const Ep=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Mp=ft("power",Ep);const Ap=[["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"}]],Pp=ft("regex",Ap);const Tp=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Mu=ft("rotate-cw",Tp);const Lp=[["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"}]],$p=ft("scan",Lp);const Ip=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Gi=ft("send",Ip);const _p=[["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"}]],Dp=ft("upload",_p);const Fp=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]],Op=ft("volume-1",Fp);const Bp=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],Au=ft("volume-2",Bp);const Up=[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]],zp=ft("whole-word",Up);async function Hp(e){let r;try{await Promise.race([e(),new Promise(s=>{r=setTimeout(s,3e3)})])}catch{}finally{clearTimeout(r)}}function Wp({active:e,rootPath:r,loading:s,delay:i,lastStartedRoot:d,load:c}){a.useEffect(()=>{if(!e||!r||s||d.current===r)return;const h=window.setTimeout(()=>{d.current=r,c(r)},i);return()=>window.clearTimeout(h)},[e,r,s,i,d,c])}function Gp(e,r,s){try{const i=e instanceof HTMLImageElement?e.naturalWidth:e.width,d=e instanceof HTMLImageElement?e.naturalHeight:e.height;if(!i||!d)return Promise.resolve(null);const c=e instanceof HTMLImageElement?1400/Math.max(i,d):Math.min(1,1400/Math.max(i,d)),h=document.createElement("canvas");h.width=Math.max(1,Math.round(i*c)),h.height=Math.max(1,Math.round(d*c));const m=h.getContext("2d");if(!m)return Promise.resolve(null);const p=getComputedStyle(document.documentElement);if(m.fillStyle=p.getPropertyValue("--surface").trim()||"white",m.fillRect(0,0,h.width,h.height),m.drawImage(e,0,0,h.width,h.height),s){const g=Math.max(10,Math.min(16,h.width/35));m.font=`${g}px sans-serif`;const f=[];let S="";for(const v of s.split(" "))S&&m.measureText(`${S} ${v}`).width>h.width-20?(f.push(S),S=v):S=S?`${S} ${v}`:v;S&&f.push(S),m.fillStyle=p.getPropertyValue("--surface").trim()||"white",m.fillRect(0,0,h.width,f.length*(g+4)+12),m.fillStyle=p.getPropertyValue("--foreground").trim()||"black",f.forEach((v,P)=>m.fillText(v,10,8+g+P*(g+4)))}if(r){const g=r.xPercent*h.width/100,f=r.yPercent*h.height/100,S=Math.max(4,Math.min(12,Math.min(h.width,h.height)*.015)),v=S*1.6;m.strokeStyle=p.getPropertyValue("--primary").trim()||"black",m.lineWidth=Math.max(1,S/3),m.beginPath(),m.arc(g,f,S,0,Math.PI*2),m.stroke(),m.beginPath(),m.moveTo(g-v,f),m.lineTo(g+v,f),m.moveTo(g,f-v),m.lineTo(g,f+v),m.stroke()}return new Promise(g=>h.toBlob(g,"image/png"))}catch{return Promise.resolve(null)}}function qp(e,r,s,i){return[e.trim(),r.trim(),i?`截图:${i}`:""].filter(Boolean).join(`
3
- `)}function y0(e,r,s){const i=r*Math.PI/360,d=Math.min(i,Math.atan(Math.tan(i)*Math.max(s,.05)));return Math.max(e,1e-6)/Math.sin(d)*1.15}async function Vp(e,r,s,i){if(!s?.snapshot){i.isCurrent()&&i.insert(e,r);return}const d=new Date().toISOString(),c=new AbortController;let h,m;try{m=await Promise.race([(async()=>{const p=await s.snapshot;if(!(!p||c.signal.aborted||!i.isCurrent()))return i.upload(new File([p],`termdock-review-${crypto.randomUUID()}.png`,{type:"image/png"}),c.signal)})(),new Promise(p=>{h=setTimeout(()=>{c.abort(),p(void 0)},3e3)})])}catch{}finally{clearTimeout(h),c.abort()}i.isCurrent()&&i.insert(m?qp(e,"",d,m):e,r)}function Kp(e){let r=1,s="terminal";for(;;){let i=!1;for(const d of e.values())if(d.name===s){i=!0;break}if(!i)break;s=`terminal-${r}`,r++}return s}const qi=Zh((e,r)=>({sessions:new Map,activeSessionId:null,nextSessionNumber:1,createSession:s=>{const i=Lm(),d=Date.now(),c=r().sessions,h=Kp(c),m={id:i,cwd:s,sessionId:null,name:h,customName:!1,createdAt:d,lastActivity:d};return e(p=>{const g=new Map(p.sessions);return g.set(i,m),{sessions:g,activeSessionId:p.activeSessionId??i,nextSessionNumber:p.nextSessionNumber+1}}),i},closeSession:s=>{e(i=>{const d=new Map(i.sessions),c=i.activeSessionId===s;d.delete(s);let h=i.activeSessionId;if(c){const m=Array.from(d.keys());h=m.length>0?m[0]:null}return{sessions:d,activeSessionId:h}})},switchSession:s=>{e(i=>i.sessions.has(s)?{activeSessionId:s}:i)},updateSession:(s,i)=>{e(d=>{const c=d.sessions.get(s);if(!c)return d;const h=new Map(d.sessions);return h.set(s,{...c,...i,lastActivity:Date.now()}),{sessions:h}})},setTerminalSession:(s,i)=>{r().updateSession(s,{sessionId:i.sessionId})},getActiveSession:()=>{const s=r();if(s.activeSessionId)return s.sessions.get(s.activeSessionId)},getSessionCount:()=>r().sessions.size,clearAllSessions:()=>{e({sessions:new Map,activeSessionId:null,nextSessionNumber:1})}}));function Yp(e,r){return e===r||r.endsWith(`/${e}`)||e.endsWith(`/${r}`)}function jd(e,r){return`${e??""}\0${r}`}function Xp(e,r,s){if(!e||e.length===0||!s)return{explained:0,stale:0};const i=jd(r,s);let d=0,c=0;for(const h of e){const m=[h.filePath,h.newPath,h.oldPath].filter(g=>typeof g=="string"&&g.length>0);(m.some(g=>jd(h.repoRoot,g)===i)||m.some(g=>Yp(g,s)))&&(d+=1)}return{explained:d,stale:c}}function Jp({status:e}){if(!e)return null;const r=e.stale>0&&e.explained===0;if(!(e.explained>0||e.stale>0))return null;const i=r?"AI audit explanation is stale":"AI audit explanation available";return t.jsx("span",{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full ${r?"bg-[color:var(--warning)]/15 text-[color:var(--warning)]":"bg-accent/10 text-accent"}`,title:i,"aria-label":i,children:r?t.jsx(ip,{size:10}):t.jsx(Bs,{size:10})})}function Vi({changeStatus:e,auditStatus:r,renderChangeBadge:s}){return t.jsxs("span",{className:"inline-flex items-center gap-1",children:[s(e),t.jsx(Jp,{status:r})]})}const Pu="termdock:right-sidebar:diff-change-list-mode:v1";function Qp(e){return e==="list"||e==="tree"}function Zp(){return mt(Pu,Qp)??"tree"}function eg(e){for(const i of e){const d=i.hunk;if(d.oldPath&&d.newPath&&d.oldPath!==d.newPath)return"renamed";if(!d.oldPath&&d.newPath)return"added";if(d.oldPath&&!d.newPath)return"deleted"}const r=e.some(i=>i.hunk.additions>0),s=e.some(i=>i.hunk.deletions>0);return r&&!s?"added":!r&&s?"deleted":"modified"}function tg(e){const r=new Map;for(const i of e){const d=r.get(i.hunk.filePath)??{key:i.hunk.filePath,filePath:i.hunk.filePath,items:[],additions:0,deletions:0,explained:0,stale:0,changeType:"modified"};d.items.push(i),d.additions+=i.hunk.additions,d.deletions+=i.hunk.deletions,i.current&&(d.explained+=1),i.stale&&(d.stale+=1),r.set(i.hunk.filePath,d)}const s=Array.from(r.values()).sort((i,d)=>i.filePath.localeCompare(d.filePath));for(const i of s)i.changeType=eg(i.items);return s}function rg(e){const r=e.filePath.split("/").pop()??e.filePath;return{key:e.key,path:e.filePath,displayName:r,displayDir:e.filePath.includes("/")?e.filePath.slice(0,-r.length-1):"",status:e.changeType,title:e.filePath}}function ng(e,r){const s=e.filter(c=>c.trim().length>0);if(s.length<=1)return s[0]??"";const i=[],d=new Set;for(const[c,h]of s.entries()){const m=h.split(`
4
- `),p=m.findIndex(S=>S.startsWith("@@ "));if(p<0){i.push(...m);continue}c===0&&i.push(...m.slice(0,p));const g=r[c];let f=p;for(;f>=0&&f<m.length;){const S=m.findIndex((A,E)=>E>f&&A.startsWith("@@ ")),v=S>=0?S:m.length,P=m.slice(f,v),N=P[0]??"",F=g?N===g:!0,B=N||g||P.join(`
5
- `);F&&!d.has(B)&&(i.push(...P),d.add(B)),f=S}}return i.join(`
6
- `)}function sg({groups:e,onInsertDiffReference:r}){return e.map(s=>{const i=ng(s.items.map(m=>m.hunk.diff||m.current?.diff||m.stale?.diff||""),s.items.map(m=>m.hunk.hunkHeader)),d=s.items.map(m=>m.current??m.stale).filter(m=>!!m).map(m=>({id:m.id,repoRoot:m.repoRoot,filePath:m.filePath,oldPath:m.oldPath,newPath:m.newPath,hunkHeader:m.hunkHeader,hunkIndex:m.hunkIndex,fingerprint:m.fingerprint,diff:m.diff,explanation:m.explanation,summary:m.summary,workspaceRoot:m.workspaceRoot,generatedBy:m.generatedBy,injectedAt:m.injectedAt})),c=s.filePath.split("/").pop()??s.filePath,h=s.filePath.includes("/")?s.filePath.slice(0,-c.length-1):"";return{key:s.key,path:s.filePath,absolutePath:d[0]?.repoRoot?`${d[0].repoRoot}/${s.filePath}`:s.filePath,status:s.changeType,repoRoot:d[0]?.repoRoot??null,displayName:c,displayDir:h,diffOverride:i,auditRecords:d,onInsertDiffReference:r}})}function ag(e,r,s){const i=Array.from(e.querySelectorAll("[data-diff-stream-item]"));if(i.length===0)return null;const c=e.getBoundingClientRect().top+48;let h=null,m=Number.POSITIVE_INFINITY;for(const g of i){const f=g.getBoundingClientRect();if(f.bottom<c)continue;const S=Math.abs(f.top-c);S<m&&(h=g,m=S)}const p=h?.dataset.diffSelectionPath??h?.dataset.diffStreamItem??null;return!p||p===r||s(p),p}function Rd({items:e,selectedKey:r,onSelect:s,emptyText:i,mobile:d=!1,backLabel:c="Back",headerTitle:h,headerMeta:m,onClose:p,closeLabel:g="Back",wrap:f=!0,onToggleWrap:S,wrapTitle:v,wrapOnLabel:P="Wrap on",wrapOffLabel:N="Wrap off",desktopLayout:F="split",onInsertDiffReference:B,onReferenceCopied:A,insertedReferenceKey:E,copiedReferenceKey:L,onClearAuditRecord:$,walkthroughs:U=[],onWalkthroughNavigate:_,initialDetailScrollTop:o,onDetailScrollPositionChange:w,scrollToKey:O,scrollToKeyNonce:j,externalSwiperRef:Y,onMobileSlideChange:se}){const{t:ie}=Mt(),ge=a.useMemo(()=>tg(e),[e]),q=a.useMemo(()=>new Map(ge.map(de=>[de.key,de])),[ge]),[Q,T]=a.useState(()=>Zp()),[z,K]=a.useState(()=>new Set),[ae,le]=a.useState({key:null,nonce:0}),we=ge.find(de=>de.explained>0||de.stale>0)?.key??ge[0]?.key??null,be=r&&ge.some(de=>de.key===r)?r:we,Ae=a.useMemo(()=>[{key:"branch-audit",label:"Branch audit",files:ge.map(rg)}],[ge]),M=a.useMemo(()=>sg({groups:ge,onInsertDiffReference:B}),[ge,B]),te=a.useRef(we),ue=a.useRef(s);te.current=we,ue.current=s,a.useEffect(()=>{!r&&te.current&&ue.current(te.current)},[r]);const Le=S?t.jsxs("button",{type:"button",onClick:S,"aria-pressed":f,title:v,className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 text-[11px] font-medium transition active:scale-95 ${f?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[t.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),t.jsx("span",{children:f?P:N})]}):null,Ge=de=>t.jsxs("div",{className:"px-0 py-0",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[h&&t.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:h}),m&&t.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:m})]}),p&&t.jsxs("button",{type:"button",onClick:p,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:[t.jsx(as,{size:14}),g]})]}),t.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[de,Le]})]});if(e.length===0){const de=t.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:i});return!h&&!p?de:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-2",children:[Ge(null),de]})}const Pe=S?({slideToList:de})=>t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("button",{type:"button",className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",onClick:de,children:[t.jsx(as,{size:14}),c]}),t.jsxs("button",{type:"button",onClick:S,"aria-pressed":f,title:v,className:`inline-flex h-9 shrink-0 items-center gap-1 rounded-full px-3 text-[11px] font-medium transition active:scale-95 ${f?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[t.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),t.jsx("span",{children:f?P:N})]})]}):void 0;return t.jsx(Ui,{mobile:d,desktopLayout:F,backLabel:c,groups:Ae,selectedKey:be,mode:Q,onModeChange:de=>{T(de),de!=="ai"&&Dt(Pu,de)},compact:d,collapsedDirectoryKeys:z,onToggleDirectory:de=>{K(Z=>{const R=new Set(Z);return R.has(de)?R.delete(de):R.add(de),R})},onSelectFile:de=>{s(de.key),le(Z=>({key:de.key,nonce:Z.nonce+1}))},renderLeading:de=>{const Z=q.get(de.key);return t.jsx(Vi,{changeStatus:de.status,auditStatus:Z,renderChangeBadge:R=>t.jsx(_s,{status:R})})},renderTrailing:de=>{const Z=q.get(de.key);return Z?t.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",Z.additions," -",Z.deletions]}):null},renderListHeader:Ge,aiContent:({slideToDetail:de,fullscreen:Z,toggleFullscreen:R})=>U.length>0&&_?t.jsx(wu,{walkthroughs:U,repoRoot:U[0]?.repoRoot,fullscreen:Z,onToggleFullscreen:R,onNavigate:V=>{d&&window.requestAnimationFrame(de),_(V)}}):t.jsx("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:ie("rightSidebar.changeWalkthroughEmpty")}),renderMobileDetailHeader:Pe,externalSwiperRef:Y,onMobileSlideChange:se,detailContainerClassName:d?"termdock-native-select termdock-diff-stream-scroller min-h-0":void 0,initialDetailScrollTop:o,scrollToKey:O??ae.key,scrollToKeyNonce:O==null?ae.nonce:j,onDetailScroll:de=>{ag(de,be,s),w?.(de.scrollTop)},files:M,activePane:!0,wrap:f,renderStreamBadge:(de,Z)=>{const R=q.get(Z.key);return t.jsx(Vi,{changeStatus:de,auditStatus:R,renderChangeBadge:V=>t.jsx(_s,{status:V})})},onInsertDiffReference:B,onReferenceCopied:A,insertedReferenceKey:E,copiedReferenceKey:L,onClearAuditRecord:$,emptyContent:t.jsx("div",{className:"rounded-lg bg-surface-2 px-3 py-6 text-center text-xs text-muted-foreground",children:i})})}function og(e){return e.replace(/\/+$/,"")||"/"}function ig(e){return[...new Set(Array.from(e,og))].sort((r,s)=>r.localeCompare(s))}function lg(e){return e==="event-storm"||e==="reconnected"||e==="directory-rescan"||e==="polling-fallback"}function cg(e){let r=null;return{applicableEvents:e.filter(i=>{const d=i.type==="rescan-required"&&!lg(i.reason);return d&&i.reason&&!r&&(r=i.reason),!d}),unavailableReason:r}}const dg=1400,ug=1200,Tu=44,fg=.7;function hi(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?"mobile":"desktop"}function Ki(e){return`termdock:right-sidebar:context-draft-height:${e}:v1`}function hg(e){try{const r=window.localStorage.getItem(Ki(e)),s=r===null?NaN:Number(r);return Number.isFinite(s)&&s>=Tu?s:null}catch{return null}}function Cd(e,r){try{r===null?window.localStorage.removeItem(Ki(e)):window.localStorage.setItem(Ki(e),String(r))}catch{}}function Fa(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function mg({value:e,collapsed:r,labels:s,focusRequest:i,insertError:d,autoCollapseAfterSend:c,onChange:h,onCollapsedChange:m,onAutoCollapseAfterSendChange:p,onDisable:g,onClear:f,onInsert:S,onInsertAndSend:v}){const[P,N]=a.useState(null),[F,B]=a.useState(!1),[A,E]=a.useState(()=>hg(hi())),L=a.useRef(A),$=a.useRef(null),U=a.useRef(null),_=a.useRef(e),o=a.useRef(null),w=a.useRef(null),O=!!e.trim(),j=e.trim().split(`
7
- `)[0]??"",Y=/Mac|iPhone|iPad/.test(window.navigator?.platform??"")?"⌘↵":"Ctrl+↵";a.useEffect(()=>()=>{$.current!==null&&window.clearTimeout($.current),U.current!==null&&window.clearTimeout(U.current)},[]),a.useEffect(()=>{let M=!1;const te=hi();return dl().then(ue=>{if(M)return;const Le=ue.contextDraftHeight?.[te]??null;Cd(te,Le),L.current=Le,E(Le)}).catch(()=>{}),()=>{M=!0}},[]),a.useEffect(()=>{if(i!==void 0&&i>0){const M=o.current;if(!M)return;Fa()||M.focus(),M.setSelectionRange(M.value.length,M.value.length),M.scrollTop=M.scrollHeight}},[i]),a.useEffect(()=>{const M=_.current;_.current=e,!(!r||e.length<=M.length)&&(B(!0),U.current!==null&&window.clearTimeout(U.current),U.current=window.setTimeout(()=>{U.current=null,B(!1)},ug))},[e,r]),a.useEffect(()=>{if(r)return;const M=o.current;M&&(M.style.height=A!==null?`${A}px`:"")},[e,r,A]),a.useEffect(()=>{if(r)return;const M=o.current;!M||document.activeElement===M||(M.scrollTop=M.scrollHeight)},[e,r]),a.useEffect(()=>{if(r||Fa())return;const M=o.current;!M||document.activeElement===M||(M.focus(),M.setSelectionRange(M.value.length,M.value.length))},[r]);const se=a.useRef(null);a.useLayoutEffect(()=>{if(!Fa())return;const M=window.visualViewport;if(!M)return;const te=()=>{const ue=se.current;if(!ue)return;if(M.height>=window.innerHeight*.75){ue.style.transform="";return}const Le=ue.getBoundingClientRect(),Ge=Math.round(M.height-Le.bottom);ue.style.transform=Ge!==0?`translateY(${Ge}px)`:""};return te(),M.addEventListener("resize",te),M.addEventListener("scroll",te),()=>{M.removeEventListener("resize",te),M.removeEventListener("scroll",te),se.current&&(se.current.style.transform="")}},[r]);const ie=M=>{N(M),$.current!==null&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{$.current=null,N(null)},dg)},ge=M=>{m(!1),Fa()&&window.requestAnimationFrame(()=>{const te=o.current;if(!te)return;te.focus();const ue=te.value.length;te.setSelectionRange(ue,ue),window.requestAnimationFrame(()=>{te.setSelectionRange(ue,ue)})})},q=()=>{S(),ie("inserted")},Q=()=>{O&&(v(),ie("sent"))},T=M=>{if(M.key==="Escape"){M.preventDefault(),m(!0);return}M.key!=="Enter"||!M.metaKey&&!M.ctrlKey||(M.preventDefault(),Q())},z=M=>{M.preventDefault()},K=M=>{M.preventDefault();const te=o.current;te&&(w.current={startY:M.clientY,startHeight:te.getBoundingClientRect().height},M.currentTarget.setPointerCapture?.(M.pointerId))},ae=M=>{const te=w.current;if(!te)return;const ue=window.visualViewport?.height??window.innerHeight,Le=Math.round(Math.min(Math.max(te.startHeight+(te.startY-M.clientY),Tu),ue*fg));L.current=Le,E(Le)},le=M=>{const te=hi();Cd(te,M),ul({contextDraftHeight:{[te]:M}}).catch(()=>{})},we=()=>{w.current&&(w.current=null,L.current!==null&&le(L.current))},be=()=>{L.current=null,E(null),le(null)},Ae=e.length>0&&t.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/50",children:s.characterCount(e.length)});return r?t.jsx("section",{ref:se,className:"shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:t.jsxs("div",{className:"flex h-8 items-center gap-1 px-2",children:[t.jsxs("button",{type:"button",onClick:()=>ge(),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:[t.jsx($m,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),t.jsx("span",{className:`truncate text-[11px] ${d?"text-destructive":F?"text-primary":O?"text-foreground/80":"text-muted-foreground/50"}`,children:d??(F?s.appended:O?j:s.title)})]}),Ae,t.jsx("button",{type:"button",onClick:Q,disabled:!O,className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition active:scale-95 disabled:opacity-30 ${O?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground"}`,"aria-label":s.send,title:s.send,children:P==="sent"?t.jsx(Di,{size:12}):t.jsx(Gi,{size:12})})]})}):t.jsxs("section",{ref:se,className:"relative shrink-0 border-t border-border/15 text-foreground","data-context-draft-dock":!0,children:[t.jsx("div",{className:"group absolute left-1/2 top-0 z-10 flex h-3 w-16 -translate-x-1/2 -translate-y-1/2 cursor-ns-resize touch-none items-center justify-center",onPointerDown:K,onPointerMove:ae,onPointerUp:we,onPointerCancel:we,onDoubleClick:be,title:s.resize,"aria-hidden":"true",children:t.jsx("span",{className:"h-1 w-8 rounded-full bg-border/50 transition group-hover:bg-border"})}),t.jsxs("div",{className:"flex h-7 items-center gap-0.5 px-2",children:[t.jsxs("button",{type:"button",onPointerDown:z,onClick:()=>m(!0),className:"group flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1 py-1 text-left transition-colors hover:bg-surface/70","aria-expanded":!0,"aria-label":s.collapse,title:s.collapse,children:[t.jsx(os,{size:11,className:"shrink-0 text-muted-foreground/55 transition-colors group-hover:text-muted-foreground","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-[10px] font-medium text-foreground/75",children:s.title}),Ae]}),t.jsx("button",{type:"button",role:"switch","aria-checked":c,onPointerDown:z,onClick:()=>p(!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:t.jsx("span",{"aria-hidden":"true",className:`relative h-3 w-5 rounded-full transition-colors ${c?"bg-primary":"bg-surface-elevated"}`,children:t.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-primary-foreground transition-transform ${c?"translate-x-2.5":"translate-x-0.5"}`})})}),t.jsx("button",{type:"button",onPointerDown:z,onClick:g,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/50 transition hover:bg-surface/70 hover:text-foreground active:scale-95","aria-label":s.disable,title:s.disable,children:t.jsx(sr,{size:11})})]}),t.jsx("div",{className:"px-2 pb-2",children:t.jsxs("div",{className:"overflow-hidden rounded-lg bg-surface/80 ring-1 ring-border/10 transition focus-within:ring-primary/35",children:[t.jsx("textarea",{ref:o,value:e,onChange:M=>h(M.target.value),onKeyDown:T,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}),t.jsxs("div",{className:"flex items-center gap-0.5 border-t border-border/10 px-1 py-1",children:[t.jsx("button",{type:"button",onPointerDown:z,onClick:f,disabled:!O,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:t.jsx(Qa,{size:11})}),d?t.jsx("span",{className:"min-w-0 flex-1 truncate px-1 text-[10px] text-destructive",role:"alert",children:d}):t.jsx("span",{className:"flex-1"}),t.jsxs("button",{type:"button",onPointerDown:z,onClick:q,disabled:!O,className:"inline-flex h-6 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-[10px] font-medium text-foreground/75 transition hover:bg-surface-2 hover:text-foreground active:scale-[0.98] disabled:opacity-30",children:[t.jsx(Im,{size:11}),t.jsx("span",{children:P==="inserted"?s.inserted:s.insert})]}),t.jsxs("button",{type:"button",onPointerDown:z,onClick:Q,disabled:!O,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} · ${Y}`,children:[P==="sent"?t.jsx(Di,{size:11}):t.jsx(Gi,{size:11}),t.jsx("span",{children:P==="sent"?s.sent:s.send})]})]})]})})]})}async function Lu(e,r){const s=await fetch(e,{...r,headers:{"Content-Type":"application/json",Accept:"application/json",...r?.headers??{}}}),i=await s.json().catch(()=>null);if(!s.ok||!i){const d=i?.error||i?.code||`ANDROID_REQUEST_FAILED_${s.status}`;throw new Error(d)}return i}async function pg(){return Lu("/api/android/devices")}async function gg(e){return Lu("/api/android/connect",{method:"POST",body:JSON.stringify({address:e})})}const so=[{id:"low",maxSize:720,bitRate:12e5,maxFps:30},{id:"medium",maxSize:1080,bitRate:4e6,maxFps:30},{id:"high",maxSize:1600,bitRate:8e6,maxFps:60}],Us=so[1];function $u(e){if(!e||typeof e!="object")return Us;const r=e,s=so.find(h=>h.id===r.id);if(s)return s;if(r.id!=="custom")return Us;const i=typeof r.maxSize=="number"?Math.max(360,Math.min(2160,Math.round(r.maxSize))):1080,d=typeof r.bitRate=="number"?Math.max(3e5,Math.min(3e7,Math.round(r.bitRate))):4e6,c=typeof r.maxFps=="number"?Math.max(0,Math.min(60,Math.round(r.maxFps))):30;return{id:"custom",maxSize:i,bitRate:d,maxFps:c}}function bg(e,r){if(!/^[0-9a-zA-Z_.:\-]{1,128}$/.test(e))throw new Error("INVALID_SERIAL");const s=new URLSearchParams;r&&(s.set("max_size",String(r.maxSize)),s.set("bit_rate",String(r.bitRate)),r.maxFps>0&&s.set("max_fps",String(r.maxFps)));const i=s.toString();return`/api/android/${e}/ws${i?`?${i}`:""}`}function Nd(e){const r={ADB_UNAVAILABLE:"本机没有可用的 adb,请先安装 Android platform-tools。",ADB_NOT_FOUND:"找不到 adb 可执行文件,可用 TERMDOCK_ADB_BIN 指定路径。",SCRCPY_NOT_FOUND:"本机没有 scrcpy,请先安装(含 scrcpy-server)。",SCRCPY_SERVER_NOT_FOUND:"找不到 scrcpy-server,可用 TERMDOCK_SCRCPY_SERVER 指定路径。",SCRCPY_VERSION_UNKNOWN:"无法读取 scrcpy 版本,请确认 scrcpy --version 可执行。",SCRCPY_CONNECT_TIMEOUT:"设备连接超时,请确认已授权 USB 调试并保持解锁。",SCRCPY_UNSUPPORTED_CODEC:"设备返回了不支持的视频编码。",INVALID_ADDRESS:"地址格式不正确,应为 ip:port。",API_NOT_ALLOWED:"当前设备权限不足:投屏需要全权服务授权。"};for(const[s,i]of Object.entries(r))if(e.includes(s))return i;return e}const xg=0,yg=1,vg=2,wg=3,kg=4,Sg=5,jg=7,Rg=10,Cg=11,Ng=16,Eg=17,Ed=0,mi=1,Mg=2,Ag=3,pi=0,Md=1,Ad=1,Es=0xffffffffffffffffn,gi=0xfffffffffffffffen,Ms={HOME:3,APP_SWITCH:187,POWER:26,VOLUME_UP:24,VOLUME_DOWN:25};function Iu(e,r,s){e.setUint32(r,Math.max(0,Math.round(s.x))&4294967295),e.setUint32(r+4,Math.max(0,Math.round(s.y))&4294967295),e.setUint16(r+8,Math.min(65535,Math.round(s.screenWidth))),e.setUint16(r+10,Math.min(65535,Math.round(s.screenHeight)))}function Pg(e,r,s,i,d,c){const h=new Uint8Array(32),m=new DataView(h.buffer);return m.setUint8(0,vg),m.setUint8(1,e),m.setBigUint64(2,r),Iu(m,10,s),m.setUint16(22,Math.max(0,Math.min(65535,Math.round(i*65536)))),m.setUint32(24,d>>>0),m.setUint32(28,c>>>0),h}function bi(e,r,s=0,i=0){const d=new Uint8Array(14),c=new DataView(d.buffer);return c.setUint8(0,xg),c.setUint8(1,e),c.setUint32(2,r>>>0),c.setUint32(6,s>>>0),c.setUint32(10,i>>>0),d}function Tg(e,r,s,i=0){const d=new Uint8Array(21),c=new DataView(d.buffer);c.setUint8(0,wg),Iu(c,1,e);const h=m=>Math.max(-32768,Math.min(32767,Math.round(Math.max(-1,Math.min(1,m/16))*32768)));return c.setInt16(13,h(r)),c.setInt16(15,h(s)),c.setUint32(17,i>>>0),d}function Lg(e){const r=new TextEncoder().encode(e);if(!r.length)return null;const s=r.subarray(0,300),i=new Uint8Array(5+s.length),d=new DataView(i.buffer);return d.setUint8(0,yg),d.setUint32(1,s.length),i.set(s,5),i}function $g(e){const r=new TextEncoder().encode(e);if(!r.length||r.length>255)return null;const s=new Uint8Array(2+r.length);return s[0]=Ng,s[1]=r.length,s.set(r,2),s}function Oa(e){return new Uint8Array([e])}function Pd(e){return new Uint8Array([kg,e])}function Ig(e){return new Uint8Array([Rg,e?1:0])}function _g(e){let r="";for(let s=0;s<e.length;s+=32768)r+=String.fromCharCode(...e.subarray(s,s+32768));return btoa(r)}function Dg(e){const r=atob(e),s=new Uint8Array(r.length);for(let i=0;i<r.length;i++)s[i]=r.charCodeAt(i);return s}function xi(e){return e.toString(16).padStart(2,"0")}function _u(e,r,s){for(let i=0;i+4<e.length;i++){const d=e[i]===0&&e[i+1]===0&&e[i+2]===1,h=e[i]===0&&e[i+1]===0&&e[i+2]===0&&e[i+3]===1?i+4:d?i+3:-1;if(h<0||h>=e.length)continue;if((s?e[h]>>1&63:e[h]&31)!==r){i=h-1;continue}let p=h+1;for(;p+2<e.length&&!(e[p]===0&&e[p+1]===0&&(e[p+2]===1||e[p+2]===0&&e[p+3]===1));)p++;return e.subarray(h,Math.min(e.length,p))}return null}function Fg(e){const r=e?_u(e,7,!1):null;return r&&r.length>=4?`avc1.${xi(r[1])}${xi(r[2])}${xi(r[3])}`:"avc1.42e01e"}function Og(e){const r=e?_u(e,32,!0):null;if(r&&r.length>=13){const s=r[1]>>6&3,i=r[1]&31,d=r[12];return`hev1.${s}.${i}.L${d}.B0`}return"hev1.1.6.L120.B0"}class Bg{constructor(r,s){this.canvas=r,this.callbacks=s}canvas;callbacks;socket=null;decoder=null;configured=!1;configData=null;header=null;closedByUser=!1;lastMessageAt=0;heartbeat=null;statsTimer=null;pendingConfig=null;needsKeyframe=!1;frameCount=0;receivedFrames=0;decodedFrames=0;controlsSent=0;lastSeq=0;deferredAck=!1;lastType="";bytesSinceSample=0;warnedUnsupported=!1;lastSampleAt=0;serial="";get currentHeader(){return this.header}connect(r,s){this.serial=r,this.closedByUser=!1,this.callbacks.onState("connecting");let i;try{i=em(bg(r,s))}catch(d){this.callbacks.onState("error",d instanceof Error?d.message:"ANDROID_STREAM_FAILED");return}this.socket=i,i.onopen=()=>{this.lastMessageAt=Date.now()},i.onmessage=d=>this.handleMessage(d.data),i.onerror=()=>{this.closedByUser||this.callbacks.onState("error","SCRCPY_CONNECTION_LOST")},i.onclose=()=>{this.teardownTimers(),this.closedByUser?this.callbacks.onState("idle"):this.callbacks.onState("error","SCRCPY_CONNECTION_CLOSED")},this.startTimers()}disconnect(){this.closedByUser=!0,this.teardownTimers();try{this.decoder?.close()}catch{}this.decoder=null,this.configured=!1;try{this.socket?.close()}catch{}this.socket=null,this.callbacks.onState("idle")}teardownTimers(){this.heartbeat&&clearInterval(this.heartbeat),this.statsTimer&&clearInterval(this.statsTimer),this.heartbeat=null,this.statsTimer=null}startTimers(){this.lastSampleAt=Date.now(),this.heartbeat=setInterval(()=>{if(!(!this.socket||this.socket.readyState!==1)){if(Date.now()-this.lastMessageAt>45e3){try{this.socket.close()}catch{}return}this.send({type:"ping"})}},15e3),this.statsTimer=setInterval(()=>{const r=Date.now(),s=(r-this.lastSampleAt)/1e3;s<=0||(this.callbacks.onStats({fps:Math.round(this.frameCount/s*10)/10,kbps:Math.round(this.bytesSinceSample*8/s/1e3),width:this.header?.width??0,height:this.header?.height??0,received:this.receivedFrames,decoded:this.decodedFrames,controls:this.controlsSent,last:this.lastType}),this.frameCount=0,this.bytesSinceSample=0,this.lastSampleAt=r)},1e3)}send(r){if(!(!this.socket||this.socket.readyState!==1))try{this.socket.send(JSON.stringify(r))}catch{}}sendControl(r){r&&(this.controlsSent++,this.send({type:"control",data:_g(r)}))}ack(){this.send({type:"ack",seq:this.lastSeq})}handleMessage(r){if(typeof r!="string")return;this.lastMessageAt=Date.now();let s;try{s=JSON.parse(r)}catch{return}this.lastType=`${s.type??"?"}${s.config?":cfg":""}${s.key?":key":""}`;try{this.dispatchMessage(s)}catch(i){console.warn("[android] message handling failed",i),this.callbacks.onWarning(`处理消息失败:${i instanceof Error?i.message:String(i)}`)}}dispatchMessage(r){switch(r.type){case"header":this.header={deviceName:r.deviceName??this.serial,codec:r.codec??"h264",width:r.width??0,height:r.height??0},this.callbacks.onHeader(this.header),this.callbacks.onState("streaming");break;case"frame":this.handleFrame(r);break;case"error":this.callbacks.onState("error",r.message||"SCRCPY_ERROR");break;case"closed":this.callbacks.onState("error","SCRCPY_SESSION_CLOSED");break}}handleFrame(r){if(typeof r.data!="string")return;typeof r.seq=="number"&&(this.lastSeq=r.seq);const s=Dg(r.data);if(this.bytesSinceSample+=r.data.length,this.receivedFrames++,this.decoder?.state==="closed"&&(this.decoder=null,this.configured=!1),r.config){this.configData=s,this.pendingConfig=s,this.configureDecoder(),this.ackWhenDecoded();return}this.configured||this.configureDecoder();const i=r.key===!0;if(this.needsKeyframe&&!i){this.ackWhenDecoded();return}let d=s;this.pendingConfig&&(d=new Uint8Array(this.pendingConfig.length+s.length),d.set(this.pendingConfig,0),d.set(s,this.pendingConfig.length),this.pendingConfig=null),i&&(this.needsKeyframe=!1),this.decode(d,i,r.pts),this.ackWhenDecoded()}ackWhenDecoded(){(this.decoder?.decodeQueueSize??0)<3?this.ack():this.deferredAck=!0}configureDecoder(){const r=this.header?.codec??"h264";if(!this.decoder||this.decoder.state==="closed"){if(typeof VideoDecoder>"u"){this.warnedUnsupported||(this.warnedUnsupported=!0,this.callbacks.onWarning("当前浏览器不支持 WebCodecs(VideoDecoder),无法解码投屏画面。")),this.callbacks.onState("error","VIDEO_DECODER_UNSUPPORTED");return}try{this.decoder=new VideoDecoder({output:c=>this.onDecodedFrame(c),error:c=>{this.configured=!1,console.warn("[android] video decoder error",c),this.callbacks.onState("error",c instanceof Error?c.message:"VIDEO_DECODER_ERROR"),this.sendControl(Oa(Eg))}})}catch(c){console.warn("[android] VideoDecoder unavailable",c),this.callbacks.onWarning(`创建 VideoDecoder 失败:${c instanceof Error?c.message:String(c)}`),this.callbacks.onState("error","VIDEO_DECODER_UNSUPPORTED");return}}const s={codec:"avc1.42e01e",optimizeForLatency:!0};let i;r==="h264"?(i=[Fg(this.configData),"avc1.42e01e","avc1.4d401e","avc1.64001f"].filter((h,m,p)=>p.indexOf(h)===m),s.avc={format:"annexb"}):r==="h265"?(i=[Og(this.configData),"hev1.1.6.L120.B0","hvc1.1.6.L120.B0"],s.hevc={format:"annexb"}):i=["av01.0.04M.08"];const d=[];for(const c of i)try{this.decoder.configure({...s,codec:c}),this.configured=!0,this.needsKeyframe=!0,c!==i[0]&&console.warn("[android] decoder configured with fallback codec",c);return}catch(h){d.push(`${c}: ${h instanceof Error?h.message:String(h)}`),console.warn("[android] decoder configure failed",c,h)}this.callbacks.onWarning(`解码器配置失败(${d.join(";")})`),this.callbacks.onState("error","VIDEO_DECODER_UNSUPPORTED")}decode(r,s,i){if(!(!this.decoder||this.decoder.state!=="configured"))try{this.decoder.decode(new EncodedVideoChunk({type:s?"key":"delta",timestamp:i?Number(i):this.lastTimestamp+1,data:r})),this.lastTimestamp=i?Number(i):this.lastTimestamp+1}catch(d){this.decodeFailureCount++<3&&(console.warn("[android] decode threw",d),this.callbacks.onWarning(`送入解码器失败:${d instanceof Error?d.message:String(d)}`))}}decodeFailureCount=0;lastTimestamp=0;onDecodedFrame(r){this.frameCount++,this.decodedFrames++;const s=r.displayWidth||r.codedWidth,i=r.displayHeight||r.codedHeight,d=this.canvas;(d.width!==s||d.height!==i)&&(d.width=s,d.height=i,this.header&&(this.header={...this.header,width:s,height:i},this.callbacks.onHeader(this.header)));const c=d.getContext("2d");c&&c.drawImage(r,0,0,d.width,d.height),r.close(),this.deferredAck&&(this.decoder?.decodeQueueSize??0)<2&&(this.deferredAck=!1,this.ack())}pointerPoint(r,s){return{x:r,y:s,screenWidth:this.header?.width??0,screenHeight:this.header?.height??0}}touch(r,s,i,d){const c=r===mi||r===Ag,h=c?0:1,m=d===Es&&!c?Ad:0,p=(r===Ed||r===mi)&&d===Es?Ad:0;this.sendControl(Pg(r,d,this.pointerPoint(s,i),h,p,m))}pointerDown(r,s,i){this.touch(Ed,r,s,i==="mouse"?Es:gi)}pointerMove(r,s,i){this.touch(Mg,r,s,i==="mouse"?Es:gi)}pointerUp(r,s,i){this.touch(mi,r,s,i==="mouse"?Es:gi)}scroll(r,s,i,d){this.sendControl(Tg(this.pointerPoint(r,s),i,d))}key(r,s=pi){this.sendControl(bi(s,r))}tapKey(r){this.sendControl(bi(pi,r)),this.sendControl(bi(Md,r))}back(){this.sendControl(Pd(pi)),this.sendControl(Pd(Md))}home(){this.tapKey(Ms.HOME)}recents(){this.tapKey(Ms.APP_SWITCH)}power(){this.tapKey(Ms.POWER)}volumeUp(){this.tapKey(Ms.VOLUME_UP)}volumeDown(){this.tapKey(Ms.VOLUME_DOWN)}rotate(){this.sendControl(Oa(Cg))}expandNotifications(){this.sendControl(Oa(Sg))}collapsePanels(){this.sendControl(Oa(jg))}setDisplayPower(r){this.sendControl(Ig(r))}sendText(r){this.sendControl(Lg(r))}startApp(r){this.sendControl($g(r))}}const Ba="android-mirror",Du="termdock:android:quality:v1",Td={low:"android.qualityLow",medium:"android.qualityMedium",high:"android.qualityHigh",custom:"android.qualityCustom"},Ug=()=>{try{const e=localStorage.getItem(Du);return e?$u(JSON.parse(e)):Us}catch{return Us}},As=e=>{try{localStorage.setItem(Du,JSON.stringify(e))}catch{}};function zg(){const{t:e}=Mt(),r=a.useRef(null),s=a.useRef(null),i=a.useMemo(Ug,[]),d=a.useRef(i),c=a.useRef(null),h=a.useRef(null),m=a.useRef(0),[p,g]=a.useState(null),[f,S]=a.useState(null),[v,P]=a.useState(!0),[N,F]=a.useState(""),[B,A]=a.useState(i.id),[E,L]=a.useState([]),[$,U]=a.useState(null),[_,o]=a.useState(""),[w,O]=a.useState({maxSize:i.maxSize,bitRate:i.bitRate,maxFps:i.maxFps}),[j,Y]=a.useState("idle"),[se,ie]=a.useState(null),[ge,q]=a.useState(null),[Q,T]=a.useState({fps:0,kbps:0,width:0,height:0,received:0,decoded:0,controls:0,last:""}),[z,K]=a.useState(null),[ae,le]=a.useState(!1),[we,be]=a.useState([]),[Ae,M]=a.useState(null),[te,ue]=a.useState([]),[Le,Ge]=a.useState(!1),Pe=a.useRef(null),de=a.useRef(0),Z=a.useRef([]),[R,V]=a.useState(!1),[Se,xe]=a.useState(""),[Ve,fe]=a.useState(!1),[Xe,Ie]=a.useState(!1),[Ze,ke]=a.useState(""),Fe=qi(k=>k.activeSessionId??k.sessions.keys().next().value??null),_e=di(k=>!!k.docks[Ba]),Wt=di(k=>k.hosts[Ba]),st=di(k=>k.setDock),At=a.useCallback(async()=>{P(!0);try{const k=await pg();g(k),S(null)}catch(k){S(k instanceof Error?k.message:"ADB_UNAVAILABLE")}finally{P(!1)}},[]);a.useEffect(()=>{At()},[At]);const Je=p?.devices??[],Ft=Je.find(k=>k.serial===N)??null,vt=!!(f&&/ADB_NOT_FOUND|ADB_UNAVAILABLE/i.test(f)),W=!!(p?.adbAvailable&&!p.scrcpyVersion),ee=a.useCallback(()=>{s.current?.disconnect(),s.current=null,Y("idle"),ie(null),q(null)},[]),me=a.useCallback(k=>{const J=r.current;if(!J||!k)return;s.current?.disconnect(),ie(null),q(null),K(null);const ce=new Bg(J,{onState:(Re,Ee)=>{Y(Re),ie(Ee??null)},onHeader:Re=>q(Re),onStats:Re=>T(Re),onWarning:Re=>K(Re)});s.current=ce,ce.connect(k,d.current)},[]),Ue=a.useCallback(k=>{const J={...k.quality?{quality:{id:k.quality.id,maxSize:k.quality.maxSize,bitRate:k.quality.bitRate,maxFps:k.quality.maxFps}}:{},...k.activePresetId!==void 0?{activePresetId:k.activePresetId}:{},...k.presets!==void 0?{presets:k.presets}:{},...k.deviceSerial!==void 0?{deviceSerial:k.deviceSerial}:{}};ul({androidPanel:J}).catch(()=>{})},[]);a.useEffect(()=>{let k=!1;return dl().then(J=>{if(k)return;const ce=J.androidPanel;if(ce?.quality){const Re=$u(ce.quality);d.current=Re,A(Re.id),O({maxSize:Re.maxSize,bitRate:Re.bitRate,maxFps:Re.maxFps}),As(Re)}L(ce?.presets??[]),U(ce?.activePresetId??null),ce?.deviceSerial&&(h.current=ce.deviceSerial,F(ce.deviceSerial))}).catch(()=>{}),()=>{k=!0}},[]);const ht=a.useCallback(k=>{const J=++de.current;be(Re=>[...Re,{id:J,left:k.left,top:k.top}]);const ce=window.setTimeout(()=>{be(Re=>Re.filter(Ee=>Ee.id!==J)),Z.current=Z.current.filter(Re=>Re!==ce)},300);Z.current.push(ce)},[]),Pt=a.useCallback(k=>{if(k.startsWith("user:")){const ce=E.find(Ee=>Ee.id===k.slice(5));if(!ce)return;const Re={id:"custom",maxSize:ce.maxSize,bitRate:ce.bitRate,maxFps:ce.maxFps};d.current=Re,A("custom"),U(ce.id),O({maxSize:ce.maxSize,bitRate:ce.bitRate,maxFps:ce.maxFps}),As(Re),Ue({quality:Re,activePresetId:ce.id}),N&&me(N);return}if(k==="custom"){const ce=d.current;A("custom"),U(null),O({maxSize:ce.maxSize,bitRate:ce.bitRate,maxFps:ce.maxFps});return}const J=so.find(ce=>ce.id===k)??Us;d.current=J,A(J.id),U(null),As(J),Ue({quality:J,activePresetId:null}),N&&me(N)},[me,N,E,Ue]),Ot=a.useCallback(()=>{const k={id:"custom",maxSize:w.maxSize,bitRate:w.bitRate,maxFps:w.maxFps};d.current=k,As(k),Ue({quality:k,activePresetId:null}),A("custom"),U(null),N&&me(N)},[me,N,w,Ue]),Yt=a.useCallback(()=>{const k=_.trim();if(!k)return;const J=`p${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,ce={id:J,name:k,maxSize:w.maxSize,bitRate:w.bitRate,maxFps:w.maxFps},Re=[...E.filter(ur=>ur.name!==k),ce].slice(-12),Ee={id:"custom",maxSize:w.maxSize,bitRate:w.bitRate,maxFps:w.maxFps};L(Re),o(""),U(J),A("custom"),d.current=Ee,As(Ee),Ue({quality:Ee,activePresetId:J,presets:Re}),N&&me(N)},[_,w,E,N,me,Ue]),Gt=a.useCallback(()=>{if(!$)return;const k=E.filter(J=>J.id!==$);L(k),U(null),Ue({activePresetId:null,presets:k})},[$,E,Ue]);a.useEffect(()=>()=>{s.current?.disconnect(),s.current=null;for(const k of Z.current)window.clearTimeout(k);Z.current=[]},[]),a.useEffect(()=>{const k=Je.filter(ce=>ce.state==="device");if(N||k.length!==1)return;const J=k[0].serial;h.current!==J&&(h.current=J,F(J))},[Je,N]),a.useEffect(()=>{N&&me(N)},[N,me]),a.useEffect(()=>{if(j==="streaming"){m.current=0,le(!1);return}if(j!=="error"||!N||!Hg(se??""))return;const k=Math.min(8e3,700*2**m.current);m.current+=1,le(!0);const J=window.setTimeout(()=>{le(!1),me(N)},k);return()=>window.clearTimeout(J)},[j,se,N,me]),a.useEffect(()=>{const k=r.current;if(!k)return;const J=ce=>{const Re=s.current;if(!Re)return;ce.preventDefault();const Ee=Ua(k,ce.clientX,ce.clientY);Re.scroll(Ee.x,Ee.y,ce.deltaX,ce.deltaY)};return k.addEventListener("wheel",J,{passive:!1}),()=>k.removeEventListener("wheel",J)},[]);const Mn=k=>{const J=s.current,ce=r.current;if(!J||!ce)return;if(k.pointerType==="mouse"&&k.button!==0){k.preventDefault(),k.button===2?J.back():k.button===1&&J.home();return}k.preventDefault(),ce.setPointerCapture?.(k.pointerId),c.current={id:k.pointerId,type:k.pointerType};const Re=Ua(ce,k.clientX,k.clientY);J.pointerDown(Re.x,Re.y,k.pointerType);const Ee=$d(ce,k.clientX,k.clientY);Ee&&(Pe.current={left:Ee.left,top:Ee.top},ue([]),Ge(!1),M(Ee))},Or=k=>{const J=s.current,ce=r.current;if(!J||!ce||c.current?.id!==k.pointerId)return;k.preventDefault();const Re=Ua(ce,k.clientX,k.clientY);J.pointerMove(Re.x,Re.y,c.current.type);const Ee=$d(ce,k.clientX,k.clientY),ur=Pe.current;!Ee||!ur||(M(Ee),Math.hypot(Ee.left-ur.left,Ee.top-ur.top)>=6&&(Ge(!0),ue(gt=>{const Ur=gt[gt.length-1];if(Ur&&Math.hypot(Ee.left-Ur.x,Ee.top-Ur.y)<4)return gt;const Tt=[...gt,{x:Ee.left,y:Ee.top}];return Tt.length>12?Tt.slice(Tt.length-12):Tt})))},Br=k=>{const J=s.current,ce=r.current;if(!J||!ce||c.current?.id!==k.pointerId)return;const Re=Ua(ce,k.clientX,k.clientY);J.pointerUp(Re.x,Re.y,c.current.type),Ae&&ht(Ae),M(null),Ge(!1),window.setTimeout(()=>ue([]),200),c.current=null,Pe.current=null},qt=k=>{const J=s.current;J&&(k.key==="Backspace"?(k.preventDefault(),J.key(67)):k.key==="Escape"?(k.preventDefault(),J.back()):k.key==="Enter"&&(k.preventDefault(),J.key(66)))},dr=async()=>{const k=Se.trim();if(k){fe(!0);try{const J=await gg(k);xe(""),V(!1),await At(),F(J.serial)}catch(J){S(J instanceof Error?J.message:"ADB_CONNECT_FAILED")}finally{fe(!1)}}},wt=()=>{const k=s.current,J=Ze;!k||!J||(k.sendText(J),ke(""))},ot=j==="streaming",De=t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface text-foreground","data-sidebar-gesture-ignore":"true",onKeyDown:qt,tabIndex:-1,children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-border px-2 py-2",children:[t.jsx(Fi,{size:14,className:"shrink-0 text-muted-foreground"}),t.jsxs("select",{value:N,onChange:k=>{const J=k.target.value;F(J),h.current=J,J&&Ue({deviceSerial:J})},className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] text-foreground outline-none","aria-label":e("android.device"),children:[t.jsx("option",{value:"",children:Je.length?e("android.selectDevice"):e("android.noDevices")}),Je.map(k=>t.jsx("option",{value:k.serial,children:(k.model||k.serial)+Wg(k,e)},k.serial))]}),t.jsxs("select",{value:$?`user:${$}`:B,onChange:k=>Pt(k.target.value),className:"shrink-0 rounded bg-surface-2 px-1.5 py-1 text-[11px] text-foreground outline-none",title:e("android.quality"),"aria-label":e("android.quality"),children:[so.map(k=>t.jsx("option",{value:k.id,children:e(Td[k.id])},k.id)),E.map(k=>t.jsx("option",{value:`user:${k.id}`,children:k.name},k.id)),t.jsx("option",{value:"custom",children:e(Td.custom)})]}),t.jsx("button",{type:"button",onClick:()=>{At()},className:"rounded p-1.5 text-muted-foreground hover:bg-surface-2",title:e("android.refresh"),children:v?t.jsx(yt,{size:13,className:"animate-spin"}):t.jsx(ro,{size:13})}),ot?t.jsx("button",{type:"button",onClick:ee,className:"rounded p-1.5 text-destructive hover:bg-surface-2",title:e("android.disconnect"),children:t.jsx(_m,{size:13})}):t.jsx("button",{type:"button",onClick:()=>N&&me(N),disabled:!N,className:"rounded p-1.5 text-primary hover:bg-surface-2 disabled:opacity-40",title:e("android.connect"),children:t.jsx(Np,{size:13})}),t.jsx("button",{type:"button",onClick:()=>V(k=>!k),className:"rounded p-1.5 text-muted-foreground hover:bg-surface-2",title:e("android.addDevice"),children:t.jsx(os,{size:13})}),t.jsx("button",{type:"button",onClick:()=>{Fe&&st(Ba,_e?null:{sessionId:Fe,side:"right"})},disabled:!Fe,className:`rounded p-1.5 hover:bg-surface-2 disabled:opacity-40 ${_e?"text-primary":"text-muted-foreground"}`,title:e(_e?"android.splitClose":"android.splitOpen"),children:t.jsx(Dm,{size:13})})]}),(B==="custom"||$)&&t.jsxs("div",{className:"grid gap-2 border-b border-border bg-surface-2/40 px-2 py-2 text-[11px]",children:[t.jsx(Ld,{label:e("android.qualityResolution"),display:`${w.maxSize}p`,min:360,max:2160,step:8,value:w.maxSize,onChange:k=>O(J=>({...J,maxSize:k}))}),t.jsx(Ld,{label:e("android.qualityBitRate"),display:`${(w.bitRate/1e6).toFixed(1)} Mbps`,min:.5,max:20,step:.5,value:w.bitRate/1e6,onChange:k=>O(J=>({...J,bitRate:Math.round(k*1e6)}))}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:e("android.qualityFrameRate")}),t.jsxs("div",{className:"flex gap-1",children:[[15,30,60].map(k=>t.jsx("button",{type:"button",onClick:()=>O(J=>({...J,maxFps:k})),className:`rounded px-2 py-0.5 ${w.maxFps===k?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:k},k)),t.jsx("button",{type:"button",onClick:()=>O(k=>({...k,maxFps:0})),className:`rounded px-2 py-0.5 ${w.maxFps===0?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:e("android.qualityAuto")})]}),t.jsx("button",{type:"button",onClick:Ot,disabled:!N,className:"ml-auto rounded bg-primary/15 px-2 py-1 text-primary disabled:opacity-40",children:e("android.qualityApply")})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{value:_,onChange:k=>o(k.target.value),onKeyDown:k=>{k.key==="Enter"&&!k.nativeEvent.isComposing&&Yt()},placeholder:e("android.presetNamePlaceholder"),maxLength:40,className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:Yt,disabled:!_.trim(),className:"shrink-0 rounded bg-surface-2 px-2 py-1 text-primary disabled:opacity-40",children:e("android.presetSave")}),$&&t.jsx("button",{type:"button",onClick:Gt,className:"shrink-0 rounded px-2 py-1 text-destructive hover:bg-surface-2",children:e("android.presetDelete")})]})]}),R&&t.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border px-2 py-2",children:[t.jsx("input",{value:Se,onChange:k=>xe(k.target.value),onKeyDown:k=>{k.key==="Enter"&&dr()},placeholder:e("android.addressPlaceholder"),className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:()=>{dr()},disabled:Ve,className:"rounded bg-surface-2 px-2 py-1 text-[11px] text-primary disabled:opacity-40",children:Ve?t.jsx(yt,{size:12,className:"animate-spin"}):e("android.connect")})]}),vt&&t.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:e("android.adbUnavailable")}),!vt&&W&&t.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:e("android.scrcpyUnavailable")}),Ft&&Ft.state!=="device"&&t.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:Gg(Ft,e)}),f&&!vt&&t.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:Nd(f)}),z&&t.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:z}),t.jsxs("div",{className:"relative flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-[var(--chrome-bg)] p-1",children:[t.jsx("canvas",{ref:r,className:"max-h-full max-w-full touch-none select-none rounded",style:{display:ot||ge?"block":"none"},onPointerDown:Mn,onPointerMove:Or,onPointerUp:Br,onPointerCancel:Br,onContextMenu:k=>k.preventDefault()}),Ae&&t.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border border-primary/80 bg-primary/35",style:{left:Ae.left,top:Ae.top}}),te.length>1&&t.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 h-full w-full",style:{opacity:Le?1:0,transition:"opacity 160ms linear"},children:te.slice(1).map((k,J)=>{const ce=te[J],Re=(J+1)/(te.length-1);return t.jsx("line",{x1:ce.x,y1:ce.y,x2:k.x,y2:k.y,stroke:"var(--primary)",strokeWidth:1+1.6*Re,strokeLinecap:"round",opacity:.06+.45*Re},J)})}),we.map(k=>t.jsx("span",{"aria-hidden":"true",className:"termdock-tap-fade pointer-events-none absolute h-4 w-4 rounded-full bg-primary",style:{left:k.left,top:k.top}},k.id)),!ot&&t.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 text-center text-[11px] text-muted-foreground",children:[j==="connecting"&&t.jsxs(t.Fragment,{children:[t.jsx(yt,{size:18,className:"animate-spin"}),t.jsx("span",{children:e("android.connecting")})]}),j==="error"&&t.jsxs(t.Fragment,{children:[t.jsx(fp,{size:14,className:"text-destructive"}),t.jsx("span",{className:"max-w-[80%] text-destructive",children:ae?e("android.reconnecting"):Nd(se||"")}),N&&t.jsx("button",{type:"button",onClick:()=>{m.current=0,me(N)},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:e("android.retry")})]}),j==="idle"&&!vt&&!W&&t.jsxs(t.Fragment,{children:[t.jsx(Rp,{size:22,className:"opacity-60"}),t.jsx("span",{children:Je.length?e("android.idleHint"):e("android.noDevicesHint")})]})]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1 border-t border-border px-2 py-1.5",children:[t.jsx(_r,{label:e("android.back"),onClick:()=>s.current?.back(),disabled:!ot,children:t.jsx(as,{size:14})}),t.jsx(_r,{label:e("android.home"),onClick:()=>s.current?.home(),disabled:!ot,children:t.jsx(Wi,{size:14})}),t.jsx(_r,{label:e("android.recents"),onClick:()=>s.current?.recents(),disabled:!ot,children:t.jsx(Fm,{size:14})}),t.jsx(_r,{label:e("android.notifications"),onClick:()=>s.current?.expandNotifications(),disabled:!ot,children:t.jsx(Om,{size:14})}),t.jsx(_r,{label:e("android.rotate"),onClick:()=>s.current?.rotate(),disabled:!ot,children:t.jsx(Mu,{size:14})}),t.jsx(_r,{label:e("android.volumeDown"),onClick:()=>s.current?.volumeDown(),disabled:!ot,children:t.jsx(Op,{size:14})}),t.jsx(_r,{label:e("android.volumeUp"),onClick:()=>s.current?.volumeUp(),disabled:!ot,children:t.jsx(Au,{size:14})}),t.jsx(_r,{label:e("android.power"),onClick:()=>s.current?.power(),disabled:!ot,children:t.jsx(Mp,{size:14})}),t.jsx(_r,{label:e("android.inputText"),active:Xe,onClick:()=>Ie(k=>!k),disabled:!ot,children:t.jsx(Bm,{size:14})}),t.jsx("span",{className:"ml-auto whitespace-nowrap text-[10px] tabular-nums text-muted-foreground",children:ge?`${Q.fps} fps · ${Q.kbps} kbps · ${Q.width}×${Q.height}`:""})]}),Xe&&t.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border px-2 py-1.5",children:[t.jsx("input",{value:Ze,onChange:k=>ke(k.target.value),onKeyDown:k=>{k.key==="Enter"&&!k.nativeEvent.isComposing&&(k.preventDefault(),wt())},placeholder:e("android.inputPlaceholder"),className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground",autoFocus:!0}),t.jsx("button",{type:"button",onClick:wt,disabled:!Ze,className:"rounded bg-surface-2 p-1.5 text-primary disabled:opacity-40",title:e("android.send"),children:t.jsx(Gi,{size:13})})]})]});return _e&&Wt?t.jsxs(t.Fragment,{children:[Fr.createPortal(De,Wt),t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[t.jsx(hl,{size:18,className:"opacity-60"}),t.jsx("span",{children:e("android.splitDockedHint")}),t.jsx("button",{type:"button",onClick:()=>st(Ba,null),className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:e("android.splitClose")})]})]}):De}function Ld({label:e,display:r,min:s,max:i,step:d,value:c,onChange:h}){return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:e}),t.jsx("input",{type:"range",min:s,max:i,step:d,value:c,onChange:m=>h(Number(m.target.value)),className:"h-1 min-w-0 flex-1 accent-primary","aria-label":e}),t.jsx("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",children:r})]})}function _r({label:e,onClick:r,disabled:s,active:i,children:d}){return t.jsx("button",{type:"button",onClick:r,disabled:s,title:e,"aria-label":e,className:`rounded p-1.5 transition active:scale-95 disabled:opacity-30 ${i?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:d})}function $d(e,r,s){const i=e.parentElement;if(!i)return null;const d=e.getBoundingClientRect(),c=i.getBoundingClientRect();return{left:d.left-c.left+(r-d.left),top:d.top-c.top+(s-d.top)}}function Ua(e,r,s){const i=e.getBoundingClientRect(),d=e.width||i.width,c=e.height||i.height,h=i.width?(r-i.left)/i.width*d:0,m=i.height?(s-i.top)/i.height*c:0;return{x:Math.max(0,Math.min(d,h)),y:Math.max(0,Math.min(c,m))}}function Hg(e){return!(/ADB_NOT_FOUND|SCRCPY_NOT_FOUND|SCRCPY_SERVER_NOT_FOUND|SCRCPY_VERSION_UNKNOWN|SCRCPY_UNSUPPORTED_CODEC|VIDEO_DECODER_UNSUPPORTED|decoder|decode/i.test(e)||/INVALID_SERIAL|INVALID_ADDRESS|API_NOT_ALLOWED|AUTHORIZATION_DENIED/i.test(e))}function Wg(e,r){return e.state==="device"?e.androidVersion?` · Android ${e.androidVersion}`:"":e.state==="unauthorized"?` · ${r("android.stateUnauthorized")}`:e.state==="offline"?` · ${r("android.stateOffline")}`:` · ${r("android.stateUnknown")}`}function Gg(e,r){return e.state==="unauthorized"?r("android.unauthorizedHint"):e.state==="offline"?r("android.offlineHint"):r("android.stateUnknown")}function qg(e,r){const s=r.trim();if(!s)return e;if(!e.trim())return s;const i=e.endsWith(`
8
-
9
- `)?"":e.endsWith(`
10
- `)?`
11
- `:`
12
-
13
- `;return`${e}${i}${s}`}function Vg(e,r){const s=e.trim();return s?r?`${s}\r`:/\s$/.test(e)?e:`${s} `:""}const Yi="termdock:right-sidebar:html-view-mode-by-file:v1";function Kg(e){return e==="preview"||e==="source"}function Fu(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(Kg)}function Ou(e,r){if(!r)return null;const s=e&&!r.startsWith("/")?`${e}/${r}`:r;return e?`${e}::${s}`:s}function Id(e,r){const s=Ou(e,r);return s?mt(Yi,Fu)?.[s]??"source":"source"}function Yg(e,r,s){const i=Ou(e,r);if(!i)return;const d=mt(Yi,Fu)??{};Dt(Yi,{...d,[i]:s})}function _d(e){try{return new URL(e,location.href).pathname.startsWith("/api/")}catch{return!1}}function ho(e,r){const[s,i]=a.useState(()=>!!navigator.serviceWorker?.controller);return a.useEffect(()=>{if(!_d(e)||s)return;const d=navigator.serviceWorker,c=()=>i(!!d?.controller);d?.addEventListener("controllerchange",c),c();const h=window.setTimeout(()=>{d?.controller||r?.()},1e4);return()=>{d?.removeEventListener("controllerchange",c),window.clearTimeout(h)}},[e,s,r]),_d(e)&&!s?void 0:e}function yi(e){const r=Number.isFinite(e)&&e>0?Math.floor(e):0,s=Math.floor(r/3600),i=Math.floor(r%3600/60),d=r%60,c=String(i).padStart(2,"0"),h=String(d).padStart(2,"0");return s>0?`${s}:${c}:${h}`:`${c}:${h}`}function Xg(e,r,s){return!Number.isFinite(s)||s<=0||!r.width?0:Math.min(1,Math.max(0,(e-r.left)/r.width))*s}const sn=2,Jg=8,Qg=60,za=5,Dd=.05,Zg=900;function eb(e){return!Number.isFinite(e)||e<=0?sn:Math.min(Jg,sn+Math.floor(e/Qg))}const tb=350,rb=12,nb=90;function sb({url:e,onLoadError:r}){const s=ho(e,r),{t:i}=Mt(),d=a.useRef(null),c=a.useRef(null),h=a.useRef(null),m=a.useRef(null),p=a.useRef(!1),g=a.useRef(null),f=a.useRef(null),S=a.useRef(0),v=a.useRef(!1),P=a.useRef(!1),N=a.useRef(!1),F=a.useRef(null),B=a.useRef(null),A=a.useRef(!1),E=a.useRef(1),L=a.useRef(!1),[$,U]=a.useState(0),[_,o]=a.useState(0),[w,O]=a.useState(!1),[j,Y]=a.useState(!1),[se,ie]=a.useState(null),[ge,q]=a.useState(!1),[Q,T]=a.useState(0),[z,K]=a.useState(!1),[ae,le]=a.useState({width:0,height:0}),[we,be]=a.useState(sn),[Ae,M]=a.useState(1),[te,ue]=a.useState(null),Le=a.useRef(sn),Ge=a.useRef(null),Pe=a.useCallback(()=>{F.current!==null&&(clearTimeout(F.current),F.current=null)},[]),de=a.useCallback(()=>{Pe();const W=B.current;if(B.current=null,!A.current)return!1;const ee=h.current;if(ee&&(ee.playbackRate=E.current,W))try{ee.releasePointerCapture?.(W.id)}catch{}return A.current=!1,Le.current=sn,q(!1),!0},[Pe]);a.useEffect(()=>()=>{g.current!==null&&cancelAnimationFrame(g.current),f.current!==null&&clearTimeout(f.current),Ge.current!==null&&clearTimeout(Ge.current),Pe();const W=h.current;W&&A.current&&(W.playbackRate=E.current)},[Pe]),a.useEffect(()=>{const W=c.current;if(!W||typeof ResizeObserver>"u")return;const ee=new ResizeObserver(([me])=>{me&&le({width:me.contentRect.width,height:me.contentRect.height})});return ee.observe(W),()=>ee.disconnect()},[]),a.useEffect(()=>{const W=()=>K(document.fullscreenElement===d.current);return document.addEventListener("fullscreenchange",W),()=>document.removeEventListener("fullscreenchange",W)},[]);const Z=a.useCallback((W,ee=!1)=>{const me=h.current;if(!me)return!1;const Ue=Number.isFinite(me.duration)?me.duration:W,ht=Math.min(Math.max(W,0),Ue);if(o(ht),Math.abs(me.currentTime-ht)<1/120)return!1;const Pt=me.fastSeek;return ee&&typeof Pt=="function"?Pt.call(me,ht):me.currentTime=ht,!0},[]),R=a.useCallback(()=>{g.current===null&&(g.current=requestAnimationFrame(()=>{g.current=null;const W=h.current;if(!W||!v.current||P.current||W.seeking)return;const ee=N.current;N.current=!1,P.current=Z(S.current,!ee)}))},[Z]),V=a.useCallback(W=>{const ee=m.current,me=h.current;if(!ee||!me)return;const Ue=ee.getBoundingClientRect(),ht=Xg(W,Ue,me.duration);S.current=ht,ie(ht),N.current=!1,R(),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,N.current=!0,R()},nb)},[R]),Se=a.useCallback(()=>{g.current!==null&&(cancelAnimationFrame(g.current),g.current=null),f.current!==null&&(clearTimeout(f.current),f.current=null),N.current=!1,P.current=!1,Z(S.current)},[Z]),xe=a.useCallback(W=>{const ee=h.current;if(!(!ee||!Number.isFinite(ee.duration)||ee.duration<=0)){p.current=!ee.paused,ee.pause(),v.current=!0,Y(!0);try{W.currentTarget.setPointerCapture(W.pointerId)}catch{}V(W.clientX)}},[V]),Ve=a.useCallback(()=>{v.current=!1,Se(),Y(!1),ie(null);const W=h.current;W&&p.current&&!W.ended&&W.play().catch(()=>{}),p.current=!1},[Se]),fe=a.useCallback(()=>{const W=h.current;if(W){if(L.current){L.current=!1;return}W.paused?W.play().catch(()=>{}):W.pause()}},[]),Xe=a.useCallback(W=>{const ee=h.current;if(!ee)return;const me=Math.min(1,Math.max(0,Math.round((ee.volume+W)*100)/100));ee.volume=me,me>0&&(ee.muted=!1),M(me),ue(me),Ge.current!==null&&clearTimeout(Ge.current),Ge.current=setTimeout(()=>{Ge.current=null,ue(null)},Zg)},[]),Ie=a.useCallback(W=>{const ee=h.current;if(ee){if(W.key==="ArrowLeft"){W.preventDefault(),Z(ee.currentTime-(W.shiftKey?za*2:za));return}if(W.key==="ArrowRight"){W.preventDefault(),Z(ee.currentTime+(W.shiftKey?za*2:za));return}if(W.key==="ArrowUp"){W.preventDefault(),Xe(Dd);return}if(W.key==="ArrowDown"){W.preventDefault(),Xe(-Dd);return}(W.key===" "||W.key==="Spacebar"||W.key==="k"||W.key==="K")&&(W.preventDefault(),ee.paused?ee.play().catch(()=>{}):ee.pause())}},[Z,Xe]),Ze=a.useCallback(W=>{const ee=h.current;!ee||ee.paused||W.button!==0||(Pe(),B.current={id:W.pointerId,x:W.clientX,y:W.clientY},F.current=setTimeout(()=>{F.current=null;const me=B.current;if(E.current=ee.playbackRate,ee.playbackRate=sn,Le.current=sn,be(sn),A.current=!0,q(!0),me)try{ee.setPointerCapture?.(me.id)}catch{}},tb))},[Pe]),ke=a.useCallback(W=>{const ee=B.current;if(!ee||ee.id!==W.pointerId)return;if(!A.current){Math.hypot(W.clientX-ee.x,W.clientY-ee.y)>rb&&(Pe(),B.current=null);return}const me=eb(W.clientX-ee.x);if(me===Le.current)return;Le.current=me,be(me);const Ue=h.current;Ue&&(Ue.playbackRate=me)},[Pe]),Fe=a.useCallback(()=>{de()&&(L.current=!0)},[de]);a.useEffect(()=>(window.addEventListener("pointerup",Fe),window.addEventListener("pointercancel",Fe),window.addEventListener("blur",Fe),()=>{window.removeEventListener("pointerup",Fe),window.removeEventListener("pointercancel",Fe),window.removeEventListener("blur",Fe)}),[Fe]);const _e=a.useCallback(async()=>{const W=d.current,ee=h.current;if(!(!W||!ee))try{document.fullscreenElement===W?await document.exitFullscreen():W.requestFullscreen?await W.requestFullscreen():ee.webkitEnterFullscreen?.()}catch{ee.webkitEnterFullscreen?.()}},[]),Wt=a.useCallback(()=>T(W=>(W+90)%360),[]),st=a.useCallback(W=>{const ee=h.current;if(!ee||!Number.isFinite(ee.duration))return;const me=W.shiftKey?10:5;let Ue=null;W.key==="ArrowLeft"?Ue=ee.currentTime-me:W.key==="ArrowRight"?Ue=ee.currentTime+me:W.key==="Home"?Ue=0:W.key==="End"&&(Ue=ee.duration),Ue!==null&&(W.preventDefault(),Z(Ue))},[Z]),At=j&&se!==null?se:_,Je=$>0?Math.min(1,Math.max(0,At/$)):0,vt=(Q===90||Q===270)&&ae.width>0&&ae.height>0?{width:`${ae.height}px`,height:`${ae.width}px`}:{width:"100%",height:"100%"};return t.jsxs("div",{ref:d,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":Q,children:[t.jsxs("div",{ref:c,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[t.jsx("video",{ref:h,"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",style:{...vt,transform:`translate(-50%, -50%) rotate(${Q}deg)`},src:s,preload:"auto",playsInline:!0,tabIndex:0,onClick:fe,onKeyDown:Ie,onVolumeChange:W=>M(W.currentTarget.volume),onPointerDown:Ze,onPointerMove:ke,onPointerUp:Fe,onPointerCancel:Fe,onContextMenu:W=>{A.current&&W.preventDefault()},onPlay:()=>O(!0),onPause:()=>O(!1),onTimeUpdate:W=>o(W.currentTarget.currentTime),onSeeked:W=>{const ee=W.currentTarget;if(o(ee.currentTime),P.current=!1,!v.current)return;const me=ee.requestVideoFrameCallback;typeof me=="function"?me.call(ee,()=>{v.current&&R()}):requestAnimationFrame(()=>{v.current&&R()})},onLoadedMetadata:W=>U(Number.isFinite(W.currentTarget.duration)?W.currentTarget.duration:0),onDurationChange:W=>U(Number.isFinite(W.currentTarget.duration)?W.currentTarget.duration:0),onError:r,children:i("rightSidebar.videoUnsupported")}),ge&&t.jsx("div",{className:"pointer-events-none absolute left-1/2 top-3 z-10 -translate-x-1/2 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md",children:i("rightSidebar.videoLongPressSpeed",{rate:String(we)})}),te!==null&&t.jsxs("div",{className:"pointer-events-none absolute right-3 top-3 z-10 inline-flex items-center gap-1 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md","data-testid":"file-preview-video-volume",children:[t.jsx(Au,{size:13}),i("rightSidebar.videoVolume",{percent:Math.round(Ae*100)})]}),j&&se!==null&&t.jsx("div",{className:"pointer-events-none absolute bottom-1 z-10 -translate-x-1/2 rounded-md bg-surface-elevated px-2 py-1 text-[11px] font-medium text-foreground shadow-md",style:{left:`${Je*100}%`},"data-testid":"file-preview-video-scrub-time",children:yi(se)})]}),t.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${rp}`,[np]:"",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:fe,"aria-label":i(w?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:i(w?"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:w?t.jsx(Um,{size:14}):t.jsx(zm,{size:14})}),t.jsxs("div",{ref:m,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor($),"aria-valuenow":Math.floor(At),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:xe,onPointerMove:W=>{j&&V(W.clientX)},onPointerUp:Ve,onPointerCancel:Ve,onKeyDown:st,children:[t.jsx("div",{className:"h-1 w-full rounded-full bg-surface-elevated"}),t.jsx("div",{className:"absolute inset-y-0 left-0 my-auto h-1 rounded-full bg-primary",style:{width:`${Je*100}%`}}),t.jsx("div",{className:"absolute top-1/2 h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary shadow",style:{left:`${Je*100}%`}})]}),t.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[yi(At)," / ",yi($)]}),t.jsx("button",{type:"button",onClick:Wt,"aria-label":i("rightSidebar.videoRotate"),title:i("rightSidebar.videoRotate"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-rotate",children:t.jsx(Mu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>{_e()},"aria-label":i(z?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:i(z?"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:z?t.jsx(Sp,{size:14}):t.jsx(wp,{size:14})})]})})]})}function ab(e){const r=Math.max(0,Math.min(100,e.xPercent)),s=Math.max(0,Math.min(100,e.yPercent));return{...r<=50?{left:`calc(${r}% + 8px)`}:{right:`calc(${100-r}% + 8px)`},...s<=50?{top:`calc(${s}% + 8px)`}:{bottom:`calc(${100-s}% + 8px)`}}}function mo({anchor:e,children:r,disabled:s=!1,onClick:i,title:d}){return t.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:s,onClick:c=>{c.stopPropagation(),i()},title:d,style:ab(e),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[t.jsx(no,{size:11}),r]})}function ob(e,r,s,i){if(s.width<=0||s.height<=0||i.width<=0||i.height<=0)return null;const d=Math.min(s.width/i.width,s.height/i.height);if(!Number.isFinite(d)||d<=0)return null;const c=i.width*d,h=i.height*d,m=s.left+(s.width-c)/2,p=s.top+(s.height-h)/2,g=e-m,f=r-p;if(g<0||f<0||g>c||f>h)return null;const S=g/c*100,v=f/h*100;return{x:i.x+i.width*S/100,y:i.y+i.height*v/100,xPercent:S,yPercent:v}}function ib(e,r,s){const i=[`SVG标注: ${e}`,`视图: ${r}`,`SVG坐标: (${s.x.toFixed(2)},${s.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return s.nearestText&&i.push(`最近文字: ${s.nearestText}`),`"${i.join(" / ")}"`}function lb(e){const r=new DOMParser().parseFromString(e,"image/svg+xml"),s=r.documentElement;if(s.nodeName.toLowerCase()!=="svg"||r.querySelector("parsererror"))throw new Error("Invalid SVG document");return r.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(i=>i.remove()),r.querySelectorAll("*").forEach(i=>{for(const d of Array.from(i.attributes)){const c=d.name.toLowerCase(),h=d.value.trim();(c.startsWith("on")||(c==="href"||c.endsWith(":href"))&&h&&!h.startsWith("#"))&&i.removeAttribute(d.name)}}),s.removeAttribute("width"),s.removeAttribute("height"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(s)}function cb(e,r,s){let i=null;for(const d of Array.from(e.querySelectorAll("text"))){const c=(d.textContent??"").replace(/\s+/g," ").trim();if(!c)continue;const h=Number(d.getAttribute("x")),m=Number(d.getAttribute("y"));if(!Number.isFinite(h)||!Number.isFinite(m))continue;const p=Math.hypot(h-r,m-s);(!i||p<i.distance)&&(i={text:c,distance:p})}return i?.text.slice(0,120)}function Bu({blobUrl:e,filePath:r,viewLabel:s,onInsertAnnotation:i}){const d=a.useRef(null),c=a.useRef(null),[h,m]=a.useState(null),[p,g]=a.useState(null),[f,S]=a.useState(1),[v,P]=a.useState(!1),[N,F]=a.useState(null),B=a.useRef(new Map),A=a.useRef(null),E=a.useRef(!1),L=a.useRef(null),$=a.useRef(f);$.current=f,a.useEffect(()=>{const T=new AbortController;return m(null),g(null),F(null),S(1),fetch(e,{signal:T.signal}).then(z=>z.text()).then(z=>m(lb(z))).catch(z=>{T.signal.aborted||g(z instanceof Error?z.message:"SVG preview failed")}),()=>T.abort()},[e]),a.useEffect(()=>{if(!v)return;const T=z=>{z.key==="Escape"&&P(!1)};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[v]),a.useLayoutEffect(()=>{const T=c.current,z=T?.querySelector("[data-svg-document] > svg");if(!T||!z)return;let K;try{K=z.getBBox()}catch{return}if(!K.width||!K.height)return;const ae=Math.max(2,Math.min(K.width,K.height)*.025);z.setAttribute("viewBox",`${K.x-ae} ${K.y-ae} ${K.width+2*ae} ${K.height+2*ae}`),z.style.width=`${f*100}%`,z.style.height=`${f*100}%`,z.style.minWidth=`${f*100}%`,z.style.minHeight=`${f*100}%`,z.style.display="block"},[h,f]);const U=a.useMemo(()=>N?ib(r,s,N):null,[r,N,s]),_=T=>{if(E.current){E.current=!1;return}const z=c.current,K=z?.querySelector("[data-svg-document] > svg"),ae=d.current;if(!z||!K||!ae)return;const le=K.viewBox.baseVal,we=ob(T.clientX,T.clientY,K.getBoundingClientRect(),le);if(!we)return;const be=ae.getBoundingClientRect();F({...we,nearestText:cb(K,we.x,we.y),stageX:T.clientX-be.left,stageY:T.clientY-be.top,stageXPercent:(T.clientX-be.left)/be.width*100,stageYPercent:(T.clientY-be.top)/be.height*100})},o=T=>Math.max(1,Math.min(12,T)),w=(T,z)=>{const K=o(z),ae=T.querySelector("[data-svg-document] > svg");if(!ae)return K;const le=`${K*100}%`;return ae.style.width=le,ae.style.height=le,ae.style.minWidth=le,ae.style.minHeight=le,$.current=K,K},O=(T,z,K,ae)=>{const le=$.current,we=T.getBoundingClientRect(),be=K-we.left,Ae=ae-we.top,M=(T.scrollLeft+be)/le,te=(T.scrollTop+Ae)/le,ue=w(T,z);return T.scrollLeft=M*ue-be,T.scrollTop=te*ue-Ae,ue},j=()=>{const T=Array.from(B.current.values());return T.length>=2?Math.hypot(T[0].x-T[1].x,T[0].y-T[1].y):0},Y=T=>{if(T.pointerType==="mouse"&&T.button!==0)return;const z=c.current;z&&(B.current.set(T.pointerId,{x:T.clientX,y:T.clientY}),z.setPointerCapture?.(T.pointerId),B.current.size>=2?(A.current={kind:"pinch",startX:T.clientX,startY:T.clientY,startScrollLeft:z.scrollLeft,startScrollTop:z.scrollTop,startDistance:j(),startZoom:$.current,moved:!1},E.current=!0):$.current>1&&(A.current={kind:"pan",startX:T.clientX,startY:T.clientY,startScrollLeft:z.scrollLeft,startScrollTop:z.scrollTop,startZoom:$.current,moved:!1}))},se=T=>{if(!B.current.has(T.pointerId))return;B.current.set(T.pointerId,{x:T.clientX,y:T.clientY});const z=c.current,K=A.current;if(!(!z||!K)){if(B.current.size>=2&&K.kind==="pinch"){const ae=j();if(!K.startDistance||!ae)return;const le=o(K.startZoom*ae/K.startDistance);if(Math.abs(le-$.current)<.01)return;const we=Array.from(B.current.values()),be=(we[0].x+we[1].x)/2,Ae=(we[0].y+we[1].y)/2;K.moved=!0,E.current=!0,O(z,le,be,Ae),T.preventDefault();return}if(K.kind==="pan"&&B.current.size===1){const ae=T.clientX-K.startX,le=T.clientY-K.startY;if(!K.moved&&Math.hypot(ae,le)<6)return;K.moved=!0,E.current=!0,z.scrollLeft=K.startScrollLeft-ae,z.scrollTop=K.startScrollTop-le,T.preventDefault()}}},ie=T=>{const z=c.current,K=A.current,ae=B.current.size===1&&!K?.moved;B.current.delete(T.pointerId);try{z?.releasePointerCapture?.(T.pointerId)}catch{}if(B.current.size===1&&K?.kind==="pinch"){const be=Array.from(B.current.values())[0];A.current=z?{kind:"pan",startX:be.x,startY:be.y,startScrollLeft:z.scrollLeft,startScrollTop:z.scrollTop,startZoom:$.current,moved:!1}:null;return}if(B.current.size>0||(A.current=null,K?.kind==="pinch"&&S($.current),!ae||E.current))return;const le=Date.now(),we=L.current;we&&le-we.time<350&&Math.hypot(T.clientX-we.x,T.clientY-we.y)<24?(L.current=null,E.current=!0,S(be=>be>1?1:2.5)):L.current={time:le,x:T.clientX,y:T.clientY}},ge=T=>{if(!T.ctrlKey&&!T.metaKey)return;const z=c.current;if(!z)return;T.preventDefault();const K=O(z,$.current*Math.exp(-T.deltaY*.01),T.clientX,T.clientY);S(K)},q=()=>{S(1),$.current=1,c.current&&(c.current.scrollLeft=0,c.current.scrollTop=0)},Q=t.jsxs("div",{className:v?"fixed inset-0 z-modal-panel flex min-h-0 flex-col bg-surface pt-[env(safe-area-inset-top,0px)]":"flex h-full min-h-0 flex-col bg-surface",children:[t.jsxs("div",{ref:d,className:"relative min-h-0 flex-1",children:[t.jsx("div",{ref:c,role:"button",tabIndex:0,onClick:_,onDoubleClick:T=>{T.preventDefault(),S(z=>z>1?1:2.5)},onPointerDown:Y,onPointerMove:se,onPointerUp:ie,onPointerCancel:ie,onWheel:ge,onScroll:()=>F(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:p?t.jsx("div",{className:"p-4 text-sm text-destructive",children:p}):h?t.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:h}}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),N&&t.jsx("span",{"data-svg-pick-marker":!0,className:"pointer-events-none absolute z-10 h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm",style:{left:N.stageX,top:N.stageY}}),N&&U&&t.jsx(mo,{anchor:{xPercent:N.stageXPercent,yPercent:N.stageYPercent},title:"引用 SVG 标注",onClick:()=>{i?.(U,`svg:${N.x.toFixed(2)}:${N.y.toFixed(2)}`),F(null)},children:"引用 SVG 标注"}),t.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[f>1.001&&t.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:T=>{T.stopPropagation(),q()},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:t.jsx($p,{size:14})}),t.jsx("button",{type:"button","aria-label":v?"退出全屏 SVG":"全屏 SVG",title:v?"退出全屏 SVG":"全屏 SVG",onClick:T=>{T.stopPropagation(),P(z=>!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:v?t.jsx(ku,{size:14}):t.jsx(hl,{size:14})})]})]}),t.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:t.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:N?`SVG (${N.x.toFixed(2)}, ${N.y.toFixed(2)}) · ${N.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return v?Fr.createPortal(Q,document.body):Q}function Za(e){switch(e){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function db(e,r,s,i){const d=[`电子标注: ${e}`,`视图: ${Za(r)}`,`图片位置: (${s.xPercent.toFixed(1)}%,${s.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(i?.available&&i.xMm!==void 0&&i.yMm!==void 0&&(d.push(`PCB坐标: (${i.xMm.toFixed(2)},${i.yMm.toFixed(2)})mm [KiCad板坐标]`),i.layer&&d.push(`显示层: ${i.layer}`),i.nearest)){const c=[i.nearest.net?`网络 ${i.nearest.net}`:null,`对象层 ${i.nearest.layer}`,`距离 ${i.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");d.push(`最近对象: ${i.nearest.label}${c?`(${c})`:""}`)}return`"${d.join(" / ")}"`}function ub({blobUrl:e,filePath:r,view:s,board:i,onViewChange:d,onInsertAnnotation:c,onRefresh:h,interactive3d:m}){const{t:p}=Mt(),g=a.useRef(null),f=a.useRef(null),S=a.useRef(null),[v,P]=a.useState(null),[N,F]=a.useState(!1);a.useEffect(()=>(S.current?.abort(),P(null),F(!1),()=>S.current?.abort()),[e,s]);const B=a.useMemo(()=>v?db(r,s,v,v.inspection):null,[r,v,s]),A=L=>{const $=g.current,U=f.current;if(!$||!U||!U.naturalWidth||!U.naturalHeight)return;const _=$.getBoundingClientRect(),o=U.getBoundingClientRect(),w=Math.min(o.width/U.naturalWidth,o.height/U.naturalHeight),O=U.naturalWidth*w,j=U.naturalHeight*w,Y=o.left+(o.width-O)/2,se=o.top+(o.height-j)/2,ie=L.clientX-Y,ge=L.clientY-se;if(ie<0||ge<0||ie>O||ge>j)return;const q={xPercent:Math.max(0,Math.min(100,ie/O*100)),yPercent:Math.max(0,Math.min(100,ge/j*100)),stageXPercent:(L.clientX-_.left)/_.width*100,stageYPercent:(L.clientY-_.top)/_.height*100,inspecting:i&&s!=="pcb-3d"};if(P(q),S.current?.abort(),!q.inspecting)return;const Q=new AbortController;S.current=Q,tm(r,s,q.xPercent,q.yPercent,Q.signal).then(T=>P(z=>z===q?{...z,inspection:T,inspecting:!1}:z)).catch(()=>{Q.signal.aborted||P(T=>T===q?{...T,inspection:{available:!1},inspecting:!1}:T)})},E=i?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:E.map(L=>t.jsx("button",{type:"button",onClick:()=>d(L),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${L===s?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:Za(L)},L))}),t.jsx("button",{type:"button",onClick:h,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:p("rightSidebar.edaRefresh"),"aria-label":p("rightSidebar.edaRefresh"),children:t.jsx(ro,{size:13})})]}),i&&m?t.jsx("div",{className:s==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:m}):null,i?s==="pcb-3d"?m?null:t.jsx("div",{className:"min-h-0 flex-1"}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:g,role:"button",tabIndex:0,onClick:A,onKeyDown:L=>{L.key!=="Enter"&&L.key!==" "||(L.preventDefault(),P({xPercent:50,yPercent:50,stageXPercent:50,stageYPercent:50}))},className:"relative min-h-0 flex-1 cursor-crosshair overflow-hidden bg-surface p-3 outline-none",title:p("rightSidebar.edaPickHint"),children:[t.jsx("img",{ref:f,src:e,alt:`${r} ${Za(s)}`,onLoad:()=>F(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${N?"opacity-100":"opacity-0"}`}),v&&t.jsx("span",{className:"pointer-events-none absolute h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-surface shadow-sm",style:{left:`${v.stageXPercent}%`,top:`${v.stageYPercent}%`}}),v&&B&&t.jsx(mo,{anchor:{xPercent:v.stageXPercent,yPercent:v.stageYPercent},disabled:v.inspecting,title:p("rightSidebar.edaInsertAnnotation"),onClick:()=>{c?.(B,`eda:${s}:${v.xPercent.toFixed(1)}:${v.yPercent.toFixed(1)}`,{snapshot:f.current?Gp(f.current,v):Promise.resolve(null)}),P(null)},children:p("rightSidebar.edaInsertAnnotation")})]}),t.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:t.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:v?v.inspecting?p("rightSidebar.edaInspecting"):v.inspection?.available?p("rightSidebar.edaPickedBoardPosition",{x:v.inspection.xMm?.toFixed(2)??"—",y:v.inspection.yMm?.toFixed(2)??"—",object:v.inspection.nearest?.label??p("rightSidebar.edaNoNearbyObject")}):p("rightSidebar.edaPickedPosition",{x:v.xPercent.toFixed(1),y:v.yPercent.toFixed(1)}):p("rightSidebar.edaPickHint")})})]}):t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Bu,{blobUrl:e,filePath:r,viewLabel:Za(s),onInsertAnnotation:c})})]})}function fb(e){const r=[];let s=[],i="",d=!1;for(let c=0;c<e.length;c+=1){const h=e[c];d?h==='"'&&e[c+1]==='"'?(i+='"',c+=1):h==='"'?d=!1:i+=h:h==='"'?d=!0:h===","?(s.push(i),i=""):h===`
14
- `?(s.push(i.replace(/\r$/,"")),r.push(s),s=[],i=""):i+=h}return(i||s.length>0)&&(s.push(i.replace(/\r$/,"")),r.push(s)),r}function hb(e,r,s,i,d){const c=r[d]||`第${d+1}列`,h=s[d]??"",m=r.map((p,g)=>`${p||`第${g+1}列`}=${s[g]??""}`).join(";");return`"表格标注: ${e} / 数据行: ${i+1} / 列: ${c} / 值: ${h} / 记录: ${m}"`}function mb({content:e,filePath:r,onInsertAnnotation:s}){const{t:i}=Mt(),d=a.useMemo(()=>fb(e),[e]),c=d[0]??[],h=d.slice(1),m=a.useRef(null),[p,g]=a.useState(null),f=p?h[p.row]:null,S=p&&f?hb(r,c,f,p.row+1,p.column):null;return t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[t.jsxs("div",{ref:m,className:"relative min-h-0 flex-1",children:[t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("table",{className:"min-w-full border-separate border-spacing-0 text-left text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:"sticky left-0 top-0 z-20 border-b border-r border-border/20 bg-surface-elevated px-2 py-2 text-[10px] font-semibold text-muted-foreground",children:"#"}),c.map((v,P)=>t.jsx("th",{className:"sticky top-0 z-10 min-w-28 border-b border-r border-border/20 bg-surface-elevated px-3 py-2 font-semibold text-foreground",children:v||i("rightSidebar.csvUnnamedColumn",{index:P+1})},`${v}:${P}`))]})}),t.jsx("tbody",{children:h.map((v,P)=>t.jsxs("tr",{className:"hover:bg-surface-2",children:[t.jsx("th",{className:"sticky left-0 z-10 border-b border-r border-border/15 bg-surface px-2 py-2 text-right text-[10px] font-normal text-muted-foreground",children:P+1}),c.map((N,F)=>{const B=p?.row===P&&p.column===F;return t.jsx("td",{className:`border-b border-r border-border/15 p-0 ${B?"bg-primary/15":""}`,children:t.jsx("button",{type:"button",onClick:A=>{const E=m.current?.getBoundingClientRect(),L=A.currentTarget.getBoundingClientRect();if(!E?.width||!E.height)return;const $=A.clientX||L.left+L.width/2,U=A.clientY||L.top+L.height/2;g({row:P,column:F,xPercent:($-E.left)/E.width*100,yPercent:(U-E.top)/E.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:v[F]||" "})},`cell:${P}:${F}`)})]},`row:${P}`))})]})}),p&&S&&t.jsx(mo,{anchor:{xPercent:p.xPercent,yPercent:p.yPercent},title:i("rightSidebar.csvInsertAnnotation"),onClick:()=>{s?.(S,`csv:${r}:${p.row+1}:${p.column+1}`),g(null)},children:i("rightSidebar.csvInsertAnnotation")})]}),t.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:t.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:p&&f?i("rightSidebar.csvSelectedCell",{row:p.row+1,column:c[p.column]||p.column+1}):i("rightSidebar.csvPickHint",{rows:h.length,columns:c.length})})})]})}function Zn(e,r){let s=e;for(const i of r){if(!s||typeof s!="object")return;s=s[i]}return s}function pb(e,r){const s=JSON.parse(e),i=Zn(s,["meta","version"]);if(r)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(i??"未知")},{label:"活动层编号",value:String(Zn(s,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(Zn(s,["board","visible_layers"])??"未知")},{label:"Git 集成",value:Zn(s,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const d=Zn(s,["net_settings","classes"]),c=Array.isArray(d)?d.find(m=>m&&typeof m=="object"&&m.name==="Default"):void 0,h=Zn(s,["board","design_settings","drc_exclusions"]);return[{label:"文件性质",value:"KiCad 工程配置"},{label:"格式版本",value:String(i??"未知")},{label:"网络类数量",value:String(Array.isArray(d)?d.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(h)?h.length:0)}]}function gb(e,r){return`"KiCad项目标注: ${e} / 项: ${r.label} / 值: ${r.value}"`}function bb({content:e,filePath:r,localState:s,onInsertAnnotation:i}){const{t:d}=Mt(),c=a.useRef(null),[h,m]=a.useState(null),p=a.useMemo(()=>{try{return{items:pb(e,s),error:null}}catch(f){return{items:[],error:f instanceof Error?f.message:String(f)}}},[e,s]),g=h===null?null:p.items[h.index];return p.error?t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-3 font-mono text-xs text-foreground",children:e}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[s&&t.jsx("div",{className:"border-b border-[color:var(--warning)]/20 bg-[color:var(--warning)]/5 px-3 py-2 text-xs text-[color:var(--warning)]",children:d("rightSidebar.kicadLocalStateNotice")}),t.jsxs("div",{ref:c,className:"relative min-h-0 flex-1",children:[t.jsxs("div",{className:"h-full overflow-auto px-3 py-2",children:[t.jsx("div",{className:"divide-y divide-border/15",children:p.items.map((f,S)=>t.jsxs("button",{type:"button",onClick:v=>{const P=c.current?.getBoundingClientRect(),N=v.currentTarget.getBoundingClientRect();if(!P?.width||!P.height)return;const F=v.clientX||N.left+N.width/2,B=v.clientY||N.top+N.height/2;m({index:S,xPercent:(F-P.left)/P.width*100,yPercent:(B-P.top)/P.height*100})},className:`grid w-full grid-cols-[minmax(7rem,0.8fr)_minmax(0,1.4fr)] gap-3 px-2 py-3 text-left transition hover:bg-surface-2 ${h?.index===S?"bg-primary/10":""}`,children:[t.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:f.label}),t.jsx("span",{className:"break-words text-xs text-foreground",children:f.value})]},f.label))}),t.jsxs("details",{className:"mt-3 border-t border-border/15 pt-3",children:[t.jsx("summary",{className:"cursor-pointer text-xs font-semibold text-muted-foreground",children:d("rightSidebar.kicadShowRawJson")}),t.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre p-2 font-mono text-[10px] leading-relaxed text-foreground",children:e})]})]}),g&&h&&t.jsx(mo,{anchor:{xPercent:h.xPercent,yPercent:h.yPercent},title:d("rightSidebar.kicadInsertSetting"),onClick:()=>{i?.(gb(r,g),`kicad-project:${r}:${g.label}`),m(null)},children:d("rightSidebar.kicadInsertSetting")})]}),t.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:t.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:g?`${g.label}: ${g.value}`:d("rightSidebar.kicadProjectPickHint")})})]})}const xb=`/** 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
- `,yb=`/* 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
- `,Ha="/api/terminal/fs/preview/",vb=8*1024*1024,wb=32*1024*1024,kb=128,Sb="data:,";function Ht(e){throw new Error(e)}function jb(e){return JSON.stringify(e).replace(/</g,"\\u003c")}async function Fd(e,r,s){let i="",d=0;for(const c of e.matchAll(r))i+=e.slice(d,c.index)+await s(c),d=c.index+c[0].length;return i+e.slice(d)}async function Uu(e,r){const s=r.origin??location.origin,i=new URL(e,s);(i.origin!==s||!Rs(i.pathname)?.startsWith(Ha))&&Ht("预览地址不是有效的本地文件入口");const d=crypto.randomUUID(),c=`https://termdock-preview.invalid/${d}/`,h=[],m=q=>{!h.includes(q)&&h.length<20&&h.push(q)},p=new Set,g=[],f=new Set,S=new Map,v=new Map;let P=0,N=!1;const F=new Set,B=()=>{N=!0;for(const q of[...F])q();p.clear(),g.length=0};async function A(q){q.ok||Ht(`预览资源读取失败(${q.status})`);const Q=q.body?.getReader(),T=[];let z=0;try{if(Q)for(;;){const le=await Q.read();if(le.done)break;z+=le.value.byteLength,P+=le.value.byteLength,(z>vb||P>wb)&&Ht("预览资源超出大小限制"),T.push(le.value)}}catch(le){throw await Q?.cancel().catch(()=>{}),le}finally{Q?.releaseLock()}const K=new Uint8Array(z);let ae=0;for(const le of T)K.set(le,ae),ae+=le.length;return{bytes:K,type:q.headers.get("content-type")??"application/octet-stream",status:q.status}}let E=i,L;for(let q=0;q<4;q++){const Q=await r.fetch(E.pathname+E.search,{signal:r.signal,redirect:"manual"});if(![301,302,303,307,308].includes(Q.status)){L=Q;break}const T=Q.headers.get("location");await Q.body?.cancel(),T||Ht("预览重定向缺少目标");const z=new URL(T,E);(z.origin!==s||!Rs(z.pathname)?.startsWith(Ha))&&Ht("预览重定向越出文件范围"),E=z}L||Ht("预览重定向次数过多");const $=Rs(E.pathname),U=$.slice(Ha.length).split("/");/^[a-f0-9]{32}$/.test(U[0])||Ht("服务未提供有效的预览资源授权");const _=Rs(i.pathname).slice(Ha.length).split("/");/^[a-f0-9]{32}$/.test(_[0])&&_.shift(),_.join("/").replace(/\/$/,"")!==U.slice(1).join("/").replace(/\/$/,"")&&Ht("预览重定向改变了文件范围");const o=$.endsWith("/")?$:$.slice(0,$.lastIndexOf("/")+1),w=new URL(E.pathname.endsWith("/")?E.pathname:E.pathname.slice(0,E.pathname.lastIndexOf("/")+1),s);function O(q,Q){const T=new URL(q,Q);return T.origin!==s?null:(Rs(T.pathname)?.startsWith(o)||Ht("已阻止预览访问目录之外的资源"),T)}function j(q){const Q=new URL(q,c);(Q.origin!==new URL(c).origin||!Q.pathname.startsWith(new URL(c).pathname))&&Ht("已阻止预览访问服务接口或目录之外的资源");const T=Q.pathname.slice(new URL(c).pathname.length)+Q.search;return O(T,w)??Ht("预览资源无效")}function Y(q){const Q=q.pathname+q.search,T=S.get(Q);if(T)return T;if(N||r.signal?.aborted)return Promise.reject(new Error("预览已关闭"));if(S.size>=kb)return Promise.reject(new Error("预览资源数量超出限制"));const z=r.fetch(Q,{signal:r.signal,redirect:"manual"}).then(A);return S.set(Q,z),z}function se(q,Q){N&&Ht("预览已关闭");const T=`termdock-resource-${d}-${g.length}`;return g.push({token:T,data:q,type:Q}),p.add(T),T}async function ie(q,Q,T,z=new Set){if(!q||q.startsWith("#")||/^data:(?:image|font)\//i.test(q)&&T==="resource")return q;try{const K=O(q,Q);if(!K){const Ae=new URL(q,Q);return(Ae.protocol!=="https:"||Ae.username||Ae.password||Ae.origin===new URL(c).origin)&&Ht("已阻止不安全的外部资源"),f.add(Ae.origin),Ae.href}const ae=`${T}:${K.href}`;(z.has(ae)||z.size>=8)&&Ht("预览资源存在循环或过深引用");const le=v.get(ae);if(le)return le;const we=new Set(z);we.add(ae);const be=(async()=>{const Ae=await Y(K);return T==="css"?se(await ge(new TextDecoder().decode(Ae.bytes),K,we),"text/css"):T==="script"?se(Ae.bytes,"text/javascript"):se(Ae.bytes,Ae.type)})();return v.set(ae,be),await be}catch(K){return m(K instanceof Error?K.message:"部分预览资源未能加载"),Sb}}async function ge(q,Q,T){return q=await Fd(q,/@import\s+(?:url\(\s*)?["']([^"']+)["']\s*\)?([^;]*);/gi,async z=>`@import url("${await ie(z[1],Q,"css",T)}")${z[2]};`),Fd(q,/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)/gi,async z=>{const K=(z[1]??z[2]??z[3]).trim();return p.has(K)?z[0]:`url("${await ie(K,Q,"resource",T)}")`})}try{const q=await A(L),Q=se(xb,"text/javascript"),T=new DOMParser().parseFromString(new TextDecoder().decode(q.bytes),"text/html");T.querySelectorAll("base,meta[http-equiv],iframe,frame,object,embed").forEach(M=>M.remove());for(const M of T.querySelectorAll("*")){if(M.removeAttribute("ping"),M.removeAttribute("srcdoc"),M.hasAttribute("style")&&M.setAttribute("style",await ge(M.getAttribute("style"),E,new Set)),M.tagName==="STYLE"&&(M.textContent=await ge(M.textContent??"",E,new Set)),M.tagName==="A"||M.tagName==="AREA"){const te=M.getAttribute("href");try{if(te&&!te.startsWith("#")){const ue=O(te,E);if(ue)M.setAttribute("href",new URL(ue.pathname.slice(w.pathname.length)+ue.search+ue.hash,c).href);else{const Le=new URL(te,E);if(Le.protocol!=="https:"){M.removeAttribute("href");continue}f.add(Le.origin),M.setAttribute("href",Le.href)}}}catch(ue){M.removeAttribute("href"),m(ue instanceof Error?ue.message:"预览链接无法加载")}}for(const te of["data","manifest"])M.removeAttribute(te);if(M.tagName==="SCRIPT"&&M.getAttribute("type")==="module"){M.setAttribute("type","module-shim");const te=M.getAttribute("src");if(te){const ue=O(te,E);if(ue)M.setAttribute("src",new URL(ue.pathname.slice(w.pathname.length)+ue.search,c).href);else{const Le=new URL(te,E);if(Le.protocol!=="https:"){M.remove();continue}f.add(Le.origin),M.setAttribute("src",Le.href)}}continue}if(M.tagName==="SCRIPT"&&M.getAttribute("type")==="importmap"){M.setAttribute("type","importmap-shim");continue}if(M.tagName==="LINK"){const te=(M.getAttribute("rel")??"").toLowerCase();if(!["stylesheet","icon"].includes(te)){M.remove();continue}const ue=M.getAttribute("href");ue&&M.setAttribute("href",await ie(ue,E,te==="stylesheet"?"css":"resource"))}if(M.hasAttribute("src")&&M.setAttribute("src",await ie(M.getAttribute("src"),E,M.tagName==="SCRIPT"?"script":"resource")),M.hasAttribute("poster")&&M.setAttribute("poster",await ie(M.getAttribute("poster"),E,"resource")),M.hasAttribute("srcset")){const te=M.getAttribute("srcset");/data:/i.test(te)?(M.removeAttribute("srcset"),m("混合内嵌图片候选暂不支持安全预览")):M.setAttribute("srcset",(await Promise.all(te.split(",").map(async ue=>{const[Le,...Ge]=ue.trim().split(/\s+/);return`${await ie(Le,E,"resource")} ${Ge.join(" ")}`}))).join(", "))}M.setAttribute("referrerpolicy","no-referrer"),M.removeAttribute("integrity"),M.removeAttribute("crossorigin")}const z=[...f].join(" "),K=T.createElement("meta");K.httpEquiv="Content-Security-Policy",K.content=`default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${z}; style-src 'unsafe-inline' blob: ${z}; img-src blob: data: ${z}; font-src blob: data: ${z}; media-src blob: data: ${z}; connect-src blob: ${z} ${[...f].map(M=>M.replace(/^https:/,"wss:")).join(" ")}; worker-src blob:; frame-src 'none'; object-src 'none'; base-uri https://termdock-preview.invalid; form-action 'none'`;const ae=T.createElement("base");ae.href=c;const le=T.createElement("meta");le.name="referrer",le.content="no-referrer";const we=T.createElement("script");we.textContent=yb+`
1636
- installPreviewRuntime(`+[d,c,[...f],Q].map(jb).join(",")+");";const be=T.createElement("script");be.src=Q,T.head.prepend(K,le,ae,we,be);const Ae=`<!doctype html>
1637
- `+T.documentElement.outerHTML;return{html:Ae,shellUrl:`/preview-shell.html#${d}`,errors:h,attach(M,te){const ue=new Set,Le=Pe=>{if(Pe.source!==M.contentWindow||Pe.data?.capability!==d)return;if(Pe.data.type==="preview-ready"){M.contentWindow?.postMessage({type:"preview-init",capability:d,html:Ae,resources:g},"*");return}if(Pe.data.type==="preview-error"){te("部分动态内容被安全预览限制");return}if(Pe.data.type==="preview-navigate"){(async()=>{const Z=j(String(Pe.data.url)),R=await Uu(Z.pathname+Z.search,r);if(N){R.dispose();return}const V=R.attach(M,te);F.add(()=>{V(),R.dispose()}),M.src=R.shellUrl.replace("#","?navigation="+crypto.randomUUID()+"#")})().catch(Z=>te(Z instanceof Error?Z.message:"无法打开预览页面"));return}if(Pe.data.type==="preview-external"){try{const Z=new URL(String(Pe.data.url));Z.protocol==="https:"&&f.has(Z.origin)&&window.open(Z.href,"_blank","noopener,noreferrer")}catch{}return}if(Pe.data.type!=="preview-fetch"||Pe.ports.length!==1)return;const de=Pe.ports[0];if(ue.size>=8||!["GET","HEAD"].includes(Pe.data.method)){de.postMessage({error:"预览仅允许读取已授权目录资源"}),de.close();return}ue.add(de),(async()=>{const Z=j(String(Pe.data.url)),R=await Y(Z);if(!ue.has(de)||N)return;const V=Pe.data.method==="HEAD"?new Uint8Array:R.bytes.slice();de.postMessage({status:R.status,headers:{"content-type":R.type},data:V.buffer},[V.buffer])})().catch(()=>{de.postMessage({error:"预览资源不在授权范围或无法加载"}),te("部分动态资源不可用或超出预览目录")}).finally(()=>{ue.delete(de),de.close()})};window.addEventListener("message",Le);const Ge=()=>{window.removeEventListener("message",Le);for(const Pe of ue)Pe.close();ue.clear(),F.delete(Ge)};return F.add(Ge),Ge},dispose:B}}catch(q){throw B(),q}}const Rb=a.forwardRef(function({src:r,title:s,exitFullscreenLabel:i,onFullscreenChange:d},c){const h=a.useRef(null),[m,p]=a.useState(null),[g,f]=a.useState(),[S,v]=a.useState("");a.useEffect(()=>{const $=new AbortController;let U;return f(void 0),v(""),(async()=>{const _=await rm();if(U=await Uu(r,{fetch:(o,w)=>_.fetch(o,w),signal:$.signal}),$.signal.aborted){U.dispose();return}f(U),U.errors.length&&v(U.errors.join(";"))})().catch(_=>{$.signal.aborted||v(_ instanceof Error?_.message:"安全预览加载失败")}),()=>{$.abort(),U?.dispose()}},[r]),a.useEffect(()=>{if(!(!g||!m))return g.attach(m,v)},[g,m]);const[P,N]=a.useState(!1),[F,B]=a.useState(!1),A=P||F;a.useEffect(()=>{d?.(A)},[A,d]),a.useEffect(()=>{const $=()=>{N(document.fullscreenElement===h.current)};return document.addEventListener("fullscreenchange",$),()=>document.removeEventListener("fullscreenchange",$)},[]),a.useEffect(()=>{if(!F)return;const $=U=>{U.key==="Escape"&&B(!1)};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[F]);const E=a.useCallback(async()=>{const $=h.current;if($){if(F){B(!1);return}if(document.fullscreenElement===$){await document.exitFullscreen();return}if($.requestFullscreen&&document.fullscreenEnabled!==!1)try{await $.requestFullscreen();return}catch{}B(!0)}},[F]);a.useImperativeHandle(c,()=>({toggleFullscreen:E}),[E]);const L=t.jsxs("div",{ref:h,"data-html-preview-frame":!0,className:A?"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:[A&&t.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/15 bg-[var(--chrome-bg)] px-3",children:[t.jsx("span",{className:"min-w-0 truncate text-[12px] font-semibold",children:s}),t.jsx("button",{type:"button",onClick:()=>{E()},"aria-label":i,title:`${i} (Esc)`,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:t.jsx(ku,{size:15})})]}),S&&t.jsx("div",{role:"status",className:"shrink-0 border-b border-border px-3 py-2 text-xs text-muted-foreground",children:S}),!g&&!S&&t.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:"正在安全加载预览资源…"}),t.jsx("iframe",{ref:p,src:g?.shellUrl,referrerPolicy:"no-referrer",title:s,sandbox:"allow-scripts",className:"block min-h-0 w-full flex-1 border-0 bg-white"})]});return F?Fr.createPortal(L,document.body):L}),zu="termdock-file-search-match",Xi="termdock-file-search-current";function Cb(e){const r=e.metaKey||e.ctrlKey,s=e.key.toLocaleLowerCase();return r&&s==="f"?"open":r&&s==="g"||e.key==="F3"?e.shiftKey?"previous":"next":e.key==="Escape"?"close":null}function Nb(e){return e.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function Eb(e,r){const s=r.trim().toLocaleLowerCase();if(!s)return[];const i=[];let d="",c=null;const h=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let f=h.nextNode();f;f=h.nextNode()){if(!(f instanceof Text)||!f.data)continue;const S=Nb(f);if(!S)continue;c&&c!==S&&(d+=`
1638
- `);const v=d.length;d+=f.data,i.push({node:f,start:v,end:d.length,group:S}),c=S}const m=d.toLocaleLowerCase(),p=[];let g=0;for(;g<=m.length-s.length;){const f=m.indexOf(s,g);if(f<0)break;const S=f+s.length,v=i.find(N=>N.start<=f&&N.end>f),P=i.find(N=>N.start<S&&N.end>=S);if(v&&P&&v.group===P.group){const N=document.createRange();N.setStart(v.node,f-v.start),N.setEnd(P.node,S-P.start),p.push(N)}g=f+Math.max(s.length,1)}return p}function Hu(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function Wa(){const e=Hu();e?.delete(zu),e?.delete(Xi)}function Od(e,r){const s=Hu();if(!s||typeof Highlight>"u")return;s.set(zu,new Highlight(...e));const i=e[r];i?s.set(Xi,new Highlight(i)):s.delete(Xi)}function Bd(e){e?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function Mb(e){return Array.from(new Set(e.split(/[\n,]/).map(r=>r.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Ab(e,r){const s=r.trim();return!s||s==="."?e:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(s)?s.replace(/[\\/]+$/,""):`${e.replace(/[\\/]+$/,"")}/${s.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function Pb(e,r){if(r===e)return".";const s=`${e.replace(/[\\/]+$/,"")}/`;return r.startsWith(s)?r.slice(s.length):r}function Wu(e,r,s){return r?e:Fr.createPortal(e,s)}const ml="termdock:right-sidebar:file-tree-scroll:v1",pl="termdock:right-sidebar:file-preview-reading-state:v1",Ls="termdock:right-sidebar:file-tree-width:v1",Gu="termdock:right-sidebar:markdown-view-mode:v1",qu="termdock:right-sidebar:diff-change-list-mode:v1",Vu="termdock:right-sidebar:diff-wrap:v1",Ku="termdock:diff-viewer:view-type:v1",Yu="termdock:right-sidebar:file-search-mode:v1",vi="termdock:right-sidebar:collapsed-git-repo-groups:v1",Ud="termdock:right-sidebar:collapsed-diff-directories:v1",wi="termdock:right-sidebar:branch-audit-module-open:v1",Xu="termdock:right-sidebar:branch-audit-module:v1",Tb=150,Ju="termdock:right-sidebar:active-git-repo:v1",zd="termdock:right-sidebar:context-draft-enabled:v1",Hd="termdock:right-sidebar:context-draft-collapsed:v1",Wd="termdock:right-sidebar:context-draft-auto-collapse:v1",ki="termdock:right-sidebar:context-draft-text:v1",Lb=300,$b=20,Ib=120,_b=250,Db=250,Fb=120,Ob=700,Si=600;function es(e){return!!(e&&ne.getState().nestedGitScanRoots[e])}const Gd=[2e3,5e3,15e3,3e4],Bb=320,Ub=500,zb=20,Hb=12e3,Ji=300,qd=240,Wb=560,Qu="border-r px-2 py-1.5 sm:px-3 sm:py-2",ao="max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",Zu=`${Qu} border-b border-border/15 font-semibold last:border-r-0`,ef=`${Qu} border-border/10 align-top text-muted-foreground last:border-r-0`,gl="termdock-file-preview-horizontal-scroll",Vd=a.lazy(()=>Os(()=>import("./ModelPreview-8jvTuVib.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),tf=`${gl} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function rf(e,r,s){return e&&!r?"unified":s}const Gb=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function qb(e){return e==="preview"||e==="source"}function Vb(e){return e==="list"||e==="tree"||e==="ai"}function Kd(){return mt(Gu,qb)??"preview"}function Kb(){return mt(qu,Vb)??"tree"}function $s(e){return typeof e=="boolean"}function Yb(e){return typeof e=="string"}function Xb(){return mt(Vu,$s)??!0}function Jb(e){return e==="unified"||e==="split"}function Qb(){return mt(Ku,Jb)??"unified"}function Zb(e){return e==="name"||e==="content"||e==="regex"}function ex(){return mt(Yu,Zb)??"name"}function nf(e){return e.repositories??(e.context?.root?[{id:e.context.root,root:e.context.root,relativeRoot:".",name:Et(e.context.root)||e.context.root,depth:0,nested:!1,available:e.available,files:e.files,context:e.context,error:e.error}]:[])}function tx(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(r=>r===null||typeof r=="string")}function sf(){return mt(Ju,tx)??{}}function Yd(e){if(!e)return;const r=sf();return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}function ji(e,r){e&&Dt(Ju,{...sf(),[e]:r})}function rx(e,r){if(!r)return null;const s=new Set((e.repoFilters??[]).map(i=>i.root));return s.has(r)?r:s.size>0?null:(e.repositories??[]).some(i=>i.root===r)?r:null}function Qi(e){return!e.activeGitRepoRoot&&(e.groupCount>1||e.label!==e.rootName)}function af(...e){const r=new Set;for(const s of e)for(const i of s)r.add(i.root);return r}function Zi(e){return Array.isArray(e)&&e.every(r=>typeof r=="string")}function Xd(e){const r=mt(e,Zi);return r?new Set(r):new Set}function Ri(e,r){Dt(e,[...r])}function nx(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return typeof r.filePath=="string"&&typeof r.hunkHeader=="string"&&typeof r.hunkIndex=="number"&&typeof r.fingerprint=="string"&&typeof r.additions=="number"&&typeof r.deletions=="number"&&typeof r.diff=="string"&&(r.oldPath===void 0||r.oldPath===null||typeof r.oldPath=="string")&&(r.newPath===void 0||r.newPath===null||typeof r.newPath=="string")&&(r.source===void 0||r.source==="committed"||r.source==="uncommitted"||r.source==="unknown")&&(r.commit===void 0||r.commit===null||typeof r.commit=="string")}function sx(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return typeof r.available=="boolean"&&(r.repoRoot===void 0||typeof r.repoRoot=="string")&&(r.workspaceRoot===void 0||typeof r.workspaceRoot=="string")&&(r.baseRef===void 0||typeof r.baseRef=="string")&&(r.baseBranch===void 0||typeof r.baseBranch=="string")&&(r.currentBranch===void 0||r.currentBranch===null||typeof r.currentBranch=="string")&&(r.headRef===void 0||r.headRef===null||typeof r.headRef=="string")&&(r.diffFingerprint===void 0||typeof r.diffFingerprint=="string")&&(r.stat===void 0||typeof r.stat=="string")&&(r.files===void 0||Zi(r.files))&&(r.hunks===void 0||Array.isArray(r.hunks)&&r.hunks.every(nx))&&(r.commits===void 0||Zi(r.commits))&&(r.commitCount===void 0||typeof r.commitCount=="number")&&(r.diff===void 0||typeof r.diff=="string")&&(r.truncated===void 0||typeof r.truncated=="boolean")&&(r.error===void 0||typeof r.error=="string")}function ax(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return typeof r.key=="string"&&sx(r.diff)&&typeof r.repoLabel=="string"&&typeof r.createdAt=="number"}function ox(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(r=>{if(!r||typeof r!="object"||Array.isArray(r))return!1;const s=r;return Array.isArray(s.selectedRepoRoots)&&s.selectedRepoRoots.every(i=>typeof i=="string")&&!!s.repoTargetBranches&&typeof s.repoTargetBranches=="object"&&!Array.isArray(s.repoTargetBranches)&&Object.values(s.repoTargetBranches).every(i=>typeof i=="string")&&(s.repoBaseBranches===void 0||!!s.repoBaseBranches&&typeof s.repoBaseBranches=="object"&&!Array.isArray(s.repoBaseBranches)&&Object.values(s.repoBaseBranches).every(i=>typeof i=="string"))&&(s.previewEntries===void 0||Array.isArray(s.previewEntries)&&s.previewEntries.every(ax))&&(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(i=>typeof i=="number"))&&(s.previewMobileSlideIndex===void 0||typeof s.previewMobileSlideIndex=="number")&&(s.includeUncommitted===void 0||typeof s.includeUncommitted=="boolean")&&typeof s.updatedAt=="number"})}function Jd(){return mt(Xu,ox)??{}}function Qd(e){return[e.repoRoot,e.baseRef,e.branchName??"",e.headRef??"",e.diffFingerprint??""].join("\0")}function Zd(e){const r=e?.trim()??"",s=r.indexOf("/");return s>=0?r.slice(s+1):r}function of(e,r){const s=e?.trim(),i=r?.trim();return!s||!i?!1:s===i||Zd(s)===Zd(i)}function eu(e){const r=e?.branch??null;return[e?.upstream,...e?.remoteBranches??[],...e?.branches??[]].find(i=>i&&!of(i,r))??""}function el(e,r){const s=Math.max(qd,r-320),i=Math.min(Wb,s);return Math.min(i,Math.max(qd,e))}function ix(e){return typeof e=="number"&&Number.isFinite(e)}function lx(e){return el(mt(Ls,ix)??Ji,e)}function lf(e){const r=e.split(/[\\/]/).pop()??e,s=r.lastIndexOf(".");return s>=0?r.slice(s).toLowerCase():""}function Ps(e){return Gb.has(lf(e))}function cf(e){const r=e.trim().replace(/\s+/g,"");return/^-{3,}$/.test(r)||/^\*{3,}$/.test(r)||/^_{3,}$/.test(r)}function tl(e){const r=e.trim();return/^#{1,6}\s+/.test(r)||cf(e)||/^>\s?/.test(r)||/^(```|~~~)/.test(r)||/^(?:[-+*]|\d+[.)])\s+/.test(r)}function df(e){const r=e.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(r)||!/^[a-z][a-z0-9+.-]*:/i.test(r)&&!/[<>]/.test(r)?r:null}const uf=a.createContext(null);function eo(e){return e.trim().replace(/\s+/g," ").toLowerCase()}function ff(e){return e.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function hf(e){return e.replace(/\s+#+\s*$/,"").trim()}function rl(e,r){const i=ff(e).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",d=r.headingSlugCounts.get(i)??0;return r.headingSlugCounts.set(i,d+1),d===0?i:`${i}-${d}`}function tu(e){return ff(e)||e.trim()}function oo(e){const r=e.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!r)return null;const s=sl(r[2]);return s?{id:eo(r[1]),definition:{href:s.href,title:s.title}}:null}function cx(e){const r=new Map;for(const s of e){const i=oo(s);i&&r.set(i.id,i.definition)}return r}function mf(e){return e.trim().toLowerCase()}function pf(e){const r=e.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return r?{id:mf(r[1]),text:r[2]}:null}function dx(e){const r=new Map;let s=null;for(const i of e){const d=pf(i);if(d){s=d.id,r.set(d.id,{id:d.id,text:d.text,index:r.size+1});continue}if(s&&/^\s{4,}\S/.test(i)){const c=r.get(s);c&&(c.text=`${c.text} ${i.trim()}`);continue}i.trim()&&(s=null)}return r}function gf(e){const r=new Set;let s=!1;return e.forEach((i,d)=>{if(pf(i)){r.add(d),s=!0;return}if(s&&/^\s{4,}\S/.test(i)){r.add(d);return}i.trim()&&(s=!1)}),r}function ux(e){const r=[...e];let s=0;const i=e[0]?.trim();if(i==="---"||i==="+++"){for(r[0]="",s=1;s<e.length&&e[s].trim()!==i;)r[s]="",s+=1;s<e.length&&(r[s]="",s+=1)}for(;s<e.length;){const d=e[s].trim();if(d.startsWith("<!--")){if(r[s]="",!d.includes("-->")){for(s+=1;s<e.length&&!e[s].includes("-->");)r[s]="",s+=1;s<e.length&&(r[s]="")}s+=1;continue}s+=1}return r}function bf(e){const r=e.replace(/\/+$/,""),s=r.lastIndexOf("/");return s<=0?s===0?"/":"":r.slice(0,s)}function Ds(e){const r=e.split(/[?#]/,1)[0],s=r.startsWith("/"),i=[];for(const c of r.split("/"))if(!(!c||c===".")){if(c===".."){i.length>0&&i.pop();continue}i.push(c)}return`${s?"/":""}${i.join("/")}`||(s?"/":".")}function bl(e,r,s){const i=e.trim();if(!i||/^(?:https?:|mailto:|javascript:|data:)/i.test(i)||/^[a-z][a-z0-9+.-]*:/i.test(i))return null;if(i.startsWith("#")){if(!r)return null;try{return{path:r,fragment:decodeURIComponent(i.slice(1))||null,directory:!1}}catch{return null}}const d=i.indexOf("#"),c=d>=0?i.slice(0,d):i,h=d>=0?i.slice(d+1):"",m=c.split("?",1)[0];if(!m)return null;let p,g=null;try{p=decodeURIComponent(m),g=h?decodeURIComponent(h):null}catch{return null}const f=s?Ds(s):null;let S;if(p.startsWith("/")){const v=f&&(p===f||p.startsWith(`${f}/`));S=Ds(f&&!v?`${f}/${p.slice(1)}`:p)}else{if(!r)return null;S=Ds(`${bf(r)}/${p}`)}return f&&S!==f&&!S.startsWith(`${f}/`)?null:{path:S,fragment:g,directory:/\/$/.test(m)}}function xl(e,r,s,i,d){const c=e.trim();if(!c||/^(?:javascript|data):/i.test(c))return null;if(/^https?:\/\//i.test(c))return c;if(!i(c.split(/[?#]/,1)[0]))return null;let h;if(c.startsWith("/")){const m=s&&(c===s||c.startsWith(`${s}/`));h=Ds(s&&!m?`${s}/${c.slice(1)}`:c)}else{if(!r)return null;h=Ds(`${bf(r)}/${c}`)}return d(h)}function fx(e,r,s){return xl(e,r,s,fl,i=>`/api/terminal/fs/blob?path=${encodeURIComponent(i)}`)}function hx(e,r,s){return xl(e,r,s,mu,pu)}const nl=128,mx=360,Ci=480;function po(e){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(e))}catch{return!1}}function xf(e,r,s,i,d=0){if(!r||!s)return null;let c,h;return d>0?(c=i>0?Math.min(d,i):d,h=s*c/r):po(e)?(h=Math.min(Math.max(s,nl),mx),c=r*h/s):(c=r,h=s),i>0&&c>i&&(h=h*i/c,c=i),h>Ci&&(c=c*Ci/h,h=Ci),{width:Math.max(1,Math.round(c)),height:Math.max(1,Math.round(h))}}function px(e){if(!e.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(e.slice(e.indexOf("?"))).get("path")}catch{return null}}function yf(e){const r=px(e),s=ne(i=>r?(i.fileChangeVersions.get(r)??0)+i.fileWatchEpoch:0);return r&&s>0?`${e}&v=${s}`:e}function gx({src:e,alt:r,title:s,requestedWidthPx:i}){const d=po(e),c=yf(e),h=ho(c),m=a.useRef(null),[p,g]=a.useState(!1),[f,S]=a.useState(0),[v,P]=a.useState({status:"loading"}),[N,F]=a.useState(null);a.useLayoutEffect(()=>{const E=m.current,L=E?.parentElement?.parentElement??E?.parentElement;if(!L)return;const $=()=>S(L.clientWidth);if($(),typeof ResizeObserver>"u")return;const U=new ResizeObserver($);return U.observe(L),()=>U.disconnect()},[]),a.useEffect(()=>{if(p)return;const E=m.current;if(!E||typeof IntersectionObserver>"u"){g(!0);return}const L=new IntersectionObserver($=>{$.some(U=>U.isIntersecting)&&(g(!0),L.disconnect())},{rootMargin:"400px"});return L.observe(E),()=>L.disconnect()},[p]),a.useEffect(()=>{if(!p)return;const E=new AbortController;let L=null;P({status:"loading"});const $=window.setTimeout(()=>{E.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return Tm(c,{signal:E.signal}).then(async U=>{if(!U.ok)throw new Error(`HTTP ${U.status}`);const _=Number(U.headers.get("X-Image-Width"))||0,o=Number(U.headers.get("X-Image-Height"))||0;return{blob:await U.blob(),width:_,height:o}}).then(({blob:U,width:_,height:o})=>{E.signal.aborted||(L=URL.createObjectURL(U),_>0&&o>0&&F({width:_,height:o}),P({status:"ready",objectUrl:L}))}).catch(()=>{const U=E.signal.reason;E.signal.aborted&&!(U instanceof DOMException&&U.name==="TimeoutError")||P({status:"fallback"})}).finally(()=>{window.clearTimeout($)}),()=>{window.clearTimeout($),E.abort(),L&&URL.revokeObjectURL(L)}},[p,c]);const B=xf(e,N?.width??0,N?.height??0,f,i??0),A=B??(i?{width:f>0?Math.min(i,f):i,height:Math.round(i*.75)}:{width:nl*2,height:nl});return t.jsx("div",{ref:m,className:"block max-w-full",style:B?{width:B.width,height:B.height}:void 0,children:v.status==="ready"?t.jsx("img",{src:v.objectUrl,alt:r,title:s,decoding:"async",className:`${d?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:B?{width:B.width,height:B.height}:void 0,onLoad:E=>{if(N)return;const L=E.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&F({width:L.naturalWidth,height:L.naturalHeight})}}):v.status==="fallback"?t.jsx("img",{src:h,alt:r,title:s,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:B?{width:B.width,height:B.height}:void 0,onLoad:E=>{if(N)return;const L=E.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&F({width:L.naturalWidth,height:L.naturalHeight})}}):t.jsx("div",{"aria-hidden":!0,className:"flex max-w-full animate-pulse items-center justify-center rounded bg-surface-elevated/60",style:{width:A.width,height:A.height},children:t.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:r||"…"})})})}function Fs(e,r,s,i,d,c){const h=fx(s,d.markdownFilePath,d.rootPath);if(!h)return c?.fallbackText??`![${r}](${s})`;const m=d.images.length;d.images.push({kind:"image",src:h,alt:r,title:i});const p=t.jsx(gx,{src:h,alt:r,title:i,requestedWidthPx:c?.requestedWidthPx});return d.onImageOpen&&c?.interactive!==!1?t.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:i||r||"Open image",onClick:g=>{g.stopPropagation(),d.onImageOpen?.(m)},children:p},e):t.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:p},e)}function Ni(e){let r=e,s="";for(;/[.,;:!?)]$/.test(r);)s=`${r.slice(-1)}${s}`,r=r.slice(0,-1);return{linkText:r,suffix:s}}function ru(e){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(e)}function sl(e){const r=e.trim(),s=r.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(s)return{href:s[1],title:s[2]??s[3]??s[4]};const i=r.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return i?{href:i[1],title:i[2]??i[3]??i[4]}:null}const vf="",bx=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function xx(e){return e.replace(bx,(r,s)=>`${vf}${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}function nu(e){return e.replace(new RegExp(`${vf}([0-9a-f]{4})`,"g"),(r,s)=>String.fromCharCode(Number.parseInt(s,16))).replace(/\\([()])/g,"$1")}function yx(e){const r=e.replace(/[\r\n]+/g," ");return/^ .+ $/.test(r)&&/[^ ]/.test(r.slice(1,-1))?r.slice(1,-1):r}const wf={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 Ga=null;function kf(){return Ga||(Ga=Os(()=>import("./purify.es-4eNOHKSq.js"),[]).then(e=>e.default??e).catch(e=>{throw Ga=null,e})),Ga}function Sf({html:e}){const{t:r}=Mt(),[s,i]=a.useState(null);return a.useEffect(()=>{let d=!1;return i(null),kf().then(c=>{d||i(c.sanitize(e,wf))}).catch(()=>{d||i("")}),()=>{d=!0}},[e]),s===null?t.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:r("rightSidebar.renderingHtml")}):s?t.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:s}}):null}function vx({html:e}){const[r,s]=a.useState(null);return a.useEffect(()=>{let i=!1;return s(null),kf().then(d=>{i||s(d.sanitize(e,wf))}).catch(()=>{i||s("")}),()=>{i=!0}},[e]),r===null?null:r?t.jsx("span",{dangerouslySetInnerHTML:{__html:r}}):e}function jf(e){const r=e.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!r)return null;const s=r[1].toLowerCase();return{tag:s,selfContained:new RegExp(`</${s}>`,"i").test(e)}}let qa=null;function wx(){return qa||(qa=Promise.all([Os(()=>import("./katex-DnlPpQZa.js"),[]),Os(()=>Promise.resolve({}),__vite__mapDeps([16]))]).then(([e])=>e.default??e).catch(e=>{throw qa=null,e})),qa}function zs({tex:e,display:r=!1}){const[s,i]=a.useState(null),[d,c]=a.useState(!1);if(a.useEffect(()=>{let m=!1;return i(null),c(!1),wx().then(p=>{m||i(p.renderToString(e,{displayMode:r,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{m||c(!0)}),()=>{m=!0}},[r,e]),d)return t.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:r?`$$${e}$$`:`$${e}$`});if(!s)return t.jsx("span",{className:"text-muted-foreground/70",children:r?"Rendering formula...":e});const h=r?"my-2 overflow-auto rounded-md bg-surface-2 px-3 py-2 text-center":"inline-block align-middle";return t.jsx("span",{className:h,dangerouslySetInnerHTML:{__html:s}})}function yl(e){const r=new Map;for(const s of e.matchAll(/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/gi))r.set(s[1].toLowerCase(),s[2]??s[3]??s[4]);return r}function su(e){const r=yl(e),s=r.get("src")?.trim()??"",i=r.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i);return{src:s,alt:r.get("alt"),title:r.get("title"),widthPx:i?Number(i[1]):void 0}}function kx(e){const r=e.indexOf(">"),s=r<0?e:e.slice(0,r+1),i=yl(s),d=i.get("src")?.trim()??"",c=i.get("width")?.trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i),h=s.replace(/=\s*(?:"[^"]*"|'[^']*')/g," "),m=r<0?"":e.slice(r+1).replace(/<\/video\s*>$/i,"").replace(/<[^>]*>/g,"").trim();return{src:d,fallbackText:m,widthPx:c?Number(c[1]):void 0,controls:/\bcontrols\b/i.test(h)}}function Sx({url:e,fallbackText:r,widthPx:s,hasControls:i}){const{t:d}=Mt(),[c,h]=a.useState(!1),m=ho(e,()=>h(!0));return m?t.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:c?t.jsx("span",{className:"block px-3 py-2 text-xs text-muted-foreground",children:r?.trim()||d("rightSidebar.videoUnsupported")}):t.jsx("video",{className:"block max-w-full",src:m,style:s?{width:`${s}px`}:void 0,controls:i,preload:"metadata",playsInline:!0,onError:()=>h(!0)})}):null}function jx(e,r,s){if(/^<a\b[^>]*>\s*<\s*img\b[^>]*>\s*<\/a\s*>$/i.test(e)){const h=e.slice(0,e.indexOf(">")+1),m=yl(h).get("href")?.trim()??"",p=e.match(/<\s*img\b[^>]*>/i)?.[0]??"",{src:g,alt:f,title:S,widthPx:v}=su(p);if(!g)return null;const P=xl(g,s.markdownFilePath,s.rootPath,fl,E=>E);if(!P)return null;const N=m?bl(m,s.markdownFilePath,s.rootPath):null,B=!!!(N&&N.path===P)&&m?df(m):null,A=Fs(r,f??"",g,S,s,{requestedWidthPx:v,interactive:B?!1:void 0});return B?t.jsx("a",{href:B,target:"_blank",rel:"noreferrer",children:A},r):A}if(/^<\s*img\b[^>]*>$/i.test(e)){const{src:h,alt:m,title:p,widthPx:g}=su(e);return h?Fs(r,m??"",h,p,s,{fallbackText:e,requestedWidthPx:g}):null}if(/^<\s*video\b[^>]*>[\s\S]*?<\/video\s*>$/i.test(e)){const{src:h,fallbackText:m,widthPx:p,controls:g}=kx(e);if(!h)return null;const f=hx(h,s.markdownFilePath,s.rootPath);return f?t.jsx(Sx,{url:f,fallbackText:m,widthPx:p,hasControls:g},r):null}if(/^<br\s*\/?>$/i.test(e))return t.jsx("br",{},r);const i=e.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!i)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(e)?t.jsx(vx,{html:e},r):null;const d=i[1].toLowerCase(),c=pt(i[2],`${r}-${d}`,!0,s);return d==="kbd"?t.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},r):d==="mark"?t.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:c},r):d==="sub"?t.jsx("sub",{children:c},r):t.jsx("sup",{children:c},r)}function pt(e,r,s=!0,i){const d=xx(e),c=/(\\\([^)]*\\\)|\$[^$\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+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\)|!?\[[^\]]+\]\[[^\]]*\]|!?\[[^\]]+\]|\[\^[^\]]+\]|(`+)([\s\S]*?)\2|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|\*[^*\s][^*]*\*|_[^_\s][^_]*_|<https?:\/\/[^>\s]+>|<[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+>|https?:\/\/[^\s<]+|www\.[^\s<]+|[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+)/gi,h=[];let m=0,p;for(;(p=c.exec(d))!==null;){p.index>m&&h.push(nu(d.slice(m,p.index)));const g=p[0],f=`${r}-${p.index}`,S=g.startsWith("<")?jx(g,f,i):null;if(S)h.push(S);else if(g.startsWith("\\(")&&g.endsWith("\\)"))h.push(t.jsx(zs,{tex:g.slice(2,-2)},f));else if(g.startsWith("$")&&g.endsWith("$"))h.push(t.jsx(zs,{tex:g.slice(1,-1)},f));else if(g.startsWith("`")){const v=g.match(/^`+/)?.[0].length??1;h.push(t.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:yx(g.slice(v,-v))},f))}else if(g.startsWith("~~"))h.push(t.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:pt(g.slice(2,-2),`${f}-del`,s,i)},f));else if(g.startsWith("**")||g.startsWith("__"))h.push(t.jsx("strong",{className:"font-semibold text-foreground",children:pt(g.slice(2,-2),`${f}-strong`,s,i)},f));else if(g.startsWith("*")||g.startsWith("_"))h.push(t.jsx("em",{className:"italic",children:pt(g.slice(1,-1),`${f}-em`,s,i)},f));else if(g.startsWith("![")){const v=g.match(/^!\[([^\]]*)\]\((.*)\)$/),P=g.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),N=g.match(/^!\[([^\]]+)\]$/);if(v){const F=sl(v[2]);h.push(F?Fs(f,v[1],F.href,F.title,i):g)}else if(P){const F=P[2]||P[1],B=i.referenceDefinitions.get(eo(F));h.push(B?Fs(f,P[1],B.href,B.title,i):g)}else if(N){const F=i.referenceDefinitions.get(eo(N[1]));h.push(F?Fs(f,N[1],F.href,F.title,i):g)}else h.push(g)}else if(g.startsWith("[^")){const v=mf(g.slice(2,-1)),P=i.footnoteDefinitions.get(v);h.push(P?t.jsx("sup",{id:`fnref-${P.id}`,title:P.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:t.jsx("a",{href:`#fn-${P.id}`,className:"text-primary no-underline",children:P.index})},f):g)}else if(g.startsWith("<http")){const v=g.slice(1,-1);h.push(t.jsx("a",{href:v,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:v},f))}else if(g.startsWith("<")&&g.endsWith(">")&&ru(g.slice(1,-1))){const v=g.slice(1,-1);h.push(t.jsx("a",{href:`mailto:${v}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:v},f))}else if(ru(Ni(g).linkText)){const{linkText:v,suffix:P}=Ni(g);h.push(t.jsx("a",{href:`mailto:${v}`,className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:v},f)),P&&h.push(P)}else if(g.startsWith("http")||g.startsWith("www.")){const{linkText:v,suffix:P}=Ni(g),N=v.startsWith("www.")?`https://${v}`:v;h.push(t.jsx("a",{href:N,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:v},f)),P&&h.push(P)}else{const v=g.match(/^\[([^\]]+)\]\((.*)\)$/),P=g.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),N=g.match(/^\[([^\]]+)\]$/),F=P?P[2]||P[1]:N?.[1]??null,B=F?i.referenceDefinitions.get(eo(F)):null,A=v?sl(v[2]):null,E=A?.href??B?.href??null,L=E?df(E):null,$=v?.[1]??P?.[1]??N?.[1]??"";h.push(L?t.jsx("a",{href:L,title:A?.title??B?.title,target:"_blank",rel:"noreferrer",className:`${s?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:pt($,`${f}-link`,s,i)},f):g)}m=c.lastIndex}return m<d.length&&h.push(nu(d.slice(m))),h.length>0?h:[e]}function Rf(e){return/(?: {2,}|\\)$/.test(e)}function Cf(e){return e.replace(/(?: {2,}|\\)$/,"")}function io(e){return/^(?: {4}|\t)/.test(e)}function Nf(e){return e.startsWith(" ")?e.slice(1):e.replace(/^ {4}/,"")}function Ef(e,r,s){const i=[];return e.forEach((d,c)=>{const h=Rf(d);i.push(...pt(Cf(d),`${r}-${c}`,!0,s)),c<e.length-1&&i.push(h?t.jsx("br",{},`${r}-${c}-br`):" ")}),i}function al(e,r,s){const i=[],d=[];return e.forEach((c,h)=>{d.push(Rf(c)),i.push(pt(Cf(c),`${r}-${h}`,!0,s))}),{perLine:i,hardBreaks:d}}function ol(e,r,s,i,d){const c=[];return e.forEach((h,m)=>{const p=s[m]??0,g=!!(d&&p>=d.start&&p<=d.end);c.push(t.jsx("span",{"data-md-ref-start":p,"data-md-ref-end":p,"data-selected":g?"true":void 0,children:h},`${i}-ref-${m}`)),m<e.length-1&&c.push(r[m]?t.jsx("br",{},`${i}-${m}-br`):" ")}),c}function Hs(e){const r=e.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let i="",d=!1,c=0,h=0;for(let m=0;m<r.length;m+=1){const p=r[m];if(d){i+=p,d=!1;continue}if(p==="\\"){d=!0;continue}if(p==="`"){const g=m;for(;m+1<r.length&&r[m+1]==="`";)m+=1;const f=m-g+1;i+="`".repeat(f),c===0?c=f:c===f&&(c=0);continue}if(c===0&&p==="["?h+=1:c===0&&p==="]"&&h>0&&(h-=1),p==="|"&&c===0&&h===0){s.push(i.trim()),i="";continue}i+=p}return d&&(i+="\\"),s.push(i.trim()),s}function Mf(e){return Hs(e).map(r=>/^:-+:$/.test(r)?"center":/^-+:$/.test(r)?"right":/^:-+$/.test(r)?"left":null)}function lo(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function co(e){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(e.trim())}function Af(e,r){return e>96||e>44&&r>.35}function go(e){return(e.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function Ws(e){const r=e.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!r)return null;const s=/^\d+[.)]$/.test(r[1]);return{ordered:s,start:s?Number.parseInt(r[1],10):void 0,content:r[2]}}function vl(e,r,s,i,d,c=new Set){const h=[],m=[];let p=r;for(;p<e.length;){const g=e[p];if(d&&(oo(g)||c.has(p))){p+=1;continue}const f=Ws(g),S=go(g);if(!f){if(S>s&&m.length>0){([...m].reverse().find(F=>F.indent<S)?.item??m[m.length-1].item).paragraphs.push(g.trim());for(const F of m)F.item.lineEnd=p+1;p+=1;continue}break}if(S<s||S===s&&f.ordered!==i)break;const v={content:f.content,ordered:f.ordered,start:f.start,children:[],paragraphs:[],lineStart:p+1,lineEnd:p+1};for(;m.length>0&&m[m.length-1].indent>=S;)m.pop();const P=m[m.length-1]?.item??null;P?P.children.push(v):h.push(v),m.push({indent:S,item:v});for(const N of m)N.item.lineEnd=p+1;p+=1}return{items:h,nextIndex:p}}function Rx(e){const r=e.find(i=>Ws(i));if(!r)return[];const s=Ws(r);return s?vl(e,0,go(r),s.ordered,!0,gf(e)).items:[]}function wl(e,r,s,i=0){return e.map((d,c)=>{const h=d.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${c}`,taskItem:!!h,refStart:d.lineStart+i,refEnd:d.lineEnd+i,content:t.jsxs(t.Fragment,{children:[h?t.jsx("input",{type:"checkbox",checked:h[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,pt(h?.[2]??d.content,`li-${r}-${c}`,!0,s),d.paragraphs.length>0&&t.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:d.paragraphs.map((m,p)=>t.jsx("p",{children:pt(m,`li-${r}-${c}-p-${p}`,!0,s)},`paragraph-${p}`))})]}),groups:Cx(d.children,`${r}-${c}`,s,i)}})}function Cx(e,r,s,i=0){const d=[];for(const c of e){const h=d[d.length-1];h&&h.ordered===c.ordered?h.items.push(c):d.push({ordered:c.ordered,items:[c]})}return d.map((c,h)=>({ordered:c.ordered,start:c.ordered?c.items[0]?.start:void 0,items:wl(c.items,`${r}-g${h}`,s,i)}))}function kl(e,r){return e.map(s=>{const i=!!(r&&s.refStart<=r.end&&s.refEnd>=r.start);return t.jsxs("li",{className:s.taskItem?"list-none":void 0,"data-md-ref-start":s.refStart,"data-md-ref-end":s.refEnd,"data-selected":i?"true":void 0,children:[s.content,s.groups.length>0&&Nx(s.groups,r)]},s.key)})}function Nx(e,r){return e.map((s,i)=>{const d=s.ordered?"ol":"ul";return t.jsx(d,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:kl(s.items,r)},`nested-${i}`)})}function Ex(e){const r=Array.from(e.footnoteDefinitions.values()).sort((s,i)=>s.index-i.index);return r.length===0?null:t.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[t.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:e.footnotesLabel}),t.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:r.map(s=>t.jsxs("li",{id:`fn-${s.id}`,children:[pt(s.text,`footnote-${s.id}`,!0,e)," ",t.jsx("a",{href:`#fnref-${s.id}`,className:"text-primary no-underline","aria-label":e.backToFootnoteLabel(s.index),children:"↩"})]},s.id))})]})}function Mx(e,r,s,i){const d=[];let c=0;const h=m=>i?.[m]??m+1;for(;c<e.length;){const m=e[c],p=m.trim();if(!p){c+=1;continue}if(/^<details>\s*$/i.test(p)){const A=c;let E="Details";const L=[];for(c+=1;c<e.length&&!/^<\/details>\s*$/i.test(e[c].trim());){const $=e[c].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);$?E=$[1].trim()||E:L.push(e[c].trimStart()),c+=1}c<e.length&&(c+=1),d.push({kind:"static",node:t.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[t.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:pt(E,`${r}-details-${A}-summary`,!0,s)}),L.length>0&&t.jsx("div",{className:"mt-2 text-sm leading-6",children:Ef(L,`${r}-details-${A}`,s)})]},`${r}-details-${A}`)});continue}const g=jf(m);if(g){const A=[m],E=c;for(c+=1;c<e.length&&!g.selfContained&&!new RegExp(`</${g.tag}>`,"i").test(e[c]);)A.push(e[c]),c+=1;c<e.length&&!g.selfContained&&(A.push(e[c]),c+=1),d.push({kind:"static",node:t.jsx(Sf,{html:A.join(`
1639
- `)},`${r}-html-${E}`)});continue}const f=p.match(/^(```|~~~)\s*(.*)$/);if(f){const A=[],E=f[1],L=f[2]?.trim(),$=c;for(c+=1;c<e.length&&!e[c].trim().startsWith(E);)A.push(e[c]),c+=1;c<e.length&&(c+=1),L.toLowerCase()==="mermaid"?d.push({kind:"static",node:t.jsx(Tf,{code:A.join(`
1640
- `),blockKey:`${r}-code-${$}`},`${r}-code-${$}`)}):["math","latex","tex"].includes(L.toLowerCase())?d.push({kind:"static",node:t.jsx(zs,{tex:A.join(`
1641
- `),display:!0},`${r}-code-${$}`)}):d.push({kind:"code",key:`${r}-code-${$}`,code:A.join(`
1642
- `),lang:L,blockKey:`${r}-code-${$}`,codeStartLine:h($)+1});continue}if(io(m)){const A=[],E=c;for(;c<e.length&&(io(e[c])||!e[c].trim());)A.push(e[c].trim()?Nf(e[c]):""),c+=1;d.push({kind:"code",key:`${r}-indented-code-${E}`,code:A.join(`
1643
- `).replace(/\n+$/,""),lang:"",blockKey:`${r}-indented-code-${E}`,codeStartLine:h(E)});continue}const S=p.match(/^(#{1,6})\s+(.+)$/);if(S){const E=`h${Math.min(6,S[1].length+1)}`,L=hf(S[2]),$=rl(L,s);d.push({kind:"static",node:t.jsx(E,{id:$,className:"scroll-mt-16 font-semibold text-foreground",children:pt(L,`${r}-heading-${c}`,!0,s)},`${r}-heading-${c}`)}),c+=1;continue}if(c+1<e.length&&m.includes("|")&&co(e[c+1])){const A=Hs(m),E=Mf(e[c+1]),L=[],$=c;for(c+=2;c<e.length&&e[c].includes("|")&&e[c].trim();)L.push(Hs(e[c])),c+=1;d.push({kind:"static",node:t.jsx("div",{className:tf,"data-markdown-table-scroll":!0,children:t.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[t.jsx("thead",{className:"bg-surface-2 text-foreground",children:t.jsx("tr",{children:A.map((U,_)=>t.jsx("th",{className:`${Zu} ${lo(E[_]??null)}`,children:t.jsx("div",{className:ao,children:pt(U,`${r}-th-${$}-${_}`,!0,s)})},`h-${_}`))})}),t.jsx("tbody",{children:L.map((U,_)=>t.jsx("tr",{className:"border-t border-border/10",children:A.map((o,w)=>t.jsx("td",{className:`${ef} ${lo(E[w]??null)}`,children:t.jsx("div",{className:ao,children:pt(U[w]??"",`${r}-td-${$}-${_}-${w}`,!0,s)})},`c-${w}`))},`r-${_}`))})]})},`${r}-table-${$}`)});continue}const v=Ws(m);if(v){const A=v.ordered,E=go(m),L=v.start,$=c,U=vl(e,c,E,A,!1);c=U.nextIndex,d.push({kind:"list",keyPrefix:`${r}-list-${$}`,ordered:A,start:A?L:void 0,renders:wl(U.items,`${r}-list-${$}`,s,h(0)-1)});continue}const P=[m.trimStart()],N=[h(c)],F=c;for(c+=1;c<e.length&&e[c].trim()&&!tl(e[c])&&!(c+1<e.length&&e[c].includes("|")&&co(e[c+1]));)P.push(e[c].trimStart()),N.push(h(c)),c+=1;const B=al(P,`${r}-p-${F}`,s);d.push({kind:"paragraph",keyPrefix:`${r}-p-${F}`,perLine:B.perLine,hardBreaks:B.hardBreaks,lineNums:N})}return d}function Ax(e,r){return e.map(s=>{switch(s.kind){case"static":return s.node;case"paragraph":return t.jsx("p",{children:ol(s.perLine,s.hardBreaks,s.lineNums,s.keyPrefix,r)},s.keyPrefix);case"list":{const i=s.ordered?"ol":"ul";return t.jsx(i,{start:s.start,className:`${s.ordered?"list-decimal":"list-disc"} space-y-0.5 pl-4 marker:text-muted-foreground/70`,children:kl(s.renders,r)},s.keyPrefix)}case"code":return t.jsx(uo,{code:s.code,lang:s.lang,blockKey:s.blockKey,codeStartLine:s.codeStartLine,lineRange:r},s.key)}})}let Va=null,au=!1;const Ka=16,Pf=192;function Px(){return Va||(Va=Os(()=>import("./mermaid.core-CUDRfRRW.js").then(e=>e.bl),__vite__mapDeps([17,1,2,3,4,5,18])).then(e=>e.default??e).catch(e=>{throw Va=null,e})),Va}function Tx(e){au||(e.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),au=!0)}function Lx(e){const r=e.match(/\sviewBox=(["'])([^"']+)\1/i);if(!r)return e;const[,,s]=r,i=s.trim().split(/[\s,]+/).map(Number),[,,d,c]=i;if(!Number.isFinite(d)||!Number.isFinite(c)||d<=0||c<=0)return e;const h=Math.max(Pf,Math.ceil(d)),m=Math.ceil(h/d*c);return e.replace(/<svg\b([^>]*)>/i,(p,g)=>`<svg${g.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${h}" height="${m}">`)}function $x(e){const r=e?.querySelector("svg");if(!r)return;let s;try{s=r.getBBox()}catch{return}if(!Number.isFinite(s.width)||!Number.isFinite(s.height)||s.width<=0||s.height<=0)return;const i=s.x-Ka,d=s.y-Ka,c=s.width+Ka*2,h=s.height+Ka*2,m=Math.max(Pf,Math.ceil(c)),p=Math.ceil(m/c*h);r.setAttribute("viewBox",`${i} ${d} ${c} ${h}`),r.setAttribute("width",String(m)),r.setAttribute("height",String(p)),r.removeAttribute("style")}function Ix(e){const r=e.trim().split(/\s+/,1)[0]?.toLowerCase();if(!r)return null;const s=r.replace(/^language-/,"");return Su(`code.${s}`)??s}function Tf({code:e,blockKey:r}){const{t:s}=Mt(),[i,d]=a.useState(null),[c,h]=a.useState(!1),m=a.useRef(null),p=a.useContext(uf);a.useEffect(()=>{let f=!1;return d(null),h(!1),Px().then(async S=>{Tx(S);const v=`termdock-md-mermaid-${r.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:P}=await S.render(v,e);f||d(Lx(P))}).catch(()=>{f||h(!0)}),()=>{f=!0}},[r,e]),a.useLayoutEffect(()=>{i&&$x(m.current)},[i]);const g=a.useCallback(()=>{const f=m.current?.querySelector("svg")?.outerHTML??i;f&&p?.(f)},[p,i]);return c?t.jsx(uo,{code:e,lang:"mermaid",blockKey:`${r}-fallback`}):t.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[t.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"}),t.jsx("div",{className:"bg-surface p-3",children:i?t.jsx("button",{type:"button",className:"block max-w-full rounded text-left focus:outline-none focus:ring-2 focus:ring-ring/45",title:s("rightSidebar.openMermaidDiagram"),onClick:f=>{f.stopPropagation(),g()},children:t.jsx("span",{ref:m,role:"img","aria-label":s("rightSidebar.mermaidDiagram"),className:"block max-h-[70vh] max-w-full overflow-auto rounded bg-white p-2 text-slate-900 [&_svg]:block [&_svg]:h-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:i}})}):t.jsx("div",{className:"py-6 text-center text-xs text-muted-foreground",children:s("rightSidebar.renderingDiagram")})})]})}function uo({code:e,lang:r,blockKey:s,codeStartLine:i,lineRange:d}){const c=Ix(r),[h,m]=a.useState(null);a.useEffect(()=>{if(!c||!ju(e)){m(null);return}let g=!1;return Ru().then(f=>{if(g||!f.registered(c)){g||m(null);return}try{m(Cu(f,e,c))}catch{g||m(null)}}).catch(()=>{g||m(null)}),()=>{g=!0}},[s,e,c]);const p=h??(e||" ").split(`
1644
- `).map(g=>[g||" "]);return t.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[r&&t.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:r}),t.jsx("pre",{className:`${gl} termdock-code overflow-auto p-3 text-[11px] leading-relaxed text-foreground`,children:t.jsx("code",{children:p.map((g,f)=>{const S=i!=null?i+f:null,v=!!(d&&S!=null&&S>=d.start&&S<=d.end);return t.jsxs("span",{"data-md-ref-start":S??void 0,"data-md-ref-end":S??void 0,"data-selected":v?"true":void 0,children:[g,f<p.length-1?`
1645
- `:null]},`${s}-line-${f}`)})})})]})}function Sl(e,r,s,i,d){e=ux(e);const c=cx(e),h=gf(e),m=[],p={markdownFilePath:r,rootPath:s,referenceDefinitions:c,footnoteDefinitions:dx(e),headingSlugCounts:new Map,images:m,onImageOpen:i,footnotesLabel:d?.footnotes??"Footnotes",backToFootnoteLabel:d?.backToFootnote??(v=>`Back to footnote ${v}`)},g=[];let f=0;for(;f<e.length;){const v=e[f],P=v.trim();if(oo(v)||h.has(f)){f+=1;continue}if(!P){f+=1;continue}if(/^<details>\s*$/i.test(P)){const _=f;let o="Details";const w=[];for(f+=1;f<e.length&&!/^<\/details>\s*$/i.test(e[f].trim());){const O=e[f].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);O?o=O[1].trim()||o:w.push(e[f].trimStart()),f+=1}f<e.length&&(f+=1),g.push({key:`details-${_}`,startLine:_+1,endLine:f,content:t.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[t.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:pt(o,`details-${_}-summary`,!0,p)}),w.length>0&&t.jsx("div",{className:"mt-2 text-sm leading-6",children:Ef(w,`details-${_}`,p)})]})});continue}const N=jf(v);if(N){const _=[v],o=f;for(f+=1;f<e.length&&!N.selfContained&&!new RegExp(`</${N.tag}>`,"i").test(e[f]);)_.push(e[f]),f+=1;f<e.length&&!N.selfContained&&(_.push(e[f]),f+=1),g.push({key:`html-${o}`,startLine:o+1,endLine:f,content:t.jsx(Sf,{html:_.join(`
1646
- `)})});continue}const F=P.match(/^(```|~~~)\s*(.*)$/);if(F){const _=[],o=F[1],w=F[2]?.trim(),O=f;for(f+=1;f<e.length&&!e[f].trim().startsWith(o);)_.push(e[f]),f+=1;f<e.length&&(f+=1),g.push({key:`code-${O}`,startLine:O+1,endLine:f,fineGrained:w.toLowerCase()!=="mermaid"&&!["math","latex","tex"].includes(w.toLowerCase()),content:w.toLowerCase()==="mermaid"?t.jsx(Tf,{code:_.join(`
1647
- `),blockKey:`code-${O}`}):["math","latex","tex"].includes(w.toLowerCase())?t.jsx(zs,{tex:_.join(`
1648
- `),display:!0}):j=>t.jsx(uo,{code:_.join(`
1649
- `),lang:w,blockKey:`code-${O}`,codeStartLine:O+2,lineRange:j})});continue}if(io(v)){const _=[],o=f;for(f+=0;f<e.length&&(io(e[f])||!e[f].trim());)_.push(e[f].trim()?Nf(e[f]):""),f+=1;g.push({key:`indented-code-${o}`,startLine:o+1,endLine:f,fineGrained:!0,content:w=>t.jsx(uo,{code:_.join(`
1650
- `).replace(/\n+$/,""),lang:"",blockKey:`indented-code-${o}`,codeStartLine:o+1,lineRange:w})});continue}if(P.startsWith("$$")){const _=[],o=f,w=P.replace(/^\$\$\s*/,"");if(w.endsWith("$$")&&w.length>2)_.push(w.replace(/\s*\$\$$/,"")),f+=1;else{for(w&&_.push(w),f+=1;f<e.length&&!e[f].trim().endsWith("$$");)_.push(e[f]),f+=1;if(f<e.length){const O=e[f].trim().replace(/\s*\$\$$/,"");O&&_.push(O),f+=1}}g.push({key:`math-${o}`,startLine:o+1,endLine:f,content:t.jsx(zs,{tex:_.join(`
1651
- `),display:!0})});continue}if(f+1<e.length&&P&&!tl(v)&&/^(=+|-+)\s*$/.test(e[f+1].trim())){const _=e[f+1].trim().startsWith("=")?1:2,o=`h${_}`,w=rl(P,p),O={level:_,text:tu(P),id:w};g.push({key:`setext-heading-${f}`,startLine:f+1,endLine:f+2,heading:O,content:t.jsx(o,{id:w,className:`scroll-mt-16 font-semibold text-foreground ${_===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:pt(P,`setext-heading-${f}`,!0,p)})}),f+=2;continue}const B=P.match(/^(#{1,6})\s+(.+)$/);if(B){const _=B[1].length,o=hf(B[2]),w={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"},O=`h${_}`,j=rl(o,p),Y={level:_,text:tu(o),id:j};g.push({key:`heading-${f}`,startLine:f+1,endLine:f+1,heading:Y,content:t.jsx(O,{id:j,className:`scroll-mt-16 font-semibold text-foreground ${w[_]}`,children:pt(o,`heading-${f}`,!0,p)})}),f+=1;continue}if(cf(v)){g.push({key:`hr-${f}`,startLine:f+1,endLine:f+1,content:t.jsx("hr",{className:"border-border/20"})}),f+=1;continue}if(P.startsWith(">")){const _=[],o=[],w=f;for(;f<e.length&&/^>\s?/.test(e[f].trim());)_.push(e[f].trim().replace(/^>\s?/,"")),o.push(f+1),f+=1;const O=_[0]?.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i);if(O){const Y=O[1].toUpperCase(),se=O[2]?.trim(),ie=[...se?[se]:[],..._.slice(1)],ge=[...se?[o[0]]:[],...o.slice(1)],q=al(ie,`callout-${w}`,p);g.push({key:`callout-${w}`,startLine:w+1,endLine:f,fineGrained:!0,content:Q=>t.jsxs("aside",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-muted-foreground",children:[t.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-primary",children:Y}),ie.length>0&&t.jsx("div",{children:ol(q.perLine,q.hardBreaks,ge,`callout-${w}`,Q)})]})});continue}const j=Mx(_,`quote-${w}`,p,o);g.push({key:`quote-${w}`,startLine:w+1,endLine:f,fineGrained:!0,content:Y=>t.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:Ax(j,Y)})});continue}if(f+1<e.length&&v.includes("|")&&co(e[f+1])){const _=Hs(v),o=Mf(e[f+1]),w=[],O=f;for(f+=2;f<e.length&&e[f].includes("|")&&e[f].trim();)w.push(Hs(e[f])),f+=1;const j=_.map((se,ie)=>pt(se,`th-${O}-${ie}`,!0,p)),Y=w.map((se,ie)=>_.map((ge,q)=>pt(se[q]??"",`td-${O}-${ie}-${q}`,!0,p)));g.push({key:`table-${O}`,startLine:O+1,endLine:f,interactive:!1,kind:"table",content:se=>{const ie=ge=>!!(se&&ge>=se.start&&ge<=se.end);return t.jsx("div",{className:tf,"data-markdown-table-scroll":!0,children:t.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[t.jsx("thead",{className:"bg-surface-2 text-foreground",children:t.jsx("tr",{"data-markdown-table-row-line":O+1,"data-md-ref-start":O+1,"data-md-ref-end":O+1,"data-selected":ie(O+1)?"true":void 0,children:j.map((ge,q)=>t.jsx("th",{className:`${Zu} ${lo(o[q]??null)}`,children:t.jsx("div",{className:ao,children:ge})},`h-${q}`))})}),t.jsx("tbody",{children:Y.map((ge,q)=>{const Q=O+q+3;return t.jsx("tr",{className:"border-t border-border/10","data-markdown-table-row-line":Q,"data-md-ref-start":Q,"data-md-ref-end":Q,"data-selected":ie(Q)?"true":void 0,children:_.map((T,z)=>t.jsx("td",{className:`${ef} ${lo(o[z]??null)}`,children:t.jsx("div",{className:ao,children:ge[z]})},`c-${z}`))},`r-${q}`)})})]})})}});continue}const A=Ws(v);if(A){const _=A.ordered,o=go(v),w=A.start,O=f,j=vl(e,f,o,_,!0,h);f=j.nextIndex;const Y=_?"ol":"ul",se=wl(j.items,`list-${O}`,p);g.push({key:`list-${O}`,startLine:O+1,endLine:f,fineGrained:!0,content:ie=>t.jsx(Y,{start:_?w:void 0,className:`${_?"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:kl(se,ie)})});continue}const E=[v.trimStart()],L=[f+1],$=f;for(f+=1;f<e.length&&e[f].trim()&&!tl(e[f])&&!(f+1<e.length&&e[f].includes("|")&&co(e[f+1]));){if(oo(e[f])||h.has(f)){f+=1;continue}E.push(e[f].trimStart()),L.push(f+1),f+=1}const U=al(E,`p-${$}`,p);g.push({key:`p-${$}`,startLine:$+1,endLine:f,fineGrained:!0,content:_=>t.jsx("p",{className:"text-muted-foreground",children:ol(U.perLine,U.hardBreaks,L,`p-${$}`,_)})})}const S=Ex(p);return S&&g.push({key:"footnotes",startLine:e.length,endLine:e.length,content:S}),{blocks:g,images:m}}function _x(e,r,s){return Sl(e,r,s).blocks}function Lf(e,r){const s=[];for(const i of e){if(i.startLine>r)break;if(i.heading){for(;s.length>0&&s[s.length-1].level>=i.heading.level;)s.pop();s.push({...i.heading,startLine:i.startLine})}}return s}function $f(e){return e.filter(r=>!!r.heading).map(r=>({...r.heading,startLine:r.startLine}))}function Dx({src:e,alt:r,onZoomChange:s,onDoubleTap:i}){const d=yf(e);return t.jsx(Vf,{src:d,alt:r,onLoad:()=>{},onError:()=>{},onZoomChange:s,onDoubleTap:i})}function If({images:e,index:r,onChange:s,onClose:i}){const{t:d}=Mt(),c=e[r],h=e.length>1,m=a.useRef(null),p=a.useRef(null),g=a.useRef(null),f=a.useRef(0),[S,v]=a.useState(!1),[P,N]=a.useState(0),[F,B]=a.useState(!1),A=a.useCallback(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),E=a.useCallback(()=>{S||Date.now()<f.current||(A(),g.current=window.setTimeout(()=>{g.current=null,i()},450))},[A,S,i]),L=a.useCallback(o=>{if(e.length===0)return;const w=(o+e.length)%e.length;m.current?.slideTo(w),s(w)},[e.length,s]),$=a.useCallback(()=>L(r-1),[L,r]),U=a.useCallback(()=>L(r+1),[L,r]);if(a.useEffect(()=>{A(),N(0),B(!1),v(!1)},[A,r]),a.useEffect(()=>{const o=m.current;o&&(o.allowTouchMove=h&&!S)},[h,S]),a.useEffect(()=>{const o=m.current;!o||o.activeIndex===r||o.slideTo(r,0)},[r]),a.useEffect(()=>A,[A]),a.useEffect(()=>{const o=w=>{if(w.key==="Escape"){w.preventDefault(),i();return}h&&(w.key==="ArrowLeft"?(w.preventDefault(),$()):w.key==="ArrowRight"&&(w.preventDefault(),U()))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[h,U,$,i]),xu({onDrag:({movement:[o,w],pinching:O})=>{O||S||Math.abs(w)<Math.abs(o)*1.15&&P===0||(B(!0),Math.abs(w)>8&&(f.current=Date.now()+300),N(Math.max(0,w)))},onDragEnd:({movement:[o,w],velocity:[,O],pinching:j,canceled:Y})=>{if(B(!1),j||Y||S||Math.abs(w)<Math.abs(o)*1.15){N(0);return}if(Math.abs(w)>8&&(f.current=Date.now()+300),Af(w,O)){i();return}N(0)}},{target:p,drag:{filterTaps:!0,pointer:{touch:!0}}}),!c)return null;const _=c.title||c.alt||(c.kind==="mermaid"?d("rightSidebar.mermaidDiagram"):d("rightSidebar.image"));return typeof document>"u"?null:Fr.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:i}),t.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:[t.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:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-sm font-medium",children:_}),t.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[r+1," / ",e.length]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[h&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:$,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":d("rightSidebar.previousImage"),title:d("common.previous"),children:t.jsx(as,{size:17})}),t.jsx("button",{type:"button",onClick: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","aria-label":d("rightSidebar.nextImage"),title:d("common.next"),children:t.jsx(pm,{size:17})})]}),t.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","aria-label":d("rightSidebar.closeImagePreview"),title:d("common.close"),children:t.jsx(sr,{size:18})})]})]}),t.jsx("div",{ref:p,className:"relative min-h-0 flex-1 overflow-hidden","data-markdown-image-lightbox-stage":!0,"data-sidebar-gesture-ignore":!0,onClick:E,children:t.jsx("div",{className:"h-full w-full",style:{transform:`translate3d(0, ${P}px, 0) scale(${Math.max(.86,1-P/900)})`,opacity:Math.max(.35,1-P/360),transition:F?"none":"transform 0.2s ease-out, opacity 0.2s ease-out",willChange:"transform, opacity"},children:t.jsx(yu,{onSwiper:o=>{m.current=o,o.allowTouchMove=h&&!S},onSlideChange:o=>{o.activeIndex!==r&&s(o.activeIndex)},onSliderMove:()=>{A(),f.current=Date.now()+450},initialSlide:r,speed:260,slidesPerView:1,resistanceRatio:.82,threshold:6,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,className:"h-full",children:e.map((o,w)=>t.jsx(Bi,{className:"h-full",children:t.jsx("div",{className:"h-full w-full px-3 py-4 sm:px-6 sm:py-6",children:o.kind==="image"?t.jsx(Dx,{src:o.src,alt:o.alt||o.title||d("rightSidebar.markdownImage"),onZoomChange:v,onDoubleTap:A}):t.jsx(Zx,{svg:o.svg,title:o.title||o.alt||d("rightSidebar.mermaidDiagram"),onZoomChange:v,onDoubleTap:A})})},`${o.kind}-${w}-${o.alt}`))})})})]})]}),document.body)}function _f({content:e,filePath:r,rootPath:s,lineRange:i,onLineRangeClick:d,onLineRangeDrag:c,scrollTop:h,outlineOpen:m,outlineCloseSignal:p,onOutlineOpen:g,onOutlineClose:f,lightboxOpen:S,lightboxCloseSignal:v,onLightboxOpen:P,onLightboxClose:N,onLocalLinkOpen:F}){const{t:B}=Mt(),[A,E]=a.useState(null),[L,$]=a.useState(null),[U,_]=a.useState(1),[o,w]=a.useState(null),O=a.useRef(null),j=a.useRef(null),{blocks:Y,images:se}=a.useMemo(()=>Sl(e.split(`
1652
- `),r,s,R=>{$(null),E(R),P?.()},{footnotes:B("rightSidebar.footnotes"),backToFootnote:R=>B("rightSidebar.backToFootnote",{index:R})}),[e,r,s,P,B]),ie=a.useMemo(()=>L?[...se,L]:se,[se,L]),ge=a.useCallback(R=>{$({kind:"mermaid",svg:R,alt:"Mermaid diagram",title:"Mermaid diagram"}),E(se.length),P?.()},[se.length,P]);a.useEffect(()=>{E(null),$(null)},[e,r]),a.useEffect(()=>{E(null),$(null)},[v]),a.useEffect(()=>{S||(E(null),$(null))},[S]),a.useEffect(()=>{_(1)},[e,r]),a.useLayoutEffect(()=>{const R=O.current;if(!R||Y.length===0)return;const V=Array.from(R.querySelectorAll("[data-markdown-preview-block-start]"));let Se=1;const xe=28;for(const Ve of V)if(Ve.offsetTop-h<=xe)Se=Number(Ve.dataset.markdownPreviewBlockStart)||Se;else break;_(Ve=>Ve===Se?Ve:Se)},[Y,h]);const q=a.useMemo(()=>Lf(Y,U),[U,Y]),Q=a.useMemo(()=>$f(Y),[Y]),T=`${r??""}
1653
- ${e}`,z=a.useRef(T),K=a.useRef(null),ae=a.useRef(null),le=a.useRef(!1);a.useEffect(()=>{z.current!==T&&(z.current=T,f?.())},[f,T]),a.useEffect(()=>{p!==void 0&&w(null)},[p]),a.useLayoutEffect(()=>{if(!m){w(null);return}const R=()=>{const V=j.current;if(!V)return;const Se=V.getBoundingClientRect(),xe=window.innerWidth;w({top:Se.bottom+6,right:Math.max(8,xe-Se.right)})};return R(),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[m,h,q]);const we=a.useCallback(R=>{const V=O.current,Se=V?.closest("[data-markdown-preview-scroller]"),xe=V?.querySelector(`[data-markdown-preview-block-start="${R.startLine}"]`);if(!Se||!xe)return;const Ve=Se.getBoundingClientRect(),fe=xe.getBoundingClientRect(),Ie=V?.querySelector("[data-markdown-heading-sticky]")?.getBoundingClientRect().height??0,Ze=fe.top-Ve.top+Se.scrollTop;Se.scrollTo({top:Math.max(0,Ze-Ie-8),behavior:"smooth"}),_(R.startLine),f?.()},[f]),be=a.useCallback(R=>{R.pointerType==="mouse"&&R.button!==0||$i(R.target)||(K.current={pointerId:R.pointerId,startX:R.clientX,startY:R.clientY})},[]),Ae=a.useCallback((R,V,Se)=>{const xe=K.current;if(K.current=null,!xe||xe.pointerId!==R.pointerId)return;const Ve=Math.abs(R.clientX-xe.startX),fe=Math.abs(R.clientY-xe.startY);if(Ve>8||fe>8)return;const Xe=R.target;if($i(Xe)||ll())return;const Ie=hu(Xe,V,Se);d(R,Ie.start,Ie.end)},[d]),M=a.useCallback(R=>{K.current?.pointerId===R.pointerId&&(K.current=null)},[]),te=a.useCallback((R,V)=>{const Se=O.current;if(!Se||typeof document.elementFromPoint!="function")return null;const xe=document.elementFromPoint(R,V);if(!(xe instanceof HTMLElement)||!Se.contains(xe))return null;const Ve=xe.closest("[data-md-ref-start]");if(Ve){const Fe=Number(Ve.dataset.mdRefStart);if(Number.isFinite(Fe)&&Fe>0)return Fe}const fe=xe.closest("[data-markdown-preview-block-start]");if(!fe)return null;const Xe=Number(fe.dataset.markdownPreviewBlockStart),Ie=Y.find(Fe=>Fe.startLine===Xe);if(!Ie)return Number.isFinite(Xe)&&Xe>0?Xe:null;if(Ie.endLine<=Ie.startLine)return Ie.startLine;const Ze=fe.getBoundingClientRect(),ke=Ze.height>0?Math.min(1,Math.max(0,(V-Ze.top)/Ze.height)):0;return Math.round(Ie.startLine+ke*(Ie.endLine-Ie.startLine))},[Y]),ue=a.useCallback(R=>{if(!c||R.pointerType==="mouse"&&R.button!==0)return;const V=te(R.clientX+24,R.clientY);if(V!=null){ae.current={pointerId:R.pointerId,anchorLine:V,moved:!1};try{R.currentTarget.setPointerCapture(R.pointerId)}catch{}}},[c,te]),Le=a.useCallback(R=>{const V=ae.current;if(!V||V.pointerId!==R.pointerId||!c)return;const Se=te(R.clientX+16,R.clientY);Se!=null&&(!V.moved&&Se===V.anchorLine||(V.moved=!0,le.current=!0,c(R,Math.min(V.anchorLine,Se),Math.max(V.anchorLine,Se),"move")))},[c,te]),Ge=a.useCallback(R=>{const V=ae.current;if(ae.current=null,!V||V.pointerId!==R.pointerId||!c||!V.moved)return;const Se=te(R.clientX+16,R.clientY)??V.anchorLine;c(R,Math.min(V.anchorLine,Se),Math.max(V.anchorLine,Se),"end")},[c,te]),Pe=a.useCallback(R=>{ae.current?.pointerId===R.pointerId&&(ae.current=null)},[]),de={onPointerDown:ue,onPointerMove:Le,onPointerUp:Ge,onPointerCancel:Pe},Z=()=>le.current?(le.current=!1,!0):!1;return Y.length===0?t.jsx("div",{className:"min-w-0 max-w-full px-4 py-4 text-sm leading-6 text-foreground",children:t.jsx("p",{className:"text-muted-foreground",children:B("rightSidebar.emptyFile")})}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:O,className:"relative min-w-0 max-w-full",onClickCapture:R=>{const V=R.target instanceof Element?R.target.closest("a[href]"):null;if(!V||!F)return;const Se=V.getAttribute("href");if(!Se)return;const xe=bl(Se,r,s);xe&&(R.preventDefault(),F(xe))},children:[q.length>0&&t.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:t.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",title:q.map(R=>R.text).join(" / "),children:[t.jsx("span",{className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/70","aria-hidden":"true"}),t.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:q[q.length-1].text}),Q.length>1&&t.jsxs("button",{ref:j,type:"button",onClick:()=>{m?f?.():g?.()},className:`inline-flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 ${m?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":m,"aria-label":B("rightSidebar.markdownOutline"),title:B("rightSidebar.markdownOutline"),children:[t.jsx(vu,{size:12}),t.jsx("span",{children:B("rightSidebar.markdownOutlineShort")})]})]})}),m&&typeof document<"u"&&Fr.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-menu-backdrop bg-[rgb(var(--background-rgb)_/_0.18)] sm:hidden",onClick:f}),t.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:o?{top:`${o.top}px`,right:`${o.right}px`}:{top:-9999,right:-9999},"data-markdown-heading-outline-desktop":!0,children:t.jsx("div",{className:"max-h-72 overflow-auto pr-1",children:Q.map(R=>{const V=q[q.length-1]?.startLine===R.startLine;return t.jsxs("button",{type:"button",onClick:()=>we(R),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] ${V?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(R.level-1,4)*12+8}px`},title:R.text,children:[t.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${V?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),t.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",R.level]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:R.text})]},`desktop-${R.id}-${R.startLine}`)})})}),t.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:[t.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 px-1.5 py-1 sm:hidden",children:[t.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:B("rightSidebar.markdownOutlineShort")}),t.jsx("button",{type:"button",onClick:f,className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":B("rightSidebar.closeMarkdownOutline"),title:B("common.close"),children:t.jsx(sr,{size:14})})]}),t.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:Q.map(R=>{const V=q[q.length-1]?.startLine===R.startLine;return t.jsxs("button",{type:"button",onClick:()=>we(R),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] ${V?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${Math.min(R.level-1,4)*12+8}px`},title:R.text,children:[t.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${V?"bg-primary":"bg-border-strong/70"}`,"aria-hidden":"true"}),t.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-muted-foreground/70",children:["H",R.level]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:R.text})]},`${R.id}-${R.startLine}`)})})]})]}),document.body),t.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:t.jsx(uf.Provider,{value:ge,children:Y.map(R=>{const V=!!(i&&R.startLine<=i.end&&R.endLine>=i.start),Se=!!(i&&i.start<=R.startLine&&i.end>=R.endLine),xe=R.kind==="table"?!1:R.fineGrained?Se:V,Ve=R.kind==="table"&&i?.start===R.startLine&&i.end===R.endLine;let fe=null;if(R.kind!=="table"&&R.fineGrained&&V&&!Se&&i){const ke=R.endLine-R.startLine+1,Fe=Math.max(i.start,R.startLine),_e=Math.min(i.end,R.endLine),Wt=(Fe-R.startLine)/ke,st=(_e-Fe+1)/ke;fe=t.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) * ${Wt})`,height:`calc((100% - 0.5rem) * ${st})`}})}const Xe=typeof R.content=="function"?R.content(i):R.content,Ie=R.startLine===R.endLine?String(R.startLine):`${R.startLine}-${R.endLine}`,Ze=t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:Pi(xe),"aria-hidden":"true",...de,children:[t.jsx("span",{className:Ti(xe)}),fe]}),t.jsx("div",{className:"min-w-0","data-sidebar-selectable":!0,children:Xe})]});return R.interactive===!1?t.jsxs("div",{"data-markdown-preview-block-start":R.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 ${xe?"bg-primary/10":""}`,title:`Line ${Ie}`,"aria-label":`Line ${Ie}`,children:[R.kind==="table"?t.jsx("button",{type:"button",className:Pi(Ve,"self"),onClick:ke=>{ke.preventDefault(),!Z()&&d(ke,R.startLine,R.endLine)},title:`Reference table lines ${Ie}`,"aria-label":`Reference table lines ${Ie}`,...de,children:t.jsx("span",{className:Ti(Ve,"self")})}):t.jsxs("span",{className:Pi(xe,"none"),"aria-hidden":"true",...de,children:[t.jsx("span",{className:Ti(xe,"none")}),fe]}),t.jsx("div",{className:"min-w-0 cursor-text select-text","data-sidebar-selectable":!0,role:"button",tabIndex:0,onPointerDown:be,onPointerUp:ke=>Ae(ke,R.startLine,R.endLine),onPointerCancel:M,onKeyDown:ke=>{ke.key!=="Enter"&&ke.key!==" "||(ke.preventDefault(),d(ke,R.startLine,R.endLine))},title:`Reference line ${Ie}`,"aria-label":`Reference line ${Ie}`,children:Xe})]},R.key):t.jsx("div",{role:"button",tabIndex:0,"data-markdown-preview-block-start":R.startLine,onClick:ke=>{const Fe=ke.target;if($i(Fe)||ll()||Z())return;const _e=hu(Fe,R.startLine,R.endLine);d(ke,_e.start,_e.end)},onKeyDown:ke=>{ke.key!=="Enter"&&ke.key!==" "||(ke.preventDefault(),d(ke,R.startLine,R.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 ${xe?"bg-primary/10":"hover:bg-[var(--surface-2)]"}`,title:`Reference line ${Ie}`,"aria-label":`Reference line ${Ie}`,children:Ze},R.key)})})})]}),S&&A!==null&&ie[A]&&t.jsx(If,{images:ie,index:A,onChange:E,onClose:()=>{E(null),$(null),N?.()}})]})}function ts({label:e,value:r,options:s,placeholder:i,searchPlaceholder:d,emptyText:c,disabled:h,onChange:m}){const{t:p}=Mt(),[g,f]=a.useState(!1),[S,v]=a.useState(""),[P,N]=a.useState(null),F=a.useRef(null),B=a.useRef(null),A=S.trim().toLowerCase(),E=a.useMemo(()=>A?s.filter(o=>`${o.label} ${o.meta??""}`.toLowerCase().includes(A)):s,[A,s]),L=s.find(o=>o.value===r),$=()=>{const o=S.trim();o&&(m(o),f(!1),v(""))},U=a.useCallback(()=>{const o=F.current?.getBoundingClientRect();if(!o)return!1;const w=12,O=Math.max(220,Math.min(o.width,window.innerWidth-w*2)),j=Math.min(Math.max(w,o.left),window.innerWidth-O-w),Y=window.innerHeight-o.bottom-w,se=o.top-w,ie=Y>=180||Y>=se,ge=Math.max(96,(ie?Y:se)-4),q=Math.min(320,ge);return N({left:j,top:ie?o.bottom+4:Math.max(w,o.top-q-4),width:O,maxHeight:q}),!0},[]),_=()=>{U(),f(!0)};return a.useEffect(()=>{if(!g)return;let o=0;const w=()=>{o||(o=window.requestAnimationFrame(()=>{o=0,U()}))},O=j=>{const Y=j.target;Y instanceof Node&&(F.current?.contains(Y)||B.current?.contains(Y)||(f(!1),v("")))};return window.addEventListener("resize",w),window.addEventListener("scroll",w,!0),document.addEventListener("pointerdown",O,!0),()=>{o&&window.cancelAnimationFrame(o),window.removeEventListener("resize",w),window.removeEventListener("scroll",w,!0),document.removeEventListener("pointerdown",O,!0)}},[g,U]),t.jsxs("div",{className:"relative min-w-0",children:[t.jsxs("button",{ref:F,type:"button",disabled:h,onClick:()=>{if(!h){if(v(""),g){f(!1);return}_()}},className:"group flex w-full items-center justify-between gap-2 min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-left transition hover:bg-surface-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:e}),t.jsx("span",{className:`min-w-0 flex-1 truncate text-[13px] ${r?"text-foreground":"text-muted-foreground/70"}`,children:L?.label??(r||i)})]}),t.jsx(os,{size:13,className:`shrink-0 text-muted-foreground transition group-hover:text-foreground ${g?"rotate-180":""}`})]}),g&&!h&&typeof document<"u"&&Fr.createPortal(t.jsxs("div",{ref:B,className:"fixed z-popover overflow-hidden rounded-lg border border-border/15 bg-surface shadow-lg",onClick:o=>o.stopPropagation(),style:{left:P?.left??12,top:P?.top??12,width:P?.width??260,maxHeight:P?.maxHeight??320},children:[t.jsx("div",{className:"border-b border-border/10 p-1.5",children:t.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5",children:[t.jsx(ns,{size:12,className:"shrink-0 text-muted-foreground"}),t.jsx("input",{autoFocus:!0,value:S,onChange:o=>v(o.target.value),onKeyDown:o=>{if(o.key==="Escape"){o.preventDefault(),f(!1),v("");return}o.key==="Enter"&&(o.preventDefault(),$())},onBlur:()=>{S.trim()&&E.length===0&&$()},placeholder:d,className:"min-w-0 flex-1 bg-transparent text-[12px] text-foreground outline-none placeholder:text-muted-foreground/70"})]})}),t.jsxs("div",{className:"overflow-y-auto p-1",style:{maxHeight:Math.max(96,(P?.maxHeight??320)-46)},children:[S.trim()&&!s.some(o=>o.value===S.trim())&&t.jsxs("button",{type:"button",onMouseDown:o=>o.preventDefault(),onClick:$,className:"mb-1 flex w-full items-center justify-between gap-2 rounded-md bg-primary/10 px-2 py-1.5 text-left text-[12px] font-medium text-primary transition hover:bg-primary/15",children:[t.jsx("span",{className:"min-w-0 truncate",children:S.trim()}),t.jsx("span",{className:"shrink-0 text-[10px] text-primary/75",children:p("common.use")})]}),E.length>0?E.map(o=>t.jsxs("button",{type:"button",onClick:()=>{m(o.value),f(!1),v("")},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 ${o.value===r?"bg-accent/10 text-accent":"text-foreground"}`,children:[t.jsx("span",{className:"min-w-0 truncate font-medium",children:o.label}),o.meta&&t.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:o.meta})]},o.value)):t.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:c})]})]}),document.body)]})}function ou({open:e,onOpenChange:r,showScopePicker:s,selectedAll:i,repos:d,selectedRoots:c,onToggleRepo:h,onGenerate:m,onSecondaryAction:p,disabled:g,generateDisabled:f,secondaryDisabled:S,inserted:v,buttonLabel:P,insertedLabel:N,title:F,ariaLabel:B,scopeTitle:A,scopeLabel:E,allLabel:L,generateLabel:$,secondaryLabel:U,secondaryTitle:_,secondaryLoading:o,loading:w,error:O,statusTitle:j,extraContent:Y,renderRepoExtra:se}){return t.jsxs("div",{className:"relative inline-flex shrink-0",children:[t.jsxs("button",{type:"button",onClick:()=>{s?r(!e):f||m()},disabled:g,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-[11px] font-medium transition active:scale-95 disabled:cursor-not-allowed disabled:opacity-50 ${O?"text-destructive hover:bg-destructive/5":v?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-label":B,title:j??(s?`${A}: ${E}`:F),children:[w?t.jsx(yt,{size:13,className:"animate-spin"}):t.jsx(Bs,{size:13}),t.jsx("span",{children:v?N:P}),s&&t.jsx(os,{size:11,className:`shrink-0 transition ${e?"rotate-180":""}`}),O&&t.jsx("span",{className:"absolute right-0.5 top-0.5 size-1.5 rounded-full bg-destructive"})]}),s&&e&&typeof document<"u"&&Fr.createPortal(t.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] px-3 py-6 backdrop-blur-sm animate-fade-in",onClick:()=>r(!1),children:t.jsxs("div",{className:"fixed left-1/2 top-1/2 z-modal-panel flex max-h-[min(82vh,36rem)] w-[calc(100vw-1.5rem)] max-w-[42rem] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border/20 bg-surface text-[11px] shadow-2xl",onClick:ie=>ie.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border/15 px-3 py-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:A}),t.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:E})]}),t.jsx("button",{type:"button",onClick:()=>r(!1),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":"Close",children:t.jsx(sr,{size:14})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[Y,t.jsxs("button",{type:"button",onClick:()=>h(null),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${i?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[t.jsx("span",{className:"truncate",children:L}),i&&t.jsx("span",{className:"text-[10px]",children:"✓"})]}),d.map(ie=>{const ge=c.includes(ie.root);return t.jsxs("div",{className:`mt-1 rounded-md transition ${ge?"bg-primary/15 text-primary":""}`,children:[t.jsxs("button",{type:"button",onClick:()=>h(ie.root),className:`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left font-medium transition ${ge?"text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:ie.root,children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate",children:ie.label}),ie.branch&&t.jsx("span",{className:"block truncate text-[9px] opacity-70",children:ie.branch})]}),ge&&t.jsx("span",{className:"text-[10px]",children:"✓"})]}),se&&(i||ge)&&t.jsx("div",{className:"px-2 pb-2",children:se(ie)})]},ie.root)})]}),t.jsxs("div",{className:`grid grid-cols-1 gap-1.5 border-t border-border/15 p-2 ${p&&U?"sm:grid-cols-2":""}`,children:[p&&U&&t.jsxs("button",{type:"button",onClick:()=>{S||(r(!1),p())},disabled:S,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:_,children:[o?t.jsx(yt,{size:12,className:"animate-spin"}):t.jsx(Eu,{size:12}),U]}),t.jsxs("button",{type:"button",onClick:()=>{f||(r(!1),m())},disabled:f,className:"flex h-7 w-full items-center justify-center gap-1 rounded-md bg-primary/15 px-2 text-[11px] font-semibold text-primary transition hover:bg-primary/25 disabled:cursor-not-allowed disabled:opacity-50 active:scale-95",title:F,children:[t.jsx(Bs,{size:12}),$]})]})]})}),document.body)]})}function Fx(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;for(const r of Object.values(e)){if(!r||typeof r!="object"||Array.isArray(r))return!1;const s=r;if(typeof s.top!="number"||!Number.isFinite(s.top)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function Df(){return mt(ml,Fx)??{}}function Ox(e,r){const s=Df(),i=Object.entries({...s,[e]:{top:r,updatedAt:Date.now()}}).sort(([,d],[,c])=>c.updatedAt-d.updatedAt).slice(0,$b);Is(ml,Object.fromEntries(i),_b)}function Bx(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return typeof r.start=="number"&&Number.isFinite(r.start)&&typeof r.end=="number"&&Number.isFinite(r.end)&&r.start>=1&&r.end>=r.start}function Ux(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;for(const r of Object.values(e)){if(!r||typeof r!="object"||Array.isArray(r))return!1;const s=r;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&&!Bx(s.lineRange)||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt))return!1}return!0}function jl(e,r){if(!r)return null;const s=e&&!r.startsWith("/")?`${e}/${r}`:r;return e?`${e}::${s}`:s}function Ff(){return mt(pl,Ux)??{}}function iu(e,r){const s=jl(e,r);return s?Ff()[s]??null:null}function Ei(e,r,s){const i=jl(e,r);if(!i)return;const d=Ff(),c=d[i]??{top:0,left:0,markdownTop:0,lineRange:null,updatedAt:Date.now()},h=Object.entries({...d,[i]:{...c,...s,updatedAt:Date.now()}}).sort(([,m],[,p])=>p.updatedAt-m.updatedAt).slice(0,Ib);Is(pl,Object.fromEntries(h),Db)}function Ya({active:e,mounted:r=!0,fallback:s=null,children:i}){return t.jsx("div",{className:`h-full min-h-0 overflow-hidden bg-surface text-foreground ${e?"block":"hidden"}`,"aria-hidden":!e,children:r?typeof i=="function"?i():i:s})}function Mi({slow:e}){return t.jsx(tp,{slow:e})}function Xa({message:e,onRetry:r}){const{t:s}=Mt();return t.jsxs("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-5 text-center text-sm text-destructive",children:[t.jsx("div",{className:"font-medium",children:s("rightSidebar.gitChangesLoadFailed")}),t.jsx("div",{className:"mt-1 break-words text-xs opacity-85",children:e}),t.jsx("button",{type:"button",onClick:r,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 to(e,r){const s=r&&e.startsWith(`${r}/`)?e.slice(r.length+1):e,i=s.split("/").filter(Boolean);return{name:i.pop()||s,dir:i.join("/")}}function Et(e){if(!e)return"";const r=e.replace(/\/+$/,"");return r.split("/").pop()||r||"/"}function Ai(e){if(!e)return null;const r=e.replace(/\/+$/,"")||"/";if(r==="/")return null;const s=r.slice(0,r.lastIndexOf("/"))||"/";return s===r?null:s}function il(e,r,s){const i=Math.min(r,s),d=Math.max(r,s);return e?.start===i&&e.end===d?null:e&&e.start===e.end?{start:Math.min(e.start,i),end:Math.max(e.end,d)}:{start:i,end:d}}function zx(e,r,s){return il(e,r,s)}function Pi(e,r="group"){return`relative flex min-h-5 w-full touch-none select-none items-stretch justify-center rounded transition sm:min-h-6 ${e?"bg-primary/20":`bg-[var(--surface-2)] ${r==="group"?"group-hover:bg-[var(--surface-elevated)]":r==="self"?"hover:bg-[var(--surface-elevated)]":""}`}`}function Ti(e,r="group"){return`my-1 w-0.5 rounded-full transition sm:w-1 ${e?"bg-primary":`bg-[var(--border-strong)] ${r==="group"?"group-hover:bg-[var(--muted-foreground)]":r==="self"?"hover:bg-[var(--muted-foreground)]":""}`}`}function lu(e,r){return`pointer-events-auto absolute z-30 inline-flex items-center gap-1 rounded-full font-semibold shadow-lg ring-1 transition active:scale-95 ${e?"h-9 px-4 text-[12px]":"h-7 px-3 text-[11px]"} ${r?"bg-surface-elevated text-foreground ring-border-strong/40 hover:bg-surface-2":"bg-primary text-primary-foreground ring-primary/30 hover:bg-primary/90"}`}function Of(e){const r=new Map;for(const s of e)r.set(Rl(s),s);return r}function Bf(e,r){const s=new Map(e);for(const i of r)s.set(Rl(i),i);return s}function cu(e,r){let s=0;for(const i of e){const d=jt(i,r);d&&r&&d!==r&&(s+=1)}return s}function Hx(e){return e.reduce((r,s)=>r+(s.staged?1:0),0)}function Wx(e,r){return Array.from(Bf(Of(e),r).values()).sort((s,i)=>s.path.localeCompare(i.path))}function Gx(e,r){const s=e.relativeRoot==="."?Et(r??e.root)||e.name||e.root:e.relativeRoot||e.name||Et(e.root)||e.root;return{root:e.root,label:s,branch:e.context?.branch??null,count:e.files.length,staged:Hx(e.files)}}function Uf(e,r){const s=Et(r??"")||r||"";return e.map(i=>Gx(i,r)).sort((i,d)=>s&&i.label===s?-1:s&&d.label===s?1:i.label.localeCompare(d.label))}function zf(e,r,s,i,d){const c=nf(s),h=c.find(F=>F.root===i)??c[0]??null,m=r.find(F=>F.root===i)??null,p=m?.relativeRoot??h?.relativeRoot??".",g=m?.name??h?.name??(Et(i)||i),f=(h?.files??s.files).map(F=>({...F,repoRoot:i,repoRelativeRoot:p,repoName:g})),S=h?.context??s.context,v={...m??h??{id:i,root:i,relativeRoot:p,name:g,depth:0,nested:!!(d&&i!==d),available:s.available,files:[],context:null},...h??{},id:m?.id??h?.id??i,root:i,displayRoot:m?.displayRoot??h?.displayRoot,relativeRoot:p,name:g,depth:m?.depth??h?.depth??0,nested:m?.nested??h?.nested??!!(d&&i!==d),available:h?.available??s.available,files:f,context:S?{...S,root:i,changedFiles:f.map(F=>({path:F.path,absolutePath:F.absolutePath,status:F.status}))}:null,untrackedDeferred:h?.untrackedDeferred??s.untrackedDeferred,error:h?.error??s.error},P=m?r.map(F=>F.root===i?v:F):[...r,v];return{files:Array.from(e).filter(F=>jt(F,d)!==i).concat(f),repositories:P,repoFilters:Uf(P,d)}}function jt(e,r){return e.repoRoot??r}function Rl(e){return`${e.repoRoot??""}\0${e.path}`}function Nt(e){return e.absolutePath||e.path}function Li(e){return Rl(e)}function qx(e){return e.repoRelativeRoot&&e.repoRelativeRoot!=="."?e.repoRelativeRoot:e.repoName??""}function du(e){return e.reduce((r,s)=>r+(s.staged?1:0),0)}function uu(e){const r={added:0,modified:0,deleted:0,renamed:0,copied:0,untracked:0,conflicted:0,staged:0,other:0};for(const s of e)s.status==="added"?r.added+=1:s.status==="modified"?r.modified+=1:s.status==="deleted"?r.deleted+=1:s.status==="renamed"?r.renamed+=1:s.status==="copied"?r.copied+=1:s.status==="untracked"?r.untracked+=1:s.status==="conflicted"?r.conflicted+=1:r.other+=1,s.staged&&(r.staged+=1);return r}function rs(e){let r=0;const s=e??"root";for(let i=0;i<s.length;i+=1)r=Math.imul(r^s.charCodeAt(i),16777619);return`right-sidebar-git-bundle:${(r>>>0).toString(36)}`}function Ts(e,r){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:new Intl.DateTimeFormat(r==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(e))}function Dr(e){return e instanceof DOMException&&e.name==="AbortError"}function Vx(e){const r=e.error??e.context?.error??"";return r.includes("request was cancelled")||r.includes("IO_REQUEST_CANCELLED")}function fu(e){return e?.available===!1&&e.code==="NOT_GIT_REPOSITORY"}function ll(){if(typeof window>"u")return!1;const e=window.getSelection();return!!(e&&!e.isCollapsed&&e.toString().trim())}function $i(e){return e instanceof HTMLElement&&!!e.closest('a, button, input, textarea, select, label, [contenteditable="true"]')}function hu(e,r,s){const i=e instanceof HTMLElement?e.closest("[data-md-ref-start]"):null,d=Number(i?.dataset.mdRefStart),c=Number(i?.dataset.mdRefEnd??i?.dataset.mdRefStart);return Number.isFinite(d)&&d>0&&Number.isFinite(c)&&c>0?{start:Math.min(d,c),end:Math.max(d,c)}:{start:r,end:s}}function Kx({actions:e,running:r,completed:s}){const{t:i}=Mt(),[d,c]=a.useState(!1),h=a.useRef(null),m=e.find(g=>r?.action===g.key),p=e.find(g=>s?.action===g.key);return e.length===0?null:(a.useEffect(()=>{if(!d)return;const g=S=>{const v=S.target;v instanceof Node&&h.current?.contains(v)||c(!1)},f=S=>{S.key==="Escape"&&c(!1)};return document.addEventListener("pointerdown",g),document.addEventListener("keydown",f),()=>{document.removeEventListener("pointerdown",g),document.removeEventListener("keydown",f)}},[d]),t.jsxs("div",{ref:h,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),c(f=>!f)},disabled:e.every(g=>g.disabled)&&!r&&!s,className:`inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md transition active:scale-95 disabled:opacity-50 ${d?"bg-surface-elevated text-foreground":p?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:m?.label??p?.label??i("rightSidebar.gitQuickActions"),children:m?t.jsx(yt,{size:13,className:"animate-spin"}):p?t.jsx("span",{className:"text-[12px] font-semibold",children:"✓"}):t.jsx(Oi,{size:14})}),d&&t.jsx("div",{className:"absolute right-0 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:e.map(g=>{const f=r?.action===g.key,S=s?.action===g.key;return t.jsxs("button",{type:"button",onClick:v=>{v.stopPropagation(),g.onClick(),c(!1)},disabled:g.disabled||!!r,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 ${S?"bg-accent/10 text-accent":g.destructive?"text-destructive hover:bg-destructive/10":"text-foreground hover:bg-surface-2"}`,children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:f?t.jsx(yt,{size:13,className:"animate-spin"}):S?"✓":null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.label})]},g.key)})})]}))}function Yx(e){const r=window.getComputedStyle(e).overflowY;return(r==="auto"||r==="scroll")&&e.scrollHeight>e.clientHeight+1}function Hf(e){let r=e;for(;r;){if(r.classList.contains("termdock-diff-stream-scroller")&&Yx(r))return r;r=r.parentElement}return e.closest(".termdock-diff-stream-scroller")}function ss(e){return e.getClientRects().length>0&&window.getComputedStyle(e).visibility!=="hidden"}const Ii=new WeakMap;function fo(e){const r=Ii.get(e);r!==void 0&&window.clearTimeout(r),e.classList.remove("diff-walkthrough-target"),e.offsetWidth,e.classList.add("diff-walkthrough-target");const s=window.setTimeout(()=>{e.classList.remove("diff-walkthrough-target"),Ii.delete(e)},1700);Ii.set(e,s)}function Xx(e){const r=CSS.escape(e),s=[`[data-diff-stream-item="${r}"]`,`[data-diff-selection-path="${r}"]`,`[data-diff-absolute-path="${r}"]`].join(","),i=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let d=null;for(const m of i){if(!ss(m))continue;const p=m.querySelector(s);if(p&&ss(p)){d=p;break}}if(d??=Array.from(document.querySelectorAll(s)).find(ss)??null,!d)return;const c=Hf(d);if(!c){d.scrollIntoView({block:"start",behavior:"smooth"}),fo(d);return}const h=d.getBoundingClientRect().top-c.getBoundingClientRect().top+c.scrollTop;c.scrollTo({top:Math.max(0,h),behavior:"instant"}),fo(d)}function En(e){const r=CSS.escape(e.filePath),s=typeof e.sectionIndex=="number"?String(e.sectionIndex):null,i=typeof e.hunkIndex=="number"?String(e.hunkIndex):null,d=e.sectionFingerprint?CSS.escape(e.sectionFingerprint):null,c=e.hunkFingerprint?CSS.escape(e.hunkFingerprint):null,h=[s!==null&&d?`[data-diff-section-audit="${r}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${d}"]`:null,s!==null&&d?`[data-diff-section-anchor="${r}"][data-diff-section-index="${s}"][data-diff-section-fingerprint="${d}"]`:null,s!==null?`[data-diff-section-audit="${r}"][data-diff-section-index="${s}"]`:null,s!==null?`[data-diff-section-anchor="${r}"][data-diff-section-index="${s}"]`:null,i!==null&&c?`[data-diff-hunk-anchor="${r}"][data-diff-hunk-index="${i}"][data-diff-hunk-fingerprint="${c}"]`:null,i!==null?`[data-diff-hunk-anchor="${r}"][data-diff-hunk-index="${i}"]`:null,`[data-diff-file-path="${r}"]`].filter(N=>!!N),m=Array.from(document.querySelectorAll(".termdock-diff-stream-scroller"));let p=null;for(const N of m)if(ss(N)){for(const F of h){const B=N.querySelector(F);if(B&&ss(B)){p=B;break}}if(p)break}if(p??=h.flatMap(N=>Array.from(document.querySelectorAll(N))).find(ss)??null,!p){Xx(e.filePath);return}const g=Hf(p);if(!g){p.scrollIntoView({block:"center",behavior:"smooth"}),fo(p);return}const f=p.getBoundingClientRect(),S=g.getBoundingClientRect(),P=f.top-S.top+g.scrollTop-Math.max(24,(g.clientHeight-f.height)/2);g.scrollTo({top:Math.max(0,P),behavior:"instant"}),fo(p)}const Wf=1,Gf=8;function Jx(e){return Math.min(Gf,Math.max(Wf,e))}function qf({resetKey:e,onZoomChange:r,onDoubleTap:s,children:i}){const d=a.useRef(null),[c,h]=a.useState({scale:1,x:0,y:0}),[m,p]=a.useState(!1),g=a.useRef(null),f=a.useRef(new Set),S=a.useRef(!1),v=a.useRef(null),P=a.useRef(0),N=a.useRef(c);N.current=c,a.useEffect(()=>{h({scale:1,x:0,y:0})},[e]);const F=a.useCallback((L,$,U)=>{const _=d.current;if(!_)return{x:$,y:U};const o=_.firstElementChild instanceof HTMLElement?_.firstElementChild:null,w=o?.clientWidth||_.clientWidth,O=o?.clientHeight||_.clientHeight,j=Math.max(0,(w*L-_.clientWidth)/2),Y=Math.max(0,(O*L-_.clientHeight)/2);return{x:Math.min(j,Math.max(-j,$)),y:Math.min(Y,Math.max(-Y,U))}},[]),B=a.useCallback((L,$,U)=>{h(_=>{const o=Jx(L),w=d.current;if(!w||o===1)return{scale:o,x:0,y:0};const O=w.getBoundingClientRect(),j=($??O.left+O.width/2)-O.left-O.width/2,Y=(U??O.top+O.height/2)-O.top-O.height/2,se=o/_.scale,ie=j-(j-_.x)*se,ge=Y-(Y-_.y)*se;return{scale:o,...F(o,ie,ge)}})},[F]),A=a.useCallback((L,$)=>{p(!0),N.current.scale>1?h({scale:1,x:0,y:0}):B(2.5,L,$),window.setTimeout(()=>p(!1),220)},[B]);a.useEffect(()=>{const L=d.current;if(!L)return;const $=o=>{if(o.pointerType==="mouse"&&o.button!==0)return;const w=f.current.size===0;if(f.current.add(o.pointerId),w){const O=Date.now(),j=v.current;if(j&&O-j.time<350&&Math.hypot(o.clientX-j.x,o.clientY-j.y)<24){v.current=null,P.current=O,s?.(),A(o.clientX,o.clientY);return}}if(f.current.size>1){S.current=!0,g.current=null;return}if(!(N.current.scale<=1)){o.preventDefault(),g.current={pointerId:o.pointerId,startX:o.clientX,startY:o.clientY,originX:N.current.x,originY:N.current.y,moved:!1};try{L.setPointerCapture?.(o.pointerId)}catch{}p(!1)}},U=o=>{const w=g.current;if(!w||w.pointerId!==o.pointerId)return;const O=o.clientX-w.startX,j=o.clientY-w.startY;if(!w.moved){if(Math.hypot(O,j)<6)return;w.moved=!0}o.stopPropagation(),o.preventDefault(),h(Y=>({...Y,...F(Y.scale,w.originX+O,w.originY+j)}))},_=o=>{const w=g.current,O=w?.pointerId===o.pointerId&&w.moved;if(w?.pointerId===o.pointerId){w.moved&&o.stopPropagation(),g.current=null;try{L.releasePointerCapture?.(o.pointerId)}catch{}}f.current.delete(o.pointerId)&&f.current.size===0&&(!S.current&&!O&&(v.current={time:Date.now(),x:o.clientX,y:o.clientY}),S.current=!1)};return L.addEventListener("pointerdown",$,{capture:!0,passive:!1}),window.addEventListener("pointermove",U,{capture:!0,passive:!1}),window.addEventListener("pointerup",_,{capture:!0}),window.addEventListener("pointercancel",_,{capture:!0}),()=>{L.removeEventListener("pointerdown",$,{capture:!0}),window.removeEventListener("pointermove",U,{capture:!0}),window.removeEventListener("pointerup",_,{capture:!0}),window.removeEventListener("pointercancel",_,{capture:!0})}},[F,s,A]),xu({onPinch:({offset:[L],origin:[$,U]})=>{p(!1),B(L,$,U)},onWheel:({event:L,delta:[$,U],ctrlKey:_})=>{if(_){L.preventDefault(),L.stopPropagation(),p(!1),B(N.current.scale*(1-U*.01),L.clientX,L.clientY);return}N.current.scale<=1||(L.preventDefault(),L.stopPropagation(),p(!1),h(o=>({...o,...F(o.scale,o.x-$,o.y-U)})))}},{target:d,eventOptions:{passive:!1},pinch:{scaleBounds:{min:Wf,max:Gf},from:()=>[N.current.scale,0],rubberband:!0}});const E=c.scale>1;return a.useEffect(()=>{r?.(E)},[r,E]),t.jsx("div",{ref:d,"data-sidebar-gesture-ignore":E?"":void 0,className:"flex h-full w-full touch-none select-none items-center justify-center overflow-hidden",style:{cursor:E?"grab":"zoom-in"},onDoubleClick:L=>{L.stopPropagation(),!(Date.now()-P.current<500)&&(s?.(),A(L.clientX,L.clientY))},children:i({scale:c.scale,zoomed:E,animateTransform:m,transformStyle:{transform:`translate3d(${c.x}px, ${c.y}px, 0) scale(${c.scale})`,transformOrigin:"center center",transition:m?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none",willChange:"transform"},vectorTransformStyle:{transform:`translate3d(${c.x}px, ${c.y}px, 0)`,transformOrigin:"center center",transition:m?"transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}})})}function Vf({src:e,alt:r,vector:s,onLoad:i,onError:d,onZoomChange:c,onDoubleTap:h}){const m=ho(e,d),[p,g]=a.useState(null),f=s??po(e);return a.useEffect(()=>{g(null)},[e]),t.jsx(qf,{resetKey:e,onZoomChange:c,onDoubleTap:h,children:({transformStyle:S,vectorTransformStyle:v,scale:P,animateTransform:N})=>{const F=t.jsx("img",{src:m,alt:r,draggable:!1,className:"max-h-full max-w-full touch-none select-none rounded border border-border/15 bg-surface object-contain shadow-sm",style:f&&p?{position:"absolute",left:"50%",top:"50%",width:p.width*P,height:p.height*P,maxWidth:"none",maxHeight:"none",transform:"translate3d(-50%, -50%, 0)",transition:N?"width 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.22s cubic-bezier(0.2, 0.8, 0.2, 1)":"none"}:p?{...S,width:p.width,height:p.height}:f?v:S,onLoad:B=>{const A=B.currentTarget,E=A.parentElement;if(E&&A.naturalWidth>0&&A.naturalHeight>0){const L=Math.max(1,E.clientWidth-2),$=Math.max(1,E.clientHeight-2),U=Math.min(L/A.naturalWidth,$/A.naturalHeight),_=f?U:Math.min(U,1);g({width:Math.max(1,Math.round(A.naturalWidth*_)),height:Math.max(1,Math.round(A.naturalHeight*_))})}i(B)},onError:d});return!f||!p?F:t.jsx("div",{"data-vector-zoom-surface":!0,className:"relative shrink-0 touch-none select-none",style:{...v,width:p.width,height:p.height},children:F})}})}function Qx({svg:e,title:r,scale:s,vectorTransformStyle:i}){const d=a.useRef(null);return a.useLayoutEffect(()=>{const c=d.current,h=c?.querySelector("svg");if(!c||!h)return;const m=()=>{const f=h.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number)??[];let S=f[2],v=f[3];if((!Number.isFinite(S)||!Number.isFinite(v)||S<=0||v<=0)&&(S=Number(h.getAttribute("width")),v=Number(h.getAttribute("height"))),!Number.isFinite(S)||!Number.isFinite(v)||S<=0||v<=0)return;const P=Math.max(1,c.clientWidth-24),N=Math.max(1,c.clientHeight-24),F=Math.min(P/S,N/v,1);h.style.width=`${Math.max(1,Math.floor(S*F*s))}px`,h.style.height=`${Math.max(1,Math.floor(v*F*s))}px`,h.style.maxWidth="none",h.style.maxHeight="none",h.style.transform=String(i.transform??""),h.style.transformOrigin="center center",h.style.transition=String(i.transition??"none")};m();const p=typeof ResizeObserver>"u"?null:new ResizeObserver(m);return p?.observe(c),()=>p?.disconnect()},[s,e,i]),t.jsx("div",{ref:d,role:"img","aria-label":r,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:e}})}function Zx({svg:e,title:r,onZoomChange:s,onDoubleTap:i}){return t.jsx(qf,{resetKey:e,onZoomChange:s,onDoubleTap:i,children:({vectorTransformStyle:d,scale:c})=>t.jsx(Qx,{svg:e,title:r,scale:c,vectorTransformStyle:d})})}let e0=0,t0=0,r0=0,n0=0,s0=0;function _i(e,r={}){if(typeof window>"u")return;const s=JSON.stringify({level:e==="still_active"?"warn":"info",message:`FILE_PREVIEW_LOADING ${e}`,data:{ts:Date.now(),...r}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function ut(e,r={}){if(typeof window>"u")return;const s=JSON.stringify({level:e==="error"||e==="empty_bundle"?"warn":"info",message:`GIT_BUNDLE ${e}`,data:{seq:++t0,ts:Date.now(),...r}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function Ja(e,r={}){if(typeof window>"u")return;const s=JSON.stringify({level:"info",message:`DIFF_INTERACTION ${e}`,data:{seq:++n0,ts:Date.now(),...r}});fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(()=>{})}function a0(){return`diff-ui-${Date.now().toString(36)}-${(++s0).toString(36)}`}function o0(e){return e instanceof Element?e.closest("[data-diff-selection-path]"):null}function i0(e){const r=e.target instanceof HTMLElement?e.target:null;return{eventType:e.type,button:e.button,pointerType:e instanceof globalThis.PointerEvent?e.pointerType:void 0,targetTag:r?.tagName,targetClass:r?.className,targetText:r?.textContent?.slice(0,80)}}function cl({onReviewReference:e,filePath:r,onInsertReference:s,onInsertText:i,onInsertFeature:d,onReferenceCopied:c,onClose:h,onDirectoryLinkOpen:m,isMobile:p,markdownOutlineOpen:g,markdownOutlineCloseSignal:f,onOpenMarkdownOutline:S,onCloseMarkdownOutline:v,markdownImageLightboxOpen:P,markdownImageLightboxCloseSignal:N,onOpenMarkdownImageLightbox:F,onCloseMarkdownImageLightbox:B,lineRange:A,onLineRangeChange:E,insertedReferenceKey:L,copiedReferenceKey:$,scrollToLine:U,onScrollToLineHandled:_}){const{t:o}=Mt(),w=ne(D=>D.rootPath),O=ne(D=>D.selectFile),[j,Y]=a.useState({kind:"idle"}),[se,ie]=a.useState("schematic"),[ge,q]=a.useState(null),Q=a.useRef(null),[T,z]=a.useState(null),K=a.useRef(new Map),ae=a.useRef(null),[le,we]=a.useState(null),[be,Ae]=a.useState(()=>Kd()),[M,te]=a.useState(()=>Id(w,r)),ue=a.useRef(null),[Le,Ge]=a.useState(!1),[Pe,de]=a.useState(null),[Z,R]=a.useState(0),[V,Se]=a.useState([]),[xe,Ve]=a.useState(null),fe=a.useRef(null),Xe=a.useRef(r),[Ie,Ze]=a.useState(null),[ke,Fe]=a.useState({status:"idle"}),[_e,Wt]=a.useState(!1),[st,At]=a.useState(""),[Je,Ft]=a.useState([]),[vt,W]=a.useState(0),ee=a.useRef(null),me=Nu(c),Ue=jl(w,r);a.useEffect(()=>{if(Xe.current===r)return;Xe.current=r;const D=r&&w&&!r.startsWith("/")?`${w}/${r}`:r;if(fe.current===D){fe.current=null;return}fe.current=null,Se([]),Ve(null),Wt(!1),At("")},[r,w]);const ht=r?w&&!r.startsWith("/")?`${w}/${r}`:r:null,Pt=ne(D=>ht?(D.fileChangeVersions.get(ht)??0)+D.fileWatchEpoch:D.fileWatchEpoch),Ot=a.useRef(null),Yt=a.useRef(null),[Gt,Mn]=a.useState(0),Or=a.useCallback(()=>Mn(D=>D+1),[]);a.useEffect(()=>{const D=Q.current;return Q.current=null,q(null),D&&URL.revokeObjectURL(D.objectUrl),()=>{const G=Q.current;Q.current=null,G&&URL.revokeObjectURL(G.objectUrl)}},[ht,Pt,Gt]),a.useEffect(()=>{if(!r){Ot.current=null,Y({kind:"idle"});return}const D=w&&!r.startsWith("/")?`${w}/${r}`:r,G=new AbortController,he=++e0,je=`right-sidebar-file-preview:${he}`,Qe=performance.now();let Be=!1;const tt=(re,Ye={})=>{Be||(Be=!0,_i("end",{loadingId:he,reason:re,durationMs:Math.round(performance.now()-Qe),filePath:r,fullPath:D,rootPath:w,...Ye}))};let Ke=null;const bt=nm(D),kt=bt?D.toLowerCase().endsWith(".kicad_pcb")?se==="schematic"?"pcb-front":se:"schematic":se,mr=!bt&&fl(D),Cr=!bt&&!mr&&sm(D),$n=!bt&&!mr&&!Cr&&mu(D),un=Ps(D),us=Cs(D),pr=bt?"eda":mr?"image":Cr?"model3d":$n?"video":"text",fs=Ot.current!==D;if(Ot.current=D,fs){_i("start",{loadingId:he,filePath:r,fullPath:D,rootPath:w,mode:pr,externalVersion:Pt}),Fe({status:"idle"}),Y({kind:"loading",mode:pr}),Yt.current=null;const re=iu(w,r);E(re?.lineRange??null),Ae(un?Kd():"source"),te(us?Id(w,r):"source"),bt&&ie(am(D))}fs||Y(re=>re.kind==="error"?{kind:"loading",mode:pr}:re);const fn=window.setTimeout(()=>{Be||G.signal.aborted||_i("still_active",{loadingId:he,filePath:r,fullPath:D,rootPath:w,mode:pr,durationMs:Math.round(performance.now()-Qe),isPathChange:fs})},3e3),qr=window.setTimeout(()=>{if(Be||G.signal.aborted)return;const re=bt?o("rightSidebar.edaTimeout"):Cr?o("rightSidebar.model3dTimeout"):"File preview timed out. Try the file again or refresh the directory.";G.abort(new DOMException(re,"TimeoutError")),Y({kind:"error",message:re}),tt("stuck_timeout",{error:re})},bt?om+5e3:Cr?im+5e3:lm(D)?35e3:Hb);if(bt){const re=kt==="pcb-3d"?Q.current:null;re?(Y(re),tt("eda_3d_client_cache_hit",{bytes:re.meta.size,view:re.view,mimeType:re.meta.mimeType})):cm(D,kt,G.signal,"view_file",je).then(Ye=>{if(G.signal.aborted)return;Ke=URL.createObjectURL(Ye.blob);const Jt={kind:"eda",sourcePath:Ye.path||D,objectUrl:Ke,view:Ye.view,meta:{size:Ye.size,mimeType:Ye.mimeType,modified:Ye.modified}};if(Ye.view==="pcb-3d"){const Nr=Q.current;Nr&&Nr.objectUrl!==Ke&&URL.revokeObjectURL(Nr.objectUrl),Q.current=Jt,q(Jt),Ke=null}Y(Jt),tt("eda_loaded",{bytes:Ye.size,view:Ye.view,mimeType:Ye.mimeType})}).catch(Ye=>{G.signal.aborted||(Y({kind:"error",message:Ye instanceof Error&&/timed out/i.test(Ye.message)?o("rightSidebar.edaTimeout"):Ye instanceof Error?Ye.message:o("rightSidebar.edaLoadFailed")}),tt("error",{error:Ye instanceof Error?Ye.message:String(Ye)}))})}else if(mr)dm(D,G.signal,"view_file",je).then(re=>{Ke=URL.createObjectURL(re.blob),Y({kind:"image",objectUrl:Ke,meta:{size:re.size,mimeType:re.mimeType,modified:re.modified}}),tt("image_loaded",{bytes:re.size,mimeType:re.mimeType})}).catch(re=>{G.signal.aborted||(Y({kind:"error",message:re instanceof Error?re.message:o("rightSidebar.imageLoadFailed")}),tt("error",{error:re instanceof Error?re.message:String(re)}))});else if(Cr)um(D,G.signal,"view_file",je).then(re=>{G.signal.aborted||(Ke=URL.createObjectURL(re.blob),Y({kind:"model3d",sourcePath:re.path||D,objectUrl:Ke,ext:re.ext,meta:{size:re.size,mimeType:re.mimeType,modified:re.modified}}),tt("model3d_loaded",{bytes:re.size,ext:re.ext}))}).catch(re=>{G.signal.aborted||(Y({kind:"error",message:re instanceof Error&&(re.name==="TimeoutError"||/timed out/i.test(re.message))?o("rightSidebar.model3dTimeout"):re instanceof Error?re.message:o("rightSidebar.model3dLoadFailed")}),tt("error",{error:re instanceof Error?re.message:String(re)}))});else if($n){const re=fm(D)??"",Ye=pu(D);Y(Jt=>Jt.kind==="video"&&Jt.url===Ye?Jt:{kind:"video",url:Ye,meta:{size:null,mimeType:re,modified:null}}),tt("video_ready",{mimeType:re})}else md(D,G.signal,"view_file",je).then(re=>{if(!G.signal.aborted){if(re.binary){Y({kind:"binary"});return}Y({kind:"text",content:re.content,sourcePath:re.path||D,meta:{size:re.size,truncated:re.truncated}}),tt("text_loaded",{bytes:re.size,truncated:!!re.truncated})}}).catch(re=>{G.signal.aborted||(Y({kind:"error",message:re instanceof Error?re.message:"Failed to read file"}),tt("error",{error:re instanceof Error?re.message:String(re)}))});return()=>{G.abort(),_t(je),window.clearTimeout(fn),window.clearTimeout(qr),Ke&&URL.revokeObjectURL(Ke),tt("cleanup")}},[r,w,Pt,Gt,E,o,se]),a.useEffect(()=>{if(j.kind!=="model3d"||!r){z(null);return}let D=!1;const G=r.lastIndexOf("/"),he=G>=0?r.slice(G+1):r,je=G>=0?r.slice(0,G):"",Qe=je.lastIndexOf("/"),Be=Qe>=0?je.slice(0,Qe):"",tt=he.replace(/\.(stl|glb|gltf)$/i,""),Ke=`${Be?`${Be}/`:""}features/${tt}.json`;return md(Ke).then(bt=>{if(!D)try{const kt=JSON.parse(bt.content);z(kt.version===1&&Array.isArray(kt.features)&&kt.features.length>0?kt.features:null)}catch{z(null)}}).catch(()=>{D||z(null)}),()=>{D=!0}},[j,r]),a.useEffect(()=>{if(j.kind!=="text"){Ze(null);return}const D=w&&r&&!r.startsWith("/")?`${w}/${r}`:r,G=Su(D),he=j.content,je=Ps(D??"")&&be==="preview",Qe=Cs(D??"")&&M==="preview";if(!G||je||Qe||!ju(he)){Ze(null);return}let Be=!1;const tt=Ke=>{if(Be||!Ke.registered(G)){Be||Ze(null);return}try{Ze(Cu(Ke,he,G))}catch{Ze(null)}};return Pe?tt(Pe):(Ze(null),Ru().then(Ke=>{Be||(de(Ke),tt(Ke))}).catch(()=>{})),()=>{Be=!0}},[j,Pe,r,w,be,M]),a.useLayoutEffect(()=>{if(!Ue||j.kind!=="text")return;const D=`${Ue}:${be}:${M}`;if(Yt.current===D)return;const G=iu(w,r);if(Yt.current=D,!G)return;const he=requestAnimationFrame(()=>{const je=ae.current;if(!je)return;const Qe=be==="preview"?G.markdownTop??G.top:G.top;je.scrollTo({top:Math.max(0,Qe??0),left:Math.max(0,G.left??0)}),R(be==="preview"?Math.max(0,Qe??0):0)});return()=>cancelAnimationFrame(he)},[r,be,M,j.kind,Ue,w]),a.useEffect(()=>{Ue&&Ei(w,r,{lineRange:A})},[r,A,Ue,w]),a.useEffect(()=>{if(U==null||j.kind!=="text")return;we(null),E({start:U,end:U});const D=U,G=requestAnimationFrame(()=>{const he=K.current.get(D);he&&he.scrollIntoView({block:"center"}),_?.()});return()=>cancelAnimationFrame(G)},[U,j,E,_]);const Br=a.useCallback(D=>{const G=ae.current;if(!G)return!1;const he=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(D):D.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),je=G.querySelector(`#${he}`);return je?(je.scrollIntoView({block:"start"}),!0):!1},[]);a.useEffect(()=>{const D=w&&r&&!r.startsWith("/")?`${w}/${r}`:r,G=j.kind==="text"&&Ps(D??"")&&be==="preview";if(!xe||!G)return;const he=requestAnimationFrame(()=>{Br(xe)&&Ve(null)});return()=>cancelAnimationFrame(he)},[r,Br,be,xe,j,w]),a.useLayoutEffect(()=>{const D=ae.current;if(!D||!A){we(null);return}if(le)return;const G=j.kind==="image"||j.kind==="loading"&&j.mode==="image",he=w&&r&&!r.startsWith("/")?`${w}/${r}`:r,je=j.kind==="text"&&Ps(he??"")&&be==="preview",Qe=j.kind==="text"&&Cs(he??"")&&M==="preview";if(j.kind!=="text"||G||je||Qe){we(null);return}const Be=()=>{const Ke=K.current.get(A.end);if(!Ke||!D){we(null);return}const bt=Ke.offsetTop+Ke.offsetHeight/2,kt=D.scrollLeft+Math.max(8,D.clientWidth-120);we({top:bt,left:kt})};Be();const tt=new ResizeObserver(()=>Be());return tt.observe(D),()=>tt.disconnect()},[A,le,j,be,M,r,w,Ie]);const qt=j.kind==="text"&&!(Cs(ht??"")&&M==="preview")&&!ht?.toLowerCase().endsWith(".csv")&&!ht?.toLowerCase().endsWith(".kicad_pro")&&!ht?.toLowerCase().endsWith(".kicad_prl"),dr=a.useCallback(()=>{Wt(!1),At(""),Ft([]),W(0),Wa()},[]),wt=a.useCallback(()=>{qt&&(Wt(!0),requestAnimationFrame(()=>{ee.current?.focus(),ee.current?.select()}))},[qt]),ot=a.useCallback(D=>{W(G=>Je.length===0?0:(G+D+Je.length)%Je.length)},[Je.length]);if(a.useEffect(()=>{const D=G=>{const he=Cb(G);if(he==="open"&&qt){G.preventDefault(),wt();return}_e&&(he==="close"?(G.preventDefault(),dr()):(he==="next"||he==="previous")&&(G.preventDefault(),ot(he==="previous"?-1:1)))};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[dr,_e,ot,wt,qt]),a.useLayoutEffect(()=>{if(Wa(),!_e||!st.trim()||!ae.current){Ft([]),W(0);return}const D=Eb(ae.current,st);return Ft(D),W(0),Od(D,0),Bd(D[0]),Wa},[_e,st,Ie,be,j]),a.useEffect(()=>{_e&&(Od(Je,vt),Bd(Je[vt]))},[vt,Je,_e]),a.useEffect(()=>Wa,[]),!r)return t.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:o("rightSidebar.selectFilePrompt")});const De=w&&!r.startsWith("/")?`${w}/${r}`:r,k=to(De,w),J=gu(De,w),ce=j.kind==="text"&&j.content?j.content.split(`
1654
- `):[],Re=Math.max(2,String(ce.length).length)+1,Ee=j.kind==="text"||j.kind==="image"||j.kind==="model3d"||j.kind==="video"||j.kind==="eda"?j.meta:null,ur=Ps(De),gt=De.toLowerCase().endsWith(".csv"),Ur=De.toLowerCase().endsWith(".kicad_pro"),Tt=De.toLowerCase().endsWith(".kicad_prl"),an=j.kind==="text"&&ur&&be==="preview",is=Cs(De),kr=j.kind==="text"&&is&&M==="preview",bo=j.kind==="image"||j.kind==="loading"&&j.mode==="image",Bt=j.kind==="model3d"||j.kind==="loading"&&j.mode==="model3d",on=j.kind==="video"||j.kind==="loading"&&j.mode==="video",ls=j.kind==="eda"||j.kind==="loading"&&j.mode==="eda",cs=j.kind==="text"?j.sourcePath:De,zr=Hm(cs,w,A),Hr=(()=>{if(!A||j.kind!=="text"||ce.length===0)return zr;const D=[];for(let je=A.start;je<=A.end;je+=1)D.push(`${je} ${ce[je-1]??""}`);const G=lf(De).replace(/^\./,""),he="```";return`${zr}
1655
- ${he}${G}
1656
- ${D.join(`
1657
- `)}
1658
- ${he}
1659
- `})(),Wr=`path:${De}`,Xt=A?`path:${De}:${A.start}-${A.end}`:Wr,ln=L===Wr,cn=L===Xt,Gs=$===Wr,Gr=$===Xt,Sr=cn||Gr,jr=A?A.start===A.end?`L${A.start}`:`L${A.start}-${A.end}`:null,An=D=>{const G=ae.current;if(!G)return;const he=G.getBoundingClientRect(),je=D.currentTarget.getBoundingClientRect(),Qe=D.clientX||je.left+je.width/2,tt=(D.clientY||je.top+je.height/2)-he.top+G.scrollTop,Ke=p?116:132,bt=G.scrollLeft+Math.max(8,G.clientWidth-Ke),kt=Math.min(Math.max(8,Qe-he.left+G.scrollLeft+10),bt);we({top:tt,left:kt})},Pn=(D,G)=>{ll()||(An(D),E(he=>{const je=il(he,G,G);return je||we(null),je}))},Rr=(D,G,he)=>{An(D),E(je=>{const Qe=il(je,G,he);return Qe||we(null),Qe})},fr=(D,G,he,je)=>{je==="end"&&An(D),E({start:G,end:he})},Oe=D=>{const{scrollTop:G,scrollLeft:he}=D.currentTarget;R(G),Ei(w,r,{top:G,left:he,markdownTop:G})},hr=D=>{if(D.directory){m?.(D.path);return}if(D.path===De||j.kind==="text"&&D.path===j.sourcePath){D.fragment&&Br(D.fragment);return}Se(G=>[...G,De]),fe.current=D.path,Ve(D.fragment),E(null),O(D.path)},dn=()=>{const D=V[V.length-1];D&&(Se(G=>G.slice(0,-1)),fe.current=D,Ve(null),E(null),O(D))},ds=D=>{const{scrollTop:G,scrollLeft:he}=D.currentTarget;Ei(w,r,{top:G,left:he})},Tn=()=>{if(e){e(Hr,Xt);return}A&&i(Hr,Xt)},Ln=async()=>{if(!(!De||ke.status==="pending")&&!(j.kind==="loading"||j.kind==="error")){Fe({status:"pending"});try{await Em(De),Fe({status:"idle"})}catch(D){Fe({status:"error",message:D instanceof Error?D.message:o("rightSidebar.downloadFailed")})}}};return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface text-foreground",children:[me.popoverNode,t.jsxs("div",{className:`shrink-0 border-b border-border/15 px-3 ${p&&(an||kr)?"py-1.5":"py-2"}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[p&&h&&t.jsx("button",{type:"button",onClick:h,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":o("rightSidebar.backToFileList"),title:o("rightSidebar.backToFileList"),children:t.jsx(vu,{size:16})}),V.length>0&&t.jsxs("button",{type:"button",onClick:dn,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:[t.jsx(as,{size:15}),!p&&t.jsx("span",{className:"text-[11px] font-medium",children:o("rightSidebar.backToPreviousPreview")})]}),t.jsxs("div",{className:"min-w-0",title:De,children:[t.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:k.name}),k.dir&&t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:k.dir})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[qt&&t.jsx("button",{type:"button",onClick:_e?dr:wt,className:`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 ${_e?"bg-surface-elevated text-foreground":"bg-surface-2"}`,"aria-label":o("rightSidebar.findInFile"),title:`${o("rightSidebar.findInFile")} (⌘/Ctrl+F)`,children:t.jsx(ns,{size:14})}),ur&&j.kind==="text"&&t.jsx("button",{type:"button",onClick:()=>{g&&v?.(),Ae(D=>{const G=D==="preview"?"source":"preview";return Dt(Gu,G),G}),E(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(be==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),title:o(be==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview"),children:p?be==="preview"?t.jsx(Hi,{size:14}):t.jsx(zi,{size:14}):o(be==="preview"?"rightSidebar.markdownSource":"rightSidebar.markdownPreview")}),is&&j.kind==="text"&&t.jsx("button",{type:"button",onClick:()=>{te(D=>{const G=D==="preview"?"source":"preview";return Yg(w,r,G),G}),E(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(M==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),title:o(M==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview"),children:p?M==="preview"?t.jsx(Hi,{size:14}):t.jsx(zi,{size:14}):o(M==="preview"?"rightSidebar.htmlSource":"rightSidebar.htmlPreview")}),kr&&t.jsx("button",{type:"button",onClick:()=>{ue.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(Le?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),title:o(Le?"rightSidebar.htmlFullscreenExit":"rightSidebar.htmlFullscreenEnter"),children:t.jsx(hl,{size:15})}),!p&&t.jsx("button",{type:"button",onClick:()=>s(De,Wr),...me(J,Wr),className:`inline-flex h-9 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${ln||Gs?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary hover:bg-primary/25"}`,title:o("rightSidebar.insertReference",{reference:J}),children:o(Gs?"rightSidebar.copied":ln?"rightSidebar.inserted":"rightSidebar.insertFileRef")}),t.jsx("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(J)},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:J}),"aria-label":o("rightSidebar.copyFileRef"),children:t.jsx(hm,{size:13})}),t.jsx("button",{type:"button",onClick:()=>{Ln()},disabled:ke.status==="pending"||j.kind==="loading"||j.kind==="error",className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95 disabled:opacity-50 disabled:active:scale-100",title:ke.status==="error"?ke.message??o("rightSidebar.downloadFailed"):o("rightSidebar.downloadFile"),"aria-label":o("rightSidebar.downloadFile"),children:ke.status==="pending"?t.jsx(yt,{size:13,className:"animate-spin"}):t.jsx(Wm,{size:14})})]})]}),_e&&qt&&t.jsxs("div",{className:"mt-2 flex min-w-0 items-center gap-1.5","data-file-preview-search":!0,children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center rounded-lg bg-surface-2 px-2 focus-within:bg-surface-elevated",children:[t.jsx(ns,{size:13,className:"shrink-0 text-muted-foreground","aria-hidden":"true"}),t.jsx("input",{ref:ee,type:"search",value:st,onChange:D=>At(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),ot(D.shiftKey?-1:1))},className:"h-8 min-w-0 flex-1 bg-transparent px-2 text-xs text-foreground outline-none placeholder:text-muted-foreground/70",placeholder:o("rightSidebar.findInFilePlaceholder"),"aria-label":o("rightSidebar.findInFile")}),t.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground","aria-live":"polite",children:Je.length>0?`${vt+1}/${Je.length}`:"0/0"})]}),t.jsx("button",{type:"button",onClick:()=>ot(-1),disabled:Je.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":o("rightSidebar.previousSearchMatch"),title:`${o("rightSidebar.previousSearchMatch")} (Shift+Enter)`,children:t.jsx(bu,{size:13})}),t.jsx("button",{type:"button",onClick:()=>ot(1),disabled:Je.length===0,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-35","aria-label":o("rightSidebar.nextSearchMatch"),title:`${o("rightSidebar.nextSearchMatch")} (Enter)`,children:t.jsx(Gm,{size:13})}),t.jsx("button",{type:"button",onClick:dr,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":o("rightSidebar.closeFileSearch"),title:`${o("rightSidebar.closeFileSearch")} (Esc)`,children:t.jsx(sr,{size:13})})]}),Ee&&!(p&&(an||kr))&&t.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[Ee.size!==null&&t.jsx("span",{children:o("rightSidebar.byteCount",{count:Ee.size.toLocaleString()})}),"truncated"in Ee&&Ee.truncated&&t.jsx("span",{className:"text-[color:var(--warning)]",children:o("rightSidebar.previewTruncated")}),"mimeType"in Ee&&t.jsx("span",{children:Ee.mimeType}),"dimensions"in j&&j.dimensions&&t.jsxs("span",{children:[j.dimensions.width," × ",j.dimensions.height]})]}),!(p&&(an||kr))&&!Bt&&j.kind!=="binary"&&t.jsx("div",{className:"mt-1 flex h-4 items-center gap-2 text-[10px] text-muted-foreground/75",children:t.jsx("span",{className:"truncate",children:ls?o("rightSidebar.edaPickHint"):gt?o("rightSidebar.csvTablePreview"):Ur||Tt?o("rightSidebar.kicadProjectPickHint"):on?o("rightSidebar.videoPreviewHint"):bo?o("rightSidebar.imagePreviewHint"):an?A?o("rightSidebar.selectedLineHint",{lineLabel:jr??""}):o("rightSidebar.markdownPreviewHint"):kr?o("rightSidebar.htmlPreviewHint"):A?o("rightSidebar.selectedLineHint",{lineLabel:jr??""}):o("rightSidebar.multiLineHint")})})]}),j.kind==="loading"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-8 text-center text-sm text-muted-foreground",children:j.mode==="eda"?o("rightSidebar.edaLoading"):j.mode==="image"?o("rightSidebar.loadingImage"):j.mode==="model3d"?o("rightSidebar.model3dLoading"):j.mode==="video"?o("rightSidebar.loadingVideo"):"Loading file…"}):j.kind==="error"?t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[t.jsx("div",{className:"mx-3 mt-3 border border-destructive/20 bg-destructive/5 px-4 py-4 text-sm text-destructive",children:j.message}),t.jsx("button",{type:"button",onClick:Or,className:"mx-3 mt-3 rounded-lg bg-surface-2 px-4 py-2 text-sm text-foreground hover:bg-surface-3",children:o("common.retry")})]}):j.kind==="binary"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx("div",{className:"mx-3 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-6 text-center text-sm text-muted-foreground",children:o("rightSidebar.binaryPreviewHint")})}):j.kind==="image"?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:j.meta.mimeType==="image/svg+xml"?t.jsx(Bu,{blobUrl:j.objectUrl,filePath:De,viewLabel:"SVG 文件",onInsertAnnotation:d}):t.jsx(Vf,{src:j.objectUrl,alt:k.name,vector:!1,onLoad:D=>{const G=D.currentTarget;Y(he=>he.kind==="image"?{...he,dimensions:{width:G.naturalWidth,height:G.naturalHeight}}:he)},onError:()=>Y({kind:"error",message:o("rightSidebar.imageLoadFailed")})})}):j.kind==="video"?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface p-3",children:t.jsx(sb,{url:j.url,onLoadError:()=>Y({kind:"error",message:o("rightSidebar.videoLoadFailed")})})}):j.kind==="eda"?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:t.jsx(ub,{blobUrl:j.objectUrl,filePath:j.sourcePath,view:j.view,board:De.toLowerCase().endsWith(".kicad_pcb"),onViewChange:ie,onInsertAnnotation:e??d,onRefresh:Or,interactive3d:ge?t.jsx(a.Suspense,{fallback:t.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:o("rightSidebar.model3dLoading")}),children:t.jsx(Vd,{blobUrl:ge.objectUrl,ext:".glb",fileName:k.name,filePath:ge.sourcePath,features:null,onInsertFeature:e??d,unitScale:1e3,dimensionUnit:"mm",coordinateSystemLabel:"KiCad 3D 导出坐标 Y-up",annotationPrefix:"PCB三维标注",normalizePickedPartName:D=>/^[A-Za-z]{1,5}\d+[A-Za-z0-9._-]*$/.test(D)?D:"PCB板体/铜箔/丝印",active:j.view==="pcb-3d"})}):void 0})}):j.kind==="model3d"?t.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-surface",children:t.jsx(a.Suspense,{fallback:t.jsx("div",{className:"min-h-0 flex-1 px-3 py-8 text-center text-sm text-muted-foreground",children:o("rightSidebar.model3dLoading")}),children:t.jsx(Vd,{blobUrl:j.objectUrl,ext:j.ext,fileName:k.name,filePath:j.sourcePath,features:T,onInsertFeature:e??d,onRefresh:Or})})}):j.kind==="text"&&gt?t.jsx(mb,{content:j.content,filePath:De,onInsertAnnotation:e??d},De):j.kind==="text"&&(Ur||Tt)?t.jsx(bb,{content:j.content,filePath:De,localState:Tt,onInsertAnnotation:e??d},De):an?t.jsxs("div",{ref:ae,className:"termdock-native-select relative min-h-0 flex-1 overflow-auto bg-surface","data-markdown-preview-scroller":!0,onScroll:Oe,style:{touchAction:"pan-x pan-y"},children:[t.jsx(_f,{content:j.content,filePath:j.sourcePath,rootPath:w,lineRange:A,onLineRangeClick:Rr,onLineRangeDrag:fr,scrollTop:Z,outlineOpen:g,outlineCloseSignal:f,onOutlineOpen:S,onOutlineClose:v,lightboxOpen:P,lightboxCloseSignal:N,onLightboxOpen:F,onLightboxClose:B,onLocalLinkOpen:hr}),A&&le&&t.jsxs("button",{type:"button",onClick:Tn,...me(Hr,Xt),style:{top:le.top,left:le.left,transform:"translateY(-50%)"},className:lu(p,Sr),title:`Insert markdown reference: ${zr}`,children:[t.jsx(no,{size:p?13:11}),Gr?o("rightSidebar.copied"):cn?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:jr??""})]})]}):kr?t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:t.jsx(Rb,{ref:ue,src:mm(De),title:`${k.name} preview`,exitFullscreenLabel:o("rightSidebar.htmlFullscreenExit"),onFullscreenChange:Ge},`${De}:${Pt}:${Gt}`)}):j.kind==="text"?t.jsxs("div",{ref:ae,onScroll:ds,className:`${gl} 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:[ce.length>0?t.jsx("div",{className:"min-w-full",children:ce.map((D,G)=>{const he=G+1,je=!!(A&&he>=A.start&&he<=A.end),Qe=Ie&&Ie.length===ce.length?Ie[G]:null;return t.jsxs("div",{ref:Be=>{Be?K.current.set(he,Be):K.current.delete(he)},role:"button","data-file-preview-line":he,tabIndex:0,onClick:Be=>Pn(Be,he),onKeyDown:Be=>{Be.key!=="Enter"&&Be.key!==" "||(Be.preventDefault(),Pn(Be,he))},style:{gridTemplateColumns:`${Re}ch 1fr`},className:`group grid w-max min-w-full cursor-text gap-2 rounded-md pr-1 text-left transition ${je?"bg-[var(--surface-2)] text-foreground":"hover:bg-surface-2"}`,title:`Tap to reference ${J}:${he}`,children:[t.jsx("span",{className:`select-none rounded text-right text-[10px] transition ${je?"bg-[var(--surface-elevated)] text-muted-foreground":"text-muted-foreground/55"}`,children:he}),t.jsx("span",{className:"whitespace-pre select-text","data-sidebar-selectable":!0,children:Qe??(D||" ")})]},G)})}):"Empty file.",A&&le&&t.jsxs("button",{type:"button",onClick:Tn,...me(Hr,Xt),style:{top:le.top,left:le.left,transform:"translateY(-50%)"},className:lu(p,Sr),title:`Insert code reference: ${zr}`,children:[t.jsx(no,{size:p?13:11}),Gr?o("rightSidebar.copied"):cn?o("rightSidebar.inserted"):o("rightSidebar.insertLineRef",{lineLabel:jr??""})]})]}):null]})}function l0({isOpen:e,drawerWidthPx:r,onClose:s,onOpen:i,push:d,pinned:c=!1,onTogglePinned:h,rightSidebarFilePreviewOpen:m=!1,rightSidebarFilePreviewCloseSignal:p,onOpenRightSidebarFilePreview:g,onCloseRightSidebarFilePreview:f,rightSidebarRepoPickerOpen:S=!1,rightSidebarRepoPickerCloseSignal:v,onOpenRightSidebarRepoPicker:P,onCloseRightSidebarRepoPicker:N,markdownOutlineOpen:F=!1,markdownOutlineCloseSignal:B,onOpenMarkdownOutline:A,onCloseMarkdownOutline:E,markdownImageLightboxOpen:L=!1,markdownImageLightboxCloseSignal:$,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:_}){const{t:o,locale:w}=Mt(),[O,j]=a.useState(""),[Y,se]=a.useState(null),ie=ne(n=>n.rightSearchOpen),ge=ne(n=>n.setRightSearchOpen),q=ne(n=>n.rightSidebarLayoutPreference),Q=ne(n=>n.setRightSidebarLayoutPreference),[T,z]=a.useState(()=>ex()),[K,ae]=a.useState("."),[le,we]=a.useState(""),[be,Ae]=a.useState(!1),[M,te]=a.useState(!1),[ue,Le]=a.useState(!1),[Ge,Pe]=a.useState(!1),de=a.useDeferredValue(O),[Z,R]=a.useState(null),[V,Se]=a.useState([]),[xe,Ve]=a.useState([]),[fe,Xe]=a.useState(null),[Ie,Ze]=a.useState(null),[ke,Fe]=a.useState(null),[_e,Wt]=a.useState(null),[st,At]=a.useState(()=>mt(zd,$s)??!1),[Je,Ft]=a.useState(()=>mt(Hd,$s)??!1),[vt,W]=a.useState(()=>mt(Wd,$s)??!1),[ee,me]=a.useState(()=>mt(ki,Yb)??""),[Ue,ht]=a.useState(0),[Pt,Ot]=a.useState(!1),[Yt,Gt]=a.useState(!1),Mn=a.useRef(null),Or=a.useRef(null),[Br,qt]=a.useState(!1),[dr,wt]=a.useState(null),[ot,De]=a.useState(null),[k,J]=a.useState(()=>Xd(vi)),[ce,Re]=a.useState(()=>Xd(Ud)),[Ee,ur]=a.useState(()=>Kb()),[gt,Ur]=a.useState(()=>Xb()),[Tt,an]=a.useState(()=>Qb()),is="words",[kr,bo]=a.useState(0),[Bt,on]=a.useState([]),[ls,cs]=a.useState([]),[zr,Hr]=a.useState(!1),[Wr,Xt]=a.useState(null),[ln,cn]=a.useState([]),[Gs,Gr]=a.useState(!1),[Sr,jr]=a.useState([]),[An,Pn]=a.useState([]),[Rr,fr]=a.useState(!1),[Oe,hr]=a.useState(null),[dn,ds]=a.useState([]),[Tn,Ln]=a.useState({}),[D,G]=a.useState(!1),[he,je]=a.useState(null),[Qe,Be]=a.useState(null),[tt,Ke]=a.useState(null),[bt,kt]=a.useState(null),[mr,Cr]=a.useState(!1),[$n,un]=a.useState(""),us=a.useDeferredValue($n),[pr,fs]=a.useState({}),[fn,qr]=a.useState([]),[re,Ye]=a.useState(!1),[Jt,Nr]=a.useState(!1),[Cl,In]=a.useState(null),[xo,_n]=a.useState(!1),gr=a.useRef(null),Vr=a.useRef(0),Nl=a.useRef({count:0,loading:!1,loadingMore:!1,hasMore:!1}),[Kf,qs]=a.useState(null),[hs,El]=a.useState(()=>mt(wi,$s)??!1),[yo,vo]=a.useState(!1),[Vs,wo]=a.useState([]),[Er,Ks]=a.useState({}),[Ut,Ys]=a.useState({}),[Kr,Ml]=a.useState(!0),[Al,Pl]=a.useState(()=>new Set),[dt,hn]=a.useState(null),[ko,mn]=a.useState(null),[Yf,Mr]=a.useState(!1),[Tl,Ar]=a.useState(0),[,So]=a.useState(0),[jo,Xs]=a.useState(!1),[br,Ro]=a.useState(!1),[Xf,Ll]=a.useState(()=>ne.getState().rightTab==="diff"),[Jf,$l]=a.useState(()=>ne.getState().rightTab==="android"),[Yr,Il]=a.useState(!1),[ze,ms]=a.useState(null),[Dn,ps]=a.useState(null),[Rt,Xr]=a.useState(null),[_l,Ct]=a.useState(null),[Fn,Dl]=a.useState(null),[Co,Qf]=a.useState(()=>Date.now()),[Zf,eh]=a.useState(!1),[pn,Js]=a.useState(!1),[Qs,Fl]=a.useState(""),[On,Zs]=a.useState(""),[gn,ea]=a.useState(""),[bn,ta]=a.useState(""),[Ol,Bn]=a.useState(null),[ra,na]=a.useState(!1),[Bl,No]=a.useState(!1),[Ul,zl]=a.useState(!1),[sa,th]=a.useState({key:null,nonce:0}),Hl=a.useRef(null),Wl=a.useRef(null),oe=Mm(r,c,q),rh=rf(oe,c,Tt),[Eo,Mo]=a.useState(()=>lx(r)),Ao=ne(n=>n.rightTab),ar=ne(n=>n.setRightTab),b=ne(n=>n.rootPath),Un=ne(n=>n.explorerRoot),Gl=ne(n=>n.pinnedExplorerRootsCache),ql=ne(n=>n.hydratePinnedExplorerRoots),Vl=ne(n=>n.syncPinnedExplorerRoots),Qt=ne(n=>n.setExplorerRoot),Kl=ne(n=>n.resetExplorerToProject),zn=ne(n=>n.pinExplorerRoot),xn=ne(n=>n.unpinExplorerRoot),it=ne(n=>n.selectedFilePath),lt=ne(n=>n.selectFile),Po=ne(n=>n.showHiddenFiles),nh=ne(n=>n.toggleShowHiddenFiles),To=ne(n=>!!(b&&n.nestedGitScanRoots[b])),Ne=ne(n=>n.changedFiles),aa=ne(n=>n.setChangedFiles),oa=ne(n=>n.invalidateDirectoryCache),sh=ne(n=>n.setDirectorySortMode),Yl=ne(n=>n.applyFileWatchEvents),Xl=ne(n=>n.reconcileDirectoryCache),Jl=ne(n=>n.bumpFileWatchEpoch),Jr=ne(n=>n.gitBundleLoading),Ql=ne(n=>n.gitBundleSlow),yn=ne(n=>n.gitBundleError),Hn=ne(n=>n.gitBundleLastLoadedAt),Zl=ne(n=>n.beginGitBundleLoading),ec=ne(n=>n.setGitBundleSlowFor),Lo=ne(n=>n.finishGitBundleLoading),ia=ne(n=>n.resetGitBundleLoading),$o=ne(n=>n.setGitBundleError),tc=ne(n=>n.markGitBundleLoaded),ye=Un??b,rc=a.useMemo(()=>ye?Ab(ye,K):"",[ye,K]),gs=a.useMemo(()=>Mb(le),[le]),nc=a.useMemo(()=>({excludePatterns:gs,caseSensitive:M,wholeWord:ue,regex:Ge}),[M,gs,Ge,ue]),la=ne(n=>ye?n.fileSortModes[ye]??"name":"name"),sc=ne(n=>!!(ye&&n.directoryCache.has(ye))),Wn=a.useRef(null),Lt=a.useRef(0),[ac]=a.useState(()=>++r0),Pr=a.useRef(null),Qr=a.useRef(null),ca=a.useRef(0),Zt=a.useRef(new Map),er=a.useRef(new Map),xr=a.useRef(new Set),vn=a.useRef(new Set),wn=a.useRef(0),Zr=a.useRef(null),Gn=a.useRef(0),qn=a.useRef(null),Vn=a.useRef(0),en=a.useRef(null),Io=a.useRef(new Set),_o=a.useRef(null),Do=a.useRef(null),da=a.useRef(null),Fo=a.useRef(null);a.useEffect(()=>{if(Fn===null)return;const n=Math.max(0,Date.now()-Fn),l=n<6e4?1e3:n<36e5?6e4:n<864e5?36e5:864e5,u=Math.max(50,l-n%l),x=window.setTimeout(()=>Qf(Date.now()),u);return()=>window.clearTimeout(x)},[Co,Fn]);const ua=a.useRef(null),Tr=a.useRef(null),fa=a.useRef(null),bs=a.useRef(null),Me=a.useCallback(n=>ne.getState().rootPath===n,[]);a.useEffect(()=>{if(!e||typeof window>"u")return;const n=l=>{const u=o0(l.target);u&&Ja("global_change_row_event",{...i0(l),selectionPath:u.dataset.diffSelectionPath,filePath:u.dataset.diffFilePath,absolutePath:u.dataset.diffAbsolutePath,repoRoot:u.dataset.diffRepoRoot,status:u.dataset.diffStatus,selectedFilePath:ne.getState().selectedFilePath,rightTab:ne.getState().rightTab,activeGitRepoRoot:fe,changedFiles:ne.getState().changedFiles.size})};return window.addEventListener("pointerdown",n,{capture:!0}),window.addEventListener("click",n,{capture:!0}),()=>{window.removeEventListener("pointerdown",n,{capture:!0}),window.removeEventListener("click",n,{capture:!0})}},[fe,e]);const oc=a.useCallback(async(n=b??void 0)=>{if(!n)return null;if(xr.current.has(n)||vn.current.has(n))return ut("untracked_skip_cached",{cwd:n,rootPath:b,completed:xr.current.has(n),running:vn.current.has(n)}),null;const l=b,u=ca.current+1;ca.current=u,Zt.current.set(n,u);const x=`right-sidebar-git-untracked:${n}`,y=new AbortController;er.current.set(n,y),vn.current.add(n),ut("untracked_start",{requestId:u,cwd:n,rootPath:b});try{let C=await pd(n,y.signal,x),I=0;for(;C.status==="running"&&I<120;){if(Zt.current.get(n)!==u||y.signal.aborted)return ut("untracked_stale_result",{requestId:u,activeRequestId:Zt.current.get(n),cwd:n,status:C.status}),null;if(!Me(l))return ut("untracked_root_changed",{requestId:u,cwd:n,expectedRootPath:l,currentRootPath:ne.getState().rootPath}),null;await new Promise(X=>window.setTimeout(X,I<10?1e3:3e3)),I+=1,C=await pd(n,y.signal,x)}if(Zt.current.get(n)!==u||!Me(l))return ut("untracked_stale_result",{requestId:u,activeRequestId:Zt.current.get(n),cwd:n,expectedRootPath:l,currentRootPath:ne.getState().rootPath,files:C.files.length,status:C.status}),null;if(C.status==="done")return aa(Bf(ne.getState().changedFiles,C.files)),C.files.length>0&&Se(X=>{const et=new Map(X.map($e=>[$e.root,$e])).get(n);if(!et)return X;const He=Wx(et.files,C.files),qe=X.map($e=>$e.root===n?{...$e,files:He,context:$e.context?{...$e.context,changedFiles:He.map(nt=>({path:nt.path,absolutePath:nt.absolutePath,status:nt.status})),truncated:!1}:$e.context,untrackedDeferred:!1}:$e);Ve(Uf(qe,b));const ve=qe.find($e=>$e.root===b);return ve?.context&&R($e=>$e?.root===ve.root?{...$e,...ve.context}:$e),qe}),xr.current.add(n),ut("untracked_apply",{requestId:u,cwd:n,files:C.files.length}),C;const H=C.error||(C.status==="running"?"Untracked file scan is still running.":"Failed to scan untracked files");return xr.current.add(n),ut("untracked_error",{requestId:u,cwd:n,message:H,code:C.code,status:C.status}),null}catch(C){if(Zt.current.get(n)!==u||!Me(l)||Dr(C))return ut("untracked_aborted",{requestId:u,activeRequestId:Zt.current.get(n),cwd:n,expectedRootPath:l,currentRootPath:ne.getState().rootPath,message:C instanceof Error?C.message:String(C)}),null;const I=C instanceof Error?C.message:"Failed to scan untracked files";return xr.current.add(n),ut("untracked_error",{requestId:u,cwd:n,message:I}),null}finally{er.current.get(n)===y&&er.current.delete(n),Zt.current.get(n)===u&&Zt.current.delete(n),vn.current.delete(n)}},[Z,Me,b,aa]),or=a.useMemo(()=>{const n=new Set(xe.map(u=>u.root)),l=ln.filter(u=>n.has(u));return l.length>0?l:fe?[fe]:[]},[fe,ln,xe]),ic=or.length===0,kn=a.useMemo(()=>or.map(n=>V.find(l=>l.root===n)).filter(n=>!!n),[or,V]),ah=a.useMemo(()=>xe.map(n=>({root:n.root,label:n.label,branch:n.branch??null})),[xe]),yr=a.useCallback(async()=>{if(!b){on([]),cs([]);return}const n=b,l=Gn.current+1;Gn.current=l,qn.current?.abort();const u=new AbortController;qn.current=u,Hr(Bt.length===0),Xt(null);try{const x=or.length>0?await Promise.all(or.map(y=>gd({workspaceRoot:b,repoRoot:y},u.signal))).then(y=>({records:y.flatMap(C=>C.records),walkthroughs:y.flatMap(C=>C.walkthroughs??[])})):await gd({workspaceRoot:b},u.signal);if(Gn.current!==l||!Me(n))return;on(x.records),cs(x.walkthroughs??[])}catch(x){if(Gn.current!==l||!Me(n)||Dr(x))return;Xt(x instanceof Error?x.message:"Failed to load change audit explanations")}finally{qn.current===u&&(qn.current=null),Gn.current===l&&Me(n)&&Hr(!1)}},[Bt.length,or,Me,b]),ha=a.useCallback(async(n,l,u)=>{if(!n&&!b){jr([]),Pn([]);return}const x=b,y=Vn.current+1;Vn.current=y,en.current?.abort();const C=new AbortController;en.current=C;try{const I=n?[n]:Array.from(new Set([b,...V.map(X=>X.root)].filter(X=>!!X))),H=await Promise.all(I.map(X=>gm({repoRoot:X,baseRef:l,branchName:u},C.signal))).then(X=>{const Te=new Map,et=new Map;for(const He of X){for(const qe of He.records)Te.set(qe.id,qe);for(const qe of He.walkthroughs??[])et.set(qe.id,qe)}return{records:Array.from(Te.values()),walkthroughs:Array.from(et.values())}});if(Vn.current!==y||!Me(x))return;jr(H.records),Pn(H.walkthroughs??[])}catch(I){if(Vn.current!==y||!Me(x)||Dr(I))return;console.warn("[RightSidebar] Failed to load branch explanations",I)}finally{en.current===C&&(en.current=null)}},[V,Me,b]),tn=a.useCallback((n,l={})=>{if(!Me(b)){ut("apply_skipped_root_changed",{expectedRootPath:b,currentRootPath:ne.getState().rootPath,bundleRoot:n.context?.root,files:n.files.length});return}ut(n.files.length===0?"empty_bundle":"apply",{rootPath:b,available:n.available,files:n.files.length,repositories:n.repositories?.map(ve=>({root:ve.root,relativeRoot:ve.relativeRoot,files:ve.files.length,available:ve.available,error:ve.error})),repoFilters:n.repoFilters?.map(ve=>({root:ve.root,label:ve.label,count:ve.count})),cached:n.cached,stale:n.stale,cacheAgeMs:n.cacheAgeMs,untrackedDeferred:n.untrackedDeferred,error:n.error});let u=nf(n),x=n.repoFilters??[],y=n.files;const C=ne.getState().changedFiles;if(!!(l.cacheOnly&&!n.cached&&n.files.length===0&&u.length===0)&&(C.size>0||V.length>0||Z)){ut("cache_only_apply_skipped_empty_backend_cache",{rootPath:b,currentFiles:C.size,currentRepositories:V.length});return}const H=u.some(ve=>ve.deferred);if(H&&!l.replaceWorkspace){const ve=new Set(u.filter(nt=>!nt.deferred||nt.root===b).map(nt=>nt.root));y=[...Array.from(C.values()).filter(nt=>!ve.has(jt(nt,b)??"")),...n.files]}const X=cu(C.values(),b),Te=cu(n.files,b),et=u.some(ve=>ve.root!==b);if(!!(l.background&&!H&&!l.replaceWorkspace&&C.size>0&&(n.files.length===0&&!n.error||X>0&&Te===0&&!et))){ut("background_apply_skipped_degraded_bundle",{rootPath:b,currentFiles:C.size,nextFiles:n.files.length,currentNestedCount:X,nextNestedCount:Te,nextRepositories:u.map(ve=>({root:ve.root,relativeRoot:ve.relativeRoot,files:ve.files.length})),cached:n.cached,stale:n.stale,error:n.error});return}if(l.replaceRepoRoot){const ve=zf(C.values(),V,n,l.replaceRepoRoot,b);y=ve.files,u=ve.repositories,x=ve.repoFilters}if(aa(Of(y)),Se(u),Ve(x),l.syncActiveRepo!==!1){const ve=l.activeRepoRoot!==void 0?l.activeRepoRoot:fe??Yd(b),$e=rx({...n,repositories:u,repoFilters:x},ve);Xe($e),ji(b,$e)}typeof n.cacheUpdatedAt=="number"&&Dl(n.cacheUpdatedAt),R(ve=>{if(l.replaceRepoRoot&&l.replaceRepoRoot!==b)return ve;if(!n.context)return null;const $e=ve?.root??b;return!ve?.available||$e!==(n.context.root??b)?n.context:{...ve,...n.context}}),l.reloadDiff&&bo(ve=>ve+1);const qe=ne.getState().selectedFilePath;if(qe&&!qe.startsWith("/")&&!y.some(ve=>ve.path===qe||ve.absolutePath===qe)&&lt(null),J(ve=>{const $e=new Set(y.map(cr=>jt(cr,b)).filter(Boolean)),nt=new Set;for(const cr of ve)$e.has(cr)&&nt.add(cr);return Ri(vi,nt),nt}),l.loadDeferred!==!1){const ve=u.filter($e=>$e.untrackedDeferred&&$e.root).map($e=>$e.root);for(const $e of ve)oc($e)}l.loadAudit!==!1&&yr()},[fe,Me,yr,oc,b,lt,aa]);a.useEffect(()=>{ia(),_o.current=null,Do.current=b;const n=[],l=[],x=Yd(b);Lt.current+=1,wn.current+=1,ca.current+=1,Pr.current?.abort(),_t(rs(Qr.current?.cwd??b??void 0)),Qr.current=null,Pr.current=null,Zr.current?.abort(),_t("right-sidebar-git-details"),Zr.current=null;for(const X of er.current.values())X.abort();for(const X of er.current.keys())_t(`right-sidebar-git-untracked:${X}`);er.current.clear(),Zt.current.clear(),Gn.current+=1,qn.current?.abort(),qn.current=null,Vn.current+=1,en.current?.abort(),en.current=null,Vr.current+=1,gr.current?.abort(),_t("right-sidebar-recent-commits"),gr.current=null,on([]),cs([]),Hr(!1),Xt(null),cn([]),Gr(!1),jr([]),Pn([]),fr(!1),hr(null),G(!1),je(null),Be(null),Ke(null),kt(null),Cr(!1),un(""),qr([]),Ye(!1),Nr(!1),In(null),_n(!1),qs(null),hn(null),mn(null),El(!1),Dt(wi,!1),vo(!1);const y=b?Jd()[b]:null,C=y?.previewEntries??[],I=y?.selectedPreviewKey??null,H=I?C.find(X=>X.key===I)??null:null;wo(y?.selectedRepoRoots??[]),Ks(y?.repoTargetBranches??{}),Ys(y?.repoBaseBranches??{}),ds(C),Ln(y?.previewScrollTops??{}),H&&y?.previewDetailOpen&&(H.diff.hunks?.length??0)>0&&(hr(H.diff),hn(H.key),mn(y.selectedPreviewFileKey??(H.diff.hunks?.[0]?`${H.diff.hunks[0].filePath}\0${H.diff.hunks[0].hunkHeader}\0${H.diff.hunks[0].hunkIndex}`:null)),fr(!0)),Ml(y?.includeUncommitted??!0),_o.current=b,Js(!1),Xe(x??null),xr.current.clear(),vn.current.clear(),ms(null),ps(null),Xr(null),Ct(null),Dl(null),Se(n),Ve(l),R(null),Fo.current=null},[ia,b]);const ir=a.useCallback(async(n=b??void 0,l={})=>{if(!n)return null;const u=b,x=Lt.current;if(await Hp(ne.getState().hydrateNestedGitScanRoots),Lt.current!==x||!Me(u))return null;const y=n===b&&es(b),C=l.includeNested??y,I=l.refresh??l.reloadDiff??!1,H=l.cacheOnly??!1,X=l.background??!1,Te=C&&(l.discoverOnly??!1);I&&xr.current.clear();const et=Qr.current;if(et&&et.cwd===n&&et.includeNested===C&&et.refresh===I&&et.cacheOnly===H&&et.discoverOnly===Te)return ut("reuse_pending",{cwd:n,includeNested:C,refresh:I,cacheOnly:H,discoverOnly:Te}),et.promise;const He=Lt.current+1;Lt.current=He;const qe=`right-sidebar:${ac}:${He}`;Pr.current?.abort();const ve=rs(n);_t(ve);const $e=new AbortController;Pr.current=$e;let nt=null;X||Zl(qe),$o(null),ut("start",{requestId:He,cwd:n,rootPath:b,requestSlotId:ve,includeNested:C,refresh:I,cacheOnly:H,background:X,existingChanges:Ne.size,lastLoadedAt:Hn}),!X&&typeof window<"u"&&(nt=window.setTimeout(()=>{Lt.current===He&&ec(qe,!0)},Ob));const cr=(async()=>{const We=await $a(n,$e.signal,{includeNested:C,refresh:I,cacheOnly:H,discoverOnly:Te,action:I?"manual_git_refresh":"open_sidebar_git_refresh",requestSlotId:ve,requestTimeoutMs:I?null:void 0});if(Vx(We)){if(ut("cancelled_result_ignored",{requestId:He,activeRequestId:Lt.current,cwd:n,error:We.error??We.context?.error}),$e.signal.aborted)return null;throw new Error(We.error??We.context?.error??"Failed to load Git changes")}return Lt.current!==He||!Me(u)?(ut("stale_result",{requestId:He,activeRequestId:Lt.current,cwd:n,expectedRootPath:u,currentRootPath:ne.getState().rootPath,files:We.files.length,repositories:We.repositories?.length??0}),null):(tn(We,{reloadDiff:l.reloadDiff,syncActiveRepo:l.replaceWorkspace?!0:C,background:X,cacheOnly:H,replaceRepoRoot:l.replaceRepoRoot,replaceWorkspace:l.replaceWorkspace}),We)})();Qr.current={cwd:n,includeNested:C,refresh:I,cacheOnly:H,discoverOnly:Te,promise:cr};try{const We=await cr;return Lt.current===He&&We&&Me(u)?tc({cached:We.cached,stale:We.stale,cacheAgeMs:We.cacheAgeMs,nestedDeferred:!C||We.nestedDeferred,untrackedDeferred:We.untrackedDeferred}):Lt.current===He&&Me(u)&&Lo(qe),We}catch(We){return Lt.current!==He||!Me(u)||$e.signal.aborted?(ut("aborted",{requestId:He,activeRequestId:Lt.current,cwd:n,expectedRootPath:u,currentRootPath:ne.getState().rootPath,message:We instanceof Error?We.message:String(We)}),null):(ut("error",{requestId:He,cwd:n,includeNested:C,refresh:I,background:X,message:We instanceof Error?We.message:String(We)}),X||(R(null),$o(We instanceof Error?We.message:"Failed to load Git changes")),null)}finally{nt!==null&&window.clearTimeout(nt),Pr.current===$e&&(Pr.current=null),Qr.current?.promise===cr&&(Qr.current=null),!X&&Lt.current===He&&Me(u)&&Lo(qe)}},[tn,Zl,Ne.size,Lo,ac,Hn,Me,tc,b,$o,ec]),xs=a.useCallback(async()=>{b&&await ir(b,{reloadDiff:!0,refresh:!0})},[ir,b]),Oo=a.useCallback(async(n=b??void 0)=>{if(!n)return null;const l=b,u=wn.current+1;wn.current=u,Zr.current?.abort(),_t("right-sidebar-git-details");const x=new AbortController;Zr.current=x,Js(!0);try{const y=await bd(n,x.signal,"load_git_details","right-sidebar-git-details");return wn.current!==u||!Me(l)?null:(Se(C=>C.map(I=>I.root===y.root?{...I,available:y.available,context:y,error:y.error}:I)),R(C=>C?.root&&y.root&&C.root!==y.root?C:!C?.available||!y.available?y:{...C,...y}),y)}catch(y){return Dr(y)||!Me(l)||wn.current===u&&Ct(y instanceof Error?y.message:"Failed to load Git details"),null}finally{Zr.current===x&&(Zr.current=null),wn.current===u&&Me(l)&&Js(!1)}},[Me,b]);a.useEffect(()=>{if(!e){Lt.current+=1,ia(),Fo.current=null,wn.current+=1,ca.current+=1,Pr.current?.abort(),_t(rs(Qr.current?.cwd??b??void 0)),Qr.current=null,Pr.current=null,Zr.current?.abort(),_t("right-sidebar-git-details"),Zr.current=null;for(const n of er.current.values())n.abort();for(const n of er.current.keys())_t(`right-sidebar-git-untracked:${n}`);er.current.clear(),Zt.current.clear(),Vn.current+=1,en.current?.abort(),en.current=null,Vr.current+=1,gr.current?.abort(),_t("right-sidebar-recent-commits"),gr.current=null,Js(!1),G(!1),je(null),Be(null),Ke(null),kt(null),Cr(!1),un(""),qr([]),Ye(!1),Nr(!1),In(null),_n(!1),j(""),ge(!1),wt(null),Ro(!1),$l(!1),oe&&Ll(!1)}},[oe,e,ia,ge]),a.useEffect(()=>{if(!ie)return;const n=setTimeout(()=>{document.querySelector("input[data-right-search]")?.focus()},50);return()=>clearTimeout(n)},[ie]),a.useEffect(()=>{oe||Mr(!1)},[oe]);const ys=a.useCallback(n=>{So(n);const l=fa.current;l&&(l.update(),l.slideTo(n,0),window.requestAnimationFrame(()=>{l.update(),l.slideTo(n,0)}))},[]);a.useEffect(()=>{if(oe)if(Mr(m),m&&it){Ar(1);const n=Tr.current;n&&(n.update(),n.activeIndex!==1&&(bs.current=1,n.slideTo(1,0)))}else{Ar(0);const n=Tr.current;n&&n.activeIndex!==0&&(bs.current=0,n.slideTo(0,0)),wt(null)}},[oe,m,b,it]),a.useEffect(()=>{if(p!==void 0&&!m){Ar(0);const n=Tr.current;n&&n.activeIndex!==0&&(bs.current=0,n.slideTo(0,0)),Mr(!1),wt(null)}},[p,m]),a.useEffect(()=>{v!==void 0&&Ze(null)},[v]),a.useEffect(()=>{!oe&&m&&f?.()},[oe,f,m]),a.useEffect(()=>{Mo(n=>el(n,r))},[r]);const oh=a.useCallback(n=>{oe||(n.preventDefault(),ua.current={startX:n.clientX,startWidth:Eo,pointerId:n.pointerId},n.currentTarget.setPointerCapture(n.pointerId))},[Eo,oe]),ih=a.useCallback(n=>{const l=ua.current;if(!l||l.pointerId!==n.pointerId)return;const u=el(l.startWidth+n.clientX-l.startX,r);Mo(u),Is(Ls,u,Fb)},[r]),lc=a.useCallback(n=>{const l=ua.current;if(!(!l||l.pointerId!==n.pointerId)){ua.current=null,Ns(Ls);try{n.currentTarget.releasePointerCapture(n.pointerId)}catch{}}},[]),Kn=!!(b&&Hn!==null&&fu(Z)),Bo=!!(b&&!yn&&Ne.size===0&&Hn===null),vr=(()=>{let n=Ao;return n==="android"&&!Yr&&(n="files"),Kn&&(n==="git"||n==="diff")&&(n="files"),n})(),ct=vr==="git",Yn=vr==="files",$t=vr==="diff",Uo=vr==="android";a.useEffect(()=>{if(!oe){Xs(!0);return}if(!e){const l=window.setTimeout(()=>{Xs(!1)},Ub);return()=>window.clearTimeout(l)}Xs(!1);const n=window.setTimeout(()=>{Xs(!0)},Bb);return()=>window.clearTimeout(n)},[oe,e]),a.useEffect(()=>{if(!oe||!$t)return;const n=fa.current;if(!n)return;const l=window.requestAnimationFrame(()=>{n.update()});return()=>window.cancelAnimationFrame(l)},[$t,oe]),a.useEffect(()=>{if(!Kn||!b||Jr)return;const n=window.setTimeout(()=>{ir(b,{background:!0})},3e3);return()=>window.clearTimeout(n)},[Kn,b,Jr,ir]);const lh=a.useCallback(n=>{ir(n,{discoverOnly:!0})},[ir]);Wp({active:e&&(ct||$t),rootPath:b,loading:Jr,delay:ct&&!oe?0:Si,lastStartedRoot:Fo,load:lh}),a.useEffect(()=>{!e||!ct||(!oe||jo)&&Ro(!0)},[ct,oe,e,jo]),a.useEffect(()=>{if(!e||ct)return;const n=window.setTimeout(()=>{Ro(!0)},Si);return()=>window.clearTimeout(n)},[ct,e]),a.useEffect(()=>{$t&&Ll(!0)},[$t]),a.useEffect(()=>{Uo&&$l(!0)},[Uo]),a.useEffect(()=>{let n=!1;return dl().then(l=>{!n&&l.androidPanel&&Il(l.androidPanel.enabled===!0)}).catch(()=>{}),()=>{n=!0}},[]);const ch=a.useCallback(n=>{Il(n),n?ar("android"):ne.getState().rightTab==="android"&&ar("files"),ul({androidPanel:{enabled:n}}).catch(()=>{})},[ar]),cc=a.useCallback(n=>{ye&&Ox(ye,n.currentTarget.scrollTop)},[ye]);a.useEffect(()=>()=>{Pr.current?.abort(),Ns(ml),Ns(pl),Ns(Ls),Ns(ki)},[]),a.useEffect(()=>{if(!ye||!sc)return;const n=Df()[ye]?.top;if(typeof n!="number")return;let l=window.requestAnimationFrame(()=>{Wn.current&&(Wn.current.scrollTop=n),l=window.requestAnimationFrame(()=>{Wn.current&&(Wn.current.scrollTop=n)})});return()=>window.cancelAnimationFrame(l)},[ye,sc]),a.useEffect(()=>{if(!e)return;const n=new AbortController;return bm(n.signal).then(l=>zl(!!l.available)).catch(()=>zl(!1)),()=>n.abort()},[e]);const vs=a.useCallback(n=>{if(se(null),lt(n),wt(null),oe){Mr(!0),Ar(1),Tr.current?.slideTo(1),g?.();return}},[oe,g,lt]),dc=a.useCallback((n,l)=>{if(se(null),lt(n),De(l),oe){Mr(!0),Ar(1),Tr.current?.slideTo(1),g?.();return}},[oe,g,lt]),ws=a.useCallback(async(n,l)=>{const u=l||Un||b;if(!(!u||n.length===0)){na(!0);try{await ui(u,n),oa(u,!1)}catch(x){Ct(x instanceof Error?x.message:o("rightSidebar.uploadFailed")),window.setTimeout(()=>Ct(null),4e3)}finally{na(!1)}}},[Un,b,oa,o]),uc=a.useCallback(async n=>{try{await xm(n)}catch(l){Ct(l instanceof Error?l.message:o("fileTree.openInFileBrowserFailed")),window.setTimeout(()=>Ct(null),4e3)}},[o]),ma=a.useCallback(n=>{n.preventDefault(),n.stopPropagation(),n.dataTransfer.types.includes("Files")&&No(!0)},[]),fc=a.useCallback(n=>{n.preventDefault(),n.stopPropagation(),No(!1)},[]),hc=a.useCallback(n=>{n.preventDefault(),n.stopPropagation(),No(!1);const l=n.dataTransfer.files;l.length>0&&ws(Array.from(l))},[ws]),zo=a.useCallback(n=>{Fe(n),window.setTimeout(()=>Fe(l=>l===n?null:l),1400)},[]),Lr=a.useCallback(n=>{Wt(n),window.setTimeout(()=>Wt(l=>l===n?null:l),1400)},[]);a.useEffect(()=>{Dt(zd,st)},[st]),a.useEffect(()=>{Dt(Hd,Je)},[Je]),a.useEffect(()=>{Dt(Wd,vt)},[vt]),a.useEffect(()=>{Is(ki,ee,Lb)},[ee]),a.useEffect(()=>(ql().catch(()=>{}),xd(n=>{n.type==="pinned-explorer-roots"&&Vl(n.pinnedExplorerRoots)})),[ql,Vl]);const mc=a.useRef(crypto.randomUUID?.()??`draft-${Math.random().toString(36).slice(2)}`),pa=a.useRef(null),Sn=a.useRef(null),[pc,Ho]=a.useState(!1);a.useEffect(()=>{if(!e)return;Ho(!1);let n=!1;ym().then(u=>{n||(pa.current=u.text,me(x=>u.text&&u.text!==x?u.text:x),Ho(!0))}).catch(()=>{n||Ho(!0)});const l=xd(u=>{u.type==="context-draft"&&u.origin!==mc.current&&(pa.current=u.text,me(u.text))});return()=>{n=!0,l(),Sn.current!==null&&(window.clearTimeout(Sn.current),Sn.current=null)}},[e]),a.useEffect(()=>{if(!pc||pa.current===ee)return;Sn.current!==null&&window.clearTimeout(Sn.current);const n=ee;Sn.current=window.setTimeout(()=>{Sn.current=null,vm(n,mc.current).then(()=>{pa.current=n}).catch(()=>{})},500)},[ee,pc]);const Xn=a.useCallback((n,l,u)=>{if(n){if(wm(u?n+u:n)){zo(l);return}st?(me(x=>qg(x,n)+(u??"")),window.matchMedia("(pointer: coarse)").matches||(Ft(!1),ht(x=>x+1))):window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:u?n+u:n,focus:!0}})),zo(l)}},[st,zo]),ga=a.useCallback(n=>{const l=_a(n,b);return qm(l,b)},[b]),Wo=Nu(Lr),rn=a.useCallback((n,l)=>{const u=_a(n,b);Xn(Vm(u,b),l??`path:${u}`)},[b,Xn]),dh=a.useCallback(async n=>{na(!0);try{await Km(n,ui,l=>{rn(l,`path:${l}`)}),oe&&!st&&s()}catch(l){Ct(l instanceof Error?l.message:o("rightSidebar.uploadFailed")),window.setTimeout(()=>Ct(null),4e3)}finally{na(!1)}},[st,rn,oe,s,o]),$r=a.useCallback((n,l)=>{if(!n)return;const u=n.includes(`
1660
- `)?`
1661
- `:void 0;Xn(n.endsWith(`
1662
- `)||n.endsWith(" ")?n:`${n} `,l,u)},[Xn]),gc=a.useRef($r);gc.current=$r;const Go=a.useRef(!0);a.useEffect(()=>(Go.current=!0,()=>{Go.current=!1}),[]);const qo=a.useRef(new Set),bc=a.useCallback((n,l,u)=>{if(qo.current.has(l))return;const x=qi.getState().activeSessionId;qo.current.add(l),Vp(n,l,u,{insert:$r,upload:async(y,C)=>(await ui("/tmp",[y],C)).files[0]?.path,isCurrent:()=>Go.current&&gc.current===$r&&x===qi.getState().activeSessionId}).finally(()=>qo.current.delete(l))},[$r]),nn=a.useCallback((n,l,u)=>{l&&Xn(l.endsWith(" ")?l:`${l} `,u??`context:${n}`,`
1663
- `)},[Xn]),xc=a.useCallback(n=>{const l=Vg(ee,n);if(!l)return;const u=n&&ee.trim().includes(`
1664
- `),x=`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`;let y=!1;const C=X=>{y||(y=!0,window.removeEventListener("termdock-insert-reference-ack",I),window.clearTimeout(H),X?(qt(!1),me(""),vt&&Ft(!0)):(qt(!0),Ft(!1)))},I=X=>{const Te=X.detail;Te?.nonce===x&&C(Te.ok===!0)},H=window.setTimeout(()=>C(!1),1500);window.addEventListener("termdock-insert-reference-ack",I),qt(!1),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:l,focus:!0,paste:u,nonce:x}}))},[vt,ee]),at=a.useMemo(()=>b?Et(b):o("rightSidebar.workspace"),[b,o]),uh=a.useMemo(()=>Et(ye)||at,[ye,at]),ba=a.useMemo(()=>Ai(ye),[ye]),xa=a.useMemo(()=>b?Gl[b]??[]:[],[Gl,b]),jn=a.useMemo(()=>new Set(xa.map(n=>n.path)),[xa]),ks=!!(ye&&jn.has(ye)),Vo=!!(b&&ye&&ye!==b),fh=!!(b&&Un&&Un!==b),Vt=ye?`path:${ye}`:null,yc="context:change-audit",hh=a.useCallback(()=>{ba&&Qt(ba)},[ba,Qt]),vc=a.useCallback(()=>{Kl()},[Kl]),mh=a.useCallback(()=>{ye&&(oa(ye,!0),Jl())},[Jl,ye,oa]),ph=a.useCallback(()=>{!ye||!Vo||(ks?xn(ye):zn(ye,"directory"))},[Vo,ye,ks,zn,xn]),wc=a.useCallback(n=>{Qt(n),j("")},[Qt]),kc=a.useCallback(n=>{ye&&(ae(Pb(ye,n)),ge(!0),window.requestAnimationFrame(()=>{document.querySelector("[data-right-search]")?.focus()}))},[ye,ge]),Sc=a.useCallback(n=>{!b||n===b||(jn.has(n)?xn(n):zn(n,"directory"))},[zn,jn,b,xn]),jc=a.useCallback(n=>{!b||!n||(jn.has(n)?xn(n):zn(n,"file"))},[zn,jn,b,xn]),Rc=ne(n=>n.expandedPaths),Ko=a.useMemo(()=>{const n=new Set;if(Yn&&ye){n.add(ye);const l=`${ye.replace(/\/+$/,"")}/`;for(const u of Rc)u.startsWith(l)&&n.add(u)}if(Yn&&b&&it){const l=it.startsWith("/")?it:`${b}/${it}`,u=Ai(l);u&&n.add(u)}return ig(n).join(`
1665
- `)},[Rc,Yn,ye,b,it]),Rn=a.useRef(new Map);a.useEffect(()=>{const n=Ko?Ko.split(`
1666
- `):[];if(!e||n.length===0){Bn(null);return}const l=new AbortController;let u=!1,x=0,y=0;Bn(null);const C=async()=>{let I=0;for(;!u&&!l.signal.aborted;){let H=null;try{Bn(null),await Am(n,Te=>{const{applicableEvents:et,unavailableReason:He}=cg(Te);et.length>0&&Yl(et);for(const qe of et){if(qe.type!=="rescan-required")continue;const ve=ne.getState();if(!ve.directoryCache.has(qe.path))continue;Rn.current.get(qe.path)?.abort();const nt=new AbortController;Rn.current.set(qe.path,nt);const cr=`file-watch-rescan:${qe.path}`;_t(cr),Pm(qe.path,nt.signal,ve.showHiddenFiles,"watch_rescan",cr,ve.fileSortModes[qe.path]??"name").then(We=>{Rn.current.get(qe.path)===nt&&Xl(qe.path,We.entries)}).catch(We=>{Dr(We)||Bn(We instanceof Error?We.message:"File refresh unavailable")}).finally(()=>{Rn.current.get(qe.path)===nt&&Rn.current.delete(qe.path)})}He&&Bn(He)},l.signal),H=new Error("File watch stream ended")}catch(Te){H=Te}if(u||l.signal.aborted||Dr(H))return;Bn(H instanceof Error?H.message:"File watching unavailable");const X=Gd[Math.min(I,Gd.length-1)];I+=1,await new Promise(Te=>{y=window.setTimeout(Te,X)})}};return x=window.setTimeout(()=>{u||C()},Si),()=>{u=!0,window.clearTimeout(x),window.clearTimeout(y),l.abort();for(const I of Rn.current.values())I.abort();Rn.current.clear()}},[Yl,e,Xl,Ko]),a.useEffect(()=>{if(!b||_o.current!==b)return;if(Do.current===b){Do.current=null;return}const n=Jd();Is(Xu,{...n,[b]:{selectedRepoRoots:Vs,repoTargetBranches:Er,repoBaseBranches:Ut,previewEntries:dn,selectedPreviewKey:Oe&&Rr?dt:null,selectedPreviewFileKey:Oe&&Rr?ko:null,previewDetailOpen:!!(Oe&&Rr),previewScrollTops:Tn,previewMobileSlideIndex:1,includeUncommitted:Kr,updatedAt:Date.now()}},Tb)},[Rr,Kr,Oe,dn,Tn,Ut,Er,Vs,b,ko,dt]);const xt=a.useMemo(()=>uu(Ne.values()),[Ne]),It=a.useMemo(()=>{const n=new Map;for(const l of V)n.set(l.root,l);return n},[V]),Yo=a.useMemo(()=>{const n=new Map;for(const l of V)l.deferred||n.set(l.root,l.files.length);return n},[V]),zt=a.useMemo(()=>fe?xe.find(n=>n.root===fe)??null:null,[fe,xe]),tr=a.useMemo(()=>it?Array.from(Ne.values()).find(n=>n.path===it||n.absolutePath===it)??null:null,[Ne,it]),Kt=a.useMemo(()=>{const n=new Map;for(const l of V)l.available&&l.context?.available&&n.set(l.root,l);return n.size===0&&Z?.available&&Z.root&&n.set(Z.root,{id:Z.root,root:Z.root,relativeRoot:".",name:at,depth:0,nested:!1,available:!0,files:Array.from(Ne.values()).filter(l=>jt(l,b)===Z.root),context:Z}),Array.from(n.values()).sort((l,u)=>l.root===b?-1:u.root===b?1:(l.relativeRoot||l.name).localeCompare(u.relativeRoot||u.name)).map(l=>{const u=l.relativeRoot==="."?at:l.relativeRoot||l.name||Et(l.root),x=du(l.files),y=l.files.length;return{value:l.root,label:u,meta:[l.context?.branch,y>0?o("rightSidebar.repoChangedCount",{count:y}):null,x>0?o("rightSidebar.repoStagedCount",{count:x}):null].filter(Boolean).join(" · ")}})},[Ne,Z,V,at,b,o]),Ce=a.useMemo(()=>fe&&Kt.some(n=>n.value===fe)?fe:tr?.repoRoot&&Kt.some(n=>n.value===tr.repoRoot)?tr.repoRoot:Kt.length===1||Kt.length>1?Kt[0].value:null,[fe,Kt,tr?.repoRoot]),Cc=Ce?It.get(Ce)??null:null,pe=Cc?.context?.available?Cc.context:Ce===Z?.root?Z:null,rt=Kt.length>0&&!Ce,Nc=a.useMemo(()=>rt?[]:Ce?Array.from(Ne.values()).filter(n=>jt(n,b)===Ce):Array.from(Ne.values()),[Ce,Ne,rt,b]),Cn=a.useMemo(()=>uu(Nc),[Nc]),Xo=!!(pe?.available&&pe.root&&Ce&&pe.root===Ce),gh=Ce?Kt.find(n=>n.value===Ce)?.label??Et(Ce):o("rightSidebar.gitRepositoryPlaceholder"),Ec=Xo?pe?.branch??"HEAD":rt?o("rightSidebar.selectRepositoryForGitActions"):pn?o("rightSidebar.gitActionRunning"):"HEAD",Jn=!!(pe?.available&&pe.root===Ce&&pe.status);a.useEffect(()=>{Nl.current={count:fn.length,loading:re,loadingMore:Jt,hasMore:xo}},[fn.length,xo,re,Jt]),a.useEffect(()=>{Vr.current+=1,gr.current?.abort(),_t("right-sidebar-recent-commits"),gr.current=null,un(""),qr([]),Ye(!1),Nr(!1),In(null),_n(!1)},[Ce]);const Ss=a.useCallback(async(n={})=>{if(!b||!Ce||rt)return;const l=n.reset??!1,u=Nl.current,x=l?0:u.count;if(!l&&(u.loading||u.loadingMore||!u.hasMore))return;const y=Vr.current+1;Vr.current=y,gr.current?.abort(),_t("right-sidebar-recent-commits");const C=new AbortController;gr.current=C,l?Ye(!0):Nr(!0),In(null);try{const I=await km({cwd:b,repoRoot:Ce,limit:zb,skip:x,query:us.trim(),requestSlotId:"right-sidebar-recent-commits"},C.signal);if(Vr.current!==y)return;if(!I.available){In(I.error??"Recent commits are unavailable"),l&&qr([]),_n(!1);return}fs(H=>l?I.commitSyncStatus??{}:{...H,...I.commitSyncStatus}),qr(H=>l?I.commits:[...H,...I.commits]),_n(I.hasMore)}catch(I){if(Vr.current!==y||Dr(I))return;In(I instanceof Error?I.message:"Failed to load recent commits"),l&&qr([]),_n(!1)}finally{gr.current===C&&(gr.current=null),Vr.current===y&&(Ye(!1),Nr(!1))}},[Ce,us,rt,b]);a.useEffect(()=>{mr&&Ss({reset:!0})},[us,Ss,mr,pe?.ahead,pe?.behind,pe?.upstream]);const bh=a.useCallback(n=>{const l=n.currentTarget;l.scrollTop+l.clientHeight<l.scrollHeight-48||Ss({reset:!1})},[Ss]);a.useEffect(()=>{!Ce||!Z?.available||!ct||!br||Jn||pn||rt||Oo(Ce)},[Ce,Z?.available,Jn,pn,ct,br,Oo,rt]),a.useEffect(()=>{!e||!$t&&!ct||!b||yr()},[$t,ct,e,yr,b]),a.useEffect(()=>{!e||!ct||!br||!hs||!b||ha(null)},[hs,ct,br,e,ha,b]);const xh=a.useMemo(()=>{if(!fe)return 0;const n=xe.findIndex(l=>l.root===fe);return n>=0?n+1:0},[fe,xe]),Mc=a.useCallback(n=>{if(!n)return null;const l=Array.from(Ne.values()).filter(u=>jt(u,b)===n).sort((u,x)=>u.path.localeCompare(x.path))[0];return l?Nt(l):null},[Ne,b]),Nn=xe.length>1,ya=a.useMemo(()=>[{root:null,label:o("rightSidebar.allRepositories"),count:Ne.size,branch:null,deferred:!1},...xe.map(n=>({root:n.root,label:n.label,count:n.deferred?Yo.get(n.root)??0:n.count,branch:n.branch??null,deferred:!!n.deferred&&!Yo.has(n.root)}))],[Ne.size,xe,Yo,o]),Ac=ya[xh]??ya[0],va=!!fe,Pc=a.useMemo(()=>af(xe,V),[xe,V]);a.useEffect(()=>{fe&&!Pc.has(fe)&&(Xe(null),ji(b,null)),cn(n=>n.filter(l=>xe.some(u=>u.root===l)))},[fe,xe,Pc,b]);const yh=a.useMemo(()=>{const n=new Set;pe?.branch&&n.add(pe.branch);for(const l of pe?.branches??[])n.add(l);return Array.from(n).map(l=>({value:l,label:l,meta:l===pe?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0}))},[pe?.branch,pe?.branches,o]),Tc=a.useMemo(()=>{const n=new Set;pe?.upstreamRemote&&n.add(pe.upstreamRemote);for(const l of pe?.remotes??[])n.add(l);return Array.from(n).map(l=>({value:l,label:l,meta:l===pe?.upstreamRemote?o("rightSidebar.pushUpstreamBadge"):void 0}))},[pe?.remotes,pe?.upstreamRemote,o]),Lc=Tc.length>1,vh=a.useMemo(()=>{const n=[],l=new Set,u=(y,C)=>{!y||l.has(y)||(l.add(y),n.push({value:y,label:y,meta:C}))};u(pe?.upstreamBranch,pe?.upstreamBranch?o("rightSidebar.pushUpstreamBadge"):void 0),u(pe?.branch,pe?.branch?o("rightSidebar.pushCurrentBranchBadge"):void 0);for(const y of pe?.branches??[])u(y,y===pe?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");const x=pe?.upstreamRemote;for(const y of pe?.remoteBranches??[]){const C=y.indexOf("/"),I=C>=0?y.slice(0,C):null,H=C>=0?y.slice(C+1):y;(!x||I===x)&&u(H,"remote")}return n},[pe?.branch,pe?.branches,pe?.remoteBranches,pe?.upstreamBranch,pe?.upstreamRemote,o]),rr=a.useMemo(()=>Kt.map(n=>{const l=It.get(n.value);return{root:n.value,label:n.label,branch:l?.context?.branch??null}}),[Kt,It]);a.useEffect(()=>{rr.length!==0&&(Ks(n=>{let l=!1;const u={...n},x=new Set(rr.map(y=>y.root));for(const y of Object.keys(u))x.has(y)||(delete u[y],l=!0);for(const y of rr)!u[y.root]&&y.branch&&(u[y.root]=y.branch,l=!0);return l?u:n}),Ys(n=>{let l=!1;const u={...n},x=new Set(rr.map(y=>y.root));for(const y of Object.keys(u))x.has(y)||(delete u[y],l=!0);for(const y of rr){const C=It.get(y.root)?.context;if(u[y.root]&&of(u[y.root],C?.branch)&&(delete u[y.root],l=!0),u[y.root])continue;const I=eu(C);I&&(u[y.root]=I,l=!0)}return l?u:n}))},[rr,It]);const wa=a.useMemo(()=>{const n=new Set(rr.map(l=>l.root));return Vs.filter(l=>n.has(l))},[Vs,rr]),ka=wa.length===0,wr=a.useMemo(()=>ka?rr:rr.filter(n=>wa.includes(n.root)),[rr,wa,ka]),lr=a.useMemo(()=>wr.filter(n=>!!Ut[n.root]?.trim()),[Ut,wr]),$c=a.useMemo(()=>wr.filter(n=>!Ut[n.root]?.trim()),[Ut,wr]),Ic=a.useCallback(async n=>{if(!n||Io.current.has(n))return;const l=It.get(n)?.context;if((l?.branches?.length??0)>0||(l?.remoteBranches?.length??0)>0||l?.upstream)return;const u=b;Io.current.add(n),Pl(x=>new Set(x).add(n));try{const x=await bd(n,void 0,"load_branch_audit_repo_details",`right-sidebar-branch-audit-details:${n}`);if(!x.available||!Me(u))return;Se(y=>y.map(C=>C.root===n?{...C,available:!0,context:{...C.context,...x},error:void 0}:C)),Ks(y=>y[n]||!x.branch?y:{...y,[n]:x.branch}),Ys(y=>{if(y[n])return y;const C=eu(x);return C?{...y,[n]:C}:y})}catch(x){Dr(x)||console.warn("[RightSidebar] Failed to load branch audit repo details",n,x)}finally{Io.current.delete(n),Pl(x=>{const y=new Set(x);return y.delete(n),y})}},[It,Me,b]);a.useEffect(()=>{if(yo)for(const n of wr)Ic(n.root)},[yo,wr,Ic]),a.useEffect(()=>{!Xo||!pe||(Zs(pe.branch||(pe.branches?.[0]??"")),ea(pe.upstreamRemote||(pe.remotes?.includes("origin")?"origin":pe.remotes?.[0]??"")),ta(pe.upstreamBranch||pe.branch||(pe.branches?.[0]??"")))},[pe,Xo]);const _c=a.useMemo(()=>{if(rt)return{text:o("rightSidebar.selectRepositoryForGitActions"),className:"bg-[rgb(var(--warning-rgb)_/_0.12)] text-[color:var(--warning)]"};if(!Jn||pn)return{text:o("common.loading"),className:"bg-surface-2 text-muted-foreground"};if(!pe?.upstream)return{text:o("rightSidebar.pushNoUpstream"),className:"bg-surface-2 text-muted-foreground"};const n=pe.ahead??0,l=pe.behind??0;return n>0&&l>0?{text:o("rightSidebar.pushDivergedCount",{ahead:n,behind:l}),className:"bg-destructive/10 text-destructive"}:n>0?{text:o("rightSidebar.pushAheadCount",{count:n}),className:"bg-accent/10 text-accent"}:l>0?{text:o("rightSidebar.pushBehindCount",{count:l}),className:"bg-surface-2 text-[color:var(--diff-hunk-accent)]"}:{text:o("rightSidebar.pushUpToDate"),className:"bg-surface-2 text-muted-foreground"}},[pe?.ahead,pe?.behind,pe?.upstream,Jn,pn,rt,o]),wh=a.useCallback(n=>{if(n&&!oe){const l=n.currentTarget.getBoundingClientRect();Ze({x:Math.min(l.left,window.innerWidth-352),y:Math.min(l.bottom+6,window.innerHeight-64)})}else Ze(null);P?.()},[oe,P]),Jo=a.useCallback(()=>{Ze(null),N?.()},[N]);function Dc(){if(!Nn)return null;const n=Ac?.label??o("rightSidebar.allRepositories"),l=Ac?.count??Ne.size,u=Et(n)||n;return t.jsxs("button",{type:"button",onClick:wh,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 ${S?"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":S,title:n,children:[t.jsx(Ir,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 truncate",children:u}),t.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${l>0?"bg-accent/10 text-accent":"bg-surface text-muted-foreground"}`,children:l}),t.jsx(os,{size:12,className:"shrink-0"})]})}function kh(){if(!S||!Nn||typeof document>"u")return null;const n=typeof window>"u"?1024:window.innerWidth,l=typeof window>"u"?768:window.innerHeight,u=Math.max(12,Math.min(Ie?.x??n-368,n-352)),x=Math.max(12,Math.min(Ie?.y??80,l-420)),y=oe?void 0:{left:u,top:x},C=t.jsx("div",{className:`fixed inset-0 z-drawer-backdrop ${oe?"bg-[var(--app-backdrop)]":"bg-transparent"}`,onClick:Jo,children:t.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:y,onClick:I=>I.stopPropagation(),children:[t.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:[t.jsxs("div",{children:[t.jsx("div",{className:oe?"text-sm font-semibold text-foreground":"text-xs font-semibold text-foreground",children:o("rightSidebar.repositories")}),!oe&&t.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[t.jsx("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:ya.length}),t.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] ${Ne.size>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:Ne.size})]})]}),t.jsx("button",{type:"button",onClick:Jo,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:t.jsx(sr,{size:oe?16:14})})]}),t.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:ya.map(I=>{const H=(I.root??null)===fe,X=Et(I.label)||I.label;return t.jsxs("button",{type:"button",onClick:()=>{nd(I.root),Jo()},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"} ${H?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:I.label,role:"option","aria-selected":H,children:[t.jsx("span",{className:`h-7 w-1 shrink-0 rounded-full ${H?"bg-primary":"bg-transparent group-hover:bg-border/40"}`}),t.jsx("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${H?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground group-hover:text-foreground"}`,children:t.jsx(Ir,{size:13})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:`${oe?"text-[13px]":"text-[12px]"} block truncate font-semibold leading-snug`,children:X}),t.jsx("span",{className:"block truncate text-[10px] leading-snug text-muted-foreground/70",children:I.root===null?o("rightSidebar.allRepositories"):I.label})]}),I.branch&&t.jsx("span",{className:"hidden max-w-[5.5rem] shrink min-w-0 truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground sm:inline",children:I.branch}),I.deferred?t.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/70",children:o("rightSidebar.repoNotLoaded")}):t.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] ${I.count>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:I.count})]},I.root??"all")})})]})});return Wu(C,oe,document.body)}function Sh(){return kh()}function Fc(n){const l=jt(n,b),u=n.absolutePath||(l?`${l}/${n.path}`:n.path),x=to(u,l??b);return{key:Nt(n),path:n.path,absolutePath:u,displayName:x.name,displayDir:x.dir,oldPath:n.oldPath,status:n.status,title:u}}function Oc(n){return n.oldPath?t.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/60",children:o("rightSidebar.changedFromPath",{path:n.oldPath})}):null}function Bc(n,l){const u=_a(n,b),x=`path:${u}`,y=ke===x,C=_e===x,I=y||C;return t.jsx("button",{type:"button",onClick:H=>{H.stopPropagation(),rn(u,x)},...Wo(ga(u),x),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 ${I?"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"} ${I?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,title:l,children:t.jsx("span",{className:"whitespace-nowrap",children:o(C?"rightSidebar.copied":y?"rightSidebar.inserted":"rightSidebar.insertFileRef")})})}function Uc(n){const l=jt(n,b),u=n.absolutePath||(l?`${l}/${n.path}`:n.path),x=Xh(n),y=Li(n);return t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Kx,{actions:x,running:ze,completed:Dn?.path===y?Dn:null}),Bc(u,o("rightSidebar.insertThisFile"))]})}function zc(n,l){const u=l.root??b;if(!u)return null;const x=_a(n,u);return Bc(x,o("fileTree.insertRefTitle"))}function Qo(){return t.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5","aria-label":o("diffViewer.view"),children:[t.jsx("button",{type:"button",onClick:()=>Jc("unified"),"aria-pressed":Tt==="unified",title:o("diffViewer.unifiedMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Tt==="unified"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.unified")}),t.jsx("button",{type:"button",onClick:()=>Jc("split"),"aria-pressed":Tt==="split",title:o("diffViewer.splitMode"),className:`inline-flex h-6 items-center rounded-full px-2 text-[10px] font-semibold transition active:scale-95 ${Tt==="split"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o("diffViewer.split")})]})}function Hc(){return js.map(n=>{const l=du(n.files.map(([,C])=>C)),u=Qi({activeGitRepoRoot:fe,groupCount:js.length,label:n.label,rootName:at}),x=!!(u&&n.root&&k.has(n.root));return{key:n.root??n.label,root:n.root,label:n.label,branch:n.branch,collapsed:x,files:n.files.map(([,C])=>Fc(C)),header:u?t.jsxs("div",{className:`flex w-full items-center gap-1.5 px-2 py-1.5 transition hover:bg-surface-2 ${x?"rounded-lg":"rounded-t-lg border-b border-border/10"}`,children:[t.jsxs("button",{type:"button",onClick:()=>zh(n.root),"aria-expanded":!x,className:"flex min-w-0 flex-1 items-center gap-2 text-left active:scale-[0.99]",children:[t.jsx("span",{className:"shrink-0 text-muted-foreground",children:x?t.jsx(Ia,{size:13}):t.jsx(os,{size:13})}),t.jsx(Ir,{size:12,className:"shrink-0 text-muted-foreground"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:n.label}),n.branch&&t.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:n.branch})]}),t.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:n.files.length}),l>0&&t.jsx("span",{className:"shrink-0 rounded bg-accent/10 px-1.5 py-0.5 text-[10px] text-accent",children:l})]}),n.root&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),Pa("stage-all",n.root,n.label)},disabled:!!ze,className:"rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:o("rightSidebar.stageAll"),children:o("rightSidebar.stageAll")}),t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),Pa("stash-all",n.root,n.label)},disabled:!!ze,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}})}function Wc(){return Ne.size===0?[{key:"empty",path:"",status:"unknown",repoRoot:null,displayName:o("rightSidebar.noChanges"),diffOverride:"",auditRecords:[]}]:ja.map(([,n])=>{const l=jt(n,b),u=n.absolutePath||(l?`${l}/${n.path}`:n.path);return{key:Nt(n),path:n.path,absolutePath:u,status:n.status,repoRoot:l,displayName:to(u,l).name,displayDir:to(u,l).dir,auditRecords:Bt}})}function Gc(n){const l=Array.from(Ne.values()).find(y=>Nt(y)===n.key),u=l?jt(l,b):null,x=Xp(Bt,u,l?.path??n.path);return t.jsx(Vi,{changeStatus:n.status,auditStatus:x,renderChangeBadge:y=>t.jsx(_s,{status:y})})}const Sa=a.useCallback(n=>{if(oe)return null;const l=Array.from(n.querySelectorAll("[data-diff-stream-item]"));if(l.length===0)return null;const x=n.getBoundingClientRect().top+48;let y=null,C=Number.POSITIVE_INFINITY;for(const H of l){const X=H.getBoundingClientRect();if(X.bottom<x)continue;const Te=Math.abs(X.top-x);Te<C&&(y=H,C=Te)}const I=y?.dataset.diffSelectionPath??y?.dataset.diffStreamItem??null;return I?(da.current===I&&ne.getState().selectedFilePath===I||(da.current=I,lt(I)),I):null},[oe,lt]),jh=!!(!ze&&Ce&&!rt&&(pe?.upstream||gn.trim()&&bn.trim())),Rh=!!(!ze&&Ce&&!rt&&(pe?.upstream||gn.trim()&&bn.trim())),Ch=!!(!ze&&Ce&&!rt&&On.trim()&&On.trim()!==pe?.branch),nr=a.useMemo(()=>{const n=de.trim().toLowerCase(),l=Array.from(Ne.entries()).filter(([,u])=>!fe||jt(u,b)===fe).sort(([u],[x])=>u.localeCompare(x));return n?l.filter(([u,x])=>`${u} ${x.path} ${x.status} ${x.repoRelativeRoot??""} ${x.repoName??""}`.toLowerCase().includes(n)):l},[fe,Ne,de,b]);a.useEffect(()=>{Ja("selected_file_state",{selectedFilePath:it,selectedChangedFilePath:tr?.path??null,selectedChangedFileAbsolutePath:tr?.absolutePath??null,selectedChangedFileRepoRoot:tr?.repoRoot??null,rootPath:b,activeGitRepoRoot:fe,rightTab:Ao,effectiveRightTab:vr,diffPaneActive:$t,changedFiles:Ne.size,filteredChangedFiles:nr.length,gitBundleLoading:Jr,gitBundleLastLoadedAt:Hn})},[fe,Ne.size,$t,vr,nr.length,Hn,Jr,Ao,b,tr?.absolutePath,tr?.path,tr?.repoRoot,it]);const js=a.useMemo(()=>{const n=new Map;for(const l of nr){const[,u]=l,x=jt(u,b),y=qx(u)||at,C=x??y,I=x?It.get(x):void 0,H=n.get(C)??{root:x,label:y,branch:I?.context?.branch,files:[]};H.files.push(l),n.set(C,H)}return Array.from(n.values()).sort((l,u)=>l.label===at?-1:u.label===at?1:l.label.localeCompare(u.label))},[nr,It,at,b]),ja=a.useMemo(()=>{const n=[],l=new Map;for(const u of nr)l.set(Nt(u[1]),u);for(const u of js){if(!!(u.root&&Qi({activeGitRepoRoot:fe,groupCount:js.length,label:u.label,rootName:at})&&k.has(u.root)))continue;if(Ee!=="tree"){n.push(...u.files);continue}const y=u.files.map(([,C])=>Fc(C));for(const C of ap(y)){const I=l.get(C.key);I&&n.push(I)}}return n},[fe,k,Ee,js,nr,at]);a.useEffect(()=>{if(!$t||ja.length===0||oe)return;const n=[],l=()=>{const u=document.querySelector(".termdock-diff-stream-scroller");if(u&&Sa(u))return;const x=document.querySelector("[data-diff-stream-item]"),y=x?.dataset.diffSelectionPath??x?.dataset.diffStreamItem??null;if(y){da.current=y,lt(y);return}const C=ja[0]?.[1];if(!C)return;const I=Nt(C);da.current=I,lt(I)};for(const u of[80,240,600,1200])n.push(window.setTimeout(l,u));return()=>n.forEach(u=>window.clearTimeout(u))},[$t,oe,ja,lt,Sa]);const Zo=a.useMemo(()=>{const n=I=>`'${I.replace(/'/g,"'\\''")}'`,l=or.length>0?kn:V.filter(I=>I.files.length>0),u=l.length>0?l:b?[{root:b,relativeRoot:".",name:at}]:[],x=u.length>0?u.map(I=>`- ${I.relativeRoot==="."?".":I.relativeRoot} (${I.root})`).join(`
1667
- `):`- ${b?".":""}`,y=u.length>0?u.map(I=>` td audit-export ${n(I.root)}`).join(`
1668
- `):" td audit-export",C=u.length>0?" td audit ~/.termdock/change-audit/payload-<repo>.json":" td audit ~/.termdock/change-audit/payload.json";return["任务:为目标仓库的 Git diff hunk 生成自包含审计解释,并通过 Termdock CLI 注入。","",`当前工作区:${b??""}`,"目标仓库:",x,"","执行步骤:","1. 仅对“目标仓库”逐个执行 audit-export。嵌套子仓使用括号内 repo 绝对路径作为命令参数。",y,"2. 先检查 audit-export 输出的 coverage[]:确认 untrackedFiles 是否为空、未跟踪文件是否已经出现在 hunks[].filePath 中;如果 coverage 显示存在未跟踪文件但 hunks[] 未包含对应文件,必须汇报导出异常,不要假装已解释。","3. 读取 audit-export 输出的全部 hunks[].diff,包含 tracked 与 untracked hunks;先理解整批改动的业务目标、行为变化、文件分工和跨 hunk 依赖。","4. 以 audit-export 内置 diff 为分析依据。仅在单个 hunk 信息不足时执行:td audit-show <hunkId> <对应仓库绝对路径>","5. 在 ~/.termdock/change-audit/ 生成批量 payload JSON。"," mkdir -p ~/.termdock/change-audit","6. payload 顶层字段:workspaceRoot、repoRoot、generatedBy、walkthrough、records[]。","7. walkthrough 必须先生成,用三层结构说明整批改动:highlights[] 面向不了解代码的人讲“改了什么/带来什么效果”;nodes[]/edges[] 表达关键链路;risks[]/checks[] 写真实风险和验证。节点可带 anchor,点击后会跳到对应 diff。","8. records[] 必须覆盖每个 hunk 内的多个 section,而不是只写 hunk 总结;从 audit-export hunk 原样复制 filePath、oldPath、newPath、hunkHeader、hunkIndex、fingerprint;如果解释的是 section,额外填写 sectionIndex 和 sectionFingerprint;补充 summary、explanation。","9. 写入 payload 后批量注入:",C,'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
- `)},[or.length,kn,V,at,b]),Nh=a.useCallback((n="generate")=>{if(Nn&&ln.length===0&&!fe){Gr(!0);return}const l=n==="generate"?Zo:[n==="regenerate"?"模式:重新生成。基于当前 audit-export 为全部 hunk 重新生成解释并覆盖写回。":"模式:补充失效。基于当前 audit-export 补充新增、变更或已失效的 hunk 解释;保留仍有效的解释。","",Zo].join(`
1670
- `);ut("insert_change_audit_prompt",{rootPath:b,activeGitRepoRoots:or,mode:n,hasAuditListCommand:l.includes("td audit-list"),promptLength:l.length}),nn(o("rightSidebar.insertChangeAuditPrompt"),l,`${yc}:${n}`),yr(),d||s()},[fe,Zo,ln.length,or,nn,yr,s,d,b,Nn,o]),Ra=a.useCallback(async n=>{try{await yd({ids:[n]}),on(l=>l.filter(u=>u.id!==n))}catch{yr()}},[yr]),Eh=a.useCallback(async()=>{if(Bt.length===0)return;const n=Bt.map(l=>l.id);try{await yd({ids:n}),on(l=>l.filter(u=>!n.includes(u.id))),Xt(null)}catch(l){const u=l instanceof Error?l.message:"Failed to clear change audit explanations";Xt(o("rightSidebar.changeAuditClearFailed",{message:u})),yr()}},[Bt,yr,o]),Mh=a.useCallback(async n=>{if(n.records.length===0)return;const l=n.records.map(u=>u.id);try{await Sm({ids:l}),jr(u=>u.filter(x=>!l.includes(x.id))),dt===n.key&&(hn(null),fr(!1))}catch(u){Ct(o("rightSidebar.branchAuditClearFailed",{message:u instanceof Error?u.message:"Failed to clear branch explanation"})),ha(null)}},[ha,dt,o]),Ah=a.useCallback(n=>{cn(l=>n===null?(Gr(!1),[]):l.includes(n)?l.filter(u=>u!==n):[...l,n])},[]),Ph=a.useCallback(n=>{wo(l=>n===null?(vo(!1),[]):l.includes(n)?l.filter(u=>u!==n):[...l,n])},[]),ei=a.useMemo(()=>{if(!br)return[];const n=l=>{const u=l.diff??"";let x=0,y=0;for(const C of u.split(`
1671
- `))C.startsWith("+++")||C.startsWith("---")||(C.startsWith("+")&&(x+=1),C.startsWith("-")&&(y+=1));return{filePath:l.filePath,oldPath:l.oldPath,newPath:l.newPath,hunkHeader:l.hunkHeader,hunkIndex:l.hunkIndex??0,fingerprint:l.fingerprint,additions:x,deletions:y,diff:u}};return Oe?(Oe.hunks??[]).map(l=>{const u=Sr.find(x=>x.repoRoot===Oe.repoRoot&&x.baseRef===Oe.baseRef&&(x.branchName??null)===(Oe.currentBranch??null)&&x.filePath===l.filePath&&x.hunkHeader===l.hunkHeader&&(x.hunkIndex??0)===l.hunkIndex&&x.fingerprint===l.fingerprint)??null;return{key:`${l.filePath}\0${l.hunkHeader}\0${l.hunkIndex}`,hunk:l,current:u,stale:null}}):dt?Sr.filter(l=>Qd(l)===dt).map(l=>{const u=n(l);return{key:`${l.filePath}\0${l.hunkHeader}\0${l.hunkIndex??0}`,hunk:u,current:l,stale:null}}):[]},[Oe,Sr,br,dt]),ti=Sr.length>0,Qn=a.useMemo(()=>{if(!br)return[];const n=new Map;for(const l of Sr){const u=l.repoRoot,x=It.get(u),y=x?.relativeRoot==="."?at:x?.relativeRoot||x?.name||Et(u),C=Qd(l),I=n.get(C)??{key:C,repoRoot:u,repoLabel:y,baseRef:l.baseRef,branchName:l.branchName??null,headRef:l.headRef??null,diffFingerprint:l.diffFingerprint??null,records:[],latestInjectedAt:0};I.records.push(l),I.latestInjectedAt=Math.max(I.latestInjectedAt,l.injectedAt??0),n.set(C,I)}return Array.from(n.values()).sort((l,u)=>u.latestInjectedAt-l.latestInjectedAt)},[Sr,It,br,at]),ri=a.useMemo(()=>dt?Qn.find(n=>n.key===dt)??null:null,[Qn,dt]),Ca=Oe?{repoRoot:Oe.repoRoot??"",repoLabel:Oe.repoRoot?It.get(Oe.repoRoot)?.relativeRoot==="."?at:It.get(Oe.repoRoot)?.relativeRoot||It.get(Oe.repoRoot)?.name||Et(Oe.repoRoot):at,baseRef:Oe.baseRef??Oe.baseBranch??"",branchName:Oe.currentBranch??null,headRef:Oe.headRef??null,diffFingerprint:Oe.diffFingerprint??null}:ri,Th=a.useMemo(()=>(Qe?.hunks??[]).map(n=>({key:`${n.filePath}\0${n.hunkHeader}\0${n.hunkIndex}`,hunk:n,current:null,stale:null})),[Qe?.hunks]),Lh=a.useMemo(()=>{if(Oe)return[];const n=ri;return n?An.filter(l=>l.repoRoot===n.repoRoot&&l.baseRef===n.baseRef&&(l.branchName??null)===n.branchName&&(!n.diffFingerprint||l.diffFingerprint===n.diffFingerprint)):[]},[Oe,An,ri]),$h=a.useCallback(n=>{const l=ei.find(u=>u.hunk.filePath===n.filePath||(n.repoRoot?`${n.repoRoot}/${u.hunk.filePath}`===n.filePath:!1));l&&(mn(l.key),window.setTimeout(()=>En(n),90),window.setTimeout(()=>En(n),320),window.setTimeout(()=>En(n),760))},[ei]),ni=a.useMemo(()=>{const n=y=>`'${y.replace(/'/g,"'\\''")}'`,l=lr,u=l.length>0?l.map(y=>`- ${y.label} (${y.root}),目标分支:${Er[y.root]||y.branch||"(current branch)"},基线分支:${Ut[y.root]||"(not set)"}`).join(`
1672
- `):`- ${b?".":""}`,x=l.length>0?l.map(y=>{const C=Er[y.root]||y.branch||"",I=Ut[y.root]||"",H=y.label.replace(/[^A-Za-z0-9_-]+/g,"_")||"repo";return[C?` git -C ${n(y.root)} switch ${n(C)}`:` # ${y.label}: keep current branch`," mkdir -p ~/.termdock/branch-audit",` td branch-audit-export ${n(I)} ${n(y.root)} > ~/.termdock/branch-audit/branch-audit-export-${H}.json`].join(`
1673
- `)}).join(`
1674
- `):" td branch-audit-export <base-branch>";return["解释目标仓库当前分支相对于基线分支的改动,并把解释写回 Termdock。","",`当前工作区:${b??""}`,`包含本地未提交更改:${Kr?"是":"否"}`,"目标仓库:",u,"","操作指令:",Kr?"1. 只针对上面列出的目标仓库导出分支 hunk;如果指定了目标分支,先在对应仓库切到目标分支。导出内容需要包含目标分支相对基线分支的提交改动,以及当前工作区 staged/unstaged/untracked 改动。嵌套子仓或软链接子仓必须使用括号里的仓库绝对路径,不要改用当前工作区根目录。示例:":"1. 只针对上面列出的目标仓库导出分支 hunk;如果指定了目标分支,先在对应仓库切到目标分支。不要包含本地 staged/unstaged/untracked 改动;如果导出结果里混入了本地工作区改动,生成解释时必须忽略这些本地改动,只解释目标分支相对基线分支的提交改动。嵌套子仓或软链接子仓必须使用括号里的仓库绝对路径,不要改用当前工作区根目录。示例:",x,"2. 读取导出的 ~/.termdock/branch-audit/branch-audit-export*.json 中的 hunks[],不要把临时 JSON 放到业务仓目录,也不要把整份 JSON 粘贴回输入框。导出工具使用 base...HEAD(三点)生成 diff,只表示当前分支独有改动;提交列表使用 base..HEAD(两点)。","3. 先生成 walkthrough,用 highlights[] 说明整批分支改动目的和影响,用 nodes[]/edges[] 画出主链路、分支链路和验证链路;节点可带 anchor,点击后会跳到对应 diff。","4. 逐个 hunk 写解释。解释要说明该 hunk 的意图、解决的问题、影响、风险,以及它和其它 hunk 的关系;不要逐行复述 diff。","5. 每个仓库分别生成 ~/.termdock/branch-audit/payload-<repo>.json,payload 必须包含 workspaceRoot、repoRoot、baseRef、branchName、headRef、diffFingerprint、walkthrough 和 records[];records[] 每条 record 对应一个 hunk,diff 字段必须从 hunk.diff 原样复制。","6. 把解释写入 payload 后执行:td branch-audit ~/.termdock/branch-audit/payload-<repo>.json","7. 注入成功后删除本次生成的临时 JSON:rm -f ~/.termdock/branch-audit/branch-audit-export-*.json ~/.termdock/branch-audit/payload-*.json","","payload 示例:","```json",JSON.stringify({workspaceRoot:b??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
- `)},[Kr,lr,Ut,Er,b]),Ih=a.useCallback((n="generate")=>{const l=n==="generate"?ni:[n==="regenerate"?"模式:重新生成。请基于当前分支导出结果重新生成全部 hunk 解释并覆盖写回。":"模式:补充失效。请基于当前分支导出结果只补充新增、变更或已失效的 hunk 解释,仍有效的解释不要重复写回。","",ni].join(`
1676
- `);nn(o("rightSidebar.branchAuditShort"),l,`context:branch-audit-scope:${n}`),d||s()},[ni,nn,s,d,o]),_h=a.useCallback(async()=>{if(!b||lr.length===0)return;const n=b;G(!0),je(null),hr(null),Be(null);try{const l=await Promise.all(lr.map(async H=>{const X=Ut[H.root]?.trim();if(!X)throw new Error(o("rightSidebar.branchAuditMissingBase",{repo:H.label}));const Te=(Er[H.root]||H.branch||"").trim();return jm({cwd:b,repoRoot:H.root,base:X,head:Te&&Te!==H.branch?Te:null,includeUncommitted:Kr,requestSlotId:`right-sidebar-branch-preview:${H.root}`})}));if(!Me(n))return;const u=l.find(H=>!H.available);if(u){je(u.error??"Branch diff is unavailable");return}const x=l.length===1?l[0]:{available:!0,workspaceRoot:b,repoRoot:b,baseRef:l.map(H=>H.baseRef??H.baseBranch).filter(Boolean).join(", "),currentBranch:l.map(H=>H.currentBranch??"HEAD").filter(Boolean).join(", "),headRef:l.map(H=>H.headRef).filter(Boolean).join(", "),diffFingerprint:l.map(H=>H.diffFingerprint).filter(Boolean).join("+"),stat:l.map(H=>H.stat).filter(Boolean).join(`
1677
- `),files:l.flatMap((H,X)=>{const Te=lr[X];return(H.files??[]).map(et=>`${Te?.label??H.repoRoot??"repo"}/${et}`)}),hunks:l.flatMap((H,X)=>{const et=lr[X]?.label??H.repoRoot??"repo";return(H.hunks??[]).map(He=>({...He,filePath:`${et}/${He.filePath}`,oldPath:He.oldPath?`${et}/${He.oldPath}`:He.oldPath,newPath:He.newPath?`${et}/${He.newPath}`:He.newPath}))}),commits:l.flatMap(H=>H.commits??[]),commitCount:l.reduce((H,X)=>H+(X.commitCount??X.commits?.length??0),0),diff:l.map(H=>H.diff).filter(Boolean).join(`
1678
- `),truncated:l.some(H=>H.truncated)};if((x.hunks??[]).length===0){je(o("rightSidebar.branchAuditDiffEmpty"));return}const y=Date.now(),C=["preview",x.repoRoot??b,x.baseRef??x.baseBranch??"",x.currentBranch??"",x.headRef??"",x.diffFingerprint??y].join("\0"),I=lr.length===1?lr[0].label:`${lr.length} repos`;hr(x),ds(H=>[{key:C,diff:x,repoLabel:I,createdAt:y},...H.filter(X=>X.key!==C)].slice(0,8)),Ln(H=>H[C]===void 0?H:{...H,[C]:0}),hn(C),mn(x.hunks?.[0]?`${x.hunks[0].filePath}\0${x.hunks[0].hunkHeader}\0${x.hunks[0].hunkIndex}`:null),fr(!0)}catch(l){if(!Me(n)||Dr(l))return;je(l instanceof Error?l.message:"Failed to load branch diff")}finally{Me(n)&&G(!1)}},[Kr,lr,Ut,Er,Me,b,o]),Dh=a.useCallback(n=>{hr(n.diff),je(null),hn(n.key),mn(n.diff.hunks?.[0]?`${n.diff.hunks[0].filePath}\0${n.diff.hunks[0].hunkHeader}\0${n.diff.hunks[0].hunkIndex}`:null),fr(!0)},[]),Fh=a.useCallback(n=>{ds(l=>l.filter(u=>u.key!==n)),Ln(l=>{if(!(n in l))return l;const u={...l};return delete u[n],u}),dt===n&&(hn(null),hr(null),fr(!1))},[dt]),Oh=a.useCallback(n=>{const l=Qn.find(u=>u.key===n);l&&(hr(null),je(null),hn(n),mn(l.records[0]?.filePath??null),fr(!0))},[Qn]),Bh=a.useCallback(async n=>{if(!b||!Ce)return;const[l]=n.split(/\s+/);if(l){Ke(l),kt(null),Be(null);try{const u=await Rm({cwd:b,repoRoot:Ce,commit:l,requestSlotId:"right-sidebar-commit-diff"});if(!u.available){kt(u.error??"Commit diff is unavailable");return}Be(u);const x=u.hunks?.[0];qs(x?`${x.filePath}\0${x.hunkHeader}\0${x.hunkIndex}`:null)}catch(u){kt(u instanceof Error?u.message:"Failed to load commit diff")}finally{Ke(null)}}},[Ce,b]),Uh=a.useCallback(n=>{if(!Oe||!dt)return;const l=Math.max(0,Math.round(n));Ln(u=>Math.abs((u[dt]??0)-l)<24?u:{...u,[dt]:l})},[Oe,dt]);a.useEffect(()=>{!oe||!Rr||!Oe||ys(1)},[Rr,Oe,oe,ys]);const qc=a.useCallback(n=>{n&&th(l=>op(l,n))},[]),Vc=sa.key===it?sa.key:null,Na=a.useCallback(n=>{const l=ne.getState(),u=a0();Ja("select_diff_file",{interactionId:u,path:n,previousSelectedFilePath:l.selectedFilePath,rootPath:l.rootPath,activeGitRepoRoot:fe,changedFiles:l.changedFiles.size,gitBundleLoading:l.gitBundleLoading,gitBundleLastLoadedAt:l.gitBundleLastLoadedAt,rightTab:l.rightTab}),lt(n),ar("diff"),oe&&n&&ys(1),qc(n),queueMicrotask(()=>{const x=ne.getState();Ja("select_diff_file_after",{interactionId:u,requestedPath:n,selectedFilePath:x.selectedFilePath,rootPath:x.rootPath,rightTab:x.rightTab,changedFiles:x.changedFiles.size,activeGitRepoRoot:fe})})},[fe,oe,qc,lt,ar,ys]),Kc=a.useCallback(n=>{const l=Array.from(Ne.values()).find(u=>{const x=jt(u,b),y=Nt(u);return u.path===n.filePath||y===n.filePath||u.absolutePath===n.filePath||(x?`${x}/${u.path}`===n.filePath:!1)||n.repoRoot&&x===n.repoRoot&&u.path===n.filePath});if(l){Na(Nt(l)),window.setTimeout(()=>En(n),90),window.setTimeout(()=>En(n),320),window.setTimeout(()=>En(n),760);return}En(n)},[Ne,b,Na]),Yc=a.useCallback(({slideToDetail:n,fullscreen:l,toggleFullscreen:u}={})=>ls.length>0?t.jsx(wu,{walkthroughs:ls,repoRoot:fe,fullscreen:l,onToggleFullscreen:u,onNavigate:x=>{oe&&window.requestAnimationFrame(()=>n?.()),Kc(x)}}):t.jsxs("div",{className:"rounded-lg border border-border/15 bg-surface px-3 py-6 text-center text-xs text-muted-foreground",children:[t.jsx(Bs,{size:18,className:"mx-auto mb-2 text-muted-foreground/80"}),o("rightSidebar.changeWalkthroughEmpty")]}),[fe,ls,Kc,oe,o]),zh=a.useCallback(n=>{n&&J(l=>{const u=new Set(l);return u.has(n)?u.delete(n):u.add(n),Ri(vi,u),u})},[]),Xc=a.useCallback(n=>{Re(l=>{const u=new Set(l);return u.has(n)?u.delete(n):u.add(n),Ri(Ud,u),u})},[]),Ea=a.useCallback(n=>{ur(n),Dt(qu,n)},[]);a.useEffect(()=>{va||Ee!=="ai"||Ea("tree")},[Ee,Ea,va]);const Ma=a.useCallback(()=>{Ur(n=>{const l=!n;return Dt(Vu,l),l})},[]),Jc=a.useCallback(n=>{an(n),Dt(Ku,n)},[]),{whitespace:Qc,context:Zc}=lp(),ed=a.useMemo(()=>({algorithm:"histogram",whitespace:Qc,context:Zc}),[Qc,Zc]),td=a.useCallback(n=>{z(n),Dt(Yu,n)},[]),Aa=a.useCallback(async(n,l,u,x)=>{let y=n;for(;y.ok&&y.status==="running";)await new Promise(I=>window.setTimeout(I,1500)),y=await vd({jobId:y.jobId,cwd:l.cwd,action:l.action});if(!y.ok)throw new Error("Git action status is unavailable");if(y.status==="error")throw new Error(y.error||y.message||"Git action failed");const C={action:l.action,path:x,label:u};return ps(C),window.setTimeout(()=>ps(I=>I?.action===C.action&&I.path===C.path?null:I),1400),y},[]),St=a.useCallback(async(n,l,u)=>{const x=b;b&&xr.current.delete(b),Ct(null),ps(null),ms({action:n.action,path:u});try{const y=await Cm({...n,includeNested:es(b)}),C=await Aa(y,n,l,u);if(!Me(x))return!1;const I=b?await $a(b,void 0,{includeNested:es(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:rs(b)}).catch(()=>C.bundle):C.bundle;return Me(x)?(I&&tn(I,{reloadDiff:!0,cacheOnly:!0}),Xr(null),!0):!1}catch(y){return ps(null),Ct(o("rightSidebar.gitActionFailed",{message:y instanceof Error?y.message:"Unknown error"})),!1}finally{Me(x)&&ms(null)}},[tn,Me,b,o,Aa]),rd=a.useCallback(async n=>{const l=b,u=await Nm({...n,includeNested:es(b)});if(!Me(l))return;const x=b?await $a(b,void 0,{includeNested:es(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:rs(b)}).catch(()=>u.bundle):u.bundle;Me(l)&&x&&tn(x,{reloadDiff:!0,cacheOnly:!0})},[tn,Me,b]),Pa=a.useCallback((n,l,u)=>{if(l){if(n==="stage-all"){St({action:"stage-all",cwd:l},o("rightSidebar.stageAll"),`repo:${l}`);return}Xr({kind:"stash-all",repoRoot:l,repoLabel:u})}},[St,o]),nd=a.useCallback(n=>{Xe(n),ji(b,n),Zs(""),ea(""),ta(""),lt(Mc(n)),ct||ar("diff"),n&&n!==b&&V.find(u=>u.root===n)?.deferred&&ir(n,{includeNested:!1,background:!0,replaceRepoRoot:n})},[Mc,ct,V,ir,b,lt,ar]),sd=a.useCallback(n=>{const l=new Set([...er.current.keys(),...vn.current,...xr.current]);for(const u of l)u!==n&&(Zt.current.delete(u),er.current.get(u)?.abort(),er.current.delete(u),_t(`right-sidebar-git-untracked:${u}`),vn.current.delete(u),xr.current.delete(u))},[]),Hh=a.useCallback(async n=>{const l=b;if(!l||(await ne.getState().setNestedGitScanRoot(l,n),!Me(l)))return;if(n){await ir(l,{includeNested:!0,discoverOnly:!0,replaceWorkspace:!0,background:!0,reloadDiff:!0});return}sd(l),Zs(""),ea(""),ta(""),wo(x=>x.filter(y=>y===l));const u=tr;u&&jt(u,l)!==l&&lt(null),await ir(l,{includeNested:!1,replaceWorkspace:!0,background:!0,reloadDiff:!0})},[sd,Me,ir,b,lt,tr]),Wh=a.useCallback(async()=>{if(!Ce||rt){Ct(o("rightSidebar.selectRepositoryForGitActions"));return}const n=On.trim();!n||n===pe?.branch||await St({action:"switch-branch",cwd:Ce,branch:n},o("rightSidebar.switchBranch"))},[pe?.branch,Ce,rt,St,On,o]),ad=a.useCallback(async()=>{if(!Ce||rt){Ct(o("rightSidebar.selectRepositoryForGitActions"));return}const n=Qs.trim();if(!n)return;await St({action:"commit",cwd:Ce,message:n},o("rightSidebar.commitChanges"))&&Fl("")},[Ce,Qs,rt,St,o]),Gh=a.useCallback(async()=>{if(!Ce||rt){Ct(o("rightSidebar.selectRepositoryForGitActions"));return}const n=gn.trim(),l=bn.trim();await St({action:"push",cwd:Ce,...n?{remote:n}:{},...l?{branch:l}:{}},o("rightSidebar.pushChanges"))},[Ce,bn,gn,rt,St,o]),qh=a.useCallback(async()=>{if(!Ce||rt){Ct(o("rightSidebar.selectRepositoryForGitActions"));return}const n=gn.trim(),l=bn.trim();await St({action:"pull",cwd:Ce,...n?{remote:n}:{},...l?{branch:l}:{}},o("rightSidebar.pullChanges"))},[Ce,bn,gn,rt,St,o]);a.useEffect(()=>{if(!ct||!Ce||ze)return;let n=!1;const l={push:o("rightSidebar.pushChanges"),pull:o("rightSidebar.pullChanges"),commit:o("rightSidebar.commitChanges"),"switch-branch":o("rightSidebar.switchBranch"),"stage-all":o("rightSidebar.stageAll"),"stash-all":o("rightSidebar.stashAll")};return(async()=>{for(const u of["push","pull","commit","switch-branch","stage-all","stash-all"]){if(n)return;const x=await vd({cwd:Ce,action:u}).catch(()=>null);if(!x?.ok||x.status!=="running")continue;const y={action:u,cwd:Ce},C=l[u]??u;ms({action:u});try{const I=await Aa(x,y,C);if(n||!Me(b))return;const H=b?await $a(b,void 0,{includeNested:es(b),cacheOnly:!0,action:"git_action_cache_sync",requestSlotId:rs(b)}).catch(()=>I.bundle):I.bundle;H&&tn(H,{reloadDiff:!0,cacheOnly:!0})}catch(I){n||Ct(o("rightSidebar.gitActionFailed",{message:I instanceof Error?I.message:"Unknown error"}))}finally{n||ms(null)}return}})(),()=>{n=!0}},[Ce,tn,ct,Me,b,ze,o,Aa]);const si=Dn?.action==="commit",ai=Dn?.action==="switch-branch",oi=Dn?.action==="pull",ii=Dn?.action==="push",Ta=ct||Zf,li=ka?o("rightSidebar.changeAuditScopeAll"):wr.length===1?wr[0].label:`${wr.length} repos`,Vh=wr.length>0,od=lr.length>0,Kh=b?t.jsx(ou,{open:yo,onOpenChange:vo,showScopePicker:!0,selectedAll:ka,repos:rr,selectedRoots:wa,onToggleRepo:Ph,onGenerate:()=>Ih(ti?"regenerate":"generate"),disabled:!Vh,generateDisabled:!od,inserted:ke?.startsWith("context:branch-audit-scope:")??!1,buttonLabel:o(ti?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.branchAuditGenerateTitle"),ariaLabel:o("rightSidebar.branchAuditShort"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:li,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o(ti?"rightSidebar.branchAuditRegenerate":"rightSidebar.branchAuditGenerate"),onSecondaryAction:()=>{_h()},secondaryDisabled:!od||D,secondaryLabel:o("rightSidebar.branchAuditViewDiff"),secondaryTitle:o("rightSidebar.branchAuditViewDiffTitle"),secondaryLoading:D,loading:Al.size>0,statusTitle:Al.size>0?o("rightSidebar.branchCandidatesLoading"):void 0,extraContent:t.jsxs("div",{className:"mb-2 space-y-1.5",children:[t.jsxs("label",{className:"flex cursor-pointer items-center justify-between gap-3 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-foreground",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block font-medium",children:o("rightSidebar.includeUncommitted")}),t.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:o("rightSidebar.includeUncommittedHint")})]}),t.jsx("input",{type:"checkbox",checked:Kr,onChange:n=>Ml(n.target.checked),className:"h-4 w-4 shrink-0 accent-[rgb(var(--primary-rgb))]"})]}),$c.length>0&&t.jsx("div",{className:"rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[10px] text-[color:var(--warning)]",children:o("rightSidebar.missingBaseReposSkipped",{repositories:$c.map(n=>n.label).join(w==="zh"?"、":", ")})})]}),renderRepoExtra:n=>{const l=It.get(n.root),u=[],x=new Set,y=(X,Te)=>{!X||x.has(X)||(x.add(X),u.push({value:X,label:X,meta:Te}))};y(Er[n.root]||l?.context?.branch,o("rightSidebar.pushCurrentBranchBadge"));for(const X of l?.context?.branches??[])y(X,X===l?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):o("rightSidebar.localBranch"));for(const X of l?.context?.remoteBranches??[])y(X,o("rightSidebar.remoteBranch"));const C=[],I=new Set,H=(X,Te)=>{!X||I.has(X)||(I.add(X),C.push({value:X,label:X,meta:Te}))};H(Ut[n.root],Ut[n.root]?o("rightSidebar.pushUpstreamBadge"):void 0),H(l?.context?.upstream,l?.context?.upstream?o("rightSidebar.pushUpstreamBadge"):void 0);for(const X of l?.context?.remoteBranches??[])H(X,"remote");for(const X of l?.context?.branches??[])H(X,X===l?.context?.branch?o("rightSidebar.pushCurrentBranchBadge"):"local");return t.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[t.jsx(ts,{label:o("rightSidebar.currentBranchLabel"),value:Er[n.root]||l?.context?.branch||"",options:u,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),onChange:X=>{Ks(Te=>({...Te,[n.root]:X}))}}),t.jsx(ts,{label:o("rightSidebar.branchAuditBaseLabel"),value:Ut[n.root]||"",options:C,placeholder:o("rightSidebar.branchAuditBasePlaceholder"),searchPlaceholder:o("rightSidebar.branchAuditBaseSearchPlaceholder"),emptyText:o("rightSidebar.branchAuditBaseEmpty"),onChange:X=>{Ys(Te=>({...Te,[n.root]:X}))}})]})}}):null,id=Ts(Bt.reduce((n,l)=>Math.max(n,l.injectedAt??0),0),w),Yh=b?t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("button",{type:"button",onClick:()=>El(n=>{const l=!n;return Dt(wi,l),l}),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":hs,children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:t.jsx(Bs,{size:14})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-[12px] font-semibold text-foreground",children:o("rightSidebar.branchAuditTitle")}),t.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:li})]}),t.jsx("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${hs?"rotate-90":""}`,children:t.jsx(Ia,{size:13})})]}),hs&&t.jsxs("div",{className:"mt-2 rounded-lg border border-border/10 bg-surface/60 p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0 text-[11px] text-muted-foreground",children:[o("rightSidebar.changeAuditScopeLabel"),": ",li]}),Kh]}),he&&t.jsx("div",{className:"mb-2 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:he}),t.jsxs("div",{className:"mt-2 space-y-1.5",children:[dn.map(n=>t.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${dt===n.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[t.jsxs("button",{type:"button",onClick:()=>Dh(n),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:n.repoLabel}),t.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[n.diff.hunks?.length??0," hunk"]})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:n.diff.currentBranch??"HEAD"}),t.jsx("span",{className:"text-muted-foreground/60",children:"→"}),t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:n.diff.baseRef??n.diff.baseBranch}),t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:o("rightSidebar.branchAuditViewDiff")})]}),Ts(n.createdAt,w)&&t.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:Ts(n.createdAt,w)})]}),t.jsx("button",{type:"button",onClick:()=>Fh(n.key),className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:o("common.delete"),"aria-label":o("common.delete"),children:t.jsx(Qa,{size:12})})]},n.key)),Qn.length>0?Qn.slice(0,Math.max(0,8-dn.length)).map(n=>t.jsxs("div",{className:`flex min-w-0 items-start gap-1 rounded-md transition ${dt===n.key?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[t.jsxs("button",{type:"button",onClick:()=>Oh(n.key),className:"min-w-0 flex-1 px-2 py-1.5 text-left active:scale-[0.99]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:n.repoLabel}),t.jsxs("span",{className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[n.records.length," hunk"]})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:n.branchName??"HEAD"}),t.jsx("span",{className:"text-muted-foreground/60",children:"→"}),t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:n.baseRef}),n.diffFingerprint&&t.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5",children:n.diffFingerprint})]}),Ts(n.latestInjectedAt,w)&&t.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground/70",children:o("rightSidebar.branchAuditGeneratedAt",{time:Ts(n.latestInjectedAt,w)??""})})]}),t.jsx("button",{type:"button",onClick:()=>{Mh(n)},className:"mr-1 mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground active:scale-95",title:o("rightSidebar.branchAuditClearTitle"),"aria-label":o("rightSidebar.branchAuditClearTitle"),children:t.jsx(Qa,{size:12})})]},n.key)):dn.length===0?t.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.branchAuditEmpty")}):null]})]})]}):null,ld=br&&b&&Jn?t.jsxs("div",{className:Ta?"overflow-visible":"overflow-hidden",children:[Yh,t.jsxs("button",{type:"button",onClick:()=>{ct||eh(n=>{const l=!n;return l&&Ce&&!Jn&&!pn&&Oo(Ce),l})},"aria-expanded":Ta,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:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground group-hover:text-foreground",children:t.jsx(Ir,{size:14})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-foreground",children:o("rightSidebar.gitQuickActions")}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[t.jsxs("span",{className:`inline-flex items-center justify-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${Cn.staged>0?"bg-accent/10 text-accent":"bg-surface-2 text-muted-foreground"}`,children:[pn&&t.jsx(yt,{size:10,className:"animate-spin"}),Cn.staged>0?o("rightSidebar.stagedCount",{count:Cn.staged}):o("rightSidebar.noStagedChangesShort")]}),!ct&&t.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${Ta?"rotate-90":""}`,children:t.jsx(Ia,{size:13})})]})]}),Ta&&t.jsxs("div",{className:"space-y-0",children:[Kt.length>1&&t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsx("div",{className:"mb-2 flex items-center justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.gitRepositorySectionTitle")}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:gh})]})}),t.jsx(ts,{label:o("rightSidebar.gitRepositoryLabel"),value:Ce??"",options:Kt,placeholder:o("rightSidebar.gitRepositoryPlaceholder"),searchPlaceholder:o("rightSidebar.gitRepositorySearchPlaceholder"),emptyText:o("rightSidebar.gitRepositoryEmpty"),disabled:!!ze,onChange:n=>{nd(n||null)}}),rt&&t.jsx("div",{className:"mt-2 rounded-md bg-[rgb(var(--warning-rgb)_/_0.12)] px-2 py-1.5 text-[11px] text-[color:var(--warning)]",children:o("rightSidebar.selectRepositoryForGitActions")})]}),t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.branchSectionTitle")}),t.jsx("div",{className:"mt-0.5 h-4 truncate text-[11px] leading-4 text-muted-foreground",children:On!==Ec?Ec:null})]}),t.jsxs("button",{type:"button",onClick:()=>{Wh()},disabled:!Ch,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 ${ai?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.switchBranch"),children:[t.jsx("span",{className:ze?.action==="switch-branch"||ai?"opacity-0":"",children:o("rightSidebar.switchBranch")}),ze?.action==="switch-branch"&&t.jsx(yt,{size:12,className:"absolute animate-spin"}),ai&&ze?.action!=="switch-branch"&&t.jsx("span",{className:"absolute",children:"✓"})]})]}),t.jsx(ts,{label:o("rightSidebar.currentBranchLabel"),value:On,options:yh,placeholder:o("rightSidebar.switchBranchPlaceholder"),searchPlaceholder:o("rightSidebar.switchBranchSearchPlaceholder"),emptyText:o("rightSidebar.switchNoBranches"),disabled:!!ze,onChange:Zs})]}),t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.commitSectionTitle")}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:rt?o("rightSidebar.selectRepositoryForGitActions"):Cn.staged>0?o("rightSidebar.commitReadyHint",{count:Cn.staged}):o("rightSidebar.commitNeedsStaged")})]}),t.jsxs("button",{type:"button",onClick:()=>{ad()},disabled:!!ze||rt||Cn.staged===0||!Qs.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 ${si?"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:rt?o("rightSidebar.selectRepositoryForGitActions"):Cn.staged===0?o("rightSidebar.commitNeedsStaged"):o("rightSidebar.commitChanges"),children:[t.jsx("span",{className:ze?.action==="commit"||si?"opacity-0":"",children:o("rightSidebar.commitChanges")}),ze?.action==="commit"&&t.jsx(yt,{size:12,className:"absolute animate-spin"}),si&&ze?.action!=="commit"&&t.jsx("span",{className:"absolute",children:"✓"})]})]}),t.jsx("input",{value:Qs,onChange:n=>Fl(n.target.value),onKeyDown:n=>{(n.metaKey||n.ctrlKey)&&n.key==="Enter"&&(n.preventDefault(),ad())},placeholder:o("rightSidebar.commitMessagePlaceholder"),disabled:!!ze,className:"w-full min-h-10 rounded-md border border-transparent bg-surface-2 px-3 py-2 text-[13px] placeholder:text-[13px] text-foreground outline-none transition placeholder:text-muted-foreground/70 focus:border-primary focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-60",maxLength:300})]}),t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("button",{type:"button",onClick:()=>Cr(n=>!n),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":mr,children:[t.jsx("span",{className:"min-w-0 text-[12px] font-medium text-foreground",children:o("rightSidebar.recentCommitsTitle")}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[re&&t.jsx(yt,{size:12,className:"animate-spin text-muted-foreground"}),t.jsx("span",{className:`flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition group-hover:bg-surface-elevated group-hover:text-foreground ${mr?"rotate-90":""}`,children:t.jsx(Ia,{size:13})})]})]}),mr&&t.jsxs("div",{className:"mt-2 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[t.jsx(ns,{size:12,className:"shrink-0"}),t.jsx("input",{value:$n,onChange:n=>un(n.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}),$n&&t.jsx("button",{type:"button",onClick:()=>un(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:t.jsx(sr,{size:12})})]}),t.jsxs("div",{className:"max-h-56 space-y-1 overflow-y-auto overscroll-contain pr-1",onScroll:bh,children:[fn.length>0?fn.map(n=>{const[l,...u]=n.split(/\s+/),x=u.join(" ")||n;return t.jsxs("button",{type:"button",onClick:()=>{Bh(n)},className:"flex w-full min-w-0 items-start gap-2 rounded-md bg-surface-2 px-2 py-1.5 text-left font-mono text-[10px] transition hover:bg-surface-elevated active:scale-[0.99]",title:x,children:[t.jsx("span",{className:"shrink-0 text-[color:var(--diff-hunk-accent)]",children:l}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",title:x,children:x}),pr[l]&&t.jsx("span",{className:`shrink-0 rounded px-1 font-sans text-[10px] ${pr[l]==="ahead"?"bg-accent/10 text-accent":pr[l]==="behind"?"bg-surface-2 text-[color:var(--warning)]":"text-muted-foreground"}`,children:o(pr[l]==="ahead"?"rightSidebar.commitAhead":pr[l]==="behind"?"rightSidebar.commitBehind":"rightSidebar.commitSynced")}),tt===l&&t.jsx(yt,{size:11,className:"shrink-0 animate-spin text-muted-foreground"})]},n)}):re?t.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-2 text-center text-[11px] text-muted-foreground",children:o("common.loading")}):t.jsx("div",{className:"rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:o("rightSidebar.recentCommitsEmpty")}),Jt&&t.jsx("div",{className:"flex justify-center rounded-md bg-surface-2 px-2 py-2 text-muted-foreground",children:t.jsx(yt,{size:12,className:"animate-spin"})}),xo&&!Jt&&fn.length>0&&t.jsx("button",{type:"button",onClick:()=>{Ss({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")})]})]}),bt&&t.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:bt}),Cl&&t.jsx("div",{className:"mt-2 rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] text-destructive",children:Cl})]}),t.jsxs("div",{className:"border-b border-border/40 px-1 py-4 last:border-b-0",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("div",{className:"text-[12px] font-medium text-foreground",children:o("rightSidebar.pushSectionTitle")}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{qh()},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 ${oi?"bg-accent/10 text-accent hover:bg-accent/15":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:o("rightSidebar.pullChanges"),children:[t.jsx("span",{className:ze?.action==="pull"||oi?"opacity-0":"",children:o("rightSidebar.pullChanges")}),ze?.action==="pull"&&t.jsx(yt,{size:12,className:"absolute animate-spin"}),oi&&ze?.action!=="pull"&&t.jsx("span",{className:"absolute",children:"✓"})]}),t.jsxs("button",{type:"button",onClick:()=>{Gh()},disabled:!Rh,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.pushChanges"),children:[t.jsx("span",{className:ze?.action==="push"||ii?"opacity-0":"",children:o("rightSidebar.pushChanges")}),ze?.action==="push"&&t.jsx(yt,{size:12,className:"absolute animate-spin"}),ii&&ze?.action!=="push"&&t.jsx("span",{className:"absolute",children:"✓"})]})]})]}),t.jsxs("div",{className:`mb-2 flex min-w-0 items-center justify-between gap-2 rounded-md px-2 py-1.5 text-[11px] ${_c.className}`,title:pe?.upstream??void 0,children:[t.jsx("span",{className:"truncate font-medium",children:_c.text}),t.jsx("span",{className:"w-[6.5rem] shrink-0 truncate text-right text-[10px] opacity-75",children:pe?.upstream??""})]}),t.jsxs("div",{className:`grid gap-1.5 ${Lc?"grid-cols-2":"grid-cols-1"}`,children:[Lc&&t.jsx(ts,{label:o("rightSidebar.pushRemoteLabel"),value:gn,options:Tc,placeholder:o("rightSidebar.pushRemotePlaceholder"),searchPlaceholder:o("rightSidebar.pushRemoteSearchPlaceholder"),emptyText:o("rightSidebar.pushNoRemotes"),disabled:!!ze,onChange:ea}),t.jsx(ts,{label:o("rightSidebar.pushBranchLabel"),value:bn,options:vh,placeholder:o("rightSidebar.pushBranchPlaceholder",{branch:pe?.branch??"HEAD"}),searchPlaceholder:o("rightSidebar.pushBranchSearchPlaceholder"),emptyText:o("rightSidebar.pushNoBranches"),disabled:!!ze,onChange:ta})]})]})]})]}):null,Xh=a.useCallback(n=>{const l=jt(n,b);if(!l)return[];const u=Li(n),x=[];return n.canStage&&x.push({key:"stage-file",label:o("rightSidebar.stageFile"),onClick:()=>{St({action:"stage-file",cwd:l,paths:[n.path]},o("rightSidebar.stageFile"),u)}}),n.canUnstage&&x.push({key:"unstage-file",label:o("rightSidebar.unstageFile"),onClick:()=>{St({action:"unstage-file",cwd:l,paths:[n.path]},o("rightSidebar.unstageFile"),u)}}),n.canStash&&x.push({key:"stash-file",label:o("rightSidebar.stashFile"),onClick:()=>{St({action:"stash-file",cwd:l,paths:[n.path]},o("rightSidebar.stashFile"),u)}}),n.canRestoreWorktree&&x.push({key:"restore-worktree-file",label:o("rightSidebar.restoreFile"),destructive:!0,onClick:()=>Xr({kind:"restore",file:n,phrase:""})}),x},[b,St,o]),Jh=a.useCallback(()=>{if(m){f?.();return}Ar(0),Tr.current?.slideTo(0),Mr(!1),wt(null)},[f,m]),cd=a.useCallback(n=>{if(j(""),Qt(n),lt(null),wt(null),se(null),oe){m&&f?.(),Ar(0),Tr.current?.slideTo(0),Mr(!1);return}},[oe,f,m,lt,Qt]);a.useEffect(()=>{const n=l=>{const u=l.detail,x=u?.path;if(typeof x!="string"||!x.startsWith("/"))return;j(""),wt(null),De(null);const y=!!(b&&(x===b||x.startsWith(`${b}/`)));if(u.kind==="file"){const C=Ai(x);vs(x),typeof u.line=="number"&&Number.isSafeInteger(u.line)&&u.line>0&&De(u.line),Qt(y?null:C),se(I=>({path:x,nonce:(I?.nonce??0)+1}));return}lt(null),y?(Qt(null),se(C=>({path:x,nonce:(C?.nonce??0)+1}))):(se(null),Qt(x)),oe&&(m&&f?.(),Ar(0),Tr.current?.slideTo(0),Mr(!1))};return window.addEventListener(wd,n),()=>window.removeEventListener(wd,n)},[vs,oe,f,m,b,lt,Qt]),a.useEffect(()=>{e||(Ot(!1),Gt(!1))},[e]),a.useEffect(()=>{if(!Pt&&!Yt)return;const n=l=>{l instanceof globalThis.KeyboardEvent&&l.key!=="Escape"||l instanceof globalThis.MouseEvent&&l.target instanceof Node&&(Mn.current?.contains(l.target)||Or.current?.contains(l.target))||(Ot(!1),Gt(!1))};return window.addEventListener("mousedown",n),window.addEventListener("keydown",n),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("keydown",n)}},[Yt,Pt]);const dd=t.jsxs("div",{"data-local-layer":"file-explorer-menu-host",className:"sticky top-0 z-20 bg-surface/95 px-2.5 py-1.5 backdrop-blur",children:[t.jsxs("div",{className:"flex min-h-9 min-w-0 items-center gap-1.5",children:[t.jsx("button",{type:"button",onClick:hh,disabled:!ba,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.parentFolder"),title:o("rightSidebar.parentFolder"),children:t.jsx(bu,{size:14})}),t.jsx("button",{type:"button",onClick:vc,disabled:!b||Un===b,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35 active:scale-95","aria-label":o("rightSidebar.backToProjectRoot"),title:o("rightSidebar.backToProjectRoot"),children:t.jsx(Wi,{size:14})}),t.jsx("button",{type:"button",onClick:mh,disabled:!ye,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:Ol?o("rightSidebar.fileWatchUnavailable",{message:Ol}):o("rightSidebar.refreshFiles"),children:t.jsx(ro,{size:13})}),t.jsx("div",{className:"min-w-0 flex-1 px-1",title:ye??void 0,children:t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[12px] font-medium text-foreground",children:[t.jsx("span",{className:"truncate",children:uh}),la==="modified"&&t.jsx("span",{className:"inline-flex shrink-0 text-primary",title:o("fileTree.sortedByModified"),"aria-label":o("fileTree.sortedByModified"),children:t.jsx(kd,{size:11})})]})}),t.jsx("button",{type:"button",onClick:()=>ye&&rn(ye,Vt??void 0),disabled:!ye,...ye&&Vt?Wo(ga(ye),Vt):{},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 ${Vt&&(ke===Vt||_e===Vt)?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary hover:bg-primary/20"}`,"aria-label":o(Vt&&_e===Vt?"rightSidebar.copied":Vt&&ke===Vt?"rightSidebar.inserted":"rightSidebar.insertCurrentFolder"),title:o("rightSidebar.insertCurrentFolder"),children:Vt&&(ke===Vt||_e===Vt)?t.jsx(Di,{size:13}):t.jsx(no,{size:13})}),t.jsxs("div",{ref:Or,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>{Ot(!1),Gt(n=>!n)},className:`inline-flex h-7 w-7 items-center justify-center rounded-md transition active:scale-95 ${Yt?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,"aria-expanded":Yt,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:t.jsx(Oi,{size:14})}),Yt&&t.jsxs("div",{role:"menu","data-local-layer":"file-explorer-menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-48 overflow-hidden rounded-xl border border-border/15 bg-surface p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in",children:[t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Gt(!1),ph()},disabled:!Vo,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition disabled:opacity-40 ${ks?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[ks?t.jsx(fi,{size:14}):t.jsx(Da,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(ks?"rightSidebar.unpinCurrentFolder":"rightSidebar.pinCurrentFolder")})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Gt(!1),nh()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${Po?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[Po?t.jsx(mp,{size:14}):t.jsx(zi,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(Po?"rightSidebar.hideHiddenFiles":"rightSidebar.showHiddenFiles")})]}),t.jsxs("button",{type:"button",role:"menuitem",disabled:!ye,onClick:()=>{ye&&(Gt(!1),sh(ye,la==="modified"?"name":"modified"))},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2 disabled:opacity-40",children:[la==="modified"?t.jsx(Ym,{size:14}):t.jsx(kd,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(la==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]})]})]}),b&&(xa.length>0||fh)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 pb-0.5 text-[11px]",children:[t.jsx("span",{className:"shrink-0 px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.pinnedFolders")}),t.jsxs("button",{type:"button",onClick:vc,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 ${ye===b?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:b,children:[t.jsx(Wi,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:at})]}),xa.map(n=>{const l=n.path,u=n.kind==="file",x=u?it===l:ye===l;return t.jsxs("span",{className:`group inline-flex max-w-[12rem] shrink-0 items-center rounded-md transition ${x?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:l,children:[t.jsxs("button",{type:"button",onClick:()=>u?vs(l):Qt(l),className:"inline-flex min-w-0 items-center gap-1 px-2 py-0.5 font-medium active:scale-95",children:[u?t.jsx(Hi,{size:10,className:"shrink-0"}):t.jsx(Da,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:Et(l)})]}),t.jsx("button",{type:"button",onClick:()=>xn(l),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:Et(l)}),title:o("rightSidebar.unpinFolder",{name:Et(l)}),children:t.jsx(sr,{size:9})})]},l)})]}),t.jsx("span",{"data-local-layer":"file-explorer-divider",className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-px bg-border/15","aria-hidden":"true"})]}),ci=a.useMemo(()=>{if(Fn===null)return null;const n=typeof navigator>"u"?void 0:navigator.language,l=Math.max(0,Math.floor((Co-Fn)/1e3)),u=new Intl.RelativeTimeFormat(n,{numeric:"auto"}),[x,y]=l<60?[-l,"second"]:l<3600?[-Math.floor(l/60),"minute"]:l<86400?[-Math.floor(l/3600),"hour"]:[-Math.floor(l/86400),"day"];return u.format(x,y)},[Co,Fn]),ud=b&&!Kn?t.jsx("button",{type:"button",onClick:()=>{Hh(!To)},"aria-pressed":To,title:o("rightSidebar.multiRepoScanTitle"),className:`inline-flex h-7 shrink-0 items-center rounded-md px-2.5 text-[11px] font-medium transition active:scale-95 ${To?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:o("rightSidebar.multiRepoScan")}):null,fd=b?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-1.5",children:[ci?t.jsx("span",{className:"whitespace-nowrap text-[10px] text-muted-foreground",title:o("rightSidebar.gitLastUpdated",{time:ci}),children:ci}):null,t.jsx("button",{type:"button",onClick:()=>{xs()},disabled:Jr,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50 active:scale-95","aria-label":o("rightSidebar.refreshGit"),title:o("rightSidebar.refreshGit"),children:t.jsx(ro,{size:13,className:Jr?"animate-spin":""})})]}):null,Qh=ic?o("rightSidebar.changeAuditScopeAll"):kn.length===1?kn[0].relativeRoot==="."?at:kn[0].relativeRoot||kn[0].name:`${kn.length} repos`,hd=b?t.jsxs("div",{className:"inline-flex h-7 shrink-0 items-center",children:[t.jsx(ou,{open:Gs,onOpenChange:Gr,showScopePicker:Nn,selectedAll:ic,repos:ah,selectedRoots:or,onToggleRepo:Ah,onGenerate:()=>Nh(),disabled:!b,inserted:ke===yc,buttonLabel:o("rightSidebar.changeAuditShort"),insertedLabel:o("rightSidebar.inserted"),title:o("rightSidebar.insertChangeAuditPromptTitle"),ariaLabel:o("rightSidebar.insertChangeAuditPrompt"),scopeTitle:o("rightSidebar.changeAuditScopeLabel"),scopeLabel:Qh,allLabel:o("rightSidebar.changeAuditScopeAll"),generateLabel:o("rightSidebar.changeAuditShort"),loading:zr,error:!!Wr,statusTitle:Wr??(zr?o("rightSidebar.changeAuditLoading"):Bt.length>0?`${o("rightSidebar.changeAuditLoaded",{count:Bt.length})}${id?` · ${o("rightSidebar.changeAuditLoadedAt",{time:id})}`:""}`:void 0)}),t.jsx("button",{type:"button",onClick:()=>{Eh()},disabled:zr||Bt.length===0,className:`inline-flex h-7 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:pointer-events-none active:scale-95 ${Bt.length>0?"":"invisible"}`,title:o("rightSidebar.clearChangeAuditTitle"),"aria-label":o("rightSidebar.clearChangeAudit"),children:t.jsx(Qa,{size:12})})]}):null,La=t.jsxs("div",{className:"flex h-5 flex-nowrap items-center gap-1 overflow-x-auto whitespace-nowrap text-[10px] font-medium [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&>*]:shrink-0",children:[Z?.available&&Z.branch&&t.jsxs("span",{className:"inline-flex min-w-0 max-w-[8rem] items-center gap-0.5 truncate rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",title:Z.branch,children:[t.jsx(Ir,{size:10,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:Z.branch})]}),xt.modified>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-hunk-accent)]",children:[xt.modified,"M"]}),xt.added>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:["+",xt.added]}),xt.deleted>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-delete-strong)]",children:["-",xt.deleted]}),xt.renamed>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[xt.renamed,"R"]}),xt.copied>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[xt.copied,"C"]}),xt.untracked>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-[color:var(--diff-insert-strong)]",children:[xt.untracked,"U"]}),xt.conflicted>0&&t.jsxs("span",{className:"rounded bg-destructive/10 px-1.5 py-0.5 text-destructive",children:[xt.conflicted,"!"]}),xt.other>0&&t.jsxs("span",{className:"rounded bg-surface-2 px-1.5 py-0.5 text-muted-foreground",children:[xt.other,"?"]}),xt.staged>0&&t.jsx("span",{className:"rounded bg-accent/10 px-1.5 py-0.5 text-accent",children:o("rightSidebar.stagedCountShort",{count:xt.staged})}),Z?.available&&b&&Ne.size>0&&V.length<=1&&t.jsx("button",{type:"button",onClick:()=>{St({action:"stage-all",cwd:b},o("rightSidebar.stageAll"))},disabled:!!ze,className:"rounded-md bg-accent/10 px-2 py-0.5 font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:o("rightSidebar.stageAll"),children:o("rightSidebar.stageAll")}),Z?.available&&b&&Ne.size>0&&V.length<=1&&t.jsx("button",{type:"button",onClick:()=>Xr({kind:"stash-all",repoRoot:b,repoLabel:at}),disabled:!!ze,className:"rounded-md bg-surface-2 px-2 py-0.5 font-medium text-foreground hover:bg-surface-elevated disabled:opacity-50",title:o("rightSidebar.stashAll"),children:o("rightSidebar.stashAll")})]});return t.jsxs(Xm,{side:"right",isOpen:e,drawerWidthPx:r,onClose:s,onOpen:i,push:d,pinned:c,children:[Wo.popoverNode,t.jsxs("div",{className:"relative shrink-0 border-b border-border/15 bg-surface px-2 pt-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsxs("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",title:b??void 0,children:at}),(!oe||jo)&&Z?.available&&Z.branch&&t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 truncate text-[11px] text-muted-foreground",title:Z.branch,children:[t.jsx(Ir,{size:10,className:"shrink-0"}),t.jsx("span",{className:"max-w-[7rem] truncate",children:Z.branch})]})]})}),t.jsx("button",{type:"button",onClick:()=>{const n=!ie;ge(n),n?window.requestAnimationFrame(()=>document.querySelector("[data-right-search]")?.focus()):j("")},className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${ie?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleSearch"),title:o("common.search"),children:t.jsx(ns,{size:14})}),t.jsxs("button",{type:"button",role:"switch","aria-checked":st,onClick:()=>{At(n=>!n),Ft(!1)},className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${st?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o("rightSidebar.toggleContextDraft"),title:o("rightSidebar.contextDraftTitle"),children:[t.jsx(Jm,{size:14}),!st&&ee.trim()&&t.jsx("span",{className:"absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-primary","aria-hidden":"true"})]}),t.jsx("input",{ref:Hl,type:"file",multiple:!0,className:"hidden",onChange:n=>{const l=n.target.files;!l||l.length===0||(ws(Array.from(l)),n.target.value="")}}),t.jsx("input",{ref:Wl,type:"file",accept:"image/*",className:"hidden",onChange:n=>{const l=n.target.files?.[0];n.target.value="",l&&dh(l)}}),h&&t.jsx("button",{type:"button",onClick:h,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${c?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":o(c?"sidebar.unpinSidebar":"sidebar.pinSidebar"),title:o(c?"sidebar.unpinSidebar":"sidebar.pinSidebar"),children:c?t.jsx(fi,{size:14}):t.jsx(Da,{size:14})}),t.jsxs("div",{ref:Mn,className:"relative shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>{Gt(!1),Ot(n=>!n)},className:`relative inline-flex h-8 w-8 items-center justify-center rounded-full transition active:scale-95 ${Pt?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":Pt,"aria-haspopup":"menu","aria-label":o("sidebar.moreActions"),title:o("sidebar.moreActions"),children:t.jsx(Oi,{size:15})}),Pt&&t.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-56 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Yr,onClick:()=>ch(!Yr),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[t.jsx(Fi,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"flex-1",children:o("rightSidebar.showAndroidTab")}),t.jsx("span",{"aria-hidden":"true",className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition ${Yr?"bg-primary":"bg-surface-elevated"}`,children:t.jsx("span",{className:`absolute h-3 w-3 rounded-full bg-background transition-all ${Yr?"left-3.5":"left-0.5"}`})})]}),t.jsx("div",{className:"my-1 h-px bg-border/15",role:"separator"}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Ot(!1),Hl.current?.click()},disabled:ra,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:[ra?t.jsx(yt,{size:14,className:"animate-spin text-muted-foreground"}):t.jsx(Dp,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o("rightSidebar.uploadFiles")})]}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Ot(!1),Wl.current?.click()},disabled:ra,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:[ra?t.jsx(yt,{size:14,className:"animate-spin text-muted-foreground"}):t.jsx(yp,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o("rightSidebar.insertLocalImage")})]}),h&&t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{Ot(!1),h()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${c?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[c?t.jsx(fi,{size:14}):t.jsx(Da,{size:14,className:"text-muted-foreground"}),t.jsx("span",{children:o(c?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]}),c&&t.jsxs("div",{className:"mt-1 flex items-center gap-2 border-t border-border/15 px-1.5 pt-1.5",role:"group","aria-label":o("rightSidebar.layoutMode"),children:[t.jsx("div",{className:"shrink-0 pl-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:o("rightSidebar.layoutMode")}),t.jsx("div",{className:"grid min-w-0 flex-1 grid-cols-3 gap-0.5 rounded-lg bg-surface-2 p-0.5",children:[["auto",o("rightSidebar.layoutModeAuto")],["narrow",o("rightSidebar.layoutModeNarrow")],["wide",o("rightSidebar.layoutModeWide")]].map(([n,l])=>{const u=q===n;return t.jsx("button",{type:"button",role:"menuitemradio","aria-checked":u,onClick:()=>{Q(n),Ot(!1)},className:`rounded-md px-1 py-1.5 text-center text-[11px] font-medium transition active:scale-95 ${u?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:l},n)})})]})]})]}),t.jsx("button",{type:"button",onClick:s,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":o("rightSidebar.close"),children:t.jsx(sr,{size:14})})]}),ie&&t.jsxs("div",{className:"mt-2 space-y-1.5 pb-0.5",children:[t.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-surface-2 px-3 py-1.5 text-muted-foreground transition focus-within:bg-surface-elevated",children:[t.jsx(ns,{size:12,className:"shrink-0"}),t.jsx("input",{"data-right-search":!0,type:"search",value:O,onChange:n=>j(n.target.value),placeholder:o(T==="content"?"rightSidebar.searchPlaceholderContent":"rightSidebar.filterChanges"),className:"min-w-0 flex-1 bg-transparent text-[13px] text-foreground placeholder:text-muted-foreground",autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",enterKeyHint:"search",spellCheck:!1}),t.jsxs("div",{className:`flex shrink-0 items-center gap-0.5 rounded-full bg-surface/70 p-0.5 font-medium ${oe?"text-[11px]":"text-[10px]"}`,children:[t.jsx("button",{type:"button",onClick:()=>td("name"),"aria-pressed":T==="name",className:`rounded-full px-2 transition active:scale-95 ${oe?"py-1":"py-0.5"} ${T==="name"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeName")}),t.jsx("button",{type:"button",onClick:()=>td("content"),"aria-pressed":T==="content",className:`rounded-full px-2 transition active:scale-95 ${oe?"py-1":"py-0.5"} ${T==="content"?"bg-primary/15 text-primary":"text-muted-foreground/80 hover:text-foreground"}`,children:o("rightSidebar.searchModeContent")})]}),O&&t.jsx("button",{type:"button",onClick:()=>j(""),className:"rounded-full p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.clearSearch"),children:t.jsx(sr,{size:12})})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsxs("label",{className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg bg-surface-2 px-2.5 py-1.5 text-muted-foreground transition focus-within:bg-surface-elevated",children:[t.jsx(Qm,{size:12,className:"shrink-0 text-primary"}),t.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:o("rightSidebar.searchScope")}),t.jsx("input",{"data-search-scope":!0,value:K,onChange:n=>ae(n.target.value),onKeyDown:n=>{n.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}),K!=="."&&t.jsx("button",{type:"button",onClick:()=>ae("."),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-surface hover:text-foreground","aria-label":o("rightSidebar.resetSearchScope"),children:t.jsx(sr,{size:11})})]}),t.jsxs("button",{type:"button",onClick:()=>Ae(n=>!n),"aria-expanded":be,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition active:scale-95 ${be||gs.length>0||M||ue||Ge?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:o("rightSidebar.searchOptions"),"aria-label":o("rightSidebar.searchOptions"),children:[t.jsx(Zm,{size:13}),gs.length>0&&t.jsx("span",{className:"absolute -right-1 -top-1 min-w-4 rounded-full bg-primary px-1 text-[8px] font-bold leading-4 text-primary-foreground",children:gs.length})]})]}),be&&t.jsxs("div",{className:"animate-fade-in rounded-xl bg-surface-2 p-2",children:[t.jsxs("label",{className:"flex items-center gap-2 rounded-lg bg-surface px-2.5 py-1.5 text-muted-foreground focus-within:bg-surface-elevated",children:[t.jsx("span",{className:"shrink-0 text-[10px] font-medium",children:o("rightSidebar.searchExclude")}),t.jsx("input",{"data-search-exclude":!0,value:le,onChange:n=>we(n.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}),le&&t.jsx("button",{type:"button",onClick:()=>we(""),className:"rounded p-0.5 hover:bg-surface-2 hover:text-foreground","aria-label":o("rightSidebar.clearSearchExclude"),children:t.jsx(sr,{size:11})})]}),T==="content"&&t.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",role:"group","aria-label":o("rightSidebar.contentSearchOptions"),children:[[M,()=>te(n=>!n),dp,o("rightSidebar.matchCase")],[ue,()=>Le(n=>!n),zp,o("rightSidebar.matchWholeWord")],[Ge,()=>Pe(n=>!n),Pp,o("rightSidebar.useRegex")]].map(([n,l,u,x])=>t.jsxs("button",{type:"button",onClick:l,"aria-pressed":n,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] transition ${n?"bg-primary/15 text-primary":"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:[t.jsx(u,{size:12}),x]},x))})]})]}),t.jsxs("div",{className:"mt-2 grid gap-0.5 rounded-md bg-surface-2 p-0.5",style:{gridTemplateColumns:`repeat(${(Kn?2:3)+(Yr?1:0)}, minmax(0, 1fr))`},children:[!Kn&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:()=>ar("git"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${vr==="git"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(Ir,{size:12}),o("rightSidebar.tabGit")]}),t.jsxs("button",{type:"button",onClick:()=>ar("diff"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${vr==="diff"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(Eu,{size:12}),o("rightSidebar.tabChanges"),Ne.size>0?t.jsx("span",{className:"text-[10px] text-accent",children:Ne.size}):null]})]}),t.jsxs("button",{type:"button",onClick:()=>ar("files"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${vr==="files"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(sp,{size:12}),o("rightSidebar.tabFiles")]}),Yr&&t.jsxs("button",{type:"button",onClick:()=>ar("android"),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium transition active:scale-[0.98] ${vr==="android"?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2"}`,children:[t.jsx(Fi,{size:12}),o("rightSidebar.tabAndroid")]})]}),t.jsx("div",{className:"h-2"}),_l&&t.jsx("div",{className:"pointer-events-none absolute right-3 top-10 z-20 max-w-[72%] rounded-lg bg-destructive/95 px-3 py-2 text-[11px] font-medium text-destructive-foreground shadow-md animate-fade-in",children:_l})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden bg-surface",children:[t.jsx(Ya,{active:ct,mounted:br,fallback:t.jsx(Mi,{slow:!1}),children:Qe?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:t.jsx(Rd,{items:Th,selectedKey:Kf,onSelect:qs,emptyText:o("rightSidebar.noChanges"),mobile:oe,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o("rightSidebar.recentCommitsTitle"),headerMeta:`${Qe.headRef??""}${Qe.commits?.[0]?` · ${Qe.commits[0]}`:""}`,onClose:()=>{Be(null),qs(null)},closeLabel:o("common.back"),wrap:gt,onToggleWrap:oe?Ma:void 0,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:oe?"stacked":"split",onInsertDiffReference:nn,onReferenceCopied:Lr,insertedReferenceKey:ke,copiedReferenceKey:_e,onClearAuditRecord:Ra})}):Rr?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:t.jsx(Rd,{items:ei,selectedKey:ko,onSelect:mn,emptyText:o(Oe?"rightSidebar.branchAuditDiffEmpty":"rightSidebar.branchAuditEmpty"),mobile:oe,backLabel:o("rightSidebar.backToChangeList"),headerTitle:o(Oe?"rightSidebar.branchAuditViewDiff":"rightSidebar.branchAuditTitle"),headerMeta:Ca?`${Ca.repoLabel} · ${Ca.branchName??"HEAD"} → ${Ca.baseRef}`:void 0,onClose:()=>{fr(!1),hr(null)},closeLabel:o("common.back"),wrap:gt,onToggleWrap:oe?Ma:void 0,wrapTitle:o("rightSidebar.wrapLongLines"),wrapOnLabel:o("rightSidebar.wrapOn"),wrapOffLabel:o("rightSidebar.wrapOff"),desktopLayout:oe?"stacked":"split",onInsertDiffReference:nn,onReferenceCopied:Lr,insertedReferenceKey:ke,copiedReferenceKey:_e,onClearAuditRecord:Ra,walkthroughs:Lh,onWalkthroughNavigate:$h,initialDetailScrollTop:Oe&&dt?Tn[dt]:void 0,onDetailScrollPositionChange:Uh,externalSwiperRef:oe?fa:void 0,onMobileSlideChange:oe?So:void 0})}):t.jsx("div",{className:"h-full overflow-y-auto overscroll-contain bg-surface pb-6",children:ld?t.jsx("div",{className:"px-3",children:ld}):Jr?t.jsx(Mi,{slow:Ql}):yn?t.jsx(Xa,{message:yn,onRetry:()=>{xs()}}):fu(Z)?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(b?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")}):Z?.available===!1?t.jsx(Xa,{message:Z.error??o("rightSidebar.gitChangesLoadFailed"),onRetry:()=>{xs()}}):b?t.jsx(Mi,{slow:Ql}):t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o(b?"rightSidebar.gitUnavailable":"fileTree.noWorkingDir")})})}),t.jsx(Ya,{active:Yn,children:oe?t.jsxs(yu,{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:n=>{Tr.current=n,n.slideTo(Tl,0)},onSlideChange:n=>{if(Ar(n.activeIndex),bs.current===n.activeIndex){bs.current=null;return}n.activeIndex===0&&(Mr(!1),wt(null),f?.())},children:[t.jsx(Bi,{className:"h-full min-h-0",children:t.jsxs("div",{ref:Wn,onScroll:cc,onDragOver:ma,onDragEnter:ma,onDragLeave:fc,onDrop:hc,className:"h-full overflow-auto overscroll-contain bg-surface relative",children:[Bl&&t.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:t.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:o("rightSidebar.dropToUpload")})}),!O.trim()&&dd,t.jsx(Sd,{rootPath:ye??"",onFileSelect:vs,onPathReference:rn,getReferenceText:ga,onReferenceCopied:Lr,insertedReferenceKey:ke,copiedReferenceKey:_e,onDirectoryRoot:wc,onSearchFromDirectory:kc,onDirectoryPinToggle:Sc,onFilePinToggle:jc,pinnedPaths:jn,selectedFilePath:it,query:de,searchRootPath:rc,searchOptions:nc,searchMode:T,onContentMatchSelect:dc,onDirectoryDropFiles:(n,l)=>ws(l,n),revealDirectory:Y,canOpenInFileBrowser:Ul,onOpenInFileBrowser:uc})]})}),t.jsx(Bi,{className:"h-full min-h-0",children:t.jsx("div",{className:"h-full overflow-hidden bg-surface",children:t.jsx(cl,{filePath:Yn&&(Yf||Tl===1)?it:null,onInsertReference:rn,onInsertText:$r,onInsertFeature:$r,onReviewReference:bc,onReferenceCopied:Lr,onClose:Jh,onDirectoryLinkOpen:cd,isMobile:!0,lineRange:dr,onLineRangeChange:wt,insertedReferenceKey:ke,copiedReferenceKey:_e,scrollToLine:ot,onScrollToLineHandled:()=>De(null),markdownOutlineOpen:F,markdownOutlineCloseSignal:B,onOpenMarkdownOutline:A,onCloseMarkdownOutline:E,markdownImageLightboxOpen:L,markdownImageLightboxCloseSignal:$,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:_})})})]}):t.jsxs("div",{className:"flex h-full min-h-0",children:[t.jsxs("div",{ref:Wn,onScroll:cc,onDragOver:ma,onDragEnter:ma,onDragLeave:fc,onDrop:hc,className:"shrink-0 overflow-auto overscroll-contain bg-surface relative",style:{width:Eo},children:[Bl&&t.jsx("div",{className:"pointer-events-none absolute left-3 right-3 top-3 z-10 flex justify-center",children:t.jsx("div",{className:"rounded-xl bg-surface-elevated px-4 py-2 text-sm font-semibold text-foreground shadow-lg",children:o("rightSidebar.dropToUpload")})}),!O.trim()&&dd,t.jsx(Sd,{rootPath:ye??"",onFileSelect:vs,onPathReference:rn,getReferenceText:ga,onReferenceCopied:Lr,insertedReferenceKey:ke,copiedReferenceKey:_e,onDirectoryRoot:wc,onSearchFromDirectory:kc,onDirectoryPinToggle:Sc,onFilePinToggle:jc,pinnedPaths:jn,selectedFilePath:it,query:de,searchRootPath:rc,searchOptions:nc,searchMode:T,onContentMatchSelect:dc,onDirectoryDropFiles:(n,l)=>ws(l,n),revealDirectory:Y,canOpenInFileBrowser:Ul,onOpenInFileBrowser:uc})]}),t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":o("rightSidebar.resizeFileTree"),title:o("rightSidebar.resizeFileTree"),"data-local-layer":"file-preview-separator",className:"group relative z-10 w-2 shrink-0 cursor-col-resize touch-none border-l border-border/15 bg-surface",onPointerDown:oh,onPointerMove:ih,onPointerUp:lc,onPointerCancel:lc,onDoubleClick:()=>{Mo(Ji),Dt(Ls,Ji)},children:t.jsx("span",{className:"absolute left-1/2 top-0 h-full w-px -translate-x-1/2 bg-border/20 transition group-hover:bg-primary/45"})}),t.jsx("div",{className:"min-w-0 flex-1 overflow-hidden bg-surface",children:t.jsx(cl,{filePath:Yn?it:null,onInsertReference:rn,onInsertText:$r,onInsertFeature:$r,onReviewReference:bc,onReferenceCopied:Lr,onDirectoryLinkOpen:cd,isMobile:!1,lineRange:dr,onLineRangeChange:wt,insertedReferenceKey:ke,copiedReferenceKey:_e,scrollToLine:ot,onScrollToLineHandled:()=>De(null),markdownOutlineOpen:F,markdownOutlineCloseSignal:B,onOpenMarkdownOutline:A,onCloseMarkdownOutline:E,markdownImageLightboxOpen:L,markdownImageLightboxCloseSignal:$,onOpenMarkdownImageLightbox:U,onCloseMarkdownImageLightbox:_})})]})}),t.jsx(Ya,{active:$t,mounted:Xf||$t,children:()=>Bo?t.jsx(ep,{}):oe?t.jsx(Ui,{mobile:!0,backLabel:o("rightSidebar.backToChangeList"),externalSwiperRef:fa,onMobileSlideChange:So,groups:nr.length>0?Hc():[],mode:Ee,onModeChange:Ea,selectedKey:it,scrollToKey:Vc,scrollToKeyNonce:sa.nonce,compact:!1,collapsedDirectoryKeys:ce,onToggleDirectory:Xc,onSelectFile:n=>{const l=Array.from(Ne.values()).find(u=>Nt(u)===n.key);l&&Na(Nt(l))},renderLeading:Gc,renderTrailing:n=>{const l=Array.from(Ne.values()).find(u=>Nt(u)===n.key);return l?Uc(l):null},renderDirectoryTrailing:zc,renderSubtitle:n=>{const l=Array.from(Ne.values()).find(u=>Nt(u)===n.key);return l?Oc(l):null},listContainerClassName:"termdock-native-select min-h-0 px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",renderListHeader:n=>b&&t.jsxs("div",{className:"px-0 py-0",children:[La&&t.jsx("div",{className:"mb-2",children:La}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:"min-w-0",children:t.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.allChanges")})}),t.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:[nr.length,"/",Ne.size]})]}),t.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[Dc(),ud,n,c&&Qo(),hd,fd]}),zt&&t.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:zt.label}),zt.branch&&t.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:zt.branch})]}),!zt&&Nn&&t.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[t.jsx(Ir,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),aiContent:va?(n=>Yc(n)):void 0,emptyContent:Bo?null:yn&&Ne.size===0?t.jsx(Xa,{message:yn,onRetry:()=>{xs()}}):Ne.size===0?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):nr.length===0?t.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderMobileDetailHeader:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>ys(0),className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:o("rightSidebar.backToChangeList"),children:[t.jsx(as,{size:14}),o("rightSidebar.backToChangeList")]}),t.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-1.5",children:[c&&Qo(),t.jsxs("button",{type:"button",onClick:Ma,"aria-pressed":gt,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 ${gt?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[t.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),t.jsx("span",{children:o(gt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]})]})]}),detailContainerClassName:"termdock-native-select termdock-diff-stream-scroller min-h-0",files:Wc(),activePane:$t,wrap:gt,diffViewType:rh,inlineMode:is,diffOptions:ed,reloadKey:kr,renderStreamBadge:n=>t.jsx(_s,{status:n}),onHunkGitAction:rd,onInsertDiffReference:nn,onReferenceCopied:Lr,insertedReferenceKey:ke,copiedReferenceKey:_e,onClearAuditRecord:Ra,onDetailScroll:Sa}):t.jsx(Ui,{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:nr.length>0?Hc():[],mode:Ee,onModeChange:Ea,selectedKey:it,scrollToKey:Vc,scrollToKeyNonce:sa.nonce,compact:!0,collapsedDirectoryKeys:ce,onToggleDirectory:Xc,onSelectFile:n=>{const l=Array.from(Ne.values()).find(u=>Nt(u)===n.key);l&&Na(Nt(l))},renderLeading:Gc,renderTrailing:n=>{const l=Array.from(Ne.values()).find(u=>Nt(u)===n.key);return l?Uc(l):null},renderDirectoryTrailing:zc,renderSubtitle:n=>{const l=Array.from(Ne.values()).find(u=>Nt(u)===n.key);return l?Oc(l):null},aiContent:va?(n=>Yc(n)):void 0,emptyContent:Bo?null:yn&&Ne.size===0?t.jsx(Xa,{message:yn,onRetry:()=>{xs()}}):Ne.size===0?t.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("rightSidebar.noChanges")}):nr.length===0?t.jsx("div",{className:"bg-surface-2 px-3 py-4 text-center text-xs text-muted-foreground",children:o("rightSidebar.noMatchingChanges")}):null,renderListHeader:n=>b&&t.jsxs("div",{className:"px-0 py-0",children:[La&&t.jsx("div",{className:"mb-2",children:La}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:o("rightSidebar.allChanges")}),t.jsx("div",{className:"flex items-center gap-1.5",children:t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[nr.length,"/",Ne.size]})})]}),t.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[Dc(),ud,n,Qo(),t.jsxs("button",{type:"button",onClick:Ma,"aria-pressed":gt,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 ${gt?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[t.jsx("span",{className:"font-mono text-[12px] leading-none",children:"Aa"}),t.jsx("span",{children:o(gt?"rightSidebar.wrapOn":"rightSidebar.wrapOff")})]}),hd,fd]}),zt&&t.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:zt.label}),zt.branch&&t.jsx("span",{className:"max-w-[7rem] truncate rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:zt.branch}),t.jsx("button",{type:"button",onClick:()=>Pa("stage-all",zt.root,zt.label),disabled:!!ze,className:"rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:o("rightSidebar.stageAll"),children:o("rightSidebar.stageAll")}),t.jsx("button",{type:"button",onClick:()=>Pa("stash-all",zt.root,zt.label),disabled:!!ze,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")})]}),!zt&&Nn&&t.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-md bg-surface-2 px-2 py-1.5 text-[11px] text-muted-foreground",children:[t.jsx(Ir,{size:12,className:"shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:o("rightSidebar.selectRepositoryForDiff")})]})]}),files:Wc(),activePane:$t,wrap:gt,diffViewType:Tt,inlineMode:is,diffOptions:ed,reloadKey:kr,renderStreamBadge:n=>t.jsx(_s,{status:n}),onHunkGitAction:rd,onInsertDiffReference:nn,onReferenceCopied:Lr,insertedReferenceKey:ke,copiedReferenceKey:_e,onClearAuditRecord:Ra,onDetailScroll:Sa})}),t.jsx(Ya,{active:Uo,mounted:Jf&&Yr,children:t.jsx(zg,{})})]}),e&&st&&t.jsx(mg,{value:ee,collapsed:Je,autoCollapseAfterSend:vt,focusRequest:Ue,insertError:Br?o("rightSidebar.contextDraftInsertFailed"):null,onChange:n=>{qt(!1),me(n)},onCollapsedChange:Ft,onAutoCollapseAfterSendChange:W,onDisable:()=>At(!1),onClear:()=>me(""),onInsert:()=>xc(!1),onInsertAndSend:()=>xc(!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:n=>o("rightSidebar.contextDraftCharacterCount",{count:n})}}),Sh(),Rt&&typeof document<"u"&&Fr.createPortal(t.jsx("div",{className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>Xr(null),children:t.jsxs("div",{className:"fixed inset-x-3 bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto max-w-md rounded-2xl border border-border/20 bg-surface-elevated p-4 shadow-2xl",onClick:n=>n.stopPropagation(),children:[t.jsx("div",{className:"text-sm font-semibold text-foreground",children:Rt.kind==="restore"?o("rightSidebar.confirmRestoreTitle"):o("rightSidebar.confirmStashAllTitle")}),t.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:Rt.kind==="restore"?o("rightSidebar.confirmRestoreDescription",{path:gu(Rt.file.absolutePath,b)}):o("rightSidebar.confirmStashAllDescription")}),Rt.kind==="restore"&&t.jsx("input",{value:Rt.phrase,onChange:n=>Xr({...Rt,phrase:n.target.value}),placeholder:o("rightSidebar.confirmRestorePlaceholder"),className:"mt-3 w-full rounded-xl border border-border/20 bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground",autoFocus:!0}),t.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:()=>Xr(null),className:"rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:o("common.cancel")}),t.jsx("button",{type:"button",disabled:!!ze||Rt.kind==="restore"&&Rt.phrase.trim()!==o("rightSidebar.confirmRestorePhrase"),onClick:()=>{if(Rt.kind==="restore"){const n=jt(Rt.file,b);if(!n)return;St({action:"restore-worktree-file",cwd:n,paths:[Rt.file.path],confirm:{acknowledged:!0,phrase:Rt.phrase}},o("rightSidebar.restoreFile"),Li(Rt.file))}else{const n=Rt.repoRoot??b;if(!n)return;St({action:"stash-all",cwd:n},o("rightSidebar.stashAll"),`repo:${n}`)}},className:`rounded-full px-3 py-1.5 text-xs font-semibold disabled:opacity-50 ${Rt.kind==="restore"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:o(ze?"rightSidebar.gitActionRunning":"rightSidebar.confirmAction")})]})]})}),document.body)]})}const v0=Object.freeze(Object.defineProperty({__proto__:null,FilePreview:cl,MarkdownImageLightbox:If,MarkdownPreview:_f,RightSidebar:l0,__testParseMarkdownListBlock:Rx,buildMarkdownPreviewBlocks:_x,buildMarkdownPreviewRenderResult:Sl,collectKnownGitRepoRoots:af,computeMarkdownImageDisplayBox:xf,getMarkdownHeadingOutline:$f,getMarkdownHeadingPathAtLine:Lf,getNextMarkdownPreviewLineRange:zx,isSvgImageSrc:po,mountRightSidebarRepoPickerOverlay:Wu,replaceGitRepositorySnapshot:zf,resolveMarkdownLocalLinkTarget:bl,resolveRightSidebarDiffViewType:rf,shouldCloseMarkdownImageLightboxDrag:Af,showsGitRepoGroupHeader:Qi},Symbol.toStringTag,{value:"Module"}));export{zi as E,Wi as H,wp as M,v0 as R,mp as a,Sp as b,Gp as c,y0 as m};