import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useEffect } from "react";
import { ToastContainer, toast } from "react-toastify";
import "./style.scss";
import { clsx } from "../../utils";
import GetSvgIcon from "../GetSvgIcon";
import ClickableText from "../ClickableText";
const ToastWithButtonV2 = ({ type = "success", label, heading = "Wow so easy!", subText = "", boldText = "", showToast = false, showButtons = false, icon, btnText = "Apply", onBtnClick = () => { }, onClose = () => { }, delay: delay, hideProgressBar = true, // Default to true to maintain current behavior
 }) => {
    const getToastConfig = (toastType) => {
        switch (toastType) {
            case "success":
                return {
                    icon: "tickCircleFilled",
                    label: "Success",
                    className: "headingSuccess",
                };
            case "warning":
                return {
                    icon: "exclamationCircleFilled",
                    label: "Warning",
                    className: "headingWarning",
                };
            case "messageSuccess":
                return {
                    icon: "socialBadge",
                    label: "Message Sent",
                    className: "headingMessageSuccess",
                };
            case "messageFailure":
                return {
                    icon: "emojiSad",
                    label: "Message Failed",
                    className: "headingMessageFailure",
                };
            default:
                return {
                    icon: "tickCircleFilled",
                    label: "Success",
                    className: "headingSuccess",
                };
        }
    };
    const notify = () => {
        const config = getToastConfig(type);
        const displayLabel = label || config.label;
        toast(({ closeToast }) => (_jsxs("div", { className: "genericToast--body", children: [_jsxs("div", { children: [_jsxs("div", { className: "headingRow", children: [_jsxs("span", { className: config.className, children: [_jsx(GetSvgIcon, { iconType: icon || config.icon, iconSize: "18" }), displayLabel] }), _jsx("button", { className: "customCloseButton", onClick: closeToast, children: _jsx(GetSvgIcon, { iconType: "cross", iconSize: "20" }) })] }), _jsx("span", { children: heading }), boldText && _jsx("span", { className: "boldText", children: boldText }), subText && _jsx("span", { className: "subtext", children: subText })] }), showButtons && (_jsx("div", { className: "genericToast--footer", children: _jsx(ClickableText, { onClick: onBtnClick, showIcon: false, sizeVariant: "sm", text: btnText, colorVariant: "orange" }) }))] })), {
            position: "top-right",
            hideProgressBar: true,
            closeOnClick: false,
            pauseOnHover: false,
            draggable: true,
            progress: undefined,
            theme: "dark",
            closeButton: false,
            onClose: () => {
                onClose();
            },
            autoClose: delay !== undefined ? delay : false,
        });
    };
    useEffect(() => {
        if (showToast) {
            notify();
        }
    }, []);
    const progressBarClass = clsx({
        "toast-container--hide-progress": hideProgressBar,
    });
    return (_jsx("div", { children: _jsx(ToastContainer, { limit: 1, closeButton: true, className: progressBarClass }) }));
};
export default ToastWithButtonV2;
