import React__default from 'react';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
import Button from 'react-bootstrap/Button';
import { L as LazyLoad } from './index-755f2cc2.js';
import urlFor from './urlFor.js';

var PublicationFeature = function PublicationFeature(_ref) {
  var data = _ref.data,
      _ref$issueMapping = _ref.issueMapping,
      issueMapping = _ref$issueMapping === undefined ? '/publications' : _ref$issueMapping,
      defaultImage = _ref.defaultImage,
      client = _ref.client;

  var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
  var _data$parent = data.parent;
  _data$parent = _data$parent === undefined ? {} : _data$parent;
  var _data$parent$identifi = _data$parent.identifier;
  _data$parent$identifi = _data$parent$identifi === undefined ? {} : _data$parent$identifi;
  var parentSlug = _data$parent$identifi.current,
      _data$identifier = data.identifier;
  _data$identifier = _data$identifier === undefined ? {} : _data$identifier;
  var childSlug = _data$identifier.current,
      name = data.name,
      articles = data.articles,
      month = data.month,
      year = data.year,
      thumbnail = data.thumbnail;

  if (name && articles && articles.length > 0) {
    return React__default.createElement(
      'div',
      { className: 'publication-feature-container border rounded p-2' },
      React__default.createElement(
        Row,
        null,
        React__default.createElement(
          Col,
          { xs: 12 },
          React__default.createElement(
            'h4',
            null,
            name,
            month && year && React__default.createElement(
              'span',
              null,
              ' ',
              '| ',
              months[parseInt(month, 10)],
              ' ',
              year
            )
          )
        ),
        React__default.createElement(
          Col,
          { xs: 12, sm: 4 },
          React__default.createElement(
            LazyLoad,
            { once: true },
            React__default.createElement('img', { className: 'w-100 mb-2', src: thumbnail && thumbnail.asset && client ? urlFor({ client: client, source: thumbnail.asset }) : defaultImage, alt: name || '' })
          )
        ),
        React__default.createElement(
          Col,
          { xs: 12, sm: 8 },
          React__default.createElement(
            Row,
            null,
            articles.map(function (article) {
              return React__default.createElement(
                Col,
                { key: article._id, xs: 12, sm: 6 },
                article.issueSection && article.issueSection.name && React__default.createElement(
                  'h6',
                  { className: 'text-primary m-0 p-0 text-uppercase font-weight-bold' },
                  article.issueSection.name
                ),
                article.title && React__default.createElement(
                  React__default.Fragment,
                  null,
                  article.url && article.url.current ? React__default.createElement(
                    'a',
                    { href: '/view/' + article.url.current },
                    React__default.createElement(
                      'h6',
                      { className: 'text-break' },
                      article.title
                    )
                  ) : React__default.createElement(
                    'h6',
                    { className: 'text-break' },
                    article.title
                  )
                )
              );
            })
          )
        ),
        issueMapping && parentSlug && childSlug && React__default.createElement(
          Col,
          { xs: 12 },
          React__default.createElement(
            Button,
            { href: issueMapping + '/' + parentSlug + '/' + childSlug, className: 'float-right', variant: 'outline-primary' },
            'More Articles ',
            '>>'
          )
        )
      ),
      React__default.createElement(
        'style',
        { jsx: 'true' },
        '\n          .row {\n            margin-top: -15px;\n            margin-left: -15px;\n            margin-right: 0;\n          }\n          .row > * {\n            padding-top: 15px;\n            padding-left: 15px;\n            padding-right: 0;\n          }\n        '
      )
    );
  }
  return null;
};

export { PublicationFeature as P };
