import { t as usePrevious } from "./usePrevious.js";
import { useEffect, useState } from "react";
const useToggle = (initialValue, callback) => {
	const [value, setValue] = useState(initialValue);
	const [prevInitialValue, setPrevInitialValue] = useState(initialValue);
	const previousValue = usePrevious(value);
	if (initialValue !== prevInitialValue) {
		setPrevInitialValue(initialValue);
		setValue(initialValue);
	}
	const toggleValue = () => {
		setValue(!value);
	};
	useEffect(() => {
		if (callback && value !== !!previousValue) callback(value);
	}, [value, callback]);
	return {
		value,
		toggleValue
	};
};
export { useToggle as t };

//# sourceMappingURL=useToggle.js.map