'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

require('./_commonjsHelpers-06173234.js');
require('./core.get-iterator-method-f3c44602.js');
require('./_library-dd23b178.js');
require('./_iter-detect-05795553.js');
require('./toConsumableArray-c9b8a0d0.js');
require('./_object-pie-68c5bcbc.js');
var _extends = require('./extends-eed4f016.js');
require('./_object-sap-171b9ea5.js');
require('./inherits-cba9c846.js');
require('./define-property-21887c62.js');
require('./web.dom.iterable-e34bf324.js');
require('./typeof-5f52cf64.js');
require('./_is-array-aa52fa1e.js');
var React = require('react');
var React__default = _interopDefault(React);
require('./events-1b438fe7.js');
require('./index-98e01cb9.js');
require('prop-types');
require('react-bootstrap/Row');
require('react-bootstrap/Col');
require('./moment-575fe24c.js');
var Router = require('next/router');
var Router__default = _interopDefault(Router);
require('./isSymbol-04666465.js');
require('./debounce-529c8d06.js');
require('./toNumber-36d1e7e5.js');
require('react-dom');
var slicedToArray = require('./slicedToArray-f6d4eaa8.js');
require('./index-be0c82be.js');
require('./urlFor.js');
require('./index-96b3db50.js');
require('./main-02daeefe.js');
require('./entities-310b46ee.js');
require('./stringify-bbc68047.js');
require('./asyncToGenerator-df19209d.js');
require('./Segment.js');
require('./Beam.js');
require('./AdSlot.js');
var Button = _interopDefault(require('react-bootstrap/Button'));
var BlockContent = require('./BlockContent-091a991f.js');
require('./index-187c967e.js');
require('./smoothscroll-5054361f.js');
require('./GroupDeck.js');
require('react-bootstrap');
require('./iconBase-68959171.js');
require('./index.esm-90433435.js');
var getSerializers = require('./index-59af05c4.js');
require('./util-f2c1b65b.js');
require('./brightcove-react-player-loader.es-156bd4d6.js');
require('next/head');
require('react-share');
require('./SocialShare.js');
require('./_object-to-array-9bac8737.js');
require('react-bootstrap/Pagination');
require('react-bootstrap/Figure');
require('react-bootstrap/OverlayTrigger');
require('react-bootstrap/Tooltip');
require('react-bootstrap/Popover');
var index$4 = require('./index-3294d3bc.js');

