"use strict";

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

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _classnames = _interopRequireDefault(require("classnames"));

var _getFlagCountryCode = _interopRequireDefault(require("./getFlagCountryCode"));

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

// Default country flag icon.
// `<img/>` is wrapped in a `<div/>` to prevent SVGs from exploding in size in IE 11.
// https://github.com/catamphetamine/react-phone-number-input/issues/111
function FlagComponent(_ref) {
  var country = _ref.country,
      flags = _ref.flags,
      flagUrl = _ref.flagUrl,
      className = _ref.className;

  if (flags && flags[country]) {
    return flags[country]();
  }

  return _react["default"].createElement("img", {
    alt: country,
    className: "PhoneInputCountryIconImg",
    src: flagUrl.replace('{0}', (0, _getFlagCountryCode["default"])(country).toLowerCase())
  });
}

FlagComponent.propTypes = {
  // The country to be selected by default.
  // Two-letter country code ("ISO 3166-1 alpha-2").
  country: _propTypes["default"].string.isRequired,
  // Country flag icon components.
  // By default flag icons are inserted as `<img/>`s
  // with their `src` pointed to `flag-icon-css` github repo.
  // There might be cases (e.g. an offline application)
  // where having a large (3 megabyte) `<svg/>` flags
  // bundle is more appropriate.
  // `import flags from 'react-phone-number-input/flags'`.
  flags: _propTypes["default"].objectOf(_propTypes["default"].elementType),
  // A URL for a country flag icon.
  // By default it points to `flag-icon-css` github pages website.
  flagUrl: _propTypes["default"].string.isRequired
};
//# sourceMappingURL=Flag.js.map