/**
 * DevExtreme (cjs/renovation/ui/grids/data_grid_next/scrolling/virtual_row.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.VirtualRowProps = exports.VirtualRow = void 0;
var _inferno = require("inferno");
var _inferno2 = require("@devextreme/runtime/inferno");
var _classes = _interopRequireDefault(require("../classes"));
var _combine_classes = require("../../../../utils/combine_classes");
var _excluded = ["cellClasses", "height", "rowKey"];
var _combineClasses;

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

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 _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)
}

function _defineProperty(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        })
    } else {
        obj[key] = value
    }
    return obj
}
var rowClasses = (0, _combine_classes.combineClasses)((_combineClasses = {}, _defineProperty(_combineClasses, _classes.default.row, true), _defineProperty(_combineClasses, _classes.default.columnLines, true), _defineProperty(_combineClasses, _classes.default.virtualRow, true), _combineClasses));
var viewFunction = function(_ref) {
    var rowKey = _ref.props.rowKey,
        virtualCells = _ref.virtualCells;
    return (0, _inferno.createVNode)(1, "tr", rowClasses, virtualCells.map((function(_ref2) {
        var cellClass = _ref2.cellClass,
            height = _ref2.height,
            key = _ref2.key;
        return (0, _inferno.createVNode)(1, "td", cellClass, null, 1, {
            style: (0, _inferno2.normalizeStyles)({
                height: height
            })
        }, key)
    })), 0, {
        role: "presentation"
    }, rowKey)
};
exports.viewFunction = viewFunction;
var VirtualRowProps = {
    height: 0,
    cellClasses: Object.freeze([]),
    rowKey: 0
};
exports.VirtualRowProps = VirtualRowProps;
var VirtualRow = function(_BaseInfernoComponent) {
    _inheritsLoose(VirtualRow, _BaseInfernoComponent);

    function VirtualRow(props) {
        var _this;
        _this = _BaseInfernoComponent.call(this, props) || this;
        _this.state = {};
        _this.__getterCache = {};
        return _this
    }
    var _proto = VirtualRow.prototype;
    _proto.componentWillUpdate = function(nextProps, nextState, context) {
        if (this.props.cellClasses !== nextProps.cellClasses || this.props.height !== nextProps.height) {
            this.__getterCache.virtualCells = void 0
        }
    };
    _proto.render = function() {
        var props = this.props;
        return viewFunction({
            props: _extends({}, props),
            virtualCells: this.virtualCells,
            restAttributes: this.restAttributes
        })
    };
    _createClass(VirtualRow, [{
        key: "virtualCells",
        get: function() {
            var _this2 = this;
            if (void 0 !== this.__getterCache.virtualCells) {
                return this.__getterCache.virtualCells
            }
            return this.__getterCache.virtualCells = function() {
                var _this2$props = _this2.props,
                    cellClasses = _this2$props.cellClasses,
                    height = _this2$props.height;
                var cells = [];
                cellClasses.forEach((function(c_class, index) {
                    cells.push({
                        height: height,
                        key: index,
                        cellClass: c_class
                    })
                }));
                return cells
            }()
        }
    }, {
        key: "restAttributes",
        get: function() {
            var _this$props = this.props,
                restProps = (_this$props.cellClasses, _this$props.height, _this$props.rowKey, _objectWithoutProperties(_this$props, _excluded));
            return restProps
        }
    }]);
    return VirtualRow
}(_inferno2.BaseInfernoComponent);
exports.VirtualRow = VirtualRow;
VirtualRow.defaultProps = VirtualRowProps;
