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

import { defineComponent, computed } from '@vue/composition-api';
import { g as getDefaultFormat, p as parseToDayjs } from '../../../_chunks/dep-c3901797.js';
import { usePrefixClass } from '../../../hooks/use-config.js';
import useTableData from '../hooks/use-table-data.js';
import useDisableDate from '../hooks/use-disabled-date.js';
import TExtraContent from './extra-content.js';
import TPanelContent from './panel-content.js';
import { useConfig } from '../../config-provider/useConfig.js';
import '../../../_chunks/dep-f38f4c93.js';
import '../../../_chunks/dep-5210251b.js';
import '../../../_chunks/dep-70c789e5.js';
import '../../../_chunks/dep-68f38014.js';
import '../../../_chunks/dep-eb467ddf.js';
import '../../../_chunks/dep-b31eb7d9.js';
import '../../../_chunks/dep-fe18d4b0.js';
import '../../../_chunks/dep-24cf4e98.js';
import '../../../_chunks/dep-22504add.js';
import '../../config-provider/context.js';
import 'lodash';
import '../../../_chunks/dep-def4c2ce.js';
import 'dayjs';
import '../../../_chunks/dep-74554e14.js';
import 'lodash/isObject';
import '../base/Footer.js';
import '../../button/index.js';
import '../../../utils/with-install.js';
import 'vue';
import '../../../config.js';
import '../../button/button.js';
import '@ldesign/icons-vue';
import '../../loading/index.js';
import '../../loading/loading.js';
import '../../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../../utils/easing.js';
import '../../../utils/render-node.js';
import '../../../utils/transfer-dom.js';
import '../../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../../../utils/mixins.js';
import '../../loading/props.js';
import '../../loading/icon/gradient.js';
import '../../../_chunks/dep-cf772670.js';
import '../../../_chunks/dep-47d77fc8.js';
import '../../loading/plugin.js';
import '../../../utils/ripple.js';
import '../../button/props.js';
import '../../../_chunks/dep-29915b8e.js';
import '../base/Header.js';
import '../../jumper/jumper.js';
import '../../../hooks/use-global-icon.js';
import '../../jumper/props.js';
import '../../select/select.js';
import 'lodash/isFunction';
import 'lodash/debounce';
import 'lodash/get';
import 'lodash/cloneDeep';
import 'lodash/isArray';
import '../../../hooks/use-default-value.js';
import '../../../hooks/use-vmodel.js';
import 'lodash/kebabCase';
import '../../../hooks/lnode.js';
import 'lodash/isEmpty';
import 'lodash/camelCase';
import '../../../hooks/render-lnode.js';
import '../../popup/index.js';
import '../../../utils/map-props.js';
import '../../popup/popup.js';
import '@popperjs/core';
import '../../../utils/helper.js';
import '../../popup/props.js';
import '../../popup/container.js';
import '../../input/index.js';
import '../../input/input.js';
import '../../../utils/event.js';
import '../../input/props.js';
import '../../input/group.js';
import '../../tag/index.js';
import '../../tag/tag.js';
import '../../tag/props.js';
import '../../tag/check-tag.js';
import '../../select-input/index.js';
import '../../select-input/select-input.js';
import '../../select-input/props.js';
import '../../select-input/hooks/use-single.js';
import 'lodash/pick';
import '../../select-input/hooks/use-multiple.js';
import '../../tag-input/index.js';
import '../../tag-input/tag-input.js';
import '../../tag-input/props.js';
import '../../tag-input/hooks/use-tag-scroll.js';
import '../../tag-input/hooks/use-tag-list.js';
import '../../tag-input/hooks/use-hover.js';
import '../../tag-input/hooks/use-drag-sorter.js';
import '../../select-input/hooks/use-overlay-innerstyle.js';
import '../../common/fake-arrow.js';
import '../../../hooks/use-form-disabled.js';
import '../../select/option.js';
import '../../checkbox/index.js';
import '../../checkbox/group.js';
import 'lodash/intersection';
import '../../checkbox/checkbox.js';
import '../../checkbox/props.js';
import '../../../hooks/use-lazy-load.js';
import '../../../_chunks/dep-356f585c.js';
import '../../../hooks/use-common-classname.js';
import '../../select/utils.js';
import '../../select/props.js';
import '../../select/select-panel.js';
import '../../../hooks/use-virtual-scroll.js';
import '../../select/hooks/use-select-options.js';
import '../base/Table.js';
import '../base/Cell.js';
import '../../time-picker/panel/time-picker-panel.js';
import '../../../_chunks/dep-2af9ce5e.js';
import 'lodash/range';
import 'lodash/padStart';
import '../../time-picker/panel/props.js';
import '../../time-picker/props.js';

