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