"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;exports.__esModule = true;exports.ModalBody = void 0;var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _react = _interopRequireDefault(require("react"));

var _ThemeContext = require("../../lib/theming/ThemeContext");

var _ZIndex = require("../../internal/ZIndex");

var _CommonWrapper = require("../../internal/CommonWrapper");
var _Emotion = require("../../lib/theming/Emotion");
var _decorator = require("../ResponsiveLayout/decorator");
var LayoutEvents = _interopRequireWildcard(require("../../lib/LayoutEvents"));
var _ResizeDetector = require("../../internal/ResizeDetector");

var _rootNode = require("../../lib/rootNode");
var _ThemeHelpers = require("../../lib/theming/ThemeHelpers");

var _ModalContext = require("./ModalContext");
var _Modal = require("./Modal.styles");
var _getModalBodyTheme = require("./getModalBodyTheme");
var _Modal2 = require("./Modal");var _class, _ModalBody;






/**
 * Контейнер с отступами для содержимого модального окна.
 *
 * @visibleName Modal.Body
 */var


ModalBody = exports.ModalBody = (0, _decorator.responsiveLayout)(_class = (0, _rootNode.rootNode)(_class = (_ModalBody = /*#__PURE__*/function (_React$Component) {function ModalBody() {var _this;for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];}_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;_this.




















    handleResize = function () {
      LayoutEvents.emit();
    };return _this;}(0, _inheritsLoose2.default)(ModalBody, _React$Component);var _proto = ModalBody.prototype;_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = (0, _getModalBodyTheme.getModalBodyTheme)(theme);return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Provider, { value: _this2.theme }, _this2.renderMain());});};_proto.

  renderMain = function renderMain() {var _this3 = this;
    var versionGTE5_2 = (0, _ThemeHelpers.isThemeGTE)(this.theme, '5.2');
    var noPadding = this.props.noPadding;
    return /*#__PURE__*/(
      _react.default.createElement(_ModalContext.ModalContext.Consumer, null,
      function (_ref) {var _cx;var additionalPadding = _ref.additionalPadding,hasHeader = _ref.hasHeader;return /*#__PURE__*/(
          _react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: _this3.setRootNode }, _this3.props), /*#__PURE__*/
          _react.default.createElement(_ZIndex.ZIndex, {
            priority: _Modal2.ModalZIndexPriority.Content,
            className: (0, _Emotion.cx)((_cx = {}, _cx[
            _Modal.styles.body(_this3.theme)] = true, _cx[
            _Modal.styles.mobileBody(_this3.theme)] = _this3.isMobileLayout, _cx[
            _Modal.styles.bodyWithoutHeader(_this3.theme)] = !hasHeader, _cx[
            _Modal.styles.mobileBodyWithoutHeader()] = !hasHeader && _this3.isMobileLayout, _cx[
            _Modal.styles.bodyAddPaddingForPanel(_this3.theme)] = additionalPadding, _cx[
            _Modal.styles.mobileBodyAddPaddingForPanel(_this3.theme)] = additionalPadding && _this3.isMobileLayout, _cx[
            _Modal.styles.mobileBodyWithoutHeader5_2(_this3.theme)] = versionGTE5_2 && !hasHeader && _this3.isMobileLayout, _cx[
            _Modal.styles.mobileBodyAddPaddingForPanel5_2(_this3.theme)] =
            versionGTE5_2 && additionalPadding && _this3.isMobileLayout, _cx[
            _Modal.styles.bodyWithoutPadding()] = noPadding, _cx)
            ) },

          _this3.isMobileLayout ? /*#__PURE__*/
          _react.default.createElement(_ResizeDetector.ResizeDetector, { onResize: _this3.handleResize }, _this3.props.children) :

          _this3.props.children

          )
          ));}

      ));

  };return ModalBody;}(_react.default.Component), _ModalBody.__KONTUR_REACT_UI__ = 'ModalBody', _ModalBody.displayName = 'ModalBody', _ModalBody.__MODAL_BODY__ = true, _ModalBody)) || _class) || _class;