{"version":3,"sources":["jsdelivr-header.js","/npm/@adonisjs/events@9.0.2/src/base_event.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,gDCGS,qBAAwB,kBAO1B,IAAM,UAAN,MACL,WAAA,IAAe,GAAW,CAK1B,eAKA,iBAAO,CAAW,GAChB,KAAK,QAAU,CACjB,CAMA,qBAAa,IAAiD,GAC5D,IAAK,KAAK,QACR,MAAM,IAAI,iBACR,oBAAoB,KAAK,+FAI7B,OAAO,KAAK,QAAQ,KAAQ,KAAM,IAAI,QAAQ,GAChD,U","file":"/npm/@adonisjs/events@9.0.2/build/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@adonisjs/events@9.0.2/build/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\n * @adonisjs/events\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { RuntimeException } from '@poppinss/utils'\nimport type { Emitter } from './emitter.js'\n\n/**\n * Base event adds ability to a class to act as an event. You can emit the\n * event by calling \"Event.dispatch\" method.\n */\nexport class BaseEvent {\n  constructor(..._: any[]) {}\n\n  /**\n   * The emitter to use for dispatching events\n   */\n  static emitter?: Emitter<any>\n\n  /**\n   * Specify the emitter instance to use for dispatching events\n   */\n  static useEmitter(emitter: Emitter<any>) {\n    this.emitter = emitter\n  }\n\n  /**\n   * Dispatch the current class as an event. The method takes the arguments\n   * accepted by the class constructor.\n   */\n  static async dispatch<T extends typeof BaseEvent>(this: T, ...args: ConstructorParameters<T>) {\n    if (!this.emitter) {\n      throw new RuntimeException(\n        `Cannot dispatch \"${this.name}\" event. Make sure to pass emitter to the \"BaseEvent\" class for dispatch method to work`\n      )\n    }\n\n    return this.emitter.emit<T>(this, new this(...args) as InstanceType<T>)\n  }\n}\n"]}