"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),n=require("./useDebounce.js");exports.default=function(o,s,r,a,i,c){void 0===i&&(i=!0);var u=t.useState([]),l=u[0],d=u[1],p=t.useState(!1),f=p[0],g=p[1],h=t.useState(null),_=h[0],w=h[1],y=n.default(o,500),v=n.default(s,500);return t.useEffect(function(){if(v&&i){e.__awaiter(void 0,void 0,void 0,function(){var t,n,o,s,r,i,u;return e.__generator(this,function(e){switch(e.label){case 0:console.log("[".concat((new Date).toLocaleTimeString(),"] Attempting to fetch suggestions...")),g(!0),w(null),e.label=1;case 1:return e.trys.push([1,4,5,6]),t={agent_context:y,agent_description:v,mode:"AgentGenie",llm:a,n:1},console.log("API Payload:",t),[4,fetch("".concat(c,"/instant_learning/mode-wta-suggestion"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})];case 2:if(!(n=e.sent()).ok)throw new Error("API Error: ".concat(n.statusText));return[4,n.json()];case 3:return o=e.sent(),s=[],null===(i=o.response.conditions_whentoapply)||void 0===i||i.forEach(function(e){s.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})}),null===(u=o.response.conditions_whennottoapply)||void 0===u||u.forEach(function(e){s.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})}),d(s),[3,6];case 4:return r=e.sent(),console.error("Failed to fetch suggestions:",r),w(r),[3,6];case 5:return g(!1),[7];case 6:return[2]}})})}else d([])},[y,v,r,i]),{suggestions:l,isLoading:f,error:_}};
//# sourceMappingURL=useAgentSuggestions.js.map
