/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
let react = require("react");

//#region src/hooks/useForkRef.ts
const setRef = (ref, value) => {
	if (typeof ref === "function") ref(value);
	else if (ref) ref.current = value;
};
const useForkRef = (...refs) => {
	/**
	* This will create a new function if the refs passed to this hook change and are all defined.
	* This means react will call the old forkRef with `null` and the new forkRef
	* with the ref. Cleanup naturally emerges from this behavior.
	*/
	return (0, react.useMemo)(() => {
		if (refs.every((ref) => ref == null)) return null;
		return (instance) => {
			refs.forEach((ref) => {
				setRef(ref, instance);
			});
		};
	}, [refs]);
};

//#endregion
exports.useForkRef = useForkRef;