import { type HookErrorHandler } from '../utils/errors.js'; /** A ref-like object whose current value is an element. @public */ export type IntersectionObserverRefTarget = { readonly current: Element | null; }; /** A direct element, ref-like target, or an empty target. @public */ export type IntersectionObserverTarget = Element | IntersectionObserverRefTarget | null | undefined; /** A native threshold value or an immutable threshold list. @public */ export type IntersectionObserverThreshold = number | readonly number[]; /** Options for {@link useIntersectionObserver}. @public */ export interface UseIntersectionObserverOptions { /** Optional target when using the object-form overload. */ readonly target?: IntersectionObserverTarget; /** Alias for `target`, useful when passing a React ref. */ readonly ref?: IntersectionObserverTarget; /** The root element or document used by the native observer. */ readonly root?: IntersectionObserverInit['root']; /** Margin around the root's bounding box. */ readonly rootMargin?: string; /** One threshold or a list of thresholds. */ readonly threshold?: IntersectionObserverThreshold; /** Disables observation and restores the empty snapshot. */ readonly enabled?: boolean; /** Called with the latest native intersection entry. */ readonly onChange?: (entry: IntersectionObserverEntry) => void; /** Observes setup and callback failures before the original error escapes. */ readonly onError?: HookErrorHandler; } /** State returned by {@link useIntersectionObserver}. @public */ export interface IntersectionObserverState { /** The most recent entry, or `null` before the first notification. */ readonly entry: IntersectionObserverEntry | null; /** Whether the most recent entry intersects the root. */ readonly isIntersecting: boolean; /** The most recent setup or callback error, if any. */ readonly error: unknown; } /** * Observes one element with the browser IntersectionObserver API. The hook * follows ref targets across committed renders, keeps the latest callback, * and returns a deterministic empty snapshot during SSR or when the API is * unavailable. * * @public */ export declare function useIntersectionObserver(options?: UseIntersectionObserverOptions): IntersectionObserverState; /** @public */ export declare function useIntersectionObserver(target: IntersectionObserverTarget, options?: Omit): IntersectionObserverState;