"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var date_time_picker_exports = {};
__export(date_time_picker_exports, {
  DateTimePicker: () => DateTimePicker
});
module.exports = __toCommonJS(date_time_picker_exports);
var import_jsx_runtime = (
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  // @ts-ignore
  require("react/jsx-runtime")
);
var import_ds_controlled_form = require("@elliemae/ds-controlled-form");
var import_react_hook_form = require("react-hook-form");
const getConfig = (value, onChange) => ({
  "full-date-time": {
    dateTime: value,
    onDateTimeChange: onChange
  },
  "date-time-inputs": {
    dateTime: value,
    onDateTimeChange: onChange
  },
  "date-time-picker": {
    dateTime: value,
    onDateTimeChange: onChange
  },
  "date-time-picker-controller-only": {
    dateTime: value,
    onDateTimeChange: onChange
  },
  "date-inputs": {
    date: value,
    onDateChange: onChange
  },
  "date-picker": {
    date: value,
    onDateChange: onChange
  },
  "date-picker-controller-only": {
    date: value,
    onDateChange: onChange
  },
  "full-date": {
    date: value,
    onDateChange: onChange
  },
  "full-time": {
    time: value,
    onTimeChange: onChange
  },
  "time-inputs": {
    time: value,
    onTimeChange: onChange
  },
  "time-picker-controller-only": {
    time: value,
    onTimeChange: onChange
  },
  "time-picker": {
    time: value,
    onTimeChange: onChange
  }
});
const DateTimePicker = ({
  name,
  defaultValue = "",
  rules = {},
  type = "full-date-time",
  ...rest
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
  import_react_hook_form.Controller,
  {
    name,
    defaultValue,
    rules,
    render: ({
      field: { value, onChange, ...restProps },
      fieldState: { error }
    }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
      import_ds_controlled_form.DSControlledDateTimePicker,
      {
        hasError: !!error,
        ...restProps,
        type,
        ...getConfig(value, onChange)[type],
        ...rest
      }
    )
  }
);
