{"version":3,"file":"use-window-event.mjs","names":[],"sources":["../../src/use-window-event/use-window-event.ts"],"sourcesContent":["import { useEffect, useEffectEvent } from 'react';\n\nexport function useWindowEvent<K extends string>(\n  type: K,\n  listener: K extends keyof WindowEventMap\n    ? (this: Window, ev: WindowEventMap[K]) => void\n    : (this: Window, ev: CustomEvent) => void,\n  options?: boolean | AddEventListenerOptions\n) {\n  const stableListener = useEffectEvent(listener);\n  const {\n    capture = false,\n    passive,\n    once = false,\n    signal,\n  } = typeof options === 'object' ? options : { capture: options };\n\n  useEffect(() => {\n    window.addEventListener(type as any, stableListener, { capture, passive, once, signal });\n    return () => window.removeEventListener(type as any, stableListener, capture);\n  }, [type, capture, passive, once, signal]);\n}\n"],"mappings":";;;AAEA,SAAgB,eACd,MACA,UAGA,SACA;CACA,MAAM,iBAAiB,eAAe,QAAQ;CAC9C,MAAM,EACJ,UAAU,OACV,SACA,OAAO,OACP,WACE,OAAO,YAAY,WAAW,UAAU,EAAE,SAAS,QAAQ;CAE/D,gBAAgB;EACd,OAAO,iBAAiB,MAAa,gBAAgB;GAAE;GAAS;GAAS;GAAM;EAAO,CAAC;EACvF,aAAa,OAAO,oBAAoB,MAAa,gBAAgB,OAAO;CAC9E,GAAG;EAAC;EAAM;EAAS;EAAS;EAAM;CAAM,CAAC;AAC3C"}