var ExternalResources = function ExternalResources(props) {
  var resources = props.resources,
      display = props.display,
      client = props.client,
      _props$cta = props.cta,
      cta = _props$cta === undefined ? 'Learn More' : _props$cta,
      _props$url = props.url,
      url = _props$url === undefined ? 'resources' : _props$url,
      _props$recentTitle = props.recentTitle,
      recentTitle = _props$recentTitle === undefined ? 'Recent' : _props$recentTitle,
      _props$archiveTitle = props.archiveTitle,
      archiveTitle = _props$archiveTitle === undefined ? 'Archive' : _props$archiveTitle,
      _props$dispalyThumb = props.dispalyThumb,
      dispalyThumb = _props$dispalyThumb === undefined ? true : _props$dispalyThumb,
      _props$dateFormat = props.dateFormat,
      dateFormat = _props$dateFormat === undefined ? 'MMMM Do YYYY, h:mm a z' : _props$dateFormat,
      _props$showToggles = props.showToggles,
      showToggles = _props$showToggles === undefined ? true : _props$showToggles;

  var _useState = React.useState(display && (display === 'recent' || display === 'archived') ? display : 'recent'),
      _useState2 = slicedToArray._slicedToArray(_useState, 2),
      active = _useState2[0],
      setActive = _useState2[1];

  var router = Router.useRouter();
  React.useEffect(function () {
    router.push(router.pathname, '/' + url + '?display=' + active, { shallow: true });
  }, [active]);
  return React__default.createElement(
    'div',
    { id: 'resources' },
    showToggles && React__default.createElement(
      'div',
      { id: 'toggles' },
      React__default.createElement(
        'div',
        { onClick: function onClick() {
            return setActive(function () {
              return 'recent';
            });
          }, className: active === 'recent' ? 'active' : '' },
        recentTitle
      ),
      React__default.createElement(
        'div',
        { onClick: function onClick() {
            return setActive(function () {
              return 'archived';
            });
          }, className: active === 'archived' ? 'active' : '' },
        archiveTitle
      )
    ),
    resources[active].length > 0 ? resources[active].map(function (r) {
      return React__default.createElement(
        'div',
        { key: r._id, className: 'resource' },
        dispalyThumb && React__default.createElement(
          'div',
          { id: 'thumb' },
          React__default.createElement(
            'a',
            { href: r.destination, target: '_blank', rel: 'noopener noreferrer' },
            React__default.createElement('img', { src: r.thumbnail })
          )
        ),
        React__default.createElement(
          'div',
          { id: 'details' },
          React__default.createElement(
            'a',
            { href: r.destination, target: '_blank', rel: 'noopener noreferrer' },
            React__default.createElement(
              'p',
              { id: 'title' },
              r.title
            ),
            r.intro && React__default.createElement(
              'div',
              { id: 'intro' },
              React__default.createElement(BlockContent.BlockContent, _extends._extends({ serializers: getSerializers.getSerializers(client), blocks: r.intro }, client.config()))
            ),
            React__default.createElement(
              'div',
              { id: 'date' },
              React__default.createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Date:'
              ),
              React__default.createElement(
                'p',
                null,
                index$4.momentTimezone.tz(r.displayDate, 'America/New_York').format(dateFormat),
                ' ',
                r.endDate && '- ' + index$4.momentTimezone.tz(r.endDate, 'America/New_York').format(dateFormat)
              )
            ),
            r.speakers && React__default.createElement(
              'div',
              { id: 'speakers' },
              React__default.createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Speakers:'
              ),
              React__default.createElement(BlockContent.BlockContent, _extends._extends({ serializers: getSerializers.getSerializers(client), blocks: r.speakers }, client.config()))
            ),
            r.location && React__default.createElement(
              'div',
              { id: 'location' },
              React__default.createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Location:'
              ),
              r.location
            ),
            r.sponsor && React__default.createElement(
              'div',
              { id: 'sponsor' },
              React__default.createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Sponsors:'
              ),
              r.sponsor
            )
          ),
          React__default.createElement(
            Button,
            { id: 'cta', variant: 'secondary', href: r.destination, target: '_blank', rel: 'noopener noreferrer' },
            cta
          )
        )
      );
    }) : React__default.createElement(
      'p',
      null,
      'No content available.'
    ),
    React__default.createElement(
      'style',
      { jsx: true },
      '\n        .resource {\n          display: flex;\n          position: relative;\n          margin: 0 0 1rem 0;\n        }\n        .resource #thumb {\n          box-sizing: border-box;\n          padding: 0.5rem;\n          width: 25%;\n        }\n        .resource #thumb img {\n          width: 100%;\n        }\n        .resource #details {\n          box-sizing: border-box;\n          padding: 0.5rem;\n          width: 75%;\n        }\n        #resources .resource p {\n          margin: 0;\n        }\n        #toggles {\n          display: flex;\n          margin: 0 0 1rem 0;\n        }\n        #toggles > div {\n          padding: 0.5rem;\n          cursor: pointer;\n        }\n        #toggles > div:hover {\n          font-weight: bold;\n          border-bottom: 2px solid #cecece;\n        }\n        #toggles > div.active {\n          font-weight: bold;\n          border-bottom: 2px solid var(--primary);\n        }\n        .resource #title {\n          font-weight: bold;\n          font-size: 1.25rem;\n        }\n        .resource #date,\n        .resource #speakers,\n        .resource #location,\n        .resource #sponsor,\n        .resource #cta {\n          margin: 1rem 0 0 0;\n        }\n      '
    )
  );
};

module.exports = ExternalResources;
