'use strict';

require('./_commonjsHelpers-06173234.js');
require('./_to-object-329a650b.js');
require('./es6.string.iterator-cc0bbaa4.js');
require('./_library-dd23b178.js');
require('./_iter-detect-60b2f026.js');
require('./core.get-iterator-method-f62321d4.js');
require('./define-property-f4d12f4e.js');
require('./web.dom.iterable-a0e279c1.js');
var React = require('react');
require('prop-types');
require('./isSymbol-04666465.js');
require('./asyncToGenerator-140e5f89.js');
var Segment = require('./Segment.js');
var get = require('./get-adbb11e3.js');
require('./eq-bb2843ed.js');
var reactSocialIcons = require('./react-social-icons-07939b41.js');
var defineProperty = require('./defineProperty-55548b25.js');

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

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

var year = new Date().getFullYear();

var renderLink = function renderLink(row) {
  if (row.blank) {
    return React__default['default'].createElement(
      'a',
      defineProperty._defineProperty({ rel: 'noopener', href: row.url, needsegmentsupport: row.needSegmentSupport ? 'true' : '', target: '_blank' }, 'rel', 'noopener noreferrer'),
      row.title
    );
  }
  return React__default['default'].createElement(
    'a',
    { href: row.url, needsegmentsupport: row.needSegmentSupport ? 'true' : '' },
    row.title
  );
};

var SideFooter = function SideFooter(props) {
  /*
  useage example: <SideFooter cache={props.cache} logo='https://mjh-web.s3.amazonaws.com/_media/an_mjhls_brand_logo.png' />
  */
  var _get = get.get_1(props, 'cache.siteSettingCache', {}),
      socialLinks = _get.socialLinks,
      footerLinks = _get.footerLinks,
      name = _get.name,
      copyRightText = _get.copyRightText;

  var logo = props.logo,
      _props$showAddress = props.showAddress,
      showAddress = _props$showAddress === undefined ? false : _props$showAddress,
      _props$address = props.address,
      address = _props$address === undefined ? null : _props$address;

  var sfRef = React.useRef(null);

  React.useEffect(function () {
    // this adds ?eKey=xxx or ?anonymousid=xxx for forms that's outside - eg) formstack forms
    // for tracking same user
    setTimeout(function () {
      var segmentLinks = sfRef.current.querySelectorAll('a[needsegmentsupport="true"]');
      for (var i = 0; i < segmentLinks.length; i++) {
        var link = segmentLinks[i];
        var href = link.getAttribute('href');
        var newRef = Segment.getURL(href, { needSegmentSupport: true });
        link.setAttribute('href', newRef);
      }
    }, 1000);
  }, []);

  if (copyRightText) {
    name = copyRightText;
  }

  return React__default['default'].createElement(
    'div',
    { className: 'side-footer', ref: sfRef },
    React__default['default'].createElement(
      'ul',
      null,
      footerLinks && footerLinks.map(function (row, index) {
        return React__default['default'].createElement(
          'li',
          { key: index },
          renderLink(row)
        );
      }),
      React__default['default'].createElement(
        'li',
        { style: { marginTop: '10px' } },
        socialLinks && socialLinks.map(function (row, index) {
          return React__default['default'].createElement(reactSocialIcons.reactSocialIcons_1, {
            target: row.blank ? '_blank' : '_self',
            rel: 'noopener noreferrer',
            key: index,
            index: index,
            url: row.url
            // including network prop to identify the icon based on the social icon title.
            , network: row.title.split(' ')[0].toLowerCase(),
            style: { width: 30, height: 30, marginRight: 5 }
          });
        })
      )
    ),
    logo && React__default['default'].createElement(
      'ul',
      null,
      React__default['default'].createElement(
        'li',
        { className: 'pt-2' },
        React__default['default'].createElement(
          'a',
          { href: 'https://www.mjhlifesciences.com' },
          React__default['default'].createElement('img', { style: { maxWidth: '100%' }, alt: 'MJHLS Brand Logo', src: logo })
        )
      )
    ),
    showAddress && React__default['default'].createElement(
      'div',
      null,
      address ? address : React__default['default'].createElement(
        'p',
        null,
        '2 Clarke Drive',
        React__default['default'].createElement('br', null),
        'Suite 100',
        React__default['default'].createElement('br', null),
        'Cranbury, NJ 08512'
      )
    ),
    React__default['default'].createElement(
      'p',
      null,
      '\xA9 ',
      year,
      ' MJH Life Sciences',
      React__default['default'].createElement(
        'sup',
        null,
        '\u2122'
      ),
      ' ',
      name && name.toLowerCase().includes(' and ') ? ', ' : ' and ',
      name,
      '. All rights reserved.'
    )
  );
};

module.exports = SideFooter;
