/**
 * useSearchImpressionBuffer — accessor for the Search Impression buffer.
 *
 * Phase 2b V4 pivot (SCRUM-259). Cards in a search-attributed surface
 * (results page, dropdown) record their `(objectID, position)` triple
 * via this hook instead of firing a per-card `Search Impression`. The
 * buffer accumulates entries within a debounce window (default 100 ms)
 * and emits ONE `Search Impression` event with parallel arrays.
 *
 * The buffer is provided by `<BufferProvider>` higher in the tree (which
 * `SearchResults` wraps automatically). If no provider is above, this
 * hook returns a no-op buffer so descendant cards don't crash and
 * downstream rendering is unchanged.
 */
import { useMemo } from "react";
import { useBufferTrio, } from "../components/buffers/BufferProvider";
const NOOP = {
    record: () => undefined,
    flush: () => undefined,
};
export function useSearchImpressionBuffer() {
    const trio = useBufferTrio();
    // Stable identity across renders so consumers can put `buffer` into a
    // useEffect dep array without retriggering.
    return useMemo(() => trio?.impression ?? NOOP, [trio]);
}
