@e-llm-studio/instant-learning 1.3.0-alpha.16 → 1.3.0-alpha.17

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 (73) hide show
  1. package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.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/RBAC/AccessManagementPanel.js +1 -1
  5. package/dist/cjs/features/LearningManagement/RuleContent/AddScopeModal.js +1 -1
  6. package/dist/cjs/features/LearningManagement/RuleContent/ApprovalLearningDialog.js +1 -1
  7. package/dist/cjs/features/LearningManagement/RuleContent/ContentLogic.js +1 -1
  8. package/dist/cjs/features/LearningManagement/RuleContent/RuleAccordionHeader.js +1 -1
  9. package/dist/cjs/features/LearningManagement/RuleContent/RuleContent.js +1 -1
  10. package/dist/cjs/features/LearningManagement/RuleContent/RuleHeader.js +1 -1
  11. package/dist/cjs/features/LearningManagement/RuleContent/TierCard.js +1 -1
  12. package/dist/cjs/features/LearningManagement/RuleContent/VariantCard.js +1 -1
  13. package/dist/cjs/features/LearningManagement/Sidebar.js +1 -1
  14. package/dist/cjs/features/LearningManagement/apis/scopeApis.js +1 -1
  15. package/dist/cjs/features/LearningManagement/components/ConfirmationModal.js +1 -1
  16. package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +1 -1
  17. package/dist/cjs/features/LearningManagement/components/ScopeTree/TreeNode.js +1 -1
  18. package/dist/cjs/features/LearningManagement/queries/useLMSConfigQuery.js +2 -0
  19. package/dist/cjs/features/LearningManagement/queries/useLMSConfigQuery.js.map +1 -0
  20. package/dist/cjs/features/LearningManagement/store/useLMSConfigStore.js +2 -0
  21. package/dist/cjs/features/LearningManagement/store/useLMSConfigStore.js.map +1 -0
  22. package/dist/cjs/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js +1 -1
  23. package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js +1 -1
  24. package/dist/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.js +1 -1
  25. package/dist/features/LearningManagement/LearningManagement.js +1 -1
  26. package/dist/features/LearningManagement/RBAC/AccessManagementPanel.js +1 -1
  27. package/dist/features/LearningManagement/RuleContent/AddScopeModal.js +1 -1
  28. package/dist/features/LearningManagement/RuleContent/ApprovalLearningDialog.js +1 -1
  29. package/dist/features/LearningManagement/RuleContent/ContentLogic.js +1 -1
  30. package/dist/features/LearningManagement/RuleContent/RuleAccordionHeader.js +1 -1
  31. package/dist/features/LearningManagement/RuleContent/RuleContent.js +1 -1
  32. package/dist/features/LearningManagement/RuleContent/RuleHeader.js +1 -1
  33. package/dist/features/LearningManagement/RuleContent/TierCard.js +1 -1
  34. package/dist/features/LearningManagement/RuleContent/VariantCard.js +1 -1
  35. package/dist/features/LearningManagement/Sidebar.js +1 -1
  36. package/dist/features/LearningManagement/apis/scopeApis.js +1 -1
  37. package/dist/features/LearningManagement/components/ConfirmationModal.js +1 -1
  38. package/dist/features/LearningManagement/components/InstantLearningModal.js +1 -1
  39. package/dist/features/LearningManagement/components/ScopeTree/TreeNode.js +1 -1
  40. package/dist/features/LearningManagement/queries/useLMSConfigQuery.js +2 -0
  41. package/dist/features/LearningManagement/queries/useLMSConfigQuery.js.map +1 -0
  42. package/dist/features/LearningManagement/store/useLMSConfigStore.js +2 -0
  43. package/dist/features/LearningManagement/store/useLMSConfigStore.js.map +1 -0
  44. package/dist/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js +1 -1
  45. package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.d.ts.map +1 -1
  46. package/dist/types/src/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.d.ts.map +1 -1
  47. package/dist/types/src/features/LearningManagement/LearningManagement.d.ts.map +1 -1
  48. package/dist/types/src/features/LearningManagement/LearningManagementTest.d.ts.map +1 -1
  49. package/dist/types/src/features/LearningManagement/RBAC/AccessManagementPanel.d.ts.map +1 -1
  50. package/dist/types/src/features/LearningManagement/RuleContent/AddScopeModal.d.ts.map +1 -1
  51. package/dist/types/src/features/LearningManagement/RuleContent/ApprovalLearningDialog.d.ts.map +1 -1
  52. package/dist/types/src/features/LearningManagement/RuleContent/ContentLogic.d.ts.map +1 -1
  53. package/dist/types/src/features/LearningManagement/RuleContent/RuleAccordionHeader.d.ts.map +1 -1
  54. package/dist/types/src/features/LearningManagement/RuleContent/RuleContent.d.ts.map +1 -1
  55. package/dist/types/src/features/LearningManagement/RuleContent/RuleHeader.d.ts.map +1 -1
  56. package/dist/types/src/features/LearningManagement/RuleContent/TierCard.d.ts.map +1 -1
  57. package/dist/types/src/features/LearningManagement/RuleContent/VariantCard.d.ts.map +1 -1
  58. package/dist/types/src/features/LearningManagement/Sidebar.d.ts.map +1 -1
  59. package/dist/types/src/features/LearningManagement/apis/scopeApis.d.ts +7 -0
  60. package/dist/types/src/features/LearningManagement/apis/scopeApis.d.ts.map +1 -1
  61. package/dist/types/src/features/LearningManagement/components/ConfirmationModal.d.ts +2 -1
  62. package/dist/types/src/features/LearningManagement/components/ConfirmationModal.d.ts.map +1 -1
  63. package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts +1 -0
  64. package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts.map +1 -1
  65. package/dist/types/src/features/LearningManagement/components/ScopeTree/TreeNode.d.ts.map +1 -1
  66. package/dist/types/src/features/LearningManagement/queries/useLMSConfigQuery.d.ts +2 -0
  67. package/dist/types/src/features/LearningManagement/queries/useLMSConfigQuery.d.ts.map +1 -0
  68. package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts +156 -0
  69. package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts.map +1 -0
  70. package/dist/types/src/plugins/ValueTypes/Default/DefaultTeachMeRenderer.d.ts +17 -0
  71. package/dist/types/src/plugins/ValueTypes/Default/DefaultTeachMeRenderer.d.ts.map +1 -1
  72. package/dist/types/src/plugins/ValueTypes/Default/DefaultTeachMeRendererOld.d.ts.map +1 -1
  73. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("lucide-react"),o=require("../../styles/ScopeTree.module.css.js"),d=require("./TreeNodeHeader.js"),t=require("./TreeSectionItem.js"),l=require("./TreeAddAction.js"),r=function(a){var s,c,u,p,h=a.node,v=a.depth,C=void 0===v?0:v,m=a.nodePath,f=void 0===m?[]:m,b=a.expandedNodeIds,g=a.activeSelection,y=a.onToggleExpand,T=a.onSectionSelect,x=a.onNodeOptionsClick,S=a.onAddChild,A=a.onRenameChild,_=a.onDeleteChild,j=a.canDeleteScope,N=a.canEditScope,L=a.canCreateScope,P=a.searchQuery,k=a.sectionsConfig,q=void 0===k?[]:k,w=a.nodeTypesConfig,D=void 0===w?[]:w,E=a.forceVisible,I=void 0!==E&&E,O=e.__spreadArray(e.__spreadArray([],f,!0),[h.id],!1),V=b.has(h.id),Q=!!g&&g.nodePath[g.nodePath.length-1]===h.id,R=!!g&&(g.nodePath.includes(h.id)&&!Q),Y=function(e,i){if(!i)return!0;var n=i.toLowerCase();return!!e.name.toLowerCase().includes(n)||!!e.children&&e.children.some(function(e){return Y(e,i)})};if(!I&&!Y(h,P||""))return null;var H=C>=D.length-1?D[D.length-1]:D[C],K=!!(null==H?void 0:H.addChildType),W=!j||j(h.id),M=!N||N(h.id),z=!L||L(h.id),B=h.children&&h.children.length>0,F=!W||B,G=W?B?"This scope cannot be deleted because other scopes inherit learnings from it.":void 0:"You do not have permission to delete this scope.",J=z?void 0:"You do not have permission to add a scope here.",U=!P||h.name.toLowerCase().includes(P.toLowerCase());return i.jsxs("div",e.__assign({className:o.default.nodeWrapper,style:{"--tree-depth":C}},{children:[i.jsx(d.TreeNodeHeader,{nodeType:h.type,name:h.name,isExpanded:V,isSelected:Q,isAncestor:R,childrenCount:null===(s=h.children)||void 0===s?void 0:s.length,onToggleExpand:function(e){e.stopPropagation(),y(h.id)},onClick:function(){T(O,"learnings")},searchQuery:P,menuOptions:e.__spreadArray(e.__spreadArray([],K?[{label:H.addChildLabel||"Add Child",icon:n.Plus,onClick:function(){return null==S?void 0:S(h.id,H.addChildType,h.name)},disabled:!z,tooltip:J}]:[],!0),[{label:"Rename",icon:n.Pencil,onClick:function(){return null==A?void 0:A(h.id,h.name)},disabled:!M||"station"===(null===(c=null==h?void 0:h.type)||void 0===c?void 0:c.toLocaleLowerCase()),tooltip:M?void 0:"You do not have permission to rename this scope."},{label:"station"===(null===(u=null==h?void 0:h.type)||void 0===u?void 0:u.toLowerCase())?"Delete Station":"Delete ".concat((null==H?void 0:H.label)||"Node"),icon:n.Trash2,onClick:function(){var e;return null==_?void 0:_(h.id,h.name,(null===(e=h.metrics)||void 0===e?void 0:e.learningsCount)||0)},disabled:F,tooltip:G,className:"text-red-500 hover:text-red-600 hover:bg-red-50"}],!1)}),V&&i.jsxs("div",e.__assign({className:o.default.childrenWrapper},{children:[q.filter(function(e){return!e.isVisible||e.isVisible(h,C)}).map(function(e){var n;return i.jsx(t.TreeSectionItem,{icon:e.icon,label:e.label,badgeCount:e.badgeKey?null===(n=h.metrics)||void 0===n?void 0:n[e.badgeKey]:void 0,isActive:Q&&(null==g?void 0:g.sectionId)===e.id,onClick:function(){return T(O,e.id)}},"".concat(h.id,"-").concat(e.id))}),null===(p=h.children)||void 0===p?void 0:p.map(function(e){return i.jsx(r,{node:e,depth:C+1,nodePath:O,expandedNodeIds:b,activeSelection:g,onToggleExpand:y,onSectionSelect:T,onNodeOptionsClick:x,onAddChild:S,onRenameChild:A,onDeleteChild:_,canDeleteScope:j,canEditScope:N,canCreateScope:L,searchQuery:P,forceVisible:U,sectionsConfig:q,nodeTypesConfig:D},e.id)}),K&&i.jsx(l.TreeAddAction,{label:H.addChildLabel||"Add Child",onAdd:function(){return null==S?void 0:S(h.id,H.addChildType,h.name)},disabled:!z,tooltip:J})]}))]}))};exports.TreeNode=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("lucide-react"),o=require("../../styles/ScopeTree.module.css.js"),d=require("./TreeNodeHeader.js"),t=require("./TreeSectionItem.js"),r=require("./TreeAddAction.js"),l=require("../../store/useLMSConfigStore.js"),a=function(s){var c,u,p,h,v=s.node,C=s.depth,m=void 0===C?0:C,f=s.nodePath,g=void 0===f?[]:f,b=s.expandedNodeIds,y=s.activeSelection,x=s.onToggleExpand,S=s.onSectionSelect,T=s.onNodeOptionsClick,A=s.onAddChild,_=s.onRenameChild,j=s.onDeleteChild,N=s.canDeleteScope,L=s.canEditScope,D=s.canCreateScope,P=s.searchQuery,q=s.sectionsConfig,w=void 0===q?[]:q,k=s.nodeTypesConfig,E=void 0===k?[]:k,I=s.forceVisible,M=void 0!==I&&I,O=e.__spreadArray(e.__spreadArray([],g,!0),[v.id],!1),V=b.has(v.id),Q=!!y&&y.nodePath[y.nodePath.length-1]===v.id,R=!!y&&(y.nodePath.includes(v.id)&&!Q),Y=function(e,n){if(!n)return!0;var i=n.toLowerCase();return!!e.name.toLowerCase().includes(i)||!!e.children&&e.children.some(function(e){return Y(e,n)})};if(!M&&!Y(v,P||""))return null;var H=m>=E.length-1?E[E.length-1]:E[m],K=!!(null==H?void 0:H.addChildType),W=!N||N(v.id),z=!L||L(v.id),B=!D||D(v.id),F=v.children&&v.children.length>0,G=!W||F,J=W?F?"This scope cannot be deleted because other scopes inherit learnings from it.":void 0:"You do not have permission to delete this scope.",U=B?void 0:"You do not have permission to add a scope here.",X=!P||v.name.toLowerCase().includes(P.toLowerCase());return n.jsxs("div",e.__assign({className:o.default.nodeWrapper,style:{"--tree-depth":m}},{children:[n.jsx(d.TreeNodeHeader,{nodeType:v.type,name:v.name,isExpanded:V,isSelected:Q,isAncestor:R,childrenCount:null===(c=v.children)||void 0===c?void 0:c.length,onToggleExpand:function(e){e.stopPropagation(),x(v.id)},onClick:function(){S(O,"learnings")},searchQuery:P,menuOptions:e.__spreadArray(e.__spreadArray([],K?[{label:H.addChildLabel||"Add Child",icon:i.Plus,onClick:function(){return null==A?void 0:A(v.id,H.addChildType,v.name)},disabled:!B,tooltip:U}]:[],!0),[{label:"".concat(l.dt("middleDrawer.contextMenu.rename","Rename")),icon:i.Pencil,onClick:function(){return null==_?void 0:_(v.id,v.name)},disabled:!z||"station"===(null===(u=null==v?void 0:v.type)||void 0===u?void 0:u.toLocaleLowerCase()),tooltip:z?void 0:"You do not have permission to rename this scope."},{label:"station"===(null===(p=null==v?void 0:v.type)||void 0===p?void 0:p.toLowerCase())?"Delete Station":" ".concat(l.dt("middleDrawer.contextMenu.Delete","Delete ".concat((null==H?void 0:H.label)||"Node"))),icon:i.Trash2,onClick:function(){var e;return null==j?void 0:j(v.id,v.name,(null===(e=v.metrics)||void 0===e?void 0:e.learningsCount)||0)},disabled:G,tooltip:J,className:"text-red-500 hover:text-red-600 hover:bg-red-50"}],!1)}),V&&n.jsxs("div",e.__assign({className:o.default.childrenWrapper},{children:[w.filter(function(e){return!e.isVisible||e.isVisible(v,m)}).map(function(e){var i;return n.jsx(t.TreeSectionItem,{icon:e.icon,label:e.label,badgeCount:e.badgeKey?null===(i=v.metrics)||void 0===i?void 0:i[e.badgeKey]:void 0,isActive:Q&&(null==y?void 0:y.sectionId)===e.id,onClick:function(){return S(O,e.id)}},"".concat(v.id,"-").concat(e.id))}),null===(h=v.children)||void 0===h?void 0:h.map(function(e){return n.jsx(a,{node:e,depth:m+1,nodePath:O,expandedNodeIds:b,activeSelection:y,onToggleExpand:x,onSectionSelect:S,onNodeOptionsClick:T,onAddChild:A,onRenameChild:_,onDeleteChild:j,canDeleteScope:N,canEditScope:L,canCreateScope:D,searchQuery:P,forceVisible:X,sectionsConfig:w,nodeTypesConfig:E},e.id)}),K&&n.jsx(r.TreeAddAction,{label:H.addChildLabel||"Add Child",onAdd:function(){return null==A?void 0:A(v.id,H.addChildType,v.name)},disabled:!B,tooltip:U})]}))]}))};exports.TreeNode=a;
2
2
  //# sourceMappingURL=TreeNode.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("@tanstack/react-query"),t=require("../store/useAuthStore.js"),n=require("../store/useEnvStore.js"),u=require("../apis/scopeApis.js"),i=require("../store/useLMSConfigStore.js"),o=require("../store/useLearningTemplateStore.js");exports.useLMSConfigQuery=function(s,a){var l=this;void 0===a&&(a=!0);var c=t.default(function(e){var r,t;return null!==(t=null===(r=e.user)||void 0===r?void 0:r.accessToken)&&void 0!==t?t:""}),f=n.default(function(e){var r;return null!==(r=e.llmStudioUrl)&&void 0!==r?r:""}),g=i.useLMSConfigStore(function(e){return e.setLMSConfig}),v=i.useTeachMeConfigStore(function(e){return e.setTeachMeConfig}),d=o.useLearningTemplateStore(function(e){return e.setTemplateData});return r.useQuery({queryKey:["lms-config",s],queryFn:function(){return e.__awaiter(l,void 0,void 0,function(){var r,t,n,i;return e.__generator(this,function(e){switch(e.label){case 0:return[4,u.fetchLMSConfig(f,s,c)];case 1:return r=e.sent(),t=r.lmsConfig,n=r.teachMeConfig,i=r.template,t&&g(t),n&&v(n),i&&d(s,i),[2,{lmsConfig:t,teachMeConfig:n,template:i}]}})})},enabled:a&&!!s&&!!c&&!!f,staleTime:6e5})};
