var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import React from 'react';
import { ThemeContext } from '../../lib/theming/ThemeContext.js';
import { ZIndex } from '../../internal/ZIndex/index.js';
import { CommonWrapper } from '../../internal/CommonWrapper/index.js';
import { responsiveLayout } from '../ResponsiveLayout/decorator.js';
import * as LayoutEvents from '../../lib/LayoutEvents.js';
import { ResizeDetector } from '../../internal/ResizeDetector/index.js';
import { rootNode } from '../../lib/rootNode/index.js';
import { withRenderEnvironment } from '../../lib/renderEnvironment/index.js';
import { ModalContext } from './ModalContext.js';
import { getStyles } from './Modal.styles.js';
import { getModalBodyTheme } from './getModalBodyTheme.js';
import { ModalZIndexPriority } from './Modal.js';
/**
 * Контейнер с отступами для содержимого модального окна.
 *
 * @visibleName Modal.Body
 */
var ModalBody = /** @class */ (function (_super) {
    __extends(ModalBody, _super);
    function ModalBody() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.handleResize = function () {
            LayoutEvents.emit();
        };
        return _this;
    }
    ModalBody.prototype.render = function () {
        var _this = this;
        this.styles = getStyles(this.emotion);
        return (React.createElement(ThemeContext.Consumer, null, function (theme) {
            _this.theme = getModalBodyTheme(theme);
            return React.createElement(ThemeContext.Provider, { value: _this.theme }, _this.renderMain());
        }));
    };
    ModalBody.prototype.renderMain = function () {
        var _this = this;
        var noPadding = this.props.noPadding;
        return (React.createElement(ModalContext.Consumer, null, function (_a) {
            var _b;
            var additionalPadding = _a.additionalPadding, hasHeader = _a.hasHeader;
            return (React.createElement(CommonWrapper, __assign({ rootNodeRef: _this.setRootNode }, _this.props),
                React.createElement(ZIndex, { priority: ModalZIndexPriority.Content, className: _this.cx((_b = {},
                        _b[_this.styles.body(_this.theme)] = true,
                        _b[_this.styles.mobileBody(_this.theme)] = _this.isMobileLayout,
                        _b[_this.styles.bodyWithoutHeader(_this.theme)] = !hasHeader,
                        _b[_this.styles.bodyAddPaddingForPanel(_this.theme)] = additionalPadding,
                        _b[_this.styles.mobileBodyAddPaddingForPanel(_this.theme)] = additionalPadding && _this.isMobileLayout,
                        _b[_this.styles.mobileBodyWithoutHeader(_this.theme)] = !hasHeader && _this.isMobileLayout,
                        _b[_this.styles.bodyWithoutPadding()] = noPadding,
                        _b)) }, _this.isMobileLayout ? (React.createElement(ResizeDetector, { onResize: _this.handleResize }, _this.props.children)) : (_this.props.children))));
        }));
    };
    ModalBody.__KONTUR_REACT_UI__ = 'ModalBody';
    ModalBody.displayName = 'ModalBody';
    ModalBody.__MODAL_BODY__ = true;
    ModalBody = __decorate([
        withRenderEnvironment,
        responsiveLayout,
        rootNode
    ], ModalBody);
    return ModalBody;
}(React.Component));
export { ModalBody };
//# sourceMappingURL=ModalBody.js.map