"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react");exports.default=function(n,r,o,a){void 0===o&&(o=!0);var l=t.useState(!1),i=l[0],s=l[1],u=t.useState(null),c=u[0],d=u[1],p=t.useState(null),f=p[0],m=p[1];return{validateRules:function(t,l){return e.__awaiter(void 0,void 0,void 0,function(){var i,u,c,p;return e.__generator(this,function(e){switch(e.label){case 0:if(!o)return[2,null];if(s(!0),d(null),m(null),0===(i={template_context:n,template_description:r,wta:t.wta.map(function(e){return e.text}),wnta:t.wnta.map(function(e){return e.text}),mode:"PromptGenie",llm_model:l}).wta.length)return console.error("WTA conditions cannot be empty."),m(new Error("When to Apply conditions cannot be empty.")),s(!1),[2,null];e.label=1;case 1:return e.trys.push([1,4,5,6]),[4,fetch("".concat(a,"/instant_learning/mode-wta-validation"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})];case 2:if(!(u=e.sent()).ok)throw new Error("API Error: ".concat(u.statusText));return[4,u.json()];case 3:return(c=e.sent()).response.is_valid?(console.log("Prompt Validation Successful!"),d(null)):(console.warn("Prompt Validation failed, conflicts found."),d(c.response)),[2,c.response];case 4:return p=e.sent(),console.error("Failed to validate prompt rules:",p),m(p),[2,null];case 5:return s(!1),[7];case 6:return[2]}})})},clearValidation:function(){d(null)},isSaving:i,validationResponse:c,error:f}};
//# sourceMappingURL=usePromptValidation.js.map