2
+ //# sourceMappingURL=useLMSConfigQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLMSConfigQuery.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("zustand"),t={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:""}}}}},n=e.create(function(e){return{lmsConfig:t,setLMSConfig:function(t){return e({lmsConfig:t})},clearLMSConfig:function(){return e({lmsConfig:t})}}});var r=e.create(function(e){return{teachMeConfig:null,setTeachMeConfig:function(t){return e({teachMeConfig:t})},clearTeachMeConfig:function(){return e({teachMeConfig:null})}}});exports.defaultLMSConfig=t,exports.dt=function(e,t,r){var i=n.getState().lmsConfig,o=e.split(".").reduce(function(e,t){return null==e?void 0:e[t]},i);return"string"!=typeof o?null!=t?t:e:"__"+o.replace(/\{(\w+)\}/g,function(e,t){var n;return String(null!==(n=null==r?void 0:r[t])&&void 0!==n?n:"{".concat(t,"}"))})},exports.dtt=function(e,t,n){var i=r.getState().teachMeConfig,o=e.split(".").reduce(function(e,t){return null==e?void 0:e[t]},i);return"string"!=typeof o?null!=t?t:e:o.replace(/\{(\w+)\}/g,function(e,t){var r;return String(null!==(r=null==n?void 0:n[t])&&void 0!==r?r:"{".concat(t,"}"))})},exports.useLMSConfigStore=n,exports.useTeachMeConfigStore=r;
2
+ //# sourceMappingURL=useLMSConfigStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLMSConfigStore.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../features/LearningManagement/components/InstantLearningModal.js");exports.default=function(i){var a=i.pluginPayload||{},n=a.editingRule,r=a.editingTier,o=a.editingVariants,d=a.focusedVariantIndex,u=a.setFocusedVariantIndex,c=a.triggerAddVariant,s=a.triggerFixGaps,l=a.copiedRule,p=a.copiedSourceTier,g=a.copiedTargetTier,I=a.initialDraftMessage,m=a.app_integration_id,w=a.modeId,x={"Separation rule":"I would want to add a separation rule","Max priority rule":"I would want to set a max priority rule","Break code matching":"I would want to add a break code matching rule","Inventory code matching":"I would want to add a inventory window matching rule","Enter a rule description":"I want to add a rule description","Tester Genie":"Loading prompt..."},y="<p><span>Hi! 👋 I'm your Instant Learning Concierge.</span>\n <span>How would you like to get started? You can select an option below or describe the rule you’d like to create.</span>\n ".concat(["Separation rule","Max priority rule","Break code matching","Inventory code matching","Enter a rule description","Tester Genie"].map(function(e){return'<button class="clickable-button" data-value="'.concat(x[e],'">').concat(e,"</button>")}).join(""),"</p>");return e.jsx(t.default,{isOpen:i.isOpen,onClose:i.onClose,initialScope:i.initialScope,ruleSet:i.ruleSet,editingRule:n,editingTier:r,editingVariants:o,focusedVariantIndex:d,setFocusedVariantIndex:u,triggerAddVariant:c,triggerFixGaps:s,copiedRule:l,copiedSourceTier:p,copiedTargetTier:g,initialDraftMessage:I,initialChatMessage:y,applicationIntegrationId:m,modeId:w})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),i=require("react"),a=require("../../../features/LearningManagement/components/InstantLearningModal.js"),r=require("../../../features/LearningManagement/store/useLMSConfigStore.js"),n={order_rules:{enabled:!1,global_min_separation_seconds:0},advertiser_rules:{enabled:!1,global_min_separation_seconds:0},inventory_rules:{respect_inventory_code:!1},break_code_rules:{respect_break_code:!1},is_default_enabled:!1};exports.default=function(l){var o=l.pluginPayload||{},s=o.editingRule,d=o.editingTier,u=o.editingVariants,p=o.focusedVariantIndex,c=o.setFocusedVariantIndex,g=o.triggerAddVariant,_=o.triggerFixGaps,T=o.copiedRule,b=o.copiedSourceTier,f=o.copiedTargetTier,v=o.initialDraftMessage,y=o.app_integration_id,L=o.modeId;r.useTeachMeConfigStore(function(e){return e.teachMeConfig});var A=i.useState(n),S=A[0];A[1],e.__assign({key:"order_rules",label:"Order"},S.order_rules),e.__assign({key:"advertiser_rules",label:"Advertiser"},S.advertiser_rules),S.inventory_rules.respect_inventory_code,S.break_code_rules.respect_break_code,S.is_default_enabled;var h={showScope:!1,showConfiguration:!1,welcomeMessage:r.dtt("welcomeMessage","Hey how can I assist you?"),formTitle:r.dtt("formTitle","Rule setup"),setupLabel:r.dtt("setupLabel","Configure your IL"),ruleTitle:r.dtt("ruleTitle","Main Rule Name"),scopeLabel:r.dtt("scopeLabel","Define Scope"),tierLabel:r.dtt("tierLabel","Select Tiers"),ruleDescriptionTitle:r.dtt("ruleDescriptionTitle","Learning Explanation"),whenToApplyTitle:r.dtt("whenToApplyTitle","Trigger Events (When to Apply)"),addWhenToApplyBtnLabel:r.dtt("addWhenToApplyBtnLabel","Add WTA"),whenNotToApplyTitle:r.dtt("whenNotToApplyTitle","Exclusion Events (When NOT to Apply)"),addWhenNotToApplyBtnLabel:r.dtt("addWhenNotToApplyBtnLabel","Add WNTA"),configTitle:r.dtt("configTitle","Advanced Settings"),saveBtnConfig:{label:r.dtt("saveBtnLabel","Save Rule"),loadingLabel:r.dtt("saveBtnLoadingLabel","Saving Rule...")}};return t.jsx(a.default,{isOpen:l.isOpen,onClose:l.onClose,initialScope:l.initialScope,ruleSet:l.ruleSet,editingRule:s,editingTier:d,editingVariants:u,focusedVariantIndex:p,setFocusedVariantIndex:c,triggerAddVariant:g,triggerFixGaps:_,copiedRule:T,copiedSourceTier:b,copiedTargetTier:f,initialDraftMessage:v,initialChatMessage:h.welcomeMessage,applicationIntegrationId:y,modeId:L,uiStateLabels:h})};
2
2
  //# sourceMappingURL=DefaultTeachMeRenderer.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__awaiter as t,__generator as r}from"tslib";import{jsx as i,jsxs as n}from"react/jsx-runtime";import{useState as a,useEffect as o}from"react";import{Box as s,CircularProgress as c,Dialog as l,DialogTitle as p,Typography as d,IconButton as u,DialogContent as f}from"@mui/material";import m from"@mui/icons-material/Close";import{useLearningTemplateStore as h}from"../../LearningManagement/store/useLearningTemplateStore.js";var v=function(){var t=a(!0),r=t[0],o=t[1];return n(l,e({open:r,onClose:function(){return o(!1)},fullWidth:!0,maxWidth:"lg",PaperProps:{sx:{borderRadius:"16px",minHeight:"70vh",overflow:"hidden"}}},{children:[n(p,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e0e0e0",px:3,py:2}},{children:[i(d,e({variant:"h6",fontWeight:600},{children:"Teach Me"})),i(u,e({onClick:function(){return o(!1)}},{children:i(m,{})}))]})),i(f,e({dividers:!0,sx:{p:3,backgroundColor:"#fafafa"}},{children:"There is some issue with the selected template. Kindly check steps to resolve."}))]}))},g=function(n){var l=n.templateRegistry,p=void 0===l?{}:l,d=h(function(e){return e.backwardCompatibility}),u=h(function(e){return n.app_integration_id?e.templateMap[n.app_integration_id]:void 0}),f=h(function(e){return e.setTemplateData}),m=d?"Radio Traffic Learning":u,g=a(!m),_=g[0],y=g[1],b=a(!1),w=b[0],x=b[1];if(o(function(){if(n.isOpen){if(!d&&!n.app_integration_id)return console.error("TeachMeWrapper requires an app_integration_id when backward compatibility is disabled."),x(!0),void y(!1);if(m)y(!1);else{t(void 0,void 0,void 0,function(){var e,i;return r(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,3,4]),y(!0),x(!1),[4,(o=n.app_integration_id,s=n.token,t(void 0,void 0,void 0,function(){var e,t;return r(this,function(r){switch(r.label){case 0:return[4,fetch("".concat("https://devllmstudio.creativeworkspace.ai","/instant_learning/ilotj/application/getValueType/").concat(o),{headers:{Authorization:"Bearer ".concat(s)}})];case 1:if(!(e=r.sent()).ok)throw new Error("Failed to fetch value type");return[4,e.json()];case 2:return t=r.sent(),console.log("Fetched value type data:",t),!t||Array.isArray(t.data)&&0===t.data.length?[2,null]:[2,t.data[0].value_type_name||t.valueTypeName||t.templateName]}})}))];case 1:return e=a.sent(),f(n.app_integration_id,e),[3,4];case 2:return i=a.sent(),console.error(i),x(!0),n.app_integration_id&&f(n.app_integration_id,"ERROR"),[3,4];case 3:return y(!1),[7];case 4:return[2]}var o,s})})}}},[n.isOpen,n.app_integration_id,m,n.token,f,d]),_)return i(s,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:i(c,{size:32})}));if(w||!m)return i(v,{});var k=p[m];return k?i(k,e({},n)):(console.warn("No renderer found for template: ".concat(m)),i(v,{}))};export{g as default};
