'use strict';

exports.__esModule = true;

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

require('./style.css');

var _index = require('../../../index');

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

var FooterLinks = function FooterLinks(footerLinks) {
  return _react2.default.createElement(
    'section',
    { className: 'ma__footer-links' },
    footerLinks.items.map(function (footerLinksNav, i) {
      return (
        /* eslint-disable-next-line react/no-array-index-key */
        _react2.default.createElement(FooterLinksNav, _extends({}, footerLinksNav, { showNavHeading: footerLinks.showNavHeading, key: 'footerLinksNav_' + i, index: i }))
      );
    })
  );
};

var FooterLinksNav = function FooterLinksNav(footerLinksNav) {
  return _react2.default.createElement(
    'nav',
    { 'aria-labelledby': footerLinksNav.id, className: 'ma__footer-links__items' + (footerLinksNav.showNavHeading ? ' ma__footer-links__items--heading' : '') },
    footerLinksNav.showNavHeading ? _react2.default.createElement(_index.SidebarHeading, { title: footerLinksNav.heading, level: 2 }) : _react2.default.createElement(
      'h2',
      { className: 'visually-hidden', id: footerLinksNav.id },
      footerLinksNav.heading
    ),
    _react2.default.createElement(
      'ul',
      null,
      footerLinksNav.links.map(function (link, i) {
        return (
          /* eslint-disable-next-line react/no-array-index-key */
          _react2.default.createElement(FooterLink, _extends({}, link, { key: 'footerLink_' + i }))
        );
      })
    )
  );
};

var FooterLink = function FooterLink(footerLink) {
  return _react2.default.createElement(
    'li',
    { className: 'ma__footer-links__item' },
    _react2.default.createElement(
      'a',
      { href: footerLink.href, className: 'ma__footer-links__link' },
      footerLink.text
    )
  );
};

FooterLink.propTypes = process.env.NODE_ENV !== "production" ? {
  /** The URL for the link */
  href: _propTypes2.default.string.isRequired,
  /** The text for the link */
  text: _propTypes2.default.string.isRequired
} : {};

FooterLinksNav.propTypes = process.env.NODE_ENV !== "production" ? {
  /** The unique ID for the column of links */
  id: _propTypes2.default.string.isRequired,
  /** The text for the heading above the column of links, visually hidden from users */
  heading: _propTypes2.default.string.isRequired,
  /** The links in the column */
  links: _propTypes2.default.arrayOf(_propTypes2.default.shape(FooterLink.propTypes)).isRequired
} : {};

FooterLinks.propTypes = process.env.NODE_ENV !== "production" ? {
  /** The columns of the nav links */
  items: _propTypes2.default.arrayOf(_propTypes2.default.shape(FooterLinksNav.propTypes)).isRequired
} : {};

exports.default = FooterLinks;
module.exports = exports['default'];