@p4code/cli 0.8.14 → 0.8.16
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.
- package/dist/bin.mjs +1 -1
- package/dist/{binCli-BvhJ8Jqb.mjs → binCli-CI34F60b.mjs} +43 -16
- package/dist/client/.vite/manifest.json +2144 -2144
- package/dist/client/assets/AlertDialogRoot-DYtW2IF3.js +2 -0
- package/dist/client/assets/{AnimatedHeight-CH-N3JTc.js → AnimatedHeight-CzFc8xri.js} +2 -2
- package/dist/client/assets/{AuthSurfaceShell-Dfm2iXjM.js → AuthSurfaceShell-BIM2_E9K.js} +2 -2
- package/dist/client/assets/{CSPContext-4VAD2_gc.js → CSPContext-DcW0os5z.js} +2 -2
- package/dist/client/assets/{ChatGptUsageButton-BE2a_fvh.js → ChatGptUsageButton-D6bmo65C.js} +2 -2
- package/dist/client/assets/{ChatMarkdown-2qihmx2E.js → ChatMarkdown-CjusdpPE.js} +4 -4
- package/dist/client/assets/{CheckboxIndicator-ClY0P0ol.js → CheckboxIndicator-DRAilQdq.js} +2 -2
- package/dist/client/assets/{CodexSetupSection.logic-CZIedhFM.js → CodexSetupSection.logic-CSXvl05k.js} +2 -2
- package/dist/client/assets/{CollapsiblePanel-Cubscn-a.js → CollapsiblePanel-DMH4QH0_.js} +2 -2
- package/dist/client/assets/{ComboboxClear-qTthzuJh.js → ComboboxClear-DV4ygCOL.js} +2 -2
- package/dist/client/assets/{CommandBlock-cV3B4sIS.js → CommandBlock-DVrmnpxz.js} +2 -2
- package/dist/client/assets/{ComposerPromptEditor-l0YJjut-.js → ComposerPromptEditor-CvJcJEtN.js} +4 -4
- package/dist/client/assets/{CompositeRoot-DUqf78yV.js → CompositeRoot-CsrLt1o5.js} +2 -2
- package/dist/client/assets/{ConnectionStatusDot-cdpNRZhA.js → ConnectionStatusDot-uWbIqk3l.js} +2 -2
- package/dist/client/assets/{DevicePanel-CyqJ_QAv.js → DevicePanel-Bf1rvcrw.js} +2 -2
- package/dist/client/assets/{DeviceSetup-B9gRys_T.js → DeviceSetup-CX-B4Xfz.js} +2 -2
- package/dist/client/assets/{DialogTitle-CQU6s1Wy.js → DialogTitle-BgclXafx.js} +2 -2
- package/dist/client/assets/{DiffCommentAnnotation-DqJdp0B7.js → DiffCommentAnnotation-CKRC0OaV.js} +2 -2
- package/dist/client/assets/{DiffFileTree-C0BZv_u5.js → DiffFileTree-xeoOBCTn.js} +2 -2
- package/dist/client/assets/{DiffPanel-DvpW3Wct.js → DiffPanel-CzkU9nAC.js} +2 -2
- package/dist/client/assets/{DiffWorkerPoolProvider-C0s_fra9.js → DiffWorkerPoolProvider-NaKmpbcL.js} +2 -2
- package/dist/client/assets/{EmbeddedDesign-DGCXXVf5.js → EmbeddedDesign-hjnHhasg.js} +2 -2
- package/dist/client/assets/{EnvironmentMachineIcon-DCdlTSYU.js → EnvironmentMachineIcon-Czk_PJpp.js} +2 -2
- package/dist/client/assets/{ExpandableText-BtdwzlFy.js → ExpandableText-Ggw0uVXl.js} +2 -2
- package/dist/client/assets/{FieldControl-BI2gK4Z0.js → FieldControl-Bw2_eFMa.js} +2 -2
- package/dist/client/assets/{FileDiff-BtKZeeO5.js → FileDiff-VvQl3KAm.js} +2 -2
- package/dist/client/assets/{FilePreviewPanel-DzVGuSCc.js → FilePreviewPanel-DpzZ6qxm.js} +2 -2
- package/dist/client/assets/{FoldedSettingsSection-VCEXXLW3.js → FoldedSettingsSection-BFkFGK44.js} +2 -2
- package/dist/client/assets/{FormContext-Bgwez2tv.js → FormContext-7fCTOXXA.js} +2 -2
- package/dist/client/assets/{Icons-B5JVkp3z.js → Icons-CSAp87pJ.js} +2 -2
- package/dist/client/assets/Input-Cr3X6dPy.js +2 -0
- package/dist/client/assets/{KeybindingsSettings.logic-6lVDnd1N.js → KeybindingsSettings.logic-CsSjvH9c.js} +2 -2
- package/dist/client/assets/{NoProjectsHero-BQBJO2CN.js → NoProjectsHero--g3-0FUP.js} +2 -2
- package/dist/client/assets/{PanelLayoutControls-DnSdAhOm.js → PanelLayoutControls-BxdDsUL3.js} +4 -4
- package/dist/client/assets/{PierreEntryIcon-B1r7qMgq.js → PierreEntryIcon-B-E3YaL1.js} +2 -2
- package/dist/client/assets/{PopoverHandle-CBT8hFut.js → PopoverHandle-BkhR-kKK.js} +2 -2
- package/dist/client/assets/{PreviewPanel-CtXaNx5N.js → PreviewPanel-VoVAdWRz.js} +2 -2
- package/dist/client/assets/{ProjectDefaultsSettings-BYtlqxeq.js → ProjectDefaultsSettings-DtvFnrMn.js} +2 -2
- package/dist/client/assets/{ProjectFavicon-B5bWp7V6.js → ProjectFavicon-CeJHd7lY.js} +3 -3
- package/dist/client/assets/{ProjectIconPickerDialog-BWSyrwJD.js → ProjectIconPickerDialog-DBo5zoxF.js} +2 -2
- package/dist/client/assets/{ProjectMonogram-B9iJhcVp.js → ProjectMonogram-CWdfC9NP.js} +2 -2
- package/dist/client/assets/{ProviderAuthTerminal-B2L5_uXE.js → ProviderAuthTerminal-BPUxIxWE.js} +2 -2
- package/dist/client/assets/{ProviderModelPicker-B8ibbi9S.js → ProviderModelPicker-JUsjo9GU.js} +2 -2
- package/dist/client/assets/{ProviderSettingsForm-DYn7It9I.js → ProviderSettingsForm-VoB8oygt.js} +2 -2
- package/dist/client/assets/{PullRequestCodeTab-BfSQc1r1.js → PullRequestCodeTab-CbKTE6Jz.js} +2 -2
- package/dist/client/assets/{ReadOnlySourcePreview-8MghAaC9.js → ReadOnlySourcePreview-DlWlnYoW.js} +2 -2
- package/dist/client/assets/{RenderErrorBoundary-Dm9BLD1I.js → RenderErrorBoundary-DpI8Ovyx.js} +2 -2
- package/dist/client/assets/{ScheduledTasksSettings-ClZG_1G7.js → ScheduledTasksSettings-Cc15ado1.js} +2 -2
- package/dist/client/assets/{ScopedSwitch-C7nxtEAT.js → ScopedSwitch-CaVh740d.js} +2 -2
- package/dist/client/assets/{ScrollAreaCorner-CoeXGFSL.js → ScrollAreaCorner-DXYr9Xbu.js} +2 -2
- package/dist/client/assets/{SecretInput-CROqj1gF.js → SecretInput-WUih9JDs.js} +2 -2
- package/dist/client/assets/{SelectScrollUpArrow-SDOpV3nj.js → SelectScrollUpArrow-BIdW5z3c.js} +2 -2
- package/dist/client/assets/{SettingsPanels-kXpGLc3M.js → SettingsPanels-CSUZtGSF.js} +2 -2
- package/dist/client/assets/{SettingsPanels.logic-CcNyZsm-.js → SettingsPanels.logic-Ce6a_3Zx.js} +2 -2
- package/dist/client/assets/{SettingsScopeNotice-CM4ubyNs.js → SettingsScopeNotice-RvGwRluQ.js} +2 -2
- package/dist/client/assets/{T3ConnectAccountPages-Cm4JG3hx.js → T3ConnectAccountPages-Dltl5esW.js} +2 -2
- package/dist/client/assets/{T3ConnectSidebarSignIn-CmvCTtlG.js → T3ConnectSidebarSignIn-qx3Qtdnf.js} +2 -2
- package/dist/client/assets/{ThemeEditorPanel-kOwPAMtd.js → ThemeEditorPanel-DspojrU_.js} +2 -2
- package/dist/client/assets/{ThreadTerminalDrawer-CK0khkH6.js → ThreadTerminalDrawer-mE2aj0U7.js} +2 -2
- package/dist/client/assets/{TooltipViewport-BKD6QABG.js → TooltipViewport-Daddx30c.js} +2 -2
- package/dist/client/assets/{Virtualizer-B895TWmX.js → Virtualizer-DySKW4Qd.js} +2 -2
- package/dist/client/assets/{WorkspaceBreadcrumb-BmVcurpi.js → WorkspaceBreadcrumb-B3WecLwo.js} +2 -2
- package/dist/client/assets/{WorkspacePageContainer-BSjVd7h4.js → WorkspacePageContainer-rn16R8Ps.js} +2 -2
- package/dist/client/assets/{WorkspacePageHeader-BLYOcS9Z.js → WorkspacePageHeader-B2wsiKGJ.js} +2 -2
- package/dist/client/assets/{_chat-akhFQFVf.js → _chat-D4KQBrU-.js} +6 -6
- package/dist/client/assets/{_chat.index-P-ZRID1j.js → _chat.index-DYOE3ChI.js} +2 -2
- package/dist/client/assets/{_chat.new-DXkFcRYp.js → _chat.new-BTckKJwz.js} +2 -2
- package/dist/client/assets/{_chat.pull-requests-BYR5YTIM.js → _chat.pull-requests-BYdISBjt.js} +2 -2
- package/dist/client/assets/{abnfDiagram-VCTEODGH-CcoyEMJc.js → abnfDiagram-VCTEODGH-CiK3BBs3.js} +2 -2
- package/dist/client/assets/{alert-5swcxUBm.js → alert-CvIEaZOb.js} +2 -2
- package/dist/client/assets/architecture-7GRP2DOG-I5ogqlvV.js +1 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-CXxubV6d.js → architectureDiagram-5GKGNRK7-wAHn9Lrj.js} +2 -2
- package/dist/client/assets/{assets-C7tdule6.js → assets-B17ISP56.js} +2 -2
- package/dist/client/assets/{blockDiagram-I7D4REHJ-DWnNJQVf.js → blockDiagram-I7D4REHJ-Cp3-BNSr.js} +2 -2
- package/dist/client/assets/{browserHistoryStore-PqPCT4tW.js → browserHistoryStore-DWdy6V_l.js} +2 -2
- package/dist/client/assets/{browserLinkTarget-CWURM-O2.js → browserLinkTarget-BEJDPOgD.js} +2 -2
- package/dist/client/assets/{c4Diagram-7LVT6UL2-DKlxhhfG.js → c4Diagram-7LVT6UL2-NaJ4CkHK.js} +2 -2
- package/dist/client/assets/channel-3VrneojD.js +2 -0
- package/dist/client/assets/{checkbox-1tz9neVf.js → checkbox-EHQPSidC.js} +2 -2
- package/dist/client/assets/{chunk-4HAMMTFA-BXCbWh-l.js → chunk-4HAMMTFA-qa80OHyq.js} +2 -2
- package/dist/client/assets/{chunk-75Z2AOVW-ByRA_PDR.js → chunk-75Z2AOVW-BQGpvZ-z.js} +2 -2
- package/dist/client/assets/{chunk-DU6HZSFF-CxOE2RJx.js → chunk-DU6HZSFF-D2KfUzzn.js} +2 -2
- package/dist/client/assets/{chunk-F27PBJKO-DXbxgIcF.js → chunk-F27PBJKO-DWzMfgh0.js} +2 -2
- package/dist/client/assets/{chunk-GMAD6QVW-C-CPxvzK.js → chunk-GMAD6QVW-C20gX9zS.js} +2 -2
- package/dist/client/assets/{chunk-GVQU2GXP-N8FA1SLM.js → chunk-GVQU2GXP-CkUVHa35.js} +2 -2
- package/dist/client/assets/{chunk-IMKFNOWR-DTBCxfEA.js → chunk-IMKFNOWR-Dnxgnf8H.js} +2 -2
- package/dist/client/assets/{chunk-L3NEJ4N5-DpY0Sgfm.js → chunk-L3NEJ4N5-DUqnqYMY.js} +2 -2
- package/dist/client/assets/{chunk-OSK3NFVY-BZXi7c79.js → chunk-OSK3NFVY-DEacs3_i.js} +2 -2
- package/dist/client/assets/{chunk-P2QGCYS3-CEZ0Wrp3.js → chunk-P2QGCYS3-ZwThzrs-.js} +2 -2
- package/dist/client/assets/{chunk-POPQ4Y6H-ChY6VtHX.js → chunk-POPQ4Y6H-BFIplCZ4.js} +2 -2
- package/dist/client/assets/{chunk-PWAF6VOD-ynZZsG4M.js → chunk-PWAF6VOD-CV049Zsa.js} +2 -2
- package/dist/client/assets/{chunk-SHT3W25Y-B2nWifo1.js → chunk-SHT3W25Y-BE3qAxKX.js} +2 -2
- package/dist/client/assets/{chunk-SVP7TREG-B8mLhKtO.js → chunk-SVP7TREG-DWTRXiC1.js} +2 -2
- package/dist/client/assets/{chunk-TICWLB2K-DRpXMD23.js → chunk-TICWLB2K-D7wrITi8.js} +2 -2
- package/dist/client/assets/classDiagram-ZZMXUADV-cGz3NSHA.js +2 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-cGz3NSHA.js +2 -0
- package/dist/client/assets/{color-picker-N6f_Hu7P.js → color-picker-Dd1K-QRk.js} +2 -2
- package/dist/client/assets/{combobox-B07cVaQY.js → combobox-BqpUmoio.js} +2 -2
- package/dist/client/assets/{command-B70eQIps.js → command-D1peviZr.js} +2 -2
- package/dist/client/assets/{connect-C2Pvay2K.js → connect-BJSxZzk6.js} +2 -2
- package/dist/client/assets/{connect-agent-F9m6jdrN.js → connect-agent-DfhS_H4b.js} +2 -2
- package/dist/client/assets/{cynefin-OW5HDTMX-Bdj9a2Tr.js → cynefin-OW5HDTMX-dVUNi-Eg.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-CI4Z0tY2.js → cynefinDiagram-5FMLGOSQ-Djkby1yV.js} +2 -2
- package/dist/client/assets/{dagre-GXQ25YYZ-BiXNu3UE.js → dagre-GXQ25YYZ-By44EUZw.js} +2 -2
- package/dist/client/assets/{device-dy573Bzs.js → device-Dk2NULhB.js} +2 -2
- package/dist/client/assets/{diagram-S7CK7UJ4-BoHm89r6.js → diagram-S7CK7UJ4-C0o6sI0g.js} +2 -2
- package/dist/client/assets/{diagram-UQ7AKVKN-C-2Ubrz8.js → diagram-UQ7AKVKN-s2vz22qd.js} +2 -2
- package/dist/client/assets/{diagram-VSXAHHWV-5CTD9pHp.js → diagram-VSXAHHWV-CylpbhVy.js} +2 -2
- package/dist/client/assets/{diagram-VX7I27RA-BJfYpp_F.js → diagram-VX7I27RA-Bz50mxAk.js} +2 -2
- package/dist/client/assets/{diagram-Z3DM3KII-z35dx_kK.js → diagram-Z3DM3KII-BwwAXl7S.js} +2 -2
- package/dist/client/assets/{dialog-DmneyTGi.js → dialog-BfenC7sz.js} +2 -2
- package/dist/client/assets/{diffRendering-BiYYLTwl.js → diffRendering-4kDIxoRz.js} +2 -2
- package/dist/client/assets/{discovery-list-ZGkddsst.js → discovery-list-NHMaJPrr.js} +2 -2
- package/dist/client/assets/{dist-Bl7QV0pY.js → dist-DPoczA-G.js} +3 -3
- package/dist/client/assets/{draft-input-DHZ1J7B_.js → draft-input-rVkOduh_.js} +2 -2
- package/dist/client/assets/{duoViewer-CPD9Wvk1.js → duoViewer-CYEmwhMX.js} +2 -2
- package/dist/client/assets/{dynamic-DcfMLaU_.js → dynamic-DO1Y_hZw.js} +2 -2
- package/dist/client/assets/{ebnfDiagram-PWID7BFC-C2Fa8ORo.js → ebnfDiagram-PWID7BFC-CZWDrYgP.js} +2 -2
- package/dist/client/assets/{embeddedScripts-DFdnbLSr.js → embeddedScripts-gw0IVEit.js} +2 -2
- package/dist/client/assets/{empty-hFNkAHps.js → empty-xf3NEL4p.js} +2 -2
- package/dist/client/assets/{entities-B2DNkHHQ.js → entities-D1h9ACDa.js} +2 -2
- package/dist/client/assets/{environments-Bqz0Jaj_.js → environments-CShRJEmR.js} +2 -2
- package/dist/client/assets/{erDiagram-RLTQ6QDP-WIlBdlNc.js → erDiagram-RLTQ6QDP-nQAwXpMH.js} +2 -2
- package/dist/client/assets/eventmodeling-NTZA5JFV-CCbbQaex.js +1 -0
- package/dist/client/assets/{fileLinks-Y7rrQ-ob.js → fileLinks-hdHZBPGX.js} +2 -2
- package/dist/client/assets/{fileTreeExpansion-CktIYdPM.js → fileTreeExpansion-VkvCaw5c.js} +2 -2
- package/dist/client/assets/flowDiagram-HODETNUW-BwO_EBwI.js +1 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-CzIDxrzr.js → ganttDiagram-EL5Y4UJY-DWYM0gWT.js} +2 -2
- package/dist/client/assets/{getDiffFileInput-DaXZ00WD.js → getDiffFileInput-D107eiKt.js} +2 -2
- package/dist/client/assets/{gitGraph-4MIJSDKK-VJZ5WW8j.js → gitGraph-4MIJSDKK-COMcQtZ6.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX--N7ACKgH.js → gitGraphDiagram-WWUBYQGX-BQoQgnaf.js} +2 -2
- package/dist/client/assets/{guideRunStore-C8Xso-YV.js → guideRunStore-U-mQ5TrH.js} +2 -2
- package/dist/client/assets/{htmlRender-BxVc1PlI.js → htmlRender-CDbYs9Mi.js} +2 -2
- package/dist/client/assets/{index-9_IX9wXh.js → index-B3Ar6SfQ.js} +3 -3
- package/dist/client/assets/{info-A6RAGUB7-BsLL2HTs.js → info-A6RAGUB7-DztiJcIo.js} +1 -1
- package/dist/client/assets/{infoDiagram-27XIBGKW-H0RWUQa6.js → infoDiagram-27XIBGKW-4UkpJDZ8.js} +2 -2
- package/dist/client/assets/{input-RqvQJ9gh.js → input-CF-egQtG.js} +2 -2
- package/dist/client/assets/{input-group-BFtrsedw.js → input-group-CifPZlNg.js} +2 -2
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-BoBtpQFP.js → ishikawaDiagram-5VMMS53U-DhRs1gS_.js} +2 -2
- package/dist/client/assets/{journeyDiagram-3NMN7TZE-rcwS0plS.js → journeyDiagram-3NMN7TZE-CkzLNTms.js} +2 -2
- package/dist/client/assets/{kanban-definition-UXKFOSKX-CMC0FYSq.js → kanban-definition-UXKFOSKX-DnnZRuwk.js} +2 -2
- package/dist/client/assets/{kbd-BnsXAHsc.js → kbd-DN9MXWor.js} +2 -2
- package/dist/client/assets/{keybindings-BtHOXkP-.js → keybindings-BlEA4Dlt.js} +2 -2
- package/dist/client/assets/{lazyRouteComponent-T0YE6Rn9.js → lazyRouteComponent-b9hpLjZB.js} +2 -2
- package/dist/client/assets/{line-CbOfbAku.js → line-BQc8Tfxv.js} +2 -2
- package/dist/client/assets/{link-gKYnbTYT.js → link-BIudTto8.js} +2 -2
- package/dist/client/assets/{linkedPrompt-Bw0INRKj.js → linkedPrompt-DhAklUFf.js} +2 -2
- package/dist/client/assets/{main-CoSpTpWL.css → main-ChIB1-3M.css} +1 -1
- package/dist/client/assets/{main-C6Kmott7.js → main-CqNzdsfA.js} +7 -7
- package/dist/client/assets/{mediaReference-CRKV_ScS.js → mediaReference-Cnqpj8T4.js} +2 -2
- package/dist/client/assets/{mediaSource-Hn2lPB2b.js → mediaSource-DoFgutG9.js} +2 -2
- package/dist/client/assets/{mermaid-parser.core-BGJPFG4o.js → mermaid-parser.core-DkdUKkht.js} +4 -4
- package/dist/client/assets/{mermaid.core-Bt6Qv84k.js → mermaid.core-Bq1JlzgL.js} +5 -5
- package/dist/client/assets/{mindmap-definition-YA3MSWOX-4Y8RevXP.js → mindmap-definition-YA3MSWOX-D8mmtbMo.js} +2 -2
- package/dist/client/assets/{number-field-DIYUxout.js → number-field-CydqGM9B.js} +2 -2
- package/dist/client/assets/{observeResize-D9ECzP-D.js → observeResize-BxVCxCXG.js} +2 -2
- package/dist/client/assets/{onboarding-BnJjKcjq.js → onboarding-DeRMOHIy.js} +2 -2
- package/dist/client/assets/{openFileInPreview-BupyBOTN.js → openFileInPreview-yiAUHSWv.js} +2 -2
- package/dist/client/assets/{p4ProjectFile-CUk0B5Zd.js → p4ProjectFile-CN1m1U7N.js} +2 -2
- package/dist/client/assets/{packet-AYTQ26CC-CRQRHja4.js → packet-AYTQ26CC-BWg_Iaga.js} +1 -1
- package/dist/client/assets/{pair-ohR-X0pV.js → pair-DzpeGOSy.js} +2 -2
- package/dist/client/assets/{pegDiagram-XKGWAZYB-Dk0K8AzU.js → pegDiagram-XKGWAZYB-CAzHwR2-.js} +2 -2
- package/dist/client/assets/{phoneViewer-DD_58CZV.js → phoneViewer-FlyoV9qT.js} +2 -2
- package/dist/client/assets/{pie-WAS4IAKB-CWKurrWM.js → pie-WAS4IAKB-DcySclOi.js} +1 -1
- package/dist/client/assets/{pieDiagram-E7YTZNPT-DlRA_ADi.js → pieDiagram-E7YTZNPT-B00nxfti.js} +2 -2
- package/dist/client/assets/{pierre-icons-Bj2UJzq7.js → pierre-icons-u_a0tCKH.js} +2 -2
- package/dist/client/assets/{popover-DE9WCm99.js → popover-BunL7s_L.js} +2 -2
- package/dist/client/assets/{preview-Cl-7ojv-.js → preview-B_wcdd8X.js} +2 -2
- package/dist/client/assets/{preview-Czvs-xjq.js → preview-DJTsHJUF.js} +2 -2
- package/dist/client/assets/{previewMiniPlayerStore-Bz1T9oVV.js → previewMiniPlayerStore-gZV-IkW-.js} +2 -2
- package/dist/client/assets/{primary-C0h34HcZ.js → primary-BqinBW4U.js} +2 -2
- package/dist/client/assets/{primaryCloudLinkState-EkUmcneJ.js → primaryCloudLinkState-hwg0TXVd.js} +2 -2
- package/dist/client/assets/{projectFilesQueryState-DDX2gPG6.js → projectFilesQueryState-DVWHpzC3.js} +2 -2
- package/dist/client/assets/{projectScriptEditor-B-W-Sbdv.js → projectScriptEditor-RRQopHne.js} +2 -2
- package/dist/client/assets/{providerSkills-OoPsDyac.js → providerSkills-BmchYM4E.js} +2 -2
- package/dist/client/assets/{pullRequestDetail.logic-BZIPv0wR.js → pullRequestDetail.logic-CjznZ6xd.js} +2 -2
- package/dist/client/assets/{pullRequestIcons-D5Yo5Zsn.js → pullRequestIcons-BZCS4C5B.js} +2 -2
- package/dist/client/assets/{pullRequestReviewStore-DaEzt1m1.js → pullRequestReviewStore-BqvYYzmT.js} +2 -2
- package/dist/client/assets/{pullRequests-BuF4aTBF.js → pullRequests-iwguXcJ4.js} +2 -2
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-Cgrn1gJf.js → quadrantDiagram-AXDQQJYC-DXb-ZTK9.js} +2 -2
- package/dist/client/assets/{queries-B5qQohie.js → queries-D53cjqgz.js} +2 -2
- package/dist/client/assets/{query-Bd5_Y_Vy.js → query-CRswjQ7f.js} +2 -2
- package/dist/client/assets/{radar-RG4KPBEZ-BNds8J7E.js → radar-RG4KPBEZ-BeXZggD1.js} +1 -1
- package/dist/client/assets/{radio-group-CBunNtTU.js → radio-group-DzD2uI5x.js} +2 -2
- package/dist/client/assets/{railroad-74A4TZTK-c-ku32yb.js → railroad-74A4TZTK-DGDA4rny.js} +1 -1
- package/dist/client/assets/railroad-abnf-HS5TGJTU-BszadkTZ.js +1 -0
- package/dist/client/assets/railroad-ebnf-LZEXJU2U-Cs2gjnvT.js +1 -0
- package/dist/client/assets/railroad-peg-WCYAUIDC-mvB_-15Z.js +1 -0
- package/dist/client/assets/{railroadDiagram-O6MQD6OU-CQ0Qmd0t.js → railroadDiagram-O6MQD6OU-2U2BGUTN.js} +2 -2
- package/dist/client/assets/{renderScheduler-CFozWmL-.js → renderScheduler-Bwwdk-oE.js} +2 -2
- package/dist/client/assets/{requirementDiagram-BXWQKSXE-ssGfFSCi.js → requirementDiagram-BXWQKSXE-BpZZUYPx.js} +2 -2
- package/dist/client/assets/{rightPanelStore-6-YhsfkE.js → rightPanelStore-CcmIdfDA.js} +2 -2
- package/dist/client/assets/{runtime-C2Cbg6bw.js → runtime-D1cxRUzP.js} +2 -2
- package/dist/client/assets/{runtime-C9FXEGBC.js → runtime-Dz1hyHmq.js} +3 -3
- package/dist/client/assets/{runtimeModeConfig-C3q8YqVA.js → runtimeModeConfig-CGosfJJ5.js} +2 -2
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-CTZUXdFj.js → sankeyDiagram-P5KCCOFB-DC4ft80C.js} +2 -2
- package/dist/client/assets/{scheduledTasksSettings.logic-Cucrqmxt.js → scheduledTasksSettings.logic-Bmbv-9DS.js} +2 -2
- package/dist/client/assets/{scroll-area-Davaj52_.js → scroll-area-OkcD8f0Y.js} +2 -2
- package/dist/client/assets/{select-B47XfaxQ.js → select-BUFUt6O3.js} +2 -2
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-B8uW-gHN.js → sequenceDiagram-WJ2MYXX4-COMPHZuQ.js} +2 -2
- package/dist/client/assets/{server-B3nCKBrK.js → server-BSKDpYuc.js} +2 -2
- package/dist/client/assets/{session-DtKtS09P.js → session-BaKBc24W.js} +2 -2
- package/dist/client/assets/session-logic-DOC4SSh-.js +26 -0
- package/dist/client/assets/{settings-BNJbLRpG.js → settings-Ce3HYftt.js} +2 -2
- package/dist/client/assets/{settings.appearance-DKLKCSXj.js → settings.appearance-BELQs8GW.js} +2 -2
- package/dist/client/assets/settings.archived-_xyYN0XB.js +2 -0
- package/dist/client/assets/{settings.computer-use-BcdKzzUy.js → settings.computer-use-BjiS8S48.js} +2 -2
- package/dist/client/assets/{settings.connections-Cjmfz_7g.js → settings.connections-CL91uyd1.js} +2 -2
- package/dist/client/assets/{settings.data-controls-CZHmsfBq.js → settings.data-controls-AB6ME8V3.js} +2 -2
- package/dist/client/assets/{settings.decisions-C3WA_g2Z.js → settings.decisions-DEFo-Pd2.js} +2 -2
- package/dist/client/assets/{settings.diagnostics-Bfh6T3JX.js → settings.diagnostics-DgncclwX.js} +2 -2
- package/dist/client/assets/{settings.general-HB-_Jy6d.js → settings.general-BHYFN8uF.js} +2 -2
- package/dist/client/assets/{settings.integrations-C-uLxrlE.js → settings.integrations-BxqEAKSC.js} +2 -2
- package/dist/client/assets/{settings.keybindings-BGq7j4EC.js → settings.keybindings-DQ8svgeo.js} +2 -2
- package/dist/client/assets/{settings.open-source-licenses-VexlqZXJ.js → settings.open-source-licenses-DX92vMDE.js} +2 -2
- package/dist/client/assets/settings.plugins-DZqUpuLK.js +5 -0
- package/dist/client/assets/{settings.projects-Bl6-Pt9m.js → settings.projects-C8uYKsz6.js} +3 -3
- package/dist/client/assets/settings.providers-CDPVCtiM.js +3 -0
- package/dist/client/assets/{settings.scheduled-tasks-IH5fvnPs.js → settings.scheduled-tasks-B2CT-4iw.js} +2 -2
- package/dist/client/assets/{settings.snap-shot-CaOvSkk3.js → settings.snap-shot-FpIHq57J.js} +2 -2
- package/dist/client/assets/{settings.source-control-hwzkeaj5.js → settings.source-control-Cgg8tzrr.js} +2 -2
- package/dist/client/assets/{settings.storage-YtslAsAl.js → settings.storage-gQMFfL_2.js} +2 -2
- package/dist/client/assets/{settingsLayout-Oe2gP0HD.js → settingsLayout-DUyA66EK.js} +2 -2
- package/dist/client/assets/{sidebar-BkujXU9U.js → sidebar-CNP67lTi.js} +2 -2
- package/dist/client/assets/{sidebarProjectGrouping-zfg6kMP5.js → sidebarProjectGrouping-lWfRDsCI.js} +2 -2
- package/dist/client/assets/{skeleton-C6_D5JUu.js → skeleton-DDh76jpd.js} +2 -2
- package/dist/client/assets/{sortable.esm-CFdu6ubt.js → sortable.esm-Bc--TVlq.js} +2 -2
- package/dist/client/assets/{sourceControl-CNpb3juM.js → sourceControl-BppF1prF.js} +2 -2
- package/dist/client/assets/{spinner-CpLstN6u.js → spinner-DYnZ-Bpa.js} +2 -2
- package/dist/client/assets/{standalone-page-7vaVYOp-.js → standalone-page-DUgQaNPq.js} +2 -2
- package/dist/client/assets/{stateDiagram-D77RDMKH-BXjvJECk.js → stateDiagram-D77RDMKH-Dk5dNGVk.js} +2 -2
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-BqI4Wri4.js +2 -0
- package/dist/client/assets/{swimlanes-42K2YHIH-BuQKiVFK.js → swimlanes-42K2YHIH-D6oOm69V.js} +2 -2
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-Des4AqSq.js +9 -0
- package/dist/client/assets/{terminal-links-CjmSI9gV.js → terminal-links-CV_3r1U3.js} +2 -2
- package/dist/client/assets/{terminalSessions-C0i8FMIw.js → terminalSessions-DCMAHO3E.js} +2 -2
- package/dist/client/assets/{textarea-DKdxwZZC.js → textarea-Dt0w6mtc.js} +2 -2
- package/dist/client/assets/{themePalette-7p_LOU3J.js → themePalette-9CODTNe7.js} +2 -2
- package/dist/client/assets/{threadSort-urWEkJav.js → threadSort-DJdKuCKp.js} +2 -2
- package/dist/client/assets/{timeline-definition-24CTP7MA-gsy_kdrp.js → timeline-definition-24CTP7MA-Dd3smJPR.js} +2 -2
- package/dist/client/assets/{toast-D1xgN6T2.js → toast-BeM8bZbF.js} +2 -2
- package/dist/client/assets/{toggle-BshAsXT6.js → toggle-C3pF5hng.js} +2 -2
- package/dist/client/assets/{toggle-group-ZNzhUvHt.js → toggle-group-C4V_4iet.js} +2 -2
- package/dist/client/assets/{tooltip-Cq9yz15d.js → tooltip-Cco13jKX.js} +2 -2
- package/dist/client/assets/{treeView-Q6P3EWNA-BHvMPOqK.js → treeView-Q6P3EWNA-Dbb-EyFc.js} +1 -1
- package/dist/client/assets/{treemap-WGGIJYW6-D8SWHA1Z.js → treemap-WGGIJYW6-C4Asv2we.js} +1 -1
- package/dist/client/assets/{usage-BsNTrKRO.js → usage-C5gCqDEF.js} +2 -2
- package/dist/client/assets/{usageAccess-CieOJbVm.js → usageAccess-CeCsk7TS.js} +2 -2
- package/dist/client/assets/{usageFormat-BEGhDYfU.js → usageFormat-CQXspPhL.js} +2 -2
- package/dist/client/assets/{usageShortcuts-DxuByyhD.js → usageShortcuts-DaMuOxo1.js} +2 -2
- package/dist/client/assets/{use-atom-command-DFVJioxM.js → use-atom-command-CMd4xAvF.js} +2 -2
- package/dist/client/assets/{useAriaLabelledBy-u5efXUxw.js → useAriaLabelledBy-BinWYOc0.js} +2 -2
- package/dist/client/assets/{useHandleNewThread-D3kzOunA.js → useHandleNewThread-2sRVaQar.js} +2 -2
- package/dist/client/assets/{useLocation-B3ir4ben.js → useLocation-BQwksr61.js} +2 -2
- package/dist/client/assets/useNavigate-LjcLtV_e.js +2 -0
- package/dist/client/assets/{useNavigateBack-XQd0WINI.js → useNavigateBack-D2S1CDHR.js} +2 -2
- package/dist/client/assets/{useParams-Cil-ZIwd.js → useParams-D_8gJiai.js} +2 -2
- package/dist/client/assets/{usePermissionStatus-C4aMrLLP.js → usePermissionStatus-Bl_cAihc.js} +2 -2
- package/dist/client/assets/{usePullRequestActions-eR9_K37m.js → usePullRequestActions-BcGz_qON.js} +2 -2
- package/dist/client/assets/{useRegisterFieldControl-75QESVfk.js → useRegisterFieldControl-Bp078Il-.js} +2 -2
- package/dist/client/assets/{useScopedModelAvailability-DloNarQ1.js → useScopedModelAvailability-DAU9OPOv.js} +2 -2
- package/dist/client/assets/{useSettings-BVUg52H2.js → useSettings-DpVy22yc.js} +2 -2
- package/dist/client/assets/{useT3ConnectAuthPrompt-iHfw63uu.js → useT3ConnectAuthPrompt-BsnsXdaF.js} +2 -2
- package/dist/client/assets/utils-Dx_TSvdC.js +37 -0
- package/dist/client/assets/{vcsRefInvalidation-DZeFb_fD.js → vcsRefInvalidation--2K54DE9.js} +2 -2
- package/dist/client/assets/{vennDiagram-4TSXK5OY-DWeHYWRx.js → vennDiagram-4TSXK5OY-V_3xLf5G.js} +2 -2
- package/dist/client/assets/{wardley-WFR3VGLG-CfPV8k7N.js → wardley-WFR3VGLG-CDlEm4As.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-D0SH6I3q.js → wardleyDiagram-VM6X3IG4-CBqbrzOI.js} +2 -2
- package/dist/client/assets/{welcome-BWkyKuVQ.js → welcome-DdV5o2sn.js} +2 -2
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-CHYweeaE.js → xychartDiagram-S5SC5T6Z-BBAHFXyY.js} +2 -2
- package/dist/client/index.html +1 -1
- package/dist/{renderer-BFtino0A.mjs → renderer-B8qsc7RL.mjs} +2 -2
- package/dist/{runtime-ERvpj9Mz.mjs → runtime-CEdmfdaF.mjs} +18 -4
- package/package.json +1 -1
- package/dist/client/assets/AlertDialogRoot-DvQNG7Nt.js +0 -2
- package/dist/client/assets/Input-BQRZG5rU.js +0 -2
- package/dist/client/assets/architecture-7GRP2DOG-BCI44Tco.js +0 -1
- package/dist/client/assets/channel-FPHxEbB1.js +0 -2
- package/dist/client/assets/classDiagram-ZZMXUADV-BmhihMCg.js +0 -2
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-BmhihMCg.js +0 -2
- package/dist/client/assets/eventmodeling-NTZA5JFV-Q6rJ-HVs.js +0 -1
- package/dist/client/assets/flowDiagram-HODETNUW-Dyon23dU.js +0 -1
- package/dist/client/assets/railroad-abnf-HS5TGJTU-DdK1L4Kf.js +0 -1
- package/dist/client/assets/railroad-ebnf-LZEXJU2U-DAIwdsWb.js +0 -1
- package/dist/client/assets/railroad-peg-WCYAUIDC-B6SwzZWt.js +0 -1
- package/dist/client/assets/session-logic-P3KsudEl.js +0 -26
- package/dist/client/assets/settings.archived-BeEB6d0D.js +0 -2
- package/dist/client/assets/settings.plugins-P_jMyYCz.js +0 -5
- package/dist/client/assets/settings.providers-Dk00EIn3.js +0 -3
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-DoChugDq.js +0 -2
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-Bwk0C9Yw.js +0 -9
- package/dist/client/assets/useNavigate-DRqH9NhA.js +0 -2
- package/dist/client/assets/utils-BEVyjoxo.js +0 -37
package/dist/client/assets/{EnvironmentMachineIcon-DCdlTSYU.js → EnvironmentMachineIcon-Czk_PJpp.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{NE as t,Pd as n,Pf as r,Xp as i,cp as a,lE as o}from"./utils-
|
|
2
|
-
//# sourceMappingURL=EnvironmentMachineIcon-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{NE as t,Pd as n,Pf as r,Xp as i,cp as a,lE as o}from"./utils-Dx_TSvdC.js";import{v as s}from"./Icons-CSAp87pJ.js";var c=t(),l=e(o(),1);function u(e){let t=(0,c.c)(2),n;return t[0]===e?n=t[1]:(n=(0,l.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e}),t[0]=e,t[1]=n),n}function d(e){let t=(0,c.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,l.jsx)(`rect`,{width:`20`,height:`8`,x:`2`,y:`8`,rx:`2`}),r=(0,l.jsx)(`path`,{d:`M6 12h.01`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,l.jsxs)(u,{...e,children:[n,r]}),t[2]=e,t[3]=i),i}function f(e){let t=(0,c.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,l.jsx)(`rect`,{width:`18`,height:`14`,x:`3`,y:`5`,rx:`2`}),r=(0,l.jsx)(`path`,{d:`M7 15h.01M11 15h.01M15 15h.01`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,l.jsxs)(u,{...e,children:[n,r]}),t[2]=e,t[3]=i),i}var p={server:i,cloud:n,linux:s,desktop:a,laptop:r,"mac-mini":d,"mac-studio":f},m={server:`Server`,cloud:`Cloud VM`,linux:`Linux/WSL`,desktop:`Desktop`,laptop:`Laptop`,"mac-mini":`Mini PC`,"mac-studio":`Workstation`};function h(e){return p[e]}function g(e){let t=(0,c.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({kind:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=p[n],a;return t[3]!==i||t[4]!==r?(a=(0,l.jsx)(i,{...r}),t[3]=i,t[4]=r,t[5]=a):a=t[5],a}export{g as n,h as r,m as t};
|
|
2
|
+
//# sourceMappingURL=EnvironmentMachineIcon-Czk_PJpp.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{NE as n,cr as r,lE as i,t as a}from"./utils-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{NE as n,cr as r,lE as i,t as a}from"./utils-Dx_TSvdC.js";var o=n(),s=e(t(),1),c=e(i(),1);function l(e){let t=(0,o.c)(19),{text:n,className:i,collapsedClassName:l,expandLabel:d}=e,f=l===void 0?`line-clamp-3`:l,p=d===void 0?`Show full error`:d,m=(0,s.useId)(),[h,g]=(0,s.useState)(!1),_;t[0]===n?_=t[1]:(_=n.length>180||n.includes(`
|
|
2
2
|
`),t[0]=n,t[1]=_);let v=_,y;t[2]===i?y=t[3]:(y=a(`min-w-0`,i),t[2]=i,t[3]=y);let b=!h&&v?f:null,x;t[4]===b?x=t[5]:(x=a(`whitespace-pre-wrap break-words`,b),t[4]=b,t[5]=x);let S;t[6]!==x||t[7]!==n||t[8]!==m?(S=(0,c.jsx)(`div`,{id:m,className:x,children:n}),t[6]=x,t[7]=n,t[8]=m,t[9]=S):S=t[9];let C;t[10]!==v||t[11]!==p||t[12]!==h||t[13]!==m?(C=v?(0,c.jsx)(r,{"aria-expanded":h,"aria-controls":m,tone:`muted`,className:`mt-1`,onClick:()=>g(u),children:h?`Show less`:p}):null,t[10]=v,t[11]=p,t[12]=h,t[13]=m,t[14]=C):C=t[14];let w;return t[15]!==y||t[16]!==S||t[17]!==C?(w=(0,c.jsxs)(`div`,{className:y,children:[S,C]}),t[15]=y,t[16]=S,t[17]=C,t[18]=w):w=t[18],w}function u(e){return!e}export{l as t};
|
|
3
|
-
//# sourceMappingURL=ExpandableText-
|
|
3
|
+
//# sourceMappingURL=ExpandableText-Ggw0uVXl.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{Ca as n,Fa as r,Ia as i,Ln as a,Nn as o,Pn as s,Va as c,io as l,sa as u,ta as d,vo as f,zn as p}from"./utils-
|
|
2
|
-
//# sourceMappingURL=FieldControl-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{Ca as n,Fa as r,Ia as i,Ln as a,Nn as o,Pn as s,Va as c,io as l,sa as u,ta as d,vo as f,zn as p}from"./utils-Dx_TSvdC.js";import{t as m}from"./useRegisterFieldControl-Bp078Il-.js";var h=e(t()),g=h.forwardRef(function(e,t){let{render:g,className:_,id:v,name:y,value:b,disabled:x=!1,onValueChange:S,defaultValue:C,autoFocus:w=!1,style:T,...E}=e,{state:D,name:O,disabled:k,setTouched:A,setDirty:j,validityData:M,setFocused:N,setFilled:P,validationMode:F,validation:I}=a(),L=k||x,R=O??y,z={...D,disabled:L},{labelId:B}=s(),V=o({id:v});r(()=>{let e=b!=null;I.inputRef.current?.value||e&&b!==``?P(!0):e&&b===``&&P(!1)},[I.inputRef,P,b]);let H=h.useRef(null);r(()=>{w&&H.current===u(d(H.current))&&N(!0)},[w,N]);let[U]=c({controlled:b,default:C,name:`FieldControl`,state:`value`}),W=b!==void 0,G=W?U:void 0,K=i(()=>I.inputRef.current?.value);return m(I.inputRef,V,G,K),f(`input`,e,{ref:[t,H],state:z,props:[{id:V,disabled:L,name:R,ref:I.inputRef,"aria-labelledby":B,autoFocus:w,...W?{value:G}:{defaultValue:C},onChange(e){let t=e.currentTarget.value;S?.(t,n(l,e.nativeEvent)),j(t!==M.initialValue),P(t!==``)},onFocus(){N(!0)},onBlur(e){A(!0),N(!1),F===`onBlur`&&I.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(A(!0),I.commit(e.currentTarget.value))}},I.getInputValidationProps(),E],stateAttributesMapping:p})});export{g as t};
|
|
2
|
+
//# sourceMappingURL=FieldControl-Bw2_eFMa.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{lE as n}from"./utils-BEVyjoxo.js";import{D as r,J as i,X as a,Y as o,_t as s,et as c,f as l,ft as u,g as d,gt as f,h as p,ht as m,mt as h,ot as g,pt as _,w as v}from"./diffRendering-BiYYLTwl.js";import{D as y,E as b,F as x,G as S,I as C,K as w,L as T,M as E,N as D,O,P as k,R as A,S as j,T as M,U as N,W as P,b as F,c as I,d as L,f as R,g as ee,i as te,k as z,n as ne,o as re,r as ie,s as ae,u as oe,v as se,x as ce,y as le,z as ue}from"./Virtualizer-B895TWmX.js";import{A as de,C as fe,D as pe,E as me,F as he,I as ge,N as _e,O as ve,Q as B,S as ye,Z as be,a as xe,b as Se,d as Ce,f as V,g as we,h as H,i as Te,l as U,m as W,n as Ee,o as De,p as Oe,r as ke,rt as Ae,s as je,t as Me,u as G,ut as Ne,v as K,w as Pe,x as q,y as Fe}from"./getDiffFileInput-DaXZ00WD.js";import{n as Ie,t as Le}from"./cloneFileDiffMetadata-zVRGqYgv.js";import{Ha as J}from"./main-C6Kmott7.js";var Y=e(n(),1);function X(e){return e===``?[]:e.split(s)}function Re(e,t,n){let r=e===`clone`?Le(t):t;if(!r.isPartial)throw Error(`hydratePartialDiff: fileDiff must be partial`);switch(r.type){case`change`:case`rename-changed`:return ze(r,Ve(r,n),He(r,n));case`rename-pure`:{let e=He(r,n);Ue(r,n);let t=X(e.contents);return r.isPartial=!1,r.deletionLines=t,r.additionLines=t,Ge(r,null,e),r}}throw Error(`hydratePartialDiff: ${r.type} diffs cannot be hydrated from loaded files`)}function ze(e,t,n){let r=X(t.contents),i=X(n.contents),{hunks:a,splitLineCount:o,unifiedLineCount:s}=Be(e.hunks,i.length);return e.hunks=a,e.splitLineCount=o,e.unifiedLineCount=s,e.isPartial=!1,e.deletionLines=r,e.additionLines=i,Ge(e,t,n),e}function Be(e,t){let n=0,r=0,i=0,s=[];for(let t of e){let e=Math.max(t.additionStart-1,0),c=Math.max(t.deletionStart-1,0),l=e,u=c,d=0,f=0,p=0,m=0,h=[];for(let e of t.hunkContent){if(e.type===`context`){h.push({...e,additionLineIndex:l,deletionLineIndex:u}),l+=e.lines,u+=e.lines,p+=e.lines,m+=e.lines;continue}h.push({...e,additionLineIndex:l,deletionLineIndex:u}),l+=e.additions,u+=e.deletions,d+=e.additions,f+=e.deletions,p+=Math.max(e.additions,e.deletions),m+=e.additions+e.deletions}let g=Math.max(a(t.additionStart,t.additionCount)-i,0);s.push({...t,collapsedBefore:g,additionLineIndex:e,deletionLineIndex:c,additionLines:d,deletionLines:f,hunkContent:h,splitLineStart:n+g,unifiedLineStart:r+g,splitLineCount:p,unifiedLineCount:m}),n+=g+p,r+=g+m,i=o(t.additionStart,t.additionCount)}if(s.length>0){let e=s[s.length-1],i=o(e.additionStart,e.additionCount),a=Math.max(t-i,0);n+=a,r+=a}return{hunks:s,splitLineCount:n,unifiedLineCount:r}}function Ve(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function He(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function Ue(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function We(e,t,n){return e.cacheKey==null?Ke(t,n):`${e.cacheKey}:hydrated`}function Ge(e,t,n){let r=We(e,t,n);if(r==null){delete e.cacheKey;return}e.cacheKey=r}function Ke(e,t){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?i(`hydrated-files`,e.cacheKey,t.cacheKey):void 0:e?.cacheKey??t?.cacheKey}var qe=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));if(n==null||t==null){this.cleanUp();return}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 Je(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function Ye(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}async function Xe(e,t=300){let n;try{await Promise.race([e(),new Promise(e=>{n=setTimeout(e,t)})])}finally{n!=null&&clearTimeout(n)}}function Ze(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:fe(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 Qe(e){return e.isPartial&&(e.type===`change`||e.type===`rename-changed`||e.type===`rename-pure`)}function $e(e){let t={...e};return delete t.cacheKey,t}function et(e,t){if(e.isPartial||t.isPartial)throw Error(`FileDiff.shouldResetEditorForExternalDiff: diffs must be fully hydrated`);let n=e.lang??J(e.name),r=t.lang??J(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 tt(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function nt(e,t){let{oldFile:n}=e;return n==null?t.type===`new`:t.type!==`new`&&n.name===(t.prevName??t.name)&&tt(n.lines,t.deletionLines)}var rt=-1,it=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++rt}`;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:g},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new T,this.scrollSyncManager=new qe,this.interactionManager=new A(`diff`,ue(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??g}getHunksRendererOptions(e){return Ze(e)}createHunksRenderer(e){return new Ee(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,o;hunkIterator:for(let s of e.hunks){let e=n===`deletions`?s.deletionStart:s.additionStart,c=n===`deletions`?s.deletionCount:s.additionCount,l=a(e,c)+1,u=s.splitLineStart,d=s.unifiedLineStart;if(t<l){let e=l-t;i=Math.max(d-e,0),o=Math.max(u-e,0);break hunkIterator}if(t>=l+c){if(s===r){let e=t-(l+c);i=d+s.unifiedLineCount+e,o=u+s.splitLineCount+e;break hunkIterator}continue}for(let e of s.hunkContent)if(e.type===`context`){if(t<l+e.lines){let e=t-l;o=u+e,i=d+e;break hunkIterator}l+=e.lines,u+=e.lines,d+=e.lines}else{let r=n===`deletions`?e.deletions:e.additions;if(t<l+r){let r=t-l;i=d+(n===`additions`?e.deletions:0)+r,o=u+r;break hunkIterator}l+=r,u+=Math.max(e.deletions,e.additions),d+=e.deletions+e.additions}break hunkIterator}if(i!=null&&o!=null)return[i,o]}setOptions(e){e!=null&&(this.options=e,this.clearReusableHeader(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(ue(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&&!Ne(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();getAnnotationSlotName=e=>ce(this.editSession?.annotations,e,B);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;if(t==null){this.lineAnnotations=e;return}this.isNewAnnotations(e)&&(this.lineAnnotations=e,j(t,e,B))}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;S(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=Me(a,`FileDiff.hydrate`),s=o?.oldFile,c=o?.newFile;this.hydrateElements(e,t);let l=this.editor!=null;l||lt(this.pre,st({fileDiff:i,oldFile:s,newFile:c}),this.options.collapsed)||ut(this.headerElement,ct({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),O(e,t);for(let t of e.shadowRoot?.children??[]){if(t instanceof SVGElement){this.spriteSVG=t;continue}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));continue}if(`diffsHeader`in t.dataset){this.headerElement=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}}}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?l(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||!Qe(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&&!Qe(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&&!Qe(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){if(this.fileDiff===e&&e.isPartial){if(Re(`merge`,e,t),this.setHydratedState(t),this.installHydratedSessionDiff(e)){this.rerender();return}await Xe(()=>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(K(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=F(t,B,this.editSession.annotations)),!0}installEditSession(e,t,n){let r=e.additionLines.join(``),i=t==null?void 0:X(t.contents),a=n!=null&&nt(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=$e(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,je(s)),this.editSession={diff:s,annotations:this.editSession?.annotations??F(this.lineAnnotations,B),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 u=Me(c,`FileDiff.render`),d=u?.oldFile,f=u?.newFile;this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:p=!1,themeType:m=`system`,expandUnchanged:h=!1}=this.options,g=p?void 0:s,v=this.hasThemeChanged(),y=u!=null,b=y&&(!ot(d,this.deletionFile)||!ot(f,this.additionFile)),x=e!=null&&!K(e,this.fileDiff),S=i!=null&&(i.length>0||this.getLatestAnnotations().length>0)&&this.isNewAnnotations(i);if(!p&&Ae(g,this.renderRange)&&!n&&!S&&!v&&(e!=null&&!x||e==null&&!b)){let e=this.applyCachedThemeState(m);return e&&this.finalizeRender(),e}let C;e==null&&y&&(b||this.fileDiff==null)&&(C=l(u.oldFile,u.newFile,this.options.parseDiffOptions));let{renderRange:w}=this;this.renderRange=g,y?(this.deletionFile=d,this.additionFile=f):e!=null&&(this.deletionFile=void 0,this.additionFile=void 0),e!=null&&x?this.updateExternalDiff(e,i):C!=null&&(x=!0,this.updateExternalDiff(C,i)),x&&this.clearReusableHeader(),i!=null&&this.setLineAnnotations(i);let T=this.getLatestDiff();if(T==null)return!1;T.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(xe(T,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),h&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.getLatestAnnotations());let{disableErrorHandling:E=!1,disableFileHeader:D=!1}=this.options;if(D&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.headerCache.lastRenderedHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,o),this.applyCachedThemeState(m),p){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(T,_);e!=null&&this.applyThemeState(a,e.themeStyles,m,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,a,e.fileDiff),this.renderSeparators([]),this.renderedDiff=e?.fileDiff??T,this.injectUnsafeCSS()}catch(e){if(E)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,S,b||x||v||!K(this.renderedDiff,T))&&this.applyPartialRender({fileDiff:T,previousRenderRange:w,renderRange:g}))){let t=this.hunksRenderer.renderDiff(T,g);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.isWorkingPool()&&this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender()),!1;this.applyThemeState(a,t.themeStyles,m,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,g),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,t||this.flushManagers(),this.finalizeRender(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(E)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?et(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??J(i.name),c=p({theme:o,lang:s});c==null?d({themes:v(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||be(e))return e;let{diffStyle:n=`split`,expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a,o;return U({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&&et(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?Ie(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(at(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=Le(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=Te(e,this.hunksRenderer.getExpandedHunksMap(),t);return xe(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(De(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;if(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();return}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 we({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 Oe({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]=Ce(o);if(e<s){let c=G({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=W({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]=Ce(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(){w(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||ke(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(e=>{ee(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||!Ye(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||!Je(i,o.annotation)){o?.element.remove();let e=t(i);if(e==null)continue;o={element:k(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=D();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:b(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):b(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=de;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:i,html:a,lastRenderedHTML:o}}=this,s=(n!==this.editSession?.diff&&K(i,n)?a:void 0)??r(e);if(this.headerCache.html=s,this.headerCache.fileDiff=n,s!==o){let e=document.createElement(`div`);e.innerHTML=s;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=s}if(this.isContainerManaged)return;let{renderCustomHeader:l,renderHeaderPrefix:u,renderHeaderFilenameSuffix:d,renderHeaderMetadata:p}=this.options;if(l!=null){let e=l(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,c,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}let g=u?.(n)??void 0,_=d?.(n)??void 0,v=p?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,f,g),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,h,_),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,m,v),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;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=E(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=pe(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=ve(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=se({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:me(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=Pe(this.themeCSSStyle.textContent??``,ve(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&M()}applyHunksToDOM(e,t){this.shouldGuardRebuildScroll()?le(e,()=>this.replaceCodeColumns(e,t)):this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){let i=this.getColumnPair(e);if(i==null)return!1;let a=Z(t[0]),o=Z(t[1]);return a==null||o==null?!1:(i.gutter.innerHTML=r(a),i.content.innerHTML=r(o),n!==this.lastRowCount&&(i.gutter.style.setProperty(`grid-row`,`span ${n}`),i.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=z({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=z({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=z({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=Z(r?.[0]),a=Z(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 i=this.hunksRenderer.renderCodeAST(`unified`,t),a=Z(i?.[0]),o=Z(i?.[1]),s=()=>{for(let[e,t]of[[n.gutter,a],[n.content,o]])t!=null&&(e.innerHTML=r(t));t.rowCount!==this.lastRowCount&&(this.applyRowSpan(`unified`,n,t.rowCount),this.lastRowCount=t.rowCount),this.renderedDiff=t.fileDiff};this.shouldGuardRebuildScroll()?le(this.pre,s):s(),this.renderSeparators(t.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=Z(t[0]),i=Z(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++;continue}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++;continue}if(`separator`in e.dataset&&`separator`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}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;continue}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){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}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};x(u,this.appliedPreAttributes)||(y(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 at(e){return{name:e.name,lang:e.lang,contents:e.additionLines.join(``)}}function ot(e,t){return e==null||t==null?e==null&&t==null:R(e,t)}function st({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function ct({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function lt(e,t,n=!1){return!n&&e==null&&t}function ut(e,t,n=!1){return e==null&&t&&!n}function Z(e){if(e!=null&&e.type===`element`)return e.children??[]}function dt({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o,canHydratePartialDiff:s}){let c=q(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=G({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=V({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=ft(i);c+=p.split*t.lineHeight,l+=p.unified*t.lineHeight;let m=n===d?W({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=ye(t);c+=e,l+=e}return{splitHeight:c,unifiedHeight:l}}function ft(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 pt(e,t)}function pt(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}}var mt=3e3,Q=new Map,ht=-1,gt=class extends it{__id=`little-virtualized-file-diff:${++ht}`;renderType=`virtualized`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0,ghostTextRows:Q,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=Fe(n)}setMetrics(e,t=!1){let n=Fe(e);(t||!P(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 he(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=!N(t,e),r=n&&wt(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:Tt(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=Q,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()??Q);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&&ge(this.renderRange)){let t=_t(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=kt(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=Fe(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=q(this.metrics,i),f=this.getLayoutCheckpointBeforeLineIndex(u),p=f?.top??d+this.cache.fileAnnotationHeight;if(o)return{top:Se(this.metrics,i),height:0};let m;return U({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=V({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??q(this.metrics,n)+this.cache.fileAnnotationHeight,u;return U({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=V({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||!K(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=Re(`clone`,e,t);if(await Xe(()=>this.primeHighlightCache(n)),this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(Re(`merge`,e,t),this.setHydratedState(t),!this.installHydratedSessionDiff(e)&&(await Xe(()=>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 we({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,!K(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()??Q);let{disableFileHeader:i=!1,collapsed:a=!1}=this.options;if(a){this.height+=Se(this.metrics,i),this.layoutDirty=!1;return}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}=dt({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:Et(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=Me(i,`VirtualizedFileDiff.render`),o=a!=null,s=a?.oldFile,c=a?.newFile,u=o&&(!Ot(s,this.deletionFile)||!Ot(c,this.additionFile)),d=t??this.fileDiff;t==null&&o&&(u||this.fileDiff==null)&&(d=l(a.oldFile,a.newFile,this.options.parseDiffOptions));let{forceRenderOverride:f,isSetup:p}=this;this.forceRenderOverride=void 0;let m=d!=null&&!K(this.fileDiff,d),h=m||u;if(e=this.getOrCreateFileContainer(e),d==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;m&&this.updateExternalDiff(d,r);let{pendingRenderDiff:g,layoutDiffChanged:_,renderedDiffChanged:v,annotationsChanged:y}=this.pendingRender!=null&&this.pendingRender.latestDiff===(this.getLatestDiff(d)??d)?{pendingRenderDiff:this.pendingRender.diff,layoutDiffChanged:!1,renderedDiffChanged:!1,annotationsChanged:this.syncLineAnnotations(r)}:this.updatePendingRender(d,r);if(_&&this.resetLayoutCache({includeEstimatedHeights:!0}),p)this.top??=this.getVirtualizedTop(),this.layoutDirty&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,g));else{this.computeApproximateSize(!1,g);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()&&(!h||!p))return a!=null&&(this.deletionFile=s,this.additionFile=c),m&&this.clearReusableHeader(),this.renderPlaceholder(this.height);let b=this.virtualizer.getWindowSpecs(),x=this.top??0,S=this.computeRenderRangeFromWindow(g,x,b);return super.render({fileDiff:d,fileContainer:e,renderRange:S,lineAnnotations:r,forceRender:(f??n)||y||v||m,...a,...i})}finalizeRender(){if(!K(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:!K(a,o),renderedDiffChanged:!K(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 Dt(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=Et(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),s=this.getHunkSeparatorType(),c=n?!0:this.hunksRenderer.getExpandedHunksMap(),l=vt(this.cache.heightDeltas),u=q(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=xt(a);for(;s<o;){let e=s-a,r=u+(e>0?n:0)+e*this.metrics.lineHeight+St(i,e)*this.metrics.lineHeight+yt(l,t,t+e);this.cache.checkpoints.push({renderedLineIndex:s,lineIndex:t+e,top:r}),s+=mt}u+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+yt(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=G({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:c,hunkIndex:t,collapsedContextThreshold:r}),u=l.collapsedLines>0?V({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?W({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:Ct({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}=G({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=W({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=Et(e,this.options.loadDiffFiles!=null),f=this.height,p=this.getLayoutLineCount(e,l),m=q(this.metrics,i),h=e.hunks.length>0?ye(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=[],D=(n+r)/2,O=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-C*c*2),s),k=t+(O?.top??_),A=O?.renderedLineIndex??0,j,M,N;if(U({diff:e,diffStyle:l,startingLine:O?.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?V({type:u,metrics:this.metrics,hunkIndex:i,hunkSpecs:a?.hunkSpecs}):void 0)?.totalHeight??0;k+=y;let b=A%s===0,x=Math.floor(A/s);if(b&&(E[x]=k-(t+_+y),N!=null)){if(N<=0)return!0;N--}let S=this.getLineHeight(l===`split`?m:h,g);if(k>n-S&&k<r&&(j??=x),M==null&&k+S>D&&(M=x),N==null&&k>=r&&b&&(N=T),A++,k+=S,c>0||v&&d){let e=H({type:u,metrics:this.metrics});e!=null&&(k<r&&k+e.totalHeight>n&&(j??=x),M==null&&k+e.totalHeight>D&&(M=x),k+=e.totalHeight)}return!1}}),j==null){if(x)j=0,M=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h}}M??=j;let P=Math.round(M-w/2),F=Math.max(0,Math.ceil(p/s)-w),I=Math.max(0,Math.min(P,F)),L=I*s,R=P<0?C+P*s:C,ee=E[I]??0,te=L===0?0:g+ee,z=I+R/s,ne=z<E.length?v-E[z]:v-(k-t-_);return{startingLine:L,totalLines:R,bufferBefore:te,bufferAfter:Math.max(0,ne)}}};function _t(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===_e&&(t=Math.max(t??0,n.getBoundingClientRect().height))}return t}function vt(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 yt({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=bt(e,n);return(t[bt(e,r)]??0)-(t[i]??0)}function bt(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 xt(e){return Math.ceil(e/mt)*mt}function St(e,t){let n=0;for(let r of e)r<t&&n++;return n}function Ct({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 wt(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 Tt(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 Et(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function Dt(e){return typeof e==`function`?`custom`:e??`line-info`}function Ot(e,t){return e==null||t==null?e==null&&t==null:R(e,t)}function kt(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}function At({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function jt(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:Mt(n,e.startContentIndex)}}function Mt(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}function Nt({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:l,lineAnnotations:u,getHoveredLine:d,getInstance:f,getAnnotationSlotName:p=B}){let m=n?.(e),h=r?.(e),g=i?.(e),_=a?.(e);return(0,Y.jsxs)(Y.Fragment,{children:[m==null?(0,Y.jsxs)(Y.Fragment,{children:[h!=null&&(0,Y.jsx)(`div`,{slot:`header-prefix`,children:h}),g!=null&&(0,Y.jsx)(`div`,{slot:`header-filename-suffix`,children:g}),_!=null&&(0,Y.jsx)(`div`,{slot:`header-metadata`,children:_})]}):(0,Y.jsx)(`div`,{slot:c,children:m}),o!=null&&u?.map((e,t)=>(0,Y.jsx)(`div`,{slot:p(e),children:o(e)},t)),t!=null&&l!=null&&f!=null&&t.map(t=>{if(t==null)return;let n=Pt(t,e);return(0,Y.jsx)(`div`,{slot:n,style:ae,children:l(t,f)},n)}),s!=null&&(0,Y.jsx)(`div`,{slot:`gutter-utility-slot`,style:re,children:s(d)})]})}function Pt(e,t){let n=jt(e,t);return n==null?void 0:At({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}var $=e(t(),1),Ft=typeof window>`u`?$.useEffect:$.useLayoutEffect;function It({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=ne(),_=s!==void 0,v=(0,$.useContext)(te),y=oe(),[b,x]=(0,$.useState)(),S=L(e=>m?.(e)),C=m==null?void 0:S,w=(0,$.useRef)(null),T=L(r=>{let i=h?.(r)??`reject`;return i===`accept`&&(w.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}),E=h==null?void 0:T,D=Lt({acceptedCache:w,fileDiff:e,newFile:n,oldFile:t,parseDiffOptions:r?.parseDiffOptions}),O=(0,$.useRef)(null),k=(0,$.useRef)(null),A=(0,$.useRef)(null),j=L(()=>{if(y==null)throw Error(`FileDiff: EditContext is not attached`);return y(`file-diff`,i??{},a)}),M=L(e=>{if(e!=null){if(O.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);g==null?O.current=new it(Bt({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),f?void 0:v,!0):O.current=new gt(Bt({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),g,l,f?void 0:v,!0),O.current.hydrate({fileDiff:D,fileContainer:e,lineAnnotations:o,prerenderedHTML:c})}else{if(O.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);A.current=null,O.current.cleanUp(),O.current=null,k.current=null}});Ft(()=>{let{current:e}=O;if(e==null)return;let t=Bt({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),n=t!==void 0&&!N(e.options,t);if(e.setOptions(t),!p&&(A.current=null,k.current!=null)){let{current:e}=k;k.current=null,e()}let i=zt(D,o,w);if(e.render({forceRender:n,fileDiff:i.fileDiff,lineAnnotations:i.lineAnnotations}),s!==void 0&&e.setSelectedLines(s),!p||k.current!=null)return;if(y==null)throw Error(`FileDiff: EditContext is not attached`);let a=()=>{O.current===e&&k.current==null&&e.__canAttachEditor()&&(k.current=Vt(e,j))};if(e.__canAttachEditor()){A.current=null,a();return}let c=e.__prepareForEditing();if(c==null){A.current=null;return}if(A.current?.promise===c)return;let l={promise:c};A.current=l,c.then(()=>{A.current===l&&(a(),A.current=null)}).catch(e=>{A.current===l&&(A.current=null,x(e))})});let P=(0,$.useCallback)(()=>O.current?.getHoveredLine(),[]),F=(0,$.useCallback)(e=>O.current?.getAnnotationSlotName(e)??B(e),[]);if(b!=null)throw b;return{fileDiff:D,ref:M,getHoveredLine:P,getAnnotationSlotName:F}}function Lt({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(Rt(r,n,o.stale)||Rt(r,n,o.installed))return o.fileDiff;a.filePair=null}return l(r??null,n??null,i)},[e,t,r,n,i])}function Rt(e,t,n){return C(e??void 0,n.oldFile??void 0)&&C(t??void 0,n.newFile??void 0)}function zt(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&&(K(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 Bt({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?I:e?.renderCustomHeader,renderGutterUtility:r?I:e?.renderGutterUtility,onEditChange:i,onEditComplete:a}:e}function Vt(e,t){let n=t();try{return n.edit(e)}catch(e){throw n.cleanUp(),e}}function Ht({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:d,renderCustomHeader:f,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:h,renderGutterUtility:g,disableWorkerPool:_=!1,edit:v=!1,onEditChange:y,onEditComplete:b}){let{ref:x,getHoveredLine:S,getAnnotationSlotName:C}=It({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:g!=null,hasCustomHeader:f!=null,disableWorkerPool:_,edit:v,onEditChange:y,onEditComplete:b}),w=Nt({fileDiff:e,renderCustomHeader:f,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:h,renderAnnotation:d,renderGutterUtility:g,lineAnnotations:a,getHoveredLine:S,getAnnotationSlotName:C});return(0,Y.jsx)(u,{ref:x,className:s,style:c,children:ie(w,l)})}export{Nt as n,gt as r,Ht as t};
|
|
2
|
-
//# sourceMappingURL=FileDiff-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{lE as n}from"./utils-Dx_TSvdC.js";import{D as r,J as i,X as a,Y as o,_t as s,et as c,f as l,ft as u,g as d,gt as f,h as p,ht as m,mt as h,ot as g,pt as _,w as v}from"./diffRendering-4kDIxoRz.js";import{D as y,E as b,F as x,G as S,I as C,K as w,L as T,M as E,N as D,O,P as k,R as A,S as j,T as M,U as N,W as P,b as F,c as I,d as L,f as R,g as ee,i as te,k as z,n as ne,o as re,r as ie,s as ae,u as oe,v as se,x as ce,y as le,z as ue}from"./Virtualizer-DySKW4Qd.js";import{A as de,C as fe,D as pe,E as me,F as he,I as ge,N as _e,O as ve,Q as B,S as ye,Z as be,a as xe,b as Se,d as Ce,f as V,g as we,h as H,i as Te,l as U,m as W,n as Ee,o as De,p as Oe,r as ke,rt as Ae,s as je,t as Me,u as G,ut as Ne,v as K,w as Pe,x as q,y as Fe}from"./getDiffFileInput-D107eiKt.js";import{n as Ie,t as Le}from"./cloneFileDiffMetadata-zVRGqYgv.js";import{Ha as J}from"./main-CqNzdsfA.js";var Y=e(n(),1);function X(e){return e===``?[]:e.split(s)}function Re(e,t,n){let r=e===`clone`?Le(t):t;if(!r.isPartial)throw Error(`hydratePartialDiff: fileDiff must be partial`);switch(r.type){case`change`:case`rename-changed`:return ze(r,Ve(r,n),He(r,n));case`rename-pure`:{let e=He(r,n);Ue(r,n);let t=X(e.contents);return r.isPartial=!1,r.deletionLines=t,r.additionLines=t,Ge(r,null,e),r}}throw Error(`hydratePartialDiff: ${r.type} diffs cannot be hydrated from loaded files`)}function ze(e,t,n){let r=X(t.contents),i=X(n.contents),{hunks:a,splitLineCount:o,unifiedLineCount:s}=Be(e.hunks,i.length);return e.hunks=a,e.splitLineCount=o,e.unifiedLineCount=s,e.isPartial=!1,e.deletionLines=r,e.additionLines=i,Ge(e,t,n),e}function Be(e,t){let n=0,r=0,i=0,s=[];for(let t of e){let e=Math.max(t.additionStart-1,0),c=Math.max(t.deletionStart-1,0),l=e,u=c,d=0,f=0,p=0,m=0,h=[];for(let e of t.hunkContent){if(e.type===`context`){h.push({...e,additionLineIndex:l,deletionLineIndex:u}),l+=e.lines,u+=e.lines,p+=e.lines,m+=e.lines;continue}h.push({...e,additionLineIndex:l,deletionLineIndex:u}),l+=e.additions,u+=e.deletions,d+=e.additions,f+=e.deletions,p+=Math.max(e.additions,e.deletions),m+=e.additions+e.deletions}let g=Math.max(a(t.additionStart,t.additionCount)-i,0);s.push({...t,collapsedBefore:g,additionLineIndex:e,deletionLineIndex:c,additionLines:d,deletionLines:f,hunkContent:h,splitLineStart:n+g,unifiedLineStart:r+g,splitLineCount:p,unifiedLineCount:m}),n+=g+p,r+=g+m,i=o(t.additionStart,t.additionCount)}if(s.length>0){let e=s[s.length-1],i=o(e.additionStart,e.additionCount),a=Math.max(t-i,0);n+=a,r+=a}return{hunks:s,splitLineCount:n,unifiedLineCount:r}}function Ve(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function He(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function Ue(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function We(e,t,n){return e.cacheKey==null?Ke(t,n):`${e.cacheKey}:hydrated`}function Ge(e,t,n){let r=We(e,t,n);if(r==null){delete e.cacheKey;return}e.cacheKey=r}function Ke(e,t){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?i(`hydrated-files`,e.cacheKey,t.cacheKey):void 0:e?.cacheKey??t?.cacheKey}var qe=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));if(n==null||t==null){this.cleanUp();return}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 Je(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function Ye(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}async function Xe(e,t=300){let n;try{await Promise.race([e(),new Promise(e=>{n=setTimeout(e,t)})])}finally{n!=null&&clearTimeout(n)}}function Ze(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:fe(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 Qe(e){return e.isPartial&&(e.type===`change`||e.type===`rename-changed`||e.type===`rename-pure`)}function $e(e){let t={...e};return delete t.cacheKey,t}function et(e,t){if(e.isPartial||t.isPartial)throw Error(`FileDiff.shouldResetEditorForExternalDiff: diffs must be fully hydrated`);let n=e.lang??J(e.name),r=t.lang??J(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 tt(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function nt(e,t){let{oldFile:n}=e;return n==null?t.type===`new`:t.type!==`new`&&n.name===(t.prevName??t.name)&&tt(n.lines,t.deletionLines)}var rt=-1,it=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++rt}`;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:g},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new T,this.scrollSyncManager=new qe,this.interactionManager=new A(`diff`,ue(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??g}getHunksRendererOptions(e){return Ze(e)}createHunksRenderer(e){return new Ee(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,o;hunkIterator:for(let s of e.hunks){let e=n===`deletions`?s.deletionStart:s.additionStart,c=n===`deletions`?s.deletionCount:s.additionCount,l=a(e,c)+1,u=s.splitLineStart,d=s.unifiedLineStart;if(t<l){let e=l-t;i=Math.max(d-e,0),o=Math.max(u-e,0);break hunkIterator}if(t>=l+c){if(s===r){let e=t-(l+c);i=d+s.unifiedLineCount+e,o=u+s.splitLineCount+e;break hunkIterator}continue}for(let e of s.hunkContent)if(e.type===`context`){if(t<l+e.lines){let e=t-l;o=u+e,i=d+e;break hunkIterator}l+=e.lines,u+=e.lines,d+=e.lines}else{let r=n===`deletions`?e.deletions:e.additions;if(t<l+r){let r=t-l;i=d+(n===`additions`?e.deletions:0)+r,o=u+r;break hunkIterator}l+=r,u+=Math.max(e.deletions,e.additions),d+=e.deletions+e.additions}break hunkIterator}if(i!=null&&o!=null)return[i,o]}setOptions(e){e!=null&&(this.options=e,this.clearReusableHeader(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(ue(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&&!Ne(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();getAnnotationSlotName=e=>ce(this.editSession?.annotations,e,B);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;if(t==null){this.lineAnnotations=e;return}this.isNewAnnotations(e)&&(this.lineAnnotations=e,j(t,e,B))}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;S(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=Me(a,`FileDiff.hydrate`),s=o?.oldFile,c=o?.newFile;this.hydrateElements(e,t);let l=this.editor!=null;l||lt(this.pre,st({fileDiff:i,oldFile:s,newFile:c}),this.options.collapsed)||ut(this.headerElement,ct({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),O(e,t);for(let t of e.shadowRoot?.children??[]){if(t instanceof SVGElement){this.spriteSVG=t;continue}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));continue}if(`diffsHeader`in t.dataset){this.headerElement=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}}}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?l(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||!Qe(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&&!Qe(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&&!Qe(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){if(this.fileDiff===e&&e.isPartial){if(Re(`merge`,e,t),this.setHydratedState(t),this.installHydratedSessionDiff(e)){this.rerender();return}await Xe(()=>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(K(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=F(t,B,this.editSession.annotations)),!0}installEditSession(e,t,n){let r=e.additionLines.join(``),i=t==null?void 0:X(t.contents),a=n!=null&&nt(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=$e(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,je(s)),this.editSession={diff:s,annotations:this.editSession?.annotations??F(this.lineAnnotations,B),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 u=Me(c,`FileDiff.render`),d=u?.oldFile,f=u?.newFile;this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:p=!1,themeType:m=`system`,expandUnchanged:h=!1}=this.options,g=p?void 0:s,v=this.hasThemeChanged(),y=u!=null,b=y&&(!ot(d,this.deletionFile)||!ot(f,this.additionFile)),x=e!=null&&!K(e,this.fileDiff),S=i!=null&&(i.length>0||this.getLatestAnnotations().length>0)&&this.isNewAnnotations(i);if(!p&&Ae(g,this.renderRange)&&!n&&!S&&!v&&(e!=null&&!x||e==null&&!b)){let e=this.applyCachedThemeState(m);return e&&this.finalizeRender(),e}let C;e==null&&y&&(b||this.fileDiff==null)&&(C=l(u.oldFile,u.newFile,this.options.parseDiffOptions));let{renderRange:w}=this;this.renderRange=g,y?(this.deletionFile=d,this.additionFile=f):e!=null&&(this.deletionFile=void 0,this.additionFile=void 0),e!=null&&x?this.updateExternalDiff(e,i):C!=null&&(x=!0,this.updateExternalDiff(C,i)),x&&this.clearReusableHeader(),i!=null&&this.setLineAnnotations(i);let T=this.getLatestDiff();if(T==null)return!1;T.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(xe(T,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),h&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.getLatestAnnotations());let{disableErrorHandling:E=!1,disableFileHeader:D=!1}=this.options;if(D&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.headerCache.lastRenderedHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,o),this.applyCachedThemeState(m),p){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(T,_);e!=null&&this.applyThemeState(a,e.themeStyles,m,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,a,e.fileDiff),this.renderSeparators([]),this.renderedDiff=e?.fileDiff??T,this.injectUnsafeCSS()}catch(e){if(E)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,S,b||x||v||!K(this.renderedDiff,T))&&this.applyPartialRender({fileDiff:T,previousRenderRange:w,renderRange:g}))){let t=this.hunksRenderer.renderDiff(T,g);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.isWorkingPool()&&this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender()),!1;this.applyThemeState(a,t.themeStyles,m,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,g),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,t||this.flushManagers(),this.finalizeRender(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(E)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?et(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??J(i.name),c=p({theme:o,lang:s});c==null?d({themes:v(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||be(e))return e;let{diffStyle:n=`split`,expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a,o;return U({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&&et(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?Ie(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(at(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=Le(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=Te(e,this.hunksRenderer.getExpandedHunksMap(),t);return xe(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(De(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;if(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();return}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 we({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 Oe({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]=Ce(o);if(e<s){let c=G({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=W({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]=Ce(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(){w(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||ke(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(e=>{ee(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||!Ye(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||!Je(i,o.annotation)){o?.element.remove();let e=t(i);if(e==null)continue;o={element:k(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=D();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:b(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):b(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=de;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:i,html:a,lastRenderedHTML:o}}=this,s=(n!==this.editSession?.diff&&K(i,n)?a:void 0)??r(e);if(this.headerCache.html=s,this.headerCache.fileDiff=n,s!==o){let e=document.createElement(`div`);e.innerHTML=s;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=s}if(this.isContainerManaged)return;let{renderCustomHeader:l,renderHeaderPrefix:u,renderHeaderFilenameSuffix:d,renderHeaderMetadata:p}=this.options;if(l!=null){let e=l(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,c,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}let g=u?.(n)??void 0,_=d?.(n)??void 0,v=p?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,f,g),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,h,_),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,m,v),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;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=E(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=pe(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=ve(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=se({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:me(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=Pe(this.themeCSSStyle.textContent??``,ve(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&M()}applyHunksToDOM(e,t){this.shouldGuardRebuildScroll()?le(e,()=>this.replaceCodeColumns(e,t)):this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){let i=this.getColumnPair(e);if(i==null)return!1;let a=Z(t[0]),o=Z(t[1]);return a==null||o==null?!1:(i.gutter.innerHTML=r(a),i.content.innerHTML=r(o),n!==this.lastRowCount&&(i.gutter.style.setProperty(`grid-row`,`span ${n}`),i.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=z({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=z({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=z({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=Z(r?.[0]),a=Z(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 i=this.hunksRenderer.renderCodeAST(`unified`,t),a=Z(i?.[0]),o=Z(i?.[1]),s=()=>{for(let[e,t]of[[n.gutter,a],[n.content,o]])t!=null&&(e.innerHTML=r(t));t.rowCount!==this.lastRowCount&&(this.applyRowSpan(`unified`,n,t.rowCount),this.lastRowCount=t.rowCount),this.renderedDiff=t.fileDiff};this.shouldGuardRebuildScroll()?le(this.pre,s):s(),this.renderSeparators(t.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=Z(t[0]),i=Z(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++;continue}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++;continue}if(`separator`in e.dataset&&`separator`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}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;continue}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){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}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};x(u,this.appliedPreAttributes)||(y(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 at(e){return{name:e.name,lang:e.lang,contents:e.additionLines.join(``)}}function ot(e,t){return e==null||t==null?e==null&&t==null:R(e,t)}function st({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function ct({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function lt(e,t,n=!1){return!n&&e==null&&t}function ut(e,t,n=!1){return e==null&&t&&!n}function Z(e){if(e!=null&&e.type===`element`)return e.children??[]}function dt({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o,canHydratePartialDiff:s}){let c=q(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=G({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=V({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=ft(i);c+=p.split*t.lineHeight,l+=p.unified*t.lineHeight;let m=n===d?W({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=ye(t);c+=e,l+=e}return{splitHeight:c,unifiedHeight:l}}function ft(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 pt(e,t)}function pt(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}}var mt=3e3,Q=new Map,ht=-1,gt=class extends it{__id=`little-virtualized-file-diff:${++ht}`;renderType=`virtualized`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0,ghostTextRows:Q,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=Fe(n)}setMetrics(e,t=!1){let n=Fe(e);(t||!P(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 he(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=!N(t,e),r=n&&wt(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:Tt(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=Q,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()??Q);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&&ge(this.renderRange)){let t=_t(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=kt(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=Fe(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=q(this.metrics,i),f=this.getLayoutCheckpointBeforeLineIndex(u),p=f?.top??d+this.cache.fileAnnotationHeight;if(o)return{top:Se(this.metrics,i),height:0};let m;return U({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=V({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??q(this.metrics,n)+this.cache.fileAnnotationHeight,u;return U({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=V({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||!K(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=Re(`clone`,e,t);if(await Xe(()=>this.primeHighlightCache(n)),this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(Re(`merge`,e,t),this.setHydratedState(t),!this.installHydratedSessionDiff(e)&&(await Xe(()=>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 we({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,!K(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()??Q);let{disableFileHeader:i=!1,collapsed:a=!1}=this.options;if(a){this.height+=Se(this.metrics,i),this.layoutDirty=!1;return}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}=dt({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:Et(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=Me(i,`VirtualizedFileDiff.render`),o=a!=null,s=a?.oldFile,c=a?.newFile,u=o&&(!Ot(s,this.deletionFile)||!Ot(c,this.additionFile)),d=t??this.fileDiff;t==null&&o&&(u||this.fileDiff==null)&&(d=l(a.oldFile,a.newFile,this.options.parseDiffOptions));let{forceRenderOverride:f,isSetup:p}=this;this.forceRenderOverride=void 0;let m=d!=null&&!K(this.fileDiff,d),h=m||u;if(e=this.getOrCreateFileContainer(e),d==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;m&&this.updateExternalDiff(d,r);let{pendingRenderDiff:g,layoutDiffChanged:_,renderedDiffChanged:v,annotationsChanged:y}=this.pendingRender!=null&&this.pendingRender.latestDiff===(this.getLatestDiff(d)??d)?{pendingRenderDiff:this.pendingRender.diff,layoutDiffChanged:!1,renderedDiffChanged:!1,annotationsChanged:this.syncLineAnnotations(r)}:this.updatePendingRender(d,r);if(_&&this.resetLayoutCache({includeEstimatedHeights:!0}),p)this.top??=this.getVirtualizedTop(),this.layoutDirty&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,g));else{this.computeApproximateSize(!1,g);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()&&(!h||!p))return a!=null&&(this.deletionFile=s,this.additionFile=c),m&&this.clearReusableHeader(),this.renderPlaceholder(this.height);let b=this.virtualizer.getWindowSpecs(),x=this.top??0,S=this.computeRenderRangeFromWindow(g,x,b);return super.render({fileDiff:d,fileContainer:e,renderRange:S,lineAnnotations:r,forceRender:(f??n)||y||v||m,...a,...i})}finalizeRender(){if(!K(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:!K(a,o),renderedDiffChanged:!K(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 Dt(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=Et(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),s=this.getHunkSeparatorType(),c=n?!0:this.hunksRenderer.getExpandedHunksMap(),l=vt(this.cache.heightDeltas),u=q(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=xt(a);for(;s<o;){let e=s-a,r=u+(e>0?n:0)+e*this.metrics.lineHeight+St(i,e)*this.metrics.lineHeight+yt(l,t,t+e);this.cache.checkpoints.push({renderedLineIndex:s,lineIndex:t+e,top:r}),s+=mt}u+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+yt(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=G({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:c,hunkIndex:t,collapsedContextThreshold:r}),u=l.collapsedLines>0?V({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?W({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:Ct({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}=G({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=W({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=Et(e,this.options.loadDiffFiles!=null),f=this.height,p=this.getLayoutLineCount(e,l),m=q(this.metrics,i),h=e.hunks.length>0?ye(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=[],D=(n+r)/2,O=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-C*c*2),s),k=t+(O?.top??_),A=O?.renderedLineIndex??0,j,M,N;if(U({diff:e,diffStyle:l,startingLine:O?.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?V({type:u,metrics:this.metrics,hunkIndex:i,hunkSpecs:a?.hunkSpecs}):void 0)?.totalHeight??0;k+=y;let b=A%s===0,x=Math.floor(A/s);if(b&&(E[x]=k-(t+_+y),N!=null)){if(N<=0)return!0;N--}let S=this.getLineHeight(l===`split`?m:h,g);if(k>n-S&&k<r&&(j??=x),M==null&&k+S>D&&(M=x),N==null&&k>=r&&b&&(N=T),A++,k+=S,c>0||v&&d){let e=H({type:u,metrics:this.metrics});e!=null&&(k<r&&k+e.totalHeight>n&&(j??=x),M==null&&k+e.totalHeight>D&&(M=x),k+=e.totalHeight)}return!1}}),j==null){if(x)j=0,M=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h}}M??=j;let P=Math.round(M-w/2),F=Math.max(0,Math.ceil(p/s)-w),I=Math.max(0,Math.min(P,F)),L=I*s,R=P<0?C+P*s:C,ee=E[I]??0,te=L===0?0:g+ee,z=I+R/s,ne=z<E.length?v-E[z]:v-(k-t-_);return{startingLine:L,totalLines:R,bufferBefore:te,bufferAfter:Math.max(0,ne)}}};function _t(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===_e&&(t=Math.max(t??0,n.getBoundingClientRect().height))}return t}function vt(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 yt({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=bt(e,n);return(t[bt(e,r)]??0)-(t[i]??0)}function bt(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 xt(e){return Math.ceil(e/mt)*mt}function St(e,t){let n=0;for(let r of e)r<t&&n++;return n}function Ct({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 wt(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 Tt(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 Et(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function Dt(e){return typeof e==`function`?`custom`:e??`line-info`}function Ot(e,t){return e==null||t==null?e==null&&t==null:R(e,t)}function kt(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}function At({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function jt(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:Mt(n,e.startContentIndex)}}function Mt(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}function Nt({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:l,lineAnnotations:u,getHoveredLine:d,getInstance:f,getAnnotationSlotName:p=B}){let m=n?.(e),h=r?.(e),g=i?.(e),_=a?.(e);return(0,Y.jsxs)(Y.Fragment,{children:[m==null?(0,Y.jsxs)(Y.Fragment,{children:[h!=null&&(0,Y.jsx)(`div`,{slot:`header-prefix`,children:h}),g!=null&&(0,Y.jsx)(`div`,{slot:`header-filename-suffix`,children:g}),_!=null&&(0,Y.jsx)(`div`,{slot:`header-metadata`,children:_})]}):(0,Y.jsx)(`div`,{slot:c,children:m}),o!=null&&u?.map((e,t)=>(0,Y.jsx)(`div`,{slot:p(e),children:o(e)},t)),t!=null&&l!=null&&f!=null&&t.map(t=>{if(t==null)return;let n=Pt(t,e);return(0,Y.jsx)(`div`,{slot:n,style:ae,children:l(t,f)},n)}),s!=null&&(0,Y.jsx)(`div`,{slot:`gutter-utility-slot`,style:re,children:s(d)})]})}function Pt(e,t){let n=jt(e,t);return n==null?void 0:At({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}var $=e(t(),1),Ft=typeof window>`u`?$.useEffect:$.useLayoutEffect;function It({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=ne(),_=s!==void 0,v=(0,$.useContext)(te),y=oe(),[b,x]=(0,$.useState)(),S=L(e=>m?.(e)),C=m==null?void 0:S,w=(0,$.useRef)(null),T=L(r=>{let i=h?.(r)??`reject`;return i===`accept`&&(w.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}),E=h==null?void 0:T,D=Lt({acceptedCache:w,fileDiff:e,newFile:n,oldFile:t,parseDiffOptions:r?.parseDiffOptions}),O=(0,$.useRef)(null),k=(0,$.useRef)(null),A=(0,$.useRef)(null),j=L(()=>{if(y==null)throw Error(`FileDiff: EditContext is not attached`);return y(`file-diff`,i??{},a)}),M=L(e=>{if(e!=null){if(O.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);g==null?O.current=new it(Bt({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),f?void 0:v,!0):O.current=new gt(Bt({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),g,l,f?void 0:v,!0),O.current.hydrate({fileDiff:D,fileContainer:e,lineAnnotations:o,prerenderedHTML:c})}else{if(O.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);A.current=null,O.current.cleanUp(),O.current=null,k.current=null}});Ft(()=>{let{current:e}=O;if(e==null)return;let t=Bt({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),n=t!==void 0&&!N(e.options,t);if(e.setOptions(t),!p&&(A.current=null,k.current!=null)){let{current:e}=k;k.current=null,e()}let i=zt(D,o,w);if(e.render({forceRender:n,fileDiff:i.fileDiff,lineAnnotations:i.lineAnnotations}),s!==void 0&&e.setSelectedLines(s),!p||k.current!=null)return;if(y==null)throw Error(`FileDiff: EditContext is not attached`);let a=()=>{O.current===e&&k.current==null&&e.__canAttachEditor()&&(k.current=Vt(e,j))};if(e.__canAttachEditor()){A.current=null,a();return}let c=e.__prepareForEditing();if(c==null){A.current=null;return}if(A.current?.promise===c)return;let l={promise:c};A.current=l,c.then(()=>{A.current===l&&(a(),A.current=null)}).catch(e=>{A.current===l&&(A.current=null,x(e))})});let P=(0,$.useCallback)(()=>O.current?.getHoveredLine(),[]),F=(0,$.useCallback)(e=>O.current?.getAnnotationSlotName(e)??B(e),[]);if(b!=null)throw b;return{fileDiff:D,ref:M,getHoveredLine:P,getAnnotationSlotName:F}}function Lt({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(Rt(r,n,o.stale)||Rt(r,n,o.installed))return o.fileDiff;a.filePair=null}return l(r??null,n??null,i)},[e,t,r,n,i])}function Rt(e,t,n){return C(e??void 0,n.oldFile??void 0)&&C(t??void 0,n.newFile??void 0)}function zt(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&&(K(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 Bt({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?I:e?.renderCustomHeader,renderGutterUtility:r?I:e?.renderGutterUtility,onEditChange:i,onEditComplete:a}:e}function Vt(e,t){let n=t();try{return n.edit(e)}catch(e){throw n.cleanUp(),e}}function Ht({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:d,renderCustomHeader:f,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:h,renderGutterUtility:g,disableWorkerPool:_=!1,edit:v=!1,onEditChange:y,onEditComplete:b}){let{ref:x,getHoveredLine:S,getAnnotationSlotName:C}=It({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:g!=null,hasCustomHeader:f!=null,disableWorkerPool:_,edit:v,onEditChange:y,onEditComplete:b}),w=Nt({fileDiff:e,renderCustomHeader:f,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:h,renderAnnotation:d,renderGutterUtility:g,lineAnnotations:a,getHoveredLine:S,getAnnotationSlotName:C});return(0,Y.jsx)(u,{ref:x,className:s,style:c,children:ie(w,l)})}export{Nt as n,gt as r,Ht as t};
|
|
2
|
+
//# sourceMappingURL=FileDiff-VvQl3KAm.js.map
|