@e-llm-studio/instant-learning 1.3.0-alpha.263 → 1.3.0-alpha.265

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("zustand").create(function(e){return{llmStudioUrl:"https://llmstudio.creativeworkspace.ai",audacyBackendUrl:null,appsecRbacUrl:null,appsecBaseUrl:null,rbacConfig:null,auditLogConfig:null,baseModeName:null,setLlmStudioUrl:function(a){return e({llmStudioUrl:a})},setAudacyBackendUrl:function(a){return e({audacyBackendUrl:a})},setRbacConfig:function(a){return e({rbacConfig:a,appsecRbacUrl:a.appsecRbacUrl,appsecBaseUrl:a.appsecBaseUrl})},setAuditLogConfig:function(a){return e({auditLogConfig:a})},setBaseModeName:function(a){return e({baseModeName:a})}}});exports.default=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("zustand").create(function(e){return{llmStudioUrl:"https://devllmstudio.creativeworkspace.ai",audacyBackendUrl:null,appsecRbacUrl:null,appsecBaseUrl:null,rbacConfig:null,auditLogConfig:null,baseModeName:null,setLlmStudioUrl:function(a){return e({llmStudioUrl:a})},setAudacyBackendUrl:function(a){return e({audacyBackendUrl:a})},setRbacConfig:function(a){return e({rbacConfig:a,appsecRbacUrl:a.appsecRbacUrl,appsecBaseUrl:a.appsecBaseUrl})},setAuditLogConfig:function(a){return e({auditLogConfig:a})},setBaseModeName:function(a){return e({baseModeName:a})}}});exports.default=e;
2
2
  //# sourceMappingURL=useEnvStore.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsx as t,jsxs as n,Fragment as a}from"react/jsx-runtime";import{useMemo as o,useEffect as i}from"react";import r from"./TeachMeWrapper.js";import l from"../../../plugins/ValueTypes/Default/DefaultTeachMeRenderer.js";import s from"../../../plugins/ValueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.js";import u from"../../../plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.js";import{useTeachMeConfigStore as d,useLMSConfigStore as c}from"../../LearningManagement/store/useLMSConfigStore.js";import{useLearningTemplateStore as m}from"../../LearningManagement/store/useLearningTemplateStore.js";import{useLMSConfigQuery as p}from"../../LearningManagement/queries/useLMSConfigQuery.js";import f from"../../LearningManagement/store/useAuthStore.js";import g from"../../LearningManagement/store/useEnvStore.js";import{QueryClient as v,QueryClientProvider as M,useQuery as h}from"@tanstack/react-query";import{fetchMarketplaceDomains as S}from"../../IL-marketplace/services/IL-marketplace.api.js";import{buildDynamicOptionsFromMarketplaceDomains as L}from"../../IL-marketplace/utils.js";import{fetchTiers as y,fetchRBACConfig as _}from"../../LearningManagement/apis/scopeApis.js";import{useConfigStore as C}from"../../LearningManagement/store/useConfigStore.js";import{useExternalWorkflowStore as R}from"../../LearningManagement/store/useExternalWorkflowStore.js";import k from"../../../ContinueWithTemplateModal.js";import{useILMarketplaceThemeStyles as T,getILMarketplaceThemeStyles as j,ILMarketplaceThemeProvider as D}from"../../IL-marketplace/marketplaceTheme.js";var I={Default:l,"Radio Traffic Learning":s,Guidelines:u},U=new v,b=function(n){var a=T(),i=o(function(){return n.theme?j(n.theme):a},[n.theme,a]);return t(D,e({theme:n.theme},{children:t(M,e({client:U},{children:t("div",e({style:i},{children:t(E,e({},n))}))}))}))},E=function(l){var s,u=l.app_integration_id,v=l.content_type_id,M=l.isOpen,T=l.onClose,j=l.pluginPayload,D=l.token,U=l.mode,b=l.config,E=l.useDynamicForm,x=l.enableChatLogs,w=l.externalWorkflowMetaData,A=l.setSendMessageInChat,B=l.triggerValidateMessage,W=l.isMarketPlace,O=l.renderContinueModal,V=void 0===O||O,q=d(function(e){return e.setTeachMeConfig});d(function(e){return e.clearTeachMeConfig});var G=c(function(e){return e.setLMSConfig});c(function(e){return e.lmsConfig});var P=C().setConfig,F=R(function(e){return e.setExternalWorkflowMetaData});R(function(e){return e.openContinueModal});var N=m(function(e){return e.tiers});i(function(){var t,n;P(b),f.getState().setUser(e(e({},f.getState().user),{accessToken:D})),g.getState().setLlmStudioUrl(null==b?void 0:b.BASE_URL),m.getState().setAppIntegrationId(null!=u?u:""),m.getState().setSelectedRuleSetId(null!==(n=null===(t=null==j?void 0:j.ruleSet)||void 0===t?void 0:t.ruleSetId)&&void 0!==n?n:null),D&&(null==b?void 0:b.BASE_URL)&&(0!==N.length||(null==j?void 0:j.tiers)||y(),u&&!g.getState().rbacConfig&&_(u,D).then(function(e){var t,n,a,o,i,r,l,s,u,d;if(e){var c=g.getState();c.setRbacConfig({applicationName:null!==(t=e.application_name)&&void 0!==t?t:"",applicationId:null!==(n=e.application_id)&&void 0!==n?n:"",moduleId:null!==(o=null===(a=e.module_data)||void 0===a?void 0:a.Scopes)&&void 0!==o?o:"",applicationModuleId:null!==(r=null===(i=e.module_data)||void 0===i?void 0:i.General)&&void 0!==r?r:"",applicationResourceId:null!==(s=null===(l=e.resource_data)||void 0===l?void 0:l["Learning Management"])&&void 0!==s?s:"",appsecRbacUrl:null!==(u=c.appsecRbacUrl)&&void 0!==u?u:"",appsecBaseUrl:null!==(d=c.appsecBaseUrl)&&void 0!==d?d:""})}}).catch(function(e){console.error("Error fetching RBAC config for TeachMePlugin:",e)}))},[u,D,null==b?void 0:b.BASE_URL]),null==j||j.teachMe;var K=p(null!=u?u:"",!1,!0,v);K.isLoading,K.isError,K.refetch,K.isSuccess,i(function(){var t,n,a;if(null==j?void 0:j.teachMe){var o=j.teachMe;o.teachMe&&q(o.teachMe),o.template&&m.getState().setTemplateData(null!=u?u:"",o.template),o.learningManagement&&G(e(e({},o.learningManagement),{agents:null!==(t=o.agents)&&void 0!==t?t:{},externalWorkflowMetaData:null!==(a=null===(n=o.teachMe)||void 0===n?void 0:n.externalWorkflowMetaData)&&void 0!==a?a:{enableExternalWorkflow:!1,current_mode:"",sub_mode:"",next_mode:"",externalWorkflowModal:{heading:"",options:{saveDraft:{title:"",desc:"",footerDesc:""},configureNow:{title:"",desc:"",footerDesc:""}}}}}))}(null==j?void 0:j.tiers)&&m.getState().setTiers(j.tiers)},[j]),i(function(){w&&F(w)},[w,F]);var Q=h({queryKey:["teachme-marketplace-domains",u],queryFn:function(){return S(u,D,null==b?void 0:b.BASE_URL)},enabled:Boolean(W&&u)}).data,z=o(function(){var e,t;if(!W)return null==j?void 0:j.dynamicOptions;var n=L(null===(t=null===(e=null==Q?void 0:Q.responseData)||void 0===e?void 0:e.data)||void 0===t?void 0:t.data);return n.categoryOptions.length?n:null==j?void 0:j.dynamicOptions},[W,Q,null==j?void 0:j.dynamicOptions]);return n(a,{children:[t(r,{app_integration_id:u,content_type_id:v,isOpen:M,onClose:T,token:D,templateRegistry:I,baseURL:null==b?void 0:b.BASE_URL,initialScope:null!==(s=null==j?void 0:j.initialScope)&&void 0!==s?s:"",ruleSet:null==j?void 0:j.ruleSet,useDynamicForm:E,enableChatLogs:x,pluginPayload:e(e({},j),{dynamicOptions:z,mode:U,triggerValidateMessage:B}),setSendMessageInChat:A}),V&&t(k,{})]})};export{I as TemplateRegistry,b as default};
