"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CallbacksRegistry=void 0;class CallbacksRegistry{constructor(){this.nextId=0,this.callbacks={},this.callbackIds=new WeakMap,this.locationInfo=new WeakMap}add(e){let t,l,s=this.callbackIds.get(e);if(null!=s)return s;s=this.nextId+=1,this.callbacks[s]=e,this.callbackIds.set(e,s);let a=/at (.*)/gi,c=Error().stack;if(!c)return s;for(;null!==(l=a.exec(c));){let e=l[1];if(e.includes("(native)")||e.includes("(<anonymous>)")||e.includes("callbacks-registry.js")||e.includes("remote.js")||e.includes("@electron/remote/dist"))continue;let s=/([^/^)]*)\)?$/gi.exec(e);s&&(t=s[1]);break}return this.locationInfo.set(e,t),s}get(e){return this.callbacks[e]||function(){}}getLocation(e){return this.locationInfo.get(e)}apply(e,...t){return this.get(e).apply(global,...t)}remove(e){let t=this.callbacks[e];t&&(this.callbackIds.delete(t),delete this.callbacks[e])}}exports.CallbacksRegistry=CallbacksRegistry;