'use strict';

var reactIntl = require('react-intl');
require('../common/theme.js');
require('../common/direction.js');
require('../common/propsValues/control.js');
require('../common/propsValues/breakpoint.js');
require('../common/propsValues/size.js');
require('../common/propsValues/typography.js');
require('../common/propsValues/width.js');
require('../common/propsValues/type.js');
require('../common/propsValues/dateMode.js');
require('../common/propsValues/monthFormat.js');
require('../common/propsValues/position.js');
require('../common/propsValues/layouts.js');
require('../common/propsValues/status.js');
require('../common/propsValues/sentiment.js');
require('../common/propsValues/profileType.js');
require('../common/propsValues/variant.js');
require('../common/propsValues/scroll.js');
require('../common/propsValues/markdownNodeType.js');
require('../common/fileType.js');
var index = require('../common/locale/index.js');
require('@transferwise/icons');
require('clsx');
require('react');
require('../common/closeButton/CloseButton.messages.js');
var jsxRuntime = require('react/jsx-runtime');
var en = require('../i18n/en.json.js');
var DirectionProvider = require('./direction/DirectionProvider.js');
var LanguageProvider = require('./language/LanguageProvider.js');

function Provider({
  i18n,
  children
}) {
  const {
    locale,
    messages,
    defaultRichTextElements
  } = i18n;
  const adjustedLocale = index.adjustLocale(locale);
  let intlConfig;
  if (adjustedLocale === null) {
    // eslint-disable-next-line no-console
    console.warn(`Unsupported locale value was provided: '${locale}', defaulting to '${index.DEFAULT_LOCALE}'`);
    intlConfig = {
      locale: index.DEFAULT_LOCALE,
      messages: {
        ...en,
        ...messages
      }
    };
  } else {
    intlConfig = {
      locale: adjustedLocale,
      messages
    };
  }
  return /*#__PURE__*/jsxRuntime.jsx(DirectionProvider.DirectionProvider, {
    direction: index.getDirectionFromLocale(locale),
    children: /*#__PURE__*/jsxRuntime.jsx(LanguageProvider.LanguageProvider, {
      locale: locale,
      children: /*#__PURE__*/jsxRuntime.jsx(reactIntl.IntlProvider, {
        defaultLocale: index.DEFAULT_LOCALE,
        locale: intlConfig.locale,
        messages: intlConfig.messages,
        defaultRichTextElements: defaultRichTextElements,
        children: children
      })
    })
  });
}

module.exports = Provider;
//# sourceMappingURL=Provider.js.map