1
+ import{__assign as e}from"tslib";import{jsx as n,jsxs as t,Fragment as a}from"react/jsx-runtime";import{useMemo as o,useEffect as r}from"react";import i from"./TeachMeWrapper.js";import l from"../../../plugins/ValueTypes/Default/DefaultTeachMeRenderer.js";import s from"../../../plugins/ValueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.js";import u from"../../../plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.js";import{useTeachMeConfigStore as d,useLMSConfigStore as c}from"../../LearningManagement/store/useLMSConfigStore.js";import{useLearningTemplateStore as m}from"../../LearningManagement/store/useLearningTemplateStore.js";import{useLMSConfigQuery as p}from"../../LearningManagement/queries/useLMSConfigQuery.js";import g from"../../LearningManagement/store/useAuthStore.js";import f from"../../LearningManagement/store/useEnvStore.js";import{QueryClient as v,QueryClientProvider as M,useQuery as h}from"@tanstack/react-query";import{fetchMarketplaceDomains as S}from"../../IL-marketplace/services/IL-marketplace.api.js";import{buildDynamicOptionsFromMarketplaceDomains as L}from"../../IL-marketplace/utils.js";import{fetchTiers as y,fetchRBACConfig as _}from"../../LearningManagement/apis/scopeApis.js";import{useConfigStore as C}from"../../LearningManagement/store/useConfigStore.js";import{useExternalWorkflowStore as R}from"../../LearningManagement/store/useExternalWorkflowStore.js";import T from"../../../ContinueWithTemplateModal.js";import{useILMarketplaceThemeStyles as k,getILMarketplaceThemeStyles as j,ILMarketplaceThemeProvider as I}from"../../IL-marketplace/marketplaceTheme.js";var D={Default:l,"Radio Traffic Learning":s,Guidelines:u},U=new v,b=function(t){var a=k(),r=o(function(){return t.theme?j(t.theme):a},[t.theme,a]);return n(I,e({theme:t.theme},{children:n(M,e({client:U},{children:n("div",e({style:r},{children:n(E,e({},t))}))}))}))},E=function(l){var s,u=l.app_integration_id,v=l.content_type_id,M=l.isOpen,k=l.onClose,j=l.pluginPayload,I=l.token,U=l.mode,b=l.config,E=l.useDynamicForm,x=l.enableChatLogs,w=l.externalWorkflowMetaData,A=l.setSendMessageInChat,B=l.triggerValidateMessage,W=l.isMarketPlace,O=l.renderContinueModal,P=void 0===O||O;console.log("TeachMePluginInner: props");var V=d(function(e){return e.setTeachMeConfig});d(function(e){return e.clearTeachMeConfig});var q=c(function(e){return e.setLMSConfig});c(function(e){return e.lmsConfig});var G=C().setConfig,F=R(function(e){return e.setExternalWorkflowMetaData});R(function(e){return e.openContinueModal});var N=m(function(e){return e.tiers});r(function(){var n,t;G(b),g.getState().setUser(e(e({},g.getState().user),{accessToken:I})),f.getState().setLlmStudioUrl(null==b?void 0:b.BASE_URL),m.getState().setAppIntegrationId(null!=u?u:""),m.getState().setSelectedRuleSetId(null!==(t=null===(n=null==j?void 0:j.ruleSet)||void 0===n?void 0:n.ruleSetId)&&void 0!==t?t:null),I&&(null==b?void 0:b.BASE_URL)&&(0!==N.length||(null==j?void 0:j.tiers)||y(),u&&!f.getState().rbacConfig&&_(u,I).then(function(e){var n,t,a,o,r,i,l,s,u,d;if(e){var c=f.getState();c.setRbacConfig({applicationName:null!==(n=e.application_name)&&void 0!==n?n:"",applicationId:null!==(t=e.application_id)&&void 0!==t?t:"",moduleId:null!==(o=null===(a=e.module_data)||void 0===a?void 0:a.Scopes)&&void 0!==o?o:"",applicationModuleId:null!==(i=null===(r=e.module_data)||void 0===r?void 0:r.General)&&void 0!==i?i:"",applicationResourceId:null!==(s=null===(l=e.resource_data)||void 0===l?void 0:l["Learning Management"])&&void 0!==s?s:"",appsecRbacUrl:null!==(u=c.appsecRbacUrl)&&void 0!==u?u:"",appsecBaseUrl:null!==(d=c.appsecBaseUrl)&&void 0!==d?d:""})}}).catch(function(e){console.error("Error fetching RBAC config for TeachMePlugin:",e)}))},[u,I,null==b?void 0:b.BASE_URL]),null==j||j.teachMe;var K=p(null!=u?u:"",!1,!0,v);K.isLoading,K.isError,K.refetch,K.isSuccess,r(function(){var n,t,a;if(null==j?void 0:j.teachMe){var o=j.teachMe;o.teachMe&&V(o.teachMe),o.template&&m.getState().setTemplateData(null!=u?u:"",o.template),o.learningManagement&&q(e(e({},o.learningManagement),{agents:null!==(n=o.agents)&&void 0!==n?n:{},externalWorkflowMetaData:null!==(a=null===(t=o.teachMe)||void 0===t?void 0:t.externalWorkflowMetaData)&&void 0!==a?a:{enableExternalWorkflow:!1,current_mode:"",sub_mode:"",next_mode:"",externalWorkflowModal:{heading:"",options:{saveDraft:{title:"",desc:"",footerDesc:""},configureNow:{title:"",desc:"",footerDesc:""}}}}}))}(null==j?void 0:j.tiers)&&m.getState().setTiers(j.tiers)},[j]),r(function(){w&&F(w)},[w,F]);var Q=h({queryKey:["teachme-marketplace-domains",u],queryFn:function(){return S(u,I,null==b?void 0:b.BASE_URL)},enabled:Boolean(W&&u)}).data,z=o(function(){var e,n;if(!W)return null==j?void 0:j.dynamicOptions;var t=L(null===(n=null===(e=null==Q?void 0:Q.responseData)||void 0===e?void 0:e.data)||void 0===n?void 0:n.data);return t.categoryOptions.length?t:null==j?void 0:j.dynamicOptions},[W,Q,null==j?void 0:j.dynamicOptions]);return t(a,{children:[n(i,{app_integration_id:u,content_type_id:v,isOpen:M,onClose:k,token:I,templateRegistry:D,baseURL:null==b?void 0:b.BASE_URL,initialScope:null!==(s=null==j?void 0:j.initialScope)&&void 0!==s?s:"",ruleSet:null==j?void 0:j.ruleSet,useDynamicForm:E,enableChatLogs:x,pluginPayload:e(e({},j),{dynamicOptions:z,mode:U,triggerValidateMessage:B}),setSendMessageInChat:A}),P&&n(T,{})]})};export{D as TemplateRegistry,b as default};
2
2
  //# sourceMappingURL=TeachMePlugin.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 j from"../shared/ErrorToastContent.js";import{findNodeById as C}from"../utils/treeUtils.js";import I from"../styles/LearningContent.module.css.js";import b from"../components/ConfirmationModal.js";import{dt as R}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 x}from"../../IL-OTJ/store/CitationsContext.js";import"@mui/material";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"../../../api/transport.js";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 D from"../../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js";import L from"../../../ContinueWithTemplateModal.js";import{LEARNING_DT_PATH as _,VARIANT_DT_PATH as k,TIER_DT_PATH as M}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"../../IL-marketplace/marketplaceTheme.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"../../IL-marketplace/components/GuidelineIconButton.js";import"@e-llm-studio/federated-dashboard-components";import"@e-llm-studio/federated-dashboard-components/styles.css";import"../hooks/useLearningTemplateQueryParams.js";import"../components/ToolTip.js";import"../../../ILMarketplaceWrapper.js";import"../LearningManagementTest.js";var A=function(A){var N,E=A.noRulesTitle,V=void 0===E?"No rules have been added !":E,F=A.noRulesDesc,P=void 0===F?"Start by adding rules that should apply across all stations.":F,B=A.noRulesButtonText,J=void 0===B?"Create New Rule":B,U=A.deleteRuleSuccessMessage,W=void 0===U?"Rule deleted successfully!":U,G=A.deleteVariantSuccessMessage,q=void 0===G?"Variant deleted successfully!":G,H=A.deleteRuleErrorMessage,Q=void 0===H?"Failed to delete rule. Please try again.":H,$=A.deleteVariantErrorMessage,z=void 0===$?"Failed to delete variant. Please try again.":$,K=A.deleteModalTitle,X=void 0===K?"Delete":K,Y=A.deleteRuleModalWarning,Z=void 0===Y?"This will permanently delete the rule configuration.":Y,ee=A.deleteVariantModalWarning,te=void 0===ee?"This will permanently delete the variant configuration.":ee,ne=A.deleteConfirmText,re=void 0===ne?"Delete":ne,oe=A.onRefreshRuleSets,ie=A.app_integration_id,le=A.token,ae=A.modeId,se=c(function(e){return e.selectedRuleSetId}),ue=c(function(e){return e.scopeTreeData}),ce=c(function(e){return e.sidebarTab}),de=c(function(e){return e.setInitialRules}),pe=c(function(e){return e.currentRules}),me=c(function(e){return e.setRawAuditRuleData});c(function(e){return e.createdVariantInfo});var fe=c(function(e){return e.resetCreatedVariantInfo}),ve=c(function(e){return e.isILModalTriggered}),ge=c(function(e){return e.setIsILModalTriggered}),he=a(null),Te=O.getState().configuration,ye=s(!1),we=ye[0],Se=ye[1],je=s(null),Ce=je[0],Ie=je[1],be=s(null),Re=be[0],xe=be[1],De=s(null),Le=De[0],_e=De[1],ke=s(null),Me=ke[0],Oe=ke[1],Ae=s(!1),Ne=Ae[0],Ee=Ae[1],Ve=s(null),Fe=Ve[0],Pe=Ve[1],Be=s(!1),Je=Be[0],Ue=Be[1],We=s(""),Ge=We[0],qe=We[1],He=s(null),Qe=He[0],$e=He[1],ze=s(!1),Ke=ze[0],Xe=ze[1],Ye=s(!1),Ze=Ye[0],et=Ye[1],tt=s("ruleDeletion"),nt=tt[0],rt=tt[1],ot=s(null),it=ot[0],lt=ot[1],at=s(!1),st=at[0],ut=at[1],ct=s(!1),dt=ct[0],pt=ct[1],mt=c.getState().tiers,ft=s(null),vt=ft[0],gt=ft[1],ht=s(null),Tt=ht[0],yt=ht[1],wt=s(null),St=wt[0],jt=wt[1],Ct=function(){Ie(null),_e(null),xe(null),gt(null),yt(null),jt(null),qe(""),Se(!0),Oe(0)},It=function(){Se(!1),ge(!1),Ie(null),xe(null),_e(null),Oe(null),et(!1),pt(!1),bt(),gt(null),yt(null),jt(null),qe(""),oe&&oe(!1,se||void 0)};u(function(){bt()},[se,de]),u(function(){ve&&Se(!0)},[ve]);var bt=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,j,C,I;return t(this,function(t){switch(t.label){case 0:if(!se)return de([]),[2];o||Ee(!0),Pe(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,p(se,le)];case 2:return e=t.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(me(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=mt.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(R("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)})}),de(y),(w=null===(I=null===(C=null===(j=g[0])||void 0===j?void 0:j.variants)||void 0===C?void 0:C[0])||void 0===I?void 0:I.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(w,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return fe()},1e4)},500):fe()):de(v),[3,5]):(de([]),[2]);case 3:return S=t.sent(),console.error("Failed to fetch rule details",S),404!==(null==S?void 0:S.status)&&Pe((null==S?void 0:S.message)||"Failed to load rules. Please try again."),de([]),[3,5];case 4:return o||Ee(!1),[7];case 5:return[2]}})})},Rt=se?C((null==ue?void 0:ue.data)||null,se):null,xt=Rt?{ruleSetId:Rt.id,ruleSetName:Rt.name,ruleSetDesc:"",ruleCount:null===(N=null==Rt?void 0:Rt.metrics)||void 0===N?void 0:N.learningsCount}:void 0,Dt=Boolean(null==ue?void 0:ue.data),Lt=Boolean(se&&!Rt&&Dt),_t=function(){if("stations"===ce)return"custom";if(!Rt)return"global";switch(Rt.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},kt=function(e){var t;if(!e)return o("p",{children:R("".concat(M,".deleteDialog.description"),"Are you sure you want to delete this rule? This action cannot be undone.")});var n=null==pe?void 0:pe.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:R("".concat(M,".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:""})})},Mt={editingRule:Ce,editingTier:Re,editingVariants:Le,focusedVariantIndex:Me,setFocusedVariantIndex:Oe,triggerAddVariant:Ze,triggerFixGaps:dt,copiedRule:vt,copiedSourceTier:Tt,copiedTargetTier:St,initialDraftMessage:Ge,app_integration_id:ie,modeId:ae};return xt?i(l,{children:[o(T,{ref:he}),o("div",r({className:I.container},{children:Ne?o(h,{}):Fe?o(w,{errorMessage:Fe,onRetry:bt}):o(y,{onAddRule:Ct,onDeleteRule:function(e){$e(e)},onEditRule:function(e,t){Ie(e),xe(t||null),_e(e.variants||null),Oe(null),et(!0),Se(!0)},onEditVariant:function(e,t,n,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==pe?void 0:pe.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==pe?void 0:pe.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;Ie(s),xe(n||null),_e(s.variants||null),Oe(c),Se(!0),"resolve_gaps"===r&&pt(!0)}},onDeleteVariant:function(e,t){lt({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(!se)return[2];Ue(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,m(se)];case 2:return e=t.sent(),n=window.URL.createObjectURL(e),(r=document.createElement("a")).href=n,i=(null==xt?void 0:xt.ruleSetName)?"".concat(xt.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(se,".csv"),r.download=i,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n),null===(a=he.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:I.successToast,content:o(S,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=t.sent(),console.error("Export error:",l),null===(s=he.current)||void 0===s||s.show({severity:"error",sticky:!1,className:I.errorToast,content:o(j,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Ue(!1),[7];case 5:return[2]}})})},isExporting:Je,onToggleSuccess:function(){return bt(!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(),bt(!0),null===(s=he.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:I.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),bt(!0),null===(u=he.current)||void 0===u||u.show({severity:"error",sticky:!1,className:I.errorToast,content:o(j,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:oe,setDeleteConfirmationUsedFor:rt,onCopyToTier:function(e,t,n,r,o){var i,l,a=null===(l=null===(i=null==pe?void 0:pe.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),gt(a),yt(r),jt(o),Ie(null),xe(null),_e(null),Oe(null),Se(!0)}}})})),we&&o(x,{children:o(D,{isOpen:we,onClose:It,app_integration_id:ie,token:le,mode:"ADD",config:Te,pluginPayload:r(r({},Mt),{initialScope:_t(),ruleSet:xt}),renderContinueModal:!1})}),o(L,{}),o(b,{isOpen:!!Qe,title:R("".concat(_,".deleteDialog.title"),X),description:kt(Qe),warning:R("".concat(_,".deleteDialog.warningText"),Z),confirmText:R("".concat(_,".deleteDialog.deleteText"),re),cancelText:R("".concat(_,".deleteDialog.cancelText"),"Cancel"),loadingText:R("".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(!Qe)return[2];Xe(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,f(Qe)];case 2:return t.sent(),$e(null),null===(n=he.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:I.successToast,content:o(S,{message:W})}),bt(),oe&&oe(!1,se||void 0),[3,5];case 3:return e=t.sent(),console.error("Failed to delete rule",e),null===(r=he.current)||void 0===r||r.show({severity:"error",sticky:!1,className:I.errorToast,content:o(j,{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)||Q})}),[3,5];case 4:return Xe(!1),[7];case 5:return[2]}})})},onCancel:function(){return $e(null)},isLoading:Ke,position:"fixed"}),o(b,{isOpen:!!it,title:R("".concat(k,".deleteVariant.title"),X),description:"variantDeletion"===nt?o("span",{children:R("".concat(k,".deleteVariant.desc"),"Are you sure you want to delete this variant? This action cannot be undone.")}):kt((null==it?void 0:it.ruleId)||null),warning:R("".concat(k,".deleteVariant.warningText"),"ruleDeletion"===nt?Z:te),confirmText:R("".concat(k,".deleteDialog.deleteText"),re),cancelText:R("".concat(k,".cancelText"),"Cancel"),loadingText:R("".concat(k,".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(!it)return[2];ut(!0),t.label=1;case 1:return t.trys.push([1,6,7,8]),"ruleDeletion"!==nt?[3,3]:[4,v(it.ruleId)];case 2:return t.sent(),[3,5];case 3:return[4,f(it.variantId)];case 4:t.sent(),t.label=5;case 5:return lt(null),null===(n=he.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:I.successToast,content:o(S,{message:"ruleDeletion"===nt?W:q})}),bt(),oe&&oe(!1,se||void 0),[3,8];case 6:return e=t.sent(),console.error("Failed to delete variant",e),null===(r=he.current)||void 0===r||r.show({severity:"error",sticky:!1,className:I.errorToast,content:o(j,{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"===nt?Q:z)})}),[3,8];case 7:return ut(!1),[7];case 8:return[2]}})})},onCancel:function(){return lt(null)},isLoading:st,position:"fixed"})]}):Lt?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==oe?void 0:oe(!0)},retryButtonText:"Refresh"}):i(l,{children:[o(d,{onCreate:Ct,title:V,desc:P,button:J}),we&&o(x,{children:o(D,{isOpen:we,onClose:It,app_integration_id:ie,token:le,mode:"ADD",config:Te,pluginPayload:r(r({},Mt),{initialScope:_t(),ruleSet:xt}),renderContinueModal:!1})}),o(L,{})]})};export{A 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 b from"../styles/LearningContent.module.css.js";import I from"../components/ConfirmationModal.js";import{dt as R}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 x}from"../../IL-OTJ/store/CitationsContext.js";import"@mui/material";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"../../../api/transport.js";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 D from"../../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js";import k from"../../../ContinueWithTemplateModal.js";import{LEARNING_DT_PATH as L,VARIANT_DT_PATH as _,TIER_DT_PATH as M}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"../../IL-marketplace/marketplaceTheme.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"../../IL-marketplace/components/GuidelineIconButton.js";import"@e-llm-studio/federated-dashboard-components";import"@e-llm-studio/federated-dashboard-components/styles.css";import"../hooks/useLearningTemplateQueryParams.js";import"../components/ToolTip.js";import"../../../ILMarketplaceWrapper.js";import"../LearningManagementTest.js";var A=function(A){var N,E=A.noRulesTitle,V=void 0===E?"No rules have been added !":E,F=A.noRulesDesc,P=void 0===F?"Start by adding rules that should apply across all stations.":F,B=A.noRulesButtonText,J=void 0===B?"Create New Rule":B,U=A.deleteRuleSuccessMessage,W=void 0===U?"Rule deleted successfully!":U,G=A.deleteVariantSuccessMessage,q=void 0===G?"Variant deleted successfully!":G,H=A.deleteRuleErrorMessage,Q=void 0===H?"Failed to delete rule. Please try again.":H,$=A.deleteVariantErrorMessage,z=void 0===$?"Failed to delete variant. Please try again.":$,K=A.deleteModalTitle,X=void 0===K?"Delete":K,Y=A.deleteRuleModalWarning,Z=void 0===Y?"This will permanently delete the rule configuration.":Y,ee=A.deleteVariantModalWarning,te=void 0===ee?"This will permanently delete the variant configuration.":ee,ne=A.deleteConfirmText,re=void 0===ne?"Delete":ne,oe=A.onRefreshRuleSets,ie=A.app_integration_id,le=A.token,ae=A.modeId,se=c(function(e){return e.selectedRuleSetId}),ue=c(function(e){return e.scopeTreeData}),ce=c(function(e){return e.sidebarTab}),de=c(function(e){return e.setInitialRules}),pe=c(function(e){return e.currentRules}),me=c(function(e){return e.setRawAuditRuleData});c(function(e){return e.createdVariantInfo});var fe=c(function(e){return e.resetCreatedVariantInfo}),ve=c(function(e){return e.isILModalTriggered}),ge=c(function(e){return e.setIsILModalTriggered}),he=a(null),Te=O.getState().configuration,ye=s(!1),we=ye[0],Se=ye[1],Ce=s(null),je=Ce[0],be=Ce[1],Ie=s(null),Re=Ie[0],xe=Ie[1],De=s(null),ke=De[0],Le=De[1],_e=s(null),Me=_e[0],Oe=_e[1],Ae=s(!1),Ne=Ae[0],Ee=Ae[1],Ve=s(null),Fe=Ve[0],Pe=Ve[1],Be=s(!1),Je=Be[0],Ue=Be[1],We=s(""),Ge=We[0],qe=We[1],He=s(null),Qe=He[0],$e=He[1],ze=s(!1),Ke=ze[0],Xe=ze[1],Ye=s(!1),Ze=Ye[0],et=Ye[1],tt=s("ruleDeletion"),nt=tt[0],rt=tt[1],ot=s(null),it=ot[0],lt=ot[1],at=s(!1),st=at[0],ut=at[1],ct=s(!1),dt=ct[0],pt=ct[1],mt=c.getState().tiers,ft=s(null),vt=ft[0],gt=ft[1],ht=s(null),Tt=ht[0],yt=ht[1],wt=s(null),St=wt[0],Ct=wt[1],jt=function(){be(null),Le(null),xe(null),gt(null),yt(null),Ct(null),qe(""),Se(!0),Oe(0)},bt=function(){Se(!1),ge(!1),be(null),xe(null),Le(null),Oe(null),et(!1),pt(!1),It(),gt(null),yt(null),Ct(null),qe(""),oe&&oe(!1,se||void 0)};u(function(){It()},[se,de]),u(function(){ve&&Se(!0)},[ve]);var It=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,b;return t(this,function(t){switch(t.label){case 0:if(!se)return de([]),[2];o||Ee(!0),Pe(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,p(se,le)];case 2:return e=t.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(me(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=mt.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(R("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)})}),de(y),(w=null===(b=null===(j=null===(C=g[0])||void 0===C?void 0:C.variants)||void 0===j?void 0:j[0])||void 0===b?void 0:b.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(w,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return fe()},1e4)},500):fe()):de(v),[3,5]):(de([]),[2]);case 3:return S=t.sent(),console.error("Failed to fetch rule details",S),404!==(null==S?void 0:S.status)&&Pe((null==S?void 0:S.message)||"Failed to load rules. Please try again."),de([]),[3,5];case 4:return o||Ee(!1),[7];case 5:return[2]}})})},Rt=se?j((null==ue?void 0:ue.data)||null,se):null,xt=Rt?{ruleSetId:Rt.id,ruleSetName:Rt.name,ruleSetDesc:"",ruleCount:null===(N=null==Rt?void 0:Rt.metrics)||void 0===N?void 0:N.learningsCount}:void 0,Dt=Boolean(null==ue?void 0:ue.data),kt=Boolean(se&&!Rt&&Dt),Lt=function(){if("stations"===ce)return"custom";if(!Rt)return"global";switch(Rt.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},_t=function(e){var t;if(!e)return o("p",{children:R("".concat(M,".deleteDialog.description"),"Are you sure you want to delete this rule? This action cannot be undone.")});var n=null==pe?void 0:pe.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:R("".concat(M,".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:""})})},Mt={editingRule:je,editingTier:Re,editingVariants:ke,focusedVariantIndex:Me,setFocusedVariantIndex:Oe,triggerAddVariant:Ze,triggerFixGaps:dt,copiedRule:vt,copiedSourceTier:Tt,copiedTargetTier:St,initialDraftMessage:Ge,app_integration_id:ie,modeId:ae,postSaveCallback:function(){console.log("postSaveCallback called with activeLearningRow:")}};return xt?i(l,{children:[o(T,{ref:he}),o("div",r({className:b.container},{children:Ne?o(h,{}):Fe?o(w,{errorMessage:Fe,onRetry:It}):o(y,{onAddRule:jt,onDeleteRule:function(e){$e(e)},onEditRule:function(e,t){be(e),xe(t||null),Le(e.variants||null),Oe(null),et(!0),Se(!0)},onEditVariant:function(e,t,n,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==pe?void 0:pe.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==pe?void 0:pe.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;be(s),xe(n||null),Le(s.variants||null),Oe(c),Se(!0),"resolve_gaps"===r&&pt(!0)}},onDeleteVariant:function(e,t){lt({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(!se)return[2];Ue(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,m(se)];case 2:return e=t.sent(),n=window.URL.createObjectURL(e),(r=document.createElement("a")).href=n,i=(null==xt?void 0:xt.ruleSetName)?"".concat(xt.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(se,".csv"),r.download=i,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n),null===(a=he.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:b.successToast,content:o(S,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=t.sent(),console.error("Export error:",l),null===(s=he.current)||void 0===s||s.show({severity:"error",sticky:!1,className:b.errorToast,content:o(C,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Ue(!1),[7];case 5:return[2]}})})},isExporting:Je,onToggleSuccess:function(){return It(!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(),It(!0),null===(s=he.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:b.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),It(!0),null===(u=he.current)||void 0===u||u.show({severity:"error",sticky:!1,className:b.errorToast,content:o(C,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:oe,setDeleteConfirmationUsedFor:rt,onCopyToTier:function(e,t,n,r,o){var i,l,a=null===(l=null===(i=null==pe?void 0:pe.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),gt(a),yt(r),Ct(o),be(null),xe(null),Le(null),Oe(null),Se(!0)}}})})),we&&o(x,{children:o(D,{isOpen:we,onClose:bt,app_integration_id:ie,token:le,mode:"ADD",config:Te,pluginPayload:r(r({},Mt),{initialScope:Lt(),ruleSet:xt}),renderContinueModal:!1})}),o(k,{}),o(I,{isOpen:!!Qe,title:R("".concat(L,".deleteDialog.title"),X),description:_t(Qe),warning:R("".concat(L,".deleteDialog.warningText"),Z),confirmText:R("".concat(L,".deleteDialog.deleteText"),re),cancelText:R("".concat(L,".deleteDialog.cancelText"),"Cancel"),loadingText:R("".concat(L,".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(!Qe)return[2];Xe(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,f(Qe)];case 2:return t.sent(),$e(null),null===(n=he.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:b.successToast,content:o(S,{message:W})}),It(),oe&&oe(!1,se||void 0),[3,5];case 3:return e=t.sent(),console.error("Failed to delete rule",e),null===(r=he.current)||void 0===r||r.show({severity:"error",sticky:!1,className:b.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)||Q})}),[3,5];case 4:return Xe(!1),[7];case 5:return[2]}})})},onCancel:function(){return $e(null)},isLoading:Ke,position:"fixed"}),o(I,{isOpen:!!it,title:R("".concat(_,".deleteVariant.title"),X),description:"variantDeletion"===nt?o("span",{children:R("".concat(_,".deleteVariant.desc"),"Are you sure you want to delete this variant? This action cannot be undone.")}):_t((null==it?void 0:it.ruleId)||null),warning:R("".concat(_,".deleteVariant.warningText"),"ruleDeletion"===nt?Z:te),confirmText:R("".concat(_,".deleteDialog.deleteText"),re),cancelText:R("".concat(_,".cancelText"),"Cancel"),loadingText:R("".concat(_,".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(!it)return[2];ut(!0),t.label=1;case 1:return t.trys.push([1,6,7,8]),"ruleDeletion"!==nt?[3,3]:[4,v(it.ruleId)];case 2:return t.sent(),[3,5];case 3:return[4,f(it.variantId)];case 4:t.sent(),t.label=5;case 5:return lt(null),null===(n=he.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:b.successToast,content:o(S,{message:"ruleDeletion"===nt?W:q})}),It(),oe&&oe(!1,se||void 0),[3,8];case 6:return e=t.sent(),console.error("Failed to delete variant",e),null===(r=he.current)||void 0===r||r.show({severity:"error",sticky:!1,className:b.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"===nt?Q:z)})}),[3,8];case 7:return ut(!1),[7];case 8:return[2]}})})},onCancel:function(){return lt(null)},isLoading:st,position:"fixed"})]}):kt?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==oe?void 0:oe(!0)},retryButtonText:"Refresh"}):i(l,{children:[o(d,{onCreate:jt,title:V,desc:P,button:J}),we&&o(x,{children:o(D,{isOpen:we,onClose:bt,app_integration_id:ie,token:le,mode:"ADD",config:Te,pluginPayload:r(r({},Mt),{initialScope:Lt(),ruleSet:xt}),renderContinueModal:!1})}),o(k,{})]})};export{A as default};
2
2
  //# sourceMappingURL=RuleContent.js.map