"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.NestedBadge = void 0;
var _react = _interopRequireDefault(require("react"));
var _ = require("../../../..");
var _NestedBadge = require("./NestedBadge.styles");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var isValidCountry = function isValidCountry(country) {
  return ['SE', 'DK', 'FI', 'NO', 'US', 'DE', 'CA', 'GB'].includes(country);
};
var NestedBadge = exports.NestedBadge = function NestedBadge(_ref) {
  var alt = _ref.alt,
    _ref$badgeSize = _ref.badgeSize,
    badgeSize = _ref$badgeSize === void 0 ? 'l' : _ref$badgeSize,
    className = _ref.className,
    country = _ref.country,
    fallback = _ref.fallback,
    logoUrl = _ref.logoUrl;
  return _react.default.createElement(_NestedBadge.StyledNestedBadge, {
    $badgeSize: badgeSize,
    className: className
  }, logoUrl ? _react.default.createElement(_NestedBadge.StyledImg, {
    src: "".concat(logoUrl, "?w=48&q=90"),
    alt: alt || fallback || logoUrl,
    $badgeSize: badgeSize
  }) : _react.default.createElement(_NestedBadge.StyledFallback, {
    $badgeSize: badgeSize
  }, _react.default.createElement(_.Typography, {
    type: "secondary",
    weight: "bold",
    color: function color(t) {
      return t.colorTokens.neutral.text_default;
    }
  }, fallback === null || fallback === void 0 ? void 0 : fallback.charAt(0).toUpperCase())), country && isValidCountry(country) && _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_NestedBadge.StyledFlag, {
    country: country,
    size: "m",
    $badgeSize: badgeSize
  }), _react.default.createElement(_NestedBadge.StyledOverlay, {
    $badgeSize: badgeSize
  })));
};