import './_commonjsHelpers-0c4b6f40.js';
import './_to-object-a4107da3.js';
import './es6.string.iterator-c990c18c.js';
import './_library-528f1934.js';
import './_iter-detect-5d49a330.js';
import './core.get-iterator-method-e1de7503.js';
import './define-property-8af5f002.js';
import './web.dom.iterable-4439f05a.js';
import React__default, { useRef, useEffect } from 'react';
import 'prop-types';
import './isSymbol-807e927e.js';
import './asyncToGenerator-502f13b4.js';
import './_set-species-3f8319f5.js';
import Segment from './Segment.js';
import { g as get_1 } from './get-5ee14cda.js';
import { r as reactSocialIcons_1 } from './react-social-icons-a7d5c5c7.js';
import { _ as _defineProperty } from './defineProperty-94fd8bfc.js';

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

var renderLink = function renderLink(row) {
  if (row.blank) {
    return React__default.createElement(
      'a',
      _defineProperty({ rel: 'noopener', href: row.url, needsegmentsupport: row.needSegmentSupport ? 'true' : '', target: '_blank' }, 'rel', 'noopener noreferrer'),
      row.title
    );
  }
  return React__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_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 = useRef(null);

  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.createElement(
    'div',
    { className: 'side-footer', ref: sfRef },
    React__default.createElement(
      'ul',
      null,
      footerLinks && footerLinks.map(function (row, index) {
        return React__default.createElement(
          'li',
          { key: index },
          renderLink(row)
        );
      }),
      React__default.createElement(
        'li',
        { style: { marginTop: '10px' } },
        socialLinks && socialLinks.map(function (row, index) {
          return React__default.createElement(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.createElement(
      'ul',
      null,
      React__default.createElement(
        'li',
        { className: 'pt-2' },
        React__default.createElement(
          'a',
          { href: 'https://www.mjhlifesciences.com' },
          React__default.createElement('img', { style: { maxWidth: '100%' }, alt: 'MJHLS Brand Logo', src: logo })
        )
      )
    ),
    showAddress && React__default.createElement(
      'div',
      null,
      address ? address : React__default.createElement(
        'p',
        null,
        '2 Clarke Drive',
        React__default.createElement('br', null),
        'Suite 100',
        React__default.createElement('br', null),
        'Cranbury, NJ 08512'
      )
    ),
    React__default.createElement(
      'p',
      null,
      '\xA9 ',
      year,
      ' MJH Life Sciences',
      React__default.createElement(
        'sup',
        null,
        '\u2122'
      ),
      ' ',
      name && name.toLowerCase().includes(' and ') ? ', ' : ' and ',
      name,
      '. All rights reserved.'
    )
  );
};

export default SideFooter;
