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 V } from "../utils/warning.mjs";
import { mergeAntdProviderConfigWithCache as l, mergeAntdProvideConfig as u } from "../utils/config-provider-preset.mjs";
import { configProviderProps as k } from "./config-provider-props.mjs";
import { DEFAULT_NAMESPACE as D } from "./constants.mjs";
import { useGlobalConfig as F, provideGlobalConfig as M } 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: k(),
  setup(o, {
    slots: m
  }) {
    V("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, f) {
      return o[a] ?? i.value?.[a] ?? f;
    }
    const i = F(), g = t(() => p(G(i.value?.aplusToken || {}), o.aplusToken)), d = t(() => p({
      ...i.value?.valueTypeMap ?? {}
    }, o.valueTypeMap)), s = t(() => ({
      namespace: e("namespace", D),
      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: g.value,
      api: e("api"),
      valueTypeMap: d.value,
      downloadCenterTriggerConfig: e("downloadCenterTriggerConfig"),
      scrollYDomName: e("scrollYDomName"),
      viewCacheOption: e("viewCacheOption"),
      maskVisible: e("maskVisible")
    })), c = M(s);
    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(m, "default", {
        config: c?.value
      })) ? a : {
        default: () => [a]
      });
    };
  }
});
export {
  I as ConfigProvider,
  r as globalConfigCached
};
