"use strict";var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;exports.__esModule = true;exports.DayCellView = void 0;
var _react = _interopRequireWildcard(require("react"));

var _ThemeContext = require("../../lib/theming/ThemeContext");
var _InternalDateTransformer = require("../../lib/date/InternalDateTransformer");

var _DayCellView = require("./DayCellView.styles");
var _CalendarContext = require("./CalendarContext");

var CDS = _interopRequireWildcard(require("./CalendarDateShape"));

var _CalendarDay = require("./CalendarDay");





var DayCellView = exports.DayCellView = function DayCellView(props) {var _isHoliday, _renderDay;
  var date = props.date;
  var _useContext = (0, _react.useContext)(_CalendarContext.CalendarContext),value = _useContext.value,minDate = _useContext.minDate,maxDate = _useContext.maxDate,isHoliday = _useContext.isHoliday,renderDay = _useContext.renderDay,today = _useContext.today,onDateClick = _useContext.onDateClick;
  var theme = (0, _react.useContext)(_ThemeContext.ThemeContext);

  var isDisabled = !CDS.isBetween(date, minDate, maxDate);

  var humanDateString = _InternalDateTransformer.InternalDateTransformer.dateToHumanString(date);

  var dayClickHandler = (0, _react.useCallback)(function () {
    onDateClick == null || onDateClick(date);
  }, [onDateClick, date]);

  var dayProps = {
    isToday: Boolean(today && CDS.isEqual(date, today)),
    isSelected: Boolean(value && CDS.isEqual(date, value)),
    isDisabled: isDisabled,
    isWeekend: (_isHoliday = isHoliday == null ? void 0 : isHoliday(humanDateString, date.isWeekend)) != null ? _isHoliday : date.isWeekend,
    date: humanDateString,
    onDayClick: dayClickHandler
  };

  var dayElement = (_renderDay = renderDay == null ? void 0 : renderDay(dayProps)) != null ? _renderDay : /*#__PURE__*/_react.default.createElement(_CalendarDay.CalendarDay, dayProps);

  return /*#__PURE__*/_react.default.createElement("div", { className: _DayCellView.styles.cell(theme) }, dayElement);
};