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 child components
import Paragraph from '../../atoms/text/Paragraph';
import PublishState from '../../atoms/text/PublishState';
import './style.css';

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

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

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

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

export default PageHeader;