"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),r=require("react"),n=require("@mui/material"),a=require("@mui/icons-material/Close"),i=require("../../LearningManagement/store/useLearningTemplateStore.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=o(a),u=function(){var a=r.useState(!0),i=a[0],o=a[1];return t.jsxs(n.Dialog,e.__assign({open:i,onClose:function(){return o(!1)},fullWidth:!0,maxWidth:"lg",PaperProps:{sx:{borderRadius:"16px",minHeight:"70vh",overflow:"hidden"}}},{children:[t.jsxs(n.DialogTitle,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e0e0e0",px:3,py:2}},{children:[t.jsx(n.Typography,e.__assign({variant:"h6",fontWeight:600},{children:"Teach Me"})),t.jsx(n.IconButton,e.__assign({onClick:function(){return o(!1)}},{children:t.jsx(s.default,{})}))]})),t.jsx(n.DialogContent,e.__assign({dividers:!0,sx:{p:3,backgroundColor:"#fafafa"}},{children:"There is some issue with the selected template. Kindly check steps to resolve."}))]}))};exports.default=function(a){var o=a.templateRegistry,s=void 0===o?{}:o,l=i.useLearningTemplateStore(function(e){return e.backwardCompatibility}),c=i.useLearningTemplateStore(function(e){return a.app_integration_id?e.templateMap[a.app_integration_id]:void 0}),p=i.useLearningTemplateStore(function(e){return e.setTemplateData}),d=l?"Radio Traffic Learning":c,_=r.useState(!d),f=_[0],g=_[1],h=r.useState(!1),v=h[0],m=h[1];if(r.useEffect(function(){if(a.isOpen){if(!l&&!a.app_integration_id)return console.error("TeachMeWrapper requires an app_integration_id when backward compatibility is disabled."),m(!0),void g(!1);if(d)g(!1);else{e.__awaiter(void 0,void 0,void 0,function(){var t,r;return e.__generator(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,3,4]),g(!0),m(!1),[4,(i=a.app_integration_id,o=a.token,e.__awaiter(void 0,void 0,void 0,function(){var t,r;return e.__generator(this,function(e){switch(e.label){case 0:return[4,fetch("".concat("https://devllmstudio.creativeworkspace.ai","/instant_learning/ilotj/application/getValueType/").concat(i),{headers:{Authorization:"Bearer ".concat(o)}})];case 1:if(!(t=e.sent()).ok)throw new Error("Failed to fetch value type");return[4,t.json()];case 2:return r=e.sent(),console.log("Fetched value type data:",r),!r||Array.isArray(r.data)&&0===r.data.length?[2,null]:[2,r.data[0].value_type_name||r.valueTypeName||r.templateName]}})}))];case 1:return t=n.sent(),p(a.app_integration_id,t),[3,4];case 2:return r=n.sent(),console.error(r),m(!0),a.app_integration_id&&p(a.app_integration_id,"ERROR"),[3,4];case 3:return g(!1),[7];case 4:return[2]}var i,o})})}}},[a.isOpen,a.app_integration_id,d,a.token,p,l]),f)return t.jsx(n.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t.jsx(n.CircularProgress,{size:32})}));if(v||!d)return t.jsx(u,{});var x=s[d&&s[d]?d:"Default"];return x?t.jsx(x,e.__assign({},a)):(console.warn("No renderer found for template: ".concat(d)),t.jsx(u,{}))};
//# sourceMappingURL=TeachMeWrapper.js.map
