"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Notification = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const box_1 = __importDefault(require("../box"));
const core_1 = require("../core");
const utils_1 = require("../utils");
const consts_1 = require("./consts");
const context_1 = require("./context");
const notificationButton_1 = __importDefault(require("./notificationButton"));
const notificationIcon_1 = __importDefault(require("./notificationIcon"));
const notificationText_1 = __importDefault(require("./notificationText"));
const notificationTitle_1 = __importDefault(require("./notificationTitle"));
/**
 * Displays informational content, like text and icon with optional action buttons.
 * Handles multiple states, like info, error or loading.
 */
exports.Notification = (0, core_1.vui)((props, ref) => {
    var _a, _b, _c, _d;
    const { action, children, className, icon, onClose, size, status, statusMapping, text, title, variant: variantProp = 'subtleBlue', verticalAlign } = props, rest = __rest(props, ["action", "children", "className", "icon", "onClose", "size", "status", "statusMapping", "text", "title", "variant", "verticalAlign"]);
    const statuses = Object.assign(Object.assign({}, consts_1.notificationStatusMapping), statusMapping);
    const { variant = variantProp } = (_a = statuses[status !== null && status !== void 0 ? status : '']) !== null && _a !== void 0 ? _a : {};
    const styles = (0, core_1.useStyleConfig)('Notification', Object.assign({ variant }, props));
    const iconName = (0, utils_1.isString)(icon) ? icon : (_c = (_b = statuses[status !== null && status !== void 0 ? status : '']) === null || _b === void 0 ? void 0 : _b.iconProps) === null || _c === void 0 ? void 0 : _c.name;
    const context = (0, utils_1.filterUndefined)({ size, status });
    const titleDisplay = action ? 'block' : 'inline-flex';
    const alignSelf = verticalAlign === 'center' ? 'center' : 'flex-start';
    return ((0, jsx_runtime_1.jsx)(context_1.NotificationProvider, { value: context, children: (0, jsx_runtime_1.jsxs)(box_1.default, Object.assign({ borderRadius: "md", borderWidth: 1, className: (0, utils_1.cs)('vui-notification', className), elevation: variant.includes('banner') ? consts_1.bannerNotificationElevation : undefined, ref: ref, role: "mark", w: "fit-content" }, styles.container, rest, { children: [iconName ? (0, jsx_runtime_1.jsx)(notificationIcon_1.default, { alignSelf: alignSelf, name: iconName }) : icon, children !== null && children !== void 0 ? children : ((0, jsx_runtime_1.jsxs)(notificationText_1.default, { alignSelf: alignSelf, children: [(0, utils_1.isReactText)(title) ? (0, jsx_runtime_1.jsx)(notificationTitle_1.default, { display: titleDisplay, text: title }) : title, " ", text] })), action, onClose && ((0, jsx_runtime_1.jsx)(notificationButton_1.default, { alignSelf: alignSelf, "aria-label": "close", icon: "falTimes", onClick: onClose, variant: (_d = consts_1.closeButtonVariantMapping === null || consts_1.closeButtonVariantMapping === void 0 ? void 0 : consts_1.closeButtonVariantMapping[variant]) !== null && _d !== void 0 ? _d : variant, w: "32px" }))] })) }));
});
exports.Notification.Button = notificationButton_1.default;
exports.Notification.Icon = notificationIcon_1.default;
exports.Notification.Text = notificationText_1.default;
exports.Notification.Title = notificationTitle_1.default;
exports.Notification.displayName = 'Notification';
exports.default = exports.Notification;
//# sourceMappingURL=notification.js.map