import { jsx } from "react/jsx-runtime";
import { ErrorMessage } from "@hookform/error-message";
import { useFormContext, Controller } from "react-hook-form";
/* empty css                                                                                                                                                                                       */
/* empty css                                                                                                                                                                                        */
/* empty css                                                                                                                                                                                                */
/* empty css                                                                                                                                                                                           */
/* empty css                                                                                                                                                                                           */
import { DatePickerInput } from "../../node_modules/.pnpm/@mantine_dates@7.15.2_@mantine_core@7.15.2_patch_hash_jclkxeaefn6uz54h34k3r3yjsq_@mantine_hoo_pt67admfm6wboa3vchveewq6zq/node_modules/@mantine/dates/esm/components/DatePickerInput/DatePickerInput.mjs";
const FormDatePicker = ({ name, rules, onChange, ...rest }) => {
  const { control, formState, getFieldState } = useFormContext();
  const { error } = getFieldState(name, formState);
  return /* @__PURE__ */ jsx(
    Controller,
    {
      control,
      name,
      rules,
      render: ({ field }) => {
        const { onChange: handleChange, ...restField } = field;
        return /* @__PURE__ */ jsx(
          DatePickerInput,
          {
            onChange: (e) => {
              handleChange(e);
              onChange == null ? void 0 : onChange(e);
            },
            error: error ? /* @__PURE__ */ jsx(ErrorMessage, { errors: formState.errors, name }) : void 0,
            ...restField,
            ...rest
          }
        );
      }
    }
  );
};
export {
  FormDatePicker
};