var TRangePanel = defineComponent({
  name: "LRangePanel",
  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,
    enableTimePicker: Boolean,
    firstDayOfWeek: Number,
    panelPreselection: Boolean,
    hidePreselection: {
      type: Boolean,
      defaultValue: true
    },
    popupVisible: Boolean,
    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(props) {
    const COMPONENT_NAME = usePrefixClass("date-range-picker__panel");
    const {
      global
    } = useConfig("datePicker");
    const {
      format
    } = getDefaultFormat({
      mode: props.mode,
      format: props.format,
      enableTimePicker: props.enableTimePicker
    });
    const hidePreselection = !props.panelPreselection && props.value.length === 2;
    const disableDateOptions = useDisableDate({
      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
    });
    const startTableData = computed(() => useTableData({
      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 || global.value.firstDayOfWeek,
      ...disableDateOptions
    }));
    const endTableData = computed(() => useTableData({
      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 || global.value.firstDayOfWeek,
      ...disableDateOptions
    }));
    const panelContentProps = computed(() => ({
      format,
      mode: props.mode,
      firstDayOfWeek: props.firstDayOfWeek || global.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 {
      COMPONENT_NAME,
      startTableData,
      endTableData,
      panelContentProps
    };
  },
  render() {
    const h = arguments[0];
    const {
      COMPONENT_NAME,
      startTableData,
      endTableData,
      panelContentProps
    } = this;
    return h("div", {
      "class": [COMPONENT_NAME, {
        [`${COMPONENT_NAME}--direction-row`]: ["left", "right"].includes(this.presetsPlacement)
      }],
      "on": {
        "click": e => {
          var _this$onClick;
          return (_this$onClick = this.onClick) === null || _this$onClick === void 0 ? void 0 : _this$onClick.call(this, {
            e
          });
        }
      }
    }, [["top", "left"].includes(this.presetsPlacement) ? h(TExtraContent, {
      "props": {
        ...{
          presets: this.presets,
          selectedValue: this.value[this.activeIndex],
          enableTimePicker: this.enableTimePicker,
          onPresetClick: this.onPresetClick,
          onConfirmClick: this.onConfirmClick,
          presetsPlacement: this.presetsPlacement
        }
      }
    }) : null, h("div", {
      "class": `${COMPONENT_NAME}-content-wrapper`
    }, [!this.enableTimePicker ? [h(TPanelContent, {
      "key": "startPanel",
      "props": {
        ...{
          partial: "start",
          year: this.year[0],
          month: this.month[0],
          time: this.time[0],
          value: this.value,
          tableData: startTableData,
          ...panelContentProps
        }
      }
    }), h(TPanelContent, {
      "key": "endPanel",
      "props": {
        ...{
          partial: "end",
          year: this.year[1],
          month: this.month[1],
          time: this.time[1],
          value: this.value,
          tableData: endTableData,
          ...panelContentProps
        }
      }
    })] : h(TPanelContent, {
      "key": "start",
      "props": {
        ...{
          partial: this.activeIndex ? "end" : "start",
          year: this.activeIndex ? this.year[1] : this.year[0],
          month: this.activeIndex ? this.month[1] : this.month[0],
          time: this.activeIndex ? this.time[1] : this.time[0],
          value: this.value,
          tableData: this.activeIndex ? endTableData : startTableData,
          ...panelContentProps
        }
      }
    })]), ["bottom", "right"].includes(this.presetsPlacement) ? h(TExtraContent, {
      "props": {
        ...{
          presets: this.presets,
          selectedValue: this.value[this.activeIndex],
          enableTimePicker: this.enableTimePicker,
          onPresetClick: this.onPresetClick,
          onConfirmClick: this.onConfirmClick,
          presetsPlacement: this.presetsPlacement
        }
      }
    }) : null]);
  }
});

export { TRangePanel as default };
//# sourceMappingURL=range-panel.js.map
