import { _ as C, O as S, t as T } from "./PrizeCard-C2El3VOB.js";
import * as u from "react";
import { F as j } from "./CheckCircle-DSloUas8.js";
import { d as K, f as M } from "./Button-DPGn5NZd.js";
const L = /* @__PURE__ */ u.createContext(void 0);
process.env.NODE_ENV !== "production" && (L.displayName = "FormControlContext");
function $() {
  return u.useContext(L);
}
function W(i = {}) {
  const {
    defaultValue: s,
    disabled: g = !1,
    error: a = !1,
    onBlur: c,
    onChange: N,
    onFocus: R,
    required: w = !1,
    value: B,
    inputRef: F
  } = i, o = $();
  let m, t, p, f, d;
  if (o) {
    var y, E, P;
    if (m = void 0, t = (y = o.disabled) != null ? y : !1, p = (E = o.error) != null ? E : !1, f = (P = o.required) != null ? P : !1, d = o.value, process.env.NODE_ENV !== "production") {
      const e = ["defaultValue", "disabled", "error", "required", "value"].filter((r) => i[r] !== void 0);
      e.length > 0 && console.warn(["MUI: You have set props on an input that is inside a FormControl.", "Set these props on a FormControl instead. Otherwise they will be ignored.", `Ignored props: ${e.join(", ")}`].join(`
`));
    }
  } else
    m = s, t = g, p = a, f = w, d = B;
  const {
    current: V
  } = u.useRef(d != null), x = u.useCallback((e) => {
    process.env.NODE_ENV !== "production" && e && e.nodeName !== "INPUT" && !e.focus && console.error(["MUI: You have provided a `slots.input` to the input component", "that does not correctly handle the `ref` prop.", "Make sure the `ref` prop is called with a HTMLInputElement."].join(`
`));
  }, []), b = u.useRef(null), I = K(b, F, x), [v, h] = u.useState(!1);
  u.useEffect(() => {
    !o && t && v && (h(!1), c == null || c());
  }, [o, t, v, c]);
  const _ = (e) => (r) => {
    var n;
    if (o != null && o.disabled) {
      r.stopPropagation();
      return;
    }
    if ((n = e.onFocus) == null || n.call(e, r), o && o.onFocus) {
      var l;
      o == null || (l = o.onFocus) == null || l.call(o);
    } else
      h(!0);
  }, q = (e) => (r) => {
    var n;
    (n = e.onBlur) == null || n.call(e, r), o && o.onBlur ? o.onBlur() : h(!1);
  }, k = (e) => (r, ...n) => {
    var l, O;
    if (!V && (r.target || b.current) == null)
      throw new Error(process.env.NODE_ENV !== "production" ? "MUI: Expected valid input target. Did you use a custom `slots.input` and forget to forward refs? See https://mui.com/r/input-component-ref-interface for more info." : S(17));
    o == null || (l = o.onChange) == null || l.call(o, r), (O = e.onChange) == null || O.call(e, r, ...n);
  }, D = (e) => (r) => {
    var n;
    b.current && r.currentTarget === r.target && b.current.focus(), (n = e.onClick) == null || n.call(e, r);
  };
  return {
    disabled: t,
    error: p,
    focused: v,
    formControlContext: o,
    getInputProps: (e = {}) => {
      const n = C({}, {
        onBlur: c,
        onChange: N,
        onFocus: R
      }, M(e)), l = C({}, n, {
        onBlur: q(n),
        onChange: k(n),
        onFocus: _(n)
      });
      return C({}, l, {
        "aria-invalid": p || void 0,
        defaultValue: m,
        value: d,
        required: f,
        disabled: t
      }, e, {
        ref: I
      }, l);
    },
    getRootProps: (e = {}) => {
      const r = M(i, ["onBlur", "onChange", "onFocus"]), n = C({}, r, M(e));
      return C({}, e, n, {
        onClick: D(n)
      });
    },
    inputRef: I,
    required: f,
    value: d
  };
}
const Y = ["aria-describedby", "aria-label", "aria-labelledby", "autoComplete", "autoFocus", "className", "defaultValue", "disabled", "disabledInProp", "error", "id", "name", "onClick", "onChange", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "placeholder", "readOnly", "required", "type", "value"];
function Q(i, s) {
  var g;
  const a = u.useContext(j), {
    "aria-describedby": c,
    "aria-label": N,
    "aria-labelledby": R,
    autoComplete: w,
    autoFocus: B,
    className: F,
    defaultValue: o,
    disabled: m,
    disabledInProp: t,
    error: p,
    id: f,
    name: d,
    onClick: y,
    onChange: E,
    onKeyDown: P,
    onKeyUp: V,
    onFocus: x,
    onBlur: b,
    placeholder: I,
    readOnly: v,
    required: h,
    type: _,
    value: q
  } = i, k = T(i, Y), {
    getRootProps: D,
    getInputProps: U,
    focused: H,
    error: e,
    disabled: r
  } = W({
    disabled: (g = t ?? (a == null ? void 0 : a.disabled)) != null ? g : m,
    defaultValue: o,
    error: p,
    onBlur: b,
    onClick: y,
    onChange: E,
    onFocus: x,
    required: h ?? (a == null ? void 0 : a.required),
    value: q
  }), n = {
    [s.disabled]: r,
    [s.error]: e,
    [s.focused]: H,
    [s.formControl]: !!a,
    [F]: F
  }, l = {
    [s.disabled]: r
  };
  return C({
    formControl: a,
    propsToForward: {
      "aria-describedby": c,
      "aria-label": N,
      "aria-labelledby": R,
      autoComplete: w,
      autoFocus: B,
      disabled: r,
      id: f,
      onKeyDown: P,
      onKeyUp: V,
      name: d,
      placeholder: I,
      readOnly: v,
      type: _
    },
    rootStateClasses: n,
    inputStateClasses: l,
    getRootProps: D,
    getInputProps: U,
    focused: H,
    error: e,
    disabled: r
  }, k);
}
export {
  Q as u
};
