import b from "../../../../rc-util/es/hooks/useMemo.mjs";
import p from "../../../../rc-util/es/isEqual.mjs";
import u from "./useThemeKey.mjs";
import { devUseWarning as l } from "../../_util/warning.mjs";
import { defaultConfig as m } from "../../theme/context.mjs";
function C(c, t) {
  var a;
  const V = l("ConfigProvider"), s = c || {}, e = s.inherit === !1 || !t ? m : t, d = u();
  if (process.env.NODE_ENV !== "production") {
    const o = s.cssVar || e.cssVar, n = !!(typeof s.cssVar == "object" && (!((a = s.cssVar) === null || a === void 0) && a.key) || d);
    process.env.NODE_ENV !== "production" && V(!o || n, "breaking", "Missing key in `cssVar` config. Please upgrade to React 18 or set `cssVar.key` manually in each ConfigProvider inside `cssVar` enabled ConfigProvider.");
  }
  return b(() => {
    var o, n;
    if (!c)
      return t;
    const r = Object.assign({}, e.components);
    Object.keys(c.components || {}).forEach((f) => {
      r[f] = Object.assign(Object.assign({}, r[f]), c.components[f]);
    });
    const i = `css-var-${d.replace(/:/g, "")}`, g = ((o = s.cssVar) !== null && o !== void 0 ? o : e.cssVar) && Object.assign(Object.assign(Object.assign({
      prefix: "ant"
    }, typeof e.cssVar == "object" ? e.cssVar : {}), typeof s.cssVar == "object" ? s.cssVar : {}), {
      key: typeof s.cssVar == "object" && ((n = s.cssVar) === null || n === void 0 ? void 0 : n.key) || i
    });
    return Object.assign(Object.assign(Object.assign({}, e), s), {
      token: Object.assign(Object.assign({}, e.token), s.token),
      components: r,
      cssVar: g
    });
  }, [s, e], (o, n) => o.some((r, i) => {
    const g = n[i];
    return !p(r, g, !0);
  }));
}
export {
  C as default
};
