import React from "react";
import { classes } from "./Toast.tokens";
import { StyledOverlay, StyledRoot } from "./Toast.styles";
import { useToastInner } from "./ToastProvider";
import { FADE_Z_INDEX, gradients } from "./utils";
export const ToastControllerHoc = (ToastComponent)=>function ToastController(props) {
        const { position = 'bottom', offset, fade, text, ...rest } = props;
        const { hideToast, isVisible } = useToastInner();
        const toastKey = `${text}${position}`;
        const showedClass = isVisible ? classes.toastShowed : classes.toastHidden;
        const showedFadeClass = isVisible ? classes.toastFadeShowed : classes.toastFadeHidden;
        const toastProps = {
            text,
            onCloseButtonClick: hideToast,
            ...rest
        };
        if (!text) {
            return null;
        }
        return /*#__PURE__*/ React.createElement(React.Fragment, null, fade && /*#__PURE__*/ React.createElement(StyledOverlay, {
            className: showedFadeClass,
            zIndex: FADE_Z_INDEX,
            backgroundColorProperty: gradients[position],
            isClickable: false
        }), /*#__PURE__*/ React.createElement(StyledRoot, {
            key: toastKey,
            position: position,
            offset: offset,
            isVisible: isVisible,
            className: showedClass
        }, /*#__PURE__*/ React.createElement(ToastComponent, toastProps)));
    };
