import React, { useMemo } from 'react';
import { FloatingNotification, } from '@wix/design-system';
import { InfoCircle, StatusComplete } from '@wix/wix-ui-icons-common';
const toastTypeToNotificationType = {
    SUCCESS: 'success',
    ERROR: 'destructive',
};
const convertToastConfigToButtonProps = ({ toastConfig, onClose, }) => {
    return {
        label: toastConfig.action?.text,
        onClick: () => {
            toastConfig.action?.onClick?.();
            if (toastConfig.action?.removeToastOnClick) {
                onClose(toastConfig);
            }
        },
    };
};
const toastTypeToIcon = {
    SUCCESS: React.createElement(StatusComplete, null),
    ERROR: React.createElement(InfoCircle, null),
};
export const ManageTagsNotification = ({ toastConfig, onClose, dataHook, }) => {
    const notificationProps = useMemo(() => {
        let type;
        let prefixIcon;
        if (toastConfig.type) {
            type = toastTypeToNotificationType[toastConfig.type];
            prefixIcon = toastTypeToIcon[toastConfig.type];
        }
        const buttonProps = convertToastConfigToButtonProps({
            toastConfig,
            onClose,
        });
        return {
            type,
            prefixIcon,
            text: toastConfig.message,
            buttonProps: toastConfig.action?.uiType === 'BUTTON' ? buttonProps : undefined,
            textButtonProps: toastConfig.action?.uiType === 'LINK' ? buttonProps : undefined,
            onClose: () => onClose(toastConfig),
        };
    }, [toastConfig, onClose]);
    return React.createElement(FloatingNotification, { dataHook: dataHook, ...notificationProps });
};
//# sourceMappingURL=ManageTagsNotification.js.map