import React, { useCallback, useEffect, useState } from "react";
import { createPortal } from "react-dom";
import { toast, Toaster as SonnerToaster } from "sonner";
const ToasterProvider = ({ children, position = "bottom-center", ...rest }) => {
    const [body, setBody] = useState(null);
    useEffect(() => {
        setBody(document.body);
    }, []);
    const toaster = React.createElement(SonnerToaster, { position: position, ...rest });
    return (React.createElement(React.Fragment, null,
        children,
        body ? createPortal(toaster, body) : null));
};
const useToaster = () => {
    return useCallback((text, timeout) => {
        return toast(text, timeout != null ? { duration: timeout } : undefined);
    }, []);
};
export { ToasterProvider, useToaster, toast };
//# sourceMappingURL=Toaster.js.map