import{__awaiter as e,__generator as t}from"tslib";import{useState as n}from"react";var r=function(r){var o=n(!1),i=o[0],s=o[1],c=n(null),l=c[0],a=c[1],u=n(null),p=u[0],m=u[1];return{checkExistingPromptRules:function(n,o,i,c){return e(void 0,void 0,void 0,function(){var e,l,u,p;return t(this,function(t){switch(t.label){case 0:s(!0),m(null),a(null),e={mode:"PromptGenie",template_title:o,template_description:i,wta:n.wta.map(function(e){return e.text}).join(" OR "),wnta:n.wnta.map(function(e){return e.text}).join(" OR "),llm:c},console.log("Checking for existing DB conflicts (PromptGenie) with payload:",e),t.label=1;case 1:return t.trys.push([1,4,5,6]),[4,fetch("".concat(r,"/instant_learning/mode-wta-existing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})];case 2:if(!(l=t.sent()).ok)throw new Error("API Error: ".concat(l.statusText));return[4,l.json()];case 3:return(u=t.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 p=t.sent(),console.error("Failed to check for existing prompt rules:",p),m(p),[3,6];case 5:return s(!1),[7];case 6:return[2]}})})},isLoading:i,existingPromptConflicts:l,error:p,clearExistingPromptConflicts:function(){a(null)}}};export{r as default};
//# sourceMappingURL=useExistingPromptCheck.js.map
