/**
 * DevExtreme (esm/__internal/grids/tree_list/m_virtual_scrolling.js)
 * Version: 23.2.6 (build 24140-0112)
 * Build date: Sun May 19 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
import _extends from "@babel/runtime/helpers/esm/extends";
import {
    extend
} from "../../../core/utils/extend";
import {
    data as virtualScrollingDataControllerExtender,
    dataSourceAdapterExtender as virtualScrollingDataSourceAdapterExtender,
    virtualScrollingModule
} from "../../grids/grid_core/virtual_scrolling/m_virtual_scrolling";
import dataSourceAdapterProvider from "./data_source_adapter/m_data_source_adapter";
import gridCore from "./m_core";
var oldDefaultOptions = virtualScrollingModule.defaultOptions;
virtualScrollingModule.extenders.controllers.data = Base => class extends(virtualScrollingDataControllerExtender(Base)) {
    _loadOnOptionChange() {
        var _a;
        var virtualScrollController = null === (_a = this._dataSource) || void 0 === _a ? void 0 : _a._virtualScrollController;
        null === virtualScrollController || void 0 === virtualScrollController ? void 0 : virtualScrollController.reset();
        super._loadOnOptionChange()
    }
};
var dataSourceAdapterExtender = Base => class extends(virtualScrollingDataSourceAdapterExtender(Base)) {
    changeRowExpand() {
        return super.changeRowExpand.apply(this, arguments).done(() => {
            var viewportItemIndex = this.getViewportItemIndex();
            viewportItemIndex >= 0 && this.setViewportItemIndex(viewportItemIndex)
        })
    }
};
gridCore.registerModule("virtualScrolling", _extends(_extends({}, virtualScrollingModule), {
    defaultOptions: () => extend(true, oldDefaultOptions(), {
        scrolling: {
            mode: "virtual"
        }
    })
}));
dataSourceAdapterProvider.extend(dataSourceAdapterExtender);
