{"version":3,"file":"index.cjs","sources":["../../../../packages/hooks/use-events/index.ts"],"sourcesContent":["import { useDebounceFn } from '@vueuse/core'\nimport type {\n  AnyFn,\n  DebounceFilterOptions,\n  MaybeRefOrGetter,\n  PromisifyFn,\n} from '@vueuse/core'\n\nexport type EventAnyFn = AnyFn\n\nexport type EventCallbacks = Record<string, EventAnyFn>\n\nexport type EventPromiseFn<F extends EventAnyFn> = PromisifyFn<F>\n\nexport interface EventOptions extends DebounceFilterOptions {\n  ms?: MaybeRefOrGetter<number>\n}\n\nexport const useEvents = <T extends EventCallbacks>(\n  callbacks: T,\n  options?: EventOptions,\n) => {\n  const { ms = 0, maxWait = 0, rejectOnCancel } = options || {}\n  return useDebounceFn(\n    (key: keyof T, ...args: any) => {\n      const callback = callbacks[key] as EventPromiseFn<EventAnyFn>\n      if (callback) callback.apply({}, args)\n    },\n    ms,\n    { maxWait: maxWait || ms, rejectOnCancel },\n  )\n}\n"],"names":["useDebounceFn"],"mappings":";;;AAkBa,MAAA,YAAY,CACvB,WACA,YACG;AACG,QAAA,EAAE,KAAK,GAAG,UAAU,GAAG,eAAe,IAAI,WAAW;AACpD,SAAAA,KAAA;AAAA,IACL,CAAC,QAAiB,SAAc;AACxB,YAAA,WAAW,UAAU,GAAG;AAC1B,UAAA;AAAmB,iBAAA,MAAM,IAAI,IAAI;AAAA,IACvC;AAAA,IACA;AAAA,IACA,EAAE,SAAS,WAAW,IAAI,eAAe;AAAA,EAAA;AAE7C;;"}