@e-llm-studio/instant-learning 1.3.0-alpha.136 → 1.3.0-alpha.138

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
- import{__assign as e}from"tslib";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as i,useMemo as n,useEffect as r}from"react";import{AuditLog as a}from"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import{User as l,ExternalLink as c}from"lucide-react";import s from"./ChangeLogDiff.js";import{BrowserRouter as d}from"react-router-dom";import{dt as p}from"../store/useLMSConfigStore.js";import h from"../RBAC/AccessPanel.module.css.js";import{usePermissionsStore as g}from"../store/usePermissionsStore.js";import u from"../store/useEnvStore.js";import{useConfigStore as m}from"../store/useConfigStore.js";var f=function(f){var b=f.configId,y=f.ruleData,x=f.scopeId,v=f.scopeName,w=(null==v?void 0:v.trim())||"Selected",C=i("scope"),S=C[0],T=C[1];m.getState().configuration;var L=g(function(e){return e.hasPermission}),A=u(function(e){var o;return(null===(o=e.rbacConfig)||void 0===o?void 0:o.applicationResourceId)||""}),k=Boolean(x&&L("ilotj.scope.changeLog.view",x)),D=Boolean(A&&L("ilotj.application.changeLog.view",A)),I=n(function(){var e=[];return x&&e.push(x),e},[y,x]);r(function(){console.log("Flattened External Resource IDs:",I)},[I]);var j={configId:b,getData:{baseUrl:window.location.origin.includes("local")?"https://dev.appmod.ai":window.location.origin,endpoint:"/changelog/audit-log/fetch"},distinctValuesApi:{baseUrl:window.location.origin.includes("local")?"https://dev.appmod.ai":window.location.origin,endpoint:"/changelog/audit-log/distinct-values"},sidebar:{config:{showAnalystFilter:!0,showDateFilter:!0,showChangeTitleFilter:!0,showImpactPercentage:!1},labels:{title:"Filters",multiSelectLabel:"Modified By",multiSelectHint:"Filter by the user who made the change",changeTitleLabel:"Change Action",changeTitleHint:"Filter by Actions"}},table:{tableProps:{scrollable:!0,scrollHeight:"80vh",showGridlines:!0,size:"small",rowClassName:function(){return"custom-compact-row"},pt:{bodyCell:{style:{paddingTop:"4px",paddingBottom:"4px"}}}},hiddenColumns:["actions","changeSummary","changeDateTime","logId"],extraColumns:[{key:"modifiedBy",header:"Modified By",body:function(i){return o("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[t(l,{size:16,color:"#64748b",style:{flexShrink:0}}),t("span",e({style:{fontWeight:500}},{children:i.modifiedBy}))]}))},style:{width:"15%",minWidth:"140px"}},{key:"changeAction",header:"Action",body:function(o){var i,n,r=(i=o.changeTitle,(n=(i||"").toUpperCase()).includes("CREATE")?{color:"#2e7d32",backgroundColor:"#edf7ed",borderColor:"#c8e6c9",boxShadow:"0 1px 2px rgba(46, 125, 50, 0.08)"}:n.includes("UPDATE")||n.includes("TOGGLE")?{color:"#1565c0",backgroundColor:"#e3f2fd",borderColor:"#bbdefb",boxShadow:"0 1px 2px rgba(21, 101, 192, 0.08)"}:n.includes("DELETE")?{color:"#c62828",backgroundColor:"#fdeeed",borderColor:"#ffcdd2",boxShadow:"0 1px 2px rgba(198, 40, 40, 0.08)"}:{color:"#475569",backgroundColor:"#f8fafc",borderColor:"#cbd5e1",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.06)"}),a=o.changeTitle?o.changeTitle.replace(/_/g," "):"—";return t("span",e({style:{color:r.color,backgroundColor:r.backgroundColor,border:"1px solid ".concat(r.borderColor),boxShadow:r.boxShadow,padding:"6px 12px",borderRadius:"999px",fontSize:"12px",lineHeight:1,fontWeight:600,display:"inline-block",minWidth:"76px",textAlign:"center",textTransform:"capitalize"}},{children:a}))},style:{width:"15%",textAlign:"center"}},{key:"customChangeSummary",header:"Change Summary",body:function(e){var o;return t(s,{change:null!==(o=e.actionText)&&void 0!==o?o:"-"})},style:{width:"30%",minWidth:"200px"}},{key:"redirectLink",header:"Link",body:function(i){var n,r=(null===(n=i.metadata)||void 0===n?void 0:n.redirect_url)||i.redirect_url;return r?t("div",e({style:{display:"flex",justifyContent:"center",alignItems:"center"}},{children:o("a",e({href:r,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"6px",color:"#2563eb",textDecoration:"none",fontWeight:500,fontSize:"13px"}},{children:["View ",t(c,{size:14})]}))})):t("span",e({style:{color:"#94a3b8",display:"flex",justifyContent:"center"}},{children:"—"}))},style:{width:"10%",minWidth:"90px",textAlign:"center"}},{key:"customChangeDateTime",header:"Change Time and Date",body:function(i){if(!i.actionDate)return t("span",e({style:{color:"#94a3b8"}},{children:"—"}));var n=new Date(i.actionDate),r=n.toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),a=n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});return o("div",e({style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",fontSize:"13px",color:"#475569"}},{children:[t("span",e({style:{fontWeight:500}},{children:r})),t("span",{children:a})]}))},style:{width:"15%",minWidth:"150px",textAlign:"center"}}]},filters:{config:{showFilterButton:!0,showSort:!0,showDate:!0,showSearch:!0,sortOptions:{latest:!0,oldest:!0,impactHighToLow:!1,impactLowToHigh:!1}}}};return t("div",e({style:{height:"100%",overflowY:"auto"}},{children:o("div",e({style:{padding:"24px",fontFamily:"Arial, sans-serif"}},{children:[o("div",e({style:{marginBottom:"16px",paddingBottom:"4px"}},{children:[t("h1",e({style:{margin:0,color:"#334155",fontSize:"20px",fontWeight:700,lineHeight:1.25}},{children:p("history.title","".concat(w," - Audit Log"),{scope_name:w})})),t("p",e({style:{margin:"8px 0 0",color:"#667085",fontSize:"16px",fontWeight:500,lineHeight:1}},{children:p("history.subtitle","Track all learning updates and modifications with the ".concat(w," scope."),{scope_name:w})}))]})),o("div",e({className:h.accessTabs,role:"tablist","aria-label":"Audit log level"},{children:[t("button",e({type:"button",role:"tab","aria-selected":"scope"===S,className:"".concat(h.accessTab," ").concat("scope"===S?h.accessTabActive:""),onClick:function(){return T("scope")},disabled:!k,title:k?"":"You do not have permission to view scope level change log"},{children:p("history.scopeLevel","Scope Level")})),t("button",e({type:"button",role:"tab","aria-selected":"application"===S,className:"".concat(h.accessTab," ").concat("application"===S?h.accessTabActive:""),onClick:function(){return T("application")},disabled:!D,title:D?"":"You do not have permission to view application level change log"},{children:p("history.applicationLevel","Application Level")}))]})),t(d,{children:"scope"===S?t(a,e({},j,{query:{externalResourceId:I.length>0?I:[""],paginationLimit:10}}),"scope-audit-log"):t(a,e({},j,{query:{externalResourceId:[],paginationLimit:10}}),"application-audit-log")})]}))}))};export{f as default};
1
+ import{__assign as e}from"tslib";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as i,useMemo as n,useEffect as a}from"react";import{AuditLog as r}from"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import{User as l,ExternalLink as c}from"lucide-react";import s from"./ChangeLogDiff.js";import{dt as d}from"../store/useLMSConfigStore.js";import p from"../RBAC/AccessPanel.module.css.js";import{usePermissionsStore as h}from"../store/usePermissionsStore.js";import g from"../store/useEnvStore.js";import{useConfigStore as u}from"../store/useConfigStore.js";var m=function(m){var f=m.configId,b=m.ruleData,y=m.scopeId,x=m.scopeName,v=(null==x?void 0:x.trim())||"Selected",w=i("scope"),C=w[0],S=w[1];u.getState().configuration;var T=h(function(e){return e.hasPermission}),L=g(function(e){var o;return(null===(o=e.rbacConfig)||void 0===o?void 0:o.applicationResourceId)||""}),A=Boolean(y&&T("ilotj.scope.changeLog.view",y)),k=Boolean(L&&T("ilotj.application.changeLog.view",L)),D=n(function(){var e=[];return y&&e.push(y),e},[b,y]);a(function(){console.log("Flattened External Resource IDs:",D)},[D]);var I={configId:f,getData:{baseUrl:window.location.origin.includes("local")?"https://dev.appmod.ai":window.location.origin,endpoint:"/changelog/audit-log/fetch"},distinctValuesApi:{baseUrl:window.location.origin.includes("local")?"https://dev.appmod.ai":window.location.origin,endpoint:"/changelog/audit-log/distinct-values"},sidebar:{config:{showAnalystFilter:!0,showDateFilter:!0,showChangeTitleFilter:!0,showImpactPercentage:!1},labels:{title:"Filters",multiSelectLabel:"Modified By",multiSelectHint:"Filter by the user who made the change",changeTitleLabel:"Change Action",changeTitleHint:"Filter by Actions"}},table:{tableProps:{scrollable:!0,scrollHeight:"80vh",showGridlines:!0,size:"small",rowClassName:function(){return"custom-compact-row"},pt:{bodyCell:{style:{paddingTop:"4px",paddingBottom:"4px"}}}},hiddenColumns:["actions","changeSummary","changeDateTime","logId"],extraColumns:[{key:"modifiedBy",header:"Modified By",body:function(i){return o("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[t(l,{size:16,color:"#64748b",style:{flexShrink:0}}),t("span",e({style:{fontWeight:500}},{children:i.modifiedBy}))]}))},style:{width:"15%",minWidth:"140px"}},{key:"changeAction",header:"Action",body:function(o){var i,n,a=(i=o.changeTitle,(n=(i||"").toUpperCase()).includes("CREATE")?{color:"#2e7d32",backgroundColor:"#edf7ed",borderColor:"#c8e6c9",boxShadow:"0 1px 2px rgba(46, 125, 50, 0.08)"}:n.includes("UPDATE")||n.includes("TOGGLE")?{color:"#1565c0",backgroundColor:"#e3f2fd",borderColor:"#bbdefb",boxShadow:"0 1px 2px rgba(21, 101, 192, 0.08)"}:n.includes("DELETE")?{color:"#c62828",backgroundColor:"#fdeeed",borderColor:"#ffcdd2",boxShadow:"0 1px 2px rgba(198, 40, 40, 0.08)"}:{color:"#475569",backgroundColor:"#f8fafc",borderColor:"#cbd5e1",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.06)"}),r=o.changeTitle?o.changeTitle.replace(/_/g," "):"—";return t("span",e({style:{color:a.color,backgroundColor:a.backgroundColor,border:"1px solid ".concat(a.borderColor),boxShadow:a.boxShadow,padding:"6px 12px",borderRadius:"999px",fontSize:"12px",lineHeight:1,fontWeight:600,display:"inline-block",minWidth:"76px",textAlign:"center",textTransform:"capitalize"}},{children:r}))},style:{width:"15%",textAlign:"center"}},{key:"customChangeSummary",header:"Change Summary",body:function(e){var o;return t(s,{change:null!==(o=e.actionText)&&void 0!==o?o:"-"})},style:{width:"30%",minWidth:"200px"}},{key:"redirectLink",header:"Link",body:function(i){var n,a=(null===(n=i.metadata)||void 0===n?void 0:n.redirect_url)||i.redirect_url;return a?t("div",e({style:{display:"flex",justifyContent:"center",alignItems:"center"}},{children:o("a",e({href:a,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"6px",color:"#2563eb",textDecoration:"none",fontWeight:500,fontSize:"13px"}},{children:["View ",t(c,{size:14})]}))})):t("span",e({style:{color:"#94a3b8",display:"flex",justifyContent:"center"}},{children:"—"}))},style:{width:"10%",minWidth:"90px",textAlign:"center"}},{key:"customChangeDateTime",header:"Change Time and Date",body:function(i){if(!i.actionDate)return t("span",e({style:{color:"#94a3b8"}},{children:"—"}));var n=new Date(i.actionDate),a=n.toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),r=n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});return o("div",e({style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",fontSize:"13px",color:"#475569"}},{children:[t("span",e({style:{fontWeight:500}},{children:a})),t("span",{children:r})]}))},style:{width:"15%",minWidth:"150px",textAlign:"center"}}]},filters:{config:{showFilterButton:!0,showSort:!0,showDate:!0,showSearch:!0,sortOptions:{latest:!0,oldest:!0,impactHighToLow:!1,impactLowToHigh:!1}}}};return t("div",e({style:{height:"100%",overflowY:"auto"}},{children:o("div",e({style:{padding:"24px",fontFamily:"Arial, sans-serif"}},{children:[o("div",e({style:{marginBottom:"16px",paddingBottom:"4px"}},{children:[t("h1",e({style:{margin:0,color:"#334155",fontSize:"20px",fontWeight:700,lineHeight:1.25}},{children:d("history.title","".concat(v," - Audit Log"),{scope_name:v})})),t("p",e({style:{margin:"8px 0 0",color:"#667085",fontSize:"16px",fontWeight:500,lineHeight:1}},{children:d("history.subtitle","Track all learning updates and modifications with the ".concat(v," scope."),{scope_name:v})}))]})),o("div",e({className:p.accessTabs,role:"tablist","aria-label":"Audit log level"},{children:[t("button",e({type:"button",role:"tab","aria-selected":"scope"===C,className:"".concat(p.accessTab," ").concat("scope"===C?p.accessTabActive:""),onClick:function(){return S("scope")},disabled:!A,title:A?"":"You do not have permission to view scope level change log"},{children:d("history.scopeLevel","Scope Level")})),t("button",e({type:"button",role:"tab","aria-selected":"application"===C,className:"".concat(p.accessTab," ").concat("application"===C?p.accessTabActive:""),onClick:function(){return S("application")},disabled:!k,title:k?"":"You do not have permission to view application level change log"},{children:d("history.applicationLevel","Application Level")}))]})),"scope"===C?t(r,e({},I,{query:{externalResourceId:D.length>0?D:[""],paginationLimit:10}}),"scope-audit-log"):t(r,e({},I,{query:{externalResourceId:[],paginationLimit:10}}),"application-audit-log")]}))}))};export{m as default};
2
2
  //# sourceMappingURL=AuditLog.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as n,__awaiter as t,__generator as r}from"tslib";import{jsx as o,jsxs as s,Fragment as i}from"react/jsx-runtime";import{useCallback as a,useState as c,useRef as l,useEffect as u}from"react";import{BookOpen as d,Users as p,History as m}from"lucide-react";import{useLearningTemplateStore as f}from"./store/useLearningTemplateStore.js";import{Toast as v}from"primereact/toast";import g from"./styles/LearningTemplateManagement.module.css.js";import h from"./LearningTemplateLayout.js";import S from"./components/EmptyLearningState.js";import y from"./store/useAuthStore.js";import{fetchTiers as b,getILInstance as C,fetchScopes as T,inheritScope as I,inheritScopeBackwardCompatible as A,createRuleSet as L,renameScope as E,deleteRuleSet as R,requestAccess as O}from"./apis/scopeApis.js";import{setQueryParams as w,QUERY_PARAM_KEYS as N}from"./hooks/useLearningTemplateQueryParams.js";import _ from"./components/ConfirmationModal.js";import j from"./components/LearningTemplateManagementSkeleton.js";import{findNodePathById as D,findNodeById as k}from"./utils/treeUtils.js";import M from"./store/useEnvStore.js";import{useConfigStore as P}from"./store/useConfigStore.js";import{TooltipProvider as U}from"./components/ToolTip.js";import B from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as q}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as G}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as F}from"./queries/useApprovalQueries.js";import{useLMSConfigQuery as x}from"./queries/useLMSConfigQuery.js";import H from"./RuleContent/AddScopeModal.js";import Q from"./components/RuleContentSkeleton.js";import z from"./components/ErrorStateDisplay.js";import{useLocation as K}from"react-router-dom";import V from"./shared/SuccessToastContent.js";import W from"./shared/ErrorToastContent.js";import Y from"./RuleContent/RenameScopeModal.js";import{dt as J,useLMSConfigStore as X}from"./store/useLMSConfigStore.js";import{MIDDLE_DRAWER_DT_PATH as Z,MIDDLE_DRAWER_CONTEXT_MENU_DT_PATH as $,EMPTY_STATE_DT_PATH as ee}from"./constants.js";function ne(ne){var te,re,oe,se=this,ie=ne.userDetails,ae=ne.llmStudioUrl,ce=ne.audacyBackendUrl,le=ne.ilLabels,ue=ne.config,de=ne.rbacConfig,pe=ne.auditLogConfig,me=ne.app_integration_id,fe=ne.backwardCompatibility,ve=void 0!==fe&&fe,ge=ne.cognitiveCompareCompatibility,he=void 0!==ge&&ge,Se=ne.modeId,ye=ne.modeDetails,be=ne.pluginPayload,Ce=[{id:"learnings",label:J("".concat(Z,".treeMenu.submenu.learnings"),"Learnings"),icon:d,badgeKey:"learningsCount"},{id:"access",label:J("".concat(Z,".treeMenu.submenu.access"),"Access"),icon:p},{id:"history",label:J("".concat(Z,".treeMenu.submenu.changeHistory"),"Change History"),icon:m}],Te=new Set(Ce.map(function(e){return e.id})),Ie=a(function(){var e;w(((e={})[N.RULESET_ID]=null,e[N.SECTION]=null,e))},[]),Ae=f(function(e){return e.selectedRuleSetId}),Le=f(function(e){return e.setSelectedRuleSetId}),Ee=f(function(e){return e.setIlInstanceId}),Re=f(function(e){return e.error}),Oe=f(function(e){return e.setError}),we=f(function(e){return e.setStations}),Ne=f(function(e){return e.scopeTreeData}),_e=f(function(e){return e.setScopeTreeData}),je=c({isOpen:!1,type:"GLOBAL"}),De=je[0],ke=je[1],Me=c(!1),Pe=Me[0],Ue=Me[1],Be=c(!1),qe=Be[0],Ge=Be[1],Fe=c("learnings"),xe=Fe[0],He=Fe[1],Qe=c(null),ze=Qe[0],Ke=Qe[1],Ve=c(!1),We=Ve[0],Ye=Ve[1],Je=c(null),Xe=Je[0];Je[1];var Ze=c(!1),$e=Ze[0],en=Ze[1],nn=c(!1),tn=nn[0],rn=nn[1];l(null);var on=l(null),sn=l(!1),an=l(null),cn=y();cn.user;var ln=cn.setUser,un=P(),dn=un.setConfig,pn=un.setIlLabels,mn=function(){try{return K()}catch(e){return{search:""}}}();u(function(){if(!sn.current){var e=new URLSearchParams(window.location.search),n=e.get(N.RULESET_ID),t=e.get(N.SECTION),r=t&&(null==Te?void 0:Te.has(t))?t:"learnings";(null==n?void 0:n.length)&&Le&&He&&(Le(n),He(r),sn.current=!0)}},[null==mn?void 0:mn.search,He,Le]);var fn=l(Ie);fn.current=Ie,u(function(){return function(){fn.current()}},[]),u(function(){var e;Ae&&w(((e={})[N.RULESET_ID]=Ae,e[N.SECTION]="learnings"===xe?null:xe,e))},[Ae,xe]),u(function(){var n;(null==be?void 0:be.learningManagement)&&X.getState().setLMSConfig(e(e({},be.learningManagement),{agents:null!==(n=be.agents)&&void 0!==n?n:{}}))},[be]);var vn=q(function(e){return e.fetchPermissions}),gn=q(function(e){return e.hasPermission}),hn=G(function(e){return e.setRoles}),Sn=M(function(e){return e.appsecRbacUrl})===de.appsecRbacUrl,yn=F(de.applicationId,Sn).data,bn=x(null!=me?me:"",ve),Cn=bn.isLoading,Tn=bn.isError,In=bn.refetch;bn.isSuccess;var An=c(0),Ln=An[0],En=An[1];u(function(){if(!ve&&me&&ae){t(se,void 0,void 0,function(){var e,n,t,o,s,i,a;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,C(me)];case 1:return e=r.sent(),(null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.ILInstanceId)&&Ee(e.data.ILInstanceId),"number"==typeof(n=null===(a=null===(i=null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.learningManagement)||void 0===i?void 0:i.scopeAndHierarchy)||void 0===a?void 0:a.maxHierarchyLevels)&&n>0&&En(n-1),[3,3];case 2:return t=r.sent(),console.error("Failed to fetch IL instance for hierarchy levels:",t),[3,3];case 3:return[2]}})})}},[me,ae]),u(function(){yn&&hn(yn.map(function(e){return{_id:e._id,name:e.name}}))},[yn,hn]),u(function(){var e;console.log("userDetails",ie),ln(ie),console.log("llmStudioUrl",ae),console.log("audacyBackendUrl",ce),M.getState().setLlmStudioUrl(ae),M.getState().setAudacyBackendUrl(ce),M.getState().setRbacConfig(de),M.getState().setAuditLogConfig(pe),M.getState().setBaseModeName((null==ye?void 0:ye.modeNameFromURL)||null),dn(ue),pn(le),f.getState().setAppIntegrationId(null!=me?me:null),f.getState().setBackwardCompatibility(ve),f.getState().setCognitiveCompareCompatibility(null!=he&&he),f.getState().setToken(null!==(e=null==ie?void 0:ie.accessToken)&&void 0!==e?e:null)},[ie,ln,ae,ce,de,pe,ue,dn,le,pn,me,ve,he,ye]),u(function(){(null==ie?void 0:ie.accessToken)&&ae&&b()},[me,null==ie?void 0:ie.accessToken,ae]);var Rn=function(n){return void 0===n&&(n=!0),t(se,void 0,void 0,function(){var t,o,s,i,a,c,l,u,d,p,m,v;return r(this,function(r){switch(r.label){case 0:n&&Ue(!0),Oe(null),r.label=1;case 1:return r.trys.push([1,7,8,9]),[4,vn(de.applicationId)];case 2:r.sent(),t=function(n){var r=q.getState().hasPermission("ilotj.scope.view",n.id),o=n.children?n.children.map(function(e){return t(e)}).filter(function(e){return null!==e}):[];return r||0!==o.length?e(e({},n),{hasAccess:r,children:o}):null},o=void 0,r.label=3;case 3:return r.trys.push([3,5,,6]),[4,T(me,ie.accessToken)];case 4:return o=r.sent(),[3,6];case 5:if(s=r.sent(),403===(null===(m=null==s?void 0:s.response)||void 0===m?void 0:m.status))return _e(null),Ke(de.applicationResourceId||null),Ye(!0),[2];throw s;case 6:return o&&o.data&&o.data.data&&(i=o.data.data,Array.isArray(i)&&(i=i.length>0?i[0]:null),i?(a=t(i))?(Ke(null),Ye(!1),_e({data:a}),on.current?(Le(on.current),He("learnings"),on.current=null):(c=f.getState().selectedRuleSetId,l=c?k(a,c):null,c&&l||(u=function(e){if(e.hasAccess)return e;for(var n=0,t=e.children||[];n<t.length;n++){var r=t[n],o=u(r);if(o)return o}return null},d=u(a),Le(d?d.id:a.id)))):(Ke(null!==(v=i.id)&&void 0!==v?v:null),Ye(!1),_e(null)):(Ke(null),Ye(!1),_e(null))),[3,9];case 7:return p=r.sent(),console.error("Failed to fetch rule sets or permissions",p),Oe("Failed to load data. Please try again later."),[3,9];case 8:return Ue(!1),[7];case 9:return[2]}})})};u(function(){var e;(null===(e=null==ie?void 0:ie.accessToken)||void 0===e?void 0:e.length)&&Sn?Rn(!0):console.warn("Error: Trying to fetch rules without access token",ie)},[null==ie?void 0:ie.accessToken,Oe,we,de.applicationId,Sn]);var On=function(n,o,s){return t(se,void 0,void 0,function(){var t,o,s,i,a,c,l,u;return r(this,function(r){switch(r.label){case 0:Ge(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,R(n,ie.accessToken)];case 2:return r.sent(),f.getState().selectedRuleSetId===n&&(t=f.getState().scopeTreeData,(o=D((null==t?void 0:t.data)||null,n))&&o.length>1&&(s=o[o.length-2],Le(s),He("learnings"))),[4,Rn(!0)];case 3:return r.sent(),ke(function(n){return e(e({},n),{isOpen:!1})}),null===(a=an.current)||void 0===a||a.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return i=r.sent(),console.error("An error occurred during scope deletion.",i),null===(c=an.current)||void 0===c||c.show({severity:"error",summary:"Delete Failed",detail:(null===(u=null===(l=null==i?void 0:i.response)||void 0===l?void 0:l.data)||void 0===u?void 0:u.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return Ge(!1),[7];case 6:return[2]}})})},wn=function(e,n){console.log("Section Selected:",{scopeId:e,sectionId:n}),He(n),Le(e),rn(!1)},Nn=Ne,_n=Xe?{data:{id:Xe.stationId,name:Xe.stationName,type:"STATION",metrics:{learningsCount:Xe.learningsCount,stationsCount:0},children:[]}}:Nn,jn=!!(null==_n?void 0:_n.data);null===(te=null==_n?void 0:_n.data)||void 0===te||te.type;var Dn=q(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",de.applicationResourceId||""),kn=function(e){return t(se,void 0,void 0,function(){var n,t,s,i,a,c,l,u,d,p;return r(this,function(r){switch(r.label){case 0:if(!(n="string"==typeof e?e:(null===(c=null===(a=f.getState().scopeTreeData)||void 0===a?void 0:a.data)||void 0===c?void 0:c.id)||ze)&&!We)return null===(l=an.current)||void 0===l||l.show({severity:"error",sticky:!1,className:g.errorToast,content:o(W,{message:"Unable to identify the global scope for this access request."})}),[2];en(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,O(n,We)];case 2:return r.sent(),rn(!0),null===(u=an.current)||void 0===u||u.show({severity:"success",sticky:!1,life:3e3,className:g.successToast,content:o(V,{message:"Access request submitted successfully!"})}),[3,5];case 3:return t=r.sent(),s=null===(d=null==t?void 0:t.response)||void 0===d?void 0:d.data,i="GLOBAL_SCOPE_NOT_FOUND"===(null==s?void 0:s.code)?"Unable to identify the global scope for this access request.":(null==s?void 0:s.detail)||(null==s?void 0:s.message)||"Failed to request access. Please try again.",null===(p=an.current)||void 0===p||p.show({severity:"error",sticky:!1,className:g.errorToast,content:o(W,{message:i})}),[3,5];case 4:return en(!1),[7];case 5:return[2]}})})};if(Cn)return o("div",e({className:g.learningManagementContainer},{children:o(Q,{})}));if(Tn)return o("div",e({className:g.learningManagementContainer},{children:o(z,{errorMessage:"Failed to load configuration. Please try again.",onRetry:function(){return In()},title:"Error Loading Configuration"})}));var Mn=n(n([{type:"GLOBAL",label:"Global",addChildLabel:"".concat(J("".concat(Z,".addScope"),"Add Scope")),addChildType:"SCOPE"}],Array.from({length:Ln},function(){return e({type:"SCOPE",label:J("".concat(Z,".scope"),"Scope")},!ve&&{addChildLabel:J("".concat($,".addSubScope"),"Add Subscope"),addChildType:"SUBSCOPE"})}),!0),ve?[]:[{type:"SUBSCOPE",label:J("".concat(Z,".subScope"),"Subscope")}],!0),Pn=Xe?Ce.filter(function(e){return"stations"!==e.id}):Ce;return o(U,{children:s("div",e({className:g.learningManagementContainer},{children:[o("div",e({className:g.mainWrapper},{children:Pe?o(j,{}):Re?s("div",e({className:g.errorContainer},{children:[o("div",e({className:g.errorTitle},{children:"Error Loading Data"})),o("p",e({className:g.errorDesc},{children:Re})),o("button",e({onClick:function(){return Rn(!0)},className:g.tryAgainBtn},{children:"Try Again"}))]})):jn?o(h,{onOpenCreateModal:function(){return ke({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,n,t){return ke({isOpen:!0,type:n,parentId:e,parentName:t})},onRenameChild:function(e,n){return ke({isOpen:!0,type:"RENAME",scopeId:e,initialName:n})},onDeleteChild:function(e,n,o){return t(se,void 0,void 0,function(){var t,s,i;return r(this,function(r){switch(r.label){case 0:return t=f.getState().scopeTreeData,s=D((null==t?void 0:t.data)||null,e),i=!!s&&3===s.length,0!==o?[3,2]:[4,On(e)];case 1:return r.sent(),[3,3];case 2:ke({isOpen:!0,type:"DELETE",scopeId:e,initialName:n,isSubscope:i}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return gn("ilotj.scope.delete",e)},canEditScope:function(e){return gn("ilotj.scope.edit",e)},canCreateScope:function(e){return gn("ilotj.scope.create",e)},onSectionSelect:wn,activeSectionId:xe,scopeTreeData:_n,sectionsConfig:Pn,onViewStation:function(e){wn(e.stationId,"learnings")},onRefreshRuleSets:function(e,n){void 0===e&&(e=!0),n&&(on.current=n),Rn(e)},nodeTypesConfig:Mn,app_integration_id:me,token:ie.accessToken,modeId:Se,onRequestAccess:kn,isRequestingAccess:$e,isAccessRequested:tn}):o(S,{onCreate:function(){return ke({isOpen:!0,type:"GLOBAL"})},title:J("".concat(ee,".title"),"No Global Scope has been added!"),desc:J("".concat(ee,".desc"),"Start by creating a Global scope to define base learnings that apply across all stations."),button:J("".concat(ee,".createGlobalScope"),"Create Global Scope"),canCreateRule:Dn,noAccessTitle:J("".concat(ee,".noAccessTitle"),"Access Restricted"),noAccessDesc:J("".concat(ee,".noAccessDesc"),"You do not have access for this application."),requestAccessButton:J("".concat(ee,".requestAccessButton"),"Request Access"),requestSentButton:J("".concat(ee,".requestSentButton"),"Request Sent"),onRequestAccess:kn,isRequestingAccess:$e,isAccessRequested:tn})})),o(v,{ref:an,pt:{root:{style:{zIndex:9999}}}}),ve&&De.isOpen&&"DELETE"!==De.type&&"RENAME"!==De.type?o(B,{isOpen:!0,onClose:function(){return ke(e(e({},De),{isOpen:!1}))},onSubmit:function(n){return t(se,void 0,void 0,function(){var t,o,s,i,a,c,l,u,d,p,m,v,g,h,S,y,b,C,T,E;return r(this,function(r){switch(r.label){case 0:Ge(!0),t=f.getState().backwardCompatibility,r.label=1;case 1:return r.trys.push([1,12,13,14]),o=void 0,t&&"object"==typeof n?o=n:(s=n,i="SCOPE"===De.type&&De.parentId,a=i?"genreRuleSet":De.type,o={topic:a,scope_reference_id:null,scopeDescription:"demo",parentScopeId:De.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:me}),[4,L(o,ie.accessToken)];case 2:if(c=r.sent(),!(l=null===(h=null==c?void 0:c.data)||void 0===h?void 0:h.scopeId))return[3,10];if(on.current=l,u=t&&(null===(S=o.topic)||void 0===S?void 0:S.toLowerCase().includes("genre")),d=!t&&"GLOBAL"!==De.type&&De.parentId,!u&&!d)return[3,10];if(!(p=t?null===(b=null===(y=f.getState().scopeTreeData)||void 0===y?void 0:y.data)||void 0===b?void 0:b.id:De.parentId))return[3,10];if(!ve)return[3,7];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,A({source_scope_id:p,target_scope_id:l})];case 4:return r.sent(),[3,6];case 5:return m=r.sent(),console.error("Failed to inherit rules for the new scope:",m),[3,6];case 6:return[3,10];case 7:return r.trys.push([7,9,,10]),[4,I({source_scope_id:p,target_scope_id:l,application_mapping_id:me||"",is_copy_parent_variant_id:!1})];case 8:return r.sent(),[3,10];case 9:return v=r.sent(),console.error("Failed to inherit rules for the new scope:",v),[3,10];case 10:return[4,Rn(!0)];case 11:return r.sent(),ke(function(n){return e(e({},n),{isOpen:!1})}),[3,14];case 12:throw g=r.sent(),console.error("An error occurred during scope creation.",g),null===(C=an.current)||void 0===C||C.show({severity:"error",summary:"Creation Failed",detail:(null===(E=null===(T=null==g?void 0:g.response)||void 0===T?void 0:T.data)||void 0===E?void 0:E.message)||"There was an error creating the scope. Please try again."}),g;case 13:return Ge(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:jn,canCreateGlobal:Dn,globalScopeId:null!==(oe=null===(re=null==Ne?void 0:Ne.data)||void 0===re?void 0:re.id)&&void 0!==oe?oe:null}):s(i,{children:[o(H,{isOpen:De.isOpen&&"DELETE"!==De.type&&"RENAME"!==De.type,onClose:function(){return ke(e(e({},De),{isOpen:!1}))},onCreate:function(e){e&&(on.current=e),Rn(!0)},hasGlobalRuleSet:jn,parentId:De.parentId}),o(Y,{isOpen:De.isOpen&&"RENAME"===De.type,onClose:function(){return ke(e(e({},De),{isOpen:!1}))},onSave:function(n){return t(se,void 0,void 0,function(){var t,s,i,a,c,l;return r(this,function(r){switch(r.label){case 0:Ge(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),De.scopeId?(t=f.getState().backwardCompatibility,s=t?{scope_id:De.scopeId,scope_name:n}:{scope_id:De.scopeId,scope_type:"Custom",scope_name:n,application_mapping_id:me},[4,E(s,ie.accessToken)]):[2];case 2:return r.sent(),[4,Rn(!0)];case 3:return r.sent(),ke(function(n){return e(e({},n),{isOpen:!1})}),[3,6];case 4:throw i=r.sent(),console.error("An error occurred during scope rename.",i),null===(a=an.current)||void 0===a||a.show({severity:"error",sticky:!1,className:g.errorToast,content:o(W,{message:(null===(l=null===(c=null==i?void 0:i.response)||void 0===c?void 0:c.data)||void 0===l?void 0:l.message)||"There was an error renaming the scope. Please try again."})}),i;case 5:return Ge(!1),[7];case 6:return[2]}})})},initialName:De.initialName})]}),o(_,{isOpen:De.isOpen&&"DELETE"===De.type,onCancel:function(){return ke(e(e({},De),{isOpen:!1}))},onConfirm:function(){return On(De.scopeId,De.initialName,De.isSubscope)},title:"Delete Scope",description:s(i,{children:["Deleting ",o("span",e({className:g.highlight},{children:De.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:qe})]}))})}export{ne as default};
