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 (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var _a;
import * as classnames from "classnames";
import * as FontAwesome from "react-fontawesome";
import * as React from "react";
import { Button } from "../Button/Button";
import { FlexBox, ItemAlign } from "../flex";
import { ToastType } from "./ToastType";
import "./ToastNotification.less";
var defaultProps = {
    showCloseButton: true,
};
var cssClass = {
    CONTAINER: "ToastNotification",
    CONTENT: "ToastNotification--content",
    ACTION: "ToastNotification--action",
    CLOSE_BUTTON: "ToastNotification--closeButton",
};
function typeCssClass(type) {
    return "ToastNotification--" + type;
}
var iconMap = (_a = {},
    _a[ToastType.ERROR] = "minus-circle",
    _a[ToastType.INFO] = "bell",
    _a[ToastType.PROCESSING] = "spinner",
    _a[ToastType.SUCCESS] = "thumbs-up",
    _a[ToastType.WARNING] = "exclamation-triangle",
    _a);
/**
 * A building block for the <ToastStack>. Renders an individual toast notification.
 */
var ToastNotification = /** @class */ (function (_super) {
    __extends(ToastNotification, _super);
    function ToastNotification() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ToastNotification.prototype.render = function () {
        var _a = this.props, action = _a.action, children = _a.children, className = _a.className, onClose = _a.onClose, showCloseButton = _a.showCloseButton, type = _a.type, closeButtonAriaLabel = _a.closeButtonAriaLabel;
        return (React.createElement(FlexBox, { className: classnames(cssClass.CONTAINER, typeCssClass(type), className), alignItems: ItemAlign.CENTER },
            React.createElement(FontAwesome, { name: iconMap[type], size: "lg", spin: type === ToastType.PROCESSING }),
            React.createElement(FlexBox, { className: cssClass.CONTENT, grow: true, role: "alert" }, children),
            action && (React.createElement(Button, { className: cssClass.ACTION, href: action.href, onClick: action.onClick, type: "link", value: action.text })),
            showCloseButton && (React.createElement(Button, { className: cssClass.CLOSE_BUTTON, onClick: onClose, type: "linkPlain", value: React.createElement(FontAwesome, { name: "times", size: "lg" }), ariaLabel: closeButtonAriaLabel || "close notification" }))));
    };
    ToastNotification.defaultProps = defaultProps;
    return ToastNotification;
}(React.PureComponent));
export { ToastNotification };
