export class HeapSnapshotWorkerDispatcher{constructor(e,t){this._objects=[],this._global=e,this._postMessage=t}_findFunction(e){const t=e.split(".");let s=this._global;for(let o=0;o<t.length;++o)s=s[t[o]];return s}sendEvent(e,t){this._postMessage({eventName:e,data:t})}dispatchMessage({data:e}){const t={callId:e.callId,result:null,error:void 0,errorCallStack:void 0,errorMethodName:void 0};try{switch(e.disposition){case"create":{const t=this._findFunction(e.methodName);this._objects[e.objectId]=new t(this);break}case"dispose":delete this._objects[e.objectId];break;case"getter":{const s=this._objects[e.objectId][e.methodName];t.result=s;break}case"factory":{const s=this._objects[e.objectId],o=s[e.methodName].apply(s,e.methodArguments);o&&(this._objects[e.newObjectId]=o),t.result=Boolean(o);break}case"method":{const s=this._objects[e.objectId];t.result=s[e.methodName].apply(s,e.methodArguments);break}case"evaluateForTest":try{t.result=self.eval(e.source)}catch(s){t.result=s.toString()}}}catch(s){t.error=s.toString(),t.errorCallStack=s.stack,e.methodName&&(t.errorMethodName=e.methodName)}this._postMessage(t)}}