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 { ReactSVG } from 'react-svg';

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

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

  var Illustration = function Illustration() {
    if (!illustration) return /*#__PURE__*/React.createElement(React.Fragment, null);
    var illustrationClasses = cx('illustration', illustration.match(/.svg$/g) && 'center');
    var Tag = illustration.match(/.svg$/g) ? ReactSVG : 'img';
    if (!stack && !illustration) return /*#__PURE__*/React.createElement(React.Fragment, null);
    return /*#__PURE__*/React.createElement("div", {
      className: illustrationClasses
    }, /*#__PURE__*/React.createElement(Tag, {
      src: illustration,
      alt: ""
    }));
  };

  var halfClasses = cx('half', stack && 'stack');
  return /*#__PURE__*/React.createElement("div", _extends({
    className: halfClasses
  }, rest), /*#__PURE__*/React.createElement(Illustration, 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 };