"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var Utilities_1 = require("../../Utilities");
var DialogContent_types_1 = require("./DialogContent.types");
var Button_1 = require("../../Button");
var DialogFooter_1 = require("./DialogFooter");
var withResponsiveMode_1 = require("../../utilities/decorators/withResponsiveMode");
var getClassNames = Utilities_1.classNamesFunction();
var DialogContentBase = /** @class */ (function (_super) {
    tslib_1.__extends(DialogContentBase, _super);
    function DialogContentBase(props) {
        return _super.call(this, props) || this;
    }
    DialogContentBase.prototype.render = function () {
        var _a = this.props, showCloseButton = _a.showCloseButton, className = _a.className, closeButtonAriaLabel = _a.closeButtonAriaLabel, onDismiss = _a.onDismiss, subTextId = _a.subTextId, subText = _a.subText, titleId = _a.titleId, title = _a.title, type = _a.type, getStyles = _a.getStyles, theme = _a.theme, _b = _a.titleAriaLevel, titleAriaLevel = _b === void 0 ? 1 : _b;
        var classNames = getClassNames(getStyles, {
            theme: theme,
            className: className,
            isLargeHeader: type === DialogContent_types_1.DialogType.largeHeader,
            isClose: type === DialogContent_types_1.DialogType.close,
        });
        var groupings = this._groupChildren();
        var subTextContent;
        if (subText) {
            subTextContent = React.createElement("p", { className: classNames.subText, id: subTextId }, subText);
        }
        return (React.createElement("div", { className: classNames.content },
            React.createElement("div", { className: classNames.header },
                React.createElement("p", { className: classNames.title, id: titleId, role: 'heading', "aria-level": titleAriaLevel }, title),
                React.createElement("div", { className: classNames.topButton },
                    this.props.topButtonsProps.map(function (props) { return (React.createElement(Button_1.IconButton, tslib_1.__assign({}, props))); }),
                    (type === DialogContent_types_1.DialogType.close || (showCloseButton && type !== DialogContent_types_1.DialogType.largeHeader)) &&
                        React.createElement(Button_1.IconButton, { className: classNames.button, iconProps: { iconName: 'Cancel' }, ariaLabel: closeButtonAriaLabel, onClick: onDismiss }))),
            React.createElement("div", { className: classNames.inner },
                React.createElement("div", { className: classNames.innerContent },
                    subTextContent,
                    groupings.contents),
                groupings.footers)));
    };
    // @TODO - typing the footers as an array of DialogFooter is difficult because
    // casing "child as DialogFooter" causes a problem because
    // "Neither type 'ReactElement<any>' nor type 'DialogFooter' is assignable to the other."
    DialogContentBase.prototype._groupChildren = function () {
        var groupings = {
            footers: [],
            contents: []
        };
        React.Children.map(this.props.children, function (child) {
            if (typeof child === 'object' && child !== null && child.type === DialogFooter_1.DialogFooter) {
                groupings.footers.push(child);
            }
            else {
                groupings.contents.push(child);
            }
        });
        return groupings;
    };
    DialogContentBase.defaultProps = {
        showCloseButton: false,
        className: '',
        topButtonsProps: [],
        closeButtonAriaLabel: 'Close'
    };
    DialogContentBase = tslib_1.__decorate([
        Utilities_1.customizable('DialogContent', ['theme']),
        withResponsiveMode_1.withResponsiveMode
    ], DialogContentBase);
    return DialogContentBase;
}(Utilities_1.BaseComponent));
exports.DialogContentBase = DialogContentBase;
//# sourceMappingURL=DialogContent.base.js.map