"use strict";

exports.__esModule = true;
exports.getLocalization = getLocalization;
exports.getNotLocalizedString = getNotLocalizedString;
exports.default = void 0;

var _propertyHelper = require("./propertyHelper");

(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;
};

function getLocalization(localizations, locale, defaultValue, useDefaultForEmptyValue) {
  var _localisation;

  if (useDefaultForEmptyValue === void 0) {
    useDefaultForEmptyValue = true;
  }

  var fallbackValue = getNotLocalizedString(defaultValue);
  if (!localizations || !locale) return fallbackValue;
  var localisation = (0, _propertyHelper.getPropertyOrDefault)(localizations, locale, fallbackValue, true);

  if (localisation === fallbackValue) {
    localisation = (0, _propertyHelper.getPropertyOrDefault)(localizations, locale.split("-")[0], fallbackValue, true, true);
  }

  if (useDefaultForEmptyValue && ((_localisation = localisation) == null ? void 0 : _localisation.trim()) === "") {
    return fallbackValue;
  }

  return localisation;
}

function getNotLocalizedString(value) {
  return value && "[".concat(value, "]");
}

var _default = {
  getLocalization: getLocalization,
  getNotLocalizedString: getNotLocalizedString
};
var _default2 = _default;
var _default3 = _default2;
exports.default = _default3;
;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(getLocalization, "getLocalization", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
  reactHotLoader.register(getNotLocalizedString, "getNotLocalizedString", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/utils/localizationHelper.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(getLocalization, "getLocalization", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
  reactHotLoader.register(getNotLocalizedString, "getNotLocalizedString", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();