/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.0.0-canary-6a365ba
 * Released under the MIT license.
 */

import { useEffect, useRef } from 'react';
export function mergeRefs(...refs) {
    return (value) => {
        refs.forEach((ref) => {
            if (!ref)
                return;
            if (typeof ref === 'function') {
                ref(value);
            }
            else {
                ref.current = value;
            }
        });
    };
}
export function useCombinedRefs(...refs) {
    const targetRef = useRef(null);
    useEffect(() => {
        mergeRefs(...refs)(targetRef.current);
    }, [refs]);
    return targetRef;
}

        