"use client"; import { useCallback, useEffect, useRef, useState } from "react"; interface UseAriaLiveOptions { politeness?: "polite" | "assertive"; /** Delay in ms before the message is injected — allows the region to reset first */ delay?: number; } interface UseAriaLiveReturn { /** The current announcement string — render this inside an aria-live region */ announcement: string; /** Call this to trigger a new announcement */ announce: (message: string) => void; /** Props to spread onto your aria-live container element */ liveRegionProps: { role: "status"; "aria-live": "polite" | "assertive"; "aria-atomic": true; }; } /** * Hook-based aria-live region manager. * Returns an `announcement` string to render inside a visually-hidden container * and an `announce` function to update it. * * @example * const { announcement, announce, liveRegionProps } = useAriaLive(); * * // Trigger * announce("Message sent"); * * // Render (visually hidden) *