"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react");exports.default=function(n){var r=t.useState(!1),s=r[0],o=r[1],i=t.useState(null),a=i[0],c=i[1],u=t.useState(null),l=u[0],g=u[1];return{checkExistingRules:function(t,r,s,i){return e.__awaiter(void 0,void 0,void 0,function(){var a,u,l,f;return e.__generator(this,function(e){switch(e.label){case 0:o(!0),g(null),c(null),a={mode:"AgentGenie",assistantname:s,organizationname:i,wta:t.wta.map(function(e){return e.text}),wnta:t.wnta.map(function(e){return e.text}),agent_id:r},console.log("Checking for existing DB conflicts with payload:",a),e.label=1;case 1:return e.trys.push([1,4,5,6]),[4,fetch("".concat(n,"/instant_learning/mode-wta-existing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})];case 2:if(!(u=e.sent()).ok)throw new Error("API Error: ".concat(u.statusText));return[4,u.json()];case 3:return(l=e.sent()).response?(console.log("DB check successful. Setting state with:",l.response),c(l.response)):(console.error("DB check: API response object was missing."),c(null)),[3,6];case 4:return f=e.sent(),console.error("Failed to check for existing rules:",f),g(f),[3,6];case 5:return o(!1),[7];case 6:return[2]}})})},isLoading:s,existingConflicts:a,error:l,clearExistingAgentConflicts:function(){c(null)}}};
//# sourceMappingURL=useExistingAgentCheck.js.map
