"use strict";

exports.__esModule = true;
exports.orderedCultureList = exports.defaultLocale = exports.defaultCulture = exports.currentLocaleOrDefault = exports.currentLocale = exports.cultures = exports.cultureOptionList = exports.cultureNameByIsoCode = exports.cultureList = void 0;
var _immutable = _interopRequireDefault(require("immutable"));
var _reselect = require("reselect");
var _localeFactory = require("../reducers/localeFactory");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var localeData = function localeData(state) {
  return state.get("locale");
};
var defaultLocale = exports.defaultLocale = (0, _reselect.createSelector)(localeData, function (data) {
  return data.getIn(["supportedLocales", 0, "cultureIso"]) || _localeFactory.cultureByDefault;
});
var supportedLocales = (0, _reselect.createSelector)(localeData, function (data) {
  return data.getIn(["supportedLocales"]) || _immutable.default.fromJS([]);
});
var currentLocaleOrDefault = exports.currentLocaleOrDefault = (0, _reselect.createSelector)(localeData, defaultLocale, function (data, defaultLocale) {
  return data.get("locale") || defaultLocale;
});
var currentLocale = exports.currentLocale = (0, _reselect.createSelector)(localeData, function (data) {
  return data.get("locale");
});
var cultures = exports.cultures = (0, _reselect.createSelector)(localeData, function (locale) {
  return locale.get("cultures");
});
var cultureList = exports.cultureList = (0, _reselect.createSelector)(cultures, function (cultures) {
  return cultures.keySeq();
});
var defaultCulture = exports.defaultCulture = (0, _reselect.createSelector)(localeData, function (locale) {
  return locale.get("defaultCulture");
});
var orderedCultureList = exports.orderedCultureList = (0, _reselect.createSelector)(cultureList, defaultCulture, function (cultures, defaultCulture) {
  return cultures.sort(function (a, b) {
    /*istanbul ignore if */if (a === defaultCulture) return -1;
    /*istanbul ignore if */
    if (b === defaultCulture) return 1;
    return 0;
  });
});
var cultureOptionList = exports.cultureOptionList = (0, _reselect.createSelector)(supportedLocales, function (locales) {
  return locales.map(function (iso) {
    return {
      value: iso.get("cultureIso"),
      label: iso.get("language")
    };
  });
});
var cultureNameByIsoCode = exports.cultureNameByIsoCode = function cultureNameByIsoCode(cultureIsoCode) {
  return (0, _reselect.createSelector)(cultures, function (cultures) {
    var culturesList = cultures == null ? void 0 : cultures.toJS();
    if (cultureIsoCode != null) {
      var culture = culturesList[cultureIsoCode];
      if (culture != null) {
        return culture.cultureName;
      }
      return "[".concat(cultureIsoCode, "]");
    }
    return null;
  });
};
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(localeData, "localeData", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(defaultLocale, "defaultLocale", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(supportedLocales, "supportedLocales", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(currentLocaleOrDefault, "currentLocaleOrDefault", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(currentLocale, "currentLocale", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultures, "cultures", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultureList, "cultureList", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(defaultCulture, "defaultCulture", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(orderedCultureList, "orderedCultureList", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultureOptionList, "cultureOptionList", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultureNameByIsoCode, "cultureNameByIsoCode", "/home/vsts/work/1/s/src/selectors/locale.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(localeData, "localeData", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(defaultLocale, "defaultLocale", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(supportedLocales, "supportedLocales", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(currentLocaleOrDefault, "currentLocaleOrDefault", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(currentLocale, "currentLocale", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultures, "cultures", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultureList, "cultureList", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(defaultCulture, "defaultCulture", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(orderedCultureList, "orderedCultureList", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultureOptionList, "cultureOptionList", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultureNameByIsoCode, "cultureNameByIsoCode", "/home/vsts/work/1/s/src/selectors/locale.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();