@e-llm-studio/instant-learning 1.3.0-alpha.33 → 1.3.0-alpha.35

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.
Files changed (37) hide show
  1. package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js +1 -1
  2. package/dist/cjs/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.js +1 -1
  3. package/dist/cjs/features/LearningManagement/LearningManagement.js +1 -1
  4. package/dist/cjs/features/LearningManagement/LearningTemplateLayout.js +1 -1
  5. package/dist/cjs/features/LearningManagement/RuleContent/RuleContent.js +1 -1
  6. package/dist/cjs/features/LearningManagement/apis/scopeApis.js +1 -1
  7. package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +1 -1
  8. package/dist/cjs/features/LearningManagement/store/useLMSConfigStore.js +1 -1
  9. package/dist/cjs/index.js +1 -1
  10. package/dist/cjs/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js +1 -1
  11. package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js +1 -1
  12. package/dist/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.js +1 -1
  13. package/dist/features/LearningManagement/LearningManagement.js +1 -1
  14. package/dist/features/LearningManagement/LearningTemplateLayout.js +1 -1
  15. package/dist/features/LearningManagement/RuleContent/RuleContent.js +1 -1
  16. package/dist/features/LearningManagement/apis/scopeApis.js +1 -1
  17. package/dist/features/LearningManagement/components/InstantLearningModal.js +1 -1
  18. package/dist/features/LearningManagement/store/useLMSConfigStore.js +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js +1 -1
  21. package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.d.ts.map +1 -1
  22. package/dist/types/src/features/IL-OTJ/_components/index.d.ts +1 -0
  23. package/dist/types/src/features/IL-OTJ/_components/index.d.ts.map +1 -1
  24. package/dist/types/src/features/LearningManagement/LearningManagement.d.ts +2 -1
  25. package/dist/types/src/features/LearningManagement/LearningManagement.d.ts.map +1 -1
  26. package/dist/types/src/features/LearningManagement/LearningTemplateLayout.d.ts +1 -0
  27. package/dist/types/src/features/LearningManagement/LearningTemplateLayout.d.ts.map +1 -1
  28. package/dist/types/src/features/LearningManagement/RuleContent/RuleContent.d.ts +1 -0
  29. package/dist/types/src/features/LearningManagement/RuleContent/RuleContent.d.ts.map +1 -1
  30. package/dist/types/src/features/LearningManagement/apis/scopeApis.d.ts.map +1 -1
  31. package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts.map +1 -1
  32. package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts +4 -0
  33. package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts.map +1 -1
  34. package/dist/types/src/index.d.ts +1 -0
  35. package/dist/types/src/index.d.ts.map +1 -1
  36. package/dist/types/src/plugins/ValueTypes/Default/DefaultTeachMeRenderer.d.ts.map +1 -1
  37. package/package.json +8 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("zustand"),t=require("./useLearningTemplateStore.js"),n={pageTitle:"",middleDrawer:{scope:"",addScope:"",addSubScope:"",addScopeDialog:{title:"",subtitle:"",scopeName:"",learningApprovalSettings:{title:"",approvalRequired:{title:"",subtitle:""},publishWithoutApproval:{title:"",subtitle:""}},submitButton:"",cancel:""},treeMenu:{search:"",submenu:{learnings:"",access:"",changeHistory:""},contextMenu:{addScope:"",rename:"",delete:"",addSubScope:""}}},learnings:{header:{title:"",exportButton:"",addNewLearningButton:""},tier:{showTierHeader:!0,tierHeader:"",subtitle:"",tierHeaderNoOfLearnings:"",deleteDialog:{title:"",description:"",cancel:"",submit:""},learning:{inheritance:"",actions:{disable:"",enable:"",approve:"",reject:"",delete:""},approveDialog:{title:"",desc:"",footer:"",cancel:"",approveLearning:""},rejectDialog:{title:"",desc:"",feedbackTitle:"",feedbackPlaceholder:"",deleteCheckboxLabel:"",cancel:"",rejectLearning:""},deleteDialog:{title:"",desc:"",warningText:"",cancelText:"",deleteText:""}}}}},a={showScope:!1,showConfiguration:!1,welcomeMessage:"Hi! 👋 I'm your Instant Learning Concierge.",welcomeMessageSubtitle:"How would you like to get started? You can select an option below or describe the rule you'd like to create.",actions:[{label:"Separation rule",value:"I would want to add a separation rule"},{label:"Max priority rule",value:"I would want to set a max priority rule"},{label:"Break code matching",value:"I would want to add a break code matching rule"},{label:"Inventory code matching",value:"I would want to add a inventory window matching rule"},{label:"Enter a rule description",value:"I want to add a rule description"},{label:"Tester Genie",value:"Loading prompt..."}],chatTitle:"Teach Me OTJ - {scope} - Add Learning",chatTitleEdit:"Teach Me OTJ - {scope} - Edit Learning",formTitle:"Rule setup",setupLabel:"Configure your IL",ruleTitle:"Main Rule Name",scopeLabel:"Define Scope",tierLabel:"Select Tiers",ruleDescriptionTitle:"Learning Explanation",whenToApplyTitle:"Trigger Events (When to Apply)",addWhenToApplyBtnLabel:"Add WTA",whenNotToApplyTitle:"Exclusion Events (When NOT to Apply)",addWhenNotToApplyBtnLabel:"Add WNTA",configTitle:"Advanced Settings",saveBtnLabel:"Save Rule",saveBtnLoadingLabel:"Saving Rule...",chatTextareaPlaceholder:"Tell me more about this learning.."},l=e.create(function(e){return{lmsConfig:n,setLMSConfig:function(t){return e({lmsConfig:t})},clearLMSConfig:function(){return e({lmsConfig:n})}}});var i=e.create(function(e){return{teachMeConfig:null,setTeachMeConfig:function(t){return e({teachMeConfig:t})},clearTeachMeConfig:function(){return e({teachMeConfig:null})}}});exports.defaultLMSConfig=n,exports.defaultTeachMeConfig=a,exports.dt=function(e,n,a){if(t.useLearningTemplateStore.getState().backwardCompatibility)return null!=n?n:"";var i=l.getState().lmsConfig,o=e.split(".").reduce(function(e,t){return null==e?void 0:e[t]},i);return"string"!=typeof o||""===o?null!=n?n:e:o.replace(/\{(\w+)\}/g,function(e,t){var n;return String(null!==(n=null==a?void 0:a[t])&&void 0!==n?n:"{".concat(t,"}"))})},exports.dtt=function(e,t,n){var a=i.getState().teachMeConfig,l=e.split(".").reduce(function(e,t){return null==e?void 0:e[t]},a);return"string"!=typeof l?null!=t?t:e:l.replace(/\{(\w+)\}/g,function(e,t){var a;return String(null!==(a=null==n?void 0:n[t])&&void 0!==a?a:"{".concat(t,"}"))})},exports.dttWelcomeMessageParts=function(){var e,t,n=null!==(e=i.getState().teachMeConfig)&&void 0!==e?e:a;return{greeting:n.welcomeMessage||a.welcomeMessage,subtitle:n.welcomeMessageSubtitle||a.welcomeMessageSubtitle,actions:(null===(t=n.actions)||void 0===t?void 0:t.length)?n.actions:a.actions}},exports.useLMSConfigStore=l,exports.useTeachMeConfigStore=i;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("zustand"),t=require("./useLearningTemplateStore.js"),n={pageTitle:"",middleDrawer:{scope:"",addScope:"",addSubScope:"",addScopeDialog:{title:"",subtitle:"",scopeName:"",learningApprovalSettings:{title:"",approvalRequired:{title:"",subtitle:""},publishWithoutApproval:{title:"",subtitle:""}},submitButton:"",cancel:""},treeMenu:{search:"",submenu:{learnings:"",access:"",changeHistory:""},contextMenu:{addScope:"",rename:"",delete:"",addSubScope:""}}},learnings:{header:{title:"",exportButton:"",addNewLearningButton:""},tier:{showTierHeader:!0,tierHeader:"",subtitle:"",tierHeaderNoOfLearnings:"",deleteDialog:{title:"",description:"",cancel:"",submit:""},learning:{inheritance:"",actions:{disable:"",enable:"",approve:"",reject:"",delete:""},approveDialog:{title:"",desc:"",footer:"",cancel:"",approveLearning:""},rejectDialog:{title:"",desc:"",feedbackTitle:"",feedbackPlaceholder:"",deleteCheckboxLabel:"",cancel:"",rejectLearning:""},deleteDialog:{title:"",desc:"",warningText:"",cancelText:"",deleteText:""}}}},agents:{LearningTerm:""}},a={showScope:!1,showConfiguration:!1,welcomeMessage:"Hi! 👋 I'm your Instant Learning Concierge.",welcomeMessageSubtitle:"How would you like to get started? You can select an option below or describe the rule you'd like to create.",actions:[{label:"Separation rule",value:"I would want to add a separation rule"},{label:"Max priority rule",value:"I would want to set a max priority rule"},{label:"Break code matching",value:"I would want to add a break code matching rule"},{label:"Inventory code matching",value:"I would want to add a inventory window matching rule"},{label:"Enter a rule description",value:"I want to add a rule description"},{label:"Tester Genie",value:"Loading prompt..."}],chatTitle:"Teach Me OTJ - {scope} - Add Learning",chatTitleEdit:"Teach Me OTJ - {scope} - Edit Learning",formTitle:"Rule setup",setupLabel:"Configure your IL",ruleTitle:"Main Rule Name",scopeLabel:"Define Scope",tierLabel:"Select Tiers",ruleDescriptionTitle:"Learning Explanation",whenToApplyTitle:"Trigger Events (When to Apply)",addWhenToApplyBtnLabel:"Add WTA",whenNotToApplyTitle:"Exclusion Events (When NOT to Apply)",addWhenNotToApplyBtnLabel:"Add WNTA",configTitle:"Advanced Settings",saveBtnLabel:"Save Rule",saveBtnLoadingLabel:"Saving Rule...",chatTextareaPlaceholder:"Tell me more about this learning.."},l=e.create(function(e){return{lmsConfig:n,setLMSConfig:function(t){return e({lmsConfig:t})},clearLMSConfig:function(){return e({lmsConfig:n})}}});var i=e.create(function(e){return{teachMeConfig:null,setTeachMeConfig:function(t){return e({teachMeConfig:t})},clearTeachMeConfig:function(){return e({teachMeConfig:null})}}});exports.defaultLMSConfig=n,exports.defaultTeachMeConfig=a,exports.dt=function(e,n,a){if(t.useLearningTemplateStore.getState().backwardCompatibility)return null!=n?n:"";var i=l.getState().lmsConfig,o=e.split(".").reduce(function(e,t){return null==e?void 0:e[t]},i);return"string"!=typeof o||""===o?null!=n?n:e:o.replace(/\{(\w+)\}/g,function(e,t){var n;return String(null!==(n=null==a?void 0:a[t])&&void 0!==n?n:"{".concat(t,"}"))})},exports.dtt=function(e,t,n){var a=i.getState().teachMeConfig,l=e.split(".").reduce(function(e,t){return null==e?void 0:e[t]},a);return"string"!=typeof l?null!=t?t:e:l.replace(/\{(\w+)\}/g,function(e,t){var a;return String(null!==(a=null==n?void 0:n[t])&&void 0!==a?a:"{".concat(t,"}"))})},exports.dttWelcomeMessageParts=function(){var e,t,n=null!==(e=i.getState().teachMeConfig)&&void 0!==e?e:a;return{greeting:n.welcomeMessage||a.welcomeMessage,subtitle:n.welcomeMessageSubtitle||a.welcomeMessageSubtitle,actions:(null===(t=n.actions)||void 0===t?void 0:t.length)?n.actions:a.actions}},exports.useLMSConfigStore=l,exports.useTeachMeConfigStore=i;
2
2
  //# sourceMappingURL=useLMSConfigStore.js.map
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./features/InstantLearning/InstantLearning.js"),t=require("./features/WtaWnta/WtaWnta.js"),r=require("./features/DocumentLearning/DocumentLearning.js"),o=require("./features/IL-OTJ/ILOTJ.js"),n=require("./features/IL-OTJ/_components/atoms/Button/Button.js"),s=require("./features/IL-OTJ/_components/atoms/Dropdown/Dropdown.js"),a=require("./features/IL-OTJ/_components/atoms/Toggle/Toggle.js"),i=require("./features/IL-OTJ/_components/atoms/Textarea/Textarea.js"),p=require("./features/IL-OTJ/_components/molecules/Condition/ConditionList.js"),u=require("./features/IL-OTJ/_components/molecules/Sections/SectionWrapper.js"),c=require("./features/IL-OTJ/_components/molecules/SeperationRow/SeparationRow.js"),T=require("./features/IL-OTJ/_components/organisms/ConfigSection/ConfigSection.js"),x=require("./features/IL-OTJ/_components/organisms/TextSection/TextSection.js"),m=require("./features/IL-OTJ/_components/organisms/ScopeSection/ScopeSection.js"),f=require("./features/IL-OTJ/_components/organisms/ConditionSection/ConditionSection.js"),g=require("./features/IL-OTJ/_components/templates/TrafficManager/TrafficManagerTemplate.js"),l=require("./features/IL-OTJ/_components/templates/Testing/Testing.js"),d=require("./features/IL-OTJ/_components/templates/TemplatesMap/templatesMap.js"),L=require("./features/IL-OTJ/helpers/utils.js"),I=require("./features/IL-OTJ/store/CitationsContext.js"),S=require("./features/IL-OTJ/ILOTJTest.js"),j=require("./features/LearningManagement/LearningManagement.js");require("tslib"),require("react/jsx-runtime"),exports.InstantLearning=e.default,exports.WtaWnta=t.default,exports.BookLearning=r.default,exports.ILOTJ=o.default,exports.Button=n.Button,exports.Dropdown=s.Dropdown,exports.Toggle=a.Toggle,exports.Textarea=i.Textarea,exports.ConditionList=p.ConditionList,exports.SectionWrapper=u.SectionWrapper,exports.SeparationRow=c.SeparationRow,exports.ConfigSection=T.ConfigSection,exports.TextSection=x.TextSection,exports.ScopeSection=m.ScopeSection,exports.ConditionSection=f.ConditionSection,exports.TrafficManagerTemplate=g.TrafficManagerTemplate,exports.Testing=l.Testing,Object.defineProperty(exports,"TemplateList",{enumerable:!0,get:function(){return d.TemplateList}}),exports.TemplateMap=d.TemplateMap,exports.extractAndParseResponse=L.extractAndParseResponse,exports.extractAndParseWithProperty=L.extractAndParseWithProperty,exports.extractTextFromChildren=L.extractTextFromChildren,exports.extractVariantIds=L.extractVariantIds,exports.parseValidationData=L.parseValidationData,exports.useHeaderObserver=L.useHeaderObserver,exports.CitationProvider=I.CitationProvider,exports.useCitations=I.useCitations,exports.dummyDat=S.dummyDat,exports.getVariantInfo=S.getVariantInfo,exports.LearningManagement=j.default;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./features/InstantLearning/InstantLearning.js"),t=require("./features/WtaWnta/WtaWnta.js"),r=require("./features/DocumentLearning/DocumentLearning.js"),o=require("./features/IL-OTJ/ILOTJ.js"),s=require("./features/IL-OTJ/_components/atoms/Button/Button.js"),n=require("./features/IL-OTJ/_components/atoms/Dropdown/Dropdown.js"),a=require("./features/IL-OTJ/_components/atoms/Toggle/Toggle.js"),i=require("./features/IL-OTJ/_components/atoms/Textarea/Textarea.js"),p=require("./features/IL-OTJ/_components/molecules/Condition/ConditionList.js"),u=require("./features/IL-OTJ/_components/molecules/Sections/SectionWrapper.js"),c=require("./features/IL-OTJ/_components/molecules/SeperationRow/SeparationRow.js"),T=require("./features/IL-OTJ/_components/organisms/ConfigSection/ConfigSection.js"),x=require("./features/IL-OTJ/_components/organisms/TextSection/TextSection.js"),m=require("./features/IL-OTJ/_components/organisms/ScopeSection/ScopeSection.js"),f=require("./features/IL-OTJ/_components/organisms/ConditionSection/ConditionSection.js"),g=require("./features/IL-OTJ/_components/templates/TrafficManager/TrafficManagerTemplate.js"),l=require("./features/IL-OTJ/_components/templates/Testing/Testing.js"),d=require("./features/IL-OTJ/_components/templates/TemplatesMap/templatesMap.js"),L=require("./features/IL-OTJ/helpers/utils.js"),I=require("./features/IL-OTJ/store/CitationsContext.js"),S=require("./features/IL-OTJ/ILOTJTest.js"),j=require("./features/LearningManagement/LearningManagement.js"),O=require("./features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js");require("tslib"),require("react/jsx-runtime"),exports.InstantLearning=e.default,exports.WtaWnta=t.default,exports.BookLearning=r.default,exports.ILOTJ=o.default,exports.Button=s.Button,exports.Dropdown=n.Dropdown,exports.Toggle=a.Toggle,exports.Textarea=i.Textarea,exports.ConditionList=p.ConditionList,exports.SectionWrapper=u.SectionWrapper,exports.SeparationRow=c.SeparationRow,exports.ConfigSection=T.ConfigSection,exports.TextSection=x.TextSection,exports.ScopeSection=m.ScopeSection,exports.ConditionSection=f.ConditionSection,exports.TrafficManagerTemplate=g.TrafficManagerTemplate,exports.Testing=l.Testing,Object.defineProperty(exports,"TemplateList",{enumerable:!0,get:function(){return d.TemplateList}}),exports.TemplateMap=d.TemplateMap,exports.extractAndParseResponse=L.extractAndParseResponse,exports.extractAndParseWithProperty=L.extractAndParseWithProperty,exports.extractTextFromChildren=L.extractTextFromChildren,exports.extractVariantIds=L.extractVariantIds,exports.parseValidationData=L.parseValidationData,exports.useHeaderObserver=L.useHeaderObserver,exports.CitationProvider=I.CitationProvider,exports.useCitations=I.useCitations,exports.dummyDat=S.dummyDat,exports.getVariantInfo=S.getVariantInfo,exports.LearningManagement=j.default,exports.TeachMePlugin=O.default,exports.TemplateRegistry=O.TemplateRegistry;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),i=require("../../../features/LearningManagement/components/InstantLearningModal.js"),a=require("../../../features/LearningManagement/store/useLMSConfigStore.js"),n=require("react-markdown"),r=require("react-dom/server");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=l(n);exports.default=function(n){var l=n.pluginPayload||{},d=l.editingRule,s=l.editingTier,c=l.editingVariants,u=l.focusedVariantIndex,p=l.setFocusedVariantIndex,g=l.triggerAddVariant,T=l.triggerFixGaps,h=l.copiedRule,f=l.copiedSourceTier,b=l.copiedTargetTier,L=l.initialDraftMessage,m=l.app_integration_id,x=l.modeId;a.useTeachMeConfigStore(function(e){return e.teachMeConfig});var A=a.dttWelcomeMessageParts(),v=A.greeting,M=A.subtitle,S=A.actions,y=r.renderToStaticMarkup(t.jsxs("p",{children:[t.jsx("span",{children:v}),t.jsx(o.default,{children:M}),t.jsx("span",e.__assign({className:"clickable-button-group"},{children:S.map(function(i){var a=i.label,n=i.value;return t.jsx("button",e.__assign({className:"clickable-button","data-value":n},{children:a}),a)})}))]})),I={showScope:!1,showConfiguration:!1,welcomeMessage:a.dtt("welcomeMessage","Hi! 👋 I'm your Instant Learning Concierge."),formTitle:a.dtt("formTitle","Rule setup"),setupLabel:a.dtt("setupLabel","Configure your IL"),ruleTitle:a.dtt("ruleTitle","Main Rule Name"),scopeLabel:a.dtt("scopeLabel","Define Scope"),tierLabel:a.dtt("tierLabel","Select Tiers"),ruleDescriptionTitle:a.dtt("ruleDescriptionTitle","Learning Explanation"),whenToApplyTitle:a.dtt("whenToApplyTitle","Trigger Events (When to Apply)"),addWhenToApplyBtnLabel:a.dtt("addWhenToApplyBtnLabel","Add WTA"),whenNotToApplyTitle:a.dtt("whenNotToApplyTitle","Exclusion Events (When NOT to Apply)"),addWhenNotToApplyBtnLabel:a.dtt("addWhenNotToApplyBtnLabel","Add WNTA"),configTitle:a.dtt("configTitle","Advanced Settings"),saveBtnConfig:{label:a.dtt("saveBtnLabel","Save Rule"),loadingLabel:a.dtt("saveBtnLoadingLabel","Saving Rule...")},chatTitle:a.dtt("chatTitle","Teach Me OTJ - {scope} - Add Learning"),chatTitleEdit:a.dtt("chatTitleEdit","Teach Me OTJ - {scope} - Edit Learning"),chatTextareaPlaceholder:a.dtt("chatTextareaPlaceholder","Tell me more about this learning..")};return t.jsx(i.default,{isOpen:n.isOpen,onClose:n.onClose,initialScope:n.initialScope,ruleSet:n.ruleSet,editingRule:d,editingTier:s,editingVariants:c,focusedVariantIndex:u,setFocusedVariantIndex:p,triggerAddVariant:g,triggerFixGaps:T,copiedRule:h,copiedSourceTier:f,copiedTargetTier:b,initialDraftMessage:L,initialChatMessage:y,applicationIntegrationId:m,modeId:x,uiStateLabels:I})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),i=require("../../../features/LearningManagement/components/InstantLearningModal.js"),a=require("../../../features/LearningManagement/store/useLMSConfigStore.js"),n=require("react-markdown"),r=require("react-dom/server");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=l(n);exports.default=function(n){var l=n.pluginPayload||{},d=l.editingRule,s=l.editingTier,c=l.editingVariants,u=l.focusedVariantIndex,p=l.setFocusedVariantIndex,g=l.triggerAddVariant,T=l.triggerFixGaps,h=l.copiedRule,f=l.copiedSourceTier,L=l.copiedTargetTier,b=l.initialDraftMessage,m=l.app_integration_id,x=l.modeId;a.useTeachMeConfigStore(function(e){return e.teachMeConfig});var A=a.dttWelcomeMessageParts(),v=A.greeting,M=A.subtitle,S=A.actions,y=r.renderToStaticMarkup(t.jsxs("p",{children:[t.jsx("span",{children:v}),t.jsx(o.default,{children:M}),t.jsx("span",e.__assign({className:"clickable-button-group"},{children:S.map(function(i){var a=i.label,n=i.value;return t.jsx("button",e.__assign({className:"clickable-button","data-value":n},{children:a}),a)})}))]})),I={showScope:!1,showConfiguration:!1,welcomeMessage:a.dtt("welcomeMessage","Hi! 👋 I'm your Instant Learning Concierge."),formTitle:a.dtt("formTitle","Rule setup"),setupLabel:a.dtt("setupLabel","Configure your IL"),ruleTitle:a.dtt("ruleTitle","Main Rule Name"),scopeLabel:a.dtt("scopeLabel","Define Scope"),tierLabel:a.dtt("tierLabel","Select Tiers"),ruleDescriptionTitle:a.dtt("ruleDescriptionTitle","Learning Explanation"),whenToApplyTitle:a.dtt("whenToApplyTitle","Trigger Events (When to Apply)"),addWhenToApplyBtnLabel:a.dtt("addWhenToApplyBtnLabel","Add WTA"),whenNotToApplyTitle:a.dtt("whenNotToApplyTitle","Exclusion Events (When NOT to Apply)"),addWhenNotToApplyBtnLabel:a.dtt("addWhenNotToApplyBtnLabel","Add WNTA"),configTitle:a.dtt("configTitle","Advanced Settings"),saveBtnConfig:{label:a.dtt("saveBtnLabel","Save Rule"),loadingLabel:a.dtt("saveBtnLoadingLabel","Saving Rule...")},chatTitle:a.dtt("chatTitle","Teach Me OTJ - {scope} - Add Learning"),chatTitleEdit:a.dtt("chatTitleEdit","Teach Me OTJ - {scope} - Edit Learning"),chatTextareaPlaceholder:a.dtt("chatTextareaPlaceholder","Tell me more about this learning.."),LearningTerm:a.dt("agents.LearningTerm","Learnings")};return t.jsx(i.default,{isOpen:n.isOpen,onClose:n.onClose,initialScope:n.initialScope,ruleSet:n.ruleSet,editingRule:d,editingTier:s,editingVariants:c,focusedVariantIndex:u,setFocusedVariantIndex:p,triggerAddVariant:g,triggerFixGaps:T,copiedRule:h,copiedSourceTier:f,copiedTargetTier:L,initialDraftMessage:b,initialChatMessage:y,applicationIntegrationId:m,modeId:x,uiStateLabels:I})};
2
2
  //# sourceMappingURL=DefaultTeachMeRenderer.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsx as i}from"react/jsx-runtime";import r from"./TeachMeWrapper.js";import n from"../../../plugins/ValueTypes/Default/DefaultTeachMeRenderer.js";import a from"../../../plugins/ValueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.js";import o from"../../../plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.js";var l={Default:n,"Radio Traffic Learning":a,Guidelines:o},t=function(n){var a,o=n.app_integration_id,t=n.isOpen,p=n.onClose,u=n.pluginPayload,s=n.token,d=n.mode;return i(r,{app_integration_id:o,isOpen:t,onClose:p,token:s,templateRegistry:l,initialScope:null!==(a=null==u?void 0:u.initialScope)&&void 0!==a?a:"",ruleSet:null==u?void 0:u.ruleSet,pluginPayload:e(e({},u),{mode:d})})};export{l as TemplateRegistry,t as default};
