import { defineComponent, useModel, computed, resolveComponent, createBlock, openBlock, withCtx, createVNode, mergeProps, toHandlers, unref, mergeModels } from 'vue';
import '../../../../../../utils/index.mjs';
import '../../../../base/datePicker/index.mjs';
import { useWatchModelChange } from '../../composables/useWatchModelChange.mjs';
import { searchFormDatePickerEmits, searchFormDatePickerProps, SearchFormDatePickerName } from './searchFormDatePicker.mjs';
import { getGmEvent } from '../../../../../../utils/src/elementPlus/event.mjs';
import { datePickerEmits } from '../../../../base/datePicker/datePicker.mjs';
import { getDateShortcuts } from '../../../../../../utils/src/date/dateShortcuts.mjs';

var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{
    name: SearchFormDatePickerName
  },
  __name: "SearchFormDatePicker",
  props: /* @__PURE__ */ mergeModels(searchFormDatePickerProps, {
    "modelValue": {},
    "modelModifiers": {}
  }),
  emits: /* @__PURE__ */ mergeModels(searchFormDatePickerEmits, ["update:modelValue"]),
  setup(__props, { emit: __emit }) {
    const modelValue = useModel(__props, "modelValue");
    const props = __props;
    const emit = __emit;
    const datePickerEvents = getGmEvent(datePickerEmits, emit);
    useWatchModelChange(modelValue, { prop: props.prop, noDefaultSync: props.noDefaultSync });
    const shortcutList = computed(() => Array.isArray(props.shortcuts) ? props.shortcuts : getDateShortcuts(props.type));
    const valueFormat = computed(() => props.valueFormat ?? (props.type === "datetimerange" ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD"));
    const defaultTime = computed(
      () => props.defaultTime ?? (props.type === "datetimerange" ? [new Date(2e3, 0, 1, 0, 0, 0), new Date(2e3, 0, 1, 23, 59, 59)] : void 0)
    );
    return (_ctx, _cache) => {
      const _component_gm_date_picker = resolveComponent("gm-date-picker");
      const _component_gm_form_item = resolveComponent("gm-form-item");
      return openBlock(), createBlock(_component_gm_form_item, { prop: _ctx.prop }, {
        default: withCtx(() => [
          createVNode(_component_gm_date_picker, mergeProps({
            modelValue: modelValue.value,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modelValue.value = $event),
            type: _ctx.type,
            "range-separator": "-",
            "value-format": valueFormat.value,
            clearable: "",
            disabled: _ctx.disabled,
            placeholder: _ctx.label,
            "start-placeholder": _ctx.startPlaceholder ?? `${_ctx.label}\u5F00\u59CB\u65E5\u671F`,
            "end-placeholder": _ctx.endPlaceholder ?? `${_ctx.label}\u7ED3\u675F\u65E5\u671F`,
            style: {
              "--el-date-editor-width": "100%"
            },
            shortcuts: shortcutList.value,
            defaultValue: _ctx.defaultValue,
            defaultTime: defaultTime.value
          }, toHandlers(unref(datePickerEvents))), null, 16, ["modelValue", "type", "value-format", "disabled", "placeholder", "start-placeholder", "end-placeholder", "shortcuts", "defaultValue", "defaultTime"])
        ]),
        _: 1
        /* STABLE */
      }, 8, ["prop"]);
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=SearchFormDatePicker.vue2.mjs.map
