import './_commonjsHelpers-0c4b6f40.js';
import './core.get-iterator-method-86d4db69.js';
import './_library-528f1934.js';
import './_iter-detect-130ee549.js';
import './define-property-6d26cb48.js';
import './web.dom.iterable-f8f967cd.js';
import React, { useRef, useEffect } from 'react';
import 'prop-types';
import './isSymbol-1981418f.js';
import './asyncToGenerator-64812e90.js';
import Segment from './Segment.js';
import { g as get_1 } from './get-1e515072.js';
import './eq-b470f743.js';
import { r as reactSocialIcons_1 } from './react-social-icons-3822f1ce.js';
import { _ as _defineProperty } from './defineProperty-d7d9b577.js';

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

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

export default SideFooter;