1
+ import{__assign as e}from"tslib";import{jsx as i}from"react/jsx-runtime";import{useEffect as n}from"react";import r from"./TeachMeWrapper.js";import t from"../../../plugins/ValueTypes/Default/DefaultTeachMeRenderer.js";import o from"../../../plugins/ValueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.js";import a from"../../../plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.js";import{useTeachMeConfigStore as l}from"../../LearningManagement/store/useLMSConfigStore.js";import{useLearningTemplateStore as u}from"../../LearningManagement/store/useLearningTemplateStore.js";var s={Default:t,"Radio Traffic Learning":o,Guidelines:a},p=function(t){var o,a=t.app_integration_id,p=t.isOpen,f=t.onClose,m=t.pluginPayload,d=t.token,g=t.mode,c=l(function(e){return e.setTeachMeConfig});return l(function(e){return e.clearTeachMeConfig}),n(function(){(null==m?void 0:m.teachMe)&&c(m.teachMe),(null==m?void 0:m.tiers)&&u.getState().setTiers(null==m?void 0:m.tiers)},[m]),i(r,{app_integration_id:a,isOpen:p,onClose:f,token:d,templateRegistry:s,initialScope:null!==(o=null==m?void 0:m.initialScope)&&void 0!==o?o:"",ruleSet:null==m?void 0:m.ruleSet,pluginPayload:e(e({},m),{mode:g})})};export{s as TemplateRegistry,p as default};
2
2
  //# sourceMappingURL=TeachMePlugin.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as i}from"tslib";import{jsxs as e,jsx as n}from"react/jsx-runtime";import t,{useState as o,useEffect as l}from"react";import{InputDataReasoningCard as r}from"../../InputDataReasoningCard.js";import{ConditionSection as a}from"../../organisms/ConditionSection/ConditionSection.js";import{ConfigSection as d}from"../../organisms/ConfigSection/ConfigSection.js";import{ScopeSection as c}from"../../organisms/ScopeSection/ScopeSection.js";import{TextSection as u}from"../../organisms/TextSection/TextSection.js";import s from"../../AccordianSection.js";import{ButtonCognitiveIcon as v}from"../../_svg/ButtonCognitiveIcon.js";import{Loader2Icon as p,Pencil as f,Check as g,AlertTriangle as h}from"lucide-react";var y=function(o){var l=o.children,r=o.onAddVariant,a=o.isDisabled,d=o.showAddVariantBtn,c=void 0===d||d,u=t.Children.toArray(l);return e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[u.map(function(i,o){var l=!(o===u.length-1)||c;return e(t.Fragment,{children:[i,l&&n("div",{style:{width:"2px",height:"20px",backgroundColor:"#E2E8F0",marginLeft:"30px"}})]},o)}),c&&n("div",i({onClick:a?void 0:r,style:{padding:"8px 16px",border:"1px solid #E2E8F0",borderRadius:"8px",color:a?"#94a3b8":"#475569",fontSize:"14px",fontWeight:"500",cursor:a?"not-allowed":"pointer",backgroundColor:a?"#f8fafc":"#FFFFFF",opacity:a?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))},m=function(m){var T,x,D,S,A,C,I,b,O,w,E,V,R=m.state,_=m.handlers,N=m.uiState,W=(null==N?void 0:N.highlights)||new Map,L=W.get("global_0")||{},B=o({}),F=B[0],M=B[1],j=o(null),k=j[0],z=j[1],q=o(function(){var i,e,n;if((null==N?void 0:N.defaultTierOpen)>=0&&(null===(i=null==N?void 0:N.tierOptions)||void 0===i?void 0:i[N.defaultTierOpen]))return N.tierOptions[N.defaultTierOpen].toLowerCase().replace(/ /g,"_");var t=null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n[0];return t?t.toLowerCase().replace(/ /g,"_"):null});q[0];var P=q[1],J="rule-setup"===(null==N?void 0:N.activeEditId),H=t.useRef(new Map),K=o(null),$=K[0],U=K[1],Z=o(null),G=Z[0],Q=Z[1],X=o(!1),Y=X[0],ii=X[1],ei=t.useRef(null==N?void 0:N.isAiStreaming);l(function(){ei.current&&!(null==N?void 0:N.isAiStreaming)&&Y&&ii(!1),ei.current=null==N?void 0:N.isAiStreaming},[null==N?void 0:N.isAiStreaming,Y]);var ni=function(){var i;U(null),Q(null),null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null)},ti=function(){var i,e,n=null!=$?$:R.ruleTitle,t=null!=G?G:R.scopeData,o=n!==R.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(R.scopeData);if(!o&&!l)return U(null),Q(null),void(null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null));if(null==N?void 0:N.setSendMessageInChat){var r="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),a=[];if(o&&a.push((null==n?void 0:n.trim())?"Title with ".concat(n):"No Title"),l){var d=null==t?void 0:t.tiers,c=d&&d.length>0?"tiers: ".concat(d.join(", ")):"No Tier Selected";a.push(c)}var u=a.join(" and ");N.setSendMessageInChat("__SKELETON__:".concat(r,":Update Rule Setup ").concat(u))}ii(!0),U(null),Q(null),null===(e=null==N?void 0:N.setActiveEditId)||void 0===e||e.call(N,null)},oi=null!==$?null==$?void 0:$.trim():(R.ruleTitle||"").trim(),li=null!=G?G:R.scopeData,ri=oi!==(R.ruleTitle||"").trim(),ai=JSON.stringify(li)!==JSON.stringify(R.scopeData),di=!ri&&!ai||""===oi,ci=t.useRef(null==N?void 0:N.defaultVariantOpen),ui=t.useRef(null==N?void 0:N.activeVariantAccordionIndex),si=t.useRef(null==N?void 0:N.defaultTierOpen),vi=t.useRef(null===(T=R.scopeData)||void 0===T?void 0:T.tiers),pi=t.useRef(R.variantsByTier);t.useEffect(function(){var i,e,n,t,o,l,r=null,a=!1;ci.current!==(null==N?void 0:N.defaultVariantOpen)&&(a=!0,ci.current=null==N?void 0:N.defaultVariantOpen),ui.current!==(null==N?void 0:N.activeVariantAccordionIndex)&&(a=!0,ui.current=null==N?void 0:N.activeVariantAccordionIndex),si.current!==(null==N?void 0:N.defaultTierOpen)&&(a=!0,si.current=null==N?void 0:N.defaultTierOpen);var d=(null===(i=R.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(vi.current)!==JSON.stringify(d)&&(a=!0,vi.current=d,d.length>0&&P(d[0].toLowerCase().replace(/ /g,"_")));var c=(null===(e=null==N?void 0:N.tierOptions)||void 0===e?void 0:e.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||[],u=c.some(function(i){var e,n,t,o,l=i.toLowerCase().replace(/ /g,"_");return((null===(n=null===(e=pi.current)||void 0===e?void 0:e[l])||void 0===n?void 0:n.length)||0)!==((null===(o=null===(t=R.variantsByTier)||void 0===t?void 0:t[l])||void 0===o?void 0:o.length)||0)});if(u&&(a=!0),a){var s=null!==(n=null==N?void 0:N.activeVariantAccordionIndex)&&void 0!==n?n:null==N?void 0:N.defaultVariantOpen;if(null==s||s<0)return z(null),void(pi.current=R.variantsByTier);c.forEach(function(i,e){var n;if(!((null==N?void 0:N.defaultTierOpen)>=0&&e!==N.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),o=(null===(n=R.variantsByTier)||void 0===n?void 0:n[t])||[];o[s]&&(r="".concat(t,"-variant-").concat(s)),null!=(null==N?void 0:N.autoScrollVariantIndex)&&o[N.autoScrollVariantIndex]&&(r="".concat(t,"-variant-").concat(N.autoScrollVariantIndex))}}),r&&z(r)}if(null===k){var v=null!==(t=null==N?void 0:N.activeVariantAccordionIndex)&&void 0!==t?t:null==N?void 0:N.defaultVariantOpen;null!=v&&v>=0&&(null===(l=null===(o=null==N?void 0:N.tierOptions)||void 0===o?void 0:o.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===l||l.forEach(function(i,e){var n;if(!((null==N?void 0:N.defaultTierOpen)>=0&&e!==N.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(n=R.variantsByTier)||void 0===n?void 0:n[t])||[])[v]&&z("".concat(t,"-variant-").concat(v))}}))}pi.current=R.variantsByTier},[R.variantsByTier,null==N?void 0:N.defaultVariantOpen,null==N?void 0:N.activeVariantAccordionIndex,null===(x=R.scopeData)||void 0===x?void 0:x.tiers,null==N?void 0:N.tierOptions,null==N?void 0:N.autoScrollVariantIndex,null==N?void 0:N.defaultTierOpen]);var fi=function(e){M(function(n){var t;return i(i({},n),((t={})[e]=!n[e],t))})},gi=function(i){var e,n,t,o=i.split("_"),l=o[o.length-1],r=/^\d+$/.test(l)?o.slice(0,-1).join("_"):i,a=null===(e=R.fieldCitations)||void 0===e?void 0:e[r];if(Array.isArray(a)&&a.length>0)return a;var d=null===(n=R.fieldCitations)||void 0===n?void 0:n[i];return Array.isArray(d)&&d.length>0?d:null!==(t=R.citations)&&void 0!==t?t:[]},hi={marginTop:"-17px",position:"relative",zIndex:1};l(function(){var i,e;null!=(null==N?void 0:N.autoScrollVariantIndex)&&(null===(e=null===(i=null==N?void 0:N.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===e||e.forEach(function(i){var e=i.toLowerCase().replace(/ /g,"_"),n="".concat(e,"-variant-").concat(N.autoScrollVariantIndex),t=H.current.get(n);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==N?void 0:N.scrollTrigger]),console.log("CreateRule state:",R),console.log("CreateRule uiState:",N);var yi=function(i){return i?i.replace(/_/g," ").replace(/([a-zA-Z])(\d)/g,"$1 $2").replace(/\b\w/g,function(i){return i.toUpperCase()}):"Variant 1"},mi=!!(null==N?void 0:N.activeEditId);return e("div",i({className:"traffic-manager-template"},{children:[n("div",i({"data-edit-id":"rule-setup"},{children:n(s,i({title:{type:"other",label:(null==N?void 0:N.setupLabel)||"Rule Setup"},actionButtons:function(e,t){if(J)return null;var o=!!(null==N?void 0:N.activeEditId)&&"rule-setup"!==N.activeEditId;return n("div",i({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:n("button",i({title:o?"Save active edits first":"Edit",onClick:function(n){n.stopPropagation(),o?(null==N?void 0:N.setPendingEditId)&&N.setPendingEditId(N.activeEditId||null):(!function(){var e,n;(null==N?void 0:N.activeEditId)&&"rule-setup"!==N.activeEditId||(null===(e=null==N?void 0:N.setActiveEditId)||void 0===e||e.call(N,"rule-setup"),U(null!==(n=R.ruleTitle)&&void 0!==n?n:""),Q(R.scopeData?i({},R.scopeData):{}))}(),(null==N?void 0:N.setPendingEditId)&&N.setPendingEditId(null),e||t())},disabled:Y,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:Y?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:Y?.5:1}},{children:n(f,{size:14})}))}))},footerData:{ruleTitle:R.ruleTitle,stations:[R.scopeData.station],tiers:null===(D=R.scopeData)||void 0===D?void 0:D.tiers},defaultOpen:"Create"===(null==N?void 0:N.usedFor),readOnly:"Create"!==(null==N?void 0:N.usedFor),isAiStreaming:null==N?void 0:N.isAiStreaming,editFlow:"Edit"===(null==N?void 0:N.usedFor)},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[Y&&(null==N?void 0:N.isAiStreaming)&&e("div",i({style:{display:"flex",alignItems:"center",color:"#141414ff",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[n(p,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),n(u,i({id:"rule-title",title:N.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:J&&null!==$?$:R.ruleTitle,onChange:function(i){return J?U(i):_.setRuleTitle(i)},readOnly:(null==N?void 0:N.isAiStreaming)||!J,isOpen:F.ruleTitle,onToggle:function(){return fi("ruleTitle")},isHighlighted:L.ruleTitle||!1,showCognitiveIcon:R.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(S=N.validationErrors)||void 0===S?void 0:S.ruleTitle},N)),R.citation.ruleTitle&&n("div",i({style:hi},{children:n(r,{isVisible:F.ruleTitle,citation:R.citation.ruleTitle,citations:gi("ruleTitle"),fieldName:"Rule Title",fieldValue:R.ruleTitle})})),(null===(A=null==N?void 0:N.tierOptions)||void 0===A?void 0:A.length)>1&&n(c,i({id:"scope",title:"",required:!1,scopeData:J&&null!==G?G:R.scopeData,onScopeChange:function(e,n){J?Q(function(t){var o;return i(i({},null!=t?t:R.scopeData),((o={})[e]=n,o))}):_.onScopeChange(e,n)},tierLabel:"Which tier are you configuring this learning for?",stationLabel:"Which scope should this learning belong to?",highlights:L,isOpen:F.scopeData,onToggle:function(){return fi("scopeData")},showCognitiveIcon:R.citation.scopeData,cognitiveIcon:n(v,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(C=N.validationErrors)||void 0===C?void 0:C.station)||(null===(I=N.validationErrors)||void 0===I?void 0:I.tiers),stationErrorMessage:null===(b=N.validationErrors)||void 0===b?void 0:b.station,tierErrorMessage:null===(O=N.validationErrors)||void 0===O?void 0:O.tiers,readOnly:(null==N?void 0:N.isAiStreaming)||!J},N)),R.citation.scopeData&&n("div",i({style:hi},{children:n(r,{isVisible:F.scopeData,citation:R.citation.scopeData,citations:gi("scopeData"),fieldName:"Scope",fieldValue:null===(E=null===(w=R.scopeData)||void 0===w?void 0:w.tiers)||void 0===E?void 0:E.join(", ")})})),J?e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[e("div",i({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[n("button",i({onClick:ni,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e("button",i({onClick:ti,disabled:di,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:di?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:di?.5:1}},{children:[n(g,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==N?void 0:N.pendingEditId)&&e("div",i({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"10px"}},{children:[n(h,{size:14,style:{color:"#C2410C"}}),n("div",i({style:{color:"#C2410C",fontSize:"13px"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]})):null]}))}))})),null===(V=null==N?void 0:N.tierOptions)||void 0===V?void 0:V.map(function(o,l){var c,v,p,f,g,h,m,T=o.toLowerCase().replace(/ /g,"_"),x=(null===(c=R.variantsByTier)||void 0===c?void 0:c[T])||[],D=null===(p=null===(v=R.scopeData)||void 0===v?void 0:v.tiers)||void 0===p?void 0:p.includes(o),S=x.length,A=!1;if(1===S){var C=x[0],I=!(null===(f=null==C?void 0:C.ruleDescription)||void 0===f?void 0:f.trim()),b=(null===(g=null==C?void 0:C.whenToApplyConditions)||void 0===g?void 0:g.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,O=(null===(h=null==C?void 0:C.whenNotToApplyConditions)||void 0===h?void 0:h.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;!I||b||O||(A=!0)}var w=A?void 0:"".concat(S," ").concat(1===S?"variant":"variants"," configured for this tier"),E=n(y,i({onAddVariant:function(){var i;return null===(i=_.addNewVariant)||void 0===i?void 0:i.call(_,T)},isDisabled:!D||(null==N?void 0:N.isAiStreaming),showAddVariantBtn:"Edit"!==(null==N?void 0:N.usedFor)},{children:x.map(function(t,o){var l,c,v,p,f,g,h,y,m,x,S=t.variantType||"default",A="".concat(T,"-variant-").concat(o),C=!0===t.is_variant,I="default"===S||"default_variant"===S,b="".concat(T,"_").concat(o),O=W.get(b)||{},w=(null===(c=null===(l=N.separationItemsByTier)||void 0===l?void 0:l[T])||void 0===c?void 0:c.get(o))||[],E=(null===(p=null===(v=N.togglesByTier)||void 0===v?void 0:v[T])||void 0===p?void 0:p.get(o))||[],V=null===(f=null==N?void 0:N.activeEditId)||void 0===f?void 0:f.startsWith("condition-wta-".concat(T,"-").concat(o)),L=null===(g=null==N?void 0:N.activeEditId)||void 0===g?void 0:g.startsWith("condition-wnta-".concat(T,"-").concat(o)),B=!D||t.isReadOnly||(null==N?void 0:N.isAiStreaming);return n("div",i({ref:function(i){i?H.current.set(A,i):H.current.delete(A)},style:{width:"100%",opacity:D?1:.7}},{children:n(s,i({title:{type:I?"default":"variant",label:yi(S),number:o+1,isNewVariant:C,isDefault:t.isDefault,isModified:t.isModified},defaultOpen:!0,expanded:k===A,onToggle:function(){var i,e=k===A;z(e?null:A),null===(i=null==N?void 0:N.setActiveVariantAccordionIndex)||void 0===i||i.call(N,e?null:o)},variant:"rule-behavior",footerData:{ruleTitle:S,description:t.ruleDescription||""},readOnly:B},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[n(u,i({id:"rule-description-".concat(T,"-").concat(o),title:N.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:B||mi&&(null==N?void 0:N.activeEditId)!=="rule-description-".concat(T,"-").concat(o),value:t.ruleDescription||"",onChange:function(i){return _.setRuleDescription(T,o,i)},isOpen:F["ruleDescription-".concat(T)],onToggle:function(){return fi("ruleDescription-".concat(T))},isHighlighted:O.ruleDescription||!1,showCognitiveIcon:null===(h=R.citation)||void 0===h?void 0:h["ruleDescription_".concat(T)],tooltipDescription:"Why this Description?",errorMessage:null===(y=N.validationErrors)||void 0===y?void 0:y["ruleDescription-".concat(T,"-").concat(o)],enableInlineEdit:!0,setSendMessageInChat:null==N?void 0:N.setSendMessageInChat,isAiStreaming:null==N?void 0:N.isAiStreaming,fieldName:"Rule Description"},N)),(null===(m=R.citation)||void 0===m?void 0:m["ruleDescription_".concat(T)])&&n("div",i({style:hi},{children:n(r,{isVisible:F["ruleDescription-".concat(T)],citation:R.citation["ruleDescription_".concat(T)],citations:gi("ruleDescription_".concat(T,"_").concat(o)),fieldName:"Rule Description",fieldValue:t.ruleDescription})})),n(a,i({id:"when-to-apply-".concat(T,"-").concat(o),idPrefix:"condition-wta",title:N.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:B||mi&&!V,conditions:t.whenToApplyConditions||[],onAdd:function(){return _.addWhenToApply(T,o)},onRemove:function(i,e,n){return _.removeWhenToApply(i,e,n)},onEdit:function(i,e,n,t){return _.editWhenToApply(i,e,n,t)},index:o,tierKey:T,isHighlighted:O.wta||!1,highlightedIds:null==N?void 0:N.highlightedIds,tooltipDescription:"Why this Condition?",citations:gi("whenToApply_".concat(T,"_").concat(o)),bordered:!0,addLabel:(null==N?void 0:N.addWhenToApplyBtnLabel)||"Add When to apply",isAiStreaming:N.isAiStreaming,errorMessage:(null===(x=N.validationErrors)||void 0===x?void 0:x["whenToApply-".concat(T,"-").concat(o)])||(null==N?void 0:N.conflictReason)},N)),n(a,i({id:"when-not-to-apply-".concat(T,"-").concat(o),idPrefix:"condition-wnta",title:N.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:B||mi&&!L,conditions:t.whenNotToApplyConditions||[],onAdd:function(){return _.addWhenNotToApply(T,o)},onRemove:function(i,e,n){return _.removeWhenNotToApply(i,e,n)},onEdit:function(i,e,n,t){return _.editWhenNotToApply(i,e,n,t)},index:o,tierKey:T,isHighlighted:O.wnta||!1,highlightedIds:null==N?void 0:N.highlightedIds,tooltipDescription:"Why this Condition?",citations:gi("whenNotToApply_".concat(T,"_").concat(o)),bordered:!0,addLabel:(null==N?void 0:N.addWhenNotToApplyBtnLabel)||"Add When NOT to apply",isAiStreaming:N.isAiStreaming},N)),(null==N?void 0:N.showConfiguration)&&n(d,i({id:"config-".concat(T,"-").concat(o),title:N.configTitle||"Configuration",required:!1,highlights:O,bordered:!0,readOnly:B||mi&&(null==N?void 0:N.activeEditId)!=="config-".concat(T,"-").concat(o),onConfigChange:function(i,e){return _.onConfigChange(T,o,i,e)},separationItems:w,toggles:E,index:o},N))]}))}),A)}),"".concat(T,"-variant-").concat(o))})}));return 1===(null===(m=null==N?void 0:N.tierOptions)||void 0===m?void 0:m.length)?n(t.Fragment,{children:E},"tier-".concat(l)):n(s,i({variant:"tier-header",title:{type:"other",label:o},subtitle:w,defaultOpen:!0,footerData:{description:"Variants for ".concat(o)}},{children:E}),"tier-".concat(l))})]}))};export{m as CreateRule};
