| 1 |
- import{a as f}from"./chunk-EDZQSM3T.js";import{a as p}from"./chunk-NUC3LT2W.js";function o(){this._listeners=[],this._scopes=[],this._toRemove=[],this._insideRaiseEvent=!1}Object.defineProperties(o.prototype,{numberOfListeners:{get:function(){return this._listeners.length-this._toRemove.length}}});o.prototype.addEventListener=function(e,t){f.typeOf.func("listener",e),this._listeners.push(e),this._scopes.push(t);var i=this;return function(){i.removeEventListener(e,t)}};o.prototype.removeEventListener=function(e,t){f.typeOf.func("listener",e);for(var i=this._listeners,r=this._scopes,n=-1,s=0;s<i.length;s++)if(i[s]===e&&r[s]===t){n=s;break}return n!==-1?(this._insideRaiseEvent?(this._toRemove.push(n),i[n]=void 0,r[n]=void 0):(i.splice(n,1),r.splice(n,1)),!0):!1};function v(e,t){return t-e}o.prototype.raiseEvent=function(){this._insideRaiseEvent=!0;var e,t=this._listeners,i=this._scopes,r=t.length;for(e=0;e<r;e++){var n=t[e];p(n)&&t[e].apply(i[e],arguments)}var s=this._toRemove;if(r=s.length,r>0){for(s.sort(v),e=0;e<r;e++){var h=s[e];t.splice(h,1),i.splice(h,1)}s.length=0}this._insideRaiseEvent=!1};var l=o;export{l as a};
|