/**
 * DevExtreme (renovation/ui/scheduler/workspaces/utils.js)
 * Version: 23.2.4 (build 24056-0112)
 * Build date: Sun Feb 25 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
exports.isVerticalGroupingApplied = exports.isHorizontalGroupingApplied = exports.isGroupingByDate = exports.getKeyByGroup = exports.getKeyByDateAndGroup = exports.getIsGroupedAllDayPanel = exports.getGroupCellClasses = exports.addWidthToStyle = exports.addToStyles = exports.addHeightToStyle = void 0;
var _combine_classes = require("../../../utils/combine_classes");
var _consts = require("../consts");

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)
}
const getKeyByDateAndGroup = (date, groupIndex) => {
    const key = date.getTime();
    if (!groupIndex) {
        return key.toString()
    }
    return (key + groupIndex).toString()
};
exports.getKeyByDateAndGroup = getKeyByDateAndGroup;
const getKeyByGroup = (groupIndex, isVerticalGrouping) => {
    if (isVerticalGrouping && !!groupIndex) {
        return groupIndex.toString()
    }
    return "0"
};
exports.getKeyByGroup = getKeyByGroup;
const addToStyles = (options, style) => {
    const nextStyle = null !== style && void 0 !== style ? style : {};
    const result = _extends({}, nextStyle);
    options.forEach(_ref => {
        let {
            attr: attr,
            value: value
        } = _ref;
        result[attr] = value || nextStyle[attr]
    });
    return result
};
exports.addToStyles = addToStyles;
const addHeightToStyle = (value, style) => {
    const height = value ? "".concat(value, "px") : "";
    return addToStyles([{
        attr: "height",
        value: height
    }], style)
};
exports.addHeightToStyle = addHeightToStyle;
const addWidthToStyle = (value, style) => {
    const width = value ? "".concat(value, "px") : "";
    return addToStyles([{
        attr: "width",
        value: width
    }], style)
};
exports.addWidthToStyle = addWidthToStyle;
const getGroupCellClasses = function() {
    let isFirstGroupCell = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : false;
    let isLastGroupCell = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : false;
    let className = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "";
    return (0, _combine_classes.combineClasses)({
        "dx-scheduler-first-group-cell": isFirstGroupCell,
        "dx-scheduler-last-group-cell": isLastGroupCell,
        [className]: true
    })
};
exports.getGroupCellClasses = getGroupCellClasses;
const getIsGroupedAllDayPanel = (hasAllDayRow, isVerticalGrouping) => hasAllDayRow && isVerticalGrouping;
exports.getIsGroupedAllDayPanel = getIsGroupedAllDayPanel;
const isVerticalGroupingApplied = (groups, groupOrientation) => groupOrientation === _consts.VERTICAL_GROUP_ORIENTATION && !!groups.length;
exports.isVerticalGroupingApplied = isVerticalGroupingApplied;
const isHorizontalGroupingApplied = (groups, groupOrientation) => groupOrientation === _consts.HORIZONTAL_GROUP_ORIENTATION && !!groups.length;
exports.isHorizontalGroupingApplied = isHorizontalGroupingApplied;
const isGroupingByDate = (groups, groupOrientation, groupByDate) => {
    const isHorizontalGrouping = isHorizontalGroupingApplied(groups, groupOrientation);
    return groupByDate && isHorizontalGrouping
};
exports.isGroupingByDate = isGroupingByDate;
