/**
 * tdesign v0.46.4
 * (c) 2022 tdesign
 * @license MIT
 */

import { h, inject, ref } from '@vue/composition-api';
import { defaultGlobalConfig } from './context.js';
import 'lodash/merge';
import 'lodash/mergeWith';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import './type.js';

var t = function t(pattern) {
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    args[_key - 1] = arguments[_key];
  }

  var data = args[0];

  if (typeof pattern === "string") {
    if (!data) return pattern;
    var regular = /\{\s*([\w-]+)\s*\}/g;
    var translated = pattern.replace(regular, function (match, key) {
      if (data) {
        return String(data[key]);
      }

      return "";
    });
    return translated;
  }

  if (typeof pattern === "function") {
    if (!args.length) return pattern(h);
    return pattern.apply(void 0, args);
  }

  return "";
};

function useConfig(componentName) {
  var injectGlobalConfig = inject("globalConfig", null);
  var mergedGlobalConfig = injectGlobalConfig || defaultGlobalConfig;
  var global = ref(mergedGlobalConfig[componentName]);
  var classPrefix = ref(mergedGlobalConfig.classPrefix);
  return {
    t: t,
    global: global,
    classPrefix: classPrefix
  };
}
function usePrefixClass(componentName) {
  var _useConfig = useConfig("classPrefix"),
      classPrefix = _useConfig.classPrefix;

  return ref(componentName ? "".concat(classPrefix.value, "-").concat(componentName) : classPrefix.value);
}

export { useConfig, usePrefixClass };
//# sourceMappingURL=useConfig.js.map
