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

// import child components


var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _Paragraph = require('../../atoms/text/Paragraph');

var _Paragraph2 = _interopRequireDefault(_Paragraph);

var _PublishState = require('../../atoms/text/PublishState');

var _PublishState2 = _interopRequireDefault(_PublishState);

require('./style.css');

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

var PageHeader = function PageHeader(pageHeader) {
  var category = pageHeader.category,
      title = pageHeader.title,
      subTitle = pageHeader.subTitle,
      optionalContents = pageHeader.optionalContents,
      publishState = pageHeader.publishState;

  return _react2.default.createElement(
    'section',
    { className: 'ma__page-header' },
    _react2.default.createElement(
      'div',
      { className: 'ma__page-header__content' },
      publishState && _react2.default.createElement(
        'div',
        { className: 'ma__page-header__publish-state' },
        _react2.default.createElement(_PublishState2.default, publishState)
      ),
      category && _react2.default.createElement(
        'div',
        { className: 'ma__page-header__category' },
        category
      ),
      _react2.default.createElement(
        'h1',
        { className: 'ma__page-header__title' },
        category && _react2.default.createElement(
          'span',
          { className: 'visually-hidden' },
          category,
          '\xA0'
        ),
        title
      ),
      subTitle && _react2.default.createElement(
        'div',
        { className: 'ma__page-header__sub-title' },
        subTitle
      ),
      optionalContents && _react2.default.createElement(
        'div',
        { className: 'ma__page-header__optional-content' },
        _react2.default.createElement(
          'div',
          { className: 'main-content main-content--two' },
          _react2.default.createElement(
            'div',
            { className: 'page-content' },

            /* eslint-disable react/no-array-index-key */
            optionalContents.map(function (p, index) {
              return _react2.default.createElement(_Paragraph2.default, _extends({ key: 'page-header-optional-content' + index }, p.paragraph));
            })
          )
        )
      )
    )
  );
};

PageHeader.propTypes = process.env.NODE_ENV !== "production" ? {
  /** render publish state above category */
  publishState: _propTypes2.default.shape(_PublishState2.default.propTypes),
  /** render category/prefix above title */
  category: _propTypes2.default.string,
  /** Render title text */
  title: _propTypes2.default.string,
  /** Render subTitle text */
  subTitle: _propTypes2.default.string,
  /** optional array of paragraphs @atoms/headings/CompHeading */
  optionalContents: _propTypes2.default.arrayOf(_propTypes2.default.shape(_Paragraph2.default.propTypes))
} : {};

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