const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Dqa23PTc.js","assets/plchelper_wasm-DS8UhsA2.js"])))=>i.map(i=>d[i]);
import{_ as i}from"./index-CqB7vtgZ.js";const o={ok:!1,error:null,units:[],problems:[],cycles:[],usesExternals:!1};class u{inner;seq=0;units=[];disposed=!1;constructor(t){this.inner=t}build(t,s){const e=this.parse(this.inner.build(JSON.stringify(t),JSON.stringify(s)),o);return this.units=e.units,this.seq=0,e}cycle(t,s){return this.parse(this.inner.cycle(JSON.stringify(t),s),[])}stop(){this.inner.stop()}status(){return this.parse(this.inner.status(),{loaded:!1,cycles:0,fault:null,debugging:!1,paused:!1})}symbols(){return this.parse(this.inner.symbols(),[])}setSymbol(t,s){return this.inner.set_symbol(t,JSON.stringify(s))}setDebug(t){this.inner.set_debug(t),t&&this.send("initialize",{adapterID:"st"})}setBreakpoints(t){this.inner.set_breakpoints(JSON.stringify(t))}pause(){return this.send("pause",{threadId:1})}continue(){return this.resume("continue")}stepOver(){return this.resume("next")}stepInto(){return this.resume("stepIn")}stepOut(){return this.resume("stepOut")}takeWrites(){return this.parse(this.inner.take_writes(),[])}stackTrace(){return this.body(this.send("stackTrace",{threadId:1}),"stackTrace")?.stackFrames??[]}scopes(t){return this.body(this.send("scopes",{frameId:t}),"scopes")?.scopes??[]}variables(t){return this.body(this.send("variables",{variablesReference:t}),"variables")?.variables??[]}setVariable(t,s,e){return this.send("setVariable",{variablesReference:t,name:s,value:e}).some(r=>r.type==="response"&&r.command==="setVariable"&&r.success)}evaluate(t,s){const n=this.send("evaluate",{expression:t,frameId:s,context:"watch"}).find(r=>r.type==="response"&&r.command==="evaluate");return n?.success?{result:String(n.body?.result??""),type:String(n.body?.type??"")}:null}toUnitLine(t){const s=this.units.find(e=>t>=e.startLine&&t<e.startLine+e.lineCount);return s?{unitId:s.unitId,unitName:s.unitName,line:t-s.startLine+1}:null}dispose(){this.disposed||(this.disposed=!0,this.inner.free())}resume(t){return this.send(t,{threadId:1})}send(t,s){if(this.disposed)return[];this.seq+=1;const e=JSON.stringify({type:"request",seq:this.seq,command:t,arguments:s});return this.parse(this.inner.pump(e),[])}body(t,s){return t.find(e=>e.type==="response"&&e.command===s&&e.success)?.body}parse(t,s){try{return JSON.parse(t)}catch{return s}}}async function d(a){await(await i(()=>import("./index-Dqa23PTc.js"),__vite__mapDeps([0,1]))).loadStEngine();const{StProgram:s}=await i(async()=>{const{StProgram:e}=await import("./plchelper_wasm-DS8UhsA2.js");return{StProgram:e}},[]);try{return JSON.parse(s.check(JSON.stringify(a)))}catch{return o}}async function p(){await(await i(()=>import("./index-Dqa23PTc.js"),__vite__mapDeps([0,1]))).loadStEngine();const{StProgram:t}=await i(async()=>{const{StProgram:s}=await import("./plchelper_wasm-DS8UhsA2.js");return{StProgram:s}},[]);return new u(new t)}export{u as ProgramRuntime,d as checkProgram,p as loadProgramRuntime};
