/**
 * DevExtreme (cjs/__internal/grids/tree_list/m_state_storing.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/
 */
"use strict";
var _m_state_storing = require("../../grids/grid_core/state_storing/m_state_storing");
var _m_core = _interopRequireDefault(require("./m_core"));

function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    }
}

function _extends() {
    _extends = Object.assign ? Object.assign.bind() : function(target) {
        for (var i = 1; i < arguments.length; i++) {
            var source = arguments[i];
            for (var key in source) {
                if (Object.prototype.hasOwnProperty.call(source, key)) {
                    target[key] = source[key]
                }
            }
        }
        return target
    };
    return _extends.apply(this, arguments)
}

function _inheritsLoose(subClass, superClass) {
    subClass.prototype = Object.create(superClass.prototype);
    subClass.prototype.constructor = subClass;
    _setPrototypeOf(subClass, superClass)
}

function _setPrototypeOf(o, p) {
    _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) {
        o.__proto__ = p;
        return o
    };
    return _setPrototypeOf(o, p)
}
const stateStoring = Base => function(_stateStoringModule$e) {
    _inheritsLoose(TreeListStateStoringExtender, _stateStoringModule$e);

    function TreeListStateStoringExtender() {
        return _stateStoringModule$e.apply(this, arguments) || this
    }
    var _proto = TreeListStateStoringExtender.prototype;
    _proto.applyState = function(state) {
        _stateStoringModule$e.prototype.applyState.call(this, state);
        this.option("expandedRowKeys", state.expandedRowKeys ? state.expandedRowKeys.slice() : [])
    };
    return TreeListStateStoringExtender
}(_m_state_storing.stateStoringModule.extenders.controllers.stateStoring(Base));
const data = Base => function(_stateStoringModule$e2) {
    _inheritsLoose(TreeListStateStoringDataExtender, _stateStoringModule$e2);

    function TreeListStateStoringDataExtender() {
        return _stateStoringModule$e2.apply(this, arguments) || this
    }
    var _proto2 = TreeListStateStoringDataExtender.prototype;
    _proto2.getUserState = function() {
        const state = _stateStoringModule$e2.prototype.getUserState.call(this);
        if (!this.option("autoExpandAll")) {
            state.expandedRowKeys = this.option("expandedRowKeys")
        }
        return state
    };
    return TreeListStateStoringDataExtender
}(_m_state_storing.stateStoringModule.extenders.controllers.data(Base));
_m_core.default.registerModule("stateStoring", _extends(_extends({}, _m_state_storing.stateStoringModule), {
    extenders: _extends(_extends({}, _m_state_storing.stateStoringModule.extenders), {
        controllers: _extends(_extends({}, _m_state_storing.stateStoringModule.extenders.controllers), {
            stateStoring: stateStoring,
            data: data
        })
    })
}));
