/**
 * DevExtreme (esm/renovation/ui/scheduler/appointment/content/layout.js)
 * Version: 22.1.7 (build 23032-0308)
 * Build date: Wed Feb 01 2023
 *
 * Copyright (c) 2012 - 2023 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 = ["appointmentTemplate", "data", "dateText", "hideReducedIconTooltip", "index", "isRecurrent", "isReduced", "showReducedIconTooltip", "text"];
import {
    createVNode,
    createFragment,
    createComponentVNode,
    normalizeProps
} from "inferno";
import {
    Fragment
} from "inferno";
import {
    InfernoEffect,
    InfernoComponent
} from "@devextreme/runtime/inferno";
import {
    AppointmentDetails
} from "./details/layout";
import {
    AppointmentTitle
} from "./title/layout";
export var viewFunction = _ref => {
    var {
        props: {
            appointmentTemplate: appointmentTemplate,
            data: data,
            dateText: dateText,
            index: index,
            isRecurrent: isRecurrent,
            isReduced: isReduced,
            text: text
        },
        refReducedIcon: refReducedIcon
    } = _ref;
    var AppointmentTemplate = appointmentTemplate;
    return createVNode(1, "div", "dx-scheduler-appointment-content", appointmentTemplate ? AppointmentTemplate({
        data: data,
        index: index
    }) : createFragment([createComponentVNode(2, AppointmentTitle, {
        text: text
    }), createComponentVNode(2, AppointmentDetails, {
        dateText: dateText
    }), isRecurrent && createVNode(1, "div", "dx-scheduler-appointment-recurrence-icon dx-icon-repeat"), isReduced && createVNode(1, "div", "dx-scheduler-appointment-reduced-icon", null, 1, null, null, refReducedIcon)], 0), 0)
};
export var AppointmentContentProps = {
    text: "",
    dateText: "",
    isRecurrent: false,
    isReduced: false,
    index: 0
};
import {
    createRef as infernoCreateRef
} from "inferno";
var getTemplate = TemplateProp => TemplateProp && (TemplateProp.defaultProps ? props => normalizeProps(createComponentVNode(2, TemplateProp, _extends({}, props))) : TemplateProp);
export class AppointmentContent extends InfernoComponent {
    constructor(props) {
        super(props);
        this.state = {};
        this.refReducedIcon = infernoCreateRef();
        this.bindHoverEffect = this.bindHoverEffect.bind(this);
        this.onReducedIconMouseEnter = this.onReducedIconMouseEnter.bind(this);
        this.onReducedIconMouseLeave = this.onReducedIconMouseLeave.bind(this)
    }
    createEffects() {
        return [new InfernoEffect(this.bindHoverEffect, [this.props.showReducedIconTooltip, this.props.data, this.props.hideReducedIconTooltip])]
    }
    updateEffects() {
        var _this$_effects$;
        null === (_this$_effects$ = this._effects[0]) || void 0 === _this$_effects$ ? void 0 : _this$_effects$.update([this.props.showReducedIconTooltip, this.props.data, this.props.hideReducedIconTooltip])
    }
    bindHoverEffect() {
        var _this$refReducedIcon$, _this$refReducedIcon$2;
        var onMouseEnter = () => this.onReducedIconMouseEnter();
        var onMouseLeave = () => this.onReducedIconMouseLeave();
        null === (_this$refReducedIcon$ = this.refReducedIcon.current) || void 0 === _this$refReducedIcon$ ? void 0 : _this$refReducedIcon$.addEventListener("mouseenter", onMouseEnter);
        null === (_this$refReducedIcon$2 = this.refReducedIcon.current) || void 0 === _this$refReducedIcon$2 ? void 0 : _this$refReducedIcon$2.addEventListener("mouseleave", onMouseLeave);
        return () => {
            var _this$refReducedIcon$3, _this$refReducedIcon$4;
            null === (_this$refReducedIcon$3 = this.refReducedIcon.current) || void 0 === _this$refReducedIcon$3 ? void 0 : _this$refReducedIcon$3.removeEventListener("mouseenter", onMouseEnter);
            null === (_this$refReducedIcon$4 = this.refReducedIcon.current) || void 0 === _this$refReducedIcon$4 ? void 0 : _this$refReducedIcon$4.removeEventListener("mouseleave", onMouseLeave)
        }
    }
    onReducedIconMouseEnter() {
        this.props.showReducedIconTooltip({
            target: this.refReducedIcon.current,
            endDate: this.props.data.appointmentData.endDate
        })
    }
    onReducedIconMouseLeave() {
        this.props.hideReducedIconTooltip()
    }
    get restAttributes() {
        var _this$props = this.props,
            restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
        return restProps
    }
    render() {
        var props = this.props;
        return viewFunction({
            props: _extends({}, props, {
                appointmentTemplate: getTemplate(props.appointmentTemplate)
            }),
            refReducedIcon: this.refReducedIcon,
            onReducedIconMouseEnter: this.onReducedIconMouseEnter,
            onReducedIconMouseLeave: this.onReducedIconMouseLeave,
            restAttributes: this.restAttributes
        })
    }
}
AppointmentContent.defaultProps = AppointmentContentProps;
