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

'use strict';

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

var VueCompositionAPI = require('@vue/composition-api');
var configProvider_context = require('./context.js');
require('lodash/merge');
require('lodash/mergeWith');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.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(VueCompositionAPI.h);
    return pattern.apply(void 0, args);
  }

  return "";
};

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

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

exports.useConfig = useConfig;
exports.usePrefixClass = usePrefixClass;
//# sourceMappingURL=useConfig.js.map
