import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["children", "className", "image", "isExternal", "isLink", "metadata", "more", "subTitle", "title", "kind", "url"];
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import { settings } from '../../globals/js';
var prefix = settings.prefix;
/**
 * Hero are a convenient means of displaying content composed of different types of objects. It is a multi usage component which creates boxes that are usually teasing some kind of content. */

var Hero = function Hero(_ref) {
  var _classNames;

  var children = _ref.children,
      className = _ref.className,
      image = _ref.image,
      isExternal = _ref.isExternal,
      isLink = _ref.isLink,
      metadata = _ref.metadata,
      more = _ref.more,
      subTitle = _ref.subTitle,
      title = _ref.title,
      kind = _ref.kind,
      url = _ref.url,
      other = _objectWithoutProperties(_ref, _excluded);

  var style = kind !== 'related' ? {
    backgroundImage: "url(".concat(image, ")")
  } : {};
  var wrapperClasses = classNames("".concat(prefix, "--photo-card"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "--photo-card--").concat(kind), kind), _defineProperty(_classNames, "".concat(prefix, "--photo-card--no-background"), !image), _defineProperty(_classNames, "".concat(prefix, "--photo-card--link"), isLink), _defineProperty(_classNames, "".concat(className), className), _classNames));
  var content = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefix, "--photo-card__background"),
    style: style
  }), image && kind === 'related' && /*#__PURE__*/React.createElement("img", {
    src: image,
    alt: title
  }), /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefix, "--photo-card__info")
  }, /*#__PURE__*/React.createElement("div", null, (kind === 'landscape' || kind === 'hero') && /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefix, "--photo-card__info__background"),
    style: style
  }), metadata && /*#__PURE__*/React.createElement("p", {
    className: "".concat(prefix, "--photo-card__info__metadata")
  }, metadata), title && (kind === 'hero' || kind === 'page-splash') && /*#__PURE__*/React.createElement("h2", {
    className: "".concat(prefix, "--photo-card__info__title")
  }, title), title && kind !== 'hero' && kind !== 'page-splash' && /*#__PURE__*/React.createElement("h3", {
    className: "".concat(prefix, "--photo-card__info__title")
  }, title), subTitle && /*#__PURE__*/React.createElement("p", {
    className: "".concat(prefix, "--photo-card__info__subtitle")
  }, subTitle)), kind === 'hero' || kind === 'splash-image' || kind === 'splash-compact' && /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefix, "--photo-card__info__more")
  }, more)), children);
  return isLink ? /*#__PURE__*/React.createElement("a", _extends({
    href: url,
    target: isExternal ? '_blank' : '',
    className: wrapperClasses
  }, other), content) : /*#__PURE__*/React.createElement("div", _extends({
    className: wrapperClasses
  }, other), content);
};

Hero.propTypes = {
  /**
   Additional className which will be added
  */
  className: PropTypes.string,

  /**
   The links target
  */
  href: PropTypes.string,

  /**
   An optimized photograph
  */
  image: PropTypes.string,

  /**
  External link flag
  */
  isExternal: PropTypes.bool,

  /**
  Render the Hero as link
  */
  isLink: PropTypes.bool,

  /**
  A short sentence to explain the content of the node (max 180 characters) 
  */
  subTitle: PropTypes.node,

  /**
   A search-friendly title (ideally 50 characters, max 100) 
  */
  title: PropTypes.node,

  /**
  Additional metadatas
  */
  metadata: PropTypes.string,

  /**
  Additional more content
  */
  more: PropTypes.node,

  /**
  Kind of Hero
  */
  kind: PropTypes.oneOf(['landscape', 'landscape-light', 'emergencies', 'split', 'hero', 'splash', 'splash-image', 'splash-compact', 'related']).isRequired,

  /**
  The URL where the content uploaded is located.
  */
  url: PropTypes.string
};
Hero.defaultProps = {
  isLink: true
};
export default Hero;