import _uniqueId from "lodash/fp/uniqueId";
import _map from "lodash/fp/map";
import _isEmpty from "lodash/fp/isEmpty";
import _getOr from "lodash/fp/getOr";
import _get from "lodash/fp/get";
import React from 'react';
import PropTypes from 'prop-types';
import { NovaCompositionNavigationArrowRight as ArrowRight, NovaCompositionNavigationArrowDown as ArrowDown } from '@coorpacademy/nova-icons';
import SocialLink from '../../atom/social-link';
import Provider from '../../atom/provider';
import CatalogSection from '../../atom/catalog-section';
import Picture from '../../atom/picture';
import style from './style.css';
const DisciplinePartners = (props, context) => {
  const {
    translate,
    skin
  } = context;
  const {
    authorTitle,
    authors = []
  } = props;
  const authorLabel = authorTitle || translate('author');
  const defaultColor = _get('common.primary', skin);
  const authorsView = _map.convert({
    cap: false
  })((author, index) => {
    const socialLinks = _getOr([], 'socialLinks', author);
    const authorLogo = _get('logo', author);
    const authorHref = _get('href', author);
    const moreDetails = _get('more', author);
    const autName = _get('name', author);
    const authorToggleId = _uniqueId('author-toggle-');
    const linkView = /*#__PURE__*/React.createElement("div", {
      className: style.authorLink
    }, /*#__PURE__*/React.createElement("a", {
      target: "_blank",
      rel: "noopener noreferrer",
      style: {
        color: defaultColor
      },
      href: authorHref
    }, authorHref));
    const moreInfoView = /*#__PURE__*/React.createElement("div", {
      className: style.authorLink
    }, /*#__PURE__*/React.createElement("a", {
      href: authorHref,
      style: {
        color: defaultColor
      }
    }, moreDetails, /*#__PURE__*/React.createElement(ArrowRight, {
      style: {
        color: defaultColor
      },
      className: style.linkicon
    })));
    const socialView = socialLinks.map((social, i) => /*#__PURE__*/React.createElement("div", {
      key: i,
      className: style.link
    }, /*#__PURE__*/React.createElement(SocialLink, social)));
    const aNameView = autName ? /*#__PURE__*/React.createElement("div", {
      "data-name": "authorName",
      className: style.authorName
    }, autName) : null;
    const logoView = authorLogo ? /*#__PURE__*/React.createElement("div", {
      className: style.logoContainer
    }, /*#__PURE__*/React.createElement(Picture, {
      className: style.logo,
      src: authorLogo.src,
      alt: authorLogo.alt
    }), /*#__PURE__*/React.createElement("div", {
      className: style.arrowWrapper
    }, /*#__PURE__*/React.createElement(ArrowDown, {
      className: style.arrow,
      height: 14,
      whidth: 14
    }))) : null;
    const authorContent = authorHref || aNameView || socialView ? /*#__PURE__*/React.createElement("div", {
      className: style.authorContent
    }, autName ? aNameView : null, moreDetails ? moreInfoView : null, !moreDetails && authorHref ? linkView : null, /*#__PURE__*/React.createElement("div", {
      className: style.links
    }, socialView)) : null;
    return /*#__PURE__*/React.createElement("div", {
      key: index,
      className: style.authorWrapper
    }, /*#__PURE__*/React.createElement("input", {
      type: "checkbox",
      id: authorToggleId,
      className: style.toggle,
      defaultChecked: true
    }), /*#__PURE__*/React.createElement("label", {
      htmlFor: authorToggleId
    }, logoView), authorContent);
  }, authors);
  return !_isEmpty(authors) ? /*#__PURE__*/React.createElement("div", {
    "data-name": "disciplinePartner",
    className: style.colDetails
  }, /*#__PURE__*/React.createElement(CatalogSection, {
    title: authorLabel
  }, authorsView)) : null;
};
DisciplinePartners.contextTypes = {
  translate: Provider.childContextTypes.translate,
  skin: Provider.childContextTypes.skin
};
DisciplinePartners.propTypes = process.env.NODE_ENV !== "production" ? {
  authors: PropTypes.arrayOf(PropTypes.shape({
    name: PropTypes.string,
    href: PropTypes.string,
    logo: PropTypes.shape({
      src: PropTypes.string,
      href: PropTypes.string,
      alt: PropTypes.string
    }),
    socialLinks: PropTypes.arrayOf(PropTypes.shape(SocialLink.propTypes))
  })),
  authorTitle: PropTypes.string
} : {};
export default DisciplinePartners;
//# sourceMappingURL=index.js.map