/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-1fc5ad1 | Cube Dev Team */
import { useEffect, useRef } from "react";

//#region src/utils/react/useCombinedRefs.ts
function mergeRefs(...refs) {
	return (value) => {
		refs.forEach((ref) => {
			if (!ref) return;
			if (typeof ref === "function") ref(value);
			else ref.current = value;
		});
	};
}
function useCombinedRefs(...refs) {
	const targetRef = useRef(null);
	useEffect(() => {
		mergeRefs(...refs)(targetRef.current);
	}, [refs]);
	return targetRef;
}

//#endregion
export { mergeRefs, useCombinedRefs };
//# sourceMappingURL=useCombinedRefs.js.map