"use strict";

exports.__esModule = true;
exports.default = void 0;
var _isEmpty2 = _interopRequireDefault(require("lodash/fp/isEmpty"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _novaIcons = require("@coorpacademy/nova-icons");
var _link = _interopRequireDefault(require("../../atom/link"));
var _socialLink = _interopRequireDefault(require("../../atom/social-link"));
var _picture = _interopRequireDefault(require("../../atom/picture"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const socialLinksTypes = process.env.NODE_ENV !== "production" ? ['facebook', 'twitter', 'linkedin', 'youtube', 'instagram'] : {};
const StoresLinks = ({
  onAppStoreButtonClick,
  appStoreButtonImageUrl,
  playStoreButtonImageUrl,
  onPlayStoreButtonClick,
  'android-alt': androidAlt,
  'ios-alt': iosAlt
}) => /*#__PURE__*/_react.default.createElement("div", {
  className: _style.default.storeLinksContainer
}, /*#__PURE__*/_react.default.createElement(_picture.default, {
  className: _style.default.imgApple,
  src: appStoreButtonImageUrl,
  onClick: onAppStoreButtonClick,
  alt: iosAlt
}), /*#__PURE__*/_react.default.createElement(_picture.default, {
  className: _style.default.img,
  src: playStoreButtonImageUrl,
  onClick: onPlayStoreButtonClick,
  alt: androidAlt
}));
StoresLinks.propTypes = process.env.NODE_ENV !== "production" ? {
  onAppStoreButtonClick: _propTypes.default.func,
  appStoreButtonImageUrl: _propTypes.default.string,
  playStoreButtonImageUrl: _propTypes.default.string,
  onPlayStoreButtonClick: _propTypes.default.func,
  'android-alt': _propTypes.default.string,
  'ios-alt': _propTypes.default.string
} : {};
function MoocFooter(props) {
  const {
    headSection = {},
    socialLinks = [],
    'logo-aria-label': logoAriaLabel,
    'social-links-aria-label': socialLinksAriaLabel,
    siteMapSections = []
  } = props;

  // Header section of the footer (the marketing banner)

  const headSectionView = !(0, _isEmpty2.default)(headSection) ? /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "headSpacingContainer",
    className: _style.default.headSpacingContainer
  }, /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "headSection",
    className: _style.default.headSectionWrapper
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.logoAndLabelWrapper
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.logoWrapper
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademyCoorpApp, {
    className: _style.default.coorpAppLogo,
    "aria-label": headSection['logo-aria-label']
  })), /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "mobile-marketing-text",
    className: _style.default.marketingLabel
  }, headSection.title)), /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "mobile-apps-buttons-wrapper",
    className: _style.default.mobileAppLinks
  }, /*#__PURE__*/_react.default.createElement(StoresLinks
  // ignored due to naming conventions in JSX rather than a linting error
  // eslint-disable-next-line react/jsx-handler-names
  , {
    onAppStoreButtonClick: headSection.onAppStoreButtonClick,
    appStoreButtonImageUrl: headSection.appStoreButtonImageUrl,
    playStoreButtonImageUrl: headSection.playStoreButtonImageUrl
    // eslint-disable-next-line react/jsx-handler-names
    ,
    onPlayStoreButtonClick: headSection.onPlayStoreButtonClick,
    "android-alt": headSection['android-alt'],
    "ios-alt": headSection['ios-alt']
  })))) : null;

  // Sitemap section of the footer (contains HELP, TOOLBOX... and other pages, as well as social links)

  const renderPagesFromSection = pages => {
    return /*#__PURE__*/_react.default.createElement("ul", {
      className: _style.default.pagesList,
      "data-name": "pages-list"
    }, pages.map((page, pindex) => {
      const handleClick = page.onClick;
      return /*#__PURE__*/_react.default.createElement("li", {
        key: pindex
      }, /*#__PURE__*/_react.default.createElement(_link.default, {
        href: page.link,
        onClick: handleClick,
        title: page.title,
        "data-text": page.title,
        className: _style.default.pageLink,
        target: page.target,
        "aria-label": page.ariaLabel ? page.ariaLabel : page.title,
        "data-name": page.title
      }, page.title));
    }));
  };
  const sections = !(0, _isEmpty2.default)(siteMapSections) ? siteMapSections.map((section, index) => {
    return /*#__PURE__*/_react.default.createElement("nav", {
      key: index,
      className: _style.default.sectionWrapper
    }, /*#__PURE__*/_react.default.createElement("p", {
      className: _style.default.sectionTitle
    }, section.title), renderPagesFromSection(section.pages));
  }) : null;
  const socialLinksView = socialLinks.map((socialLink, index) => {
    return /*#__PURE__*/_react.default.createElement("li", {
      className: _style.default.socialLink,
      key: index
    }, /*#__PURE__*/_react.default.createElement(_socialLink.default, {
      type: socialLink.type,
      link: socialLink.link,
      mode: "footer",
      "aria-label": socialLink['aria-label']
    }));
  });
  const socialNetworks = /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "logo-social-networks-container",
    className: _style.default.logoSocialNetworksContainer
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademyCoorpLogo, {
    className: _style.default.coorpLogo,
    "data-name": "coorp-social-networks-logo",
    "aria-label": logoAriaLabel
  }), /*#__PURE__*/_react.default.createElement("ul", {
    "data-name": "social-networks-wrapper",
    className: _style.default.socialNetworksWrapper,
    "aria-label": socialLinksAriaLabel
  }, socialLinksView));
  const siteMap = /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "site-map-spacing-container",
    className: _style.default.siteMapSpacingContainer
  }, /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "site-map",
    className: _style.default.siteMapContainer
  }, /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "sections",
    className: _style.default.sectionsContainer
  }, sections), socialNetworks));
  return /*#__PURE__*/_react.default.createElement("footer", {
    "data-name": "mooc-footer"
  }, headSectionView, siteMap);
}
MoocFooter.propTypes = process.env.NODE_ENV !== "production" ? {
  headSection: _propTypes.default.shape({
    title: _propTypes.default.string,
    onAppStoreButtonClick: _propTypes.default.func,
    appStoreButtonImageUrl: _propTypes.default.string,
    playStoreButtonImageUrl: _propTypes.default.string,
    onPlayStoreButtonClick: _propTypes.default.func,
    'logo-aria-label': _propTypes.default.string,
    'android-alt': _propTypes.default.string,
    'ios-alt': _propTypes.default.string
  }),
  siteMapSections: _propTypes.default.arrayOf(_propTypes.default.shape({
    title: _propTypes.default.string,
    pages: _propTypes.default.arrayOf(_propTypes.default.shape({
      title: _propTypes.default.string,
      link: _propTypes.default.string,
      target: _propTypes.default.string,
      ariaLabel: _propTypes.default.string
    }))
  })),
  socialLinks: _propTypes.default.arrayOf(_propTypes.default.shape({
    type: _propTypes.default.oneOf(socialLinksTypes),
    link: _propTypes.default.string,
    onClick: _propTypes.default.func,
    'aria-label': _propTypes.default.string
  })),
  'logo-aria-label': _propTypes.default.string,
  'social-links-aria-label': _propTypes.default.string
} : {};
var _default = exports.default = MoocFooter;
//# sourceMappingURL=index.js.map