'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../locale/index.js');
var en_US = require('../locale/lang/en_US.js');

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

exports.default = LocaleReceiver;
exports.useLocaleReceiver = useLocaleReceiver;
//# sourceMappingURL=LocaleReceiver.js.map
