"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = _interopRequireDefault(require("react"));
var _Content = _interopRequireDefault(require("./components/Content"));
var _Box = _interopRequireDefault(require("../Box"));
var _Proportion = _interopRequireDefault(require("../Proportion"));
var _constants = require("./constants");
var _MarketingLayoutSt = require("./MarketingLayout.st.css.js");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/MarketingLayout/MarketingLayout.jsx";
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
var imagePlaceholderAspectRatioBySize = (0, _defineProperty2["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, _constants.SIZES.tiny, 1), _constants.SIZES.small, 1), _constants.SIZES.medium, 282 / 188);

/** Marketing layout is a layout designed to promote new features or display first time visit.
 * Component has title, description, action and illustration areas. */
var MarketingLayout = /*#__PURE__*/function (_React$PureComponent) {
  function MarketingLayout() {
    var _this;
    (0, _classCallCheck2["default"])(this, MarketingLayout);
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    _this = _callSuper(this, MarketingLayout, [].concat(args));
    _this.renderImagePlaceholder = function () {
      var size = _this.props.size;
      return /*#__PURE__*/_react["default"].createElement(_Proportion["default"], {
        aspectRatio: imagePlaceholderAspectRatioBySize[size],
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 30,
          columnNumber: 7
        }
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: _MarketingLayoutSt.classes.imagePlaceholder,
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 31,
          columnNumber: 9
        }
      }));
    };
    _this.getBorderRadiusProps = function () {
      var _this$props = _this.props,
        inverted = _this$props.inverted,
        direction = _this$props.direction,
        imagePadding = _this$props.imagePadding;
      if (direction === 'horizontal') return {
        borderTopLeftRadius: !imagePadding && inverted ? 'inherit' : undefined,
        borderTopRightRadius: !imagePadding && !inverted ? 'inherit' : undefined,
        borderBottomLeftRadius: !imagePadding && inverted ? 'inherit' : undefined,
        borderBottomRightRadius: !imagePadding && !inverted ? 'inherit' : undefined
      };else return {};
    };
    _this.renderImage = function () {
      var _this$props2 = _this.props,
        image = _this$props2.image,
        imageBackgroundColor = _this$props2.imageBackgroundColor,
        inverted = _this$props2.inverted,
        size = _this$props2.size,
        direction = _this$props2.direction,
        imagePadding = _this$props2.imagePadding;
      if (!image && !imageBackgroundColor) {
        return null;
      }
      return /*#__PURE__*/_react["default"].createElement(_Box["default"], (0, _extends2["default"])({
        key: "image",
        display: "flex",
        backgroundColor: imageBackgroundColor,
        justifyContent: "flex-end",
        className: (0, _MarketingLayoutSt.st)(_MarketingLayoutSt.classes.imageBackground)
      }, _this.getBorderRadiusProps(), {
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 66,
          columnNumber: 7
        }
      }), /*#__PURE__*/_react["default"].createElement("div", {
        className: (0, _MarketingLayoutSt.st)(_MarketingLayoutSt.classes.imageWrapper, {
          size: size,
          inverted: inverted,
          direction: direction
        }),
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 74,
          columnNumber: 9
        }
      }, typeof image === 'string' ? /*#__PURE__*/_react["default"].createElement("img", {
        src: image,
        width: "100%",
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 82,
          columnNumber: 13
        }
      }) : image || _this.renderImagePlaceholder()));
    };
    _this.renderContent = function () {
      var _this$props3 = _this.props,
        size = _this$props3.size,
        actions = _this$props3.actions,
        title = _this$props3.title,
        description = _this$props3.description,
        badge = _this$props3.badge,
        hiddenBadge = _this$props3.hiddenBadge,
        inverted = _this$props3.inverted,
        direction = _this$props3.direction,
        imageBackgroundColor = _this$props3.imageBackgroundColor;
      return /*#__PURE__*/_react["default"].createElement(_Box["default"], {
        key: "content",
        className: (0, _MarketingLayoutSt.st)(_MarketingLayoutSt.classes.contentWrapper, {
          inverted: inverted,
          size: size,
          direction: direction,
          withImageBackground: !!imageBackgroundColor
        }),
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 105,
          columnNumber: 7
        }
      }, badge && !hiddenBadge && /*#__PURE__*/_react["default"].createElement("div", {
        className: _MarketingLayoutSt.classes.badge,
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 114,
          columnNumber: 35
        }
      }, badge), /*#__PURE__*/_react["default"].createElement(_Content["default"], {
        size: size,
        actions: actions,
        title: title,
        description: description,
        badge: badge,
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 115,
          columnNumber: 9
        }
      }));
    };
    return _this;
  }
  (0, _inherits2["default"])(MarketingLayout, _React$PureComponent);
  return (0, _createClass2["default"])(MarketingLayout, [{
    key: "renderHorizontal",
    value: function renderHorizontal() {
      var image = this.renderImage();
      var content = this.renderContent();
      return this.props.inverted ? [image, content] : [content, image];
    }
  }, {
    key: "renderVertical",
    value: function renderVertical() {
      var image = this.props.image && this.renderImage();
      var content = this.renderContent();
      return this.props.inverted ? [content, image] : [image, content];
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props4 = this.props,
        size = _this$props4.size,
        badge = _this$props4.badge,
        hiddenBadge = _this$props4.hiddenBadge,
        alignItems = _this$props4.alignItems,
        inverted = _this$props4.inverted,
        actions = _this$props4.actions,
        dataHook = _this$props4.dataHook,
        imageBackgroundColor = _this$props4.imageBackgroundColor,
        direction = _this$props4.direction,
        imagePadding = _this$props4.imagePadding;
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: (0, _MarketingLayoutSt.st)(_MarketingLayoutSt.classes.root, {
          size: size,
          badge: !!badge,
          hiddenBadge: hiddenBadge,
          alignItems: alignItems,
          inverted: inverted,
          withActions: !!actions,
          withImageBackground: !!imageBackgroundColor,
          direction: direction,
          imagePadding: imagePadding
        }),
        style: this.getBorderRadiusProps(),
        "data-hook": dataHook,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 153,
          columnNumber: 7
        }
      }, direction === _constants.DIRECTIONS.vertical ? this.renderVertical() : this.renderHorizontal());
    }
  }]);
}(_react["default"].PureComponent);
MarketingLayout.displayName = 'MarketingLayout';
MarketingLayout.defaultProps = {
  size: 'small',
  alignItems: 'center',
  inverted: false,
  direction: 'horizontal',
  hiddenBadge: false,
  imagePadding: true
};
var _default = exports["default"] = MarketingLayout;