Liferay.Loader.define("frontend-taglib@5.6.15/translation_manager/components/LocalesList", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/button', '@frontend-taglib-clay$clayui/icon', '@frontend-taglib-clay$clayui/tabs', 'frontend-js-react-web$react'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = LocalesList;

    var _button = _interopRequireDefault(require("@frontend-taglib-clay$clayui/button"));

    var _icon = _interopRequireDefault(require("@frontend-taglib-clay$clayui/icon"));

    var _tabs = _interopRequireDefault(require("@frontend-taglib-clay$clayui/tabs"));

    var _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { default: obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
          var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }newObj.default = obj;if (cache) {
        cache.set(obj, newObj);
      }return newObj;
    }

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { default: obj };
    }

    function _toConsumableArray(arr) {
      return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
    }

    function _nonIterableSpread() {
      throw new TypeError("Invalid attempt to spread non-iterable instance");
    }

    function _iterableToArray(iter) {
      if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
    }

    function _arrayWithoutHoles(arr) {
      if (Array.isArray(arr)) {
        for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
          arr2[i] = arr[i];
        }return arr2;
      }
    }

    var Locale = function Locale(_ref) {
      var children = _ref.children,
          editingLocale = _ref.editingLocale,
          locale = _ref.locale,
          onLocaleClicked = _ref.onLocaleClicked;
      return (/*#__PURE__*/_react.default.createElement(_tabs.default.Item, {
          active: editingLocale === locale.id,
          onClick: function onClick() {
            return onLocaleClicked && onLocaleClicked(locale);
          }
        }, /*#__PURE__*/_react.default.createElement(_icon.default, {
          className: "inline-item-before",
          symbol: locale.icon
        }), /*#__PURE__*/_react.default.createElement("span", {
          className: "inline-item-before"
        }, locale.label), children)
      );
    };

    function LocalesList(_ref2) {
      var availableLocales = _ref2.availableLocales,
          changeableDefaultLanguage = _ref2.changeableDefaultLanguage,
          defaultLocale = _ref2.defaultLocale,
          editingLocale = _ref2.editingLocale,
          _onLocaleClicked = _ref2.onLocaleClicked,
          onLocaleRemoved = _ref2.onLocaleRemoved;
      var sortedLocales = (0, _react.useMemo)(function () {
        var availableLocalesArray = Array.from(availableLocales.values());

        if (!availableLocalesArray.some(function (locale) {
          return locale.id === defaultLocale;
        })) {
          return availableLocalesArray;
        }

        return [availableLocalesArray.find(function (locale) {
          return locale.id === defaultLocale;
        })].concat(_toConsumableArray(availableLocalesArray.filter(function (locale) {
          return locale.id !== defaultLocale;
        })));
      }, [availableLocales, defaultLocale]);
      return (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, sortedLocales.map(function (locale) {
          return (/*#__PURE__*/_react.default.createElement(Locale, {
              editingLocale: editingLocale,
              key: locale.id,
              locale: locale,
              onLocaleClicked: function onLocaleClicked() {
                return _onLocaleClicked && _onLocaleClicked(locale);
              }
            }, changeableDefaultLanguage && defaultLocale === locale.id || locale.id !== defaultLocale && /*#__PURE__*/_react.default.createElement(_button.default, {
              displayType: "unstyled",
              onClick: function onClick() {
                return onLocaleRemoved && onLocaleRemoved(locale);
              },
              small: true
            }, /*#__PURE__*/_react.default.createElement(_icon.default, {
              symbol: "times-small"
            })))
          );
        }))
      );
    }
    //# sourceMappingURL=LocalesList.js.map
  }
});
//# sourceMappingURL=LocalesList.js.map