@e-llm-studio/instant-learning 1.3.0-alpha.6 → 1.3.0-alpha.61

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 (223) hide show
  1. package/README.md +195 -5
  2. package/dist/cjs/features/IL-OTJ/ILOTJTest.js +1 -1
  3. package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js +1 -1
  4. package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js +1 -1
  5. package/dist/cjs/features/IL-OTJ/_components/CitationLink.js +1 -1
  6. package/dist/cjs/features/IL-OTJ/_components/MarkdownRenderer.js +2 -0
  7. package/dist/cjs/features/IL-OTJ/_components/MarkdownRenderer.js.map +1 -0
  8. package/dist/cjs/features/IL-OTJ/_components/MarkdownRenderer.module.css.js +2 -0
  9. package/dist/cjs/features/IL-OTJ/_components/MarkdownRenderer.module.css.js.map +1 -0
  10. package/dist/cjs/features/IL-OTJ/_components/MessageRendering/ClickableChatComponents.js +1 -1
  11. package/dist/cjs/features/IL-OTJ/_components/MessageRendering/RuleValidationCard.js +1 -1
  12. package/dist/cjs/features/IL-OTJ/_components/templates/RuleComparison/AgentComposerRuleComparison.js +1 -1
  13. package/dist/cjs/features/IL-OTJ/_components/templates/RuleComparison/RuleComparison.js +1 -1
  14. package/dist/cjs/features/IL-OTJ/_components/templates/RuleComparison/RuleComparisonNew.js +1 -1
  15. package/dist/cjs/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.js +1 -1
  16. package/dist/cjs/features/LearningManagement/AuditLog/AuditLog.js +1 -1
  17. package/dist/cjs/features/LearningManagement/AuditLog/ChangeLogDiff.js +2 -0
  18. package/dist/cjs/features/LearningManagement/AuditLog/ChangeLogDiff.js.map +1 -0
  19. package/dist/cjs/features/LearningManagement/LearningManagement.js +1 -1
  20. package/dist/cjs/features/LearningManagement/LearningManagementTest.js +2 -0
  21. package/dist/cjs/features/LearningManagement/LearningManagementTest.js.map +1 -0
  22. package/dist/cjs/features/LearningManagement/LearningTemplateLayout.js +1 -1
  23. package/dist/cjs/features/LearningManagement/RBAC/AccessManagementPanel.js +1 -1
  24. package/dist/cjs/features/LearningManagement/RuleContent/AddScopeApprovalSearchComponent.js +1 -1
  25. package/dist/cjs/features/LearningManagement/RuleContent/AddScopeModal.js +1 -1
  26. package/dist/cjs/features/LearningManagement/RuleContent/ApprovalLearningDialog.js +1 -1
  27. package/dist/cjs/features/LearningManagement/RuleContent/ContentLogic.js +1 -1
  28. package/dist/cjs/features/LearningManagement/RuleContent/RuleAccordionHeader.js +1 -1
  29. package/dist/cjs/features/LearningManagement/RuleContent/RuleContent.js +1 -1
  30. package/dist/cjs/features/LearningManagement/RuleContent/RuleHeader.js +1 -1
  31. package/dist/cjs/features/LearningManagement/RuleContent/RuleTierList.js +1 -1
  32. package/dist/cjs/features/LearningManagement/RuleContent/TierCard.js +1 -1
  33. package/dist/cjs/features/LearningManagement/RuleContent/VariantCard.js +1 -1
  34. package/dist/cjs/features/LearningManagement/Sidebar.js +1 -1
  35. package/dist/cjs/features/LearningManagement/StationsContent/StationsContent.js +1 -1
  36. package/dist/cjs/features/LearningManagement/apis/apiConfig.js +1 -1
  37. package/dist/cjs/features/LearningManagement/apis/scopeApis.js +1 -1
  38. package/dist/cjs/features/LearningManagement/assets/Search-result(add new).svg.js +2 -0
  39. package/dist/cjs/features/LearningManagement/assets/Search-result(add new).svg.js.map +1 -0
  40. package/dist/cjs/features/LearningManagement/components/ConfirmationModal.js +1 -1
  41. package/dist/cjs/features/LearningManagement/components/CreateRuleSetLegacyModal.js +1 -1
  42. package/dist/cjs/features/LearningManagement/components/EmptyLearningState.js +1 -1
  43. package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +1 -1
  44. package/dist/cjs/features/LearningManagement/components/ScopeTree/TreeNode.js +1 -1
  45. package/dist/cjs/features/LearningManagement/components/ScopeTree/TreeNodeHeader.js +1 -1
  46. package/dist/cjs/features/LearningManagement/components/ScopeTree/TreeSidebar.js +1 -1
  47. package/dist/cjs/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js +2 -0
  48. package/dist/cjs/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js.map +1 -0
  49. package/dist/cjs/features/LearningManagement/components/StationOnboarding/DayToggleSelector.js +2 -0
  50. package/dist/cjs/features/LearningManagement/components/StationOnboarding/DayToggleSelector.js.map +1 -0
  51. package/dist/cjs/features/LearningManagement/components/StationOnboarding/StationOnboardModal.js +1 -1
  52. package/dist/cjs/features/LearningManagement/config.js +1 -1
  53. package/dist/cjs/features/LearningManagement/constants.js +2 -0
  54. package/dist/cjs/features/LearningManagement/constants.js.map +1 -0
  55. package/dist/cjs/features/LearningManagement/hooks/useLearningTemplateQueryParams.js +1 -1
  56. package/dist/cjs/features/LearningManagement/queries/useLMSConfigQuery.js +2 -0
  57. package/dist/cjs/features/LearningManagement/queries/useLMSConfigQuery.js.map +1 -0
  58. package/dist/cjs/features/LearningManagement/store/useEnvStore.js +1 -1
  59. package/dist/cjs/features/LearningManagement/store/useLMSConfigStore.js +2 -0
  60. package/dist/cjs/features/LearningManagement/store/useLMSConfigStore.js.map +1 -0
  61. package/dist/cjs/features/LearningManagement/store/useLearningTemplateStore.js +1 -1
  62. package/dist/cjs/features/LearningManagement/store/usePermissionsStore.js +1 -1
  63. package/dist/cjs/features/LearningManagement/styles/TierCard.module.css.js +1 -1
  64. package/dist/cjs/features/LearningManagement/utils/treeUtils.js +1 -1
  65. package/dist/cjs/index.js +1 -1
  66. package/dist/cjs/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js +1 -1
  67. package/dist/cjs/plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.js +1 -1
  68. package/dist/features/IL-OTJ/ILOTJTest.js +1 -1
  69. package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js +1 -1
  70. package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js +1 -1
  71. package/dist/features/IL-OTJ/_components/CitationLink.js +1 -1
  72. package/dist/features/IL-OTJ/_components/MarkdownRenderer.js +2 -0
  73. package/dist/features/IL-OTJ/_components/MarkdownRenderer.js.map +1 -0
  74. package/dist/features/IL-OTJ/_components/MarkdownRenderer.module.css.js +2 -0
  75. package/dist/features/IL-OTJ/_components/MarkdownRenderer.module.css.js.map +1 -0
  76. package/dist/features/IL-OTJ/_components/MessageRendering/ClickableChatComponents.js +1 -1
  77. package/dist/features/IL-OTJ/_components/MessageRendering/RuleValidationCard.js +1 -1
  78. package/dist/features/IL-OTJ/_components/templates/RuleComparison/AgentComposerRuleComparison.js +1 -1
  79. package/dist/features/IL-OTJ/_components/templates/RuleComparison/RuleComparison.js +1 -1
  80. package/dist/features/IL-OTJ/_components/templates/RuleComparison/RuleComparisonNew.js +1 -1
  81. package/dist/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.js +1 -1
  82. package/dist/features/LearningManagement/AuditLog/AuditLog.js +1 -1
  83. package/dist/features/LearningManagement/AuditLog/ChangeLogDiff.js +2 -0
  84. package/dist/features/LearningManagement/AuditLog/ChangeLogDiff.js.map +1 -0
  85. package/dist/features/LearningManagement/LearningManagement.js +1 -1
  86. package/dist/features/LearningManagement/LearningManagementTest.js +2 -0
  87. package/dist/features/LearningManagement/LearningManagementTest.js.map +1 -0
  88. package/dist/features/LearningManagement/LearningTemplateLayout.js +1 -1
  89. package/dist/features/LearningManagement/RBAC/AccessManagementPanel.js +1 -1
  90. package/dist/features/LearningManagement/RuleContent/AddScopeApprovalSearchComponent.js +1 -1
  91. package/dist/features/LearningManagement/RuleContent/AddScopeModal.js +1 -1
  92. package/dist/features/LearningManagement/RuleContent/ApprovalLearningDialog.js +1 -1
  93. package/dist/features/LearningManagement/RuleContent/ContentLogic.js +1 -1
  94. package/dist/features/LearningManagement/RuleContent/RuleAccordionHeader.js +1 -1
  95. package/dist/features/LearningManagement/RuleContent/RuleContent.js +1 -1
  96. package/dist/features/LearningManagement/RuleContent/RuleHeader.js +1 -1
  97. package/dist/features/LearningManagement/RuleContent/RuleTierList.js +1 -1
  98. package/dist/features/LearningManagement/RuleContent/TierCard.js +1 -1
  99. package/dist/features/LearningManagement/RuleContent/VariantCard.js +1 -1
  100. package/dist/features/LearningManagement/Sidebar.js +1 -1
  101. package/dist/features/LearningManagement/StationsContent/StationsContent.js +1 -1
  102. package/dist/features/LearningManagement/apis/apiConfig.js +1 -1
  103. package/dist/features/LearningManagement/apis/scopeApis.js +1 -1
  104. package/dist/features/LearningManagement/assets/Search-result(add new).svg.js +2 -0
  105. package/dist/features/LearningManagement/assets/Search-result(add new).svg.js.map +1 -0
  106. package/dist/features/LearningManagement/components/ConfirmationModal.js +1 -1
  107. package/dist/features/LearningManagement/components/CreateRuleSetLegacyModal.js +1 -1
  108. package/dist/features/LearningManagement/components/EmptyLearningState.js +1 -1
  109. package/dist/features/LearningManagement/components/InstantLearningModal.js +1 -1
  110. package/dist/features/LearningManagement/components/ScopeTree/TreeNode.js +1 -1
  111. package/dist/features/LearningManagement/components/ScopeTree/TreeNodeHeader.js +1 -1
  112. package/dist/features/LearningManagement/components/ScopeTree/TreeSidebar.js +1 -1
  113. package/dist/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js +2 -0
  114. package/dist/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js.map +1 -0
  115. package/dist/features/LearningManagement/components/StationOnboarding/DayToggleSelector.js +2 -0
  116. package/dist/features/LearningManagement/components/StationOnboarding/DayToggleSelector.js.map +1 -0
  117. package/dist/features/LearningManagement/components/StationOnboarding/StationOnboardModal.js +1 -1
  118. package/dist/features/LearningManagement/config.js +1 -1
  119. package/dist/features/LearningManagement/constants.js +2 -0
  120. package/dist/features/LearningManagement/constants.js.map +1 -0
  121. package/dist/features/LearningManagement/hooks/useLearningTemplateQueryParams.js +1 -1
  122. package/dist/features/LearningManagement/queries/useLMSConfigQuery.js +2 -0
  123. package/dist/features/LearningManagement/queries/useLMSConfigQuery.js.map +1 -0
  124. package/dist/features/LearningManagement/store/useEnvStore.js +1 -1
  125. package/dist/features/LearningManagement/store/useLMSConfigStore.js +2 -0
  126. package/dist/features/LearningManagement/store/useLMSConfigStore.js.map +1 -0
  127. package/dist/features/LearningManagement/store/useLearningTemplateStore.js +1 -1
  128. package/dist/features/LearningManagement/store/usePermissionsStore.js +1 -1
  129. package/dist/features/LearningManagement/styles/TierCard.module.css.js +1 -1
  130. package/dist/features/LearningManagement/utils/treeUtils.js +1 -1
  131. package/dist/index.js +1 -1
  132. package/dist/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js +1 -1
  133. package/dist/plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.js +1 -1
  134. package/dist/types/src/features/IL-OTJ/ILOTJTest.d.ts +597 -0
  135. package/dist/types/src/features/IL-OTJ/ILOTJTest.d.ts.map +1 -1
  136. package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.d.ts +1 -17
  137. package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.d.ts.map +1 -1
  138. package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.d.ts +1 -0
  139. package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.d.ts.map +1 -1
  140. package/dist/types/src/features/IL-OTJ/_components/CitationLink.d.ts.map +1 -1
  141. package/dist/types/src/features/IL-OTJ/_components/MarkdownRenderer.d.ts +25 -0
  142. package/dist/types/src/features/IL-OTJ/_components/MarkdownRenderer.d.ts.map +1 -0
  143. package/dist/types/src/features/IL-OTJ/_components/MessageRendering/ClickableChatComponents.d.ts.map +1 -1
  144. package/dist/types/src/features/IL-OTJ/_components/MessageRendering/RuleValidationCard.d.ts.map +1 -1
  145. package/dist/types/src/features/IL-OTJ/_components/index.d.ts +2 -0
  146. package/dist/types/src/features/IL-OTJ/_components/index.d.ts.map +1 -1
  147. package/dist/types/src/features/IL-OTJ/_components/templates/RuleComparison/RuleComparison.d.ts.map +1 -1
  148. package/dist/types/src/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.d.ts.map +1 -1
  149. package/dist/types/src/features/LearningManagement/AuditLog/AuditLog.d.ts.map +1 -1
  150. package/dist/types/src/features/LearningManagement/AuditLog/ChangeLogDiff.d.ts +15 -0
  151. package/dist/types/src/features/LearningManagement/AuditLog/ChangeLogDiff.d.ts.map +1 -0
  152. package/dist/types/src/features/LearningManagement/LearningManagement.d.ts +7 -1
  153. package/dist/types/src/features/LearningManagement/LearningManagement.d.ts.map +1 -1
  154. package/dist/types/src/features/LearningManagement/LearningManagementTest.d.ts.map +1 -1
  155. package/dist/types/src/features/LearningManagement/LearningTemplateLayout.d.ts +1 -0
  156. package/dist/types/src/features/LearningManagement/LearningTemplateLayout.d.ts.map +1 -1
  157. package/dist/types/src/features/LearningManagement/RBAC/AccessManagementPanel.d.ts +1 -0
  158. package/dist/types/src/features/LearningManagement/RBAC/AccessManagementPanel.d.ts.map +1 -1
  159. package/dist/types/src/features/LearningManagement/RuleContent/AddScopeApprovalSearchComponent.d.ts.map +1 -1
  160. package/dist/types/src/features/LearningManagement/RuleContent/AddScopeModal.d.ts +1 -0
  161. package/dist/types/src/features/LearningManagement/RuleContent/AddScopeModal.d.ts.map +1 -1
  162. package/dist/types/src/features/LearningManagement/RuleContent/ApprovalLearningDialog.d.ts.map +1 -1
  163. package/dist/types/src/features/LearningManagement/RuleContent/ContentLogic.d.ts.map +1 -1
  164. package/dist/types/src/features/LearningManagement/RuleContent/RuleAccordionHeader.d.ts.map +1 -1
  165. package/dist/types/src/features/LearningManagement/RuleContent/RuleContent.d.ts +1 -0
  166. package/dist/types/src/features/LearningManagement/RuleContent/RuleContent.d.ts.map +1 -1
  167. package/dist/types/src/features/LearningManagement/RuleContent/RuleHeader.d.ts.map +1 -1
  168. package/dist/types/src/features/LearningManagement/RuleContent/RuleTierList.d.ts.map +1 -1
  169. package/dist/types/src/features/LearningManagement/RuleContent/TierCard.d.ts +1 -0
  170. package/dist/types/src/features/LearningManagement/RuleContent/TierCard.d.ts.map +1 -1
  171. package/dist/types/src/features/LearningManagement/RuleContent/VariantCard.d.ts.map +1 -1
  172. package/dist/types/src/features/LearningManagement/Sidebar.d.ts.map +1 -1
  173. package/dist/types/src/features/LearningManagement/StationsContent/StationsContent.d.ts +1 -0
  174. package/dist/types/src/features/LearningManagement/StationsContent/StationsContent.d.ts.map +1 -1
  175. package/dist/types/src/features/LearningManagement/apis/apiConfig.d.ts +8 -0
  176. package/dist/types/src/features/LearningManagement/apis/apiConfig.d.ts.map +1 -1
  177. package/dist/types/src/features/LearningManagement/apis/scopeApis.d.ts +25 -3
  178. package/dist/types/src/features/LearningManagement/apis/scopeApis.d.ts.map +1 -1
  179. package/dist/types/src/features/LearningManagement/components/ConfirmationModal.d.ts +2 -1
  180. package/dist/types/src/features/LearningManagement/components/ConfirmationModal.d.ts.map +1 -1
  181. package/dist/types/src/features/LearningManagement/components/CreateRuleSetLegacyModal.d.ts +1 -0
  182. package/dist/types/src/features/LearningManagement/components/CreateRuleSetLegacyModal.d.ts.map +1 -1
  183. package/dist/types/src/features/LearningManagement/components/EmptyLearningState.d.ts +6 -0
  184. package/dist/types/src/features/LearningManagement/components/EmptyLearningState.d.ts.map +1 -1
  185. package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts +1 -0
  186. package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts.map +1 -1
  187. package/dist/types/src/features/LearningManagement/components/ScopeTree/TreeNode.d.ts +9 -0
  188. package/dist/types/src/features/LearningManagement/components/ScopeTree/TreeNode.d.ts.map +1 -1
  189. package/dist/types/src/features/LearningManagement/components/ScopeTree/TreeNodeHeader.d.ts +1 -0
  190. package/dist/types/src/features/LearningManagement/components/ScopeTree/TreeNodeHeader.d.ts.map +1 -1
  191. package/dist/types/src/features/LearningManagement/components/ScopeTree/TreeSidebar.d.ts.map +1 -1
  192. package/dist/types/src/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.d.ts +12 -0
  193. package/dist/types/src/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.d.ts.map +1 -0
  194. package/dist/types/src/features/LearningManagement/components/StationOnboarding/DayToggleSelector.d.ts +13 -0
  195. package/dist/types/src/features/LearningManagement/components/StationOnboarding/DayToggleSelector.d.ts.map +1 -0
  196. package/dist/types/src/features/LearningManagement/components/StationOnboarding/StationOnboardModal.d.ts.map +1 -1
  197. package/dist/types/src/features/LearningManagement/constants.d.ts +9 -0
  198. package/dist/types/src/features/LearningManagement/constants.d.ts.map +1 -0
  199. package/dist/types/src/features/LearningManagement/hooks/useLearningTemplateQueryParams.d.ts +2 -0
  200. package/dist/types/src/features/LearningManagement/hooks/useLearningTemplateQueryParams.d.ts.map +1 -1
  201. package/dist/types/src/features/LearningManagement/queries/useLMSConfigQuery.d.ts +2 -0
  202. package/dist/types/src/features/LearningManagement/queries/useLMSConfigQuery.d.ts.map +1 -0
  203. package/dist/types/src/features/LearningManagement/store/useEnvStore.d.ts +2 -0
  204. package/dist/types/src/features/LearningManagement/store/useEnvStore.d.ts.map +1 -1
  205. package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts +195 -0
  206. package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts.map +1 -0
  207. package/dist/types/src/features/LearningManagement/store/useLearningTemplateStore.d.ts +2 -0
  208. package/dist/types/src/features/LearningManagement/store/useLearningTemplateStore.d.ts.map +1 -1
  209. package/dist/types/src/features/LearningManagement/store/usePermissionsStore.d.ts +2 -1
  210. package/dist/types/src/features/LearningManagement/store/usePermissionsStore.d.ts.map +1 -1
  211. package/dist/types/src/features/LearningManagement/utils/treeUtils.d.ts +2 -1
  212. package/dist/types/src/features/LearningManagement/utils/treeUtils.d.ts.map +1 -1
  213. package/dist/types/src/index.d.ts +1 -0
  214. package/dist/types/src/index.d.ts.map +1 -1
  215. package/dist/types/src/plugins/ValueTypes/Category/CategoryTeachMeRenderer.d.ts +1 -0
  216. package/dist/types/src/plugins/ValueTypes/Category/CategoryTeachMeRenderer.d.ts.map +1 -1
  217. package/dist/types/src/plugins/ValueTypes/Default/DefaultTeachMeRenderer.d.ts +2 -8
  218. package/dist/types/src/plugins/ValueTypes/Default/DefaultTeachMeRenderer.d.ts.map +1 -1
  219. package/dist/types/src/plugins/ValueTypes/Default/DefaultTeachMeRendererOld.d.ts +28 -0
  220. package/dist/types/src/plugins/ValueTypes/Default/DefaultTeachMeRendererOld.d.ts.map +1 -0
  221. package/dist/types/src/plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.d.ts +1 -0
  222. package/dist/types/src/plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.d.ts.map +1 -1
  223. package/package.json +9 -2
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as n,__rest as t}from"tslib";import{jsxs as i,jsx as r}from"react/jsx-runtime";import o,{useState as l,useRef as a,useEffect as s,useMemo as d}from"react";import{Box as c,Typography as p,IconButton as h,Skeleton as g}from"@mui/material";import{ArrowLeft as u,ArrowRight as x}from"lucide-react";import f from"../../_svg/SparkleIcon.js";import{CognitiveDecisioningCard as m}from"@e-llm-studio/citation";import{ButtonCognitiveIcon as b}from"../../_svg/ButtonCognitiveIcon.js";var v=function(e,n){if(!n)return null;var t=new RegExp("<".concat(e,"[^>]*>([\\s\\S]*?)<\\/").concat(e,">"),"i"),i=n.match(t);return i?i[1].replace(/\\n/g,"\n"):null},y=function(e,n,t){var i=100*e;if(!t)return{bg:"#FFFFFF",border:"#E2E8F0",badgeBg:"#F1F5F9",badgeBorder:"#CBD5E1",badgeText:"#64748B",highlightBg:"transparent",label:"Not Defined"};var r=function(e){return e.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(" ")}(n);return i>=70?{bg:"#FEF2F2",border:"#FEE2E2",badgeBg:"#FEF2F2",badgeBorder:"#FECACA",badgeText:"#B91C1C",highlightBg:"#FECACA",label:r}:i>=40?{bg:"#FFFCF6",border:"#FFDD80",badgeBg:"#FEF9C3",badgeBorder:"#FEF08A",badgeText:"#A16207",highlightBg:"#FDDEB3",label:r}:{bg:"#FFFFFF",border:"#E2E8F0",badgeBg:"#F1F5F9",badgeBorder:"#CBD5E1",badgeText:"#64748B",highlightBg:"transparent",label:r}},w=o.forwardRef(function(n,t){var o=n.label,l=n.content,a=n.highlights,s=void 0===a?[]:a,d=n.styleVariant,h=n.isHighlighted,g=void 0!==h&&h,u=Array.isArray(l)?l.join("\n"):l||"",x="#B91C1C"===d.badgeText?{borderColor:"#EF4444",shadow:"rgba(239, 68, 68, 0.25)"}:"#A16207"===d.badgeText?{borderColor:"#F59E0B",shadow:"rgba(245, 158, 11, 0.25)"}:{borderColor:"#6366F1",shadow:"rgba(99, 102, 241, 0.25)"};return i(c,e({sx:{mb:1.5}},{children:[r(p,e({sx:{fontSize:"12px",color:"#19213D",mb:.5,fontWeight:500,lineHeight:"130%"}},{children:o})),r(c,e({ref:t,sx:{p:"4px 12px",borderRadius:"6px",border:g?"1.5px solid ".concat(x.borderColor):"1px solid ".concat(d.border),boxShadow:g?"0px 0px 0px 2px ".concat(x.shadow):"none",bgcolor:d.bg,fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,minHeight:"24px",display:"flex",alignItems:"center",whiteSpace:"pre-line",wordBreak:"break-word"}},{children:r(c,{children:function(){if(!u)return r(p,e({sx:{color:"#94A3B8",fontSize:"12px",fontStyle:"italic"}},{children:"Not Defined"}));if(!s||0===s.length)return u;var n=s.filter(function(e){return e&&e.length>0}).map(function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")});if(0===n.length)return u;var t=new RegExp("(".concat(n.join("|"),")"),"gi");return u.split(t).map(function(n,t){return s.some(function(e){return e&&e.toLowerCase()===n.toLowerCase()})?r(c,e({component:"span",sx:{bgcolor:d.highlightBg,borderRadius:"2px",px:"2px"}},{children:n}),t):n})}()})}))]}))}),F=function(n){var t=n.data,o=n.isSelected,l=n.isCognitiveOpen,a=n.onToggleCognitive,s=n.onClick,d=t.summaryText||t.description||"",h=d.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),u=h?d.replace(h[0],"").trim():d,x=!!h;return i(c,e({id:"variant-card-".concat(t.id),onClick:s,sx:{minWidth:"280px",maxWidth:"280px",p:2,m:.5,bgcolor:o?"#EFF6FF99":"#FFFFFF",borderRadius:"8px",cursor:"pointer",transition:"all 0.2s",display:"flex",flexDirection:"column",gap:1,flexShrink:0,opacity:t.isLoading?.7:1,border:o?"1.4px solid #2563EB":null,boxShadow:o?"none":"0px 2px 4px 0px #19213D14","&:hover":{borderColor:o?"#2563EB":"#CBD5E1",boxShadow:o?"none":"0px 4px 8px 0px #19213D1F"}}},{children:[r(c,e({sx:{display:"flex",alignItems:"center",gap:1.5}},{children:t.isLoading?r(g,{variant:"rounded",width:80,height:20}):i(c,e({sx:{bgcolor:"#FEF2F2",color:"#B91C1C",fontSize:"11px",fontWeight:600,px:1,py:.5,borderRadius:"100px",border:"1px solid #FFE1E1"}},{children:[void 0!==t.similarity?t.similarity:0,"% Similarity"]}))})),i(c,e({sx:{display:"flex",flexDirection:"column",gap:1}},{children:[i(c,e({sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap"}},{children:[r(p,e({title:t.title,sx:{fontWeight:500,fontSize:"14px",color:"#19213D",lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"}},{children:t.title})),t.scope&&r(c,e({sx:{flexShrink:0,fontSize:"10px",fontWeight:600,color:"#19213D",bgcolor:"#FFF",border:"1px solid #EDEFF2",px:.75,py:.25,borderRadius:"6px",lineHeight:1.4,whiteSpace:"nowrap"}},{children:t.scope}))]})),t.isLoading?i(c,{children:[r(g,{width:"90%"}),r(g,{width:"60%"})]}):i(c,e({title:u,sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[r(p,e({sx:{fontWeight:400,fontSize:"13px",color:"#666F8D",lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"}},{children:u})),x&&i(c,e({onClick:function(e){e.stopPropagation(),o||s(),a()},sx:{display:"inline-flex",alignItems:"center",alignSelf:"flex-start",gap:"4px",padding:"2px 6px",borderRadius:"4px",cursor:"pointer",transition:"all 0.2s ease",marginLeft:"-4px","&:hover":{backgroundColor:"#F1F5F9"}}},{children:[r("div",e({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:r(b,{})})),r("svg",e({width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#4B5563",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:o&&l?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}},{children:r("path",{d:"M6 9l6 6 6-6"})}))]}))]}))]}))]}))},_=function(o){var g,_,C=o.proposedRule,B=o.variants,E=void 0===B?[]:B,k=o.onSelectVariant;o.onAddAsVariant;var S=o.onSkip,A=o.onBack,L=o.targetVariantId,D=o.highlightedField,W=l(L||null),z=W[0],T=W[1],I=l(!1),R=I[0],j=I[1],H=l(null),O=H[0],M=H[1],V=a(null),N=a(null);s(function(){if(L&&T(L),M(null!=D?D:null),D){var e=setTimeout(function(){return M(null)},6e3);return function(){return clearTimeout(e)}}},[L,D]);var U=function(e){V.current&&V.current.scrollBy({left:"left"===e?-300:300,behavior:"smooth"})},P=d(function(){return n([],E,!0).sort(function(e,n){return(n.similarity||0)-(e.similarity||0)})},[E]),Y=d(function(){if(z){var e=String(z).trim();return E.find(function(n){return n.id&&String(n.id).trim()===e})||P[0]}return P.length>0?P[0]:null},[z,E,P]);s(function(){if(z&&V.current){var e=z.trim();setTimeout(function(){var n=document.getElementById("variant-card-".concat(e)),t=V.current;if(n&&t){var i=n.offsetLeft-t.offsetLeft-t.clientWidth/2+n.clientWidth/2;t.scrollTo({left:i,behavior:"smooth"})}},150)}},[z,P]);var $=Y||{title:"",scope:"",description:"",wta:"",wnta:"",variantType:"Default"},q=null==Y?void 0:Y.analysis,J=(null===(_=null===(g=null==q?void 0:q.rule_difference_comparison)||void 0===g?void 0:g.summary)||void 0===_?void 0:_.overall_summary)||"",X=J.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),G=!!X,K=X?X[1]:"",Q=v("reason",K)||"",Z=v("gap",K)||"",ee=v("relevance_score",K)||"",ne=d(function(){return{ul:function(n){n.node;var i=t(n,["node"]);return r("ol",e({},i,{style:{paddingLeft:"1.25rem",listStyleType:"decimal",margin:0}}))},li:function(n){n.node;var i=t(n,["node"]);return r("li",e({},i,{style:{marginBottom:"4px",listStyleType:"decimal"}},{children:i.children}))},ol:function(n){n.node;var i=t(n,["node"]);return r("li",e({},i,{style:{marginBottom:"4px",listStyleType:"decimal"}},{children:i.children}))},a:function(n){var o=n.href,l=n.children,a=t(n,["href","children"]);if(!o)return r("a",e({},a,{children:l}));var s=o||"";try{s=decodeURIComponent(o)}catch(e){console.error("Error decoding href",e)}if(s.includes("variant_id=")){var d="",c="",p=s.match(/variant_id=([^?&]+)/);p&&(d=p[1]);var h=s.match(/field_name=([^&]+)/);return h&&(c=h[1]),i("button",e({type:"button",onClick:function(e){e.preventDefault(),e.stopPropagation(),T(d),M(c),setTimeout(function(){return M(null)},6e3)},style:{background:"none",border:"none",outline:"none",borderRadius:"6px",padding:"1px 4px",color:"#0F172A",cursor:"pointer",fontSize:"13px",fontWeight:500,display:"inline-flex",alignItems:"center",gap:"2px",margin:"0 1px",verticalAlign:"baseline",textDecoration:"none",boxShadow:"none",WebkitAppearance:"none",MozAppearance:"none"},title:"View Comparison"},{children:[l,r("svg",e({width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:r("path",{d:"M10.2082 8.67708H2.0415M2.0415 8.67708L4.08317 6.63542M2.0415 8.67708L4.08317 10.7188M2.0415 3.57292H10.2082M10.2082 3.57292L8.1665 1.53125M10.2082 3.57292L8.1665 5.61458",stroke:"#0F172A",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}))]}))}return r("a",e({href:o,target:"_blank",rel:"noopener noreferrer",style:{color:"#7C3AED"}},a,{children:l}))}}},[]);s(function(){!z&&!L&&P.length>0&&!P[0].isLoading&&T(P[0].id)},[P,z,L]);var te=a(null),ie=l([]),re=ie[0],oe=ie[1],le=l(!1),ae=le[0],se=le[1],de=l(!1),ce=de[0],pe=de[1];s(function(){var e=V.current;if(e){var n=function(){se(e.scrollLeft>0),pe(e.scrollLeft+e.clientWidth<e.scrollWidth-1)};return n(),e.addEventListener("scroll",n),window.addEventListener("resize",n),function(){e.removeEventListener("scroll",n),window.removeEventListener("resize",n)}}},[P]);var he={title:a(null),scope:a(null),description:a(null),wta:a(null),wnta:a(null)},ge={title:a(null),scope:a(null),description:a(null),wta:a(null),wnta:a(null)};s(function(){if(O){var e="when_to_apply"===O?"wta":"when_not_to_apply"===O?"wnta":O,n=he[e]||ge[e];n&&n.current&&setTimeout(function(){n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}},[O]);var ue=function(e){var n,t,i,r,o,l=null===(n=null==q?void 0:q.rule_difference_comparison)||void 0===n?void 0:n.fields,a="when_to_apply"===e?"wta":"when_not_to_apply"===e?"wnta":e,s=!(!C[a]&&!$[a]);if(!l||!l[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=l[e];if(d.mappings){var c=d.mappings[0]||{};return{score:d.score,relation:c.relation||"",highlightsA:(null===(t=c.highlights)||void 0===t?void 0:t.ruleA_spans)||[],highlightsB:(null===(i=c.highlights)||void 0===i?void 0:i.ruleB_spans)||[],hasContent:s}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(r=d.highlights)||void 0===r?void 0:r.ruleA_spans)||[],highlightsB:(null===(o=d.highlights)||void 0===o?void 0:o.ruleB_spans)||[],hasContent:s}},xe=["title","scope","description","when_to_apply","when_not_to_apply"],fe=function(){if(te.current){var e=te.current.getBoundingClientRect(),n=[];xe.forEach(function(t){var i="when_to_apply"===t?he.wta:"when_not_to_apply"===t?he.wnta:he[t],r="when_to_apply"===t?ge.wta:"when_not_to_apply"===t?ge.wnta:ge[t];if(i.current&&r.current){i.current.style.height="auto",r.current.style.height="auto";var o=i.current.getBoundingClientRect(),l=r.current.getBoundingClientRect(),a=Math.max(o.height,l.height);i.current.style.height="".concat(a,"px"),r.current.style.height="".concat(a,"px");var s=i.current.getBoundingClientRect(),d=r.current.getBoundingClientRect(),c=ue(t),p=y(c.score,c.relation,c.hasContent),h=s.top+s.height/2-e.top;n.push({x1:s.right-e.left,y1:h,x2:d.left-e.left,y2:h,style:p})}}),oe(n)}};return s(function(){var e=setTimeout(fe,250);window.addEventListener("resize",fe);var n=null;return te.current&&(n=new ResizeObserver(function(){window.requestAnimationFrame(function(){fe()})})).observe(te.current),function(){clearTimeout(e),window.removeEventListener("resize",fe),n&&n.disconnect()}},[C,$,q,R]),i(c,e({sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"hidden"}},{children:[i(c,e({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4"}},{children:[i(c,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:[r(h,e({onClick:A,size:"small"},{children:r(u,{})})),r(p,e({sx:{fontSize:"16px",fontWeight:450,color:"#0F172A"}},{children:"Learning Comparison"}))]})),r(h,e({onClick:S,size:"small"},{children:r(c,e({sx:{fontSize:24,lineHeight:.5}},{children:"×"}))}))]})),P.length>1&&i(c,e({sx:{px:3,pb:.25}},{children:[i(c,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1}},{children:[r(p,e({sx:{fontSize:"13px",color:"#475569"}},{children:"Choose the Learning you want to compare with the rule you are creating."})),i(c,e({sx:{display:"flex",gap:.5,flexShrink:0,ml:1}},{children:[r(h,e({onClick:function(){return U("left")},size:"small",disabled:!ae},{children:r(u,{size:18})})),r(h,e({onClick:function(){return U("right")},size:"small",disabled:!ce},{children:r(x,{size:18})}))]}))]})),r(c,e({ref:V,sx:{display:"flex",gap:1,overflowX:"auto",pb:.05,"&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"transparent",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"transparent"}}},{children:P.map(function(e){return r(F,{data:e,isSelected:(null==Y?void 0:Y.id)===e.id,isCognitiveOpen:R,onToggleCognitive:function(){j(function(e){var n=!e;return n&&N.current&&N.current.scrollTo({top:0,behavior:"smooth"}),n})},onClick:function(){return T((n=e).id),k(n),void j(!1);var n}},e.id)})}))]})),r(c,e({ref:N,sx:{flex:1,overflowY:"auto",py:1.5,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",borderTop:J&&G&&R?"none":"1.5px solid #EEF0F4"}},{children:i(c,e({sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"}},{children:[J&&G&&R&&r(c,e({sx:{width:"100%",pb:1,animation:"fadeIn 0.2s ease-out","& > div > button":{display:"none !important"},"& > div > div":{marginTop:"0px"}}},{children:r(m,{headerIcon:r(b,{}),reasoning:Q,gap:Z,score:ee,mdComponents:ne,isOpen:!0,onToggle:function(){return j(!1)}})})),i(c,e({ref:te,sx:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative"}},{children:[r("svg",e({style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:10}},{children:re.map(function(n,t){var o=(n.x1+n.x2)/2,l=n.y1;return i("g",{children:[r("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder,strokeWidth:"1"}),r("foreignObject",e({x:o-125,y:l-16,width:"250",height:"32"},{children:r(c,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:r(c,e({sx:{fontSize:"11px",bgcolor:n.style.badgeBg,color:n.style.badgeText,border:"1px solid ".concat(n.style.badgeBorder),borderRadius:"12px",px:1.5,py:.25,fontWeight:500,textAlign:"center",whiteSpace:"nowrap"}},{children:n.style.label}))}))}))]},t)})})),i(c,e({sx:{border:"1px dashed #B0B0B0",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",minWidth:0}},{children:[r(c,e({sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px dashed #B0B0B0",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"24px",alignItems:"center"}},{children:r(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D"}},{children:"Learning You’re Creating"}))})),r(c,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:xe.map(function(e){var n=ue(e),t=y(n.score,n.relation,n.hasContent),i="when_to_apply"===e?he.wta:"when_not_to_apply"===e?he.wnta:he[e],o=C["when_to_apply"===e?"wta":"when_not_to_apply"===e?"wnta":e];return r(w,{ref:i,label:"when_to_apply"===e?"When to apply":"when_not_to_apply"===e?"When NOT to Apply":e.charAt(0).toUpperCase()+e.slice(1).replace("_"," "),content:o,highlights:n.highlightsA,styleVariant:t,isHighlighted:O===e},"left-".concat(e))})}))]})),r(c,{sx:{width:"1px"}}),i(c,e({sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0}},{children:[r(c,e({sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"24px",display:"flex",alignItems:"center"}},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",display:"flex",alignItems:"center",gap:1}},{children:[r("div",e({style:{width:"18px",height:"18px",display:"flex",alignItems:"center",justifyContent:"center"}},{children:r(f,{})})),"Existing Learning"]}))})),r(c,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:xe.map(function(e){var n=ue(e),t=y(n.score,n.relation,n.hasContent),i="when_to_apply"===e?ge.wta:"when_not_to_apply"===e?ge.wnta:ge[e],o=$["when_to_apply"===e?"wta":"when_not_to_apply"===e?"wnta":e];return r(w,{ref:i,label:"when_to_apply"===e?"When to apply":"when_not_to_apply"===e?"When NOT to Apply":e.charAt(0).toUpperCase()+e.slice(1).replace("_"," "),content:o,highlights:n.highlightsB,styleVariant:t,isHighlighted:O===e},"right-".concat(e))})}))]}))]}))]}))}))]}))};export{_ as default};
1
+ import{__assign as e,__spreadArray as n,__rest as t}from"tslib";import{jsxs as i,jsx as r}from"react/jsx-runtime";import o,{useState as l,useRef as a,useEffect as s,useMemo as d}from"react";import{Box as c,Typography as p,IconButton as h,Skeleton as g}from"@mui/material";import{ArrowLeft as u,ArrowRight as x}from"lucide-react";import f from"../../_svg/SparkleIcon.js";import{CognitiveDecisioningCard as m}from"@e-llm-studio/citation";import{ButtonCognitiveIcon as b}from"../../_svg/ButtonCognitiveIcon.js";var v=function(e,n){if(!n)return null;var t=new RegExp("<".concat(e,"[^>]*>([\\s\\S]*?)<\\/").concat(e,">"),"i"),i=n.match(t);return i?i[1].replace(/\\n/g,"\n"):null},y=function(e,n,t){var i=100*e;if(!t)return{bg:"#FFFFFF",border:"#E2E8F0",badgeBg:"#F1F5F9",badgeBorder:"#CBD5E1",badgeText:"#64748B",highlightBg:"transparent",label:"Not Defined"};var r=function(e){return e.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(" ")}(n);return i>=70?{bg:"#FEF2F2",border:"#FEE2E2",badgeBg:"#FEF2F2",badgeBorder:"#FECACA",badgeText:"#B91C1C",highlightBg:"#FECACA",label:r}:i>=40?{bg:"#FFFCF6",border:"#FFDD80",badgeBg:"#FEF9C3",badgeBorder:"#FEF08A",badgeText:"#A16207",highlightBg:"#FDDEB3",label:r}:{bg:"#FFFFFF",border:"#E2E8F0",badgeBg:"#F1F5F9",badgeBorder:"#CBD5E1",badgeText:"#64748B",highlightBg:"transparent",label:r}},w=o.forwardRef(function(n,t){var o=n.label,l=n.content,a=n.highlights,s=void 0===a?[]:a,d=n.styleVariant,h=n.isHighlighted,g=void 0!==h&&h,u=Array.isArray(l)?l.join("\n"):l||"",x="#B91C1C"===d.badgeText?{borderColor:"#EF4444",shadow:"rgba(239, 68, 68, 0.25)"}:"#A16207"===d.badgeText?{borderColor:"#F59E0B",shadow:"rgba(245, 158, 11, 0.25)"}:{borderColor:"#6366F1",shadow:"rgba(99, 102, 241, 0.25)"};return i(c,e({sx:{mb:1.5}},{children:[r(p,e({sx:{fontSize:"12px",color:"#19213D",mb:.5,fontWeight:500,lineHeight:"130%"}},{children:o})),r(c,e({ref:t,sx:{p:"4px 12px",borderRadius:"6px",border:g?"1.5px solid ".concat(x.borderColor):"1px solid ".concat(d.border),boxShadow:g?"0px 0px 0px 2px ".concat(x.shadow):"none",bgcolor:d.bg,fontSize:"13px",color:"#0B0E1A",lineHeight:1.4,minHeight:"24px",display:"flex",alignItems:"center",whiteSpace:"pre-line",wordBreak:"break-word"}},{children:r(c,{children:function(){if(!u)return r(p,e({sx:{color:"#94A3B8",fontSize:"12px",fontStyle:"italic"}},{children:"Not Defined"}));if(!s||0===s.length)return u;var n=s.filter(function(e){return e&&e.length>0}).map(function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")});if(0===n.length)return u;var t=new RegExp("(".concat(n.join("|"),")"),"gi");return u.split(t).map(function(n,t){return s.some(function(e){return e&&e.toLowerCase()===n.toLowerCase()})?r(c,e({component:"span",sx:{bgcolor:d.highlightBg,borderRadius:"2px",px:"2px"}},{children:n}),t):n})}()})}))]}))}),F=function(n){var t=n.data,o=n.isSelected,l=n.isCognitiveOpen,a=n.onToggleCognitive,s=n.onClick,d=t.summaryText||t.description||"",h=d.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),u=h?d.replace(h[0],"").trim():d,x=!!h;return i(c,e({id:"variant-card-".concat(t.id),onClick:s,sx:{minWidth:"280px",maxWidth:"280px",p:2,m:.5,bgcolor:o?"#EFF6FF99":"#FFFFFF",borderRadius:"8px",cursor:"pointer",transition:"all 0.2s",display:"flex",flexDirection:"column",gap:1,flexShrink:0,opacity:t.isLoading?.7:1,border:o?"1.4px solid #2563EB":null,boxShadow:o?"none":"0px 2px 4px 0px #19213D14","&:hover":{borderColor:o?"#2563EB":"#CBD5E1",boxShadow:o?"none":"0px 4px 8px 0px #19213D1F"}}},{children:[r(c,e({sx:{display:"flex",alignItems:"center",gap:1.5}},{children:t.isLoading?r(g,{variant:"rounded",width:80,height:20}):i(c,e({sx:{bgcolor:"#FEF2F2",color:"#B91C1C",fontSize:"11px",fontWeight:600,px:1,py:.5,borderRadius:"100px",border:"1px solid #FFE1E1"}},{children:[void 0!==t.similarity?t.similarity:0,"% Similarity"]}))})),i(c,e({sx:{display:"flex",flexDirection:"column",gap:1}},{children:[i(c,e({sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap"}},{children:[r(p,e({title:t.title,sx:{fontWeight:500,fontSize:"14px",color:"#19213D",lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"}},{children:t.title})),t.scope&&r(c,e({sx:{flexShrink:0,fontSize:"10px",fontWeight:600,color:"#19213D",bgcolor:"#FFF",border:"1px solid #EDEFF2",px:.75,py:.25,borderRadius:"6px",lineHeight:1.4,whiteSpace:"nowrap"}},{children:t.scope}))]})),t.isLoading?i(c,{children:[r(g,{width:"90%"}),r(g,{width:"60%"})]}):i(c,e({title:u,sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[r(p,e({sx:{fontWeight:400,fontSize:"13px",color:"#666F8D",lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"}},{children:u})),x&&i(c,e({onClick:function(e){e.stopPropagation(),o||s(),a()},sx:{display:"inline-flex",alignItems:"center",alignSelf:"flex-start",gap:"4px",padding:"2px 6px",borderRadius:"4px",cursor:"pointer",transition:"all 0.2s ease",marginLeft:"-4px","&:hover":{backgroundColor:"#F1F5F9"}}},{children:[r("div",e({style:{width:"13px",height:"13px",display:"flex",alignItems:"center"}},{children:r(b,{})})),r("svg",e({width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#4B5563",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:o&&l?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}},{children:r("path",{d:"M6 9l6 6 6-6"})}))]}))]}))]}))]}))},_=function(o){var g,_,C=o.proposedRule,B=o.variants,E=void 0===B?[]:B,k=o.onSelectVariant;o.onAddAsVariant;var S=o.onSkip,A=o.onBack,L=o.targetVariantId,D=o.highlightedField,W=l(L||null),z=W[0],T=W[1],I=l(!1),R=I[0],j=I[1],H=l(null),O=H[0],M=H[1],V=a(null),N=a(null);s(function(){if(L&&T(L),M(null!=D?D:null),D){var e=setTimeout(function(){return M(null)},6e3);return function(){return clearTimeout(e)}}},[L,D]);var U=function(e){V.current&&V.current.scrollBy({left:"left"===e?-300:300,behavior:"smooth"})},P=d(function(){return n([],E,!0).sort(function(e,n){return(n.similarity||0)-(e.similarity||0)})},[E]),Y=d(function(){if(z){var e=String(z).trim();return E.find(function(n){return n.id&&String(n.id).trim()===e})||P[0]}return P.length>0?P[0]:null},[z,E,P]);s(function(){if(z&&V.current){var e=z.trim();setTimeout(function(){var n=document.getElementById("variant-card-".concat(e)),t=V.current;if(n&&t){var i=n.offsetLeft-t.offsetLeft-t.clientWidth/2+n.clientWidth/2;t.scrollTo({left:i,behavior:"smooth"})}},150)}},[z,P]);var $=Y||{title:"",scope:"",description:"",wta:"",wnta:"",variantType:"Default"},q=null==Y?void 0:Y.analysis,J=(null===(_=null===(g=null==q?void 0:q.rule_difference_comparison)||void 0===g?void 0:g.summary)||void 0===_?void 0:_.overall_summary)||"",X=J.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),G=!!X,K=X?X[1]:"",Q=v("reason",K)||"",Z=v("gap",K)||"",ee=v("relevance_score",K)||"",ne=d(function(){return{ul:function(n){n.node;var i=t(n,["node"]);return r("ol",e({},i,{style:{paddingLeft:"1.25rem",listStyleType:"decimal",margin:0}}))},li:function(n){n.node;var i=t(n,["node"]);return r("li",e({},i,{style:{marginBottom:"4px",listStyleType:"decimal"}},{children:i.children}))},ol:function(n){n.node;var i=t(n,["node"]);return r("li",e({},i,{style:{marginBottom:"4px",listStyleType:"decimal"}},{children:i.children}))},a:function(n){var o=n.href,l=n.children,a=t(n,["href","children"]);if(!o)return r("a",e({},a,{children:l}));var s=o||"";try{s=decodeURIComponent(o)}catch(e){console.error("Error decoding href",e)}if(s.includes("variant_id=")){var d="",c="",p=s.match(/variant_id=([^?&]+)/);p&&(d=p[1]);var h=s.match(/field_name=([^&]+)/);return h&&(c=h[1]),i("button",e({type:"button",onClick:function(e){e.preventDefault(),e.stopPropagation(),T(d),M(c),setTimeout(function(){return M(null)},6e3)},style:{background:"none",border:"none",outline:"none",borderRadius:"6px",padding:"1px 4px",color:"#0F172A",cursor:"pointer",fontSize:"13px",fontWeight:500,display:"inline-flex",alignItems:"center",gap:"2px",margin:"0 1px",verticalAlign:"baseline",textDecoration:"none",boxShadow:"none",WebkitAppearance:"none",MozAppearance:"none"},title:"View Comparison"},{children:[l,r("svg",e({width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:r("path",{d:"M10.2082 8.67708H2.0415M2.0415 8.67708L4.08317 6.63542M2.0415 8.67708L4.08317 10.7188M2.0415 3.57292H10.2082M10.2082 3.57292L8.1665 1.53125M10.2082 3.57292L8.1665 5.61458",stroke:"#0F172A",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}))]}))}return r("a",e({href:o,target:"_blank",rel:"noopener noreferrer",style:{color:"#7C3AED"}},a,{children:l}))}}},[]);s(function(){!z&&!L&&P.length>0&&!P[0].isLoading&&T(P[0].id)},[P,z,L]);var te=a(null),ie=l([]),re=ie[0],oe=ie[1],le=l(!1),ae=le[0],se=le[1],de=l(!1),ce=de[0],pe=de[1];s(function(){var e=V.current;if(e){var n=function(){se(e.scrollLeft>0),pe(e.scrollLeft+e.clientWidth<e.scrollWidth-1)};return n(),e.addEventListener("scroll",n),window.addEventListener("resize",n),function(){e.removeEventListener("scroll",n),window.removeEventListener("resize",n)}}},[P]);var he={title:a(null),scope:a(null),description:a(null),wta:a(null),wnta:a(null)},ge={title:a(null),scope:a(null),description:a(null),wta:a(null),wnta:a(null)};s(function(){if(O){var e="when_to_apply"===O?"wta":"when_not_to_apply"===O?"wnta":O,n=he[e]||ge[e];n&&n.current&&setTimeout(function(){n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}},[O]);var ue=function(e){var n,t,i,r,o,l=null===(n=null==q?void 0:q.rule_difference_comparison)||void 0===n?void 0:n.fields,a="when_to_apply"===e?"wta":"when_not_to_apply"===e?"wnta":e,s=!(!C[a]&&!$[a]);if(!l||!l[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=l[e];if(d.mappings){var c=d.mappings[0]||{};return{score:d.score,relation:c.relation||"",highlightsA:(null===(t=c.highlights)||void 0===t?void 0:t.ruleA_spans)||[],highlightsB:(null===(i=c.highlights)||void 0===i?void 0:i.ruleB_spans)||[],hasContent:s}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(r=d.highlights)||void 0===r?void 0:r.ruleA_spans)||[],highlightsB:(null===(o=d.highlights)||void 0===o?void 0:o.ruleB_spans)||[],hasContent:s}},xe=["title","scope","description","when_to_apply","when_not_to_apply"],fe=function(){if(te.current){var e=te.current.getBoundingClientRect(),n=[];xe.forEach(function(t){var i="when_to_apply"===t?he.wta:"when_not_to_apply"===t?he.wnta:he[t],r="when_to_apply"===t?ge.wta:"when_not_to_apply"===t?ge.wnta:ge[t];if(i.current&&r.current){i.current.style.height="auto",r.current.style.height="auto";var o=i.current.getBoundingClientRect(),l=r.current.getBoundingClientRect(),a=Math.max(o.height,l.height);i.current.style.height="".concat(a,"px"),r.current.style.height="".concat(a,"px");var s=i.current.getBoundingClientRect(),d=r.current.getBoundingClientRect(),c=ue(t),p=y(c.score,c.relation,c.hasContent),h=s.top+s.height/2-e.top;n.push({x1:s.right-e.left,y1:h,x2:d.left-e.left,y2:h,style:p})}}),oe(n)}};return s(function(){var e=setTimeout(fe,250);window.addEventListener("resize",fe);var n=null;return te.current&&(n=new ResizeObserver(function(){window.requestAnimationFrame(function(){fe()})})).observe(te.current),function(){clearTimeout(e),window.removeEventListener("resize",fe),n&&n.disconnect()}},[C,$,q,R]),i(c,e({sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"hidden"}},{children:[i(c,e({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4"}},{children:[i(c,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:[r(h,e({onClick:A,size:"small"},{children:r(u,{})})),r(p,e({sx:{fontSize:"16px",fontWeight:450,color:"#0F172A"}},{children:"Learning Comparison"}))]})),r(h,e({onClick:S,size:"small"},{children:r(c,e({sx:{fontSize:24,lineHeight:.5}},{children:"×"}))}))]})),P.length>0&&i(c,e({sx:{px:3,pb:.25}},{children:[i(c,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1}},{children:[r(p,e({sx:{fontSize:"13px",color:"#475569"}},{children:"Choose the Learning you want to compare with the rule you are creating."})),i(c,e({sx:{display:"flex",gap:.5,flexShrink:0,ml:1}},{children:[r(h,e({onClick:function(){return U("left")},size:"small",disabled:!ae},{children:r(u,{size:18})})),r(h,e({onClick:function(){return U("right")},size:"small",disabled:!ce},{children:r(x,{size:18})}))]}))]})),r(c,e({ref:V,sx:{display:"flex",gap:1,overflowX:"auto",pb:.05,"&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"transparent",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"transparent"}}},{children:P.map(function(e){return r(F,{data:e,isSelected:(null==Y?void 0:Y.id)===e.id,isCognitiveOpen:R,onToggleCognitive:function(){j(function(e){var n=!e;return n&&N.current&&N.current.scrollTo({top:0,behavior:"smooth"}),n})},onClick:function(){return T((n=e).id),k(n),void j(!1);var n}},e.id)})}))]})),r(c,e({ref:N,sx:{flex:1,overflowY:"auto",py:1.5,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",borderTop:J&&G&&R?"none":"1.5px solid #EEF0F4"}},{children:i(c,e({sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"}},{children:[J&&G&&R&&r(c,e({sx:{width:"100%",pb:1,animation:"fadeIn 0.2s ease-out","& > div > button":{display:"none !important"},"& > div > div":{marginTop:"0px"}}},{children:r(m,{headerIcon:r(b,{}),reasoning:Q,gap:Z,score:ee,mdComponents:ne,isOpen:!0,onToggle:function(){return j(!1)}})})),i(c,e({ref:te,sx:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative"}},{children:[r("svg",e({style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:10}},{children:re.map(function(n,t){var o=(n.x1+n.x2)/2,l=n.y1;return i("g",{children:[r("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder,strokeWidth:"1"}),r("foreignObject",e({x:o-125,y:l-16,width:"250",height:"32"},{children:r(c,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:r(c,e({sx:{fontSize:"11px",bgcolor:n.style.badgeBg,color:n.style.badgeText,border:"1px solid ".concat(n.style.badgeBorder),borderRadius:"12px",px:1.5,py:.25,fontWeight:500,textAlign:"center",whiteSpace:"nowrap"}},{children:n.style.label}))}))}))]},t)})})),i(c,e({sx:{border:"1px dashed #B0B0B0",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",minWidth:0}},{children:[r(c,e({sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px dashed #B0B0B0",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"24px",alignItems:"center"}},{children:r(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D"}},{children:"Learning You’re Creating"}))})),r(c,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:xe.map(function(e){var n=ue(e),t=y(n.score,n.relation,n.hasContent),i="when_to_apply"===e?he.wta:"when_not_to_apply"===e?he.wnta:he[e],o=C["when_to_apply"===e?"wta":"when_not_to_apply"===e?"wnta":e];return r(w,{ref:i,label:"when_to_apply"===e?"When to apply":"when_not_to_apply"===e?"When NOT to Apply":e.charAt(0).toUpperCase()+e.slice(1).replace("_"," "),content:o,highlights:n.highlightsA,styleVariant:t,isHighlighted:O===e},"left-".concat(e))})}))]})),r(c,{sx:{width:"1px"}}),i(c,e({sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0}},{children:[r(c,e({sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"24px",display:"flex",alignItems:"center"}},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",display:"flex",alignItems:"center",gap:1}},{children:[r("div",e({style:{width:"18px",height:"18px",display:"flex",alignItems:"center",justifyContent:"center"}},{children:r(f,{})})),"Existing Learning"]}))})),r(c,e({sx:{p:"12px",display:"flex",flexDirection:"column"}},{children:xe.map(function(e){var n=ue(e),t=y(n.score,n.relation,n.hasContent),i="when_to_apply"===e?ge.wta:"when_not_to_apply"===e?ge.wnta:ge[e],o=$["when_to_apply"===e?"wta":"when_not_to_apply"===e?"wnta":e];return r(w,{ref:i,label:"when_to_apply"===e?"When to apply":"when_not_to_apply"===e?"When NOT to Apply":e.charAt(0).toUpperCase()+e.slice(1).replace("_"," "),content:o,highlights:n.highlightsB,styleVariant:t,isHighlighted:O===e},"right-".concat(e))})}))]}))]}))]}))}))]}))};export{_ as default};
2
2
  //# sourceMappingURL=RuleComparisonNew.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,AlertTriangle as f,Pencil as g,Check 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 x,T,A,D,S,C,I,b,O,E,w,V,R=m.state,_=m.handlers,N=m.uiState,W=(null==N?void 0:N.highlights)||new Map,F=W.get("global_0")||{},L=o({}),B=L[0],j=L[1],M=o(null),k=M[0],z=M[1],q=o(function(){var i,e,n;if((null==N?void 0:N.defaultTierOpen)>=0&&(null===(i=null==N?void 0:N.tierOptions)||void 0===i?void 0:i[N.defaultTierOpen]))return N.tierOptions[N.defaultTierOpen].toLowerCase().replace(/ /g,"_");var t=null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n[0];return t?t.toLowerCase().replace(/ /g,"_"):null});q[0];var P=q[1],J="rule-setup"===(null==N?void 0:N.activeEditId),H=t.useRef(new Map),K=o(null),$=K[0],U=K[1],Z=o(null),G=Z[0],Q=Z[1],X=o(!1),Y=X[0],ii=X[1],ei=t.useRef(null==N?void 0:N.isAiStreaming);l(function(){ei.current&&!(null==N?void 0:N.isAiStreaming)&&Y&&ii(!1),ei.current=null==N?void 0:N.isAiStreaming},[null==N?void 0:N.isAiStreaming,Y]);var ni=function(){var i;U(null),Q(null),null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null)},ti=function(){var i,e,n=null!=$?$:R.ruleTitle,t=null!=G?G:R.scopeData,o=n!==R.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(R.scopeData);if(!o&&!l)return U(null),Q(null),void(null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null));if(null==N?void 0:N.setSendMessageInChat){var r="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),a=[];if(o&&a.push((null==n?void 0:n.trim())?"Title with ".concat(n):"No Title"),l){var d=null==t?void 0:t.tiers,c=d&&d.length>0?"tiers: ".concat(d.join(", ")):"No Tier Selected";a.push(c)}var u=a.join(" and ");N.setSendMessageInChat("__SKELETON__:".concat(r,":Update Rule Setup ").concat(u))}ii(!0),U(null),Q(null),null===(e=null==N?void 0:N.setActiveEditId)||void 0===e||e.call(N,null)},oi=null!==$?null==$?void 0:$.trim():(R.ruleTitle||"").trim(),li=null!=G?G:R.scopeData,ri=oi!==(R.ruleTitle||"").trim(),ai=JSON.stringify(li)!==JSON.stringify(R.scopeData),di=!ri&&!ai||""===oi,ci=t.useRef(null==N?void 0:N.defaultVariantOpen),ui=t.useRef(null==N?void 0:N.activeVariantAccordionIndex),si=t.useRef(null==N?void 0:N.defaultTierOpen),vi=t.useRef(null===(x=R.scopeData)||void 0===x?void 0:x.tiers),pi=t.useRef(R.variantsByTier);t.useEffect(function(){var i,e,n,t,o,l,r=null,a=!1;ci.current!==(null==N?void 0:N.defaultVariantOpen)&&(a=!0,ci.current=null==N?void 0:N.defaultVariantOpen),ui.current!==(null==N?void 0:N.activeVariantAccordionIndex)&&(a=!0,ui.current=null==N?void 0:N.activeVariantAccordionIndex),si.current!==(null==N?void 0:N.defaultTierOpen)&&(a=!0,si.current=null==N?void 0:N.defaultTierOpen);var d=(null===(i=R.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(vi.current)!==JSON.stringify(d)&&(a=!0,vi.current=d,d.length>0&&P(d[0].toLowerCase().replace(/ /g,"_")));var c=(null===(e=null==N?void 0:N.tierOptions)||void 0===e?void 0:e.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||[],u=c.some(function(i){var e,n,t,o,l=i.toLowerCase().replace(/ /g,"_");return((null===(n=null===(e=pi.current)||void 0===e?void 0:e[l])||void 0===n?void 0:n.length)||0)!==((null===(o=null===(t=R.variantsByTier)||void 0===t?void 0:t[l])||void 0===o?void 0:o.length)||0)});if(u&&(a=!0),a){var s=null!==(n=null==N?void 0:N.activeVariantAccordionIndex)&&void 0!==n?n:null==N?void 0:N.defaultVariantOpen;if(null==s||s<0)return z(null),void(pi.current=R.variantsByTier);c.forEach(function(i,e){var n;if(!((null==N?void 0:N.defaultTierOpen)>=0&&e!==N.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),o=(null===(n=R.variantsByTier)||void 0===n?void 0:n[t])||[];o[s]&&(r="".concat(t,"-variant-").concat(s)),null!=(null==N?void 0:N.autoScrollVariantIndex)&&o[N.autoScrollVariantIndex]&&(r="".concat(t,"-variant-").concat(N.autoScrollVariantIndex))}}),r&&z(r)}if(null===k){var v=null!==(t=null==N?void 0:N.activeVariantAccordionIndex)&&void 0!==t?t:null==N?void 0:N.defaultVariantOpen;null!=v&&v>=0&&(null===(l=null===(o=null==N?void 0:N.tierOptions)||void 0===o?void 0:o.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===l||l.forEach(function(i,e){var n;if(!((null==N?void 0:N.defaultTierOpen)>=0&&e!==N.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(n=R.variantsByTier)||void 0===n?void 0:n[t])||[])[v]&&z("".concat(t,"-variant-").concat(v))}}))}pi.current=R.variantsByTier},[R.variantsByTier,null==N?void 0:N.defaultVariantOpen,null==N?void 0:N.activeVariantAccordionIndex,null===(T=R.scopeData)||void 0===T?void 0:T.tiers,null==N?void 0:N.tierOptions,null==N?void 0:N.autoScrollVariantIndex,null==N?void 0:N.defaultTierOpen]);var fi=function(e){j(function(n){var t;return i(i({},n),((t={})[e]=!n[e],t))})},gi=function(i){var e,n,t,o=i.split("_"),l=o[o.length-1],r=/^\d+$/.test(l)?o.slice(0,-1).join("_"):i,a=null===(e=R.fieldCitations)||void 0===e?void 0:e[r];if(Array.isArray(a)&&a.length>0)return a;var d=null===(n=R.fieldCitations)||void 0===n?void 0:n[i];return Array.isArray(d)&&d.length>0?d:null!==(t=R.citations)&&void 0!==t?t:[]},hi={marginTop:"-17px",position:"relative",zIndex:1};l(function(){var i,e;null!=(null==N?void 0:N.autoScrollVariantIndex)&&(null===(e=null===(i=null==N?void 0:N.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===e||e.forEach(function(i){var e=i.toLowerCase().replace(/ /g,"_"),n="".concat(e,"-variant-").concat(N.autoScrollVariantIndex),t=H.current.get(n);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==N?void 0:N.scrollTrigger]),console.log("CreateRule state:",R),console.log("CreateRule uiState:",N);var yi=function(i){return i?i.replace(/_/g," ").replace(/([a-zA-Z])(\d)/g,"$1 $2").replace(/\b\w/g,function(i){return i.toUpperCase()}):"Variant 1"},mi=!!(null==N?void 0:N.activeEditId);return e("div",i({className:"traffic-manager-template"},{children:[n("div",i({"data-edit-id":"rule-setup"},{children:n(s,i({title:{type:"other",label:(null==N?void 0:N.setupLabel)||"Rule Setup"},actionButtons:function(e,t){if(J)return null;var o=!!(null==N?void 0:N.activeEditId)&&"rule-setup"!==N.activeEditId;return n("div",i({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:n("button",i({title:o?"Save active edits first":"Edit",onClick:function(n){n.stopPropagation(),o?(null==N?void 0:N.setPendingEditId)&&N.setPendingEditId(N.activeEditId||null):(!function(){var e,n;(null==N?void 0:N.activeEditId)&&"rule-setup"!==N.activeEditId||(null===(e=null==N?void 0:N.setActiveEditId)||void 0===e||e.call(N,"rule-setup"),U(null!==(n=R.ruleTitle)&&void 0!==n?n:""),Q(R.scopeData?i({},R.scopeData):{}))}(),(null==N?void 0:N.setPendingEditId)&&N.setPendingEditId(null),e||t())},disabled:Y,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:Y?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:Y?.5:1}},{children:n(g,{size:14})}))}))},footerData:{ruleTitle:R.ruleTitle,stations:[R.scopeData.station],tiers:null===(A=R.scopeData)||void 0===A?void 0:A.tiers},defaultOpen:"Create"===(null==N?void 0:N.usedFor),readOnly:"Create"!==(null==N?void 0:N.usedFor),isAiStreaming:null==N?void 0:N.isAiStreaming,editFlow:"Edit"===(null==N?void 0:N.usedFor)},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[Y&&(null==N?void 0:N.isAiStreaming)&&e("div",i({style:{display:"flex",alignItems:"center",color:"#141414ff",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[n(p,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),n(u,i({id:"rule-title",title:N.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:J&&null!==$?$:R.ruleTitle,onChange:function(i){return J?U(i):_.setRuleTitle(i)},readOnly:(null==N?void 0:N.isAiStreaming)||!J,isOpen:B.ruleTitle,onToggle:function(){return fi("ruleTitle")},isHighlighted:F.ruleTitle||!1,showCognitiveIcon:R.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(D=N.validationErrors)||void 0===D?void 0:D.ruleTitle},N)),R.citation.ruleTitle&&n("div",i({style:hi},{children:n(r,{isVisible:B.ruleTitle,citation:R.citation.ruleTitle,citations:gi("ruleTitle"),fieldName:"Rule Title",fieldValue:R.ruleTitle})})),(null===(S=null==N?void 0:N.tierOptions)||void 0===S?void 0:S.length)>1&&n(c,i({id:"scope",title:"",required:!1,scopeData:J&&null!==G?G:R.scopeData,onScopeChange:function(e,n){J?Q(function(t){var o;return i(i({},null!=t?t:R.scopeData),((o={})[e]=n,o))}):_.onScopeChange(e,n)},tierLabel:"Which tier are you configuring this learning for?",stationLabel:"Which scope should this learning belong to?",highlights:F,isOpen:B.scopeData,onToggle:function(){return fi("scopeData")},showCognitiveIcon:R.citation.scopeData,cognitiveIcon:n(v,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(C=N.validationErrors)||void 0===C?void 0:C.station)||(null===(I=N.validationErrors)||void 0===I?void 0:I.tiers),stationErrorMessage:null===(b=N.validationErrors)||void 0===b?void 0:b.station,tierErrorMessage:null===(O=N.validationErrors)||void 0===O?void 0:O.tiers,readOnly:(null==N?void 0:N.isAiStreaming)||!J},N)),R.citation.scopeData&&n("div",i({style:hi},{children:n(r,{isVisible:B.scopeData,citation:R.citation.scopeData,citations:gi("scopeData"),fieldName:"Scope",fieldValue:null===(w=null===(E=R.scopeData)||void 0===E?void 0:E.tiers)||void 0===w?void 0:w.join(", ")})})),J?e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[e("div",i({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[n("button",i({onClick:ni,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e("button",i({onClick:ti,disabled:di,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:di?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:di?.5:1}},{children:[n(h,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==N?void 0:N.pendingEditId)&&e("div",i({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"10px"}},{children:[n(f,{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==N?void 0:N.tierOptions)||0===N.tierOptions.length)&&e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",padding:"32px 16px",marginTop:"8px",backgroundColor:"#FAFAFA",border:"1px dashed #E2E8F0",borderRadius:"12px",color:"#94a3b8"}},{children:[n(f,{size:20,style:{color:"#94a3b8"}}),n("span",i({style:{fontSize:"13px",fontWeight:500,color:"#64748b"}},{children:"No tiers found"}))]})),null===(V=null==N?void 0:N.tierOptions)||void 0===V?void 0:V.map(function(o,l){var c,v,p,f,g,h,m,x=o.toLowerCase().replace(/ /g,"_"),T=(null===(c=R.variantsByTier)||void 0===c?void 0:c[x])||[],A=null===(p=null===(v=R.scopeData)||void 0===v?void 0:v.tiers)||void 0===p?void 0:p.includes(o),D=T.length,S=!1;if(1===D){var C=T[0],I=!(null===(f=null==C?void 0:C.ruleDescription)||void 0===f?void 0:f.trim()),b=(null===(g=null==C?void 0:C.whenToApplyConditions)||void 0===g?void 0:g.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,O=(null===(h=null==C?void 0:C.whenNotToApplyConditions)||void 0===h?void 0:h.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;!I||b||O||(S=!0)}var E=S?void 0:"".concat(D," ").concat(1===D?"variant":"variants"," configured for this tier"),w=n(y,i({onAddVariant:function(){var i;return null===(i=_.addNewVariant)||void 0===i?void 0:i.call(_,x)},isDisabled:!A||(null==N?void 0:N.isAiStreaming),showAddVariantBtn:"Edit"!==(null==N?void 0:N.usedFor)},{children:T.map(function(t,o){var l,c,v,p,f,g,h,y,m,T,D=t.variantType||"default",S="".concat(x,"-variant-").concat(o),C=!0===t.is_variant,I="default"===D||"default_variant"===D,b="".concat(x,"_").concat(o),O=W.get(b)||{},E=(null===(c=null===(l=N.separationItemsByTier)||void 0===l?void 0:l[x])||void 0===c?void 0:c.get(o))||[],w=(null===(p=null===(v=N.togglesByTier)||void 0===v?void 0:v[x])||void 0===p?void 0:p.get(o))||[],V=null===(f=null==N?void 0:N.activeEditId)||void 0===f?void 0:f.startsWith("condition-wta-".concat(x,"-").concat(o)),F=null===(g=null==N?void 0:N.activeEditId)||void 0===g?void 0:g.startsWith("condition-wnta-".concat(x,"-").concat(o)),L=!A||t.isReadOnly||(null==N?void 0:N.isAiStreaming);return n("div",i({ref:function(i){i?H.current.set(S,i):H.current.delete(S)},style:{width:"100%",opacity:A?1:.7}},{children:n(s,i({title:{type:I?"default":"variant",label:yi(D),number:o+1,isNewVariant:C,isDefault:t.isDefault,isModified:t.isModified},defaultOpen:!0,expanded:1==(null==N?void 0:N.tierOptions.length)&&k===S,onToggle:function(){var i,e=k===S;z(e?null:S),null===(i=null==N?void 0:N.setActiveVariantAccordionIndex)||void 0===i||i.call(N,e?null:o)},variant:"rule-behavior",footerData:{ruleTitle:D,description:t.ruleDescription||""},readOnly:L},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[n(u,i({id:"rule-description-".concat(x,"-").concat(o),title:N.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:L||mi&&(null==N?void 0:N.activeEditId)!=="rule-description-".concat(x,"-").concat(o),value:t.ruleDescription||"",onChange:function(i){return _.setRuleDescription(x,o,i)},isOpen:B["ruleDescription-".concat(x)],onToggle:function(){return fi("ruleDescription-".concat(x))},isHighlighted:O.ruleDescription||!1,showCognitiveIcon:null===(h=R.citation)||void 0===h?void 0:h["ruleDescription_".concat(x)],tooltipDescription:"Why this Description?",errorMessage:null===(y=N.validationErrors)||void 0===y?void 0:y["ruleDescription-".concat(x,"-").concat(o)],enableInlineEdit:!0,setSendMessageInChat:null==N?void 0:N.setSendMessageInChat,isAiStreaming:null==N?void 0:N.isAiStreaming,fieldName:"Rule Description"},N)),(null===(m=R.citation)||void 0===m?void 0:m["ruleDescription_".concat(x)])&&n("div",i({style:hi},{children:n(r,{isVisible:B["ruleDescription-".concat(x)],citation:R.citation["ruleDescription_".concat(x)],citations:gi("ruleDescription_".concat(x,"_").concat(o)),fieldName:"Rule Description",fieldValue:t.ruleDescription})})),n(a,i({id:"when-to-apply-".concat(x,"-").concat(o),idPrefix:"condition-wta",title:N.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:L||mi&&!V,conditions:t.whenToApplyConditions||[],onAdd:function(){return _.addWhenToApply(x,o)},onRemove:function(i,e,n){return _.removeWhenToApply(i,e,n)},onEdit:function(i,e,n,t){return _.editWhenToApply(i,e,n,t)},index:o,tierKey:x,isHighlighted:O.wta||!1,highlightedIds:null==N?void 0:N.highlightedIds,tooltipDescription:"Why this Condition?",citations:gi("whenToApply_".concat(x,"_").concat(o)),bordered:!0,addLabel:(null==N?void 0:N.addWhenToApplyBtnLabel)||"Add When to apply",isAiStreaming:N.isAiStreaming,errorMessage:(null===(T=N.validationErrors)||void 0===T?void 0:T["whenToApply-".concat(x,"-").concat(o)])||(null==N?void 0:N.conflictReason)},N)),n(a,i({id:"when-not-to-apply-".concat(x,"-").concat(o),idPrefix:"condition-wnta",title:N.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:L||mi&&!F,conditions:t.whenNotToApplyConditions||[],onAdd:function(){return _.addWhenNotToApply(x,o)},onRemove:function(i,e,n){return _.removeWhenNotToApply(i,e,n)},onEdit:function(i,e,n,t){return _.editWhenNotToApply(i,e,n,t)},index:o,tierKey:x,isHighlighted:O.wnta||!1,highlightedIds:null==N?void 0:N.highlightedIds,tooltipDescription:"Why this Condition?",citations:gi("whenNotToApply_".concat(x,"_").concat(o)),bordered:!0,addLabel:(null==N?void 0:N.addWhenNotToApplyBtnLabel)||"Add When NOT to apply",isAiStreaming:N.isAiStreaming},N)),(null==N?void 0:N.showConfiguration)&&n(d,i({id:"config-".concat(x,"-").concat(o),title:N.configTitle||"Configuration",required:!1,highlights:O,bordered:!0,readOnly:L||mi&&(null==N?void 0:N.activeEditId)!=="config-".concat(x,"-").concat(o),onConfigChange:function(i,e){return _.onConfigChange(x,o,i,e)},separationItems:E,toggles:w,index:o},N))]}))}),S)}),"".concat(x,"-variant-").concat(o))})}));return 1===(null===(m=null==N?void 0:N.tierOptions)||void 0===m?void 0:m.length)?n(t.Fragment,{children:w},"tier-".concat(l)):n(s,i({variant:"tier-header",title:{type:"other",label:o},subtitle:E,defaultOpen:!0,footerData:{description:"Variants for ".concat(o)}},{children:w}),"tier-".concat(l))})]}))};export{m as CreateRule};
2
2
  //# sourceMappingURL=CreateRule.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useMemo as o,useEffect as n}from"react";import{AuditLog as r}from"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import{User as l,FileText as a,ExternalLink as d}from"lucide-react";var c=function(c){var s=c.configId,h=c.ruleData,p=c.scopeId,g=c.scopeName,u=(null==g?void 0:g.trim())||"Selected",m=o(function(){var e=[];return p&&e.push(p),e},[h,p]);return n(function(){console.log("Flattened External Resource IDs:",m)},[m]),t("div",e({style:{padding:"24px",fontFamily:"Arial, sans-serif"}},{children:[t("div",e({style:{marginBottom:"16px",paddingBottom:"4px"}},{children:[t("h1",e({style:{margin:0,color:"#334155",fontSize:"20px",fontWeight:700,lineHeight:1.25}},{children:[u," - Audit Log"]})),t("p",e({style:{margin:"8px 0 0",color:"#667085",fontSize:"16px",fontWeight:500,lineHeight:1}},{children:["Track all learning updates and modifications with the ",u," scope."]}))]})),i(r,{configId:s,getData:{baseUrl:"https://dev.appmod.ai",endpoint:"/changelog/audit-log/fetch"},distinctValuesApi:{baseUrl:"https://dev.appmod.ai",endpoint:"/changelog/audit-log/distinct-values"},query:{externalResourceId:m.length>0?m:[""],paginationLimit:10},sidebar:{config:{showAnalystFilter:!0,showDateFilter:!0,showChangeTitleFilter:!0,showImpactPercentage:!1},labels:{title:"Filters",multiSelectLabel:"Modified By",multiSelectHint:"Filter by the user who made the change",changeTitleLabel:"Change Action",changeTitleHint:"Filter by Actions"}},table:{tableProps:{scrollable:!0,scrollHeight:"80vh",showGridlines:!0,size:"small",rowClassName:function(){return"custom-compact-row"},pt:{bodyCell:{style:{paddingTop:"4px",paddingBottom:"4px"}}}},hiddenColumns:["actions","changeSummary","changeDateTime","logId"],extraColumns:[{key:"modifiedBy",header:"Modified By",body:function(o){return t("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[i(l,{size:16,color:"#64748b",style:{flexShrink:0}}),i("span",e({style:{fontWeight:500}},{children:o.modifiedBy}))]}))},style:{width:"15%",minWidth:"140px"}},{key:"changeAction",header:"Action",body:function(t){var o,n,r=(o=t.changeTitle,(n=(o||"").toUpperCase()).includes("CREATE")?{color:"#2e7d32",backgroundColor:"#edf7ed",borderColor:"#c8e6c9",boxShadow:"0 1px 2px rgba(46, 125, 50, 0.08)"}:n.includes("UPDATE")||n.includes("TOGGLE")?{color:"#1565c0",backgroundColor:"#e3f2fd",borderColor:"#bbdefb",boxShadow:"0 1px 2px rgba(21, 101, 192, 0.08)"}:n.includes("DELETE")?{color:"#c62828",backgroundColor:"#fdeeed",borderColor:"#ffcdd2",boxShadow:"0 1px 2px rgba(198, 40, 40, 0.08)"}:{color:"#475569",backgroundColor:"#f8fafc",borderColor:"#cbd5e1",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.06)"}),l=t.changeTitle?t.changeTitle.replace(/_/g," "):"—";return i("span",e({style:{color:r.color,backgroundColor:r.backgroundColor,border:"1px solid ".concat(r.borderColor),boxShadow:r.boxShadow,padding:"6px 12px",borderRadius:"999px",fontSize:"12px",lineHeight:1,fontWeight:600,display:"inline-block",minWidth:"76px",textAlign:"center",textTransform:"capitalize"}},{children:l}))},style:{width:"15%",textAlign:"center"}},{key:"customChangeSummary",header:"Change Summary",body:function(o){var n;return t("div",e({style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"4px 0"}},{children:[i(a,{size:16,color:"#94a3b8",style:{flexShrink:0,marginTop:"2px"}}),i("span",e({style:{color:"#334155",fontSize:"13px",lineHeight:1.5}},{children:null!==(n=o.actionText)&&void 0!==n?n:""}))]}))},style:{width:"30%",minWidth:"200px"}},{key:"redirectLink",header:"Link",body:function(o){var n,r=(null===(n=o.metadata)||void 0===n?void 0:n.redirect_url)||o.redirect_url;return r?i("div",e({style:{display:"flex",justifyContent:"center",alignItems:"center"}},{children:t("a",e({href:r,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"6px",color:"#2563eb",textDecoration:"none",fontWeight:500,fontSize:"13px"}},{children:["View ",i(d,{size:14})]}))})):i("span",e({style:{color:"#94a3b8",display:"flex",justifyContent:"center"}},{children:"—"}))},style:{width:"10%",minWidth:"90px",textAlign:"center"}},{key:"customChangeDateTime",header:"Change Time and Date",body:function(o){if(!o.actionDate)return i("span",e({style:{color:"#94a3b8"}},{children:"—"}));var n=new Date(o.actionDate),r=n.toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),l=n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});return t("div",e({style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",fontSize:"13px",color:"#475569"}},{children:[i("span",e({style:{fontWeight:500}},{children:r})),i("span",{children:l})]}))},style:{width:"15%",minWidth:"150px",textAlign:"center"}}]},filters:{config:{showFilterButton:!0,showSort:!0,showDate:!0,showSearch:!0,sortOptions:{latest:!0,oldest:!0,impactHighToLow:!1,impactLowToHigh:!1}}}})]}))};export{c as default};
1
+ import{__assign as e}from"tslib";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as i,useMemo as n,useEffect as a}from"react";import{AuditLog as r}from"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import{User as l,ExternalLink as c}from"lucide-react";import s from"./ChangeLogDiff.js";import{dt as d}from"../store/useLMSConfigStore.js";import p from"../RBAC/AccessPanel.module.css.js";import{usePermissionsStore as h}from"../store/usePermissionsStore.js";import g from"../store/useEnvStore.js";import{useConfigStore as u}from"../store/useConfigStore.js";var m=function(m){var f=m.configId,b=m.ruleData,y=m.scopeId,x=m.scopeName,v=(null==x?void 0:x.trim())||"Selected",w=i("scope"),C=w[0],S=w[1];u.getState().configuration;var T=h(function(e){return e.hasPermission}),L=g(function(e){var o;return(null===(o=e.rbacConfig)||void 0===o?void 0:o.applicationResourceId)||""}),A=Boolean(y&&T("ilotj.scope.changeLog.view",y)),k=Boolean(L&&T("ilotj.application.changeLog.view",L)),D=n(function(){var e=[];return y&&e.push(y),e},[b,y]);a(function(){console.log("Flattened External Resource IDs:",D)},[D]);var I={configId:f,getData:{baseUrl:window.location.origin.includes("local")?"https://dev.appmod.ai":window.location.origin,endpoint:"/changelog/audit-log/fetch"},distinctValuesApi:{baseUrl:window.location.origin.includes("local")?"https://dev.appmod.ai":window.location.origin,endpoint:"/changelog/audit-log/distinct-values"},sidebar:{config:{showAnalystFilter:!0,showDateFilter:!0,showChangeTitleFilter:!0,showImpactPercentage:!1},labels:{title:"Filters",multiSelectLabel:"Modified By",multiSelectHint:"Filter by the user who made the change",changeTitleLabel:"Change Action",changeTitleHint:"Filter by Actions"}},table:{tableProps:{scrollable:!0,scrollHeight:"80vh",showGridlines:!0,size:"small",rowClassName:function(){return"custom-compact-row"},pt:{bodyCell:{style:{paddingTop:"4px",paddingBottom:"4px"}}}},hiddenColumns:["actions","changeSummary","changeDateTime","logId"],extraColumns:[{key:"modifiedBy",header:"Modified By",body:function(i){return o("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[t(l,{size:16,color:"#64748b",style:{flexShrink:0}}),t("span",e({style:{fontWeight:500}},{children:i.modifiedBy}))]}))},style:{width:"15%",minWidth:"140px"}},{key:"changeAction",header:"Action",body:function(o){var i,n,a=(i=o.changeTitle,(n=(i||"").toUpperCase()).includes("CREATE")?{color:"#2e7d32",backgroundColor:"#edf7ed",borderColor:"#c8e6c9",boxShadow:"0 1px 2px rgba(46, 125, 50, 0.08)"}:n.includes("UPDATE")||n.includes("TOGGLE")?{color:"#1565c0",backgroundColor:"#e3f2fd",borderColor:"#bbdefb",boxShadow:"0 1px 2px rgba(21, 101, 192, 0.08)"}:n.includes("DELETE")?{color:"#c62828",backgroundColor:"#fdeeed",borderColor:"#ffcdd2",boxShadow:"0 1px 2px rgba(198, 40, 40, 0.08)"}:{color:"#475569",backgroundColor:"#f8fafc",borderColor:"#cbd5e1",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.06)"}),r=o.changeTitle?o.changeTitle.replace(/_/g," "):"—";return t("span",e({style:{color:a.color,backgroundColor:a.backgroundColor,border:"1px solid ".concat(a.borderColor),boxShadow:a.boxShadow,padding:"6px 12px",borderRadius:"999px",fontSize:"12px",lineHeight:1,fontWeight:600,display:"inline-block",minWidth:"76px",textAlign:"center",textTransform:"capitalize"}},{children:r}))},style:{width:"15%",textAlign:"center"}},{key:"customChangeSummary",header:"Change Summary",body:function(e){var o;return t(s,{change:null!==(o=e.actionText)&&void 0!==o?o:"-"})},style:{width:"30%",minWidth:"200px"}},{key:"redirectLink",header:"Link",body:function(i){var n,a=(null===(n=i.metadata)||void 0===n?void 0:n.redirect_url)||i.redirect_url;return a?t("div",e({style:{display:"flex",justifyContent:"center",alignItems:"center"}},{children:o("a",e({href:a,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"6px",color:"#2563eb",textDecoration:"none",fontWeight:500,fontSize:"13px"}},{children:["View ",t(c,{size:14})]}))})):t("span",e({style:{color:"#94a3b8",display:"flex",justifyContent:"center"}},{children:"—"}))},style:{width:"10%",minWidth:"90px",textAlign:"center"}},{key:"customChangeDateTime",header:"Change Time and Date",body:function(i){if(!i.actionDate)return t("span",e({style:{color:"#94a3b8"}},{children:"—"}));var n=new Date(i.actionDate),a=n.toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),r=n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});return o("div",e({style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",fontSize:"13px",color:"#475569"}},{children:[t("span",e({style:{fontWeight:500}},{children:a})),t("span",{children:r})]}))},style:{width:"15%",minWidth:"150px",textAlign:"center"}}]},filters:{config:{showFilterButton:!0,showSort:!0,showDate:!0,showSearch:!0,sortOptions:{latest:!0,oldest:!0,impactHighToLow:!1,impactLowToHigh:!1}}}};return t("div",e({style:{height:"100%",overflowY:"auto"}},{children:o("div",e({style:{padding:"24px",fontFamily:"Arial, sans-serif"}},{children:[o("div",e({style:{marginBottom:"16px",paddingBottom:"4px"}},{children:[t("h1",e({style:{margin:0,color:"#334155",fontSize:"20px",fontWeight:700,lineHeight:1.25}},{children:d("history.title","".concat(v," - Audit Log"),{scope_name:v})})),t("p",e({style:{margin:"8px 0 0",color:"#667085",fontSize:"16px",fontWeight:500,lineHeight:1}},{children:d("history.subtitle","Track all learning updates and modifications with the ".concat(v," scope."),{scope_name:v})}))]})),o("div",e({className:p.accessTabs,role:"tablist","aria-label":"Audit log level"},{children:[t("button",e({type:"button",role:"tab","aria-selected":"scope"===C,className:"".concat(p.accessTab," ").concat("scope"===C?p.accessTabActive:""),onClick:function(){return S("scope")},disabled:!A,title:A?"":"You do not have permission to view scope level change log"},{children:d("history.scopeLevel","Scope Level")})),t("button",e({type:"button",role:"tab","aria-selected":"application"===C,className:"".concat(p.accessTab," ").concat("application"===C?p.accessTabActive:""),onClick:function(){return S("application")},disabled:!k,title:k?"":"You do not have permission to view application level change log"},{children:d("history.applicationLevel","Application Level")}))]})),"scope"===C?t(r,e({},I,{query:{externalResourceId:D.length>0?D:[""],paginationLimit:10}}),"scope-audit-log"):t(r,e({},I,{query:{externalResourceId:[],paginationLimit:10}}),"application-audit-log")]}))}))};export{m as default};
2
2
  //# sourceMappingURL=AuditLog.js.map
@@ -0,0 +1,2 @@
1
+ import{__assign as e,__spreadArray as r}from"tslib";import{jsx as n,jsxs as t,Fragment as a}from"react/jsx-runtime";import{useState as i}from"react";import{Layers as o,BookOpen as l,GitBranch as d,ChevronUp as c,ChevronDown as p}from"lucide-react";var f={scope:{label:"Scope",icon:n(o,{size:11}),accent:"#6d28d9",accentBg:"#f5f3ff",accentBorder:"#ddd6fe"},learning:{label:"Learning",icon:n(l,{size:11}),accent:"#1d4ed8",accentBg:"#eff6ff",accentBorder:"#bfdbfe"},variant:{label:"Variant",icon:n(d,{size:11}),accent:"#b45309",accentBg:"#fffbeb",accentBorder:"#fde68a"}},s={label:"Change",icon:null,accent:"#475569",accentBg:"#f8fafc",accentBorder:"#e2e8f0"},u={created:{label:"Created",color:"#15803d",bg:"#f0fdf4",border:"#bbf7d0"},updated:{label:"Updated",color:"#92400e",bg:"#fffbeb",border:"#fde68a"},deleted:{label:"Deleted",color:"#b91c1c",bg:"#fef2f2",border:"#fecaca"}},g=function(e,n){var t=new Set(r(r([],Object.keys(e),!0),Object.keys(n),!0));return Array.from(t).filter(function(r){var t,a;return String(null!==(t=e[r])&&void 0!==t?t:"")!==String(null!==(a=n[r])&&void 0!==a?a:"")})},b=function(e,r){void 0===r&&(r=28);var n=Array.isArray(e)?e.join(", "):String(null!=e?e:"—");return n.length>r?n.slice(0,r)+"…":n||"—"},x=function(r){var t=r.cols;return n("div",e({style:{display:"grid",gridTemplateColumns:t.map(function(){return"1fr"}).join(" "),gap:"6px",padding:"2px 6px 4px",fontSize:"9px",fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.07em",borderBottom:"1px solid #e2e8f0",marginBottom:"2px"}},{children:t.map(function(e){return n("span",{children:e},e)})}))},h=function(r){var a=r.label,i=r.value,o=r.mode;return t("div",e({style:{display:"grid",gridTemplateColumns:"1fr 1.4fr",gap:"6px",alignItems:"start",padding:"3px 6px",borderRadius:"5px",fontSize:"11px",lineHeight:1.4}},{children:[n("span",e({style:{color:"#64748b",fontWeight:500}},{children:a})),n("span",e({style:{color:"created"===o?"#15803d":"#b91c1c",background:"created"===o?"#f0fdf4":"#fef2f2",border:"1px solid ".concat("created"===o?"#bbf7d0":"#fecaca"),borderRadius:"4px",padding:"1px 5px",wordBreak:"break-word",fontWeight:500},title:Array.isArray(i)?i.join(", "):String(null!=i?i:"—")},{children:b(i)}))]}))},y=function(r){var a=r.label,i=r.before,o=r.after,l=r.changed;return t("div",e({style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"6px",alignItems:"start",padding:"3px 6px",borderRadius:"5px",background:l?"rgba(255,251,235,0.7)":"transparent",fontSize:"11px",lineHeight:1.4}},{children:[n("span",e({style:{color:"#64748b",fontWeight:500}},{children:a})),n("span",e({style:{color:l?"#b91c1c":"#94a3b8",background:l?"#fff1f0":"transparent",border:l?"1px solid #fecaca":"none",borderRadius:"4px",padding:l?"1px 5px":"0",textDecoration:l?"line-through":"none",wordBreak:"break-word",opacity:l?1:.6},title:Array.isArray(i)?i.join(", "):String(null!=i?i:"—")},{children:b(i)})),n("span",e({style:{color:l?"#15803d":"#475569",background:l?"#f0fdf4":"transparent",border:l?"1px solid #bbf7d0":"none",borderRadius:"4px",padding:l?"1px 5px":"0",fontWeight:l?600:400,wordBreak:"break-word"},title:Array.isArray(o)?o.join(", "):String(null!=o?o:"—")},{children:b(o)}))]}))},v=function(i){var o=i.mode,l=i.before,d=i.after,c=Array.from(new Set(r(r([],Object.keys(l),!0),Object.keys(d),!0))),p=g(l,d);if(0===c.length)return n("span",e({style:{fontSize:"11px",color:"#94a3b8",padding:"4px 6px"}},{children:"No details available"}));var f=c;return t(a,{children:[n(x,"updated"===o?{cols:["Field","Before","After"]}:{cols:["Field","created"===o?"Value":"Was"]}),f.map(function(e){return"updated"===o?n(y,{label:e,before:l[e],after:d[e],changed:p.includes(e)},e):n(h,{label:e,value:"created"===o?d[e]:l[e],mode:o},e)})]})},m=function(r){return n(v,e({},r))},S=function(r){return n(v,e({},r))},k=function(r){return n(v,e({},r))},w=function(a){var o,l,d,b,x,h=a.change,y=i(!1),w=y[0],B=y[1],j=function(e){if(!e)return null;if("object"==typeof e&&e.data)return e;if("string"==typeof e)try{var r=JSON.parse(e);if(null==r?void 0:r.data)return r}catch(e){return null}return null}(h);if(!j)return n("span",e({style:{color:"#334155",fontSize:"13px",lineHeight:1.5}},{children:"string"==typeof h?h:"—"}));var T=j.action,z=j.data,W=null!==(o=null==z?void 0:z.before)&&void 0!==o?o:{},A=null!==(l=null==z?void 0:z.after)&&void 0!==l?l:{},D=function(e,r){var n=e&&Object.keys(e).length>0,t=r&&Object.keys(r).length>0;return n&&t?"updated":t?"created":"deleted"}(W,A),O=null!==(b=null===(d=null==z?void 0:z.type)||void 0===d?void 0:d.toLowerCase())&&void 0!==b?b:"",R=null!==(x=f[O])&&void 0!==x?x:s,C=u[D],H=g(W,A),I=Array.from(new Set(r(r([],Object.keys(W),!0),Object.keys(A),!0))),L=I.length>0,V=function(e,r,n,t){var a="deleted"===r?n:t;switch(e){case"scope":return"Name: ".concat((null==a?void 0:a.name)||"—",", Description: ").concat((null==a?void 0:a.description)||"—",", Type: ").concat((null==a?void 0:a.scopeType)||"—");case"learning":return"Title: ".concat((null==a?void 0:a.LearningTitle)||"—",", Tier: ").concat((null==a?void 0:a.Tier)||"—");case"variant":return"Title: ".concat((null==a?void 0:a.Learning)||"—",", Description: ").concat((null==a?void 0:a["Variant Description"])||(null==a?void 0:a.VariantDescription)||(null==a?void 0:a.Description)||"—",", Tier: ").concat((null==a?void 0:a.Tier)||"—");default:return"Details available in table below."}}(O,D,W,A),N={mode:D,before:W,after:A};return t("div",e({style:{display:"flex",flexDirection:"column",gap:"8px",minWidth:0,padding:"4px 0"}},{children:[t("div",e({style:{display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"}},{children:[t("span",e({style:{display:"inline-flex",alignItems:"center",gap:"3px",fontSize:"11px",fontWeight:600,color:R.accent,background:R.accentBg,border:"1px solid ".concat(R.accentBorder),borderRadius:"999px",padding:"2px 8px"}},{children:[R.icon,R.label]})),n("span",e({style:{fontSize:"11px",fontWeight:700,color:R.accent,background:R.accentBg,border:"1px solid ".concat(R.accentBorder),borderRadius:"999px",padding:"2px 8px",whiteSpace:"nowrap"}},{children:T})),t("span",e({style:{fontSize:"11px",fontWeight:600,color:C.color,background:C.bg,border:"1px solid ".concat(C.border),borderRadius:"999px",padding:"2px 8px",whiteSpace:"nowrap"}},{children:[C.label,"updated"===D&&H.length>0&&" · ".concat(H.length," field").concat(1!==H.length?"s":"")]}))]})),n("div",e({style:{fontSize:"13px",color:"#1e293b",fontWeight:400,lineHeight:1.5,marginLeft:"2px"}},{children:V})),L&&t("button",e({onClick:function(){return B(function(e){return!e})},style:{display:"inline-flex",alignItems:"center",gap:"4px",background:"none",border:"none",cursor:"pointer",color:R.accent,fontSize:"11px",fontWeight:600,padding:"2px",alignSelf:"flex-start",marginTop:"-2px"}},{children:[n(w?c:p,{size:13}),w?"Hide diff table":"Show details (".concat(I.length," fields)")]})),w&&L&&n("div",e({style:{display:"flex",flexDirection:"column",gap:"2px",background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:"8px",padding:"6px 4px 4px",overflow:"hidden",marginTop:"4px"}},{children:function(){switch(O){case"scope":return n(m,e({},N));case"learning":return n(S,e({},N));case"variant":return n(k,e({},N));default:return n(v,e({},N))}}()}))]}))};export{w as default};
2
+ //# sourceMappingURL=ChangeLogDiff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChangeLogDiff.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -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 L,deleteRuleSet as A,requestAccess as O}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as w,setQueryParams as I}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 k from"./store/useEnvStore.js";import{useConfigStore as D}from"./store/useConfigStore.js";import{TooltipProvider as _}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=this,K=u.userDetails,V=u.llmStudioUrl,W=u.audacyBackendUrl,Y=u.ilLabels,J=u.config,X=u.rbacConfig,Z=u.auditLogConfig,$=u.app_integration_id,ee=u.backwardCompatibility,te=void 0!==ee&&ee,ne=m(function(e){return e.selectedRuleSetId}),re=m(function(e){return e.setSelectedRuleSetId}),oe=m(function(e){return e.error}),se=m(function(e){return e.setError}),ie=m(function(e){return e.setStations}),ae=m(function(e){return e.scopeTreeData}),le=m(function(e){return e.setScopeTreeData}),ce=a({isOpen:!1,type:"GLOBAL"}),ue=ce[0],de=ce[1],pe=a(!1),me=pe[0],fe=pe[1],ve=a(!1),ge=ve[0],he=ve[1],ye=a("learnings"),Se=ye[0],be=ye[1],Ce=a(null),Te=Ce[0],Ee=Ce[1],Le=a(null),Ae=Le[0],Oe=Le[1],we=l(null),Ie=l(null),Re=l(null),je=y();je.user;var Ne=je.setUser,ke=D(),De=ke.setConfig,_e=ke.setIlLabels,Pe=e([{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},t({type:"SCOPE",label:"Scope"},!te&&{addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"})],te?[]:[{type:"SUBSCOPE",label:"Subscope"}],!0),Ue=function(){try{return F()}catch(e){return{search:""}}}();c(function(){var e=new URLSearchParams(window.location.search),t=e.get(w.RULESET_ID),n=e.get(w.SECTION),r=n&&z.has(n)?n:"learnings";(null==t?void 0:t.length)&&re&&be&&(re(t),be(r))},[null==Ue?void 0:Ue.search,be,re]);var Ge=U(function(e){return e.fetchPermissions}),Me=U(function(e){return e.hasPermission}),Be=G(function(e){return e.setRoles}),Fe=k(function(e){return e.appsecRbacUrl})===X.appsecRbacUrl,qe=M(X.applicationId,Fe).data;c(function(){qe&&Be(qe.map(function(e){return{_id:e._id,name:e.name}}))},[qe,Be]),c(function(){var e;console.log("userDetails",K),Ne(K),console.log("llmStudioUrl",V),console.log("audacyBackendUrl",W),k.getState().setLlmStudioUrl(V),k.getState().setAudacyBackendUrl(W),k.getState().setRbacConfig(X),k.getState().setAuditLogConfig(Z),De(J),_e(Y),m.getState().setAppIntegrationId(null!=$?$:null),m.getState().setBackwardCompatibility(te),m.getState().setToken(null!==(e=K.accessToken)&&void 0!==e?e:null)},[K,Ne,V,W,X,Z,J,De,Y,_e,$,te]),c(function(){(null==K?void 0:K.accessToken)&&V&&S()},[$,null==K?void 0:K.accessToken,V]);var xe=function(e){return void 0===e&&(e=!0),n(p,void 0,void 0,function(){var n,o,s,i,a,l;return r(this,function(r){switch(r.label){case 0:e&&fe(!0),se(null),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Ge(X.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($,K.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))?(Ee(null),le({data:i}),Ie.current?(re(Ie.current),be("learnings"),Ie.current=null):m.getState().selectedRuleSetId||re(i.id)):(Ee(null!==(l=s.id)&&void 0!==l?l:null),le(null)):(Ee(null),le(null))),[3,6];case 4:return a=r.sent(),console.error("Failed to fetch rule sets or permissions",a),se("Failed to load data. Please try again later."),[3,6];case 5:return fe(!1),[7];case 6:return[2]}})})};c(function(){var e;(null===(e=null==K?void 0:K.accessToken)||void 0===e?void 0:e.length)&&Fe?xe(!0):console.warn("Error: Trying to fetch rules without access token",K)},[null==K?void 0:K.accessToken,se,ie,X.applicationId,Fe]);var He=function(e){return n(p,void 0,void 0,function(){var n,s,i,a;return r(this,function(r){switch(r.label){case 0:he(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),ue.scopeId?[4,L({scope_id:ue.scopeId,scope_name:e})]:[2];case 2:return r.sent(),[4,xe(!0)];case 3:return r.sent(),de(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=Re.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 he(!1),[7];case 6:return[2]}})})},Qe=function(e,o,s){return n(p,void 0,void 0,function(){var n,o,s,i,a,l,c,u;return r(this,function(r){switch(r.label){case 0:he(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,A(e,K.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],re(s),be("learnings"))),[4,xe(!0)];case 3:return r.sent(),de(function(e){return t(t({},e),{isOpen:!1})}),null===(a=Re.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=Re.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 he(!1),[7];case 6:return[2]}})})},ze=ae,Ke=Ae?{data:{id:Ae.stationId,name:Ae.stationName,type:"STATION",metrics:{learningsCount:Ae.learningsCount,stationsCount:0},children:[]}}:ze,Ve=!!(null==Ke?void 0:Ke.data);null===(d=null==Ke?void 0:Ke.data)||void 0===d||d.type;var We=U(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",X.applicationResourceId||""),Ye=(Ae?Q.filter(function(e){return"stations"!==e.id}):Q).filter(function(e){return!(!te&&"access"===e.id)});return o(_,{children:s("div",t({className:v.learningManagementContainer},{children:[o("div",t({className:v.mainWrapper},{children:me?o(j,{}):oe?s("div",t({className:v.errorContainer},{children:[o("div",t({className:v.errorTitle},{children:"Error Loading Data"})),o("p",t({className:v.errorDesc},{children:oe})),o("button",t({onClick:function(){return xe(!0)},className:v.tryAgainBtn},{children:"Try Again"}))]})):Ve?o(g,{onOpenCreateModal:function(){return de({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return de({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return de({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(e,t,o){return n(p,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,Qe(e)];case 1:return r.sent(),[3,3];case 2:de({isOpen:!0,type:"DELETE",scopeId:e,initialName:t,isSubscope:i}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return Me("ilotj.scope.delete",e)},canEditScope:function(e){return Me("ilotj.scope.edit",e)},canCreateScope:function(e){return Me("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),I(((n={})[w.SECTION]="learnings"===t?null:t,n)),be(t),re(e)},activeSectionId:Se,scopeTreeData:Ke,sectionsConfig:Ye,onViewStation:function(e){we.current=ne,Oe(e),be("learnings"),re(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(Ie.current=t),xe(e)},nodeTypesConfig:Pe,app_integration_id:$,token:K.accessToken}):o(h,{onCreate:function(){return de({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:We,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return n(p,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)||Te))return null===(i=Re.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,O(e)];case 2:return r.sent(),null===(a=Re.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=Re.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:Re,pt:{root:{style:{zIndex:9999}}}}),te&&ue.isOpen&&"DELETE"!==ue.type&&"RENAME"!==ue.type?o(P,{isOpen:!0,onClose:function(){return de(t(t({},ue),{isOpen:!1}))},onSubmit:function(e){return n(p,void 0,void 0,function(){var n,o,s,i,a,l,c,u,d,p,f,v,g,h,y,S,b,L,A,O;return r(this,function(r){switch(r.label){case 0:he(!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"===ue.type&&ue.parentId,a=i?"genreRuleSet":ue.type,o={topic:a,scope_reference_id:null,scopeDescription:"demo",parentScopeId:ue.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:$}),[4,E(o,K.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(Ie.current=c,u=n&&(null===(y=o.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),d=!n&&"GLOBAL"!==ue.type&&ue.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:ue.parentId))return[3,10];if(!te)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:$||"",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,xe(!0)];case 11:return r.sent(),de(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===(L=Re.current)||void 0===L||L.show({severity:"error",summary:"Creation Failed",detail:(null===(O=null===(A=null==g?void 0:g.response)||void 0===A?void 0:A.data)||void 0===O?void 0:O.message)||"There was an error creating the scope. Please try again."}),g;case 13:return he(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ve,canCreateGlobal:We}):s(i,{children:[o(B,{isOpen:ue.isOpen&&"DELETE"!==ue.type&&"RENAME"!==ue.type,onClose:function(){return de(t(t({},ue),{isOpen:!1}))},onCreate:function(e){return He(null!=e?e:"")},hasGlobalRuleSet:Ve}),o(H,{isOpen:ue.isOpen&&"RENAME"===ue.type,onClose:function(){return de(t(t({},ue),{isOpen:!1}))},onSave:He,initialName:ue.initialName})]}),o(R,{isOpen:ue.isOpen&&"DELETE"===ue.type,onCancel:function(){return de(t(t({},ue),{isOpen:!1}))},onConfirm:function(){return Qe(ue.scopeId,ue.initialName,ue.isSubscope)},title:"Delete Scope",description:s(i,{children:["Deleting ",o("span",t({className:v.highlight},{children:ue.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:ge})]}))})}export{K as default};
1
+ import{__assign as e,__spreadArray as t,__awaiter as n,__generator as r}from"tslib";import{jsx as o,jsxs as s,Fragment as a}from"react/jsx-runtime";import{useState as i,useRef as c,useEffect as l}from"react";import{BookOpen as u,Users as d,History as p}from"lucide-react";import{useLearningTemplateStore as m}from"./store/useLearningTemplateStore.js";import{Toast as f}from"primereact/toast";import v from"./styles/LearningTemplateManagement.module.css.js";import g from"./LearningTemplateLayout.js";import h from"./components/EmptyLearningState.js";import S from"./store/useAuthStore.js";import{fetchTiers as y,getILInstance as b,fetchScopes as C,inheritScope as T,inheritScopeBackwardCompatible as A,createRuleSet as L,renameScope as E,deleteRuleSet as I,requestAccess as R}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as w,setQueryParams as O}from"./hooks/useLearningTemplateQueryParams.js";import j from"./components/ConfirmationModal.js";import N from"./components/LearningTemplateManagementSkeleton.js";import{findNodeById as _,findNodePathById as D}from"./utils/treeUtils.js";import k from"./store/useEnvStore.js";import{useConfigStore as M}from"./store/useConfigStore.js";import{TooltipProvider as B}from"./components/ToolTip.js";import P from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as U}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as q}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as G}from"./queries/useApprovalQueries.js";import{useLMSConfigQuery as F}from"./queries/useLMSConfigQuery.js";import x from"./RuleContent/AddScopeModal.js";import H from"./components/RuleContentSkeleton.js";import Q from"./components/ErrorStateDisplay.js";import{useLocation as z}from"react-router-dom";import K from"./shared/SuccessToastContent.js";import V from"./shared/ErrorToastContent.js";import W from"./RuleContent/RenameScopeModal.js";import{dt as Y}from"./store/useLMSConfigStore.js";import{MIDDLE_DRAWER_DT_PATH as J,MIDDLE_DRAWER_CONTEXT_MENU_DT_PATH as X,EMPTY_STATE_DT_PATH as Z}from"./constants.js";function $($){var ee,te,ne,re=this,oe=$.userDetails,se=$.llmStudioUrl,ae=$.audacyBackendUrl,ie=$.ilLabels,ce=$.config,le=$.rbacConfig,ue=$.auditLogConfig,de=$.app_integration_id,pe=$.backwardCompatibility,me=void 0!==pe&&pe,fe=$.modeId,ve=$.modeDetails;m(function(e){return e.selectedRuleSetId});var ge=m(function(e){return e.setSelectedRuleSetId}),he=m(function(e){return e.error}),Se=m(function(e){return e.setError}),ye=m(function(e){return e.setStations}),be=m(function(e){return e.scopeTreeData}),Ce=m(function(e){return e.setScopeTreeData}),Te=i({isOpen:!1,type:"GLOBAL"}),Ae=Te[0],Le=Te[1],Ee=i(!1),Ie=Ee[0],Re=Ee[1],we=i(!1),Oe=we[0],je=we[1],Ne=i("learnings"),_e=Ne[0],De=Ne[1],ke=i(null),Me=ke[0],Be=ke[1],Pe=i(null),Ue=Pe[0];Pe[1];var qe=i(!1),Ge=qe[0],Fe=qe[1],xe=i(!1),He=xe[0],Qe=xe[1];c(null);var ze=c(null),Ke=c(!1),Ve=c(null),We=S();We.user;var Ye=We.setUser,Je=M(),Xe=Je.setConfig,Ze=Je.setIlLabels,$e=function(){try{return z()}catch(e){return{search:""}}}();l(function(){if(!Ke.current){var e=new URLSearchParams(window.location.search),t=e.get(w.RULESET_ID),n=e.get(w.SECTION),r=n&&Ct.has(n)?n:"learnings";(null==t?void 0:t.length)&&ge&&De&&(ge(t),De(r),Ke.current=!0)}},[null==$e?void 0:$e.search,De,ge]);var et=U(function(e){return e.fetchPermissions}),tt=U(function(e){return e.hasPermission}),nt=q(function(e){return e.setRoles}),rt=k(function(e){return e.appsecRbacUrl})===le.appsecRbacUrl,ot=G(le.applicationId,rt).data,st=F(null!=de?de:"",me),at=st.isLoading,it=st.isError,ct=st.refetch;st.isSuccess;var lt=i(0),ut=lt[0],dt=lt[1];l(function(){if(!me&&de&&se){n(re,void 0,void 0,function(){var e,t,n,o,s,a;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,b(de)];case 1:return e=r.sent(),"number"==typeof(t=null===(a=null===(s=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.learningManagement)||void 0===s?void 0:s.scopeAndHierarchy)||void 0===a?void 0:a.maxHierarchyLevels)&&t>0&&dt(t-1),[3,3];case 2:return n=r.sent(),console.error("Failed to fetch IL instance for hierarchy levels:",n),[3,3];case 3:return[2]}})})}},[de,se]),l(function(){ot&&nt(ot.map(function(e){return{_id:e._id,name:e.name}}))},[ot,nt]),l(function(){var e;console.log("userDetails",oe),Ye(oe),console.log("llmStudioUrl",se),console.log("audacyBackendUrl",ae),k.getState().setLlmStudioUrl(se),k.getState().setAudacyBackendUrl(ae),k.getState().setRbacConfig(le),k.getState().setAuditLogConfig(ue),k.getState().setBaseModeName((null==ve?void 0:ve.modeNameFromURL)||null),Xe(ce),Ze(ie),m.getState().setAppIntegrationId(null!=de?de:null),m.getState().setBackwardCompatibility(me),m.getState().setToken(null!==(e=null==oe?void 0:oe.accessToken)&&void 0!==e?e:null)},[oe,Ye,se,ae,le,ue,ce,Xe,ie,Ze,de,me,ve]),l(function(){(null==oe?void 0:oe.accessToken)&&se&&y()},[de,null==oe?void 0:oe.accessToken,se]);var pt=function(t){return void 0===t&&(t=!0),n(re,void 0,void 0,function(){var n,o,s,a,i,c,l,u;return r(this,function(r){switch(r.label){case 0:t&&Re(!0),Se(null),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,et(le.applicationId)];case 2:return r.sent(),n=function(t){if(!U.getState().hasPermission("ilotj.scope.view",t.id))return null;var r=t.children?t.children.map(function(e){return n(e)}).filter(function(e){return null!==e}):[];return e(e({},t),{children:r})},[4,C(de,oe.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?(a=n(s))?(Be(null),Ce({data:a}),ze.current?(ge(ze.current),De("learnings"),ze.current=null):(i=m.getState().selectedRuleSetId,c=i?_(a,i):null,i&&c||ge(a.id))):(Be(null!==(u=s.id)&&void 0!==u?u:null),Ce(null)):(Be(null),Ce(null))),[3,6];case 4:return l=r.sent(),console.error("Failed to fetch rule sets or permissions",l),Se("Failed to load data. Please try again later."),[3,6];case 5:return Re(!1),[7];case 6:return[2]}})})};l(function(){var e;(null===(e=null==oe?void 0:oe.accessToken)||void 0===e?void 0:e.length)&&rt?pt(!0):console.warn("Error: Trying to fetch rules without access token",oe)},[null==oe?void 0:oe.accessToken,Se,ye,le.applicationId,rt]);var mt=function(t,o,s){return n(re,void 0,void 0,function(){var n,o,s,a,i,c,l,u;return r(this,function(r){switch(r.label){case 0:je(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,I(t,oe.accessToken)];case 2:return r.sent(),m.getState().selectedRuleSetId===t&&(n=m.getState().scopeTreeData,(o=D((null==n?void 0:n.data)||null,t))&&o.length>1&&(s=o[o.length-2],ge(s),De("learnings"))),[4,pt(!0)];case 3:return r.sent(),Le(function(t){return e(e({},t),{isOpen:!1})}),null===(i=Ve.current)||void 0===i||i.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return a=r.sent(),console.error("An error occurred during scope deletion.",a),null===(c=Ve.current)||void 0===c||c.show({severity:"error",summary:"Delete Failed",detail:(null===(u=null===(l=null==a?void 0:a.response)||void 0===l?void 0:l.data)||void 0===u?void 0:u.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return je(!1),[7];case 6:return[2]}})})},ft=function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),O(((n={})[w.SECTION]="learnings"===t?null:t,n[w.RULESET_ID]=e,n)),De(t),ge(e)},vt=be,gt=Ue?{data:{id:Ue.stationId,name:Ue.stationName,type:"STATION",metrics:{learningsCount:Ue.learningsCount,stationsCount:0},children:[]}}:vt,ht=!!(null==gt?void 0:gt.data);null===(ee=null==gt?void 0:gt.data)||void 0===ee||ee.type;var St=U(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",le.applicationResourceId||"");if(at)return o("div",e({className:v.learningManagementContainer},{children:o(H,{})}));if(it)return o("div",e({className:v.learningManagementContainer},{children:o(Q,{errorMessage:"Failed to load configuration. Please try again.",onRetry:function(){return ct()},title:"Error Loading Configuration"})}));var yt=t(t([{type:"GLOBAL",label:"Global",addChildLabel:"".concat(Y("".concat(J,".addScope"),"Add Scope")),addChildType:"SCOPE"}],Array.from({length:ut},function(){return e({type:"SCOPE",label:Y("".concat(J,".scope"),"Scope")},!me&&{addChildLabel:Y("".concat(X,".addSubScope"),"Add Subscope"),addChildType:"SUBSCOPE"})}),!0),me?[]:[{type:"SUBSCOPE",label:Y("".concat(J,".subScope"),"Subscope")}],!0),bt=[{id:"learnings",label:Y("".concat(J,".treeMenu.submenu.learnings"),"Learnings"),icon:u,badgeKey:"learningsCount"},{id:"access",label:Y("".concat(J,".treeMenu.submenu.access"),"Access"),icon:d},{id:"history",label:Y("".concat(J,".treeMenu.submenu.changeHistory"),"Change History"),icon:p}],Ct=new Set(bt.map(function(e){return e.id})),Tt=Ue?bt.filter(function(e){return"stations"!==e.id}):bt;return o(B,{children:s("div",e({className:v.learningManagementContainer},{children:[o("div",e({className:v.mainWrapper},{children:Ie?o(N,{}):he?s("div",e({className:v.errorContainer},{children:[o("div",e({className:v.errorTitle},{children:"Error Loading Data"})),o("p",e({className:v.errorDesc},{children:he})),o("button",e({onClick:function(){return pt(!0)},className:v.tryAgainBtn},{children:"Try Again"}))]})):ht?o(g,{onOpenCreateModal:function(){return Le({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return Le({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return Le({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(e,t,o){return n(re,void 0,void 0,function(){var n,s,a;return r(this,function(r){switch(r.label){case 0:return n=m.getState().scopeTreeData,s=D((null==n?void 0:n.data)||null,e),a=!!s&&3===s.length,0!==o?[3,2]:[4,mt(e)];case 1:return r.sent(),[3,3];case 2:Le({isOpen:!0,type:"DELETE",scopeId:e,initialName:t,isSubscope:a}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return tt("ilotj.scope.delete",e)},canEditScope:function(e){return tt("ilotj.scope.edit",e)},canCreateScope:function(e){return tt("ilotj.scope.create",e)},onSectionSelect:ft,activeSectionId:_e,scopeTreeData:gt,sectionsConfig:Tt,onViewStation:function(e){ft(e.stationId,"learnings")},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(ze.current=t),pt(e)},nodeTypesConfig:yt,app_integration_id:de,token:oe.accessToken,modeId:fe}):o(h,{onCreate:function(){return Le({isOpen:!0,type:"GLOBAL"})},title:Y("".concat(Z,".title"),"No Global Scope has been added!"),desc:Y("".concat(Z,".desc"),"Start by creating a Global scope to define base learnings that apply across all stations."),button:Y("".concat(Z,".createGlobalScope"),"Create Global Scope"),canCreateRule:St,noAccessTitle:Y("".concat(Z,".noAccessTitle"),"Access Restricted"),noAccessDesc:Y("".concat(Z,".noAccessDesc"),"You do not have access for this application."),requestAccessButton:Y("".concat(Z,".requestAccessButton"),"Request Access"),requestSentButton:Y("".concat(Z,".requestSentButton"),"Request Sent"),onRequestAccess:function(){return n(re,void 0,void 0,function(){var e,t,n,s,a,i,c,l,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)||Me))return null===(a=Ve.current)||void 0===a||a.show({severity:"error",sticky:!1,className:v.errorToast,content:o(V,{message:"Unable to identify the global scope for this access request."})}),[2];Fe(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,R(e)];case 2:return r.sent(),Qe(!0),null===(i=Ve.current)||void 0===i||i.show({severity:"success",sticky:!1,life:3e3,className:v.successToast,content:o(K,{message:"Access request submitted successfully!"})}),[3,5];case 3:return t=r.sent(),null===(c=Ve.current)||void 0===c||c.show({severity:"error",sticky:!1,className:v.errorToast,content:o(V,{message:(null===(u=null===(l=null==t?void 0:t.response)||void 0===l?void 0:l.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,5];case 4:return Fe(!1),[7];case 5:return[2]}})})},isRequestingAccess:Ge,isAccessRequested:He})})),o(f,{ref:Ve,pt:{root:{style:{zIndex:9999}}}}),me&&Ae.isOpen&&"DELETE"!==Ae.type&&"RENAME"!==Ae.type?o(P,{isOpen:!0,onClose:function(){return Le(e(e({},Ae),{isOpen:!1}))},onSubmit:function(t){return n(re,void 0,void 0,function(){var n,o,s,a,i,c,l,u,d,p,f,v,g,h,S,y,b,C,E,I;return r(this,function(r){switch(r.label){case 0:je(!0),n=m.getState().backwardCompatibility,r.label=1;case 1:return r.trys.push([1,12,13,14]),o=void 0,n&&"object"==typeof t?o=t:(s=t,a="SCOPE"===Ae.type&&Ae.parentId,i=a?"genreRuleSet":Ae.type,o={topic:i,scope_reference_id:null,scopeDescription:"demo",parentScopeId:Ae.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:de}),[4,L(o,oe.accessToken)];case 2:if(c=r.sent(),!(l=null===(h=null==c?void 0:c.data)||void 0===h?void 0:h.scopeId))return[3,10];if(ze.current=l,u=n&&(null===(S=o.topic)||void 0===S?void 0:S.toLowerCase().includes("genre")),d=!n&&"GLOBAL"!==Ae.type&&Ae.parentId,!u&&!d)return[3,10];if(!(p=n?null===(b=null===(y=m.getState().scopeTreeData)||void 0===y?void 0:y.data)||void 0===b?void 0:b.id:Ae.parentId))return[3,10];if(!me)return[3,7];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,A({source_scope_id:p,target_scope_id:l})];case 4:return r.sent(),[3,6];case 5:return f=r.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,6];case 6:return[3,10];case 7:return r.trys.push([7,9,,10]),[4,T({source_scope_id:p,target_scope_id:l,application_mapping_id:de||"",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,pt(!0)];case 11:return r.sent(),Le(function(t){return e(e({},t),{isOpen:!1})}),[3,14];case 12:throw g=r.sent(),console.error("An error occurred during scope creation.",g),null===(C=Ve.current)||void 0===C||C.show({severity:"error",summary:"Creation Failed",detail:(null===(I=null===(E=null==g?void 0:g.response)||void 0===E?void 0:E.data)||void 0===I?void 0:I.message)||"There was an error creating the scope. Please try again."}),g;case 13:return je(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:ht,canCreateGlobal:St,globalScopeId:null!==(ne=null===(te=null==be?void 0:be.data)||void 0===te?void 0:te.id)&&void 0!==ne?ne:null}):s(a,{children:[o(x,{isOpen:Ae.isOpen&&"DELETE"!==Ae.type&&"RENAME"!==Ae.type,onClose:function(){return Le(e(e({},Ae),{isOpen:!1}))},onCreate:function(e){e&&(ze.current=e),pt(!0)},hasGlobalRuleSet:ht,parentId:Ae.parentId}),o(W,{isOpen:Ae.isOpen&&"RENAME"===Ae.type,onClose:function(){return Le(e(e({},Ae),{isOpen:!1}))},onSave:function(t){return n(re,void 0,void 0,function(){var n,s,a,i,c,l;return r(this,function(r){switch(r.label){case 0:je(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),Ae.scopeId?(n=m.getState().backwardCompatibility,s=n?{scope_id:Ae.scopeId,scope_name:t}:{scope_id:Ae.scopeId,scope_type:"Custom",scope_name:t,description:"demo",application_mapping_id:de},[4,E(s,oe.accessToken)]):[2];case 2:return r.sent(),[4,pt(!0)];case 3:return r.sent(),Le(function(t){return e(e({},t),{isOpen:!1})}),[3,6];case 4:throw a=r.sent(),console.error("An error occurred during scope rename.",a),null===(i=Ve.current)||void 0===i||i.show({severity:"error",sticky:!1,className:v.errorToast,content:o(V,{message:(null===(l=null===(c=null==a?void 0:a.response)||void 0===c?void 0:c.data)||void 0===l?void 0:l.message)||"There was an error renaming the scope. Please try again."})}),a;case 5:return je(!1),[7];case 6:return[2]}})})},initialName:Ae.initialName})]}),o(j,{isOpen:Ae.isOpen&&"DELETE"===Ae.type,onCancel:function(){return Le(e(e({},Ae),{isOpen:!1}))},onConfirm:function(){return mt(Ae.scopeId,Ae.initialName,Ae.isSubscope)},title:"Delete Scope",description:s(a,{children:["Deleting ",o("span",e({className:v.highlight},{children:Ae.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:Oe})]}))})}export{$ as default};
2
2
  //# sourceMappingURL=LearningManagement.js.map
@@ -0,0 +1,2 @@
1
+ import"tslib";import"react/jsx-runtime";import"react";import"lucide-react";import"./store/useLearningTemplateStore.js";import"primereact/toast";import"./apis/scopeApis.js";import"./store/usePermissionsStore.js";import"./store/useLMSConfigStore.js";import"./components/ToolTip.js";import"./store/useAuthStore.js";import"@mui/material";import"@mui/icons-material/Check";import"@mui/icons-material/CloseRounded";import{QueryClient as t}from"@tanstack/react-query";import"./store/useEnvStore.js";import"date-fns";import"framer-motion";import"../IL-OTJ/_components/atoms/Textarea/Textarea.js";import"../IL-OTJ/_components/InputDataReasoningCard.js";import"../IL-OTJ/_components/TooltipComponent.js";import"../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js";import"../IL-OTJ/store/CitationsContext.js";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"axios";import"@e-llm-studio/streaming-response";import"@e-llm-studio/watch-me-work";import"../IL-OTJ/_components/ChatComponents/ChatHeader.js";import"remark-gfm";import"../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js";import"../IL-OTJ/_components/CitationLink.js";import"@e-llm-studio/citation";import"@viswa-test/test-citation";import"../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js";import"./store/useConfigStore.js";import"appsec-ui";import"@radix-ui/react-tooltip";import"./components/StationOnboarding/InputField.js";import"./config.js";import"./store/useAppSecRolesStore.js";import"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import"./AuditLog/ChangeLogDiff.js";import"react-router-dom";new t;
2
+ //# sourceMappingURL=LearningManagementTest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LearningManagementTest.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsxs as o,jsx as n}from"react/jsx-runtime";import t from"./RuleContent/RuleContent.js";import i from"./StationsContent/StationsContent.js";import a from"./RBAC/AccessManagementPanel.js";import"appsec-ui";import"./store/useAuthStore.js";import"./store/usePermissionsStore.js";import r from"./store/useEnvStore.js";import s from"./styles/LearningTemplateLayout.module.css.js";import{findNodeById as l}from"./utils/treeUtils.js";import d from"./SidebarWrapper.js";import{useLearningTemplateStore as c}from"./store/useLearningTemplateStore.js";import u from"./components/StationOnboarding/StationOnboardModal.js";import p from"./AuditLog/AuditLog.js";var m=function(m){var f,S,C=m.onOpenCreateModal,v=m.onRefreshRuleSets,g=m.scopeTreeData,h=m.onAddChild,R=m.onRenameChild,j=m.onDeleteChild,A=m.canDeleteScope,D=m.canEditScope,I=m.canCreateScope,M=m.onSectionSelect,O=m.onViewStation,w=m.activeSectionId,y=void 0===w?"learnings":w,L=m.sectionsConfig,T=m.nodeTypesConfig,_=m.app_integration_id,k=m.token,b=c(function(e){return e.isStationModalOpen}),N=c(function(e){return e.setStationModalOpen}),x=c(function(e){return e.selectedRuleSetId}),B=c(function(e){return e.rawAuditRuleData}),E=r(function(e){return e.auditLogConfig});c(function(e){return e.ruleData});var U=x?l((null==g?void 0:g.data)||null,x):null;return Boolean((null===(f=null==g?void 0:g.data)||void 0===f?void 0:f.id)&&x===g.data.id),o("div",e({className:s.container},{children:[n(d,{onOpenCreateModal:C,onRefreshRuleSets:v,scopeTreeData:g,onAddChild:h,onRenameChild:R,onDeleteChild:j,canDeleteScope:A,canEditScope:D,canCreateScope:I,onSectionSelect:M,activeSectionId:y,sectionsConfig:L,nodeTypesConfig:T}),n("div",e({id:"rule-template-layout-content",className:"".concat(s.content," relative flex-1 overflow-hidden")},{children:"stations"===y?n(i,{scopeId:x||"",scopeName:(null==U?void 0:U.name)||"Unknown Scope",stationsCount:null===(S=null==U?void 0:U.metrics)||void 0===S?void 0:S.stationsCount,onViewStation:O}):"access"===y?n(a,{selectedRuleSetId:x,useApplicationModuleForScopeAccess:!1}):"history"===y?(null==E?void 0:E.configId)?n(p,{configId:E.configId,scopeId:x||void 0,scopeName:(null==U?void 0:U.name)||"Unknown Scope",ruleData:B}):null:n(t,{onRefreshRuleSets:v,app_integration_id:_,token:k})})),n(u,{isOpen:b,onClose:function(){N(!1)},onBoardStation:function(e){v(!0,e)},app_integration_id:_,token:k})]}))};export{m as default};
1
+ import{__assign as e}from"tslib";import{jsxs as o,jsx as n}from"react/jsx-runtime";import{useEffect as t}from"react";import i from"./RuleContent/RuleContent.js";import r from"./StationsContent/StationsContent.js";import a from"./RBAC/AccessManagementPanel.js";import"appsec-ui";import"./store/useAuthStore.js";import"./store/usePermissionsStore.js";import s from"./store/useEnvStore.js";import d from"./styles/LearningTemplateLayout.module.css.js";import{findNodeById as l,mapScopeChildrenToStations as c}from"./utils/treeUtils.js";import u from"./SidebarWrapper.js";import{useLearningTemplateStore as p}from"./store/useLearningTemplateStore.js";import m from"./components/StationOnboarding/StationOnboardModal.js";import f from"./AuditLog/AuditLog.js";var S=function(S){var g,v,C=S.onOpenCreateModal,h=S.onRefreshRuleSets,R=S.scopeTreeData,j=S.onAddChild,I=S.onRenameChild,A=S.onDeleteChild,D=S.canDeleteScope,M=S.canEditScope,O=S.canCreateScope,T=S.onSectionSelect,w=S.onViewStation,b=S.activeSectionId,k=void 0===b?"learnings":b,y=S.sectionsConfig,L=S.nodeTypesConfig,_=S.app_integration_id,N=S.token,U=S.modeId,x=p(function(e){return e.isStationModalOpen}),B=p(function(e){return e.setStationModalOpen}),E=p(function(e){return e.isStationOnboardModalTriggered}),P=p(function(e){return e.setIsStationOnboardModalTriggered}),V=p(function(e){return e.selectedRuleSetId}),F=p(function(e){return e.rawAuditRuleData}),W=s(function(e){return e.auditLogConfig});p(function(e){return e.ruleData});var q=V?l((null==R?void 0:R.data)||null,V):null;return Boolean((null===(g=null==R?void 0:R.data)||void 0===g?void 0:g.id)&&V===R.data.id),t(function(){E&&B(!0)},[E,B,P]),o("div",e({className:d.container},{children:[n(u,{onOpenCreateModal:C,onRefreshRuleSets:h,scopeTreeData:R,onAddChild:j,onRenameChild:I,onDeleteChild:A,canDeleteScope:D,canEditScope:M,canCreateScope:O,onSectionSelect:T,activeSectionId:k,sectionsConfig:y,nodeTypesConfig:L}),n("div",e({id:"rule-template-layout-content",className:"".concat(d.content," relative flex-1 overflow-hidden")},{children:"stations"===k?n(r,{scopeId:V||"",scopeName:(null==q?void 0:q.name)||"Unknown Scope",stationsCount:null===(v=null==q?void 0:q.metrics)||void 0===v?void 0:v.stationsCount,stations:c(q),onViewStation:w}):"access"===k?n(a,{selectedRuleSetId:V,scopeName:(null==q?void 0:q.name)||"Unknown Scope",useApplicationModuleForScopeAccess:!1}):"history"===k?(null==W?void 0:W.configId)?n(f,{configId:W.configId,scopeId:V||void 0,scopeName:(null==q?void 0:q.name)||"Unknown Scope",ruleData:F}):null:n(i,{onRefreshRuleSets:h,app_integration_id:_,token:N,modeId:U})})),n(m,{isOpen:x,onClose:function(){B(!1),P(!1)},onBoardStation:function(e){h(!0,e)},app_integration_id:_,token:N})]}))};export{S as default};
2
2
  //# sourceMappingURL=LearningTemplateLayout.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,m=void 0!==d&&d,u=r.scopeName,v=(null==u?void 0:u.trim())||"Selected",f=o("scope"),b=f[0],h=f[1],g=t(function(e){return e.rbacConfig}),A=i(function(e){return e.hasPermission}),S=null==g?void 0:g.applicationResourceId,x=(null==g?void 0:g.applicationModuleId)||(null==g?void 0:g.moduleId),I=m?x:null==g?void 0:g.moduleId,j=Boolean(S&&A("ilotj.scope.access.application.view",S));return c("div",e({className:l.accessManagement},{children:[s("div",e({style:{padding:"24px 24px 0",fontFamily:"Arial, sans-serif"}},{children:c("div",e({style:{marginBottom:"16px",paddingBottom:"4px"}},{children:[s("h1",e({style:{margin:0,color:"#334155",fontSize:"20px",fontWeight:700,lineHeight:1.25}},{children:n("access.title","".concat(v," - Access Management"),{scope_name:v})})),s("p",e({style:{margin:"8px 0 0",color:"#667085",fontSize:"16px",fontWeight:500,lineHeight:1}},{children:n("access.subtitle","Manage users and groups within the ".concat(v," scope."),{scope_name:v})}))]}))})),c("div",e({className:l.accessTabs,role:"tablist","aria-label":"Access level"},{children:[s("button",e({type:"button",role:"tab","aria-selected":"scope"===b,className:"".concat(l.accessTab," ").concat("scope"===b?l.accessTabActive:""),onClick:function(){return h("scope")}},{children:n("access.scopeLevelAccess","Scope Level Access")})),s("button",e({type:"button",role:"tab","aria-selected":"application"===b,className:"".concat(l.accessTab," ").concat("application"===b?l.accessTabActive:""),onClick:function(){return h("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"===b?{resourceId:S,moduleId:x,accessLevel:"application"}:{ruleSetId:p,moduleId:I,accessLevel:"scope"})}))]}))};export{r as default};
2
2
  //# sourceMappingURL=AccessManagementPanel.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as r,jsx as t}from"react/jsx-runtime";import{useState as o,useRef as i,useEffect as l}from"react";import{Search as u,X as a}from"lucide-react";import{useApproverSearchQuery as c,useGroupSearchQuery as d}from"../queries/useApprovalQueries.js";var p={root:{marginLeft:"1.5rem"},sectionLabel:{fontSize:"0.875rem",fontWeight:500,color:"#19213D"},requiredMark:{marginRight:"0.25rem",fontSize:"1rem",fontWeight:600,color:"#8F2C23"},dropdownWrapper:{position:"relative",marginTop:"0.375rem"},inputShell:{display:"flex",minHeight:"38px",width:"100%",cursor:"text",flexWrap:"wrap",alignItems:"center",gap:"0.375rem",borderRadius:"0.375rem",border:"1px solid #E2E8F0",padding:"0.375rem 0.5rem",boxSizing:"border-box",transition:"border-color 150ms ease-in-out, box-shadow 150ms ease-in-out"},searchIcon:{flexShrink:0,color:"#9CA3AF"},chip:{display:"flex",alignItems:"center",gap:"0.25rem",borderRadius:"9999px",backgroundColor:"#EFF6FF",padding:"0.125rem 0.625rem",fontSize:"0.75rem",fontWeight:500,color:"#1D4ED8"},chipRemoveButton:{marginLeft:"0.125rem",border:"none",borderRadius:"9999px",background:"transparent",padding:0,cursor:"pointer",outline:"none"},input:{minWidth:"120px",flex:1,border:"none",backgroundColor:"transparent",fontSize:"0.875rem",color:"#19213D",outline:"none"},dropdown:{position:"absolute",zIndex:50,marginTop:"0.25rem",maxHeight:"12rem",width:"100%",overflowY:"auto",borderRadius:"0.375rem",border:"1px solid #E2E8F0",backgroundColor:"#FFFFFF",padding:"0.25rem 0",listStyle:"none",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",boxSizing:"border-box"},skeletonItem:{padding:"0.5rem 0.75rem"},skeletonLinePrimary:{height:"1rem",width:"75%",borderRadius:"0.25rem",backgroundColor:"#E5E7EB"},skeletonLineSecondary:{height:"0.75rem",width:"50%",borderRadius:"0.25rem",backgroundColor:"#E5E7EB",marginTop:"0.375rem"},checkboxOption:{display:"flex",alignItems:"center",gap:"0.625rem",width:"100%",padding:"0.5rem 0.75rem",cursor:"pointer",boxSizing:"border-box"},checkboxInput:{width:"14px",height:"14px",flexShrink:0,cursor:"pointer",accentColor:"#2563EB",margin:0},optionTitle:{fontSize:"0.875rem",fontWeight:500,color:"#19213D",margin:0},optionSubtitle:{fontSize:"0.75rem",color:"#666F8D",margin:0}},s=function(s){var m=s.selectedApprovers,h=s.selectedGroupOfApprovers,f=s.onApproversChange,g=s.onGroupsChange,b=o(""),v=b[0],y=b[1],x=o(""),k=x[0],F=x[1],E=o(!1),S=E[0],w=E[1],C=i(null),L=i(null),D=o(""),M=D[0],z=D[1],B=o(""),I=B[0],_=B[1],T=o(!1),A=T[0],R=T[1],W=i(null),q=i(null),O=o(!1),P=O[0],j=O[1],G=o(!1),H=G[0],Q=G[1],Y=o(null),J=Y[0],K=Y[1],N=o(null),U=N[0],V=N[1],X=o(null),Z=X[0],$=X[1],ee=o(null),ne=ee[0],re=ee[1];l(function(){if(!v.trim())return F(""),void w(!1);var e=setTimeout(function(){return F(v)},500);return function(){return clearTimeout(e)}},[v]),l(function(){var e=setTimeout(function(){return _(M)},300);return function(){return clearTimeout(e)}},[M]);var te=c(k),oe=te.data,ie=te.isFetching,le=(oe||[]).filter(function(e){return!m.some(function(n){return n.id===e._id})}).slice(0,10).map(function(e){var n,r,t,o;return{id:e._id,email:null!==(n=e.email)&&void 0!==n?n:"",name:(null===(r=e.firstname)||void 0===r?void 0:r.trim())?"".concat(e.firstname," ").concat(null!==(t=e.lastname)&&void 0!==t?t:"").trim():null!==(o=e.email)&&void 0!==o?o:""}});l(function(){k.trim()&&(ie||le.length>0)&&w(!0)},[ie,le.length,k]);var ue=d(I),ae=ue.data,ce=ue.isFetching,de=(ae||[]).filter(function(e){return!h.some(function(n){return n._id===e._id})}).slice(0,10);l(function(){H&&(ce||de.length>0)&&R(!0)},[ce,de.length,H]),l(function(){var e=function(e){C.current&&!C.current.contains(e.target)&&w(!1),W.current&&!W.current.contains(e.target)&&R(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}},[]);return r("div",e({style:p.root},{children:[r("label",e({htmlFor:"approver-search-input",style:p.sectionLabel},{children:[t("span",e({style:p.requiredMark},{children:"*"})),"Select who can Approve"]})),r("div",e({ref:C,style:p.dropdownWrapper},{children:[r("label",e({htmlFor:"approver-search-input",style:e(e({},p.inputShell),{borderColor:P?"#2563EB":"#E2E8F0",boxShadow:P?"0 0 0 1px #2563EB":"none"})},{children:[t(u,{size:14,style:p.searchIcon}),m.map(function(n){return r("span",e({style:p.chip},{children:[n.email,t("button",e({type:"button",onMouseDown:function(e){var r;e.preventDefault(),r=n.id,f(m.filter(function(e){return e.id!==r}))},onMouseEnter:function(){return $(n.id)},onMouseLeave:function(){return $(null)},style:e(e({},p.chipRemoveButton),{backgroundColor:Z===n.id?"#DBEAFE":"transparent"})},{children:t(a,{size:12})}))]}),n.id)}),t("input",{ref:L,id:"approver-search-input",type:"text",value:v,onChange:function(e){return y(e.target.value)},onFocus:function(){j(!0),(le.length>0||ie)&&w(!0)},onBlur:function(){return j(!1)},placeholder:0===m.length?"Search by name or email...":"",style:p.input})]})),S&&(ie||le.length>0)&&t("ul",e({style:p.dropdown},{children:ie?[1,2,3,4].map(function(n){return r("li",e({style:p.skeletonItem},{children:[t("div",{style:p.skeletonLinePrimary}),t("div",{style:p.skeletonLineSecondary})]}),n)}):le.map(function(o){return t("li",{children:r("div",e({onMouseDown:function(e){e.preventDefault(),function(e){var r;f(n(n([],m,!0),[e],!1)),y(""),w(!1),null===(r=L.current)||void 0===r||r.focus()}(o)},onMouseEnter:function(){return K(o.id)},onMouseLeave:function(){return K(null)},style:e(e({},p.checkboxOption),{backgroundColor:J===o.id?"#F1F5F9":"transparent"})},{children:[t("input",{type:"checkbox",checked:!1,onChange:function(){},style:p.checkboxInput}),r("div",{children:[t("p",e({style:p.optionTitle},{children:o.name})),t("p",e({style:p.optionSubtitle},{children:o.email}))]})]}))},o.id)})}))]})),r("label",e({htmlFor:"group-search-input",style:e(e({},p.sectionLabel),{display:"inline-block",marginTop:"0.375rem"})},{children:[t("span",e({style:p.requiredMark},{children:"*"})),"Select user group who can Approve"]})),r("div",e({ref:W,style:p.dropdownWrapper},{children:[r("label",e({htmlFor:"group-search-input",style:e(e({},p.inputShell),{borderColor:H?"#2563EB":"#E2E8F0",boxShadow:H?"0 0 0 1px #2563EB":"none"})},{children:[t(u,{size:14,style:p.searchIcon}),h.map(function(n){return r("span",e({style:p.chip},{children:[n.name,t("button",e({type:"button",onMouseDown:function(e){var r;e.preventDefault(),r=n._id,g(h.filter(function(e){return e._id!==r}))},onMouseEnter:function(){return re(n._id)},onMouseLeave:function(){return re(null)},style:e(e({},p.chipRemoveButton),{backgroundColor:ne===n._id?"#DBEAFE":"transparent"})},{children:t(a,{size:12})}))]}),n._id)}),t("input",{ref:q,id:"group-search-input",type:"text",value:M,onChange:function(e){return z(e.target.value)},onFocus:function(){Q(!0)},onBlur:function(){return Q(!1)},placeholder:0===h.length?"Search by group name...":"",style:p.input})]})),A&&(ce||de.length>0)&&t("ul",e({style:p.dropdown},{children:ce?[1,2,3,4].map(function(n){return r("li",e({style:p.skeletonItem},{children:[t("div",{style:p.skeletonLinePrimary}),t("div",{style:p.skeletonLineSecondary})]}),n)}):de.map(function(o){return t("li",{children:r("div",e({onMouseDown:function(e){e.preventDefault(),function(e){var r;g(n(n([],h,!0),[e],!1)),z(""),R(!1),null===(r=q.current)||void 0===r||r.focus()}(o)},onMouseEnter:function(){return V(o._id)},onMouseLeave:function(){return V(null)},style:e(e({},p.checkboxOption),{backgroundColor:U===o._id?"#F1F5F9":"transparent"})},{children:[t("input",{type:"checkbox",checked:!1,onChange:function(){},style:p.checkboxInput}),r("div",{children:[t("p",e({style:p.optionTitle},{children:o.name})),t("p",e({style:p.optionSubtitle},{children:o.description}))]})]}))},o._id)})}))]}))]}))};export{s as default};
1
+ import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as r,jsx as t}from"react/jsx-runtime";import{useState as o,useRef as i,useEffect as l}from"react";import{Search as u,X as a}from"lucide-react";import{useApproverSearchQuery as c,useGroupSearchQuery as d}from"../queries/useApprovalQueries.js";import p from"../store/useAuthStore.js";var s={root:{marginLeft:"1.5rem"},sectionLabel:{fontSize:"0.875rem",fontWeight:500,color:"#19213D"},requiredMark:{marginRight:"0.25rem",fontSize:"1rem",fontWeight:600,color:"#8F2C23"},dropdownWrapper:{position:"relative",marginTop:"0.375rem"},inputShell:{display:"flex",minHeight:"38px",width:"100%",cursor:"text",flexWrap:"wrap",alignItems:"center",gap:"0.375rem",borderRadius:"0.375rem",border:"1px solid #E2E8F0",padding:"0.375rem 0.5rem",boxSizing:"border-box",transition:"border-color 150ms ease-in-out, box-shadow 150ms ease-in-out"},searchIcon:{flexShrink:0,color:"#9CA3AF"},chip:{display:"flex",alignItems:"center",gap:"0.25rem",borderRadius:"9999px",backgroundColor:"#EFF6FF",padding:"0.125rem 0.625rem",fontSize:"0.75rem",fontWeight:500,color:"#1D4ED8"},chipRemoveButton:{marginLeft:"0.125rem",border:"none",borderRadius:"9999px",background:"transparent",padding:0,cursor:"pointer",outline:"none"},input:{minWidth:"120px",flex:1,border:"none",backgroundColor:"transparent",fontSize:"0.875rem",color:"#19213D",outline:"none"},dropdown:{position:"absolute",zIndex:50,marginTop:"0.25rem",maxHeight:"12rem",width:"100%",overflowY:"auto",borderRadius:"0.375rem",border:"1px solid #E2E8F0",backgroundColor:"#FFFFFF",padding:"0.25rem 0",listStyle:"none",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",boxSizing:"border-box"},skeletonItem:{padding:"0.5rem 0.75rem"},skeletonLinePrimary:{height:"1rem",width:"75%",borderRadius:"0.25rem",backgroundColor:"#E5E7EB"},skeletonLineSecondary:{height:"0.75rem",width:"50%",borderRadius:"0.25rem",backgroundColor:"#E5E7EB",marginTop:"0.375rem"},checkboxOption:{display:"flex",alignItems:"center",gap:"0.625rem",width:"100%",padding:"0.5rem 0.75rem",cursor:"pointer",boxSizing:"border-box"},checkboxInput:{width:"14px",height:"14px",flexShrink:0,cursor:"pointer",accentColor:"#2563EB",margin:0},optionTitle:{fontSize:"0.875rem",fontWeight:500,color:"#19213D",margin:0},optionSubtitle:{fontSize:"0.75rem",color:"#666F8D",margin:0}},m=function(m){var h,f=m.selectedApprovers,g=m.selectedGroupOfApprovers,b=m.onApproversChange,v=m.onGroupsChange,y=p(function(e){return e.user}),x=(null==y?void 0:y.firstname)?"".concat(y.firstname," ").concat(null!==(h=y.lastname)&&void 0!==h?h:"").trim():null==y?void 0:y.email,k=o(""),F=k[0],E=k[1],S=o(""),w=S[0],C=S[1],L=o(!1),D=L[0],B=L[1],M=i(null),z=i(null),I=o(""),_=I[0],T=I[1],R=o(""),A=R[0],W=R[1],q=o(!1),O=q[0],j=q[1],P=i(null),G=i(null),H=o(!1),Y=H[0],Q=H[1],J=o(!1),K=J[0],N=J[1],U=o(null),V=U[0],X=U[1],Z=o(null),$=Z[0],ee=Z[1],ne=o(null),re=ne[0],te=ne[1],oe=o(null),ie=oe[0],le=oe[1];l(function(){if(!F.trim())return C(""),void B(!1);var e=setTimeout(function(){return C(F)},500);return function(){return clearTimeout(e)}},[F]),l(function(){var e=setTimeout(function(){return W(_)},300);return function(){return clearTimeout(e)}},[_]);var ue=c(w),ae=ue.data,ce=ue.isFetching,de=(ae||[]).filter(function(e){return!f.some(function(n){return n.id===e._id})&&e.email!==(null==y?void 0:y.email)}).slice(0,10).map(function(e){var n,r,t,o;return{id:e._id,email:null!==(n=e.email)&&void 0!==n?n:"",name:(null===(r=e.firstname)||void 0===r?void 0:r.trim())?"".concat(e.firstname," ").concat(null!==(t=e.lastname)&&void 0!==t?t:"").trim():null!==(o=e.email)&&void 0!==o?o:""}});l(function(){w.trim()&&(ce||de.length>0)&&B(!0)},[ce,de.length,w]);var pe=d(A),se=pe.data,me=pe.isFetching,he=(se||[]).filter(function(e){return!g.some(function(n){return n._id===e._id})}).slice(0,10);l(function(){K&&(me||he.length>0)&&j(!0)},[me,he.length,K]),l(function(){var e=function(e){M.current&&!M.current.contains(e.target)&&B(!1),P.current&&!P.current.contains(e.target)&&j(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}},[]);return r("div",e({style:s.root},{children:[r("label",e({htmlFor:"approver-search-input",style:s.sectionLabel},{children:[t("span",e({style:s.requiredMark},{children:"*"})),"Select who can approve"]})),r("div",e({ref:M,style:s.dropdownWrapper},{children:[r("label",e({htmlFor:"approver-search-input",style:e(e({},s.inputShell),{borderColor:Y?"#2563EB":"#E2E8F0",boxShadow:Y?"0 0 0 1px #2563EB":"none"})},{children:[t(u,{size:14,style:s.searchIcon}),(null==y?void 0:y.email)&&r("span",e({style:e(e({},s.chip),{backgroundColor:"#F1F5F9",color:"#64748B"})},{children:[x," (You)"]})),f.map(function(n){return r("span",e({style:s.chip,title:n.email},{children:[n.name||n.email,t("button",e({type:"button",onMouseDown:function(e){var r;e.preventDefault(),r=n.id,b(f.filter(function(e){return e.id!==r}))},onMouseEnter:function(){return te(n.id)},onMouseLeave:function(){return te(null)},style:e(e({},s.chipRemoveButton),{backgroundColor:re===n.id?"#DBEAFE":"transparent"})},{children:t(a,{size:12})}))]}),n.id)}),t("input",{ref:z,id:"approver-search-input",type:"text",value:F,onChange:function(e){return E(e.target.value)},onFocus:function(){Q(!0),(de.length>0||ce)&&B(!0)},onBlur:function(){return Q(!1)},placeholder:0===f.length?"Search by name or email...":"",style:s.input})]})),D&&(ce||de.length>0)&&t("ul",e({style:s.dropdown},{children:ce?[1,2,3,4].map(function(n){return r("li",e({style:s.skeletonItem},{children:[t("div",{style:s.skeletonLinePrimary}),t("div",{style:s.skeletonLineSecondary})]}),n)}):de.map(function(o){return t("li",{children:r("div",e({onMouseDown:function(e){e.preventDefault(),function(e){var r;b(n(n([],f,!0),[e],!1)),E(""),B(!1),null===(r=z.current)||void 0===r||r.focus()}(o)},onMouseEnter:function(){return X(o.id)},onMouseLeave:function(){return X(null)},style:e(e({},s.checkboxOption),{backgroundColor:V===o.id?"#F1F5F9":"transparent"})},{children:[t("input",{type:"checkbox",checked:!1,onChange:function(){},style:s.checkboxInput}),r("div",{children:[t("p",e({style:s.optionTitle},{children:o.name})),t("p",e({style:s.optionSubtitle},{children:o.email}))]})]}))},o.id)})}))]})),r("label",e({htmlFor:"group-search-input",style:e(e({},s.sectionLabel),{display:"inline-block",marginTop:"0.375rem"})},{children:[t("span",e({style:s.requiredMark},{children:"*"})),"Select user group who can approve"]})),r("div",e({ref:P,style:s.dropdownWrapper},{children:[r("label",e({htmlFor:"group-search-input",style:e(e({},s.inputShell),{borderColor:K?"#2563EB":"#E2E8F0",boxShadow:K?"0 0 0 1px #2563EB":"none"})},{children:[t(u,{size:14,style:s.searchIcon}),g.map(function(n){return r("span",e({style:s.chip},{children:[n.name,t("button",e({type:"button",onMouseDown:function(e){var r;e.preventDefault(),r=n._id,v(g.filter(function(e){return e._id!==r}))},onMouseEnter:function(){return le(n._id)},onMouseLeave:function(){return le(null)},style:e(e({},s.chipRemoveButton),{backgroundColor:ie===n._id?"#DBEAFE":"transparent"})},{children:t(a,{size:12})}))]}),n._id)}),t("input",{ref:G,id:"group-search-input",type:"text",value:_,onChange:function(e){return T(e.target.value)},onFocus:function(){N(!0)},onBlur:function(){return N(!1)},placeholder:0===g.length?"Search by group name...":"",style:s.input})]})),O&&(me||he.length>0)&&t("ul",e({style:s.dropdown},{children:me?[1,2,3,4].map(function(n){return r("li",e({style:s.skeletonItem},{children:[t("div",{style:s.skeletonLinePrimary}),t("div",{style:s.skeletonLineSecondary})]}),n)}):he.map(function(o){return t("li",{children:r("div",e({onMouseDown:function(e){e.preventDefault(),function(e){var r;v(n(n([],g,!0),[e],!1)),T(""),j(!1),null===(r=G.current)||void 0===r||r.focus()}(o)},onMouseEnter:function(){return ee(o._id)},onMouseLeave:function(){return ee(null)},style:e(e({},s.checkboxOption),{backgroundColor:$===o._id?"#F1F5F9":"transparent"})},{children:[t("input",{type:"checkbox",checked:!1,onChange:function(){},style:s.checkboxInput}),r("div",{children:[t("p",e({style:s.optionTitle},{children:o.name})),t("p",e({style:s.optionSubtitle},{children:o.description}))]})]}))},o._id)})}))]}))]}))};export{m as default};
2
2
  //# sourceMappingURL=AddScopeApprovalSearchComponent.js.map
@@ -1,2 +1,2 @@
1
- import{__awaiter as e,__generator as o,__assign as r,__spreadArray as i}from"tslib";import{jsx as n,jsxs as t,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as d,useEffect as c}from"react";import{useMutation as s}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=a(""),z=q[0],F=q[1],j=a(""),E=j[0],L=j[1],B=a({}),N=B[0],W=B[1],G=d(null),P=b().user,O=S(function(e){return e.roles}),T=C(function(e){return e.rbacConfig}),M=a(null),K=M[0],U=M[1],H=a("approval_required"),J=H[0],Q=H[1],V=a([]),X=V[0],Y=V[1],Z=a([]),$=Z[0],ee=Z[1],oe=a(""),re=oe[0],ie=oe[1],ne=s({mutationFn:function(r){return e(void 0,void 0,void 0,function(){var e;return o(this,function(o){switch(o.label){case 0:return[4,x(r,null!==(e=null==P?void 0:P.accessToken)&&void 0!==e?e:"")];case 1:return[2,o.sent()]}})})},onSuccess:function(r){return e(void 0,void 0,void 0,function(){return o(this,function(e){return console.log("Rule Set Created Successfully",r),[2]})})}}),te=ne.data,le=ne.isPending,ae=ne.mutateAsync;return c(function(){A&&(F(""),L(""),W({}),U(null),Q("approval_required"),Y([]),ee([]),ie(""))},[A]),A?le?n(v,{isLoading:le}):t("div",r({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[n(m,{ref:G}),t("div",r({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",r({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[t("div",{children:[n("h2",r({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:"Add Scope"})),n("p",r({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."}))]}),n("button",r({onClick:R,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:n(p,{size:24})}))]})),t("div",r({style:{display:"flex",flexDirection:"column",gap:20}},{children:[t("div",r({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[t("label",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n("span",r({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),"Scope Name"]})),"Custom"===z?n(h,{value:E,onChange:function(e){if(e.length>50)return L(e.slice(0,50)),void W(function(e){return r(r({},e),{name:"Scope Name must be 50 characters or fewer"})});L(e),W(function(e){return r(r({},e),{name:void 0})})},onStationSelect:function(e){U(e)},style:{border:N.name?"1px solid #8F2C23":void 0}}):n(y,{value:E,onChange:function(e){var o=e.target.value;if(o.length>50)return L(o.slice(0,50)),void W(function(e){return r(r({},e),{name:"Scope Name must be 50 characters or fewer"})});L(o),W(function(e){return r(r({},e),{name:void 0})})},style:{border:"1px solid ".concat(N.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),N.name&&n("p",r({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:N.name}))]})),t("div",r({style:{display:"flex",flexDirection:"column",gap:12}},{children:[t("label",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n("span",r({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),"Learning Approval Settings"]})),t("div",r({role:"radio","aria-checked":"approval_required"===J,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return Q("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||Q("approval_required")}},{children:[t("div",r({style:{display:"flex",alignItems:"center",gap:8}},{children:[n("div",r({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===J?"#2563EB":"#CBD5E1")}},{children:"approval_required"===J&&n("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n("span",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:"Approval Required Before Publishing"}))]})),n("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:"Learnings require approval before publishing."}))]})),"approval_required"===J&&n(g,{selectedApprovers:X,selectedGroupOfApprovers:$,onApproversChange:Y,onGroupsChange:ee}),re&&n("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:re})),t("div",r({role:"radio","aria-checked":"publish_without"===J,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){Q("publish_without"),ie("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(Q("publish_without"),ie(""))}},{children:[t("div",r({style:{display:"flex",alignItems:"center",gap:8}},{children:[n("div",r({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===J?"#2563EB":"#CBD5E1")}},{children:"publish_without"===J&&n("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n("span",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:"Publish Without Approval"}))]})),n("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:"Learnings can be published directly."}))]}))]})),t("div",r({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[n("button",r({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"})),n("button",r({onClick:function(){return e(void 0,void 0,void 0,function(){var e,r,n,t,l,a,d,c,s,p,u,m;return o(this,function(o){if(e={},E.trim()?E.length>50&&(e.name="Scope Name must be 50 characters or fewer"):e.name="Scope Name is required","approval_required"===J&&0===X.length&&0===$.length&&ie("Please select at least one approver or approver group."),e.name)return W(e),[2];if("approval_required"===J&&0===X.length&&0===$.length)return[2];ie("");try{r="approval_required"===J,n=w.getState().backwardCompatibility,t=n?{topic:I?"genreRuleSet":"globalRuleSet",customScopeGroupName:_.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:E,parentScopeId:null,customScopeName:E,customScopeId:f(),createByName:(null==P?void 0:P.firstname)||"System",createdBy:(null==P?void 0:P.email)||"system@audacy.com",approvalRequired:r,appsecData:{application:null==T?void 0:T.applicationId,module:null==T?void 0:T.moduleId,roles:i(i([],r?[{users:X.map(function(e){return e.email}),groups:$.map(function(e){return e._id}),role:null!==(a=null===(l=O.find(function(e){return"Learning Manager"===e.name}))||void 0===l?void 0:l._id)&&void 0!==a?a:""}]:[],!0),[{users:[null==P?void 0:P.email],groups:[],role:null!==(c=null===(d=O.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===d?void 0:d._id)&&void 0!==c?c:""}],!1)}}:{topic:I?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:E,parentScopeId:null,scopeName:E,scopeReferenceMetadata:{},applicationMappingId:w.getState().app_integration_id},console.log("Add Scope payload:",t),ae(t),D(null===(s=null==te?void 0:te.data)||void 0===s?void 0:s.scopeId),R()}catch(e){console.error("An error occurred during scope creation.",e),null===(p=G.current)||void 0===p||p.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(m=null===(u=null==e?void 0:e.response)||void 0===u?void 0:u.data)||void 0===m?void 0:m.message)||"There was an error creating the scope. Please try again."})}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"===z&&!K?.5:1},disabled:le||"Custom"===z&&!K},{children:le?t(l,{children:[n(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 o,__assign as r,__spreadArray as n}from"tslib";import{jsxs as i,jsx 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 u,Loader2 as p}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,inheritScope as _}from"../apis/scopeApis.js";import{useLearningTemplateStore as w}from"../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as k}from"../config.js";import{dt as A}from"../store/useLMSConfigStore.js";import{MIDDLE_DRAWER_ADD_SCOPE_DT_PATH as R,MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH as I}from"../constants.js";var D=function(D){var j=D.isOpen,q=D.onClose,F=D.onCreate,z=D.hasGlobalRuleSet,E=D.parentId,L=a(""),B=L[0],W=L[1],N=a(""),G=N[0],T=N[1],M=a({}),P=M[0],O=M[1],K=s(null),U=b().user,H=S(function(e){return e.roles}),J=C(function(e){return e.rbacConfig}),Q=a(!1),V=Q[0],X=Q[1],Y=a(null),Z=Y[0],$=Y[1],ee=a("approval_required"),oe=ee[0],re=ee[1],ne=a([]),ie=ne[0],te=ne[1],le=a([]),ae=le[0],se=le[1],ce=a(!1);ce[0];var de=ce[1],ue=d({mutationFn:function(r){return e(void 0,void 0,void 0,function(){var e;return o(this,function(o){switch(o.label){case 0:return[4,x(r,null!==(e=null==U?void 0:U.accessToken)&&void 0!==e?e:"")];case 1:return[2,o.sent()]}})})},onSuccess:function(r){return e(void 0,void 0,void 0,function(){var e,n;return o(this,function(o){return console.log("Rule Set Created Successfully",r),null===(e=K.current)||void 0===e||e.show({severity:"success",summary:"Scope Created",detail:(null===(n=null==r?void 0:r.data)||void 0===n?void 0:n.message)||"Scope created successfully",life:3e3}),[2]})})},onError:function(e){var o,r,n;console.error("Create scope failed",e),null===(o=K.current)||void 0===o||o.show({severity:"error",summary:"Creation Failed",detail:(null===(n=null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.data)||void 0===n?void 0:n.message)||"There was an error creating the scope. Please try again."})}});ue.data;var pe=ue.isPending,me=ue.mutateAsync;return c(function(){j&&(W(""),T(""),O({}),$(null),re("approval_required"),te([]),se([]))},[j]),j?i("div",r({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[t(m,{ref:K}),pe||V?t(v,{isLoading:pe||V}):i("div",r({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[i("div",r({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[i("div",{children:[t("h2",r({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:z?A("".concat(R,".title"),"Add Scope"):A("".concat(R,".globalTitle"),"Create Global Scope")})),t("p",r({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:z?A("".concat(R,".subtitle"),"This scope will be created under Global scope and will inherit its learnings by default.",{parent:"Global"}):A("".concat(R,".globalSubtitle"),"This will be your Global scope that defines the base learnings shared across all stations.")}))]}),t("button",r({onClick:q,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:t(u,{size:24})}))]})),i("div",r({style:{display:"flex",flexDirection:"column",gap:20}},{children:[i("div",r({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[i("label",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[t("span",r({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),A("".concat(R,".scopeName"),"Scope Name")]})),"Custom"===B?t(h,{value:G,onChange:function(e){if(e.length>50)return T(e.slice(0,50)),void O(function(e){return r(r({},e),{name:"Scope Name must be 50 characters or fewer"})});T(e),O(function(e){return r(r({},e),{name:void 0})})},onStationSelect:function(e){$(e)},style:{border:P.name?"1px solid #8F2C23":void 0}}):t(y,{value:G,onChange:function(e){var o=e.target.value;if(o.length>50)return T(o.slice(0,50)),void O(function(e){return r(r({},e),{name:"Scope Name must be 50 characters or fewer"})});T(o),O(function(e){return r(r({},e),{name:void 0})})},style:{border:"1px solid ".concat(P.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),P.name&&t("p",r({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:P.name}))]})),i("div",r({style:{display:"flex",flexDirection:"column",gap:12}},{children:[i("label",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[t("span",r({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),A("".concat(I,".title"),"Learning Approval Settings")]})),i("div",r({role:"radio","aria-checked":"approval_required"===oe,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return re("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||re("approval_required")}},{children:[i("div",r({style:{display:"flex",alignItems:"center",gap:8}},{children:[t("div",r({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===oe?"#2563EB":"#CBD5E1")}},{children:"approval_required"===oe&&t("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),t("span",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:A("".concat(I,".approvalRequired.title"),"Approval Required Before Publishing")}))]})),t("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:A("".concat(I,".approvalRequired.subtitle"),"Learnings require approval before publishing.")}))]})),"approval_required"===oe&&t(g,{selectedApprovers:ie,selectedGroupOfApprovers:ae,onApproversChange:te,onGroupsChange:se}),i("div",r({role:"radio","aria-checked":"publish_without"===oe,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){re("publish_without")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||re("publish_without")}},{children:[i("div",r({style:{display:"flex",alignItems:"center",gap:8}},{children:[t("div",r({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===oe?"#2563EB":"#CBD5E1")}},{children:"publish_without"===oe&&t("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),t("span",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:A("".concat(I,".publishWithoutApproval.title"),"Publish Without Approval")}))]})),t("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:A("".concat(I,".publishWithoutApproval.subtitle"),"Learnings can be published directly.")}))]}))]})),i("div",r({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[t("button",r({onClick:q,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:pe?.5:1},disabled:pe},{children:A("".concat(R,".cancel"),"Cancel")})),t("button",r({onClick:function(){return e(void 0,void 0,void 0,function(){var e,r,i,t,l,a,s,c,d,u,p,m,h,g,v,y,b,S,C,x,A;return o(this,function(o){switch(o.label){case 0:if(e={},G.trim()?G.length>50&&(e.name="Scope Name must be 50 characters or fewer"):e.name="Scope Name is required",e.name)return O(e),[2];o.label=1;case 1:return o.trys.push([1,8,9,10]),X(!0),r="approval_required"===oe,i=w.getState().backwardCompatibility,t=ie.length>0||ae.length>0,l=i?{topic:z?"genreRuleSet":"globalRuleSet",customScopeGroupName:k.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:G,parentScopeId:null,customScopeName:G,customScopeId:f(),createByName:(null==U?void 0:U.firstname)||"System",createdBy:(null==U?void 0:U.email)||"system@audacy.com",approvalRequired:r,appsecData:{application:null==J?void 0:J.applicationId,module:null==J?void 0:J.moduleId,roles:n(n([],r&&t?[{users:ie.map(function(e){return e.email}),groups:ae.map(function(e){return e._id}),role:null!==(p=null===(u=H.find(function(e){return"Learning Manager"===e.name}))||void 0===u?void 0:u._id)&&void 0!==p?p:""}]:[],!0),[{users:[null==U?void 0:U.email],groups:[],role:null!==(h=null===(m=H.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===m?void 0:m._id)&&void 0!==h?h:""}],!1)}}:{topic:z?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:G,parentScopeId:null!=E?E:null,scopeName:G,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:w.getState().app_integration_id,approvalRequired:r,appsecData:{application:null==J?void 0:J.applicationId,module:null==J?void 0:J.moduleId,roles:n(n([],r&&t?[{users:ie.map(function(e){return e.email}),groups:ae.map(function(e){return e._id}),role:null!==(v=null===(g=H.find(function(e){return"Learning Manager"===e.name}))||void 0===g?void 0:g._id)&&void 0!==v?v:""}]:[],!0),[{users:[null==U?void 0:U.email],groups:[],role:null!==(b=null===(y=H.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===y?void 0:y._id)&&void 0!==b?b:""}],!1)}},console.log("Add Scope payload:",l),[4,me(l)];case 2:if(a=o.sent(),s=null===(S=null==a?void 0:a.data)||void 0===S?void 0:S.scopeId,i||!s||!E)return[3,7];de(!0),o.label=3;case 3:return o.trys.push([3,5,6,7]),[4,_({source_scope_id:E,target_scope_id:s,application_mapping_id:w.getState().app_integration_id||"",is_copy_parent_variant_id:!1})];case 4:return o.sent(),[3,7];case 5:return c=o.sent(),console.error("Failed to inherit rules for the new scope:",c),[3,7];case 6:return de(!1),[7];case 7:return F(s),q(),[3,10];case 8:return d=o.sent(),console.error("An error occurred during scope creation.",d),null===(C=K.current)||void 0===C||C.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(A=null===(x=null==d?void 0:d.response)||void 0===x?void 0:x.data)||void 0===A?void 0:A.message)||"There was an error creating the scope. Please try again."}),[3,10];case 9:return X(!1),[7];case 10: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:pe||"Custom"===B&&!Z?.5:1},disabled:pe||"Custom"===B&&!Z},{children:pe?i(l,{children:[t(p,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):A("".concat(R,".submitButton"),"Create Scope")}))]}))]}))]}))]})):null};export{D as default};
2
2
  //# sourceMappingURL=AddScopeModal.js.map