import{__awaiter as n,__generator as t,__assign as e}from"tslib";import{useState as o}from"react";var r=function(r){var a=o(!1),s=a[0],i=a[1],c=o([]),u=c[0],l=c[1],p=o(null),f=p[0],d=p[1];return{fixAgentRules:function(o,a,s,c,u){return n(void 0,void 0,void 0,function(){var n,p,f,h,w,x,m;return t(this,function(t){switch(t.label){case 0:i(!0),l([]),d(null),n=e(e({},o),{wta:a.wta.map(function(n){return n.text}),wnta:a.wnta.map(function(n){return n.text}),mode:"AgentGenie",agent_description:c,agent_context:s,llm:u,n:1}),t.label=1;case 1:return t.trys.push([1,4,5,6]),[4,fetch("".concat(r,"/instant_learning/mode-wta-validation-fix"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})];case 2:if(!(p=t.sent()).ok)throw new Error("API Error: ".concat(p.statusText));return[4,p.json()];case 3:return f=t.sent(),h=[],null===(x=f.response.conditions_whentoapply)||void 0===x||x.forEach(function(n){h.push({type:"wta",text:n.whentoapply,score:n.confidence_score,reason:n.reason})}),null===(m=f.response.conditions_whennottoapply)||void 0===m||m.forEach(function(n){h.push({type:"wnta",text:n.whennottoapply,score:n.confidence_score,reason:n.reason})}),l(h),[3,6];case 4:return w=t.sent(),console.error("Failed to fix rules:",w),d(w),[3,6];case 5:return i(!1),[7];case 6:return[2]}})})},isFixing:s,fixedSuggestions:u,error:f}};export{r as default};
//# sourceMappingURL=useAgentFix.js.map
