import { isVNode as v, ref as C, defineComponent as P, computed as t, watch as T, onActivated as h, createVNode as w, renderSlot as b } from "vue";
import { ConfigProvider as A } from "@aplus-frontend/antdv";
import { merge as p, cloneDeep as G } from "lodash-unified";
import { useDevWarning as D } from "../utils/warning.mjs";
import { mergeAntdProviderConfigWithCache as l, mergeAntdProvideConfig as u } from "../utils/config-provider-preset.mjs";
import { configProviderProps as F } from "./config-provider-props.mjs";
import { DEFAULT_NAMESPACE as M } from "./constants.mjs";
import { useGlobalConfig as V, provideGlobalConfig as k } from "./hooks/use-global-config.mjs";
function y(o) {
  return typeof o == "function" || Object.prototype.toString.call(o) === "[object Object]" && !v(o);
}
const r = C({}), I = /* @__PURE__ */ P({
  name: "AplusConfigProvider",
  props: F(),
  setup(o, {
    slots: g
  }) {
    D("ConfigProvider")(!o.uiMode, "breaking", "uiMode has been remove, see migrate guide https://aplus.aplnk.com/aplus-ui/guide/migrate-7.2.html");
    function e(a, s) {
      return o[a] ?? i.value?.[a] ?? s;
    }
    const i = V(), m = t(() => p(G(i.value?.aplusToken || {}), o.aplusToken)), d = t(() => p({
      ...i.value?.valueTypeMap ?? {}
    }, o.valueTypeMap)), c = t(() => ({
      namespace: e("namespace", M),
      apGrid: e("apGrid"),
      agGrid: e("agGrid"),
      apProCard: e("apProCard"),
      apImage: e("apImage"),
      apTitle: e("apTitle"),
      searchForm: e("searchForm"),
      apUpload: e("apUpload"),
      apDescriptions: e("apDescriptions"),
      apFilePreview: e("apFilePreview"),
      apExportGroup: e("apExportGroup"),
      apView: e("apView"),
      aplusLocale: e("aplusLocale"),
      aplusToken: m.value,
      api: e("api"),
      valueTypeMap: d.value,
      downloadCenterTriggerConfig: e("downloadCenterTriggerConfig"),
      scrollYDomName: e("scrollYDomName"),
      viewCacheOption: e("viewCacheOption")
    })), f = k(c);
    let n = !0;
    return T(() => o, (a) => {
      r.value = l(u(a), r.value);
    }, {
      deep: !0,
      immediate: !0
    }), h(() => {
      if (n) {
        n = !1;
        return;
      }
      r.value = l(u(o), r.value);
    }), () => {
      let a;
      return w(A, r.value, y(a = b(g, "default", {
        config: f?.value
      })) ? a : {
        default: () => [a]
      });
    };
  }
});
export {
  I as ConfigProvider,
  r as globalConfigCached
};
