'use strict';

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

var vue = require('vue');
var elementPlus = require('element-plus');
var dayjs = require('dayjs');

"use strict";
const _hoisted_1 = { class: "me-input-range-date" };
const _hoisted_2 = { style: { "width": "20px", "margin": "0 10px", "text-align": "center" } };
const __default__ = vue.defineComponent({
  name: "me-input-range-date"
});
var script = /* @__PURE__ */ vue.defineComponent({
  ...__default__,
  props: /* @__PURE__ */ vue.mergeModels({
    connector: { type: String, required: false, default: "-" },
    disabledData: { type: Boolean, required: false, default: false },
    disabledStartDateFn: { type: Function, required: false },
    disabledEndDateFn: { type: Function, required: false }
  }, {
    "start": {},
    "startModifiers": {},
    "end": {},
    "endModifiers": {}
  }),
  emits: ["update:start", "update:end"],
  setup(__props) {
    const props = __props;
    const start = vue.useModel(__props, "start");
    const end = vue.useModel(__props, "end");
    const disabledStartDate = (time) => {
      if (props.disabledStartDateFn) {
        return props.disabledStartDateFn(time);
      }
      if (!props.disabledData) {
        if (end.value) {
          if (time.getTime() <= dayjs(end.value).valueOf()) {
            return false;
          } else {
            return true;
          }
        }
        return;
      }
      if (end.value) {
        if (time.getTime() >= Date.now() - 3600 * 1e3 * 24 && time.getTime() <= dayjs(end.value).valueOf()) {
          return false;
        } else {
          return true;
        }
      }
      return time.getTime() < Date.now() - 3600 * 1e3 * 24;
    };
    const disabledEndDate = (time) => {
      if (props.disabledEndDateFn) return props.disabledEndDateFn(time);
      if (!props.disabledData) {
        if (start.value) return time.getTime() < dayjs(start.value).valueOf();
        return true;
      }
      if (end.value) return time.getTime() < dayjs(start.value).valueOf();
      return time.getTime() < Date.now() - 3600 * 1e3 * 24;
    };
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
        vue.createVNode(vue.unref(elementPlus.ElDatePicker), vue.mergeProps({
          "disabled-date": disabledStartDate,
          modelValue: start.value,
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => start.value = $event),
          type: "date",
          placeholder: "\u5F00\u59CB\u65F6\u95F4"
        }, _ctx.$attrs), null, 16, ["modelValue"]),
        vue.renderSlot(_ctx.$slots, "connector", {}, () => [
          vue.createElementVNode(
            "span",
            _hoisted_2,
            vue.toDisplayString(__props.connector),
            1
            /* TEXT */
          )
        ]),
        vue.createVNode(vue.unref(elementPlus.ElDatePicker), vue.mergeProps({
          "disabled-date": disabledEndDate,
          modelValue: end.value,
          "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => end.value = $event),
          type: "date",
          placeholder: "\u7ED3\u675F\u65F6\u95F4"
        }, _ctx.$attrs), null, 16, ["modelValue"])
      ]);
    };
  }
});

exports.default = script;
//# sourceMappingURL=input-range-date.vue2.js.map
