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 { componentWithName } from 'airbnb-prop-types';
import Icon from '../../base/Icon';

import './style.css';

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

  var title = props.title,
      icon = props.icon,
      prefix = props.prefix,
      theme = props.theme;

  var linkArgs = {
    theme: theme,
    linkClasses: 'ma__content-link'
  };
  var h2Classes = classNames((_classNames = {
    'ma__emergency-header': true
  }, _classNames['ma__emergency-header--' + theme] = theme, _classNames));
  return React.createElement(
    'h2',
    { className: h2Classes },
    (icon || prefix) && React.createElement(
      'span',
      { className: 'ma__emergency-header__label' },
      icon,
      React.createElement(
        'span',
        null,
        prefix
      )
    ),
    React.createElement(
      'span',
      { className: 'ma__emergency-header__title' },
      is.fn(title) ? title(_extends({}, linkArgs)) : title
    )
  );
};

EmergencyHeader.propTypes = process.env.NODE_ENV !== "production" ? {
  /** A function whose return value is displayed in the text to the right of the divider bar. */
  title: PropTypes.oneOfType([PropTypes.func, PropTypes.string]).isRequired,
  /** 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 SVG icon to display to the left of the prefix text. */
  icon: componentWithName('Icon'),
  /** An optional string displayed to the left of the divider bar. */
  prefix: PropTypes.string
} : {};
EmergencyHeader.defaultProps = {
  theme: 'c-warning',
  prefix: 'Emergency Alerts',
  icon: React.createElement(Icon, { name: 'alert' })
};

export default EmergencyHeader;