/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

import { defineComponent, computed } from '@vue/composition-api';
import { e as extractTimeObj } from '../../../_chunks/dep-68f38014.js';
import { usePrefixClass } from '../../../hooks/use-config.js';
import '../../../_chunks/dep-eb467ddf.js';
import '../../../_chunks/dep-f38f4c93.js';
import '../../../_chunks/dep-5210251b.js';
import '../../../_chunks/dep-b31eb7d9.js';
import '../../../_chunks/dep-fe18d4b0.js';
import '../../../_chunks/dep-24cf4e98.js';
import '../../../_chunks/dep-22504add.js';
import '../../config-provider/useConfig.js';
import '../../config-provider/context.js';
import 'lodash';
import '../../../_chunks/dep-def4c2ce.js';

var TDatePickerCell = defineComponent({
  name: "LDatePickerCell",
  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
  },
  setup(props) {
    const COMPONENT_NAME = usePrefixClass("date-picker__cell");
    const cellClass = computed(() => [COMPONENT_NAME.value, {
      [`${COMPONENT_NAME.value}--now`]: props.now,
      [`${COMPONENT_NAME.value}--active`]: props.active,
      [`${COMPONENT_NAME.value}--disabled`]: props.disabled,
      [`${COMPONENT_NAME.value}--highlight`]: props.highlight,
      [`${COMPONENT_NAME.value}--hover-highlight`]: props.hoverHighlight,
      [`${COMPONENT_NAME.value}--active-start`]: props.startOfRange,
      [`${COMPONENT_NAME.value}--active-end`]: props.endOfRange,
      [`${COMPONENT_NAME.value}--hover-start`]: props.hoverStartOfRange,
      [`${COMPONENT_NAME.value}--hover-end`]: props.hoverEndOfRange,
      [`${COMPONENT_NAME.value}--additional`]: props.additional,
      [`${COMPONENT_NAME.value}--first-day-of-month`]: props.firstDayOfMonth,
      [`${COMPONENT_NAME.value}--last-day-of-month`]: props.lastDayOfMonth
    }]);
    function handleClick(e) {
      var _props$onClick;
      if (props.disabled) return;
      if (props.time) {
        const {
          hours,
          minutes,
          seconds,
          milliseconds,
          meridiem
        } = extractTimeObj(props.time);
        let 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
      });
    }
    function handleMouseEnter() {
      var _props$onMouseEnter;
      if (props.disabled) return;
      if (props.time) {
        const {
          hours,
          minutes,
          seconds,
          milliseconds,
          meridiem
        } = extractTimeObj(props.time);
        let 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 {
      cellClass,
      COMPONENT_NAME,
      handleClick,
      handleMouseEnter
    };
  },
  render() {
    const h = arguments[0];
    const {
      cellClass,
      COMPONENT_NAME,
      handleClick,
      handleMouseEnter
    } = this;
    return h("td", {
      "class": cellClass,
      "on": {
        "click": handleClick,
        "mouseenter": handleMouseEnter
      }
    }, [h("div", {
      "class": `${COMPONENT_NAME}-inner`
    }, [this.text])]);
  }
});

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