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

import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import is from 'is';
import './style.css';

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 = classNames((_classNames = {
    'ma__emergency-alert': true
  }, _classNames['ma__emergency-alert--' + theme] = theme, _classNames));
  return React.createElement(
    'p',
    { className: pClasses },
    React.createElement(
      'span',
      { className: 'ma__emergency-alert__message' },
      message,
      timeStamp && React.createElement(
        'span',
        { className: 'ma__emergency-alert__time-stamp' },
        '\xA0',
        timeStamp
      )
    ),
    is.fn(link) && React.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: PropTypes.oneOf(['c-warning', 'c-primary-alt', 'c-primary', 'c-gray', 'c-error']),
  /** A message describing the event. */
  message: PropTypes.string.isRequired,
  /** A string representing the time of the event. */
  timeStamp: PropTypes.string,
  /** An optional function whose return value is a link to take the user to page with more information. */
  link: PropTypes.func
} : {};

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

export default EmergencyAlert;