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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var VueCompositionAPI = require('@vue/composition-api');
var format = require('../../../chunks/format.js');
var hooks_useConfig = require('../../../hooks/use-config.js');
var components_datePicker_hooks_useTableData = require('../hooks/use-table-data.js');
var components_datePicker_hooks_useDisabledDate = require('../hooks/use-disabled-date.js');
var components_datePicker_panel_extraContent = require('./extra-content.js');
var components_datePicker_panel_panelContent = require('./panel-content.js');
var components_configProvider_useConfig = require('../../config-provider/useConfig.js');
require('../../../chunks/dayjs.min-c4f4ce86.js');
require('../../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../../chunks/log.js');
require('../../../chunks/utils.js');
require('../../../chunks/defineProperty-838e4192.js');
require('../../../chunks/_isIndex-52887d1e.js');
require('../../../chunks/isFunction-91acade7.js');
require('../../../chunks/isObjectLike-c22c7e3b.js');
require('../../../chunks/isSymbol-a38a5184.js');
require('../../config-provider/context.js');
require('lodash');
require('../../../chunks/zh_CN.js');
require('dayjs');
require('../../../chunks/_commonjsHelpers.js');
require('lodash/isObject');
require('../base/Footer.js');
require('../../button/index.js');
require('../../../utils/with-install.js');
require('vue');
require('../../../config.js');
require('../../button/button.js');
require('@ldesign/icons-vue');
require('../../loading/index.js');
require('../../loading/loading.js');
require('../../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../../utils/easing.js');
require('../../../utils/render-node.js');
require('../../../utils/transfer-dom.js');
require('../../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../../../utils/mixins.js');
require('../../loading/props.js');
require('../../loading/icon/gradient.js');
require('../../../chunks/set-style.js');
require('../../../chunks/helper2.js');
require('../../loading/plugin.js');
require('../../../utils/ripple.js');
require('../../button/props.js');
require('../../../chunks/helper.js');
require('../base/Header.js');
require('../../jumper/jumper.js');
require('../../../hooks/use-global-icon.js');
require('../../jumper/props.js');
require('../../select/select.js');
require('lodash/isFunction');
require('lodash/debounce');
require('lodash/get');
require('lodash/cloneDeep');
require('lodash/isArray');
require('../../../hooks/use-default-value.js');
require('../../../hooks/use-vmodel.js');
require('lodash/kebabCase');
require('../../../hooks/lnode.js');
require('lodash/isEmpty');
require('lodash/camelCase');
require('../../../hooks/render-lnode.js');
require('../../popup/index.js');
require('../../../utils/map-props.js');
require('../../popup/popup.js');
require('@popperjs/core');
require('../../../utils/helper.js');
require('../../popup/props.js');
require('../../popup/container.js');
require('../../input/index.js');
require('../../input/input.js');
require('../../../utils/event.js');
require('../../input/props.js');
require('../../input/group.js');
require('../../tag/index.js');
require('../../tag/tag.js');
require('../../tag/props.js');
require('../../tag/check-tag.js');
require('../../select-input/index.js');
require('../../select-input/select-input.js');
require('../../select-input/props.js');
require('../../select-input/hooks/use-single.js');
require('lodash/pick');
require('../../select-input/hooks/use-multiple.js');
require('../../tag-input/index.js');
require('../../tag-input/tag-input.js');
require('../../tag-input/props.js');
require('../../tag-input/hooks/use-tag-scroll.js');
require('../../tag-input/hooks/use-tag-list.js');
require('../../tag-input/hooks/use-hover.js');
require('../../tag-input/hooks/use-drag-sorter.js');
require('../../select-input/hooks/use-overlay-innerstyle.js');
require('../../common/fake-arrow.js');
require('../../../hooks/use-form-disabled.js');
require('../../select/option.js');
require('../../checkbox/index.js');
require('../../checkbox/group.js');
require('lodash/intersection');
require('../../checkbox/checkbox.js');
require('../../checkbox/props.js');
require('../../../hooks/use-lazy-load.js');
require('../../../chunks/observe.js');
require('../../../hooks/use-common-classname.js');
require('../../select/utils.js');
require('../../select/props.js');
require('../../select/select-panel.js');
require('../../../hooks/use-virtual-scroll.js');
require('../../select/hooks/use-select-options.js');
require('../base/Table.js');
require('../base/Cell.js');
require('../../time-picker/panel/time-picker-panel.js');
require('../../../chunks/single-panel.js');
require('lodash/range');
require('lodash/padStart');
require('../../time-picker/panel/props.js');
require('../../time-picker/props.js');

