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

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