"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react");exports.default=function(n){var r=t.useState(!1),o=r[0],s=r[1],i=t.useState(null),c=i[0],a=i[1],l=t.useState(null),u=l[0],p=l[1];return{checkExistingPromptRules:function(t,r,o,i){return e.__awaiter(void 0,void 0,void 0,function(){var c,l,u,f;return e.__generator(this,function(e){switch(e.label){case 0:s(!0),p(null),a(null),c={mode:"PromptGenie",template_title:r,template_description:o,wta:t.wta.map(function(e){return e.text}).join(" OR "),wnta:t.wnta.map(function(e){return e.text}).join(" OR "),llm:i},console.log("Checking for existing DB conflicts (PromptGenie) with payload:",c),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(c)})];case 2:if(!(l=e.sent()).ok)throw new Error("API Error: ".concat(l.statusText));return[4,l.json()];case 3:return(u=e.sent()).response?(console.log("DB check (PromptGenie) successful. Setting state with:",u.response),a(u.response)):(console.error("DB check (PromptGenie): API response object was missing."),a(null)),[3,6];case 4:return f=e.sent(),console.error("Failed to check for existing prompt rules:",f),p(f),[3,6];case 5:return s(!1),[7];case 6:return[2]}})})},isLoading:o,existingPromptConflicts:c,error:u,clearExistingPromptConflicts:function(){a(null)}}};
//# sourceMappingURL=useExistingPromptCheck.js.map
