function _extends() { _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; }; return _extends.apply(this, arguments); }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

import React from 'react';
import cx from 'classnames';
import { Illustration } from '../Illustration';

var Half = function Half(_ref) {
  var _ref$illustration = _ref.illustration,
      illustration = _ref$illustration === void 0 ? {
    center: false,
    middle: false
  } : _ref$illustration,
      _ref$photo = _ref.photo,
      photo = _ref$photo === void 0 ? {
    middle: false
  } : _ref$photo,
      _ref$center = _ref.center,
      center = _ref$center === void 0 ? false : _ref$center,
      _ref$middle = _ref.middle,
      middle = _ref$middle === void 0 ? false : _ref$middle,
      _ref$stack = _ref.stack,
      stack = _ref$stack === void 0 ? false : _ref$stack,
      children = _ref.children,
      rest = _objectWithoutPropertiesLoose(_ref, ["illustration", "photo", "center", "middle", "stack", "children"]);

  var Content = function Content() {
    var contentClasses = cx('content', center && 'center', middle && 'middle');
    if (!stack && !!illustration.src) return /*#__PURE__*/React.createElement(React.Fragment, null);
    return /*#__PURE__*/React.createElement("div", {
      className: contentClasses
    }, /*#__PURE__*/React.createElement("div", {
      className: "inner"
    }, children));
  };

  var ShowIllustration = function ShowIllustration() {
    if (!illustration.src) return /*#__PURE__*/React.createElement(React.Fragment, null);
    if (!stack && !illustration.src) return /*#__PURE__*/React.createElement(React.Fragment, null);
    var illustrationClasses = cx('illustration', illustration.middle && 'middle', illustration.center && 'center');
    return /*#__PURE__*/React.createElement(Illustration, {
      className: illustrationClasses,
      src: illustration.src
    });
  };

  var Photo = function Photo() {
    if (!photo) return /*#__PURE__*/React.createElement(React.Fragment, null);
    if (!stack && !photo.src) return /*#__PURE__*/React.createElement(React.Fragment, null);
    var photoClasses = cx('photo', photo.middle && 'middle');
    return /*#__PURE__*/React.createElement("div", {
      className: photoClasses
    }, /*#__PURE__*/React.createElement("img", {
      src: photo.src,
      alt: ""
    }));
  };

  var halfClasses = cx('half', stack && 'stack');
  return /*#__PURE__*/React.createElement("div", _extends({
    className: halfClasses
  }, rest), /*#__PURE__*/React.createElement(Photo, null), /*#__PURE__*/React.createElement(ShowIllustration, null), /*#__PURE__*/React.createElement(Content, null));
};

Half.displayName = 'Half';
var HalfDoc;

if (process.env.NODE_ENV !== 'production') {
  // eslint-disable-next-line global-require
  HalfDoc = require('./doc').doc(Half);
}

var HalfWrapper = HalfDoc || Half;
export { HalfWrapper as Half };