/**
 * DevExtreme (renovation/ui/grids/data_grid_next/widgets/row_base.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.RowPropertiesGetter = exports.RowClassesGetter = exports.RowBaseProps = exports.RowBase = void 0;
var _inferno = require("inferno");
var _inferno2 = require("@devextreme/runtime/inferno");
var _combine_classes = require("../../../../utils/combine_classes");
var _context = require("../../../../utils/plugin/context");
var _classes = _interopRequireDefault(require("../classes"));
var _excluded = ["children", "row"];

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

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

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)
}
var RowPropertiesGetter = (0, _context.createGetter)((function() {
    return {}
}));
exports.RowPropertiesGetter = RowPropertiesGetter;
var RowClassesGetter = (0, _context.createGetter)((function() {
    return {}
}));
exports.RowClassesGetter = RowClassesGetter;
var viewFunction = function(viewModel) {
    return (0, _inferno.normalizeProps)((0, _inferno.createVNode)(1, "tr", viewModel.cssClasses, viewModel.props.children, 0, _extends({
        role: "row",
        "aria-selected": "false"
    }, viewModel.additionalParams)))
};
exports.viewFunction = viewFunction;
var RowBaseProps = {
    row: Object.freeze({
        data: {},
        rowType: "data"
    })
};
exports.RowBaseProps = RowBaseProps;
var RowBase = function(_InfernoComponent) {
    _inheritsLoose(RowBase, _InfernoComponent);

    function RowBase(props) {
        var _this;
        _this = _InfernoComponent.call(this, props) || this;
        _this.state = {
            additionalParams: {},
            additionalClasses: {}
        };
        _this.watchAdditionalParams = _this.watchAdditionalParams.bind(_assertThisInitialized(_this));
        _this.watchAdditionalClasses = _this.watchAdditionalClasses.bind(_assertThisInitialized(_this));
        return _this
    }
    var _proto = RowBase.prototype;
    _proto.createEffects = function() {
        return [new _inferno2.InfernoEffect(this.watchAdditionalParams, [this.plugins, this.props.row]), new _inferno2.InfernoEffect(this.watchAdditionalClasses, [this.plugins, this.props.row])]
    };
    _proto.updateEffects = function() {
        var _this$_effects$, _this$_effects$2;
        null === (_this$_effects$ = this._effects[0]) || void 0 === _this$_effects$ ? void 0 : _this$_effects$.update([this.plugins, this.props.row]);
        null === (_this$_effects$2 = this._effects[1]) || void 0 === _this$_effects$2 ? void 0 : _this$_effects$2.update([this.plugins, this.props.row])
    };
    _proto.watchAdditionalParams = function() {
        var _this2 = this;
        return this.plugins.watch(RowPropertiesGetter, (function(getter) {
            _this2.setState((function(__state_argument) {
                return {
                    additionalParams: getter(_this2.props.row)
                }
            }))
        }))
    };
    _proto.watchAdditionalClasses = function() {
        var _this3 = this;
        return this.plugins.watch(RowClassesGetter, (function(getter) {
            _this3.setState((function(__state_argument) {
                return {
                    additionalClasses: getter(_this3.props.row)
                }
            }))
        }))
    };
    _proto.render = function() {
        var props = this.props;
        return viewFunction({
            props: _extends({}, props),
            additionalParams: this.state.additionalParams,
            additionalClasses: this.state.additionalClasses,
            plugins: this.plugins,
            cssClasses: this.cssClasses,
            restAttributes: this.restAttributes
        })
    };
    _createClass(RowBase, [{
        key: "plugins",
        get: function() {
            if ("PluginsContext" in this.context) {
                return this.context.PluginsContext
            }
            return _context.PluginsContext
        }
    }, {
        key: "cssClasses",
        get: function() {
            var _extends2;
            return (0, _combine_classes.combineClasses)(_extends((_extends2 = {}, _defineProperty(_extends2, _classes.default.row, true), _defineProperty(_extends2, _classes.default.columnLines, true), _extends2), this.state.additionalClasses))
        }
    }, {
        key: "restAttributes",
        get: function() {
            var _this$props = this.props,
                restProps = (_this$props.children, _this$props.row, _objectWithoutProperties(_this$props, _excluded));
            return restProps
        }
    }]);
    return RowBase
}(_inferno2.InfernoComponent);
exports.RowBase = RowBase;
RowBase.defaultProps = RowBaseProps;
