import"./index.a1506152.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[e]="19ae832f-0fb9-4cc7-a942-ef9444f2f9e5",a._sentryDebugIdIdentifier="sentry-dbid-19ae832f-0fb9-4cc7-a942-ef9444f2f9e5")}catch{}})();class p{static async*sendMessage(e,t,o,s,c,f){var r;const n=await fetch("/_editor/api/ai/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:e,stageId:t,langGraphThreadId:o,code:s,executionError:c})});if(!n.ok)throw new Error("Failed to send message");const i=(r=n.body)==null?void 0:r.getReader();if(!i)throw new Error("No response body");for(;!f();){const d=await i.read();if(d.done)break;yield new TextDecoder().decode(d.value)}}static async getHistory(e,t){const o=await fetch(`/_editor/api/ai/history?limit=${e}&offset=${t}`,{method:"GET"});if(!o.ok)throw new Error("Failed to fetch history");return await o.json()}static async createThread(){return(await fetch("/_editor/api/ai/thread",{method:"POST"})).json()}static async cancelAllRuns(e){return(await fetch("/_editor/api/ai/cancel-all",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:e})})).ok}static async generateProject(e){const t=await fetch("/_editor/api/ai/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e})});if(!t.ok){const o=await t.text();throw new Error(o)}}static async vote(e,t,o,s){await fetch("/_editor/api/ai/vote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({vote:e,question:t,answer:o,context:s})})}}export{p as A};
//# sourceMappingURL=ai.397baef3.js.map
