"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useDelayedUnmount = useDelayedUnmount;
const react_1 = require("react");
/**
 * Hook for delaying component unmount during animation
 *
 * @param isOpen - Open/close flag
 * @param delayTime - Delay time in milliseconds (default 300ms)
 * @returns shouldRender - Whether the element should be rendered
 */
function useDelayedUnmount(isOpen, delayTime = 300) {
    const [shouldRender, setShouldRender] = (0, react_1.useState)(isOpen);
    (0, react_1.useEffect)(() => {
        if (isOpen) {
            // If opening, show immediately
            setShouldRender(true);
        }
        else {
            // If closing, wait for animation to complete
            const timeoutId = setTimeout(() => {
                setShouldRender(false);
            }, delayTime);
            return () => clearTimeout(timeoutId);
        }
        return undefined;
    }, [isOpen, delayTime]);
    return shouldRender;
}
//# sourceMappingURL=useDelayedUnmount.js.map