1
+ import{__assign as i}from"tslib";import{jsxs as e,jsx as n}from"react/jsx-runtime";import t,{useState as o,useEffect as l}from"react";import{InputDataReasoningCard as r}from"../../InputDataReasoningCard.js";import{ConditionSection as a}from"../../organisms/ConditionSection/ConditionSection.js";import{ConfigSection as d}from"../../organisms/ConfigSection/ConfigSection.js";import{ScopeSection as c}from"../../organisms/ScopeSection/ScopeSection.js";import{TextSection as u}from"../../organisms/TextSection/TextSection.js";import s from"../../AccordianSection.js";import{ButtonCognitiveIcon as v}from"../../_svg/ButtonCognitiveIcon.js";import{Loader2Icon as p,Pencil as f,Check as g,AlertTriangle as h}from"lucide-react";var y=function(o){var l=o.children,r=o.onAddVariant,a=o.isDisabled,d=o.showAddVariantBtn,c=void 0===d||d,u=t.Children.toArray(l);return e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[u.map(function(i,o){var l=!(o===u.length-1)||c;return e(t.Fragment,{children:[i,l&&n("div",{style:{width:"2px",height:"20px",backgroundColor:"#E2E8F0",marginLeft:"30px"}})]},o)}),c&&n("div",i({onClick:a?void 0:r,style:{padding:"8px 16px",border:"1px solid #E2E8F0",borderRadius:"8px",color:a?"#94a3b8":"#475569",fontSize:"14px",fontWeight:"500",cursor:a?"not-allowed":"pointer",backgroundColor:a?"#f8fafc":"#FFFFFF",opacity:a?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))},m=function(m){var T,x,D,S,A,C,I,b,O,w,E,V,R=m.state,_=m.handlers,N=m.uiState,W=(null==N?void 0:N.highlights)||new Map,L=W.get("global_0")||{},B=o({}),F=B[0],M=B[1],j=o(null),k=j[0],z=j[1],q=o(function(){var i,e,n;if((null==N?void 0:N.defaultTierOpen)>=0&&(null===(i=null==N?void 0:N.tierOptions)||void 0===i?void 0:i[N.defaultTierOpen]))return N.tierOptions[N.defaultTierOpen].toLowerCase().replace(/ /g,"_");var t=null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n[0];return t?t.toLowerCase().replace(/ /g,"_"):null});q[0];var P=q[1],J="rule-setup"===(null==N?void 0:N.activeEditId),H=t.useRef(new Map),K=o(null),$=K[0],U=K[1],Z=o(null),G=Z[0],Q=Z[1],X=o(!1),Y=X[0],ii=X[1],ei=t.useRef(null==N?void 0:N.isAiStreaming);l(function(){ei.current&&!(null==N?void 0:N.isAiStreaming)&&Y&&ii(!1),ei.current=null==N?void 0:N.isAiStreaming},[null==N?void 0:N.isAiStreaming,Y]);var ni=function(){var i;U(null),Q(null),null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null)},ti=function(){var i,e,n=null!=$?$:R.ruleTitle,t=null!=G?G:R.scopeData,o=n!==R.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(R.scopeData);if(!o&&!l)return U(null),Q(null),void(null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null));if(null==N?void 0:N.setSendMessageInChat){var r="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),a=[];if(o&&a.push((null==n?void 0:n.trim())?"Title with ".concat(n):"No Title"),l){var d=null==t?void 0:t.tiers,c=d&&d.length>0?"tiers: ".concat(d.join(", ")):"No Tier Selected";a.push(c)}var u=a.join(" and ");N.setSendMessageInChat("__SKELETON__:".concat(r,":Update Rule Setup ").concat(u))}ii(!0),U(null),Q(null),null===(e=null==N?void 0:N.setActiveEditId)||void 0===e||e.call(N,null)},oi=null!==$?null==$?void 0:$.trim():(R.ruleTitle||"").trim(),li=null!=G?G:R.scopeData,ri=oi!==(R.ruleTitle||"").trim(),ai=JSON.stringify(li)!==JSON.stringify(R.scopeData),di=!ri&&!ai||""===oi,ci=t.useRef(null==N?void 0:N.defaultVariantOpen),ui=t.useRef(null==N?void 0:N.activeVariantAccordionIndex),si=t.useRef(null==N?void 0:N.defaultTierOpen),vi=t.useRef(null===(T=R.scopeData)||void 0===T?void 0:T.tiers),pi=t.useRef(R.variantsByTier);t.useEffect(function(){var i,e,n,t,o,l,r=null,a=!1;ci.current!==(null==N?void 0:N.defaultVariantOpen)&&(a=!0,ci.current=null==N?void 0:N.defaultVariantOpen),ui.current!==(null==N?void 0:N.activeVariantAccordionIndex)&&(a=!0,ui.current=null==N?void 0:N.activeVariantAccordionIndex),si.current!==(null==N?void 0:N.defaultTierOpen)&&(a=!0,si.current=null==N?void 0:N.defaultTierOpen);var d=(null===(i=R.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(vi.current)!==JSON.stringify(d)&&(a=!0,vi.current=d,d.length>0&&P(d[0].toLowerCase().replace(/ /g,"_")));var c=(null===(e=null==N?void 0:N.tierOptions)||void 0===e?void 0:e.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||[],u=c.some(function(i){var e,n,t,o,l=i.toLowerCase().replace(/ /g,"_");return((null===(n=null===(e=pi.current)||void 0===e?void 0:e[l])||void 0===n?void 0:n.length)||0)!==((null===(o=null===(t=R.variantsByTier)||void 0===t?void 0:t[l])||void 0===o?void 0:o.length)||0)});if(u&&(a=!0),a){var s=null!==(n=null==N?void 0:N.activeVariantAccordionIndex)&&void 0!==n?n:null==N?void 0:N.defaultVariantOpen;if(null==s||s<0)return z(null),void(pi.current=R.variantsByTier);c.forEach(function(i,e){var n;if(!((null==N?void 0:N.defaultTierOpen)>=0&&e!==N.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),o=(null===(n=R.variantsByTier)||void 0===n?void 0:n[t])||[];o[s]&&(r="".concat(t,"-variant-").concat(s)),null!=(null==N?void 0:N.autoScrollVariantIndex)&&o[N.autoScrollVariantIndex]&&(r="".concat(t,"-variant-").concat(N.autoScrollVariantIndex))}}),r&&z(r)}if(null===k){var v=null!==(t=null==N?void 0:N.activeVariantAccordionIndex)&&void 0!==t?t:null==N?void 0:N.defaultVariantOpen;null!=v&&v>=0&&(null===(l=null===(o=null==N?void 0:N.tierOptions)||void 0===o?void 0:o.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===l||l.forEach(function(i,e){var n;if(!((null==N?void 0:N.defaultTierOpen)>=0&&e!==N.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(n=R.variantsByTier)||void 0===n?void 0:n[t])||[])[v]&&z("".concat(t,"-variant-").concat(v))}}))}pi.current=R.variantsByTier},[R.variantsByTier,null==N?void 0:N.defaultVariantOpen,null==N?void 0:N.activeVariantAccordionIndex,null===(x=R.scopeData)||void 0===x?void 0:x.tiers,null==N?void 0:N.tierOptions,null==N?void 0:N.autoScrollVariantIndex,null==N?void 0:N.defaultTierOpen]);var fi=function(e){M(function(n){var t;return i(i({},n),((t={})[e]=!n[e],t))})},gi=function(i){var e,n,t,o=i.split("_"),l=o[o.length-1],r=/^\d+$/.test(l)?o.slice(0,-1).join("_"):i,a=null===(e=R.fieldCitations)||void 0===e?void 0:e[r];if(Array.isArray(a)&&a.length>0)return a;var d=null===(n=R.fieldCitations)||void 0===n?void 0:n[i];return Array.isArray(d)&&d.length>0?d:null!==(t=R.citations)&&void 0!==t?t:[]},hi={marginTop:"-17px",position:"relative",zIndex:1};l(function(){var i,e;null!=(null==N?void 0:N.autoScrollVariantIndex)&&(null===(e=null===(i=null==N?void 0:N.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===e||e.forEach(function(i){var e=i.toLowerCase().replace(/ /g,"_"),n="".concat(e,"-variant-").concat(N.autoScrollVariantIndex),t=H.current.get(n);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==N?void 0:N.scrollTrigger]),console.log("CreateRule state:",R),console.log("CreateRule uiState:",N);var yi=function(i){return i?i.replace(/_/g," ").replace(/([a-zA-Z])(\d)/g,"$1 $2").replace(/\b\w/g,function(i){return i.toUpperCase()}):"Variant 1"},mi=!!(null==N?void 0:N.activeEditId);return e("div",i({className:"traffic-manager-template"},{children:[n("div",i({"data-edit-id":"rule-setup"},{children:n(s,i({title:{type:"other",label:(null==N?void 0:N.setupLabel)||"Rule Setup"},actionButtons:function(e,t){if(J)return null;var o=!!(null==N?void 0:N.activeEditId)&&"rule-setup"!==N.activeEditId;return n("div",i({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:n("button",i({title:o?"Save active edits first":"Edit",onClick:function(n){n.stopPropagation(),o?(null==N?void 0:N.setPendingEditId)&&N.setPendingEditId(N.activeEditId||null):(!function(){var e,n;(null==N?void 0:N.activeEditId)&&"rule-setup"!==N.activeEditId||(null===(e=null==N?void 0:N.setActiveEditId)||void 0===e||e.call(N,"rule-setup"),U(null!==(n=R.ruleTitle)&&void 0!==n?n:""),Q(R.scopeData?i({},R.scopeData):{}))}(),(null==N?void 0:N.setPendingEditId)&&N.setPendingEditId(null),e||t())},disabled:Y,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:Y?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:Y?.5:1}},{children:n(f,{size:14})}))}))},footerData:{ruleTitle:R.ruleTitle,stations:[R.scopeData.station],tiers:null===(D=R.scopeData)||void 0===D?void 0:D.tiers},defaultOpen:"Create"===(null==N?void 0:N.usedFor),readOnly:"Create"!==(null==N?void 0:N.usedFor),isAiStreaming:null==N?void 0:N.isAiStreaming,editFlow:"Edit"===(null==N?void 0:N.usedFor)},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[Y&&(null==N?void 0:N.isAiStreaming)&&e("div",i({style:{display:"flex",alignItems:"center",color:"#141414ff",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[n(p,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),n(u,i({id:"rule-title",title:N.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:J&&null!==$?$:R.ruleTitle,onChange:function(i){return J?U(i):_.setRuleTitle(i)},readOnly:(null==N?void 0:N.isAiStreaming)||!J,isOpen:F.ruleTitle,onToggle:function(){return fi("ruleTitle")},isHighlighted:L.ruleTitle||!1,showCognitiveIcon:R.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(S=N.validationErrors)||void 0===S?void 0:S.ruleTitle},N)),R.citation.ruleTitle&&n("div",i({style:hi},{children:n(r,{isVisible:F.ruleTitle,citation:R.citation.ruleTitle,citations:gi("ruleTitle"),fieldName:"Rule Title",fieldValue:R.ruleTitle})})),(null===(A=null==N?void 0:N.tierOptions)||void 0===A?void 0:A.length)>1&&n(c,i({id:"scope",title:"",required:!1,scopeData:J&&null!==G?G:R.scopeData,onScopeChange:function(e,n){J?Q(function(t){var o;return i(i({},null!=t?t:R.scopeData),((o={})[e]=n,o))}):_.onScopeChange(e,n)},tierLabel:"Which tier are you configuring this learning for?",stationLabel:"Which scope should this learning belong to?",highlights:L,isOpen:F.scopeData,onToggle:function(){return fi("scopeData")},showCognitiveIcon:R.citation.scopeData,cognitiveIcon:n(v,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(C=N.validationErrors)||void 0===C?void 0:C.station)||(null===(I=N.validationErrors)||void 0===I?void 0:I.tiers),stationErrorMessage:null===(b=N.validationErrors)||void 0===b?void 0:b.station,tierErrorMessage:null===(O=N.validationErrors)||void 0===O?void 0:O.tiers,readOnly:(null==N?void 0:N.isAiStreaming)||!J},N)),R.citation.scopeData&&n("div",i({style:hi},{children:n(r,{isVisible:F.scopeData,citation:R.citation.scopeData,citations:gi("scopeData"),fieldName:"Scope",fieldValue:null===(E=null===(w=R.scopeData)||void 0===w?void 0:w.tiers)||void 0===E?void 0:E.join(", ")})})),J?e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[e("div",i({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[n("button",i({onClick:ni,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e("button",i({onClick:ti,disabled:di,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:di?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:di?.5:1}},{children:[n(g,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==N?void 0:N.pendingEditId)&&e("div",i({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"10px"}},{children:[n(h,{size:14,style:{color:"#C2410C"}}),n("div",i({style:{color:"#C2410C",fontSize:"13px"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]})):null]}))}))})),null===(V=null==N?void 0:N.tierOptions)||void 0===V?void 0:V.map(function(o,l){var c,v,p,f,g,h,m,T=o.toLowerCase().replace(/ /g,"_"),x=(null===(c=R.variantsByTier)||void 0===c?void 0:c[T])||[],D=null===(p=null===(v=R.scopeData)||void 0===v?void 0:v.tiers)||void 0===p?void 0:p.includes(o),S=x.length,A=!1;if(1===S){var C=x[0],I=!(null===(f=null==C?void 0:C.ruleDescription)||void 0===f?void 0:f.trim()),b=(null===(g=null==C?void 0:C.whenToApplyConditions)||void 0===g?void 0:g.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,O=(null===(h=null==C?void 0:C.whenNotToApplyConditions)||void 0===h?void 0:h.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;!I||b||O||(A=!0)}var w=A?void 0:"".concat(S," ").concat(1===S?"variant":"variants"," configured for this tier"),E=n(y,i({onAddVariant:function(){var i;return null===(i=_.addNewVariant)||void 0===i?void 0:i.call(_,T)},isDisabled:!D||(null==N?void 0:N.isAiStreaming),showAddVariantBtn:"Edit"!==(null==N?void 0:N.usedFor)},{children:x.map(function(t,o){var l,c,v,p,f,g,h,y,m,x,S=t.variantType||"default",A="".concat(T,"-variant-").concat(o),C=!0===t.is_variant,I="default"===S||"default_variant"===S,b="".concat(T,"_").concat(o),O=W.get(b)||{},w=(null===(c=null===(l=N.separationItemsByTier)||void 0===l?void 0:l[T])||void 0===c?void 0:c.get(o))||[],E=(null===(p=null===(v=N.togglesByTier)||void 0===v?void 0:v[T])||void 0===p?void 0:p.get(o))||[],V=null===(f=null==N?void 0:N.activeEditId)||void 0===f?void 0:f.startsWith("condition-wta-".concat(T,"-").concat(o)),L=null===(g=null==N?void 0:N.activeEditId)||void 0===g?void 0:g.startsWith("condition-wnta-".concat(T,"-").concat(o)),B=!D||t.isReadOnly||(null==N?void 0:N.isAiStreaming);return n("div",i({ref:function(i){i?H.current.set(A,i):H.current.delete(A)},style:{width:"100%",opacity:D?1:.7}},{children:n(s,i({title:{type:I?"default":"variant",label:yi(S),number:o+1,isNewVariant:C,isDefault:t.isDefault,isModified:t.isModified},defaultOpen:!0,expanded:1==(null==N?void 0:N.tierOptions.length)||k===A,onToggle:function(){var i,e=k===A;z(e?null:A),null===(i=null==N?void 0:N.setActiveVariantAccordionIndex)||void 0===i||i.call(N,e?null:o)},variant:"rule-behavior",footerData:{ruleTitle:S,description:t.ruleDescription||""},readOnly:B},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[n(u,i({id:"rule-description-".concat(T,"-").concat(o),title:N.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:B||mi&&(null==N?void 0:N.activeEditId)!=="rule-description-".concat(T,"-").concat(o),value:t.ruleDescription||"",onChange:function(i){return _.setRuleDescription(T,o,i)},isOpen:F["ruleDescription-".concat(T)],onToggle:function(){return fi("ruleDescription-".concat(T))},isHighlighted:O.ruleDescription||!1,showCognitiveIcon:null===(h=R.citation)||void 0===h?void 0:h["ruleDescription_".concat(T)],tooltipDescription:"Why this Description?",errorMessage:null===(y=N.validationErrors)||void 0===y?void 0:y["ruleDescription-".concat(T,"-").concat(o)],enableInlineEdit:!0,setSendMessageInChat:null==N?void 0:N.setSendMessageInChat,isAiStreaming:null==N?void 0:N.isAiStreaming,fieldName:"Rule Description"},N)),(null===(m=R.citation)||void 0===m?void 0:m["ruleDescription_".concat(T)])&&n("div",i({style:hi},{children:n(r,{isVisible:F["ruleDescription-".concat(T)],citation:R.citation["ruleDescription_".concat(T)],citations:gi("ruleDescription_".concat(T,"_").concat(o)),fieldName:"Rule Description",fieldValue:t.ruleDescription})})),n(a,i({id:"when-to-apply-".concat(T,"-").concat(o),idPrefix:"condition-wta",title:N.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:B||mi&&!V,conditions:t.whenToApplyConditions||[],onAdd:function(){return _.addWhenToApply(T,o)},onRemove:function(i,e,n){return _.removeWhenToApply(i,e,n)},onEdit:function(i,e,n,t){return _.editWhenToApply(i,e,n,t)},index:o,tierKey:T,isHighlighted:O.wta||!1,highlightedIds:null==N?void 0:N.highlightedIds,tooltipDescription:"Why this Condition?",citations:gi("whenToApply_".concat(T,"_").concat(o)),bordered:!0,addLabel:(null==N?void 0:N.addWhenToApplyBtnLabel)||"Add When to apply",isAiStreaming:N.isAiStreaming,errorMessage:(null===(x=N.validationErrors)||void 0===x?void 0:x["whenToApply-".concat(T,"-").concat(o)])||(null==N?void 0:N.conflictReason)},N)),n(a,i({id:"when-not-to-apply-".concat(T,"-").concat(o),idPrefix:"condition-wnta",title:N.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:B||mi&&!L,conditions:t.whenNotToApplyConditions||[],onAdd:function(){return _.addWhenNotToApply(T,o)},onRemove:function(i,e,n){return _.removeWhenNotToApply(i,e,n)},onEdit:function(i,e,n,t){return _.editWhenNotToApply(i,e,n,t)},index:o,tierKey:T,isHighlighted:O.wnta||!1,highlightedIds:null==N?void 0:N.highlightedIds,tooltipDescription:"Why this Condition?",citations:gi("whenNotToApply_".concat(T,"_").concat(o)),bordered:!0,addLabel:(null==N?void 0:N.addWhenNotToApplyBtnLabel)||"Add When NOT to apply",isAiStreaming:N.isAiStreaming},N)),(null==N?void 0:N.showConfiguration)&&n(d,i({id:"config-".concat(T,"-").concat(o),title:N.configTitle||"Configuration",required:!1,highlights:O,bordered:!0,readOnly:B||mi&&(null==N?void 0:N.activeEditId)!=="config-".concat(T,"-").concat(o),onConfigChange:function(i,e){return _.onConfigChange(T,o,i,e)},separationItems:w,toggles:E,index:o},N))]}))}),A)}),"".concat(T,"-variant-").concat(o))})}));return 1===(null===(m=null==N?void 0:N.tierOptions)||void 0===m?void 0:m.length)?n(t.Fragment,{children:E},"tier-".concat(l)):n(s,i({variant:"tier-header",title:{type:"other",label:o},subtitle:w,defaultOpen:!0,footerData:{description:"Variants for ".concat(o)}},{children:E}),"tier-".concat(l))})]}))};export{m as CreateRule};
2
2
  //# sourceMappingURL=CreateRule.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 i,Fragment as s}from"react/jsx-runtime";import{useState as a,useRef as c,useEffect as l}from"react";import{BookOpen as u,Users as d,History as p}from"lucide-react";import{useLearningTemplateStore as m}from"./store/useLearningTemplateStore.js";import{Toast as f}from"primereact/toast";import v from"./styles/LearningTemplateManagement.module.css.js";import g from"./LearningTemplateLayout.js";import h from"./components/EmptyLearningState.js";import y from"./store/useAuthStore.js";import{fetchTiers as S,getILInstance as b,fetchScopes as C,inheritScope as T,inheritScopeBackwardCompatible as L,createRuleSet as E,renameScope as I,deleteRuleSet as A,requestAccess as w}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as O,setQueryParams as j}from"./hooks/useLearningTemplateQueryParams.js";import R from"./components/ConfirmationModal.js";import _ from"./components/LearningTemplateManagementSkeleton.js";import{findNodePathById as N}from"./utils/treeUtils.js";import k from"./store/useEnvStore.js";import{useConfigStore as D}from"./store/useConfigStore.js";import{TooltipProvider as M}from"./components/ToolTip.js";import P from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as U}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as G}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as B}from"./queries/useApprovalQueries.js";import{useLMSConfigQuery as F}from"./queries/useLMSConfigQuery.js";import q from"./RuleContent/AddScopeModal.js";import x from"./components/RuleContentSkeleton.js";import H from"./components/ErrorStateDisplay.js";import{useLocation as Q}from"react-router-dom";import z from"./shared/SuccessToastContent.js";import K from"./shared/ErrorToastContent.js";import V from"./RuleContent/RenameScopeModal.js";import{dt as W}from"./store/useLMSConfigStore.js";import{MIDDLE_DRAWER_DT_PATH as Y,MIDDLE_DRAWER_CONTEXT_MENU_DT_PATH as J}from"./constants.js";function X(X){var Z,$,ee,ne=this,te=X.userDetails,re=X.llmStudioUrl,oe=X.audacyBackendUrl,ie=X.ilLabels,se=X.config,ae=X.rbacConfig,ce=X.auditLogConfig,le=X.app_integration_id,ue=X.backwardCompatibility,de=void 0!==ue&&ue,pe=m(function(e){return e.selectedRuleSetId}),me=m(function(e){return e.setSelectedRuleSetId}),fe=m(function(e){return e.error}),ve=m(function(e){return e.setError}),ge=m(function(e){return e.setStations}),he=m(function(e){return e.scopeTreeData}),ye=m(function(e){return e.setScopeTreeData}),Se=a({isOpen:!1,type:"GLOBAL"}),be=Se[0],Ce=Se[1],Te=a(!1),Le=Te[0],Ee=Te[1],Ie=a(!1),Ae=Ie[0],we=Ie[1],Oe=a("learnings"),je=Oe[0],Re=Oe[1],_e=a(null),Ne=_e[0],ke=_e[1],De=a(null),Me=De[0],Pe=De[1],Ue=c(null),Ge=c(null),Be=c(!1),Fe=c(null),qe=y();qe.user;var xe=qe.setUser,He=D(),Qe=He.setConfig,ze=He.setIlLabels,Ke=function(){try{return Q()}catch(e){return{search:""}}}();l(function(){if(!Be.current){var e=new URLSearchParams(window.location.search),n=e.get(O.RULESET_ID),t=e.get(O.SECTION),r=t&&fn.has(t)?t:"learnings";(null==n?void 0:n.length)&&me&&Re&&(me(n),Re(r),Be.current=!0)}},[null==Ke?void 0:Ke.search,Re,me]);var Ve=U(function(e){return e.fetchPermissions}),We=U(function(e){return e.hasPermission}),Ye=G(function(e){return e.setRoles}),Je=k(function(e){return e.appsecRbacUrl})===ae.appsecRbacUrl,Xe=B(ae.applicationId,Je).data,Ze=F(null!=le?le:"",de),$e=Ze.isLoading,en=Ze.isError,nn=Ze.refetch;Ze.isSuccess;var tn=a(0),rn=tn[0],on=tn[1];l(function(){if(!de&&le&&re){t(ne,void 0,void 0,function(){var e,n,t,o,i;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,b(le)];case 1:return e=r.sent(),"number"==typeof(n=null===(i=null===(o=null==e?void 0:e.learningManagement)||void 0===o?void 0:o.scopeAndHierarchy)||void 0===i?void 0:i.maxHierarchyLevels)&&n>0&&on(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]}})})}},[le,re]),l(function(){Xe&&Ye(Xe.map(function(e){return{_id:e._id,name:e.name}}))},[Xe,Ye]),l(function(){var e;console.log("userDetails",te),xe(te),console.log("llmStudioUrl",re),console.log("audacyBackendUrl",oe),k.getState().setLlmStudioUrl(re),k.getState().setAudacyBackendUrl(oe),k.getState().setRbacConfig(ae),k.getState().setAuditLogConfig(ce),Qe(se),ze(ie),m.getState().setAppIntegrationId(null!=le?le:null),m.getState().setBackwardCompatibility(de),m.getState().setToken(null!==(e=null==te?void 0:te.accessToken)&&void 0!==e?e:null)},[te,xe,re,oe,ae,ce,se,Qe,ie,ze,le,de]),l(function(){(null==te?void 0:te.accessToken)&&re&&S()},[le,null==te?void 0:te.accessToken,re]);var sn=function(n){return void 0===n&&(n=!0),t(ne,void 0,void 0,function(){var t,o,i,s,a,c;return r(this,function(r){switch(r.label){case 0:n&&Ee(!0),ve(null),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Ve(ae.applicationId)];case 2:return r.sent(),t=function(n){if(!U.getState().hasPermission("ilotj.scope.view",n.id))return null;var r=n.children?n.children.map(function(e){return t(e)}).filter(function(e){return null!==e}):[];return e(e({},n),{children:r})},[4,C(le,te.accessToken)];case 3:return(o=r.sent())&&o.data&&o.data.data&&(i=o.data.data,Array.isArray(i)&&(i=i.length>0?i[0]:null),i?(s=t(i))?(ke(null),ye({data:s}),Ge.current?(me(Ge.current),Re("learnings"),Ge.current=null):m.getState().selectedRuleSetId||me(s.id)):(ke(null!==(c=i.id)&&void 0!==c?c:null),ye(null)):(ke(null),ye(null))),[3,6];case 4:return a=r.sent(),console.error("Failed to fetch rule sets or permissions",a),ve("Failed to load data. Please try again later."),[3,6];case 5:return Ee(!1),[7];case 6:return[2]}})})};l(function(){var e;(null===(e=null==te?void 0:te.accessToken)||void 0===e?void 0:e.length)&&Je?sn(!0):console.warn("Error: Trying to fetch rules without access token",te)},[null==te?void 0:te.accessToken,ve,ge,ae.applicationId,Je]);var an=function(n,o,i){return t(ne,void 0,void 0,function(){var t,o,i,s,a,c,l,u;return r(this,function(r){switch(r.label){case 0:we(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,A(n,te.accessToken)];case 2:return r.sent(),m.getState().selectedRuleSetId===n&&(t=m.getState().scopeTreeData,(o=N((null==t?void 0:t.data)||null,n))&&o.length>1&&(i=o[o.length-2],me(i),Re("learnings"))),[4,sn(!0)];case 3:return r.sent(),Ce(function(n){return e(e({},n),{isOpen:!1})}),null===(a=Fe.current)||void 0===a||a.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return s=r.sent(),console.error("An error occurred during scope deletion.",s),null===(c=Fe.current)||void 0===c||c.show({severity:"error",summary:"Delete Failed",detail:(null===(u=null===(l=null==s?void 0:s.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 we(!1),[7];case 6:return[2]}})})},cn=he,ln=Me?{data:{id:Me.stationId,name:Me.stationName,type:"STATION",metrics:{learningsCount:Me.learningsCount,stationsCount:0},children:[]}}:cn,un=!!(null==ln?void 0:ln.data);null===(Z=null==ln?void 0:ln.data)||void 0===Z||Z.type;var dn=U(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",ae.applicationResourceId||"");if($e)return o("div",e({className:v.learningManagementContainer},{children:o(x,{})}));if(en)return o("div",e({className:v.learningManagementContainer},{children:o(H,{errorMessage:"Failed to load configuration. Please try again.",onRetry:function(){return nn()},title:"Error Loading Configuration"})}));var pn=n(n([{type:"GLOBAL",label:"Global",addChildLabel:"".concat(W("".concat(Y,".addScope"),"Add Scope")),addChildType:"SCOPE"}],Array.from({length:rn},function(){return e({type:"SCOPE",label:W("".concat(Y,".scope"),"Scope")},!de&&{addChildLabel:W("".concat(J,".addSubScope"),"Add Subscope"),addChildType:"SUBSCOPE"})}),!0),de?[]:[{type:"SUBSCOPE",label:W("".concat(Y,".subScope"),"Subscope")}],!0),mn=[{id:"learnings",label:W("".concat(Y,".treeMenu.submenu.learnings"),"Learnings"),icon:u,badgeKey:"learningsCount"},{id:"access",label:W("".concat(Y,".treeMenu.submenu.access"),"Access"),icon:d},{id:"history",label:W("".concat(Y,".treeMenu.submenu.changeHistory"),"Change History"),icon:p}],fn=new Set(mn.map(function(e){return e.id})),vn=Me?mn.filter(function(e){return"stations"!==e.id}):mn;return o(M,{children:i("div",e({className:v.learningManagementContainer},{children:[o("div",e({className:v.mainWrapper},{children:Le?o(_,{}):fe?i("div",e({className:v.errorContainer},{children:[o("div",e({className:v.errorTitle},{children:"Error Loading Data"})),o("p",e({className:v.errorDesc},{children:fe})),o("button",e({onClick:function(){return sn(!0)},className:v.tryAgainBtn},{children:"Try Again"}))]})):un?o(g,{onOpenCreateModal:function(){return Ce({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,n,t){return Ce({isOpen:!0,type:n,parentId:e,parentName:t})},onRenameChild:function(e,n){return Ce({isOpen:!0,type:"RENAME",scopeId:e,initialName:n})},onDeleteChild:function(e,n,o){return t(ne,void 0,void 0,function(){var t,i,s;return r(this,function(r){switch(r.label){case 0:return t=m.getState().scopeTreeData,i=N((null==t?void 0:t.data)||null,e),s=!!i&&3===i.length,0!==o?[3,2]:[4,an(e)];case 1:return r.sent(),[3,3];case 2:Ce({isOpen:!0,type:"DELETE",scopeId:e,initialName:n,isSubscope:s}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return We("ilotj.scope.delete",e)},canEditScope:function(e){return We("ilotj.scope.edit",e)},canCreateScope:function(e){return We("ilotj.scope.create",e)},onSectionSelect:function(e,n){var t;console.log("Section Selected:",{scopeId:e,sectionId:n}),j(((t={})[O.SECTION]="learnings"===n?null:n,t[O.RULESET_ID]=e,t)),Re(n),me(e)},activeSectionId:je,scopeTreeData:ln,sectionsConfig:vn,onViewStation:function(e){Ue.current=pe,Pe(e),Re("learnings"),me(e.stationId)},onRefreshRuleSets:function(e,n){void 0===e&&(e=!0),n&&(Ge.current=n),sn(e)},nodeTypesConfig:pn,app_integration_id:le,token:te.accessToken}):o(h,{onCreate:function(){return Ce({isOpen:!0,type:"GLOBAL"})},title:"No Global Scope has been added!",desc:"Start by creating a Global scope to define base learnings that apply across all stations.",button:"Create Global Scope",canCreateRule:dn,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return t(ne,void 0,void 0,function(){var e,n,t,i,s,a,c,l,u;return r(this,function(r){switch(r.label){case 0:if(!(e=(null===(i=null===(t=m.getState().scopeTreeData)||void 0===t?void 0:t.data)||void 0===i?void 0:i.id)||Ne))return null===(s=Fe.current)||void 0===s||s.show({severity:"error",sticky:!1,className:v.errorToast,content:o(K,{message:"Unable to identify the global scope for this access request."})}),[2];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,w(e)];case 2:return r.sent(),null===(a=Fe.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:v.successToast,content:o(z,{message:"Access request submitted successfully!"})}),[3,4];case 3:return n=r.sent(),null===(c=Fe.current)||void 0===c||c.show({severity:"error",sticky:!1,className:v.errorToast,content:o(K,{message:(null===(u=null===(l=null==n?void 0:n.response)||void 0===l?void 0:l.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),o(f,{ref:Fe,pt:{root:{style:{zIndex:9999}}}}),de&&be.isOpen&&"DELETE"!==be.type&&"RENAME"!==be.type?o(P,{isOpen:!0,onClose:function(){return Ce(e(e({},be),{isOpen:!1}))},onSubmit:function(n){return t(ne,void 0,void 0,function(){var t,o,i,s,a,c,l,u,d,p,f,v,g,h,y,S,b,C,I,A;return r(this,function(r){switch(r.label){case 0:we(!0),t=m.getState().backwardCompatibility,r.label=1;case 1:return r.trys.push([1,12,13,14]),o=void 0,t&&"object"==typeof n?o=n:(i=n,s="SCOPE"===be.type&&be.parentId,a=s?"genreRuleSet":be.type,o={topic:a,scope_reference_id:null,scopeDescription:"demo",parentScopeId:be.parentId||null,scopeName:i,scopeReferenceMetadata:{},applicationMappingId:le}),[4,E(o,te.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(Ge.current=l,u=t&&(null===(y=o.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),d=!t&&"GLOBAL"!==be.type&&be.parentId,!u&&!d)return[3,10];if(!(p=t?null===(b=null===(S=m.getState().scopeTreeData)||void 0===S?void 0:S.data)||void 0===b?void 0:b.id:be.parentId))return[3,10];if(!de)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 f=r.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,6];case 6:return[3,10];case 7:return r.trys.push([7,9,,10]),[4,T({source_scope_id:p,target_scope_id:l,application_mapping_id:le||"",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,sn(!0)];case 11:return r.sent(),Ce(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=Fe.current)||void 0===C||C.show({severity:"error",summary:"Creation Failed",detail:(null===(A=null===(I=null==g?void 0:g.response)||void 0===I?void 0:I.data)||void 0===A?void 0:A.message)||"There was an error creating the scope. Please try again."}),g;case 13:return we(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:un,canCreateGlobal:dn,globalScopeId:null!==(ee=null===($=null==he?void 0:he.data)||void 0===$?void 0:$.id)&&void 0!==ee?ee:null}):i(s,{children:[o(q,{isOpen:be.isOpen&&"DELETE"!==be.type&&"RENAME"!==be.type,onClose:function(){return Ce(e(e({},be),{isOpen:!1}))},onCreate:function(e){e&&(Ge.current=e),sn(!0)},hasGlobalRuleSet:un,parentId:be.parentId}),o(V,{isOpen:be.isOpen&&"RENAME"===be.type,onClose:function(){return Ce(e(e({},be),{isOpen:!1}))},onSave:function(n){return t(ne,void 0,void 0,function(){var t,i,s,a,c,l;return r(this,function(r){switch(r.label){case 0:we(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),be.scopeId?(t=m.getState().backwardCompatibility,i=t?{scope_id:be.scopeId,scope_name:n}:{scope_id:be.scopeId,scope_type:"Custom",scope_name:n,description:"demo",application_mapping_id:le},[4,I(i,te.accessToken)]):[2];case 2:return r.sent(),[4,sn(!0)];case 3:return r.sent(),Ce(function(n){return e(e({},n),{isOpen:!1})}),[3,6];case 4:throw s=r.sent(),console.error("An error occurred during scope rename.",s),null===(a=Fe.current)||void 0===a||a.show({severity:"error",sticky:!1,className:v.errorToast,content:o(K,{message:(null===(l=null===(c=null==s?void 0:s.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."})}),s;case 5:return we(!1),[7];case 6:return[2]}})})},initialName:be.initialName})]}),o(R,{isOpen:be.isOpen&&"DELETE"===be.type,onCancel:function(){return Ce(e(e({},be),{isOpen:!1}))},onConfirm:function(){return an(be.scopeId,be.initialName,be.isSubscope)},title:"Delete Scope",description:i(s,{children:["Deleting ",o("span",e({className:v.highlight},{children:be.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{X as default};
1
+ import{__assign as e,__spreadArray as n,__awaiter as t,__generator as r}from"tslib";import{jsx as o,jsxs as i,Fragment as s}from"react/jsx-runtime";import{useState as a,useRef as c,useEffect as l}from"react";import{BookOpen as u,Users as d,History as p}from"lucide-react";import{useLearningTemplateStore as m}from"./store/useLearningTemplateStore.js";import{Toast as f}from"primereact/toast";import v from"./styles/LearningTemplateManagement.module.css.js";import g from"./LearningTemplateLayout.js";import h from"./components/EmptyLearningState.js";import y from"./store/useAuthStore.js";import{fetchTiers as S,getILInstance as b,fetchScopes as C,inheritScope as T,inheritScopeBackwardCompatible as L,createRuleSet as E,renameScope as I,deleteRuleSet as A,requestAccess as w}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as O,setQueryParams as j}from"./hooks/useLearningTemplateQueryParams.js";import R from"./components/ConfirmationModal.js";import _ from"./components/LearningTemplateManagementSkeleton.js";import{findNodePathById as N}from"./utils/treeUtils.js";import k from"./store/useEnvStore.js";import{useConfigStore as D}from"./store/useConfigStore.js";import{TooltipProvider as M}from"./components/ToolTip.js";import P from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as U}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as G}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as B}from"./queries/useApprovalQueries.js";import{useLMSConfigQuery as F}from"./queries/useLMSConfigQuery.js";import q from"./RuleContent/AddScopeModal.js";import x from"./components/RuleContentSkeleton.js";import H from"./components/ErrorStateDisplay.js";import{useLocation as Q}from"react-router-dom";import z from"./shared/SuccessToastContent.js";import K from"./shared/ErrorToastContent.js";import V from"./RuleContent/RenameScopeModal.js";import{dt as W}from"./store/useLMSConfigStore.js";import{MIDDLE_DRAWER_DT_PATH as Y,MIDDLE_DRAWER_CONTEXT_MENU_DT_PATH as J}from"./constants.js";function X(X){var Z,$,ee,ne=this,te=X.userDetails,re=X.llmStudioUrl,oe=X.audacyBackendUrl,ie=X.ilLabels,se=X.config,ae=X.rbacConfig,ce=X.auditLogConfig,le=X.app_integration_id,ue=X.backwardCompatibility,de=void 0!==ue&&ue,pe=X.modeId,me=m(function(e){return e.selectedRuleSetId}),fe=m(function(e){return e.setSelectedRuleSetId}),ve=m(function(e){return e.error}),ge=m(function(e){return e.setError}),he=m(function(e){return e.setStations}),ye=m(function(e){return e.scopeTreeData}),Se=m(function(e){return e.setScopeTreeData}),be=a({isOpen:!1,type:"GLOBAL"}),Ce=be[0],Te=be[1],Le=a(!1),Ee=Le[0],Ie=Le[1],Ae=a(!1),we=Ae[0],Oe=Ae[1],je=a("learnings"),Re=je[0],_e=je[1],Ne=a(null),ke=Ne[0],De=Ne[1],Me=a(null),Pe=Me[0],Ue=Me[1],Ge=c(null),Be=c(null),Fe=c(!1),qe=c(null),xe=y();xe.user;var He=xe.setUser,Qe=D(),ze=Qe.setConfig,Ke=Qe.setIlLabels,Ve=function(){try{return Q()}catch(e){return{search:""}}}();l(function(){if(!Fe.current){var e=new URLSearchParams(window.location.search),n=e.get(O.RULESET_ID),t=e.get(O.SECTION),r=t&&vn.has(t)?t:"learnings";(null==n?void 0:n.length)&&fe&&_e&&(fe(n),_e(r),Fe.current=!0)}},[null==Ve?void 0:Ve.search,_e,fe]);var We=U(function(e){return e.fetchPermissions}),Ye=U(function(e){return e.hasPermission}),Je=G(function(e){return e.setRoles}),Xe=k(function(e){return e.appsecRbacUrl})===ae.appsecRbacUrl,Ze=B(ae.applicationId,Xe).data,$e=F(null!=le?le:"",de),en=$e.isLoading,nn=$e.isError,tn=$e.refetch;$e.isSuccess;var rn=a(0),on=rn[0],sn=rn[1];l(function(){if(!de&&le&&re){t(ne,void 0,void 0,function(){var e,n,t,o,i;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,b(le)];case 1:return e=r.sent(),"number"==typeof(n=null===(i=null===(o=null==e?void 0:e.learningManagement)||void 0===o?void 0:o.scopeAndHierarchy)||void 0===i?void 0:i.maxHierarchyLevels)&&n>0&&sn(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]}})})}},[le,re]),l(function(){Ze&&Je(Ze.map(function(e){return{_id:e._id,name:e.name}}))},[Ze,Je]),l(function(){var e;console.log("userDetails",te),He(te),console.log("llmStudioUrl",re),console.log("audacyBackendUrl",oe),k.getState().setLlmStudioUrl(re),k.getState().setAudacyBackendUrl(oe),k.getState().setRbacConfig(ae),k.getState().setAuditLogConfig(ce),ze(se),Ke(ie),m.getState().setAppIntegrationId(null!=le?le:null),m.getState().setBackwardCompatibility(de),m.getState().setToken(null!==(e=null==te?void 0:te.accessToken)&&void 0!==e?e:null)},[te,He,re,oe,ae,ce,se,ze,ie,Ke,le,de]),l(function(){(null==te?void 0:te.accessToken)&&re&&S()},[le,null==te?void 0:te.accessToken,re]);var an=function(n){return void 0===n&&(n=!0),t(ne,void 0,void 0,function(){var t,o,i,s,a,c;return r(this,function(r){switch(r.label){case 0:n&&Ie(!0),ge(null),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,We(ae.applicationId)];case 2:return r.sent(),t=function(n){if(!U.getState().hasPermission("ilotj.scope.view",n.id))return null;var r=n.children?n.children.map(function(e){return t(e)}).filter(function(e){return null!==e}):[];return e(e({},n),{children:r})},[4,C(le,te.accessToken)];case 3:return(o=r.sent())&&o.data&&o.data.data&&(i=o.data.data,Array.isArray(i)&&(i=i.length>0?i[0]:null),i?(s=t(i))?(De(null),Se({data:s}),Be.current?(fe(Be.current),_e("learnings"),Be.current=null):m.getState().selectedRuleSetId||fe(s.id)):(De(null!==(c=i.id)&&void 0!==c?c:null),Se(null)):(De(null),Se(null))),[3,6];case 4:return a=r.sent(),console.error("Failed to fetch rule sets or permissions",a),ge("Failed to load data. Please try again later."),[3,6];case 5:return Ie(!1),[7];case 6:return[2]}})})};l(function(){var e;(null===(e=null==te?void 0:te.accessToken)||void 0===e?void 0:e.length)&&Xe?an(!0):console.warn("Error: Trying to fetch rules without access token",te)},[null==te?void 0:te.accessToken,ge,he,ae.applicationId,Xe]);var cn=function(n,o,i){return t(ne,void 0,void 0,function(){var t,o,i,s,a,c,l,u;return r(this,function(r){switch(r.label){case 0:Oe(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,A(n,te.accessToken)];case 2:return r.sent(),m.getState().selectedRuleSetId===n&&(t=m.getState().scopeTreeData,(o=N((null==t?void 0:t.data)||null,n))&&o.length>1&&(i=o[o.length-2],fe(i),_e("learnings"))),[4,an(!0)];case 3:return r.sent(),Te(function(n){return e(e({},n),{isOpen:!1})}),null===(a=qe.current)||void 0===a||a.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return s=r.sent(),console.error("An error occurred during scope deletion.",s),null===(c=qe.current)||void 0===c||c.show({severity:"error",summary:"Delete Failed",detail:(null===(u=null===(l=null==s?void 0:s.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 Oe(!1),[7];case 6:return[2]}})})},ln=ye,un=Pe?{data:{id:Pe.stationId,name:Pe.stationName,type:"STATION",metrics:{learningsCount:Pe.learningsCount,stationsCount:0},children:[]}}:ln,dn=!!(null==un?void 0:un.data);null===(Z=null==un?void 0:un.data)||void 0===Z||Z.type;var pn=U(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",ae.applicationResourceId||"");if(en)return o("div",e({className:v.learningManagementContainer},{children:o(x,{})}));if(nn)return o("div",e({className:v.learningManagementContainer},{children:o(H,{errorMessage:"Failed to load configuration. Please try again.",onRetry:function(){return tn()},title:"Error Loading Configuration"})}));var mn=n(n([{type:"GLOBAL",label:"Global",addChildLabel:"".concat(W("".concat(Y,".addScope"),"Add Scope")),addChildType:"SCOPE"}],Array.from({length:on},function(){return e({type:"SCOPE",label:W("".concat(Y,".scope"),"Scope")},!de&&{addChildLabel:W("".concat(J,".addSubScope"),"Add Subscope"),addChildType:"SUBSCOPE"})}),!0),de?[]:[{type:"SUBSCOPE",label:W("".concat(Y,".subScope"),"Subscope")}],!0),fn=[{id:"learnings",label:W("".concat(Y,".treeMenu.submenu.learnings"),"Learnings"),icon:u,badgeKey:"learningsCount"},{id:"access",label:W("".concat(Y,".treeMenu.submenu.access"),"Access"),icon:d},{id:"history",label:W("".concat(Y,".treeMenu.submenu.changeHistory"),"Change History"),icon:p}],vn=new Set(fn.map(function(e){return e.id})),gn=Pe?fn.filter(function(e){return"stations"!==e.id}):fn;return o(M,{children:i("div",e({className:v.learningManagementContainer},{children:[o("div",e({className:v.mainWrapper},{children:Ee?o(_,{}):ve?i("div",e({className:v.errorContainer},{children:[o("div",e({className:v.errorTitle},{children:"Error Loading Data"})),o("p",e({className:v.errorDesc},{children:ve})),o("button",e({onClick:function(){return an(!0)},className:v.tryAgainBtn},{children:"Try Again"}))]})):dn?o(g,{onOpenCreateModal:function(){return Te({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,n,t){return Te({isOpen:!0,type:n,parentId:e,parentName:t})},onRenameChild:function(e,n){return Te({isOpen:!0,type:"RENAME",scopeId:e,initialName:n})},onDeleteChild:function(e,n,o){return t(ne,void 0,void 0,function(){var t,i,s;return r(this,function(r){switch(r.label){case 0:return t=m.getState().scopeTreeData,i=N((null==t?void 0:t.data)||null,e),s=!!i&&3===i.length,0!==o?[3,2]:[4,cn(e)];case 1:return r.sent(),[3,3];case 2:Te({isOpen:!0,type:"DELETE",scopeId:e,initialName:n,isSubscope:s}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return Ye("ilotj.scope.delete",e)},canEditScope:function(e){return Ye("ilotj.scope.edit",e)},canCreateScope:function(e){return Ye("ilotj.scope.create",e)},onSectionSelect:function(e,n){var t;console.log("Section Selected:",{scopeId:e,sectionId:n}),j(((t={})[O.SECTION]="learnings"===n?null:n,t[O.RULESET_ID]=e,t)),_e(n),fe(e)},activeSectionId:Re,scopeTreeData:un,sectionsConfig:gn,onViewStation:function(e){Ge.current=me,Ue(e),_e("learnings"),fe(e.stationId)},onRefreshRuleSets:function(e,n){void 0===e&&(e=!0),n&&(Be.current=n),an(e)},nodeTypesConfig:mn,app_integration_id:le,token:te.accessToken,modeId:pe}):o(h,{onCreate:function(){return Te({isOpen:!0,type:"GLOBAL"})},title:"No Global Scope has been added!",desc:"Start by creating a Global scope to define base learnings that apply across all stations.",button:"Create Global Scope",canCreateRule:pn,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return t(ne,void 0,void 0,function(){var e,n,t,i,s,a,c,l,u;return r(this,function(r){switch(r.label){case 0:if(!(e=(null===(i=null===(t=m.getState().scopeTreeData)||void 0===t?void 0:t.data)||void 0===i?void 0:i.id)||ke))return null===(s=qe.current)||void 0===s||s.show({severity:"error",sticky:!1,className:v.errorToast,content:o(K,{message:"Unable to identify the global scope for this access request."})}),[2];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,w(e)];case 2:return r.sent(),null===(a=qe.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:v.successToast,content:o(z,{message:"Access request submitted successfully!"})}),[3,4];case 3:return n=r.sent(),null===(c=qe.current)||void 0===c||c.show({severity:"error",sticky:!1,className:v.errorToast,content:o(K,{message:(null===(u=null===(l=null==n?void 0:n.response)||void 0===l?void 0:l.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),o(f,{ref:qe,pt:{root:{style:{zIndex:9999}}}}),de&&Ce.isOpen&&"DELETE"!==Ce.type&&"RENAME"!==Ce.type?o(P,{isOpen:!0,onClose:function(){return Te(e(e({},Ce),{isOpen:!1}))},onSubmit:function(n){return t(ne,void 0,void 0,function(){var t,o,i,s,a,c,l,u,d,p,f,v,g,h,y,S,b,C,I,A;return r(this,function(r){switch(r.label){case 0:Oe(!0),t=m.getState().backwardCompatibility,r.label=1;case 1:return r.trys.push([1,12,13,14]),o=void 0,t&&"object"==typeof n?o=n:(i=n,s="SCOPE"===Ce.type&&Ce.parentId,a=s?"genreRuleSet":Ce.type,o={topic:a,scope_reference_id:null,scopeDescription:"demo",parentScopeId:Ce.parentId||null,scopeName:i,scopeReferenceMetadata:{},applicationMappingId:le}),[4,E(o,te.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(Be.current=l,u=t&&(null===(y=o.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),d=!t&&"GLOBAL"!==Ce.type&&Ce.parentId,!u&&!d)return[3,10];if(!(p=t?null===(b=null===(S=m.getState().scopeTreeData)||void 0===S?void 0:S.data)||void 0===b?void 0:b.id:Ce.parentId))return[3,10];if(!de)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 f=r.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,6];case 6:return[3,10];case 7:return r.trys.push([7,9,,10]),[4,T({source_scope_id:p,target_scope_id:l,application_mapping_id:le||"",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,an(!0)];case 11:return r.sent(),Te(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=qe.current)||void 0===C||C.show({severity:"error",summary:"Creation Failed",detail:(null===(A=null===(I=null==g?void 0:g.response)||void 0===I?void 0:I.data)||void 0===A?void 0:A.message)||"There was an error creating the scope. Please try again."}),g;case 13:return Oe(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:dn,canCreateGlobal:pn,globalScopeId:null!==(ee=null===($=null==ye?void 0:ye.data)||void 0===$?void 0:$.id)&&void 0!==ee?ee:null}):i(s,{children:[o(q,{isOpen:Ce.isOpen&&"DELETE"!==Ce.type&&"RENAME"!==Ce.type,onClose:function(){return Te(e(e({},Ce),{isOpen:!1}))},onCreate:function(e){e&&(Be.current=e),an(!0)},hasGlobalRuleSet:dn,parentId:Ce.parentId}),o(V,{isOpen:Ce.isOpen&&"RENAME"===Ce.type,onClose:function(){return Te(e(e({},Ce),{isOpen:!1}))},onSave:function(n){return t(ne,void 0,void 0,function(){var t,i,s,a,c,l;return r(this,function(r){switch(r.label){case 0:Oe(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),Ce.scopeId?(t=m.getState().backwardCompatibility,i=t?{scope_id:Ce.scopeId,scope_name:n}:{scope_id:Ce.scopeId,scope_type:"Custom",scope_name:n,description:"demo",application_mapping_id:le},[4,I(i,te.accessToken)]):[2];case 2:return r.sent(),[4,an(!0)];case 3:return r.sent(),Te(function(n){return e(e({},n),{isOpen:!1})}),[3,6];case 4:throw s=r.sent(),console.error("An error occurred during scope rename.",s),null===(a=qe.current)||void 0===a||a.show({severity:"error",sticky:!1,className:v.errorToast,content:o(K,{message:(null===(l=null===(c=null==s?void 0:s.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."})}),s;case 5:return Oe(!1),[7];case 6:return[2]}})})},initialName:Ce.initialName})]}),o(R,{isOpen:Ce.isOpen&&"DELETE"===Ce.type,onCancel:function(){return Te(e(e({},Ce),{isOpen:!1}))},onConfirm:function(){return cn(Ce.scopeId,Ce.initialName,Ce.isSubscope)},title:"Delete Scope",description:i(s,{children:["Deleting ",o("span",e({className:v.highlight},{children:Ce.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:we})]}))})}export{X as default};
2
2
  //# sourceMappingURL=LearningManagement.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsxs as o,jsx as n}from"react/jsx-runtime";import{useEffect as t}from"react";import i from"./RuleContent/RuleContent.js";import r from"./StationsContent/StationsContent.js";import a from"./RBAC/AccessManagementPanel.js";import"appsec-ui";import"./store/useAuthStore.js";import"./store/usePermissionsStore.js";import s from"./store/useEnvStore.js";import l from"./styles/LearningTemplateLayout.module.css.js";import{findNodeById as d}from"./utils/treeUtils.js";import c from"./SidebarWrapper.js";import{useLearningTemplateStore as u}from"./store/useLearningTemplateStore.js";import p from"./components/StationOnboarding/StationOnboardModal.js";import m from"./AuditLog/AuditLog.js";var f=function(f){var S,g,v=f.onOpenCreateModal,C=f.onRefreshRuleSets,h=f.scopeTreeData,R=f.onAddChild,j=f.onRenameChild,A=f.onDeleteChild,I=f.canDeleteScope,D=f.canEditScope,M=f.canCreateScope,O=f.onSectionSelect,T=f.onViewStation,w=f.activeSectionId,b=void 0===w?"learnings":w,k=f.sectionsConfig,y=f.nodeTypesConfig,L=f.app_integration_id,_=f.token,N=u(function(e){return e.isStationModalOpen}),U=u(function(e){return e.setStationModalOpen}),x=u(function(e){return e.isStationOnboardModalTriggered}),B=u(function(e){return e.setIsStationOnboardModalTriggered}),E=u(function(e){return e.selectedRuleSetId}),P=u(function(e){return e.rawAuditRuleData}),V=s(function(e){return e.auditLogConfig});u(function(e){return e.ruleData});var F=E?d((null==h?void 0:h.data)||null,E):null;return Boolean((null===(S=null==h?void 0:h.data)||void 0===S?void 0:S.id)&&E===h.data.id),t(function(){x&&U(!0)},[x,U,B]),o("div",e({className:l.container},{children:[n(c,{onOpenCreateModal:v,onRefreshRuleSets:C,scopeTreeData:h,onAddChild:R,onRenameChild:j,onDeleteChild:A,canDeleteScope:I,canEditScope:D,canCreateScope:M,onSectionSelect:O,activeSectionId:b,sectionsConfig:k,nodeTypesConfig:y}),n("div",e({id:"rule-template-layout-content",className:"".concat(l.content," relative flex-1 overflow-hidden")},{children:"stations"===b?n(r,{scopeId:E||"",scopeName:(null==F?void 0:F.name)||"Unknown Scope",stationsCount:null===(g=null==F?void 0:F.metrics)||void 0===g?void 0:g.stationsCount,onViewStation:T}):"access"===b?n(a,{selectedRuleSetId:E,scopeName:(null==F?void 0:F.name)||"Unknown Scope",useApplicationModuleForScopeAccess:!1}):"history"===b?(null==V?void 0:V.configId)?n(m,{configId:V.configId,scopeId:E||void 0,scopeName:(null==F?void 0:F.name)||"Unknown Scope",ruleData:P}):null:n(i,{onRefreshRuleSets:C,app_integration_id:L,token:_})})),n(p,{isOpen:N,onClose:function(){U(!1),B(!1)},onBoardStation:function(e){C(!0,e)},app_integration_id:L,token:_})]}))};export{f as default};
