import { t as usePrevious } from "./usePrevious.js";
import { useEffect, useState } from "react";
const useExpand = (expanded, onExpand) => {
	const [isExpanded, setIsExpanded] = useState(expanded);
	const [prevExpanded, setPrevExpanded] = useState(expanded);
	const previousIsExpanded = usePrevious(isExpanded);
	if (expanded !== prevExpanded) {
		setPrevExpanded(expanded);
		setIsExpanded(expanded);
	}
	useEffect(() => {
		if (onExpand && isExpanded !== !!previousIsExpanded) onExpand(isExpanded);
	}, [isExpanded, onExpand]);
	return [isExpanded, setIsExpanded];
};
export { useExpand as t };

//# sourceMappingURL=useExpand.js.map