var v=Object.defineProperty;var R=(d,r)=>{for(var t in r)v(d,t,{get:r[t],enumerable:!0})};var B={};R(B,{dissambleWASM:()=>k});import*as w from"./../../core/common/common.js";import*as a from"./../../third_party/wasmparser/wasmparser.js";function k(d,r){try{let t=w.Base64.decode(d.content),e=new a.WasmParser.BinaryReader;e.setData(t.buffer,0,t.byteLength);let u=new a.WasmDis.DevToolsNameGenerator;u.read(e);let n=new Uint8Array(t);e=new a.WasmParser.BinaryReader;let f=new a.WasmDis.WasmDisassembler;f.addOffsets=!0,f.exportMetadata=u.getExportMetadata(),f.nameResolver=u.getNameResolver();let g=[],b=[],W=[],c=128*1024,o=new Uint8Array(c),i=0,h=0;for(let m=0;m<n.length;){c>n.length-m&&(c=n.length-m);let l=i+c;if(o.byteLength<l){let s=new Uint8Array(l);s.set(o),o=s}for(;i<l;)o[i++]=n[m++];e.setData(o.buffer,0,l,m===n.length);let P=f.disassembleChunk(e,h),p=f.getResult();for(let s of p.lines)g.push(s);for(let s of p.offsets)b.push(s);for(let s of p.functionBodyOffsets)W.push(s);if(P)break;if(e.position===0){i=l;continue}let y=e.data.subarray(e.position,e.length);i=y.length,o.set(y),h+=e.position;let D=Math.floor(h/n.length*100);r({event:"progress",params:{percentage:D}})}r({event:"progress",params:{percentage:100}}),r({method:"disassemble",result:{lines:g,offsets:b,functionBodyOffsets:W}})}catch(t){r({method:"disassemble",error:t})}}export{B as WasmParserWorker};
//# sourceMappingURL=wasmparser_worker.js.map
