@opentig/cli 0.2.3 → 0.2.4

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 (174) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +14 -14
  3. package/dist/bin.mjs +25 -10
  4. package/dist/chunks/{cli-L6lvCZdX.mjs → cli-gyjD1t0O.mjs} +611 -268
  5. package/dist/chunks/network-settings-CdFeKFRB.mjs +142 -0
  6. package/dist/chunks/{server-Cz0gvydn.mjs → server-DMk8-Xxt.mjs} +557 -105
  7. package/dist/chunks/{service-manager-Jyx-MWo-.mjs → service-manager-BxSmV_8Z.mjs} +88 -14
  8. package/dist/client/assets/App-Bfw_TX8q.js +132 -0
  9. package/dist/client/assets/CreatePullRequestDialog-DyPd6SKH.js +2 -0
  10. package/dist/client/assets/DiffWorkspace-DCo89dF1.js +7 -0
  11. package/dist/client/assets/EditableFileViewer-Dotntfij.js +1 -0
  12. package/dist/client/assets/EditableFileViewer-svutjHZv.css +1 -0
  13. package/dist/client/assets/ExternalLink-jdtpN_yL.js +1 -0
  14. package/dist/client/assets/{File-BPxtFxHC.js → File-DHnVtIhS.js} +1 -1
  15. package/dist/client/assets/FilesView-D6f1hPVy.js +1 -0
  16. package/dist/client/assets/GitHubAvatar-B6vyoVlh.js +1 -0
  17. package/dist/client/assets/HistoryView-D9RhzCPY.js +1 -0
  18. package/dist/client/assets/HtmlFileViewer-Bwmj5umg.js +2 -0
  19. package/dist/client/assets/{IconAlertTriangle-C1OX2bTH.js → IconAlertTriangle-B9iDJKvP.js} +1 -1
  20. package/dist/client/assets/IconCheck-C-G-IA13.js +1 -0
  21. package/dist/client/assets/IconChevronDown-DU5i40lD.js +1 -0
  22. package/dist/client/assets/{IconEdit-BP5Emwzw.js → IconEdit-CZe-EJxX.js} +1 -1
  23. package/dist/client/assets/{IconFolderSymlink-BNWI0eXB.js → IconFolderSymlink-DkLEuUb6.js} +1 -1
  24. package/dist/client/assets/IconGitMerge-D9KEj1cE.js +1 -0
  25. package/dist/client/assets/IconGitPullRequest-ClaUqyVa.js +1 -0
  26. package/dist/client/assets/{IconLoader4-Bk6G4Bls.js → IconLoader4-D2VN7u1V.js} +1 -1
  27. package/dist/client/assets/{IconPlus-DUFNSK_i.js → IconPlus-DJCoD3wt.js} +1 -1
  28. package/dist/client/assets/{IconSearch-ZL3YVslZ.js → IconSearch-1VQ4P4kW.js} +1 -1
  29. package/dist/client/assets/{IconSelector-BGwY84R8.js → IconSelector-BVMU1PEt.js} +1 -1
  30. package/dist/client/assets/ImageFileViewer-3izbFVTw.css +1 -0
  31. package/dist/client/assets/ImageFileViewer-CdFLl_in.js +1 -0
  32. package/dist/client/assets/LinkedMarkdown-Bnc2OA63.js +1 -0
  33. package/dist/client/assets/LinkedText-BD6K3d1t.js +1 -0
  34. package/dist/client/assets/LocalRefsDialog-Bl-fddap.js +1 -0
  35. package/dist/client/assets/MarkdownFileViewer-NUAoQmv5.js +2 -0
  36. package/dist/client/assets/PairingPage-CqrxpC3_.js +1 -0
  37. package/dist/client/assets/PierreDiffViewer-CDfQ32e0.js +1 -0
  38. package/dist/client/assets/{PierreEditBoundary-Bt0q7SXc.js → PierreEditBoundary-DAdYNYZ3.js} +1 -1
  39. package/dist/client/assets/{PierreWorkerPool-DMFigp0u.js → PierreWorkerPool-mIDzTMB9.js} +3 -3
  40. package/dist/client/assets/PullRequestDiff-n1NZFHKN.js +1 -0
  41. package/dist/client/assets/PullRequestViewer-u89zl169.js +2 -0
  42. package/dist/client/assets/PullRequestsView-D6BqvB4E.js +1 -0
  43. package/dist/client/assets/QuickOpenDialog-BbEifGRi.js +1 -0
  44. package/dist/client/assets/RepositoryProjectsDialog-EGAsXL-Z.js +1 -0
  45. package/dist/client/assets/{SearchView-BYz1K1Ta.js → SearchView-BMz7qOdc.js} +1 -1
  46. package/dist/client/assets/SettingsDialog-DmD7HvhX.js +9 -0
  47. package/dist/client/assets/Viewer-CDj_vo6w.js +3 -0
  48. package/dist/client/assets/{abnfDiagram-YUKMZFIV-CpKAN_8n.js → abnfDiagram-YUKMZFIV-It6tW-4v.js} +1 -1
  49. package/dist/client/assets/{architecture-WOLXFQ4H-DrizVopY.js → architecture-WOLXFQ4H-CaOaChND.js} +1 -1
  50. package/dist/client/assets/{architectureDiagram-47P4ROYG-gvUijB3H.js → architectureDiagram-47P4ROYG-COtncecA.js} +1 -1
  51. package/dist/client/assets/{blockDiagram-E7TT5TSB-CdcXmnf_.js → blockDiagram-E7TT5TSB-NU4wFrfP.js} +1 -1
  52. package/dist/client/assets/{c4Diagram-CRA5TL53-DtoD1jKt.js → c4Diagram-CRA5TL53-0xzM4S8q.js} +1 -1
  53. package/dist/client/assets/channel-QED-4ACa.js +1 -0
  54. package/dist/client/assets/checkbox-Dh4T0bCe.js +1 -0
  55. package/dist/client/assets/{chunk-2BW5OAIV-Bxqf2dFQ.js → chunk-2BW5OAIV-BQMxlSNI.js} +1 -1
  56. package/dist/client/assets/{chunk-3YJQHVM4-BhzXJiq0.js → chunk-3YJQHVM4-CdP15KtA.js} +1 -1
  57. package/dist/client/assets/{chunk-4EA7E6EY-CvEILf8c.js → chunk-4EA7E6EY-xRPCCZLU.js} +1 -1
  58. package/dist/client/assets/{chunk-7TKQ45FW-pTEdzVz3.js → chunk-7TKQ45FW-Cr_UAObV.js} +1 -1
  59. package/dist/client/assets/{chunk-AW2ZBBNX-LVROkcXk.js → chunk-AW2ZBBNX-DBqqxF2h.js} +1 -1
  60. package/dist/client/assets/{chunk-DBDB3WZW-FCGrB-q8.js → chunk-DBDB3WZW-BonEIRP2.js} +1 -1
  61. package/dist/client/assets/{chunk-E2ZNV5FY-B3rGXPn-.js → chunk-E2ZNV5FY-DnKvxSiA.js} +1 -1
  62. package/dist/client/assets/{chunk-EU5HNXII-D6a_Ly_W.js → chunk-EU5HNXII-DLK0K3sR.js} +1 -1
  63. package/dist/client/assets/{chunk-FVRAUYC3-B5hy0Ket.js → chunk-FVRAUYC3-DmjKoYAh.js} +1 -1
  64. package/dist/client/assets/{chunk-HJ2JQQFS-CKHFz1Wl.js → chunk-HJ2JQQFS-AF4phse0.js} +1 -1
  65. package/dist/client/assets/{chunk-HTAEGDNF-CtwDuO27.js → chunk-HTAEGDNF-CG4pBnUZ.js} +1 -1
  66. package/dist/client/assets/{chunk-KQW6MTUR-BN3uxLYf.js → chunk-KQW6MTUR-Dd87yj5r.js} +1 -1
  67. package/dist/client/assets/{chunk-NTY3LDVX-CfXSvyIC.js → chunk-NTY3LDVX-OolU2PaP.js} +1 -1
  68. package/dist/client/assets/{chunk-VPRB5NB3-LAggcSji.js → chunk-VPRB5NB3-Dnr3edxV.js} +3 -3
  69. package/dist/client/assets/{chunk-XC4XBNZT-BksIPWQU.js → chunk-XC4XBNZT-CIqGRxkD.js} +1 -1
  70. package/dist/client/assets/{classDiagram-v2-K4WV4PDN-DH78Maqm.js → classDiagram-v2-K4WV4PDN-CPGawm8n.js} +1 -1
  71. package/dist/client/assets/createReactComponent-Ctub7J3a.js +1 -0
  72. package/dist/client/assets/{cynefin-EF2NZ3EQ-DozKlDV1.js → cynefin-EF2NZ3EQ-OA2R9WCH.js} +1 -1
  73. package/dist/client/assets/{cynefinDiagram-3GCD6N5R-A1yS7NKN.js → cynefinDiagram-3GCD6N5R-DqCVtoKt.js} +1 -1
  74. package/dist/client/assets/{dagre-W4DXFKR2-DRJ1mmbe.js → dagre-W4DXFKR2-kc3-tkAQ.js} +1 -1
  75. package/dist/client/assets/{diagram-2UJZ2QOL-B1sI2b2o.js → diagram-2UJZ2QOL-DoBZKT3s.js} +1 -1
  76. package/dist/client/assets/{diagram-OVF4WLC6-DLE1o4-P.js → diagram-OVF4WLC6-DGkyha_F.js} +1 -1
  77. package/dist/client/assets/{diagram-PFPMY2P6-UtIEsv14.js → diagram-PFPMY2P6-DpRDDgdV.js} +1 -1
  78. package/dist/client/assets/{diagram-UMYRVEAY-BwTyzVap.js → diagram-UMYRVEAY-DlsfhYv3.js} +1 -1
  79. package/dist/client/assets/{diagram-YEKJPTXX-DNPUQqu0.js → diagram-YEKJPTXX-BIhRZzBM.js} +1 -1
  80. package/dist/client/assets/{diagram-ZIFT7M5P-ClXykQ3I.js → diagram-ZIFT7M5P-mweJcgBZ.js} +1 -1
  81. package/dist/client/assets/diff-parse.worker-C1IFRYY9.js +13 -0
  82. package/dist/client/assets/{ebnfDiagram-VR2GEFS7-Dm8VAviu.js → ebnfDiagram-VR2GEFS7-Dn5zyIbZ.js} +1 -1
  83. package/dist/client/assets/{elk-IJKZMXRS-CEEoPARn.js → elk-IJKZMXRS-eBPlf1-o.js} +1 -1
  84. package/dist/client/assets/{erDiagram-O2IAPWRE-CaDE4obX.js → erDiagram-O2IAPWRE-WEE519yZ.js} +1 -1
  85. package/dist/client/assets/{eventmodeling-K75KTNOO-PjYgMkPC.js → eventmodeling-K75KTNOO-BgE_VmNy.js} +1 -1
  86. package/dist/client/assets/external-url-IUS7RmYD.js +1 -0
  87. package/dist/client/assets/flowDiagram-OXPTDLAJ-CHQYfkMg.js +1 -0
  88. package/dist/client/assets/{ganttDiagram-R7TSEDQI-CmkBarBi.js → ganttDiagram-R7TSEDQI-D_1KyJZU.js} +1 -1
  89. package/dist/client/assets/{gitGraph-VSP46ZUC-DeotTdHj.js → gitGraph-VSP46ZUC-CEbT7DA4.js} +1 -1
  90. package/dist/client/assets/{gitGraphDiagram-XJZIOB7I-uV1hPaZT.js → gitGraphDiagram-XJZIOB7I-QQyYc1gM.js} +1 -1
  91. package/dist/client/assets/index-DsKvWsTs.js +47 -0
  92. package/dist/client/assets/index-kyWCnbkb.css +2 -0
  93. package/dist/client/assets/{info-OHQRW6UA-BQDsGvSl.js → info-OHQRW6UA-ChHAnveo.js} +1 -1
  94. package/dist/client/assets/{infoDiagram-5W2HQ5XZ-CDfEPsgZ.js → infoDiagram-5W2HQ5XZ-BaxAE7UA.js} +1 -1
  95. package/dist/client/assets/{ishikawaDiagram-K3B6WC7H-Bb7PQGe6.js → ishikawaDiagram-K3B6WC7H-vhUflBE_.js} +1 -1
  96. package/dist/client/assets/{journeyDiagram-COXZFDF6-BDythglw.js → journeyDiagram-COXZFDF6-C8WWosVa.js} +1 -1
  97. package/dist/client/assets/{kanban-definition-P3RFRI5V-CvY5kXhh.js → kanban-definition-P3RFRI5V-CU6W9Yi3.js} +1 -1
  98. package/dist/client/assets/katex-CQfTPFh0.js +1 -0
  99. package/dist/client/assets/{line-99p2yFnB.js → line-Axq4vVX-.js} +1 -1
  100. package/dist/client/assets/{mermaid-parser.core-BjZYtoJ8.js → mermaid-parser.core-DNeaCX12.js} +3 -3
  101. package/dist/client/assets/{mermaid.core-DRcXnUox.js → mermaid.core-Dtt7rXw0.js} +4 -4
  102. package/dist/client/assets/{mindmap-definition-LZFPQGKD-t9LoCpnW.js → mindmap-definition-LZFPQGKD-D_8ZqQot.js} +1 -1
  103. package/dist/client/assets/{packet-JDAUHWVQ-BlR-5V7K.js → packet-JDAUHWVQ-6z7ujmGF.js} +1 -1
  104. package/dist/client/assets/{pegDiagram-BGZESJAR-CWeGI-T9.js → pegDiagram-BGZESJAR-3ujyk-bt.js} +1 -1
  105. package/dist/client/assets/{pie-XZMESJXO-BkvYHWgl.js → pie-XZMESJXO-DvpLy2DB.js} +1 -1
  106. package/dist/client/assets/{pieDiagram-CAPJLFHJ-CY5PPIr3.js → pieDiagram-CAPJLFHJ-BPMPWyc7.js} +1 -1
  107. package/dist/client/assets/{quadrantDiagram-GDMTTRAM-kqj-z271.js → quadrantDiagram-GDMTTRAM-BVUCR_lf.js} +1 -1
  108. package/dist/client/assets/{radar-ABXABTNO-DuEtYatv.js → radar-ABXABTNO-lu14X99R.js} +1 -1
  109. package/dist/client/assets/{railroad-I3PHUGI6-CVlnj2j9.js → railroad-I3PHUGI6-DI_WtDmt.js} +1 -1
  110. package/dist/client/assets/{railroad-abnf-LNEFI6M7-9Qiczw4d.js → railroad-abnf-LNEFI6M7-CmWAKZ2T.js} +1 -1
  111. package/dist/client/assets/{railroad-ebnf-DWYD2UWJ-BNL7TMEg.js → railroad-ebnf-DWYD2UWJ-BWKFU_UH.js} +1 -1
  112. package/dist/client/assets/{railroad-peg-JR7BVNR7-DdpRxgk6.js → railroad-peg-JR7BVNR7-9wkgzxMB.js} +1 -1
  113. package/dist/client/assets/{railroadDiagram-SM67HX2B-CDXvYNqW.js → railroadDiagram-SM67HX2B-4JnRbxl_.js} +1 -1
  114. package/dist/client/assets/{render-markdown-DF9Fy7MD.js → render-markdown-CQi2yKYQ.js} +2 -2
  115. package/dist/client/assets/{requirementDiagram-X7JNWC4A-BDdhqnZA.js → requirementDiagram-X7JNWC4A-CVJiZZsi.js} +1 -1
  116. package/dist/client/assets/{sankeyDiagram-UM26HJRW-Rkyk5oEf.js → sankeyDiagram-UM26HJRW-BmlWQdkv.js} +1 -1
  117. package/dist/client/assets/select-Dq3KDX2O.js +1 -0
  118. package/dist/client/assets/{sequenceDiagram-ZO4K6R2Y-Coj9ap7h.js → sequenceDiagram-ZO4K6R2Y-zUx3LmPj.js} +1 -1
  119. package/dist/client/assets/{stateDiagram-v2-TBUQTH76-BucWlahR.js → stateDiagram-v2-TBUQTH76-o_ci-2bu.js} +1 -1
  120. package/dist/client/assets/{swimlanes-N4OXWK64-tEECcFP9.js → swimlanes-N4OXWK64-BlI0GC5-.js} +1 -1
  121. package/dist/client/assets/swimlanesDiagram-K3J5GTZL-BEeJLN8d.js +8 -0
  122. package/dist/client/assets/tanstack-CVAt_k_T.js +1 -0
  123. package/dist/client/assets/{timeline-definition-YOQAKGHF-XvIbGO4d.js → timeline-definition-YOQAKGHF-DLnvF__o.js} +1 -1
  124. package/dist/client/assets/{treeView-D4JQ5SDB-DuhJpfXe.js → treeView-D4JQ5SDB-DPuMLQhB.js} +1 -1
  125. package/dist/client/assets/{treemap-SAJKECNS-CLiUWfZh.js → treemap-SAJKECNS-DjxqxJ8-.js} +1 -1
  126. package/dist/client/assets/{usecaseDiagram-VIAY4XPW-BuwkpV9w.js → usecaseDiagram-VIAY4XPW-BtnFNltN.js} +1 -1
  127. package/dist/client/assets/utils-D0T3A-kS.js +1 -0
  128. package/dist/client/assets/{vennDiagram-BLWOH2XV-kfza5Rxq.js → vennDiagram-BLWOH2XV-CAiF2FKz.js} +1 -1
  129. package/dist/client/assets/viewer-tabs-DkkqN9MD.js +1 -0
  130. package/dist/client/assets/{wardley-7MLQ67FV-CcbU_Ykg.js → wardley-7MLQ67FV-DAWySamq.js} +1 -1
  131. package/dist/client/assets/{wardleyDiagram-YMQ3BMBF-DnxlEg3a.js → wardleyDiagram-YMQ3BMBF-DiBCclEL.js} +1 -1
  132. package/dist/client/assets/{xychartDiagram-TAQBALBS-BzgtwtvK.js → xychartDiagram-TAQBALBS-B0NgfXz6.js} +1 -1
  133. package/dist/client/index.html +6 -4
  134. package/dist/dev.mjs +6 -6
  135. package/dist/manifest.json +1 -1
  136. package/dist/server.mjs +1 -1
  137. package/dist/service-update.mjs +11 -3
  138. package/dist/utility.mjs +25 -4
  139. package/package.json +4 -4
  140. package/dist/client/assets/App-DEIZhWJG.js +0 -132
  141. package/dist/client/assets/CreatePullRequestDialog-BceOUbYK.js +0 -2
  142. package/dist/client/assets/DiffWorkspace-BMtV4MMc.js +0 -6
  143. package/dist/client/assets/EditableFileViewer-B44TSuFu.css +0 -1
  144. package/dist/client/assets/EditableFileViewer-BE3AsnVa.js +0 -1
  145. package/dist/client/assets/FilesView-DoVhRfi1.js +0 -1
  146. package/dist/client/assets/GitHubAvatar-RiePq1Yf.js +0 -1
  147. package/dist/client/assets/HistoryView-Dl8uqmKe.js +0 -1
  148. package/dist/client/assets/HtmlFileViewer-xfjY1Swc.js +0 -2
  149. package/dist/client/assets/IconCheck-BPhxw_LS.js +0 -1
  150. package/dist/client/assets/IconChevronDown-C3FplJL8.js +0 -1
  151. package/dist/client/assets/ImageFileViewer-BJBOmpsf.css +0 -1
  152. package/dist/client/assets/ImageFileViewer-DXaIo7_d.js +0 -1
  153. package/dist/client/assets/LocalRefsDialog-C5J3kgTe.js +0 -1
  154. package/dist/client/assets/MarkdownFileViewer-18mvm0f2.js +0 -2
  155. package/dist/client/assets/PairingPage-BEUj3t0V.js +0 -1
  156. package/dist/client/assets/PierreDiffViewer-p29h7lW_.js +0 -1
  157. package/dist/client/assets/PullRequestDiff-C17JA4ko.js +0 -1
  158. package/dist/client/assets/PullRequestViewer-DaMtkESD.js +0 -2
  159. package/dist/client/assets/PullRequestsView-44f03VLC.js +0 -1
  160. package/dist/client/assets/QuickOpenDialog-Bi-L68PU.js +0 -1
  161. package/dist/client/assets/RepositoryProjectsDialog-DFGn74fe.js +0 -1
  162. package/dist/client/assets/SettingsDialog-CruoIiyN.js +0 -9
  163. package/dist/client/assets/Viewer-3WKpwRzo.js +0 -3
  164. package/dist/client/assets/channel-BqKQxg-1.js +0 -1
  165. package/dist/client/assets/checkbox-MDl2t9_3.js +0 -1
  166. package/dist/client/assets/createReactComponent-BfrD_oQK.js +0 -1
  167. package/dist/client/assets/flowDiagram-OXPTDLAJ-DSokwYKA.js +0 -1
  168. package/dist/client/assets/index-CoZCJqTQ.js +0 -47
  169. package/dist/client/assets/index-DUERTTRS.css +0 -2
  170. package/dist/client/assets/katex-C6e6EqXB.js +0 -1
  171. package/dist/client/assets/select-pZpCy7qn.js +0 -1
  172. package/dist/client/assets/swimlanesDiagram-K3J5GTZL-DEFKR6Vf.js +0 -8
  173. package/dist/client/assets/tanstack-CYi5knVJ.js +0 -1
  174. package/dist/client/assets/viewer-tabs-MMNrJqGE.js +0 -1
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/render-markdown-DF9Fy7MD.js","assets/index-CoZCJqTQ.js","assets/rolldown-runtime-C0FnF6B9.js","assets/base-ui-DDpgJXgO.js","assets/react-BlQ_XOQu.js","assets/tanstack-CYi5knVJ.js","assets/createReactComponent-BfrD_oQK.js","assets/index-DUERTTRS.css","assets/string-TLTPtCPs-SBynuHAV.js","assets/dist-B8XHAue7.js","assets/App-DEIZhWJG.js","assets/IconAlertTriangle-C1OX2bTH.js","assets/IconPlus-DUFNSK_i.js","assets/IconCheck-BPhxw_LS.js","assets/select-pZpCy7qn.js","assets/IconChevronDown-C3FplJL8.js","assets/IconSelector-BGwY84R8.js","assets/IconLoader4-Bk6G4Bls.js","assets/IconSearch-ZL3YVslZ.js","assets/shortcuts-BzIlT01I.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Ct as t,xt as n}from"./base-ui-DDpgJXgO.js";import{t as r}from"./createReactComponent-BfrD_oQK.js";import{t as i}from"./IconLoader4-Bk6G4Bls.js";import{A as a,O as o,T as s,l as c,t as l}from"./index-CoZCJqTQ.js";import{Dt as ee,Ft as u,Ht as d,Ot as te,Tt as ne,g as re,h as f,kt as p,m,o as ie,s as ae,wt as oe,yt as se,zt as h}from"./App-DEIZhWJG.js";import{n as ce,r as g,t as le}from"./viewer-tabs-MMNrJqGE.js";/* empty css */import{t as ue}from"./checkbox-MDl2t9_3.js";var _=r(`outline`,`upload`,`Upload`,[[`path`,{d:`M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2`,key:`svg-0`}],[`path`,{d:`M7 9l5 -5l5 5`,key:`svg-1`}],[`path`,{d:`M12 4l0 12`,key:`svg-2`}]]),v=n();function de({coverage:e,stale:t}){let n=e.files.filter(e=>e.detail===`partial`),r=e.files.filter(e=>e.detail===`inventory-only`),i=e.files.length-n.length-r.length,a=e.files.filter(e=>e.detail!==`complete`),o=e.commitsIncluded<e.commitsTotal,s=a.length>0||o||e.summaryTruncated;return(0,v.jsxs)(`section`,{className:`pr-context-coverage`,"data-warning":t||s||void 0,"aria-label":`Draft context coverage`,children:[(0,v.jsxs)(`div`,{role:`status`,children:[(0,v.jsx)(`strong`,{children:t?`Draft context is outdated`:s?`Partial draft context`:e.contextLines===1?`Compact diff, all changes included`:`All changes included`}),(0,v.jsx)(`p`,{children:t?`The repository, branch, base or commit changed. Regenerate the draft or review it manually against the new comparison.`:`This describes the input supplied to the AI. Review the draft before publishing.`})]}),(0,v.jsxs)(`p`,{children:[e.files.length,` files inventoried · `,i,` complete · `,n.length,` partial · `,r.length,` inventory only`]}),(0,v.jsxs)(`p`,{children:[e.commitsIncluded,` of `,e.commitsTotal,` commit subjects included · `,e.summaryTruncated?`Summary shortened`:`Summary complete`]}),(0,v.jsxs)(`details`,{children:[(0,v.jsx)(`summary`,{children:a.length>0||o||e.summaryTruncated?`Review omitted information`:`Context details`}),(0,v.jsxs)(`div`,{className:`pr-context-details`,children:[o&&(0,v.jsxs)(`p`,{children:[e.commitsTotal-e.commitsIncluded,` commit subjects omitted. This does not mean those changes are missing from the final diff.`]}),e.summaryTruncated&&(0,v.jsx)(`p`,{children:`The display summary was shortened. The separate file inventory remains complete.`}),a.map(e=>(0,v.jsxs)(`div`,{className:`pr-context-file`,children:[(0,v.jsx)(`code`,{children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),(0,v.jsxs)(`span`,{children:[e.detail===`inventory-only`?`Inventory only`:`Partial detail`,` · `,e.omittedChangedLines,` changed lines omitted · `,e.omittedHunks,` hunks incomplete or omitted`]})]},e.path)),(0,v.jsx)(`p`,{children:`Binary entries describe metadata, not binary contents. Reduced context keeps fewer surrounding lines.`}),(0,v.jsxs)(`p`,{children:[e.contextLines,` context `,e.contextLines===1?`line`:`lines`,` · `,e.suppliedPatchCharacters.toLocaleString(),` patch characters · `,e.promptCharacters.toLocaleString(),` / `,e.promptCharacterLimit.toLocaleString(),` prompt characters. Character counts are not token counts.`]}),(0,v.jsxs)(`p`,{children:[`Compared head `,(0,v.jsx)(`code`,{children:e.headOid.slice(0,12)}),` with base `,(0,v.jsx)(`code`,{children:e.baseOid.slice(0,12)}),`, from merge-base `,(0,v.jsx)(`code`,{children:e.mergeBaseOid.slice(0,12)}),`.`]})]})]})]})}var y=e(t());function b(e){let t=se(e.open?e.repositoryId:null),n=t.data,[r,b]=(0,y.useState)(``),[O,k]=(0,y.useState)(null),[A,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(``),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(`edit`),[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)(!1),[H,U]=(0,y.useState)(null),W=(0,y.useRef)(null),G=(0,y.useRef)(0),K=e.status?.branch??null,q=e.preferences.commitMessageHarness,J=e.preferences.commitMessageModels[q]??`default`,fe=w(e.aiProviders,q,J),Y=(0,y.useMemo)(()=>e.branches.filter(e=>e.remote&&!e.fullName.endsWith(`/HEAD`)&&e.name!==`origin/${K??``}`).map(e=>e.name),[K,e.branches]);(0,y.useEffect)(()=>{e.open&&N(e=>e&&Y.includes(e)?e:x(Y))},[Y,e.open]),(0,y.useEffect)(()=>{if(!e.open||I!==`preview`)return;let t=++G.current;l(async()=>{let{renderMarkdown:e}=await import(`./render-markdown-DF9Fy7MD.js`);return{renderMarkdown:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])).then(({renderMarkdown:e})=>e(A||`_No description._`)).then(e=>{t===G.current&&z(e)}).catch(()=>{t===G.current&&z(`<p>Could not render the preview.</p>`)})},[A,I,e.open]);let pe=e.branches.find(e=>e.name===M)?.oid;(0,y.useEffect)(()=>()=>{let e=W.current;W.current=null,U(null),e&&c.github.cancelDraft(e).catch(()=>void 0)},[e.repositoryId,e.open,K,e.status?.oid,M,pe]);let X=e.status!==null&&!e.status.upstream,Z=e.status!==null&&!!e.status.upstream&&e.status.ahead>0,Q=e.status!==null&&(e.status.detached||e.status.unborn||!e.status.branch),$=e.status===null||X||Z||Q||Y.length===0,me=async()=>{let e=W.current;e&&await c.github.cancelDraft(e).catch(()=>void 0)},he=async()=>{if($||H||B||!M)return;let t=crypto.randomUUID();W.current=t,U(t);try{let n=await c.github.generateDraft({repositoryId:e.repositoryId,base:M,harness:q,model:J,requestId:t});if(W.current!==t)return;b(n.title),j(n.body),k(n.coverage??null),L(`edit`),a.success({title:`Draft generated with ${C(n.harness)}`,description:n.contextWasTruncated?`Some context was omitted. Review the coverage details before publishing.`:`Review and edit before publishing.`})}catch(e){if(W.current!==t)return;let n=T(e);n?.code===`AI_CANCELLED`?a.info({title:`Generation canceled`}):a.error({title:`Could not generate the draft`,description:n?.message??E(e),duration:1e4})}finally{W.current===t&&(W.current=null),U(e=>e===t?null:e)}},ge=async()=>{if(!$&&!B&&!H&&r.trim()&&M&&n?.state===`ready`&&n.login){V(!0);try{let t=await c.github.createPullRequest({repositoryId:e.repositoryId,title:r.trim(),body:A,base:M,draft:P,expectedAccount:{login:n.login,revision:n.revision}});b(``),j(``),F(!1),k(null),a.success({title:P?`Draft pull request created`:`Pull request created`,description:t.url,button:{title:`Open`,onClick:()=>re(t.url)}}),e.onCreated(t.number)}catch(e){let n=m(e);n?.code===`GH_ACCOUNT_UNRESOLVED`&&t.refetch(),a.error({title:f(n),description:n?.message??E(e),duration:1e4})}finally{V(!1)}}};return(0,v.jsx)(ne,{open:e.open,onOpenChange:t=>{B||e.onOpenChange(t)},children:(0,v.jsxs)(te,{className:`create-pr-dialog`,children:[(0,v.jsxs)(`div`,{className:`create-pr-content`,children:[(0,v.jsxs)(p,{children:[(0,v.jsx)(h,{"aria-hidden":`true`}),` Create pull request`]}),(0,v.jsx)(ee,{children:K?(0,v.jsxs)(v.Fragment,{children:[`From `,(0,v.jsx)(`code`,{children:K}),` into the selected base branch on GitHub.`]}):`Check out a branch to create a pull request.`}),(0,v.jsxs)(`div`,{className:`github-operation-account`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`strong`,{children:n?.state===`ready`?`Publish as @${n.login}`:t.isFetching?(0,v.jsx)(o,{text:`Checking GitHub identity…`}):`GitHub account needs attention`}),(0,v.jsxs)(`small`,{children:[n?.message??(n?.source===`ssh`?`Automatic · identity verified through SSH`:n?.source===`environment`?`Credentials from the backend environment`:n?.source===`explicit`?`Chosen for this repository`:`Active GitHub CLI credentials`),t.error?` · Could not check the account.`:``]})]}),(0,v.jsx)(s,{variant:`ghost`,size:`sm`,onClick:e.onOpenGitHubSettings,disabled:B,children:`Change`})]}),X&&(0,v.jsxs)(`div`,{className:`create-pr-notice`,children:[(0,v.jsx)(`span`,{children:Q?`Check out a branch with at least one commit before publishing.`:`Publish this branch before creating a pull request.`}),(0,v.jsxs)(s,{variant:`outline`,size:`xs`,disabled:e.pushBusy||Q||!!e.status?.readOnly,onClick:e.onPush,children:[e.pushBusy?(0,v.jsx)(i,{className:`animate-spin`}):(0,v.jsx)(_,{}),` Publish branch`]})]}),Z&&(0,v.jsxs)(`div`,{className:`create-pr-notice`,children:[(0,v.jsxs)(`span`,{children:[`The branch has `,e.status?.ahead,` unpushed `,e.status?.ahead===1?`commit`:`commits`,`. Push them so the pull request includes your work.`]}),(0,v.jsxs)(s,{variant:`outline`,size:`xs`,disabled:e.pushBusy,onClick:e.onPush,children:[e.pushBusy?(0,v.jsx)(i,{className:`animate-spin`}):(0,v.jsx)(_,{}),` Push`]})]}),!X&&!Z&&Q&&(0,v.jsx)(`div`,{className:`create-pr-notice`,children:(0,v.jsx)(`span`,{children:`Pull requests need a checked-out branch with commits.`})}),Y.length===0&&!Q&&(0,v.jsx)(`div`,{className:`create-pr-notice`,children:(0,v.jsx)(`span`,{children:`No remote branches are available to use as a base. Fetch the remote first.`})}),(0,v.jsxs)(`div`,{className:`create-pr-base-row`,children:[(0,v.jsxs)(`div`,{className:`create-pr-field`,children:[(0,v.jsx)(`label`,{htmlFor:`create-pr-base`,children:`Base branch`}),(0,v.jsx)(oe,{groups:[{id:`branches`,label:``,items:Y.map(e=>({value:e,label:S(e),search:e,icon:(0,v.jsx)(d,{})}))}],value:M,onValueChange:N,label:`Base branch`,triggerId:`create-pr-base`,triggerLabel:M?S(M):`Select a base`,triggerClassName:`create-pr-base`,size:`default`,align:`start`,placeholder:`Search base branches…`,disabled:$||B||!!H})]}),(0,v.jsxs)(`label`,{className:`create-pr-draft`,children:[(0,v.jsx)(ue,{checked:P,onCheckedChange:e=>F(e===!0),disabled:$||B||!!H}),(0,v.jsx)(`span`,{children:`Create as draft`})]})]}),(0,v.jsxs)(`div`,{className:`create-pr-field`,children:[(0,v.jsx)(`label`,{htmlFor:`create-pr-title`,children:`Title`}),(0,v.jsx)(`input`,{id:`create-pr-title`,className:`create-pr-title`,value:r,maxLength:300,placeholder:`Pull request title`,disabled:$||B||!!H,onChange:e=>b(e.target.value)})]}),O&&(0,v.jsx)(de,{coverage:O,stale:!D(O,e.repositoryId,M,e.status,e.branches)}),(0,v.jsxs)(le,{value:I,onValueChange:e=>L(e),className:`create-pr-field create-pr-body-field`,children:[(0,v.jsxs)(`div`,{className:`create-pr-body-header`,children:[(0,v.jsx)(`label`,{htmlFor:`create-pr-body`,children:`Description`}),(0,v.jsx)(ce,{label:`Description view`,className:`markdown-viewer-tabs`,items:[{value:`edit`,label:`Edit`},{value:`preview`,label:`Preview`}]})]}),(0,v.jsx)(g,{value:`edit`,className:`create-pr-body-panel`,children:(0,v.jsx)(ae,{id:`create-pr-body`,value:A,rows:10,placeholder:`Describe the change (GitHub Markdown)`,disabled:$||B||!!H,onChange:e=>j(e.target.value)})}),(0,v.jsx)(g,{value:`preview`,className:`create-pr-preview markdown-prose`,dangerouslySetInnerHTML:{__html:R}})]})]}),(0,v.jsxs)(`div`,{className:`create-pr-actions`,children:[(0,v.jsxs)(s,{variant:`outline`,className:`create-pr-generate commit-composer-generate`,disabled:$||B,"aria-label":H?`Cancel generation`:void 0,onClick:()=>H?void me():void he(),children:[H?(0,v.jsx)(u,{className:`text-destructive`}):(0,v.jsx)(ie,{harness:q}),H?(0,v.jsx)(o,{text:`Generating draft…`}):(0,v.jsxs)(`span`,{className:`commit-composer-provider`,children:[`Generate with `,(0,v.jsx)(`span`,{className:`commit-composer-harness`,children:C(q)}),(0,v.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,v.jsx)(`span`,{className:`commit-composer-model`,children:fe})]})]}),(0,v.jsxs)(`div`,{className:`create-pr-submit-actions`,children:[(0,v.jsx)(s,{variant:`ghost`,onClick:()=>e.onOpenChange(!1),disabled:B,children:`Cancel`}),(0,v.jsxs)(s,{onClick:()=>void ge(),disabled:$||B||!!H||!r.trim()||!M||n?.state!==`ready`||t.isFetching,children:[B?(0,v.jsx)(i,{className:`animate-spin`}):(0,v.jsx)(h,{}),` `,B?(0,v.jsx)(o,{text:`Creating…`}):`Create pull request`]})]})]})]})})}function x(e){return e.find(e=>e===`origin/main`)??e.find(e=>e===`origin/master`)??e[0]??``}function S(e){return e.replace(/^origin\//,``)}function C(e){return e===`codex`?`Codex`:e===`claude`?`Claude Code`:`OpenCode`}function w(e,t,n){return e?.find(e=>e.id===t)?.models.find(e=>e.id===n)?.label??(n==="default"?`Default (CLI)`:n)}function T(e){if(!(e instanceof Error)||!(`detail`in e)||!e.detail||typeof e.detail!=`object`)return null;let t=e.detail;return typeof t.code==`string`&&t.code.startsWith(`AI_`)&&typeof t.message==`string`?t:null}function E(e){return e instanceof Error?e.message:`An unexpected error occurred.`}function D(e,t,n,r,i){let a=i.find(e=>e.name===n)?.oid;return e.repositoryId===t&&e.base===n&&e.branch===r?.branch&&e.headOid===r?.oid&&e.baseOid===a}export{b as CreatePullRequestDialog};
@@ -1,6 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Ct as t,xt as n}from"./base-ui-DDpgJXgO.js";import{t as r}from"./createReactComponent-BfrD_oQK.js";import{t as i}from"./IconChevronDown-C3FplJL8.js";import{T as a,g as o,h as s,v as c}from"./index-CoZCJqTQ.js";import{C as l,D as u,F as d,I as f,M as p,T as m,V as h,b as g,d as _,f as v,h as y,m as b,p as x,w as S,y as C,z as w}from"./color-C1Sk4dBL.js";import{n as T,t as E}from"./cloneFileDiffMetadata-zVRGqYgv.js";import{$ as D,A as O,At as k,B as A,C as j,Ct as M,D as N,E as P,F as ee,Ft as F,G as I,H as te,I as ne,It as re,J as ie,K as ae,L as oe,Lt as se,M as ce,Mt as le,N as ue,Nt as de,O as fe,Ot as pe,P as me,Pt as L,Q as he,R as ge,Rt as _e,S as ve,St as R,T as ye,U as be,V as xe,W as Se,X as Ce,Y as we,Z as Te,_ as Ee,_t as De,a as Oe,at as z,b as ke,bt as Ae,c as je,ct as Me,d as Ne,dt as Pe,et as Fe,f as Ie,ft as Le,g as Re,gt as B,h as ze,ht as Be,it as Ve,j as He,jt as Ue,k as We,kt as Ge,l as Ke,lt as qe,m as Je,mt as V,n as Ye,nt as Xe,o as Ze,ot as H,p as Qe,pt as $e,q as et,r as tt,rt as nt,s as rt,st as it,tt as at,u as ot,ut as st,v as ct,w as lt,wt as ut,x as dt,xt as ft,y as pt,yt as U,z as mt}from"./PierreWorkerPool-DMFigp0u.js";import{s as W}from"./string-TLTPtCPs-SBynuHAV.js";import{At as ht,Zt as gt,d as _t}from"./App-DEIZhWJG.js";import{n as vt,r as yt}from"./EditContext-rlYgrfe2.js";var bt=r(`outline`,`arrows-maximize`,`ArrowsMaximize`,[[`path`,{d:`M16 4l4 0l0 4`,key:`svg-0`}],[`path`,{d:`M14 10l6 -6`,key:`svg-1`}],[`path`,{d:`M8 20l-4 0l0 -4`,key:`svg-2`}],[`path`,{d:`M4 20l6 -6`,key:`svg-3`}],[`path`,{d:`M16 20l4 0l0 -4`,key:`svg-4`}],[`path`,{d:`M14 14l6 6`,key:`svg-5`}],[`path`,{d:`M8 4l-4 0l0 4`,key:`svg-6`}],[`path`,{d:`M4 4l6 6`,key:`svg-7`}]]),xt=r(`outline`,`arrows-minimize`,`ArrowsMinimize`,[[`path`,{d:`M5 9l4 0l0 -4`,key:`svg-0`}],[`path`,{d:`M3 3l6 6`,key:`svg-1`}],[`path`,{d:`M5 15l4 0l0 4`,key:`svg-2`}],[`path`,{d:`M3 21l6 -6`,key:`svg-3`}],[`path`,{d:`M19 9l-4 0l0 -4`,key:`svg-4`}],[`path`,{d:`M15 9l6 -6`,key:`svg-5`}],[`path`,{d:`M19 15l-4 0l0 4`,key:`svg-6`}],[`path`,{d:`M15 15l6 6`,key:`svg-7`}]]),St=r(`outline`,`layout-columns`,`LayoutColumns`,[[`path`,{d:`M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12`,key:`svg-0`}],[`path`,{d:`M12 4l0 16`,key:`svg-1`}]]),Ct=r(`outline`,`layout-rows`,`LayoutRows`,[[`path`,{d:`M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12`,key:`svg-0`}],[`path`,{d:`M4 12l16 0`,key:`svg-1`}]]),wt=r(`outline`,`text-wrap`,`TextWrap`,[[`path`,{d:`M4 6l16 0`,key:`svg-0`}],[`path`,{d:`M4 18l5 0`,key:`svg-1`}],[`path`,{d:`M4 12h13a3 3 0 0 1 0 6h-4l2 -2m0 4l-2 -2`,key:`svg-2`}]]);function Tt({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function Et(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:Kt(n,e.startContentIndex)}}function Dt(e,t=6){t=Math.max(t,1);let n={deletionLines:[],additionLines:[],conflictStack:[],conflictBuilders:[],actions:[],hunks:[],nextConflictIndex:0,splitLineCount:0,unifiedLineCount:0,lastHunkEnd:0,activeHunk:void 0,maxContextLines:t,maxContextLines2:t*2},r=e.contents,i=r.length;if(i>0){let e=0,t=0,a=r.indexOf(`
2
- `,e);for(;a!==-1;)Ot(n,r.slice(e,a+1),t),e=a+1,t++,a=r.indexOf(`
3
- `,e);e<i&&Ot(n,r.slice(e),t)}if(n.conflictStack.length>0)throw Error(`parseMergeConflictDiffFromFile: unfinished merge conflict marker stack`);n.activeHunk!=null&&n.activeHunk.hunkContent.length>0&&(Mt(n,n.activeHunk,`trailing`),Nt(n));for(let e=0;e<n.conflictBuilders.length;e++){let t=n.conflictBuilders[e];if(t==null||!t.completed)throw Error(`parseMergeConflictDiffFromFile: failed to build merge conflict action ${e}`)}if(n.hunks.length>0&&n.additionLines.length>0&&n.deletionLines.length>0){let e=n.hunks[n.hunks.length-1],t=Math.max(n.additionLines.length-L(e.additionStart,e.additionCount),0);n.splitLineCount+=t,n.unifiedLineCount+=t}let a=n.deletionLines.join(``),o=n.additionLines.join(``),s=Wt(e,`current`,a),c=Wt(e,`incoming`,o),l=`change`;o===``?l=`deleted`:a===``&&(l=`new`);let u={name:e.name,prevName:void 0,type:l,hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,isPartial:!1,deletionLines:n.deletionLines,additionLines:n.additionLines,cacheKey:e.cacheKey==null?void 0:`${e.cacheKey}:merge-conflict-diff`};return{fileDiff:u,currentFile:s,incomingFile:c,actions:n.actions,markerRows:Gt(u,n.actions)}}function Ot(e,t,n){let r=e.conflictStack[e.conflictStack.length-1];if(r==null){if(t.length>=7&&t.charCodeAt(0)===60&&Vt(t)===`start`){Rt(e,t,n);return}Ft(e,t);return}let i=Vt(t);if(i===`start`)Rt(e,t,n);else if(i===`base`)r.stage=`base`,r.baseMarkerLineIndex=n,r.markerLines.base=t;else if(i===`separator`)r.stage=`incoming`,r.separatorLineIndex=n,r.markerLines.separator=t;else if(i===`end`){let r=e.conflictStack.pop();if(r==null)throw Error(`parseMergeConflictDiffFromFile: encountered end marker before start marker`);Lt(e,r,n,t)}else r.stage===`current`?It(e,`deletion`,t,r.conflictIndex,`current`):r.stage===`base`?Ft(e,t,r.conflictIndex):It(e,`addition`,t,r.conflictIndex,`incoming`)}function kt(e){return e.activeHunk??=zt(e.additionLines.length+1,e.deletionLines.length+1),e.activeHunk}function At(e,t,n,r){let i=e.conflictBuilders[t];if(i==null)throw Error(`parseMergeConflictDiffFromFile: failed to locate conflict action ${t}`);let a=i.action,o=e.hunks.length;if(a.hunkIndex<0)a.hunkIndex=o;else if(a.hunkIndex!==o)throw Error(`parseMergeConflictDiffFromFile: conflict ${t} spans multiple hunks and cannot be anchored`);a.startContentIndex<0&&(a.startContentIndex=r),a.endContentIndex=r,a.endMarkerContentIndex=r,n===`current`?a.currentContentIndex??=r:n===`base`?a.baseContentIndex??=r:a.incomingContentIndex=r}function jt(e,t,n,r){let i=e.hunkContent,a=i[i.length-1];return a?.type===`change`?(t===`addition`?a.additions++:a.deletions++,i.length-1):(i.push({type:`change`,additions:+(t===`addition`),deletions:+(t===`deletion`),additionLineIndex:n,deletionLineIndex:r}),i.length-1)}function Mt(e,t,n){let r=t.contextBufferCount,i=t.contextBufferAdditionStart,a=t.contextBufferDeletionStart;if(n===`leading`&&r>e.maxContextLines){let n=r-e.maxContextLines;i+=n,a+=n,r=e.maxContextLines,t.additionStart+=n,t.deletionStart+=n,t.additionLineIndex+=n,t.deletionLineIndex+=n}if(n===`trailing`&&r>e.maxContextLines&&(r=e.maxContextLines),r===0){t.contextBufferCount=0,t.contextBufferBaseConflicts=void 0;return}let o=t.hunkContent,s=o[o.length-1],c;s?.type===`context`?(s.lines+=r,c=o.length-1):(o.push({type:`context`,lines:r,additionLineIndex:i,deletionLineIndex:a}),c=o.length-1),t.additionCount+=r,t.deletionCount+=r;let l=t.contextBufferBaseConflicts;if(l!=null){let n=i-t.contextBufferAdditionStart;for(let[t,i]of l)t>=n&&t<n+r&&At(e,i,`base`,c)}t.contextBufferCount=0,t.contextBufferBaseConflicts=void 0}function Nt(e){if(e.activeHunk==null)return;let t=e.activeHunk;if(e.activeHunk=void 0,t.hunkContent.length===0)return;let n=0,r=0;for(let e of t.hunkContent)e.type===`context`?(n+=e.lines,r+=e.lines):(n+=Math.max(e.additions,e.deletions),r+=e.additions+e.deletions);let i=t.additionCount===0?t.additionStart-1:t.additionStart,a=t.deletionCount===0?t.deletionStart-1:t.deletionStart,o=Math.max(F(i,t.additionCount)-e.lastHunkEnd,0),s={collapsedBefore:o,additionStart:i,additionCount:t.additionCount,additionLines:t.additionLines,additionLineIndex:t.additionLineIndex,deletionStart:a,deletionCount:t.deletionCount,deletionLines:t.deletionLines,deletionLineIndex:t.deletionLineIndex,hunkContent:t.hunkContent,hunkContext:void 0,hunkSpecs:`@@ -${Bt(a,t.deletionCount)} +${Bt(i,t.additionCount)} @@\n`,splitLineStart:e.splitLineCount+o,splitLineCount:n,unifiedLineStart:e.unifiedLineCount+o,unifiedLineCount:r,noEOFCRAdditions:!1,noEOFCRDeletions:!1};e.hunks.push(s),e.splitLineCount+=o+n,e.unifiedLineCount+=o+r,e.lastHunkEnd=L(i,t.additionCount)}function Pt(e){if(e.activeHunk==null)return;let t=e.activeHunk,n=t.contextBufferCount,r=n-e.maxContextLines2,i=t.contextBufferAdditionStart+n-e.maxContextLines,a=t.contextBufferDeletionStart+n-e.maxContextLines,o;if(t.contextBufferBaseConflicts!=null){let r=n-e.maxContextLines;for(let[e,n]of t.contextBufferBaseConflicts)e>=r&&(o??=new Map,o.set(e-r,n))}Mt(e,t,`trailing`);let s=t.additionCount,c=t.deletionCount;Nt(e),e.activeHunk=zt(t.additionStart+s+r,t.deletionStart+c+r),e.activeHunk.contextBufferAdditionStart=i,e.activeHunk.contextBufferDeletionStart=a,e.activeHunk.contextBufferCount=e.maxContextLines,e.activeHunk.contextBufferBaseConflicts=o}function Ft(e,t,n=-1){let r=kt(e);r.contextBufferCount===0&&(r.contextBufferAdditionStart=e.additionLines.length,r.contextBufferDeletionStart=e.deletionLines.length),e.additionLines.push(t),e.deletionLines.push(t),n>=0&&(r.contextBufferBaseConflicts??=new Map,r.contextBufferBaseConflicts.set(r.contextBufferCount,n)),r.contextBufferCount++}function It(e,t,n,r,i){let a=kt(e);a.hunkContent.length>0&&a.contextBufferCount>e.maxContextLines2&&(Pt(e),a=e.activeHunk),Mt(e,a,a.hunkContent.length===0?`leading`:`before-change`);let o=e.additionLines.length,s=e.deletionLines.length;t===`addition`?e.additionLines.push(n):e.deletionLines.push(n);let c=jt(a,t,o,s);t===`addition`?(a.additionCount++,a.additionLines++):(a.deletionCount++,a.deletionLines++),At(e,r,i,c)}function Lt(e,t,n,r){if(t.separatorLineIndex==null||t.markerLines.separator==null)throw Error(`parseMergeConflictDiffFromFile: conflict ${t.conflictIndex} is missing a separator marker`);let i=e.conflictBuilders[t.conflictIndex];if(i==null)throw Error(`parseMergeConflictDiffFromFile: failed to finalize conflict ${t.conflictIndex}`);let a=i.action;a.markerLines.separator=t.markerLines.separator,a.markerLines.end=r,t.markerLines.base!=null&&(a.markerLines.base=t.markerLines.base),a.conflict={conflictIndex:t.conflictIndex,startLineIndex:t.startLineIndex,startLineNumber:t.startLineIndex+1,separatorLineIndex:t.separatorLineIndex,separatorLineNumber:t.separatorLineIndex+1,endLineIndex:n,endLineNumber:n+1,baseMarkerLineIndex:t.baseMarkerLineIndex,baseMarkerLineNumber:t.baseMarkerLineIndex==null?void 0:t.baseMarkerLineIndex+1};let o=a.currentContentIndex??a.incomingContentIndex;if(a.currentContentIndex??=o,a.incomingContentIndex??=o,a.startContentIndex<0&&o!=null&&(a.startContentIndex=o),a.endContentIndex<0&&o!=null&&(a.endContentIndex=o),a.endMarkerContentIndex<0&&o!=null&&(a.endMarkerContentIndex=o),a.hunkIndex<0||a.startContentIndex<0||a.endContentIndex<0||a.endMarkerContentIndex<0)throw Error(`parseMergeConflictDiffFromFile: failed to anchor merge conflict ${t.conflictIndex}`);e.actions[a.conflictIndex]=a,i.completed=!0}function Rt(e,t,n){let r=e.nextConflictIndex;e.nextConflictIndex++,e.conflictStack.push({conflictIndex:r,stage:`current`,startLineIndex:n,markerLines:{start:t}}),e.conflictBuilders[r]={completed:!1,action:{conflict:{conflictIndex:r,startLineIndex:n,startLineNumber:n+1,separatorLineIndex:n,separatorLineNumber:n+1,endLineIndex:n,endLineNumber:n+1,baseMarkerLineIndex:void 0,baseMarkerLineNumber:void 0},conflictIndex:r,hunkIndex:-1,startContentIndex:-1,endContentIndex:-1,endMarkerContentIndex:-1,markerLines:{start:t,separator:``,end:``}}}}function zt(e,t){return{additionStart:e,deletionStart:t,additionCount:0,deletionCount:0,additionLines:0,deletionLines:0,additionLineIndex:Math.max(e-1,0),deletionLineIndex:Math.max(t-1,0),hunkContent:[],contextBufferAdditionStart:Math.max(e-1,0),contextBufferDeletionStart:Math.max(t-1,0),contextBufferCount:0,contextBufferBaseConflicts:void 0}}function Bt(e,t){return t===1?`${e}`:`${e},${t}`}function Vt(e){if(e.length<7)return;let t=e.charCodeAt(0);if(t!==60&&t!==62&&t!==61&&t!==124)return;let n=Ht(e);if(n<7)return;let r=1;for(;r<n&&e.charCodeAt(r)===t;)r++;if(!(r<7)){if(t===61)return r===n?`separator`:void 0;if(r===n||Ut(e.charCodeAt(r)))return t===60?`start`:t===62?`end`:`base`}}function Ht(e){let t=e.length;return t>0&&e.charCodeAt(t-1)===10&&t--,t>0&&e.charCodeAt(t-1)===13&&t--,t}function Ut(e){return e===9||e===10||e===11||e===12||e===13||e===32}function Wt(e,t,n){return{...e,contents:n,cacheKey:e.cacheKey==null?void 0:`${e.cacheKey}:merge-conflict-${t}`}}function Gt(e,t){let n=[],r=Array(e.hunks.length),i=(t,n)=>{let i=e.hunks[t];if(i==null)return 0;let a=r[t];if(a==null){a=Array(i.hunkContent.length+1);let e=i.unifiedLineStart;a[0]=e;for(let t=0;t<i.hunkContent.length;t++){let n=i.hunkContent[t];e+=n.type===`context`?n.lines:n.deletions+n.additions,a[t+1]=e}r[t]=a}return a[Math.max(n,0)]??i.unifiedLineStart},a=(e,t)=>{let n=i(e,t),a=r[e]?.[Math.max(t+1,0)]??i(e,t+1);return Math.max(n,a-1)};for(let r of t){if(r==null)continue;let t=e.hunks[r.hunkIndex];if(t==null)continue;let o=i(r.hunkIndex,r.startContentIndex);if(n.push(G(r,`marker-start`,r.startContentIndex,r.markerLines.start,o)),r.baseContentIndex!=null){let e=r.currentContentIndex,o=r.incomingContentIndex;if(e==null||o==null)continue;let s=r.markerLines.base;if(s==null)continue;let c=t.hunkContent[e],l=t.hunkContent[r.baseContentIndex],u=t.hunkContent[o];if(c?.type!==`change`||l?.type!==`context`||u?.type!==`change`)continue;let d=i(r.hunkIndex,e),f=i(r.hunkIndex,o);n.push(G(r,`marker-base`,r.baseContentIndex,s,d+c.deletions)),n.push(G(r,`marker-separator`,r.baseContentIndex,r.markerLines.separator,f),G(r,`marker-end`,r.endMarkerContentIndex,r.markerLines.end,a(r.hunkIndex,r.endMarkerContentIndex)));continue}let s=r.currentContentIndex;if(s==null)continue;let c=t.hunkContent[s];if(c?.type!==`change`)continue;let l=i(r.hunkIndex,s),u=c.deletions>0?l+c.deletions:o;n.push(G(r,`marker-separator`,s,r.markerLines.separator,u),G(r,`marker-end`,r.endMarkerContentIndex,r.markerLines.end,a(r.hunkIndex,r.endMarkerContentIndex)))}return n}function G(e,t,n,r,i){return{type:t,hunkIndex:e.hunkIndex,contentIndex:n,conflictIndex:e.conflictIndex,lineText:r,lineIndex:i}}function Kt(e,t){let n=e.unifiedLineStart;for(let r=0;r<t;r++){let t=e.hunkContent[r];n+=t.type===`context`?t.lines:t.deletions+t.additions}return n}var K=n();function qt({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:c,lineAnnotations:l,getHoveredLine:u,getInstance:d,getAnnotationSlotName:f=w}){let p=n?.(e),m=r?.(e),h=i?.(e),g=a?.(e);return(0,K.jsxs)(K.Fragment,{children:[p==null?(0,K.jsxs)(K.Fragment,{children:[m!=null&&(0,K.jsx)(`div`,{slot:`header-prefix`,children:m}),h!=null&&(0,K.jsx)(`div`,{slot:`header-filename-suffix`,children:h}),g!=null&&(0,K.jsx)(`div`,{slot:`header-metadata`,children:g})]}):(0,K.jsx)(`div`,{slot:_,children:p}),o!=null&&l?.map((e,t)=>(0,K.jsx)(`div`,{slot:f(e),children:o(e)},t)),t!=null&&c!=null&&d!=null&&t.map(t=>{if(t==null)return;let n=Jt(t,e);return(0,K.jsx)(`div`,{slot:n,style:se,children:c(t,d)},n)}),s!=null&&(0,K.jsx)(`div`,{slot:`gutter-utility-slot`,style:re,children:s(u)})]})}function Jt(e,t){let n=Et(e,t);return n==null?void 0:Tt({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}async function Yt(e,t=300){let n;try{await Promise.race([e(),new Promise(e=>{n=setTimeout(e,t)})])}finally{n!=null&&clearTimeout(n)}}function Xt({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o,canHydratePartialDiff:s}){let c=Pe(t,n),l=c,u=i?!0:a,d=e.hunks.length-1;for(let n=0;n<e.hunks.length;n++){let i=e.hunks[n];if(i==null)throw Error(`computeEstimatedDiffHeights: invalid hunk index`);let a=Fe({isPartial:e.isPartial,rangeSize:i.collapsedBefore,expandedHunks:u,hunkIndex:n,collapsedContextThreshold:o}),f=(a.fromStart+a.fromEnd)*t.lineHeight;if(c+=f,l+=f,a.collapsedLines>0){let e=Xe({type:r,metrics:t,hunkIndex:n,hunkSpecs:i.hunkSpecs})?.totalHeight??0;c+=e,l+=e}c+=i.splitLineCount*t.lineHeight,l+=i.unifiedLineCount*t.lineHeight;let p=Zt(i);c+=p.split*t.lineHeight,l+=p.unified*t.lineHeight;let m=n===d?z({fileDiff:e,hunkIndex:n,expandedHunks:u,collapsedContextThreshold:o,errorPrefix:`computeEstimatedDiffHeights`}):void 0;if(m!=null){let e=(m.fromStart+m.fromEnd)*t.lineHeight;if(c+=e,l+=e,m.collapsedLines>0){let e=H({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}else if(n===d&&e.isPartial&&s){let e=H({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}if(e.hunks.length>0){let e=Le(t);c+=e,l+=e}return{splitHeight:c,unifiedHeight:l}}function Zt(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};let t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type===`context`){let e=+(t.lines>0);return{split:e,unified:e}}return Qt(e,t)}function Qt(e,t){let n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),r=t.deletions>0&&e.noEOFCRDeletions,i=t.additions>0&&e.noEOFCRAdditions;return{split:r||i?1:0,unified:n}}function $t({oldFile:e,newFile:t},n){if(e!==void 0||t!==void 0){if(e===void 0||t===void 0)throw Error(`${n}: Pass null for an intentionally missing oldFile or newFile side`);if(e===null){if(t===null)throw Error(`${n}: You must pass oldFile, newFile, or both`);return{oldFile:e,newFile:t}}return{oldFile:e,newFile:t}}}function en(e){return e===``?[]:e.split(u)}function tn(e,t,n){let r=e===`clone`?E(t):t;if(!r.isPartial)throw Error(`hydratePartialDiff: fileDiff must be partial`);switch(r.type){case`change`:case`rename-changed`:return nn(r,an(r,n),on(r,n));case`rename-pure`:{let e=on(r,n);sn(r,n);let t=en(e.contents);return r.isPartial=!1,r.deletionLines=t,r.additionLines=t,ln(r,null,e),r}}throw Error(`hydratePartialDiff: ${r.type} diffs cannot be hydrated from loaded files`)}function nn(e,t,n){let r=en(t.contents),i=en(n.contents),{hunks:a,splitLineCount:o,unifiedLineCount:s}=rn(e.hunks,i.length);return e.hunks=a,e.splitLineCount=o,e.unifiedLineCount=s,e.isPartial=!1,e.deletionLines=r,e.additionLines=i,ln(e,t,n),e}function rn(e,t){let n=0,r=0,i=0,a=[];for(let t of e){let e=Math.max(t.additionStart-1,0),o=Math.max(t.deletionStart-1,0),s=e,c=o,l=0,u=0,d=0,f=0,p=[];for(let e of t.hunkContent)e.type===`context`?(p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.lines,c+=e.lines,d+=e.lines,f+=e.lines):(p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.additions,c+=e.deletions,l+=e.additions,u+=e.deletions,d+=Math.max(e.additions,e.deletions),f+=e.additions+e.deletions);let m=Math.max(F(t.additionStart,t.additionCount)-i,0);a.push({...t,collapsedBefore:m,additionLineIndex:e,deletionLineIndex:o,additionLines:l,deletionLines:u,hunkContent:p,splitLineStart:n+m,unifiedLineStart:r+m,splitLineCount:d,unifiedLineCount:f}),n+=m+d,r+=m+f,i=L(t.additionStart,t.additionCount)}if(a.length>0){let e=a[a.length-1],i=L(e.additionStart,e.additionCount),o=Math.max(t-i,0);n+=o,r+=o}return{hunks:a,splitLineCount:n,unifiedLineCount:r}}function an(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function on(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function sn(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function cn(e,t,n){return e.cacheKey==null?un(t,n):`${e.cacheKey}:hydrated`}function ln(e,t,n){let r=cn(e,t,n);r==null?delete e.cacheKey:e.cacheKey=r}function un(e,t){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?Ne(`hydrated-files`,e.cacheKey,t.cacheKey):void 0:e?.cacheKey??t?.cacheKey}var dn=`/dev/null`;function q(e,t,n,r=!1){if(e===null&&t===null)throw Error(`parseDiffFromFile: You must pass oldFile, newFile, or both`);let i=e??fn(),a=t??fn(),o=Te(i.name,a.name,i.contents,a.contents,i.header,a.header,n),s=Ke(o,{cacheKey:(()=>{let n=e?.cacheKey,r=t?.cacheKey;return n!=null&&r!=null?Ne(`diff`,n,r):void 0})(),oldFile:i,newFile:a,throwOnError:r});if(s==null)throw Error(`parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?`);e===null?(s.type=`new`,s.prevName=void 0):t===null&&(s.type=`deleted`,s.prevName=void 0);let c=t?.lang??(t===null?e?.lang:void 0);return c!=null&&(s.lang=c),s}function fn(){return{name:dn,contents:``}}var pn=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){this.enabled&&=(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,!1)}setup(e,t,n){if(t==null||n==null)for(let r of e.children??[])r instanceof HTMLElement&&(`deletions`in r.dataset?t=r:`additions`in r.dataset&&(n=r));n==null||t==null?this.cleanUp():(this.codeDeletions!==t&&(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener(`scroll`,this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&(this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener(`scroll`,this.handleAdditionsScroll,{passive:!0})),this.enabled=!0)}handleDeletionsScroll=()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))};handleAdditionsScroll=()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))}};function J(e,t){let n=q({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t);return{hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,additionLines:n.additionLines,deletionLines:n.deletionLines,type:n.type}}function mn(e,t){let n=Math.max(e,1),r=Array.from({length:n},(e,t)=>`${` `.repeat(t+1)}\n`).join(``);return r===t&&(r=Array.from({length:n},(e,t)=>`\u0000${` `.repeat(t)}\n`).join(``)),r}function hn(e){for(let t of e)if(t.trim().length>0)return!1;return!0}function gn(e,t){return t.length>0&&t.length<e.deletionLines.length&&hn(t)}function _n(e,t,n){let r=e.deletionLines.join(``),i=mn(t.length,r),a=q({name:e.prevName??e.name,contents:r},{name:e.name,contents:i,lang:e.lang},n);return{hunks:a.hunks,splitLineCount:a.splitLineCount,unifiedLineCount:a.unifiedLineCount,additionLines:t,deletionLines:a.deletionLines,type:a.type}}function vn(e,t){return _n(e,[``],t)}function yn(e,t){if(e.additionLines.length===0)return vn(e,t);if(gn(e,e.additionLines))return _n(e,e.additionLines,t);let n=e.additionLines,r=J(e,t);return xn(r,n),r}function bn(e){return e.length>1&&e.at(-1)===``}function xn(e,t){if(!bn(t))return;let n=t.length-e.additionLines.length;if(n<=0)return;let r=e.additionLines.length,i=e.hunks.at(-1);if(i!=null&&L(i.additionStart,i.additionCount)===r){for(let a of i.hunkContent)if(a.type===`change`&&a.additions<a.deletions&&a.additionLineIndex+a.additions===r){e.additionLines=t,a.additions+=n,i.additionCount+=n,i.additionLines+=n,An(e);return}}}function Sn(e,t,n){if(e.isPartial||e.deletionLines.length!==e.additionLines.length)return Y(e,J(e,n));let r=Array.from(t);if(r.length===0)return Y(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type});for(let t of r){let r=e.additionLines[t],i=e.deletionLines[t];if(r==null||i==null||he(r)===he(i))return Y(e,J(e,n))}let i=Cn(e,r);if(i.size===0)return Y(e,J(e,n));for(let t of i)if(!Tn(e,t,n))return Y(e,J(e,n));return An(e),it(e)?Y(e,J(e,n)):Y(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type})}function Y(e,t){return Object.assign(e,t),t}function Cn(e,t){let n=new Set;for(let r of t){let t=wn(e,r);if(t==null)return new Set;n.add(t)}return n}function wn(e,t){for(let[n,r]of e.hunks.entries()){let e=r.additionLineIndex+r.additionCount;if(t>=r.additionLineIndex&&t<e)return n}}function Tn(e,t,n){let r=e.hunks[t];if(r==null)return!1;let i=e.deletionLines.slice(r.deletionLineIndex,r.deletionLineIndex+r.deletionCount),a=e.additionLines.slice(r.additionLineIndex,r.additionLineIndex+r.additionCount),o=q({name:e.prevName??e.name,contents:i.join(``)},{name:e.name,contents:a.join(``),lang:e.lang},{...n,context:0}),s=o.hunks[0];return s==null||o.hunks.length!==1?!1:(Dn(r,s),En(e,t),!0)}function En(e,t){let n=e.hunks[t];if(n==null)return;if(t!==e.hunks.length-1){n.noEOFCRAdditions=!1,n.noEOFCRDeletions=!1;return}let r=e.additionLines.at(-1),i=e.deletionLines.at(-1);n.noEOFCRAdditions=r!=null&&r!==``&&!r.endsWith(`
4
- `),n.noEOFCRDeletions=i!=null&&i!==``&&!i.endsWith(`
5
- `)}function Dn(e,t){let n=e.additionLineIndex,r=e.deletionLineIndex;e.hunkContent=t.hunkContent.map(e=>On(e,n,r)),e.additionLineIndex=n+t.additionLineIndex,e.additionStart+=t.additionLineIndex,e.additionCount=t.additionCount,e.additionLines=t.additionLines,t.deletionLineIndex>=0&&(e.deletionLineIndex=r+t.deletionLineIndex,e.deletionStart+=t.deletionLineIndex),e.deletionCount=t.deletionCount,e.deletionLines=t.deletionLines,e.noEOFCRAdditions=t.noEOFCRAdditions,e.noEOFCRDeletions=t.noEOFCRDeletions,kn(e)}function On(e,t,n){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+n}}function kn(e){let t=0,n=0;for(let r of e.hunkContent)r.type===`context`?(t+=r.lines,n+=r.lines):(t+=Math.max(r.additions,r.deletions),n+=r.additions+r.deletions);e.splitLineCount=t,e.unifiedLineCount=n}function An(e){let t=0,n=0,r=0;for(let i of e.hunks)i.collapsedBefore=Math.max(F(i.additionStart,i.additionCount)-r,0),i.splitLineStart=t+i.collapsedBefore,i.unifiedLineStart=n+i.collapsedBefore,kn(i),t+=i.collapsedBefore+i.splitLineCount,n+=i.collapsedBefore+i.unifiedLineCount,r=L(i.additionStart,i.additionCount);if(e.hunks.length>0){let r=e.hunks[e.hunks.length-1],i=Math.max(e.additionLines.length-L(r.additionStart,r.additionCount),0);t+=i,n+=i}e.splitLineCount=t,e.unifiedLineCount=n}var jn=new WeakMap;function Mn(e){return e.length>1&&e[e.length-1]===``?e.slice(0,-1):e}function Nn(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;let i=e.length,a=t.length;for(;i>r&&a>r&&e[i-1]===t[a-1];)i--,a--;if(r!==i||r!==a)return{start:r,deletionEnd:i,additionEnd:a}}function Pn(e,t,n){let r=e.hunks,i=e.additionLines,a=Mn(i),o=a===i?e:{...e,additionLines:a},s=Gn(r,Un(o,t,n),e.deletionLines.length),c=Jn(o,s);if(e.additionLines=a,e.hunks=c,e.editSessionDirty=!0,rr(e),xn(e,i),Zn(r,e.hunks))return{regions:s.map(e=>e.previousSpan)}}function Fn(e,t,n,r){let i=new Set(t),a=Array.from(i).filter(t=>t>=0&&t<e.additionLines.length).sort((e,t)=>e-t);if(a.length===0)return;let o=t=>i.has(t)?r?.get(t):e.additionLines[t],{hunks:s}=e,c,l=0;for(let t of a){for(;l<s.length;){let e=s[l];if(t<er(e)+e.additionCount)break;l++}let r=s[l],i=r==null?void 0:er(r);if(i==null||t<i||c!=null&&c!==l)return Pn(e,n,o);c=l}if(c!=null){if(In(e,a,c,r,n))e.editSessionDirty=!0;else return Pn(e,n,o)}}function In(e,t,n,r,i){if(r==null||i?.ignoreWhitespace===!0||i?.stripTrailingCr===!0)return!1;let a=Ln(e),o=e.hunks[n];if(o.hunkContent.some(Rn))return!1;for(let n of t){let t=r.get(n),i=e.additionLines[n];if(t==null||i==null||a.has(t)||a.has(i))return!1;let s=!1;for(let e of o.hunkContent)if(e.type===`change`&&e.additions===e.deletions&&n>=e.additionLineIndex&&n<e.additionLineIndex+e.additions){s=!0;break}if(!s)return!1}return!0}function Ln(e){let t=jn.get(e);if(t?.lines===e.deletionLines)return t.set;let n=new Set(e.deletionLines);return jn.set(e,{lines:e.deletionLines,set:n}),n}function Rn(e){return e?.type===`change`&&(e.additions===0||e.deletions===0)}function zn(e,t){let n=new Map,{regions:r}=t;for(let t=0;t<=r.length;t++){let i=r[t-1],a=r[t],o=t===0?e.get(0):i==null?void 0:e.get(i.lastIndex+1),s=a==null?void 0:e.get(a.firstIndex),c=o?.fromStart??0,l=s?.fromEnd??0;(c>0||l>0)&&n.set(t,{fromStart:c,fromEnd:l})}return n}function Bn(e,t,n){let r=[];if(e.isPartial)return r;for(let[i,a]of e.hunks.entries()){let o=Fe({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:t,hunkIndex:i,collapsedContextThreshold:n});if(o.rangeSize<=n)continue;let s=X(a),c=s-o.rangeSize;o.fromStart>0&&r.push([c,c+o.fromStart]),o.fromEnd>0&&r.push([s-o.fromEnd,s])}let i=z({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`captureExpansionAnchors`});if(i!=null&&i.fromStart>0&&i.rangeSize>n){let t=e.hunks[e.hunks.length-1],n=X(t)+t.deletionCount;r.push([n,n+i.fromStart])}return r}function Vn(e,t){let n=new Map;if(t.length===0)return n;let r=(e,r,i)=>{if(i<=r)return;let a=0,o=0;for(let[e,n]of t)n<=r||e>=i||(e<=r&&(a=Math.max(a,Math.min(n,i)-r)),n>=i&&(o=Math.max(o,i-Math.max(e,r))));(a>0||o>0)&&n.set(e,{fromStart:a,fromEnd:o})};for(let[t,n]of e.hunks.entries()){let e=X(n);r(t,e-Math.max(n.collapsedBefore,0),e)}let i=e.hunks[e.hunks.length-1];return i!=null&&!e.isPartial&&e.deletionLines.length>0&&r(e.hunks.length,X(i)+i.deletionCount,e.deletionLines.length),n}function Hn(e,t){return e.editSessionDirty===!0&&(delete e.editSessionDirty,Object.assign(e,e.additionLines.length<=1&&e.additionLines.join(``)===``?J(e,t):yn(e,t)),!0)}function Un(e,t,n){if(Nn(e.deletionLines,e.additionLines)==null)return[];let r=q({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t),i,a=(t,a)=>{i??=Wn(e.hunks);for(let e=0;e<=a;e++){let o=i.get(t.deletionLineIndex-e);if(o!=null&&o.additions===t.additions&&o.deletions===t.deletions){if(t.additions>0&&n!=null){for(let e=0;e<t.additions;e++)if(n(o.additionLineIndex+e)!==r.additionLines[t.additionLineIndex+e])return a}return e}}return a},o=[],s=0,c=0;for(let e of r.hunks){ot(e,r,a);let t=e.additionCount>0?e.additionLineIndex-s:e.deletionLineIndex-c;s+=t,c+=t;for(let t of e.hunkContent){if(t.type===`context`){s+=t.lines,c+=t.lines;continue}let e=On(t,0,0);e.additions===0&&(e.additionLineIndex=s),e.deletions===0&&(e.deletionLineIndex=c),o.push(e),s+=e.additions,c+=e.deletions}}return o}function Wn(e){let t=new Map;for(let n of e)for(let e of n.hunkContent)e.type===`change`&&(e.additions===0||e.deletions===0)&&t.set(e.deletionLineIndex,e);return t}function Gn(e,t,n){let r=e.map((e,t)=>{let n=X(e);return{deletionStart:n,deletionEnd:n+e.deletionCount,blocks:[],previousSpan:{firstIndex:t,lastIndex:t}}}),i=[],a=0;for(let e of t){let t=e.deletionLineIndex,o=t+e.deletions;for(;a<r.length&&r[a].deletionEnd<t;)i.push(r[a]),a++;let s=i.length>0&&Kn(t,o,i[i.length-1])?i.pop():void 0;for(;a<r.length&&r[a].deletionStart<=o;)s=qn(s,r[a]),a++;if(s==null){let c=t,l=o;if((e.deletions===0||e.additions===0)&&n>e.deletions){let e=i[i.length-1]?.deletionEnd??0,s=r[a]?.deletionStart??n;t>e?c--:o<s&&l++}s={deletionStart:c,deletionEnd:l,blocks:[],previousSpan:void 0}}s.deletionStart=Math.min(s.deletionStart,t),s.deletionEnd=Math.max(s.deletionEnd,o),s.blocks.push(e),i.push(s)}for(;a<r.length;)i.push(r[a]),a++;return i}function Kn(e,t,n){return e<=n.deletionEnd&&t>=n.deletionStart}function qn(e,t){return e==null?t:(e.deletionStart=Math.min(e.deletionStart,t.deletionStart),e.deletionEnd=Math.max(e.deletionEnd,t.deletionEnd),e.blocks.push(...t.blocks),t.previousSpan!=null&&(e.previousSpan??={...t.previousSpan},e.previousSpan.firstIndex=Math.min(e.previousSpan.firstIndex,t.previousSpan.firstIndex),e.previousSpan.lastIndex=Math.max(e.previousSpan.lastIndex,t.previousSpan.lastIndex)),e)}function Jn(e,t){let n=[],r=0,i=0;for(let a of t){let t=a.deletionStart-r;if(t<0)throw Error(`buildRegionHunks: overlapping old-side regions`);r+=t,i+=t;let o=i,s=[];for(let e of a.blocks){let t=e.deletionLineIndex-r,n=e.additionLineIndex-i;if(t<0||t!==n)throw Error(`buildRegionHunks: canonical block context mismatch`);Xn(s,t,i,r),r+=t,i+=n,s.push({...e}),r+=e.deletions,i+=e.additions}let c=a.deletionEnd-r;if(c<0)throw Error(`buildRegionHunks: block exceeds its old-side region`);Xn(s,c,i,r),r+=c,i+=c,n.push(Yn(e,{additionStart:o,additionEnd:i,deletionStart:a.deletionStart,deletionEnd:a.deletionEnd},s))}if(e.deletionLines.length-r!==e.additionLines.length-i)throw Error(`buildRegionHunks: trailing context mismatch`);return n}function Yn(e,t,n){let r=t.additionEnd-t.additionStart,i=t.deletionEnd-t.deletionStart,a=0,o=0;for(let e of n)e.type===`change`&&(a+=e.additions,o+=e.deletions);let s={collapsedBefore:0,additionStart:tr(t.additionStart,r),additionCount:r,additionLines:a,additionLineIndex:nr(t.additionStart,r),deletionStart:tr(t.deletionStart,i),deletionCount:i,deletionLines:o,deletionLineIndex:nr(t.deletionStart,i),hunkContent:n,hunkSpecs:`@@ -${tr(t.deletionStart,i)},${i} +${tr(t.additionStart,r)},${r} @@`,splitLineStart:0,splitLineCount:0,unifiedLineStart:0,unifiedLineCount:0,noEOFCRAdditions:!1,noEOFCRDeletions:!1};return kn(s),s}function Xn(e,t,n,r){t>0&&e.push({type:`context`,lines:t,additionLineIndex:n,deletionLineIndex:r})}function Zn(e,t){if(e.length!==t.length)return!0;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(X(r)!==X(i)||r.deletionCount!==i.deletionCount||er(r)!==er(i)||r.additionCount!==i.additionCount||r.splitLineCount!==i.splitLineCount||!Qn(r,i))return!0}return!1}function Qn(e,t){let n=$n(e),r=$n(t);for(;;){let e=n.next(),t=r.next();if(e.done===!0||t.done===!0)return e.done===t.done;if(e.value[0]!==t.value[0]||e.value[1]!==t.value[1])return!1}}function*$n(e){for(let t of e.hunkContent){if(t.type===`context`){for(let e=0;e<t.lines;e++)yield[t.deletionLineIndex+e,t.additionLineIndex+e];continue}let e=Math.max(t.deletions,t.additions);for(let n=0;n<e;n++)yield[n<t.deletions?t.deletionLineIndex+n:void 0,n<t.additions?t.additionLineIndex+n:void 0]}}function er(e){return F(e.additionStart,e.additionCount)}function X(e){return F(e.deletionStart,e.deletionCount)}function tr(e,t){return t===0?e:e+1}function nr(e,t){return t===0?e-1:e}function rr(e){An(e);for(let t=0;t<e.hunks.length;t++)En(e,t)}function ir(e){return R({tagName:`div`,properties:{"data-content-buffer":``,"data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function ar(e){return R({tagName:`div`,children:[R({tagName:`span`,children:[ut(`No newline at end of file`)]})],properties:{"data-no-newline":``,"data-line-type":e,"data-column-content":``}})}function or(e){return R({tagName:`div`,children:[M({name:e===`both`?`diffs-icon-expand-all`:`diffs-icon-expand`,properties:{"data-icon":``}})],properties:{role:`button`,"data-expand-button":``,"data-expand-both":e===`both`?``:void 0,"data-expand-up":e===`up`?``:void 0,"data-expand-down":e===`down`?``:void 0}})}function Z({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:a,isLastHunk:o}){let s=0,c=[];if(e===`metadata`&&t!=null&&c.push(R({tagName:`div`,children:[ut(t)],properties:{"data-separator-wrapper":``}})),(e===`line-info`||e===`line-info-basic`)&&t!=null){let e=[];n!=null&&(r?(a||(e.push(or(`up`)),s++),o||(e.push(or(`down`)),s++)):(e.push(or(!a&&!o?`both`:a?`down`:`up`)),s++)),e.push(R({tagName:`div`,children:[R({tagName:`span`,children:[ut(t)],properties:{"data-unmodified-lines":``}})],properties:{"data-separator-content":``}})),r&&n!=null&&e.push(R({tagName:`div`,children:[ut(`Expand all`)],properties:{role:`button`,"data-expand-button":``,"data-expand-all-button":``}})),c.push(R({tagName:`div`,children:e,properties:{"data-separator-wrapper":``,"data-separator-multi-button":s>1?``:void 0}}))}return e===`custom`&&i!=null&&c.push(R({tagName:`slot`,properties:{name:i}})),R({tagName:`div`,children:c,properties:{"data-separator":c.length===0?`simple`:e,"data-expand-index":n,"data-separator-first":a?``:void 0,"data-separator-last":o?``:void 0}})}function sr(e,t){return`hunk-separator-${e}-${t}`}function cr(e){let t=e.at(-1);return t==null?0:Math.max(L(t.additionStart,t.additionCount),L(t.deletionStart,t.deletionCount))}var lr=-1,ur=class{options;annotationSlotName;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++lr}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLangs=[`text`];renderCache;pendingHighlightResult;pendingStructuralRows;editSessionActive=!1;constructor(e={theme:b},t=w,n,r){this.options=e,this.annotationSlotName=t,this.onRenderUpdate=n,this.workerManager=r,r?.isWorkingPool()!==!0&&(this.highlighter=Ue(e.theme??b)?Ge():void 0)}cleanUp(){this.endEditSession(),this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.editSessionActive?(this.renderCache!=null&&(this.renderCache.renderRange=void 0),this.pendingHighlightResult=void 0,this.pendingStructuralRows=void 0):this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this)}beginEditSession(e,t){let{editSessionActive:n}=this;this.editSessionActive=!0,n||(this.pendingHighlightResult=void 0),this.diff=e,n&&this.renderCache!=null&&this.renderCache.diff!==e&&this.clearRenderCache();let{renderCache:r}=this;if(!e.isPartial&&e.additionLines.length===0){Object.assign(e,vn(e,this.options.parseDiffOptions)),this.markEditSessionPass(e),this.clearRenderCache();return}if(r==null||n&&r.diff===e)return;let{options:i}=this.getRenderOptions(e),a=r.diff===e,o=t!=null&&B(r.diff,t),{result:s}=r;!r.highlighted||s==null||!V(r.options,i)||!a&&!o?this.clearRenderCache():a||(this.renderCache={diff:e,options:i,highlighted:!0,result:{...s,code:{...s.code,additionLines:[...s.code.additionLines]}},renderRange:r.renderRange})}endEditSession(){this.editSessionActive=!1,this.pendingHighlightResult=void 0,this.diff??this.clearRenderCache()}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}refreshHighlightedResult(){let{diff:e,renderCache:t,workerManager:n}=this;return e==null||t==null||!B(t.diff,e)||$e(e)||wr(e,this.getTokenizeMaxLength())?Promise.resolve():!this.editSessionActive&&n?.isWorkingPool()===!0&&e.cacheKey!=null?(n.evictDiffFromCache(e.cacheKey),n.primeDiffHighlightCache(e).then(()=>{this.applyRefreshedResult(e,n.getDiffResultCache(e))}).catch(e=>this.onHighlightError(e))):this.asyncHighlight(e).then(t=>this.applyRefreshedResult(e,t)).catch(e=>this.onHighlightError(e))}applyRefreshedResult(e,t){let{diff:n,renderCache:r}=this;if(t==null||n==null||r==null||!B(n,e)||!B(r.diff,e)||this.editSessionActive)return;let{options:i}=this.getRenderOptions(n);V(i,t.options)&&(this.pendingHighlightResult={diff:n,options:t.options,highlighted:!0,result:t.result},this.onRenderUpdate?.())}get diffCache(){return this.renderCache?.diff??this.diff}clearRenderCache(){this.renderCache=void 0,this.pendingHighlightResult=void 0,this.pendingStructuralRows=void 0}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){let r={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};(t===`up`||t===`both`)&&(r.fromStart+=n),(t===`down`||t===`both`)&&(r.fromEnd+=n),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??v}getExpandedHunksMap(){return this.expandedHunks}setExpandedHunksMap(e){this.expandedHunks=e}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(let t of e){let e=(()=>{switch(t.side){case`deletions`:return this.deletionAnnotations;case`additions`:return this.additionAnnotations}})(),n=e[t.lineNumber]??[];e[t.lineNumber]=n,n.push(t)}}updateRenderCache(e,t,n=!1,r,i){this.pendingStructuralRows=void 0;let{renderCache:a}=this;if(a==null)return!1;let{result:o,diff:s}=a;if(o==null)return!1;if(s.isPartial)throw Error(`Could not update render cache for partial diff`);let c=o.code.additionLines,l=this.pendingStructuralRows=n?new Map:void 0,u=[],d=new Map;if(l==null&&r!=null){let t=s.additionLines.length,n=br(s.additionLines,i);for(let[i,a]of r){if(i<0||i>t||i===t&&(a===``||!n))continue;let r=s.additionLines[i]??``;r!==a&&(s.additionLines[i]=a,u.push(i),d.set(i,r),e.has(i)||(c[i]=xr(i,he(a))))}}for(let[t,n]of e){let e=c[t]?.properties??{},i=n.map(e=>e[2]).join(``),a=t<s.additionLines.length,o=a?s.additionLines[t]??``:``,f=he(o);l==null&&a&&r?.has(t)!==!0&&(s.additionLines[t]=ne(o,i),f!==i&&(u.push(t),d.set(t,o)));let p={type:`element`,tagName:`div`,properties:{"data-line":e[`data-line`]??t+1,"data-line-index":e[`data-line-index`]??t,"data-line-type":e[`data-line-type`]??`context`},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})};l==null?c[t]=p:l.set(t,p)}let f=!1;if(u.length>0){if(this.editSessionActive){if(s.additionLines.length<=1&&s.additionLines.join(``)===``)this.applyRecomputePreservingSessionType(s,vn(s,this.options.parseDiffOptions)),f=!0;else if(gn(s,s.additionLines))this.applyRecomputePreservingSessionType(s,_n(s,s.additionLines,this.options.parseDiffOptions)),f=!0;else{let e=Fn(s,u,this.options.parseDiffOptions,d);this.applyExpansionRemap(e),f=e!=null}}else Object.assign(s,Sn(s,u,this.options.parseDiffOptions))}return o.baseThemeType=t,a.isDirty=!0,f}applyExpansionRemap(e){e!=null&&(this.expandedHunks=zn(this.expandedHunks,e))}applyDocumentChange(e){let{pendingStructuralRows:t,renderCache:n}=this;this.pendingStructuralRows=void 0;let r=this.diff??n?.diff;if(r==null)return;let i=n?.result;if(r.isPartial)throw Error(`Could not apply document change for partial diff`);let{additionLines:a}=r;if(r.additionLines=Sr(e),i!=null&&(i.code.additionLines=yr(a,r.additionLines,i.code.additionLines,e)),r.additionLines.length<=1&&r.additionLines.join(``)===``?(this.applyRecomputePreservingSessionType(r,vn(r,this.options.parseDiffOptions)),i!=null&&(i.code.additionLines[0]=xr(0,e.getLineText(0)))):this.editSessionActive?this.applySessionDocumentChange(r,a):Object.assign(r,yn(r,this.options.parseDiffOptions)),t!=null&&i!=null)for(let[e,n]of t)e<i.code.additionLines.length&&(i.code.additionLines[e]=n);n!=null&&(n.isDirty=!0)}applySessionDocumentChange(e,t){let{parseDiffOptions:n}=this.options,r=e.additionLines;gn(e,r)?this.applyRecomputePreservingSessionType(e,_n(e,r,n)):this.applyExpansionRemap(Pn(e,n,e=>t[e]))}applyRecomputePreservingSessionType(e,t){let n=this.editSessionActive?e.type:void 0;Object.assign(e,t),n!=null&&(e.type=n),this.markEditSessionPass(e)}markEditSessionPass(e){this.editSessionActive&&(e.editSessionDirty=!0)}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e,contentProperties:{"data-line-type":e}}}getSplitLineDecoration({side:e,type:t}){let n=t===`change`?e===`deletions`?`change-deletion`:`change-addition`:t;return{gutterLineType:n,contentProperties:{"data-line-type":n}}}createAnnotationElement=e=>ee(e);getOptionsWithDefaults(){let{diffIndicators:e=`bars`,diffStyle:t=`split`,disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:a=!1,collapsed:o=!1,expandUnchanged:s=!1,collapsedContextThreshold:c=1,expansionLineCount:l=100,hunkSeparators:u=`line-info`,lineDiffType:d=`word-alt`,maxLineDiffLength:f=1e3,overflow:p=`scroll`,stickyHeader:m=!1,theme:h=b,headerRenderMode:g=`default`,tokenizeMaxLineLength:_=1e3,tokenizeMaxLength:v=y,useTokenTransformer:x=!1,useCSSClasses:S=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:a,collapsed:o,expandUnchanged:s,collapsedContextThreshold:c,expansionLineCount:l,hunkSeparators:u,lineDiffType:d,maxLineDiffLength:f,overflow:p,stickyHeader:m,theme:this.workerManager?.getDiffRenderOptions().theme??h,headerRenderMode:g,tokenizeMaxLineLength:_,tokenizeMaxLength:v,useTokenTransformer:x,useCSSClasses:S}}async initializeHighlighter(){return this.highlighter=await k(He(this.computedLangs,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=wr(e,this.getTokenizeMaxLength()),r=this.workerManager?.getDiffResultCache(e);r!=null&&!V(t,r.options)&&(r=void 0),this.renderCache??={diff:e,hydrated:!0,highlighted:!n&&!$e(e),options:t,result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter??(this.computedLangs=Cr(e),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??b}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getDiffRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let e=this.workerManager.getDiffRenderOptions();return this.editSessionActive&&e.useTokenTransformer!==!0?{...e,useTokenTransformer:!0}:e}let{theme:e,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}=this.getOptionsWithDefaults();return{theme:e,useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}})();this.getOptionsWithDefaults();let{renderCache:n}=this;return n?.result==null||!B(e,n.diff)||!V(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}getDiffForNextRender(e){let{options:t}=this.getRenderOptions(e);if(this.getReadyRenderResult(e,t)!=null||this.renderCache==null)return e;if(B(this.renderCache.diff,e))return this.renderCache.diff;let n=!(e.additionLines.length>0||e.deletionLines.length>0)||$e(e)||wr(e,this.getTokenizeMaxLength());return this.canRenderDiff(e,t,n)?e:this.renderCache.diff}canRenderDiff(e,t,n){let{renderCache:r}=this;return r==null||B(r.diff,e)?!0:n?r.result==null&&r.hydrated!==!0||this.workerManager?.isWorkingPool()===!0||this.highlighter!=null&&Ue(t.theme):r.result==null&&r.hydrated!==!0?!0:!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?!r.highlighted:this.highlighter!=null&&Ue(t.theme)}renderDiff(e=this.diff,t=x){if(this.diff=e,e==null){this.pendingHighlightResult=void 0;return}let{expandUnchanged:n,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),{options:i,forceHighlight:a}=this.getRenderOptions(e),o=this.getReadyRenderResult(e,i);this.pendingHighlightResult=void 0,o!=null&&(this.renderCache={...o,diff:e,renderRange:void 0},a=!1),this.renderCache??={diff:e,highlighted:!1,options:i,result:void 0,renderRange:void 0};let s=e.additionLines.length>0||e.deletionLines.length>0,c=!s||$e(e)||wr(e,this.getTokenizeMaxLength()),l=this.canRenderDiff(e,i,c),u=!B(e,this.renderCache.diff),d=!oe(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){let o=this.renderCache.result==null&&this.renderCache.highlighted&&!c&&!u&&O(t);l&&!o&&(c||this.renderCache.result==null||!this.renderCache.highlighted&&(u||d))&&(this.renderCache.diff=e,this.renderCache.options=i,this.renderCache.highlighted=!1,(this.renderCache.result==null||u||d||a)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,O(t)||n?!0:this.expandedHunks,r)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||a)&&this.workerManager.highlightDiffAST(this,e)}else{this.computedLangs=Cr(e),this.highlighter??=Ge();let t=this.highlighter!=null&&Ue(i.theme),n=this.highlighter!=null&&de(this.computedLangs),r=!c&&n;if(l&&this.highlighter!=null&&t&&(a||c||!this.renderCache.highlighted&&r||this.renderCache.result==null)){let{result:t,options:i}=this.renderDiffWithHighlighter(e,this.highlighter,c||!n);this.renderCache={diff:e,options:i,highlighted:r,result:t,renderRange:void 0}}(!t||!c&&!n)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.applyHighlightResult(e,t,n,!c)})}return this.renderCache.result==null?void 0:this.processDiffResult(this.renderCache.diff,t,this.renderCache.result)}async asyncRender(e,t=x){this.diff=e;let{result:n}=await this.asyncHighlight(e);return this.processDiffResult(e,t,n)}createPreElement(e,t,n){let{diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o}=this.getOptionsWithDefaults();return ce({type:`diff`,diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e){let t=wr(e,this.getTokenizeMaxLength());this.computedLangs=t?[`text`]:Cr(e);let n=this.highlighter!=null&&Ue(this.getLocalHighlightTheme()),r=t||this.highlighter!=null&&de(this.computedLangs);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter,t)}renderDiffWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e),{collapsedContextThreshold:i}=this.getOptionsWithDefaults(),a=Ce(e,t,r,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:i});if(this.editSessionActive&&e.additionLines.length===1&&e.additionLines[0]===``&&a.code.additionLines[0]==null){let t;if(D({diff:e,diffStyle:`both`,expandedHunks:n?!0:void 0,collapsedContextThreshold:i,callback:({additionLine:e})=>{if(e?.lineIndex===0)return t=e,!0}}),t==null)throw Error(`DiffHunksRenderer: missing empty addition line`);a.code.additionLines[0]=xr(0,``,t.unifiedLineIndex,t.splitLineIndex)}return{result:a,options:r}}onHighlightSuccess(e,t,n,r=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){let{diff:i,renderCache:a}=this;i!=null&&a!=null&&B(i,e)&&V(n,this.getRenderOptions(i).options)&&(a.result!=null&&a.highlighted&&V(a.options,n)&&B(a.diff,i)||(this.pendingHighlightResult={diff:i,options:n,highlighted:r,result:t},this.onRenderUpdate?.()))}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getDiffResultCache(e);if(n!=null&&V(t,n.options))return n}getReadyRenderResult(e,t){let{pendingHighlightResult:n}=this;if(n!=null&&B(n.diff,e)&&V(n.options,t))return n;let r=this.getMatchingWorkerResultCache(e,t);if(!(r==null||this.hasHighlightedRenderCache(e,t)))return{diff:e,highlighted:!0,...r}}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&B(e,n.diff)&&V(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let{diffStyle:a,disableFileHeader:o,expandUnchanged:s,expansionLineCount:c,collapsedContextThreshold:l,hunkSeparators:u}=this.getOptionsWithDefaults(),d=this.renderCache?.isDirty??!1,f=a===`unified`,p=Tr(e,this.options.loadDiffFiles!=null),m=!e.isPartial||p,h=[],g=[],_=[],v=[],{additionLines:y,deletionLines:b}=n,x={rowCount:0,hunkSeparators:u,additionsContentAST:h,deletionsContentAST:g,unifiedContentAST:_,unifiedGutterAST:ft(),deletionsGutterAST:ft(),additionsGutterAST:ft(),expansionLineCount:c,hunkData:v,incrementRowCount(e=1){x.rowCount+=e},pushToGutter(e,t){switch(e){case`unified`:x.unifiedGutterAST.children.push(t);break;case`deletions`:x.deletionsGutterAST.children.push(t);break;case`additions`:x.additionsGutterAST.children.push(t)}}},S=Ve({fileDiff:e,errorPrefix:`DiffHunksRenderer.processDiffResult`}),C={size:0,side:void 0,increment(){this.size+=1},flush(){a!==`unified`&&(this.size<=0||this.side==null?(this.side=void 0,this.size=0):(this.side===`additions`?(x.pushToGutter(`additions`,U(void 0,`buffer`,this.size)),h?.push(ir(this.size))):(x.pushToGutter(`deletions`,U(void 0,`buffer`,this.size)),g?.push(ir(this.size))),this.size=0,this.side=void 0))}},w=(e,t,n,r,i)=>{x.pushToGutter(e,Ae(t,n,r,i))};function T(e){C.flush(),a===`unified`?gr(`unified`,e,x):(gr(`deletions`,e,x),gr(`additions`,e,x))}this.pushFileLevelAnnotations(e,a,t,x),D({diff:e,diffStyle:a,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:s?!0:this.expandedHunks,collapsedContextThreshold:l,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,additionLine:o,deletionLine:s,type:c})=>{let l=s==null?o.splitLineIndex:s.splitLineIndex,f=o==null?s.unifiedLineIndex:o.unifiedLineIndex;a===`split`&&c!==`change`&&C.flush(),r>0&&T({hunkIndex:t,collapsedLines:r,rangeSize:Math.max(n?.collapsedBefore??0,0),hunkSpecs:n?.hunkSpecs,isFirstHunk:t===0,isLastHunk:!1,isExpandable:m});let h=a===`unified`?f:l,g={type:c,hunkIndex:t,lineIndex:h,unifiedLineIndex:f,splitLineIndex:l,deletionLine:s,additionLine:o};if(a===`unified`){let n=this.getUnifiedInjectedRowsForLine?.(g);n?.before!=null&&pr(n.before,x);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex];if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let a=c===`change`?o==null?`change-deletion`:`change-addition`:c,u=this.getUnifiedLineDecoration({type:c,lineType:a,additionLineIndex:o?.lineIndex,deletionLineIndex:s?.lineIndex});w(`unified`,u.gutterLineType,o==null?s.lineNumber:o.lineNumber,`${f},${l}`,u.gutterProperties),i==null?r!=null&&(r=_r(r,u.contentProperties,d&&s!=null?{"data-line":s.lineNumber,"data-line-index":`${f},${l}`}:void 0)):i=_r(i,u.contentProperties,d&&o!=null?{"data-line":o.lineNumber,"data-line-index":`${f},${l}`}:void 0),hr({diffStyle:`unified`,type:c,deletionLine:r,additionLine:i,unifiedSpan:this.getAnnotations(`unified`,s?.lineNumber,o?.lineNumber,t,h),createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&pr(n.after,x)}else{let n=this.getSplitInjectedRowsForLine?.(g);n?.before!=null&&mr(n.before,x,C);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex],a=this.getSplitLineDecoration({side:`deletions`,type:c,lineIndex:s?.lineIndex}),u=this.getSplitLineDecoration({side:`additions`,type:c,lineIndex:o?.lineIndex});if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let f=(()=>{if(c===`change`){if(i==null)return`additions`;if(r==null)return`deletions`}})();f==null?c===`change`&&C.flush():(C.side!=null&&C.side!==f&&C.flush(),C.side=f,C.increment());let p=this.getAnnotations(`split`,s?.lineNumber,o?.lineNumber,t,h);if(p!=null&&C.size>0&&C.flush(),s!=null){let e=_r(r,a.contentProperties,d?{"data-line":s.lineNumber,"data-line-index":`${s.unifiedLineIndex},${l}`}:void 0);w(`deletions`,a.gutterLineType,s.lineNumber,`${s.unifiedLineIndex},${l}`,a.gutterProperties),e!=null&&(r=e)}if(o!=null){let e=_r(i,u.contentProperties,d?{"data-line":o.lineNumber,"data-line-index":`${o.unifiedLineIndex},${l}`}:void 0);w(`additions`,u.gutterLineType,o.lineNumber,`${o.unifiedLineIndex},${l}`,u.gutterProperties),e!=null&&(i=e)}hr({diffStyle:`split`,type:c,additionLine:i,deletionLine:r,...p,createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&mr(n.after,x,C)}let _=a===`split`&&n!=null&&l===n.splitLineStart+n.splitLineCount-1,v=t===e.hunks.length-1&&n!=null&&(a===`split`?l===n.splitLineStart+n.splitLineCount-1:f===n.unifiedLineStart+n.unifiedLineCount-1),E=_?n.noEOFCRDeletions:!1,D=_?n.noEOFCRAdditions:!1,O=(s?.noEOFCR??!1)||E,k=(o?.noEOFCR??!1)||D;if(k||O){if(a===`split`&&C.flush(),O){let e=c===`context`||c===`context-expanded`?c:`change-deletion`;a===`unified`?(x.unifiedContentAST.push(ar(e)),x.pushToGutter(`unified`,U(e,`metadata`,1))):(x.deletionsContentAST.push(ar(e)),x.pushToGutter(`deletions`,U(e,`metadata`,1)),k||(x.pushToGutter(`additions`,U(void 0,`buffer`,1)),x.additionsContentAST.push(ir(1))))}if(k){let e=c===`context`||c===`context-expanded`?c:`change-addition`;a===`unified`?(x.unifiedContentAST.push(ar(e)),x.pushToGutter(`unified`,U(e,`metadata`,1))):(x.additionsContentAST.push(ar(e)),x.pushToGutter(`additions`,U(e,`metadata`,1)),O||(x.pushToGutter(`deletions`,U(void 0,`buffer`,1)),x.deletionsContentAST.push(ir(1))))}x.incrementRowCount(1)}u!==`simple`&&u!==`metadata`&&(i>0||v&&p)&&T({hunkIndex:c===`context-expanded`?t:t+1,collapsedLines:v&&p?`unknown`:i,rangeSize:S,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:m}),x.incrementRowCount(1)}}),a===`split`&&C.flush();let E=Math.max(cr(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),O=t.bufferBefore>0||t.bufferAfter>0,k=!f&&e.type!==`deleted`,A=!f&&e.type!==`new`,j=x.rowCount>0||O;h=k&&j?h:void 0,g=A&&j?g:void 0,_=f&&j?_:void 0;let M=this.createPreElement(g!=null&&h!=null,E);return{fileDiff:e,unifiedGutterAST:f&&j?x.unifiedGutterAST.children:void 0,unifiedContentAST:_,deletionsGutterAST:A&&j?x.deletionsGutterAST.children:void 0,deletionsContentAST:g,additionsGutterAST:k&&j?x.additionsGutterAST.children:void 0,additionsContentAST:h,hunkData:v,preNode:M,themeStyles:r,baseThemeType:i,headerElement:o?void 0:this.renderHeader(e),totalLines:E,rowCount:x.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderCodeAST(e,t){let n=e===`unified`?t.unifiedGutterAST:e===`deletions`?t.deletionsGutterAST:t.additionsGutterAST,r=e===`unified`?t.unifiedContentAST:e===`deletions`?t.deletionsContentAST:t.additionsContentAST;if(n==null||r==null)return;let i=ft(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,me(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators===`line-info`,r=this.renderCodeAST(`unified`,e);if(r!=null)return t.push(R({tagName:`code`,children:r,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-unified":``}})),{...e.preNode,children:t};let i=this.renderCodeAST(`deletions`,e);i!=null&&t.push(R({tagName:`code`,children:i,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-deletions":``}}));let a=this.renderCodeAST(`additions`,e);return a!=null&&t.push(R({tagName:`code`,children:a,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-additions":``}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return W(this.renderFullAST(e,t))}renderPartialHTML(e,t){return W(t==null?e:R({tagName:`code`,children:e,properties:{"data-code":``,"data-container-size":this.getOptionsWithDefaults().hunkSeparators===`line-info`?``:void 0,[`data-${t}`]:``}}))}pushFileLevelAnnotations(e,t,n,r){if(!Se(n))return;let i=e.type===`new`?[]:this.getAnnotationNames(te(this.deletionAnnotations)),a=e.type===`deleted`?[]:this.getAnnotationNames(te(this.additionAnnotations));if(i.length===0&&a.length===0)return;let{createAnnotationElement:o}=this;hr(t===`unified`?{diffStyle:t,type:`context`,unifiedSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i.concat(a)},createAnnotationElement:o,context:r}:{diffStyle:t,type:`context`,deletionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i},additionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:a},createAnnotationElement:o,context:r})}getAnnotations(e,t,n,r,i){let a={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(t!=null)for(let e of this.deletionAnnotations[t]??[])a.annotations.push(this.annotationSlotName(e));let o={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(n!=null)for(let t of this.additionAnnotations[n]??[])(e===`unified`?a:o).annotations.push(this.annotationSlotName(t));if(e===`unified`)return a.annotations.length>0?a:void 0;if(o.annotations.length!==0||a.annotations.length!==0)return{deletionSpan:a,additionSpan:o}}getAnnotationNames(e){return e?.map(e=>this.annotationSlotName(e))??[]}renderHeader(e){let{headerRenderMode:t,stickyHeader:n}=this.getOptionsWithDefaults();return ue({fileOrDiff:e,mode:t,stickyHeader:n})}},dr=new Intl.PluralRules(`en-US`);function fr(e){return`${e} unmodified line${dr.select(e)===`one`?``:`s`}`}function pr(e,t){for(let n of e)t.unifiedContentAST.push(n.content),t.pushToGutter(`unified`,n.gutter),t.incrementRowCount(1)}function mr(e,t,n){for(let{deletion:r,addition:i}of e){if(r==null&&i==null)continue;let e=r!=null&&i!=null?void 0:r==null?`deletions`:`additions`;(e==null||n.side!==e)&&n.flush(),r!=null&&(t.deletionsContentAST.push(r.content),t.pushToGutter(`deletions`,r.gutter)),i!=null&&(t.additionsContentAST.push(i.content),t.pushToGutter(`additions`,i.gutter)),e!=null&&(n.side=e,n.increment()),t.incrementRowCount(1)}}function hr({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:a,additionSpan:o,createAnnotationElement:s,context:c}){let l=!1;if(e===`unified`){if(r==null?n!=null&&c.unifiedContentAST.push(n):c.unifiedContentAST.push(r),i!=null){let e=t===`change`?n==null?`change-addition`:`change-deletion`:t;c.unifiedContentAST.push(s(i)),c.pushToGutter(`unified`,U(e,`annotation`,1)),l=!0}}else if(e===`split`){if(n!=null&&c.deletionsContentAST.push(n),r!=null&&c.additionsContentAST.push(r),a!=null){let e=t===`change`?n==null?`context`:`change-deletion`:t;c.deletionsContentAST.push(s(a)),c.pushToGutter(`deletions`,U(e,`annotation`,1)),l=!0}if(o!=null){let e=t===`change`?r==null?`context`:`change-addition`:t;c.additionsContentAST.push(s(o)),c.pushToGutter(`additions`,U(e,`annotation`,1)),l=!0}}l&&c.incrementRowCount(1)}function gr(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:a,isLastHunk:o,isExpandable:s},c){if(typeof n==`number`&&n<=0)return;let l=e===`unified`?c.unifiedContentAST:e===`deletions`?c.deletionsContentAST:c.additionsContentAST;if(c.hunkSeparators===`metadata`){i!=null&&(c.pushToGutter(e,Z({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),l.push(Z({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1));return}if(c.hunkSeparators===`simple`){t>0&&(c.pushToGutter(e,Z({type:`simple`,isFirstHunk:a,isLastHunk:!1})),l.push(Z({type:`simple`,isFirstHunk:a,isLastHunk:!1})),e!==`additions`&&c.incrementRowCount(1));return}let u=sr(e,t),d=r>c.expansionLineCount,f=s?t:void 0,p=typeof n==`number`?fr(n):`More unchanged context may be available`;c.pushToGutter(e,Z({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),l.push(Z({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1),c.hunkData.push({slotName:u,hunkIndex:t,lines:typeof n==`number`?n:0,lineCountKnown:typeof n==`number`,type:e,expandable:s?{up:!a,down:!o,chunked:d}:void 0})}function _r(e,t,n){return e==null||e.type!==`element`||t==null&&n==null?e:{...e,properties:{...e.properties,...t,...n}}}function vr(e){return e.length>0&&e[e.length-1]===``?e.length-1:e.length}function yr(e,t,n,r){let i=vr(e),a=vr(t),o=Math.min(i,a),s=0;for(;s<o&&e[s]===t[s];)s++;let c=0;for(;c<o-s&&e[i-1-c]===t[a-1-c];)c++;let l=Array(t.length);for(let e=0;e<s;e++)l[e]=n[e];for(let e=0;e<c;e++)l[a-1-e]=n[i-1-e];i<e.length&&a<t.length&&(l[t.length-1]=n[e.length-1]);for(let e=s;e<t.length;e++)l[e]??=xr(e,r.getLineText(e));return l}function br(e,t){return t===e.length+1&&e.at(-1)?.endsWith(`
6
- `)===!0}function xr(e,t,n=e,r=e){return{type:`element`,tagName:`div`,properties:{"data-line":e+1,"data-line-index":`${n},${r}`,"data-line-type":`context`},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:t}]}]}}function Sr(e){let t=[];for(let n=0;n<e.lineCount;n++)t.push(e.getLineText(n,!0));return t}function Cr(e){if(e.lang!=null)return[e.lang];let t=p(e.prevName??e.name),n=p(e.name);return t===n?[n]:[t,n]}function wr(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function Tr(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function Er(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function Dr(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.lineCountKnown===t.lineCountKnown&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function Or(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:Ee(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators==`function`?`custom`:e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,loadDiffFiles:e?.loadDiffFiles,parseDiffOptions:e?.parseDiffOptions,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}function kr(e){return e.isPartial&&(e.type===`change`||e.type===`rename-changed`||e.type===`rename-pure`)}function Ar(e){let t={...e};return delete t.cacheKey,t}function jr(e,t){if(e.isPartial||t.isPartial)throw Error(`FileDiff.shouldResetEditorForExternalDiff: diffs must be fully hydrated`);let n=e.lang??p(e.name),r=t.lang??p(t.name),i=e.type!==`new`,a=t.type!==`new`;return e.name!==t.name||n!==r||i!==a||e.deletionLines.length!==t.deletionLines.length||e.deletionLines.some((e,n)=>e!==t.deletionLines[n])}function Mr(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Nr(e,t){let{oldFile:n}=e;return n==null?t.type===`new`:t.type!==`new`&&n.name===(t.prevName??t.name)&&Mr(n.lines,t.deletionLines)}var Pr=-1,Fr=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++Pr}`;type=`file-diff`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;editSession;renderedDiff;renderRange;pendingFiles;appliedPreAttributes;headerCache={lastRenderedHTML:void 0,html:void 0,fileDiff:void 0};lastRowCount;mounted=!1;enabled=!0;editor;refreshViewTimeout;lineStateRefreshPending=!1;deferredSelectedLines;deferredEditorActiveLine;constructor(e={theme:b},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new ge,this.scrollSyncManager=new pn,this.interactionManager=new mt(`diff`,A(e,typeof e.hunkSeparators==`function`||(e.hunkSeparators??`line-info`)===`line-info`||e.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??b}getHunksRendererOptions(e){return Or(e)}createHunksRenderer(e){return new ur(this.getHunksRendererOptions(e),this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t=`additions`)=>this.getLineIndexForDiff(this.getDiffForLineIndex(),e,t);getDiffForLineIndex(){return this.getRenderedDiff()}getLineIndexForDiff(e,t,n){if(e==null)return;let r=e.hunks.at(-1),i,a;hunkIterator:for(let o of e.hunks){let e=n===`deletions`?o.deletionStart:o.additionStart,s=n===`deletions`?o.deletionCount:o.additionCount,c=F(e,s)+1,l=o.splitLineStart,u=o.unifiedLineStart;if(t<c){let e=c-t;i=Math.max(u-e,0),a=Math.max(l-e,0);break hunkIterator}if(t>=c+s){if(o===r){let e=t-(c+s);i=u+o.unifiedLineCount+e,a=l+o.splitLineCount+e;break hunkIterator}}else{for(let e of o.hunkContent)if(e.type===`context`){if(t<c+e.lines){let e=t-c;a=l+e,i=u+e;break hunkIterator}c+=e.lines,l+=e.lines,u+=e.lines}else{let r=n===`deletions`?e.deletions:e.additions;if(t<c+r){let r=t-c;i=u+(n===`additions`?e.deletions:0)+r,a=l+r;break hunkIterator}c+=r,l+=Math.max(e.deletions,e.additions),u+=e.deletions+e.additions}break hunkIterator}}if(i!=null&&a!=null)return[i,a]}setOptions(e){e!=null&&(this.options=e,this.clearReusableHeader(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(A(this.options,typeof this.options.hunkSeparators==`function`||(this.options.hunkSeparators??`line-info`)===`line-info`||this.options.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType!==t&&(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!pe(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();getAnnotationSlotName=e=>pt(this.editSession?.annotations,e,w);getLatestAnnotations(){return this.editSession?.annotations?.current??this.lineAnnotations}isNewAnnotations(e){let t=this.editSession?.annotations;return e===this.lineAnnotations?!1:t==null||e!==t.provided&&e!==t.current}setLineAnnotations(e){let t=this.editSession?.annotations;t==null?this.lineAnnotations=e:this.isNewAnnotations(e)&&(this.lineAnnotations=e,ke(t,e,w))}syncEditSessionAnnotationsFromEditor(e){let t=this.editSession?.annotations;return t==null||e===t.current?!1:(t.current=e,this.hunksRenderer.setLineAnnotations(e),this.renderAnnotations(),!0)}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators==`function`)}setSelectedLines(e,t){this.lineStateRefreshPending?this.deferredSelectedLines=[e,t]:this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.lineStateRefreshPending?this.deferredEditorActiveLine=[e,t]:this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??`additions`})}flushDeferredLineState(){let{deferredEditorActiveLine:e,deferredSelectedLines:t}=this;this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,e!=null&&this.setEditorActiveLine(...e),t!=null&&this.interactionManager.setSelection(...t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:e=`split`,overflow:t=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t===`wrap`,columnVariables:this.shouldApplyColumnVariables(t)?`apply`:`measure`}),t===`scroll`&&e===`split`?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}shouldApplyColumnVariables(e){return typeof this.options.hunkSeparators==`function`||e===`scroll`&&(this.getLatestAnnotations().length>0||this.pre?.hasAttribute(`data-has-merge-conflict`)===!0)}getCodeScrollLeft(){return Math.max(this.codeUnified?.scrollLeft??0,this.codeDeletions?.scrollLeft??0,this.codeAdditions?.scrollLeft??0)}setCodeScrollLeft(e){this.codeUnified!=null&&(this.codeUnified.scrollLeft=e),this.codeAdditions!=null&&(this.codeAdditions.scrollLeft=e),this.codeDeletions!=null&&(this.codeDeletions.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(e=!1){let{editor:t}=this;d(this.handleEditSessionRender),this.emitPostRender(!0),t?.cleanUp(e?`recycle`:`discard`),e||(this.editor=void 0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,e||(this.pendingFiles=void 0),this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,this.headerCache.lastRenderedHTML=void 0,e||this.clearReusableHeader(),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.editSession=void 0,this.renderedDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate({fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:r,fileDiff:i,...a}){if(!this.enabled)throw Error(`FileDiff.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated`);let o=$t(a,`FileDiff.hydrate`),s=o?.oldFile,c=o?.newFile;this.hydrateElements(e,t);let l=this.editor!=null;l||Br(this.pre,Rr({fileDiff:i,oldFile:s,newFile:c}),this.options.collapsed)||Vr(this.headerElement,zr({fileDiff:i,oldFile:s,newFile:c}),this.options.disableFileHeader)?this.render({...a,fileContainer:e,lineAnnotations:r,fileDiff:i,forceRender:l||a.forceRender,preventEmit:!0}):this.hydrationSetup({fileDiff:i,lineAnnotations:r,...o}),n||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Qe(e,t);for(let t of e.shadowRoot?.children??[])if(t instanceof SVGElement)this.spriteSVG=t;else if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t;for(let e of t.children)e instanceof HTMLElement&&e.tagName.toLowerCase()===`code`&&(`deletions`in e.dataset&&(this.codeDeletions=e),`additions`in e.dataset&&(this.codeAdditions=e),`unified`in e.dataset&&(this.codeUnified=e))}else`diffsHeader`in t.dataset?this.headerElement=t:t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)?this.themeCSSStyle=t:t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent)}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){this.lineAnnotations=r??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?q(t,n,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderedDiff=this.fileDiff,this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.loadFilesIfNecessary(),this.hunksRenderer.expandHunk(e,t,n),this.rerender()};loadFilesIfNecessary(){let{fileDiff:e,options:{loadDiffFiles:t}}=this;if(e==null||!kr(e)||this.pendingFiles?.fileDiff===e)return;if(t==null)throw Error(`FileDiff: loadDiffFiles is required to load full files for a partial diff`);let n=this.loadFilesForDiff(e,t),r=this.pendingFiles={fileDiff:e,promise:n};r.promise=n.finally(()=>{this.pendingFiles===r&&(this.pendingFiles=void 0)})}__canAttachEditor(){return this.fileDiff!=null&&!this.fileDiff.isPartial}async prepareForEditing(){if(this.__canAttachEditor())return;let e=this.__prepareForEditing();if(e==null)throw this.fileDiff?.isPartial===!0&&!kr(this.fileDiff)?Error(`FileDiff.prepareForEditing: this partial diff cannot be hydrated; provide a complete diff`):Error(`FileDiff.prepareForEditing: a partial diff requires loadDiffFiles`);if(await e,!this.__canAttachEditor())throw Error(`FileDiff.prepareForEditing: the diff did not finish loading`)}__prepareForEditing(){if(!this.__canAttachEditor()){if(this.fileDiff?.isPartial===!0&&!kr(this.fileDiff))throw Error(`FileDiff: this partial diff cannot be hydrated; provide a complete diff to edit`);return this.loadFilesIfNecessary(),this.pendingFiles?.promise}}async loadFilesForDiff(e,t){try{let n=await t(e);if(this.fileDiff!==e)return;await this.handleFilesLoaded(e,n)}catch(e){if(this.options.disableErrorHandling===!0)throw e;console.error(e)}}async handleFilesLoaded(e,t){this.fileDiff===e&&e.isPartial&&(tn(`merge`,e,t),this.setHydratedState(t),this.installHydratedSessionDiff(e)?this.rerender():(await Yt(()=>this.primeHighlightCache(e)),this.enabled&&this.fileDiff===e&&this.rerender()))}installHydratedSessionDiff(e){if(e.isPartial)throw Error(`FileDiff.installHydratedSessionDiff: diffs cannot be partial for editing`);return this.fileDiff===e&&this.editSession?.outgoingDiff!=null&&(this.installEditSession(e),!0)}updateExternalDiff(e,t){if(B(this.fileDiff,e))return!1;let n=this.editSession?.outgoingDiff??this.editSession?.diff;return this.fileDiff=e,n!=null&&(e.isPartial?this.loadFilesIfNecessary():this.installEditSession(e),this.editSession!=null&&(this.editSession.outgoingDiff=n)),this.editSession?.annotations!=null&&t!=null&&(this.lineAnnotations=t,this.editSession.annotations=ct(t,w,this.editSession.annotations)),!0}installEditSession(e,t,n){let r=e.additionLines.join(``),i=t==null?void 0:en(t.contents),a=n!=null&&Nr(n,e);if(n!=null&&!a)throw Error(`FileDiff: retained session cannot resume against a different old file`);if(t!=null&&t.contents!==r&&!a)throw Error(`FileDiff: retained edits are missing their diff session state`);let o=t==null||t.name===e.name&&t.lang===e.lang&&t.contents===r,s=Ar(e);t!=null&&i!=null&&!o&&(s.name=t.name,s.lang=t.lang),a&&n!=null&&i!=null&&(s.additionLines=i,s.type=n.type,s.hunks=n.hunks,s.editSessionDirty=!0,An(s)),this.editSession={diff:s,annotations:this.editSession?.annotations??ct(this.lineAnnotations,w),outgoingDiff:this.editSession?.outgoingDiff},this.hunksRenderer.beginEditSession(s,o&&!a?e:void 0)}setHydratedState(e){this.deletionFile=e.oldFile,this.additionFile=e.newFile,this.workerManager?.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:e,deferManagers:t=!1,forceRender:n=!1,preventEmit:r=!1,lineAnnotations:i,fileContainer:a,containerWrapper:o,renderRange:s,...c}){if(!this.enabled)throw Error(`FileDiff.render: attempting to call render after cleaned up`);let l=$t(c,`FileDiff.render`),u=l?.oldFile,d=l?.newFile;this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:f=!1,themeType:p=`system`,expandUnchanged:m=!1}=this.options,h=f?void 0:s,_=this.hasThemeChanged(),v=l!=null,y=v&&(!Lr(u,this.deletionFile)||!Lr(d,this.additionFile)),b=e!=null&&!B(e,this.fileDiff),x=i!=null&&(i.length>0||this.getLatestAnnotations().length>0)&&this.isNewAnnotations(i);if(!f&&oe(h,this.renderRange)&&!n&&!x&&!_&&(e!=null&&!b||e==null&&!y)){let e=this.applyCachedThemeState(p);return e&&this.finalizeRender(),e}let S;e==null&&v&&(y||this.fileDiff==null)&&(S=q(l.oldFile,l.newFile,this.options.parseDiffOptions));let{renderRange:C}=this;this.renderRange=h,v?(this.deletionFile=u,this.additionFile=d):e!=null&&(this.deletionFile=void 0,this.additionFile=void 0),e!=null&&b?this.updateExternalDiff(e,i):S!=null&&(b=!0,this.updateExternalDiff(S,i)),b&&this.clearReusableHeader(),i!=null&&this.setLineAnnotations(i);let w=this.getLatestDiff();if(w==null)return!1;w.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(Hn(w,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),m&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.getLatestAnnotations());let{disableErrorHandling:T=!1,disableFileHeader:E=!1}=this.options;if(E&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.headerCache.lastRenderedHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,o),this.applyCachedThemeState(p),f){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(w,g);e!=null&&this.applyThemeState(a,e.themeStyles,p,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,a,e.fileDiff),this.renderSeparators([]),this.renderedDiff=e?.fileDiff??w,this.injectUnsafeCSS()}catch(e){if(T)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return this.finalizeRender(),r||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(a);if(!(this.canPartiallyRender(n,x,y||b||_||!B(this.renderedDiff,w))&&this.applyPartialRender({fileDiff:w,previousRenderRange:C,renderRange:h}))){let t=this.hunksRenderer.renderDiff(w,h);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.isWorkingPool()&&this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender()),!1;this.applyThemeState(a,t.themeStyles,p,t.baseThemeType),t.headerElement!=null&&this.applyHeaderToDOM(t.headerElement,a,t.fileDiff),t.additionsContentAST!=null||t.deletionsContentAST!=null||t.unifiedContentAST!=null?this.applyHunksToDOM(e,t):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(t.hunkData),this.renderedDiff=t.fileDiff}this.applyBuffers(e,h),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,t||this.flushManagers(),this.finalizeRender(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(T)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return r||this.emitPostRender(),!0}finalizeRender(){}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}getLatestDiff(e=this.fileDiff){return this.editSession?.diff??e}getRenderedDiff(){return this.renderedDiff}syncRenderViewToEditor(){let{editor:e,fileContainer:t}=this,n=this.getLatestAnnotations(),r=this.computeEditorRenderRange(this.renderRange),i=this.getLatestDiff();if(e==null||t==null||i==null||i.isPartial)return;let a=a=>{if(!this.enabled||this.editor!==e||this.fileContainer!==t||this.getLatestDiff()!==i)return;let o=this.editSession?.outgoingDiff,{fileDiff:s}=this,c=o!=null&&s!=null&&o!==i,l=c&&o!=null&&s!=null?jr(o,s):!1;e.__syncRenderView({highlighter:a,fileContainer:t,fileDiff:i,lineAnnotations:n,renderRange:r,externalDocument:c,resetHistory:l})},o=this.getTheme(),s=i.lang??p(i.name),c=Ge({theme:o,lang:s});c==null?k({themes:le(o),langs:[`text`,s],preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter}).then(a):a(c)}computeEditorRenderRange(e){let t=this.getLatestDiff();if(e==null||t==null||O(e))return e;let{diffStyle:n=`split`,expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a,o;return D({diff:t,diffStyle:n,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({additionLine:e})=>{e!=null&&(a??=e.lineNumber,o=e.lineNumber)}}),a==null||o==null?{...e,startingLine:0,totalLines:0}:{...e,startingLine:a-1,totalLines:o-a+1}}__acknowledgeDocumentUpdate(){this.editSession!=null&&(this.editSession.outgoingDiff=void 0)}__acceptEditorChange(e){let{lineAnnotations:t}=e;t!=null&&this.syncEditSessionAnnotationsFromEditor(t)}emitEditChange(e){let{onEditChange:t}=this.options;t?.(e)}__captureDocumentSessionState(e=!0){let{fileDiff:t,editSession:{diff:n,outgoingDiff:r}={}}=this;if(r!=null&&t!=null){if(!t.isPartial&&jr(r,t))return;n=r}if(!(n==null||n.isPartial))return{diffSession:{oldFile:n.type===`new`?null:{name:n.prevName??n.name,lines:e?[...n.deletionLines]:n.deletionLines},type:n.type,hunks:e?T(n.hunks):n.hunks},hasChanges:n.editSessionDirty===!0}}__attachEditor(e){if(this.type!==`file-diff`)throw Error(`FileDiff.__attachEditor: cannot attach an editor to a "${this.type}" diff`);if(this.editor!=null)throw Error(`FileDiff.__attachEditor: an editor is already attached`);if(!this.__canAttachEditor())throw Error(`FileDiff.__attachEditor: a complete diff is required before editing`);let t=()=>{this.editor=void 0,this.finishEditSession()};try{return this.resumeEditorRendering(e),t}catch(e){throw t(),e}}__resumeEditor(e){if(this.editor!==e)throw Error(`FileDiff.__resumeEditor: editor association changed`);this.resumeEditorRendering(e)}resumeEditorRendering(e){let{fileDiff:t}=this,n=this.editSession?.outgoingDiff;n!=null&&t!=null&&!t.isPartial&&this.editSession?.diff===n&&this.installEditSession(t);let r=this.editSession==null&&t!=null&&!t.isPartial?t:void 0;r==null?this.editSession!=null&&this.hunksRenderer.beginEditSession(this.editSession.diff):this.installEditSession(r,e.__getDocumentContents(Ir(r)),e.__getDocumentSessionState()),this.editor=e,this.fileDiff?.isPartial===!0&&this.loadFilesIfNecessary();let i=this.editSession?.diff;this.hunksRenderer.editorRenderReady()?(i!=null&&this.hunksRenderer.diffCache===i&&(this.renderedDiff=i),this.syncRenderViewToEditor()):this.rerender()}finishEditSession(){this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks()}__completeEditSession(e,t){this.settleEditSession(t===`install`,e)}settleEditSession(e,t){let{editSession:n,fileDiff:r,lineAnnotations:i}=this;if(n==null||r==null)return;let{diff:a,annotations:o}=n;if(this.editor!=null)throw Error(`FileDiff.__completeEditSession: detach the editor before completing the session`);this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks();let s=o?.current,c,l=null,u=null,d=!1,f;if(t==null)throw Error(`FileDiff.__completeEditSession: editor is required for completion`);let p=E(a),m={name:p.name,contents:p.additionLines.join(``)};p.lang!=null&&(m.lang=p.lang);let h={fileDiff:p,editor:t,originalFileDiff:r,oldFile:p.type===`new`?null:{name:p.prevName??p.name,contents:p.deletionLines.join(``)},newFile:m,lineAnnotations:s,originalLineAnnotations:i};Object.freeze(h);try{if(t.__emitEditComplete(h),this.options.onEditComplete?.(h)===`accept`){if(p.cacheKey!=null&&p.cacheKey===r.cacheKey)throw Error(`FileDiff.__completeEditSession: an accepted diff must not reuse the replaced diff cacheKey`);c=p,l=h.oldFile,u=h.newFile}}catch(e){d=!0,f=e}if(e&&c!=null&&(this.fileDiff=c,this.additionFile!=null&&(this.deletionFile=l,this.additionFile=u),s!=null&&(this.lineAnnotations=s)),this.editSession=void 0,e&&this.fileContainer!=null&&this.rerender(),d)throw f}finalizeEditSessionHunks(){let e=this.getLatestDiff();if(e==null||e.editSessionDirty!==!0)return!1;let{collapsedContextThreshold:t=1}=this.options,n=Bn(e,this.hunksRenderer.getExpandedHunksMap(),t);return Hn(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(Vn(e,n)),this.hunksRenderer.refreshHighlightedResult(),this.escalateEditSessionRender(),!0}applyDocumentChange(e,t){let n=this.editSession?.diff;if(n==null)throw Error(`FileDiff.applyDocumentChange: requires an active edit session`);this.detachAdditionLines(),this.hunksRenderer.beginEditSession(n),this.hunksRenderer.applyDocumentChange(e),t!=null&&this.syncEditSessionAnnotationsFromEditor(t),this.rerender(),this.interactionManager.setSelectionDirty()}applySuspendedDocumentChange(e,t){this.applyDocumentChange(e,t),this.hunksRenderer.clearRenderCache()}updateRenderCache(e,t,n={}){let r=this.editSession?.diff;if(r==null)throw Error(`FileDiff.updateRenderCache: requires an active edit session`);this.detachAdditionLines(),this.hunksRenderer.beginEditSession(r);let{shouldRefreshDiffsView:i,lineCountChangeInFlight:a}=n;this.hunksRenderer.updateRenderCache(e,t,a,n.changedDocumentLines,n.documentLineCount)?(this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!0,this.escalateEditSessionRender()):i===!0&&(this.refreshViewTimeout!=null&&clearTimeout(this.refreshViewTimeout),this.lineStateRefreshPending=!0,this.refreshViewTimeout=setTimeout(()=>{this.refreshViewTimeout=void 0,this.options.diffStyle===`split`?this.refreshSplitDiffView():this.refreshUnifiedDiffView(),this.flushDeferredLineState()},150))}detachAdditionLines(){let e=this.editSession?.diff,{fileDiff:t}=this;e!=null&&(e.additionLines===t?.additionLines||e.additionLines===e.deletionLines)&&(e.additionLines=[...e.additionLines])}isLineRenderable(e){let t=this.getRenderedDiff();if(t==null)return!0;let{expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options;return Me({fileDiff:t,lineNumber:e,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r})}getNearestRenderableLine(e,t){let n=this.getRenderedDiff();if(n==null)return e;let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;return nt({fileDiff:n,lineNumber:e,direction:t,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i})}revealLine(e){let t=this.getRenderedDiff(),{expandUnchanged:n=!1,collapsedContextThreshold:r=1,expansionLineCount:i=100}=this.options;if(t==null||t.isPartial||n)return!1;let a=this.hunksRenderer.getExpandedHunksMap();for(let[n,o]of t.hunks.entries()){let[s,c]=at(o);if(e<s){let c=Fe({isPartial:t.isPartial,rangeSize:o.collapsedBefore,expandedHunks:a,hunkIndex:n,collapsedContextThreshold:r}),l=s-c.rangeSize;if(c.renderAll||e<l+c.fromStart||e>=s-c.fromEnd)return!1;let u=e-(l+c.fromStart)+1,d=s-c.fromEnd-e;return u<=d?this.expandHunk(n,`up`,u+i):this.expandHunk(n,`down`,d+i),!0}if(e<c)return!1}let o=z({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:a,collapsedContextThreshold:r,errorPrefix:`FileDiff.revealLine`});if(o==null||o.renderAll)return!1;let s=t.hunks[t.hunks.length-1],[,c]=at(s);return e<c+o.fromStart||e>=c+o.rangeSize?!1:(this.expandHunk(t.hunks.length,`up`,e-(c+o.fromStart)+1+i),!0)}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){f(this.handleEditSessionRender)}handleEditSessionRender=()=>{this.rerender(),this.flushDeferredLineState()};removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.setPlaceholderHeight(e)}setPlaceholderHeight(e){return this.placeHolder!=null&&(this.placeHolder.style.setProperty(`height`,`${e}px`),!0)}async primeHighlightCache(e=this.fileDiff){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||$e(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(e=>{De(e)||console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.headerCache.lastRenderedHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){let{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!=`function`){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();return}let n=new Map(this.separatorCache);for(let r of e){let e=r.slotName,i=this.separatorCache.get(e);if(i==null||!Dr(r,i.hunkData)){i?.element.remove();let n=document.createElement(`div`);n.style.display=`contents`,n.slot=r.slotName;let a=t(r,this);a!=null&&n.appendChild(a),this.fileContainer.appendChild(n),i={element:n,hunkData:r},this.separatorCache.set(e,i)}n.delete(e)}for(let[e,{element:t}]of n.entries())this.separatorCache.delete(e),t.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options,n=this.getLatestAnnotations();if(t!=null&&n.length>0)for(let[r,i]of n.entries()){let n=this.getAnnotationSlotName(i),a=`${r}-${n}`,o=this.annotationCache.get(a);if(o==null||!Er(i,o.annotation)){o?.element.remove();let e=t(i);if(e==null)continue;o={element:N(n),annotation:i},o.element.appendChild(e),this.fileContainer.appendChild(o.element),this.annotationCache.set(a,o)}e.delete(a)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=P();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.headerCache.lastRenderedHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:ae(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):ae(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=We;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute(`data-unified`)?this.codeUnified=t:t.hasAttribute(`data-deletions`)?this.codeDeletions=t:t.hasAttribute(`data-additions`)&&(this.codeAdditions=t))}applyHeaderToDOM(e,t,n){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{headerCache:{fileDiff:r,html:i,lastRenderedHTML:a}}=this,o=(n!==this.editSession?.diff&&B(r,n)?i:void 0)??W(e);if(this.headerCache.html=o,this.headerCache.fileDiff=n,o!==a){let e=document.createElement(`div`);e.innerHTML=o;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.headerCache.lastRenderedHTML=o}if(this.isContainerManaged)return;let{renderCustomHeader:s,renderHeaderPrefix:c,renderHeaderFilenameSuffix:u,renderHeaderMetadata:d}=this.options;if(s!=null){let e=s(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,_,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}let f=c?.(n)??void 0,p=u?.(n)??void 0,h=d?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,m,f),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,l,p),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,S,h),this.headerCustom?.remove(),this.headerCustom=void 0}clearReusableHeader(){this.headerCache.html=void 0,this.headerCache.fileDiff=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;t!=null&&(e==null||e===``?(this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0):(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=ye(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=j(e),this.appliedUnsafeCSS=e))}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.getTheme(),s=typeof o==`string`?o:{...o},c=lt(i);this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c?this.appliedThemeCSS.theme=s:this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i?(this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}):(this.themeCSSStyle=Je({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:ve(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c})}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e!=null&&this.themeCSSStyle!=null&&(this.themeCSSStyle.textContent=dt(this.themeCSSStyle.textContent??``,lt(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&h()}applyHunksToDOM(e,t){this.shouldGuardRebuildScroll()?ze(e,()=>this.replaceCodeColumns(e,t)):this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){let r=this.getColumnPair(e);if(r==null)return!1;let i=Q(t[0]),a=Q(t[1]);return i==null||a==null?!1:(r.gutter.innerHTML=W(i),r.content.innerHTML=W(a),n!==this.lastRowCount&&(r.gutter.style.setProperty(`grid-row`,`span ${n}`),r.content.style.setProperty(`grid-row`,`span ${n}`)),!0)}replaceCodeColumns(e,t){let{overflow:n=`scroll`}=this.options,r=(this.options.hunkSeparators??`line-info`)===`line-info`,i=n===`wrap`?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let a=!1,o=[],s=this.hunksRenderer.renderCodeAST(`unified`,t),c=this.hunksRenderer.renderCodeAST(`deletions`,t),l=this.hunksRenderer.renderCodeAST(`additions`,t);this.editor?.__captureFocusForDOMReplacement(),s==null?c!=null||l!=null?(c==null?(this.codeDeletions?.remove(),this.codeDeletions=void 0):(a=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=Re({code:this.codeDeletions,columnType:`deletions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeDeletions,c,t.rowCount)||(this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(c)),o.push(this.codeDeletions)),l==null?(this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=a||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=Re({code:this.codeAdditions,columnType:`additions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeAdditions,l,t.rowCount)||(this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(l)),o.push(this.codeAdditions))):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=Re({code:this.codeUnified,columnType:`unified`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeUnified,s,t.rowCount)||(this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(s)),o.push(this.codeUnified)),o.length===0?e.textContent=``:a&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({fileDiff:e,previousRenderRange:t,renderRange:n}){let{pre:r,codeUnified:i,codeAdditions:a,codeDeletions:o,options:{diffStyle:s=`split`}}=this;if(r==null||t==null||n==null||!Number.isFinite(t.totalLines)||!Number.isFinite(n.totalLines)||this.lastRowCount==null)return!1;let c=this.getCodeColumns(s,i,o,a);if(c==null)return!1;let l=t.startingLine,u=n.startingLine,d=l+t.totalLines,f=u+n.totalLines,p=Math.max(l,u),m=Math.min(d,f);if(m<=p)return!1;let h=Math.max(0,p-l),g=Math.max(0,d-m),_=this.trimColumns({columns:c,trimStart:h,trimEnd:g,previousStart:l,overlapStart:p,overlapEnd:m,diffStyle:s});if(_<0)throw Error(`FileDiff.applyPartialRender: failed to trim to overlap`);if(this.lastRowCount<_)throw Error(`FileDiff.applyPartialRender: trimmed beyond DOM row count`);let v=this.lastRowCount-_,y=(t,n)=>{if(!(n<=0))return this.hunksRenderer.renderDiff(e,{startingLine:t,totalLines:n,bufferBefore:0,bufferAfter:0})},b=y(u,Math.max(p-u,0));if(b==null&&u<p)return!1;let x=y(m,Math.max(f-m,0));if(x==null&&f>m)return!1;let S=(e,t)=>{if(e!=null){if(s===`unified`&&!Array.isArray(c))this.insertPartialHTML(s,c,e,t);else if(s===`split`&&Array.isArray(c))this.insertPartialHTML(s,c,e,t);else throw Error(`FileDiff.applyPartialRender.applyChunk: invalid chunk application`);v+=e.rowCount,this.renderedDiff=e.fileDiff}};return this.cleanupErrorWrapper(),S(b,`afterbegin`),S(x,`beforeend`),this.lastRowCount!==v&&(this.applyRowSpan(s,c,v),this.lastRowCount=v),!0}insertPartialHTML(e,t,n,r){if(e===`unified`&&!Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`unified`,n);this.renderPartialColumn(t,e,r)}else if(e===`split`&&Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`deletions`,n),i=this.hunksRenderer.renderCodeAST(`additions`,n);this.renderPartialColumn(t[0],e,r),this.renderPartialColumn(t[1],i,r)}else throw Error(`FileDiff.insertPartialHTML: Invalid argument composition`)}refreshSplitDiffView(){let e=this.getLatestDiff();if(this.options.diffStyle!==`split`||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns(`split`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(n))return;let r=(e,n)=>{if(n==null)return;let r=this.hunksRenderer.renderCodeAST(e,t),i=Q(r?.[0]),a=Q(r?.[1]);for(let[e,t]of[[n.gutter,i],[n.content,a]])if(t!=null&&e.childElementCount===t.length)for(let n=0;n<t.length;n++){let r=e.children[n],i=t[n].properties[`data-line-type`];i!=null&&r.dataset.lineType!==i&&(r.dataset.lineType=i)}};r(`deletions`,n[0]),r(`additions`,n[1]),this.renderedDiff=t.fileDiff}refreshUnifiedDiffView(){let e=this.getLatestDiff();if(this.options.diffStyle!==`unified`||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns(`unified`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(n==null||Array.isArray(n))return;let r=this.hunksRenderer.renderCodeAST(`unified`,t),i=Q(r?.[0]),a=Q(r?.[1]),o=()=>{for(let[e,t]of[[n.gutter,i],[n.content,a]])t!=null&&(e.innerHTML=W(t));t.rowCount!==this.lastRowCount&&(this.applyRowSpan(`unified`,n,t.rowCount),this.lastRowCount=t.rowCount),this.renderedDiff=t.fileDiff};this.shouldGuardRebuildScroll()?ze(this.pre,o):o(),this.renderSeparators(t.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=Q(t[0]),i=Q(t[1]);if(r==null||i==null)throw Error(`FileDiff.insertPartialHTML: Unexpected AST structure`);let a=i.at(0);n===`beforeend`&&a?.type===`element`&&typeof a.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(a.properties[`data-buffer-size`],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let o=i.at(-1);n===`afterbegin`&&o?.type===`element`&&typeof o.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(o.properties[`data-buffer-size`],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,a){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let o=this.getBufferSize(t.dataset);o!=null&&(a?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(n,o+e))}applyRowSpan(e,t,n){let r=e=>{e!=null&&(e.gutter.style.setProperty(`grid-row`,`span ${n}`),e.content.style.setProperty(`grid-row`,`span ${n}`))};if(e===`unified`&&!Array.isArray(t))r(t);else if(e===`split`&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error(`dun fuuuuked up`)}trimColumnRows(e,t,n){let r=0,i=0,a=0,o=!1,s=n>=0;if(e==null)return 0;let c=Array.from(e.content.children),l=Array.from(e.gutter.children);if(c.length!==l.length)throw Error(`FileDiff.trimColumnRows: columns do not match`);for(;a<c.length&&!(t<=0&&!s&&!o);){let e=l[a],u=c[a];if(a++,!(e instanceof HTMLElement)||!(u instanceof HTMLElement))throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: invalid row elements`);if(o&&(o=!1,e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset||e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset))e.remove(),u.remove(),i++;else if(`lineIndex`in e.dataset&&`lineIndex`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),t>0&&(t--,t===0&&(o=!0)),i++),r++;else if(`separator`in e.dataset&&`separator`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);else if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);else if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);else if(e.dataset.gutterBuffer===`buffer`&&`contentBuffer`in u.dataset){let a=this.getBufferSize(u.dataset);if(a==null)throw Error(`FileDiff.trimColumnRows: invalid element`);if(t>0){let n=Math.min(t,a),r=a-n;r>0?(this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=n):(e.remove(),u.remove(),i+=a),t-=n,t===0&&r===0&&(o=!0)}else if(s){let t=r,o=r+a-1;if(n<=t)e.remove(),u.remove(),i+=a;else if(n<=o){let t=o-n+1,r=a-t;this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=t}}r+=a}else throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: unknown row elements`)}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:a,trimStart:o}){let s=Math.max(0,r-i),c=n-i;if(c<0)throw Error(`FileDiff.trimColumns: overlap ends before previous`);let l=o>0,u=a>0;if(!l&&!u)return 0;let d=l?s:0,f=u?c:-1;if(t===`unified`&&!Array.isArray(e))return this.trimColumnRows(e,d,f);if(t===`split`&&Array.isArray(e)){let t=this.trimColumnRows(e[0],d,f),n=this.trimColumnRows(e[1],d,f);if(e[0]!=null&&e[1]!=null&&t!==n)throw Error(`FileDiff.trimColumns: split columns out of sync`);return e[0]==null?n:t}throw console.error({diffStyle:t,columns:e}),Error(`FileDiff.trimColumns: Invalid columns for diffType`)}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??``,10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty(`grid-row`,`span ${t}`),e.style.setProperty(`min-height`,`calc(${t} * 1lh)`)}getColumnPair(e){if(e==null)return;let t=e.children[0],n=e.children[1];if(t instanceof HTMLElement&&n instanceof HTMLElement&&t.dataset.gutter!=null&&n.dataset.content!=null)return{gutter:t,content:n}}getCodeColumns(e,t,n,r){if(e===`unified`)return this.getColumnPair(t);{let e=this.getColumnPair(n),t=this.getColumnPair(r);return e!=null||t!=null?[e,t]:void 0}}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}applyBuffers(e,t){t==null||this.shouldDisableVirtualizationBuffers()?(this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)):(t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0))}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){let{diffIndicators:a=`bars`,disableBackground:o=!1,disableLineNumbers:s=!1,overflow:c=`scroll`,diffStyle:l=`split`}=this.options,u={type:`diff`,diffIndicators:a,disableBackground:o,disableLineNumbers:s,overflow:c,split:l!==`unified`&&t!=null&&n!=null,totalLines:r,customProperties:i};fe(u,this.appliedPreAttributes)||(Ie(e,u),this.appliedPreAttributes=u)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function Ir(e){return{name:e.name,lang:e.lang,contents:e.additionLines.join(``)}}function Lr(e,t){return e==null||t==null?e==null&&t==null:Be(e,t)}function Rr({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function zr({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function Br(e,t,n=!1){return!n&&e==null&&t}function Vr(e,t,n=!1){return e==null&&t&&!n}function Q(e){if(e!=null&&e.type===`element`)return e.children??[]}var Hr=3e3,Ur=new Map,Wr=-1,Gr=class extends Fr{__id=`little-virtualized-file-diff:${++Wr}`;renderType=`virtualized`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0,ghostTextRows:Ur,ghostTextRowsByIndex:new Map};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;pendingHydratedDiff;pendingExpansions;pendingRender;constructor(e,t,n,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=qe(n)}setMetrics(e,t=!1){let n=qe(e);(t||!ie(this.metrics,n))&&(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&(this.forceRenderOverride=!0)}syncLineAnnotations(e){return e==null||!this.isNewAnnotations(e)||e.length===0&&this.getLatestAnnotations().length===0?!1:(super.setLineAnnotations(e),!0)}syncEditSessionAnnotationsFromEditor(e){return super.syncEditSessionAnnotationsFromEditor(e)?(this.forceRenderOverride=!0,!0):!1}setFileAnnotationHeight(e){let t=this.cache.fileAnnotationHeight;return e!==t&&(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0)}hasFileAnnotations(e){let t=this.getLatestAnnotations();return be(t)?t.some(t=>t.lineNumber===0?e.type===`new`?t.side===`additions`:e.type!==`deleted`||t.side===`deletions`:!1):!1}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){let t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!et(t,e),r=n&&$r(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:ei(t,e)}),n&&(this.forceRenderOverride=!0),n&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1,resetRenderRange:n=!0}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal=0,this.cache.ghostTextRows=Ur,this.cache.ghostTextRowsByIndex.size>0&&this.cache.ghostTextRowsByIndex.clear(),this.invalidateDerivedLayoutCache(t,n),e&&this.isSimpleMode()&&this.computeApproximateSize()}invalidateDerivedLayoutCache(e,t=!0){this.layoutDirty=!0,this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),e&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&t&&(this.renderRange=void 0)}applyGhostTextRows(e,t){let{cache:{heightDeltas:n,ghostTextRows:r,ghostTextRowsByIndex:i},metrics:{lineHeight:a}}=this;if(r===t)return!1;let o=this.getDiffStyle(),s=new Map;for(let[n,r]of t){let t=this.getLineIndexForDiff(e,n+1,`additions`);t!=null&&s.set(o===`split`?t[1]:t[0],r)}let c=!1;for(let e of new Set([...i.keys(),...s.keys()])){let t=((s.get(e)??0)-(i.get(e)??0))*a;if(t===0)continue;let r=(n.get(e)??0)+t;r===0?n.delete(e):n.set(e,r),this.cache.measuredHeightDeltaTotal+=t,c=!0}return this.cache.ghostTextRows=t,this.cache.ghostTextRowsByIndex=s,c}reconcileHeights(){let e=!1,{options:{overflow:t=`scroll`},metrics:{lineHeight:n}}=this,r=this.placeHolder==null?this.getRenderedDiff():this.getLayoutDiff();if(this.fileContainer==null||r==null)return this.height!==0&&(e=!0),this.height=0,e;this.top=this.getVirtualizedTop(),e=this.applyGhostTextRows(r,this.editor?.__getGhostTextRows()??Ur);let{ghostTextRowsByIndex:i}=this.cache,a=t!==`scroll`||this.getLatestAnnotations().length>0||this.isResizeDebuggingEnabled();if(this.placeHolder!=null||!a&&this.cache.heightDeltas.size===0&&this.cache.fileAnnotationHeight===0)return e&&(this.computeApproximateSize(!0),this.setPlaceholderHeight(this.height)),e;let o=this.getDiffStyle(),s=o===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified];if(this.renderRange!=null&&Se(this.renderRange)){let t=Kr(s)??0;this.setFileAnnotationHeight(t)&&(e=!0)}for(let t of s){if(t==null)continue;let r=t.children[1];if(!(r instanceof HTMLElement))continue;let s=o===`split`&&t===this.codeDeletions;for(let t of r.children){if(!(t instanceof HTMLElement))continue;let r=t.dataset.lineIndex;if(r==null)continue;let c=ii(r,o),l=i.get(c)??0;if(s&&l>0)continue;let u=this.cache.heightDeltas.get(c)??0;if(!a&&u===l*n)continue;let d=t.getBoundingClientRect().height+l*n,f=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(f=!0),d+=t.nextElementSibling.getBoundingClientRect().height);let p=this.getEstimatedLineHeight(f),m=d-p;m!==u&&(e=!0,this.cache.measuredHeightDeltaTotal+=m-u,m===0?this.cache.heightDeltas.delete(c):this.cache.heightDeltas.set(c,m))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer!=null&&(e&&(this.top=this.getVirtualizedTop()),this.render());flushManagers(){super.flushManagers(),this.lineStateRefreshPending&&this.flushDeferredLineState()}updateCodeViewLayout(e,t,n,r){let i=!1,a=!1,{pendingExpansions:o,pendingHydratedDiff:s,options:{collapsed:c=!1}}=this;if(s!=null&&(this.pendingHydratedDiff=void 0,s.expectedDiff===e&&(Object.assign(e,s.nextDiff),this.setHydratedState(s.files),this.installHydratedSessionDiff(e),this.forceRenderOverride=!0,i=!0,a=!0)),o!=null){this.pendingExpansions=void 0;for(let{hunkIndex:e,direction:t,expansionLineCountOverride:n}of o)this.hunksRenderer.expandHunk(e,t,n),this.forceRenderOverride=!0,a=!0}let l=this.updateExternalDiff(e,r),{pendingRenderDiff:u,layoutDiffChanged:d,renderedDiffChanged:f,annotationsChanged:p}=this.updatePendingRender(e,r);return!this.forceRenderOverride&&(l||f||p)&&(this.forceRenderOverride=!0),(n?.resetDiffLayoutCache===!0||d)&&(i=!0),(d||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights)&&(a=!0),n?.metrics!=null&&(this.metrics=qe(n.metrics),i=!0,a=!0),this.currentCollapsed!==c&&(this.currentCollapsed=c,i=!0),i?this.resetLayoutCache({includeEstimatedHeights:a}):a&&this.invalidateDerivedLayoutCache(!0),this.top=t,this.computeApproximateSize(!1,u),this.height}getLinePosition(e,t=`additions`){let n=this.getLayoutDiff();if(n==null||e<1)return;let r=this.getLineIndexForDiff(n,e,t);if(r==null)return;let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsed:o=!1,collapsedContextThreshold:s=1}=this.options,c=this.getDiffStyle(),l=this.getHunkSeparatorType(),u=c===`split`?r[1]:r[0];this.approximateLayoutCheckpoints(n);let d=Pe(this.metrics,i),f=this.getLayoutCheckpointBeforeLineIndex(u),p=f?.top??d+this.cache.fileAnnotationHeight;if(o)return{top:st(this.metrics,i),height:0};let m;return D({diff:n,diffStyle:c,startingLine:f?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:s,callback:({hunkIndex:e,hunk:t,collapsedBefore:n,collapsedAfter:r,deletionLine:i,additionLine:a})=>{let o=c===`split`?a?.splitLineIndex??i?.splitLineIndex:a?.unifiedLineIndex??i?.unifiedLineIndex;if(o==null)throw Error(`VirtualizedFileDiff.getLinePosition: missing line index data`);if(n>0){let r=Xe({type:l,metrics:this.metrics,hunkIndex:e,hunkSpecs:t?.hunkSpecs});if(r!=null){if(p+=r.gapBefore,u>=o-n&&u<o)return m={top:p,height:r.height},!0;p+=r.height+r.gapAfter}}let s=this.getLineHeight(o,(a?.noEOFCR??!1)||(i?.noEOFCR??!1));if(o===u)return m={top:p,height:s},!0;if(p+=s,r>0){let e=H({type:l,metrics:this.metrics});if(e!=null){if(u>o&&u<=o+r)return m={top:p+e.gapBefore,height:e.height},!0;p+=e.totalHeight}}return!1}}),m}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){let t=this.getLayoutDiff();if(t==null)return;let{disableFileHeader:n=!1,expandUnchanged:r=!1,collapsed:i=!1,collapsedContextThreshold:a=1}=this.options;if(i)return;let o=this.getDiffStyle(),s=this.getHunkSeparatorType();this.approximateLayoutCheckpoints(t);let c=this.getLayoutCheckpointBeforeTop(e),l=c?.top??Pe(this.metrics,n)+this.cache.fileAnnotationHeight,u;return D({diff:t,diffStyle:o,startingLine:c?.renderedLineIndex??0,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:a,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,deletionLine:a,additionLine:c})=>{let d=o===`split`?c?.splitLineIndex??a?.splitLineIndex:c?.unifiedLineIndex??a?.unifiedLineIndex;if(d==null)throw Error(`VirtualizedFileDiff.getNumericScrollAnchor: missing line index data`);if(r>0){let e=Xe({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n?.hunkSpecs});e!=null&&(l+=e.totalHeight)}if(l>=e&&(a==null?c!=null&&(u={lineNumber:c.lineNumber,side:`additions`,top:l}):u={lineNumber:a.lineNumber,side:`deletions`,top:l},u!=null))return!0;let f=this.getLineHeight(d,(c?.noEOFCR??!1)||(a?.noEOFCR??!1));if(l+=f,i>0){let e=H({type:s,metrics:this.metrics});e!=null&&(l+=e.totalHeight)}return!1}}),u}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){let t=this.getLayoutDiff();if(this.top==null||t==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let n=e==null?this.renderRange:this.computeRenderRangeFromWindow(t,this.top,e);if(n==null)return;let{bufferBefore:r,bufferAfter:i,totalLines:a}=n,o=0;if(a===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(o=i)}return{topOffset:this.top+r+o,height:this.height-(r+i)}}cleanUp(e=!1){let t=this.cache.ghostTextRows.size>0;t&&(this.layoutDirty=!0);let n=e&&this.isAdvancedMode()&&this.fileContainer!=null&&(t||!B(this.getRenderedDiff(),this.getLatestDiff()));this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||(this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0),this.pendingRender=void 0,this.isSetup=!1,super.cleanUp(e),n&&this.virtualizer.instanceChanged(this,!0)}expandHunk=(e,t,n)=>{this.fileDiff!=null&&(this.loadFilesIfNecessary(),this.isAdvancedMode()?(this.pendingExpansions??=[],this.pendingExpansions.push({hunkIndex:e,direction:t,expansionLineCountOverride:n})):(this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))};async handleFilesLoaded(e,t){if(this.fileDiff===e&&e.isPartial){if(this.isAdvancedMode()){let n=tn(`clone`,e,t);if(await Yt(()=>this.primeHighlightCache(n)),this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(tn(`merge`,e,t),this.setHydratedState(t),!this.installHydratedSessionDiff(e)&&(await Yt(()=>this.primeHighlightCache(e)),this.fileDiff!==e))return;this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}}loadFilesIfNecessary(){if(this.pendingHydratedDiff!=null){if(this.pendingHydratedDiff.expectedDiff===this.fileDiff)return;this.pendingHydratedDiff=void 0}super.loadFilesIfNecessary()}isLineRenderable(e){if(super.isLineRenderable(e))return!0;let{pendingExpansions:t}=this,n=this.getRenderedDiff();if(t==null||t.length===0||n==null)return!1;let{expansionLineCount:r=100,collapsedContextThreshold:i=1}=this.options,a=new Map(this.hunksRenderer.getExpandedHunksMap());for(let e of t){let t={...a.get(e.hunkIndex)??{fromStart:0,fromEnd:0}},n=e.expansionLineCountOverride??r;(e.direction===`up`||e.direction===`both`)&&(t.fromStart+=n),(e.direction===`down`||e.direction===`both`)&&(t.fromEnd+=n),a.set(e.hunkIndex,t)}return Me({fileDiff:n,lineNumber:e,expandedHunks:a,collapsedContextThreshold:i})}invalidateEditSessionLayout(){this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),this.isSimpleMode()||this.computeApproximateSize(!0),this.getSimpleVirtualizer()?.requestHeightReconcile(this)}escalateEditSessionRender(){this.invalidateEditSessionLayout(),this.enabled&&this.fileDiff!=null&&(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))}shouldSelfHealEditSession(){return!this.isAdvancedMode()&&super.shouldSelfHealEditSession()}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){if(!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null)return;let e=this.getLatestDiff(),t=e==null?void 0:this.hunksRenderer.getDiffForNextRender(e);this.isSimpleMode()&&(this.pendingRender=void 0),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!B(this.getRenderedDiff(),t))}syncGhostTextRows(){let e=this.getAdvancedVirtualizer();e==null?this.getSimpleVirtualizer()?.requestHeightReconcile(this):(e.capturePendingLayoutAnchor(),this.layoutDirty=!0,e.instanceChanged(this,!0))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1});let i=this.getRenderedDiff();if(!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!=null&&i!=null){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(i,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.getLayoutDiff()){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,t==null){this.layoutDirty=!1;return}this.applyGhostTextRows(t,this.editor?.__getGhostTextRows()??Ur);let{disableFileHeader:i=!1,collapsed:a=!1}=this.options;a?(this.height+=st(this.metrics,i),this.layoutDirty=!1):(this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!r&&this.validateComputedHeight(t),this.layoutDirty=!1)}getLayoutDiff(){return this.pendingRender?.diff??this.getRenderedDiff()}getActiveEstimatedHeight(e=this.getLayoutDiff()){this.ensureEstimatedDiffHeights(e);let t=this.getDiffStyle()===`split`?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(t==null)throw Error(`VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height`);return t}ensureEstimatedDiffHeights(e=this.getLayoutDiff()){if(e==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,{splitHeight:i,unifiedHeight:a}=Xt({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:ti(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=i,this.cache.estimatedUnifiedHeight=a}validateComputedHeight(e=this.getLayoutDiff()){if(this.fileContainer==null||e==null)return;let t=this.fileContainer.getBoundingClientRect();t.height===this.height?console.log(`VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFileDiff.computeApproximateSize: computed height doesnt match`,{name:e.name,elementHeight:t.height,computedHeight:this.height})}render({fileContainer:e,fileDiff:t,forceRender:n=!1,lineAnnotations:r,...i}={}){let a=$t(i,`VirtualizedFileDiff.render`),o=a!=null,s=a?.oldFile,c=a?.newFile,l=o&&(!ri(s,this.deletionFile)||!ri(c,this.additionFile)),u=t??this.fileDiff;t==null&&o&&(l||this.fileDiff==null)&&(u=q(a.oldFile,a.newFile,this.options.parseDiffOptions));let{forceRenderOverride:d,isSetup:f}=this;this.forceRenderOverride=void 0;let p=u!=null&&!B(this.fileDiff,u),m=p||l;if(e=this.getOrCreateFileContainer(e),u==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;p&&this.updateExternalDiff(u,r);let{pendingRenderDiff:h,layoutDiffChanged:g,renderedDiffChanged:_,annotationsChanged:v}=this.pendingRender!=null&&this.pendingRender.latestDiff===(this.getLatestDiff(u)??u)?{pendingRenderDiff:this.pendingRender.diff,layoutDiffChanged:!1,renderedDiffChanged:!1,annotationsChanged:this.syncLineAnnotations(r)}:this.updatePendingRender(u,r);if(g&&this.resetLayoutCache({includeEstimatedHeights:!0}),f)this.top??=this.getVirtualizedTop(),this.layoutDirty&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,h));else{this.computeApproximateSize(!1,h);let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFileDiff.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!m||!f))return a!=null&&(this.deletionFile=s,this.additionFile=c),p&&this.clearReusableHeader(),this.renderPlaceholder(this.height);let y=this.virtualizer.getWindowSpecs(),b=this.top??0,x=this.computeRenderRangeFromWindow(h,b,y);return super.render({fileDiff:u,fileContainer:e,renderRange:x,lineAnnotations:r,forceRender:(d??n)||v||_||p,...a,...i})}finalizeRender(){if(!B(this.getRenderedDiff(),this.pendingRender?.diff))throw Error(`VirtualizedFileDiff.render: rendered a different diff than its prepared layout`);this.pendingRender=void 0,this.isSimpleMode()&&this.getSimpleVirtualizer()?.requestHeightReconcile(this)}updatePendingRender(e,t){let n=this.getLatestDiff(e)??e,r=this.getRenderedDiff(),{pendingRender:i}=this,a=i?.diff??r,o=this.hunksRenderer.getDiffForNextRender(n);return this.pendingRender={latestDiff:n,diff:o},{pendingRenderDiff:o,annotationsChanged:this.syncLineAnnotations(t),layoutDiffChanged:!B(a,o),renderedDiffChanged:!B(r,o)}}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type===`advanced`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??`split`}getHunkSeparatorType(){return ni(this.options.hunkSeparators)}approximateLayoutCheckpoints(e){if(!this.layoutDirty&&this.cache.checkpoints.length>0||e.hunks.length===0||this.options.collapsed===!0)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,i=e.hunks.length-1,a=ti(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),s=this.getHunkSeparatorType(),c=n?!0:this.hunksRenderer.getExpandedHunksMap(),l=qr(this.cache.heightDeltas),u=Pe(this.metrics,t)+this.cache.fileAnnotationHeight,d=0,f=({rowCount:e,startLineIndex:t,preSeparatorHeight:n=0,postSeparatorHeight:r=0,metadataOffsets:i=[]})=>{if(e<=0)return;let a=d,o=d+e,s=Xr(a);for(;s<o;){let e=s-a,r=u+(e>0?n:0)+e*this.metrics.lineHeight+Zr(i,e)*this.metrics.lineHeight+Jr(l,t,t+e);this.cache.checkpoints.push({renderedLineIndex:s,lineIndex:t+e,top:r}),s+=Hr}u+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+Jr(l,t,t+e)+r,d=o};for(let t=0;t<e.hunks.length;t++){let n=e.hunks[t];if(n==null)throw Error(`VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index`);let l=Fe({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:c,hunkIndex:t,collapsedContextThreshold:r}),u=l.collapsedLines>0?Xe({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n.hunkSpecs})?.totalHeight??0:0;f({rowCount:l.fromStart,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.rangeSize});let d=u;f({rowCount:l.fromEnd,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.fromEnd,preSeparatorHeight:d}),l.fromEnd>0&&(d=0);let p=t===i?z({fileDiff:e,hunkIndex:t,expandedHunks:c,collapsedContextThreshold:r,errorPrefix:`VirtualizedFileDiff`}):void 0,m=p!=null&&p.collapsedLines>0||t===i&&a?H({type:s,metrics:this.metrics})?.totalHeight??0:0,h=p==null?0:p.fromStart+p.fromEnd,g=o===`split`?n.splitLineCount:n.unifiedLineCount,_=o===`split`?n.splitLineStart:n.unifiedLineStart;f({rowCount:g,startLineIndex:_,preSeparatorHeight:d,postSeparatorHeight:h===0?m:0,metadataOffsets:Qr({diffStyle:o,hunk:n,rowCount:g})}),p!=null&&h>0&&f({rowCount:h,startLineIndex:_+g,postSeparatorHeight:m})}this.cache.totalLines=d}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);if(n.renderedLineIndex%t===0)return n}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let r of e.hunks)n+=t===`split`?r.splitLineCount:r.unifiedLineCount;return n}let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a=r?!0:this.hunksRenderer.getExpandedHunksMap();for(let[r,o]of e.hunks.entries()){let s=t===`split`?o.splitLineCount:o.unifiedLineCount;n+=s;let c=Math.max(o.collapsedBefore,0),{fromStart:l,fromEnd:u,renderAll:d}=Fe({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=z({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:a,collapsedContextThreshold:i,errorPrefix:`VirtualizedFileDiff`});return o!=null&&(n+=o.fromStart+o.fromEnd),n}getLayoutLineCount(e,t){let n=this.getExpandedLineCount(e,t),r=t===`split`?e.splitLineCount:e.unifiedLineCount;return Math.max(n,r,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:s,lineHeight:c}=this.metrics,l=this.getDiffStyle(),u=this.getHunkSeparatorType(),d=ti(e,this.options.loadDiffFiles!=null),f=this.height,p=this.getLayoutLineCount(e,l),m=Pe(this.metrics,i),h=e.hunks.length>0?Le(this.metrics):0,{fileAnnotationHeight:g}=this.cache,_=m+g,v=Math.max(0,f-m-g-h),y=this.hasFileAnnotations(e),b=t+m,x=g>0&&y&&b<r&&b+g>n;if(t<n-f||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h};if(p<=s||e.hunks.length===0)return{startingLine:0,totalLines:s,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),p=this.getLayoutLineCount(e,l);let S=Math.ceil(Math.max(r-n,0)/c),C=Math.ceil(S/s)*s+s,w=C/s,T=w,E=[],O=(n+r)/2,k=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-C*c*2),s),A=t+(k?.top??_),j=k?.renderedLineIndex??0,M,N,P;if(D({diff:e,diffStyle:l,startingLine:k?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:i,hunk:a,collapsedBefore:o,collapsedAfter:c,deletionLine:f,additionLine:p})=>{let m=p==null?f.splitLineIndex:p.splitLineIndex,h=p==null?f.unifiedLineIndex:p.unifiedLineIndex,g=(p?.noEOFCR??!1)||(f?.noEOFCR??!1),v=i===e.hunks.length-1&&a!=null&&(l===`split`?m===a.splitLineStart+a.splitLineCount-1:h===a.unifiedLineStart+a.unifiedLineCount-1),y=(o>0?Xe({type:u,metrics:this.metrics,hunkIndex:i,hunkSpecs:a?.hunkSpecs}):void 0)?.totalHeight??0;A+=y;let b=j%s===0,x=Math.floor(j/s);if(b&&(E[x]=A-(t+_+y),P!=null)){if(P<=0)return!0;P--}let S=this.getLineHeight(l===`split`?m:h,g);if(A>n-S&&A<r&&(M??=x),N==null&&A+S>O&&(N=x),P==null&&A>=r&&b&&(P=T),j++,A+=S,c>0||v&&d){let e=H({type:u,metrics:this.metrics});e!=null&&(A<r&&A+e.totalHeight>n&&(M??=x),N==null&&A+e.totalHeight>O&&(N=x),A+=e.totalHeight)}return!1}}),M==null){if(x)M=0,N=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h}}N??=M;let ee=Math.round(N-w/2),F=Math.max(0,Math.ceil(p/s)-w),I=Math.max(0,Math.min(ee,F)),te=I*s,ne=ee<0?C+ee*s:C,re=E[I]??0,ie=te===0?0:g+re,ae=I+ne/s,oe=ae<E.length?v-E[ae]:v-(A-t-_);return{startingLine:te,totalLines:ne,bufferBefore:ie,bufferAfter:Math.max(0,oe)}}};function Kr(e){let t;for(let n of e){if(n==null)continue;let e=n.children[1];if(e instanceof HTMLElement)for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===xe&&(t=Math.max(t??0,n.getBoundingClientRect().height))}return t}function qr(e){let t=Array.from(e).sort((e,t)=>e[0]-t[0]),n=[],r=[0],i=0;for(let[e,a]of t)n.push(e),i+=a,r.push(i);return{lineIndexes:n,prefixTotals:r}}function Jr({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=Yr(e,n);return(t[Yr(e,r)]??0)-(t[i]??0)}function Yr(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid prefix index`);a<t?n=i+1:r=i}return n}function Xr(e){return Math.ceil(e/Hr)*Hr}function Zr(e,t){let n=0;for(let r of e)r<t&&n++;return n}function Qr({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];let r=t.hunkContent.at(-1);if(r==null)return[];if(r.type===`context`)return[n-1];let i=Math.max(r.deletions,r.additions),a=r.deletions+r.additions;if(e===`split`)return i>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];let o=[],s=n-a;return r.deletions>0&&t.noEOFCRDeletions&&o.push(s+r.deletions-1),r.additions>0&&t.noEOFCRAdditions&&o.push(n-1),o}function $r(e,t){return(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function ei(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function ti(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function ni(e){return typeof e==`function`?`custom`:e??`line-info`}function ri(e,t){return e==null||t==null?e==null&&t==null:Be(e,t)}function ii(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}var $=e(t(),1),ai=typeof window>`u`?$.useEffect:$.useLayoutEffect;function oi({fileDiff:e,oldFile:t,newFile:n,options:r,editorOptions:i,editStateKey:a,lineAnnotations:o,selectedLines:s,prerenderedHTML:c,metrics:l,hasGutterRenderUtility:u,hasCustomHeader:d,disableWorkerPool:f,edit:p,onEditChange:m,onEditComplete:h}){let g=rt(),_=s!==void 0,v=(0,$.useContext)(we),y=vt(),[b,x]=(0,$.useState)(),S=yt(e=>m?.(e)),C=m==null?void 0:S,T=(0,$.useRef)(null),E=yt(r=>{let i=h?.(r)??`reject`;return i===`accept`&&(T.current={fileDiff:{installed:r.fileDiff,stale:r.originalFileDiff},filePair:e==null?{fileDiff:r.fileDiff,installed:{oldFile:r.oldFile,newFile:r.newFile},stale:{oldFile:t??null,newFile:n??null}}:null,annotations:{installed:r.lineAnnotations,stale:r.originalLineAnnotations}}),i}),D=h==null?void 0:E,O=si({acceptedCache:T,fileDiff:e,newFile:n,oldFile:t,parseDiffOptions:r?.parseDiffOptions}),k=(0,$.useRef)(null),A=(0,$.useRef)(null),j=(0,$.useRef)(null),M=yt(()=>{if(y==null)throw Error(`FileDiff: EditContext is not attached`);return y(`file-diff`,i??{},a)}),N=yt(e=>{if(e!=null){if(k.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);g==null?k.current=new Fr(ui({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:D,options:r}),f?void 0:v,!0):k.current=new Gr(ui({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:D,options:r}),g,l,f?void 0:v,!0),k.current.hydrate({fileDiff:O,fileContainer:e,lineAnnotations:o,prerenderedHTML:c})}else{if(k.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);j.current=null,k.current.cleanUp(),k.current=null,A.current=null}});ai(()=>{let{current:e}=k;if(e==null)return;let t=ui({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:D,options:r}),n=t!==void 0&&!et(e.options,t);if(e.setOptions(t),!p&&(j.current=null,A.current!=null)){let{current:e}=A;A.current=null,e()}let i=li(O,o,T);if(e.render({forceRender:n,fileDiff:i.fileDiff,lineAnnotations:i.lineAnnotations}),s!==void 0&&e.setSelectedLines(s),!p||A.current!=null)return;if(y==null)throw Error(`FileDiff: EditContext is not attached`);let a=()=>{k.current===e&&A.current==null&&e.__canAttachEditor()&&(A.current=di(e,M))};if(e.__canAttachEditor()){j.current=null,a();return}let c=e.__prepareForEditing();if(c==null){j.current=null;return}if(j.current?.promise===c)return;let l={promise:c};j.current=l,c.then(()=>{j.current===l&&(a(),j.current=null)}).catch(e=>{j.current===l&&(j.current=null,x(e))})});let P=(0,$.useCallback)(()=>k.current?.getHoveredLine(),[]),ee=(0,$.useCallback)(e=>k.current?.getAnnotationSlotName(e)??w(e),[]);if(b!=null)throw b;return{fileDiff:O,ref:N,getHoveredLine:P,getAnnotationSlotName:ee}}function si({acceptedCache:e,fileDiff:t,newFile:n,oldFile:r,parseDiffOptions:i}){return(0,$.useMemo)(()=>{if(t!=null)return t;let{current:a}=e,o=a?.filePair;if(a!=null&&o!=null){if(ci(r,n,o.stale)||ci(r,n,o.installed))return o.fileDiff;a.filePair=null}return q(r??null,n??null,i)},[e,t,r,n,i])}function ci(e,t,n){return I(e??void 0,n.oldFile??void 0)&&I(t??void 0,n.newFile??void 0)}function li(e,t,n){let{current:r}=n;if(r==null)return{fileDiff:e,lineAnnotations:t};let{fileDiff:i,annotations:a}=r,o=e;i!=null&&(B(e,i.stale)?o=i.installed:r.fileDiff=null);let s=t;return a!=null&&(t===a.stale?s=a.installed:r.annotations=null),r.fileDiff==null&&r.annotations==null&&r.filePair==null&&(n.current=null),{fileDiff:o,lineAnnotations:s}}function ui({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r,onEditChange:i,onEditComplete:a}){return t||r||n||i!=null||a!=null?{...e,controlledSelection:t,renderCustomHeader:n?_e:e?.renderCustomHeader,renderGutterUtility:r?_e:e?.renderGutterUtility,onEditChange:i,onEditComplete:a}:e}function di(e,t){let n=t();try{return n.edit(e)}catch(e){throw n.cleanUp(),e}}function fi({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:u,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderGutterUtility:h,disableWorkerPool:g=!1,edit:_=!1,onEditChange:v,onEditComplete:y}){let{ref:b,getHoveredLine:x,getAnnotationSlotName:S}=oi({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:h!=null,hasCustomHeader:d!=null,disableWorkerPool:g,edit:_,onEditChange:v,onEditComplete:y}),w=qt({fileDiff:e,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderAnnotation:u,renderGutterUtility:h,lineAnnotations:a,getHoveredLine:x,getAnnotationSlotName:S});return(0,K.jsx)(C,{ref:b,className:s,style:c,children:je(w,l)})}function pi({contentKey:e,diff:t,diffView:n,themeType:r,wrapLines:a,initiallyCollapsed:o=!1,compact:s=!1,scopeControl:c,onDiffViewChange:l,onWrapLinesChange:u,onClose:d}){let f=(0,$.useMemo)(()=>tt(t.patch),[t.patch]),[p,m]=(0,$.useState)(()=>new Set(o?f.map(e=>e.key):[])),h=f.length>0&&f.every(e=>p.has(e.key)),g=f.reduce((e,t)=>e+t.additions,0),_=f.reduce((e,t)=>e+t.deletions,0),v=e=>{m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},y=()=>m(h?new Set:new Set(f.map(e=>e.key))),b=e=>(0,K.jsxs)(`div`,{className:`diff-workspace-actions`,children:[e&&(0,K.jsx)(gi,{label:h?`Expand all files`:`Collapse all files`,onClick:y,children:h?(0,K.jsx)(bt,{}):(0,K.jsx)(xt,{})}),(0,K.jsx)(gi,{label:n===`unified`?`Use split diff`:`Use unified diff`,pressed:n===`split`,onClick:()=>l?.(n===`unified`?`split`:`unified`),children:n===`unified`?(0,K.jsx)(St,{}):(0,K.jsx)(Ct,{})}),(0,K.jsx)(gi,{label:a?`Disable line wrapping`:`Wrap long lines`,pressed:a,onClick:()=>u?.(!a),children:(0,K.jsx)(wt,{})}),d&&(0,K.jsx)(gi,{label:`Close diff`,onClick:d,children:(0,K.jsx)(ht,{})})]});return(0,K.jsxs)(`div`,{className:`diff-workspace${s?` compact`:``}`,children:[!s&&(0,K.jsxs)(`div`,{className:`diff-workspace-toolbar`,children:[c&&(0,K.jsx)(`div`,{className:`diff-workspace-scope`,children:c}),(0,K.jsxs)(`span`,{className:`diff-file-count`,children:[f.length,` `,f.length===1?`file`:`files`]}),(0,K.jsxs)(`span`,{className:`diff-total-stats`,"aria-label":`${g} additions and ${_} deletions`,children:[(0,K.jsxs)(`span`,{className:`add`,children:[`+`,g]}),(0,K.jsxs)(`span`,{className:`del`,children:[`−`,_]})]}),b(!0)]}),(0,K.jsx)(Ze,{className:`diff-workspace-scroll`,contentClassName:`diff-workspace-content`,children:f.map(o=>{let c=!s&&p.has(o.key);return(0,K.jsxs)(`section`,{className:`diff-file-section`,children:[s?(0,K.jsxs)(`div`,{className:`diff-file-header diff-file-header-compact`,children:[(0,K.jsx)(`img`,{src:_t(o.path),className:`diff-file-icon`,alt:``}),(0,K.jsx)(`span`,{className:`diff-file-path`,children:(0,K.jsx)(hi,{path:o.path})}),o.previousPath&&o.previousPath!==o.path&&(0,K.jsxs)(`span`,{className:`diff-file-previous`,children:[`from `,o.previousPath]}),(0,K.jsxs)(`span`,{className:`diff-file-stats`,children:[(0,K.jsxs)(`span`,{className:`add`,children:[`+`,o.additions]}),(0,K.jsxs)(`span`,{className:`del`,children:[`−`,o.deletions]})]}),b(!1)]}):(0,K.jsxs)(`button`,{type:`button`,className:`diff-file-header`,"aria-expanded":!c,onClick:()=>v(o.key),children:[c?(0,K.jsx)(gt,{className:`diff-file-chevron`}):(0,K.jsx)(i,{className:`diff-file-chevron`}),(0,K.jsx)(`img`,{src:_t(o.path),className:`diff-file-icon`,alt:``}),(0,K.jsx)(`span`,{className:`diff-file-path`,children:(0,K.jsx)(hi,{path:o.path})}),o.previousPath&&o.previousPath!==o.path&&(0,K.jsxs)(`span`,{className:`diff-file-previous`,children:[`from `,o.previousPath]}),(0,K.jsxs)(`span`,{className:`diff-file-stats`,children:[(0,K.jsxs)(`span`,{className:`add`,children:[`+`,o.additions]}),(0,K.jsxs)(`span`,{className:`del`,children:[`−`,o.deletions]})]})]}),!c&&(0,K.jsx)(fi,{fileDiff:o.fileDiff,disableWorkerPool:t.lineCount>1e4,options:{diffStyle:n,diffIndicators:`classic`,themeType:r,theme:Oe,overflow:a?`wrap`:`scroll`,disableFileHeader:!0,hunkSeparators:`line-info-basic`,unsafeCSS:Ye}},`${e}:${o.key}:${n}:${a}`)]},o.key)})})]},e)}function mi(e){let t=e.replaceAll(`\\`,`/`),n=t.lastIndexOf(`/`);return n<0?{name:t,directory:``}:{name:t.slice(n+1),directory:t.slice(0,n)}}function hi({path:e}){let{name:t,directory:n}=mi(e);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`diff-file-name`,children:t}),n?(0,K.jsx)(`small`,{className:`diff-file-directory`,children:n}):null]})}function gi({label:e,pressed:t,onClick:n,children:r}){return(0,K.jsxs)(s,{children:[(0,K.jsx)(c,{render:(0,K.jsx)(a,{type:`button`,variant:t?`secondary`:`ghost`,size:`icon-sm`,"aria-label":e,"aria-pressed":t,onClick:n}),children:r}),(0,K.jsx)(o,{children:e})]})}export{qt as a,Dt as c,en as i,Tt as l,Fr as n,Gt as o,ur as r,Et as s,pi as t};
@@ -1 +0,0 @@
1
- .source-file-viewer{background:var(--background);flex-direction:column;height:100%;min-height:0;display:flex;position:relative}.file-viewer-pill{z-index:10;border:1px solid color-mix(in oklch, var(--border) 82%, var(--foreground));background:color-mix(in oklch, var(--muted) 58%, var(--background));scrollbar-width:none;border-radius:999px;align-items:center;gap:4px;max-width:calc(100% - 16px);padding:4px;display:flex;position:absolute;top:10px;left:50%;overflow-x:auto;transform:translate(-50%);box-shadow:0 8px 28px #0000003d,inset 0 1px #ffffff0d}.file-viewer-pill::-webkit-scrollbar{display:none}.file-viewer-tabs{isolation:isolate;grid-template-columns:repeat(2,minmax(0,1fr));display:inline-grid;position:relative}.file-viewer-tabs>button{z-index:1;text-align:center;justify-content:center;width:100%;min-width:0;position:relative}.source-file-toolbar{z-index:10;position:absolute;top:10px;right:10px}.file-save-button{border:1px solid color-mix(in oklch, var(--border) 82%, var(--foreground));border-radius:var(--radius-md);background:color-mix(in oklch, var(--muted) 58%, var(--background));width:30px;height:30px;color:var(--muted-foreground);justify-content:center;align-items:center;transition:background-color .12s,border-color .12s,color .12s,transform .12s;display:inline-flex;box-shadow:0 8px 20px #0003,inset 0 1px #ffffff0d}.file-save-button[data-state=dirty]{border-color:color-mix(in oklch, var(--warning) 50%, var(--border));background:color-mix(in oklch, var(--warning) 14%, var(--muted));color:var(--warning)}.file-save-button[data-state=saving]{border-color:color-mix(in oklch, var(--primary) 50%, var(--border));background:color-mix(in oklch, var(--primary) 14%, var(--muted));color:var(--primary)}.file-save-button:hover:not(:disabled){border-color:color-mix(in oklch, var(--primary) 45%, var(--border));background:var(--accent);transform:translateY(-1px)}.file-save-button:disabled{cursor:default;opacity:.45}.file-save-button svg{width:15px;height:15px}.source-editor-scroll{flex:1;min-height:0;overflow:hidden}.source-code-editor{--diffs-font-family:var(--opentig-font-mono);width:100%;height:100%;color:var(--foreground);overflow:auto}.source-code-editor-content{min-width:100%;min-height:100%}
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Ct as t,xt as n}from"./base-ui-DDpgJXgO.js";import{t as r}from"./createReactComponent-BfrD_oQK.js";import{A as i,g as a,h as o,v as s}from"./index-CoZCJqTQ.js";import{a as c,i as l,n as u,o as d,s as f,t as p}from"./PierreWorkerPool-DMFigp0u.js";import{s as m,t as h}from"./shortcuts-BzIlT01I.js";import{x as g}from"./App-DEIZhWJG.js";import{t as _}from"./File-BPxtFxHC.js";import{t as v}from"./edit-ready-context-MO-PrQZN.js";var y=r(`outline`,`device-floppy`,`DeviceFloppy`,[[`path`,{d:`M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2`,key:`svg-0`}],[`path`,{d:`M10 14a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-1`}],[`path`,{d:`M14 4l0 4l-6 0l0 -4`,key:`svg-2`}]]),b=e(t()),x={stableFrames:3,maxFrames:60,userScrollTolerance:2};function S(e,t,n={}){let r=n.stableFrames??x.stableFrames,i=n.maxFrames??x.maxFrames,a=n.userScrollTolerance??x.userScrollTolerance,o=n.requestFrame??(e=>requestAnimationFrame(e)),s=n.cancelFrame??(e=>cancelAnimationFrame(e)),c=Number.isFinite(t)?Math.min(1,Math.max(0,t)):0,l=null,u=0,d=0,f=null,p=null,m=!1,h=()=>{m=!0,l!==null&&s(l),l=null},g=()=>{if(l=null,m)return;u+=1;let t=e.getContentHeight();if(p!==null&&f===t&&Math.abs(e.getScrollTop()-p)>a){h();return}let n=e.getScrollRange(),s=n>0?c*n:0;e.scrollTo(s),p=s,d=t>0&&f===t?d+1:0,f=t,d>=r||u>=i?h():l=o(g)};return g(),h}function C(e){let t=e.split(`+`),n=t.pop().toLowerCase();return[...t.map(e=>e===`Ctrl`?`cmdOrCtrl`:e.toLowerCase()),n].join(`+`)}function w(e){return[{bindings:{[C(e)]:`openSearchReplacePanel`}}]}w(h.editorSearch);var T=2e3;function E(e,t=T){let n=1;for(let r=0;r<e.length;r+=1)if(e.charCodeAt(r)===10&&(n+=1,n>t))return!0;return!1}function D(e,t,n=h.saveFile){return m({key:e.key,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey??!1,altKey:e.altKey??!1},n)?(e.preventDefault(),t(),!0):!1}async function O(e){if(!e.dirty||e.readOnly||!e.claim())return`skipped`;try{return(await e.persist()).status===`conflict`?(e.onConflict(),`conflict`):(e.onSuccess(),`saved`)}catch(t){return e.onError(t),`error`}finally{e.release()}}function k({file:e,initialContent:t,readOnly:n,messages:r,onDirtyChange:a,onDraftChange:o,onSave:s}){let c=g(),[l,u]=(0,b.useState)(t),[d,f]=(0,b.useState)(!1),p=(0,b.useRef)(!1),m=l!==e.content,h=(0,b.useRef)(e.content);(0,b.useLayoutEffect)(()=>{l===h.current&&e.content!==h.current&&u(e.content),h.current=e.content},[e.content,l]),(0,b.useEffect)(()=>{a(m)},[m,a]),(0,b.useEffect)(()=>()=>a(!1),[a]);let _=(0,b.useCallback)(t=>{u(t),a(t!==e.content),o(t)},[e.content,a,o]),v=(0,b.useCallback)(async()=>{await O({dirty:m,readOnly:n,claim:()=>!p.current&&(p.current=!0,f(!0),!0),release:()=>{p.current=!1,f(!1)},persist:()=>s(e.path,l,e.content),onConflict:()=>i.error({title:r.conflictTitle,description:`Your draft is still open. Copy it or reload the file before saving again.`,duration:1e4}),onSuccess:()=>i.success({title:r.successTitle,description:e.path}),onError:e=>i.error({title:r.errorTitle,description:e instanceof Error?e.message:`Unknown error`,duration:1e4})})},[m,l,e.content,e.path,r,s,n]),y=(0,b.useRef)(v);return(0,b.useEffect)(()=>{y.current=v},[v]),(0,b.useEffect)(()=>{let e=e=>{D(e,()=>{y.current()},c.saveFile)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c.saveFile]),{draft:l,updateDraft:_,dirty:m,saving:d,save:v}}var A=n();function j({dirty:e,saving:t,readOnly:n,onSave:r}){let i=g();if(!e&&!t)return null;let c=n?`Read only`:t?`Saving…`:`Save file (${i.saveFile})`;return(0,A.jsxs)(o,{children:[(0,A.jsx)(s,{render:(0,A.jsx)(`button`,{type:`button`,className:`file-save-button`,"data-state":n?`readonly`:t?`saving`:`dirty`,disabled:t||n,onClick:r,"aria-label":c}),children:(0,A.jsx)(y,{"aria-hidden":`true`})}),(0,A.jsx)(a,{children:c})]})}function M({handleRef:e}){let t=f();return(0,b.useLayoutEffect)(()=>{e.current=t},[t,e]),null}function N({path:e,cacheKey:t,value:n,themeType:r,wrapLines:i,readOnly:a,onChange:o,ref:s}){let f=(0,b.useContext)(v),m=g(),[h]=(0,b.useState)(()=>E(n)),y=(0,b.useRef)(o);(0,b.useEffect)(()=>{y.current=o},[o]);let x=(0,b.useRef)(void 0),C=(0,b.useRef)(null),T=(0,b.useMemo)(()=>({name:e,lang:l(e),contents:n,cacheKey:t}),[t,e,n]),D=(0,b.useMemo)(()=>({disableFileHeader:!0,themeType:r,theme:c,overflow:i?`wrap`:`scroll`,unsafeCSS:u}),[r,i]),O=(0,b.useMemo)(()=>({historyMaxEntries:500,keymap:w(m.editorSearch),onChange(e){y.current(e.file.contents)}}),[m.editorSearch]),k=(0,b.useRef)(null);(0,b.useEffect)(()=>()=>k.current?.(),[]),(0,b.useImperativeHandle)(s,()=>({getScrollFraction(){let e=x.current?.getRoot()??C.current;if(!(e instanceof HTMLElement))return 0;let t=e.scrollHeight-e.clientHeight;return t>0?e.scrollTop/t:0},scrollToFraction(e){k.current?.(),k.current=S({getScrollRange(){let e=x.current?.getRoot()??C.current;return e instanceof HTMLElement?Math.max(0,e.scrollHeight-e.clientHeight):0},getScrollTop(){let e=x.current?.getRoot()??C.current;return e instanceof HTMLElement?e.scrollTop:0},getContentHeight(){let e=x.current?.getRoot()??C.current;return e instanceof HTMLElement?e.scrollHeight:0},scrollTo(e){let t=x.current;t&&t.getRoot()instanceof HTMLElement?t.scrollTo({top:e}):C.current?.scrollTo({top:e})}},e)}}),[]);let j=(0,A.jsx)(_,{file:T,options:D,editorOptions:O,edit:f&&!a});return(0,A.jsx)(p,{theme:c,children:h?(0,A.jsxs)(d,{className:`source-code-editor`,contentClassName:`source-code-editor-content`,children:[(0,A.jsx)(M,{handleRef:x}),j]}):(0,A.jsx)(`div`,{ref:C,className:`source-code-editor`,children:(0,A.jsx)(`div`,{className:`source-code-editor-content`,children:j})})})}var P={conflictTitle:`File was changed outside OpenTig`,successTitle:`File saved`,errorTitle:`Could not save file`};function F({file:e,initialContent:t,themeType:n,wrapLines:r,readOnly:i,onDirtyChange:a,onDraftChange:o,onSave:s}){let{draft:c,updateDraft:l,dirty:u,saving:d,save:f}=k({file:e,initialContent:t,readOnly:i,messages:P,onDirtyChange:a,onDraftChange:o,onSave:s});return(0,A.jsxs)(`div`,{className:`source-file-viewer`,children:[(u||d)&&(0,A.jsx)(`div`,{className:`source-file-toolbar`,children:(0,A.jsx)(j,{dirty:u,saving:d,readOnly:i,onSave:()=>void f()})}),(0,A.jsx)(`div`,{className:`source-editor-scroll`,children:(0,A.jsx)(N,{path:e.path,cacheKey:e.path,value:c,themeType:n,wrapLines:r,readOnly:i||d,onChange:l})})]})}export{F as EditableFileViewer,j as FileSaveControls,N as SourceCodeEditor,S as n,k as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Ct as t,St as n,_ as r,d as i,f as a,p as o,u as s,v as c,xt as l,y as u}from"./base-ui-DDpgJXgO.js";import{o as d}from"./tanstack-CYi5knVJ.js";import{n as f,t as p}from"./createReactComponent-BfrD_oQK.js";import{t as m}from"./IconCheck-BPhxw_LS.js";import{t as h}from"./IconEdit-BP5Emwzw.js";import{n as g,t as _}from"./IconFolderSymlink-BNWI0eXB.js";import{t as ee}from"./IconLoader4-Bk6G4Bls.js";import{t as te}from"./IconSearch-ZL3YVslZ.js";import{O as ne,T as v,w as y}from"./index-CoZCJqTQ.js";import{$ as re,$t as b,Dt as x,G as ie,Gt as ae,J as S,Jt as oe,K as se,Kt as C,Ot as ce,Q as w,Tt as le,Ut as ue,W as de,Wt as T,X as E,Y as D,Z as fe,Zt as O,at as pe,b as me,d as k,dt as A,f as j,ft as he,gt as M,ht as ge,it as _e,jt as N,kt as P,mt as ve,nt as ye,ot as F,pt as be,qt as xe,rt as Se,st as Ce,tt as we,ut as Te,x as Ee,y as I,z as De}from"./App-DEIZhWJG.js";var L=p(`outline`,`arrow-back-up`,`ArrowBackUp`,[[`path`,{d:`M9 14l-4 -4l4 -4`,key:`svg-0`}],[`path`,{d:`M5 10h11a4 4 0 1 1 0 8h-1`,key:`svg-1`}]]),R=p(`outline`,`arrow-forward-up`,`ArrowForwardUp`,[[`path`,{d:`M15 14l4 -4l-4 -4`,key:`svg-0`}],[`path`,{d:`M19 10h-11a4 4 0 1 0 0 8h1`,key:`svg-1`}]]),Oe=p(`outline`,`clipboard`,`Clipboard`,[[`path`,{d:`M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2`,key:`svg-0`}],[`path`,{d:`M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2`,key:`svg-1`}]]),z=p(`outline`,`columns-2`,`Columns2`,[[`path`,{d:`M3 4a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v16a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-16`,key:`svg-0`}],[`path`,{d:`M12 3v18`,key:`svg-1`}]]),B=p(`outline`,`cut`,`Cut`,[[`path`,{d:`M4 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-0`}],[`path`,{d:`M14 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-1`}],[`path`,{d:`M9.15 14.85l8.85 -10.85`,key:`svg-2`}],[`path`,{d:`M6 4l8.85 10.85`,key:`svg-3`}]]),ke=p(`outline`,`file-plus`,`FilePlus`,[[`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`,key:`svg-0`}],[`path`,{d:`M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2`,key:`svg-1`}],[`path`,{d:`M12 11l0 6`,key:`svg-2`}],[`path`,{d:`M9 14l6 0`,key:`svg-3`}]]),V=e(t()),Ae=e(n()),H=l(),je=a,Me=i;function Ne({className:e,children:t,...n}){return(0,H.jsx)(r,{children:(0,H.jsx)(s,{className:`isolate z-50 outline-none`,children:(0,H.jsx)(c,{"data-slot":`context-menu-content`,className:f(`min-w-44 origin-(--transform-origin) rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-xl outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...n,children:t})})})}function U({className:e,...t}){return(0,H.jsx)(u,{"data-slot":`context-menu-item`,className:f(`flex h-8 cursor-default items-center gap-2 rounded-md px-2 text-xs outline-none select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-45 [&_svg]:size-3.5 [&_svg]:shrink-0`,e),...t})}function W({className:e,...t}){return(0,H.jsx)(o,{"data-slot":`context-menu-separator`,className:f(`mx-1 my-1 h-px bg-border`,e),...t})}function Pe({state:e,onClose:t,onRename:n,onCreate:r}){let[i,a]=(0,V.useState)(``);if((0,V.useEffect)(()=>{e&&a(e.mode===`rename`?e.entry.name:``)},[e]),!e)return null;let o=e.mode===`rename`,s=e.mode===`new-folder`?`directory`:`file`,c=e.entry.type===`directory`?e.entry.path:A(e.entry.path),l=o?`Rename`:s===`directory`?`New Folder`:`New File`,u=i.trim(),d=u.length>0&&!/[\\/]/.test(u)&&!(o&&u===e.entry.name),f=()=>{d&&(o?n(e.entry,u):r(c,u,s),t())};return(0,H.jsx)(le,{open:!0,onOpenChange:e=>{e||t()},children:(0,H.jsx)(ce,{className:`name-dialog`,children:(0,H.jsxs)(`form`,{className:`name-dialog-content`,onSubmit:e=>{e.preventDefault(),f()},children:[(0,H.jsx)(P,{children:l}),(0,H.jsx)(x,{children:o?(0,H.jsxs)(H.Fragment,{children:[`Enter a new name for `,(0,H.jsx)(`code`,{children:e.entry.name}),`.`]}):(0,H.jsxs)(H.Fragment,{children:[`Create a new `,s===`directory`?`folder`:`file`,` in `,(0,H.jsx)(`code`,{children:c||`the repository root`}),`.`]})}),(0,H.jsx)(`input`,{autoFocus:!0,className:`name-dialog-input`,value:i,maxLength:255,placeholder:o?`New name`:s===`directory`?`Folder name`:`File name`,onChange:e=>a(e.target.value),onFocus:t=>{if(!o)return;let n=e.entry.name.lastIndexOf(`.`);t.target.setSelectionRange(0,n>0?n:e.entry.name.length)}}),(0,H.jsxs)(`div`,{className:`name-dialog-actions`,children:[(0,H.jsx)(v,{type:`button`,variant:`ghost`,onClick:t,children:`Cancel`}),(0,H.jsx)(v,{type:`submit`,disabled:!d,children:o?`Rename`:`Create`})]})]})})})}function G(e,t,n,r=!0){let[i,a]=(0,V.useState)(null);(0,V.useEffect)(()=>{if(!r)return;let i=!1;return n(e).then(n=>{i||a({path:e,revision:t,entries:n,failed:!1})},()=>{i||a({path:e,revision:t,entries:[],failed:!0})}),()=>{i=!0}},[e,t,n,r]);let o=r&&i?.path===e;return{entries:o?i.entries:null,failed:o&&i.failed,refreshing:!o||i.revision!==t}}function Fe({entries:e,initialDirectory:t,revision:n,readOnly:r,onLoadDirectory:i,onMove:a,onClose:o}){let[s,c]=(0,V.useState)(t),[l,u]=(0,V.useState)(!1),{entries:d,failed:f,refreshing:p}=G(s,n,i),m=e.map(e=>e.path),h=d?.filter(e=>e.type===`directory`&&!m.some(t=>he(t,e.path)))??[],g=!r&&!l&&!p&&d!==null&&!f&&ye(m,s),_=async()=>{if(g){u(!0);try{await a(e,s),o()}finally{u(!1)}}};return(0,H.jsxs)(I,{open:!0,onOpenChange:e=>{!e&&!l&&o()},title:`Move to…`,description:`${e.length} selected ${e.length===1?`item`:`items`}. Choose a destination folder.`,children:[(0,H.jsxs)(`div`,{className:`mobile-folder-location`,children:[s&&(0,H.jsx)(v,{variant:`ghost`,size:`icon`,"aria-label":`Parent folder`,disabled:l,onClick:()=>c(A(s)),children:(0,H.jsx)(b,{})}),(0,H.jsx)(`span`,{children:s||`Repository root`})]}),(0,H.jsx)(`div`,{className:`mobile-destination-list`,children:d===null?(0,H.jsxs)(`p`,{className:`mobile-list-message`,role:`status`,children:[(0,H.jsx)(ee,{className:`animate-spin`,"aria-hidden":`true`}),(0,H.jsx)(ne,{text:`Loading folders…`})]}):f?(0,H.jsx)(`p`,{className:`mobile-list-message`,role:`alert`,children:`Could not read this folder.`}):h.length===0?(0,H.jsx)(`p`,{className:`mobile-list-message`,children:`No subfolders. You can choose this folder below.`}):h.map(e=>(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:l,onClick:()=>c(e.path),children:[(0,H.jsx)(`img`,{src:j(e.path,!1),alt:``,"aria-hidden":`true`,draggable:!1}),(0,H.jsx)(`span`,{children:e.name}),(0,H.jsx)(O,{})]},e.path))}),(0,H.jsxs)(`div`,{className:`mobile-sheet-footer`,children:[(0,H.jsx)(v,{variant:`ghost`,disabled:l,onClick:o,children:`Cancel`}),(0,H.jsxs)(v,{disabled:!g,onClick:()=>void _(),children:[l&&(0,H.jsx)(ee,{className:`animate-spin`}),` Move here`]})]})]})}var Ie=56;function Le(e){let[t,n]=(0,V.useState)(()=>A(e.activePath??``)),[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(new Map),[l,u]=(0,V.useState)(null),[f,p]=(0,V.useState)(null),[re,b]=(0,V.useState)(null),x=(0,V.useRef)(null),ie=(0,V.useRef)(new Map),ae=(0,V.useRef)(e.activePath),{entries:S,failed:se}=G(t,e.filesSnapshotRevision,e.onLoadDirectory,e.active),C=(0,V.useMemo)(()=>(S??[]).filter(t=>(e.showDotEnvFiles||!t.ignored)&&t.name.toLocaleLowerCase().includes(r.toLocaleLowerCase())),[S,e.showDotEnvFiles,r]),ce=d({count:C.length,enabled:e.active&&S!==null,getScrollElement:()=>x.current,estimateSize:()=>Ie,getItemKey:e=>C[e].path,overscan:8,paddingEnd:12});(0,V.useEffect)(()=>{e.activePath!==ae.current&&(ae.current=e.activePath,e.activePath&&(n(A(e.activePath)),i(``)))},[e.activePath]),(0,V.useEffect)(()=>{if(!S)return;let e=new Set(S.map(e=>e.path));c(t=>{let n=new Map([...t].filter(([t])=>e.has(t)));return n.size===t.size?t:n})},[S]),(0,V.useEffect)(()=>{S&&x.current&&(x.current.scrollTop=ie.current.get(t)??0)},[t,S]),(0,V.useEffect)(()=>{if(!e.files||!t||M(e.files,t)!==`missing`)return;let r=A(t);for(;r&&M(e.files,r)===`missing`;)r=A(r);n(r),i(``),c(new Map)},[e.files,t]);let w=e=>{n(e),i(``),c(new Map)},le=e=>c(t=>{let n=new Map(t);return n.has(e.path)?n.delete(e.path):n.set(e.path,e),n}),de={type:`directory`,path:t,name:t.split(`/`).pop()??``,children:[]},T=[...s.values()],E=l&&l!==`tools`?l:null,D=e=>{u(null),e()};return(0,H.jsxs)(`div`,{className:`mobile-files-view`,children:[(0,H.jsxs)(`div`,{className:`mobile-view-heading`,children:[(0,H.jsxs)(`h2`,{children:[a?`Select items`:`Files`,a&&(0,H.jsx)(`small`,{children:s.size})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(v,{variant:`ghost`,size:`sm`,"aria-pressed":a,onClick:()=>{o(!a),c(new Map)},children:a?`Cancel`:`Select`}),(0,H.jsx)(v,{variant:`ghost`,size:`icon`,"aria-label":`File browser actions`,onClick:()=>u(`tools`),children:(0,H.jsx)(oe,{})})]})]}),(0,H.jsxs)(`label`,{className:`mobile-file-filter`,children:[(0,H.jsx)(te,{"aria-hidden":`true`}),(0,H.jsx)(`input`,{type:`search`,value:r,placeholder:`Filter this folder…`,"aria-label":`Filter this folder`,onChange:e=>{i(e.target.value),ie.current.set(t,0),x.current?.scrollTo({top:0})}})]}),(0,H.jsxs)(`nav`,{className:`mobile-file-breadcrumb`,"aria-label":`Folder location`,children:[(0,H.jsxs)(`button`,{onClick:()=>w(``),"aria-current":t===``?`location`:void 0,children:[(0,H.jsx)(ue,{"aria-hidden":`true`}),` Root`]}),t.split(`/`).filter(Boolean).map((e,n,r)=>{let i=r.slice(0,n+1).join(`/`);return(0,H.jsxs)(`span`,{children:[(0,H.jsx)(O,{"aria-hidden":`true`}),(0,H.jsx)(`button`,{"aria-current":i===t?`location`:void 0,onClick:()=>w(i),children:e})]},i)})]}),(0,H.jsx)(`div`,{className:`mobile-files-scroll`,ref:x,onScroll:e=>ie.current.set(t,e.currentTarget.scrollTop),children:S===null?(0,H.jsxs)(`p`,{className:`mobile-list-message`,role:`status`,children:[(0,H.jsx)(ee,{className:`animate-spin`,"aria-hidden":`true`}),(0,H.jsx)(ne,{text:`Loading files…`})]}):se?(0,H.jsx)(`p`,{className:`mobile-list-message`,role:`alert`,children:`Could not read this folder.`}):C.length===0?(0,H.jsx)(`p`,{className:`mobile-list-message`,children:r?`No matching files in this folder.`:`This folder is empty.`}):(0,H.jsx)(`div`,{className:`virtual-list`,role:`list`,"aria-label":`Files in this folder`,style:{height:ce.getTotalSize()},children:ce.getVirtualItems().map(t=>{let n=C[t.index],r=s.has(n.path);return(0,H.jsxs)(`div`,{role:`listitem`,className:`mobile-file-row ${r?`selected`:``}`,style:{height:t.size,transform:`translateY(${t.start}px)`},children:[(0,H.jsxs)(`button`,{className:`mobile-file-open`,"aria-pressed":a?r:void 0,"aria-current":e.activePath===n.path?`true`:void 0,onClick:()=>a?le(n):n.type===`directory`?w(n.path):e.onOpenFile(n.path),children:[a?(0,H.jsx)(`span`,{className:`mobile-file-check ${r?`checked`:``}`,children:r&&(0,H.jsx)(m,{"aria-hidden":`true`})}):(0,H.jsx)(`img`,{src:n.type===`directory`?j(n.path,!1):k(n.path),alt:``,"aria-hidden":`true`,draggable:!1}),(0,H.jsxs)(`span`,{className:`mobile-file-copy`,children:[(0,H.jsx)(`strong`,{children:n.name}),(0,H.jsx)(`small`,{children:n.type===`directory`?n.ignored?`Ignored folder`:`Folder`:`${n.ignored?`Ignored · `:``}${Math.max(1,Math.ceil(n.size/1024))} KB`})]}),!a&&n.type===`directory`&&(0,H.jsx)(O,{"aria-hidden":`true`})]}),!a&&(0,H.jsx)(v,{variant:`ghost`,size:`icon`,className:`mobile-file-menu`,"aria-label":`Actions for ${n.name}`,onClick:()=>u(n),children:(0,H.jsx)(oe,{})})]},n.path)})})}),a&&(0,H.jsxs)(`div`,{className:`mobile-file-selection-actions`,children:[(0,H.jsxs)(v,{variant:`ghost`,size:`sm`,disabled:e.readOnly||s.size===0,onClick:()=>b(T),children:[(0,H.jsx)(_,{}),` Move to…`]}),(0,H.jsxs)(v,{variant:`ghost`,size:`sm`,disabled:s.size===0,onClick:()=>void(e.fileClipboardAvailable?e.onCopyEntries(T):e.onCopyPath(T)),children:[(0,H.jsx)(y,{}),` `,e.fileClipboardAvailable?`Copy`:`Copy paths`]}),e.fileClipboardAvailable&&(0,H.jsx)(v,{variant:`ghost`,size:`icon`,"aria-label":`Cut selected items`,disabled:e.readOnly||s.size===0,onClick:()=>void e.onCutEntries(T),children:(0,H.jsx)(B,{})}),(0,H.jsx)(v,{variant:`ghost`,size:`icon`,"aria-label":`Delete selected items`,disabled:e.readOnly||s.size===0,onClick:()=>void e.onDeleteEntries(T),children:(0,H.jsx)(N,{})})]}),(0,H.jsx)(I,{open:l!==null,onOpenChange:e=>{e||u(null)},title:E?.name??`File browser actions`,description:E?.path??`Actions for the current folder.`,children:E?(0,H.jsxs)(H.Fragment,{children:[E.type===`file`&&(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,onClick:()=>D(()=>e.onOpenFile(E.path,`pinned`)),children:[(0,H.jsx)(ke,{}),(0,H.jsx)(`span`,{children:`Keep file open`})]}),E.type===`directory`&&(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,onClick:()=>D(()=>w(E.path)),children:[(0,H.jsx)(ue,{}),(0,H.jsx)(`span`,{children:`Open folder`})]}),(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly,onClick:()=>D(()=>b([E])),children:[(0,H.jsx)(_,{}),(0,H.jsx)(`span`,{children:`Move to…`})]}),(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly,onClick:()=>D(()=>p({mode:`rename`,entry:E})),children:[(0,H.jsx)(h,{}),(0,H.jsx)(`span`,{children:`Rename`})]}),e.fileClipboardAvailable&&(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,onClick:()=>D(()=>{e.onCopyEntries([E])}),children:[(0,H.jsx)(y,{}),(0,H.jsx)(`span`,{children:`Copy`})]}),e.fileClipboardAvailable&&(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly,onClick:()=>D(()=>{e.onCutEntries([E])}),children:[(0,H.jsx)(B,{}),(0,H.jsx)(`span`,{children:`Cut`})]}),(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,onClick:()=>D(()=>{e.onCopyPath([E])}),children:[(0,H.jsx)(y,{}),(0,H.jsx)(`span`,{children:`Copy path`})]}),E.type===`file`&&(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,onClick:()=>D(()=>{e.onCopyContents(E)}),children:[(0,H.jsx)(y,{}),(0,H.jsx)(`span`,{children:`Copy contents`})]}),e.revealAvailable&&(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,onClick:()=>D(()=>{e.onReveal(E)}),children:[(0,H.jsx)(xe,{}),(0,H.jsx)(`span`,{children:`Reveal in file manager`})]}),e.fileClipboardAvailable&&(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly,onClick:()=>D(()=>{e.onPaste(E.type===`directory`?E.path:A(E.path))}),children:[(0,H.jsx)(Oe,{}),(0,H.jsx)(`span`,{children:`Paste here`})]}),(0,H.jsxs)(`button`,{className:`mobile-sheet-action destructive`,disabled:e.readOnly,onClick:()=>D(()=>{e.onDeleteEntries([E])}),children:[(0,H.jsx)(N,{}),(0,H.jsx)(`span`,{children:`Delete`})]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,onClick:()=>D(e.onQuickOpen),children:[(0,H.jsx)(te,{}),(0,H.jsx)(`span`,{children:`Find file in repository`})]}),(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly,onClick:()=>D(()=>p({mode:`new-file`,entry:de})),children:[(0,H.jsx)(ke,{}),(0,H.jsx)(`span`,{children:`New file`})]}),(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly,onClick:()=>D(()=>p({mode:`new-folder`,entry:de})),children:[(0,H.jsx)(g,{}),(0,H.jsx)(`span`,{children:`New folder`})]}),e.fileClipboardAvailable&&(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly,onClick:()=>D(()=>{e.onPaste(t)}),children:[(0,H.jsx)(Oe,{}),(0,H.jsx)(`span`,{children:`Paste here`})]}),(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly||!e.historyState.canUndo,onClick:()=>D(()=>{e.onUndo()}),children:[(0,H.jsx)(L,{}),(0,H.jsx)(`span`,{children:e.historyState.undoLabel?`Undo ${e.historyState.undoLabel}`:`Undo`})]}),(0,H.jsxs)(`button`,{className:`mobile-sheet-action`,disabled:e.readOnly||!e.historyState.canRedo,onClick:()=>D(()=>{e.onRedo()}),children:[(0,H.jsx)(R,{}),(0,H.jsx)(`span`,{children:e.historyState.redoLabel?`Redo ${e.historyState.redoLabel}`:`Redo`})]})]})}),(0,H.jsx)(Pe,{state:f,onClose:()=>p(null),onRename:e.onRename,onCreate:e.onCreate}),re&&(0,H.jsx)(Fe,{entries:re,initialDirectory:t,revision:e.filesSnapshotRevision,readOnly:e.readOnly,onLoadDirectory:e.onLoadDirectory,onMove:e.onMoveEntries,onClose:()=>{b(null),c(new Map)}})]})}function Re(e){return me()?(0,H.jsx)(Le,{...e}):(0,H.jsx)(K,{...e})}var ze=29,Be=6,Ve=`files-tree-root-drop`,He=550,Ue={duration:160,easing:`cubic-bezier(0.2, 0, 0, 1)`},We=6,Ge=e=>{let t=D(e),n=t.length>0?t:S(e),r=n.find(e=>e.id!==Ve);return r?[r]:n.slice(0,1)};function Ke(e,t,n=0){let r=[];for(let i of e)r.push({entry:i,depth:n}),i.type===`directory`&&t.has(i.path)&&r.push(...Ke(i.children,t,n+1));return r}function qe(e,t,n){let r=e.findIndex(e=>e.entry.path===t),i=e.findIndex(e=>e.entry.path===n);if(r===-1||i===-1)return[n];let[a,o]=r<=i?[r,i]:[i,r];return e.slice(a,o+1).map(e=>e.entry.path)}function Je(e){return e.type===`directory`?e.path:A(e.path)}function K({active:e,initialExpandedPaths:t,files:n,filesSnapshotRevision:r,showDotEnvFiles:i,activePath:a,readOnly:o,fileClipboardAvailable:s,revealAvailable:c,historyState:l,onQuickOpen:u,onUndo:f,onRedo:p,onOpenFile:m,onLoadDirectory:h,onPersistExpandedPaths:_,onCopyPath:y,onCopyEntries:b,onCutEntries:x,onCopyContents:ae,onPaste:S,onMoveEntries:oe,onDeleteEntries:C,onReveal:ce,onRename:le,onCreate:ue}){let T=Ee(),E=me(),[D,fe]=(0,V.useState)(!1),k=E?44:ze,j=(0,V.useRef)(null),M=(0,V.useRef)(null),[N,P]=(0,V.useState)(new Set),[xe,I]=(0,V.useState)(a),[L,R]=(0,V.useState)(a),[z,B]=(0,V.useState)(()=>new Set(t)),[je,Me]=(0,V.useState)([]),[Ne,U]=(0,V.useState)(null),[W,G]=(0,V.useState)(null),[Fe,Ie]=(0,V.useState)(null),[Le,Re]=(0,V.useState)(!1),[Ve,K]=(0,V.useState)(null),[tt,nt]=(0,V.useState)(0),[q,rt]=(0,V.useState)(new Map),it=re(w(De,{activationConstraint:{distance:5}}),w(se)),at=(0,V.useRef)(q),ot=(0,V.useRef)(new Set),st=(0,V.useRef)(0),J=(0,V.useRef)(null),ct=(0,V.useRef)(null),lt=(0,V.useRef)(t.join(`\0`)),ut=(0,V.useMemo)(()=>new Set(q.keys()),[q]),Y=(0,V.useMemo)(()=>n===null?null:Te(n,q),[n,q]),X=(0,V.useMemo)(()=>Y===null?null:i?Y:pe(Y),[Y,i]);(0,V.useEffect)(()=>{at.current=q},[q]),(0,V.useEffect)(()=>{Ie(document.getElementById(we))},[a]),(0,V.useEffect)(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>Re(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,V.useEffect)(()=>()=>{J.current&&clearTimeout(J.current)},[]),(0,V.useEffect)(()=>{let e=++st.current,t=[...at.current.keys()];t.length!==0&&Promise.all(t.map(async e=>({path:e,children:await h(e)}))).then(t=>{if(e!==st.current)return;let n=new Map(t.map(({path:e,children:t})=>[e,t]));rt(e=>ge(e,n))})},[r,h]),(0,V.useEffect)(()=>{Y?B(e=>{let t=new Set(ve(Y,e,ut).retained);return Qe(e,t)?e:t}):(ot.current.clear(),rt(e=>e.size===0?e:new Map))},[ut,Y]),(0,V.useEffect)(()=>{if(!Y)return;let e=be(Y,z,ut),t=e.join(`\0`);t!==lt.current&&(lt.current=t,_(e))},[z,ut,Y,_]),(0,V.useEffect)(()=>{if(!e||!X)return;let t=Math.max(0,2-ot.current.size);for(let e of z){if(t===0)break;let n=F(X,e);n&&n.type===`directory`&&n.ignored===!0&&(n.children.length>0||q.has(e)||ot.current.has(e)||(ot.current.add(e),--t,h(e).catch(()=>[]).then(t=>{rt(n=>new Map(n).set(e,t))}).finally(()=>{ot.current.delete(e)})))}},[e,z,q,h,X]),(0,V.useEffect)(()=>{e||(K(null),Me([]),U(null),G(null),J.current&&clearTimeout(J.current),J.current=null,ct.current=null)},[e]),(0,V.useEffect)(()=>{X&&(P(e=>{if(e.size===0)return e;let t=new Set([...e].filter(e=>F(X,e)));return t.size===e.size?e:t}),I(e=>e&&F(X,e)?e:null),R(e=>e&&F(X,e)?e:a&&F(X,a)?a:null))},[a,X]);let Z=(0,V.useMemo)(()=>X?Ke(X,z):[],[z,X]),Q=d({enabled:e,count:Z.length,getScrollElement:()=>j.current,estimateSize:()=>k,getItemKey:e=>Z[e]?.entry.path??e,overscan:12,paddingStart:Be,paddingEnd:12});(0,V.useEffect)(()=>{Q.measure()},[Q,k]),(0,V.useEffect)(()=>{e&&a&&X&&F(X,a)&&B(e=>{let t=new Set(e),n=!1,r=a.split(`/`),i=``;for(let e=0;e<r.length-1;e+=1)i=i?`${i}/${r[e]}`:r[e],t.has(i)||(t.add(i),n=!0);return n?t:e})},[e,a,X]),(0,V.useEffect)(()=>{if(!e)return;if(!a){M.current=null;return}if(M.current===a)return;let t=Z.findIndex(e=>e.entry.path===a);t>=0&&(Q.scrollToIndex(t,{align:`auto`}),M.current=a)},[e,a,Z]);let dt=(0,V.useMemo)(()=>{let e=new Map;for(let t of Z)e.set(t.entry.path,t);return e},[Z]),ft=(0,V.useMemo)(()=>{let e={headers:[],push:0};if(Z.length===0||!a)return e;let t=new Set,n=a.split(`/`),r=``;for(let e=0;e<n.length-1;e+=1)r=r?`${r}/${n[e]}`:n[e],t.add(r);if(t.size===0)return e;let i=Math.min(Z.length-1,Math.max(0,Math.floor((tt-Be)/k))),o=Z[i];if(!o)return e;let s=o.entry.path.split(`/`),c=[],l=``;for(let e=0;e<s.length-1;e+=1){if(l=l?`${l}/${s[e]}`:s[e],!t.has(l))continue;let n=dt.get(l);n&&n.entry.type===`directory`&&c.push(n)}if(c.length>We&&c.splice(0,c.length-We),c.length===0)return e;let u=c[c.length-1],d=c.length*k,f=1/0,p=Math.ceil((tt+d-Be)/k)+2;for(let e=i;e<Z.length&&e<=p;e+=1)if(Z[e].depth<=u.depth){f=Be+e*k;break}return{headers:c,push:Math.max(0,Math.min(k,d-(f-tt)))}},[Z,dt,tt,a,k]);if(X===null)return(0,H.jsxs)(`div`,{className:`view-loading`,role:`status`,hidden:!e,children:[(0,H.jsx)(ee,{className:`spinner`,"aria-hidden":`true`}),(0,H.jsx)(ne,{text:`Loading files…`})]});let pt=D||N.size>0?N:a?new Set([a]):new Set,mt=N.size>0?[...N]:a?[a]:[],ht=e=>{let t=[];for(let n of e){let e=F(X,n);e&&t.push(e)}return t},gt=e=>{P(new Set([e])),I(e),R(e)},_t=e=>{let t=Z.findIndex(t=>t.entry.path===e.path);t>=0&&Q.scrollToIndex(t,{align:`start`})},vt=(e,t)=>{if(E&&D)P(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n});else if(t.shift&&(xe||L)){let t=qe(Z,xe??L,e.path);P(new Set(t)),R(e.path)}else t.ctrl?(P(t=>{let n=new Set(t.size===0&&a?[a]:t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),I(e.path),R(e.path),e.type===`file`&&m(e.path,`pinned`)):(gt(e.path),e.type===`file`?m(e.path):wt(e.path))},yt=e=>{!(E&&D)&&e.type===`file`&&m(e.path,`pinned`)},bt=e=>{N.has(e.path)||gt(e.path)},xt=e=>N.has(e.path)&&N.size>0?ht(N):[e],St=e=>{if(Ce(e.target))return;let t=_e(e.nativeEvent,T);if(t===`undo`&&l.canUndo&&!o){e.preventDefault(),e.repeat||f();return}if(t===`redo`&&l.canRedo&&!o){e.preventDefault(),e.repeat||p();return}let n=(e.ctrlKey||e.metaKey)&&!e.altKey,r=e.key.toLowerCase();if(n&&r===`a`){e.preventDefault(),P(new Set(Z.map(e=>e.entry.path)));return}let i=ht(mt),a=L?F(X,L):null;if(n&&r===`c`&&i.length)e.preventDefault(),b(i);else if(n&&r===`x`&&i.length&&!o)e.preventDefault(),x(i);else if(n&&r===`v`&&!o&&s)e.preventDefault(),S(a?Je(a):A(i[0]?.path??``));else if(e.key===`F2`&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!o){if(N.size===1){let t=F(X,[...N][0]);t&&(e.preventDefault(),K({mode:`rename`,entry:t}))}}else e.key===`Delete`&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!o&&i.length&&(e.preventDefault(),C(i))},Ct=async(e,t)=>{let n=ht(e);n.length&&await oe(n,t)},wt=(e,t=!1)=>{let n=!t&&z.has(e),r=n&&F(X??[],e)?.ignored===!0;B(n=>{let i=new Set(n);if(t||!i.has(e)){if(i.has(e))return n;i.add(e)}else if(r)for(let t of i)he(e,t)&&i.delete(t);else i.delete(e);return Qe(n,i)?n:i}),n&&rt(t=>{let n=[...t.keys()].filter(t=>he(e,t));if(n.length===0)return t;let r=new Map(t);for(let e of n)r.delete(e);return r})},$=()=>{J.current&&clearTimeout(J.current),J.current=null,ct.current=null},Tt=()=>{$(),Me([]),U(null),G(null)},Et=e=>{let t=e.active.data.current;return t?.entry&&Array.isArray(t.sourcePaths)?{entry:t.entry,sourcePaths:t.sourcePaths}:null};return(0,H.jsxs)(de,{sensors:it,collisionDetection:Ge,autoScroll:{enabled:!0,threshold:{x:.1,y:.16},acceleration:12},onDragStart:e=>{let t=Et(e);t&&(N.has(t.entry.path)||gt(t.entry.path),Me(t.sourcePaths),G({entry:t.entry,sourcePaths:t.sourcePaths,count:t.sourcePaths.length}))},onDragOver:e=>{let t=Et(e);if(e.over?.data.current?.openPinned===!0){U(null),$();return}let n=e.over?.data.current?.targetDirectory;if(!t||typeof n!=`string`||!ye(t.sourcePaths,n)){U(null),$();return}U(n);let r=e.over?.data.current?.expandPath;typeof r!=`string`||z.has(r)?$():ct.current!==r&&($(),ct.current=r,J.current=setTimeout(()=>{wt(r,!0),J.current=null,ct.current=null},He))},onDragCancel:Tt,onDragEnd:e=>{let t=Et(e),n=e.over?.data.current?.openPinned===!0,r=e.over?.data.current?.targetDirectory;Tt(),t&&n&&Se(t.entry,t.sourcePaths)?m(t.entry.path,`pinned`):t&&typeof r==`string`&&ye(t.sourcePaths,r)&&Ct(t.sourcePaths,r)},children:[(0,H.jsxs)(`div`,{className:`files-mobile-tools`,children:[(0,H.jsxs)(v,{variant:`ghost`,size:`sm`,onClick:u,children:[(0,H.jsx)(te,{}),` Find file`]}),(0,H.jsx)(v,{variant:`ghost`,size:`sm`,"aria-pressed":D,onClick:()=>{fe(!D),P(new Set)},children:D?`Done (${N.size})`:`Select`}),(0,H.jsxs)(v,{variant:`ghost`,size:`sm`,disabled:o,onClick:()=>K({mode:`new-file`,entry:{type:`directory`,path:``,name:``,children:[]}}),children:[(0,H.jsx)(ke,{}),` New file`]}),(0,H.jsxs)(v,{variant:`ghost`,size:`sm`,disabled:o,onClick:()=>K({mode:`new-folder`,entry:{type:`directory`,path:``,name:``,children:[]}}),children:[(0,H.jsx)(g,{}),` Folder`]}),s&&(0,H.jsxs)(v,{variant:`ghost`,size:`sm`,disabled:o,onClick:()=>void S(``),children:[(0,H.jsx)(Oe,{}),` Paste`]})]}),(0,H.jsxs)(`div`,{ref:j,className:`files-view virtual-scroll`,hidden:!e,onScroll:e=>nt(e.currentTarget.scrollTop),children:[ft.headers.length>0&&(0,H.jsx)(`div`,{className:`files-sticky`,children:ft.headers.map((e,t)=>{let n=t===ft.headers.length-1;return(0,H.jsxs)(`button`,{type:`button`,className:`file-tree-row files-sticky-row`,"aria-label":`Scroll to ${e.entry.path}`,style:{top:t*k-(n?ft.push:0),paddingLeft:12+e.depth*14,zIndex:ft.headers.length-t},onClick:()=>_t(e.entry),children:[(0,H.jsx)(O,{className:`folder-chevron open`}),(0,H.jsx)(et,{path:e.entry.path,type:`directory`,expanded:!0}),(0,H.jsx)(`span`,{children:e.entry.name})]},e.entry.path)})}),X.length?(0,H.jsx)(Ye,{role:`tree`,"aria-label":`Files`,className:`files-tree ${Ne===``&&je.length>0?`root-drop-target`:``}`,style:{height:Q.getTotalSize()},tabIndex:0,onKeyDown:St,onPointerDown:e=>{e.target.closest(`.file-tree-row, .file-touch-actions`)||(P(new Set),I(null),R(null),e.currentTarget.focus())},children:Q.getVirtualItems().map(e=>{let{entry:t,depth:n}=Z[e.index],r=t.type===`directory`&&z.has(t.path),i=N.has(t.path)&&N.size>1;return(0,H.jsx)(`div`,{className:`virtual-row`,style:{height:e.size,transform:`translateY(${e.start}px)`},children:(0,H.jsx)($e,{entry:t,depth:n,expanded:r,pendingChildren:t.type===`directory`&&t.ignored===!0&&t.children.length===0&&!q.has(t.path),selected:pt.has(t.path),active:a===t.path,multiSelected:i,readOnly:o,fileClipboardAvailable:s,revealAvailable:c,historyState:l,onUndo:f,onRedo:p,draggedPaths:je,dropTargetPath:Ne,onFocus:R,onRowClick:vt,onRowDoubleClick:yt,onRowContextMenu:bt,onOpen:e=>m(e.path),onOpenPinned:e=>m(e.path,`pinned`),onCopy:e=>void b(xt(e)),onCut:e=>void x(xt(e)),onPasteInto:e=>void S(Je(e)),onCopyPath:e=>void y(xt(e)),onCopyContents:ae,onRename:e=>K({mode:`rename`,entry:e}),onNewFile:e=>K({mode:`new-file`,entry:e}),onNewFolder:e=>K({mode:`new-folder`,entry:e}),onReveal:ce,onDelete:e=>void C(xt(e)),dragPaths:N.has(t.path)&&N.size>0?[...N]:[t.path]})},e.key)})}):(0,H.jsx)(`p`,{className:`empty-list`,children:`No files.`}),(0,H.jsx)(Pe,{state:Ve,onClose:()=>K(null),onRename:le,onCreate:ue})]}),(0,H.jsx)(ie,{dropAnimation:Le?null:Ue,children:W&&(0,H.jsx)(Ze,{preview:W})}),Fe&&(0,Ae.createPortal)((0,H.jsx)(Xe,{visible:!!(W&&Se(W.entry,W.sourcePaths))}),Fe)]})}function Ye(e){let{setNodeRef:t}=fe({id:Ve,data:{targetDirectory:``,expandPath:null}});return(0,H.jsx)(`div`,{ref:t,...e})}function Xe({visible:e}){let{isOver:t,setNodeRef:n}=fe({id:`files-open-pinned-drop`,data:{openPinned:!0}});return(0,H.jsxs)(`div`,{ref:n,className:`open-files-drop-target ${e?`visible`:``} ${e&&t?`over`:``}`,"aria-hidden":`true`,children:[(0,H.jsx)(z,{}),(0,H.jsx)(`span`,{children:`Drop to open beside`})]})}function Ze({preview:e}){return(0,H.jsxs)(`div`,{className:`file-drag-overlay`,children:[(0,H.jsx)(et,{path:e.entry.path,type:e.entry.type,expanded:!1}),(0,H.jsx)(`span`,{children:e.entry.name}),e.count>1&&(0,H.jsx)(`strong`,{children:e.count})]})}function Qe(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function $e({entry:e,depth:t,expanded:n,pendingChildren:r,selected:i,active:a,multiSelected:o,readOnly:s,fileClipboardAvailable:c,revealAvailable:l,historyState:u,onUndo:d,onRedo:f,draggedPaths:p,dropTargetPath:m,onFocus:_,onRowClick:ee,onRowDoubleClick:te,onRowContextMenu:ne,onOpen:v,onOpenPinned:re,onCopy:b,onCut:x,onPasteInto:ie,onCopyPath:S,onCopyContents:se,onRename:ce,onNewFile:w,onNewFolder:le,onReveal:ue,onDelete:de,dragPaths:D}){let pe=(0,V.useRef)(null),me=Je(e),{attributes:k,listeners:A,setNodeRef:j,isDragging:M}=E({id:`file-drag:${e.path}`,data:{sourcePaths:D,entry:e},disabled:s}),{setNodeRef:ge}=fe({id:`file-drop:${e.path}`,data:{targetDirectory:me,expandPath:e.type===`directory`?e.path:null}}),_e=e=>{pe.current=e,j(e),ge(e)},P=p.length>0&&e.type===`directory`&&m===e.path,ve=p.length>0&&m!==null&&m!==``&&m!==e.path&&he(m,e.path),ye=(0,H.jsxs)(`button`,{type:`button`,ref:_e,...k,role:`treeitem`,"aria-selected":i,"aria-current":a?`true`:void 0,"aria-expanded":e.type===`directory`?n:void 0,className:[`file-tree-row`,e.ignored?`ignored-file`:``,p.includes(e.path)||M?`dragging`:``,P?`drop-target`:``,ve?`drop-target-region`:``].filter(Boolean).join(` `),style:{paddingLeft:12+t*14},...A,onClick:t=>ee(e,{ctrl:t.ctrlKey||t.metaKey,shift:t.shiftKey}),onDoubleClick:()=>te(e),onFocus:()=>_(e.path),onContextMenu:()=>ne(e),children:[e.type===`directory`?(0,H.jsx)(O,{className:`folder-chevron ${n?`open`:``} ${e.children.length===0&&!r?`empty`:``}`}):(0,H.jsx)(`span`,{className:`tree-spacer`}),(0,H.jsx)(et,{path:e.path,type:e.type,expanded:n}),(0,H.jsx)(`span`,{children:e.name})]});return(0,H.jsxs)(je,{children:[(0,H.jsx)(Me,{render:ye}),(0,H.jsx)(`button`,{type:`button`,className:`file-touch-actions`,"aria-label":`Actions for ${e.name}`,"aria-haspopup":`menu`,onClick:e=>{e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();pe.current?.dispatchEvent(new MouseEvent(`contextmenu`,{bubbles:!0,cancelable:!0,clientX:t.left,clientY:t.bottom}))},children:(0,H.jsx)(oe,{})}),(0,H.jsxs)(Ne,{children:[e.type===`file`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(U,{onClick:()=>v(e),children:[(0,H.jsx)(C,{"aria-hidden":`true`}),` Open`]}),(0,H.jsxs)(U,{onClick:()=>re(e),children:[(0,H.jsx)(z,{"aria-hidden":`true`}),` Open to the Side `,(0,H.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`Ctrl+Click`})]}),(0,H.jsx)(W,{})]}),(0,H.jsxs)(U,{disabled:s||!u.canUndo,onClick:()=>void d(),children:[(0,H.jsx)(L,{"aria-hidden":`true`}),` `,u.undoLabel?`Undo ${u.undoLabel}`:`Undo`,` `,(0,H.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`Ctrl+Z`})]}),(0,H.jsxs)(U,{disabled:s||!u.canRedo,onClick:()=>void f(),children:[(0,H.jsx)(R,{"aria-hidden":`true`}),` `,u.redoLabel?`Redo ${u.redoLabel}`:`Redo`,` `,(0,H.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`Ctrl+Shift+Z`})]}),(0,H.jsx)(W,{}),(0,H.jsxs)(U,{onClick:()=>b(e),children:[(0,H.jsx)(T,{"aria-hidden":`true`}),` Copy `,(0,H.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`Ctrl+C`})]}),(0,H.jsxs)(U,{disabled:s,onClick:()=>x(e),children:[(0,H.jsx)(B,{"aria-hidden":`true`}),` Cut `,(0,H.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`Ctrl+X`})]}),c&&(0,H.jsxs)(U,{disabled:s,onClick:()=>ie(e),children:[(0,H.jsx)(Oe,{"aria-hidden":`true`}),` Paste `,(0,H.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`Ctrl+V`})]}),(0,H.jsx)(W,{}),(0,H.jsxs)(U,{disabled:s||o,onClick:()=>ce(e),children:[(0,H.jsx)(h,{"aria-hidden":`true`}),` Rename `,(0,H.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`F2`})]}),(0,H.jsxs)(U,{disabled:s||o,onClick:()=>w(e),children:[(0,H.jsx)(ke,{"aria-hidden":`true`}),` New File…`]}),(0,H.jsxs)(U,{disabled:s||o,onClick:()=>le(e),children:[(0,H.jsx)(g,{"aria-hidden":`true`}),` New Folder…`]}),(0,H.jsx)(W,{}),(0,H.jsxs)(U,{onClick:()=>S(e),children:[(0,H.jsx)(ae,{"aria-hidden":`true`}),` Copy path`]}),(0,H.jsxs)(U,{disabled:e.type!==`file`||o,onClick:()=>void se(e),children:[(0,H.jsx)(y,{"aria-hidden":`true`}),` Copy contents`]}),l&&(0,H.jsxs)(U,{disabled:o,onClick:()=>void ue(e),children:[(0,H.jsx)(xe,{"aria-hidden":`true`}),` Reveal in File Explorer`]}),(0,H.jsx)(W,{}),(0,H.jsxs)(U,{className:`text-destructive data-highlighted:text-destructive`,disabled:s,onClick:()=>de(e),children:[(0,H.jsx)(N,{"aria-hidden":`true`}),` Delete `,(0,H.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:`Del`})]})]})]})}function et({path:e,type:t,expanded:n=!1}){let r=t===`file`?k(e):j(e,n);return(0,H.jsx)(`img`,{className:`vscode-tree-icon`,src:r,alt:``,"aria-hidden":`true`})}export{Re as FilesView};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{C as t,Ct as n,S as r,b as i,w as a,x as o,xt as s}from"./base-ui-DDpgJXgO.js";import{l as c}from"./tanstack-CYi5knVJ.js";import{t as l}from"./createReactComponent-BfrD_oQK.js";import{t as u}from"./IconCheck-BPhxw_LS.js";import{t as d}from"./IconLoader4-Bk6G4Bls.js";import{O as f,T as p,g as m,h,l as g,n as _,v}from"./index-CoZCJqTQ.js";import{Bt as y,zt as b}from"./App-DEIZhWJG.js";var x=l(`outline`,`circle-check`,`CircleCheck`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`,key:`svg-0`}],[`path`,{d:`M9 12l2 2l4 -4`,key:`svg-1`}]]),S=l(`outline`,`circle-x`,`CircleX`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`,key:`svg-0`}],[`path`,{d:`M10 10l4 4m0 -4l-4 4`,key:`svg-1`}]]),C=l(`outline`,`stack-2`,`Stack2`,[[`path`,{d:`M12 4l-8 4l8 4l8 -4l-8 -4`,key:`svg-0`}],[`path`,{d:`M4 12l8 4l8 -4`,key:`svg-1`}],[`path`,{d:`M4 16l8 4l8 -4`,key:`svg-2`}]]),w=l(`outline`,`user-circle`,`UserCircle`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`,key:`svg-0`}],[`path`,{d:`M9 10a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-1`}],[`path`,{d:`M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855`,key:`svg-2`}]]),T=e(n()),E=s();function D({repositoryId:e,number:n,membership:s,onSelect:l}){let[x,S]=(0,T.useState)(!1),w=c({queryKey:_.pullRequestStack(e,n),queryFn:()=>g.github.getPullRequestStack(e,n),enabled:x,staleTime:0}),D=w.data,O=D?D.layers.findIndex(e=>e.number===n)+1:s.position,k=D?.layers.length??s.size,A=D?.number??s.number;return w.isSuccess&&D===null&&!x?null:(0,E.jsxs)(a,{open:x,onOpenChange:S,children:[(0,E.jsxs)(h,{children:[(0,E.jsxs)(v,{render:(0,E.jsx)(t,{render:(0,E.jsx)(`button`,{className:`pr-stack-trigger`,"aria-label":`Stack ${A}, layer ${O} of ${k}`})}),children:[(0,E.jsx)(C,{"aria-hidden":`true`}),` `,O,`/`,k]}),(0,E.jsxs)(m,{children:[`View stack #`,A,` · layer `,O,` of `,k]})]}),(0,E.jsx)(r,{children:(0,E.jsx)(o,{side:`bottom`,align:`start`,sideOffset:6,className:`isolate z-50 outline-none`,children:(0,E.jsxs)(i,{className:`pr-stack-popup`,"aria-label":`Stack #${A}`,children:[(0,E.jsxs)(`div`,{className:`pr-stack-heading`,children:[(0,E.jsxs)(`strong`,{children:[`Stack #`,A]}),(0,E.jsx)(p,{variant:`ghost`,size:`xs`,disabled:w.isFetching,onClick:()=>void w.refetch(),children:`Refresh`})]}),w.isFetching&&(0,E.jsxs)(`p`,{className:`pr-stack-notice`,role:`status`,children:[(0,E.jsx)(d,{className:`animate-spin`,"aria-hidden":`true`}),(0,E.jsx)(f,{text:D?`Refreshing stack…`:`Loading stack…`})]}),w.isError&&(0,E.jsxs)(`div`,{className:`pr-stack-notice`,role:`status`,children:[(0,E.jsx)(`p`,{children:D?`Could not refresh. Showing saved layers.`:`Could not load the stack.`}),(0,E.jsx)(p,{variant:`outline`,size:`xs`,onClick:()=>void w.refetch(),children:`Retry`})]}),D===null&&!w.isFetching&&!w.isError&&(0,E.jsx)(`p`,{className:`pr-stack-notice`,children:`This PR is no longer in a stack, or stack data is unavailable.`}),D&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`pr-stack-layers`,children:[...D.layers].reverse().map(e=>{let t=e.isDraft&&e.state===`OPEN`?`Draft`:e.state===`MERGED`?`Merged`:e.state===`CLOSED`?`Closed`:`Open`,r=e.state===`MERGED`?y:b;return(0,E.jsxs)(h,{children:[(0,E.jsxs)(v,{render:(0,E.jsx)(`button`,{className:`pr-stack-layer`,"aria-current":e.number===n?`true`:void 0,onClick:()=>{S(!1),l(e.number)}}),children:[(0,E.jsx)(r,{className:`pr-stack-state ${t.toLowerCase()}`,"aria-hidden":`true`}),(0,E.jsxs)(`span`,{className:`pr-stack-layer-text`,children:[(0,E.jsx)(`strong`,{children:e.title}),(0,E.jsxs)(`small`,{children:[`#`,e.number,` · `,e.headRefName,` · `,t]})]}),e.number===n&&(0,E.jsx)(u,{"aria-hidden":`true`})]}),(0,E.jsxs)(m,{children:[e.title,` · `,e.headRefName,` · `,t]})]},e.number)})}),(0,E.jsxs)(`div`,{className:`pr-stack-base`,children:[`↳ `,D.base]})]})]})})})]})}function O({src:e,className:t}){let[n,r]=(0,T.useState)(!1);return(0,E.jsx)(`span`,{className:t,"aria-hidden":`true`,children:e&&!n?(0,E.jsx)(`img`,{src:e,alt:``,onError:()=>r(!0)}):(0,E.jsx)(w,{})})}export{x as i,D as n,S as r,O as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Ct as t,xt as n}from"./base-ui-DDpgJXgO.js";import{o as r}from"./tanstack-CYi5knVJ.js";import{t as i}from"./IconLoader4-Bk6G4Bls.js";import{t as a}from"./IconSearch-ZL3YVslZ.js";import{A as o,O as s,S as c,T as l,g as u,h as d,l as f,v as p}from"./index-CoZCJqTQ.js";import{Ct as ee,Nt as m,St as h,Zt as g,a as _,b as v,c as y,d as b,en as x,i as S,zt as C}from"./App-DEIZhWJG.js";var w=e(t());function T(e){let t=[],n=e.some(e=>e.color!==void 0)?3:0,r=1,i=new Map,a=[],o=new Map(e.map(e=>[e.oid,e])),s=new Set,c=e[0];for(;c&&!s.has(c.oid);)s.add(c.oid),c.color!==void 0&&i.set(c.oid,c.color),c=o.get(c.parentOids[0]??``);for(let o of e){let e=t.indexOf(o.oid),s=e>=0;e<0&&(e=t.length,t=[...t,o.oid]);let c=t,l=E(i,o.oid,()=>o.color??n++),u=l<3?o.color??l:l;i.set(o.oid,u);let d=c.filter((t,n)=>n!==e),f=Math.min(e,d.length);o.parentOids.forEach((e,t)=>{i.has(e)||i.set(e,t===0?u:n++),!d.includes(e)&&(d.splice(f,0,e),f+=1)});let p=[];c.forEach((t,n)=>{if(n===e){s&&p.push({fromLane:n,from:`top`,toLane:e,to:`node`,color:l});return}let r=d.indexOf(t);r>=0&&p.push({fromLane:n,from:`top`,toLane:r,to:`bottom`,color:i.get(t)??0})}),o.parentOids.forEach(t=>{let n=d.indexOf(t);n>=0&&p.push({fromLane:e,from:`node`,toLane:n,to:`bottom`,color:i.get(t)??u})}),r=Math.max(r,c.length,d.length),a.push({lane:e,color:u,segments:p,continuations:d.map((e,t)=>({lane:t,color:i.get(e)??0}))}),t=d}return{rows:a,laneCount:r}}function E(e,t,n){let r=e.get(t);if(r!==void 0)return r;let i=n();return e.set(t,i),i}function D(e){let t=e.parentCount>1&&/^Merge pull request #(\d+)\b/i.exec(e.subject),n=/\(#(\d+)\)\s*$/.exec(e.subject),r=t||n;if(!r)return null;let i=Number(r[1]);return Number.isSafeInteger(i)&&i>0?{number:i,source:t?`merge`:`subject`}:null}function O(e){if(e.upstreamState===`local-only`)return 0;if(e.baseState===`included`)return 2;if(e.upstreamState===`published`)return 1}function k(e,t){if(!t)return e.map(e=>({commit:e,parentOids:e.parentOids,grouped:[]}));let n=new Map(e.map(e=>[e.oid,e])),r=new Map;e.forEach(e=>e.parentOids.forEach(t=>{let n=r.get(t)??new Set;n.add(e.oid),r.set(t,n)}));let i=new Set,a=[];for(let t of e){if(i.has(t.oid))continue;let e={commit:t,parentOids:t.parentOids,grouped:[]};if(a.push(e),t.parentOids.length!==2)continue;let o=new Set,s=n.get(t.parentOids[0]);for(;s&&!o.has(s.oid);)o.add(s.oid),s=n.get(s.parentOids[0]??``);let c=t.parentOids[1],l=[],u=new Set;for(;!o.has(c);){let e=n.get(c);if(!e||u.has(c)||i.has(c)||e.isHead||e.parentOids.length!==1)break;u.add(c),l.push(e),c=e.parentOids[0]}if(!o.has(c)||l.length===0)continue;let d=new Set([t.oid,...l.map(e=>e.oid)]);l.some(e=>[...r.get(e.oid)??[]].some(e=>!d.has(e)))||l.some(e=>a.some(t=>t.commit.oid===e.oid))||(e.grouped=l,e.parentOids=[t.parentOids[0]],l.forEach(e=>i.add(e.oid)))}return a}function A(e,t){let n=t.trim().toLocaleLowerCase();return n.length>0&&[e.subject,e.author,e.oid,...e.decorations].some(e=>e.toLocaleLowerCase().includes(n))}var j=n();function M({repositoryId:e,upstream:t,readOnly:n,operation:o,canPublish:c,pushBusy:f,onPublish:ee,commits:m,nextCursor:h,loading:g,undoing:_,baseRef:y,activeOid:b,onSelectReference:S,onSelectCommit:C,onSelectFile:E,onUndo:D,onMore:M}){let P=v(),F=(0,w.useRef)(null),[L,R]=(0,w.useState)(new Set),[z,B]=(0,w.useState)(!0),[V,H]=(0,w.useState)(!1),[U,W]=(0,w.useState)(``),[G,K]=(0,w.useState)(-1),q=P?52:z?42:56,J=(0,w.useMemo)(()=>k(m??[],V&&!U.trim()),[m,V,U]),Y=(0,w.useMemo)(()=>T(J.map(({commit:e,parentOids:t})=>({oid:e.oid,parentOids:t,color:O(e)}))),[J]),X=(0,w.useMemo)(()=>J.flatMap(({commit:e},t)=>A(e,U)?[t]:[]),[J,U]),Z=I(Y.laneCount),Q=r({count:J.length,getScrollElement:()=>F.current,estimateSize:()=>q,getItemKey:e=>J[e].commit.oid,overscan:8});(0,w.useEffect)(()=>{Q.measure()},[Q,q]);let te=()=>{if(!X.length)return;let e=(G+1)%X.length;K(e),Q.scrollToIndex(X[e],{align:`center`})};if(m===null)return(0,j.jsxs)(`div`,{className:`view-loading`,role:`status`,children:[(0,j.jsx)(i,{className:`spinner`}),` `,(0,j.jsx)(s,{text:`Loading history…`})]});let $=m.filter(e=>e.upstreamState===`local-only`).length;return(0,j.jsxs)(`div`,{className:`history-list`,style:{"--history-row-height":`${q}px`},children:[(0,j.jsxs)(`div`,{className:`history-toolbar`,children:[(0,j.jsxs)(`label`,{className:`history-search`,children:[(0,j.jsx)(a,{"aria-hidden":`true`}),(0,j.jsx)(`input`,{type:`search`,"aria-label":`Search loaded commits`,placeholder:`Find commit…`,value:U,onChange:e=>{W(e.target.value),K(-1)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),te())}})]}),U&&(0,j.jsxs)(d,{children:[(0,j.jsx)(p,{render:(0,j.jsx)(`button`,{className:`history-next-match`,onClick:te,disabled:!X.length,"aria-label":`Next matching commit`}),children:(0,j.jsx)(x,{})}),(0,j.jsx)(u,{children:`Next match in loaded history (Enter)`})]}),(0,j.jsxs)(d,{children:[(0,j.jsx)(p,{render:(0,j.jsx)(`button`,{className:`history-option`,"aria-pressed":V,disabled:!m.some(e=>e.parentCount>1),onClick:()=>H(!V)}),children:`Group merges`}),(0,j.jsx)(u,{children:`Collapse complete merge branches. Searching reveals their commits.`})]}),!P&&(0,j.jsxs)(d,{children:[(0,j.jsx)(p,{render:(0,j.jsx)(`button`,{className:`history-option`,"aria-pressed":z,onClick:()=>B(!z)}),children:z?`Compact`:`Comfortable`}),(0,j.jsx)(u,{children:`Change row density without moving the diff viewer`})]})]}),!t&&m.length>0&&(0,j.jsxs)(`div`,{className:`history-upstream-notice`,role:`status`,children:[(0,j.jsx)(`span`,{children:`Publish this branch to configure an upstream and distinguish local from published commits.`}),c&&(0,j.jsx)(l,{variant:`outline`,size:`xs`,disabled:f||n||!!o,onClick:ee,children:f?(0,j.jsx)(s,{text:`Publishing…`}):`Publish branch`})]}),t&&$>0&&(0,j.jsxs)(`div`,{className:`history-local-summary`,children:[`↑ `,$,` `,$===1?`local commit`:`local commits`,` in loaded history`]}),(0,j.jsx)(`div`,{ref:F,className:`history-scroll`,role:`list`,"aria-label":`Commit history`,children:J.length===0?(0,j.jsx)(`p`,{className:`empty-list`,children:`This repository has no commits yet.`}):(0,j.jsxs)(`div`,{className:`virtual-list`,style:{height:Q.getTotalSize()+(h?52:0)},children:[Q.getVirtualItems().map(r=>{let{commit:i,grouped:a}=J[r.index];return(0,j.jsx)(`div`,{ref:Q.measureElement,"data-index":r.index,className:`virtual-row`,style:{transform:`translateY(${r.start}px)`},children:(0,j.jsx)(N,{repositoryId:e,upstream:t,baseRef:y,commit:i,graphRow:Y.rows[r.index],graphWidth:Z,rowHeight:q,active:b===i.oid||a.some(e=>e.oid===b),match:A(i,U),groupedCount:a.length,onRevealGroup:()=>H(!1),onSelectReference:S,expanded:L.has(i.oid),onExpandedChange:e=>R(t=>{let n=new Set(t);return e?n.add(i.oid):n.delete(i.oid),n}),canUndo:!n&&!o&&!_&&i.upstreamState===`local-only`&&i.isHead&&i.parentCount===1,onSelectCommit:C,onSelectFile:E,onUndo:D})},r.key)}),h&&(0,j.jsx)(l,{variant:`ghost`,className:`history-more`,style:{top:Q.getTotalSize()},disabled:g,onClick:M,children:g?(0,j.jsx)(s,{text:`Loading…`}):`Load more`})]})}),m.length>0&&(0,j.jsxs)(`div`,{className:`history-legend`,children:[(0,j.jsxs)(`span`,{children:[(0,j.jsx)(`i`,{"data-color":`local`}),`Local`]}),(0,j.jsxs)(`span`,{children:[(0,j.jsx)(`i`,{"data-color":`published`}),`Published`]}),y&&(0,j.jsxs)(d,{children:[(0,j.jsxs)(p,{render:(0,j.jsx)(`span`,{className:`history-base-label`}),children:[(0,j.jsx)(`i`,{"data-color":`base`}),y]}),(0,j.jsxs)(u,{children:[`Primary-line commits reachable from `,y,`, using the latest known local refs. Side branches use the published color.`]})]}),(0,j.jsx)(`span`,{className:`history-count`,role:`status`,children:U?`${X.length} matches in ${m.length} loaded`:`${m.length} loaded`})]})]})}function N({repositoryId:e,upstream:t,baseRef:n,commit:r,graphRow:a,graphWidth:v,rowHeight:y,active:b,match:x,groupedCount:T,onRevealGroup:E,onSelectReference:O,expanded:k,onExpandedChange:A,canUndo:M,onSelectCommit:N,onSelectFile:P,onUndo:F}){let I=`${e}:${r.oid}`,[L,R]=(0,w.useState)(()=>S(I)??null),[U,G]=(0,w.useState)(null);(0,w.useEffect)(()=>{if(!k||L||U)return;let t=!0;return f.commits.files(e,r.oid).then(e=>{t&&(_(I,e),R(e))}).catch(e=>{t&&G(W(e))}),()=>{t=!1}},[I,r.oid,k,L,U,e]);let K=D(r),q=H(r.decorations),J=q.slice(0,3),Y=q.slice(3),X=L?.reduce((e,t)=>e+t.additions,0)??0,Z=L?.reduce((e,t)=>e+t.deletions,0)??0,Q=async()=>{try{await c(r.oid),o.success({title:`Hash copied`,description:r.oid})}catch{o.error({title:`Could not copy hash`})}};return(0,j.jsxs)(`div`,{className:`commit-item${b?` active`:``}${x?` commit-search-match`:``}`,role:`listitem`,children:[(0,j.jsxs)(`div`,{className:`commit-header`,children:[(0,j.jsx)(z,{graph:a,width:v,height:y,merge:r.parentCount>1,head:r.isHead}),(0,j.jsx)(`button`,{className:`commit-expand`,"aria-expanded":k,"aria-label":k?`Collapse commit`:`Expand commit`,onClick:()=>A(!k),children:(0,j.jsx)(g,{className:`folder-chevron ${k?`open`:``}`})}),(0,j.jsxs)(`div`,{className:`commit-main`,children:[(0,j.jsxs)(`span`,{className:`commit-title-row`,children:[(0,j.jsx)(`button`,{className:`commit-subject`,"aria-pressed":b,onClick:()=>N(r),children:r.subject||`(no subject)`}),K&&(0,j.jsxs)(d,{children:[(0,j.jsxs)(p,{render:O?(0,j.jsx)(`button`,{className:`ref-chip commit-pr`,onClick:()=>O(K.number),"aria-label":`Open pull request #${K.number}`}):(0,j.jsx)(`span`,{className:`ref-chip commit-pr`}),children:[(0,j.jsx)(C,{"aria-hidden":`true`}),`#`,K.number]}),(0,j.jsxs)(u,{children:[K.source===`merge`?`Pull request reference from the merge message.`:`Reference from the commit subject; it may identify a pull request or issue.`,O?` Open as a pull request in the right-hand viewer.`:``,` No merge method is inferred from the number.`]})]}),(0,j.jsxs)(d,{children:[(0,j.jsx)(p,{render:(0,j.jsx)(`time`,{className:`commit-date`,dateTime:r.date}),children:h(r.date)}),(0,j.jsx)(u,{children:ee(r.date)})]})]}),(0,j.jsxs)(`span`,{className:`commit-meta`,children:[(q.length>0||r.parentCount>1||r.upstreamState===`local-only`)&&(0,j.jsxs)(`span`,{className:`commit-refs`,children:[r.upstreamState===`local-only`&&(0,j.jsxs)(d,{children:[(0,j.jsx)(p,{render:(0,j.jsx)(`span`,{className:`ref-chip local-only`}),children:`Local`}),(0,j.jsx)(u,{children:r.isHead?`Not in ${t??`the upstream`} according to the latest known remote state.`:`Not published. To avoid rewriting multiple commits, only the latest can be undone.`})]}),r.parentCount>1&&(0,j.jsx)(`span`,{className:`ref-chip merge`,children:`merge`}),J.map(e=>(0,j.jsxs)(d,{children:[(0,j.jsx)(p,{render:(0,j.jsx)(`span`,{className:`ref-chip ${e.kind}`,"data-base":e.label===n||e.label.endsWith(`/HEAD`)&&r.baseState===`included`}),children:e.label}),(0,j.jsx)(u,{children:e.label})]},`${e.kind}:${e.label}`)),Y.length>0&&(0,j.jsxs)(d,{children:[(0,j.jsxs)(p,{render:(0,j.jsx)(`span`,{className:`ref-chip more`}),children:[`+`,Y.length]}),(0,j.jsx)(u,{children:Y.map(e=>e.label).join(` · `)})]})]}),(0,j.jsxs)(d,{children:[(0,j.jsx)(p,{render:(0,j.jsx)(`button`,{className:`commit-oid`,onClick:()=>void Q(),"aria-label":`Copiar hash ${r.shortOid}`}),children:r.shortOid}),(0,j.jsx)(u,{children:`Copy full hash`})]}),(0,j.jsxs)(d,{children:[(0,j.jsx)(p,{render:(0,j.jsx)(`span`,{className:`commit-author`}),children:r.author}),(0,j.jsx)(u,{children:r.author})]}),T>0&&(0,j.jsxs)(d,{children:[(0,j.jsxs)(p,{render:(0,j.jsx)(`button`,{className:`commit-group-count`,onClick:E}),children:[T,` grouped`]}),(0,j.jsxs)(u,{children:[`Show the `,T,` commits in this merge branch`]})]})]})]}),M&&(0,j.jsxs)(d,{children:[(0,j.jsx)(p,{render:(0,j.jsx)(l,{variant:`ghost`,size:`icon-xs`,className:`change-action-button commit-undo`,onClick:e=>{e.stopPropagation(),F(r)},"aria-label":`Undo commit ${r.shortOid}`}),children:(0,j.jsx)(m,{})}),(0,j.jsx)(u,{children:`Undo commit and keep its changes staged`})]})]}),k&&a.continuations.length>0&&(0,j.jsx)(B,{graph:a,width:v}),k&&(0,j.jsxs)(`div`,{className:`commit-files`,style:{paddingLeft:v+31},children:[r.body&&(0,j.jsx)(`p`,{className:`commit-description`,children:r.body}),U&&(0,j.jsx)(`div`,{className:`commit-files-message error`,children:U}),!L&&!U&&(0,j.jsxs)(`div`,{className:`commit-files-message`,children:[(0,j.jsx)(i,{className:`spinner`}),` `,(0,j.jsx)(s,{text:`Loading files…`})]}),L&&L.length===0&&(0,j.jsx)(`div`,{className:`commit-files-message`,children:r.parentCount>1?`This merge commit has no changes of its own.`:`This commit has no file changes.`}),L&&L.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`commit-files-summary`,children:[L.length,` `,L.length===1?`file`:`files`,(X>0||Z>0)&&(0,j.jsxs)(j.Fragment,{children:[` · `,(0,j.jsxs)(`span`,{className:`add`,children:[`+`,X]}),` `,(0,j.jsxs)(`span`,{className:`del`,children:[`−`,Z]})]})]}),L.map(e=>(0,j.jsx)(V,{file:e,onSelect:()=>P(r.oid,e)},e.path))]})]})]})}var P=14,F=[`var(--history-local)`,`var(--history-published)`,`var(--history-base)`];function I(e){return 14+Math.max(0,e-1)*P}function L(e){return 7+e*P}function R(e){return F[e]??`var(--history-published)`}function z({graph:e,width:t,height:n,merge:r,head:i}){let a=n/2;return(0,j.jsxs)(`svg`,{className:`commit-graph`,width:t,height:n,viewBox:`0 0 ${t} ${n}`,"aria-hidden":`true`,children:[e.segments.map((e,t)=>{let r=L(e.fromLane),i=L(e.toLane),o=e.from===`top`?0:a,s=e.to===`node`?a:n,c=(o+s)/2,l=r===i?`M ${r} ${o} L ${i} ${s}`:`M ${r} ${o} C ${r} ${c}, ${i} ${c}, ${i} ${s}`;return(0,j.jsx)(`path`,{d:l,stroke:R(e.color)},`${t}:${l}`)}),(0,j.jsx)(`circle`,{cx:L(e.lane),cy:a,r:r||i?4.5:3,fill:r||i?`var(--sidebar)`:R(e.color),stroke:R(e.color)}),r&&(0,j.jsx)(`circle`,{cx:L(e.lane),cy:a,r:`1.6`,fill:R(e.color)})]})}function B({graph:e,width:t}){return(0,j.jsx)(`svg`,{className:`commit-graph-continuation`,width:t,viewBox:`0 0 ${t} 100`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:e.continuations.map(e=>(0,j.jsx)(`line`,{x1:L(e.lane),y1:`0`,x2:L(e.lane),y2:`100`,stroke:R(e.color)},e.lane))})}function V({file:e,onSelect:t}){let n=(0,w.useRef)(null),r=e.path.lastIndexOf(`/`),i=r<0?e.path:e.path.slice(r+1),a=e.oldPath?.split(`/`).pop();return(0,j.jsxs)(`div`,{ref:n,className:`commit-file-row`,children:[(0,j.jsxs)(d,{children:[(0,j.jsxs)(p,{render:(0,j.jsx)(`button`,{className:`commit-file-label`,onClick:t,"aria-label":`Ver el diff de ${e.path}`}),children:[(0,j.jsx)(U,{path:e.path,type:`file`}),(0,j.jsxs)(`span`,{className:`commit-file-text`,children:[(0,j.jsx)(`span`,{children:i}),a&&(0,j.jsxs)(`small`,{className:`commit-file-rename`,children:[a,` →`]})]})]}),(0,j.jsx)(u,{anchor:n,side:`right`,sideOffset:10,children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path})]}),(0,j.jsx)(`span`,{className:`commit-file-stats`,children:e.binary?(0,j.jsx)(`span`,{className:`binary`,children:`bin`}):(0,j.jsxs)(j.Fragment,{children:[e.additions>0&&(0,j.jsxs)(`span`,{className:`add`,children:[`+`,e.additions]}),e.deletions>0&&(0,j.jsxs)(`span`,{className:`del`,children:[`−`,e.deletions]})]})}),(0,j.jsx)(`span`,{className:`status-code`,"data-kind":e.kind,children:y(e.kind)})]})}function H(e){return e.map(e=>e.startsWith(`tag: `)?{label:e.slice(5),kind:`tag`}:e.startsWith(`HEAD -> `)?{label:e.slice(8),kind:`head`}:e===`HEAD`?{label:`HEAD`,kind:`head`}:{label:e,kind:e.includes(`/`)?`remote`:`branch`})}function U({path:e}){return(0,j.jsx)(`img`,{className:`vscode-tree-icon`,src:b(e),alt:``,"aria-hidden":`true`,draggable:!1})}function W(e){return e instanceof Error?e.message:`An unexpected error occurred.`}export{M as HistoryView};
@@ -1,2 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{Ct as t,xt as n}from"./base-ui-DDpgJXgO.js";import{n as r,r as i,t as a}from"./viewer-tabs-MMNrJqGE.js";import{FileSaveControls as o,SourceCodeEditor as s,t as c}from"./EditableFileViewer-BE3AsnVa.js";var l=e(t()),u=`data-opentig-preview-scrollbar`;function d(e,t){let n=t?`255 255 255`:`0 0 0`,r=[`<style ${u}>`,`html {`,` color-scheme: ${t?`dark`:`light`} !important;`,` background-color: ${t?`oklch(0.13 0 0)`:`oklch(0.985 0 0)`} !important;`,`}`,`html, body, * {`,` scrollbar-width: thin !important;`,` scrollbar-color: rgb(${n} / 18%) transparent !important;`,`}`,`html::-webkit-scrollbar, body::-webkit-scrollbar, *::-webkit-scrollbar { width: 10px !important; height: 10px !important; }`,`html::-webkit-scrollbar-track, body::-webkit-scrollbar-track, *::-webkit-scrollbar-track,`,`html::-webkit-scrollbar-corner, body::-webkit-scrollbar-corner, *::-webkit-scrollbar-corner { background: transparent !important; }`,`html::-webkit-scrollbar-thumb, body::-webkit-scrollbar-thumb, *::-webkit-scrollbar-thumb {`,` background-color: rgb(${n} / 18%) !important;`,` background-clip: content-box !important;`,` border: 3px solid transparent !important;`,` border-radius: 999px !important;`,`}`,`html::-webkit-scrollbar-thumb:hover, body::-webkit-scrollbar-thumb:hover, *::-webkit-scrollbar-thumb:hover { background-color: rgb(${n} / 28%) !important; }`,`html::-webkit-scrollbar-button, body::-webkit-scrollbar-button, *::-webkit-scrollbar-button { display: none !important; width: 0 !important; height: 0 !important; }`,`</style>`].join(`
2
- `),i=e.search(/<\/head\s*>/i);if(i>=0)return`${e.slice(0,i)}${r}\n${e.slice(i)}`;let a=/<head(?:\s[^>]*)?>/i.exec(e);if(a?.index!==void 0){let t=a.index+a[0].length;return`${e.slice(0,t)}\n${r}${e.slice(t)}`}let o=/<html(?:\s[^>]*)?>/i.exec(e);if(o?.index!==void 0){let t=o.index+o[0].length;return`${e.slice(0,t)}\n<head>${r}</head>${e.slice(t)}`}return`${r}\n${e}`}var f=n(),p={conflictTitle:`HTML was changed outside OpenTig`,successTitle:`HTML saved`,errorTitle:`Could not save HTML`};function m({file:e,initialContent:t,themeType:n,wrapLines:u,readOnly:m,onDirtyChange:h,onDraftChange:g,onSave:_}){let[v,y]=(0,l.useState)(`preview`),b=(0,l.useRef)(null),x=`html-preview-${(0,l.useId)().replace(/:/g,``)}`,{draft:S,updateDraft:C,dirty:w,saving:T,save:E}=c({file:e,initialContent:t,readOnly:m,messages:p,onDirtyChange:h,onDraftChange:g,onSave:_}),D=n===`dark`||n===`system`&&document.documentElement.classList.contains(`dark`),O=(0,l.useMemo)(()=>d(S,D),[D,S]);return(0,l.useEffect)(()=>{v===`preview`&&b.current?.requestSubmit()},[O,v]),(0,l.useEffect)(()=>{y(`preview`)},[e.path]),(0,f.jsxs)(a,{value:v,onValueChange:e=>y(e),className:`markdown-viewer html-file-viewer`,children:[(0,f.jsxs)(`div`,{className:`file-viewer-pill markdown-viewer-toolbar`,children:[(0,f.jsx)(r,{label:`HTML view`,className:`file-viewer-tabs markdown-viewer-tabs`,items:[{value:`preview`,label:`Preview`},{value:`code`,label:(0,f.jsxs)(f.Fragment,{children:[`Code `,w&&(0,f.jsx)(`span`,{className:`markdown-unsaved-dot`,"aria-label":`Unsaved changes`})]})}]}),(0,f.jsx)(o,{dirty:w,saving:T,readOnly:m,onSave:()=>void E()})]}),(0,f.jsxs)(i,{value:`preview`,className:`html-preview-panel`,children:[(0,f.jsx)(`iframe`,{className:`html-preview-frame`,name:x,title:`Preview of ${e.path}`,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`}),(0,f.jsx)(`form`,{ref:b,className:`html-preview-form`,method:`post`,action:`/api/html-preview`,target:x,encType:`application/x-www-form-urlencoded`,children:(0,f.jsx)(`input`,{type:`hidden`,name:`document`,value:O})})]}),(0,f.jsx)(i,{value:`code`,className:`markdown-code-view`,"data-theme":n,children:(0,f.jsx)(s,{path:e.path,cacheKey:e.path,value:S,themeType:n,wrapLines:u,readOnly:m||T,onChange:C})})]})}export{m as HtmlFileViewer};
@@ -1 +0,0 @@
1
- import{t as e}from"./createReactComponent-BfrD_oQK.js";var t=e(`outline`,`check`,`Check`,[[`path`,{d:`M5 12l5 5l10 -10`,key:`svg-0`}]]);export{t};
@@ -1 +0,0 @@
1
- import{t as e}from"./createReactComponent-BfrD_oQK.js";var t=e(`outline`,`chevron-down`,`ChevronDown`,[[`path`,{d:`M6 9l6 6l6 -6`,key:`svg-0`}]]);export{t};