1
+ import{__assign as e,__spreadArray as n,__awaiter as t,__generator as r}from"tslib";import{jsx as o,jsxs as s,Fragment as a}from"react/jsx-runtime";import{useCallback as i,useState as c,useRef as l,useEffect as u}from"react";import{BookOpen as d,Users as p,History as m}from"lucide-react";import{useLearningTemplateStore as f}from"./store/useLearningTemplateStore.js";import{Toast as v}from"primereact/toast";import g from"./styles/LearningTemplateManagement.module.css.js";import h from"./LearningTemplateLayout.js";import S from"./components/EmptyLearningState.js";import y from"./store/useAuthStore.js";import{fetchTiers as b,getILInstance as C,fetchScopes as T,inheritScope as I,inheritScopeBackwardCompatible as L,createRuleSet as A,renameScope as E,deleteRuleSet as R,requestAccess as O}from"./apis/scopeApis.js";import{setQueryParams as w,QUERY_PARAM_KEYS as N}from"./hooks/useLearningTemplateQueryParams.js";import _ from"./components/ConfirmationModal.js";import j from"./components/LearningTemplateManagementSkeleton.js";import{findNodePathById as D,findNodeById as k}from"./utils/treeUtils.js";import M from"./store/useEnvStore.js";import{useConfigStore as U}from"./store/useConfigStore.js";import{TooltipProvider as P}from"./components/ToolTip.js";import B from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as q}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as G}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as F}from"./queries/useApprovalQueries.js";import{useLMSConfigQuery as x}from"./queries/useLMSConfigQuery.js";import H from"./RuleContent/AddScopeModal.js";import Q from"./components/RuleContentSkeleton.js";import z from"./components/ErrorStateDisplay.js";import{useLocation as K}from"react-router-dom";import V from"./shared/SuccessToastContent.js";import W from"./shared/ErrorToastContent.js";import Y from"./RuleContent/RenameScopeModal.js";import{dt as J,useLMSConfigStore as X}from"./store/useLMSConfigStore.js";import{MIDDLE_DRAWER_DT_PATH as Z,MIDDLE_DRAWER_CONTEXT_MENU_DT_PATH as $,EMPTY_STATE_DT_PATH as ee}from"./constants.js";function ne(ne){var te,re,oe,se=this,ae=ne.userDetails,ie=ne.llmStudioUrl,ce=ne.audacyBackendUrl,le=ne.ilLabels,ue=ne.config,de=ne.rbacConfig,pe=ne.auditLogConfig,me=ne.app_integration_id,fe=ne.backwardCompatibility,ve=void 0!==fe&&fe,ge=ne.cognitiveCompareCompatibility,he=void 0!==ge&&ge,Se=ne.modeId,ye=ne.modeDetails,be=ne.pluginPayload,Ce=[{id:"learnings",label:J("".concat(Z,".treeMenu.submenu.learnings"),"Learnings"),icon:d,badgeKey:"learningsCount"},{id:"access",label:J("".concat(Z,".treeMenu.submenu.access"),"Access"),icon:p},{id:"history",label:J("".concat(Z,".treeMenu.submenu.changeHistory"),"Change History"),icon:m}],Te=new Set(Ce.map(function(e){return e.id})),Ie=i(function(){var e;w(((e={})[N.RULESET_ID]=null,e[N.SECTION]=null,e))},[]),Le=f(function(e){return e.selectedRuleSetId}),Ae=f(function(e){return e.setSelectedRuleSetId}),Ee=f(function(e){return e.setIlInstanceId}),Re=f(function(e){return e.error}),Oe=f(function(e){return e.setError}),we=f(function(e){return e.setStations}),Ne=f(function(e){return e.scopeTreeData}),_e=f(function(e){return e.setScopeTreeData}),je=c({isOpen:!1,type:"GLOBAL"}),De=je[0],ke=je[1],Me=c(!1),Ue=Me[0],Pe=Me[1],Be=c(!1),qe=Be[0],Ge=Be[1],Fe=c("learnings"),xe=Fe[0],He=Fe[1],Qe=c(null),ze=Qe[0],Ke=Qe[1],Ve=c(!1),We=Ve[0],Ye=Ve[1],Je=c(null),Xe=Je[0];Je[1];var Ze=c(!1),$e=Ze[0],en=Ze[1],nn=c(!1),tn=nn[0],rn=nn[1];l(null);var on=l(null),sn=l(!1),an=l(null),cn=y();cn.user;var ln=cn.setUser,un=U(),dn=un.setConfig,pn=un.setIlLabels,mn=function(){try{return K()}catch(e){return{search:""}}}();u(function(){if(!sn.current){var e=new URLSearchParams(window.location.search),n=e.get(N.RULESET_ID),t=e.get(N.SECTION),r=t&&(null==Te?void 0:Te.has(t))?t:"learnings";(null==n?void 0:n.length)&&Ae&&He&&(Ae(n),He(r),sn.current=!0)}},[null==mn?void 0:mn.search,He,Ae]);var fn=l(Ie);fn.current=Ie,u(function(){return function(){fn.current()}},[]),u(function(){var e;Le&&w(((e={})[N.RULESET_ID]=Le,e[N.SECTION]="learnings"===xe?null:xe,e))},[Le,xe]),u(function(){var n;(null==be?void 0:be.learningManagement)&&X.getState().setLMSConfig(e(e({},be.learningManagement),{agents:null!==(n=be.agents)&&void 0!==n?n:{}}))},[be]);var vn=q(function(e){return e.fetchPermissions}),gn=q(function(e){return e.hasPermission}),hn=G(function(e){return e.setRoles}),Sn=M(function(e){return e.appsecRbacUrl})===de.appsecRbacUrl,yn=F(de.applicationId,Sn).data,bn=x(null!=me?me:"",ve),Cn=bn.isLoading,Tn=bn.isError,In=bn.refetch;bn.isSuccess;var Ln=c(0),An=Ln[0],En=Ln[1];u(function(){if(!ve&&me&&ie){t(se,void 0,void 0,function(){var e,n,t,o,s,a,i;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,C(me)];case 1:return e=r.sent(),(null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.ILInstanceId)&&Ee(e.data.ILInstanceId),"number"==typeof(n=null===(i=null===(a=null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.learningManagement)||void 0===a?void 0:a.scopeAndHierarchy)||void 0===i?void 0:i.maxHierarchyLevels)&&n>0&&En(n-1),[3,3];case 2:return t=r.sent(),console.error("Failed to fetch IL instance for hierarchy levels:",t),[3,3];case 3:return[2]}})})}},[me,ie]),u(function(){yn&&hn(yn.map(function(e){return{_id:e._id,name:e.name}}))},[yn,hn]),u(function(){var e;console.log("userDetails",ae),ln(ae),console.log("llmStudioUrl",ie),console.log("audacyBackendUrl",ce),M.getState().setLlmStudioUrl(ie),M.getState().setAudacyBackendUrl(ce),M.getState().setRbacConfig(de),M.getState().setAuditLogConfig(pe),M.getState().setBaseModeName((null==ye?void 0:ye.modeNameFromURL)||null),dn(ue),pn(le),f.getState().setAppIntegrationId(null!=me?me:null),f.getState().setBackwardCompatibility(ve),f.getState().setCognitiveCompareCompatibility(null!=he&&he),f.getState().setToken(null!==(e=null==ae?void 0:ae.accessToken)&&void 0!==e?e:null)},[ae,ln,ie,ce,de,pe,ue,dn,le,pn,me,ve,he,ye]),u(function(){(null==ae?void 0:ae.accessToken)&&ie&&b()},[me,null==ae?void 0:ae.accessToken,ie]);var Rn=function(n){return void 0===n&&(n=!0),t(se,void 0,void 0,function(){var t,o,s,a,i,c,l,u,d,p,m,v;return r(this,function(r){switch(r.label){case 0:n&&Pe(!0),Oe(null),r.label=1;case 1:return r.trys.push([1,7,8,9]),[4,vn(de.applicationId)];case 2:r.sent(),t=function(n){var r=q.getState().hasPermission("ilotj.scope.view",n.id),o=n.children?n.children.map(function(e){return t(e)}).filter(function(e){return null!==e}):[];return r||0!==o.length?e(e({},n),{hasAccess:r,children:o}):null},o=void 0,r.label=3;case 3:return r.trys.push([3,5,,6]),[4,T(me,ae.accessToken)];case 4:return o=r.sent(),[3,6];case 5:if(s=r.sent(),403===(null===(m=null==s?void 0:s.response)||void 0===m?void 0:m.status))return _e(null),Ke(de.applicationResourceId||null),Ye(!0),[2];throw s;case 6:return o&&o.data&&o.data.data&&(a=o.data.data,Array.isArray(a)&&(a=a.length>0?a[0]:null),a?(i=t(a))?(Ke(null),Ye(!1),_e({data:i}),on.current?(Ae(on.current),He("learnings"),on.current=null):(c=f.getState().selectedRuleSetId,l=c?k(i,c):null,c&&l||(u=function(e){if(e.hasAccess)return e;for(var n=0,t=e.children||[];n<t.length;n++){var r=t[n],o=u(r);if(o)return o}return null},d=u(i),Ae(d?d.id:i.id)))):(Ke(null!==(v=a.id)&&void 0!==v?v:null),Ye(!1),_e(null)):(Ke(null),Ye(!1),_e(null))),[3,9];case 7:return p=r.sent(),console.error("Failed to fetch rule sets or permissions",p),Oe("Failed to load data. Please try again later."),[3,9];case 8:return Pe(!1),[7];case 9:return[2]}})})};u(function(){var e;(null===(e=null==ae?void 0:ae.accessToken)||void 0===e?void 0:e.length)&&Sn?Rn(!0):console.warn("Error: Trying to fetch rules without access token",ae)},[null==ae?void 0:ae.accessToken,Oe,we,de.applicationId,Sn]);var On=function(n,o,s){return t(se,void 0,void 0,function(){var t,o,s,a,i,c,l,u;return r(this,function(r){switch(r.label){case 0:Ge(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,R(n,ae.accessToken)];case 2:return r.sent(),f.getState().selectedRuleSetId===n&&(t=f.getState().scopeTreeData,(o=D((null==t?void 0:t.data)||null,n))&&o.length>1&&(s=o[o.length-2],Ae(s),He("learnings"))),[4,Rn(!0)];case 3:return r.sent(),ke(function(n){return e(e({},n),{isOpen:!1})}),null===(i=an.current)||void 0===i||i.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return a=r.sent(),console.error("An error occurred during scope deletion.",a),null===(c=an.current)||void 0===c||c.show({severity:"error",summary:"Delete Failed",detail:(null===(u=null===(l=null==a?void 0:a.response)||void 0===l?void 0:l.data)||void 0===u?void 0:u.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return Ge(!1),[7];case 6:return[2]}})})},wn=function(e,n){var t;console.log("Section Selected:",{scopeId:e,sectionId:n}),w(((t={})[N.RULESET_ID]=e,t[N.SECTION]="learnings"===n?null:n,t)),He(n),Ae(e),rn(!1)},Nn=Ne,_n=Xe?{data:{id:Xe.stationId,name:Xe.stationName,type:"STATION",metrics:{learningsCount:Xe.learningsCount,stationsCount:0},children:[]}}:Nn,jn=!!(null==_n?void 0:_n.data);null===(te=null==_n?void 0:_n.data)||void 0===te||te.type;var Dn=q(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",de.applicationResourceId||""),kn=function(e){return t(se,void 0,void 0,function(){var n,t,s,a,i,c,l,u,d,p;return r(this,function(r){switch(r.label){case 0:if(!(n="string"==typeof e?e:(null===(c=null===(i=f.getState().scopeTreeData)||void 0===i?void 0:i.data)||void 0===c?void 0:c.id)||ze)&&!We)return null===(l=an.current)||void 0===l||l.show({severity:"error",sticky:!1,className:g.errorToast,content:o(W,{message:"Unable to identify the global scope for this access request."})}),[2];en(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,O(n,We)];case 2:return r.sent(),rn(!0),null===(u=an.current)||void 0===u||u.show({severity:"success",sticky:!1,life:3e3,className:g.successToast,content:o(V,{message:"Access request submitted successfully!"})}),[3,5];case 3:return t=r.sent(),s=null===(d=null==t?void 0:t.response)||void 0===d?void 0:d.data,a="GLOBAL_SCOPE_NOT_FOUND"===(null==s?void 0:s.code)?"Unable to identify the global scope for this access request.":(null==s?void 0:s.detail)||(null==s?void 0:s.message)||"Failed to request access. Please try again.",null===(p=an.current)||void 0===p||p.show({severity:"error",sticky:!1,className:g.errorToast,content:o(W,{message:a})}),[3,5];case 4:return en(!1),[7];case 5:return[2]}})})};if(Cn)return o("div",e({className:g.learningManagementContainer},{children:o(Q,{})}));if(Tn)return o("div",e({className:g.learningManagementContainer},{children:o(z,{errorMessage:"Failed to load configuration. Please try again.",onRetry:function(){return In()},title:"Error Loading Configuration"})}));var Mn=n(n([{type:"GLOBAL",label:"Global",addChildLabel:"".concat(J("".concat(Z,".addScope"),"Add Scope")),addChildType:"SCOPE"}],Array.from({length:An},function(){return e({type:"SCOPE",label:J("".concat(Z,".scope"),"Scope")},!ve&&{addChildLabel:J("".concat($,".addSubScope"),"Add Subscope"),addChildType:"SUBSCOPE"})}),!0),ve?[]:[{type:"SUBSCOPE",label:J("".concat(Z,".subScope"),"Subscope")}],!0),Un=Xe?Ce.filter(function(e){return"stations"!==e.id}):Ce;return o(P,{children:s("div",e({className:g.learningManagementContainer},{children:[o("div",e({className:g.mainWrapper},{children:Ue?o(j,{}):Re?s("div",e({className:g.errorContainer},{children:[o("div",e({className:g.errorTitle},{children:"Error Loading Data"})),o("p",e({className:g.errorDesc},{children:Re})),o("button",e({onClick:function(){return Rn(!0)},className:g.tryAgainBtn},{children:"Try Again"}))]})):jn?o(h,{onOpenCreateModal:function(){return ke({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,n,t){return ke({isOpen:!0,type:n,parentId:e,parentName:t})},onRenameChild:function(e,n){return ke({isOpen:!0,type:"RENAME",scopeId:e,initialName:n})},onDeleteChild:function(e,n,o){return t(se,void 0,void 0,function(){var t,s,a;return r(this,function(r){switch(r.label){case 0:return t=f.getState().scopeTreeData,s=D((null==t?void 0:t.data)||null,e),a=!!s&&3===s.length,0!==o?[3,2]:[4,On(e)];case 1:return r.sent(),[3,3];case 2:ke({isOpen:!0,type:"DELETE",scopeId:e,initialName:n,isSubscope:a}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return gn("ilotj.scope.delete",e)},canEditScope:function(e){return gn("ilotj.scope.edit",e)},canCreateScope:function(e){return gn("ilotj.scope.create",e)},onSectionSelect:wn,activeSectionId:xe,scopeTreeData:_n,sectionsConfig:Un,onViewStation:function(e){wn(e.stationId,"learnings")},onRefreshRuleSets:function(e,n){void 0===e&&(e=!0),n&&(on.current=n),Rn(e)},nodeTypesConfig:Mn,app_integration_id:me,token:ae.accessToken,modeId:Se,onRequestAccess:kn,isRequestingAccess:$e,isAccessRequested:tn}):o(S,{onCreate:function(){return ke({isOpen:!0,type:"GLOBAL"})},title:J("".concat(ee,".title"),"No Global Scope has been added!"),desc:J("".concat(ee,".desc"),"Start by creating a Global scope to define base learnings that apply across all stations."),button:J("".concat(ee,".createGlobalScope"),"Create Global Scope"),canCreateRule:Dn,noAccessTitle:J("".concat(ee,".noAccessTitle"),"Access Restricted"),noAccessDesc:J("".concat(ee,".noAccessDesc"),"You do not have access for this application."),requestAccessButton:J("".concat(ee,".requestAccessButton"),"Request Access"),requestSentButton:J("".concat(ee,".requestSentButton"),"Request Sent"),onRequestAccess:kn,isRequestingAccess:$e,isAccessRequested:tn})})),o(v,{ref:an,pt:{root:{style:{zIndex:9999}}}}),ve&&De.isOpen&&"DELETE"!==De.type&&"RENAME"!==De.type?o(B,{isOpen:!0,onClose:function(){return ke(e(e({},De),{isOpen:!1}))},onSubmit:function(n){return t(se,void 0,void 0,function(){var t,o,s,a,i,c,l,u,d,p,m,v,g,h,S,y,b,C,T,E;return r(this,function(r){switch(r.label){case 0:Ge(!0),t=f.getState().backwardCompatibility,r.label=1;case 1:return r.trys.push([1,12,13,14]),o=void 0,t&&"object"==typeof n?o=n:(s=n,a="SCOPE"===De.type&&De.parentId,i=a?"genreRuleSet":De.type,o={topic:i,scope_reference_id:null,scopeDescription:"demo",parentScopeId:De.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:me}),[4,A(o,ae.accessToken)];case 2:if(c=r.sent(),!(l=null===(h=null==c?void 0:c.data)||void 0===h?void 0:h.scopeId))return[3,10];if(on.current=l,u=t&&(null===(S=o.topic)||void 0===S?void 0:S.toLowerCase().includes("genre")),d=!t&&"GLOBAL"!==De.type&&De.parentId,!u&&!d)return[3,10];if(!(p=t?null===(b=null===(y=f.getState().scopeTreeData)||void 0===y?void 0:y.data)||void 0===b?void 0:b.id:De.parentId))return[3,10];if(!ve)return[3,7];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,L({source_scope_id:p,target_scope_id:l})];case 4:return r.sent(),[3,6];case 5:return m=r.sent(),console.error("Failed to inherit rules for the new scope:",m),[3,6];case 6:return[3,10];case 7:return r.trys.push([7,9,,10]),[4,I({source_scope_id:p,target_scope_id:l,application_mapping_id:me||"",is_copy_parent_variant_id:!1})];case 8:return r.sent(),[3,10];case 9:return v=r.sent(),console.error("Failed to inherit rules for the new scope:",v),[3,10];case 10:return[4,Rn(!0)];case 11:return r.sent(),ke(function(n){return e(e({},n),{isOpen:!1})}),[3,14];case 12:throw g=r.sent(),console.error("An error occurred during scope creation.",g),null===(C=an.current)||void 0===C||C.show({severity:"error",summary:"Creation Failed",detail:(null===(E=null===(T=null==g?void 0:g.response)||void 0===T?void 0:T.data)||void 0===E?void 0:E.message)||"There was an error creating the scope. Please try again."}),g;case 13:return Ge(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:jn,canCreateGlobal:Dn,globalScopeId:null!==(oe=null===(re=null==Ne?void 0:Ne.data)||void 0===re?void 0:re.id)&&void 0!==oe?oe:null}):s(a,{children:[o(H,{isOpen:De.isOpen&&"DELETE"!==De.type&&"RENAME"!==De.type,onClose:function(){return ke(e(e({},De),{isOpen:!1}))},onCreate:function(e){e&&(on.current=e),Rn(!0)},hasGlobalRuleSet:jn,parentId:De.parentId}),o(Y,{isOpen:De.isOpen&&"RENAME"===De.type,onClose:function(){return ke(e(e({},De),{isOpen:!1}))},onSave:function(n){return t(se,void 0,void 0,function(){var t,s,a,i,c,l;return r(this,function(r){switch(r.label){case 0:Ge(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),De.scopeId?(t=f.getState().backwardCompatibility,s=t?{scope_id:De.scopeId,scope_name:n}:{scope_id:De.scopeId,scope_type:"Custom",scope_name:n,application_mapping_id:me},[4,E(s,ae.accessToken)]):[2];case 2:return r.sent(),[4,Rn(!0)];case 3:return r.sent(),ke(function(n){return e(e({},n),{isOpen:!1})}),[3,6];case 4:throw a=r.sent(),console.error("An error occurred during scope rename.",a),null===(i=an.current)||void 0===i||i.show({severity:"error",sticky:!1,className:g.errorToast,content:o(W,{message:(null===(l=null===(c=null==a?void 0:a.response)||void 0===c?void 0:c.data)||void 0===l?void 0:l.message)||"There was an error renaming the scope. Please try again."})}),a;case 5:return Ge(!1),[7];case 6:return[2]}})})},initialName:De.initialName})]}),o(_,{isOpen:De.isOpen&&"DELETE"===De.type,onCancel:function(){return ke(e(e({},De),{isOpen:!1}))},onConfirm:function(){return On(De.scopeId,De.initialName,De.isSubscope)},title:"Delete Scope",description:s(a,{children:["Deleting ",o("span",e({className:g.highlight},{children:De.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:qe})]}))})}export{ne as default};
2
2
  //# sourceMappingURL=LearningManagement.js.map
@@ -1,2 +1,2 @@
1
- import"tslib";import"react/jsx-runtime";import"react";import"lucide-react";import"./store/useLearningTemplateStore.js";import"primereact/toast";import"./apis/scopeApis.js";import"./store/usePermissionsStore.js";import"./store/useLMSConfigStore.js";import"./components/ToolTip.js";import"./store/useAuthStore.js";import"@mui/material";import"@mui/icons-material/Check";import"@mui/icons-material/CloseRounded";import{QueryClient as t}from"@tanstack/react-query";import"./store/useEnvStore.js";import"date-fns/format";import"date-fns/isValid";import"date-fns/parseISO";import"framer-motion";import"../IL-OTJ/_components/atoms/Textarea/Textarea.js";import"../IL-OTJ/_components/InputDataReasoningCard.js";import"../IL-OTJ/_components/TooltipComponent.js";import"../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js";import"../IL-OTJ/store/CitationsContext.js";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"axios";import"@e-llm-studio/streaming-response";import"@e-llm-studio/watch-me-work";import"../IL-OTJ/_components/ChatComponents/ChatHeader.js";import"remark-gfm";import"../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js";import"../IL-OTJ/_components/CitationLink.js";import"@e-llm-studio/citation";import"../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js";import"./store/useConfigStore.js";import"appsec-ui";import"react-dom";import"@radix-ui/react-tooltip";import"./components/StationOnboarding/InputField.js";import"./config.js";import"./store/useAppSecRolesStore.js";import"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import"./AuditLog/ChangeLogDiff.js";import"react-router-dom";import"./hooks/useLearningTemplateQueryParams.js";new t;
1
+ import"tslib";import"react/jsx-runtime";import"react";import"lucide-react";import"./store/useLearningTemplateStore.js";import"primereact/toast";import"./apis/scopeApis.js";import"./store/usePermissionsStore.js";import"./store/useLMSConfigStore.js";import"./components/ToolTip.js";import"./store/useAuthStore.js";import"@mui/material";import"@mui/icons-material/Check";import"@mui/icons-material/CloseRounded";import{QueryClient as t}from"@tanstack/react-query";import"./store/useEnvStore.js";import"date-fns/format";import"date-fns/isValid";import"date-fns/parseISO";import"framer-motion";import"../IL-OTJ/_components/atoms/Textarea/Textarea.js";import"../IL-OTJ/_components/InputDataReasoningCard.js";import"../IL-OTJ/_components/TooltipComponent.js";import"../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js";import"../IL-OTJ/store/CitationsContext.js";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"axios";import"@e-llm-studio/streaming-response";import"@e-llm-studio/watch-me-work";import"../IL-OTJ/_components/ChatComponents/ChatHeader.js";import"remark-gfm";import"../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js";import"../IL-OTJ/_components/CitationLink.js";import"@e-llm-studio/citation";import"../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js";import"./store/useConfigStore.js";import"appsec-ui";import"react-dom";import"@radix-ui/react-tooltip";import"./components/StationOnboarding/InputField.js";import"./config.js";import"./store/useAppSecRolesStore.js";import"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import"./AuditLog/ChangeLogDiff.js";import"./hooks/useLearningTemplateQueryParams.js";import"react-router-dom";new t;
2
2
  //# sourceMappingURL=LearningManagementTest.js.map
@@ -1,2 +1,2 @@
1
- import{__awaiter as e,__generator as t,__spreadArray as n,__assign as r}from"tslib";import{jsx as o,jsxs as i,Fragment as l}from"react/jsx-runtime";import{useRef as a,useState as s,useEffect as u}from"react";import{useLearningTemplateStore as c}from"../store/useLearningTemplateStore.js";import d from"../components/EmptyLearningState.js";import{getRulesInRuleSetById as p,exportRuleSet as m,deleteRule as f,deleteQuestion as v,alterQuestionPriority as g}from"../apis/scopeApis.js";import h from"../components/RuleContentSkeleton.js";import{Toast as T}from"primereact/toast";import y from"./ContentLogic.js";import w from"../components/ErrorStateDisplay.js";import S from"../shared/SuccessToastContent.js";import C from"../shared/ErrorToastContent.js";import{findNodeById as j}from"../utils/treeUtils.js";import R from"../styles/LearningContent.module.css.js";import b from"../components/ConfirmationModal.js";import{dt as I}from"../store/useLMSConfigStore.js";import"../../IL-OTJ/_components/atoms/Textarea/Textarea.js";import"lucide-react";import"../../IL-OTJ/_components/InputDataReasoningCard.js";import"../../IL-OTJ/_components/TooltipComponent.js";import"../../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js";import{CitationProvider as D}from"../../IL-OTJ/store/CitationsContext.js";import"@mui/material";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"axios";import"@e-llm-studio/streaming-response";import"@e-llm-studio/watch-me-work";import"../../IL-OTJ/_components/ChatComponents/ChatHeader.js";import"remark-gfm";import"../../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js";import"../../IL-OTJ/_components/CitationLink.js";import"@e-llm-studio/citation";import x from"../../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js";import{LEARNING_DT_PATH as _,VARIANT_DT_PATH as L,TIER_DT_PATH as k}from"../constants.js";import{useConfigStore as O}from"../store/useConfigStore.js";import"../store/usePermissionsStore.js";import"appsec-ui";import"../store/useAuthStore.js";import"../store/useEnvStore.js";import"react-dom";import"@radix-ui/react-tooltip";import"../components/StationOnboarding/InputField.js";import"../config.js";import"../store/useAppSecRolesStore.js";import"@tanstack/react-query";import"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import"../AuditLog/ChangeLogDiff.js";import"react-router-dom";import"../hooks/useLearningTemplateQueryParams.js";import"../components/ToolTip.js";import"../LearningManagementTest.js";var M=function(M){var A,N=M.noRulesTitle,E=void 0===N?"No rules have been added !":N,V=M.noRulesDesc,F=void 0===V?"Start by adding rules that should apply across all stations.":V,P=M.noRulesButtonText,B=void 0===P?"Create New Rule":P,J=M.deleteRuleSuccessMessage,U=void 0===J?"Rule deleted successfully!":J,W=M.deleteVariantSuccessMessage,q=void 0===W?"Variant deleted successfully!":W,G=M.deleteRuleErrorMessage,H=void 0===G?"Failed to delete rule. Please try again.":G,Q=M.deleteVariantErrorMessage,$=void 0===Q?"Failed to delete variant. Please try again.":Q,z=M.deleteModalTitle,K=void 0===z?"Delete":z,X=M.deleteRuleModalWarning,Y=void 0===X?"This will permanently delete the rule configuration.":X,Z=M.deleteVariantModalWarning,ee=void 0===Z?"This will permanently delete the variant configuration.":Z,te=M.deleteConfirmText,ne=void 0===te?"Delete":te,re=M.onRefreshRuleSets,oe=M.app_integration_id,ie=M.token,le=M.modeId,ae=c(function(e){return e.selectedRuleSetId}),se=c(function(e){return e.scopeTreeData}),ue=c(function(e){return e.sidebarTab}),ce=c(function(e){return e.setInitialRules}),de=c(function(e){return e.currentRules}),pe=c(function(e){return e.setRawAuditRuleData});c(function(e){return e.createdVariantInfo});var me=c(function(e){return e.resetCreatedVariantInfo}),fe=c(function(e){return e.isILModalTriggered}),ve=c(function(e){return e.setIsILModalTriggered}),ge=a(null),he=O.getState().configuration,Te=s(!1),ye=Te[0],we=Te[1],Se=s(null),Ce=Se[0],je=Se[1],Re=s(null),be=Re[0],Ie=Re[1],De=s(null),xe=De[0],_e=De[1],Le=s(null),ke=Le[0],Oe=Le[1],Me=s(!1),Ae=Me[0],Ne=Me[1],Ee=s(null),Ve=Ee[0],Fe=Ee[1],Pe=s(!1),Be=Pe[0],Je=Pe[1],Ue=s(""),We=Ue[0],qe=Ue[1],Ge=s(null),He=Ge[0],Qe=Ge[1],$e=s(!1),ze=$e[0],Ke=$e[1],Xe=s(!1),Ye=Xe[0],Ze=Xe[1],et=s("ruleDeletion"),tt=et[0],nt=et[1],rt=s(null),ot=rt[0],it=rt[1],lt=s(!1),at=lt[0],st=lt[1],ut=s(!1),ct=ut[0],dt=ut[1],pt=c.getState().tiers,mt=s(null),ft=mt[0],vt=mt[1],gt=s(null),ht=gt[0],Tt=gt[1],yt=s(null),wt=yt[0],St=yt[1],Ct=function(){je(null),Ie(null),we(!0),Oe(0)},jt=function(){we(!1),ve(!1),je(null),Ie(null),_e(null),Oe(null),Ze(!1),dt(!1),Rt(),vt(null),Tt(null),St(null),re&&re(!1,ae||void 0)};u(function(){Rt()},[ae,ce]),u(function(){fe&&we(!0)},[fe]);var Rt=function(o){return void 0===o&&(o=!1),e(void 0,void 0,void 0,function(){var e,i,l,a,s,u,d,m,f,v,g,h,T,y,w,S,C,j,R;return t(this,function(t){switch(t.label){case 0:if(!ae)return ce([]),[2];o||Ne(!0),Fe(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,p(ae,ie)];case 2:return e=t.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(pe(e),i=e.data,console.log("rulesData==",i),l=new Set(["ruleSetName","ruleSetDesc","created_at","updated_at","created_by","updated_by"]),a=Array.isArray(i.tiers)?n([],i.tiers,!0).sort(function(e,t){var n,r;return(null!==(n=e.tier_priority)&&void 0!==n?n:0)-(null!==(r=t.tier_priority)&&void 0!==r?r:0)}).map(function(e){return[e.name,e.value]}):Object.entries(i).filter(function(e){var t=e[0],n=e[1];return!l.has(t)&&Array.isArray(n)}),s=a.map(function(e){var t=e[1];return new Set(t.flatMap(function(e){var t,n;return null!==(n=null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return e.link_id}).filter(Boolean))&&void 0!==n?n:[]}))}),u=s.flatMap(function(e){return Array.from(e)}),d=u.reduce(function(e,t){var n;return e[t]=(null!==(n=e[t])&&void 0!==n?n:0)+1,e},{}),m=new Set(Object.entries(d).filter(function(e){return e[1]>1}).map(function(e){return e[0]})),f=function(e){return e.map(function(e){var t;return r(r({},e),{variants:null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return r(r({},e),{isLinked:!!e.link_id&&m.has(e.link_id)})})})})},v=a.map(function(e,t){var n,r=e[0],o=e[1],i=pt.find(function(e){return e.tier_name===r}),l=r.replace(/tier(\d+)/i,"tier_$1");return{id:null!==(n=null==i?void 0:i.tier_id)&&void 0!==n?n:String(t+1),name:l.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),ruleCount:o.length,description:0===t?"".concat(I("tier.subtitle","These are the system-wide learnings applied across all stations.")):"These learnings apply after higher-priority tiers and may refine or relax default behavior.",isOpen:0===t,rules:f(o)}}),(g=c.getState().createdVariantInfo)&&g.length>0?(h=Object.fromEntries(a.map(function(e,t){return[e[0],String(t+1)]})),T=new Set(g.map(function(e){return h[e.tierName]}).filter(Boolean)),y=v.map(function(e){return r(r({},e),{isOpen:e.isOpen||T.has(e.id)})}),ce(y),(w=null===(R=null===(j=null===(C=g[0])||void 0===C?void 0:C.variants)||void 0===j?void 0:j[0])||void 0===R?void 0:R.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(w,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return me()},1e4)},500):me()):ce(v),[3,5]):(ce([]),[2]);case 3:return S=t.sent(),console.error("Failed to fetch rule details",S),404!==(null==S?void 0:S.status)&&Fe((null==S?void 0:S.message)||"Failed to load rules. Please try again."),ce([]),[3,5];case 4:return o||Ne(!1),[7];case 5:return[2]}})})},bt=ae?j((null==se?void 0:se.data)||null,ae):null,It=bt?{ruleSetId:bt.id,ruleSetName:bt.name,ruleSetDesc:"",ruleCount:null===(A=null==bt?void 0:bt.metrics)||void 0===A?void 0:A.learningsCount}:void 0,Dt=Boolean(null==se?void 0:se.data),xt=Boolean(ae&&!bt&&Dt),_t=function(){if("stations"===ue)return"custom";if(!bt)return"global";switch(bt.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},Lt=function(e){var t;if(!e)return o("p",{children:I("".concat(k,".deleteDialog.description"),"Are you sure you want to delete this rule? This action cannot be undone.")});var n=null==de?void 0:de.flatMap(function(e){var t;return null!==(t=e.rules)&&void 0!==t?t:[]}).find(function(t){return t.ruleId===e});return o("p",{children:I("".concat(k,".deleteDialog.description"),"Are you sure you want to delete ".concat(null==n?void 0:n.ruleTitle," rule? This action cannot be undone."),{rule_title:null!==(t=null==n?void 0:n.ruleTitle)&&void 0!==t?t:""})})},kt={editingRule:Ce,editingTier:be,editingVariants:xe,focusedVariantIndex:ke,setFocusedVariantIndex:Oe,triggerAddVariant:Ye,triggerFixGaps:ct,copiedRule:ft,copiedSourceTier:ht,copiedTargetTier:wt,initialDraftMessage:We,app_integration_id:oe,modeId:le};return It?i(l,{children:[o(T,{ref:ge}),o("div",r({className:R.container},{children:Ae?o(h,{}):Ve?o(w,{errorMessage:Ve,onRetry:Rt}):o(y,{onAddRule:Ct,onDeleteRule:function(e){Qe(e)},onEditRule:function(e,t){je(e),Ie(t||null),_e(e.variants||null),Oe(null),Ze(!0),we(!0)},onEditVariant:function(e,t,n,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==de?void 0:de.find(function(e){return e.name===n}))||void 0===o?void 0:o.rules)||void 0===i?void 0:i.find(function(e){return e.ruleId===t}))&&void 0!==l?l:null==de?void 0:de.flatMap(function(e){return e.rules}).find(function(e){return e.ruleId===t});if(s){var u=null===(a=s.variants)||void 0===a?void 0:a.findIndex(function(t){return t.variantId===e.variantId}),c=void 0!==u&&-1!==u?u:0;je(s),Ie(n||null),_e(s.variants||null),Oe(c),we(!0),"resolve_gaps"===r&&dt(!0)}},onDeleteVariant:function(e,t){it({variantId:e,ruleId:t})},onExportRule:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l,a,s;return t(this,function(t){switch(t.label){case 0:if(!ae)return[2];Je(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,m(ae)];case 2:return e=t.sent(),n=window.URL.createObjectURL(e),(r=document.createElement("a")).href=n,i=(null==It?void 0:It.ruleSetName)?"".concat(It.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(ae,".csv"),r.download=i,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n),null===(a=ge.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=t.sent(),console.error("Export error:",l),null===(s=ge.current)||void 0===s||s.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Je(!1),[7];case 5:return[2]}})})},isExporting:Be,onToggleSuccess:function(){return Rt(!0)},onReorderRules:function(n,r,i,l,a){return e(void 0,void 0,void 0,function(){var e,s,u;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,g(n,r,i,l,a)];case 1:return t.sent(),Rt(!0),null===(s=ge.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:"Rule order changed successfully. Future rule applications will follow the updated order."})}),[3,3];case 2:return e=t.sent(),console.error("Failed to reorder rules:",e),Rt(!0),null===(u=ge.current)||void 0===u||u.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:re,setDeleteConfirmationUsedFor:nt,onCopyToTier:function(e,t,n,r,o){var i,l,a=null===(l=null===(i=null==de?void 0:de.find(function(e){return e.name===r}))||void 0===i?void 0:i.rules)||void 0===l?void 0:l.find(function(e){return e.ruleId===t});if(a){var s=["Add a new learning with the following details:","- Rule Title: ".concat(n),"- Description: ".concat(e.description),"- When to apply: ".concat(e.whenToApply),"- When NOT to apply: ".concat(e.whenNotToApply),"- Tier information: ".concat(o)].join("\n");qe(s),vt(a),Tt(r),St(o),je(null),Ie(null),_e(null),Oe(null),we(!0)}}})})),ye&&o(D,{children:o(x,{isOpen:ye,onClose:jt,app_integration_id:oe,token:ie,mode:"ADD",config:he,pluginPayload:r(r({},kt),{initialScope:_t(),ruleSet:It})})}),o(b,{isOpen:!!He,title:I("".concat(_,".deleteDialog.title"),K),description:Lt(He),warning:I("".concat(_,".deleteDialog.warningText"),Y),confirmText:I("".concat(_,".deleteDialog.deleteText"),ne),cancelText:I("".concat(_,".deleteDialog.cancelText"),"Cancel"),loadingText:I("".concat(_,".deleteDialog.loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l;return t(this,function(t){switch(t.label){case 0:if(!He)return[2];Ke(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,f(He)];case 2:return t.sent(),Qe(null),null===(n=ge.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:U})}),Rt(),re&&re(!1,ae||void 0),[3,5];case 3:return e=t.sent(),console.error("Failed to delete rule",e),null===(r=ge.current)||void 0===r||r.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:(null===(l=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===l?void 0:l.detail)||H})}),[3,5];case 4:return Ke(!1),[7];case 5:return[2]}})})},onCancel:function(){return Qe(null)},isLoading:ze}),o(b,{isOpen:!!ot,title:I("".concat(L,".deleteVariant.title"),K),description:"variantDeletion"===tt?o("span",{children:I("".concat(L,".deleteVariant.desc"),"Are you sure you want to delete this variant? This action cannot be undone.")}):Lt((null==ot?void 0:ot.ruleId)||null),warning:I("".concat(L,".deleteVariant.warningText"),"ruleDeletion"===tt?Y:ee),confirmText:I("".concat(L,".deleteDialog.deleteText"),ne),cancelText:I("".concat(L,".cancelText"),"Cancel"),loadingText:I("".concat(L,".loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l;return t(this,function(t){switch(t.label){case 0:if(!ot)return[2];st(!0),t.label=1;case 1:return t.trys.push([1,6,7,8]),"ruleDeletion"!==tt?[3,3]:[4,v(ot.ruleId)];case 2:return t.sent(),[3,5];case 3:return[4,f(ot.variantId)];case 4:t.sent(),t.label=5;case 5:return it(null),null===(n=ge.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:"ruleDeletion"===tt?U:q})}),Rt(),re&&re(!1,ae||void 0),[3,8];case 6:return e=t.sent(),console.error("Failed to delete variant",e),null===(r=ge.current)||void 0===r||r.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:(null===(l=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===l?void 0:l.detail)||("ruleDeletion"===tt?H:$)})}),[3,8];case 7:return st(!1),[7];case 8:return[2]}})})},onCancel:function(){return it(null)},isLoading:at})]}):xt?o(w,{title:"Scope Not Found",errorMessage:"The selected scope does not exist. Please refresh the page or choose a valid scope.",onRetry:function(){return null==re?void 0:re(!0)},retryButtonText:"Refresh"}):i(l,{children:[o(d,{onCreate:Ct,title:E,desc:F,button:B}),ye&&o(D,{children:o(x,{isOpen:ye,onClose:jt,app_integration_id:oe,token:ie,mode:"ADD",config:he,pluginPayload:r(r({},kt),{initialScope:_t(),ruleSet:It})})})]})};export{M as default};
1
+ import{__awaiter as e,__generator as t,__spreadArray as n,__assign as r}from"tslib";import{jsx as o,jsxs as i,Fragment as l}from"react/jsx-runtime";import{useRef as a,useState as s,useEffect as u}from"react";import{useLearningTemplateStore as c}from"../store/useLearningTemplateStore.js";import d from"../components/EmptyLearningState.js";import{getRulesInRuleSetById as p,exportRuleSet as m,deleteRule as f,deleteQuestion as v,alterQuestionPriority as g}from"../apis/scopeApis.js";import h from"../components/RuleContentSkeleton.js";import{Toast as T}from"primereact/toast";import y from"./ContentLogic.js";import w from"../components/ErrorStateDisplay.js";import S from"../shared/SuccessToastContent.js";import C from"../shared/ErrorToastContent.js";import{findNodeById as j}from"../utils/treeUtils.js";import R from"../styles/LearningContent.module.css.js";import b from"../components/ConfirmationModal.js";import{dt as I}from"../store/useLMSConfigStore.js";import"../../IL-OTJ/_components/atoms/Textarea/Textarea.js";import"lucide-react";import"../../IL-OTJ/_components/InputDataReasoningCard.js";import"../../IL-OTJ/_components/TooltipComponent.js";import"../../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js";import{CitationProvider as D}from"../../IL-OTJ/store/CitationsContext.js";import"@mui/material";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"axios";import"@e-llm-studio/streaming-response";import"@e-llm-studio/watch-me-work";import"../../IL-OTJ/_components/ChatComponents/ChatHeader.js";import"remark-gfm";import"../../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js";import"../../IL-OTJ/_components/CitationLink.js";import"@e-llm-studio/citation";import x from"../../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js";import{LEARNING_DT_PATH as _,VARIANT_DT_PATH as L,TIER_DT_PATH as k}from"../constants.js";import{useConfigStore as O}from"../store/useConfigStore.js";import"../store/usePermissionsStore.js";import"appsec-ui";import"../store/useAuthStore.js";import"../store/useEnvStore.js";import"react-dom";import"@radix-ui/react-tooltip";import"../components/StationOnboarding/InputField.js";import"../config.js";import"../store/useAppSecRolesStore.js";import"@tanstack/react-query";import"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import"../AuditLog/ChangeLogDiff.js";import"../hooks/useLearningTemplateQueryParams.js";import"../components/ToolTip.js";import"react-router-dom";import"../LearningManagementTest.js";var M=function(M){var A,N=M.noRulesTitle,E=void 0===N?"No rules have been added !":N,V=M.noRulesDesc,F=void 0===V?"Start by adding rules that should apply across all stations.":V,P=M.noRulesButtonText,B=void 0===P?"Create New Rule":P,J=M.deleteRuleSuccessMessage,U=void 0===J?"Rule deleted successfully!":J,W=M.deleteVariantSuccessMessage,q=void 0===W?"Variant deleted successfully!":W,G=M.deleteRuleErrorMessage,H=void 0===G?"Failed to delete rule. Please try again.":G,Q=M.deleteVariantErrorMessage,$=void 0===Q?"Failed to delete variant. Please try again.":Q,z=M.deleteModalTitle,K=void 0===z?"Delete":z,X=M.deleteRuleModalWarning,Y=void 0===X?"This will permanently delete the rule configuration.":X,Z=M.deleteVariantModalWarning,ee=void 0===Z?"This will permanently delete the variant configuration.":Z,te=M.deleteConfirmText,ne=void 0===te?"Delete":te,re=M.onRefreshRuleSets,oe=M.app_integration_id,ie=M.token,le=M.modeId,ae=c(function(e){return e.selectedRuleSetId}),se=c(function(e){return e.scopeTreeData}),ue=c(function(e){return e.sidebarTab}),ce=c(function(e){return e.setInitialRules}),de=c(function(e){return e.currentRules}),pe=c(function(e){return e.setRawAuditRuleData});c(function(e){return e.createdVariantInfo});var me=c(function(e){return e.resetCreatedVariantInfo}),fe=c(function(e){return e.isILModalTriggered}),ve=c(function(e){return e.setIsILModalTriggered}),ge=a(null),he=O.getState().configuration,Te=s(!1),ye=Te[0],we=Te[1],Se=s(null),Ce=Se[0],je=Se[1],Re=s(null),be=Re[0],Ie=Re[1],De=s(null),xe=De[0],_e=De[1],Le=s(null),ke=Le[0],Oe=Le[1],Me=s(!1),Ae=Me[0],Ne=Me[1],Ee=s(null),Ve=Ee[0],Fe=Ee[1],Pe=s(!1),Be=Pe[0],Je=Pe[1],Ue=s(""),We=Ue[0],qe=Ue[1],Ge=s(null),He=Ge[0],Qe=Ge[1],$e=s(!1),ze=$e[0],Ke=$e[1],Xe=s(!1),Ye=Xe[0],Ze=Xe[1],et=s("ruleDeletion"),tt=et[0],nt=et[1],rt=s(null),ot=rt[0],it=rt[1],lt=s(!1),at=lt[0],st=lt[1],ut=s(!1),ct=ut[0],dt=ut[1],pt=c.getState().tiers,mt=s(null),ft=mt[0],vt=mt[1],gt=s(null),ht=gt[0],Tt=gt[1],yt=s(null),wt=yt[0],St=yt[1],Ct=function(){je(null),Ie(null),we(!0),Oe(0)},jt=function(){we(!1),ve(!1),je(null),Ie(null),_e(null),Oe(null),Ze(!1),dt(!1),Rt(),vt(null),Tt(null),St(null),re&&re(!1,ae||void 0)};u(function(){Rt()},[ae,ce]),u(function(){fe&&we(!0)},[fe]);var Rt=function(o){return void 0===o&&(o=!1),e(void 0,void 0,void 0,function(){var e,i,l,a,s,u,d,m,f,v,g,h,T,y,w,S,C,j,R;return t(this,function(t){switch(t.label){case 0:if(!ae)return ce([]),[2];o||Ne(!0),Fe(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,p(ae,ie)];case 2:return e=t.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(pe(e),i=e.data,console.log("rulesData==",i),l=new Set(["ruleSetName","ruleSetDesc","created_at","updated_at","created_by","updated_by"]),a=Array.isArray(i.tiers)?n([],i.tiers,!0).sort(function(e,t){var n,r;return(null!==(n=e.tier_priority)&&void 0!==n?n:0)-(null!==(r=t.tier_priority)&&void 0!==r?r:0)}).map(function(e){return[e.name,e.value]}):Object.entries(i).filter(function(e){var t=e[0],n=e[1];return!l.has(t)&&Array.isArray(n)}),s=a.map(function(e){var t=e[1];return new Set(t.flatMap(function(e){var t,n;return null!==(n=null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return e.link_id}).filter(Boolean))&&void 0!==n?n:[]}))}),u=s.flatMap(function(e){return Array.from(e)}),d=u.reduce(function(e,t){var n;return e[t]=(null!==(n=e[t])&&void 0!==n?n:0)+1,e},{}),m=new Set(Object.entries(d).filter(function(e){return e[1]>1}).map(function(e){return e[0]})),f=function(e){return e.map(function(e){var t;return r(r({},e),{variants:null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return r(r({},e),{isLinked:!!e.link_id&&m.has(e.link_id)})})})})},v=a.map(function(e,t){var n,r=e[0],o=e[1],i=pt.find(function(e){return e.tier_name===r}),l=r.replace(/tier(\d+)/i,"tier_$1");return{id:null!==(n=null==i?void 0:i.tier_id)&&void 0!==n?n:String(t+1),name:l.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),ruleCount:o.length,description:0===t?"".concat(I("tier.subtitle","These are the system-wide learnings applied across all stations.")):"These learnings apply after higher-priority tiers and may refine or relax default behavior.",isOpen:0===t,rules:f(o)}}),(g=c.getState().createdVariantInfo)&&g.length>0?(h=Object.fromEntries(a.map(function(e,t){return[e[0],String(t+1)]})),T=new Set(g.map(function(e){return h[e.tierName]}).filter(Boolean)),y=v.map(function(e){return r(r({},e),{isOpen:e.isOpen||T.has(e.id)})}),ce(y),(w=null===(R=null===(j=null===(C=g[0])||void 0===C?void 0:C.variants)||void 0===j?void 0:j[0])||void 0===R?void 0:R.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(w,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return me()},1e4)},500):me()):ce(v),[3,5]):(ce([]),[2]);case 3:return S=t.sent(),console.error("Failed to fetch rule details",S),404!==(null==S?void 0:S.status)&&Fe((null==S?void 0:S.message)||"Failed to load rules. Please try again."),ce([]),[3,5];case 4:return o||Ne(!1),[7];case 5:return[2]}})})},bt=ae?j((null==se?void 0:se.data)||null,ae):null,It=bt?{ruleSetId:bt.id,ruleSetName:bt.name,ruleSetDesc:"",ruleCount:null===(A=null==bt?void 0:bt.metrics)||void 0===A?void 0:A.learningsCount}:void 0,Dt=Boolean(null==se?void 0:se.data),xt=Boolean(ae&&!bt&&Dt),_t=function(){if("stations"===ue)return"custom";if(!bt)return"global";switch(bt.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},Lt=function(e){var t;if(!e)return o("p",{children:I("".concat(k,".deleteDialog.description"),"Are you sure you want to delete this rule? This action cannot be undone.")});var n=null==de?void 0:de.flatMap(function(e){var t;return null!==(t=e.rules)&&void 0!==t?t:[]}).find(function(t){return t.ruleId===e});return o("p",{children:I("".concat(k,".deleteDialog.description"),"Are you sure you want to delete ".concat(null==n?void 0:n.ruleTitle," rule? This action cannot be undone."),{rule_title:null!==(t=null==n?void 0:n.ruleTitle)&&void 0!==t?t:""})})},kt={editingRule:Ce,editingTier:be,editingVariants:xe,focusedVariantIndex:ke,setFocusedVariantIndex:Oe,triggerAddVariant:Ye,triggerFixGaps:ct,copiedRule:ft,copiedSourceTier:ht,copiedTargetTier:wt,initialDraftMessage:We,app_integration_id:oe,modeId:le};return It?i(l,{children:[o(T,{ref:ge}),o("div",r({className:R.container},{children:Ae?o(h,{}):Ve?o(w,{errorMessage:Ve,onRetry:Rt}):o(y,{onAddRule:Ct,onDeleteRule:function(e){Qe(e)},onEditRule:function(e,t){je(e),Ie(t||null),_e(e.variants||null),Oe(null),Ze(!0),we(!0)},onEditVariant:function(e,t,n,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==de?void 0:de.find(function(e){return e.name===n}))||void 0===o?void 0:o.rules)||void 0===i?void 0:i.find(function(e){return e.ruleId===t}))&&void 0!==l?l:null==de?void 0:de.flatMap(function(e){return e.rules}).find(function(e){return e.ruleId===t});if(s){var u=null===(a=s.variants)||void 0===a?void 0:a.findIndex(function(t){return t.variantId===e.variantId}),c=void 0!==u&&-1!==u?u:0;je(s),Ie(n||null),_e(s.variants||null),Oe(c),we(!0),"resolve_gaps"===r&&dt(!0)}},onDeleteVariant:function(e,t){it({variantId:e,ruleId:t})},onExportRule:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l,a,s;return t(this,function(t){switch(t.label){case 0:if(!ae)return[2];Je(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,m(ae)];case 2:return e=t.sent(),n=window.URL.createObjectURL(e),(r=document.createElement("a")).href=n,i=(null==It?void 0:It.ruleSetName)?"".concat(It.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(ae,".csv"),r.download=i,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n),null===(a=ge.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=t.sent(),console.error("Export error:",l),null===(s=ge.current)||void 0===s||s.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Je(!1),[7];case 5:return[2]}})})},isExporting:Be,onToggleSuccess:function(){return Rt(!0)},onReorderRules:function(n,r,i,l,a){return e(void 0,void 0,void 0,function(){var e,s,u;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,g(n,r,i,l,a)];case 1:return t.sent(),Rt(!0),null===(s=ge.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:"Rule order changed successfully. Future rule applications will follow the updated order."})}),[3,3];case 2:return e=t.sent(),console.error("Failed to reorder rules:",e),Rt(!0),null===(u=ge.current)||void 0===u||u.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:re,setDeleteConfirmationUsedFor:nt,onCopyToTier:function(e,t,n,r,o){var i,l,a=null===(l=null===(i=null==de?void 0:de.find(function(e){return e.name===r}))||void 0===i?void 0:i.rules)||void 0===l?void 0:l.find(function(e){return e.ruleId===t});if(a){var s=["Add a new learning with the following details:","- Rule Title: ".concat(n),"- Description: ".concat(e.description),"- When to apply: ".concat(e.whenToApply),"- When NOT to apply: ".concat(e.whenNotToApply),"- Tier information: ".concat(o)].join("\n");qe(s),vt(a),Tt(r),St(o),je(null),Ie(null),_e(null),Oe(null),we(!0)}}})})),ye&&o(D,{children:o(x,{isOpen:ye,onClose:jt,app_integration_id:oe,token:ie,mode:"ADD",config:he,pluginPayload:r(r({},kt),{initialScope:_t(),ruleSet:It})})}),o(b,{isOpen:!!He,title:I("".concat(_,".deleteDialog.title"),K),description:Lt(He),warning:I("".concat(_,".deleteDialog.warningText"),Y),confirmText:I("".concat(_,".deleteDialog.deleteText"),ne),cancelText:I("".concat(_,".deleteDialog.cancelText"),"Cancel"),loadingText:I("".concat(_,".deleteDialog.loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l;return t(this,function(t){switch(t.label){case 0:if(!He)return[2];Ke(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,f(He)];case 2:return t.sent(),Qe(null),null===(n=ge.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:U})}),Rt(),re&&re(!1,ae||void 0),[3,5];case 3:return e=t.sent(),console.error("Failed to delete rule",e),null===(r=ge.current)||void 0===r||r.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:(null===(l=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===l?void 0:l.detail)||H})}),[3,5];case 4:return Ke(!1),[7];case 5:return[2]}})})},onCancel:function(){return Qe(null)},isLoading:ze}),o(b,{isOpen:!!ot,title:I("".concat(L,".deleteVariant.title"),K),description:"variantDeletion"===tt?o("span",{children:I("".concat(L,".deleteVariant.desc"),"Are you sure you want to delete this variant? This action cannot be undone.")}):Lt((null==ot?void 0:ot.ruleId)||null),warning:I("".concat(L,".deleteVariant.warningText"),"ruleDeletion"===tt?Y:ee),confirmText:I("".concat(L,".deleteDialog.deleteText"),ne),cancelText:I("".concat(L,".cancelText"),"Cancel"),loadingText:I("".concat(L,".loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l;return t(this,function(t){switch(t.label){case 0:if(!ot)return[2];st(!0),t.label=1;case 1:return t.trys.push([1,6,7,8]),"ruleDeletion"!==tt?[3,3]:[4,v(ot.ruleId)];case 2:return t.sent(),[3,5];case 3:return[4,f(ot.variantId)];case 4:t.sent(),t.label=5;case 5:return it(null),null===(n=ge.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:"ruleDeletion"===tt?U:q})}),Rt(),re&&re(!1,ae||void 0),[3,8];case 6:return e=t.sent(),console.error("Failed to delete variant",e),null===(r=ge.current)||void 0===r||r.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:(null===(l=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===l?void 0:l.detail)||("ruleDeletion"===tt?H:$)})}),[3,8];case 7:return st(!1),[7];case 8:return[2]}})})},onCancel:function(){return it(null)},isLoading:at})]}):xt?o(w,{title:"Scope Not Found",errorMessage:"The selected scope does not exist. Please refresh the page or choose a valid scope.",onRetry:function(){return null==re?void 0:re(!0)},retryButtonText:"Refresh"}):i(l,{children:[o(d,{onCreate:Ct,title:E,desc:F,button:B}),ye&&o(D,{children:o(x,{isOpen:ye,onClose:jt,app_integration_id:oe,token:ie,mode:"ADD",config:he,pluginPayload:r(r({},kt),{initialScope:_t(),ruleSet:It})})})]})};export{M as default};
2
2
  //# sourceMappingURL=RuleContent.js.map