System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2"], function (_export, _context) {
  "use strict";

  var _reporterNs, _cclegacy, Singleton, LogMgr, EventManager, _crd;

  function _reportPossibleCrUseOfSingleton(extras) {
    _reporterNs.report("Singleton", "../plugin/Singleton", _context.meta, extras);
  }

  function _reportPossibleCrUseOfLogMgr(extras) {
    _reporterNs.report("LogMgr", "./LogMgr", _context.meta, extras);
  }

  _export("default", void 0);

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc) {
      _cclegacy = _cc.cclegacy;
    }, function (_unresolved_2) {
      Singleton = _unresolved_2.default;
    }, function (_unresolved_3) {
      LogMgr = _unresolved_3.default;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "44dcc1WhyhGcKP7z7dED0Ao", "EventManager", undefined);

      _export("default", EventManager = class EventManager extends (_crd && Singleton === void 0 ? (_reportPossibleCrUseOfSingleton({
        error: Error()
      }), Singleton) : Singleton) {
        static init() {
          this.events = {};
          (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
            error: Error()
          }), LogMgr) : LogMgr).log(`事件管理器初始化成功`);
        }
        /**注册事件
         * @param eventName 事件名
         * @param callBack 回调函数
         * @param target 回调函数的this
         */


        static on(eventName, callBack, target) {
          if (!this.events[eventName]) {
            this.events[eventName] = [];
          }

          this.events[eventName].push({
            target: target,
            callBack: callBack
          });
          (_crd && LogMgr === void 0 ? (_reportPossibleCrUseOfLogMgr({
            error: Error()
          }), LogMgr) : LogMgr).log(`注册事件${eventName},::${this.events[eventName]}`);
        }
        /**发射事件
         * @param eventName 事件名
         * @param args 参数数组
         */


        static emit(eventName, ...args) {
          let eventCB = this.events[eventName];

          if (eventCB) {
            eventCB.forEach(ec => {
              ec.callBack.call(ec.target, ...args);
            });
          }
        }
        /**取消监听事件
         * @param eventName 事件名
         */


        static off(eventName, callBack) {
          let eventCB = this.events[eventName];

          if (eventCB) {
            this.events[eventName] = eventCB.filter(ec => ec.callBack !== callBack);
          }
        }
        /**取消所有事件     */


        static offAll() {
          this.events = {};
        }

      });

      EventManager.events = {};

      _cclegacy._RF.pop();

      _crd = false;
    }
  };
});
//# sourceMappingURL=5bf5cb8f5dd36ce3b140dba9e124cb006a5aaa25.js.map