var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
import React, { useCallback, useContext } from 'react';
import { useStyles } from '../../lib/renderEnvironment/index.js';
import { ThemeContext } from '../../lib/theming/ThemeContext.js';
import { InternalDateTransformer } from '../../lib/date/InternalDateTransformer.js';
import { getStyles } from './DayCellView.styles.js';
import { CalendarContext } from './CalendarContext.js';
import * as CDS from './CalendarDateShape.js';
import { CalendarDay } from './CalendarDay.js';
export var DayCellView = function (props) {
    var _a, _b;
    var date = props.date;
    var _c = useContext(CalendarContext), value = _c.value, minDate = _c.minDate, maxDate = _c.maxDate, isHoliday = _c.isHoliday, renderDay = _c.renderDay, today = _c.today, onDateClick = _c.onDateClick;
    var styles = useStyles(getStyles);
    var theme = useContext(ThemeContext);
    var isDisabled = !CDS.isBetween(date, minDate, maxDate);
    var humanDateString = InternalDateTransformer.dateToHumanString(date);
    var dayClickHandler = useCallback(function () {
        onDateClick === null || onDateClick === void 0 ? void 0 : onDateClick(date);
    }, [onDateClick, date]);
    var dayProps = {
        isToday: Boolean(today && CDS.isEqual(date, today)),
        isSelected: Boolean(value && CDS.isEqual(date, value)),
        isDisabled: isDisabled,
        isWeekend: (_a = isHoliday === null || isHoliday === void 0 ? void 0 : isHoliday(humanDateString, date.isWeekend)) !== null && _a !== void 0 ? _a : date.isWeekend,
        date: humanDateString,
        onDayClick: dayClickHandler,
    };
    var dayElement = (_b = renderDay === null || renderDay === void 0 ? void 0 : renderDay(dayProps)) !== null && _b !== void 0 ? _b : React.createElement(CalendarDay, __assign({}, dayProps));
    return React.createElement("div", { className: styles.cell(theme) }, dayElement);
};
//# sourceMappingURL=DayCellView.js.map