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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, computed, createVNode, mergeProps } from 'vue';
import { usePrefixClass } from '../../hooks/useConfig.js';
import { getDefaultFormat, parseToDayjs } from '../../_common/js/date-picker/format.js';
import useTableData from '../hooks/useTableData.js';
import useDisableDate from '../hooks/useDisableDate.js';
import TExtraContent from './ExtraContent.js';
import TPanelContent from './PanelContent.js';
import { useConfig } from '../../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import 'lodash/isFunction';
import 'lodash/isString';
import '../../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import 'lodash/isArray';
import '../../_common/js/global-config/default-config.js';
import '../../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../../_chunks/dep-e041f5b0.js';
import 'dayjs';
import '../../_common/js/date-picker/utils.js';
import '@babel/runtime/helpers/slicedToArray';
import '@babel/runtime/helpers/objectDestructuringEmpty';
import '@babel/runtime/helpers/extends';
import '../../_chunks/dep-e86e320e.js';
import 'lodash/chunk';
import '../../_common/js/log/log.js';
import 'lodash/isObject';
import '../base/Footer.js';
import '../../button/index.js';
import '../../utils/withInstall.js';
import '../../button/button.js';
import '@babel/runtime/helpers/toConsumableArray';
import '../../loading/index.js';
import '../../loading/directive.js';
import '../../loading/plugin.js';
import '../../utils/dom.js';
import '../../utils/easing.js';
import '../../loading/loading.js';
import '../../utils/render-tnode.js';
import 'lodash/isEmpty';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../../hooks/useTeleport.js';
import '../../loading/props.js';
import '../../loading/icon/gradient.js';
import '../../_common/js/loading/circle-adapter.js';
import '../../_common/js/utils/set-style.js';
import '../../_common/js/utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'lodash/isNull';
import 'lodash/isUndefined';
import 'lodash/isNumber';
import '../../hooks/useRipple.js';
import '../../utils/set-style.js';
import '../../hooks/useKeepAnimation.js';
import '../../form/hooks.js';
import '../../hooks/tnode.js';
import '../../button/props.js';
import '../base/Header.js';
import '../../pagination/index.js';
import '../../pagination/pagination.js';
import 'lodash/isNaN';
import '@ldesign/icons-vue-next';
import '../../hooks/useGlobalIcon.js';
import '../../input-number/index.js';
import '../../input-number/input-number.js';
import '../../input/index.js';
import '../../input/input.js';
import '../../input/props.js';
import '../../input/useInput.js';
import '../../form/const.js';
import '../../hooks/useVModel.js';
import '../../input/useLengthLimit.js';
import '../../input/useInputEventHandler.js';
import '../../input/useInputWidth.js';
import '../../input/input-group.js';
import '../../input/input-group-props.js';
import '../../input-number/props.js';
import '../../input-number/useInputNumber.js';
import '../../hooks/useCommonClassName.js';
import '../../_common/js/input-number/number.js';
import 'lodash/isNil';
import '../../_common/js/input-number/large-number.js';
import '../../select/index.js';
import '../../select/select.js';
import 'lodash/pick';
import 'lodash/debounce';
import 'lodash/get';
import 'lodash/intersection';
import '../../common-components/fake-arrow.js';
import '../../select-input/index.js';
import '../../select-input/select-input.js';
import '../../popup/index.js';
import '../../popup/popup.js';
import '@popperjs/core';
import '../../popup/props.js';
import '../../popup/container.js';
import '../../hooks/useResizeObserver.js';
import '../../select-input/props.js';
import '../../select-input/useSingle.js';
import '../../hooks/useDefaultValue.js';
import '../../select-input/useMultiple.js';
import '../../tag-input/index.js';
import '../../tag-input/tag-input.js';
import '../../tag-input/props.js';
import '../../tag-input/hooks/useTagScroll.js';
import '../../tag-input/useTagList.js';
import '../../tag/index.js';
import '../../tag/tag.js';
import '../../tag/props.js';
import '../../tag/check-tag.js';
import '../../tag/check-tag-props.js';
import '../../tag-input/hooks/useHover.js';
import '../../tag-input/hooks/useDragSorter.js';
import '../../select-input/useOverlayInnerStyle.js';
import '../../select/props.js';
import '../../select/select-panel.js';
import 'lodash/omit';
import '../../select/option.js';
import '../../checkbox/index.js';
import '../../checkbox/checkbox.js';
import '../../checkbox/props.js';
import '../../checkbox/constants.js';
import '../../checkbox/group.js';
import '../../hooks/slot.js';
import '../../checkbox/checkbox-group-props.js';
import '../../select/option-props.js';
import '../../select/helper.js';
import '../../select/optionGroup.js';
import '../../select/option-group-props.js';
import '../../select/hooks/usePanelVirtualScroll.js';
import '../../hooks/useVirtualScroll.js';
import '../../select/hooks/useSelectOptions.js';
import '../../input-adornment/index.js';
import '../../input-adornment/input-adornment.js';
import '../../input-adornment/props.js';
import '../../pagination/props.js';
import '../../pagination/usePaginationClasses.js';
import '../../pagination/useMoreAction.js';
import '../../pagination/pagination-mini.js';
import '../../pagination/pagination-mini-props.js';
import '../base/Table.js';
import '../base/Cell.js';
import '../../time-picker/panel/time-picker-panel.js';
import '../../_common/js/time-picker/const.js';
import '../../time-picker/panel/props.js';
import 'lodash/isBoolean';
import '../../time-picker/props.js';
import '../../time-picker/panel/single-panel.js';
import 'lodash/range';
import 'lodash/padStart';
import '../../_common/js/time-picker/utils.js';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var TRangePanel = defineComponent({
  name: "TRangePanel",
  props: {
    hoverValue: Array,
    activeIndex: Number,
    isFirstValueSelected: Boolean,
    disableDate: [Object, Array, Function],
    mode: {
      type: String,
      "default": "date"
    },
    format: String,
    presetsPlacement: {
      type: String,
      "default": "bottom"
    },
    value: Array,
    timePickerProps: Object,
    presets: Object,
    popupVisible: Boolean,
    enableTimePicker: Boolean,
    panelPreselection: Boolean,
    firstDayOfWeek: Number,
    year: Array,
    month: Array,
    time: Array,
    onClick: Function,
    onCellClick: Function,
    onCellMouseEnter: Function,
    onCellMouseLeave: Function,
    onJumperClick: Function,
    onConfirmClick: Function,
    onPresetClick: Function,
    onYearChange: Function,
    onMonthChange: Function,
    onTimePickerChange: Function
  },
  setup: function setup(props) {
    var COMPONENT_NAME = usePrefixClass("date-range-picker__panel");
    var _useConfig = useConfig("datePicker"),
      globalConfig = _useConfig.globalConfig;
    var _getDefaultFormat = getDefaultFormat({
        mode: props.mode,
        format: props.format,
        enableTimePicker: props.enableTimePicker
      }),
      format = _getDefaultFormat.format;
    var hidePreselection = !props.panelPreselection && props.value.length === 2;
    var disableDateOptions = computed(function () {
      return useDisableDate({
        format: format,
        mode: props.mode,
        disableDate: props.disableDate,
        start: props.isFirstValueSelected && props.activeIndex === 1 ? new Date(parseToDayjs(props.value[0], format, "start").toDate().setHours(0, 0, 0)) : void 0,
        end: props.isFirstValueSelected && props.activeIndex === 0 ? new Date(parseToDayjs(props.value[1], format).toDate().setHours(23, 59, 59)) : void 0
      });
    });
    var startTableData = computed(function () {
      return useTableData(_objectSpread({
        isRange: true,
        start: props.value[0] ? parseToDayjs(props.value[0], format).toDate() : void 0,
        end: props.value[1] ? parseToDayjs(props.value[1], format).toDate() : void 0,
        hoverStart: !hidePreselection && props.hoverValue[0] ? parseToDayjs(props.hoverValue[0], format).toDate() : void 0,
        hoverEnd: !hidePreselection && props.hoverValue[1] ? parseToDayjs(props.hoverValue[1], format).toDate() : void 0,
        year: props.year[0],
        month: props.month[0],
        mode: props.mode,
        firstDayOfWeek: props.firstDayOfWeek || globalConfig.value.firstDayOfWeek
      }, disableDateOptions.value));
    });
    var endTableData = computed(function () {
      return useTableData(_objectSpread({
        isRange: true,
        start: props.value[0] ? parseToDayjs(props.value[0], format).toDate() : void 0,
        end: props.value[1] ? parseToDayjs(props.value[1], format).toDate() : void 0,
        hoverStart: !hidePreselection && props.hoverValue[0] ? parseToDayjs(props.hoverValue[0], format).toDate() : void 0,
        hoverEnd: !hidePreselection && props.hoverValue[1] ? parseToDayjs(props.hoverValue[1], format).toDate() : void 0,
        year: props.year[1],
        month: props.month[1],
        mode: props.mode,
        firstDayOfWeek: props.firstDayOfWeek || globalConfig.value.firstDayOfWeek
      }, disableDateOptions.value));
    });
    var panelContentProps = computed(function () {
      return {
        format: format,
        mode: props.mode,
        firstDayOfWeek: props.firstDayOfWeek || globalConfig.value.firstDayOfWeek,
        popupVisible: props.popupVisible,
        enableTimePicker: props.enableTimePicker,
        timePickerProps: props.timePickerProps,
        onMonthChange: props.onMonthChange,
        onYearChange: props.onYearChange,
        onJumperClick: props.onJumperClick,
        onCellClick: props.onCellClick,
        onCellMouseEnter: props.onCellMouseEnter,
        onCellMouseLeave: props.onCellMouseLeave,
        onTimePickerChange: props.onTimePickerChange
      };
    });
    return function () {
      return createVNode("div", {
        "class": [COMPONENT_NAME.value, _defineProperty({}, "".concat(COMPONENT_NAME.value, "--direction-row"), ["left", "right"].includes(props.presetsPlacement))],
        "onClick": function onClick(e) {
          var _props$onClick;
          return (_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props, {
            e: e
          });
        }
      }, [["top", "left"].includes(props.presetsPlacement) ? createVNode(TExtraContent, {
        "presets": props.presets,
        "selectedValue": props.value[props.activeIndex],
        "enableTimePicker": props.enableTimePicker,
        "onPresetClick": props.onPresetClick,
        "onConfirmClick": props.onConfirmClick,
        "presetsPlacement": props.presetsPlacement
      }, null) : null, createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "-content-wrapper")
      }, [!props.enableTimePicker ? [createVNode(TPanelContent, mergeProps({
        "key": "startPanel",
        "partial": "start",
        "year": props.year[0],
        "month": props.month[0],
        "time": props.time[0],
        "value": props.value,
        "tableData": startTableData.value
      }, panelContentProps.value), null), createVNode(TPanelContent, mergeProps({
        "key": "endPanel",
        "partial": "end",
        "year": props.year[1],
        "month": props.month[1],
        "time": props.time[1],
        "value": props.value,
        "tableData": endTableData.value
      }, panelContentProps.value), null)] : createVNode(TPanelContent, mergeProps({
        "key": "start",
        "partial": props.activeIndex ? "end" : "start",
        "year": props.activeIndex ? props.year[1] : props.year[0],
        "month": props.activeIndex ? props.month[1] : props.month[0],
        "time": props.activeIndex ? props.time[1] : props.time[0],
        "value": props.value,
        "tableData": props.activeIndex ? endTableData.value : startTableData.value
      }, panelContentProps.value), null)]), ["bottom", "right"].includes(props.presetsPlacement) ? createVNode(TExtraContent, {
        "presets": props.presets,
        "selectedValue": props.value[props.activeIndex],
        "enableTimePicker": props.enableTimePicker,
        "onPresetClick": props.onPresetClick,
        "onConfirmClick": props.onConfirmClick,
        "presetsPlacement": props.presetsPlacement
      }, null) : null]);
    };
  }
});

export { TRangePanel as default };
//# sourceMappingURL=RangePanel.js.map
