/**
 * DevExtreme (renovation/ui/grids/data_grid_next/paging/paging.js)
 * Version: 22.1.3 (build 22180-0310)
 * Build date: Wed Jun 29 2022
 *
 * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
exports.viewFunction = exports.DataGridNextPagingProps = exports.DataGridNextPaging = void 0;
var _inferno = require("inferno");
var _inferno2 = require("@devextreme/runtime/inferno");
var _value_setter = require("../../../../utils/plugin/value_setter");
var _getter_extender = require("../../../../utils/plugin/getter_extender");
var _plugins = require("../plugins");
var _plugins2 = require("./plugins");
var _excluded = ["defaultPageIndex", "defaultPageSize", "enabled", "pageIndex", "pageIndexChange", "pageSize", "pageSizeChange"];

function _objectWithoutProperties(source, excluded) {
    if (null == source) {
        return {}
    }
    var target = _objectWithoutPropertiesLoose(source, excluded);
    var key, i;
    if (Object.getOwnPropertySymbols) {
        var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
        for (i = 0; i < sourceSymbolKeys.length; i++) {
            key = sourceSymbolKeys[i];
            if (excluded.indexOf(key) >= 0) {
                continue
            }
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) {
                continue
            }
            target[key] = source[key]
        }
    }
    return target
}

function _objectWithoutPropertiesLoose(source, excluded) {
    if (null == source) {
        return {}
    }
    var target = {};
    var sourceKeys = Object.keys(source);
    var key, i;
    for (i = 0; i < sourceKeys.length; i++) {
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) {
            continue
        }
        target[key] = source[key]
    }
    return target
}

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 _defineProperties(target, props) {
    for (var i = 0; i < props.length; i++) {
        var descriptor = props[i];
        descriptor.enumerable = descriptor.enumerable || false;
        descriptor.configurable = true;
        if ("value" in descriptor) {
            descriptor.writable = true
        }
        Object.defineProperty(target, descriptor.key, descriptor)
    }
}

function _createClass(Constructor, protoProps, staticProps) {
    if (protoProps) {
        _defineProperties(Constructor.prototype, protoProps)
    }
    if (staticProps) {
        _defineProperties(Constructor, staticProps)
    }
    Object.defineProperty(Constructor, "prototype", {
        writable: false
    });
    return Constructor
}

function _assertThisInitialized(self) {
    if (void 0 === self) {
        throw new ReferenceError("this hasn't been initialised - super() hasn't been called")
    }
    return self
}

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)
}
var viewFunction = function(viewModel) {
    return (0, _inferno.createFragment)([(0, _inferno.createComponentVNode)(2, _value_setter.ValueSetter, {
        type: _plugins2.PageIndex,
        value: viewModel.props.pageIndex
    }), (0, _inferno.createComponentVNode)(2, _value_setter.ValueSetter, {
        type: _plugins2.PageSize,
        value: viewModel.pageSize
    }), (0, _inferno.createComponentVNode)(2, _value_setter.ValueSetter, {
        type: _plugins2.PagingEnabled,
        value: viewModel.props.enabled
    }), (0, _inferno.createComponentVNode)(2, _value_setter.ValueSetter, {
        type: _plugins2.SetPageIndex,
        value: viewModel.setPageIndex
    }), (0, _inferno.createComponentVNode)(2, _value_setter.ValueSetter, {
        type: _plugins2.SetPageSize,
        value: viewModel.setPageSize
    }), (0, _inferno.createComponentVNode)(2, _value_setter.ValueSetter, {
        type: _plugins2.LoadPageCount,
        value: viewModel.loadPageCount
    }), (0, _inferno.createComponentVNode)(2, _value_setter.ValueSetter, {
        type: _plugins2.SetLoadPageCount,
        value: viewModel.setLoadPageCount
    }), (0, _inferno.createComponentVNode)(2, _getter_extender.GetterExtender, {
        type: _plugins.LocalVisibleItems,
        order: 1,
        value: _plugins2.ApplyPagingToVisibleItems
    }), (0, _inferno.createComponentVNode)(2, _getter_extender.GetterExtender, {
        type: _plugins.LoadOptionsValue,
        order: 1,
        value: _plugins2.AddPagingToLoadOptions
    }), (0, _inferno.createComponentVNode)(2, _getter_extender.GetterExtender, {
        type: _plugins.LocalDataState,
        order: 1,
        value: _plugins2.AddPagingToLocalDataState
    })], 4)
};
exports.viewFunction = viewFunction;
var DataGridNextPagingProps = {
    enabled: true,
    defaultPageSize: 20,
    pageSizeChange: function() {},
    defaultPageIndex: 0,
    pageIndexChange: function() {}
};
exports.DataGridNextPagingProps = DataGridNextPagingProps;
var DataGridNextPaging = function(_BaseInfernoComponent) {
    _inheritsLoose(DataGridNextPaging, _BaseInfernoComponent);

    function DataGridNextPaging(props) {
        var _this;
        _this = _BaseInfernoComponent.call(this, props) || this;
        _this.state = {
            loadPageCount: 1,
            pageSize: void 0 !== _this.props.pageSize ? _this.props.pageSize : _this.props.defaultPageSize,
            pageIndex: void 0 !== _this.props.pageIndex ? _this.props.pageIndex : _this.props.defaultPageIndex
        };
        _this.setPageIndex = _this.setPageIndex.bind(_assertThisInitialized(_this));
        _this.setPageSize = _this.setPageSize.bind(_assertThisInitialized(_this));
        _this.setLoadPageCount = _this.setLoadPageCount.bind(_assertThisInitialized(_this));
        return _this
    }
    var _proto = DataGridNextPaging.prototype;
    _proto.setPageIndex = function(pageIndex) {
        var __newValue;
        this.setState((function(__state_argument) {
            __newValue = pageIndex;
            return {
                pageIndex: __newValue
            }
        }));
        this.props.pageIndexChange(__newValue)
    };
    _proto.setPageSize = function(pageSize) {
        var __newValue;
        this.setState((function(__state_argument) {
            __newValue = pageSize;
            return {
                pageSize: __newValue
            }
        }));
        this.props.pageSizeChange(__newValue)
    };
    _proto.setLoadPageCount = function(loadPageCount) {
        this.setState((function(__state_argument) {
            return {
                loadPageCount: loadPageCount
            }
        }))
    };
    _proto.render = function() {
        var props = this.props;
        return viewFunction({
            props: _extends({}, props, {
                pageSize: void 0 !== this.props.pageSize ? this.props.pageSize : this.state.pageSize,
                pageIndex: void 0 !== this.props.pageIndex ? this.props.pageIndex : this.state.pageIndex
            }),
            loadPageCount: this.state.loadPageCount,
            pageSize: this.pageSize,
            setPageIndex: this.setPageIndex,
            setPageSize: this.setPageSize,
            setLoadPageCount: this.setLoadPageCount,
            restAttributes: this.restAttributes
        })
    };
    _createClass(DataGridNextPaging, [{
        key: "pageSize",
        get: function() {
            if (0 === (void 0 !== this.props.pageSize ? this.props.pageSize : this.state.pageSize)) {
                return "all"
            }
            return void 0 !== this.props.pageSize ? this.props.pageSize : this.state.pageSize
        }
    }, {
        key: "restAttributes",
        get: function() {
            var _this$props$pageSize$ = _extends({}, this.props, {
                    pageSize: void 0 !== this.props.pageSize ? this.props.pageSize : this.state.pageSize,
                    pageIndex: void 0 !== this.props.pageIndex ? this.props.pageIndex : this.state.pageIndex
                }),
                restProps = (_this$props$pageSize$.defaultPageIndex, _this$props$pageSize$.defaultPageSize, _this$props$pageSize$.enabled, _this$props$pageSize$.pageIndex, _this$props$pageSize$.pageIndexChange, _this$props$pageSize$.pageSize, _this$props$pageSize$.pageSizeChange, _objectWithoutProperties(_this$props$pageSize$, _excluded));
            return restProps
        }
    }]);
    return DataGridNextPaging
}(_inferno2.BaseInfernoComponent);
exports.DataGridNextPaging = DataGridNextPaging;
DataGridNextPaging.defaultProps = DataGridNextPagingProps;
