@e-llm-studio/instant-learning 0.1.1-alpha.41 → 0.1.1-alpha.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),r=require("lucide-react"),a=require("./store/useLearningTemplateStore.js"),s=require("primereact/toast"),i=require("./styles/LearningTemplateManagement.module.css.js"),o=require("./LearningTemplateLayout.js"),l=require("./components/EmptyLearningState.js"),u=require("./store/useAuthStore.js"),c=require("./apis/scopeApis.js"),d=require("./components/ConfirmationModal.js"),p=require("./components/LearningTemplateManagementSkeleton.js"),g=require("./utils/treeUtils.js"),S=require("./components/CreateLearningSetModal.js"),f=require("./store/useEnvStore.js"),m=require("./store/useConfigStore.js"),h=require("./components/ToolTip.js"),y=require("./components/CreateRuleSetLegacyModal.js"),_=require("react-router-dom"),v=[{id:"learnings",label:"Learnings",icon:r.BookOpen,badgeKey:"learningsCount"}],L=[{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},{type:"SCOPE",label:"Scope"}];exports.default=function(r){var b,T=this,C=r.userDetails,E=r.tiers,O=r.llmStudioUrl,w=r.audacyBackendUrl,j=r.ilLabels,A=r.config,N=r.app_integration_id,B=r.backwardCompatibility,I=void 0!==B&&B,R=a.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),P=a.useLearningTemplateStore(function(e){return e.setSelectedRuleSetId}),D=a.useLearningTemplateStore(function(e){return e.error}),q=a.useLearningTemplateStore(function(e){return e.setError}),x=a.useLearningTemplateStore(function(e){return e.setStations}),k=a.useLearningTemplateStore(function(e){return e.scopeTreeData}),G=a.useLearningTemplateStore(function(e){return e.setScopeTreeData}),M=n.useState({isOpen:!1,type:"GLOBAL"}),U=M[0],F=M[1],V=n.useState(!1),H=V[0],K=V[1],W=n.useState(!1),z=W[0],J=W[1],Q=n.useState("learnings"),X=Q[0],Y=Q[1],Z=n.useState(null),$=Z[0],ee=Z[1],te=n.useRef(null),ne=n.useRef(null),re=n.useRef(null),ae=u.default();ae.user;var se=ae.setUser,ie=m.useConfigStore(),oe=ie.setConfig,le=ie.setIlLabels,ue=_.useLocation();n.useEffect(function(){var e=new URLSearchParams(ue.search).get("rulesetid");(null==e?void 0:e.length)&&P&&Y&&(P(e),Y("learnings"))},[null==ue?void 0:ue.search,Y,P]),n.useEffect(function(){console.log("userDetails",C),se(C),console.log("tiers",E),a.useLearningTemplateStore.getState().setTiers(E),console.log("llmStudioUrl",O),console.log("audacyBackendUrl",w),f.default.getState().setLlmStudioUrl(O),f.default.getState().setAudacyBackendUrl(w),oe(A),le(j),a.useLearningTemplateStore.getState().setBackwardCompatibility(I)},[C,se,E,O,w,A,oe,j,le]);var ce=function(t){return void 0===t&&(t=!0),e.__awaiter(T,void 0,void 0,function(){var n,r,s;return e.__generator(this,function(e){switch(e.label){case 0:t&&K(!0),q(null),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,c.fetchScopes(N,C.accessToken)];case 2:return(n=e.sent())&&n.data&&n.data.data&&(r=n.data.data,Array.isArray(r)&&(r=r.length>0?r[0]:null),r?(G({data:r}),ne.current?(P(ne.current),Y("learnings"),ne.current=null):a.useLearningTemplateStore.getState().selectedRuleSetId||P(r.id)):G(null)),[3,5];case 3:return s=e.sent(),console.error("Failed to fetch rule sets",s),q("Failed to load rule sets. Please try again later."),[3,5];case 4:return K(!1),[7];case 5:return[2]}})})};n.useEffect(function(){var e;(null===(e=null==C?void 0:C.accessToken)||void 0===e?void 0:e.length)?ce(!0):console.warn("Error: Trying to fetch rules without access token",C)},[null==C?void 0:C.accessToken,q,x]);var de=function(t){return e.__awaiter(T,void 0,void 0,function(){var n,r,s,i,o,l,u,d,p,g,S,f,m,h,y,_,v,L,b,T;return e.__generator(this,function(E){switch(E.label){case 0:J(!0),n=a.useLearningTemplateStore.getState().backwardCompatibility,E.label=1;case 1:return E.trys.push([1,12,13,14]),r=void 0,n&&"object"==typeof t?r=t:(s=t,i="SCOPE"===U.type&&U.parentId,o=i?"genreRuleSet":U.type,r={topic:o,scope_reference_id:null,scopeDescription:"demo",parentScopeId:U.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:N}),[4,c.createRuleSet(r,C.accessToken)];case 2:if(l=E.sent(),!(u=null===(h=null==l?void 0:l.data)||void 0===h?void 0:h.scopeId))return[3,10];if(ne.current=u,d=n&&(null===(y=r.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),p=!n&&"GLOBAL"!==U.type&&U.parentId,!d&&!p)return[3,10];if(!(g=n?null===(v=null===(_=a.useLearningTemplateStore.getState().scopeTreeData)||void 0===_?void 0:_.data)||void 0===v?void 0:v.id:U.parentId))return[3,10];if(!I)return[3,7];E.label=3;case 3:return E.trys.push([3,5,,6]),[4,c.inheritScopeBackwardCompatible({source_scope_id:g,target_scope_id:u})];case 4:return E.sent(),[3,6];case 5:return S=E.sent(),console.error("Failed to inherit rules for the new scope:",S),[3,6];case 6:return[3,10];case 7:return E.trys.push([7,9,,10]),[4,c.inheritScope({source_scope_id:g,target_scope_id:u,application_mapping_id:N||"",is_copy_parent_variant_id:!1})];case 8:return E.sent(),[3,10];case 9:return f=E.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,10];case 10:return[4,ce(!0)];case 11:return E.sent(),F(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,14];case 12:throw m=E.sent(),console.error("An error occurred during scope creation.",m),null===(L=re.current)||void 0===L||L.show({severity:"error",summary:"Creation Failed",detail:(null===(T=null===(b=null==m?void 0:m.response)||void 0===b?void 0:b.data)||void 0===T?void 0:T.message)||"There was an error creating the scope. Please try again."}),m;case 13:return J(!1),[7];case 14:return[2]}})})},pe=function(t,n,r){return e.__awaiter(T,void 0,void 0,function(){var s,i,o,l,u,d,p,S,f;return e.__generator(this,function(m){switch(m.label){case 0:J(!0),m.label=1;case 1:return m.trys.push([1,8,9,10]),[4,c.deleteRuleSet(t,C.accessToken)];case 2:if(m.sent(),a.useLearningTemplateStore.getState().selectedRuleSetId===t&&(s=a.useLearningTemplateStore.getState().scopeTreeData,(i=g.findNodePathById((null==s?void 0:s.data)||null,t))&&i.length>1&&(o=i[i.length-2],P(o),Y("learnings"))),!r||!n)return[3,6];m.label=3;case 3:return m.trys.push([3,5,,6]),[4,c.updateStation({station_name:n,ruleset_id:""})];case 4:return m.sent(),[3,6];case 5:return l=m.sent(),console.error("Error unlinking station on subscope delete:",l),[3,6];case 6:return[4,ce(!0)];case 7:return m.sent(),F(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),null===(d=re.current)||void 0===d||d.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,10];case 8:return u=m.sent(),console.error("An error occurred during scope deletion.",u),null===(p=re.current)||void 0===p||p.show({severity:"error",summary:"Delete Failed",detail:(null===(f=null===(S=null==u?void 0:u.response)||void 0===S?void 0:S.data)||void 0===f?void 0:f.message)||"There was an error deleting the scope. Please try again."}),[3,10];case 9:return J(!1),[7];case 10:return[2]}})})},ge=k,Se=$?{data:{id:$.stationId,name:$.stationName,type:"STATION",metrics:{learningsCount:$.learningsCount,stationsCount:0},children:[]}}:ge,fe=!!(null==Se?void 0:Se.data),me="GLOBAL"===(null===(b=null==Se?void 0:Se.data)||void 0===b?void 0:b.type),he=$?v.filter(function(e){return"stations"!==e.id}):v;return t.jsx(h.TooltipProvider,{children:t.jsxs("div",e.__assign({className:i.default.learningManagementContainer},{children:[t.jsx("div",e.__assign({className:i.default.mainWrapper},{children:H?t.jsx(p.default,{}):D?t.jsxs("div",e.__assign({className:i.default.errorContainer},{children:[t.jsx("div",e.__assign({className:i.default.errorTitle},{children:"Error Loading Data"})),t.jsx("p",e.__assign({className:i.default.errorDesc},{children:D})),t.jsx("button",e.__assign({onClick:function(){return ce(!0)},className:i.default.tryAgainBtn},{children:"Try Again"}))]})):fe?t.jsx(o.default,{onOpenCreateModal:function(){return F({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return F({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return F({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(t,n,r){return e.__awaiter(T,void 0,void 0,function(){var s,i,o;return e.__generator(this,function(e){switch(e.label){case 0:return s=a.useLearningTemplateStore.getState().scopeTreeData,i=g.findNodePathById((null==s?void 0:s.data)||null,t),o=!!i&&3===i.length,0!==r?[3,2]:[4,pe(t,n,o)];case 1:return e.sent(),[3,3];case 2:F({isOpen:!0,type:"DELETE",scopeId:t,initialName:n,isSubscope:o}),e.label=3;case 3:return[2]}})})},onSectionSelect:function(e,t){console.log("Section Selected:",{scopeId:e,sectionId:t}),Y(t),P(e)},activeSectionId:X,scopeTreeData:Se,sectionsConfig:he,onViewStation:function(e){te.current=R,ee(e),Y("learnings"),P(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(ne.current=t),ce(e)},nodeTypesConfig:L,app_integration_id:N,token:C.accessToken}):t.jsx(l.default,{onCreate:function(){return F({isOpen:!0,type:"GLOBAL"})},title:"No Global Scope has been added!",desc:"Start by creating a Global scope to define base learnings that apply across all stations.",button:"Create Global Scope"})})),t.jsx(s.Toast,{ref:re}),I&&U.isOpen&&"DELETE"!==U.type&&"RENAME"!==U.type?t.jsx(y.default,{isOpen:!0,onClose:function(){return F(e.__assign(e.__assign({},U),{isOpen:!1}))},onSubmit:de,hasGlobalRuleSet:me}):t.jsx(S.default,{isOpen:U.isOpen&&"DELETE"!==U.type,onClose:function(){return F(e.__assign(e.__assign({},U),{isOpen:!1}))},onSubmit:"RENAME"===U.type?function(t){return e.__awaiter(T,void 0,void 0,function(){var n,r,a,s;return e.__generator(this,function(i){switch(i.label){case 0:J(!0),i.label=1;case 1:return i.trys.push([1,4,5,6]),U.scopeId?[4,c.renameScope({scope_id:U.scopeId,scope_name:t})]:[2];case 2:return i.sent(),[4,ce(!0)];case 3:return i.sent(),F(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,6];case 4:throw n=i.sent(),console.error("An error occurred during scope rename.",n),null===(r=re.current)||void 0===r||r.show({severity:"error",summary:"Rename Failed",detail:(null===(s=null===(a=null==n?void 0:n.response)||void 0===a?void 0:a.data)||void 0===s?void 0:s.message)||"There was an error renaming the scope. Please try again."}),n;case 5:return J(!1),[7];case 6:return[2]}})})}:de,isLoading:z,title:"GLOBAL"===U.type?"Create Global Scope":"SCOPE"===U.type?"Add Scope":"SUBSCOPE"===U.type?"Add Subscope":"Rename Scope",description:"GLOBAL"===U.type?"Create the Global scope to define base learnings that apply across all stations.":"SCOPE"===U.type?"This scope will be created under ".concat(U.parentName||"Global"," and will inherit its Learnings by default."):"SUBSCOPE"===U.type?"This subscope will be created under ".concat(U.parentName||"Scope"," and will inherit ").concat(U.parentName||"Scope","'s Learnings and Stations by default."):"",inputLabel:"GLOBAL"===U.type||"SCOPE"===U.type?"Scope Name":"SUBSCOPE"===U.type?"Subscope Name":"Scope Name",submitLabel:"GLOBAL"===U.type?"Create Scope":"SCOPE"===U.type?"Add Scope":"SUBSCOPE"===U.type?"Add Subscope":"Save",placeholder:"GLOBAL"===U.type?"Enter the global scope name":"SCOPE"===U.type?"Enter the scope name":"SUBSCOPE"===U.type?"Enter the subscope name":"Enter the new name",initialValue:"RENAME"===U.type?U.initialName:""}),t.jsx(d.default,{isOpen:U.isOpen&&"DELETE"===U.type,onCancel:function(){return F(e.__assign(e.__assign({},U),{isOpen:!1}))},onConfirm:function(){return pe(U.scopeId,U.initialName,U.isSubscope)},title:"Delete Scope",description:t.jsxs(t.Fragment,{children:["Deleting ",t.jsx("span",e.__assign({className:i.default.highlight},{children:U.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:z})]}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),r=require("lucide-react"),a=require("./store/useLearningTemplateStore.js"),s=require("primereact/toast"),i=require("./styles/LearningTemplateManagement.module.css.js"),o=require("./LearningTemplateLayout.js"),l=require("./components/EmptyLearningState.js"),c=require("./store/useAuthStore.js"),u=require("./apis/scopeApis.js"),d=require("./components/ConfirmationModal.js"),p=require("./components/LearningTemplateManagementSkeleton.js"),g=require("./utils/treeUtils.js"),f=require("./components/CreateLearningSetModal.js"),S=require("./store/useEnvStore.js"),m=require("./store/useConfigStore.js"),h=require("./components/ToolTip.js"),_=require("./components/CreateRuleSetLegacyModal.js"),y=require("react-router-dom"),v=[{id:"learnings",label:"Learnings",icon:r.BookOpen,badgeKey:"learningsCount"}],L=[{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},{type:"SCOPE",label:"Scope"}];exports.default=function(r){var b,T=this,C=r.userDetails,E=r.tiers,O=r.llmStudioUrl,w=r.audacyBackendUrl,j=r.ilLabels,A=r.config,N=r.app_integration_id,B=r.backwardCompatibility,I=void 0!==B&&B,R=a.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),k=a.useLearningTemplateStore(function(e){return e.setSelectedRuleSetId}),P=a.useLearningTemplateStore(function(e){return e.error}),D=a.useLearningTemplateStore(function(e){return e.setError}),q=a.useLearningTemplateStore(function(e){return e.setStations}),x=a.useLearningTemplateStore(function(e){return e.scopeTreeData}),G=a.useLearningTemplateStore(function(e){return e.setScopeTreeData}),M=n.useState({isOpen:!1,type:"GLOBAL"}),U=M[0],F=M[1],V=n.useState(!1),z=V[0],H=V[1],K=n.useState(!1),W=K[0],J=K[1],Q=n.useState("learnings"),X=Q[0],Y=Q[1],Z=n.useState(null),$=Z[0],ee=Z[1],te=n.useRef(null),ne=n.useRef(null),re=n.useRef(null),ae=c.default();ae.user;var se=ae.setUser,ie=m.useConfigStore(),oe=ie.setConfig,le=ie.setIlLabels,ce=y.useLocation();n.useEffect(function(){var e=new URLSearchParams(ce.search).get("rulesetid");(null==e?void 0:e.length)&&k&&Y&&(k(e),Y("learnings"))},[null==ce?void 0:ce.search,Y,k]),n.useEffect(function(){console.log("userDetails",C),se(C),console.log("tiers",E),console.log("llmStudioUrl",O),console.log("audacyBackendUrl",w),S.default.getState().setLlmStudioUrl(O),S.default.getState().setAudacyBackendUrl(w),oe(A),le(j),a.useLearningTemplateStore.getState().setBackwardCompatibility(I)},[C,se,E,O,w,A,oe,j,le]),n.useEffect(function(){if(N&&(null==C?void 0:C.accessToken)&&O){e.__awaiter(T,void 0,void 0,function(){var t,n;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,fetch("".concat(O,"/instant_learning/ilotj/tier/").concat(N),{headers:{Authorization:"Bearer ".concat(C.accessToken)}})];case 1:return[4,e.sent().json()];case 2:return"success"===(t=e.sent()).status&&a.useLearningTemplateStore.getState().setTiers(t.data.map(function(e){return{tier_id:e.id,tier_name:e.name,tier_priority:e.tier_priority}})),[3,4];case 3:return n=e.sent(),console.error("Failed to fetch tiers:",n),[3,4];case 4:return[2]}})})}},[N,null==C?void 0:C.accessToken,O]);var ue=function(t){return void 0===t&&(t=!0),e.__awaiter(T,void 0,void 0,function(){var n,r,s;return e.__generator(this,function(e){switch(e.label){case 0:t&&H(!0),D(null),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,u.fetchScopes(N,C.accessToken)];case 2:return(n=e.sent())&&n.data&&n.data.data&&(r=n.data.data,Array.isArray(r)&&(r=r.length>0?r[0]:null),r?(G({data:r}),ne.current?(k(ne.current),Y("learnings"),ne.current=null):a.useLearningTemplateStore.getState().selectedRuleSetId||k(r.id)):G(null)),[3,5];case 3:return s=e.sent(),console.error("Failed to fetch rule sets",s),D("Failed to load rule sets. Please try again later."),[3,5];case 4:return H(!1),[7];case 5:return[2]}})})};n.useEffect(function(){var e;(null===(e=null==C?void 0:C.accessToken)||void 0===e?void 0:e.length)?ue(!0):console.warn("Error: Trying to fetch rules without access token",C)},[null==C?void 0:C.accessToken,D,q]);var de=function(t){return e.__awaiter(T,void 0,void 0,function(){var n,r,s,i,o,l,c,d,p,g,f,S,m,h,_,y,v,L,b,T;return e.__generator(this,function(E){switch(E.label){case 0:J(!0),n=a.useLearningTemplateStore.getState().backwardCompatibility,E.label=1;case 1:return E.trys.push([1,12,13,14]),r=void 0,n&&"object"==typeof t?r=t:(s=t,i="SCOPE"===U.type&&U.parentId,o=i?"genreRuleSet":U.type,r={topic:o,scope_reference_id:null,scopeDescription:"demo",parentScopeId:U.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:N}),[4,u.createRuleSet(r,C.accessToken)];case 2:if(l=E.sent(),!(c=null===(h=null==l?void 0:l.data)||void 0===h?void 0:h.scopeId))return[3,10];if(ne.current=c,d=n&&(null===(_=r.topic)||void 0===_?void 0:_.toLowerCase().includes("genre")),p=!n&&"GLOBAL"!==U.type&&U.parentId,!d&&!p)return[3,10];if(!(g=n?null===(v=null===(y=a.useLearningTemplateStore.getState().scopeTreeData)||void 0===y?void 0:y.data)||void 0===v?void 0:v.id:U.parentId))return[3,10];if(!I)return[3,7];E.label=3;case 3:return E.trys.push([3,5,,6]),[4,u.inheritScopeBackwardCompatible({source_scope_id:g,target_scope_id:c})];case 4:return E.sent(),[3,6];case 5:return f=E.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,6];case 6:return[3,10];case 7:return E.trys.push([7,9,,10]),[4,u.inheritScope({source_scope_id:g,target_scope_id:c,application_mapping_id:N||"",is_copy_parent_variant_id:!1})];case 8:return E.sent(),[3,10];case 9:return S=E.sent(),console.error("Failed to inherit rules for the new scope:",S),[3,10];case 10:return[4,ue(!0)];case 11:return E.sent(),F(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,14];case 12:throw m=E.sent(),console.error("An error occurred during scope creation.",m),null===(L=re.current)||void 0===L||L.show({severity:"error",summary:"Creation Failed",detail:(null===(T=null===(b=null==m?void 0:m.response)||void 0===b?void 0:b.data)||void 0===T?void 0:T.message)||"There was an error creating the scope. Please try again."}),m;case 13:return J(!1),[7];case 14:return[2]}})})},pe=function(t,n,r){return e.__awaiter(T,void 0,void 0,function(){var s,i,o,l,c,d,p,f,S;return e.__generator(this,function(m){switch(m.label){case 0:J(!0),m.label=1;case 1:return m.trys.push([1,8,9,10]),[4,u.deleteRuleSet(t,C.accessToken)];case 2:if(m.sent(),a.useLearningTemplateStore.getState().selectedRuleSetId===t&&(s=a.useLearningTemplateStore.getState().scopeTreeData,(i=g.findNodePathById((null==s?void 0:s.data)||null,t))&&i.length>1&&(o=i[i.length-2],k(o),Y("learnings"))),!r||!n)return[3,6];m.label=3;case 3:return m.trys.push([3,5,,6]),[4,u.updateStation({station_name:n,ruleset_id:""})];case 4:return m.sent(),[3,6];case 5:return l=m.sent(),console.error("Error unlinking station on subscope delete:",l),[3,6];case 6:return[4,ue(!0)];case 7:return m.sent(),F(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),null===(d=re.current)||void 0===d||d.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,10];case 8:return c=m.sent(),console.error("An error occurred during scope deletion.",c),null===(p=re.current)||void 0===p||p.show({severity:"error",summary:"Delete Failed",detail:(null===(S=null===(f=null==c?void 0:c.response)||void 0===f?void 0:f.data)||void 0===S?void 0:S.message)||"There was an error deleting the scope. Please try again."}),[3,10];case 9:return J(!1),[7];case 10:return[2]}})})},ge=x,fe=$?{data:{id:$.stationId,name:$.stationName,type:"STATION",metrics:{learningsCount:$.learningsCount,stationsCount:0},children:[]}}:ge,Se=!!(null==fe?void 0:fe.data),me="GLOBAL"===(null===(b=null==fe?void 0:fe.data)||void 0===b?void 0:b.type),he=$?v.filter(function(e){return"stations"!==e.id}):v;return t.jsx(h.TooltipProvider,{children:t.jsxs("div",e.__assign({className:i.default.learningManagementContainer},{children:[t.jsx("div",e.__assign({className:i.default.mainWrapper},{children:z?t.jsx(p.default,{}):P?t.jsxs("div",e.__assign({className:i.default.errorContainer},{children:[t.jsx("div",e.__assign({className:i.default.errorTitle},{children:"Error Loading Data"})),t.jsx("p",e.__assign({className:i.default.errorDesc},{children:P})),t.jsx("button",e.__assign({onClick:function(){return ue(!0)},className:i.default.tryAgainBtn},{children:"Try Again"}))]})):Se?t.jsx(o.default,{onOpenCreateModal:function(){return F({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return F({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return F({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(t,n,r){return e.__awaiter(T,void 0,void 0,function(){var s,i,o;return e.__generator(this,function(e){switch(e.label){case 0:return s=a.useLearningTemplateStore.getState().scopeTreeData,i=g.findNodePathById((null==s?void 0:s.data)||null,t),o=!!i&&3===i.length,0!==r?[3,2]:[4,pe(t,n,o)];case 1:return e.sent(),[3,3];case 2:F({isOpen:!0,type:"DELETE",scopeId:t,initialName:n,isSubscope:o}),e.label=3;case 3:return[2]}})})},onSectionSelect:function(e,t){console.log("Section Selected:",{scopeId:e,sectionId:t}),Y(t),k(e)},activeSectionId:X,scopeTreeData:fe,sectionsConfig:he,onViewStation:function(e){te.current=R,ee(e),Y("learnings"),k(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(ne.current=t),ue(e)},nodeTypesConfig:L,app_integration_id:N,token:C.accessToken}):t.jsx(l.default,{onCreate:function(){return F({isOpen:!0,type:"GLOBAL"})},title:"No Global Scope has been added!",desc:"Start by creating a Global scope to define base learnings that apply across all stations.",button:"Create Global Scope"})})),t.jsx(s.Toast,{ref:re}),I&&U.isOpen&&"DELETE"!==U.type&&"RENAME"!==U.type?t.jsx(_.default,{isOpen:!0,onClose:function(){return F(e.__assign(e.__assign({},U),{isOpen:!1}))},onSubmit:de,hasGlobalRuleSet:me}):t.jsx(f.default,{isOpen:U.isOpen&&"DELETE"!==U.type,onClose:function(){return F(e.__assign(e.__assign({},U),{isOpen:!1}))},onSubmit:"RENAME"===U.type?function(t){return e.__awaiter(T,void 0,void 0,function(){var n,r,a,s;return e.__generator(this,function(i){switch(i.label){case 0:J(!0),i.label=1;case 1:return i.trys.push([1,4,5,6]),U.scopeId?[4,u.renameScope({scope_id:U.scopeId,scope_name:t})]:[2];case 2:return i.sent(),[4,ue(!0)];case 3:return i.sent(),F(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,6];case 4:throw n=i.sent(),console.error("An error occurred during scope rename.",n),null===(r=re.current)||void 0===r||r.show({severity:"error",summary:"Rename Failed",detail:(null===(s=null===(a=null==n?void 0:n.response)||void 0===a?void 0:a.data)||void 0===s?void 0:s.message)||"There was an error renaming the scope. Please try again."}),n;case 5:return J(!1),[7];case 6:return[2]}})})}:de,isLoading:W,title:"GLOBAL"===U.type?"Create Global Scope":"SCOPE"===U.type?"Add Scope":"SUBSCOPE"===U.type?"Add Subscope":"Rename Scope",description:"GLOBAL"===U.type?"Create the Global scope to define base learnings that apply across all stations.":"SCOPE"===U.type?"This scope will be created under ".concat(U.parentName||"Global"," and will inherit its Learnings by default."):"SUBSCOPE"===U.type?"This subscope will be created under ".concat(U.parentName||"Scope"," and will inherit ").concat(U.parentName||"Scope","'s Learnings and Stations by default."):"",inputLabel:"GLOBAL"===U.type||"SCOPE"===U.type?"Scope Name":"SUBSCOPE"===U.type?"Subscope Name":"Scope Name",submitLabel:"GLOBAL"===U.type?"Create Scope":"SCOPE"===U.type?"Add Scope":"SUBSCOPE"===U.type?"Add Subscope":"Save",placeholder:"GLOBAL"===U.type?"Enter the global scope name":"SCOPE"===U.type?"Enter the scope name":"SUBSCOPE"===U.type?"Enter the subscope name":"Enter the new name",initialValue:"RENAME"===U.type?U.initialName:""}),t.jsx(d.default,{isOpen:U.isOpen&&"DELETE"===U.type,onCancel:function(){return F(e.__assign(e.__assign({},U),{isOpen:!1}))},onConfirm:function(){return pe(U.scopeId,U.initialName,U.isSubscope)},title:"Delete Scope",description:t.jsxs(t.Fragment,{children:["Deleting ",t.jsx("span",e.__assign({className:i.default.highlight},{children:U.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:W})]}))})};
2
2
  //# sourceMappingURL=LearningManagement.js.map