import React from 'react';
import { ReactSVG } from 'react-svg';
import cx from 'classnames';
import * as Icons from '@dragonchain-dev/dragon-kit-icons';
import { LinkTo } from '../LinkTo';

var Footer = function Footer(_ref) {
  var entity = _ref.entity,
      links = _ref.links,
      logo = _ref.logo,
      _ref$large = _ref.large,
      large = _ref$large === void 0 ? false : _ref$large,
      social = _ref.social,
      tagline = _ref.tagline,
      _ref$usaFlag = _ref.usaFlag,
      usaFlag = _ref$usaFlag === void 0 ? true : _ref$usaFlag,
      children = _ref.children;

  var renderLinkGroup = function renderLinkGroup(rawLinkSet) {
    // TODO: cleanup logic here
    var linkSet = [];
    var linkChildren = [];
    var i = 1;
    var n = rawLinkSet.length - 1;
    rawLinkSet.map(function (link, index) {
      var blank = link.blank,
          name = link.name,
          type = link.type,
          url = link.url;
      linkChildren.push( /*#__PURE__*/React.createElement("li", {
        key: name
      }, /*#__PURE__*/React.createElement(LinkTo, {
        type: type,
        url: url,
        blank: blank
      }, name)));

      if (i === 4 || index === n) {
        linkSet.push( /*#__PURE__*/React.createElement("ul", {
          key: "set-" + link.name
        }, linkChildren));
        linkChildren = [];
        i = 0;
      }

      i += 1;
      return '';
    });
    return linkSet;
  };

  var socialLink = function socialLink() {
    return Object.keys(social).map(function (keyName, i) {
      var icon = keyName.charAt(0).toUpperCase() + keyName.slice(1);
      var Tag = Icons[icon];
      return /*#__PURE__*/React.createElement("li", {
        key: i
      }, /*#__PURE__*/React.createElement(LinkTo, {
        type: "link",
        url: social[keyName],
        blank: true
      }, /*#__PURE__*/React.createElement(Tag, {
        color: "dark-blue",
        size: "large"
      })));
    });
  };

  var year = new Date().getFullYear();
  var logoClass = cx(large ? 'logo-large' : 'logo');
  return /*#__PURE__*/React.createElement("footer", {
    className: "footer"
  }, /*#__PURE__*/React.createElement("div", {
    className: "inner"
  }, /*#__PURE__*/React.createElement("div", {
    className: "promise"
  }, /*#__PURE__*/React.createElement("div", {
    className: "inner"
  }, /*#__PURE__*/React.createElement("div", {
    className: logoClass
  }, /*#__PURE__*/React.createElement(ReactSVG, {
    src: logo
  })), tagline && /*#__PURE__*/React.createElement("div", {
    className: "tagline"
  }, tagline), /*#__PURE__*/React.createElement("div", {
    className: "copyright"
  }, "Copyright \xA9 " + year + " " + entity + ". All rights reserved."), /*#__PURE__*/React.createElement("div", {
    className: "colors"
  }, /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null)))), /*#__PURE__*/React.createElement("div", {
    className: "links"
  }, links && /*#__PURE__*/React.createElement("div", {
    className: "dragonchain-links"
  }, renderLinkGroup(links)), social && /*#__PURE__*/React.createElement("div", {
    className: "social-links"
  }, /*#__PURE__*/React.createElement("ul", null, socialLink()))), /*#__PURE__*/React.createElement("div", {
    className: "fine-print"
  }, children && /*#__PURE__*/React.createElement("div", {
    className: "disclaimer"
  }, children), children && usaFlag && /*#__PURE__*/React.createElement("div", {
    className: "location"
  }, /*#__PURE__*/React.createElement(Icons.Usa, {
    color: "plain",
    className: "flag-usa"
  }), /*#__PURE__*/React.createElement("div", {
    className: "country"
  }, "U.S. Based")))));
};

Footer.displayName = 'Footer';
var FooterDoc;

if (process.env.NODE_ENV !== 'production') {
  // eslint-disable-next-line global-require
  FooterDoc = require('./doc').doc(Footer);
}

var FooterWrapper = FooterDoc || Footer;
export { FooterWrapper as Footer };