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AAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAClD,KAAK,IAAI,SAAS,IAAI,IAAI,EAAE;YACxB,MAAM,IAAI,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;SAC7D;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AA9HD,0BA8HC","file":"","sourceRoot":"/","sourcesContent":["export class Disposable {\n private _disposed = false;\n private _disposalAction: () => void;\n\n constructor(disposalAction: () => void) {\n this._disposalAction = disposalAction;\n }\n\n get disposed() {\n return this._disposed;\n }\n\n dispose() {\n if (!this.disposed) {\n this._disposed = true;\n if (this._disposalAction) {\n this._disposalAction();\n this._disposalAction = null;\n }\n }\n }\n}\n\nexport class CompositeDisposable {\n private _disposed = false;\n private _disposables: Set<Disposable> = new Set();\n\n constructor(...disposables: Disposable[]) {\n for (let disposable of disposables) {\n this.add(disposable);\n }\n }\n\n add(disposable: Disposable) {\n if (!this._disposed) {\n if (disposable) {\n this._disposables.add(disposable);\n }\n }\n }\n\n remove(disposable: Disposable) {\n if (!this._disposed) {\n this._disposables.delete(disposable);\n }\n }\n\n clear() {\n if (!this._disposed) {\n this._disposables.clear();\n }\n }\n\n dispose() {\n if (!this._disposed) {\n this._disposed = true;\n this._disposables.forEach((disposable) => {\n disposable.dispose();\n });\n this._disposables = null;\n }\n }\n}\n\nexport class Event<T extends (...args: any[]) => any> {\n private emitter: Emitter;\n private name: string | symbol;\n\n constructor(emitter: Emitter, name: string | symbol) {\n this.emitter = emitter;\n this.name = name;\n }\n\n getName() {\n return this.name;\n }\n\n toString() {\n return `[Event ${this.name.toString()}]`;\n }\n\n on(handler: T, unshift: boolean = false) {\n return this.emitter.on(this.name, handler, unshift);\n }\n\n once(handler: T, unshift: boolean = false) {\n return this.emitter.once(this.name, handler, unshift);\n }\n\n readonly emit = ((...argsparam: any[]): Promise<ReturnType<T>>[] => {\n argsparam.unshift(this.name);\n return this.emitter.emit.apply(this.emitter, argsparam);\n }) as T;\n}\n\nexport class Emitter {\n private _disposed = false;\n private _handlersByEventName: Map<string | symbol, Array<(...args: any[]) => any>> = new Map();\n\n get disposed() {\n return this._disposed;\n }\n\n clear() {\n this._handlersByEventName.clear();\n }\n\n dispose() {\n this._handlersByEventName = null;\n this._disposed = true;\n }\n\n createEvent<T extends (...args: any[]) => void>(eventName?: string | symbol) {\n if (!eventName) {\n return new Event<T>(this, Symbol(\"Event\"));\n }\n return new Event<T>(this, eventName);\n }\n\n on(eventName: string | symbol, handler: (...args: any[]) => any, unshift: boolean = false) {\n if (this._disposed) {\n throw new Error(\"Emitter has been diposed\");\n }\n\n let currentHandler = this._handlersByEventName.get(eventName);\n if (currentHandler) {\n if (unshift) {\n currentHandler.unshift(handler);\n } else {\n currentHandler.push(handler);\n }\n } else {\n this._handlersByEventName.set(eventName, [handler]);\n }\n return new Disposable(this.off.bind(this, eventName, handler));\n }\n\n once(eventName: string | symbol, handler: (...args: any[]) => any, unshift: boolean = false) {\n let wrapped = (...args: any[]) => {\n disposable.dispose();\n return handler(...args);\n };\n let disposable = this.on(eventName, wrapped, unshift);\n return disposable;\n }\n\n private off = (eventName: string | symbol, handlerToRemove: (...args: any[]) => any) => {\n if (this._disposed) return;\n let oldHandlers = this._handlersByEventName.get(eventName);\n if (oldHandlers) {\n let newHandlers = [];\n for (let handler of oldHandlers) {\n if (handler != handlerToRemove) {\n newHandlers.push(handler);\n }\n }\n if (newHandlers.length) {\n this._handlersByEventName.set(eventName, newHandlers);\n } else {\n this._handlersByEventName.delete(eventName);\n }\n }\n };\n\n emit(eventName: string | symbol, ...args: any[]) {\n let handlers = this._handlersByEventName.get(eventName);\n let result: Promise<any>[] = [];\n if (handlers) {\n for (let handler of handlers) {\n try {\n let ret = handler(...args);\n if (ret === undefined) {\n result.push(Promise.resolve());\n } else if (ret instanceof Promise) {\n result.push(ret);\n } else {\n result.push(Promise.resolve(ret));\n }\n } catch (e) {\n console.error(e);\n }\n }\n }\n return result;\n }\n\n getEventNames() {\n let ret: string[] = [];\n let keys = Object.keys(this._handlersByEventName);\n for (let k of keys) {\n if (typeof (k) === 'string') {\n ret.push(k);\n }\n }\n return ret;\n }\n\n getEventSymbols() {\n let ret: symbol[] = [];\n let keys = Object.keys(this._handlersByEventName);\n for (let k of keys) {\n if (typeof (k) === 'symbol') {\n ret.push(k);\n }\n }\n return ret;\n }\n\n listenerCountForEventName(eventName: string | symbol) {\n let handlers = this._handlersByEventName.get(eventName);\n return handlers ? handlers.length : 0;\n }\n\n getTotalListenerCount() {\n let result = 0;\n let keys = Object.keys(this._handlersByEventName);\n for (let eventName of keys) {\n result += this._handlersByEventName.get(eventName).length;\n }\n return result;\n }\n}\n"]}