1
+ import{__assign as e}from"tslib";import{jsxs as o,jsx as n}from"react/jsx-runtime";import{useEffect as t}from"react";import i from"./RuleContent/RuleContent.js";import r from"./StationsContent/StationsContent.js";import a from"./RBAC/AccessManagementPanel.js";import"appsec-ui";import"./store/useAuthStore.js";import"./store/usePermissionsStore.js";import s from"./store/useEnvStore.js";import d from"./styles/LearningTemplateLayout.module.css.js";import{findNodeById as l}from"./utils/treeUtils.js";import c from"./SidebarWrapper.js";import{useLearningTemplateStore as u}from"./store/useLearningTemplateStore.js";import p from"./components/StationOnboarding/StationOnboardModal.js";import m from"./AuditLog/AuditLog.js";var f=function(f){var S,g,v=f.onOpenCreateModal,C=f.onRefreshRuleSets,h=f.scopeTreeData,R=f.onAddChild,j=f.onRenameChild,I=f.onDeleteChild,A=f.canDeleteScope,D=f.canEditScope,M=f.canCreateScope,O=f.onSectionSelect,T=f.onViewStation,w=f.activeSectionId,b=void 0===w?"learnings":w,k=f.sectionsConfig,y=f.nodeTypesConfig,L=f.app_integration_id,_=f.token,N=f.modeId,U=u(function(e){return e.isStationModalOpen}),x=u(function(e){return e.setStationModalOpen}),B=u(function(e){return e.isStationOnboardModalTriggered}),E=u(function(e){return e.setIsStationOnboardModalTriggered}),P=u(function(e){return e.selectedRuleSetId}),V=u(function(e){return e.rawAuditRuleData}),F=s(function(e){return e.auditLogConfig});u(function(e){return e.ruleData});var W=P?l((null==h?void 0:h.data)||null,P):null;return Boolean((null===(S=null==h?void 0:h.data)||void 0===S?void 0:S.id)&&P===h.data.id),t(function(){B&&x(!0)},[B,x,E]),o("div",e({className:d.container},{children:[n(c,{onOpenCreateModal:v,onRefreshRuleSets:C,scopeTreeData:h,onAddChild:R,onRenameChild:j,onDeleteChild:I,canDeleteScope:A,canEditScope:D,canCreateScope:M,onSectionSelect:O,activeSectionId:b,sectionsConfig:k,nodeTypesConfig:y}),n("div",e({id:"rule-template-layout-content",className:"".concat(d.content," relative flex-1 overflow-hidden")},{children:"stations"===b?n(r,{scopeId:P||"",scopeName:(null==W?void 0:W.name)||"Unknown Scope",stationsCount:null===(g=null==W?void 0:W.metrics)||void 0===g?void 0:g.stationsCount,onViewStation:T}):"access"===b?n(a,{selectedRuleSetId:P,scopeName:(null==W?void 0:W.name)||"Unknown Scope",useApplicationModuleForScopeAccess:!1}):"history"===b?(null==F?void 0:F.configId)?n(m,{configId:F.configId,scopeId:P||void 0,scopeName:(null==W?void 0:W.name)||"Unknown Scope",ruleData:V}):null:n(i,{onRefreshRuleSets:C,app_integration_id:L,token:_,modeId:N})})),n(p,{isOpen:U,onClose:function(){x(!1),E(!1)},onBoardStation:function(e){C(!0,e)},app_integration_id:L,token:_})]}))};export{f as default};
2
2
  //# sourceMappingURL=LearningTemplateLayout.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 b}from"../utils/treeUtils.js";import j from"../styles/LearningContent.module.css.js";import R from"../components/ConfirmationModal.js";import{dt as D}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 I}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"@viswa-test/test-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"../store/usePermissionsStore.js";import"appsec-ui";import"../store/useAuthStore.js";import"../store/useEnvStore.js";import"@radix-ui/react-tooltip";import"../components/StationOnboarding/InputField.js";import"../store/useConfigStore.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"../components/ToolTip.js";import"react-router-dom";var O=function(O){var M,A=O.noRulesTitle,N=void 0===A?"No rules have been added !":A,E=O.noRulesDesc,V=void 0===E?"Start by adding rules that should apply across all stations.":E,F=O.noRulesButtonText,P=void 0===F?"Create New Rule":F,B=O.deleteRuleSuccessMessage,J=void 0===B?"Rule deleted successfully!":B,U=O.deleteVariantSuccessMessage,W=void 0===U?"Variant deleted successfully!":U,q=O.deleteRuleErrorMessage,G=void 0===q?"Failed to delete rule. Please try again.":q,H=O.deleteVariantErrorMessage,$=void 0===H?"Failed to delete variant. Please try again.":H,z=O.deleteModalTitle,K=void 0===z?"Delete":z,Q=O.deleteRuleModalWarning,X=void 0===Q?"This will permanently delete the rule configuration.":Q,Y=O.deleteVariantModalWarning,Z=void 0===Y?"This will permanently delete the variant configuration.":Y,ee=O.deleteConfirmText,te=void 0===ee?"Delete":ee,ne=O.onRefreshRuleSets,re=O.app_integration_id,oe=O.token,ie=c(function(e){return e.selectedRuleSetId}),le=c(function(e){return e.scopeTreeData}),ae=c(function(e){return e.sidebarTab}),se=c(function(e){return e.setInitialRules}),ue=c(function(e){return e.currentRules}),ce=c(function(e){return e.setRawAuditRuleData});c(function(e){return e.createdVariantInfo});var de=c(function(e){return e.resetCreatedVariantInfo}),pe=c(function(e){return e.isILModalTriggered}),me=c(function(e){return e.setIsILModalTriggered}),fe=a(null),ve=s(!1),ge=ve[0],he=ve[1],Te=s(null),ye=Te[0],we=Te[1],Se=s(null),Ce=Se[0],be=Se[1],je=s(null),Re=je[0],De=je[1],Ie=s(null),xe=Ie[0],_e=Ie[1],Le=s(!1),ke=Le[0],Oe=Le[1],Me=s(null),Ae=Me[0],Ne=Me[1],Ee=s(!1),Ve=Ee[0],Fe=Ee[1],Pe=s(""),Be=Pe[0],Je=Pe[1],Ue=s(null),We=Ue[0],qe=Ue[1],Ge=s(!1),He=Ge[0],$e=Ge[1],ze=s(!1),Ke=ze[0],Qe=ze[1],Xe=s("ruleDeletion"),Ye=Xe[0],Ze=Xe[1],et=s(null),tt=et[0],nt=et[1],rt=s(!1),ot=rt[0],it=rt[1],lt=s(!1),at=lt[0],st=lt[1],ut=c.getState().tiers,ct=s(null),dt=ct[0],pt=ct[1],mt=s(null),ft=mt[0],vt=mt[1],gt=s(null),ht=gt[0],Tt=gt[1],yt=function(){we(null),be(null),he(!0),_e(0)},wt=function(){he(!1),me(!1),we(null),be(null),De(null),_e(null),Qe(!1),st(!1),St(),pt(null),vt(null),Tt(null),ne&&ne(!1,ie||void 0)};u(function(){St()},[ie,se]),u(function(){pe&&he(!0)},[pe]);var St=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,b,j;return t(this,function(t){switch(t.label){case 0:if(!ie)return se([]),[2];o||Oe(!0),Ne(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,p(ie,oe)];case 2:return e=t.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(ce(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=ut.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(D("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)})}),se(y),(w=null===(j=null===(b=null===(C=g[0])||void 0===C?void 0:C.variants)||void 0===b?void 0:b[0])||void 0===j?void 0:j.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(w,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return de()},1e4)},500):de()):se(v),[3,5]):(se([]),[2]);case 3:return S=t.sent(),console.error("Failed to fetch rule details",S),404!==(null==S?void 0:S.status)&&Ne((null==S?void 0:S.message)||"Failed to load rules. Please try again."),se([]),[3,5];case 4:return o||Oe(!1),[7];case 5:return[2]}})})},Ct=ie?b((null==le?void 0:le.data)||null,ie):null,bt=Ct?{ruleSetId:Ct.id,ruleSetName:Ct.name,ruleSetDesc:"",ruleCount:null===(M=null==Ct?void 0:Ct.metrics)||void 0===M?void 0:M.learningsCount}:void 0,jt=Boolean(null==le?void 0:le.data),Rt=Boolean(ie&&!Ct&&jt),Dt=function(){if("stations"===ae)return"custom";if(!Ct)return"global";switch(Ct.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},It=function(e){var t;if(!e)return o("p",{children:D("".concat(k,".deleteDialog.description"),"Are you sure you want to delete this rule? This action cannot be undone.")});var n=null==ue?void 0:ue.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:D("".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:""})})},xt={editingRule:ye,editingTier:Ce,editingVariants:Re,focusedVariantIndex:xe,setFocusedVariantIndex:_e,triggerAddVariant:Ke,triggerFixGaps:at,copiedRule:dt,copiedSourceTier:ft,copiedTargetTier:ht,initialDraftMessage:Be,app_integration_id:re,modeId:"019dde79-0494-78d7-ba5b-54a35d20f0fc"};return bt?i(l,{children:[o(T,{ref:fe}),o("div",r({className:j.container},{children:ke?o(h,{}):Ae?o(w,{errorMessage:Ae,onRetry:St}):o(y,{onAddRule:yt,onDeleteRule:function(e){qe(e)},onEditRule:function(e,t){we(e),be(t||null),De(e.variants||null),_e(null),Qe(!0),he(!0)},onEditVariant:function(e,t,n,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==ue?void 0:ue.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==ue?void 0:ue.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;we(s),be(n||null),De(s.variants||null),_e(c),he(!0),"resolve_gaps"===r&&st(!0)}},onDeleteVariant:function(e,t){nt({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(!ie)return[2];Fe(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,m(ie)];case 2:return e=t.sent(),n=window.URL.createObjectURL(e),(r=document.createElement("a")).href=n,i=(null==bt?void 0:bt.ruleSetName)?"".concat(bt.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(ie,".csv"),r.download=i,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n),null===(a=fe.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:j.successToast,content:o(S,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=t.sent(),console.error("Export error:",l),null===(s=fe.current)||void 0===s||s.show({severity:"error",sticky:!1,className:j.errorToast,content:o(C,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Fe(!1),[7];case 5:return[2]}})})},isExporting:Ve,onToggleSuccess:function(){return St(!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(),St(!0),null===(s=fe.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:j.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),St(!0),null===(u=fe.current)||void 0===u||u.show({severity:"error",sticky:!1,className:j.errorToast,content:o(C,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:ne,setDeleteConfirmationUsedFor:Ze,onCopyToTier:function(e,t,n,r,o){var i,l,a=null===(l=null===(i=null==ue?void 0:ue.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");Je(s),pt(a),vt(r),Tt(o),we(null),be(null),De(null),_e(null),he(!0)}}})})),ge&&o(I,{children:o(x,{isOpen:ge,onClose:wt,app_integration_id:re,token:oe,mode:"ADD",pluginPayload:r(r({},xt),{initialScope:Dt(),ruleSet:bt})})}),o(R,{isOpen:!!We,title:D("".concat(_,".deleteDialog.title"),K),description:It(We),warning:D("".concat(_,".deleteDialog.warningText"),X),confirmText:D("".concat(_,".deleteDialog.deleteText"),te),cancelText:D("".concat(_,".deleteDialog.cancelText"),"Cancel"),loadingText:D("".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(!We)return[2];$e(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,f(We)];case 2:return t.sent(),qe(null),null===(n=fe.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:j.successToast,content:o(S,{message:J})}),St(),ne&&ne(!1,ie||void 0),[3,5];case 3:return e=t.sent(),console.error("Failed to delete rule",e),null===(r=fe.current)||void 0===r||r.show({severity:"error",sticky:!1,className:j.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)||G})}),[3,5];case 4:return $e(!1),[7];case 5:return[2]}})})},onCancel:function(){return qe(null)},isLoading:He}),o(R,{isOpen:!!tt,title:D("".concat(L,".deleteVariant.title"),K),description:"variantDeletion"===Ye?o("span",{children:D("".concat(L,".deleteVariant.desc"),"Are you sure you want to delete this variant? This action cannot be undone.")}):It((null==tt?void 0:tt.ruleId)||null),warning:D("".concat(L,".deleteVariant.warningText"),"ruleDeletion"===Ye?X:Z),confirmText:D("".concat(L,".deleteDialog.deleteText"),te),cancelText:D("".concat(L,".cancelText"),"Cancel"),loadingText:D("".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(!tt)return[2];it(!0),t.label=1;case 1:return t.trys.push([1,6,7,8]),"ruleDeletion"!==Ye?[3,3]:[4,v(tt.ruleId)];case 2:return t.sent(),[3,5];case 3:return[4,f(tt.variantId)];case 4:t.sent(),t.label=5;case 5:return nt(null),null===(n=fe.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:j.successToast,content:o(S,{message:"ruleDeletion"===Ye?J:W})}),St(),ne&&ne(!1,ie||void 0),[3,8];case 6:return e=t.sent(),console.error("Failed to delete variant",e),null===(r=fe.current)||void 0===r||r.show({severity:"error",sticky:!1,className:j.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"===Ye?G:$)})}),[3,8];case 7:return it(!1),[7];case 8:return[2]}})})},onCancel:function(){return nt(null)},isLoading:ot})]}):Rt?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==ne?void 0:ne(!0)},retryButtonText:"Refresh"}):i(l,{children:[o(d,{onCreate:yt,title:N,desc:V,button:P}),ge&&o(I,{children:o(x,{isOpen:ge,onClose:wt,app_integration_id:re,token:oe,mode:"ADD",pluginPayload:r(r({},xt),{initialScope:Dt(),ruleSet:bt})})})]})};export{O 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"@viswa-test/test-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"../store/usePermissionsStore.js";import"appsec-ui";import"../store/useAuthStore.js";import"../store/useEnvStore.js";import"@radix-ui/react-tooltip";import"../components/StationOnboarding/InputField.js";import"../store/useConfigStore.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"../components/ToolTip.js";import"react-router-dom";var O=function(O){var M,A=O.noRulesTitle,N=void 0===A?"No rules have been added !":A,E=O.noRulesDesc,V=void 0===E?"Start by adding rules that should apply across all stations.":E,F=O.noRulesButtonText,P=void 0===F?"Create New Rule":F,B=O.deleteRuleSuccessMessage,J=void 0===B?"Rule deleted successfully!":B,U=O.deleteVariantSuccessMessage,W=void 0===U?"Variant deleted successfully!":U,q=O.deleteRuleErrorMessage,G=void 0===q?"Failed to delete rule. Please try again.":q,H=O.deleteVariantErrorMessage,$=void 0===H?"Failed to delete variant. Please try again.":H,z=O.deleteModalTitle,K=void 0===z?"Delete":z,Q=O.deleteRuleModalWarning,X=void 0===Q?"This will permanently delete the rule configuration.":Q,Y=O.deleteVariantModalWarning,Z=void 0===Y?"This will permanently delete the variant configuration.":Y,ee=O.deleteConfirmText,te=void 0===ee?"Delete":ee,ne=O.onRefreshRuleSets,re=O.app_integration_id,oe=O.token,ie=O.modeId,le=c(function(e){return e.selectedRuleSetId}),ae=c(function(e){return e.scopeTreeData}),se=c(function(e){return e.sidebarTab}),ue=c(function(e){return e.setInitialRules}),ce=c(function(e){return e.currentRules}),de=c(function(e){return e.setRawAuditRuleData});c(function(e){return e.createdVariantInfo});var pe=c(function(e){return e.resetCreatedVariantInfo}),me=c(function(e){return e.isILModalTriggered}),fe=c(function(e){return e.setIsILModalTriggered}),ve=a(null),ge=s(!1),he=ge[0],Te=ge[1],ye=s(null),we=ye[0],Se=ye[1],Ce=s(null),je=Ce[0],Re=Ce[1],be=s(null),Ie=be[0],De=be[1],xe=s(null),_e=xe[0],Le=xe[1],ke=s(!1),Oe=ke[0],Me=ke[1],Ae=s(null),Ne=Ae[0],Ee=Ae[1],Ve=s(!1),Fe=Ve[0],Pe=Ve[1],Be=s(""),Je=Be[0],Ue=Be[1],We=s(null),qe=We[0],Ge=We[1],He=s(!1),$e=He[0],ze=He[1],Ke=s(!1),Qe=Ke[0],Xe=Ke[1],Ye=s("ruleDeletion"),Ze=Ye[0],et=Ye[1],tt=s(null),nt=tt[0],rt=tt[1],ot=s(!1),it=ot[0],lt=ot[1],at=s(!1),st=at[0],ut=at[1],ct=c.getState().tiers,dt=s(null),pt=dt[0],mt=dt[1],ft=s(null),vt=ft[0],gt=ft[1],ht=s(null),Tt=ht[0],yt=ht[1],wt=function(){Se(null),Re(null),Te(!0),Le(0)},St=function(){Te(!1),fe(!1),Se(null),Re(null),De(null),Le(null),Xe(!1),ut(!1),Ct(),mt(null),gt(null),yt(null),ne&&ne(!1,le||void 0)};u(function(){Ct()},[le,ue]),u(function(){me&&Te(!0)},[me]);var Ct=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(!le)return ue([]),[2];o||Me(!0),Ee(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,p(le,oe)];case 2:return e=t.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(de(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=ct.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)})}),ue(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 pe()},1e4)},500):pe()):ue(v),[3,5]):(ue([]),[2]);case 3:return S=t.sent(),console.error("Failed to fetch rule details",S),404!==(null==S?void 0:S.status)&&Ee((null==S?void 0:S.message)||"Failed to load rules. Please try again."),ue([]),[3,5];case 4:return o||Me(!1),[7];case 5:return[2]}})})},jt=le?j((null==ae?void 0:ae.data)||null,le):null,Rt=jt?{ruleSetId:jt.id,ruleSetName:jt.name,ruleSetDesc:"",ruleCount:null===(M=null==jt?void 0:jt.metrics)||void 0===M?void 0:M.learningsCount}:void 0,bt=Boolean(null==ae?void 0:ae.data),It=Boolean(le&&!jt&&bt),Dt=function(){if("stations"===se)return"custom";if(!jt)return"global";switch(jt.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},xt=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==ce?void 0:ce.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:""})})},_t={editingRule:we,editingTier:je,editingVariants:Ie,focusedVariantIndex:_e,setFocusedVariantIndex:Le,triggerAddVariant:Qe,triggerFixGaps:st,copiedRule:pt,copiedSourceTier:vt,copiedTargetTier:Tt,initialDraftMessage:Je,app_integration_id:re,modeId:ie};return Rt?i(l,{children:[o(T,{ref:ve}),o("div",r({className:R.container},{children:Oe?o(h,{}):Ne?o(w,{errorMessage:Ne,onRetry:Ct}):o(y,{onAddRule:wt,onDeleteRule:function(e){Ge(e)},onEditRule:function(e,t){Se(e),Re(t||null),De(e.variants||null),Le(null),Xe(!0),Te(!0)},onEditVariant:function(e,t,n,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==ce?void 0:ce.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==ce?void 0:ce.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;Se(s),Re(n||null),De(s.variants||null),Le(c),Te(!0),"resolve_gaps"===r&&ut(!0)}},onDeleteVariant:function(e,t){rt({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(!le)return[2];Pe(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,m(le)];case 2:return e=t.sent(),n=window.URL.createObjectURL(e),(r=document.createElement("a")).href=n,i=(null==Rt?void 0:Rt.ruleSetName)?"".concat(Rt.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(le,".csv"),r.download=i,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n),null===(a=ve.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=ve.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 Pe(!1),[7];case 5:return[2]}})})},isExporting:Fe,onToggleSuccess:function(){return Ct(!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(),Ct(!0),null===(s=ve.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),Ct(!0),null===(u=ve.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:ne,setDeleteConfirmationUsedFor:et,onCopyToTier:function(e,t,n,r,o){var i,l,a=null===(l=null===(i=null==ce?void 0:ce.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");Ue(s),mt(a),gt(r),yt(o),Se(null),Re(null),De(null),Le(null),Te(!0)}}})})),he&&o(D,{children:o(x,{isOpen:he,onClose:St,app_integration_id:re,token:oe,mode:"ADD",pluginPayload:r(r({},_t),{initialScope:Dt(),ruleSet:Rt})})}),o(b,{isOpen:!!qe,title:I("".concat(_,".deleteDialog.title"),K),description:xt(qe),warning:I("".concat(_,".deleteDialog.warningText"),X),confirmText:I("".concat(_,".deleteDialog.deleteText"),te),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(!qe)return[2];ze(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,f(qe)];case 2:return t.sent(),Ge(null),null===(n=ve.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:J})}),Ct(),ne&&ne(!1,le||void 0),[3,5];case 3:return e=t.sent(),console.error("Failed to delete rule",e),null===(r=ve.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)||G})}),[3,5];case 4:return ze(!1),[7];case 5:return[2]}})})},onCancel:function(){return Ge(null)},isLoading:$e}),o(b,{isOpen:!!nt,title:I("".concat(L,".deleteVariant.title"),K),description:"variantDeletion"===Ze?o("span",{children:I("".concat(L,".deleteVariant.desc"),"Are you sure you want to delete this variant? This action cannot be undone.")}):xt((null==nt?void 0:nt.ruleId)||null),warning:I("".concat(L,".deleteVariant.warningText"),"ruleDeletion"===Ze?X:Z),confirmText:I("".concat(L,".deleteDialog.deleteText"),te),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(!nt)return[2];lt(!0),t.label=1;case 1:return t.trys.push([1,6,7,8]),"ruleDeletion"!==Ze?[3,3]:[4,v(nt.ruleId)];case 2:return t.sent(),[3,5];case 3:return[4,f(nt.variantId)];case 4:t.sent(),t.label=5;case 5:return rt(null),null===(n=ve.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:"ruleDeletion"===Ze?J:W})}),Ct(),ne&&ne(!1,le||void 0),[3,8];case 6:return e=t.sent(),console.error("Failed to delete variant",e),null===(r=ve.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"===Ze?G:$)})}),[3,8];case 7:return lt(!1),[7];case 8:return[2]}})})},onCancel:function(){return rt(null)},isLoading:it})]}):It?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==ne?void 0:ne(!0)},retryButtonText:"Refresh"}):i(l,{children:[o(d,{onCreate:wt,title:N,desc:V,button:P}),he&&o(D,{children:o(x,{isOpen:he,onClose:St,app_integration_id:re,token:oe,mode:"ADD",pluginPayload:r(r({},_t),{initialScope:Dt(),ruleSet:Rt})})})]})};export{O as default};
