'use strict';

exports.__esModule = true;

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _is = require('is');

var _is2 = _interopRequireDefault(_is);

require('./style.css');

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

var EmergencyAlert = function EmergencyAlert(props) {
  var _classNames;

  var message = props.message,
      timeStamp = props.timeStamp,
      link = props.link,
      theme = props.theme;

  var linkArgs = {
    theme: theme,
    linkClasses: 'ma__content-link',
    TextElement: 'span'
  };
  var pClasses = (0, _classnames2.default)((_classNames = {
    'ma__emergency-alert': true
  }, _classNames['ma__emergency-alert--' + theme] = theme, _classNames));
  return _react2.default.createElement(
    'p',
    { className: pClasses },
    _react2.default.createElement(
      'span',
      { className: 'ma__emergency-alert__message' },
      message,
      timeStamp && _react2.default.createElement(
        'span',
        { className: 'ma__emergency-alert__time-stamp' },
        '\xA0',
        timeStamp
      )
    ),
    _is2.default.fn(link) && _react2.default.createElement(
      'span',
      { className: 'ma__emergency-alert__link' },
      '\xA0',
      link(_extends({}, linkArgs))
    )
  );
};

EmergencyAlert.propTypes = process.env.NODE_ENV !== "production" ? {
  /** A string that controls different color themes for the component. */
  theme: _propTypes2.default.oneOf(['c-warning', 'c-primary-alt', 'c-primary', 'c-gray', 'c-error']),
  /** A message describing the event. */
  message: _propTypes2.default.string.isRequired,
  /** A string representing the time of the event. */
  timeStamp: _propTypes2.default.string,
  /** An optional function whose return value is a link to take the user to page with more information. */
  link: _propTypes2.default.func
} : {};

EmergencyAlert.defaultProps = {
  theme: 'c-warning'
};

exports.default = EmergencyAlert;
module.exports = exports['default'];