import { jsx as r } from "react/jsx-runtime";
import { useCallback as f } from "react";
import { b as v } from "../../FormPrimitives-CuaI5fdh.js";
import { c as h } from "../../index-BtlgVD4m.js";
import { FormProvider as y } from "react-hook-form";
const F = ({
  form: a,
  children: s,
  onSubmit: t,
  onError: i,
  disabled: n = !1,
  loading: o = !1,
  className: d,
  id: p,
  noValidate: u = !1,
  ariaLabel: m,
  ariaLabelledBy: b
}) => {
  const e = n || o, c = f(
    (l) => {
      if (l.stopPropagation(), e) {
        l.preventDefault();
        return;
      }
      a == null || a.handleSubmit(t, i)(l);
    },
    [a, t, i, e]
  );
  return a ? /* @__PURE__ */ r(y, { ...a, children: /* @__PURE__ */ r(v.Provider, { value: { disabled: e }, children: /* @__PURE__ */ r(
    "form",
    {
      id: p,
      onSubmit: c,
      noValidate: u,
      "aria-busy": o || void 0,
      "aria-label": m,
      "aria-labelledby": b,
      className: h("w-full", e && "pointer-events-none opacity-50", d),
      "aria-disabled": e || void 0,
      children: s
    }
  ) }) }) : (console.warn("form prop should not be null"), null);
};
F.displayName = "Form";
export {
  F as default
};
//# sourceMappingURL=Form.js.map
