'use strict';

var reactIntl = require('react-intl');
var en = require('../i18n/en.json.js');
var DirectionProvider = require('./direction/DirectionProvider.js');
var LanguageProvider = require('./language/LanguageProvider.js');
var jsxRuntime = require('react/jsx-runtime');
var index = require('../common/locale/index.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
