"use strict";

exports.__esModule = true;
exports.Footer = void 0;

var _react = _interopRequireDefault(require("react"));

var _reactSvg = require("react-svg");

var _classnames = _interopRequireDefault(require("classnames"));

var _LinkTo = require("../LinkTo");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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(_react.default.createElement("li", {
        key: name
      }, _react.default.createElement(_LinkTo.LinkTo, {
        type: type,
        url: url,
        blank: blank
      }, name)));

      if (i === 4 || index === n) {
        linkSet.push(_react.default.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) {
      return _react.default.createElement("li", {
        key: i
      }, _react.default.createElement(_LinkTo.LinkTo, {
        type: "link",
        className: "footer-" + keyName,
        url: social[keyName],
        blank: true
      }));
    });
  };

  var year = new Date().getFullYear();
  var logoClass = (0, _classnames.default)(large ? 'logo-large' : 'logo');
  return _react.default.createElement("footer", {
    className: "footer"
  }, _react.default.createElement("div", {
    className: "inner"
  }, _react.default.createElement("div", {
    className: "promise"
  }, _react.default.createElement("div", {
    className: "inner"
  }, _react.default.createElement("div", {
    className: logoClass
  }, _react.default.createElement(_reactSvg.ReactSVG, {
    src: logo
  })), tagline && _react.default.createElement("div", {
    className: "tagline"
  }, tagline), _react.default.createElement("div", {
    className: "copyright"
  }, "Copyright \xA9 " + year + " " + entity + ", Inc. All rights reserved."), _react.default.createElement("div", {
    className: "colors"
  }, _react.default.createElement("div", null), _react.default.createElement("div", null), _react.default.createElement("div", null), _react.default.createElement("div", null), _react.default.createElement("div", null), _react.default.createElement("div", null)))), _react.default.createElement("div", {
    className: "links"
  }, links && _react.default.createElement("div", {
    className: "dragonchain-links"
  }, renderLinkGroup(links)), social && _react.default.createElement("div", {
    className: "social-links"
  }, _react.default.createElement("ul", null, socialLink()))), _react.default.createElement("div", {
    className: "fine-print"
  }, children && _react.default.createElement("div", {
    className: "disclaimer"
  }, children), children && usaFlag && _react.default.createElement("div", {
    className: "location"
  }, _react.default.createElement("div", {
    className: "flag-usa"
  }), _react.default.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;
exports.Footer = FooterWrapper;