import React, { useRef } from 'react';
import { useToast as useToast$1 } from '@chakra-ui/react';
import BareAlert from '../components/alert/Bare.js';

var useToast = function () {
    var toast = useToast$1();
    var toastIdRef = useRef([]);
    var closeToast = function (toastId) {
        var _a;
        if (toastId) {
            toast.close(toastId);
            toastIdRef.current = (_a = toastIdRef.current) === null || _a === void 0 ? void 0 : _a.filter(function (id) { return id !== toastId; });
        }
    };
    return function (options) {
        var _a = options.position, position = _a === void 0 ? 'top' : _a, icon = options.icon, title = options.title, description = options.description, link = options.link, type = options.type;
        var toastId = toast({
            position: position,
            render: function () { return (React.createElement(BareAlert, { type: type, icon: icon, title: title, description: description, link: link, onClose: function () { return closeToast(toastId); } })); },
        });
        toastIdRef.current.push(toastId);
        return { closeToast: function () { return closeToast(toastId); } };
    };
};

export { useToast as default };
//# sourceMappingURL=UseToast.js.map
