@e-llm-studio/instant-learning 0.1.1-alpha.67 → 0.1.1-alpha.69

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"),s=require("./store/useLearningTemplateStore.js"),a=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("./hooks/useLearningTemplateQueryParams.js"),p=require("./components/ConfirmationModal.js"),f=require("./components/LearningTemplateManagementSkeleton.js"),g=require("./utils/treeUtils.js"),m=require("./store/useEnvStore.js"),S=require("./store/useConfigStore.js"),v=require("./components/ToolTip.js"),h=require("./components/CreateRuleSetLegacyModal.js"),_=require("./store/usePermissionsStore.js"),y=require("./store/useAppSecRolesStore.js"),T=require("./queries/useApprovalQueries.js"),b=require("./RuleContent/AddScopeModal.js"),C=require("react-router-dom"),L=require("./shared/SuccessToastContent.js"),j=require("./shared/ErrorToastContent.js"),E=require("./RuleContent/RenameScopeModal.js"),R=[{id:"learnings",label:"Learnings",icon:r.BookOpen,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:r.Users}],A=[{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},{type:"SCOPE",label:"Scope",addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"},{type:"SUBSCOPE",label:"Subscope"}],w=new Set(R.map(function(e){return e.id}));exports.default=function(r){var O,I=this,q=r.userDetails,N=r.llmStudioUrl,P=r.audacyBackendUrl,k=r.ilLabels,x=r.config,D=r.rbacConfig,U=r.app_integration_id,M=r.backwardCompatibility,B=void 0!==M&&M,G=s.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),F=s.useLearningTemplateStore(function(e){return e.setSelectedRuleSetId}),Q=s.useLearningTemplateStore(function(e){return e.error}),Y=s.useLearningTemplateStore(function(e){return e.setError}),K=s.useLearningTemplateStore(function(e){return e.setStations}),H=s.useLearningTemplateStore(function(e){return e.scopeTreeData}),V=s.useLearningTemplateStore(function(e){return e.setScopeTreeData}),W=n.useState({isOpen:!1,type:"GLOBAL"}),z=W[0],J=W[1],X=n.useState(!1),Z=X[0],$=X[1],ee=n.useState(!1),te=ee[0],ne=ee[1],re=n.useState("learnings"),se=re[0],ae=re[1],ie=n.useState(null),oe=ie[0],le=ie[1],ue=n.useState(null),ce=ue[0],de=ue[1],pe=n.useRef(null),fe=n.useRef(null),ge=n.useRef(null),me=u.default();me.user;var Se=me.setUser,ve=S.useConfigStore(),he=ve.setConfig,_e=ve.setIlLabels,ye=function(){try{return C.useLocation()}catch(e){return{search:""}}}();n.useEffect(function(){var e=new URLSearchParams(window.location.search),t=e.get(d.QUERY_PARAM_KEYS.RULESET_ID),n=e.get(d.QUERY_PARAM_KEYS.SECTION),r=n&&w.has(n)?n:"learnings";(null==t?void 0:t.length)&&F&&ae&&(F(t),ae(r))},[null==ye?void 0:ye.search,ae,F]);var Te=_.usePermissionsStore(function(e){return e.fetchPermissions}),be=_.usePermissionsStore(function(e){return e.hasPermission}),Ce=y.useAppSecRolesStore(function(e){return e.setRoles}),Le=m.default(function(e){return e.appsecRbacUrl})===D.appsecRbacUrl,je=T.useGetAppSecRolesQuery(D.applicationId,Le).data;n.useEffect(function(){je&&Ce(je.map(function(e){return{_id:e._id,name:e.name}}))},[je,Ce]),n.useEffect(function(){var e;console.log("userDetails",q),Se(q),console.log("llmStudioUrl",N),console.log("audacyBackendUrl",P),m.default.getState().setLlmStudioUrl(N),m.default.getState().setAudacyBackendUrl(P),m.default.getState().setRbacConfig(D),he(x),_e(k),s.useLearningTemplateStore.getState().setAppIntegrationId(null!=U?U:null),s.useLearningTemplateStore.getState().setBackwardCompatibility(B),s.useLearningTemplateStore.getState().setToken(null!==(e=q.accessToken)&&void 0!==e?e:null)},[q,Se,N,P,D,x,he,k,_e,U,B]),n.useEffect(function(){(null==q?void 0:q.accessToken)&&N&&c.fetchTiers()},[U,null==q?void 0:q.accessToken,N]);var Ee=function(t){return void 0===t&&(t=!0),e.__awaiter(I,void 0,void 0,function(){var n,r,a,i,o,l;return e.__generator(this,function(u){switch(u.label){case 0:t&&$(!0),Y(null),u.label=1;case 1:return u.trys.push([1,4,5,6]),[4,Te(D.applicationId)];case 2:return u.sent(),n=function(t){if(!_.usePermissionsStore.getState().hasPermission("ilotj.scope.view",t.id))return null;var r=t.children?t.children.map(function(e){return n(e)}).filter(function(e){return null!==e}):[];return e.__assign(e.__assign({},t),{children:r})},[4,c.fetchScopes(U,q.accessToken)];case 3:return(r=u.sent())&&r.data&&r.data.data&&(a=r.data.data,Array.isArray(a)&&(a=a.length>0?a[0]:null),a?(i=n(a))?(le(null),V({data:i}),fe.current?(F(fe.current),ae("learnings"),fe.current=null):s.useLearningTemplateStore.getState().selectedRuleSetId||F(i.id)):(le(null!==(l=a.id)&&void 0!==l?l:null),V(null)):(le(null),V(null))),[3,6];case 4:return o=u.sent(),console.error("Failed to fetch rule sets or permissions",o),Y("Failed to load data. Please try again later."),[3,6];case 5:return $(!1),[7];case 6:return[2]}})})};n.useEffect(function(){var e;(null===(e=null==q?void 0:q.accessToken)||void 0===e?void 0:e.length)&&Le?Ee(!0):console.warn("Error: Trying to fetch rules without access token",q)},[null==q?void 0:q.accessToken,Y,K,D.applicationId,Le]);var Re=function(t){return e.__awaiter(I,void 0,void 0,function(){var n,r,s,a;return e.__generator(this,function(i){switch(i.label){case 0:ne(!0),i.label=1;case 1:return i.trys.push([1,4,5,6]),z.scopeId?[4,c.renameScope({scope_id:z.scopeId,scope_name:t})]:[2];case 2:return i.sent(),[4,Ee(!0)];case 3:return i.sent(),J(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=ge.current)||void 0===r||r.show({severity:"error",summary:"Rename Failed",detail:(null===(a=null===(s=null==n?void 0:n.response)||void 0===s?void 0:s.data)||void 0===a?void 0:a.message)||"There was an error renaming the scope. Please try again."}),n;case 5:return ne(!1),[7];case 6:return[2]}})})},Ae=function(t,n,r){return e.__awaiter(I,void 0,void 0,function(){var a,i,o,l,u,d,p,f,m;return e.__generator(this,function(S){switch(S.label){case 0:ne(!0),S.label=1;case 1:return S.trys.push([1,8,9,10]),[4,c.deleteRuleSet(t,q.accessToken)];case 2:if(S.sent(),s.useLearningTemplateStore.getState().selectedRuleSetId===t&&(a=s.useLearningTemplateStore.getState().scopeTreeData,(i=g.findNodePathById((null==a?void 0:a.data)||null,t))&&i.length>1&&(o=i[i.length-2],F(o),ae("learnings"))),!r||!n)return[3,6];S.label=3;case 3:return S.trys.push([3,5,,6]),[4,c.updateStation({station_name:n,ruleset_id:""})];case 4:return S.sent(),[3,6];case 5:return l=S.sent(),console.error("Error unlinking station on subscope delete:",l),[3,6];case 6:return[4,Ee(!0)];case 7:return S.sent(),J(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),null===(d=ge.current)||void 0===d||d.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,10];case 8:return u=S.sent(),console.error("An error occurred during scope deletion.",u),null===(p=ge.current)||void 0===p||p.show({severity:"error",summary:"Delete Failed",detail:(null===(m=null===(f=null==u?void 0:u.response)||void 0===f?void 0:f.data)||void 0===m?void 0:m.message)||"There was an error deleting the scope. Please try again."}),[3,10];case 9:return ne(!1),[7];case 10:return[2]}})})},we=H,Oe=ce?{data:{id:ce.stationId,name:ce.stationName,type:"STATION",metrics:{learningsCount:ce.learningsCount,stationsCount:0},children:[]}}:we,Ie=!!(null==Oe?void 0:Oe.data);null===(O=null==Oe?void 0:Oe.data)||void 0===O||O.type;var qe=_.usePermissionsStore(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",D.applicationResourceId||""),Ne=(ce?R.filter(function(e){return"stations"!==e.id}):R).filter(function(e){return!(!B&&"access"===e.id)});return t.jsx(v.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(f.default,{}):Q?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:Q})),t.jsx("button",e.__assign({onClick:function(){return Ee(!0)},className:i.default.tryAgainBtn},{children:"Try Again"}))]})):Ie?t.jsx(o.default,{onOpenCreateModal:function(){return J({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return J({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return J({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(t,n,r){return e.__awaiter(I,void 0,void 0,function(){var a,i,o;return e.__generator(this,function(e){switch(e.label){case 0:return a=s.useLearningTemplateStore.getState().scopeTreeData,i=g.findNodePathById((null==a?void 0:a.data)||null,t),o=!!i&&3===i.length,0!==r?[3,2]:[4,Ae(t,n,o)];case 1:return e.sent(),[3,3];case 2:J({isOpen:!0,type:"DELETE",scopeId:t,initialName:n,isSubscope:o}),e.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return be("ilotj.scope.delete",e)},canEditScope:function(e){return be("ilotj.scope.edit",e)},canCreateScope:function(e){return be("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),d.setQueryParams(((n={})[d.QUERY_PARAM_KEYS.SECTION]="learnings"===t?null:t,n)),ae(t),F(e)},activeSectionId:se,scopeTreeData:Oe,sectionsConfig:Ne,onViewStation:function(e){pe.current=G,de(e),ae("learnings"),F(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(fe.current=t),Ee(e)},nodeTypesConfig:A,app_integration_id:U,token:q.accessToken}):t.jsx(l.default,{onCreate:function(){return J({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",canCreateRule:qe,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return e.__awaiter(I,void 0,void 0,function(){var n,r,a,o,l,u,d,p,f;return e.__generator(this,function(e){switch(e.label){case 0:if(!(n=(null===(o=null===(a=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===a?void 0:a.data)||void 0===o?void 0:o.id)||oe))return null===(l=ge.current)||void 0===l||l.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:"Unable to identify the global scope for this access request."})}),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.requestAccess(n)];case 2:return e.sent(),null===(u=ge.current)||void 0===u||u.show({severity:"success",sticky:!1,life:3e3,className:i.default.successToast,content:t.jsx(L.default,{message:"Access request submitted successfully!"})}),[3,4];case 3:return r=e.sent(),null===(d=ge.current)||void 0===d||d.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:(null===(f=null===(p=null==r?void 0:r.response)||void 0===p?void 0:p.data)||void 0===f?void 0:f.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),t.jsx(a.Toast,{ref:ge}),B&&z.isOpen&&"DELETE"!==z.type&&"RENAME"!==z.type?t.jsx(h.default,{isOpen:!0,onClose:function(){return J(e.__assign(e.__assign({},z),{isOpen:!1}))},onSubmit:function(t){return e.__awaiter(I,void 0,void 0,function(){var n,r,a,i,o,l,u,d,p,f,g,m,S,v,h,_,y,T,b,C;return e.__generator(this,function(L){switch(L.label){case 0:ne(!0),n=s.useLearningTemplateStore.getState().backwardCompatibility,L.label=1;case 1:return L.trys.push([1,12,13,14]),r=void 0,n&&"object"==typeof t?r=t:(a=t,i="SCOPE"===z.type&&z.parentId,o=i?"genreRuleSet":z.type,r={topic:o,scope_reference_id:null,scopeDescription:"demo",parentScopeId:z.parentId||null,scopeName:a,scopeReferenceMetadata:{},applicationMappingId:U}),[4,c.createRuleSet(r,q.accessToken)];case 2:if(l=L.sent(),!(u=null===(v=null==l?void 0:l.data)||void 0===v?void 0:v.scopeId))return[3,10];if(fe.current=u,d=n&&(null===(h=r.topic)||void 0===h?void 0:h.toLowerCase().includes("genre")),p=!n&&"GLOBAL"!==z.type&&z.parentId,!d&&!p)return[3,10];if(!(f=n?null===(y=null===(_=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===_?void 0:_.data)||void 0===y?void 0:y.id:z.parentId))return[3,10];if(!B)return[3,7];L.label=3;case 3:return L.trys.push([3,5,,6]),[4,c.inheritScopeBackwardCompatible({source_scope_id:f,target_scope_id:u})];case 4:return L.sent(),[3,6];case 5:return g=L.sent(),console.error("Failed to inherit rules for the new scope:",g),[3,6];case 6:return[3,10];case 7:return L.trys.push([7,9,,10]),[4,c.inheritScope({source_scope_id:f,target_scope_id:u,application_mapping_id:U||"",is_copy_parent_variant_id:!1})];case 8:return L.sent(),[3,10];case 9:return m=L.sent(),console.error("Failed to inherit rules for the new scope:",m),[3,10];case 10:return[4,Ee(!0)];case 11:return L.sent(),J(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,14];case 12:throw S=L.sent(),console.error("An error occurred during scope creation.",S),null===(T=ge.current)||void 0===T||T.show({severity:"error",summary:"Creation Failed",detail:(null===(C=null===(b=null==S?void 0:S.response)||void 0===b?void 0:b.data)||void 0===C?void 0:C.message)||"There was an error creating the scope. Please try again."}),S;case 13:return ne(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ie,canCreateGlobal:qe}):t.jsxs(t.Fragment,{children:[t.jsx(b.default,{isOpen:z.isOpen&&"DELETE"!==z.type&&"RENAME"!==z.type,onClose:function(){return J(e.__assign(e.__assign({},z),{isOpen:!1}))},onCreate:function(e){return Re(null!=e?e:"")},hasGlobalRuleSet:Ie}),t.jsx(E.default,{isOpen:z.isOpen&&"RENAME"===z.type,onClose:function(){return J(e.__assign(e.__assign({},z),{isOpen:!1}))},onSave:Re,initialName:z.initialName})]}),t.jsx(p.default,{isOpen:z.isOpen&&"DELETE"===z.type,onCancel:function(){return J(e.__assign(e.__assign({},z),{isOpen:!1}))},onConfirm:function(){return Ae(z.scopeId,z.initialName,z.isSubscope)},title:"Delete Scope",description:t.jsxs(t.Fragment,{children:["Deleting ",t.jsx("span",e.__assign({className:i.default.highlight},{children:z.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:te})]}))})};
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"),s=require("./store/useLearningTemplateStore.js"),a=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("./hooks/useLearningTemplateQueryParams.js"),p=require("./components/ConfirmationModal.js"),f=require("./components/LearningTemplateManagementSkeleton.js"),g=require("./utils/treeUtils.js"),S=require("./store/useEnvStore.js"),m=require("./store/useConfigStore.js"),v=require("./components/ToolTip.js"),h=require("./components/CreateRuleSetLegacyModal.js"),_=require("./store/usePermissionsStore.js"),y=require("./store/useAppSecRolesStore.js"),T=require("./queries/useApprovalQueries.js"),b=require("./RuleContent/AddScopeModal.js"),C=require("react-router-dom"),L=require("./shared/SuccessToastContent.js"),j=require("./shared/ErrorToastContent.js"),E=require("./RuleContent/RenameScopeModal.js"),A=[{id:"learnings",label:"Learnings",icon:r.BookOpen,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:r.Users}],R=[{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},{type:"SCOPE",label:"Scope",addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"},{type:"SUBSCOPE",label:"Subscope"}],w=new Set(A.map(function(e){return e.id}));exports.default=function(r){var O,I=this,q=r.userDetails,N=r.llmStudioUrl,P=r.audacyBackendUrl,k=r.ilLabels,x=r.config,D=r.rbacConfig,U=r.app_integration_id,M=r.backwardCompatibility,B=void 0!==M&&M,G=s.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),F=s.useLearningTemplateStore(function(e){return e.setSelectedRuleSetId}),Q=s.useLearningTemplateStore(function(e){return e.error}),Y=s.useLearningTemplateStore(function(e){return e.setError}),K=s.useLearningTemplateStore(function(e){return e.setStations}),H=s.useLearningTemplateStore(function(e){return e.scopeTreeData}),V=s.useLearningTemplateStore(function(e){return e.setScopeTreeData}),W=n.useState({isOpen:!1,type:"GLOBAL"}),z=W[0],J=W[1],X=n.useState(!1),Z=X[0],$=X[1],ee=n.useState(!1),te=ee[0],ne=ee[1],re=n.useState("learnings"),se=re[0],ae=re[1],ie=n.useState(null),oe=ie[0],le=ie[1],ue=n.useState(null),ce=ue[0],de=ue[1],pe=n.useRef(null),fe=n.useRef(null),ge=n.useRef(null),Se=u.default();Se.user;var me=Se.setUser,ve=m.useConfigStore(),he=ve.setConfig,_e=ve.setIlLabels,ye=function(){try{return C.useLocation()}catch(e){return{search:""}}}();n.useEffect(function(){var e=new URLSearchParams(window.location.search),t=e.get(d.QUERY_PARAM_KEYS.RULESET_ID),n=e.get(d.QUERY_PARAM_KEYS.SECTION),r=n&&w.has(n)?n:"learnings";(null==t?void 0:t.length)&&F&&ae&&(F(t),ae(r))},[null==ye?void 0:ye.search,ae,F]);var Te=_.usePermissionsStore(function(e){return e.fetchPermissions}),be=_.usePermissionsStore(function(e){return e.hasPermission}),Ce=y.useAppSecRolesStore(function(e){return e.setRoles}),Le=S.default(function(e){return e.appsecRbacUrl})===D.appsecRbacUrl,je=T.useGetAppSecRolesQuery(D.applicationId,Le).data;n.useEffect(function(){je&&Ce(je.map(function(e){return{_id:e._id,name:e.name}}))},[je,Ce]),n.useEffect(function(){var e;console.log("userDetails",q),me(q),console.log("llmStudioUrl",N),console.log("audacyBackendUrl",P),S.default.getState().setLlmStudioUrl(N),S.default.getState().setAudacyBackendUrl(P),S.default.getState().setRbacConfig(D),he(x),_e(k),s.useLearningTemplateStore.getState().setAppIntegrationId(null!=U?U:null),s.useLearningTemplateStore.getState().setBackwardCompatibility(B),s.useLearningTemplateStore.getState().setToken(null!==(e=q.accessToken)&&void 0!==e?e:null)},[q,me,N,P,D,x,he,k,_e,U,B]),n.useEffect(function(){(null==q?void 0:q.accessToken)&&N&&c.fetchTiers()},[U,null==q?void 0:q.accessToken,N]);var Ee=function(t){return void 0===t&&(t=!0),e.__awaiter(I,void 0,void 0,function(){var n,r,a,i,o,l;return e.__generator(this,function(u){switch(u.label){case 0:t&&$(!0),Y(null),u.label=1;case 1:return u.trys.push([1,4,5,6]),[4,Te(D.applicationId)];case 2:return u.sent(),n=function(t){if(!_.usePermissionsStore.getState().hasPermission("ilotj.scope.view",t.id))return null;var r=t.children?t.children.map(function(e){return n(e)}).filter(function(e){return null!==e}):[];return e.__assign(e.__assign({},t),{children:r})},[4,c.fetchScopes(U,q.accessToken)];case 3:return(r=u.sent())&&r.data&&r.data.data&&(a=r.data.data,Array.isArray(a)&&(a=a.length>0?a[0]:null),a?(i=n(a))?(le(null),V({data:i}),fe.current?(F(fe.current),ae("learnings"),fe.current=null):s.useLearningTemplateStore.getState().selectedRuleSetId||F(i.id)):(le(null!==(l=a.id)&&void 0!==l?l:null),V(null)):(le(null),V(null))),[3,6];case 4:return o=u.sent(),console.error("Failed to fetch rule sets or permissions",o),Y("Failed to load data. Please try again later."),[3,6];case 5:return $(!1),[7];case 6:return[2]}})})};n.useEffect(function(){var e;(null===(e=null==q?void 0:q.accessToken)||void 0===e?void 0:e.length)&&Le?Ee(!0):console.warn("Error: Trying to fetch rules without access token",q)},[null==q?void 0:q.accessToken,Y,K,D.applicationId,Le]);var Ae=function(n){return e.__awaiter(I,void 0,void 0,function(){var r,s,a,o;return e.__generator(this,function(l){switch(l.label){case 0:ne(!0),l.label=1;case 1:return l.trys.push([1,4,5,6]),z.scopeId?[4,c.renameScope({scope_id:z.scopeId,scope_name:n})]:[2];case 2:return l.sent(),[4,Ee(!0)];case 3:return l.sent(),J(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,6];case 4:throw r=l.sent(),console.error("An error occurred during scope rename.",r),null===(s=ge.current)||void 0===s||s.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:(null===(o=null===(a=null==r?void 0:r.response)||void 0===a?void 0:a.data)||void 0===o?void 0:o.message)||"There was an error renaming the scope. Please try again."})}),r;case 5:return ne(!1),[7];case 6:return[2]}})})},Re=function(t,n,r){return e.__awaiter(I,void 0,void 0,function(){var a,i,o,l,u,d,p,f,S;return e.__generator(this,function(m){switch(m.label){case 0:ne(!0),m.label=1;case 1:return m.trys.push([1,8,9,10]),[4,c.deleteRuleSet(t,q.accessToken)];case 2:if(m.sent(),s.useLearningTemplateStore.getState().selectedRuleSetId===t&&(a=s.useLearningTemplateStore.getState().scopeTreeData,(i=g.findNodePathById((null==a?void 0:a.data)||null,t))&&i.length>1&&(o=i[i.length-2],F(o),ae("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,Ee(!0)];case 7:return m.sent(),J(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),null===(d=ge.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=ge.current)||void 0===p||p.show({severity:"error",summary:"Delete Failed",detail:(null===(S=null===(f=null==u?void 0:u.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 ne(!1),[7];case 10:return[2]}})})},we=H,Oe=ce?{data:{id:ce.stationId,name:ce.stationName,type:"STATION",metrics:{learningsCount:ce.learningsCount,stationsCount:0},children:[]}}:we,Ie=!!(null==Oe?void 0:Oe.data);null===(O=null==Oe?void 0:Oe.data)||void 0===O||O.type;var qe=_.usePermissionsStore(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",D.applicationResourceId||""),Ne=(ce?A.filter(function(e){return"stations"!==e.id}):A).filter(function(e){return!(!B&&"access"===e.id)});return t.jsx(v.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(f.default,{}):Q?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:Q})),t.jsx("button",e.__assign({onClick:function(){return Ee(!0)},className:i.default.tryAgainBtn},{children:"Try Again"}))]})):Ie?t.jsx(o.default,{onOpenCreateModal:function(){return J({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return J({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return J({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(t,n,r){return e.__awaiter(I,void 0,void 0,function(){var a,i,o;return e.__generator(this,function(e){switch(e.label){case 0:return a=s.useLearningTemplateStore.getState().scopeTreeData,i=g.findNodePathById((null==a?void 0:a.data)||null,t),o=!!i&&3===i.length,0!==r?[3,2]:[4,Re(t,n,o)];case 1:return e.sent(),[3,3];case 2:J({isOpen:!0,type:"DELETE",scopeId:t,initialName:n,isSubscope:o}),e.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return be("ilotj.scope.delete",e)},canEditScope:function(e){return be("ilotj.scope.edit",e)},canCreateScope:function(e){return be("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),d.setQueryParams(((n={})[d.QUERY_PARAM_KEYS.SECTION]="learnings"===t?null:t,n)),ae(t),F(e)},activeSectionId:se,scopeTreeData:Oe,sectionsConfig:Ne,onViewStation:function(e){pe.current=G,de(e),ae("learnings"),F(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(fe.current=t),Ee(e)},nodeTypesConfig:R,app_integration_id:U,token:q.accessToken}):t.jsx(l.default,{onCreate:function(){return J({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",canCreateRule:qe,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return e.__awaiter(I,void 0,void 0,function(){var n,r,a,o,l,u,d,p,f;return e.__generator(this,function(e){switch(e.label){case 0:if(!(n=(null===(o=null===(a=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===a?void 0:a.data)||void 0===o?void 0:o.id)||oe))return null===(l=ge.current)||void 0===l||l.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:"Unable to identify the global scope for this access request."})}),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.requestAccess(n)];case 2:return e.sent(),null===(u=ge.current)||void 0===u||u.show({severity:"success",sticky:!1,life:3e3,className:i.default.successToast,content:t.jsx(L.default,{message:"Access request submitted successfully!"})}),[3,4];case 3:return r=e.sent(),null===(d=ge.current)||void 0===d||d.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:(null===(f=null===(p=null==r?void 0:r.response)||void 0===p?void 0:p.data)||void 0===f?void 0:f.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),t.jsx(a.Toast,{ref:ge}),B&&z.isOpen&&"DELETE"!==z.type&&"RENAME"!==z.type?t.jsx(h.default,{isOpen:!0,onClose:function(){return J(e.__assign(e.__assign({},z),{isOpen:!1}))},onSubmit:function(t){return e.__awaiter(I,void 0,void 0,function(){var n,r,a,i,o,l,u,d,p,f,g,S,m,v,h,_,y,T,b,C;return e.__generator(this,function(L){switch(L.label){case 0:ne(!0),n=s.useLearningTemplateStore.getState().backwardCompatibility,L.label=1;case 1:return L.trys.push([1,12,13,14]),r=void 0,n&&"object"==typeof t?r=t:(a=t,i="SCOPE"===z.type&&z.parentId,o=i?"genreRuleSet":z.type,r={topic:o,scope_reference_id:null,scopeDescription:"demo",parentScopeId:z.parentId||null,scopeName:a,scopeReferenceMetadata:{},applicationMappingId:U}),[4,c.createRuleSet(r,q.accessToken)];case 2:if(l=L.sent(),!(u=null===(v=null==l?void 0:l.data)||void 0===v?void 0:v.scopeId))return[3,10];if(fe.current=u,d=n&&(null===(h=r.topic)||void 0===h?void 0:h.toLowerCase().includes("genre")),p=!n&&"GLOBAL"!==z.type&&z.parentId,!d&&!p)return[3,10];if(!(f=n?null===(y=null===(_=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===_?void 0:_.data)||void 0===y?void 0:y.id:z.parentId))return[3,10];if(!B)return[3,7];L.label=3;case 3:return L.trys.push([3,5,,6]),[4,c.inheritScopeBackwardCompatible({source_scope_id:f,target_scope_id:u})];case 4:return L.sent(),[3,6];case 5:return g=L.sent(),console.error("Failed to inherit rules for the new scope:",g),[3,6];case 6:return[3,10];case 7:return L.trys.push([7,9,,10]),[4,c.inheritScope({source_scope_id:f,target_scope_id:u,application_mapping_id:U||"",is_copy_parent_variant_id:!1})];case 8:return L.sent(),[3,10];case 9:return S=L.sent(),console.error("Failed to inherit rules for the new scope:",S),[3,10];case 10:return[4,Ee(!0)];case 11:return L.sent(),J(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,14];case 12:throw m=L.sent(),console.error("An error occurred during scope creation.",m),null===(T=ge.current)||void 0===T||T.show({severity:"error",summary:"Creation Failed",detail:(null===(C=null===(b=null==m?void 0:m.response)||void 0===b?void 0:b.data)||void 0===C?void 0:C.message)||"There was an error creating the scope. Please try again."}),m;case 13:return ne(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ie,canCreateGlobal:qe}):t.jsxs(t.Fragment,{children:[t.jsx(b.default,{isOpen:z.isOpen&&"DELETE"!==z.type&&"RENAME"!==z.type,onClose:function(){return J(e.__assign(e.__assign({},z),{isOpen:!1}))},onCreate:function(e){return Ae(null!=e?e:"")},hasGlobalRuleSet:Ie}),t.jsx(E.default,{isOpen:z.isOpen&&"RENAME"===z.type,onClose:function(){return J(e.__assign(e.__assign({},z),{isOpen:!1}))},onSave:Ae,initialName:z.initialName})]}),t.jsx(p.default,{isOpen:z.isOpen&&"DELETE"===z.type,onCancel:function(){return J(e.__assign(e.__assign({},z),{isOpen:!1}))},onConfirm:function(){return Re(z.scopeId,z.initialName,z.isSubscope)},title:"Delete Scope",description:t.jsxs(t.Fragment,{children:["Deleting ",t.jsx("span",e.__assign({className:i.default.highlight},{children:z.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:te})]}))})};
2
2
  //# sourceMappingURL=LearningManagement.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("lucide-react");exports.default=function(r){var o=r.isOpen,s=r.onClose,a=r.onSave,l=r.initialName,c=void 0===l?"":l,d=t.useState(c),u=d[0],p=d[1],x=t.useState(""),f=x[0],g=x[1],b=t.useState(!1),y=b[0],_=b[1],h=t.useRef(null);if(t.useEffect(function(){o&&(p(c),g(""),setTimeout(function(){var e,n;null===(e=h.current)||void 0===e||e.focus(),null===(n=h.current)||void 0===n||n.select()},50))},[o,c]),!o)return null;var v=function(){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:if(!u.trim())return g("Scope Name is required"),[2];g(""),_(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,a(u.trim())];case 2:return e.sent(),s(),[3,5];case 3:return e.sent(),g("Failed to rename scope. Please try again."),[3,5];case 4:return _(!1),[7];case 5:return[2]}})})};return n.jsx("div",e.__assign({style:{position:"fixed",inset:0,zIndex:1300,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"},onClick:function(e){e.target===e.currentTarget&&s()}},{children:n.jsxs("div",e.__assign({style:{width:"480px",backgroundColor:"#fff",borderRadius:"12px",boxShadow:"0 20px 60px rgba(0,0,0,0.15)",padding:"24px",fontFamily:"sans-serif"}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"}},{children:[n.jsx("span",e.__assign({style:{fontSize:"16px",fontWeight:600,color:"#19213D"}},{children:"Rename Scope"})),n.jsx("button",e.__assign({onClick:s,disabled:y,style:{background:"none",border:"none",cursor:"pointer",color:"#9CA3AF",padding:"4px",lineHeight:0}},{children:n.jsx(i.X,{size:20})}))]})),n.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:"6px",marginBottom:"24px"}},{children:[n.jsxs("label",e.__assign({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{color:"#E53E3E",marginRight:"3px"}},{children:"*"})),"Scope Name"]})),n.jsx("input",{ref:h,type:"text",value:u,onChange:function(e){p(e.target.value),f&&g("")},onKeyDown:function(e){"Enter"===e.key&&v(),"Escape"===e.key&&s()},placeholder:"Enter scope name",style:{padding:"8px 12px",fontSize:"14px",color:"#19213D",borderRadius:"6px",border:"1px solid ".concat(f?"#EF4444":"#E2E8F0"),outline:"none",width:"100%",boxSizing:"border-box"}}),f&&n.jsx("p",e.__assign({style:{margin:0,fontSize:"12px",color:"#EF4444"}},{children:f}))]})),n.jsxs("div",e.__assign({style:{display:"flex",justifyContent:"flex-end",gap:"10px"}},{children:[n.jsx("button",e.__assign({onClick:s,disabled:y,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #E2E8F0",backgroundColor:"#fff",color:"#64748B",fontSize:"14px",fontWeight:500,cursor:y?"not-allowed":"pointer",opacity:y?.6:1}},{children:"Cancel"})),n.jsx("button",e.__assign({onClick:v,disabled:y,style:{padding:"8px 20px",borderRadius:"6px",border:"none",backgroundColor:"#2563EB",color:"#fff",fontSize:"14px",fontWeight:500,cursor:y?"not-allowed":"pointer",opacity:y?.7:1}},{children:y?"Saving...":"Save"}))]}))]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("lucide-react");exports.default=function(r){var o=r.isOpen,s=r.onClose,a=r.onSave,l=r.initialName,d=void 0===l?"":l,c=t.useState(d),u=c[0],p=c[1],x=t.useState(""),f=x[0],g=x[1],b=t.useState(!1),y=b[0],_=b[1],h=t.useRef(null);if(t.useEffect(function(){o&&(p(d),g(""),setTimeout(function(){var e,n;null===(e=h.current)||void 0===e||e.focus(),null===(n=h.current)||void 0===n||n.select()},50))},[o,d]),!o)return null;var v=function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,t;return e.__generator(this,function(e){switch(e.label){case 0:if(!u.trim())return g("Scope Name is required"),[2];g(""),_(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,a(u.trim())];case 2:return e.sent(),s(),[3,5];case 3:return n=e.sent(),409===(null==(t=n)?void 0:t.status)?g("Scope name already exists."):g("Failed to rename scope. Please try again."),[3,5];case 4:return _(!1),[7];case 5:return[2]}})})};return n.jsx("div",e.__assign({style:{position:"fixed",inset:0,zIndex:1300,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"},onClick:function(e){e.target===e.currentTarget&&s()}},{children:n.jsxs("div",e.__assign({style:{width:"480px",backgroundColor:"#fff",borderRadius:"12px",boxShadow:"0 20px 60px rgba(0,0,0,0.15)",padding:"24px",fontFamily:"sans-serif"}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"}},{children:[n.jsx("span",e.__assign({style:{fontSize:"16px",fontWeight:600,color:"#19213D"}},{children:"Rename Scope"})),n.jsx("button",e.__assign({onClick:s,disabled:y,style:{background:"none",border:"none",cursor:"pointer",color:"#9CA3AF",padding:"4px",lineHeight:0}},{children:n.jsx(i.X,{size:20})}))]})),n.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:"6px",marginBottom:"24px"}},{children:[n.jsxs("label",e.__assign({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{color:"#E53E3E",marginRight:"3px"}},{children:"*"})),"Scope Name"]})),n.jsx("input",{ref:h,type:"text",value:u,onChange:function(e){p(e.target.value),f&&g("")},onKeyDown:function(e){"Enter"===e.key&&v(),"Escape"===e.key&&s()},placeholder:"Enter scope name",style:{padding:"8px 12px",fontSize:"14px",color:"#19213D",borderRadius:"6px",border:"1px solid ".concat(f?"#EF4444":"#E2E8F0"),outline:"none",width:"100%",boxSizing:"border-box"}}),f&&n.jsx("p",e.__assign({style:{margin:0,fontSize:"12px",color:"#EF4444"}},{children:f}))]})),n.jsxs("div",e.__assign({style:{display:"flex",justifyContent:"flex-end",gap:"10px"}},{children:[n.jsx("button",e.__assign({onClick:s,disabled:y,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #E2E8F0",backgroundColor:"#fff",color:"#64748B",fontSize:"14px",fontWeight:500,cursor:y?"not-allowed":"pointer",opacity:y?.6:1}},{children:"Cancel"})),n.jsx("button",e.__assign({onClick:v,disabled:y,style:{padding:"8px 20px",borderRadius:"6px",border:"none",backgroundColor:"#2563EB",color:"#fff",fontSize:"14px",fontWeight:500,cursor:y?"not-allowed":"pointer",opacity:y?.7:1}},{children:y?"Saving...":"Save"}))]}))]}))}))};
2
2
  //# sourceMappingURL=RenameScopeModal.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__awaiter as t,__generator as n}from"tslib";import{jsx as r,jsxs as o,Fragment as s}from"react/jsx-runtime";import{useState as a,useRef as i,useEffect as l}from"react";import{BookOpen as c,Users as u}from"lucide-react";import{useLearningTemplateStore as d}from"./store/useLearningTemplateStore.js";import{Toast as p}from"primereact/toast";import m from"./styles/LearningTemplateManagement.module.css.js";import f from"./LearningTemplateLayout.js";import v from"./components/EmptyLearningState.js";import h from"./store/useAuthStore.js";import{fetchTiers as g,fetchScopes as y,inheritScope as S,inheritScopeBackwardCompatible as b,createRuleSet as C,renameScope as T,updateStation as E,deleteRuleSet as O,requestAccess as w}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as A,setQueryParams as L}from"./hooks/useLearningTemplateQueryParams.js";import I from"./components/ConfirmationModal.js";import R from"./components/LearningTemplateManagementSkeleton.js";import{findNodePathById as j}from"./utils/treeUtils.js";import N from"./store/useEnvStore.js";import{useConfigStore as _}from"./store/useConfigStore.js";import{TooltipProvider as k}from"./components/ToolTip.js";import D from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as P}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as U}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as G}from"./queries/useApprovalQueries.js";import M from"./RuleContent/AddScopeModal.js";import{useLocation as B}from"react-router-dom";import F from"./shared/SuccessToastContent.js";import q from"./shared/ErrorToastContent.js";import x from"./RuleContent/RenameScopeModal.js";var Q=[{id:"learnings",label:"Learnings",icon:c,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:u}],H=[{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},{type:"SCOPE",label:"Scope",addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"},{type:"SUBSCOPE",label:"Subscope"}],K=new Set(Q.map(function(e){return e.id}));function V(c){var u,V=this,W=c.userDetails,Y=c.llmStudioUrl,z=c.audacyBackendUrl,J=c.ilLabels,X=c.config,Z=c.rbacConfig,$=c.app_integration_id,ee=c.backwardCompatibility,te=void 0!==ee&&ee,ne=d(function(e){return e.selectedRuleSetId}),re=d(function(e){return e.setSelectedRuleSetId}),oe=d(function(e){return e.error}),se=d(function(e){return e.setError}),ae=d(function(e){return e.setStations}),ie=d(function(e){return e.scopeTreeData}),le=d(function(e){return e.setScopeTreeData}),ce=a({isOpen:!1,type:"GLOBAL"}),ue=ce[0],de=ce[1],pe=a(!1),me=pe[0],fe=pe[1],ve=a(!1),he=ve[0],ge=ve[1],ye=a("learnings"),Se=ye[0],be=ye[1],Ce=a(null),Te=Ce[0],Ee=Ce[1],Oe=a(null),we=Oe[0],Ae=Oe[1],Le=i(null),Ie=i(null),Re=i(null),je=h();je.user;var Ne=je.setUser,_e=_(),ke=_e.setConfig,De=_e.setIlLabels,Pe=function(){try{return B()}catch(e){return{search:""}}}();l(function(){var e=new URLSearchParams(window.location.search),t=e.get(A.RULESET_ID),n=e.get(A.SECTION),r=n&&K.has(n)?n:"learnings";(null==t?void 0:t.length)&&re&&be&&(re(t),be(r))},[null==Pe?void 0:Pe.search,be,re]);var Ue=P(function(e){return e.fetchPermissions}),Ge=P(function(e){return e.hasPermission}),Me=U(function(e){return e.setRoles}),Be=N(function(e){return e.appsecRbacUrl})===Z.appsecRbacUrl,Fe=G(Z.applicationId,Be).data;l(function(){Fe&&Me(Fe.map(function(e){return{_id:e._id,name:e.name}}))},[Fe,Me]),l(function(){var e;console.log("userDetails",W),Ne(W),console.log("llmStudioUrl",Y),console.log("audacyBackendUrl",z),N.getState().setLlmStudioUrl(Y),N.getState().setAudacyBackendUrl(z),N.getState().setRbacConfig(Z),ke(X),De(J),d.getState().setAppIntegrationId(null!=$?$:null),d.getState().setBackwardCompatibility(te),d.getState().setToken(null!==(e=W.accessToken)&&void 0!==e?e:null)},[W,Ne,Y,z,Z,X,ke,J,De,$,te]),l(function(){(null==W?void 0:W.accessToken)&&Y&&g()},[$,null==W?void 0:W.accessToken,Y]);var qe=function(r){return void 0===r&&(r=!0),t(V,void 0,void 0,function(){var t,o,s,a,i,l;return n(this,function(n){switch(n.label){case 0:r&&fe(!0),se(null),n.label=1;case 1:return n.trys.push([1,4,5,6]),[4,Ue(Z.applicationId)];case 2:return n.sent(),t=function(n){if(!P.getState().hasPermission("ilotj.scope.view",n.id))return null;var r=n.children?n.children.map(function(e){return t(e)}).filter(function(e){return null!==e}):[];return e(e({},n),{children:r})},[4,y($,W.accessToken)];case 3:return(o=n.sent())&&o.data&&o.data.data&&(s=o.data.data,Array.isArray(s)&&(s=s.length>0?s[0]:null),s?(a=t(s))?(Ee(null),le({data:a}),Ie.current?(re(Ie.current),be("learnings"),Ie.current=null):d.getState().selectedRuleSetId||re(a.id)):(Ee(null!==(l=s.id)&&void 0!==l?l:null),le(null)):(Ee(null),le(null))),[3,6];case 4:return i=n.sent(),console.error("Failed to fetch rule sets or permissions",i),se("Failed to load data. Please try again later."),[3,6];case 5:return fe(!1),[7];case 6:return[2]}})})};l(function(){var e;(null===(e=null==W?void 0:W.accessToken)||void 0===e?void 0:e.length)&&Be?qe(!0):console.warn("Error: Trying to fetch rules without access token",W)},[null==W?void 0:W.accessToken,se,ae,Z.applicationId,Be]);var xe=function(r){return t(V,void 0,void 0,function(){var t,o,s,a;return n(this,function(n){switch(n.label){case 0:ge(!0),n.label=1;case 1:return n.trys.push([1,4,5,6]),ue.scopeId?[4,T({scope_id:ue.scopeId,scope_name:r})]:[2];case 2:return n.sent(),[4,qe(!0)];case 3:return n.sent(),de(function(t){return e(e({},t),{isOpen:!1})}),[3,6];case 4:throw t=n.sent(),console.error("An error occurred during scope rename.",t),null===(o=Re.current)||void 0===o||o.show({severity:"error",summary:"Rename Failed",detail:(null===(a=null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.data)||void 0===a?void 0:a.message)||"There was an error renaming the scope. Please try again."}),t;case 5:return ge(!1),[7];case 6:return[2]}})})},Qe=function(r,o,s){return t(V,void 0,void 0,function(){var t,a,i,l,c,u,p,m,f;return n(this,function(n){switch(n.label){case 0:ge(!0),n.label=1;case 1:return n.trys.push([1,8,9,10]),[4,O(r,W.accessToken)];case 2:if(n.sent(),d.getState().selectedRuleSetId===r&&(t=d.getState().scopeTreeData,(a=j((null==t?void 0:t.data)||null,r))&&a.length>1&&(i=a[a.length-2],re(i),be("learnings"))),!s||!o)return[3,6];n.label=3;case 3:return n.trys.push([3,5,,6]),[4,E({station_name:o,ruleset_id:""})];case 4:return n.sent(),[3,6];case 5:return l=n.sent(),console.error("Error unlinking station on subscope delete:",l),[3,6];case 6:return[4,qe(!0)];case 7:return n.sent(),de(function(t){return e(e({},t),{isOpen:!1})}),null===(u=Re.current)||void 0===u||u.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,10];case 8:return c=n.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===(f=null===(m=null==c?void 0:c.response)||void 0===m?void 0:m.data)||void 0===f?void 0:f.message)||"There was an error deleting the scope. Please try again."}),[3,10];case 9:return ge(!1),[7];case 10:return[2]}})})},He=ie,Ke=we?{data:{id:we.stationId,name:we.stationName,type:"STATION",metrics:{learningsCount:we.learningsCount,stationsCount:0},children:[]}}:He,Ve=!!(null==Ke?void 0:Ke.data);null===(u=null==Ke?void 0:Ke.data)||void 0===u||u.type;var We=P(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",Z.applicationResourceId||""),Ye=(we?Q.filter(function(e){return"stations"!==e.id}):Q).filter(function(e){return!(!te&&"access"===e.id)});return r(k,{children:o("div",e({className:m.learningManagementContainer},{children:[r("div",e({className:m.mainWrapper},{children:me?r(R,{}):oe?o("div",e({className:m.errorContainer},{children:[r("div",e({className:m.errorTitle},{children:"Error Loading Data"})),r("p",e({className:m.errorDesc},{children:oe})),r("button",e({onClick:function(){return qe(!0)},className:m.tryAgainBtn},{children:"Try Again"}))]})):Ve?r(f,{onOpenCreateModal:function(){return de({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return de({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return de({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(e,r,o){return t(V,void 0,void 0,function(){var t,s,a;return n(this,function(n){switch(n.label){case 0:return t=d.getState().scopeTreeData,s=j((null==t?void 0:t.data)||null,e),a=!!s&&3===s.length,0!==o?[3,2]:[4,Qe(e,r,a)];case 1:return n.sent(),[3,3];case 2:de({isOpen:!0,type:"DELETE",scopeId:e,initialName:r,isSubscope:a}),n.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return Ge("ilotj.scope.delete",e)},canEditScope:function(e){return Ge("ilotj.scope.edit",e)},canCreateScope:function(e){return Ge("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),L(((n={})[A.SECTION]="learnings"===t?null:t,n)),be(t),re(e)},activeSectionId:Se,scopeTreeData:Ke,sectionsConfig:Ye,onViewStation:function(e){Le.current=ne,Ae(e),be("learnings"),re(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(Ie.current=t),qe(e)},nodeTypesConfig:H,app_integration_id:$,token:W.accessToken}):r(v,{onCreate:function(){return de({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",canCreateRule:We,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return t(V,void 0,void 0,function(){var e,t,o,s,a,i,l,c,u;return n(this,function(n){switch(n.label){case 0:if(!(e=(null===(s=null===(o=d.getState().scopeTreeData)||void 0===o?void 0:o.data)||void 0===s?void 0:s.id)||Te))return null===(a=Re.current)||void 0===a||a.show({severity:"error",sticky:!1,className:m.errorToast,content:r(q,{message:"Unable to identify the global scope for this access request."})}),[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,w(e)];case 2:return n.sent(),null===(i=Re.current)||void 0===i||i.show({severity:"success",sticky:!1,life:3e3,className:m.successToast,content:r(F,{message:"Access request submitted successfully!"})}),[3,4];case 3:return t=n.sent(),null===(l=Re.current)||void 0===l||l.show({severity:"error",sticky:!1,className:m.errorToast,content:r(q,{message:(null===(u=null===(c=null==t?void 0:t.response)||void 0===c?void 0:c.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),r(p,{ref:Re}),te&&ue.isOpen&&"DELETE"!==ue.type&&"RENAME"!==ue.type?r(D,{isOpen:!0,onClose:function(){return de(e(e({},ue),{isOpen:!1}))},onSubmit:function(r){return t(V,void 0,void 0,function(){var t,o,s,a,i,l,c,u,p,m,f,v,h,g,y,T,E,O,w,A;return n(this,function(n){switch(n.label){case 0:ge(!0),t=d.getState().backwardCompatibility,n.label=1;case 1:return n.trys.push([1,12,13,14]),o=void 0,t&&"object"==typeof r?o=r:(s=r,a="SCOPE"===ue.type&&ue.parentId,i=a?"genreRuleSet":ue.type,o={topic:i,scope_reference_id:null,scopeDescription:"demo",parentScopeId:ue.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:$}),[4,C(o,W.accessToken)];case 2:if(l=n.sent(),!(c=null===(g=null==l?void 0:l.data)||void 0===g?void 0:g.scopeId))return[3,10];if(Ie.current=c,u=t&&(null===(y=o.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),p=!t&&"GLOBAL"!==ue.type&&ue.parentId,!u&&!p)return[3,10];if(!(m=t?null===(E=null===(T=d.getState().scopeTreeData)||void 0===T?void 0:T.data)||void 0===E?void 0:E.id:ue.parentId))return[3,10];if(!te)return[3,7];n.label=3;case 3:return n.trys.push([3,5,,6]),[4,b({source_scope_id:m,target_scope_id:c})];case 4:return n.sent(),[3,6];case 5:return f=n.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,6];case 6:return[3,10];case 7:return n.trys.push([7,9,,10]),[4,S({source_scope_id:m,target_scope_id:c,application_mapping_id:$||"",is_copy_parent_variant_id:!1})];case 8:return n.sent(),[3,10];case 9:return v=n.sent(),console.error("Failed to inherit rules for the new scope:",v),[3,10];case 10:return[4,qe(!0)];case 11:return n.sent(),de(function(t){return e(e({},t),{isOpen:!1})}),[3,14];case 12:throw h=n.sent(),console.error("An error occurred during scope creation.",h),null===(O=Re.current)||void 0===O||O.show({severity:"error",summary:"Creation Failed",detail:(null===(A=null===(w=null==h?void 0:h.response)||void 0===w?void 0:w.data)||void 0===A?void 0:A.message)||"There was an error creating the scope. Please try again."}),h;case 13:return ge(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ve,canCreateGlobal:We}):o(s,{children:[r(M,{isOpen:ue.isOpen&&"DELETE"!==ue.type&&"RENAME"!==ue.type,onClose:function(){return de(e(e({},ue),{isOpen:!1}))},onCreate:function(e){return xe(null!=e?e:"")},hasGlobalRuleSet:Ve}),r(x,{isOpen:ue.isOpen&&"RENAME"===ue.type,onClose:function(){return de(e(e({},ue),{isOpen:!1}))},onSave:xe,initialName:ue.initialName})]}),r(I,{isOpen:ue.isOpen&&"DELETE"===ue.type,onCancel:function(){return de(e(e({},ue),{isOpen:!1}))},onConfirm:function(){return Qe(ue.scopeId,ue.initialName,ue.isSubscope)},title:"Delete Scope",description:o(s,{children:["Deleting ",r("span",e({className:m.highlight},{children:ue.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:he})]}))})}export{V as default};
1
+ import{__assign as e,__awaiter as t,__generator as n}from"tslib";import{jsx as r,jsxs as o,Fragment as s}from"react/jsx-runtime";import{useState as a,useRef as i,useEffect as l}from"react";import{BookOpen as c,Users as u}from"lucide-react";import{useLearningTemplateStore as d}from"./store/useLearningTemplateStore.js";import{Toast as p}from"primereact/toast";import m from"./styles/LearningTemplateManagement.module.css.js";import f from"./LearningTemplateLayout.js";import v from"./components/EmptyLearningState.js";import h from"./store/useAuthStore.js";import{fetchTiers as g,fetchScopes as y,inheritScope as S,inheritScopeBackwardCompatible as b,createRuleSet as C,renameScope as T,updateStation as E,deleteRuleSet as O,requestAccess as w}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as A,setQueryParams as L}from"./hooks/useLearningTemplateQueryParams.js";import I from"./components/ConfirmationModal.js";import R from"./components/LearningTemplateManagementSkeleton.js";import{findNodePathById as j}from"./utils/treeUtils.js";import N from"./store/useEnvStore.js";import{useConfigStore as _}from"./store/useConfigStore.js";import{TooltipProvider as k}from"./components/ToolTip.js";import D from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as P}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as U}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as G}from"./queries/useApprovalQueries.js";import M from"./RuleContent/AddScopeModal.js";import{useLocation as B}from"react-router-dom";import F from"./shared/SuccessToastContent.js";import q from"./shared/ErrorToastContent.js";import x from"./RuleContent/RenameScopeModal.js";var Q=[{id:"learnings",label:"Learnings",icon:c,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:u}],H=[{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},{type:"SCOPE",label:"Scope",addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"},{type:"SUBSCOPE",label:"Subscope"}],K=new Set(Q.map(function(e){return e.id}));function V(c){var u,V=this,W=c.userDetails,Y=c.llmStudioUrl,z=c.audacyBackendUrl,J=c.ilLabels,X=c.config,Z=c.rbacConfig,$=c.app_integration_id,ee=c.backwardCompatibility,te=void 0!==ee&&ee,ne=d(function(e){return e.selectedRuleSetId}),re=d(function(e){return e.setSelectedRuleSetId}),oe=d(function(e){return e.error}),se=d(function(e){return e.setError}),ae=d(function(e){return e.setStations}),ie=d(function(e){return e.scopeTreeData}),le=d(function(e){return e.setScopeTreeData}),ce=a({isOpen:!1,type:"GLOBAL"}),ue=ce[0],de=ce[1],pe=a(!1),me=pe[0],fe=pe[1],ve=a(!1),he=ve[0],ge=ve[1],ye=a("learnings"),Se=ye[0],be=ye[1],Ce=a(null),Te=Ce[0],Ee=Ce[1],Oe=a(null),we=Oe[0],Ae=Oe[1],Le=i(null),Ie=i(null),Re=i(null),je=h();je.user;var Ne=je.setUser,_e=_(),ke=_e.setConfig,De=_e.setIlLabels,Pe=function(){try{return B()}catch(e){return{search:""}}}();l(function(){var e=new URLSearchParams(window.location.search),t=e.get(A.RULESET_ID),n=e.get(A.SECTION),r=n&&K.has(n)?n:"learnings";(null==t?void 0:t.length)&&re&&be&&(re(t),be(r))},[null==Pe?void 0:Pe.search,be,re]);var Ue=P(function(e){return e.fetchPermissions}),Ge=P(function(e){return e.hasPermission}),Me=U(function(e){return e.setRoles}),Be=N(function(e){return e.appsecRbacUrl})===Z.appsecRbacUrl,Fe=G(Z.applicationId,Be).data;l(function(){Fe&&Me(Fe.map(function(e){return{_id:e._id,name:e.name}}))},[Fe,Me]),l(function(){var e;console.log("userDetails",W),Ne(W),console.log("llmStudioUrl",Y),console.log("audacyBackendUrl",z),N.getState().setLlmStudioUrl(Y),N.getState().setAudacyBackendUrl(z),N.getState().setRbacConfig(Z),ke(X),De(J),d.getState().setAppIntegrationId(null!=$?$:null),d.getState().setBackwardCompatibility(te),d.getState().setToken(null!==(e=W.accessToken)&&void 0!==e?e:null)},[W,Ne,Y,z,Z,X,ke,J,De,$,te]),l(function(){(null==W?void 0:W.accessToken)&&Y&&g()},[$,null==W?void 0:W.accessToken,Y]);var qe=function(r){return void 0===r&&(r=!0),t(V,void 0,void 0,function(){var t,o,s,a,i,l;return n(this,function(n){switch(n.label){case 0:r&&fe(!0),se(null),n.label=1;case 1:return n.trys.push([1,4,5,6]),[4,Ue(Z.applicationId)];case 2:return n.sent(),t=function(n){if(!P.getState().hasPermission("ilotj.scope.view",n.id))return null;var r=n.children?n.children.map(function(e){return t(e)}).filter(function(e){return null!==e}):[];return e(e({},n),{children:r})},[4,y($,W.accessToken)];case 3:return(o=n.sent())&&o.data&&o.data.data&&(s=o.data.data,Array.isArray(s)&&(s=s.length>0?s[0]:null),s?(a=t(s))?(Ee(null),le({data:a}),Ie.current?(re(Ie.current),be("learnings"),Ie.current=null):d.getState().selectedRuleSetId||re(a.id)):(Ee(null!==(l=s.id)&&void 0!==l?l:null),le(null)):(Ee(null),le(null))),[3,6];case 4:return i=n.sent(),console.error("Failed to fetch rule sets or permissions",i),se("Failed to load data. Please try again later."),[3,6];case 5:return fe(!1),[7];case 6:return[2]}})})};l(function(){var e;(null===(e=null==W?void 0:W.accessToken)||void 0===e?void 0:e.length)&&Be?qe(!0):console.warn("Error: Trying to fetch rules without access token",W)},[null==W?void 0:W.accessToken,se,ae,Z.applicationId,Be]);var xe=function(o){return t(V,void 0,void 0,function(){var t,s,a,i;return n(this,function(n){switch(n.label){case 0:ge(!0),n.label=1;case 1:return n.trys.push([1,4,5,6]),ue.scopeId?[4,T({scope_id:ue.scopeId,scope_name:o})]:[2];case 2:return n.sent(),[4,qe(!0)];case 3:return n.sent(),de(function(t){return e(e({},t),{isOpen:!1})}),[3,6];case 4:throw t=n.sent(),console.error("An error occurred during scope rename.",t),null===(s=Re.current)||void 0===s||s.show({severity:"error",sticky:!1,className:m.errorToast,content:r(q,{message:(null===(i=null===(a=null==t?void 0:t.response)||void 0===a?void 0:a.data)||void 0===i?void 0:i.message)||"There was an error renaming the scope. Please try again."})}),t;case 5:return ge(!1),[7];case 6:return[2]}})})},Qe=function(r,o,s){return t(V,void 0,void 0,function(){var t,a,i,l,c,u,p,m,f;return n(this,function(n){switch(n.label){case 0:ge(!0),n.label=1;case 1:return n.trys.push([1,8,9,10]),[4,O(r,W.accessToken)];case 2:if(n.sent(),d.getState().selectedRuleSetId===r&&(t=d.getState().scopeTreeData,(a=j((null==t?void 0:t.data)||null,r))&&a.length>1&&(i=a[a.length-2],re(i),be("learnings"))),!s||!o)return[3,6];n.label=3;case 3:return n.trys.push([3,5,,6]),[4,E({station_name:o,ruleset_id:""})];case 4:return n.sent(),[3,6];case 5:return l=n.sent(),console.error("Error unlinking station on subscope delete:",l),[3,6];case 6:return[4,qe(!0)];case 7:return n.sent(),de(function(t){return e(e({},t),{isOpen:!1})}),null===(u=Re.current)||void 0===u||u.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,10];case 8:return c=n.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===(f=null===(m=null==c?void 0:c.response)||void 0===m?void 0:m.data)||void 0===f?void 0:f.message)||"There was an error deleting the scope. Please try again."}),[3,10];case 9:return ge(!1),[7];case 10:return[2]}})})},He=ie,Ke=we?{data:{id:we.stationId,name:we.stationName,type:"STATION",metrics:{learningsCount:we.learningsCount,stationsCount:0},children:[]}}:He,Ve=!!(null==Ke?void 0:Ke.data);null===(u=null==Ke?void 0:Ke.data)||void 0===u||u.type;var We=P(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",Z.applicationResourceId||""),Ye=(we?Q.filter(function(e){return"stations"!==e.id}):Q).filter(function(e){return!(!te&&"access"===e.id)});return r(k,{children:o("div",e({className:m.learningManagementContainer},{children:[r("div",e({className:m.mainWrapper},{children:me?r(R,{}):oe?o("div",e({className:m.errorContainer},{children:[r("div",e({className:m.errorTitle},{children:"Error Loading Data"})),r("p",e({className:m.errorDesc},{children:oe})),r("button",e({onClick:function(){return qe(!0)},className:m.tryAgainBtn},{children:"Try Again"}))]})):Ve?r(f,{onOpenCreateModal:function(){return de({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return de({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return de({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(e,r,o){return t(V,void 0,void 0,function(){var t,s,a;return n(this,function(n){switch(n.label){case 0:return t=d.getState().scopeTreeData,s=j((null==t?void 0:t.data)||null,e),a=!!s&&3===s.length,0!==o?[3,2]:[4,Qe(e,r,a)];case 1:return n.sent(),[3,3];case 2:de({isOpen:!0,type:"DELETE",scopeId:e,initialName:r,isSubscope:a}),n.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return Ge("ilotj.scope.delete",e)},canEditScope:function(e){return Ge("ilotj.scope.edit",e)},canCreateScope:function(e){return Ge("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),L(((n={})[A.SECTION]="learnings"===t?null:t,n)),be(t),re(e)},activeSectionId:Se,scopeTreeData:Ke,sectionsConfig:Ye,onViewStation:function(e){Le.current=ne,Ae(e),be("learnings"),re(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(Ie.current=t),qe(e)},nodeTypesConfig:H,app_integration_id:$,token:W.accessToken}):r(v,{onCreate:function(){return de({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",canCreateRule:We,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return t(V,void 0,void 0,function(){var e,t,o,s,a,i,l,c,u;return n(this,function(n){switch(n.label){case 0:if(!(e=(null===(s=null===(o=d.getState().scopeTreeData)||void 0===o?void 0:o.data)||void 0===s?void 0:s.id)||Te))return null===(a=Re.current)||void 0===a||a.show({severity:"error",sticky:!1,className:m.errorToast,content:r(q,{message:"Unable to identify the global scope for this access request."})}),[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,w(e)];case 2:return n.sent(),null===(i=Re.current)||void 0===i||i.show({severity:"success",sticky:!1,life:3e3,className:m.successToast,content:r(F,{message:"Access request submitted successfully!"})}),[3,4];case 3:return t=n.sent(),null===(l=Re.current)||void 0===l||l.show({severity:"error",sticky:!1,className:m.errorToast,content:r(q,{message:(null===(u=null===(c=null==t?void 0:t.response)||void 0===c?void 0:c.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),r(p,{ref:Re}),te&&ue.isOpen&&"DELETE"!==ue.type&&"RENAME"!==ue.type?r(D,{isOpen:!0,onClose:function(){return de(e(e({},ue),{isOpen:!1}))},onSubmit:function(r){return t(V,void 0,void 0,function(){var t,o,s,a,i,l,c,u,p,m,f,v,h,g,y,T,E,O,w,A;return n(this,function(n){switch(n.label){case 0:ge(!0),t=d.getState().backwardCompatibility,n.label=1;case 1:return n.trys.push([1,12,13,14]),o=void 0,t&&"object"==typeof r?o=r:(s=r,a="SCOPE"===ue.type&&ue.parentId,i=a?"genreRuleSet":ue.type,o={topic:i,scope_reference_id:null,scopeDescription:"demo",parentScopeId:ue.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:$}),[4,C(o,W.accessToken)];case 2:if(l=n.sent(),!(c=null===(g=null==l?void 0:l.data)||void 0===g?void 0:g.scopeId))return[3,10];if(Ie.current=c,u=t&&(null===(y=o.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),p=!t&&"GLOBAL"!==ue.type&&ue.parentId,!u&&!p)return[3,10];if(!(m=t?null===(E=null===(T=d.getState().scopeTreeData)||void 0===T?void 0:T.data)||void 0===E?void 0:E.id:ue.parentId))return[3,10];if(!te)return[3,7];n.label=3;case 3:return n.trys.push([3,5,,6]),[4,b({source_scope_id:m,target_scope_id:c})];case 4:return n.sent(),[3,6];case 5:return f=n.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,6];case 6:return[3,10];case 7:return n.trys.push([7,9,,10]),[4,S({source_scope_id:m,target_scope_id:c,application_mapping_id:$||"",is_copy_parent_variant_id:!1})];case 8:return n.sent(),[3,10];case 9:return v=n.sent(),console.error("Failed to inherit rules for the new scope:",v),[3,10];case 10:return[4,qe(!0)];case 11:return n.sent(),de(function(t){return e(e({},t),{isOpen:!1})}),[3,14];case 12:throw h=n.sent(),console.error("An error occurred during scope creation.",h),null===(O=Re.current)||void 0===O||O.show({severity:"error",summary:"Creation Failed",detail:(null===(A=null===(w=null==h?void 0:h.response)||void 0===w?void 0:w.data)||void 0===A?void 0:A.message)||"There was an error creating the scope. Please try again."}),h;case 13:return ge(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ve,canCreateGlobal:We}):o(s,{children:[r(M,{isOpen:ue.isOpen&&"DELETE"!==ue.type&&"RENAME"!==ue.type,onClose:function(){return de(e(e({},ue),{isOpen:!1}))},onCreate:function(e){return xe(null!=e?e:"")},hasGlobalRuleSet:Ve}),r(x,{isOpen:ue.isOpen&&"RENAME"===ue.type,onClose:function(){return de(e(e({},ue),{isOpen:!1}))},onSave:xe,initialName:ue.initialName})]}),r(I,{isOpen:ue.isOpen&&"DELETE"===ue.type,onCancel:function(){return de(e(e({},ue),{isOpen:!1}))},onConfirm:function(){return Qe(ue.scopeId,ue.initialName,ue.isSubscope)},title:"Delete Scope",description:o(s,{children:["Deleting ",r("span",e({className:m.highlight},{children:ue.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:he})]}))})}export{V as default};
2
2
  //# sourceMappingURL=LearningManagement.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__awaiter as n,__generator as o}from"tslib";import{jsx as t,jsxs as r}from"react/jsx-runtime";import{useState as i,useRef as l,useEffect as a}from"react";import{X as d}from"lucide-react";var c=function(c){var s=c.isOpen,p=c.onClose,u=c.onSave,f=c.initialName,x=void 0===f?"":f,g=i(x),b=g[0],y=g[1],m=i(""),h=m[0],v=m[1],C=i(!1),S=C[0],E=C[1],k=l(null);if(a(function(){s&&(y(x),v(""),setTimeout(function(){var e,n;null===(e=k.current)||void 0===e||e.focus(),null===(n=k.current)||void 0===n||n.select()},50))},[s,x]),!s)return null;var z=function(){return n(void 0,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:if(!b.trim())return v("Scope Name is required"),[2];v(""),E(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,u(b.trim())];case 2:return e.sent(),p(),[3,5];case 3:return e.sent(),v("Failed to rename scope. Please try again."),[3,5];case 4:return E(!1),[7];case 5:return[2]}})})};return t("div",e({style:{position:"fixed",inset:0,zIndex:1300,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"},onClick:function(e){e.target===e.currentTarget&&p()}},{children:r("div",e({style:{width:"480px",backgroundColor:"#fff",borderRadius:"12px",boxShadow:"0 20px 60px rgba(0,0,0,0.15)",padding:"24px",fontFamily:"sans-serif"}},{children:[r("div",e({style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"}},{children:[t("span",e({style:{fontSize:"16px",fontWeight:600,color:"#19213D"}},{children:"Rename Scope"})),t("button",e({onClick:p,disabled:S,style:{background:"none",border:"none",cursor:"pointer",color:"#9CA3AF",padding:"4px",lineHeight:0}},{children:t(d,{size:20})}))]})),r("div",e({style:{display:"flex",flexDirection:"column",gap:"6px",marginBottom:"24px"}},{children:[r("label",e({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:[t("span",e({style:{color:"#E53E3E",marginRight:"3px"}},{children:"*"})),"Scope Name"]})),t("input",{ref:k,type:"text",value:b,onChange:function(e){y(e.target.value),h&&v("")},onKeyDown:function(e){"Enter"===e.key&&z(),"Escape"===e.key&&p()},placeholder:"Enter scope name",style:{padding:"8px 12px",fontSize:"14px",color:"#19213D",borderRadius:"6px",border:"1px solid ".concat(h?"#EF4444":"#E2E8F0"),outline:"none",width:"100%",boxSizing:"border-box"}}),h&&t("p",e({style:{margin:0,fontSize:"12px",color:"#EF4444"}},{children:h}))]})),r("div",e({style:{display:"flex",justifyContent:"flex-end",gap:"10px"}},{children:[t("button",e({onClick:p,disabled:S,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #E2E8F0",backgroundColor:"#fff",color:"#64748B",fontSize:"14px",fontWeight:500,cursor:S?"not-allowed":"pointer",opacity:S?.6:1}},{children:"Cancel"})),t("button",e({onClick:z,disabled:S,style:{padding:"8px 20px",borderRadius:"6px",border:"none",backgroundColor:"#2563EB",color:"#fff",fontSize:"14px",fontWeight:500,cursor:S?"not-allowed":"pointer",opacity:S?.7:1}},{children:S?"Saving...":"Save"}))]}))]}))}))};export{c as default};
1
+ import{__assign as e,__awaiter as n,__generator as o}from"tslib";import{jsx as t,jsxs as r}from"react/jsx-runtime";import{useState as i,useRef as l,useEffect as a}from"react";import{X as d}from"lucide-react";var c=function(c){var s=c.isOpen,p=c.onClose,u=c.onSave,f=c.initialName,x=void 0===f?"":f,g=i(x),b=g[0],y=g[1],m=i(""),h=m[0],v=m[1],C=i(!1),S=C[0],E=C[1],k=l(null);if(a(function(){s&&(y(x),v(""),setTimeout(function(){var e,n;null===(e=k.current)||void 0===e||e.focus(),null===(n=k.current)||void 0===n||n.select()},50))},[s,x]),!s)return null;var z=function(){return n(void 0,void 0,void 0,function(){var e,n;return o(this,function(o){switch(o.label){case 0:if(!b.trim())return v("Scope Name is required"),[2];v(""),E(!0),o.label=1;case 1:return o.trys.push([1,3,4,5]),[4,u(b.trim())];case 2:return o.sent(),p(),[3,5];case 3:return e=o.sent(),409===(null==(n=e)?void 0:n.status)?v("Scope name already exists."):v("Failed to rename scope. Please try again."),[3,5];case 4:return E(!1),[7];case 5:return[2]}})})};return t("div",e({style:{position:"fixed",inset:0,zIndex:1300,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"},onClick:function(e){e.target===e.currentTarget&&p()}},{children:r("div",e({style:{width:"480px",backgroundColor:"#fff",borderRadius:"12px",boxShadow:"0 20px 60px rgba(0,0,0,0.15)",padding:"24px",fontFamily:"sans-serif"}},{children:[r("div",e({style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"}},{children:[t("span",e({style:{fontSize:"16px",fontWeight:600,color:"#19213D"}},{children:"Rename Scope"})),t("button",e({onClick:p,disabled:S,style:{background:"none",border:"none",cursor:"pointer",color:"#9CA3AF",padding:"4px",lineHeight:0}},{children:t(d,{size:20})}))]})),r("div",e({style:{display:"flex",flexDirection:"column",gap:"6px",marginBottom:"24px"}},{children:[r("label",e({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:[t("span",e({style:{color:"#E53E3E",marginRight:"3px"}},{children:"*"})),"Scope Name"]})),t("input",{ref:k,type:"text",value:b,onChange:function(e){y(e.target.value),h&&v("")},onKeyDown:function(e){"Enter"===e.key&&z(),"Escape"===e.key&&p()},placeholder:"Enter scope name",style:{padding:"8px 12px",fontSize:"14px",color:"#19213D",borderRadius:"6px",border:"1px solid ".concat(h?"#EF4444":"#E2E8F0"),outline:"none",width:"100%",boxSizing:"border-box"}}),h&&t("p",e({style:{margin:0,fontSize:"12px",color:"#EF4444"}},{children:h}))]})),r("div",e({style:{display:"flex",justifyContent:"flex-end",gap:"10px"}},{children:[t("button",e({onClick:p,disabled:S,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #E2E8F0",backgroundColor:"#fff",color:"#64748B",fontSize:"14px",fontWeight:500,cursor:S?"not-allowed":"pointer",opacity:S?.6:1}},{children:"Cancel"})),t("button",e({onClick:z,disabled:S,style:{padding:"8px 20px",borderRadius:"6px",border:"none",backgroundColor:"#2563EB",color:"#fff",fontSize:"14px",fontWeight:500,cursor:S?"not-allowed":"pointer",opacity:S?.7:1}},{children:S?"Saving...":"Save"}))]}))]}))}))};export{c as default};
2
2
  //# sourceMappingURL=RenameScopeModal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LearningManagement.d.ts","sourceRoot":"","sources":["../../../../../src/features/LearningManagement/LearningManagement.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAWrC,OAAoB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAgF9D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,uBAAuB;IAC/B,WAAW,EAAE,IAAI,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,GAAG,CAAC;IACZ,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE;QACR,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,CAAA;IACD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;GAGG;AACH,iBAAS,kBAAkB,CAAC,EAC1B,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,UAAU,EACV,kBAAkB,EAClB,qBAA2B,EAC5B,EAAE,uBAAuB,2CAujBzB;AAED,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"LearningManagement.d.ts","sourceRoot":"","sources":["../../../../../src/features/LearningManagement/LearningManagement.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAWrC,OAAoB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAgF9D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,uBAAuB;IAC/B,WAAW,EAAE,IAAI,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,GAAG,CAAC;IACZ,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE;QACR,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,CAAA;IACD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;GAGG;AACH,iBAAS,kBAAkB,CAAC,EAC1B,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,UAAU,EACV,kBAAkB,EAClB,qBAA2B,EAC5B,EAAE,uBAAuB,2CAwjBzB;AAED,eAAe,kBAAkB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"RenameScopeModal.d.ts","sourceRoot":"","sources":["../../../../../../src/features/LearningManagement/RuleContent/RenameScopeModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,UAAU,qBAAqB;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAgJrD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"RenameScopeModal.d.ts","sourceRoot":"","sources":["../../../../../../src/features/LearningManagement/RuleContent/RenameScopeModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,UAAU,qBAAqB;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAqJrD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-llm-studio/instant-learning",
3
- "version": "0.1.1-alpha.67",
3
+ "version": "0.1.1-alpha.69",
4
4
  "author": "Devesh Patel",
5
5
  "description": "",
6
6
  "license": "MIT",