import * as o from "react";
import "../../../@ant-design/cssinjs/es/extractStyle.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useCacheToken.mjs";
import "../../../@ant-design/cssinjs/es/StyleContext.mjs";
import W from "../../../@ant-design/cssinjs/es/theme/createTheme.mjs";
import "../../../rc-util/es/warning.mjs";
import "../../../@ant-design/cssinjs/es/theme/ThemeCache.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useCompatibleInsertionEffect.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useEffectCleanupRegister.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useHMR.mjs";
import "../../../@ant-design/cssinjs/es/transformers/legacyLogicalProperties.mjs";
import Ye from "../../../@ant-design/icons/es/components/Context.mjs";
import Ze from "../../../rc-util/es/hooks/useMemo.mjs";
import { merge as et } from "../../../rc-util/es/utils/set.mjs";
import w, { WarningContext as tt } from "../_util/warning.mjs";
import ot from "../form/validateMessagesContext.mjs";
import rt, { ANT_MARK as nt } from "../locale/index.mjs";
import it from "../locale/context.mjs";
import at from "../locale/en_US.mjs";
import { defaultTheme as st, DesignTokenContext as lt } from "../theme/context.mjs";
import ct from "../theme/themes/seed.mjs";
import { ConfigContext as S, defaultIconPrefixCls as L } from "./context.mjs";
import { registerTheme as mt } from "./cssVariables.mjs";
import { DisabledContextProvider as ft } from "./DisabledContext.mjs";
import dt from "./hooks/useConfig.mjs";
import pt from "./hooks/useTheme.mjs";
import gt from "./MotionWrapper.mjs";
import ut from "./PropWarning.mjs";
import z, { SizeContextProvider as vt } from "./SizeContext.mjs";
import Ct from "../theme/util/useResetIconStyle.mjs";
var ht = globalThis && globalThis.__rest || function(e, a) {
  var s = {};
  for (var r in e)
    Object.prototype.hasOwnProperty.call(e, r) && a.indexOf(r) < 0 && (s[r] = e[r]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var f = 0, r = Object.getOwnPropertySymbols(e); f < r.length; f++)
      a.indexOf(r[f]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[f]) && (s[r[f]] = e[r[f]]);
  return s;
};
let j = !1;
const eo = process.env.NODE_ENV !== "production" ? (e) => {
  process.env.NODE_ENV !== "production" && w(!j, e, "Static function can not consume context like dynamic theme. Please use 'App' component instead.");
} : (
  /* istanbul ignore next */
  null
), Pt = ["getTargetContainer", "getPopupContainer", "renderEmpty", "pageHeader", "input", "pagination", "form", "select", "button"], bt = "ant";
let O, R, K;
function x() {
  return O || bt;
}
function xt() {
  return R || L;
}
function Ot(e) {
  return Object.keys(e).some((a) => a.endsWith("Color"));
}
const yt = (e) => {
  let {
    prefixCls: a,
    iconPrefixCls: s,
    theme: r
  } = e;
  a !== void 0 && (O = a), s !== void 0 && (R = s), r && (Ot(r) ? (process.env.NODE_ENV !== "production" && w(!1, "ConfigProvider", "`config` of css variable theme is not work in v5. Please use new `theme` config instead."), mt(x(), r)) : K = r);
}, to = () => ({
  getPrefixCls: (e, a) => a || (e ? `${x()}-${e}` : x()),
  getIconPrefixCls: xt,
  getRootPrefixCls: () => O || x(),
  getTheme: () => K
}), Et = (e) => {
  const {
    children: a,
    csp: s,
    autoInsertSpaceInButton: r,
    alert: f,
    anchor: $,
    form: d,
    locale: y,
    componentSize: k,
    direction: F,
    space: G,
    virtual: H,
    dropdownMatchSelectWidth: M,
    popupMatchSelectWidth: E,
    popupOverflow: B,
    legacyLocale: q,
    parentContext: p,
    iconPrefixCls: J,
    theme: N,
    componentDisabled: V,
    segmented: Q,
    statistic: U,
    spin: X,
    calendar: Y,
    carousel: Z,
    cascader: ee,
    collapse: te,
    typography: oe,
    checkbox: re,
    descriptions: ne,
    divider: ie,
    drawer: ae,
    skeleton: se,
    steps: le,
    image: ce,
    layout: me,
    list: fe,
    mentions: de,
    modal: pe,
    progress: ge,
    result: ue,
    slider: ve,
    breadcrumb: Ce,
    menu: he,
    pagination: Pe,
    input: be,
    empty: xe,
    badge: Oe,
    radio: ye,
    rate: Ee,
    switch: Te,
    transfer: _e,
    avatar: je,
    message: we,
    tag: Se,
    table: ke,
    card: Me,
    tabs: Ne,
    timeline: Ve,
    timePicker: Ae,
    upload: De,
    notification: Ie,
    tree: We,
    colorPicker: Le,
    datePicker: ze,
    rangePicker: Re,
    flex: Ke,
    wave: $e,
    dropdown: Fe,
    warning: Ge
  } = e, He = o.useCallback((t, i) => {
    const {
      prefixCls: l
    } = e;
    if (i)
      return i;
    const c = l || p.getPrefixCls("");
    return t ? `${c}-${t}` : c;
  }, [p.getPrefixCls, e.prefixCls]), v = J || p.iconPrefixCls || L, C = s || p.csp;
  Ct(v, C);
  const h = pt(N, p.theme);
  process.env.NODE_ENV !== "production" && (j = j || !!h);
  const T = {
    csp: C,
    autoInsertSpaceInButton: r,
    alert: f,
    anchor: $,
    locale: y || q,
    direction: F,
    space: G,
    virtual: H,
    popupMatchSelectWidth: E ?? M,
    popupOverflow: B,
    getPrefixCls: He,
    iconPrefixCls: v,
    theme: h,
    segmented: Q,
    statistic: U,
    spin: X,
    calendar: Y,
    carousel: Z,
    cascader: ee,
    collapse: te,
    typography: oe,
    checkbox: re,
    descriptions: ne,
    divider: ie,
    drawer: ae,
    skeleton: se,
    steps: le,
    image: ce,
    input: be,
    layout: me,
    list: fe,
    mentions: de,
    modal: pe,
    progress: ge,
    result: ue,
    slider: ve,
    breadcrumb: Ce,
    menu: he,
    pagination: Pe,
    empty: xe,
    badge: Oe,
    radio: ye,
    rate: Ee,
    switch: Te,
    transfer: _e,
    avatar: je,
    message: we,
    tag: Se,
    table: ke,
    card: Me,
    tabs: Ne,
    timeline: Ve,
    timePicker: Ae,
    upload: De,
    notification: Ie,
    tree: We,
    colorPicker: Le,
    datePicker: ze,
    rangePicker: Re,
    flex: Ke,
    wave: $e,
    dropdown: Fe,
    warning: Ge
  }, P = Object.assign({}, p);
  Object.keys(T).forEach((t) => {
    T[t] !== void 0 && (P[t] = T[t]);
  }), Pt.forEach((t) => {
    const i = e[t];
    i && (P[t] = i);
  });
  const g = Ze(() => P, P, (t, i) => {
    const l = Object.keys(t), c = Object.keys(i);
    return l.length !== c.length || l.some((b) => t[b] !== i[b]);
  }), Be = o.useMemo(() => ({
    prefixCls: v,
    csp: C
  }), [v, C]);
  let n = /* @__PURE__ */ o.createElement(o.Fragment, null, /* @__PURE__ */ o.createElement(ut, {
    dropdownMatchSelectWidth: M
  }), a);
  const A = o.useMemo(() => {
    var t, i, l, c;
    return et(((t = at.Form) === null || t === void 0 ? void 0 : t.defaultValidateMessages) || {}, ((l = (i = g.locale) === null || i === void 0 ? void 0 : i.Form) === null || l === void 0 ? void 0 : l.defaultValidateMessages) || {}, ((c = g.form) === null || c === void 0 ? void 0 : c.validateMessages) || {}, (d == null ? void 0 : d.validateMessages) || {});
  }, [g, d == null ? void 0 : d.validateMessages]);
  Object.keys(A).length > 0 && (n = /* @__PURE__ */ o.createElement(ot.Provider, {
    value: A
  }, n)), y && (n = /* @__PURE__ */ o.createElement(rt, {
    locale: y,
    _ANT_MARK__: nt
  }, n)), (v || C) && (n = /* @__PURE__ */ o.createElement(Ye.Provider, {
    value: Be
  }, n)), k && (n = /* @__PURE__ */ o.createElement(vt, {
    size: k
  }, n)), n = /* @__PURE__ */ o.createElement(gt, null, n);
  const qe = o.useMemo(() => {
    const t = h || {}, {
      algorithm: i,
      token: l,
      components: c,
      cssVar: b
    } = t, Je = ht(t, ["algorithm", "token", "components", "cssVar"]), D = i && (!Array.isArray(i) || i.length > 0) ? W(i) : st, _ = {};
    Object.entries(c || {}).forEach((Qe) => {
      let [Ue, Xe] = Qe;
      const m = Object.assign({}, Xe);
      "algorithm" in m && (m.algorithm === !0 ? m.theme = D : (Array.isArray(m.algorithm) || typeof m.algorithm == "function") && (m.theme = W(m.algorithm)), delete m.algorithm), _[Ue] = m;
    });
    const I = Object.assign(Object.assign({}, ct), l);
    return Object.assign(Object.assign({}, Je), {
      theme: D,
      token: I,
      components: _,
      override: Object.assign({
        override: I
      }, _),
      cssVar: b
    });
  }, [h]);
  return N && (n = /* @__PURE__ */ o.createElement(lt.Provider, {
    value: qe
  }, n)), g.warning && (n = /* @__PURE__ */ o.createElement(tt.Provider, {
    value: g.warning
  }, n)), V !== void 0 && (n = /* @__PURE__ */ o.createElement(ft, {
    disabled: V
  }, n)), /* @__PURE__ */ o.createElement(S.Provider, {
    value: g
  }, n);
}, u = (e) => {
  const a = o.useContext(S), s = o.useContext(it);
  return /* @__PURE__ */ o.createElement(Et, Object.assign({
    parentContext: a,
    legacyLocale: s
  }, e));
};
u.ConfigContext = S;
u.SizeContext = z;
u.config = yt;
u.useConfig = dt;
Object.defineProperty(u, "SizeContext", {
  get: () => (process.env.NODE_ENV !== "production" && w(!1, "ConfigProvider", "ConfigProvider.SizeContext is deprecated. Please use `ConfigProvider.useConfig().componentSize` instead."), z)
});
process.env.NODE_ENV !== "production" && (u.displayName = "ConfigProvider");
export {
  S as ConfigContext,
  u as default,
  L as defaultIconPrefixCls,
  bt as defaultPrefixCls,
  to as globalConfig,
  eo as warnContext
};
