-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathts-events.min.js
1 lines (1 loc) · 28 KB
/
ts-events.min.js
1
!function(f){"object"==typeof exports&&"undefined"!=typeof module?module.exports=f():"function"==typeof define&&define.amd?define([],f):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).listComponent=f()}(function(){return require=function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){return o(e[i][1][r]||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({1:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var sync_event_1=require("./sync-event"),EventQueue=function(){function EventQueue(){this.evtFilled=new sync_event_1.SyncEvent,this.evtDrained=new sync_event_1.SyncEvent,this._queue=[],this._flushing=!1}return EventQueue.global=function(){return EventQueue._instance||EventQueue.resetGlobal(),EventQueue._instance},EventQueue.resetGlobal=function(){EventQueue._instance=new EventQueue},EventQueue.prototype.empty=function(){return 0===this._queue.length},EventQueue.prototype.add=function(handler){this._queue.push(handler),1!==this._queue.length||this._flushing||this.evtFilled.post(this)},EventQueue.prototype.flushOnce=function(){var empty=0===this._queue.length,flushing=this._flushing;this._flushing=!0;try{var queue=this._queue;this._queue=[];for(var i=0;i<queue.length;++i)queue[i]()}finally{this._flushing=flushing,empty||flushing||0!==this._queue.length||this.evtDrained.post(this)}},EventQueue.prototype.flush=function(maxRounds){void 0===maxRounds&&(maxRounds=10);var empty=0===this._queue.length,flushing=this._flushing;this._flushing=!0;try{for(var i=0;0<this._queue.length;){if("number"==typeof maxRounds&&maxRounds<=i)throw this._queue=[],new Error("unable to flush the queue due to recursively added event. Clearing queue now");this.flushOnce(),++i}}finally{this._flushing=flushing,empty||flushing||0!==this._queue.length||this.evtDrained.post(this)}},EventQueue}();exports.default=EventQueue},{"./sync-event":7}],2:[function(require,module,exports){"use strict";var extendStatics,__extends=this&&this.__extends||(extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)},function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)});Object.defineProperty(exports,"__esModule",{value:!0}),exports.ErrorAnyEvent=exports.VoidAnyEvent=exports.AnyEvent=exports.EventType=void 0;var EventType,objects_1=require("./objects"),sync_event_1=require("./sync-event"),async_event_1=require("./async-event"),queued_event_1=require("./queued-event");!function(EventType){EventType[EventType.Sync=0]="Sync",EventType[EventType.Async=1]="Async",EventType[EventType.Queued=2]="Queued"}(EventType=exports.EventType||(exports.EventType={}));var AnyEvent=function(){function AnyEvent(opts){this._events=[],opts&&opts.monitorAttach&&(this.evtFirstAttached=new VoidAnyEvent,this.evtLastDetached=new VoidAnyEvent)}return Object.defineProperty(AnyEvent.prototype,"evtListenersChanged",{get:function(){return this._listenersChanged||(this._listenersChanged=new sync_event_1.VoidSyncEvent),this._listenersChanged},enumerable:!1,configurable:!0}),AnyEvent.prototype.attach=function(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];var mode=EventType.Sync;0<args.length&&"number"==typeof args[0]&&(mode=args.shift());var handler,postable,boundTo=this,opts="function"==typeof args[0]||args[0]&&"object"==typeof args[0]&&"function"==typeof args[0].post?("function"==typeof args[0]?handler=args[0]:postable=args[0],args[1]):(boundTo=args[0],handler=args[1],args[2]);return this._attach(mode,boundTo,handler,postable,opts,!1)},AnyEvent.prototype.once=function(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];var mode=EventType.Sync;0<args.length&&"number"==typeof args[0]&&(mode=args.shift());var handler,postable,boundTo=this,opts="function"==typeof args[0]||args[0]&&"object"==typeof args[0]&&"function"==typeof args[0].post?("function"==typeof args[0]?handler=args[0]:postable=args[0],args[1]):(boundTo=args[0],handler=args[1],args[2]);return this._attach(mode,boundTo,handler,postable,opts,!0)},AnyEvent.prototype._attach=function(mode,boundTo,handler,postable,opts,once){var event,detacher,_this=this,prevCount=this.evtFirstAttached?this.listenerCount():0;switch(mode){case EventType.Sync:for(var _i=0,_a=this._events;_i<_a.length;_i++){(evt=_a[_i])instanceof sync_event_1.SyncEvent&&(event=evt)}event||(event=new sync_event_1.SyncEvent,this._events.push(event));break;case EventType.Async:for(var _b=0,_c=this._events;_b<_c.length;_b++){(evt=_c[_b])instanceof async_event_1.AsyncEvent&&objects_1.shallowEquals(evt.options,opts)&&(event=evt)}event||(event=new async_event_1.AsyncEvent(opts),this._events.push(event));break;case EventType.Queued:for(var evt,_d=0,_e=this._events;_d<_e.length;_d++){(evt=_e[_d])instanceof queued_event_1.QueuedEvent&&objects_1.shallowEquals(evt.options,opts)&&(event=evt)}event||(event=new queued_event_1.QueuedEvent(opts),this._events.push(event));break;default:throw new Error("unknown EventType")}return detacher=once?postable?event.once(postable):event.once(boundTo,handler):postable?event.attach(postable):event.attach(boundTo,handler),this.evtFirstAttached&&0===prevCount&&this.evtFirstAttached.post(),this.evtListenersChanged&&prevCount!==this.listenerCount()&&this.evtListenersChanged.post(),function(){var prevCount=_this.evtLastDetached?_this.listenerCount():0;detacher(),_this.evtLastDetached&&0<prevCount&&0===_this.listenerCount()&&_this.evtLastDetached.post(),_this.evtListenersChanged&&prevCount!==_this.listenerCount()&&_this.evtListenersChanged.post()}},AnyEvent.prototype.attachSync=function(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];return args.unshift(EventType.Sync),this.attach.apply(this,args)},AnyEvent.prototype.onceSync=function(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];return args.unshift(EventType.Sync),this.once.apply(this,args)},AnyEvent.prototype.attachAsync=function(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];return args.unshift(EventType.Async),this.attach.apply(this,args)},AnyEvent.prototype.onceAsync=function(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];return args.unshift(EventType.Async),this.once.apply(this,args)},AnyEvent.prototype.attachQueued=function(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];return args.unshift(EventType.Queued),this.attach.apply(this,args)},AnyEvent.prototype.onceQueued=function(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];return args.unshift(EventType.Queued),this.once.apply(this,args)},AnyEvent.prototype.detach=function(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];for(var prevCount=this.listenerCount(),i=0;i<this._events.length;++i)this._events[i].detach.apply(this._events[i],args);this.evtListenersChanged&&prevCount!==this.listenerCount()&&this.evtListenersChanged.post(),this.evtLastDetached&&0<prevCount&&0===this.listenerCount()&&this.evtLastDetached.post()},AnyEvent.prototype.post=function(data){for(var events=[],i=0;i<this._events.length;++i)events.push(this._events[i]);for(i=0;i<events.length;++i)events[i].post(data)},AnyEvent.prototype.listenerCount=function(){for(var result=0,i=0;i<this._events.length;++i)result+=this._events[i].listenerCount();return result},AnyEvent}(),VoidAnyEvent=function(_super){function VoidAnyEvent(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(VoidAnyEvent,_super),VoidAnyEvent.prototype.post=function(){_super.prototype.post.call(this,void 0)},VoidAnyEvent}(exports.AnyEvent=AnyEvent);exports.VoidAnyEvent=VoidAnyEvent;var ErrorAnyEvent=function(_super){function ErrorAnyEvent(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(ErrorAnyEvent,_super),ErrorAnyEvent.prototype.post=function(data){if(0===this.listenerCount())throw new Error("error event posted while no listeners attached. Error: "+data.message);_super.prototype.post.call(this,data)},ErrorAnyEvent}(AnyEvent);exports.ErrorAnyEvent=ErrorAnyEvent},{"./async-event":3,"./objects":5,"./queued-event":6,"./sync-event":7}],3:[function(require,module,exports){(function(setImmediate){"use strict";var extendStatics,__extends=this&&this.__extends||(extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)},function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)});Object.defineProperty(exports,"__esModule",{value:!0}),exports.ErrorAsyncEvent=exports.VoidAsyncEvent=exports.AsyncEvent=void 0;var base_event_1=require("./base-event"),sync_event_1=require("./sync-event"),AsyncEvent=function(_super){function AsyncEvent(opts){void 0===opts&&(opts={});var _this=_super.call(this)||this;return _this._queued=!1,"boolean"==typeof(_this.options=opts).condensed?_this._condensed=opts.condensed:_this._condensed=!1,_this}return __extends(AsyncEvent,_super),Object.defineProperty(AsyncEvent.prototype,"evtListenersChanged",{get:function(){return this._listenersChanged||(this._listenersChanged=new sync_event_1.VoidSyncEvent),this._listenersChanged},enumerable:!1,configurable:!0}),AsyncEvent.defaultScheduler=function(callback){"undefined"!=typeof window?setTimeout(callback,0):setImmediate(callback)},AsyncEvent.setScheduler=function(scheduler){AsyncEvent._scheduler=scheduler},AsyncEvent.prototype.post=function(){for(var _this=this,args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];if(this._listeners&&0!==this._listeners.length)if(this._condensed){if(this._queuedData=args,this._queuedListeners=this._listeners,this._queued)return;this._queued=!0,AsyncEvent._scheduler(function(){_this._queued=!1;for(var data=_this._queuedData,listeners=_this._queuedListeners,i=0;i<listeners.length;++i){var listener=listeners[i];_this._call(listener,data)}})}else{var listeners_1=this._listeners;AsyncEvent._scheduler(function(){for(var i=0;i<listeners_1.length;++i){var listener=listeners_1[i];_this._call(listener,args)}})}},AsyncEvent.prototype._call=function(listener,args){listener.event&&listener.event instanceof AsyncEvent?listener.event._postDirect(args):_super.prototype._call.call(this,listener,args)},AsyncEvent.prototype._postDirect=function(args){if(this._listeners&&0!==this._listeners.length)for(var listeners=this._listeners,i=0;i<listeners.length;++i){var listener=listeners[i];this._call(listener,args)}},AsyncEvent.prototype._attach=function(a,b,once){var _a,_b,_c,_d,count=null!==(_b=null===(_a=this._listeners)||void 0===_a?void 0:_a.length)&&void 0!==_b?_b:0,result=_super.prototype._attach.call(this,a,b,once);return this.evtListenersChanged&&count!==(null!==(_d=null===(_c=this._listeners)||void 0===_c?void 0:_c.length)&&void 0!==_d?_d:0)&&this.evtListenersChanged.post(),result},AsyncEvent.prototype._detach=function(){for(var _a,_b,_c,_d,args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];var count=null!==(_b=null===(_a=this._listeners)||void 0===_a?void 0:_a.length)&&void 0!==_b?_b:0,result=_super.prototype._detach.apply(this,args);return this.evtListenersChanged&&count!==(null!==(_d=null===(_c=this._listeners)||void 0===_c?void 0:_c.length)&&void 0!==_d?_d:0)&&this.evtListenersChanged.post(),result},AsyncEvent._scheduler=AsyncEvent.defaultScheduler,AsyncEvent}(base_event_1.BaseEvent),VoidAsyncEvent=function(_super){function VoidAsyncEvent(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(VoidAsyncEvent,_super),VoidAsyncEvent.prototype.post=function(){_super.prototype.post.call(this,void 0)},VoidAsyncEvent}(exports.AsyncEvent=AsyncEvent);exports.VoidAsyncEvent=VoidAsyncEvent;var ErrorAsyncEvent=function(_super){function ErrorAsyncEvent(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(ErrorAsyncEvent,_super),ErrorAsyncEvent.prototype.post=function(data){if(0===this.listenerCount())throw new Error("error event posted while no listeners attached. Error: "+data.message);_super.prototype.post.call(this,data)},ErrorAsyncEvent}(AsyncEvent);exports.ErrorAsyncEvent=ErrorAsyncEvent}).call(this,require("timers").setImmediate)},{"./base-event":4,"./sync-event":7,timers:9}],4:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseEvent=void 0;var BaseEvent=function(){function BaseEvent(){}return BaseEvent.prototype.attach=function(a,b){return this._attach(a,b,!1)},BaseEvent.prototype.once=function(a,b){return this._attach(a,b,!0)},BaseEvent.prototype._attach=function(a,b,once){var boundTo,handler,event,result,_this=this;if("function"==typeof a)handler=a,result=function(){return _this.detach(handler)};else if(b||"function"!=typeof a.post){if("object"!=typeof a||void 0===a)throw new Error("Expect a function or object as first argument");if("function"!=typeof b)throw new Error("Expect a function as second argument");boundTo=a,handler=b,result=function(){return _this.detach(boundTo,handler)}}else event=a,result=function(){return _this.detach(event)};return this._listeners?this._listeners=this._listeners.slice():this._listeners=[],this._listeners.push({deleted:!1,boundTo:boundTo,handler:handler,event:event,once:once}),result},BaseEvent.prototype.detach=function(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];this._detach.apply(this,args)},BaseEvent.prototype._detach=function(){for(var boundTo,handler,event,args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];this._listeners&&0!==this._listeners.length&&(1<=args.length&&("function"==typeof args[0]?handler=args[0]:1===args.length&&"function"==typeof args[0].post?event=args[0]:boundTo=args[0]),2<=args.length&&(handler=args[1]),this._listeners=this._listeners.filter(function(listener){return void 0!==handler&&listener.handler!==handler||void 0!==event&&listener.event!==event||void 0!==boundTo&&listener.boundTo!==boundTo||!(listener.deleted=!0)}),0===this._listeners.length&&delete this._listeners)},BaseEvent.prototype.post=function(data){throw new Error("abstract")},BaseEvent.prototype.listenerCount=function(){return this._listeners?this._listeners.length:0},BaseEvent.prototype._call=function(listener,args){this._listeners&&(listener.deleted||(listener.once&&(listener.deleted=!0,this._listeners=this._listeners.filter(function(l){return l!==listener}),0===this._listeners.length&&delete this._listeners),listener.event?listener.event.post.apply(listener.event,args):listener.handler&&listener.handler.apply("object"==typeof listener.boundTo?listener.boundTo:this,args)))},BaseEvent}();exports.BaseEvent=BaseEvent},{}],5:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.shallowEquals=void 0,exports.shallowEquals=function(a,b){if(a===b)return!0;if(typeof a!=typeof b)return!1;switch(typeof a){case"boolean":case"number":case"string":case"function":case"symbol":case"undefined":return!1;case"object":if(null===a||null===b)return!1;if(Array.isArray(a)||Array.isArray(b)){if(!Array.isArray(a)||!Array.isArray(b))return!1;if(a.length!==b.length)return!1;for(var i=0;i<a.length;++i)if(a[i]!==b[i])return!1;return!0}var namesA=[],namesB=[];for(var name_1 in a)a.hasOwnProperty(name_1)&&namesA.push(name_1);for(var name_2 in b)b.hasOwnProperty(name_2)&&namesB.push(name_2);if(namesA.sort(),namesB.sort(),namesA.join(",")!==namesB.join(","))return!1;for(i=0;i<namesA.length;++i)if(a[namesA[i]]!==b[namesA[i]])return!1;return!0;default:return!1}}},{}],6:[function(require,module,exports){"use strict";var extendStatics,__extends=this&&this.__extends||(extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)},function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)});Object.defineProperty(exports,"__esModule",{value:!0}),exports.ErrorQueuedEvent=exports.VoidQueuedEvent=exports.QueuedEvent=void 0;var base_event_1=require("./base-event"),EventQueue_1=require("./EventQueue"),sync_event_1=require("./sync-event"),QueuedEvent=function(_super){function QueuedEvent(opts){void 0===opts&&(opts={});var _this=_super.call(this)||this;return _this._queued=!1,"boolean"==typeof(_this.options=opts).condensed?_this._condensed=opts.condensed:_this._condensed=!1,"object"==typeof opts.queue&&null!==opts.queue&&(_this._queue=opts.queue),_this}return __extends(QueuedEvent,_super),Object.defineProperty(QueuedEvent.prototype,"evtListenersChanged",{get:function(){return this._listenersChanged||(this._listenersChanged=new sync_event_1.VoidSyncEvent),this._listenersChanged},enumerable:!1,configurable:!0}),QueuedEvent.prototype.post=function(){for(var _this=this,args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];if(this._listeners&&0!==this._listeners.length){var queue=this._queue?this._queue:EventQueue_1.default.global();if(this._condensed){if(this._queuedData=args,this._queuedListeners=this._listeners,this._queued)return;this._queued=!0,queue.add(function(){_this._queued=!1;for(var data=_this._queuedData,listeners=_this._queuedListeners,i=0;i<listeners.length;++i){var listener=listeners[i];_this._call(listener,data)}})}else{var listeners_1=this._listeners;queue.add(function(){for(var i=0;i<listeners_1.length;++i){var listener=listeners_1[i];_this._call(listener,args)}})}}},QueuedEvent.prototype._attach=function(a,b,once){var _a,_b,_c,_d,count=null!==(_b=null===(_a=this._listeners)||void 0===_a?void 0:_a.length)&&void 0!==_b?_b:0,result=_super.prototype._attach.call(this,a,b,once);return this.evtListenersChanged&&count!==(null!==(_d=null===(_c=this._listeners)||void 0===_c?void 0:_c.length)&&void 0!==_d?_d:0)&&this.evtListenersChanged.post(),result},QueuedEvent.prototype._detach=function(){for(var _a,_b,_c,_d,args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];var count=null!==(_b=null===(_a=this._listeners)||void 0===_a?void 0:_a.length)&&void 0!==_b?_b:0,result=_super.prototype._detach.apply(this,args);return this.evtListenersChanged&&count!==(null!==(_d=null===(_c=this._listeners)||void 0===_c?void 0:_c.length)&&void 0!==_d?_d:0)&&this.evtListenersChanged.post(),result},QueuedEvent}(base_event_1.BaseEvent),VoidQueuedEvent=function(_super){function VoidQueuedEvent(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(VoidQueuedEvent,_super),VoidQueuedEvent.prototype.post=function(){_super.prototype.post.call(this,void 0)},VoidQueuedEvent}(exports.QueuedEvent=QueuedEvent);exports.VoidQueuedEvent=VoidQueuedEvent;var ErrorQueuedEvent=function(_super){function ErrorQueuedEvent(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(ErrorQueuedEvent,_super),ErrorQueuedEvent.prototype.post=function(data){if(!this._listeners||0===this._listeners.length)throw new Error("error event posted while no listeners attached. Error: "+data.message);_super.prototype.post.call(this,data)},ErrorQueuedEvent}(QueuedEvent);exports.ErrorQueuedEvent=ErrorQueuedEvent},{"./EventQueue":1,"./base-event":4,"./sync-event":7}],7:[function(require,module,exports){"use strict";var extendStatics,__extends=this&&this.__extends||(extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)},function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)});Object.defineProperty(exports,"__esModule",{value:!0}),exports.ErrorSyncEvent=exports.VoidSyncEvent=exports.SyncEvent=void 0;var SyncEvent=function(_super){function SyncEvent(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this._recursion=0,_this}return __extends(SyncEvent,_super),Object.defineProperty(SyncEvent.prototype,"evtListenersChanged",{get:function(){return this._listenersChanged||(this._listenersChanged=new VoidSyncEvent),this._listenersChanged},enumerable:!1,configurable:!0}),SyncEvent.prototype.post=function(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];if(this._listeners&&0!==this._listeners.length){if(this._recursion++,"number"==typeof SyncEvent.MAX_RECURSION_DEPTH&&Number.isInteger(SyncEvent.MAX_RECURSION_DEPTH)&&0<SyncEvent.MAX_RECURSION_DEPTH&&this._recursion>SyncEvent.MAX_RECURSION_DEPTH)throw new Error("event fired recursively");for(var listeners=this._listeners,i=0;i<listeners.length;++i){var listener=listeners[i];this._call(listener,args)}this._recursion--}},SyncEvent.prototype._attach=function(a,b,once){var _a,_b,_c,_d,count=null!==(_b=null===(_a=this._listeners)||void 0===_a?void 0:_a.length)&&void 0!==_b?_b:0,result=_super.prototype._attach.call(this,a,b,once);return this.evtListenersChanged&&count!==(null!==(_d=null===(_c=this._listeners)||void 0===_c?void 0:_c.length)&&void 0!==_d?_d:0)&&this.evtListenersChanged.post(),result},SyncEvent.prototype._detach=function(){for(var _a,_b,_c,_d,args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];var count=null!==(_b=null===(_a=this._listeners)||void 0===_a?void 0:_a.length)&&void 0!==_b?_b:0,result=_super.prototype._detach.apply(this,args);return this.evtListenersChanged&&count!==(null!==(_d=null===(_c=this._listeners)||void 0===_c?void 0:_c.length)&&void 0!==_d?_d:0)&&this.evtListenersChanged.post(),result},SyncEvent.MAX_RECURSION_DEPTH=10,SyncEvent}(require("./base-event").BaseEvent),VoidSyncEvent=function(_super){function VoidSyncEvent(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(VoidSyncEvent,_super),VoidSyncEvent.prototype.post=function(){_super.prototype.post.call(this,void 0)},VoidSyncEvent}(exports.SyncEvent=SyncEvent);exports.VoidSyncEvent=VoidSyncEvent;var ErrorSyncEvent=function(_super){function ErrorSyncEvent(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(ErrorSyncEvent,_super),ErrorSyncEvent.prototype.post=function(data){if(0===this.listenerCount())throw new Error("error event posted while no listeners attached. Error: "+data.message);_super.prototype.post.call(this,data)},ErrorSyncEvent}(SyncEvent);exports.ErrorSyncEvent=ErrorSyncEvent},{"./base-event":4}],8:[function(require,module,exports){var cachedSetTimeout,cachedClearTimeout,process=module.exports={};function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(fun){if(cachedSetTimeout===setTimeout)return setTimeout(fun,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(fun,0);try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}!function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}}();var currentQueue,queue=[],draining=!1,queueIndex=-1;function cleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var timeout=runTimeout(cleanUpNextTick);draining=!0;for(var len=queue.length;len;){for(currentQueue=queue,queue=[];++queueIndex<len;)currentQueue&¤tQueue[queueIndex].run();queueIndex=-1,len=queue.length}currentQueue=null,draining=!1,function(marker){if(cachedClearTimeout===clearTimeout)return clearTimeout(marker);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(marker);try{cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}(timeout)}}function Item(fun,array){this.fun=fun,this.array=array}function noop(){}process.nextTick=function(fun){var args=new Array(arguments.length-1);if(1<arguments.length)for(var i=1;i<arguments.length;i++)args[i-1]=arguments[i];queue.push(new Item(fun,args)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.prependListener=noop,process.prependOnceListener=noop,process.listeners=function(name){return[]},process.binding=function(name){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(dir){throw new Error("process.chdir is not supported")},process.umask=function(){return 0}},{}],9:[function(require,module,exports){(function(setImmediate,clearImmediate){var nextTick=require("process/browser.js").nextTick,apply=Function.prototype.apply,slice=Array.prototype.slice,immediateIds={},nextImmediateId=0;function Timeout(id,clearFn){this._id=id,this._clearFn=clearFn}exports.setTimeout=function(){return new Timeout(apply.call(setTimeout,window,arguments),clearTimeout)},exports.setInterval=function(){return new Timeout(apply.call(setInterval,window,arguments),clearInterval)},exports.clearTimeout=exports.clearInterval=function(timeout){timeout.close()},Timeout.prototype.unref=Timeout.prototype.ref=function(){},Timeout.prototype.close=function(){this._clearFn.call(window,this._id)},exports.enroll=function(item,msecs){clearTimeout(item._idleTimeoutId),item._idleTimeout=msecs},exports.unenroll=function(item){clearTimeout(item._idleTimeoutId),item._idleTimeout=-1},exports._unrefActive=exports.active=function(item){clearTimeout(item._idleTimeoutId);var msecs=item._idleTimeout;0<=msecs&&(item._idleTimeoutId=setTimeout(function(){item._onTimeout&&item._onTimeout()},msecs))},exports.setImmediate="function"==typeof setImmediate?setImmediate:function(fn){var id=nextImmediateId++,args=!(arguments.length<2)&&slice.call(arguments,1);return immediateIds[id]=!0,nextTick(function(){immediateIds[id]&&(args?fn.apply(null,args):fn.call(null),exports.clearImmediate(id))}),id},exports.clearImmediate="function"==typeof clearImmediate?clearImmediate:function(id){delete immediateIds[id]}}).call(this,require("timers").setImmediate,require("timers").clearImmediate)},{"process/browser.js":8,timers:9}],"ts-events":[function(require,module,exports){"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k),Object.defineProperty(o,k2,{enumerable:!0,get:function(){return m[k]}})}:function(o,m,k,k2){void 0===k2&&(k2=k),o[k2]=m[k]}),__exportStar=this&&this.__exportStar||function(m,exports){for(var p in m)"default"===p||exports.hasOwnProperty(p)||__createBinding(exports,m,p)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.flush=exports.flushOnce=exports.queue=void 0,__exportStar(require("./base-event"),exports),__exportStar(require("./sync-event"),exports),__exportStar(require("./queued-event"),exports),__exportStar(require("./async-event"),exports),__exportStar(require("./any-event"),exports);var EventQueue_1=require("./EventQueue"),EventQueue_2=require("./EventQueue");Object.defineProperty(exports,"EventQueue",{enumerable:!0,get:function(){return EventQueue_2.default}}),exports.queue=function(){return EventQueue_1.default.global()},exports.flushOnce=function(){EventQueue_1.default.global().flushOnce()},exports.flush=function(maxRounds){void 0===maxRounds&&(maxRounds=10),EventQueue_1.default.global().flush(maxRounds)}},{"./EventQueue":1,"./any-event":2,"./async-event":3,"./base-event":4,"./queued-event":6,"./sync-event":7}]},{},[]),require("ts-events")});