import * as r from "react";
import b from "../../../classnames/index.mjs";
import { Checkbox as k } from "../../../rc-checkbox/es/index.mjs";
import { composeRef as D } from "../../../rc-util/es/ref.mjs";
import { devUseWarning as M } from "../_util/warning.mjs";
import G from "../_util/wave/index.mjs";
import { TARGET_CLS as L } from "../_util/wave/interface.mjs";
import "../config-provider/index.mjs";
import F from "../config-provider/DisabledContext.mjs";
import { FormItemInputContext as W } from "../form/context.mjs";
import z, { RadioOptionTypeContext as A } from "./context.mjs";
import B from "./style/index.mjs";
import U from "../config-provider/hooks/useCSSVarCls.mjs";
import { ConfigContext as q } from "../config-provider/context.mjs";
var H = globalThis && globalThis.__rest || function(o, l) {
  var a = {};
  for (var t in o)
    Object.prototype.hasOwnProperty.call(o, t) && l.indexOf(t) < 0 && (a[t] = o[t]);
  if (o != null && typeof Object.getOwnPropertySymbols == "function")
    for (var e = 0, t = Object.getOwnPropertySymbols(o); e < t.length; e++)
      l.indexOf(t[e]) < 0 && Object.prototype.propertyIsEnumerable.call(o, t[e]) && (a[t[e]] = o[t[e]]);
  return a;
};
const J = (o, l) => {
  var a, t;
  const e = r.useContext(z), x = r.useContext(A), {
    getPrefixCls: y,
    direction: g,
    radio: s
  } = r.useContext(q), O = r.useRef(null), h = D(l, O), {
    isFormItemInput: N
  } = r.useContext(W);
  if (process.env.NODE_ENV !== "production") {
    const c = M("Radio");
    process.env.NODE_ENV !== "production" && c(!("optionType" in o), "usage", "`optionType` is only support in Radio.Group.");
  }
  const R = (c) => {
    var p, m;
    (p = o.onChange) === null || p === void 0 || p.call(o, c), (m = e == null ? void 0 : e.onChange) === null || m === void 0 || m.call(e, c);
  }, {
    prefixCls: E,
    className: w,
    rootClassName: _,
    children: u,
    style: T
  } = o, S = H(o, ["prefixCls", "className", "rootClassName", "children", "style"]), d = y("radio", E), f = ((e == null ? void 0 : e.optionType) || x) === "button", i = f ? `${d}-button` : d, C = U(d), [j, I, P] = B(d, C), n = Object.assign({}, S), $ = r.useContext(F);
  e && (n.name = e.name, n.onChange = R, n.checked = o.value === e.value, n.disabled = (a = n.disabled) !== null && a !== void 0 ? a : e.disabled), n.disabled = (t = n.disabled) !== null && t !== void 0 ? t : $;
  const V = b(`${i}-wrapper`, {
    [`${i}-wrapper-checked`]: n.checked,
    [`${i}-wrapper-disabled`]: n.disabled,
    [`${i}-wrapper-rtl`]: g === "rtl",
    [`${i}-wrapper-in-form-item`]: N
  }, s == null ? void 0 : s.className, w, _, I, P, C);
  return j(/* @__PURE__ */ r.createElement(G, {
    component: "Radio",
    disabled: n.disabled
  }, /* @__PURE__ */ r.createElement("label", {
    className: V,
    style: Object.assign(Object.assign({}, s == null ? void 0 : s.style), T),
    onMouseEnter: o.onMouseEnter,
    onMouseLeave: o.onMouseLeave
  }, /* @__PURE__ */ r.createElement(k, Object.assign({}, n, {
    className: b(n.className, !f && L),
    type: "radio",
    prefixCls: i,
    ref: h
  })), u !== void 0 ? /* @__PURE__ */ r.createElement("span", null, u) : null)));
}, v = /* @__PURE__ */ r.forwardRef(J);
process.env.NODE_ENV !== "production" && (v.displayName = "Radio");
const le = v;
export {
  le as default
};
