import * as r from "react";
import B from "../../../classnames/index.mjs";
import F from "../../../rc-util/es/hooks/useMergedState.mjs";
import I from "../../../rc-util/es/pickAttrs.mjs";
import "../config-provider/index.mjs";
import L from "../config-provider/hooks/useSize.mjs";
import { RadioGroupContextProvider as j } from "./context.mjs";
import f from "./radio.mjs";
import A from "./style/index.mjs";
import O from "../config-provider/hooks/useCSSVarCls.mjs";
import { ConfigContext as D } from "../config-provider/context.mjs";
const H = /* @__PURE__ */ r.forwardRef((t, C) => {
  const {
    getPrefixCls: g,
    direction: v
  } = r.useContext(D), [s, y] = F(t.defaultValue, {
    value: t.value
  }), S = (e) => {
    const w = s, c = e.target.value;
    "value" in t || y(c);
    const {
      onChange: m
    } = t;
    m && c !== w && m(e);
  }, {
    prefixCls: x,
    className: b,
    rootClassName: h,
    options: o,
    buttonStyle: R = "outline",
    disabled: i,
    children: $,
    size: z,
    style: E,
    id: V,
    onMouseEnter: k,
    onMouseLeave: M,
    onFocus: N,
    onBlur: P
  } = t, a = g("radio", x), l = `${a}-group`, n = O(a), [p, G, T] = A(a, n);
  let u = $;
  o && o.length > 0 && (u = o.map((e) => typeof e == "string" || typeof e == "number" ? /* @__PURE__ */ r.createElement(f, {
    key: e.toString(),
    prefixCls: a,
    disabled: i,
    value: e,
    checked: s === e
  }, e) : /* @__PURE__ */ r.createElement(f, {
    key: `radio-group-value-options-${e.value}`,
    prefixCls: a,
    disabled: e.disabled || i,
    value: e.value,
    checked: s === e.value,
    title: e.title,
    style: e.style,
    id: e.id,
    required: e.required
  }, e.label)));
  const d = L(z), q = B(l, `${l}-${R}`, {
    [`${l}-${d}`]: d,
    [`${l}-rtl`]: v === "rtl"
  }, b, h, G, T, n);
  return p(/* @__PURE__ */ r.createElement("div", Object.assign({}, I(t, {
    aria: !0,
    data: !0
  }), {
    className: q,
    style: E,
    onMouseEnter: k,
    onMouseLeave: M,
    onFocus: N,
    onBlur: P,
    id: V,
    ref: C
  }), /* @__PURE__ */ r.createElement(j, {
    value: {
      onChange: S,
      value: s,
      disabled: t.disabled,
      name: t.name,
      optionType: t.optionType
    }
  }, u)));
}), te = /* @__PURE__ */ r.memo(H);
export {
  te as default
};
