{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../packages/hooks/use-prevent-global/index.ts"],"sourcesContent":["import { watch } from 'vue'\nimport { useEventListener } from '@vueuse/core'\n\nimport type { Ref } from 'vue'\n\nexport const usePreventGlobal = <E extends keyof DocumentEventMap>(\n  indicator: Ref<boolean>,\n  evt: E,\n  cb: (e: DocumentEventMap[E]) => boolean\n) => {\n  const prevent = (e: DocumentEventMap[E]) => {\n    if (cb(e)) e.stopImmediatePropagation()\n  }\n  let stop: (() => void) | undefined = undefined\n  watch(\n    () => indicator.value,\n    (val) => {\n      if (val) {\n        stop = useEventListener(document, evt, prevent, true)\n      } else {\n        stop?.()\n      }\n    },\n    { immediate: true }\n  )\n}\n"],"mappings":";;;AAKA,MAAa,oBACX,WACA,KACA,OACG;CACH,MAAM,WAAW,MAA2B;EAC1C,IAAI,GAAG,EAAE,EAAE,EAAE,0BAA0B;;CAEzC,IAAI,OAAiC,KAAA;CACrC,YACQ,UAAU,QACf,QAAQ;EACP,IAAI,KACF,OAAO,iBAAiB,UAAU,KAAK,SAAS,KAAK;OAErD,QAAQ;IAGZ,EAAE,WAAW,MAAM,CACpB"}