1
+ import{__assign as e,__awaiter as t,__generator as r}from"tslib";import{jsx as i,jsxs as n}from"react/jsx-runtime";import{useState as a,useEffect as o}from"react";import{Box as s,CircularProgress as c,Dialog as l,DialogTitle as p,Typography as d,IconButton as u,DialogContent as f}from"@mui/material";import m from"@mui/icons-material/Close";import{useLearningTemplateStore as h}from"../../LearningManagement/store/useLearningTemplateStore.js";var v=function(){var t=a(!0),r=t[0],o=t[1];return n(l,e({open:r,onClose:function(){return o(!1)},fullWidth:!0,maxWidth:"lg",PaperProps:{sx:{borderRadius:"16px",minHeight:"70vh",overflow:"hidden"}}},{children:[n(p,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e0e0e0",px:3,py:2}},{children:[i(d,e({variant:"h6",fontWeight:600},{children:"Teach Me"})),i(u,e({onClick:function(){return o(!1)}},{children:i(m,{})}))]})),i(f,e({dividers:!0,sx:{p:3,backgroundColor:"#fafafa"}},{children:"There is some issue with the selected template. Kindly check steps to resolve."}))]}))},g=function(n){var l=n.templateRegistry,p=void 0===l?{}:l,d=h(function(e){return e.backwardCompatibility}),u=h(function(e){return n.app_integration_id?e.templateMap[n.app_integration_id]:void 0}),f=h(function(e){return e.setTemplateData}),m=d?"Radio Traffic Learning":u,g=a(!m),_=g[0],y=g[1],b=a(!1),w=b[0],x=b[1];if(o(function(){if(n.isOpen){if(!d&&!n.app_integration_id)return console.error("TeachMeWrapper requires an app_integration_id when backward compatibility is disabled."),x(!0),void y(!1);if(m)y(!1);else{t(void 0,void 0,void 0,function(){var e,i;return r(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,3,4]),y(!0),x(!1),[4,(o=n.app_integration_id,s=n.token,t(void 0,void 0,void 0,function(){var e,t;return r(this,function(r){switch(r.label){case 0:return[4,fetch("".concat("https://devllmstudio.creativeworkspace.ai","/instant_learning/ilotj/application/getValueType/").concat(o),{headers:{Authorization:"Bearer ".concat(s)}})];case 1:if(!(e=r.sent()).ok)throw new Error("Failed to fetch value type");return[4,e.json()];case 2:return t=r.sent(),console.log("Fetched value type data:",t),!t||Array.isArray(t.data)&&0===t.data.length?[2,null]:[2,t.data[0].value_type_name||t.valueTypeName||t.templateName]}})}))];case 1:return e=a.sent(),f(n.app_integration_id,e),[3,4];case 2:return i=a.sent(),console.error(i),x(!0),n.app_integration_id&&f(n.app_integration_id,"ERROR"),[3,4];case 3:return y(!1),[7];case 4:return[2]}var o,s})})}}},[n.isOpen,n.app_integration_id,m,n.token,f,d]),_)return i(s,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:i(c,{size:32})}));if(w||!m)return i(v,{});var k=p[m&&p[m]?m:"Default"];return k?i(k,e({},n)):(console.warn("No renderer found for template: ".concat(m)),i(v,{}))};export{g as default};
2
2
  //# sourceMappingURL=TeachMeWrapper.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=m.state,R=m.handlers,_=m.uiState,N=(null==_?void 0:_.highlights)||new Map,W=N.get("global_0")||{},L=o({}),B=L[0],F=L[1],M=o(null),j=M[0],k=M[1],z=o(function(){var i,e,n;if((null==_?void 0:_.defaultTierOpen)>=0&&(null===(i=null==_?void 0:_.tierOptions)||void 0===i?void 0:i[_.defaultTierOpen]))return _.tierOptions[_.defaultTierOpen].toLowerCase().replace(/ /g,"_");var t=null===(n=null===(e=V.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n[0];return t?t.toLowerCase().replace(/ /g,"_"):null});z[0];var q=z[1],P="rule-setup"===(null==_?void 0:_.activeEditId),J=t.useRef(new Map),H=o(null),K=H[0],$=H[1],U=o(null),Z=U[0],G=U[1],Q=o(!1),X=Q[0],Y=Q[1],ii=t.useRef(null==_?void 0:_.isAiStreaming);l(function(){ii.current&&!(null==_?void 0:_.isAiStreaming)&&X&&Y(!1),ii.current=null==_?void 0:_.isAiStreaming},[null==_?void 0:_.isAiStreaming,X]);var ei=function(){var i;$(null),G(null),null===(i=null==_?void 0:_.setActiveEditId)||void 0===i||i.call(_,null)},ni=function(){var i,e,n=null!=K?K:V.ruleTitle,t=null!=Z?Z:V.scopeData,o=n!==V.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(V.scopeData);if(!o&&!l)return $(null),G(null),void(null===(i=null==_?void 0:_.setActiveEditId)||void 0===i||i.call(_,null));if(null==_?void 0:_.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 ");_.setSendMessageInChat("__SKELETON__:".concat(r,":Update Rule Setup ").concat(u))}Y(!0),$(null),G(null),null===(e=null==_?void 0:_.setActiveEditId)||void 0===e||e.call(_,null)},ti=null!==K?null==K?void 0:K.trim():(V.ruleTitle||"").trim(),oi=null!=Z?Z:V.scopeData,li=ti!==(V.ruleTitle||"").trim(),ri=JSON.stringify(oi)!==JSON.stringify(V.scopeData),ai=!li&&!ri||""===ti,di=t.useRef(null==_?void 0:_.defaultVariantOpen),ci=t.useRef(null==_?void 0:_.activeVariantAccordionIndex),ui=t.useRef(null==_?void 0:_.defaultTierOpen),si=t.useRef(null===(T=V.scopeData)||void 0===T?void 0:T.tiers),vi=t.useRef(V.variantsByTier);t.useEffect(function(){var i,e,n,t,o,l,r=null,a=!1;di.current!==(null==_?void 0:_.defaultVariantOpen)&&(a=!0,di.current=null==_?void 0:_.defaultVariantOpen),ci.current!==(null==_?void 0:_.activeVariantAccordionIndex)&&(a=!0,ci.current=null==_?void 0:_.activeVariantAccordionIndex),ui.current!==(null==_?void 0:_.defaultTierOpen)&&(a=!0,ui.current=null==_?void 0:_.defaultTierOpen);var d=(null===(i=V.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(si.current)!==JSON.stringify(d)&&(a=!0,si.current=d,d.length>0&&q(d[0].toLowerCase().replace(/ /g,"_")));var c=(null===(e=null==_?void 0:_.tierOptions)||void 0===e?void 0:e.filter(function(i){var e,n;return null===(n=null===(e=V.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=vi.current)||void 0===e?void 0:e[l])||void 0===n?void 0:n.length)||0)!==((null===(o=null===(t=V.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==_?void 0:_.activeVariantAccordionIndex)&&void 0!==n?n:null==_?void 0:_.defaultVariantOpen;if(null==s||s<0)return k(null),void(vi.current=V.variantsByTier);c.forEach(function(i,e){var n;if(!((null==_?void 0:_.defaultTierOpen)>=0&&e!==_.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),o=(null===(n=V.variantsByTier)||void 0===n?void 0:n[t])||[];o[s]&&(r="".concat(t,"-variant-").concat(s)),null!=(null==_?void 0:_.autoScrollVariantIndex)&&o[_.autoScrollVariantIndex]&&(r="".concat(t,"-variant-").concat(_.autoScrollVariantIndex))}}),r&&k(r)}if(null===j){var v=null!==(t=null==_?void 0:_.activeVariantAccordionIndex)&&void 0!==t?t:null==_?void 0:_.defaultVariantOpen;null!=v&&v>=0&&(null===(l=null===(o=null==_?void 0:_.tierOptions)||void 0===o?void 0:o.filter(function(i){var e,n;return null===(n=null===(e=V.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==_?void 0:_.defaultTierOpen)>=0&&e!==_.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(n=V.variantsByTier)||void 0===n?void 0:n[t])||[])[v]&&k("".concat(t,"-variant-").concat(v))}}))}vi.current=V.variantsByTier},[V.variantsByTier,null==_?void 0:_.defaultVariantOpen,null==_?void 0:_.activeVariantAccordionIndex,null===(x=V.scopeData)||void 0===x?void 0:x.tiers,null==_?void 0:_.tierOptions,null==_?void 0:_.autoScrollVariantIndex,null==_?void 0:_.defaultTierOpen]);var pi=function(e){F(function(n){var t;return i(i({},n),((t={})[e]=!n[e],t))})},fi=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=V.fieldCitations)||void 0===e?void 0:e[r];if(Array.isArray(a)&&a.length>0)return a;var d=null===(n=V.fieldCitations)||void 0===n?void 0:n[i];return Array.isArray(d)&&d.length>0?d:null!==(t=V.citations)&&void 0!==t?t:[]},gi={marginTop:"-17px",position:"relative",zIndex:1};l(function(){var i,e;null!=(null==_?void 0:_.autoScrollVariantIndex)&&(null===(e=null===(i=null==_?void 0:_.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,n;return null===(n=null===(e=V.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(_.autoScrollVariantIndex),t=J.current.get(n);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==_?void 0:_.scrollTrigger]),console.log("CreateRule state:",V),console.log("CreateRule uiState:",_);var hi=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"},yi=!!(null==_?void 0:_.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==_?void 0:_.setupLabel)||"Rule Setup"},actionButtons:function(e,t){if(P)return null;var o=!!(null==_?void 0:_.activeEditId)&&"rule-setup"!==_.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==_?void 0:_.setPendingEditId)&&_.setPendingEditId(_.activeEditId||null):(!function(){var e,n;(null==_?void 0:_.activeEditId)&&"rule-setup"!==_.activeEditId||(null===(e=null==_?void 0:_.setActiveEditId)||void 0===e||e.call(_,"rule-setup"),$(null!==(n=V.ruleTitle)&&void 0!==n?n:""),G(V.scopeData?i({},V.scopeData):{}))}(),(null==_?void 0:_.setPendingEditId)&&_.setPendingEditId(null),e||t())},disabled:X,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:X?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:X?.5:1}},{children:n(f,{size:14})}))}))},footerData:{ruleTitle:V.ruleTitle,stations:[V.scopeData.station],tiers:null===(D=V.scopeData)||void 0===D?void 0:D.tiers},defaultOpen:"Create"===(null==_?void 0:_.usedFor),readOnly:"Create"!==(null==_?void 0:_.usedFor),isAiStreaming:null==_?void 0:_.isAiStreaming,editFlow:"Edit"===(null==_?void 0:_.usedFor)},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[X&&(null==_?void 0:_.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:_.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:P&&null!==K?K:V.ruleTitle,onChange:function(i){return P?$(i):R.setRuleTitle(i)},readOnly:(null==_?void 0:_.isAiStreaming)||!P,isOpen:B.ruleTitle,onToggle:function(){return pi("ruleTitle")},isHighlighted:W.ruleTitle||!1,showCognitiveIcon:V.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(S=_.validationErrors)||void 0===S?void 0:S.ruleTitle},_)),V.citation.ruleTitle&&n("div",i({style:gi},{children:n(r,{isVisible:B.ruleTitle,citation:V.citation.ruleTitle,citations:fi("ruleTitle"),fieldName:"Rule Title",fieldValue:V.ruleTitle})})),n(c,i({id:"scope",title:"",required:!1,scopeData:P&&null!==Z?Z:V.scopeData,onScopeChange:function(e,n){P?G(function(t){var o;return i(i({},null!=t?t:V.scopeData),((o={})[e]=n,o))}):R.onScopeChange(e,n)},tierLabel:"Which tier are you configuring this learning for?",stationLabel:"Which scope should this learning belong to?",highlights:W,isOpen:B.scopeData,onToggle:function(){return pi("scopeData")},showCognitiveIcon:V.citation.scopeData,cognitiveIcon:n(v,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(A=_.validationErrors)||void 0===A?void 0:A.station)||(null===(C=_.validationErrors)||void 0===C?void 0:C.tiers),stationErrorMessage:null===(I=_.validationErrors)||void 0===I?void 0:I.station,tierErrorMessage:null===(b=_.validationErrors)||void 0===b?void 0:b.tiers,readOnly:(null==_?void 0:_.isAiStreaming)||!P},_)),V.citation.scopeData&&n("div",i({style:gi},{children:n(r,{isVisible:B.scopeData,citation:V.citation.scopeData,citations:fi("scopeData"),fieldName:"Scope",fieldValue:null===(w=null===(O=V.scopeData)||void 0===O?void 0:O.tiers)||void 0===w?void 0:w.join(", ")})})),P?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:ei,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e("button",i({onClick:ni,disabled:ai,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:ai?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:ai?.5:1}},{children:[n(g,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==_?void 0:_.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===(E=null==_?void 0:_.tierOptions)||void 0===E?void 0:E.map(function(t,o){var l,c,v,p,f,g,h=t.toLowerCase().replace(/ /g,"_"),m=(null===(l=V.variantsByTier)||void 0===l?void 0:l[h])||[],T=null===(v=null===(c=V.scopeData)||void 0===c?void 0:c.tiers)||void 0===v?void 0:v.includes(t),x=m.length,D=!1;if(1===x){var S=m[0],A=!(null===(p=null==S?void 0:S.ruleDescription)||void 0===p?void 0:p.trim()),C=(null===(f=null==S?void 0:S.whenToApplyConditions)||void 0===f?void 0:f.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,I=(null===(g=null==S?void 0:S.whenNotToApplyConditions)||void 0===g?void 0:g.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;!A||C||I||(D=!0)}var b=D?void 0:"".concat(x," ").concat(1===x?"variant":"variants"," configured for this tier");return console.log("Rendering tier : ",t),n(s,i({variant:"tier-header",title:{type:"other",label:t},subtitle:b,defaultOpen:!0,footerData:{description:"Variants for ".concat(t)}},{children:n(y,i({onAddVariant:function(){var i;return null===(i=R.addNewVariant)||void 0===i?void 0:i.call(R,h)},isDisabled:!T||(null==_?void 0:_.isAiStreaming),showAddVariantBtn:"Edit"!==(null==_?void 0:_.usedFor)},{children:m.map(function(t,o){var l,c,v,p,f,g,y,m,x,D,S=t.variantType||"default",A="".concat(h,"-variant-").concat(o),C=!0===t.is_variant,I="default"===S||"default_variant"===S,b="".concat(h,"_").concat(o),O=N.get(b)||{},w=(null===(c=null===(l=_.separationItemsByTier)||void 0===l?void 0:l[h])||void 0===c?void 0:c.get(o))||[],E=(null===(p=null===(v=_.togglesByTier)||void 0===v?void 0:v[h])||void 0===p?void 0:p.get(o))||[],W=null===(f=null==_?void 0:_.activeEditId)||void 0===f?void 0:f.startsWith("condition-wta-".concat(h,"-").concat(o)),L=null===(g=null==_?void 0:_.activeEditId)||void 0===g?void 0:g.startsWith("condition-wnta-".concat(h,"-").concat(o)),F=!T||t.isReadOnly||(null==_?void 0:_.isAiStreaming);return n("div",i({ref:function(i){i?J.current.set(A,i):J.current.delete(A)},style:{width:"100%",opacity:T?1:.7}},{children:n(s,i({title:{type:I?"default":"variant",label:hi(S),number:o+1,isNewVariant:C,isDefault:t.isDefault,isModified:t.isModified},defaultOpen:!0,expanded:j===A,onToggle:function(){var i,e=j===A;k(e?null:A),null===(i=null==_?void 0:_.setActiveVariantAccordionIndex)||void 0===i||i.call(_,e?null:o)},variant:"rule-behavior",footerData:{ruleTitle:S,description:t.ruleDescription||""},readOnly:F},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[n(u,i({id:"rule-description-".concat(h,"-").concat(o),title:_.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:F||yi&&(null==_?void 0:_.activeEditId)!=="rule-description-".concat(h,"-").concat(o),value:t.ruleDescription||"",onChange:function(i){return R.setRuleDescription(h,o,i)},isOpen:B["ruleDescription-".concat(h)],onToggle:function(){return pi("ruleDescription-".concat(h))},isHighlighted:O.ruleDescription||!1,showCognitiveIcon:null===(y=V.citation)||void 0===y?void 0:y["ruleDescription_".concat(h)],tooltipDescription:"Why this Description?",errorMessage:null===(m=_.validationErrors)||void 0===m?void 0:m["ruleDescription-".concat(h,"-").concat(o)],enableInlineEdit:!0,setSendMessageInChat:null==_?void 0:_.setSendMessageInChat,isAiStreaming:null==_?void 0:_.isAiStreaming,fieldName:"Rule Description"},_)),(null===(x=V.citation)||void 0===x?void 0:x["ruleDescription_".concat(h)])&&n("div",i({style:gi},{children:n(r,{isVisible:B["ruleDescription-".concat(h)],citation:V.citation["ruleDescription_".concat(h)],citations:fi("ruleDescription_".concat(h,"_").concat(o)),fieldName:"Rule Description",fieldValue:t.ruleDescription})})),n(a,i({id:"when-to-apply-".concat(h,"-").concat(o),idPrefix:"condition-wta",title:_.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:F||yi&&!W,conditions:t.whenToApplyConditions||[],onAdd:function(){return R.addWhenToApply(h,o)},onRemove:function(i,e,n){return R.removeWhenToApply(i,e,n)},onEdit:function(i,e,n,t){return R.editWhenToApply(i,e,n,t)},index:o,tierKey:h,isHighlighted:O.wta||!1,highlightedIds:null==_?void 0:_.highlightedIds,tooltipDescription:"Why this Condition?",citations:fi("whenToApply_".concat(h,"_").concat(o)),bordered:!0,addLabel:"Add When to apply",isAiStreaming:_.isAiStreaming,errorMessage:(null===(D=_.validationErrors)||void 0===D?void 0:D["whenToApply-".concat(h,"-").concat(o)])||(null==_?void 0:_.conflictReason)},_)),n(a,i({id:"when-not-to-apply-".concat(h,"-").concat(o),idPrefix:"condition-wnta",title:_.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:F||yi&&!L,conditions:t.whenNotToApplyConditions||[],onAdd:function(){return R.addWhenNotToApply(h,o)},onRemove:function(i,e,n){return R.removeWhenNotToApply(i,e,n)},onEdit:function(i,e,n,t){return R.editWhenNotToApply(i,e,n,t)},index:o,tierKey:h,isHighlighted:O.wnta||!1,highlightedIds:null==_?void 0:_.highlightedIds,tooltipDescription:"Why this Condition?",citations:fi("whenNotToApply_".concat(h,"_").concat(o)),bordered:!0,addLabel:"Add When NOT to apply",isAiStreaming:_.isAiStreaming},_)),n(d,i({id:"config-".concat(h,"-").concat(o),title:_.configTitle||"Configuration",required:!1,highlights:O,bordered:!0,readOnly:F||yi&&(null==_?void 0:_.activeEditId)!=="config-".concat(h,"-").concat(o),onConfigChange:function(i,e){return R.onConfigChange(h,o,i,e)},separationItems:w,toggles:E,index:o},_))]}))}),A)}),"".concat(h,"-variant-").concat(o))})}))}),"tier-".concat(o))})]}))};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,w,O,E,V=m.state,R=m.handlers,_=m.uiState,N=(null==_?void 0:_.highlights)||new Map,W=N.get("global_0")||{},L=o({}),B=L[0],F=L[1],M=o(null),j=M[0],k=M[1],z=o(function(){var i,e,n;if((null==_?void 0:_.defaultTierOpen)>=0&&(null===(i=null==_?void 0:_.tierOptions)||void 0===i?void 0:i[_.defaultTierOpen]))return _.tierOptions[_.defaultTierOpen].toLowerCase().replace(/ /g,"_");var t=null===(n=null===(e=V.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n[0];return t?t.toLowerCase().replace(/ /g,"_"):null});z[0];var q=z[1],P="rule-setup"===(null==_?void 0:_.activeEditId),J=t.useRef(new Map),H=o(null),K=H[0],$=H[1],U=o(null),Z=U[0],G=U[1],Q=o(!1),X=Q[0],Y=Q[1],ii=t.useRef(null==_?void 0:_.isAiStreaming);l(function(){ii.current&&!(null==_?void 0:_.isAiStreaming)&&X&&Y(!1),ii.current=null==_?void 0:_.isAiStreaming},[null==_?void 0:_.isAiStreaming,X]);var ei=function(){var i;$(null),G(null),null===(i=null==_?void 0:_.setActiveEditId)||void 0===i||i.call(_,null)},ni=function(){var i,e,n=null!=K?K:V.ruleTitle,t=null!=Z?Z:V.scopeData,o=n!==V.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(V.scopeData);if(!o&&!l)return $(null),G(null),void(null===(i=null==_?void 0:_.setActiveEditId)||void 0===i||i.call(_,null));if(null==_?void 0:_.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 ");_.setSendMessageInChat("__SKELETON__:".concat(r,":Update Rule Setup ").concat(u))}Y(!0),$(null),G(null),null===(e=null==_?void 0:_.setActiveEditId)||void 0===e||e.call(_,null)},ti=null!==K?null==K?void 0:K.trim():(V.ruleTitle||"").trim(),oi=null!=Z?Z:V.scopeData,li=ti!==(V.ruleTitle||"").trim(),ri=JSON.stringify(oi)!==JSON.stringify(V.scopeData),ai=!li&&!ri||""===ti,di=t.useRef(null==_?void 0:_.defaultVariantOpen),ci=t.useRef(null==_?void 0:_.activeVariantAccordionIndex),ui=t.useRef(null==_?void 0:_.defaultTierOpen),si=t.useRef(null===(T=V.scopeData)||void 0===T?void 0:T.tiers),vi=t.useRef(V.variantsByTier);t.useEffect(function(){var i,e,n,t,o,l,r=null,a=!1;di.current!==(null==_?void 0:_.defaultVariantOpen)&&(a=!0,di.current=null==_?void 0:_.defaultVariantOpen),ci.current!==(null==_?void 0:_.activeVariantAccordionIndex)&&(a=!0,ci.current=null==_?void 0:_.activeVariantAccordionIndex),ui.current!==(null==_?void 0:_.defaultTierOpen)&&(a=!0,ui.current=null==_?void 0:_.defaultTierOpen);var d=(null===(i=V.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(si.current)!==JSON.stringify(d)&&(a=!0,si.current=d,d.length>0&&q(d[0].toLowerCase().replace(/ /g,"_")));var c=(null===(e=null==_?void 0:_.tierOptions)||void 0===e?void 0:e.filter(function(i){var e,n;return null===(n=null===(e=V.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=vi.current)||void 0===e?void 0:e[l])||void 0===n?void 0:n.length)||0)!==((null===(o=null===(t=V.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==_?void 0:_.activeVariantAccordionIndex)&&void 0!==n?n:null==_?void 0:_.defaultVariantOpen;if(null==s||s<0)return k(null),void(vi.current=V.variantsByTier);c.forEach(function(i,e){var n;if(!((null==_?void 0:_.defaultTierOpen)>=0&&e!==_.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),o=(null===(n=V.variantsByTier)||void 0===n?void 0:n[t])||[];o[s]&&(r="".concat(t,"-variant-").concat(s)),null!=(null==_?void 0:_.autoScrollVariantIndex)&&o[_.autoScrollVariantIndex]&&(r="".concat(t,"-variant-").concat(_.autoScrollVariantIndex))}}),r&&k(r)}if(null===j){var v=null!==(t=null==_?void 0:_.activeVariantAccordionIndex)&&void 0!==t?t:null==_?void 0:_.defaultVariantOpen;null!=v&&v>=0&&(null===(l=null===(o=null==_?void 0:_.tierOptions)||void 0===o?void 0:o.filter(function(i){var e,n;return null===(n=null===(e=V.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==_?void 0:_.defaultTierOpen)>=0&&e!==_.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(n=V.variantsByTier)||void 0===n?void 0:n[t])||[])[v]&&k("".concat(t,"-variant-").concat(v))}}))}vi.current=V.variantsByTier},[V.variantsByTier,null==_?void 0:_.defaultVariantOpen,null==_?void 0:_.activeVariantAccordionIndex,null===(x=V.scopeData)||void 0===x?void 0:x.tiers,null==_?void 0:_.tierOptions,null==_?void 0:_.autoScrollVariantIndex,null==_?void 0:_.defaultTierOpen]);var pi=function(e){F(function(n){var t;return i(i({},n),((t={})[e]=!n[e],t))})},fi=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=V.fieldCitations)||void 0===e?void 0:e[r];if(Array.isArray(a)&&a.length>0)return a;var d=null===(n=V.fieldCitations)||void 0===n?void 0:n[i];return Array.isArray(d)&&d.length>0?d:null!==(t=V.citations)&&void 0!==t?t:[]},gi={marginTop:"-17px",position:"relative",zIndex:1};l(function(){var i,e;null!=(null==_?void 0:_.autoScrollVariantIndex)&&(null===(e=null===(i=null==_?void 0:_.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,n;return null===(n=null===(e=V.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(_.autoScrollVariantIndex),t=J.current.get(n);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==_?void 0:_.scrollTrigger]),console.log("CreateRule state:",V),console.log("CreateRule uiState:",_);var hi=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"},yi=!!(null==_?void 0:_.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==_?void 0:_.setupLabel)||"Rule Setup"},actionButtons:function(e,t){if(P)return null;var o=!!(null==_?void 0:_.activeEditId)&&"rule-setup"!==_.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==_?void 0:_.setPendingEditId)&&_.setPendingEditId(_.activeEditId||null):(!function(){var e,n;(null==_?void 0:_.activeEditId)&&"rule-setup"!==_.activeEditId||(null===(e=null==_?void 0:_.setActiveEditId)||void 0===e||e.call(_,"rule-setup"),$(null!==(n=V.ruleTitle)&&void 0!==n?n:""),G(V.scopeData?i({},V.scopeData):{}))}(),(null==_?void 0:_.setPendingEditId)&&_.setPendingEditId(null),e||t())},disabled:X,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:X?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:X?.5:1}},{children:n(f,{size:14})}))}))},footerData:{ruleTitle:V.ruleTitle,stations:[V.scopeData.station],tiers:null===(D=V.scopeData)||void 0===D?void 0:D.tiers},defaultOpen:"Create"===(null==_?void 0:_.usedFor),readOnly:"Create"!==(null==_?void 0:_.usedFor),isAiStreaming:null==_?void 0:_.isAiStreaming,editFlow:"Edit"===(null==_?void 0:_.usedFor)},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[X&&(null==_?void 0:_.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:_.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:P&&null!==K?K:V.ruleTitle,onChange:function(i){return P?$(i):R.setRuleTitle(i)},readOnly:(null==_?void 0:_.isAiStreaming)||!P,isOpen:B.ruleTitle,onToggle:function(){return pi("ruleTitle")},isHighlighted:W.ruleTitle||!1,showCognitiveIcon:V.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(S=_.validationErrors)||void 0===S?void 0:S.ruleTitle},_)),V.citation.ruleTitle&&n("div",i({style:gi},{children:n(r,{isVisible:B.ruleTitle,citation:V.citation.ruleTitle,citations:fi("ruleTitle"),fieldName:"Rule Title",fieldValue:V.ruleTitle})})),n(c,i({id:"scope",title:"",required:!1,scopeData:P&&null!==Z?Z:V.scopeData,onScopeChange:function(e,n){P?G(function(t){var o;return i(i({},null!=t?t:V.scopeData),((o={})[e]=n,o))}):R.onScopeChange(e,n)},tierLabel:"Which tier are you configuring this learning for?",stationLabel:"Which scope should this learning belong to?",highlights:W,isOpen:B.scopeData,onToggle:function(){return pi("scopeData")},showCognitiveIcon:V.citation.scopeData,cognitiveIcon:n(v,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(A=_.validationErrors)||void 0===A?void 0:A.station)||(null===(C=_.validationErrors)||void 0===C?void 0:C.tiers),stationErrorMessage:null===(I=_.validationErrors)||void 0===I?void 0:I.station,tierErrorMessage:null===(b=_.validationErrors)||void 0===b?void 0:b.tiers,readOnly:(null==_?void 0:_.isAiStreaming)||!P},_)),V.citation.scopeData&&n("div",i({style:gi},{children:n(r,{isVisible:B.scopeData,citation:V.citation.scopeData,citations:fi("scopeData"),fieldName:"Scope",fieldValue:null===(O=null===(w=V.scopeData)||void 0===w?void 0:w.tiers)||void 0===O?void 0:O.join(", ")})})),P?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:ei,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e("button",i({onClick:ni,disabled:ai,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:ai?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:ai?.5:1}},{children:[n(g,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==_?void 0:_.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===(E=null==_?void 0:_.tierOptions)||void 0===E?void 0:E.map(function(t,o){var l,c,v,p,f,g,h=t.toLowerCase().replace(/ /g,"_"),m=(null===(l=V.variantsByTier)||void 0===l?void 0:l[h])||[],T=null===(v=null===(c=V.scopeData)||void 0===c?void 0:c.tiers)||void 0===v?void 0:v.includes(t),x=m.length,D=!1;if(1===x){var S=m[0],A=!(null===(p=null==S?void 0:S.ruleDescription)||void 0===p?void 0:p.trim()),C=(null===(f=null==S?void 0:S.whenToApplyConditions)||void 0===f?void 0:f.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,I=(null===(g=null==S?void 0:S.whenNotToApplyConditions)||void 0===g?void 0:g.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;!A||C||I||(D=!0)}var b=D?void 0:"".concat(x," ").concat(1===x?"variant":"variants"," configured for this tier");return console.log("Rendering tier : ",t),n(s,i({variant:"tier-header",title:{type:"other",label:t},subtitle:b,defaultOpen:!0,footerData:{description:"Variants for ".concat(t)}},{children:n(y,i({onAddVariant:function(){var i;return null===(i=R.addNewVariant)||void 0===i?void 0:i.call(R,h)},isDisabled:!T||(null==_?void 0:_.isAiStreaming),showAddVariantBtn:"Edit"!==(null==_?void 0:_.usedFor)},{children:m.map(function(t,o){var l,c,v,p,f,g,y,m,x,D,S=t.variantType||"default",A="".concat(h,"-variant-").concat(o),C=!0===t.is_variant,I="default"===S||"default_variant"===S,b="".concat(h,"_").concat(o),w=N.get(b)||{},O=(null===(c=null===(l=_.separationItemsByTier)||void 0===l?void 0:l[h])||void 0===c?void 0:c.get(o))||[],E=(null===(p=null===(v=_.togglesByTier)||void 0===v?void 0:v[h])||void 0===p?void 0:p.get(o))||[],W=null===(f=null==_?void 0:_.activeEditId)||void 0===f?void 0:f.startsWith("condition-wta-".concat(h,"-").concat(o)),L=null===(g=null==_?void 0:_.activeEditId)||void 0===g?void 0:g.startsWith("condition-wnta-".concat(h,"-").concat(o)),F=!T||t.isReadOnly||(null==_?void 0:_.isAiStreaming);return n("div",i({ref:function(i){i?J.current.set(A,i):J.current.delete(A)},style:{width:"100%",opacity:T?1:.7}},{children:n(s,i({title:{type:I?"default":"variant",label:hi(S),number:o+1,isNewVariant:C,isDefault:t.isDefault,isModified:t.isModified},defaultOpen:!0,expanded:j===A,onToggle:function(){var i,e=j===A;k(e?null:A),null===(i=null==_?void 0:_.setActiveVariantAccordionIndex)||void 0===i||i.call(_,e?null:o)},variant:"rule-behavior",footerData:{ruleTitle:S,description:t.ruleDescription||""},readOnly:F},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[n(u,i({id:"rule-description-".concat(h,"-").concat(o),title:_.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:F||yi&&(null==_?void 0:_.activeEditId)!=="rule-description-".concat(h,"-").concat(o),value:t.ruleDescription||"",onChange:function(i){return R.setRuleDescription(h,o,i)},isOpen:B["ruleDescription-".concat(h)],onToggle:function(){return pi("ruleDescription-".concat(h))},isHighlighted:w.ruleDescription||!1,showCognitiveIcon:null===(y=V.citation)||void 0===y?void 0:y["ruleDescription_".concat(h)],tooltipDescription:"Why this Description?",errorMessage:null===(m=_.validationErrors)||void 0===m?void 0:m["ruleDescription-".concat(h,"-").concat(o)],enableInlineEdit:!0,setSendMessageInChat:null==_?void 0:_.setSendMessageInChat,isAiStreaming:null==_?void 0:_.isAiStreaming,fieldName:"Rule Description"},_)),(null===(x=V.citation)||void 0===x?void 0:x["ruleDescription_".concat(h)])&&n("div",i({style:gi},{children:n(r,{isVisible:B["ruleDescription-".concat(h)],citation:V.citation["ruleDescription_".concat(h)],citations:fi("ruleDescription_".concat(h,"_").concat(o)),fieldName:"Rule Description",fieldValue:t.ruleDescription})})),n(a,i({id:"when-to-apply-".concat(h,"-").concat(o),idPrefix:"condition-wta",title:_.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:F||yi&&!W,conditions:t.whenToApplyConditions||[],onAdd:function(){return R.addWhenToApply(h,o)},onRemove:function(i,e,n){return R.removeWhenToApply(i,e,n)},onEdit:function(i,e,n,t){return R.editWhenToApply(i,e,n,t)},index:o,tierKey:h,isHighlighted:w.wta||!1,highlightedIds:null==_?void 0:_.highlightedIds,tooltipDescription:"Why this Condition?",citations:fi("whenToApply_".concat(h,"_").concat(o)),bordered:!0,addLabel:(null==_?void 0:_.addWhenToApplyBtnLabel)||"Add When to apply",isAiStreaming:_.isAiStreaming,errorMessage:(null===(D=_.validationErrors)||void 0===D?void 0:D["whenToApply-".concat(h,"-").concat(o)])||(null==_?void 0:_.conflictReason)},_)),n(a,i({id:"when-not-to-apply-".concat(h,"-").concat(o),idPrefix:"condition-wnta",title:_.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:F||yi&&!L,conditions:t.whenNotToApplyConditions||[],onAdd:function(){return R.addWhenNotToApply(h,o)},onRemove:function(i,e,n){return R.removeWhenNotToApply(i,e,n)},onEdit:function(i,e,n,t){return R.editWhenNotToApply(i,e,n,t)},index:o,tierKey:h,isHighlighted:w.wnta||!1,highlightedIds:null==_?void 0:_.highlightedIds,tooltipDescription:"Why this Condition?",citations:fi("whenNotToApply_".concat(h,"_").concat(o)),bordered:!0,addLabel:(null==_?void 0:_.addWhenNotToApplyBtnLabel)||"Add When NOT to apply",isAiStreaming:_.isAiStreaming},_)),(null==_?void 0:_.showConfiguration)&&n(d,i({id:"config-".concat(h,"-").concat(o),title:_.configTitle||"Configuration",required:!1,highlights:w,bordered:!0,readOnly:F||yi&&(null==_?void 0:_.activeEditId)!=="config-".concat(h,"-").concat(o),onConfigChange:function(i,e){return R.onConfigChange(h,o,i,e)},separationItems:O,toggles:E,index:o},_))]}))}),A)}),"".concat(h,"-variant-").concat(o))})}))}),"tier-".concat(o))})]}))};export{m as CreateRule};
2
2
  //# sourceMappingURL=CreateRule.js.map
@@ -1,2 +1,2 @@
1
- import{__spreadArray as e,__assign as t,__awaiter as n,__generator as r}from"tslib";import{jsx as o,jsxs as s,Fragment as i}from"react/jsx-runtime";import{useState as a,useRef as l,useEffect as c}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,fetchScopes as b,inheritScope as C,inheritScopeBackwardCompatible as T,createRuleSet as E,renameScope as I,deleteRuleSet as L,requestAccess as A}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as O,setQueryParams as w}from"./hooks/useLearningTemplateQueryParams.js";import R from"./components/ConfirmationModal.js";import j from"./components/LearningTemplateManagementSkeleton.js";import{findNodePathById as N}from"./utils/treeUtils.js";import D from"./store/useEnvStore.js";import{useConfigStore as _}from"./store/useConfigStore.js";import{TooltipProvider as k}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 M}from"./queries/useApprovalQueries.js";import B from"./RuleContent/AddScopeModal.js";import{useLocation as F}from"react-router-dom";import q from"./shared/SuccessToastContent.js";import x from"./shared/ErrorToastContent.js";import H from"./RuleContent/RenameScopeModal.js";var Q=[{id:"learnings",label:"Learnings",icon:u,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:d},{id:"history",label:"Change History",icon:p}],z=new Set(Q.map(function(e){return e.id}));function K(u){var d,p,K,V=this,W=u.userDetails,Y=u.llmStudioUrl,J=u.audacyBackendUrl,X=u.ilLabels,Z=u.config,$=u.rbacConfig,ee=u.auditLogConfig,te=u.app_integration_id,ne=u.backwardCompatibility,re=void 0!==ne&&ne,oe=m(function(e){return e.selectedRuleSetId}),se=m(function(e){return e.setSelectedRuleSetId}),ie=m(function(e){return e.error}),ae=m(function(e){return e.setError}),le=m(function(e){return e.setStations}),ce=m(function(e){return e.scopeTreeData}),ue=m(function(e){return e.setScopeTreeData}),de=a({isOpen:!1,type:"GLOBAL"}),pe=de[0],me=de[1],fe=a(!1),ve=fe[0],ge=fe[1],he=a(!1),ye=he[0],Se=he[1],be=a("learnings"),Ce=be[0],Te=be[1],Ee=a(null),Ie=Ee[0],Le=Ee[1],Ae=a(null),Oe=Ae[0],we=Ae[1],Re=l(null),je=l(null),Ne=l(!1),De=l(null),_e=y();_e.user;var ke=_e.setUser,Pe=_(),Ue=Pe.setConfig,Ge=Pe.setIlLabels,Me=e([{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},t({type:"SCOPE",label:"Scope"},!re&&{addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"})],re?[]:[{type:"SUBSCOPE",label:"Subscope"}],!0),Be=function(){try{return F()}catch(e){return{search:""}}}();c(function(){if(!Ne.current){var e=new URLSearchParams(window.location.search),t=e.get(O.RULESET_ID),n=e.get(O.SECTION),r=n&&z.has(n)?n:"learnings";(null==t?void 0:t.length)&&se&&Te&&(se(t),Te(r),Ne.current=!0)}},[null==Be?void 0:Be.search,Te,se]);var Fe=U(function(e){return e.fetchPermissions}),qe=U(function(e){return e.hasPermission}),xe=G(function(e){return e.setRoles}),He=D(function(e){return e.appsecRbacUrl})===$.appsecRbacUrl,Qe=M($.applicationId,He).data;c(function(){Qe&&xe(Qe.map(function(e){return{_id:e._id,name:e.name}}))},[Qe,xe]),c(function(){var e;console.log("userDetails",W),ke(W),console.log("llmStudioUrl",Y),console.log("audacyBackendUrl",J),D.getState().setLlmStudioUrl(Y),D.getState().setAudacyBackendUrl(J),D.getState().setRbacConfig($),D.getState().setAuditLogConfig(ee),Ue(Z),Ge(X),m.getState().setAppIntegrationId(null!=te?te:null),m.getState().setBackwardCompatibility(re),m.getState().setToken(null!==(e=null==W?void 0:W.accessToken)&&void 0!==e?e:null)},[W,ke,Y,J,$,ee,Z,Ue,X,Ge,te,re]),c(function(){(null==W?void 0:W.accessToken)&&Y&&S()},[te,null==W?void 0:W.accessToken,Y]);var ze=function(e){return void 0===e&&(e=!0),n(V,void 0,void 0,function(){var n,o,s,i,a,l;return r(this,function(r){switch(r.label){case 0:e&&ge(!0),ae(null),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Fe($.applicationId)];case 2:return r.sent(),n=function(e){if(!U.getState().hasPermission("ilotj.scope.view",e.id))return null;var r=e.children?e.children.map(function(e){return n(e)}).filter(function(e){return null!==e}):[];return t(t({},e),{children:r})},[4,b(te,W.accessToken)];case 3:return(o=r.sent())&&o.data&&o.data.data&&(s=o.data.data,Array.isArray(s)&&(s=s.length>0?s[0]:null),s?(i=n(s))?(Le(null),ue({data:i}),je.current?(se(je.current),Te("learnings"),je.current=null):m.getState().selectedRuleSetId||se(i.id)):(Le(null!==(l=s.id)&&void 0!==l?l:null),ue(null)):(Le(null),ue(null))),[3,6];case 4:return a=r.sent(),console.error("Failed to fetch rule sets or permissions",a),ae("Failed to load data. Please try again later."),[3,6];case 5:return ge(!1),[7];case 6:return[2]}})})};c(function(){var e;(null===(e=null==W?void 0:W.accessToken)||void 0===e?void 0:e.length)&&He?ze(!0):console.warn("Error: Trying to fetch rules without access token",W)},[null==W?void 0:W.accessToken,ae,le,$.applicationId,He]);var Ke=function(e,o,s){return n(V,void 0,void 0,function(){var n,o,s,i,a,l,c,u;return r(this,function(r){switch(r.label){case 0:Se(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,L(e,W.accessToken)];case 2:return r.sent(),m.getState().selectedRuleSetId===e&&(n=m.getState().scopeTreeData,(o=N((null==n?void 0:n.data)||null,e))&&o.length>1&&(s=o[o.length-2],se(s),Te("learnings"))),[4,ze(!0)];case 3:return r.sent(),me(function(e){return t(t({},e),{isOpen:!1})}),null===(a=De.current)||void 0===a||a.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return i=r.sent(),console.error("An error occurred during scope deletion.",i),null===(l=De.current)||void 0===l||l.show({severity:"error",summary:"Delete Failed",detail:(null===(u=null===(c=null==i?void 0:i.response)||void 0===c?void 0:c.data)||void 0===u?void 0:u.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return Se(!1),[7];case 6:return[2]}})})},Ve=ce,We=Oe?{data:{id:Oe.stationId,name:Oe.stationName,type:"STATION",metrics:{learningsCount:Oe.learningsCount,stationsCount:0},children:[]}}:Ve,Ye=!!(null==We?void 0:We.data);null===(d=null==We?void 0:We.data)||void 0===d||d.type;var Je=U(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",$.applicationResourceId||""),Xe=Oe?Q.filter(function(e){return"stations"!==e.id}):Q;return o(k,{children:s("div",t({className:v.learningManagementContainer},{children:[o("div",t({className:v.mainWrapper},{children:ve?o(j,{}):ie?s("div",t({className:v.errorContainer},{children:[o("div",t({className:v.errorTitle},{children:"Error Loading Data"})),o("p",t({className:v.errorDesc},{children:ie})),o("button",t({onClick:function(){return ze(!0)},className:v.tryAgainBtn},{children:"Try Again"}))]})):Ye?o(g,{onOpenCreateModal:function(){return me({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return me({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return me({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(e,t,o){return n(V,void 0,void 0,function(){var n,s,i;return r(this,function(r){switch(r.label){case 0:return n=m.getState().scopeTreeData,s=N((null==n?void 0:n.data)||null,e),i=!!s&&3===s.length,0!==o?[3,2]:[4,Ke(e)];case 1:return r.sent(),[3,3];case 2:me({isOpen:!0,type:"DELETE",scopeId:e,initialName:t,isSubscope:i}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return qe("ilotj.scope.delete",e)},canEditScope:function(e){return qe("ilotj.scope.edit",e)},canCreateScope:function(e){return qe("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),w(((n={})[O.SECTION]="learnings"===t?null:t,n[O.RULESET_ID]=e,n)),Te(t),se(e)},activeSectionId:Ce,scopeTreeData:We,sectionsConfig:Xe,onViewStation:function(e){Re.current=oe,we(e),Te("learnings"),se(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(je.current=t),ze(e)},nodeTypesConfig:Me,app_integration_id:te,token:W.accessToken}):o(h,{onCreate:function(){return me({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:Je,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return n(V,void 0,void 0,function(){var e,t,n,s,i,a,l,c,u;return r(this,function(r){switch(r.label){case 0:if(!(e=(null===(s=null===(n=m.getState().scopeTreeData)||void 0===n?void 0:n.data)||void 0===s?void 0:s.id)||Ie))return null===(i=De.current)||void 0===i||i.show({severity:"error",sticky:!1,className:v.errorToast,content:o(x,{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,A(e)];case 2:return r.sent(),null===(a=De.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:v.successToast,content:o(q,{message:"Access request submitted successfully!"})}),[3,4];case 3:return t=r.sent(),null===(l=De.current)||void 0===l||l.show({severity:"error",sticky:!1,className:v.errorToast,content:o(x,{message:(null===(u=null===(c=null==t?void 0:t.response)||void 0===c?void 0:c.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),o(f,{ref:De,pt:{root:{style:{zIndex:9999}}}}),re&&pe.isOpen&&"DELETE"!==pe.type&&"RENAME"!==pe.type?o(P,{isOpen:!0,onClose:function(){return me(t(t({},pe),{isOpen:!1}))},onSubmit:function(e){return n(V,void 0,void 0,function(){var n,o,s,i,a,l,c,u,d,p,f,v,g,h,y,S,b,I,L,A;return r(this,function(r){switch(r.label){case 0:Se(!0),n=m.getState().backwardCompatibility,r.label=1;case 1:return r.trys.push([1,12,13,14]),o=void 0,n&&"object"==typeof e?o=e:(s=e,i="SCOPE"===pe.type&&pe.parentId,a=i?"genreRuleSet":pe.type,o={topic:a,scope_reference_id:null,scopeDescription:"demo",parentScopeId:pe.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:te}),[4,E(o,W.accessToken)];case 2:if(l=r.sent(),!(c=null===(h=null==l?void 0:l.data)||void 0===h?void 0:h.scopeId))return[3,10];if(je.current=c,u=n&&(null===(y=o.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),d=!n&&"GLOBAL"!==pe.type&&pe.parentId,!u&&!d)return[3,10];if(!(p=n?null===(b=null===(S=m.getState().scopeTreeData)||void 0===S?void 0:S.data)||void 0===b?void 0:b.id:pe.parentId))return[3,10];if(!re)return[3,7];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,T({source_scope_id:p,target_scope_id:c})];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,C({source_scope_id:p,target_scope_id:c,application_mapping_id:te||"",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,ze(!0)];case 11:return r.sent(),me(function(e){return t(t({},e),{isOpen:!1})}),[3,14];case 12:throw g=r.sent(),console.error("An error occurred during scope creation.",g),null===(I=De.current)||void 0===I||I.show({severity:"error",summary:"Creation Failed",detail:(null===(A=null===(L=null==g?void 0:g.response)||void 0===L?void 0:L.data)||void 0===A?void 0:A.message)||"There was an error creating the scope. Please try again."}),g;case 13:return Se(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ye,canCreateGlobal:Je,globalScopeId:null!==(K=null===(p=null==ce?void 0:ce.data)||void 0===p?void 0:p.id)&&void 0!==K?K:null}):s(i,{children:[o(B,{isOpen:pe.isOpen&&"DELETE"!==pe.type&&"RENAME"!==pe.type,onClose:function(){return me(t(t({},pe),{isOpen:!1}))},onCreate:function(e){e&&(je.current=e),ze(!0)},hasGlobalRuleSet:Ye,parentId:pe.parentId}),o(H,{isOpen:pe.isOpen&&"RENAME"===pe.type,onClose:function(){return me(t(t({},pe),{isOpen:!1}))},onSave:function(e){return n(V,void 0,void 0,function(){var n,s,i,a;return r(this,function(r){switch(r.label){case 0:Se(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),pe.scopeId?[4,I({scope_id:pe.scopeId,scope_name:e})]:[2];case 2:return r.sent(),[4,ze(!0)];case 3:return r.sent(),me(function(e){return t(t({},e),{isOpen:!1})}),[3,6];case 4:throw n=r.sent(),console.error("An error occurred during scope rename.",n),null===(s=De.current)||void 0===s||s.show({severity:"error",sticky:!1,className:v.errorToast,content:o(x,{message:(null===(a=null===(i=null==n?void 0:n.response)||void 0===i?void 0:i.data)||void 0===a?void 0:a.message)||"There was an error renaming the scope. Please try again."})}),n;case 5:return Se(!1),[7];case 6:return[2]}})})},initialName:pe.initialName})]}),o(R,{isOpen:pe.isOpen&&"DELETE"===pe.type,onCancel:function(){return me(t(t({},pe),{isOpen:!1}))},onConfirm:function(){return Ke(pe.scopeId,pe.initialName,pe.isSubscope)},title:"Delete Scope",description:s(i,{children:["Deleting ",o("span",t({className:v.highlight},{children:pe.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:ye})]}))})}export{K as default};
1
+ import{__assign as e,__spreadArray as n,__awaiter as t,__generator as r}from"tslib";import{jsx as o,jsxs as s,Fragment as i}from"react/jsx-runtime";import{useState as a,useRef as l,useEffect as c}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 g from"./styles/LearningTemplateManagement.module.css.js";import v from"./LearningTemplateLayout.js";import h from"./components/EmptyLearningState.js";import S from"./store/useAuthStore.js";import{fetchTiers as y,fetchScopes as b,inheritScope as C,inheritScopeBackwardCompatible as T,createRuleSet as w,renameScope as E,deleteRuleSet as L,requestAccess as I}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as D,setQueryParams as A}from"./hooks/useLearningTemplateQueryParams.js";import O from"./components/ConfirmationModal.js";import R from"./components/LearningTemplateManagementSkeleton.js";import{findNodePathById as j}from"./utils/treeUtils.js";import N from"./store/useEnvStore.js";import{useConfigStore as k}from"./store/useConfigStore.js";import{TooltipProvider as M}from"./components/ToolTip.js";import _ from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as P}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as U}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as G}from"./queries/useApprovalQueries.js";import{useLMSConfigQuery as B}from"./queries/useLMSConfigQuery.js";import F from"./RuleContent/AddScopeModal.js";import q from"./components/RuleContentSkeleton.js";import x from"./components/ErrorStateDisplay.js";import{useLocation as H}from"react-router-dom";import Q from"./shared/SuccessToastContent.js";import z from"./shared/ErrorToastContent.js";import K from"./RuleContent/RenameScopeModal.js";import{dt as V}from"./store/useLMSConfigStore.js";function W(W){var Y,J,X,Z=this,$=W.userDetails,ee=W.llmStudioUrl,ne=W.audacyBackendUrl,te=W.ilLabels,re=W.config,oe=W.rbacConfig,se=W.auditLogConfig,ie=W.app_integration_id,ae=W.backwardCompatibility,le=void 0!==ae&&ae,ce=m(function(e){return e.selectedRuleSetId}),ue=m(function(e){return e.setSelectedRuleSetId}),de=m(function(e){return e.error}),pe=m(function(e){return e.setError}),me=m(function(e){return e.setStations}),fe=m(function(e){return e.scopeTreeData}),ge=m(function(e){return e.setScopeTreeData}),ve=a({isOpen:!1,type:"GLOBAL"}),he=ve[0],Se=ve[1],ye=a(!1),be=ye[0],Ce=ye[1],Te=a(!1),we=Te[0],Ee=Te[1],Le=a("learnings"),Ie=Le[0],De=Le[1],Ae=a(null),Oe=Ae[0],Re=Ae[1],je=a(null),Ne=je[0],ke=je[1],Me=l(null),_e=l(null),Pe=l(!1),Ue=l(null),Ge=S();Ge.user;var Be=Ge.setUser,Fe=k(),qe=Fe.setConfig,xe=Fe.setIlLabels;console.log("testing",V("middleDrawer.contextMenu.addSubscope",""));var He=function(){try{return H()}catch(e){return{search:""}}}();c(function(){if(!Pe.current){var e=new URLSearchParams(window.location.search),n=e.get(D.RULESET_ID),t=e.get(D.SECTION),r=t&&ln.has(t)?t:"learnings";(null==n?void 0:n.length)&&ue&&De&&(ue(n),De(r),Pe.current=!0)}},[null==He?void 0:He.search,De,ue]);var Qe=P(function(e){return e.fetchPermissions}),ze=P(function(e){return e.hasPermission}),Ke=U(function(e){return e.setRoles}),Ve=N(function(e){return e.appsecRbacUrl})===oe.appsecRbacUrl,We=G(oe.applicationId,Ve).data,Ye=B(null!=ie?ie:""),Je=Ye.isLoading,Xe=Ye.isError,Ze=Ye.refetch;Ye.isSuccess,c(function(){We&&Ke(We.map(function(e){return{_id:e._id,name:e.name}}))},[We,Ke]),c(function(){var e;console.log("userDetails",$),Be($),console.log("llmStudioUrl",ee),console.log("audacyBackendUrl",ne),N.getState().setLlmStudioUrl(ee),N.getState().setAudacyBackendUrl(ne),N.getState().setRbacConfig(oe),N.getState().setAuditLogConfig(se),qe(re),xe(te),m.getState().setAppIntegrationId(null!=ie?ie:null),m.getState().setBackwardCompatibility(le),m.getState().setToken(null!==(e=null==$?void 0:$.accessToken)&&void 0!==e?e:null)},[$,Be,ee,ne,oe,se,re,qe,te,xe,ie,le]),c(function(){(null==$?void 0:$.accessToken)&&ee&&y()},[ie,null==$?void 0:$.accessToken,ee]);var $e=function(n){return void 0===n&&(n=!0),t(Z,void 0,void 0,function(){var t,o,s,i,a,l;return r(this,function(r){switch(r.label){case 0:n&&Ce(!0),pe(null),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Qe(oe.applicationId)];case 2:return r.sent(),t=function(n){if(!P.getState().hasPermission("ilotj.scope.view",n.id))return null;var r=n.children?n.children.map(function(e){return t(e)}).filter(function(e){return null!==e}):[];return e(e({},n),{children:r})},[4,b(ie,$.accessToken)];case 3:return(o=r.sent())&&o.data&&o.data.data&&(s=o.data.data,Array.isArray(s)&&(s=s.length>0?s[0]:null),s?(i=t(s))?(Re(null),ge({data:i}),_e.current?(ue(_e.current),De("learnings"),_e.current=null):m.getState().selectedRuleSetId||ue(i.id)):(Re(null!==(l=s.id)&&void 0!==l?l:null),ge(null)):(Re(null),ge(null))),[3,6];case 4:return a=r.sent(),console.error("Failed to fetch rule sets or permissions",a),pe("Failed to load data. Please try again later."),[3,6];case 5:return Ce(!1),[7];case 6:return[2]}})})};c(function(){var e;(null===(e=null==$?void 0:$.accessToken)||void 0===e?void 0:e.length)&&Ve?$e(!0):console.warn("Error: Trying to fetch rules without access token",$)},[null==$?void 0:$.accessToken,pe,me,oe.applicationId,Ve]);var en=function(n,o,s){return t(Z,void 0,void 0,function(){var t,o,s,i,a,l,c,u;return r(this,function(r){switch(r.label){case 0:Ee(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,L(n,$.accessToken)];case 2:return r.sent(),m.getState().selectedRuleSetId===n&&(t=m.getState().scopeTreeData,(o=j((null==t?void 0:t.data)||null,n))&&o.length>1&&(s=o[o.length-2],ue(s),De("learnings"))),[4,$e(!0)];case 3:return r.sent(),Se(function(n){return e(e({},n),{isOpen:!1})}),null===(a=Ue.current)||void 0===a||a.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return i=r.sent(),console.error("An error occurred during scope deletion.",i),null===(l=Ue.current)||void 0===l||l.show({severity:"error",summary:"Delete Failed",detail:(null===(u=null===(c=null==i?void 0:i.response)||void 0===c?void 0:c.data)||void 0===u?void 0:u.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return Ee(!1),[7];case 6:return[2]}})})},nn=fe,tn=Ne?{data:{id:Ne.stationId,name:Ne.stationName,type:"STATION",metrics:{learningsCount:Ne.learningsCount,stationsCount:0},children:[]}}:nn,rn=!!(null==tn?void 0:tn.data);null===(Y=null==tn?void 0:tn.data)||void 0===Y||Y.type;var on=P(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",oe.applicationResourceId||"");if(Je)return o("div",e({className:g.learningManagementContainer},{children:o(q,{})}));if(Xe)return o("div",e({className:g.learningManagementContainer},{children:o(x,{errorMessage:"Failed to load configuration. Please try again.",onRetry:function(){return Ze()},title:"Error Loading Configuration"})}));var sn=n([{type:"GLOBAL",label:"Global",addChildLabel:"".concat(V("middleDrawer.addScope","Add Scope")),addChildType:"SCOPE"},e({type:"SCOPE",label:V("middleDrawer.scope","Scope")},!le&&{addChildLabel:V("middleDrawer.treeMenu.contextMenu.addSubscope","Add Subscope"),addChildType:"SUBSCOPE"})],le?[]:[{type:"SUBSCOPE",label:V("middleDrawer.subScope","Subscope")}],!0),an=[{id:"learnings",label:V("middleDrawer.treeMenu.submenu.learnings","Learnings"),icon:u,badgeKey:"learningsCount"},{id:"access",label:V("middleDrawer.treeMenu.submenu.access","Access"),icon:d},{id:"history",label:V("middleDrawer.treeMenu.submenu.changeHistory","Change History"),icon:p}],ln=new Set(an.map(function(e){return e.id})),cn=Ne?an.filter(function(e){return"stations"!==e.id}):an;return o(M,{children:s("div",e({className:g.learningManagementContainer},{children:[o("div",e({className:g.mainWrapper},{children:be?o(R,{}):de?s("div",e({className:g.errorContainer},{children:[o("div",e({className:g.errorTitle},{children:"Error Loading Data"})),o("p",e({className:g.errorDesc},{children:de})),o("button",e({onClick:function(){return $e(!0)},className:g.tryAgainBtn},{children:"Try Again"}))]})):rn?o(v,{onOpenCreateModal:function(){return Se({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,n,t){return Se({isOpen:!0,type:n,parentId:e,parentName:t})},onRenameChild:function(e,n){return Se({isOpen:!0,type:"RENAME",scopeId:e,initialName:n})},onDeleteChild:function(e,n,o){return t(Z,void 0,void 0,function(){var t,s,i;return r(this,function(r){switch(r.label){case 0:return t=m.getState().scopeTreeData,s=j((null==t?void 0:t.data)||null,e),i=!!s&&3===s.length,0!==o?[3,2]:[4,en(e)];case 1:return r.sent(),[3,3];case 2:Se({isOpen:!0,type:"DELETE",scopeId:e,initialName:n,isSubscope:i}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return ze("ilotj.scope.delete",e)},canEditScope:function(e){return ze("ilotj.scope.edit",e)},canCreateScope:function(e){return ze("ilotj.scope.create",e)},onSectionSelect:function(e,n){var t;console.log("Section Selected:",{scopeId:e,sectionId:n}),A(((t={})[D.SECTION]="learnings"===n?null:n,t[D.RULESET_ID]=e,t)),De(n),ue(e)},activeSectionId:Ie,scopeTreeData:tn,sectionsConfig:cn,onViewStation:function(e){Me.current=ce,ke(e),De("learnings"),ue(e.stationId)},onRefreshRuleSets:function(e,n){void 0===e&&(e=!0),n&&(_e.current=n),$e(e)},nodeTypesConfig:sn,app_integration_id:ie,token:$.accessToken}):o(h,{onCreate:function(){return Se({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:on,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return t(Z,void 0,void 0,function(){var e,n,t,s,i,a,l,c,u;return r(this,function(r){switch(r.label){case 0:if(!(e=(null===(s=null===(t=m.getState().scopeTreeData)||void 0===t?void 0:t.data)||void 0===s?void 0:s.id)||Oe))return null===(i=Ue.current)||void 0===i||i.show({severity:"error",sticky:!1,className:g.errorToast,content:o(z,{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,I(e)];case 2:return r.sent(),null===(a=Ue.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:g.successToast,content:o(Q,{message:"Access request submitted successfully!"})}),[3,4];case 3:return n=r.sent(),null===(l=Ue.current)||void 0===l||l.show({severity:"error",sticky:!1,className:g.errorToast,content:o(z,{message:(null===(u=null===(c=null==n?void 0:n.response)||void 0===c?void 0:c.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),o(f,{ref:Ue,pt:{root:{style:{zIndex:9999}}}}),le&&he.isOpen&&"DELETE"!==he.type&&"RENAME"!==he.type?o(_,{isOpen:!0,onClose:function(){return Se(e(e({},he),{isOpen:!1}))},onSubmit:function(n){return t(Z,void 0,void 0,function(){var t,o,s,i,a,l,c,u,d,p,f,g,v,h,S,y,b,E,L,I;return r(this,function(r){switch(r.label){case 0:Ee(!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:(s=n,i="SCOPE"===he.type&&he.parentId,a=i?"genreRuleSet":he.type,o={topic:a,scope_reference_id:null,scopeDescription:"demo",parentScopeId:he.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:ie}),[4,w(o,$.accessToken)];case 2:if(l=r.sent(),!(c=null===(h=null==l?void 0:l.data)||void 0===h?void 0:h.scopeId))return[3,10];if(_e.current=c,u=t&&(null===(S=o.topic)||void 0===S?void 0:S.toLowerCase().includes("genre")),d=!t&&"GLOBAL"!==he.type&&he.parentId,!u&&!d)return[3,10];if(!(p=t?null===(b=null===(y=m.getState().scopeTreeData)||void 0===y?void 0:y.data)||void 0===b?void 0:b.id:he.parentId))return[3,10];if(!le)return[3,7];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,T({source_scope_id:p,target_scope_id:c})];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,C({source_scope_id:p,target_scope_id:c,application_mapping_id:ie||"",is_copy_parent_variant_id:!1})];case 8:return r.sent(),[3,10];case 9:return g=r.sent(),console.error("Failed to inherit rules for the new scope:",g),[3,10];case 10:return[4,$e(!0)];case 11:return r.sent(),Se(function(n){return e(e({},n),{isOpen:!1})}),[3,14];case 12:throw v=r.sent(),console.error("An error occurred during scope creation.",v),null===(E=Ue.current)||void 0===E||E.show({severity:"error",summary:"Creation Failed",detail:(null===(I=null===(L=null==v?void 0:v.response)||void 0===L?void 0:L.data)||void 0===I?void 0:I.message)||"There was an error creating the scope. Please try again."}),v;case 13:return Ee(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:rn,canCreateGlobal:on,globalScopeId:null!==(X=null===(J=null==fe?void 0:fe.data)||void 0===J?void 0:J.id)&&void 0!==X?X:null}):s(i,{children:[o(F,{isOpen:he.isOpen&&"DELETE"!==he.type&&"RENAME"!==he.type,onClose:function(){return Se(e(e({},he),{isOpen:!1}))},onCreate:function(e){e&&(_e.current=e),$e(!0)},hasGlobalRuleSet:rn,parentId:he.parentId}),o(K,{isOpen:he.isOpen&&"RENAME"===he.type,onClose:function(){return Se(e(e({},he),{isOpen:!1}))},onSave:function(n){return t(Z,void 0,void 0,function(){var t,s,i,a;return r(this,function(r){switch(r.label){case 0:Ee(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),he.scopeId?[4,E({scope_id:he.scopeId,scope_name:n})]:[2];case 2:return r.sent(),[4,$e(!0)];case 3:return r.sent(),Se(function(n){return e(e({},n),{isOpen:!1})}),[3,6];case 4:throw t=r.sent(),console.error("An error occurred during scope rename.",t),null===(s=Ue.current)||void 0===s||s.show({severity:"error",sticky:!1,className:g.errorToast,content:o(z,{message:(null===(a=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.data)||void 0===a?void 0:a.message)||"There was an error renaming the scope. Please try again."})}),t;case 5:return Ee(!1),[7];case 6:return[2]}})})},initialName:he.initialName})]}),o(O,{isOpen:he.isOpen&&"DELETE"===he.type,onCancel:function(){return Se(e(e({},he),{isOpen:!1}))},onConfirm:function(){return en(he.scopeId,he.initialName,he.isSubscope)},title:"Delete Scope",description:s(i,{children:["Deleting ",o("span",e({className:g.highlight},{children:he.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})]}))})}console.log("learningstest",V("middleDrawer.treeMenu.submenu.learnings"));export{W as default};
2
2
  //# sourceMappingURL=LearningManagement.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsxs as c,jsx as o}from"react/jsx-runtime";import{useState as s}from"react";import a from"./AccessPanel.js";import t from"../store/useEnvStore.js";import{usePermissionsStore as i}from"../store/usePermissionsStore.js";import l from"./AccessPanel.module.css.js";var n=function(n){var r=n.selectedRuleSetId,p=n.useApplicationModuleForScopeAccess,d=void 0!==p&&p,u=s("scope"),m=u[0],v=u[1],b=t(function(e){return e.rbacConfig}),f=i(function(e){return e.hasPermission}),A=null==b?void 0:b.applicationResourceId,I=(null==b?void 0:b.applicationModuleId)||(null==b?void 0:b.moduleId),h=d?I:null==b?void 0:b.moduleId,j=Boolean(A&&f("ilotj.scope.access.application.view",A));return c("div",e({className:l.accessManagement},{children:[c("div",e({className:l.accessTabs,role:"tablist","aria-label":"Access level"},{children:[o("button",e({type:"button",role:"tab","aria-selected":"scope"===m,className:"".concat(l.accessTab," ").concat("scope"===m?l.accessTabActive:""),onClick:function(){return v("scope")}},{children:"Scope Level Access"})),o("button",e({type:"button",role:"tab","aria-selected":"application"===m,className:"".concat(l.accessTab," ").concat("application"===m?l.accessTabActive:""),onClick:function(){return v("application")},disabled:!j,title:j?"":"You don't have permission to view application access"},{children:"Application Level Access"}))]})),o("div",e({className:l.accessTabPanel,role:"tabpanel"},{children:o(a,"application"===m?{resourceId:A,moduleId:I,accessLevel:"application"}:{ruleSetId:r,moduleId:h,accessLevel:"scope"})}))]}))};export{n as default};
1
+ import{__assign as e}from"tslib";import{jsxs as c,jsx as s}from"react/jsx-runtime";import{useState as o}from"react";import a from"./AccessPanel.js";import t from"../store/useEnvStore.js";import{usePermissionsStore as i}from"../store/usePermissionsStore.js";import l from"./AccessPanel.module.css.js";import{dt as n}from"../store/useLMSConfigStore.js";var r=function(r){var p=r.selectedRuleSetId,d=r.useApplicationModuleForScopeAccess,u=void 0!==d&&d,m=o("scope"),v=m[0],b=m[1],f=t(function(e){return e.rbacConfig}),A=i(function(e){return e.hasPermission}),I=null==f?void 0:f.applicationResourceId,S=(null==f?void 0:f.applicationModuleId)||(null==f?void 0:f.moduleId),h=u?S:null==f?void 0:f.moduleId,j=Boolean(I&&A("ilotj.scope.access.application.view",I));return c("div",e({className:l.accessManagement},{children:[c("div",e({className:l.accessTabs,role:"tablist","aria-label":"Access level"},{children:[s("button",e({type:"button",role:"tab","aria-selected":"scope"===v,className:"".concat(l.accessTab," ").concat("scope"===v?l.accessTabActive:""),onClick:function(){return b("scope")}},{children:n("access.scopeLevelAccess","Scope Level Access")})),s("button",e({type:"button",role:"tab","aria-selected":"application"===v,className:"".concat(l.accessTab," ").concat("application"===v?l.accessTabActive:""),onClick:function(){return b("application")},disabled:!j,title:j?"":"You don't have permission to view application access"},{children:n("access.appLevelAccess","Application Level Access")}))]})),s("div",e({className:l.accessTabPanel,role:"tabpanel"},{children:s(a,"application"===v?{resourceId:I,moduleId:S,accessLevel:"application"}:{ruleSetId:p,moduleId:h,accessLevel:"scope"})}))]}))};export{r as default};
2
2
  //# sourceMappingURL=AccessManagementPanel.js.map
@@ -1,2 +1,2 @@
1
- import{__awaiter as e,__generator as r,__assign as o,__spreadArray as n}from"tslib";import{jsx as i,jsxs as t,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as s,useEffect as c}from"react";import{useMutation as d}from"@tanstack/react-query";import{X as p,Loader2 as u}from"lucide-react";import{Toast as m}from"primereact/toast";import{v4 as f}from"uuid";import h from"../components/StationOnboarding/StationAutocomplete.js";import g from"./AddScopeApprovalSearchComponent.js";import v from"../components/ScopeSkeletonLoader.js";import{Input as y}from"@mui/material";import b from"../store/useAuthStore.js";import{useAppSecRolesStore as S}from"../store/useAppSecRolesStore.js";import C from"../store/useEnvStore.js";import{createRuleSet as x}from"../apis/scopeApis.js";import{useLearningTemplateStore as w}from"../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as _}from"../config.js";var k=function(k){var A=k.isOpen,R=k.onClose,D=k.onCreate,I=k.hasGlobalRuleSet,q=k.parentId,z=a(""),F=z[0],j=z[1],E=a(""),L=E[0],B=E[1],N=a({}),W=N[0],G=N[1],P=s(null),T=b().user,O=S(function(e){return e.roles}),M=C(function(e){return e.rbacConfig}),K=a(null),U=K[0],H=K[1],J=a("approval_required"),Q=J[0],V=J[1],X=a([]),Y=X[0],Z=X[1],$=a([]),ee=$[0],re=$[1],oe=a(""),ne=oe[0],ie=oe[1],te=d({mutationFn:function(o){return e(void 0,void 0,void 0,function(){var e;return r(this,function(r){switch(r.label){case 0:return[4,x(o,null!==(e=null==T?void 0:T.accessToken)&&void 0!==e?e:"")];case 1:return[2,r.sent()]}})})},onSuccess:function(o){return e(void 0,void 0,void 0,function(){return r(this,function(e){return console.log("Rule Set Created Successfully",o),[2]})})}});te.data;var le=te.isPending,ae=te.mutateAsync;return c(function(){A&&(j(""),B(""),G({}),H(null),V("approval_required"),Z([]),re([]),ie(""))},[A]),A?le?i(v,{isLoading:le}):t("div",o({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[i(m,{ref:P}),t("div",o({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[t("div",o({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[t("div",{children:[i("h2",o({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:"Add Scope"})),i("p",o({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:"This scope will be created under Global and will inherit its Learnings by default."}))]}),i("button",o({onClick:R,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:i(p,{size:24})}))]})),t("div",o({style:{display:"flex",flexDirection:"column",gap:20}},{children:[t("div",o({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[t("label",o({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[i("span",o({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),"Scope Name"]})),"Custom"===F?i(h,{value:L,onChange:function(e){if(e.length>50)return B(e.slice(0,50)),void G(function(e){return o(o({},e),{name:"Scope Name must be 50 characters or fewer"})});B(e),G(function(e){return o(o({},e),{name:void 0})})},onStationSelect:function(e){H(e)},style:{border:W.name?"1px solid #8F2C23":void 0}}):i(y,{value:L,onChange:function(e){var r=e.target.value;if(r.length>50)return B(r.slice(0,50)),void G(function(e){return o(o({},e),{name:"Scope Name must be 50 characters or fewer"})});B(r),G(function(e){return o(o({},e),{name:void 0})})},style:{border:"1px solid ".concat(W.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),W.name&&i("p",o({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:W.name}))]})),t("div",o({style:{display:"flex",flexDirection:"column",gap:12}},{children:[t("label",o({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[i("span",o({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),"Learning Approval Settings"]})),t("div",o({role:"radio","aria-checked":"approval_required"===Q,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return V("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||V("approval_required")}},{children:[t("div",o({style:{display:"flex",alignItems:"center",gap:8}},{children:[i("div",o({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===Q?"#2563EB":"#CBD5E1")}},{children:"approval_required"===Q&&i("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),i("span",o({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:"Approval Required Before Publishing"}))]})),i("p",o({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:"Learnings require approval before publishing."}))]})),"approval_required"===Q&&i(g,{selectedApprovers:Y,selectedGroupOfApprovers:ee,onApproversChange:Z,onGroupsChange:re}),ne&&i("p",o({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:ne})),t("div",o({role:"radio","aria-checked":"publish_without"===Q,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){V("publish_without"),ie("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(V("publish_without"),ie(""))}},{children:[t("div",o({style:{display:"flex",alignItems:"center",gap:8}},{children:[i("div",o({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===Q?"#2563EB":"#CBD5E1")}},{children:"publish_without"===Q&&i("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),i("span",o({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:"Publish Without Approval"}))]})),i("p",o({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:"Learnings can be published directly."}))]}))]})),t("div",o({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[i("button",o({onClick:R,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:le?.5:1},disabled:le},{children:"Cancel"})),i("button",o({onClick:function(){return e(void 0,void 0,void 0,function(){var e,o,i,t,l,a,s,c,d,p,u,m,h,g;return r(this,function(r){switch(r.label){case 0:if(e={},L.trim()?L.length>50&&(e.name="Scope Name must be 50 characters or fewer"):e.name="Scope Name is required","approval_required"===Q&&0===Y.length&&0===ee.length&&ie("Please select at least one approver or approver group."),e.name)return G(e),[2];if("approval_required"===Q&&0===Y.length&&0===ee.length)return[2];ie(""),r.label=1;case 1:return r.trys.push([1,3,,4]),o="approval_required"===Q,i=w.getState().backwardCompatibility,t=i?{topic:I?"genreRuleSet":"globalRuleSet",customScopeGroupName:_.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:L,parentScopeId:null,customScopeName:L,customScopeId:f(),createByName:(null==T?void 0:T.firstname)||"System",createdBy:(null==T?void 0:T.email)||"system@audacy.com",approvalRequired:o,appsecData:{application:null==M?void 0:M.applicationId,module:null==M?void 0:M.moduleId,roles:n(n([],o?[{users:Y.map(function(e){return e.email}),groups:ee.map(function(e){return e._id}),role:null!==(c=null===(s=O.find(function(e){return"Learning Manager"===e.name}))||void 0===s?void 0:s._id)&&void 0!==c?c:""}]:[],!0),[{users:[null==T?void 0:T.email],groups:[],role:null!==(p=null===(d=O.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===d?void 0:d._id)&&void 0!==p?p:""}],!1)}}:{topic:I?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:L,parentScopeId:null!=q?q:null,scopeName:L,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:w.getState().app_integration_id},console.log("Add Scope payload:",t),[4,ae(t)];case 2:return l=r.sent(),D(null===(u=null==l?void 0:l.data)||void 0===u?void 0:u.scopeId),R(),[3,4];case 3:return a=r.sent(),console.error("An error occurred during scope creation.",a),null===(m=P.current)||void 0===m||m.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(g=null===(h=null==a?void 0:a.response)||void 0===h?void 0:h.data)||void 0===g?void 0:g.message)||"There was an error creating the scope. Please try again."}),[3,4];case 4:return[2]}})})},style:{display:"flex",alignItems:"center",borderRadius:6,backgroundColor:"#2563EB",padding:"8px 16px",fontSize:14,fontWeight:500,color:"white",border:"none",cursor:"pointer",opacity:le||"Custom"===F&&!U?.5:1},disabled:le||"Custom"===F&&!U},{children:le?t(l,{children:[i(u,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):"Create Scope"}))]}))]}))]}))]})):null};export{k as default};
1
+ import{__awaiter as e,__generator as r,__assign as o,__spreadArray as i}from"tslib";import{jsx as t,jsxs as n,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as d,useEffect as s}from"react";import{useMutation as c}from"@tanstack/react-query";import{X as p,Loader2 as u}from"lucide-react";import{Toast as m}from"primereact/toast";import{v4 as g}from"uuid";import f from"../components/StationOnboarding/StationAutocomplete.js";import h from"./AddScopeApprovalSearchComponent.js";import v from"../components/ScopeSkeletonLoader.js";import{Input as y}from"@mui/material";import S from"../store/useAuthStore.js";import{useAppSecRolesStore as b}from"../store/useAppSecRolesStore.js";import C from"../store/useEnvStore.js";import{createRuleSet as x}from"../apis/scopeApis.js";import{useLearningTemplateStore as D}from"../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as w}from"../config.js";import{dt as A}from"../store/useLMSConfigStore.js";var _=function(_){var k=_.isOpen,R=_.onClose,I=_.onCreate,q=_.hasGlobalRuleSet,j=_.parentId,z=a(""),F=z[0],E=z[1],L=a(""),B=L[0],W=L[1],N=a({}),G=N[0],P=N[1],T=d(null),M=S().user,O=b(function(e){return e.roles}),K=C(function(e){return e.rbacConfig}),U=a(null),H=U[0],J=U[1],Q=a("approval_required"),V=Q[0],X=Q[1],Y=a([]),Z=Y[0],$=Y[1],ee=a([]),re=ee[0],oe=ee[1],ie=a(""),te=ie[0],ne=ie[1],le=c({mutationFn:function(o){return e(void 0,void 0,void 0,function(){var e;return r(this,function(r){switch(r.label){case 0:return[4,x(o,null!==(e=null==M?void 0:M.accessToken)&&void 0!==e?e:"")];case 1:return[2,r.sent()]}})})},onSuccess:function(o){return e(void 0,void 0,void 0,function(){return r(this,function(e){return console.log("Rule Set Created Successfully",o),[2]})})}});le.data;var ae=le.isPending,de=le.mutateAsync;return s(function(){k&&(E(""),W(""),P({}),J(null),X("approval_required"),$([]),oe([]),ne(""))},[k]),k?ae?t(v,{isLoading:ae}):n("div",o({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[t(m,{ref:T}),n("div",o({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[n("div",o({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[n("div",{children:[t("h2",o({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:A("middleDrawer.addScopeDialog.title","Add Scope")})),t("p",o({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:A("middleDrawer.addScopeDialog.subtitle","This scope will be created under Global and will inherit its Learnings by default.",{parent:"Global"})}))]}),t("button",o({onClick:R,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:t(p,{size:24})}))]})),n("div",o({style:{display:"flex",flexDirection:"column",gap:20}},{children:[n("div",o({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[n("label",o({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[t("span",o({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),A("middleDrawer.addScopeDialog.scopeName","Scope Name")]})),"Custom"===F?t(f,{value:B,onChange:function(e){if(e.length>50)return W(e.slice(0,50)),void P(function(e){return o(o({},e),{name:"Scope Name must be 50 characters or fewer"})});W(e),P(function(e){return o(o({},e),{name:void 0})})},onStationSelect:function(e){J(e)},style:{border:G.name?"1px solid #8F2C23":void 0}}):t(y,{value:B,onChange:function(e){var r=e.target.value;if(r.length>50)return W(r.slice(0,50)),void P(function(e){return o(o({},e),{name:"Scope Name must be 50 characters or fewer"})});W(r),P(function(e){return o(o({},e),{name:void 0})})},style:{border:"1px solid ".concat(G.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),G.name&&t("p",o({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:G.name}))]})),n("div",o({style:{display:"flex",flexDirection:"column",gap:12}},{children:[n("label",o({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[t("span",o({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),A("middleDrawer.addScopeDialog.learningApprovalSettings.title","Learning Approval Settings")]})),n("div",o({role:"radio","aria-checked":"approval_required"===V,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return X("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||X("approval_required")}},{children:[n("div",o({style:{display:"flex",alignItems:"center",gap:8}},{children:[t("div",o({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===V?"#2563EB":"#CBD5E1")}},{children:"approval_required"===V&&t("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),t("span",o({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:A("middleDrawer.addScopeDialog.learningApprovalSettings.approvalRequired.title","Approval Required Before Publishing")}))]})),t("p",o({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:A("middleDrawer.addScopeDialog.learningApprovalSettings.approvalRequired.subtitle","Learnings require approval before publishing.")}))]})),"approval_required"===V&&t(h,{selectedApprovers:Z,selectedGroupOfApprovers:re,onApproversChange:$,onGroupsChange:oe}),te&&t("p",o({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:te})),n("div",o({role:"radio","aria-checked":"publish_without"===V,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){X("publish_without"),ne("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(X("publish_without"),ne(""))}},{children:[n("div",o({style:{display:"flex",alignItems:"center",gap:8}},{children:[t("div",o({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===V?"#2563EB":"#CBD5E1")}},{children:"publish_without"===V&&t("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),t("span",o({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:A("middleDrawer.addScopeDialog.learningApprovalSettings.publishWithoutApproval.title","Publish Without Approval")}))]})),t("p",o({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:A("middleDrawer.addScopeDialog.learningApprovalSettings.publishWithoutApproval.subtitle","Learnings can be published directly.")}))]}))]})),n("div",o({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[t("button",o({onClick:R,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:ae?.5:1},disabled:ae},{children:A("middleDrawer.addScopeDialog.cancel","Cancel")})),t("button",o({onClick:function(){return e(void 0,void 0,void 0,function(){var e,o,t,n,l,a,d,s,c,p,u,m,f,h;return r(this,function(r){switch(r.label){case 0:if(e={},B.trim()?B.length>50&&(e.name="Scope Name must be 50 characters or fewer"):e.name="Scope Name is required","approval_required"===V&&0===Z.length&&0===re.length&&ne("Please select at least one approver or approver group."),e.name)return P(e),[2];if("approval_required"===V&&0===Z.length&&0===re.length)return[2];ne(""),r.label=1;case 1:return r.trys.push([1,3,,4]),o="approval_required"===V,t=D.getState().backwardCompatibility,n=t?{topic:q?"genreRuleSet":"globalRuleSet",customScopeGroupName:w.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:B,parentScopeId:null,customScopeName:B,customScopeId:g(),createByName:(null==M?void 0:M.firstname)||"System",createdBy:(null==M?void 0:M.email)||"system@audacy.com",approvalRequired:o,appsecData:{application:null==K?void 0:K.applicationId,module:null==K?void 0:K.moduleId,roles:i(i([],o?[{users:Z.map(function(e){return e.email}),groups:re.map(function(e){return e._id}),role:null!==(s=null===(d=O.find(function(e){return"Learning Manager"===e.name}))||void 0===d?void 0:d._id)&&void 0!==s?s:""}]:[],!0),[{users:[null==M?void 0:M.email],groups:[],role:null!==(p=null===(c=O.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===c?void 0:c._id)&&void 0!==p?p:""}],!1)}}:{topic:q?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:B,parentScopeId:null!=j?j:null,scopeName:B,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:D.getState().app_integration_id},console.log("Add Scope payload:",n),[4,de(n)];case 2:return l=r.sent(),I(null===(u=null==l?void 0:l.data)||void 0===u?void 0:u.scopeId),R(),[3,4];case 3:return a=r.sent(),console.error("An error occurred during scope creation.",a),null===(m=T.current)||void 0===m||m.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(h=null===(f=null==a?void 0:a.response)||void 0===f?void 0:f.data)||void 0===h?void 0:h.message)||"There was an error creating the scope. Please try again."}),[3,4];case 4:return[2]}})})},style:{display:"flex",alignItems:"center",borderRadius:6,backgroundColor:"#2563EB",padding:"8px 16px",fontSize:14,fontWeight:500,color:"white",border:"none",cursor:"pointer",opacity:ae||"Custom"===F&&!H?.5:1},disabled:ae||"Custom"===F&&!H},{children:ae?n(l,{children:[t(u,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):A("middleDrawer.addScopeDialog.submitButton","Create Scope")}))]}))]}))]}))]})):null};export{_ as default};
2
2
  //# sourceMappingURL=AddScopeModal.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{useState as r}from"react";import{Dialog as t,DialogContent as i,DialogContentText as a,DialogActions as c}from"@mui/material";import l from"@mui/icons-material/Check";import d from"@mui/icons-material/CloseRounded";import{X as s,Loader2 as p}from"lucide-react";var u={header:{padding:"16px 16px 0",display:"flex",justifyContent:"space-between",alignItems:"center"},title:{color:"#334155",fontSize:"1rem"},closeButton:{border:"none",background:"transparent",padding:0,color:"#9CA3AF",cursor:"pointer",outline:"none",transition:"color 150ms ease-in-out"},dialogContent:{padding:"8px 16px"},description:{color:"#475569",fontSize:"0.875rem",lineHeight:1.625},descriptionStrong:{fontWeight:700,color:"#1E293B"},secondaryDescription:{color:"#475569",fontSize:"0.875rem",marginTop:"8px"},rejectSection:{marginTop:"20px"},feedbackLabel:{display:"block",fontSize:"0.875rem",fontWeight:600,color:"#334155",marginBottom:"6px"},textarea:{width:"100%",fontSize:"0.875rem",color:"#1E293B",padding:"10px",border:"1px solid #E2E8F0",borderRadius:"0.5rem",outline:"none",resize:"none",transition:"border-color 150ms ease-in-out, box-shadow 150ms ease-in-out",boxSizing:"border-box",fontFamily:"inherit"},checkboxLabel:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"8px",cursor:"pointer",userSelect:"none",marginTop:"16px"},checkbox:{margin:0,height:"1.125rem",width:"1.125rem",borderRadius:"0.25rem",border:"1px solid #CBD5E1",accentColor:"#DC2626",cursor:"pointer"},checkboxTextWrap:{display:"flex",alignItems:"center"},checkboxText:{fontSize:"0.875rem",fontWeight:500,color:"#1E293B",transition:"color 150ms ease-in-out"},actions:{padding:"24px",gap:"8px"},secondaryButton:{padding:"8px 20px",fontSize:"0.875rem",fontWeight:500,color:"#475569",border:"1px solid #E2E8F0",borderRadius:"0.5rem",backgroundColor:"#FFFFFF",transition:"background-color 150ms ease-in-out, border-color 150ms ease-in-out",cursor:"pointer"},primaryButton:{display:"inline-flex",alignItems:"center",gap:"0.375rem",padding:"8px 20px",fontSize:"0.875rem",fontWeight:500,color:"#FFFFFF",border:"none",borderRadius:"0.5rem",transition:"background-color 150ms ease-in-out",boxShadow:"none",cursor:"pointer"},actionIcon:{width:"1rem",height:"1rem",fontSize:"1rem"},variantCard:{backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:"10px",padding:"16px 20px",marginTop:"12px"},variantCardTitle:{fontSize:"0.9375rem",fontWeight:700,color:"#111111",marginBottom:"4px"},variantCardDescription:{fontSize:"0.8125rem",color:"#374151",marginBottom:"12px",lineHeight:1.5},variantCardMono:{fontSize:"0.75rem",color:"#4b5563",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",lineHeight:1.6}},m=function(m){var h=m.open,b=m.mode,f=m.onClose,g=m.onSubmit,x=m.variantInformation,y=m.ruleTitle,C=m.pendingVariants,v=void 0===C?[]:C,k=m.isPending,F=void 0!==k&&k,E=r(""),S=E[0],w=E[1],B=r(!0),A=B[0],z=B[1],M=r(!1),T=M[0],L=M[1],W=r(!1),j=W[0],I=W[1],R=r(!1),D=R[0],H=R[1],N=r(!1),V=N[0],P=N[1],Y=r(!1),q=Y[0],G=Y[1],J="undefined"!=typeof document?document.getElementById("rule-template-layout-content"):null,K="reject"===b,O=function(){g(K?{feedback:S,deleteLearning:A}:{}),w(""),z(!1)},Q=function(){w(""),z(!1),f()};return o(t,e({open:h,onClose:Q,container:J,maxWidth:!1,fullWidth:!0,sx:{position:"absolute",inset:0,zIndex:999,"& .MuiBackdrop-root":{position:"absolute"},"& .MuiDialog-container":{alignItems:"center",justifyContent:"center",padding:"24px 16px"},"& .MuiDialog-paper":{width:"100%",maxWidth:"640px",margin:0,borderRadius:"16px"}}},{children:[o("div",e({style:u.header},{children:[n("div",e({style:u.title},{children:K?"Reject Learning":"Approve Learning"})),n("button",e({onClick:f,onMouseEnter:function(){return L(!0)},onMouseLeave:function(){return L(!1)},style:e(e({},u.closeButton),{color:T?"#4B5563":"#9CA3AF"})},{children:n(s,{size:24})}))]})),o(i,e({sx:u.dialogContent},{children:[o(a,e({sx:u.description},{children:[n("span",e({style:u.descriptionStrong},{children:x}))," ",K?"will not be published or applied within the selected scope. You can provide feedback before rejecting.":"will be published and become active within the selected scope after approval."]})),v.length>0&&n("div",{children:v.map(function(r,t){return o("div",e({style:u.variantCard},{children:[o("div",e({style:u.variantCardTitle},{children:[y,v.length>1?" — Variant ".concat(t+1):""]})),r.description&&n("div",e({style:u.variantCardDescription},{children:r.description})),o("div",e({style:u.variantCardMono},{children:[r.whenToApply&&o("div",{children:["WTA — ",r.whenToApply]}),r.whenNotToApply&&o("div",{children:["WNTA — ",r.whenNotToApply]})]}))]}),r.variantId)})}),n(a,e({sx:u.secondaryDescription},{children:K?"":"Take a moment to check the configuration before moving forward."})),K&&o("div",e({style:u.rejectSection},{children:[o("div",{children:[n("label",e({htmlFor:"feedback",style:u.feedbackLabel},{children:"Feedback"})),n("textarea",{id:"feedback",rows:4,value:S,onChange:function(e){return w(e.target.value)},onFocus:function(){return I(!0)},onBlur:function(){return I(!1)},placeholder:"Add feedback or reason for rejection",style:e(e({},u.textarea),{borderColor:j?"#EF4444":"#E2E8F0",boxShadow:j?"0 0 0 2px rgba(239, 68, 68, 0.2)":"none"})})]}),o("label",e({style:u.checkboxLabel,onMouseEnter:function(){return H(!0)},onMouseLeave:function(){return H(!1)}},{children:[n("input",{type:"checkbox",checked:A,disabled:!1,onChange:function(e){return z(e.target.checked)},style:u.checkbox}),n("div",e({style:u.checkboxTextWrap},{children:n("span",e({style:e(e({},u.checkboxText),{color:D?"#0F172A":"#1E293B"})},{children:"Also delete this learning"}))}))]}))]}))]})),o(c,e({sx:u.actions},{children:[n("button",e({onClick:Q,type:"button",disabled:F,onMouseEnter:function(){return P(!0)},onMouseLeave:function(){return P(!1)},style:e(e({},u.secondaryButton),{backgroundColor:V&&!F?"#F8FAFC":"#FFFFFF",borderColor:V&&!F?"#CBD5E1":"#E2E8F0",opacity:F?.5:1,cursor:F?"not-allowed":"pointer"})},{children:"Cancel"})),o("button",K?e({onClick:O,type:"button",disabled:F,onMouseEnter:function(){return G(!0)},onMouseLeave:function(){return G(!1)},style:e(e({},u.primaryButton),{backgroundColor:F?"#EF4444":q?"#DC2626":"#EF4444",opacity:F?.7:1,cursor:F?"not-allowed":"pointer"})},{children:[F?n(p,{size:16,style:{animation:"spin 1s linear infinite"}}):n(d,{sx:u.actionIcon}),F?"Rejecting…":"Reject Learning"]}):e({onClick:O,type:"button",disabled:F,onMouseEnter:function(){return G(!0)},onMouseLeave:function(){return G(!1)},style:e(e({},u.primaryButton),{backgroundColor:F?"#22C55E":q?"#16A34A":"#22C55E",opacity:F?.7:1,cursor:F?"not-allowed":"pointer"})},{children:[F?n(p,{size:16,style:{animation:"spin 1s linear infinite"}}):n(l,{sx:u.actionIcon}),F?"Approving…":"Approve Learning"]}))]})),n("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}))};export{m as default};
1
+ import{__assign as e}from"tslib";import{jsxs as o,jsx as n}from"react/jsx-runtime";import{useState as r}from"react";import{Dialog as t,DialogContent as i,DialogContentText as a,DialogActions as l}from"@mui/material";import c from"@mui/icons-material/Check";import d from"@mui/icons-material/CloseRounded";import{X as s,Loader2 as p}from"lucide-react";import{dt as u}from"../store/useLMSConfigStore.js";var g={header:{padding:"16px 16px 0",display:"flex",justifyContent:"space-between",alignItems:"center"},title:{color:"#334155",fontSize:"1rem"},closeButton:{border:"none",background:"transparent",padding:0,color:"#9CA3AF",cursor:"pointer",outline:"none",transition:"color 150ms ease-in-out"},dialogContent:{padding:"8px 16px"},description:{color:"#475569",fontSize:"0.875rem",lineHeight:1.625},descriptionStrong:{fontWeight:700,color:"#1E293B"},secondaryDescription:{color:"#475569",fontSize:"0.875rem",marginTop:"8px"},rejectSection:{marginTop:"20px"},feedbackLabel:{display:"block",fontSize:"0.875rem",fontWeight:600,color:"#334155",marginBottom:"6px"},textarea:{width:"100%",fontSize:"0.875rem",color:"#1E293B",padding:"10px",border:"1px solid #E2E8F0",borderRadius:"0.5rem",outline:"none",resize:"none",transition:"border-color 150ms ease-in-out, box-shadow 150ms ease-in-out",boxSizing:"border-box",fontFamily:"inherit"},checkboxLabel:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"8px",cursor:"pointer",userSelect:"none",marginTop:"16px"},checkbox:{margin:0,height:"1.125rem",width:"1.125rem",borderRadius:"0.25rem",border:"1px solid #CBD5E1",accentColor:"#DC2626",cursor:"pointer"},checkboxTextWrap:{display:"flex",alignItems:"center"},checkboxText:{fontSize:"0.875rem",fontWeight:500,color:"#1E293B",transition:"color 150ms ease-in-out"},actions:{padding:"24px",gap:"8px"},secondaryButton:{padding:"8px 20px",fontSize:"0.875rem",fontWeight:500,color:"#475569",border:"1px solid #E2E8F0",borderRadius:"0.5rem",backgroundColor:"#FFFFFF",transition:"background-color 150ms ease-in-out, border-color 150ms ease-in-out",cursor:"pointer"},primaryButton:{display:"inline-flex",alignItems:"center",gap:"0.375rem",padding:"8px 20px",fontSize:"0.875rem",fontWeight:500,color:"#FFFFFF",border:"none",borderRadius:"0.5rem",transition:"background-color 150ms ease-in-out",boxShadow:"none",cursor:"pointer"},actionIcon:{width:"1rem",height:"1rem",fontSize:"1rem"},variantCard:{backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:"10px",padding:"16px 20px",marginTop:"12px"},variantCardTitle:{fontSize:"0.9375rem",fontWeight:700,color:"#111111",marginBottom:"4px"},variantCardDescription:{fontSize:"0.8125rem",color:"#374151",marginBottom:"12px",lineHeight:1.5},variantCardMono:{fontSize:"0.75rem",color:"#4b5563",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",lineHeight:1.6}},m=function(m){var h=m.open,b=m.mode,f=m.onClose,x=m.onSubmit,y=m.variantInformation,v=m.ruleTitle,C=m.pendingVariants,k=void 0===C?[]:C,F=m.isPending,E=void 0!==F&&F,S=r(""),D=S[0],w=S[1],T=r(!0),B=T[0],j=T[1],M=r(!1),z=M[0],A=M[1],L=r(!1),W=L[0],I=L[1],R=r(!1),P=R[0],H=R[1],N=r(!1),V=N[0],Y=N[1],q=r(!1),G=q[0],J=q[1],K="undefined"!=typeof document?document.getElementById("rule-template-layout-content"):null,O="reject"===b,Q=function(){x(O?{feedback:D,deleteLearning:B}:{}),w(""),j(!1)},U=function(){w(""),j(!1),f()};return o(t,e({open:h,onClose:U,container:K,maxWidth:!1,fullWidth:!0,sx:{position:"absolute",inset:0,zIndex:999,"& .MuiBackdrop-root":{position:"absolute"},"& .MuiDialog-container":{alignItems:"center",justifyContent:"center",padding:"24px 16px"},"& .MuiDialog-paper":{width:"100%",maxWidth:"640px",margin:0,borderRadius:"16px"}}},{children:[o("div",e({style:g.header},{children:[n("div",e({style:g.title},{children:"".concat(O?u("learnings.tier.rejectDialog.title","Reject Learning"):u("learnings.tier.approveDialog.title","Approve Learning"))})),n("button",e({onClick:f,onMouseEnter:function(){return A(!0)},onMouseLeave:function(){return A(!1)},style:e(e({},g.closeButton),{color:z?"#4B5563":"#9CA3AF"})},{children:n(s,{size:24})}))]})),o(i,e({sx:g.dialogContent},{children:[o(a,e({sx:g.description},{children:[n("span",e({style:g.descriptionStrong},{children:y}))," ","".concat(O?u("learnings.tier.rejectDialog.desc","will not be published or applied within the selected scope. You can provide feedback before rejecting"):u("learnings.tier.approveDialog.desc","will be published and become active within the selected scope after approval."))]})),k.length>0&&n("div",{children:k.map(function(r,t){return o("div",e({style:g.variantCard},{children:[o("div",e({style:g.variantCardTitle},{children:[v,k.length>1?" — Variant ".concat(t+1):""]})),r.description&&n("div",e({style:g.variantCardDescription},{children:r.description})),o("div",e({style:g.variantCardMono},{children:[r.whenToApply&&o("div",{children:["WTA — ",r.whenToApply]}),r.whenNotToApply&&o("div",{children:["WNTA — ",r.whenNotToApply]})]}))]}),r.variantId)})}),n(a,e({sx:g.secondaryDescription},{children:O?"":u("learnings.tier.approveDialog.footer","Take a moment to check the configuration before moving forward.")})),O&&o("div",e({style:g.rejectSection},{children:[o("div",{children:[n("label",e({htmlFor:"feedback",style:g.feedbackLabel},{children:u("learnings.tier.rejectDialog.feedbackTitle","Feedback")})),n("textarea",{id:"feedback",rows:4,value:D,onChange:function(e){return w(e.target.value)},onFocus:function(){return I(!0)},onBlur:function(){return I(!1)},placeholder:"".concat(u("learnings.tier.rejectDialog.feedbackPlaceholder","Add feedback or reason for rejection")),style:e(e({},g.textarea),{borderColor:W?"#EF4444":"#E2E8F0",boxShadow:W?"0 0 0 2px rgba(239, 68, 68, 0.2)":"none"})})]}),o("label",e({style:g.checkboxLabel,onMouseEnter:function(){return H(!0)},onMouseLeave:function(){return H(!1)}},{children:[n("input",{type:"checkbox",checked:B,disabled:!1,onChange:function(e){return j(e.target.checked)},style:g.checkbox}),n("div",e({style:g.checkboxTextWrap},{children:n("span",e({style:e(e({},g.checkboxText),{color:P?"#0F172A":"#1E293B"})},{children:u("learnings.tier.rejectDialog.deleteCheckboxLabel","Also delete this learning")}))}))]}))]}))]})),o(l,e({sx:g.actions},{children:[n("button",e({onClick:U,type:"button",disabled:E,onMouseEnter:function(){return Y(!0)},onMouseLeave:function(){return Y(!1)},style:e(e({},g.secondaryButton),{backgroundColor:V&&!E?"#F8FAFC":"#FFFFFF",borderColor:V&&!E?"#CBD5E1":"#E2E8F0",opacity:E?.5:1,cursor:E?"not-allowed":"pointer"})},{children:u("learnings.tier.approveDialog.cancel","Cancel")})),o("button",O?e({onClick:Q,type:"button",disabled:E,onMouseEnter:function(){return J(!0)},onMouseLeave:function(){return J(!1)},style:e(e({},g.primaryButton),{backgroundColor:E?"#EF4444":G?"#DC2626":"#EF4444",opacity:E?.7:1,cursor:E?"not-allowed":"pointer"})},{children:[E?n(p,{size:16,style:{animation:"spin 1s linear infinite"}}):n(d,{sx:g.actionIcon}),E?u("learnings.tier.rejectDialog.loadingText","Processing..."):u("learnings.tier.rejectDialog.title","Reject Learning")]}):e({onClick:Q,type:"button",disabled:E,onMouseEnter:function(){return J(!0)},onMouseLeave:function(){return J(!1)},style:e(e({},g.primaryButton),{backgroundColor:E?"#22C55E":G?"#16A34A":"#22C55E",opacity:E?.7:1,cursor:E?"not-allowed":"pointer"})},{children:[E?n(p,{size:16,style:{animation:"spin 1s linear infinite"}}):n(c,{sx:g.actionIcon}),E?u("learnings.tier.approveDialog.loadingText","Processing..."):u("learnings.tier.approveDialog.title","Approve Learning")]}))]})),n("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}))};export{m as default};
2
2
  //# sourceMappingURL=ApprovalLearningDialog.js.map
@@ -1,2 +1,2 @@
1
- import{__awaiter as e,__generator as t,__assign as r}from"tslib";import{jsx as i,jsxs as n,Fragment as o}from"react/jsx-runtime";import{useMemo as l,useCallback as a}from"react";import{Loader2 as s,Lock as u}from"lucide-react";import{useLearningTemplateStore as d}from"../store/useLearningTemplateStore.js";import{findNodeById as c}from"../utils/treeUtils.js";import m from"./RuleHeader.js";import f from"../components/EmptyLearningState.js";import p from"./RuleTierList.js";import{getRuleOverrideHistory as h}from"../apis/scopeApis.js";import{usePermissionsStore as g}from"../store/usePermissionsStore.js";var v=function(v){var S,y=v.onAddRule,x=v.onDeleteRule,R=v.onEditRule,b=v.onEditVariant,D=v.onDeleteVariant,E=v.onExportRule,T=v.isExporting,j=v.emptyStateTitle,C=void 0===j?"No learnings have been added !":j,I=v.emptyStateDesc,w=void 0===I?"Start by adding learnings that should apply across all stations.":I,N=v.emptyStateButtonText,A=void 0===N?"Create New Learning":N,L=v.onToggleSuccess,V=v.onReorderRules,B=v.onRefreshRuleSets,F=v.setDeleteConfirmationUsedFor,G=v.onCopyToTier,H=d(function(e){return e.currentRules}),z=d(function(e){return e.toggleRuleTier}),k=d(function(e){return e.scopeTreeData}),U=d(function(e){return e.selectedRuleSetId}),W=d(function(e){return e.createdVariantInfo}),O=d(function(e){return e.urlVariantId}),P=g(function(e){return e.isLoading}),_=g(function(e){return e.hasPermission}),M=U?c((null==k?void 0:k.data)||null,U):null,Y=null==M?void 0:M.id,q="GLOBAL"===(null==M?void 0:M.type)||"Global"===(null==M?void 0:M.name),J=M?{ruleSetId:M.id,ruleSetName:M.name,ruleSetDesc:"",ruleCount:null===(S=null==M?void 0:M.metrics)||void 0===S?void 0:S.learningsCount}:void 0,K=_("ilotj.rule.create",Y)||_("ilotj.rule.variant.create",Y),Q=_("ilotj.rule.view",Y),X=l(function(){var e=new Map;return W&&W.forEach(function(t){t.variants.forEach(function(t){return e.set(t.id,t.action)})}),O&&e.set(O,"existing"),e.size>0?e:void 0},[W,O]),Z=l(function(){if(W&&H){var e={tier1:"1",tier2:"2",tier_1:"1",tier_2:"2"},t={};return H.forEach(function(e){t[e.id]=e.name}),W.map(function(r){return t[e[r.tierName]]}).filter(Boolean)}},[W,H]),$=a(function(r,i){return e(void 0,void 0,void 0,function(){var e,r;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,h(i||"")];case 1:return(e=t.sent())&&e.data?[2,e.data]:[2,null];case 2:throw r=t.sent(),console.error("Failed to fetch override history",r),r;case 3:return[2]}})})},[]);return P?i("div",r({style:{display:"flex",height:"100vh",alignItems:"center",justifyContent:"center",backgroundColor:"#f9fafb",fontFamily:"Helvetica, Arial, sans-serif"}},{children:n("div",r({style:{display:"flex",flexDirection:"column",alignItems:"center",color:"#4b5563"}},{children:[i(s,{style:{marginBottom:"1rem",height:"3rem",width:"3rem",color:"#007aff",animation:"spin 1s linear infinite"}}),i("p",r({style:{fontSize:"1rem",fontWeight:500,color:"#4b5563"}},{children:"Loading your permissions…"}))]}))})):Q?H&&0!==(null==H?void 0:H.length)?n(o,{children:[i(m,{onAddRule:y,onExport:E,isExporting:T,ruleSetName:null==J?void 0:J.ruleSetName,ruleSetDescription:null==J?void 0:J.ruleSetDesc,isGlobal:q,ruleSetId:Y}),i(p,{tiers:H,ruleSetId:(null==J?void 0:J.ruleSetId)||"",onToggleTier:z,onDeleteRule:x,isGlobalScope:q,onFetchOverrideHistory:$,onEditRule:R,onEditVariant:b,onDeleteVariant:D,highlightedVariants:X,highlightedTierNames:Z,onToggleSuccess:L,onReorderRules:V,onRefreshRuleSets:B,setDeleteConfirmationUsedFor:F,onCopyToTier:G})]}):n(o,{children:[i(m,{onAddRule:y,onExport:E,isExporting:T,ruleSetName:null==J?void 0:J.ruleSetName,ruleSetDescription:null==J?void 0:J.ruleSetDesc,isGlobal:q}),i(f,{onCreate:y,title:C,desc:w,button:A,canCreateRule:K})]}):n(o,{children:[i(m,{onAddRule:y,onExport:E,isExporting:T,ruleSetName:null==J?void 0:J.ruleSetName,ruleSetDescription:null==J?void 0:J.ruleSetDesc,isGlobal:q,ruleSetId:Y}),n("div",r({style:{display:"flex",height:"80vh",width:"100%",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"2rem",textAlign:"center",backgroundColor:"#f0f2f5",fontFamily:"Helvetica, Arial, sans-serif"}},{children:[i("div",r({style:{marginBottom:"1.5rem",height:"4rem",width:"4rem",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"linear-gradient(145deg, #e0e0e0, #ffffff)",boxShadow:"4px 4px 12px rgba(0,0,0,0.05), -4px -4px 12px rgba(255,255,255,0.7)"}},{children:i(u,{style:{height:"2rem",width:"2rem",color:"#8e8e93"}})})),i("h3",r({style:{fontSize:"1.25rem",fontWeight:600,color:"#1c1c1e"}},{children:"Access Denied"})),i("p",r({style:{maxWidth:"22rem",fontSize:"1rem",color:"#636366",lineHeight:1.6,marginBottom:"1rem"}},{children:"You do not have permission to view learnings for this scope."}))]}))]})};export{v as default};
1
+ import{__awaiter as e,__generator as t,__assign as r}from"tslib";import{jsx as i,jsxs as n,Fragment as o}from"react/jsx-runtime";import{useMemo as l,useCallback as a}from"react";import{Loader2 as s,Lock as u}from"lucide-react";import{useLearningTemplateStore as d}from"../store/useLearningTemplateStore.js";import{findNodeById as c}from"../utils/treeUtils.js";import m from"./RuleHeader.js";import f from"../components/EmptyLearningState.js";import p from"./RuleTierList.js";import{getRuleOverrideHistory as g}from"../apis/scopeApis.js";import{usePermissionsStore as h}from"../store/usePermissionsStore.js";import{dt as v}from"../store/useLMSConfigStore.js";var S=function(S){var y,x=S.onAddRule,R=S.onDeleteRule,b=S.onEditRule,D=S.onEditVariant,E=S.onDeleteVariant,j=S.onExportRule,C=S.isExporting,T=S.emptyStateTitle,L=void 0===T?v("emptyStateLearning.title","No learnings have been added !"):T,w=S.emptyStateDesc,I=void 0===w?v("emptyStateLearning.desc","Start by adding learnings that should apply across all stations."):w,N=S.emptyStateButtonText,A=void 0===N?v("emptyStateLearning.createNewLearning","Create New Learning"):N,V=S.onToggleSuccess,B=S.onReorderRules,F=S.onRefreshRuleSets,G=S.setDeleteConfirmationUsedFor,H=S.onCopyToTier,z=d(function(e){return e.currentRules}),k=d(function(e){return e.toggleRuleTier}),U=d(function(e){return e.scopeTreeData}),W=d(function(e){return e.selectedRuleSetId}),M=d(function(e){return e.createdVariantInfo}),O=d(function(e){return e.urlVariantId}),P=h(function(e){return e.isLoading}),_=h(function(e){return e.hasPermission}),Y=W?c((null==U?void 0:U.data)||null,W):null,q=null==Y?void 0:Y.id,J="GLOBAL"===(null==Y?void 0:Y.type)||"Global"===(null==Y?void 0:Y.name),K=Y?{ruleSetId:Y.id,ruleSetName:Y.name,ruleSetDesc:"",ruleCount:null===(y=null==Y?void 0:Y.metrics)||void 0===y?void 0:y.learningsCount}:void 0,Q=_("ilotj.rule.create",q)||_("ilotj.rule.variant.create",q),X=_("ilotj.rule.view",q),Z=l(function(){var e=new Map;return M&&M.forEach(function(t){t.variants.forEach(function(t){return e.set(t.id,t.action)})}),O&&e.set(O,"existing"),e.size>0?e:void 0},[M,O]),$=l(function(){if(M&&z){var e={tier1:"1",tier2:"2",tier_1:"1",tier_2:"2"},t={};return z.forEach(function(e){t[e.id]=e.name}),M.map(function(r){return t[e[r.tierName]]}).filter(Boolean)}},[M,z]),ee=a(function(r,i){return e(void 0,void 0,void 0,function(){var e,r;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,g(i||"")];case 1:return(e=t.sent())&&e.data?[2,e.data]:[2,null];case 2:throw r=t.sent(),console.error("Failed to fetch override history",r),r;case 3:return[2]}})})},[]);return P?i("div",r({style:{display:"flex",height:"100vh",alignItems:"center",justifyContent:"center",backgroundColor:"#f9fafb",fontFamily:"Helvetica, Arial, sans-serif"}},{children:n("div",r({style:{display:"flex",flexDirection:"column",alignItems:"center",color:"#4b5563"}},{children:[i(s,{style:{marginBottom:"1rem",height:"3rem",width:"3rem",color:"#007aff",animation:"spin 1s linear infinite"}}),i("p",r({style:{fontSize:"1rem",fontWeight:500,color:"#4b5563"}},{children:"Loading your permissions…"}))]}))})):X?z&&0!==(null==z?void 0:z.length)?n(o,{children:[i(m,{onAddRule:x,onExport:j,isExporting:C,ruleSetName:null==K?void 0:K.ruleSetName,ruleSetDescription:null==K?void 0:K.ruleSetDesc,isGlobal:J,ruleSetId:q}),i(p,{tiers:z,ruleSetId:(null==K?void 0:K.ruleSetId)||"",onToggleTier:k,onDeleteRule:R,isGlobalScope:J,onFetchOverrideHistory:ee,onEditRule:b,onEditVariant:D,onDeleteVariant:E,highlightedVariants:Z,highlightedTierNames:$,onToggleSuccess:V,onReorderRules:B,onRefreshRuleSets:F,setDeleteConfirmationUsedFor:G,onCopyToTier:H})]}):n(o,{children:[i(m,{onAddRule:x,onExport:j,isExporting:C,ruleSetName:null==K?void 0:K.ruleSetName,ruleSetDescription:null==K?void 0:K.ruleSetDesc,isGlobal:J}),i(f,{onCreate:x,title:L,desc:I,button:A,canCreateRule:Q})]}):n(o,{children:[i(m,{onAddRule:x,onExport:j,isExporting:C,ruleSetName:null==K?void 0:K.ruleSetName,ruleSetDescription:null==K?void 0:K.ruleSetDesc,isGlobal:J,ruleSetId:q}),n("div",r({style:{display:"flex",height:"80vh",width:"100%",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"2rem",textAlign:"center",backgroundColor:"#f0f2f5",fontFamily:"Helvetica, Arial, sans-serif"}},{children:[i("div",r({style:{marginBottom:"1.5rem",height:"4rem",width:"4rem",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"linear-gradient(145deg, #e0e0e0, #ffffff)",boxShadow:"4px 4px 12px rgba(0,0,0,0.05), -4px -4px 12px rgba(255,255,255,0.7)"}},{children:i(u,{style:{height:"2rem",width:"2rem",color:"#8e8e93"}})})),i("h3",r({style:{fontSize:"1.25rem",fontWeight:600,color:"#1c1c1e"}},{children:"Access Denied"})),i("p",r({style:{maxWidth:"22rem",fontSize:"1rem",color:"#636366",lineHeight:1.6,marginBottom:"1rem"}},{children:"You do not have permission to view learnings for this scope."}))]}))]})};export{S as default};
2
2
  //# sourceMappingURL=ContentLogic.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__awaiter as n,__generator as r}from"tslib";import{jsxs as o,Fragment as i,jsx as t}from"react/jsx-runtime";import{useRef as a,useState as l,useEffect as s}from"react";import{GripVertical as c,ChevronUp as u,ChevronDown as d}from"lucide-react";import{toggleVariant as p}from"../apis/scopeApis.js";import v from"../styles/RuleAccordion.module.css.js";import m from"../styles/CustomTooltip.module.css.js";import f from"./InheritanceBreadcrumb.js";import g from"../components/ConfirmationModal.js";import h from"../components/CustomTooltip.js";import b from"../store/useAuthStore.js";import{usePermissionsStore as j}from"../store/usePermissionsStore.js";import{useLearningTemplateStore as A}from"../store/useLearningTemplateStore.js";import I from"./ApprovalLearningDialog.js";import T from"./ApprovalActionButton.js";import C from"./PendingApprovalChip.js";import{useApproveOrRejectVariantsMutation as S}from"../queries/useApprovalQueries.js";import L from"../store/useEnvStore.js";import{Toast as N}from"primereact/toast";var y=function(y){var w,P,D,O,R,B,k,x,E,_,H,M,V,z=y.rule,F=y.idx,G=y.ruleSetId,q=y.isOpen,Q=y.onToggle,U=y.onDelete;y.onEdit,y.isGlobalScope;var Y=y.deleteButtonLabel,J=void 0===Y?"Delete":Y;y.editButtonLabel;var K=y.enableLearningRuleLabel,W=void 0===K?"Enable":K,X=y.disableLearningRuleLabel,Z=void 0===X?"Disable":X,$=y.onToggleSuccess,ee=y.dragControls,ne=b.getState().user,re=j(function(e){return e.hasPermission}),oe=re("ilotj.rule.delete",G),ie=re("ilotj.rule.enable",G),te=re("ilotj.rule.disable",G),ae=re("ilotj.rule.selfApprove",G),le=re("ilotj.rule.approve",G),se=re("ilotj.scope.approve",G),ce=re("ilotj.rule.pendingApproval.view",G),ue=re("ilotj.rule.variant.pendingApproval.edit",G),de=ae||le||se||ue,pe=ce||de,ve=S(),me=L(function(e){return e.rbacConfig}),fe=me?{application:null==me?void 0:me.applicationId,scopeLevelModuleId:null!==(w=null==me?void 0:me.moduleId)&&void 0!==w?w:"",applicationLevelModuleId:null!==(P=null==me?void 0:me.applicationModuleId)&&void 0!==P?P:"",applicationLevelResourceId:null!==(D=null==me?void 0:me.applicationResourceId)&&void 0!==D?D:""}:void 0,ge=a(null),he=l(!1),be=he[0],je=he[1],Ae=z.variants&&z.variants.length>0?!z.variants.every(function(e){return!1===e.is_enabled}):!1!==z.is_enabled,Ie=l(!1),Te=Ie[0],Ce=Ie[1],Se=null===(O=z.variants)||void 0===O?void 0:O.map(function(e){return e.inheritance||[]}).reduce(function(e,n){return n.length>e.length?n:e},[]),Le=null===(R=z.variants)||void 0===R?void 0:R.some(function(e){return null==e?void 0:e.isOverridden}),Ne=Ae?te:ie;z.inheritance&&z.inheritance.length>0&&(null===(B=z.inheritance)||void 0===B||B.length);var ye=null!==(x=null===(k=z.variants)||void 0===k?void 0:k.length)&&void 0!==x?x:0,we=l({isOpen:!1,mode:"approve"}),Pe=we[0],De=we[1],Oe=null!==(_=null===(E=z.variants)||void 0===E?void 0:E.filter(function(e){return"pending_approval"===e.approvalStatus}).length)&&void 0!==_?_:0,Re=A(function(e){return e.urlVariantId}),Be=A(function(e){return e.urlApprovalAction}),ke=A(function(e){return e.clearUrlApprovalParams});s(function(){var e;if(Re&&Be){var n=null===(e=z.variants)||void 0===e?void 0:e.find(function(e){return e.variantId===Re});n&&"pending_approval"===(null==n?void 0:n.approvalStatus)&&de&&(De({isOpen:!0,mode:Be}),ke())}},[Re,Be,z.variants,ke,de]);var xe=function(e,n){e.stopPropagation(),De({isOpen:!0,mode:n})},Ee=q?"".concat(v.accordionHeader," ").concat(v.accordionHeaderOpen):v.accordionHeader;return o(i,{children:[t(N,{ref:ge}),t("div",e({className:Ee,onClick:Q},{children:o("div",e({className:v.headerContent},{children:[o("div",e({className:v.headerTopRow},{children:[t("div",e({className:v.titleSection},{children:o("div",e({className:v.titleRow},{children:[t("div",e({className:v.dragHandle,title:"Drag to reorder",style:{touchAction:"none"},onPointerDown:function(e){e.stopPropagation(),null==ee||ee.start(e)}},{children:t(c,{size:18})})),o("span",e({className:v.ruleTitle},{children:[F+1,". ",z.ruleTitle]})),z.dataSource&&t("span",e({className:v.dataSourceTag},{children:null===(H=z.dataSource)||void 0===H?void 0:H.tag})),pe&&t(C,{count:Oe}),Le&&t(h,e({content:"Inherited from the ".concat((null==Se?void 0:Se.length)>=2?Se[Se.length-2]:"parent"," scope and overridden in this scope."),placement:"top",withArrow:!0,contentClassName:m.customTooltip,sideOffset:5},{children:t("span",e({className:v.overriddenTag},{children:"Overridden"}))})),!Ae&&t("span",e({className:v.learningDisabledPill},{children:"Disabled"}))]}))})),t("div",e({className:v.headerActions},{children:t("div",e({className:v.chevronIcon},{children:t(q?u:d,{size:20})}))}))]})),o("div",e({className:v.footerRow},{children:[t(f,{inheritance:Se||[]}),o("div",e({className:v.headerButtonGroup},{children:[Ne&&t("button",e({onClick:function(e){return n(void 0,void 0,void 0,function(){return r(this,function(n){return e.stopPropagation(),je(!0),[2]})})},disabled:Te,className:v.toggleLearningButton},{children:Ae?Z:W})),de&&Oe>1&&o(i,{children:[t(T,{variant:"approve",text:Oe>1?"Approve All":"Approve",onClick:function(e){return xe(e,"approve")}}),t(T,{variant:"reject",text:Oe>1?"Reject All":"Reject",onClick:function(e){return xe(e,"reject")}})]}),oe&&U&&t("button",e({className:v.deleteButton,onClick:function(e){e.stopPropagation(),null==U||U()}},{children:J}))]}))]}))]}))})),t(g,{isOpen:be,title:Ae?"Disable Learning?":"Enable Learning?",description:"Are you sure you want to ".concat(Ae?"disable":"enable"," this learning for ").concat(z.ruleTitle,"?"),warning:Ae?"This learning will no longer influence upcoming schedules. You can enable it again anytime.":"This learning will start influencing upcoming schedules again.",confirmText:Ae?"Disable":"Enable",cancelText:"Cancel",confirmBgColor:Ae?"#DC2626":"#16A34A",onConfirm:function(){return n(void 0,void 0,void 0,function(){var e,n,o;return r(this,function(r){switch(r.label){case 0:Ce(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),0===(e=(null===(o=z.variants)||void 0===o?void 0:o.map(function(e){return e.variantId}))||[]).length&&z.ruleId&&e.push(z.ruleId),null==ne?void 0:ne.email,[4,p(e,!Ae)];case 2:return r.sent(),null==$||$(),[3,5];case 3:return n=r.sent(),console.error("Failed to toggle rule variants",n),[3,5];case 4:return Ce(!1),je(!1),[7];case 5:return[2]}})})},onCancel:function(){return je(!1)},isLoading:Te}),t(I,{open:Pe.isOpen,mode:Pe.mode,onClose:function(){return De(function(n){return e(e({},n),{isOpen:!1})})},onSubmit:function(n){return function(n){var r,o,i=null!==(o=null===(r=z.variants)||void 0===r?void 0:r.filter(function(e){return"pending_approval"===e.approvalStatus}).map(function(e){return e.variantId}))&&void 0!==o?o:[];i.length&&G&&ve.mutate({variantIds:i,status:"approve"===Pe.mode?"approved":"rejected",feedback:n.feedback,scopeId:G,appsecData:fe},{onSuccess:function(){var n;De(function(n){return e(e({},n),{isOpen:!1})}),null==$||$(),null===(n=ge.current)||void 0===n||n.show({severity:"success",summary:"".concat(Pe.mode," Successfully"),detail:"approve"===Pe.mode?"Learning approved successfully":"Learning rejected successfully"})},onError:function(e){var n;console.error("An error occurred during rejecting.",e),null===(n=ge.current)||void 0===n||n.show({severity:"error",summary:"".concat(Pe.mode," Failed"),detail:"There was an error ".concat("approve"===Pe.mode?"approving":"rejecting"," the learning. Please try again.")})}})}(n)},variantInformation:"".concat(z.ruleTitle,"-").concat(ye>1?"Variants":"Variant 1"),ruleTitle:z.ruleTitle,pendingVariants:null!==(V=null===(M=z.variants)||void 0===M?void 0:M.filter(function(e){return"pending_approval"===e.approvalStatus}))&&void 0!==V?V:[],isPending:ve.isPending})]})};export{y as default};
1
+ import{__assign as e,__awaiter as n,__generator as i}from"tslib";import{jsxs as r,Fragment as o,jsx as t}from"react/jsx-runtime";import{useRef as a,useState as l,useEffect as s}from"react";import{GripVertical as c,ChevronUp as u,ChevronDown as d}from"lucide-react";import{toggleVariant as p}from"../apis/scopeApis.js";import v from"../styles/RuleAccordion.module.css.js";import m from"../styles/CustomTooltip.module.css.js";import g from"./InheritanceBreadcrumb.js";import f from"../components/ConfirmationModal.js";import h from"../components/CustomTooltip.js";import b from"../store/useAuthStore.js";import{usePermissionsStore as j}from"../store/usePermissionsStore.js";import{useLearningTemplateStore as T}from"../store/useLearningTemplateStore.js";import A from"./ApprovalLearningDialog.js";import D from"./ApprovalActionButton.js";import S from"./PendingApprovalChip.js";import{useApproveOrRejectVariantsMutation as C}from"../queries/useApprovalQueries.js";import I from"../store/useEnvStore.js";import{Toast as w}from"primereact/toast";import{dt as y}from"../store/useLMSConfigStore.js";var L=function(L){var N,x,P,O,R,_,B,k,E,M,H,V,z,F=L.rule,G=L.idx,q=L.ruleSetId,Q=L.isOpen,U=L.onToggle,Y=L.onDelete;L.onEdit,L.isGlobalScope;var J=L.deleteButtonLabel,K=void 0===J?"Delete":J;L.editButtonLabel;var W=L.enableLearningRuleLabel,X=void 0===W?"Enable":W,Z=L.disableLearningRuleLabel,$=void 0===Z?"Disable":Z,ee=L.onToggleSuccess,ne=L.dragControls,ie=b.getState().user,re=j(function(e){return e.hasPermission}),oe=re("ilotj.rule.delete",q),te=re("ilotj.rule.enable",q),ae=re("ilotj.rule.disable",q),le=re("ilotj.rule.selfApprove",q),se=re("ilotj.rule.approve",q),ce=re("ilotj.scope.approve",q),ue=re("ilotj.rule.pendingApproval.view",q),de=re("ilotj.rule.variant.pendingApproval.edit",q),pe=le||se||ce||de,ve=ue||pe,me=C(),ge=I(function(e){return e.rbacConfig}),fe=ge?{application:null==ge?void 0:ge.applicationId,scopeLevelModuleId:null!==(N=null==ge?void 0:ge.moduleId)&&void 0!==N?N:"",applicationLevelModuleId:null!==(x=null==ge?void 0:ge.applicationModuleId)&&void 0!==x?x:"",applicationLevelResourceId:null!==(P=null==ge?void 0:ge.applicationResourceId)&&void 0!==P?P:""}:void 0,he=a(null),be=l(!1),je=be[0],Te=be[1],Ae=F.variants&&F.variants.length>0?!F.variants.every(function(e){return!1===e.is_enabled}):!1!==F.is_enabled,De=l(!1),Se=De[0],Ce=De[1],Ie=null===(O=F.variants)||void 0===O?void 0:O.map(function(e){return e.inheritance||[]}).reduce(function(e,n){return n.length>e.length?n:e},[]),we=null===(R=F.variants)||void 0===R?void 0:R.some(function(e){return null==e?void 0:e.isOverridden}),ye=Ae?ae:te;F.inheritance&&F.inheritance.length>0&&(null===(_=F.inheritance)||void 0===_||_.length);var Le=null!==(k=null===(B=F.variants)||void 0===B?void 0:B.length)&&void 0!==k?k:0,Ne=l({isOpen:!1,mode:"approve"}),xe=Ne[0],Pe=Ne[1],Oe=null!==(M=null===(E=F.variants)||void 0===E?void 0:E.filter(function(e){return"pending_approval"===e.approvalStatus}).length)&&void 0!==M?M:0,Re=T(function(e){return e.urlVariantId}),_e=T(function(e){return e.urlApprovalAction}),Be=T(function(e){return e.clearUrlApprovalParams});s(function(){var e;if(Re&&_e){var n=null===(e=F.variants)||void 0===e?void 0:e.find(function(e){return e.variantId===Re});n&&"pending_approval"===(null==n?void 0:n.approvalStatus)&&pe&&(Pe({isOpen:!0,mode:_e}),Be())}},[Re,_e,F.variants,Be,pe]);var ke=function(e,n){e.stopPropagation(),Pe({isOpen:!0,mode:n})},Ee=Q?"".concat(v.accordionHeader," ").concat(v.accordionHeaderOpen):v.accordionHeader;return r(o,{children:[t(w,{ref:he}),t("div",e({className:Ee,onClick:U},{children:r("div",e({className:v.headerContent},{children:[r("div",e({className:v.headerTopRow},{children:[t("div",e({className:v.titleSection},{children:r("div",e({className:v.titleRow},{children:[t("div",e({className:v.dragHandle,title:"Drag to reorder",style:{touchAction:"none"},onPointerDown:function(e){e.stopPropagation(),null==ne||ne.start(e)}},{children:t(c,{size:18})})),r("span",e({className:v.ruleTitle},{children:[G+1,". ",F.ruleTitle]})),F.dataSource&&t("span",e({className:v.dataSourceTag},{children:null===(H=F.dataSource)||void 0===H?void 0:H.tag})),ve&&t(S,{count:Oe}),we&&t(h,e({content:"Inherited from the ".concat((null==Ie?void 0:Ie.length)>=2?Ie[Ie.length-2]:"parent"," scope and overridden in this scope."),placement:"top",withArrow:!0,contentClassName:m.customTooltip,sideOffset:5},{children:t("span",e({className:v.overriddenTag},{children:"Overridden"}))})),!Ae&&t("span",e({className:v.learningDisabledPill},{children:"Disabled"}))]}))})),t("div",e({className:v.headerActions},{children:t("div",e({className:v.chevronIcon},{children:t(Q?u:d,{size:20})}))}))]})),r("div",e({className:v.footerRow},{children:[t(g,{inheritance:Ie||[]}),r("div",e({className:v.headerButtonGroup},{children:[ye&&t("button",e({onClick:function(e){return n(void 0,void 0,void 0,function(){return i(this,function(n){return e.stopPropagation(),Te(!0),[2]})})},disabled:Se,className:v.toggleLearningButton},{children:Ae?$:X})),pe&&Oe>1&&r(o,{children:[t(D,{variant:"approve",text:Oe>1?"Approve All":"Approve",onClick:function(e){return ke(e,"approve")}}),t(D,{variant:"reject",text:Oe>1?"Reject All":"Reject",onClick:function(e){return ke(e,"reject")}})]}),oe&&Y&&t("button",e({className:v.deleteButton,onClick:function(e){e.stopPropagation(),null==Y||Y()}},{children:K}))]}))]}))]}))})),t(f,{isOpen:je,title:Ae?y("learnings.tier.disableDialog.title","Disable Learning?"):y("learnings.tier.enableDialog.title","Enable Learning?"),description:Ae?y("learnings.tier.disableDialog.desc","Are you sure you want to disable this learning for {rule_title}?",{rule_title:F.ruleTitle}):y("learnings.tier.enableDialog.desc","Are you sure you want to enable this learning for {rule_title}?",{rule_title:F.ruleTitle}),warning:Ae?y("learnings.tier.disableDialog.warningText","This learning will no longer influence upcoming schedules. You can enable it again anytime."):y("learnings.tier.enableDialog.warningText","This learning will start influencing upcoming schedules again."),confirmText:Ae?y("learnings.tier.disableDialog.deleteText","Disable"):y("learnings.tier.enableDialog.deleteText","Enable"),cancelText:y(Ae?"learnings.tier.disableDialog.cancelText":"learnings.tier.enableDialog.cancelText","Cancel"),loadingText:y(Ae?"learnings.tier.disableDialog.loadingText":"learnings.tier.enableDialog.loadingText","Processing..."),confirmBgColor:Ae?"#DC2626":"#16A34A",onConfirm:function(){return n(void 0,void 0,void 0,function(){var e,n,r;return i(this,function(i){switch(i.label){case 0:Ce(!0),i.label=1;case 1:return i.trys.push([1,3,4,5]),0===(e=(null===(r=F.variants)||void 0===r?void 0:r.map(function(e){return e.variantId}))||[]).length&&F.ruleId&&e.push(F.ruleId),null==ie?void 0:ie.email,[4,p(e,!Ae)];case 2:return i.sent(),null==ee||ee(),[3,5];case 3:return n=i.sent(),console.error("Failed to toggle rule variants",n),[3,5];case 4:return Ce(!1),Te(!1),[7];case 5:return[2]}})})},onCancel:function(){return Te(!1)},isLoading:Se}),t(A,{open:xe.isOpen,mode:xe.mode,onClose:function(){return Pe(function(n){return e(e({},n),{isOpen:!1})})},onSubmit:function(n){return function(n){var i,r,o=null!==(r=null===(i=F.variants)||void 0===i?void 0:i.filter(function(e){return"pending_approval"===e.approvalStatus}).map(function(e){return e.variantId}))&&void 0!==r?r:[];o.length&&q&&me.mutate({variantIds:o,status:"approve"===xe.mode?"approved":"rejected",feedback:n.feedback,scopeId:q,appsecData:fe},{onSuccess:function(){var n;Pe(function(n){return e(e({},n),{isOpen:!1})}),null==ee||ee(),null===(n=he.current)||void 0===n||n.show({severity:"success",summary:"".concat(xe.mode," Successfully"),detail:"approve"===xe.mode?"Learning approved successfully":"Learning rejected successfully"})},onError:function(e){var n;console.error("An error occurred during rejecting.",e),null===(n=he.current)||void 0===n||n.show({severity:"error",summary:"".concat(xe.mode," Failed"),detail:"There was an error ".concat("approve"===xe.mode?"approving":"rejecting"," the learning. Please try again.")})}})}(n)},variantInformation:"".concat(F.ruleTitle,"-").concat(Le>1?"Variants":"Variant 1"),ruleTitle:F.ruleTitle,pendingVariants:null!==(z=null===(V=F.variants)||void 0===V?void 0:V.filter(function(e){return"pending_approval"===e.approvalStatus}))&&void 0!==z?z:[],isPending:me.isPending})]})};export{L as default};
2
2
  //# sourceMappingURL=RuleAccordionHeader.js.map