let triggerPaused = false;
/* Triggers a callback when a DOM element is removed from the document. */
export default function onRemove(element, callback) {
    const observer = new MutationObserver(mutations => {
        for (const mutation of mutations) {
            for (const removedNode of mutation.removedNodes) {
                if (removedNode.contains(element) && !triggerPaused) {
                    observer.disconnect();
                    callback();
                }
            }
        }
    });
    observer.observe(document, { childList: true, subtree: true });
}
/* Globally pauses all callback invocations. */
onRemove.pause = () => {
    triggerPaused = true;
};
/* Globally resumes all callback invocations. */
onRemove.resume = () => {
    triggerPaused = false;
};
//# sourceMappingURL=onRemove.js.map