import React, { useEffect } from "react";
import Button from "../../../Button";
import P2 from "../../../typography/P2";
import { SnackBarStyled, SnackBarCounterStyled } from "./styles";
var SnackBar = function (_a) {
    var message = _a.message, action = _a.action, closeSnackBar = _a.closeSnackBar, timeoutId = _a.timeoutId, id = _a.id, count = _a.count;
    useEffect(function () { return function () {
        timeoutId && clearTimeout(timeoutId);
    }; }, []);
    var onCloseSnackBar = function () {
        closeSnackBar === null || closeSnackBar === void 0 ? void 0 : closeSnackBar(id);
    };
    return (React.createElement(SnackBarStyled, { className: "snack-bar" },
        React.createElement(P2, { type: "corvus", className: "snack-bar__text" }, message),
        action && (React.createElement(Button, { viewType: "link", size: "s", onClick: action.onClick || onCloseSnackBar, className: "action-button" }, action.text)),
        count && React.createElement(SnackBarCounterStyled, null, count)));
};
export default SnackBar;
