"use client";
const require_use_callback_ref = require("../utils/use-callback-ref/use-callback-ref.cjs");
let react = require("react");
//#region packages/@mantine/hooks/src/use-timeout/use-timeout.ts
function useTimeout(callback, delay, options = { autoInvoke: false }) {
	const timeoutRef = (0, react.useRef)(null);
	const handleCallback = require_use_callback_ref.useCallbackRef(callback);
	const start = (0, react.useCallback)((...args) => {
		if (!timeoutRef.current) timeoutRef.current = window.setTimeout(() => {
			handleCallback(...args);
			timeoutRef.current = null;
		}, delay);
	}, [delay]);
	const clear = (0, react.useCallback)(() => {
		if (timeoutRef.current) {
			window.clearTimeout(timeoutRef.current);
			timeoutRef.current = null;
		}
	}, []);
	(0, react.useEffect)(() => {
		if (options.autoInvoke) start();
		return clear;
	}, [clear, start]);
	return {
		start,
		clear
	};
}
//#endregion
exports.useTimeout = useTimeout;

//# sourceMappingURL=use-timeout.cjs.map