/**
 * DevExtreme (esm/renovation/ui/scheduler/workspaces/base/time_panel/cell.js)
 * Version: 22.1.13
 * Build date: Fri Feb 09 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
import _extends from "@babel/runtime/helpers/esm/extends";
var _excluded = ["allDay", "ariaLabel", "children", "className", "contentTemplateProps", "endDate", "groupIndex", "groups", "index", "isFirstGroupCell", "isLastGroupCell", "startDate", "text", "timeCellTemplate"];
import {
    createVNode,
    createComponentVNode,
    normalizeProps
} from "inferno";
import {
    BaseInfernoComponent
} from "@devextreme/runtime/inferno";
import {
    CellBase as Cell,
    CellBaseProps
} from "../cell";
export var viewFunction = _ref => {
    var {
        props: {
            className: className,
            isFirstGroupCell: isFirstGroupCell,
            isLastGroupCell: isLastGroupCell,
            text: text,
            timeCellTemplate: TimeCellTemplate
        },
        timeCellTemplateProps: timeCellTemplateProps
    } = _ref;
    return createComponentVNode(2, Cell, {
        isFirstGroupCell: isFirstGroupCell,
        isLastGroupCell: isLastGroupCell,
        className: "dx-scheduler-time-panel-cell dx-scheduler-cell-sizes-vertical ".concat(className),
        children: [!TimeCellTemplate && createVNode(1, "div", null, text, 0), !!TimeCellTemplate && TimeCellTemplate({
            index: timeCellTemplateProps.index,
            data: timeCellTemplateProps.data
        })]
    })
};
export var TimePanelCellProps = CellBaseProps;
var getTemplate = TemplateProp => TemplateProp && (TemplateProp.defaultProps ? props => normalizeProps(createComponentVNode(2, TemplateProp, _extends({}, props))) : TemplateProp);
export class TimePanelCell extends BaseInfernoComponent {
    constructor(props) {
        super(props);
        this.state = {};
        this.__getterCache = {}
    }
    get timeCellTemplateProps() {
        if (void 0 !== this.__getterCache.timeCellTemplateProps) {
            return this.__getterCache.timeCellTemplateProps
        }
        return this.__getterCache.timeCellTemplateProps = (() => {
            var {
                groupIndex: groupIndex,
                groups: groups,
                index: index,
                startDate: startDate,
                text: text
            } = this.props;
            return {
                data: {
                    date: startDate,
                    groups: groups,
                    groupIndex: groupIndex,
                    text: text
                },
                index: index
            }
        })()
    }
    get restAttributes() {
        var _this$props = this.props,
            restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
        return restProps
    }
    componentWillUpdate(nextProps, nextState, context) {
        if (this.props.groupIndex !== nextProps.groupIndex || this.props.groups !== nextProps.groups || this.props.index !== nextProps.index || this.props.startDate !== nextProps.startDate || this.props.text !== nextProps.text) {
            this.__getterCache.timeCellTemplateProps = void 0
        }
    }
    render() {
        var props = this.props;
        return viewFunction({
            props: _extends({}, props, {
                timeCellTemplate: getTemplate(props.timeCellTemplate)
            }),
            timeCellTemplateProps: this.timeCellTemplateProps,
            restAttributes: this.restAttributes
        })
    }
}
TimePanelCell.defaultProps = TimePanelCellProps;
