"use strict";

exports.__esModule = true;
exports.Half = void 0;

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _reactSvg = require("react-svg");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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; }

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 = (0, _classnames.default)('content', center && 'center');
    if (!stack && !!illustration) return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
    return /*#__PURE__*/_react.default.createElement("div", {
      className: contentClasses
    }, children);
  };

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

  var halfClasses = (0, _classnames.default)('half', stack && 'stack');
  return /*#__PURE__*/_react.default.createElement("div", _extends({
    className: halfClasses
  }, rest), /*#__PURE__*/_react.default.createElement(Illustration, null), /*#__PURE__*/_react.default.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;
exports.Half = HalfWrapper;