import { defineComponent, inject, computed, unref } from 'vue';
import '../locale/index.mjs';
import localeValues from '../locale/lang/en_US.mjs';

const LocaleReceiver = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "LocaleReceiver",
  props: {
    componentName: String,
    defaultLocale: {
      type: [Object, Function]
    },
    children: {
      type: Function
    }
  },
  setup(props, {
    slots
  }) {
    const localeData = inject("localeData", {});
    const locale = computed(() => {
      const {
        componentName = "global",
        defaultLocale
      } = props;
      const locale2 = defaultLocale || localeValues[componentName || "global"];
      const {
        antLocale
      } = localeData;
      const localeFromContext = componentName && antLocale ? antLocale[componentName] : {};
      return {
        ...typeof locale2 === "function" ? locale2() : locale2,
        ...localeFromContext || {}
      };
    });
    const localeCode = computed(() => {
      const {
        antLocale
      } = localeData;
      const localeCode2 = antLocale && antLocale.locale;
      if (antLocale && antLocale.exist && !localeCode2)
        return localeValues.locale;
      return localeCode2;
    });
    return () => {
      const children = props.children || slots.default;
      const {
        antLocale
      } = localeData;
      return children == null ? void 0 : children(locale.value, localeCode.value, antLocale);
    };
  }
});
function useLocaleReceiver(componentName, defaultLocale, propsLocale) {
  const localeData = inject("localeData", {});
  const componentLocale = computed(() => {
    const {
      antLocale
    } = localeData;
    const locale = unref(defaultLocale) || localeValues[componentName || "global"];
    const localeFromContext = componentName && antLocale ? antLocale[componentName] : {};
    return {
      ...typeof locale === "function" ? locale() : locale,
      ...localeFromContext || {},
      ...unref(propsLocale) || {}
    };
  });
  return [componentLocale];
}

export { LocaleReceiver as default, useLocaleReceiver };
//# sourceMappingURL=LocaleReceiver.mjs.map
