import React from 'react';
import { ConfigContext, getPrefixClassName } from './context';
import i18n from '../i18n';

var ConfigProvider = function ConfigProvider(props) {
  var locale = props.locale,
      children = props.children,
      prefix = props.prefix,
      getPopupContainer = props.getPopupContainer,
      _props$size = props.size,
      size = _props$size === void 0 ? 'medium' : _props$size;

  var resetGetPrefixClassName = function resetGetPrefixClassName(suffixCls, customPrefix) {
    var endPrefix = prefix || 'klein';

    if (customPrefix) {
      return customPrefix;
    }

    return suffixCls ? "".concat(endPrefix, "-").concat(suffixCls) : endPrefix;
  };

  var config = {
    locale: locale ? i18n[locale] : i18n.zh_CN,
    getPrefixClassName: getPrefixClassName,
    size: size
  };

  if (prefix) {
    config.getPrefixClassName = resetGetPrefixClassName;
  }

  if (getPopupContainer) {
    config.getPopupContainer = getPopupContainer;
  }

  return /*#__PURE__*/React.createElement(ConfigContext.Provider, {
    value: config
  }, children);
};

export default ConfigProvider;