{"version":3,"file":"useAriaLiveAnnouncer.mjs","names":[],"sources":["../../../../src/components/Accessibility/useAriaLiveAnnouncer.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nexport type AriaLivePriority = 'assertive' | 'polite';\n\nexport type AriaLiveAnnounceOptions = {\n  priority?: AriaLivePriority;\n  /**\n   * Delay (ms) before the message is placed in the live region, to let a competing screen-reader\n   * utterance settle first (e.g. a dialog announcement made while a field is auto-focused is\n   * otherwise superseded by the field's focus announcement). Defaults to `0` (immediately).\n   */\n  delayMs?: number;\n  /**\n   * When set, an identical `message` is announced at most once per this window (ms), and repeats\n   * within it are suppressed. The window starts when the message is actually announced. Guards\n   * against duplicates such as an effect double-invoked by React StrictMode.\n   */\n  dedupeMs?: number;\n};\n\n/**\n * Announces `message` to assistive technology; `priority` defaults to `'polite'`. Returns a\n * `cancel` function that stops a still-pending delayed announcement (call it from effect cleanup\n * so a closing surface does not announce after unmount) and is a no-op for an immediate one.\n */\nexport type AriaLiveAnnounce = (\n  message: string,\n  options?: AriaLiveAnnounceOptions,\n) => () => void;\n\nexport type AriaLiveAnnouncerContextValue = {\n  announce: AriaLiveAnnounce;\n};\n\nconst noopAnnounce: AriaLiveAnnounce = () => () => undefined;\n\nexport const AriaLiveAnnouncerContext = createContext<\n  AriaLiveAnnouncerContextValue | undefined\n>(undefined);\n\n/**\n * Returns the `announce` function of the nearest `AriaLiveAnnouncerProvider`, or a no-op outside\n * one: announcements are a progressive enhancement, not a requirement.\n */\nexport const useAriaLiveAnnouncer = () =>\n  useContext(AriaLiveAnnouncerContext)?.announce ?? noopAnnounce;\n"],"mappings":";;AAkCA,IAAM,2BAA6C,KAAA;AAEnD,IAAa,2BAA2B,cAEtC,KAAA,CAAS;;;;;AAMX,IAAa,6BACX,WAAW,wBAAwB,CAAC,EAAE,YAAY"}