2
2
  //# sourceMappingURL=RuleContent.js.map
@@ -1,2 +1,2 @@
1
- import{__awaiter as e,__generator as t,__assign as r}from"tslib";import n from"axios";import{API_ENDPOINTS as a,LEGACY_API_ENDPOINTS as i}from"./apiConfig.js";import o from"../store/useAuthStore.js";import s from"../store/useEnvStore.js";import{useLearningTemplateStore as c}from"../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as u}from"../config.js";var l=function(e){return e.interceptors.request.use(function(e){var t=o.getState().user,r=null==t?void 0:t.accessToken;return r&&(e.headers.Authorization="Bearer ".concat(r)),e}),e},d=function(e,t){return e.interceptors.request.use(function(e){return e.baseURL=t(),e}),e},p=d(l(n.create({headers:{"Content-Type":"application/json"}})),function(){return s.getState().audacyBackendUrl||""}),v=d(l(n.create({headers:{"Content-Type":"application/json"}})),function(){return s.getState().llmStudioUrl||""}),h=d(l(n.create({headers:{"Content-Type":"application/json"}})),function(){return s.getState().appsecRbacUrl||""}),g=d(l(n.create({headers:{"Content-Type":"application/json"}})),function(){return s.getState().appsecBaseUrl||""}),f=function(e){return d(l(n.create({headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},withCredentials:!0})),function(){return s.getState().llmStudioUrl||""})},b=function(r,n){return e(void 0,void 0,void 0,function(){var e,n,o;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,t.label=1;case 1:return t.trys.push([1,3,,4]),n=e?i.publishFeedback:"".concat(a.publishFeedback),[4,v.post(n,r)];case 2:return[2,t.sent().data];case 3:throw o=t.sent(),console.error("Error publishing feedback to LLM Studio:",o),o;case 4:return[2]}})})},S=function(r){return e(void 0,void 0,void 0,function(){var e,n,o;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,n=e?i.submitChatFeedback:a.submitChatFeedback,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,v.post(n,r)];case 2:return[2,t.sent().data];case 3:throw o=t.sent(),console.error("Error submitting chat feedback:",o),o;case 4:return[2]}})})},w=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v.post(a.saveInstantLearningQuestion,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error saving instant learning question:",e),e;case 3:return[2]}})})},y=function(r,n){return e(void 0,void 0,void 0,function(){var e,o,s;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,t.label=1;case 1:if(t.trys.push([1,3,,4]),!r&&!1===e)throw new Error("App Integration ID is not provided. Falling back to legacy endpoint for fetching scopes.");return o=e?i.fetchScopes:"".concat(a.fetchScopes,"/").concat(r),[4,f(n).get(o)];case 2:return[2,t.sent().data];case 3:throw s=t.sent(),console.error("Error fetching rule sets:",s),s;case 4:return[2]}})})},m=function(r,n){return e(void 0,void 0,void 0,function(){var e,o,s;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,t.label=1;case 1:return t.trys.push([1,3,,4]),o=e?i.renameScope:a.renameScope,[4,f(n).put(o,r)];case 2:return[2,t.sent().data];case 3:throw s=t.sent(),console.error("Error renaming scope:",s),s;case 4:return[2]}})})},_=function(r,n){return e(void 0,void 0,void 0,function(){var e,o,s,u;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,o=c.getState().app_integration_id,t.label=1;case 1:return t.trys.push([1,3,,4]),s=e?"".concat(i.getRulesInRuleSetById,"/").concat(r,"?include_config=True&sort_variant_by=createdAt"):"".concat(a.getRulesInRuleSetById,"/").concat(r,"/").concat(null!=o?o:""),[4,f(n).get(s)];case 2:return[2,t.sent().data];case 3:return u=t.sent(),console.error("Error fetching rules in rule set:",u),[3,4];case 4:return[2]}})})},I=function(r){return e(void 0,void 0,void 0,function(){var e,n,i,o;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,n=c.getState().app_integration_id,t.label=1;case 1:return t.trys.push([1,3,,4]),i=e?"".concat(a.getRuleOverrideHistory,"/").concat(r):"".concat(a.getRuleOverrideHistory,"/").concat(r,"/").concat(null!=n?n:""),[4,v.get(i)];case 2:return[2,t.sent().data];case 3:throw o=t.sent(),console.error("Error getting rule override history:",o),o;case 4:return[2]}})})},k=function(r,n){return e(void 0,void 0,void 0,function(){var e,o,s;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=c.getState().backwardCompatibility,o=e?i.createRuleSet:a.createRuleSet,[4,f(n).post(o,r)];case 1:return[2,t.sent().data];case 2:throw s=t.sent(),console.error("Error creating rule set:",s),s;case 3:return[2]}})})},E=function(r,n){return void 0===n&&(n=!1),e(void 0,void 0,void 0,function(){var e,i;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e="".concat(a.fetchStationsByKeyword.replace("{keyword}",r),"?allow_existing=").concat(n),[4,p.get(e)];case 1:return[2,t.sent().data];case 2:throw i=t.sent(),console.error("Error fetching station name by keyword:",i),i;case 3:return[2]}})})},C=function(r,n){return e(void 0,void 0,void 0,function(){var e,o,s,u;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,o=c.getState().app_integration_id,t.label=1;case 1:return t.trys.push([1,3,,4]),s=void 0,s=e?i.deleteRuleSet.replace("{ruleSetId}",r):a.deleteRuleSet.replace("{ruleSetId}",r).replace("{appIntegrationId}",null!=o?o:""),[4,f(n).delete(s)];case 2:return[2,t.sent().data];case 3:throw u=t.sent(),console.error("Error deleting rule set:",u),u;case 4:return[2]}})})},R=function(r){return e(void 0,void 0,void 0,function(){var e,n,o,s,u;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,n=c.getState().app_integration_id,o=c.getState().token,t.label=1;case 1:return t.trys.push([1,6,,7]),e?(s=i.deleteRule.replace("{ruleId}",r),[4,v.delete(s)]):[3,3];case 2:return[2,t.sent().data];case 3:return s=a.deleteRule.replace("{ruleId}",r).replace("{appIntegrationId}",null!=n?n:""),[4,f(o).delete(s)];case 4:return[2,t.sent().data];case 5:return[3,7];case 6:throw u=t.sent(),console.error("Error deleting rule:",u),u;case 7:return[2]}})})},P=function(r){return e(void 0,void 0,void 0,function(){var e,n,o,s,u;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,n=c.getState().app_integration_id,o=c.getState().token,t.label=1;case 1:return t.trys.push([1,6,,7]),e?(s=i.deleteQuestion.replace("{questionId}",r),[4,v.delete(s)]):[3,3];case 2:return[2,t.sent().data];case 3:return s=a.deleteQuestion.replace("{questionId}",r).replace("{appIntegrationId}",null!=n?n:""),[4,f(o).delete(s)];case 4:return[2,t.sent().data];case 5:return[3,7];case 6:throw u=t.sent(),console.error("Error deleting question:",u),u;case 7:return[2]}})})},T=function(r,n){return e(void 0,void 0,void 0,function(){var e,o,s,u,l;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,o=c.getState().app_integration_id,s=c.getState().token,t.label=1;case 1:return t.trys.push([1,6,,7]),e?(u=i.deleteTier.replace("{scopeId}",r).replace("{tierId}",n),[4,v.delete(u)]):[3,3];case 2:return[2,t.sent().data];case 3:return u=a.deleteTier.replace("{scopeId}",r).replace("{tierId}",n).replace("{appIntegrationId}",null!=o?o:""),[4,f(s).delete(u)];case 4:return[2,t.sent().data];case 5:return[3,7];case 6:throw l=t.sent(),console.error("Error deleting tier:",l),l;case 7:return[2]}})})},A=function(r,n){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v.put(a.updateVariant,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error updating variant:",e),e;case 3:return[2]}})})},q=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v.post(i.inheritScope,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error inheriting scope:",e),e;case 3:return[2]}})})},L=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,4,,5]),(null==r?void 0:r.application_mapping_id)?[4,v.post(a.inheritScope,r)]:[3,2];case 1:return[2,t.sent().data];case 2:throw Error("Fatal Error: Trying to call inherit API without appintegration ID");case 3:return[3,5];case 4:throw e=t.sent(),console.error("Error inheriting scope:",e),e;case 5:return[2]}})})},j=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:if(!r)throw new Error("scopeId is required for exporting rule sets");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,v.post(a.exportRuleSet,{scope_id:r},{responseType:"blob"})];case 2:return[2,t.sent().data];case 3:throw e=t.sent(),console.error("Error exporting rule set:",e),e;case 4:return[2]}})})},B=function(r,n,o){return e(void 0,void 0,void 0,function(){var e,o,s,u;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,o=c.getState().app_integration_id,s=c.getState().token,t.label=1;case 1:return t.trys.push([1,6,,7]),e?[4,f(s).patch(i.toggleVariant,{variant_ids:r,is_enabled:n})]:[3,3];case 2:return[2,t.sent().data];case 3:return[4,f(s).patch(a.toggleVariant,{variant_ids:r,application_mapping_id:o,is_enabled:n})];case 4:return[2,t.sent().data];case 5:return[3,7];case 6:throw u=t.sent(),console.error("Error toggling variant status:",u),u;case 7:return[2]}})})},U=function(){return e(void 0,void 0,void 0,function(){var e,r,n,o,s,l,d,p;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,r=c.getState().app_integration_id,n=c.getState().token,t.label=1;case 1:return t.trys.push([1,6,,7]),e?(o=u.CUSTOM_SCOPE_GROUP_NAME,[4,f(n).post(i.getTiers,{tier_group_name:o})]):[3,3];case 2:return s=t.sent(),c.getState().setTiers((null===(d=s.data)||void 0===d?void 0:d.response)||[]),[3,5];case 3:return[4,f(n).get(a.getTiers.replace("{appIntegrationId}",null!=r?r:""))];case 4:s=t.sent(),"success"===(null===(p=s.data)||void 0===p?void 0:p.status)&&c.getState().setTiers(s.data.data.map(function(e){return{tier_id:e.id,tier_name:e.tier_title,tier_priority:e.tier_priority}})),t.label=5;case 5:return[3,7];case 6:throw l=t.sent(),console.error("Error fetching tiers:",l),l;case 7:return[2]}})})},z=function(r,n,o,s,u){return e(void 0,void 0,void 0,function(){var e,l,d,p,v,h;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,l=c.getState().app_integration_id,d=c.getState().token,t.label=1;case 1:return t.trys.push([1,3,,4]),p=e?i.alterRulePriority:a.alterRulePriority,v=e?{scopeId:r,tierId:n,move:{movedRuleId:o,prevRuleId:s,nextRuleId:u}}:{scope_id:r,tier_id:n,move:{moved_rule_id:o,prev_rule_id:s,next_rule_id:u},application_mapping_id:l},[4,f(d).put(p,v)];case 2:return[2,t.sent().data];case 3:throw h=t.sent(),console.error("Error altering question priority:",h),h;case 4:return[2]}})})},F=function(r,n){return e(void 0,void 0,void 0,function(){var e,o,s,u,l;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,o=c.getState().app_integration_id,s=c.getState().token,t.label=1;case 1:return t.trys.push([1,6,,7]),e?(u=i.fetchRulesByQuestionId.replace("{questionId}",r).replace("{scopeId}",n),[4,v.get(u)]):[3,3];case 2:return[2,t.sent().data];case 3:return u=a.fetchRulesByQuestionId.replace("{appIntegrationId}",null!=o?o:"").replace("{questionId}",r).replace("{scopeId}",n),[4,f(s).get(u)];case 4:return[2,t.sent().data];case 5:return[3,7];case 6:throw l=t.sent(),console.error("Error fetching rules by question id:",l),l;case 7:return[2]}})})},O=function(r){return void 0===r&&(r={limit:"50",offset:"0"}),e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v.post(a.retrieveGenreScopes,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error retrieving genre scopes:",e),e;case 3:return[2]}})})},x=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v.post(a.searchScopes,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error searching scopes:",e),e;case 3:return[2]}})})},M=function(r){return e(void 0,void 0,void 0,function(){return t(this,function(e){return[2,new Promise(function(e){setTimeout(function(){e({data:[{stationId:"reetrtdfsds",stationName:"Hot 98.7",stationDesc:"Learnings that apply for Hot 98.7 Station",learningsCount:5},{stationId:"sta-102",stationName:"Smooth Jazz 102.1",stationDesc:"Learnings that apply for Smooth Jazz 102.1 Station",learningsCount:12},{stationId:"sta-103",stationName:"Rock 94",stationDesc:"Learnings that apply for Rock 94 Station",learningsCount:8}]})},500)})]})})},D=function(r,n){return e(void 0,void 0,void 0,function(){var e,a,i,o,s,c,u,l,d,p,v,h,f,b,S,w,y;return t(this,function(t){switch(t.label){case 0:a=(e=n||{}).isPopulateRoles,i=void 0!==a&&a,o=e.isPopulatePermissions,s=void 0!==o&&o,c=e.isPopulateApps,u=void 0!==c&&c,l=e.isPopulateEnvironments,d=void 0!==l&&l,p=e.isPopulateOperations,v=void 0!==p&&p,h=e.isPopulateGroups,f=void 0!==h&&h,b=e.isPopulateOrganization,S=void 0!==b&&b,w=new URLSearchParams({search:r,isPopulateRoles:String(i),isPopulatePermissions:String(s),isPopulateApps:String(u),isPopulateEnvironments:String(d),isPopulateOperations:String(v),isPopulateGroups:String(f),isPopulateOrganization:String(S)}),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,g.get("/api/user/get-by-query-v2?".concat(w.toString()))];case 2:return[2,t.sent().data];case 3:throw y=t.sent(),console.error("Failed to fetch users",y),y;case 4:return[2]}})})},Q=function(r){return void 0===r&&(r={}),e(void 0,void 0,void 0,function(){var e,n,a,i,o,s,c,u,l,d,p,v,g,f,b,S;return t(this,function(t){switch(t.label){case 0:e=r.appId,n=void 0===e?"":e,a=r.name,i=void 0===a?"":a,o=r.user,s=void 0===o?"":o,c=r.isActive,u=void 0===c||c,l=r.page,d=void 0===l?1:l,p=r.limit,v=void 0===p?10:p,g=r.pagination,f=void 0===g||g,b=new URLSearchParams({appId:n,name:i,user:s,isActive:String(u),page:String(d),limit:String(v),pagination:String(f)}),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,h.get("/groups?".concat(b.toString()))];case 2:return[2,t.sent().data];case 3:throw S=t.sent(),console.error("Failed to fetch user groups",S),S;case 4:return[2]}})})},G=function(n){var a=n.variant_ids,i=n.status,o=n.feedback,s=n.scopeId,c=n.is_deleted,u=n.appsecData;return e(void 0,void 0,void 0,function(){var e,n,l;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=r({variant_ids:a,status:i,feedback:o||"",is_deleted:null!=c&&c},u&&{appsecData:u}),n="instant_learning/scopes/".concat(s,"/variants/update_variant_status"),[4,v.patch(n,e)];case 1:return[2,t.sent().data];case 2:throw l=t.sent(),console.log(l),l;case 3:return[2]}})})},H=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,h.get("/roles?appId=".concat(r))];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error(e),e;case 3:return[2]}})})},N=function(r){return e(void 0,void 0,void 0,function(){var e,n,o,s;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,n=c.getState().app_integration_id,o=c.getState().token,t.label=1;case 1:return t.trys.push([1,6,,7]),e?[4,v.post(i.requestAccess,{scope_id:r})]:[3,3];case 2:return[2,t.sent().data];case 3:return[4,f(o).post(a.requestAccess,{scope_id:r,application_mapping_id:n})];case 4:return[2,t.sent().data];case 5:return[3,7];case 6:throw s=t.sent(),console.error("Error requesting global scope access:",s),s;case 7:return[2]}})})};function V(r,n,a){var i,o,s,c;return e(this,void 0,void 0,function(){var e,u,l;return t(this,function(t){switch(t.label){case 0:return[4,fetch("".concat(r,"/instant_learning/ilotj/application/getValueType/").concat(n),{headers:{Authorization:"Bearer ".concat(a)}})];case 1:if(!(e=t.sent()).ok)throw new Error("Failed to fetch LMS config");return[4,e.json()];case 2:return!(u=t.sent())||Array.isArray(u.data)&&0===u.data.length?[2,{lmsConfig:null,teachMeConfig:null,template:null}]:(l=null===(i=u.data[0])||void 0===i?void 0:i.value_type_config,[2,{lmsConfig:null!==(o=null==l?void 0:l.learningManagement)&&void 0!==o?o:null,teachMeConfig:null!==(s=null==l?void 0:l.teachMe)&&void 0!==s?s:null,template:null!==(c=null==l?void 0:l.template)&&void 0!==c?c:null}])}})})}var J=function(r){return e(void 0,void 0,void 0,function(){var e,n;return t(this,function(t){switch(t.label){case 0:e=c.getState().token,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,f(e).get("".concat(a.getILInstance).concat(r))];case 2:return[2,t.sent().data];case 3:throw n=t.sent(),console.error("Error fetching IL instance:",n),n;case 4:return[2]}})})};export{G as ApproveOrRejectVariants,H as GetAppsecRoles,z as alterQuestionPriority,h as appsecApi,g as appsecApigetUser,Q as appsecGetUserGroups,D as appsecGetUsersByQueryLite,p as audacyApi,k as createRuleSet,v as default,P as deleteQuestion,R as deleteRule,C as deleteRuleSet,T as deleteTier,j as exportRuleSet,V as fetchLMSConfig,F as fetchRulesByQuestionId,y as fetchScopes,E as fetchStationsByKeyword,U as fetchTiers,J as getILInstance,I as getRuleOverrideHistory,_ as getRulesInRuleSetById,M as getStationsByScopeId,L as inheritScope,q as inheritScopeBackwardCompatible,f as llmApiWithToken,b as publishFeedback,m as renameScope,N as requestAccess,O as retrieveGenreScopes,w as saveInstantLearningQuestion,x as searchScopes,S as submitChatFeedback,B as toggleVariant,A as updateVariant};
1
+ import{__awaiter as e,__generator as t,__assign as r}from"tslib";import n from"axios";import{API_ENDPOINTS as a,LEGACY_API_ENDPOINTS as i}from"./apiConfig.js";import o from"../store/useAuthStore.js";import s from"../store/useEnvStore.js";import{useLearningTemplateStore as c}from"../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as u}from"../config.js";var l=function(e){return e.interceptors.request.use(function(e){var t=o.getState().user,r=null==t?void 0:t.accessToken;return r&&(e.headers.Authorization="Bearer ".concat(r)),e}),e},d=function(e,t){return e.interceptors.request.use(function(e){return e.baseURL=t(),e}),e},p=d(l(n.create({headers:{"Content-Type":"application/json"}})),function(){return s.getState().audacyBackendUrl||""}),v=d(l(n.create({headers:{"Content-Type":"application/json"}})),function(){return s.getState().llmStudioUrl||""}),h=d(l(n.create({headers:{"Content-Type":"application/json"}})),function(){return s.getState().appsecRbacUrl||""}),g=d(l(n.create({headers:{"Content-Type":"application/json"}})),function(){return s.getState().appsecBaseUrl||""}),f=function(e){return d(l(n.create({headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},withCredentials:!0})),function(){return s.getState().llmStudioUrl||""})},b=function(r,n){return e(void 0,void 0,void 0,function(){var e,n,o;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,t.label=1;case 1:return t.trys.push([1,3,,4]),n=e?i.publishFeedback:"".concat(a.publishFeedback),[4,v.post(n,r)];case 2:return[2,t.sent().data];case 3:throw o=t.sent(),console.error("Error publishing feedback to LLM Studio:",o),o;case 4:return[2]}})})},S=function(r){return e(void 0,void 0,void 0,function(){var e,n,o;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,n=e?i.submitChatFeedback:a.submitChatFeedback,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,v.post(n,r)];case 2:return[2,t.sent().data];case 3:throw o=t.sent(),console.error("Error submitting chat feedback:",o),o;case 4:return[2]}})})},w=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v.post(a.saveInstantLearningQuestion,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error saving instant learning question:",e),e;case 3:return[2]}})})},y=function(r,n){return e(void 0,void 0,void 0,function(){var e,o,s;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,t.label=1;case 1:if(t.trys.push([1,3,,4]),!r&&!1===e)throw new Error("App Integration ID is not provided. Falling back to legacy endpoint for fetching scopes.");return o=e?i.fetchScopes:"".concat(a.fetchScopes,"/").concat(r),[4,f(n).get(o)];case 2:return[2,t.sent().data];case 3:throw s=t.sent(),console.error("Error fetching rule sets:",s),s;case 4:return[2]}})})},m=function(r,n){return e(void 0,void 0,void 0,function(){var e,o,s;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,t.label=1;case 1:return t.trys.push([1,3,,4]),o=e?i.renameScope:a.renameScope,[4,f(n).put(o,r)];case 2:return[2,t.sent().data];case 3:throw s=t.sent(),console.error("Error renaming scope:",s),s;case 4:return[2]}})})},_=function(r,n){return e(void 0,void 0,void 0,function(){var e,o,s,u;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,o=c.getState().app_integration_id,t.label=1;case 1:return t.trys.push([1,3,,4]),s=e?"".concat(i.getRulesInRuleSetById,"/").concat(r,"?include_config=True&sort_variant_by=createdAt"):"".concat(a.getRulesInRuleSetById,"/").concat(r,"/").concat(null!=o?o:""),[4,f(n).get(s)];case 2:return[2,t.sent().data];case 3:return u=t.sent(),console.error("Error fetching rules in rule set:",u),[3,4];case 4:return[2]}})})},I=function(r){return e(void 0,void 0,void 0,function(){var e,n,i,o;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,n=c.getState().app_integration_id,t.label=1;case 1:return t.trys.push([1,3,,4]),i=e?"".concat(a.getRuleOverrideHistory,"/").concat(r):"".concat(a.getRuleOverrideHistory,"/").concat(r,"/").concat(null!=n?n:""),[4,v.get(i)];case 2:return[2,t.sent().data];case 3:throw o=t.sent(),console.error("Error getting rule override history:",o),o;case 4:return[2]}})})},k=function(r,n){return e(void 0,void 0,void 0,function(){var e,o,s;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=c.getState().backwardCompatibility,o=e?i.createRuleSet:a.createRuleSet,[4,f(n).post(o,r)];case 1:return[2,t.sent().data];case 2:throw s=t.sent(),console.error("Error creating rule set:",s),s;case 3:return[2]}})})},E=function(r,n){return void 0===n&&(n=!1),e(void 0,void 0,void 0,function(){var e,i;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e="".concat(a.fetchStationsByKeyword.replace("{keyword}",r),"?allow_existing=").concat(n),[4,p.get(e)];case 1:return[2,t.sent().data];case 2:throw i=t.sent(),console.error("Error fetching station name by keyword:",i),i;case 3:return[2]}})})},C=function(r,n){return e(void 0,void 0,void 0,function(){var e,o,s,u;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,o=c.getState().app_integration_id,t.label=1;case 1:return t.trys.push([1,3,,4]),s=void 0,s=e?i.deleteRuleSet.replace("{ruleSetId}",r):a.deleteRuleSet.replace("{ruleSetId}",r).replace("{appIntegrationId}",null!=o?o:""),[4,f(n).delete(s)];case 2:return[2,t.sent().data];case 3:throw u=t.sent(),console.error("Error deleting rule set:",u),u;case 4:return[2]}})})},R=function(r){return e(void 0,void 0,void 0,function(){var e,n,o,s,u;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,n=c.getState().app_integration_id,o=c.getState().token,t.label=1;case 1:return t.trys.push([1,6,,7]),e?(s=i.deleteRule.replace("{ruleId}",r),[4,v.delete(s)]):[3,3];case 2:return[2,t.sent().data];case 3:return s=a.deleteRule.replace("{ruleId}",r).replace("{appIntegrationId}",null!=n?n:""),[4,f(o).delete(s)];case 4:return[2,t.sent().data];case 5:return[3,7];case 6:throw u=t.sent(),console.error("Error deleting rule:",u),u;case 7:return[2]}})})},P=function(r){return e(void 0,void 0,void 0,function(){var e,n,o,s,u;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,n=c.getState().app_integration_id,o=c.getState().token,t.label=1;case 1:return t.trys.push([1,6,,7]),e?(s=i.deleteQuestion.replace("{questionId}",r),[4,v.delete(s)]):[3,3];case 2:return[2,t.sent().data];case 3:return s=a.deleteQuestion.replace("{questionId}",r).replace("{appIntegrationId}",null!=n?n:""),[4,f(o).delete(s)];case 4:return[2,t.sent().data];case 5:return[3,7];case 6:throw u=t.sent(),console.error("Error deleting question:",u),u;case 7:return[2]}})})},T=function(r,n){return e(void 0,void 0,void 0,function(){var e,o,s,u,l;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,o=c.getState().app_integration_id,s=c.getState().token,t.label=1;case 1:return t.trys.push([1,6,,7]),e?(u=i.deleteTier.replace("{scopeId}",r).replace("{tierId}",n),[4,v.delete(u)]):[3,3];case 2:return[2,t.sent().data];case 3:return u=a.deleteTier.replace("{scopeId}",r).replace("{tierId}",n).replace("{appIntegrationId}",null!=o?o:""),[4,f(s).delete(u)];case 4:return[2,t.sent().data];case 5:return[3,7];case 6:throw l=t.sent(),console.error("Error deleting tier:",l),l;case 7:return[2]}})})},A=function(r,n){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v.put(a.updateVariant,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error updating variant:",e),e;case 3:return[2]}})})},q=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v.post(i.inheritScope,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error inheriting scope:",e),e;case 3:return[2]}})})},L=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,4,,5]),(null==r?void 0:r.application_mapping_id)?[4,v.post(a.inheritScope,r)]:[3,2];case 1:return[2,t.sent().data];case 2:throw Error("Fatal Error: Trying to call inherit API without appintegration ID");case 3:return[3,5];case 4:throw e=t.sent(),console.error("Error inheriting scope:",e),e;case 5:return[2]}})})},j=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:if(!r)throw new Error("scopeId is required for exporting rule sets");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,v.post(a.exportRuleSet,{scope_id:r},{responseType:"blob"})];case 2:return[2,t.sent().data];case 3:throw e=t.sent(),console.error("Error exporting rule set:",e),e;case 4:return[2]}})})},B=function(r,n,o){return e(void 0,void 0,void 0,function(){var e,o,s,u;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,o=c.getState().app_integration_id,s=c.getState().token,t.label=1;case 1:return t.trys.push([1,6,,7]),e?[4,f(s).patch(i.toggleVariant,{variant_ids:r,is_enabled:n})]:[3,3];case 2:return[2,t.sent().data];case 3:return[4,f(s).patch(a.toggleVariant,{variant_ids:r,application_mapping_id:o,is_enabled:n})];case 4:return[2,t.sent().data];case 5:return[3,7];case 6:throw u=t.sent(),console.error("Error toggling variant status:",u),u;case 7:return[2]}})})},U=function(){return e(void 0,void 0,void 0,function(){var e,r,n,o,s,l,d,p;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,r=c.getState().app_integration_id,n=c.getState().token,t.label=1;case 1:return t.trys.push([1,6,,7]),e?(o=u.CUSTOM_SCOPE_GROUP_NAME,[4,f(n).post(i.getTiers,{tier_group_name:o})]):[3,3];case 2:return s=t.sent(),c.getState().setTiers((null===(d=s.data)||void 0===d?void 0:d.response)||[]),[3,5];case 3:return[4,f(n).get(a.getTiers.replace("{appIntegrationId}",null!=r?r:""))];case 4:s=t.sent(),"success"===(null===(p=s.data)||void 0===p?void 0:p.status)&&c.getState().setTiers(s.data.data.map(function(e){return{tier_id:e.id,tier_name:e.tier_title,tier_priority:e.tier_priority}})),t.label=5;case 5:return[3,7];case 6:throw l=t.sent(),console.error("Error fetching tiers:",l),l;case 7:return[2]}})})},z=function(r,n,o,s,u){return e(void 0,void 0,void 0,function(){var e,l,d,p,v,h;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,l=c.getState().app_integration_id,d=c.getState().token,t.label=1;case 1:return t.trys.push([1,3,,4]),p=e?i.alterRulePriority:a.alterRulePriority,v=e?{scopeId:r,tierId:n,move:{movedRuleId:o,prevRuleId:s,nextRuleId:u}}:{scope_id:r,tier_id:n,move:{moved_rule_id:o,prev_rule_id:s,next_rule_id:u},application_mapping_id:l},[4,f(d).put(p,v)];case 2:return[2,t.sent().data];case 3:throw h=t.sent(),console.error("Error altering question priority:",h),h;case 4:return[2]}})})},F=function(r,n){return e(void 0,void 0,void 0,function(){var e,o,s,u,l;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,o=c.getState().app_integration_id,s=c.getState().token,t.label=1;case 1:return t.trys.push([1,6,,7]),e?(u=i.fetchRulesByQuestionId.replace("{questionId}",r).replace("{scopeId}",n),[4,v.get(u)]):[3,3];case 2:return[2,t.sent().data];case 3:return u=a.fetchRulesByQuestionId.replace("{appIntegrationId}",null!=o?o:"").replace("{questionId}",r).replace("{scopeId}",n),[4,f(s).get(u)];case 4:return[2,t.sent().data];case 5:return[3,7];case 6:throw l=t.sent(),console.error("Error fetching rules by question id:",l),l;case 7:return[2]}})})},O=function(r){return void 0===r&&(r={limit:"50",offset:"0"}),e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v.post(a.retrieveGenreScopes,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error retrieving genre scopes:",e),e;case 3:return[2]}})})},x=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v.post(a.searchScopes,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error searching scopes:",e),e;case 3:return[2]}})})},M=function(r){return e(void 0,void 0,void 0,function(){return t(this,function(e){return[2,new Promise(function(e){setTimeout(function(){e({data:[{stationId:"reetrtdfsds",stationName:"Hot 98.7",stationDesc:"Learnings that apply for Hot 98.7 Station",learningsCount:5},{stationId:"sta-102",stationName:"Smooth Jazz 102.1",stationDesc:"Learnings that apply for Smooth Jazz 102.1 Station",learningsCount:12},{stationId:"sta-103",stationName:"Rock 94",stationDesc:"Learnings that apply for Rock 94 Station",learningsCount:8}]})},500)})]})})},D=function(r,n){return e(void 0,void 0,void 0,function(){var e,a,i,o,s,c,u,l,d,p,v,h,f,b,S,w,y;return t(this,function(t){switch(t.label){case 0:a=(e=n||{}).isPopulateRoles,i=void 0!==a&&a,o=e.isPopulatePermissions,s=void 0!==o&&o,c=e.isPopulateApps,u=void 0!==c&&c,l=e.isPopulateEnvironments,d=void 0!==l&&l,p=e.isPopulateOperations,v=void 0!==p&&p,h=e.isPopulateGroups,f=void 0!==h&&h,b=e.isPopulateOrganization,S=void 0!==b&&b,w=new URLSearchParams({search:r,isPopulateRoles:String(i),isPopulatePermissions:String(s),isPopulateApps:String(u),isPopulateEnvironments:String(d),isPopulateOperations:String(v),isPopulateGroups:String(f),isPopulateOrganization:String(S)}),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,g.get("/api/user/get-by-query-v2?".concat(w.toString()))];case 2:return[2,t.sent().data];case 3:throw y=t.sent(),console.error("Failed to fetch users",y),y;case 4:return[2]}})})},Q=function(r){return void 0===r&&(r={}),e(void 0,void 0,void 0,function(){var e,n,a,i,o,s,c,u,l,d,p,v,g,f,b,S;return t(this,function(t){switch(t.label){case 0:e=r.appId,n=void 0===e?"":e,a=r.name,i=void 0===a?"":a,o=r.user,s=void 0===o?"":o,c=r.isActive,u=void 0===c||c,l=r.page,d=void 0===l?1:l,p=r.limit,v=void 0===p?10:p,g=r.pagination,f=void 0===g||g,b=new URLSearchParams({appId:n,name:i,user:s,isActive:String(u),page:String(d),limit:String(v),pagination:String(f)}),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,h.get("/groups?".concat(b.toString()))];case 2:return[2,t.sent().data];case 3:throw S=t.sent(),console.error("Failed to fetch user groups",S),S;case 4:return[2]}})})},G=function(n){var a=n.variant_ids,i=n.status,o=n.feedback,s=n.scopeId,c=n.is_deleted,u=n.appsecData;return e(void 0,void 0,void 0,function(){var e,n,l;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=r({variant_ids:a,status:i,feedback:o||"",is_deleted:null!=c&&c},u&&{appsecData:u}),n="instant_learning/scopes/".concat(s,"/variants/update_variant_status"),[4,v.patch(n,e)];case 1:return[2,t.sent().data];case 2:throw l=t.sent(),console.log(l),l;case 3:return[2]}})})},H=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,h.get("/roles?appId=".concat(r))];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error(e),e;case 3:return[2]}})})},N=function(r){return e(void 0,void 0,void 0,function(){var e,n,o,s;return t(this,function(t){switch(t.label){case 0:e=c.getState().backwardCompatibility,n=c.getState().app_integration_id,o=c.getState().token,t.label=1;case 1:return t.trys.push([1,6,,7]),e?[4,v.post(i.requestAccess,{scope_id:r})]:[3,3];case 2:return[2,t.sent().data];case 3:return[4,f(o).post(a.requestAccess,{scope_id:r,application_mapping_id:n})];case 4:return[2,t.sent().data];case 5:return[3,7];case 6:throw s=t.sent(),console.error("Error requesting global scope access:",s),s;case 7:return[2]}})})};function V(n,a,i){var o,s,c,u,l;return e(this,void 0,void 0,function(){var e,d,p,v;return t(this,function(t){switch(t.label){case 0:return[4,fetch("".concat(n,"/instant_learning/ilotj/application/getValueType/").concat(a),{headers:{Authorization:"Bearer ".concat(i)}})];case 1:if(!(e=t.sent()).ok)throw new Error("Failed to fetch LMS config");return[4,e.json()];case 2:return!(d=t.sent())||Array.isArray(d.data)&&0===d.data.length?[2,{lmsConfig:null,teachMeConfig:null,template:null}]:(p=null===(o=d.data[0])||void 0===o?void 0:o.value_type_config,[2,{lmsConfig:(v=null!==(s=null==p?void 0:p.learningManagement)&&void 0!==s?s:null)?r(r({},v),{agents:null!==(c=null==p?void 0:p.agents)&&void 0!==c?c:{}}):null,teachMeConfig:null!==(u=null==p?void 0:p.teachMe)&&void 0!==u?u:null,template:null!==(l=null==p?void 0:p.template)&&void 0!==l?l:null}])}})})}var J=function(r){return e(void 0,void 0,void 0,function(){var e,n;return t(this,function(t){switch(t.label){case 0:e=c.getState().token,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,f(e).get("".concat(a.getILInstance).concat(r))];case 2:return[2,t.sent().data];case 3:throw n=t.sent(),console.error("Error fetching IL instance:",n),n;case 4:return[2]}})})};export{G as ApproveOrRejectVariants,H as GetAppsecRoles,z as alterQuestionPriority,h as appsecApi,g as appsecApigetUser,Q as appsecGetUserGroups,D as appsecGetUsersByQueryLite,p as audacyApi,k as createRuleSet,v as default,P as deleteQuestion,R as deleteRule,C as deleteRuleSet,T as deleteTier,j as exportRuleSet,V as fetchLMSConfig,F as fetchRulesByQuestionId,y as fetchScopes,E as fetchStationsByKeyword,U as fetchTiers,J as getILInstance,I as getRuleOverrideHistory,_ as getRulesInRuleSetById,M as getStationsByScopeId,L as inheritScope,q as inheritScopeBackwardCompatible,f as llmApiWithToken,b as publishFeedback,m as renameScope,N as requestAccess,O as retrieveGenreScopes,w as saveInstantLearningQuestion,x as searchScopes,S as submitChatFeedback,B as toggleVariant,A as updateVariant};
2
2
  //# sourceMappingURL=scopeApis.js.map