var TRangePanel = VueCompositionAPI.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 = hooks_useConfig.usePrefixClass("date-range-picker__panel");
    const {
      global
    } = components_configProvider_useConfig.useConfig("datePicker");
    const {
      format: format$1
    } = format.getDefaultFormat({
      mode: props.mode,
      format: props.format,
      enableTimePicker: props.enableTimePicker
    });
    const hidePreselection = !props.panelPreselection && props.value.length === 2;
    const disableDateOptions = components_datePicker_hooks_useDisabledDate["default"]({
      format: format$1,
      mode: props.mode,
      disableDate: props.disableDate,
      start: props.isFirstValueSelected && props.activeIndex === 1 ? new Date(format.parseToDayjs(props.value[0], format$1, "start").toDate().setHours(0, 0, 0)) : void 0,
      end: props.isFirstValueSelected && props.activeIndex === 0 ? new Date(format.parseToDayjs(props.value[1], format$1).toDate().setHours(23, 59, 59)) : void 0
    });
    const startTableData = VueCompositionAPI.computed(() => components_datePicker_hooks_useTableData["default"]({
      isRange: true,
      start: props.value[0] ? format.parseToDayjs(props.value[0], format$1).toDate() : void 0,
      end: props.value[1] ? format.parseToDayjs(props.value[1], format$1).toDate() : void 0,
      hoverStart: !hidePreselection && props.hoverValue[0] ? format.parseToDayjs(props.hoverValue[0], format$1).toDate() : void 0,
      hoverEnd: !hidePreselection && props.hoverValue[1] ? format.parseToDayjs(props.hoverValue[1], format$1).toDate() : void 0,
      year: props.year[0],
      month: props.month[0],
      mode: props.mode,
      firstDayOfWeek: props.firstDayOfWeek || global.value.firstDayOfWeek,
      ...disableDateOptions
    }));
    const endTableData = VueCompositionAPI.computed(() => components_datePicker_hooks_useTableData["default"]({
      isRange: true,
      start: props.value[0] ? format.parseToDayjs(props.value[0], format$1).toDate() : void 0,
      end: props.value[1] ? format.parseToDayjs(props.value[1], format$1).toDate() : void 0,
      hoverStart: !hidePreselection && props.hoverValue[0] ? format.parseToDayjs(props.hoverValue[0], format$1).toDate() : void 0,
      hoverEnd: !hidePreselection && props.hoverValue[1] ? format.parseToDayjs(props.hoverValue[1], format$1).toDate() : void 0,
      year: props.year[1],
      month: props.month[1],
      mode: props.mode,
      firstDayOfWeek: props.firstDayOfWeek || global.value.firstDayOfWeek,
      ...disableDateOptions
    }));
    const panelContentProps = VueCompositionAPI.computed(() => ({
      format: format$1,
      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(components_datePicker_panel_extraContent["default"], {
      "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(components_datePicker_panel_panelContent["default"], {
      "key": "startPanel",
      "props": {
        ...{
          partial: "start",
          year: this.year[0],
          month: this.month[0],
          time: this.time[0],
          value: this.value,
          tableData: startTableData,
          ...panelContentProps
        }
      }
    }), h(components_datePicker_panel_panelContent["default"], {
      "key": "endPanel",
      "props": {
        ...{
          partial: "end",
          year: this.year[1],
          month: this.month[1],
          time: this.time[1],
          value: this.value,
          tableData: endTableData,
          ...panelContentProps
        }
      }
    })] : h(components_datePicker_panel_panelContent["default"], {
      "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(components_datePicker_panel_extraContent["default"], {
      "props": {
        ...{
          presets: this.presets,
          selectedValue: this.value[this.activeIndex],
          enableTimePicker: this.enableTimePicker,
          onPresetClick: this.onPresetClick,
          onConfirmClick: this.onConfirmClick,
          presetsPlacement: this.presetsPlacement
        }
      }
    }) : null]);
  }
});

exports["default"] = TRangePanel;
//# sourceMappingURL=range-panel.js.map
