'use strict';

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-7df78678.js');
require('./_object-sap-171b9ea5.js');
require('./inherits-420ee86f.js');
require('./define-property-21887c62.js');
require('./web.dom.iterable-e34bf324.js');
require('./typeof-ec08d471.js');
require('./_is-array-aa52fa1e.js');
var React = require('react');
require('./index-44481153.js');
require('prop-types');
require('react-bootstrap/Row');
require('react-bootstrap/Col');
require('./moment-ca3bd9fb.js');
var Router = require('next/router');
require('./isSymbol-04666465.js');
require('./debounce-529c8d06.js');
require('./toNumber-36d1e7e5.js');
require('react-dom');
var slicedToArray = require('./slicedToArray-f6d4eaa8.js');
require('./index-b5eb3ff8.js');
require('./urlFor.js');
require('./index-9d365128.js');
require('./main-7b5e57b0.js');
require('./entities-310b46ee.js');
require('./stringify-bbc68047.js');
require('./asyncToGenerator-df19209d.js');
require('./Segment.js');
require('./Beam.js');
require('./AdSlot.js');
var Button = require('react-bootstrap/Button');
var BlockContent = require('./BlockContent-8b494587.js');
require('./index-187c967e.js');
require('./smoothscroll-5054361f.js');
require('./GroupDeck.js');
require('react-bootstrap');
require('./iconBase-68959171.js');
require('./index.esm-48e0f0d8.js');
var getSerializers = require('./index-32808e3c.js');
require('./util-f2c1b65b.js');
require('./brightcove-react-player-loader.es-5c98aec7.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');
require('react-script-tag');
var index = require('./index-99edf08a.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);

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['default'].createElement(
    'div',
    { id: 'resources' },
    showToggles && React__default['default'].createElement(
      'div',
      { id: 'toggles' },
      React__default['default'].createElement(
        'div',
        { onClick: function onClick() {
            return setActive(function () {
              return 'recent';
            });
          }, className: active === 'recent' ? 'active' : '' },
        recentTitle
      ),
      React__default['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['default'].createElement(
        'div',
        { key: r._id, className: 'resource' },
        dispalyThumb && React__default['default'].createElement(
          'div',
          { id: 'thumb' },
          React__default['default'].createElement(
            'a',
            { href: r.destination, target: '_blank', rel: 'noopener noreferrer' },
            React__default['default'].createElement('img', { src: r.thumbnail })
          )
        ),
        React__default['default'].createElement(
          'div',
          { id: 'details' },
          React__default['default'].createElement(
            'a',
            { href: r.destination, target: '_blank', rel: 'noopener noreferrer' },
            React__default['default'].createElement(
              'p',
              { id: 'title' },
              r.title
            ),
            r.intro && React__default['default'].createElement(
              'div',
              { id: 'intro' },
              React__default['default'].createElement(BlockContent.BlockContent, _extends._extends({ serializers: getSerializers.getSerializers(client), blocks: r.intro }, client.config()))
            ),
            React__default['default'].createElement(
              'div',
              { id: 'date' },
              React__default['default'].createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Date:'
              ),
              React__default['default'].createElement(
                'p',
                null,
                index.momentTimezone.tz(r.displayDate, 'America/New_York').format(dateFormat),
                ' ',
                r.endDate && '- ' + index.momentTimezone.tz(r.endDate, 'America/New_York').format(dateFormat)
              )
            ),
            r.speakers && React__default['default'].createElement(
              'div',
              { id: 'speakers' },
              React__default['default'].createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Speakers:'
              ),
              React__default['default'].createElement(BlockContent.BlockContent, _extends._extends({ serializers: getSerializers.getSerializers(client), blocks: r.speakers }, client.config()))
            ),
            r.location && React__default['default'].createElement(
              'div',
              { id: 'location' },
              React__default['default'].createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Location:'
              ),
              r.location
            ),
            r.sponsor && React__default['default'].createElement(
              'div',
              { id: 'sponsor' },
              React__default['default'].createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Sponsors:'
              ),
              r.sponsor
            )
          ),
          React__default['default'].createElement(
            Button__default['default'],
            { id: 'cta', variant: 'secondary', href: r.destination, target: '_blank', rel: 'noopener noreferrer' },
            cta
          )
        )
      );
    }) : React__default['default'].createElement(
      'p',
      null,
      'No content available.'
    ),
    React__default['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;
