import { jsx as m } from "react/jsx-runtime";
import f, { useContext as d, createContext as i } from "react";
import { Slot as F } from "@radix-ui/react-slot";
import { useFormContext as u, useFormState as I, Controller as p } from "react-hook-form";
import { c as C } from "./index-BtlgVD4m.js";
const x = () => {
  const e = d(c), o = d(l), { getFieldState: t, control: r } = u(), s = I({ control: r, name: e.name }), n = t(e.name, s), { id: a } = o;
  return {
    id: a,
    name: e.name,
    formItemId: `${a}-form-item`,
    formDescriptionId: `${a}-form-item-description`,
    formMessageId: `${a}-form-item-message`,
    ...n
  };
}, D = i({ disabled: !1 }), c = i({}), v = ({
  ...e
}) => /* @__PURE__ */ m(c.Provider, { value: { name: e.name }, children: /* @__PURE__ */ m(p, { ...e }) });
v.displayName = "FormField";
const l = i({}), S = ({ ref: e, className: o, ...t }) => {
  const r = f.useId();
  return /* @__PURE__ */ m(l.Provider, { value: { id: r }, children: /* @__PURE__ */ m("div", { ref: e, className: C("space-y-2", o), ...t }) });
};
S.displayName = "FormItem";
const $ = ({ ref: e, ...o }) => {
  const { error: t, formItemId: r, formDescriptionId: s, formMessageId: n } = x();
  return /* @__PURE__ */ m(
    F,
    {
      ref: e,
      id: r,
      "aria-describedby": t ? `${s} ${n}` : `${s}`,
      "aria-invalid": !!t,
      ...o
    }
  );
};
$.displayName = "FormControl";
export {
  v as F,
  S as a,
  D as b,
  l as c,
  $ as d,
  c as e,
  x as u
};
//# sourceMappingURL=FormPrimitives-CuaI5fdh.js.map
