import * as React from 'react' ; type PossibleRef < T > = React . Ref < T > | undefined ; /**
 * Set a given ref to a given value
 * This utility takes care of different types of refs: callback refs and RefObject(s)
 */ function setRef < T > ( ref , value ) { if ( typeof ref === 'function' ) { ref ( value ) ; } else if ( ref !== null && ref !== undefined ) { ( ref as React . MutableRefObject < T > ) . current = value ; } } /**
 * A utility to compose multiple refs together
 * Accepts callback refs and RefObject(s)
 */ function composeRefs < T > ( ... refs ) { return ( node ) => refs . forEach ( ( ref ) => setRef ( ref , node ) ) ; } /**
 * A custom hook that composes multiple refs
 * Accepts callback refs and RefObject(s)
 */ function useComposedRefs < T > ( ... refs ) { return React . useCallback ( composeRefs ( ... refs ) , refs ) ; } export { composeRefs , useComposedRefs } ;