import { defineComponent, ref, createVNode, mergeProps } from 'vue';
import generatePicker from '../date-picker/generatePicker/index.mjs';
import { commonProps, datePickerProps, rangePickerProps } from '../date-picker/generatePicker/props.mjs';
import devWarning from '../vc-util/devWarning.mjs';
import { useInjectFormItemContext } from '../form/FormItemContext.mjs';
import omit from '../_util/omit.mjs';
import { booleanType, stringType } from '../_util/type.mjs';

const timePickerProps = () => ({
  format: String,
  showNow: booleanType(),
  showHour: booleanType(),
  showMinute: booleanType(),
  showSecond: booleanType(),
  use12Hours: booleanType(),
  hourStep: Number,
  minuteStep: Number,
  secondStep: Number,
  hideDisabledOptions: booleanType(),
  popupClassName: String,
  status: stringType()
});
function createTimePicker(generateConfig) {
  const DatePicker = generatePicker(generateConfig, {
    ...timePickerProps(),
    order: {
      type: Boolean,
      default: true
    }
  });
  const {
    TimePicker: InternalTimePicker,
    RangePicker: InternalRangePicker
  } = DatePicker;
  const TimePicker = /* @__PURE__ */ defineComponent({
    name: "ATimePicker",
    inheritAttrs: false,
    props: {
      ...commonProps(),
      ...datePickerProps(),
      ...timePickerProps(),
      addon: {
        type: Function
      }
    },
    slots: Object,
    setup(p, {
      slots,
      expose,
      emit,
      attrs
    }) {
      const props = p;
      const formItemContext = useInjectFormItemContext();
      devWarning(!(slots.addon || props.addon), "TimePicker", "`addon` is deprecated. Please use `v-slot:renderExtraFooter` instead.");
      const pickerRef = ref();
      expose({
        focus: () => {
          var _a;
          (_a = pickerRef.value) == null ? void 0 : _a.focus();
        },
        blur: () => {
          var _a;
          (_a = pickerRef.value) == null ? void 0 : _a.blur();
        }
      });
      const onChange = (value, dateString) => {
        emit("update:value", value);
        emit("change", value, dateString);
        formItemContext.onFieldChange();
      };
      const onOpenChange = (open) => {
        emit("update:open", open);
        emit("openChange", open);
      };
      const onFocus = (e) => {
        emit("focus", e);
      };
      const onBlur = (e) => {
        emit("blur", e);
        formItemContext.onFieldBlur();
      };
      const onOk = (value) => {
        emit("ok", value);
      };
      return () => {
        const {
          id = formItemContext.id.value
        } = props;
        return createVNode(InternalTimePicker, mergeProps(attrs, omit(props, ["onUpdate:value", "onUpdate:open"]), {
          "id": id,
          "dropdownClassName": props.popupClassName,
          "mode": void 0,
          "ref": pickerRef,
          "renderExtraFooter": props.addon || slots.addon || props.renderExtraFooter || slots.renderExtraFooter,
          "onChange": onChange,
          "onOpenChange": onOpenChange,
          "onFocus": onFocus,
          "onBlur": onBlur,
          "onOk": onOk
        }), slots);
      };
    }
  });
  const TimeRangePicker = /* @__PURE__ */ defineComponent({
    name: "ATimeRangePicker",
    inheritAttrs: false,
    props: {
      ...commonProps(),
      ...rangePickerProps(),
      ...timePickerProps(),
      order: {
        type: Boolean,
        default: true
      }
    },
    slots: Object,
    setup(p, {
      slots,
      expose,
      emit,
      attrs
    }) {
      const props = p;
      const pickerRef = ref();
      const formItemContext = useInjectFormItemContext();
      expose({
        focus: () => {
          var _a;
          (_a = pickerRef.value) == null ? void 0 : _a.focus();
        },
        blur: () => {
          var _a;
          (_a = pickerRef.value) == null ? void 0 : _a.blur();
        }
      });
      const onChange = (values, dateStrings) => {
        emit("update:value", values);
        emit("change", values, dateStrings);
        formItemContext.onFieldChange();
      };
      const onOpenChange = (open) => {
        emit("update:open", open);
        emit("openChange", open);
      };
      const onFocus = (e) => {
        emit("focus", e);
      };
      const onBlur = (e) => {
        emit("blur", e);
        formItemContext.onFieldBlur();
      };
      const onPanelChange = (values, modes) => {
        emit("panelChange", values, modes);
      };
      const onOk = (values) => {
        emit("ok", values);
      };
      const onCalendarChange = (values, dateStrings, info) => {
        emit("calendarChange", values, dateStrings, info);
      };
      return () => {
        const {
          id = formItemContext.id.value
        } = props;
        return createVNode(InternalRangePicker, mergeProps(attrs, omit(props, ["onUpdate:open", "onUpdate:value"]), {
          "id": id,
          "dropdownClassName": props.popupClassName,
          "picker": "time",
          "mode": void 0,
          "ref": pickerRef,
          "onChange": onChange,
          "onOpenChange": onOpenChange,
          "onFocus": onFocus,
          "onBlur": onBlur,
          "onPanelChange": onPanelChange,
          "onOk": onOk,
          "onCalendarChange": onCalendarChange
        }), slots);
      };
    }
  });
  return {
    TimePicker,
    TimeRangePicker
  };
}

export { createTimePicker as default, timePickerProps };
//# sourceMappingURL=time-picker.mjs.map
