/**
 * ldesign v0.3.13
 * (c) 2023 ldesign
 * @license MIT
 */

import { _ as _defineProperty } from '../../_chunks/dep-2db7b3ec.mjs';
import { defineComponent, computed, createVNode } from 'vue';
import { a as dayjs_min } from '../../_chunks/dep-9888611c.mjs';
import { usePrefixClass } from '../../hooks/useConfig.mjs';
import { extractTimeObj } from '../../_common/js/date-picker/utils.mjs';
import '../../_chunks/dep-255303ba.mjs';
import '../../_chunks/dep-eba0ea6e.mjs';
import '../../config-provider/useConfig.mjs';
import '../../_chunks/dep-095107f7.mjs';
import '../../_chunks/dep-c989dff3.mjs';
import '../../_chunks/dep-9cf86cf1.mjs';
import '../../_chunks/dep-bc1d737a.mjs';
import '../../_chunks/dep-4d7a675b.mjs';
import '../../_chunks/dep-5717e263.mjs';
import '../../_chunks/dep-469b4ae0.mjs';
import '../../_chunks/dep-a8bcacea.mjs';
import '../../_chunks/dep-2e7f59b1.mjs';
import '../../_chunks/dep-855db8bc.mjs';
import '../../_chunks/dep-a87f3e4c.mjs';
import '../../_chunks/dep-1e566bb5.mjs';
import '../../_chunks/dep-1434aa15.mjs';
import '../../_chunks/dep-3da99438.mjs';
import '../../_chunks/dep-b57180d0.mjs';
import '../../_chunks/dep-c8d7b6b4.mjs';
import '../../_chunks/dep-e5eb9f23.mjs';
import '../../_chunks/dep-9fe2ef12.mjs';
import '../../_chunks/dep-672e7d1a.mjs';
import '../../_chunks/dep-42a19209.mjs';
import '../../_chunks/dep-9262ee2f.mjs';
import '../../_chunks/dep-334a4f6b.mjs';
import '../../_chunks/dep-8d3e9aa3.mjs';
import '../../_chunks/dep-876fb3ec.mjs';
import '../../_chunks/dep-40d69a9c.mjs';
import '../../_chunks/dep-dcc83161.mjs';
import '../../_chunks/dep-0fc02184.mjs';
import '../../_chunks/dep-f1994936.mjs';
import '../../_chunks/dep-345e1be3.mjs';
import '../../_common/js/global-config/default-config.mjs';
import '../../_common/js/global-config/locale/zh_CN.mjs';
import '../../_chunks/dep-697a1365.mjs';
import '../../config-provider/type.mjs';
import '../../_chunks/dep-84acf3c2.mjs';
import '../../_chunks/dep-b8d7992c.mjs';
import '../../_chunks/dep-d24841dc.mjs';
import '../../_chunks/dep-f709f709.mjs';
import '../../_chunks/dep-2bc37d52.mjs';
import '../../_chunks/dep-8b989474.mjs';

var TDatePickerCell = defineComponent({
  name: "TDatePickerCell",
  props: {
    time: String,
    text: [String, Number],
    value: Date,
    active: Boolean,
    highlight: Boolean,
    disabled: Boolean,
    startOfRange: Boolean,
    endOfRange: Boolean,
    hoverHighlight: Boolean,
    hoverStartOfRange: Boolean,
    hoverEndOfRange: Boolean,
    additional: Boolean,
    now: Boolean,
    firstDayOfMonth: Boolean,
    lastDayOfMonth: Boolean,
    onClick: Function,
    onMouseEnter: Function,
    dayjsObj: dayjs_min.exports.Dayjs
  },
  setup: function setup(props) {
    var COMPONENT_NAME = usePrefixClass("date-picker__cell");
    var cellClass = computed(function () {
      var _ref;
      return [COMPONENT_NAME.value, (_ref = {}, _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "--now"), props.now), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "--active"), props.active), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "--disabled"), props.disabled), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "--highlight"), props.highlight), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "--hover-highlight"), props.hoverHighlight), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "--active-start"), props.startOfRange), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "--active-end"), props.endOfRange), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "--hover-start"), props.hoverStartOfRange), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "--hover-end"), props.hoverEndOfRange), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "--additional"), props.additional), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "--first-day-of-month"), props.firstDayOfMonth), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "--last-day-of-month"), props.lastDayOfMonth), _ref)];
    });
    function handleClick(e) {
      var _props$onClick;
      if (props.disabled) return;
      if (props.time) {
        var _extractTimeObj = extractTimeObj(props.time),
          hours = _extractTimeObj.hours,
          minutes = _extractTimeObj.minutes,
          seconds = _extractTimeObj.seconds,
          milliseconds = _extractTimeObj.milliseconds,
          meridiem = _extractTimeObj.meridiem;
        var nextHours = hours;
        if (/am/i.test(meridiem) && nextHours === 12) nextHours -= 12;
        if (/pm/i.test(meridiem) && nextHours < 12) nextHours += 12;
        props.value.setHours(nextHours);
        props.value.setMinutes(minutes);
        props.value.setSeconds(seconds);
        props.value.setMilliseconds(milliseconds);
      }
      (_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props, props.value, {
        e: e
      });
    }
    function handleMouseEnter() {
      var _props$onMouseEnter;
      if (props.disabled) return;
      if (props.time) {
        var _extractTimeObj2 = extractTimeObj(props.time),
          hours = _extractTimeObj2.hours,
          minutes = _extractTimeObj2.minutes,
          seconds = _extractTimeObj2.seconds,
          milliseconds = _extractTimeObj2.milliseconds,
          meridiem = _extractTimeObj2.meridiem;
        var nextHours = hours;
        if (/am/i.test(meridiem) && nextHours === 12) nextHours -= 12;
        if (/pm/i.test(meridiem) && nextHours < 12) nextHours += 12;
        props.value.setHours(nextHours);
        props.value.setMinutes(minutes);
        props.value.setSeconds(seconds);
        props.value.setMilliseconds(milliseconds);
      }
      (_props$onMouseEnter = props.onMouseEnter) === null || _props$onMouseEnter === void 0 ? void 0 : _props$onMouseEnter.call(props, props.value);
    }
    return function () {
      return createVNode("td", {
        "class": cellClass.value,
        "onClick": handleClick,
        "onMouseenter": handleMouseEnter
      }, [createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "-inner")
      }, [props.text])]);
    };
  }
});

export { TDatePickerCell as default };
//# sourceMappingURL=Cell.mjs.map
