@veloceapps/sdk 8.0.0-12 → 8.0.0-121

Sign up to get free protection for your applications and to get access to all the features.
Files changed (332) hide show
  1. package/README.md +0 -1
  2. package/cms/README.md +0 -20
  3. package/cms/cms.actions.d.ts +7 -1
  4. package/cms/components/preview/preview.component.d.ts +1 -2
  5. package/cms/components/preview/preview.types.d.ts +4 -0
  6. package/cms/index.d.ts +1 -0
  7. package/cms/modules/runtime/services/runtime.service.d.ts +1 -1
  8. package/cms/services/index.d.ts +0 -1
  9. package/cms/types/index.d.ts +0 -1
  10. package/cms/utils/element-metadata-worker.d.ts +11 -0
  11. package/cms/utils/element.utils.d.ts +1 -0
  12. package/cms/utils/elements-resolver.d.ts +0 -2
  13. package/cms/utils/index.d.ts +3 -0
  14. package/cms/utils/transpilation-worker.d.ts +13 -0
  15. package/cms/vendor-map.d.ts +26 -13
  16. package/core/README.md +20 -0
  17. package/core/modules/configuration/helpers.d.ts +4 -3
  18. package/core/modules/configuration/services/configuration-runtime.service.d.ts +1 -1
  19. package/core/modules/configuration/services/configuration.service.d.ts +6 -1
  20. package/core/modules/configuration/types/configuration.types.d.ts +4 -0
  21. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +5 -0
  22. package/core/pipes/action-code.pipe.d.ts +8 -0
  23. package/core/pipes/date.pipe.d.ts +2 -1
  24. package/core/pipes/index.d.ts +1 -0
  25. package/core/pipes/pipes.module.d.ts +2 -1
  26. package/core/services/context.service.d.ts +3 -0
  27. package/core/services/flow-info.service.d.ts +27 -0
  28. package/core/services/flow-state-configuration.service.d.ts +20 -0
  29. package/core/services/flow-state.service.d.ts +70 -0
  30. package/core/services/index.d.ts +4 -0
  31. package/core/services/quote-draft.service.d.ts +8 -1
  32. package/core/services/runtime-settings.service.d.ts +4 -1
  33. package/core/types/flow-customization.types.d.ts +22 -0
  34. package/core/types/flow-state.types.d.ts +6 -0
  35. package/core/types/formatting-settings.types.d.ts +2 -0
  36. package/core/types/index.d.ts +3 -0
  37. package/{cms → core}/types/integration.types.d.ts +1 -0
  38. package/core/types/pipe.types.d.ts +1 -0
  39. package/esm2020/cms/cms.actions.mjs +15 -1
  40. package/esm2020/cms/components/element-children/element-children.component.mjs +3 -3
  41. package/esm2020/cms/components/element-children/element-children.module.mjs +4 -4
  42. package/esm2020/cms/components/element-drop-handle/element-drop-handle.component.mjs +3 -3
  43. package/esm2020/cms/components/element-drop-handle/element-drop-handle.module.mjs +4 -4
  44. package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +3 -3
  45. package/esm2020/cms/components/element-renderer/element-renderer.module.mjs +4 -4
  46. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +5 -5
  47. package/esm2020/cms/components/plugin.component.mjs +3 -3
  48. package/esm2020/cms/components/preview/preview.component.mjs +11 -11
  49. package/esm2020/cms/components/preview/preview.module.mjs +6 -6
  50. package/esm2020/cms/components/preview/preview.types.mjs +1 -1
  51. package/esm2020/cms/directives/custom-template.directive.mjs +7 -7
  52. package/esm2020/cms/index.mjs +2 -1
  53. package/esm2020/cms/launcher.module.mjs +7 -7
  54. package/esm2020/cms/modules/federated/federated-host.directive.mjs +3 -3
  55. package/esm2020/cms/modules/federated/federated.component.mjs +3 -3
  56. package/esm2020/cms/modules/federated/federated.module.mjs +4 -4
  57. package/esm2020/cms/modules/migrations/migrations.module.mjs +4 -4
  58. package/esm2020/cms/modules/migrations/services/migrations.service.mjs +3 -3
  59. package/esm2020/cms/modules/runtime/runtime.module.mjs +4 -4
  60. package/esm2020/cms/modules/runtime/services/compilation.service.mjs +12 -8
  61. package/esm2020/cms/modules/runtime/services/runtime-editor.service.mjs +3 -3
  62. package/esm2020/cms/modules/runtime/services/runtime.service.mjs +7 -7
  63. package/esm2020/cms/plugins/configuration.plugin.mjs +3 -3
  64. package/esm2020/cms/plugins/element-hover.plugin.mjs +3 -3
  65. package/esm2020/cms/plugins/io.plugin.mjs +8 -7
  66. package/esm2020/cms/plugins/page.plugin.mjs +3 -3
  67. package/esm2020/cms/plugins/region.plugin.mjs +3 -3
  68. package/esm2020/cms/plugins/script.plugin.mjs +3 -3
  69. package/esm2020/cms/services/element-context.service.mjs +3 -3
  70. package/esm2020/cms/services/index.mjs +1 -2
  71. package/esm2020/cms/services/io-provider.service.mjs +3 -3
  72. package/esm2020/cms/services/resources.service.mjs +3 -3
  73. package/esm2020/cms/services/templates.service.mjs +3 -3
  74. package/esm2020/cms/types/index.mjs +1 -2
  75. package/esm2020/cms/utils/element-metadata-worker.mjs +31 -0
  76. package/esm2020/cms/utils/element.utils.mjs +10 -3
  77. package/esm2020/cms/utils/elements-resolver.mjs +14 -28
  78. package/esm2020/cms/utils/index.mjs +4 -1
  79. package/esm2020/cms/utils/transpilation-worker.mjs +52 -0
  80. package/esm2020/cms/vendor-map.mjs +18 -5
  81. package/esm2020/core/core.module.mjs +12 -17
  82. package/esm2020/core/directives/directives.module.mjs +4 -4
  83. package/esm2020/core/directives/primeng-calendar.directive.mjs +3 -3
  84. package/esm2020/core/modules/configuration/configuration.module.mjs +4 -4
  85. package/esm2020/core/modules/configuration/helpers.mjs +28 -3
  86. package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +11 -14
  87. package/esm2020/core/modules/configuration/services/configuration.service.mjs +29 -10
  88. package/esm2020/core/modules/configuration/services/configuration.state.mjs +5 -5
  89. package/esm2020/core/modules/configuration/services/runtime-context.service.mjs +9 -9
  90. package/esm2020/core/modules/configuration/types/configuration.types.mjs +1 -1
  91. package/esm2020/core/modules/flow-configuration/flow-configuration.module.mjs +4 -4
  92. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +15 -11
  93. package/esm2020/core/modules/flow-configuration/services/flow-update.service.mjs +3 -3
  94. package/esm2020/core/pipes/action-code.pipe.mjs +20 -0
  95. package/esm2020/core/pipes/date.pipe.mjs +13 -7
  96. package/esm2020/core/pipes/index.mjs +2 -1
  97. package/esm2020/core/pipes/number.pipe.mjs +3 -3
  98. package/esm2020/core/pipes/pipes.module.mjs +8 -7
  99. package/esm2020/core/pipes/price.pipe.mjs +3 -3
  100. package/esm2020/core/services/context.service.mjs +32 -5
  101. package/esm2020/core/services/flow-info.service.mjs +94 -0
  102. package/esm2020/core/services/flow-state-configuration.service.mjs +52 -0
  103. package/esm2020/core/services/flow-state.service.mjs +441 -0
  104. package/esm2020/core/services/index.mjs +5 -1
  105. package/esm2020/core/services/integration.state.mjs +37 -0
  106. package/esm2020/core/services/metric-calculation/metric-calculation.service.mjs +3 -3
  107. package/esm2020/core/services/product-images.service.mjs +3 -3
  108. package/esm2020/core/services/quote-draft.service.mjs +31 -6
  109. package/esm2020/core/services/runtime-settings.service.mjs +20 -5
  110. package/esm2020/core/types/flow-customization.types.mjs +3 -0
  111. package/esm2020/core/types/flow-state.types.mjs +2 -0
  112. package/esm2020/core/types/formatting-settings.types.mjs +1 -1
  113. package/esm2020/core/types/index.mjs +4 -1
  114. package/esm2020/core/types/integration.types.mjs +2 -0
  115. package/esm2020/core/types/pipe.types.mjs +2 -0
  116. package/esm2020/src/components/dialog/dialog.component.mjs +3 -3
  117. package/esm2020/src/components/dialog/dialog.module.mjs +4 -4
  118. package/esm2020/src/components/doc-gen/doc-gen.component.mjs +45 -54
  119. package/esm2020/src/components/doc-gen/doc-gen.module.mjs +4 -4
  120. package/esm2020/src/components/flow-header/flow-header.component.mjs +108 -0
  121. package/esm2020/src/components/flow-header/flow-header.module.mjs +19 -0
  122. package/esm2020/src/components/flow-header/index.mjs +2 -0
  123. package/esm2020/src/components/guided-selling/guided-selling.component.mjs +42 -51
  124. package/esm2020/src/components/guided-selling/guided-selling.module.mjs +4 -4
  125. package/esm2020/src/configure-primeng.mjs +33 -0
  126. package/esm2020/src/flow-routing.module.mjs +66 -75
  127. package/esm2020/src/flow.component.mjs +24 -33
  128. package/esm2020/src/flow.module.mjs +11 -9
  129. package/esm2020/src/guards/context.guard.mjs +7 -12
  130. package/esm2020/src/guards/flow.guard.mjs +31 -0
  131. package/esm2020/src/guards/product-unload.guard.mjs +7 -4
  132. package/esm2020/src/guards/root.guard.mjs +17 -13
  133. package/esm2020/src/pages/assets/assets.component.mjs +34 -38
  134. package/esm2020/src/pages/assets/assets.module.mjs +4 -4
  135. package/esm2020/src/pages/catalog/catalog.component.mjs +34 -38
  136. package/esm2020/src/pages/catalog/catalog.module.mjs +4 -4
  137. package/esm2020/src/pages/debug/debug.component.mjs +12 -16
  138. package/esm2020/src/pages/debug/debug.module.mjs +4 -4
  139. package/esm2020/src/pages/empty-account/empty-account.component.mjs +3 -3
  140. package/esm2020/src/pages/empty-account/empty-account.module.mjs +4 -4
  141. package/esm2020/src/pages/product/product.component.mjs +7 -10
  142. package/esm2020/src/pages/product/product.module.mjs +4 -4
  143. package/esm2020/src/pages/record-not-found/record-not-found.component.mjs +3 -3
  144. package/esm2020/src/pages/record-not-found/record-not-found.module.mjs +4 -4
  145. package/esm2020/src/pages/remote/remote.component.mjs +13 -14
  146. package/esm2020/src/pages/remote/remote.module.mjs +4 -4
  147. package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +35 -39
  148. package/esm2020/src/pages/shopping-cart/shopping-cart.module.mjs +4 -4
  149. package/esm2020/src/resolvers/flow.resolver.mjs +37 -51
  150. package/esm2020/src/resolvers/quote.resolver.mjs +40 -65
  151. package/esm2020/src/services/doc-gen.service.mjs +7 -6
  152. package/esm2020/src/services/flow-dialog.service.mjs +22 -7
  153. package/esm2020/src/services/flow-router.service.mjs +31 -10
  154. package/esm2020/src/services/flow.service.mjs +36 -11
  155. package/esm2020/src/services/guided-selling.service.mjs +8 -7
  156. package/esm2020/src/services/index.mjs +3 -1
  157. package/esm2020/src/types/index.mjs +1 -2
  158. package/esm2020/src/utils/flow.utils.mjs +6 -2
  159. package/fesm2015/veloceapps-sdk-cms.mjs +329 -248
  160. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  161. package/fesm2015/veloceapps-sdk-core.mjs +1551 -826
  162. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  163. package/fesm2015/veloceapps-sdk.mjs +744 -1544
  164. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  165. package/fesm2020/veloceapps-sdk-cms.mjs +343 -270
  166. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  167. package/fesm2020/veloceapps-sdk-core.mjs +1866 -1158
  168. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  169. package/fesm2020/veloceapps-sdk.mjs +856 -1655
  170. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  171. package/package.json +7 -13
  172. package/src/components/doc-gen/doc-gen.component.d.ts +8 -12
  173. package/src/components/flow-header/flow-header.component.d.ts +25 -0
  174. package/src/components/flow-header/flow-header.module.d.ts +9 -0
  175. package/src/components/flow-header/index.d.ts +1 -0
  176. package/src/components/guided-selling/guided-selling.component.d.ts +7 -11
  177. package/src/configure-primeng.d.ts +1 -0
  178. package/src/flow-routing.module.d.ts +6 -7
  179. package/src/flow.component.d.ts +7 -11
  180. package/src/flow.module.d.ts +2 -2
  181. package/src/guards/context.guard.d.ts +4 -5
  182. package/src/guards/flow.guard.d.ts +2 -0
  183. package/src/guards/product-unload.guard.d.ts +2 -2
  184. package/src/guards/root.guard.d.ts +0 -1
  185. package/src/pages/assets/assets.component.d.ts +5 -7
  186. package/src/pages/catalog/catalog.component.d.ts +5 -7
  187. package/src/pages/debug/debug.component.d.ts +5 -8
  188. package/src/pages/product/product.component.d.ts +2 -3
  189. package/src/pages/remote/remote.component.d.ts +1 -2
  190. package/src/pages/shopping-cart/shopping-cart.component.d.ts +5 -7
  191. package/src/resolvers/flow.resolver.d.ts +6 -7
  192. package/src/resolvers/quote.resolver.d.ts +6 -12
  193. package/src/services/doc-gen.service.d.ts +1 -1
  194. package/src/services/flow-dialog.service.d.ts +5 -2
  195. package/src/services/flow-router.service.d.ts +4 -2
  196. package/src/services/flow.service.d.ts +4 -2
  197. package/src/services/guided-selling.service.d.ts +1 -1
  198. package/src/services/index.d.ts +2 -0
  199. package/src/types/index.d.ts +0 -1
  200. package/esm2020/cms/services/integration.state.mjs +0 -37
  201. package/esm2020/cms/types/integration.types.mjs +0 -2
  202. package/esm2020/runtime/components/component-preview/component-preview.component.mjs +0 -125
  203. package/esm2020/runtime/components/index.mjs +0 -5
  204. package/esm2020/runtime/components/section-renderer/section-renderer.component.mjs +0 -67
  205. package/esm2020/runtime/components/ui-runtime/runtime.component.mjs +0 -440
  206. package/esm2020/runtime/components/ui-runtime-preview/runtime-preview.component.mjs +0 -108
  207. package/esm2020/runtime/execution/components/children-placeholder/children-placeholder.component.mjs +0 -60
  208. package/esm2020/runtime/execution/components/context-provider/context-provider.component.mjs +0 -39
  209. package/esm2020/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.mjs +0 -67
  210. package/esm2020/runtime/execution/components/federated/federated.component.mjs +0 -74
  211. package/esm2020/runtime/execution/components/velo-attribute/velo-attribute.component.mjs +0 -60
  212. package/esm2020/runtime/execution/components/velo-multiselect/velo-multiselect.component.mjs +0 -130
  213. package/esm2020/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.mjs +0 -72
  214. package/esm2020/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.mjs +0 -97
  215. package/esm2020/runtime/execution/components/velo-port-radio/velo-port-radio.component.mjs +0 -142
  216. package/esm2020/runtime/execution/components/velo-type/velo-type.component.mjs +0 -119
  217. package/esm2020/runtime/execution/directives/section-script.directive.mjs +0 -247
  218. package/esm2020/runtime/execution/directives/sf-query.directive.mjs +0 -35
  219. package/esm2020/runtime/execution/directives/velo-attribute.directive.mjs +0 -88
  220. package/esm2020/runtime/execution/directives/velo-port.directive.mjs +0 -376
  221. package/esm2020/runtime/execution/directives/vl-approval.directive.mjs +0 -23
  222. package/esm2020/runtime/execution/directives/vl-document-attachments.directive.mjs +0 -36
  223. package/esm2020/runtime/execution/directives/vl-document-templates.directive.mjs +0 -60
  224. package/esm2020/runtime/execution/directives/vl-quote.directive.mjs +0 -42
  225. package/esm2020/runtime/execution/directives/vl-ramp.directive.mjs +0 -55
  226. package/esm2020/runtime/execution/runtime-execution.module.mjs +0 -133
  227. package/esm2020/runtime/execution/utils/federated.util.mjs +0 -32
  228. package/esm2020/runtime/index.mjs +0 -5
  229. package/esm2020/runtime/runtime.module.mjs +0 -74
  230. package/esm2020/runtime/services/cart.service.mjs +0 -29
  231. package/esm2020/runtime/services/collapsible-state.service.mjs +0 -34
  232. package/esm2020/runtime/services/configuration.service.mjs +0 -119
  233. package/esm2020/runtime/services/current-state.service.mjs +0 -17
  234. package/esm2020/runtime/services/form-scope.service.mjs +0 -30
  235. package/esm2020/runtime/services/index.mjs +0 -4
  236. package/esm2020/runtime/services/product-model-cache.service.mjs +0 -31
  237. package/esm2020/runtime/services/runtime-context.service.mjs +0 -60
  238. package/esm2020/runtime/services/runtime-form.service.mjs +0 -219
  239. package/esm2020/runtime/services/runtime.service.mjs +0 -115
  240. package/esm2020/runtime/services/section-helper.service.mjs +0 -27
  241. package/esm2020/runtime/services/section-scope.service.mjs +0 -36
  242. package/esm2020/runtime/services/section-store.service.mjs +0 -22
  243. package/esm2020/runtime/services/section.service.mjs +0 -117
  244. package/esm2020/runtime/types/bound-data.types.mjs +0 -7
  245. package/esm2020/runtime/types/index.mjs +0 -3
  246. package/esm2020/runtime/types/quote-states.types.mjs +0 -2
  247. package/esm2020/runtime/types/runtime.types.mjs +0 -2
  248. package/esm2020/runtime/types/script-registry.types.mjs +0 -51
  249. package/esm2020/runtime/utils/line-item.util.mjs +0 -270
  250. package/esm2020/runtime/utils/section.utils.mjs +0 -26
  251. package/esm2020/runtime/utils/sections-binder.helper.mjs +0 -105
  252. package/esm2020/runtime/veloceapps-sdk-runtime.mjs +0 -5
  253. package/esm2020/src/components/header/cart-overlay/cart-preview.component.mjs +0 -119
  254. package/esm2020/src/components/header/cart-overlay/cart-preview.module.mjs +0 -47
  255. package/esm2020/src/components/header/header.component.mjs +0 -355
  256. package/esm2020/src/components/header/header.module.mjs +0 -52
  257. package/esm2020/src/components/header/header.types.mjs +0 -2
  258. package/esm2020/src/components/header/metrics/index.mjs +0 -2
  259. package/esm2020/src/components/header/metrics/metrics.component.mjs +0 -255
  260. package/esm2020/src/components/header/metrics/metrics.definitions.mjs +0 -2
  261. package/esm2020/src/components/header/metrics/metrics.module.mjs +0 -69
  262. package/esm2020/src/pages/legacy-product/legacy-product.component.mjs +0 -137
  263. package/esm2020/src/pages/legacy-product/legacy-product.module.mjs +0 -19
  264. package/esm2020/src/types/flow-customization.types.mjs +0 -3
  265. package/fesm2015/veloceapps-sdk-runtime.mjs +0 -3770
  266. package/fesm2015/veloceapps-sdk-runtime.mjs.map +0 -1
  267. package/fesm2020/veloceapps-sdk-runtime.mjs +0 -3767
  268. package/fesm2020/veloceapps-sdk-runtime.mjs.map +0 -1
  269. package/runtime/README.md +0 -5
  270. package/runtime/components/component-preview/component-preview.component.d.ts +0 -27
  271. package/runtime/components/index.d.ts +0 -4
  272. package/runtime/components/section-renderer/section-renderer.component.d.ts +0 -25
  273. package/runtime/components/ui-runtime/runtime.component.d.ts +0 -53
  274. package/runtime/components/ui-runtime-preview/runtime-preview.component.d.ts +0 -27
  275. package/runtime/execution/components/children-placeholder/children-placeholder.component.d.ts +0 -30
  276. package/runtime/execution/components/context-provider/context-provider.component.d.ts +0 -14
  277. package/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.d.ts +0 -25
  278. package/runtime/execution/components/federated/federated.component.d.ts +0 -36
  279. package/runtime/execution/components/velo-attribute/velo-attribute.component.d.ts +0 -19
  280. package/runtime/execution/components/velo-multiselect/velo-multiselect.component.d.ts +0 -35
  281. package/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.d.ts +0 -22
  282. package/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.d.ts +0 -22
  283. package/runtime/execution/components/velo-port-radio/velo-port-radio.component.d.ts +0 -28
  284. package/runtime/execution/components/velo-type/velo-type.component.d.ts +0 -31
  285. package/runtime/execution/directives/section-script.directive.d.ts +0 -59
  286. package/runtime/execution/directives/sf-query.directive.d.ts +0 -15
  287. package/runtime/execution/directives/velo-attribute.directive.d.ts +0 -26
  288. package/runtime/execution/directives/velo-port.directive.d.ts +0 -74
  289. package/runtime/execution/directives/vl-approval.directive.d.ts +0 -10
  290. package/runtime/execution/directives/vl-document-attachments.directive.d.ts +0 -15
  291. package/runtime/execution/directives/vl-document-templates.directive.d.ts +0 -33
  292. package/runtime/execution/directives/vl-quote.directive.d.ts +0 -14
  293. package/runtime/execution/directives/vl-ramp.directive.d.ts +0 -15
  294. package/runtime/execution/runtime-execution.module.d.ts +0 -25
  295. package/runtime/execution/utils/federated.util.d.ts +0 -6
  296. package/runtime/index.d.ts +0 -4
  297. package/runtime/runtime.module.d.ts +0 -16
  298. package/runtime/services/cart.service.d.ts +0 -15
  299. package/runtime/services/collapsible-state.service.d.ts +0 -15
  300. package/runtime/services/configuration.service.d.ts +0 -20
  301. package/runtime/services/current-state.service.d.ts +0 -8
  302. package/runtime/services/form-scope.service.d.ts +0 -20
  303. package/runtime/services/index.d.ts +0 -3
  304. package/runtime/services/product-model-cache.service.d.ts +0 -14
  305. package/runtime/services/runtime-context.service.d.ts +0 -16
  306. package/runtime/services/runtime-form.service.d.ts +0 -24
  307. package/runtime/services/runtime.service.d.ts +0 -44
  308. package/runtime/services/section-helper.service.d.ts +0 -8
  309. package/runtime/services/section-scope.service.d.ts +0 -14
  310. package/runtime/services/section-store.service.d.ts +0 -11
  311. package/runtime/services/section.service.d.ts +0 -30
  312. package/runtime/types/bound-data.types.d.ts +0 -13
  313. package/runtime/types/index.d.ts +0 -2
  314. package/runtime/types/quote-states.types.d.ts +0 -6
  315. package/runtime/types/runtime.types.d.ts +0 -19
  316. package/runtime/types/script-registry.types.d.ts +0 -13
  317. package/runtime/utils/line-item.util.d.ts +0 -34
  318. package/runtime/utils/section.utils.d.ts +0 -2
  319. package/runtime/utils/sections-binder.helper.d.ts +0 -16
  320. package/src/components/header/cart-overlay/cart-preview.component.d.ts +0 -36
  321. package/src/components/header/cart-overlay/cart-preview.module.d.ts +0 -14
  322. package/src/components/header/header.component.d.ts +0 -70
  323. package/src/components/header/header.module.d.ts +0 -16
  324. package/src/components/header/header.types.d.ts +0 -20
  325. package/src/components/header/metrics/index.d.ts +0 -1
  326. package/src/components/header/metrics/metrics.component.d.ts +0 -67
  327. package/src/components/header/metrics/metrics.definitions.d.ts +0 -1
  328. package/src/components/header/metrics/metrics.module.d.ts +0 -18
  329. package/src/pages/legacy-product/legacy-product.component.d.ts +0 -37
  330. package/src/pages/legacy-product/legacy-product.module.d.ts +0 -9
  331. package/src/types/flow-customization.types.d.ts +0 -12
  332. /package/{cms → core}/services/integration.state.d.ts +0 -0
@@ -1,16 +1,16 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, InjectionToken, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
3
- import { UUID, ConfigurationContextMode, ConfigurationContext, RuntimeModel, getUIDefinitionProperties, isLegacyUIDefinition, SalesforceIdUtils, ConfigurationMode, ConfigurationTranslatorUtils, EntityUtil, ChargeGroupUtils, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, parseJsonSafely, formatNumber } from '@veloceapps/core';
2
+ import { Injectable, InjectionToken, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
3
+ import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, isDefined, ConfigurationProcessorTypes, EntityUtil, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, DEFAULT_ACTION_CODE_LABELS, parseJsonSafely, ConfigurationMode, ConfigurationTranslatorUtils, ChargeGroupUtils, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
4
4
  import * as i1 from '@veloceapps/api';
5
5
  import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloceapps/api';
6
- import { BehaviorSubject, combineLatest, zip, noop, throwError, shareReplay as shareReplay$1, switchMap as switchMap$1, of, tap as tap$1, map as map$2, catchError as catchError$1, Subject, take as take$1, distinctUntilChanged } from 'rxjs';
7
- import { filter, tap, map, first, switchMap, skip, take, shareReplay, catchError, finalize } from 'rxjs/operators';
8
- import { merge, isEqual, flatten, sortBy, map as map$1, transform, omit, cloneDeep, uniq } from 'lodash';
9
- import { HttpErrorResponse } from '@angular/common/http';
10
- import * as i4 from '@veloceapps/components';
6
+ import { BehaviorSubject, switchMap, map as map$1, tap as tap$1, noop, catchError, throwError, of, forkJoin, Subject, filter as filter$1, zip, combineLatest, shareReplay as shareReplay$1, finalize, takeUntil, take as take$1, distinctUntilChanged } from 'rxjs';
7
+ import { map, filter, tap, switchMap as switchMap$1, skip, take, shareReplay, catchError as catchError$1, finalize as finalize$1, first } from 'rxjs/operators';
8
+ import { merge, isEmpty, flatten, sortBy, map as map$2, omit, isEqual, cloneDeep, assign, uniqBy, transform, uniq } from 'lodash';
9
+ import * as i6 from '@veloceapps/components';
11
10
  import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@veloceapps/components';
11
+ import { HttpErrorResponse } from '@angular/common/http';
12
12
  import * as i5 from 'primeng/api';
13
- import * as i6 from 'primeng/dynamicdialog';
13
+ import * as i6$1 from 'primeng/dynamicdialog';
14
14
  import moment from 'moment';
15
15
  import { NgControl } from '@angular/forms';
16
16
  import 'primeng/calendar';
@@ -33,15 +33,20 @@ const getDefaultLineItem = (context, uiDefinitionProperties, qty = 1) => {
33
33
  ...(uiDefinitionProperties.offeringId ? { offeringId: uiDefinitionProperties.offeringId } : {}),
34
34
  };
35
35
  };
36
- const getGuidedSellingConfigurationRequest = (data) => {
36
+ const getGuidedSellingConfigurationRequest = (data, context) => {
37
+ const _context = { ...context };
38
+ delete _context.configurationToken;
39
+ const properties = { ...context.properties };
40
+ delete properties['ConfigurationToken'];
37
41
  return {
38
42
  mode: 'SEARCH',
39
43
  step: 'START',
40
44
  attributeDomainMode: 'ALL',
41
45
  context: {
42
- headerId: 'TestId',
46
+ ..._context,
43
47
  mode: ConfigurationContextMode.TEST,
44
48
  properties: {
49
+ ...properties,
45
50
  ModelId: data.modelId,
46
51
  Name: 'Veloce Guided Selling',
47
52
  PricingEnabled: 'false',
@@ -62,6 +67,26 @@ const getGuidedSellingConfigurationRequest = (data) => {
62
67
  },
63
68
  };
64
69
  };
70
+ const generateConfigurationLineItem = (props, qty = 1) => {
71
+ const id = UUID.UUID();
72
+ const attributes = Object.entries(props.attributesMap ?? {}).map(([name, value]) => ({
73
+ name,
74
+ value,
75
+ cfgStatus: 'User',
76
+ }));
77
+ const lineItems = [];
78
+ return {
79
+ id,
80
+ type: props.product.typeName ?? '',
81
+ cfgStatus: 'Default',
82
+ actionCode: 'ADD',
83
+ qty,
84
+ attributes,
85
+ lineItems,
86
+ productName: props.product.name,
87
+ productId: props.product.id ?? '',
88
+ };
89
+ };
65
90
 
66
91
  class ContextService {
67
92
  constructor(contextApiService) {
@@ -71,9 +96,24 @@ class ContextService {
71
96
  get isInitialized() {
72
97
  return Boolean(this.context.value);
73
98
  }
99
+ get isInitialized$() {
100
+ return this.context.pipe(map(Boolean));
101
+ }
74
102
  get mode() {
75
103
  return this.resolve().properties.mode;
76
104
  }
105
+ get isEditMode$() {
106
+ return this.resolve$().pipe(map(() => {
107
+ const context = this.resolve();
108
+ if (context.mode === ConfigurationContextMode.ACCOUNT) {
109
+ return true;
110
+ }
111
+ if (context.mode === ConfigurationContextMode.QUOTE) {
112
+ return context.properties.Status === 'Draft';
113
+ }
114
+ return false;
115
+ }));
116
+ }
77
117
  resolve() {
78
118
  if (!this.context.value) {
79
119
  throw new Error('Context is not initialized yet!');
@@ -86,6 +126,18 @@ class ContextService {
86
126
  create(headerId, mode) {
87
127
  return this.contextApiService.getContext(headerId, mode).pipe(tap(context => this.context.next(merge(new ConfigurationContext(headerId, mode), context))), map(() => this.resolve()));
88
128
  }
129
+ initTestMode() {
130
+ return this.create('TestId', ConfigurationContextMode.TEST).pipe(map(context => {
131
+ return this.update({
132
+ properties: {
133
+ ...context.properties,
134
+ RuntimeMode: ConfigurationContextMode.TEST,
135
+ StartDate: new Date().toISOString().substring(0, 10),
136
+ standalone: 'true',
137
+ },
138
+ });
139
+ }));
140
+ }
89
141
  update(partialContext) {
90
142
  const originalContext = this.resolve();
91
143
  const updatedContext = {
@@ -112,13 +164,15 @@ class ContextService {
112
164
  this.context.next(null);
113
165
  }
114
166
  }
115
- ContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ContextService, deps: [{ token: i1.ContextApiService }], target: i0.ɵɵFactoryTarget.Injectable });
116
- ContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ContextService, providedIn: 'root' });
117
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ContextService, decorators: [{
167
+ ContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, deps: [{ token: i1.ContextApiService }], target: i0.ɵɵFactoryTarget.Injectable });
168
+ ContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, providedIn: 'root' });
169
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, decorators: [{
118
170
  type: Injectable,
119
171
  args: [{ providedIn: 'root' }]
120
172
  }], ctorParameters: function () { return [{ type: i1.ContextApiService }]; } });
121
173
 
174
+ const FLOW_CUSTOMIZATION = new InjectionToken('FLOW_CUSTOMIZATION');
175
+
122
176
  const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
123
177
 
124
178
  var RuntimeMode;
@@ -139,416 +193,141 @@ var RuntimeStep;
139
193
 
140
194
  const UI_DEFINITION_VERSION = 3;
141
195
 
142
- class RuntimeContextService {
143
- constructor(configurationApiService) {
144
- this.configurationApiService = configurationApiService;
145
- }
146
- getRuntimeContext(productId, offeringId) {
147
- return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
148
- const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
149
- const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
150
- const { productName, properties } = Array.from(runtimeModel.components.values()).find(c => c.productId === productId) ?? {};
151
- const uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
152
- return {
153
- modelId: runtimeData.modelId,
154
- uiDefinitionContainer: uiDefinitionContainer,
155
- runtimeModel: runtimeModel,
156
- runtimeMode: RuntimeMode.PROD,
157
- productId: productId,
158
- productType: properties?.['displayName'] || productName,
159
- offeringId: offeringId,
160
- properties: {
161
- PricingEnabled: uiDefinitionProperties.pricingEnabled ? 'true' : 'false',
162
- PriceListId: uiDefinitionProperties.priceList,
163
- },
164
- };
196
+ class FlowInfoService {
197
+ get flow() {
198
+ return this.flowSubj$.value;
199
+ }
200
+ set flow(value) {
201
+ this.flowSubj$.next(value);
202
+ }
203
+ constructor(flowsApiService, templatesApiService, customizationService) {
204
+ this.flowsApiService = flowsApiService;
205
+ this.templatesApiService = templatesApiService;
206
+ this.customizationService = customizationService;
207
+ this.templates = {};
208
+ this.defaultTemplates = {
209
+ flowEngine: 'Flow Engine',
210
+ };
211
+ this.flowSubj$ = new BehaviorSubject(null);
212
+ this.flow$ = this.flowSubj$.asObservable();
213
+ }
214
+ init$(flowId, params) {
215
+ this.params = params;
216
+ return this.flowsApiService.getFlow(flowId).pipe(switchMap(flow => this.initFlowTemplates$(flow).pipe(map$1(() => flow))), tap$1(flow => this.flowSubj$.next(flow)), map$1(noop), catchError(e => {
217
+ this.flowSubj$.next(null);
218
+ return throwError(() => e);
165
219
  }));
166
220
  }
167
- getUIDefinitionContainer(runtimeData) {
168
- const containers = runtimeData.uiDefinitions.filter(container => !isLegacyUIDefinition(container.source));
169
- return containers.find(container => container.source.primary) ?? containers[0];
170
- }
171
- }
172
- RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }], target: i0.ɵɵFactoryTarget.Injectable });
173
- RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeContextService });
174
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeContextService, decorators: [{
175
- type: Injectable
176
- }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }]; } });
177
-
178
- class ConfigurationRuntimeService {
179
- constructor(apiService, contextService, runtimeContextService) {
180
- this.apiService = apiService;
181
- this.contextService = contextService;
182
- this.runtimeContextService = runtimeContextService;
183
- this._isInitialized = false;
184
- this.uiDefinitionProperties = {};
185
- }
186
- reset() {
187
- this._isInitialized = false;
188
- this._runtimeContext = undefined;
189
- this.initializationProps = undefined;
190
- this.uiDefinitionProperties = {};
191
- }
192
- initTestMode(uiDefinitionContainer) {
193
- this.uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
194
- const uiDefinitionExternals = uiDefinitionContainer.source.externals ?? {};
195
- return combineLatest([
196
- this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
197
- this.contextService.create('TestId', ConfigurationContextMode.TEST),
198
- ]).pipe(first(), map(([runtimeData, context]) => {
199
- this.contextService.update({
200
- properties: {
201
- ...this.runtimeContext?.properties,
202
- ...context.properties,
203
- ModelId: uiDefinitionContainer.modelId,
204
- RuntimeMode: ConfigurationContextMode.TEST,
205
- PricingEnabled: this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false',
206
- StartDate: new Date().toISOString().substring(0, 10),
207
- PriceListId: this.uiDefinitionProperties.priceList,
208
- offeringId: this.uiDefinitionProperties.offeringId,
209
- standalone: 'true',
210
- ...uiDefinitionExternals,
211
- },
212
- });
213
- this._runtimeContext = {
214
- modelId: uiDefinitionContainer.modelId,
215
- runtimeModel: RuntimeModel.create(runtimeData.types, runtimeData.products),
216
- runtimeMode: RuntimeMode.TEST,
217
- uiDefinitionContainer,
218
- };
219
- return this._runtimeContext;
220
- }), tap(() => (this._isInitialized = true)));
221
- }
222
- init(props) {
223
- this.initializationProps = props;
224
- const context = this.contextService.resolve();
225
- return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
226
- this.uiDefinitionProperties = getUIDefinitionProperties(runtimeContext.uiDefinitionContainer);
227
- const { PriceListId } = context.properties ?? {};
228
- const mergeContext = {
229
- ...runtimeContext,
230
- properties: {
231
- ...runtimeContext.properties,
232
- ...context.properties,
233
- PricingEnabled: PriceListId ? 'true' : 'false',
234
- },
235
- };
236
- this.id15to18('AccountId', mergeContext.properties);
237
- this._runtimeContext = mergeContext;
238
- if (context.properties && this._runtimeContext.properties?.StartDate) {
239
- this.contextService.update({
240
- properties: {
241
- ...this._runtimeContext.properties,
242
- ...context.properties,
243
- },
244
- });
245
- }
246
- return this._runtimeContext;
247
- }), tap(() => (this._isInitialized = true)));
221
+ cleanup() {
222
+ this.flowSubj$.next(null);
223
+ this.params = undefined;
224
+ this.templates = {};
248
225
  }
249
- overrideUIDefinition(uiDefinitionContainer) {
250
- if (!this._runtimeContext) {
251
- return;
226
+ initFlowTemplates$(flow) {
227
+ if (isEmpty(flow.properties.templates)) {
228
+ return of(undefined);
252
229
  }
253
- this._runtimeContext.uiDefinitionContainer = uiDefinitionContainer;
254
- this.uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
230
+ return forkJoin([
231
+ this.templatesApiService.fetchTemplates$(),
232
+ this.customizationService?.getTemplates?.() ?? of([]),
233
+ ]).pipe(map$1(([templates, localTemplates]) => {
234
+ Object.entries({ ...this.defaultTemplates, ...flow.properties.templates }).forEach(([key, name]) => {
235
+ const type = this.remapTemplateName(key);
236
+ if (type) {
237
+ this.templates[type] =
238
+ localTemplates.find(template => template.name === name && template.type === type) ??
239
+ templates.find(template => template.name === name && template.type === type);
240
+ }
241
+ });
242
+ }));
255
243
  }
256
- id15to18(propertyName, source) {
257
- if (!source) {
258
- return;
244
+ remapTemplateName(templateType) {
245
+ switch (templateType) {
246
+ case 'flowEngine':
247
+ return UITemplateType.FLOW_ENGINE;
248
+ default:
249
+ break;
259
250
  }
260
- const value = source[propertyName];
261
- if (typeof value === 'string' && value.length === 15) {
262
- source[propertyName] = SalesforceIdUtils.generateId18FromId15(value);
251
+ switch (templateType) {
252
+ case 'assets':
253
+ case 'shoppingCart':
254
+ // No separate Assets template at the moment
255
+ return UITemplateType.SHOPPING_CART;
256
+ case 'catalog':
257
+ return UITemplateType.CATALOG;
258
+ case 'docGen':
259
+ return UITemplateType.DOCGEN;
260
+ case 'guidedSelling':
261
+ return UITemplateType.GUIDED_SELLING;
262
+ case 'flowHeader':
263
+ return UITemplateType.FLOW_HEADER;
264
+ default:
265
+ break;
263
266
  }
264
- }
265
- get isInitialized() {
266
- return this._isInitialized;
267
- }
268
- get runtimeModel() {
269
- return this.runtimeContext?.runtimeModel;
270
- }
271
- get runtimeContext() {
272
- return this._runtimeContext;
267
+ return undefined;
273
268
  }
274
269
  }
275
- ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.ConfigurationApiService }, { token: ContextService }, { token: RuntimeContextService }], target: i0.ɵɵFactoryTarget.Injectable });
276
- ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationRuntimeService });
277
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
278
- type: Injectable
279
- }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
270
+ FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: i1.FlowsApiService }, { token: i1.UITemplatesApiService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
271
+ FlowInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, providedIn: 'root' });
272
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, decorators: [{
273
+ type: Injectable,
274
+ args: [{ providedIn: 'root' }]
275
+ }], ctorParameters: function () { return [{ type: i1.FlowsApiService }, { type: i1.UITemplatesApiService }, { type: undefined, decorators: [{
276
+ type: Optional
277
+ }, {
278
+ type: Inject,
279
+ args: [FLOW_CUSTOMIZATION]
280
+ }] }]; } });
280
281
 
281
- class QuoteDraftService {
282
- get isInitialized() {
283
- return this.isInitializedSubj$.getValue();
284
- }
285
- set isInitialized(value) {
286
- if (this.isInitialized !== value) {
287
- this.isInitializedSubj$.next(value);
282
+ const findLineItem = (id, lineItems) => {
283
+ return findLineItemWithComparator(lineItems, (li) => li.id === id);
284
+ };
285
+ const findLineItemWithComparator = (lineItems, comparator) => {
286
+ let currentLevel = lineItems;
287
+ while (currentLevel.length) {
288
+ const found = currentLevel.find(comparator);
289
+ if (found) {
290
+ return found;
288
291
  }
292
+ currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
289
293
  }
290
- get hasUnsavedChanges() {
291
- return this._hasUnsavedChanges;
292
- }
293
- set hasUnsavedChanges(value) {
294
- this._hasUnsavedChanges = value;
295
- if (!this._hasUnsavedChanges) {
296
- this.initialCurrentState = this.quoteDraft?.currentState ?? [];
294
+ return;
295
+ };
296
+ const insertLineItem = (lineItem, parentId, toInsert) => {
297
+ const insertData = lineItem.id === parentId ? [toInsert] : [];
298
+ return {
299
+ ...lineItem,
300
+ lineItems: [
301
+ ...insertData,
302
+ ...lineItem.lineItems.map(li => {
303
+ return insertLineItem(li, parentId, toInsert);
304
+ }),
305
+ ],
306
+ };
307
+ };
308
+ const removeLineItem = (lineItem, idToRemove) => {
309
+ return {
310
+ ...lineItem,
311
+ lineItems: lineItem.lineItems
312
+ .map(li => {
313
+ if (li.id === idToRemove) {
314
+ return;
315
+ }
316
+ else if (li.lineItems.length) {
317
+ return removeLineItem(li, idToRemove);
318
+ }
319
+ return li;
320
+ })
321
+ .filter(r => !!r),
322
+ };
323
+ };
324
+ const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false) => {
325
+ if (lineItem.id === replaceTo.id) {
326
+ if (!skipCardinalityCalculation) {
327
+ return { ...recalculateCardinalityVariables(lineItem, replaceTo) };
297
328
  }
298
- }
299
- get hasProducts$() {
300
- return this.quoteSubj$.pipe(map(() => this.hasProducts));
301
- }
302
- get hasProducts() {
303
- const quoteDraft = this.quoteSubj$.value;
304
- return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
305
- }
306
- constructor(context, quoteApiService, priceApiService) {
307
- this.context = context;
308
- this.quoteApiService = quoteApiService;
309
- this.priceApiService = priceApiService;
310
- this.quoteSubj$ = new BehaviorSubject(null);
311
- this.resetSubj$ = new BehaviorSubject(true);
312
- this.isInitializedSubj$ = new BehaviorSubject(false);
313
- this.initialCurrentState = [];
314
- this._hasUnsavedChanges = false;
315
- this.allPriceLists = [];
316
- this.assetPriceLists = [];
317
- this.reset$ = this.resetSubj$.asObservable();
318
- this.activePriceList$ = this.context.resolve$().pipe(map(ctx => this.allPriceLists.find(priceList => priceList.id === ctx.properties.PriceListId)), map(priceList => priceList ?? null));
319
- this.isInitializedSubj$
320
- .pipe(filter(isInitialized => isInitialized), switchMap(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
321
- .subscribe();
322
- }
323
- reset() {
324
- this.resetSubj$.next(true);
325
- this.quoteSubj$.next(null);
326
- this.hasUnsavedChanges = false;
327
- }
328
- init(quoteId, params) {
329
- return zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()).pipe(tap(([quote, allPriceLists]) => {
330
- this.allPriceLists = allPriceLists;
331
- this.quoteSubj$.next(quote);
332
- this.context.update(quote.context);
333
- this.populateActivePriceLists$();
334
- }), map(() => noop()), take(1));
335
- }
336
- setCurrentLineItemState(lineItems) {
337
- const quoteDraft = this.quoteSubj$.value;
338
- if (!quoteDraft) {
339
- return;
340
- }
341
- this.quoteSubj$.next({
342
- ...quoteDraft,
343
- currentState: lineItems,
344
- });
345
- }
346
- updateQuoteDraft(update) {
347
- const quoteDraft = this.quoteSubj$.value;
348
- if (!quoteDraft) {
349
- return;
350
- }
351
- if (update.context) {
352
- this.context.set(update.context);
353
- }
354
- this.quoteSubj$.next({
355
- ...quoteDraft,
356
- ...update,
357
- });
358
- }
359
- updateByPriceSummary(priceSummary) {
360
- const quoteDraft = this.quoteSubj$.value;
361
- if (!quoteDraft) {
362
- return;
363
- }
364
- const updatedCurrentState = this.currentState.map(lineItem => {
365
- const updated = priceSummary.lineItems.find(li => li.id === lineItem.id);
366
- return updated ?? lineItem;
367
- });
368
- this.quoteSubj$.next({
369
- ...quoteDraft,
370
- currentState: updatedCurrentState,
371
- totalPrices: priceSummary.totalPrices,
372
- approvalItems: priceSummary.approvalItems,
373
- });
374
- }
375
- get quoteDraft$() {
376
- return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map(() => this.quoteDraft), filter((quote) => Boolean(quote)), shareReplay());
377
- }
378
- get quoteDraft() {
379
- const quote = this.quoteSubj$.value;
380
- if (!quote) {
381
- return null;
382
- }
383
- return {
384
- ...quote,
385
- context: this.context.resolve(),
386
- };
387
- }
388
- get quoteDraftForActivePriceList() {
389
- const quoteDraft = this.quoteDraft;
390
- if (!quoteDraft) {
391
- return null;
392
- }
393
- return {
394
- ...quoteDraft,
395
- initialState: this.filterByActivePriceList(quoteDraft.initialState),
396
- currentState: this.filterByActivePriceList(quoteDraft.currentState),
397
- };
398
- }
399
- get currentState$() {
400
- return this.quoteDraft$.pipe(map(quote => quote.currentState));
401
- }
402
- get currentState() {
403
- return this.quoteDraft?.currentState ?? [];
404
- }
405
- /**
406
- * Stream of activeCurrentState
407
- */
408
- get activeCurrentState$() {
409
- return this.quoteDraft$.pipe(map(() => this.activeCurrentState));
410
- }
411
- /**
412
- * activeCurrentState is currentState passed through additional filters
413
- */
414
- get activeCurrentState() {
415
- let currentState = this.quoteDraft?.currentState ?? [];
416
- currentState = this.filterByActivePriceList(currentState);
417
- return currentState;
418
- }
419
- /**
420
- * Stream of activeInitialState
421
- */
422
- get activeInitialState$() {
423
- return this.quoteDraft$.pipe(map(() => this.activeInitialState));
424
- }
425
- /**
426
- * activeInitialState is initialState passed through additional filters
427
- */
428
- get activeInitialState() {
429
- const ctx = this.context.resolve();
430
- let initialState = this.quoteDraft?.initialState ?? [];
431
- if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
432
- initialState = this.filterByActivePriceList(initialState);
433
- }
434
- return initialState;
435
- }
436
- get isStandalone() {
437
- return this.context.resolve().properties.standalone === 'true';
438
- }
439
- get isStandalone$() {
440
- return this.context.resolve$().pipe(map(() => this.isStandalone));
441
- }
442
- getInitialCurrentState() {
443
- return this.initialCurrentState;
444
- }
445
- isEditMode$() {
446
- return this.context.resolve$().pipe(map(() => this.isEditMode()));
447
- }
448
- isEditMode() {
449
- const context = this.context.resolve();
450
- if (context.mode === ConfigurationContextMode.ACCOUNT) {
451
- return true;
452
- }
453
- if (context.mode === ConfigurationContextMode.QUOTE) {
454
- return context.properties.Status === 'Draft';
455
- }
456
- return false;
457
- }
458
- updateActivePriceList(priceListId) {
459
- this.context.update({ properties: { PriceListId: priceListId } });
460
- }
461
- populateActivePriceLists$() {
462
- const ctx = this.context.resolve();
463
- const quoteDraft = this.quoteDraft;
464
- if (!quoteDraft) {
465
- return;
466
- }
467
- // In ACCOUNT mode populate price lists from related assets
468
- if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
469
- // Populate list of price lists
470
- this.assetPriceLists = quoteDraft.currentState
471
- .map(({ priceListId }) => priceListId)
472
- .reduce((trunk, priceListId) => {
473
- if (!priceListId || trunk.some(item => item.id === priceListId)) {
474
- return trunk;
475
- }
476
- return [
477
- ...trunk,
478
- { id: priceListId, name: this.allPriceLists.find(item => item.id === priceListId)?.name ?? '' },
479
- ];
480
- }, []);
481
- }
482
- }
483
- filterByActivePriceList(lineItems) {
484
- const ctx = this.context.resolve();
485
- return lineItems.filter(li => !li.priceListId || li.priceListId === ctx.properties.PriceListId);
486
- }
487
- markAsUpdated(quote) {
488
- if (quote?.context.properties.mode === ConfigurationContextMode.ACCOUNT) {
489
- this.hasUnsavedChanges = !!quote && !quote.currentState.every(li => li.actionCode === 'EXIST');
490
- }
491
- else {
492
- this.hasUnsavedChanges = !isEqual(this.initialCurrentState, quote?.currentState);
493
- }
494
- }
495
- }
496
- QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.QuoteApiService }, { token: i1.PriceApiService }], target: i0.ɵɵFactoryTarget.Injectable });
497
- QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: QuoteDraftService, providedIn: 'root' });
498
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: QuoteDraftService, decorators: [{
499
- type: Injectable,
500
- args: [{ providedIn: 'root' }]
501
- }], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }]; } });
502
-
503
- const findLineItem = (id, lineItems) => {
504
- return findLineItemWithComparator(lineItems, (li) => li.id === id);
505
- };
506
- const findLineItemWithComparator = (lineItems, comparator) => {
507
- let currentLevel = lineItems;
508
- while (currentLevel.length) {
509
- const found = currentLevel.find(comparator);
510
- if (found) {
511
- return found;
512
- }
513
- currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
514
- }
515
- return;
516
- };
517
- const insertLineItem = (lineItem, parentId, toInsert) => {
518
- const insertData = lineItem.id === parentId ? [toInsert] : [];
519
- return {
520
- ...lineItem,
521
- lineItems: [
522
- ...insertData,
523
- ...lineItem.lineItems.map(li => {
524
- return insertLineItem(li, parentId, toInsert);
525
- }),
526
- ],
527
- };
528
- };
529
- const removeLineItem = (lineItem, idToRemove) => {
530
- return {
531
- ...lineItem,
532
- lineItems: lineItem.lineItems
533
- .map(li => {
534
- if (li.id === idToRemove) {
535
- return;
536
- }
537
- else if (li.lineItems.length) {
538
- return removeLineItem(li, idToRemove);
539
- }
540
- return li;
541
- })
542
- .filter(r => !!r),
543
- };
544
- };
545
- const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false) => {
546
- if (lineItem.id === replaceTo.id) {
547
- if (!skipCardinalityCalculation) {
548
- return { ...recalculateCardinalityVariables(lineItem, replaceTo) };
549
- }
550
- else {
551
- return { ...replaceTo };
329
+ else {
330
+ return { ...replaceTo };
552
331
  }
553
332
  }
554
333
  return {
@@ -666,7 +445,7 @@ const multiplyLineItems = (lineItem, qty, split) => {
666
445
  id: UUID.UUID(),
667
446
  lineItems: lineItem.lineItems.map(unifyIds),
668
447
  });
669
- return map$1(new Array(qty), () => unifyIds(lineItem));
448
+ return map$2(new Array(qty), () => unifyIds(lineItem));
670
449
  }
671
450
  else {
672
451
  return [
@@ -726,205 +505,1635 @@ class LineItemWorker {
726
505
  }
727
506
  }
728
507
 
729
- class ConfigurationService {
730
- constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService) {
731
- this.quoteDraftService = quoteDraftService;
732
- this.runtimeService = runtimeService;
733
- this.contextService = contextService;
734
- this.configurationApiService = configurationApiService;
735
- this.messageService = messageService;
736
- this.dialogService = dialogService;
737
- this.mode = ConfigurationMode.SEARCH;
738
- this.lineItem = new BehaviorSubject(undefined);
739
- this.charges = new BehaviorSubject({});
740
- this.pricePlans = new BehaviorSubject({});
741
- this.isLoadingSubj$ = new BehaviorSubject(false);
742
- this.isLoading$ = this.isLoadingSubj$.asObservable();
743
- this.hasUnsavedChanges = false;
508
+ function extractMetadata(uiDefinition) {
509
+ return omit(uiDefinition, [
510
+ 'children',
511
+ 'pages',
512
+ 'components',
513
+ ]);
514
+ }
515
+
516
+ class IntegrationState {
517
+ constructor() {
518
+ this.stateSubj$ = new BehaviorSubject({});
519
+ this.action$ = new Subject();
744
520
  }
745
- reset() {
746
- this.hasUnsavedChanges = false;
747
- this.runtimeService.reset();
748
- this.configurableRamp = undefined;
749
- this.lineItem.next(undefined);
750
- this.charges.next({});
751
- this.pricePlans.next({});
521
+ get state$() {
522
+ return this.stateSubj$.asObservable();
752
523
  }
753
- patch$(lineItem, options) {
754
- if (!this.lineItem.value) {
755
- return throwError(() => new Error(`Source LineItem not found`));
756
- }
757
- const skipCardinalityCalculation = options?.skipCardinalityCalculation || this.contextSnapshot.properties['#skipCardinalityCalculation'] === 'true';
758
- this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem, skipCardinalityCalculation).li;
759
- return this.configure().pipe(catchError(error => {
760
- console.error(error);
761
- if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
762
- this.messageService.add({ severity: 'error', summary: error });
763
- }
764
- // bounce back if configuration call has failed
765
- this.lineItem.next(this.lineItem.value ? { ...this.lineItem.value } : undefined);
766
- return throwError(() => error);
767
- }), tap(() => {
768
- if (!this.hasUnsavedChanges) {
769
- this.hasUnsavedChanges = true;
770
- }
771
- }));
524
+ get state() {
525
+ return this.stateSubj$.getValue();
772
526
  }
773
- patch(lineItem, options) {
774
- this.patch$(lineItem, options).subscribe();
527
+ patchState(update) {
528
+ this.stateSubj$.next({ ...this.stateSubj$.getValue(), ...update });
775
529
  }
776
- setConfigurableRamp(lineItem) {
777
- this.configurableRamp = lineItem;
530
+ dispatch(action) {
531
+ this.action$.next(action);
778
532
  }
779
- get() {
780
- return this.lineItem.asObservable().pipe(shareReplay$1());
533
+ listen$(actionType) {
534
+ return this.action$.pipe(filter$1(action => action.type === actionType), map$1(action => action.payload));
781
535
  }
782
- getSnapshot() {
783
- return this.lineItem.value ? { ...this.lineItem.value } : undefined;
536
+ listenAll$() {
537
+ return this.action$.asObservable();
784
538
  }
785
- getRuntimeModel() {
786
- const runtimeModel = this.runtimeService.runtimeModel;
787
- if (!runtimeModel) {
788
- throw new Error('Runtime model not initialized');
539
+ clear() {
540
+ this.stateSubj$.next({});
541
+ }
542
+ }
543
+ IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
544
+ IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, providedIn: 'root' });
545
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, decorators: [{
546
+ type: Injectable,
547
+ args: [{ providedIn: 'root' }]
548
+ }] });
549
+
550
+ class QuoteDraftService {
551
+ get isInitialized$() {
552
+ return this.isInitializedSubj$.asObservable();
553
+ }
554
+ get isInitialized() {
555
+ return this.isInitializedSubj$.getValue();
556
+ }
557
+ set isInitialized(value) {
558
+ if (this.isInitialized !== value) {
559
+ this.isInitializedSubj$.next(value);
789
560
  }
790
- return runtimeModel;
791
561
  }
792
- getRuntimeContext() {
793
- const runtimeContext = this.runtimeService.runtimeContext;
794
- if (!runtimeContext) {
795
- throw new Error('Runtime context not initialized');
562
+ get hasUnsavedChanges() {
563
+ return this._hasUnsavedChanges;
564
+ }
565
+ set hasUnsavedChanges(value) {
566
+ this._hasUnsavedChanges = value;
567
+ if (!this._hasUnsavedChanges) {
568
+ this.initialCurrentState = this.quoteDraft?.currentState ?? [];
796
569
  }
797
- return runtimeContext;
798
570
  }
799
- get contextSnapshot() {
800
- return this.contextService.resolve();
571
+ get hasProducts$() {
572
+ return this.quoteSubj$.pipe(map(() => this.hasProducts));
801
573
  }
802
- get context$() {
803
- return this.contextService.resolve$();
574
+ get hasProducts() {
575
+ const quoteDraft = this.quoteSubj$.value;
576
+ return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
804
577
  }
805
- get charges$() {
806
- return this.charges.asObservable();
578
+ get hasAssets$() {
579
+ return this.quoteSubj$.pipe(map(() => this.hasAssets));
807
580
  }
808
- get chargesSnapshot() {
809
- return this.charges.value;
581
+ get hasAssets() {
582
+ const quoteDraft = this.quoteSubj$.value;
583
+ return quoteDraft?.currentState.some(li => li.assetId || li.openOrderLineItemId) ?? false;
810
584
  }
811
- get pricePlans$() {
812
- return this.pricePlans.asObservable();
585
+ constructor(context, quoteApiService, priceApiService, integrationState) {
586
+ this.context = context;
587
+ this.quoteApiService = quoteApiService;
588
+ this.priceApiService = priceApiService;
589
+ this.integrationState = integrationState;
590
+ this.quoteSubj$ = new BehaviorSubject(null);
591
+ this.resetSubj$ = new BehaviorSubject(true);
592
+ this.isInitializedSubj$ = new BehaviorSubject(false);
593
+ this.initialCurrentState = [];
594
+ this._hasUnsavedChanges = false;
595
+ this.allPriceLists = [];
596
+ this.assetPriceLists = [];
597
+ this.reset$ = this.resetSubj$.asObservable();
598
+ this.activePriceList$ = this.context.resolve$().pipe(map(ctx => this.allPriceLists.find(priceList => priceList.id === ctx.properties.PriceListId)), map(priceList => priceList ?? null));
599
+ this.isInitializedSubj$
600
+ .pipe(filter(isInitialized => isInitialized), switchMap$1(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
601
+ .subscribe();
813
602
  }
814
- get pricePlansSnapshot() {
815
- return this.pricePlans.value;
603
+ reset() {
604
+ this.resetSubj$.next(true);
605
+ this.quoteSubj$.next(null);
606
+ this.isInitialized = false;
607
+ this.hasUnsavedChanges = false;
816
608
  }
817
- configure() {
818
- return this.configureRequest$(this.generateRequest());
609
+ init(quoteId, params) {
610
+ return zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()).pipe(tap(([quote, allPriceLists]) => {
611
+ this.allPriceLists = allPriceLists;
612
+ this.quoteSubj$.next(quote);
613
+ this.context.update(quote.context);
614
+ this.populateActivePriceLists$();
615
+ }), map(() => noop()), take(1));
819
616
  }
820
- configureRequest$(configurationRequest) {
821
- const runtimeContext = this.getRuntimeContext();
822
- const runtimeModel = this.getRuntimeModel();
823
- const uiDefinitionProperties = this.getUIDefinitionProperties();
824
- const mainPricingEnabled = runtimeContext.properties?.PricingEnabled;
825
- const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
826
- this.isLoadingSubj$.next(true);
827
- return this.configurationApiService.configureLineItem({ configurationRequest, runtimeModel, pricingEnabled }).pipe(tap(({ lineItem, context, charges, pricePlans, deletedLineItems }) => {
828
- this.contextService.update(context ?? {});
829
- this.charges.next(charges ?? {});
830
- this.pricePlans.next(pricePlans ?? {});
831
- if (lineItem) {
832
- this.lineItem.next(lineItem);
833
- }
834
- if (deletedLineItems?.length) {
835
- this.showInactiveProductsConfirmation();
836
- }
837
- this.configurableRamp = lineItem;
838
- }), map(({ lineItem }) => lineItem), catchError(error => throwError(() => new Error(error.error?.message || error.message || JSON.stringify(error)))), finalize(() => this.isLoadingSubj$.next(false)));
617
+ finalizeInit() {
618
+ this.initializeModifiedAssetsMap();
619
+ this.isInitialized = true;
620
+ this.hasUnsavedChanges = false;
839
621
  }
840
- configureExternal$(props) {
841
- return this.runtimeService
842
- .init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
843
- .pipe(switchMap(() => this.configure()), first(), catchError(error => {
844
- this.messageService.add({ severity: ToastType.error, summary: error });
845
- throw error;
846
- }), finalize(() => this.reset()));
622
+ setCurrentLineItemState(lineItems) {
623
+ const quoteDraft = this.quoteSubj$.value;
624
+ if (!quoteDraft) {
625
+ return;
626
+ }
627
+ this.quoteSubj$.next({
628
+ ...quoteDraft,
629
+ currentState: lineItems,
630
+ });
847
631
  }
848
- configureGuidedSelling$(data) {
849
- return this.configurationApiService
850
- .configureLineItem({
851
- configurationRequest: getGuidedSellingConfigurationRequest(data),
852
- })
853
- .pipe(catchError(error => {
854
- if (error instanceof HttpErrorResponse) {
855
- this.messageService.add({ severity: ToastType.error, summary: error.error.message || error.error });
856
- }
857
- throw error;
858
- }));
632
+ updateQuoteDraft(update) {
633
+ const quoteDraft = this.quoteSubj$.value;
634
+ if (!quoteDraft) {
635
+ return;
636
+ }
637
+ if (update.context) {
638
+ this.context.set(update.context);
639
+ }
640
+ this.quoteSubj$.next({
641
+ ...quoteDraft,
642
+ ...update,
643
+ });
859
644
  }
860
- generateRequest() {
861
- const runtimeContext = this.getRuntimeContext();
862
- const uiDefinitionProperties = this.getUIDefinitionProperties();
863
- let lineItem = this.configurableRamp;
864
- if (!lineItem) {
865
- const { initializationProps } = this.runtimeService ?? {};
866
- lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps?.defaultQty);
867
- // Set default attributes
868
- if (initializationProps?.attributesMap) {
869
- const attributes = transform(initializationProps?.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
870
- lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
871
- }
645
+ updateByPriceSummary(priceSummary) {
646
+ const quoteDraft = this.quoteSubj$.value;
647
+ if (!quoteDraft) {
648
+ return;
872
649
  }
873
- let request = {
874
- lineItem,
875
- mode: this.mode,
876
- step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
877
- attributeDomainMode: 'ALL',
878
- context: this.contextService.resolve(),
879
- lineItems: this.quoteDraftService.quoteDraft?.currentState || [],
880
- asset: this.getAsset(),
881
- };
882
- request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
883
- return request;
650
+ const updatedCurrentState = this.currentState.map(lineItem => {
651
+ const updated = priceSummary.lineItems.find(li => li.id === lineItem.id);
652
+ return updated ?? lineItem;
653
+ });
654
+ this.quoteSubj$.next({
655
+ ...quoteDraft,
656
+ currentState: updatedCurrentState,
657
+ totalPrices: priceSummary.totalPrices,
658
+ approvalItems: priceSummary.approvalItems,
659
+ });
884
660
  }
885
- getUIDefinitionProperties() {
661
+ get quoteDraft$() {
662
+ return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map(() => this.quoteDraft), filter((quote) => Boolean(quote)), shareReplay());
663
+ }
664
+ get quoteDraft() {
665
+ const quote = this.quoteSubj$.value;
666
+ if (!quote) {
667
+ return null;
668
+ }
886
669
  return {
887
- ...getUIDefinitionProperties(this.getRuntimeContext().uiDefinitionContainer),
888
- ...(this.runtimeService.uiDefinitionProperties ?? {}),
670
+ ...quote,
671
+ context: this.context.resolve(),
889
672
  };
890
673
  }
891
- showInactiveProductsConfirmation() {
892
- const confirmationConfig = {
893
- title: ' ',
894
- description: 'This quote contains inactive products. Do you want to remove them?',
895
- primaryButtonLabel: 'Remove products',
896
- secondaryButtonLabel: 'Back to Quote',
674
+ get quoteDraftForActivePriceList() {
675
+ const quoteDraft = this.quoteDraft;
676
+ if (!quoteDraft) {
677
+ return null;
678
+ }
679
+ return {
680
+ ...quoteDraft,
681
+ initialState: this.filterByActivePriceList(quoteDraft.initialState),
682
+ currentState: this.filterByActivePriceList(quoteDraft.currentState),
897
683
  };
898
- this.dialogService
899
- .open(ConfirmationComponent, {
900
- dismissableMask: false,
901
- closeOnEscape: false,
902
- closable: false,
903
- showHeader: true,
904
- header: `Inactive Products in Quote`,
905
- width: '440px',
906
- data: { confirmationConfig },
907
- })
908
- .onClose.subscribe(result => {
909
- if (!result) {
910
- const context = this.contextService.resolve();
911
- window['VELO_BACK_FN'].apply(null, [context.headerId]);
912
- }
913
- });
914
684
  }
915
- getAsset() {
916
- const lineItem = this.configurableRamp;
917
- if (!lineItem) {
918
- return;
919
- }
920
- return this.quoteDraftService.quoteDraft?.initialState.find(a => a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId);
685
+ get currentState$() {
686
+ return this.quoteDraft$.pipe(map(quote => quote.currentState));
687
+ }
688
+ get currentState() {
689
+ return this.quoteDraft?.currentState ?? [];
690
+ }
691
+ /**
692
+ * Stream of activeCurrentState
693
+ */
694
+ get activeCurrentState$() {
695
+ return this.quoteDraft$.pipe(map(() => this.activeCurrentState));
696
+ }
697
+ /**
698
+ * activeCurrentState is currentState passed through additional filters
699
+ */
700
+ get activeCurrentState() {
701
+ let currentState = this.quoteDraft?.currentState ?? [];
702
+ currentState = this.filterByActivePriceList(currentState);
703
+ return currentState;
704
+ }
705
+ /**
706
+ * Stream of activeInitialState
707
+ */
708
+ get activeInitialState$() {
709
+ return this.quoteDraft$.pipe(map(() => this.activeInitialState));
710
+ }
711
+ /**
712
+ * activeInitialState is initialState passed through additional filters
713
+ */
714
+ get activeInitialState() {
715
+ const ctx = this.context.resolve();
716
+ let initialState = this.quoteDraft?.initialState ?? [];
717
+ if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
718
+ initialState = this.filterByActivePriceList(initialState);
719
+ }
720
+ return initialState;
721
+ }
722
+ get isStandalone() {
723
+ return this.context.resolve().properties.standalone === 'true';
724
+ }
725
+ get isStandalone$() {
726
+ return this.context.resolve$().pipe(map(() => this.isStandalone));
727
+ }
728
+ getInitialCurrentState() {
729
+ return this.initialCurrentState;
730
+ }
731
+ isEditMode$() {
732
+ return this.context.resolve$().pipe(map(() => this.isEditMode()));
733
+ }
734
+ isEditMode() {
735
+ const context = this.context.resolve();
736
+ if (context.mode === ConfigurationContextMode.ACCOUNT) {
737
+ return true;
738
+ }
739
+ if (context.mode === ConfigurationContextMode.QUOTE) {
740
+ return context.properties.Status === 'Draft';
741
+ }
742
+ return false;
743
+ }
744
+ updateActivePriceList(priceListId) {
745
+ this.context.update({ properties: { PriceListId: priceListId } });
746
+ }
747
+ populateActivePriceLists$() {
748
+ const ctx = this.context.resolve();
749
+ const quoteDraft = this.quoteDraft;
750
+ if (!quoteDraft) {
751
+ return;
752
+ }
753
+ // In ACCOUNT mode populate price lists from related assets
754
+ if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
755
+ // Populate list of price lists
756
+ this.assetPriceLists = quoteDraft.currentState
757
+ .map(({ priceListId }) => priceListId)
758
+ .reduce((trunk, priceListId) => {
759
+ if (!priceListId || trunk.some(item => item.id === priceListId)) {
760
+ return trunk;
761
+ }
762
+ return [
763
+ ...trunk,
764
+ { id: priceListId, name: this.allPriceLists.find(item => item.id === priceListId)?.name ?? '' },
765
+ ];
766
+ }, []);
767
+ }
768
+ }
769
+ filterByActivePriceList(lineItems) {
770
+ const ctx = this.context.resolve();
771
+ return lineItems.filter(li => !li.priceListId || li.priceListId === ctx.properties.PriceListId);
772
+ }
773
+ markAsUpdated(quote) {
774
+ if (quote?.context.properties.mode === ConfigurationContextMode.ACCOUNT) {
775
+ this.hasUnsavedChanges = !!quote && !quote.currentState.every(li => li.actionCode === 'EXIST');
776
+ }
777
+ else {
778
+ this.hasUnsavedChanges = !isEqual(this.initialCurrentState, quote?.currentState);
779
+ }
780
+ }
781
+ initializeModifiedAssetsMap() {
782
+ this.integrationState.patchState({
783
+ modifiedAssets: generateModifiedAssetsMap(this.currentState),
784
+ });
785
+ }
786
+ }
787
+ QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.QuoteApiService }, { token: i1.PriceApiService }, { token: IntegrationState }], target: i0.ɵɵFactoryTarget.Injectable });
788
+ QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, providedIn: 'root' });
789
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, decorators: [{
790
+ type: Injectable,
791
+ args: [{ providedIn: 'root' }]
792
+ }], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }, { type: IntegrationState }]; } });
793
+
794
+ class FlowStateService {
795
+ constructor(contextService, quoteDraftService, flowInfoService, flowConfiguration, processorsApiService, flowStateApiService, quoteApiService, toastService, customizationService) {
796
+ this.contextService = contextService;
797
+ this.quoteDraftService = quoteDraftService;
798
+ this.flowInfoService = flowInfoService;
799
+ this.flowConfiguration = flowConfiguration;
800
+ this.processorsApiService = processorsApiService;
801
+ this.flowStateApiService = flowStateApiService;
802
+ this.quoteApiService = quoteApiService;
803
+ this.toastService = toastService;
804
+ this.customizationService = customizationService;
805
+ this.NOT_INITIALIZED = Symbol();
806
+ this._hasStatefulUnsavedChanges = false;
807
+ this.stateId$ = new BehaviorSubject(null);
808
+ this.processors = {};
809
+ this.subscriptions = {};
810
+ this.cleanup$ = new Subject();
811
+ /*
812
+ In stateless mode watch QuoteDraft changes and call executeRequest so that
813
+ all subscriptions get their updates according to updated QuoteDraft
814
+ */
815
+ this.isInitialized$()
816
+ .pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
817
+ .subscribe();
818
+ this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
819
+ if (!flow.properties.stateful) {
820
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.charges));
821
+ }
822
+ else {
823
+ return this.subscribe$(UITemplateType.FLOW_ENGINE, 'CHARGES', null, {
824
+ cold: true,
825
+ }).pipe(map$1(response => (response.success ? response.result : {})));
826
+ }
827
+ }), filter$1(isDefined), shareReplay$1());
828
+ this.charges$.subscribe();
829
+ this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
830
+ if (!flow.properties.stateful) {
831
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.pricePlans));
832
+ }
833
+ else {
834
+ return this.subscribe$(UITemplateType.FLOW_ENGINE, 'PRICE_PLANS', null, {
835
+ cold: true,
836
+ }).pipe(map$1(response => (response.success ? response.result : {})));
837
+ }
838
+ }), filter$1(isDefined), shareReplay$1());
839
+ this.pricePlans$.subscribe();
840
+ this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
841
+ if (!flow.properties.stateful) {
842
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.activeMetrics));
843
+ }
844
+ else {
845
+ return this.subscribe$(UITemplateType.FLOW_ENGINE, 'ACTIVE_METRICS', null, {
846
+ cold: true,
847
+ }).pipe(map$1(response => (response.success ? response.result : [])));
848
+ }
849
+ }), filter$1(isDefined), shareReplay$1());
850
+ this.activeMetrics$.subscribe();
851
+ }
852
+ init$() {
853
+ return this.initProcessors$().pipe(switchMap(() => {
854
+ if (this.getFlowSafe().properties.stateful) {
855
+ return this.initStateful$();
856
+ }
857
+ else {
858
+ return this.initStateless$();
859
+ }
860
+ }));
861
+ }
862
+ cleanup() {
863
+ Object.values(this.subscriptions).forEach(({ data$ }) => data$.complete());
864
+ this.subscriptions = {};
865
+ if (this.stateId$.value) {
866
+ this.flowStateApiService.cancel(this.stateId$.value).subscribe();
867
+ this.stateId$.next(null);
868
+ }
869
+ this.processors = {};
870
+ this.cleanup$.next();
871
+ }
872
+ get hasUnsavedChanges() {
873
+ return this.getFlowSafe().properties.stateful
874
+ ? this._hasStatefulUnsavedChanges
875
+ : this.quoteDraftService.hasUnsavedChanges;
876
+ }
877
+ get stateId() {
878
+ return this.stateId$.value;
879
+ }
880
+ isInitialized$() {
881
+ return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map$1(values => values.some(Boolean)));
882
+ }
883
+ isInitialized() {
884
+ return Boolean(this.stateId$.value) || this.quoteDraftService.isInitialized;
885
+ }
886
+ execute$(scope, exec) {
887
+ const request = this.execToRequest(scope, exec);
888
+ return this.executeRequest$(request).pipe(map$1(result => {
889
+ // Keep only requested results
890
+ const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
891
+ if (exec.selectors?.[requestId]) {
892
+ trunk[requestId] = result;
893
+ }
894
+ return trunk;
895
+ }, {});
896
+ return actualSelectors;
897
+ }));
898
+ }
899
+ dispatch$(scope, action, inputData) {
900
+ const exec = {
901
+ actions: [{ name: action, inputData }],
902
+ };
903
+ const request = this.execToRequest(scope, exec);
904
+ return this.executeRequest$(request).pipe(map$1(noop));
905
+ }
906
+ select$(scope, selectorName, inputData) {
907
+ const requestId = this.generateRequestId(scope, selectorName, inputData);
908
+ const request = this.execToRequest(scope, {
909
+ selectors: {
910
+ [requestId]: {
911
+ name: selectorName,
912
+ inputData,
913
+ },
914
+ },
915
+ });
916
+ return this.executeRequest$(request).pipe(map$1(response => response.selectors[requestId]));
917
+ }
918
+ subscribe$(scope, selectorName, inputData, options) {
919
+ const requestId = this.generateRequestId(scope, selectorName, inputData);
920
+ if (!this.subscriptions[requestId]) {
921
+ const request = this.execToRequest(scope, {
922
+ selectors: {
923
+ [requestId]: {
924
+ name: selectorName,
925
+ inputData,
926
+ },
927
+ },
928
+ });
929
+ this.subscriptions[requestId] = {
930
+ request,
931
+ data$: new BehaviorSubject(this.NOT_INITIALIZED),
932
+ };
933
+ if (!options?.cold) {
934
+ this.executeRequest$(request).subscribe();
935
+ }
936
+ }
937
+ return this.subscriptions[requestId].data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map$1(data => data), finalize(() => {
938
+ if (!this.subscriptions[requestId].data$.observed) {
939
+ delete this.subscriptions[requestId];
940
+ }
941
+ }));
942
+ }
943
+ save$() {
944
+ if (this.getFlowSafe().properties.stateful) {
945
+ if (this.stateId$.value) {
946
+ return this.flowStateApiService.save(this.stateId$.value);
947
+ }
948
+ }
949
+ else {
950
+ const quoteDraft = this.quoteDraftService.quoteDraftForActivePriceList;
951
+ if (quoteDraft) {
952
+ return this.quoteApiService.upsertQuote(quoteDraft);
953
+ }
954
+ }
955
+ return of({ quoteId: '' });
956
+ }
957
+ submit$() {
958
+ if (this.getFlowSafe().properties.stateful) {
959
+ if (this.stateId$.value) {
960
+ return this.flowStateApiService.submit(this.stateId$.value);
961
+ }
962
+ }
963
+ else {
964
+ const quoteDraft = this.quoteDraftService.quoteDraftForActivePriceList;
965
+ if (quoteDraft) {
966
+ return this.quoteApiService.submitQuote(quoteDraft);
967
+ }
968
+ }
969
+ return of({ quoteId: '' });
970
+ }
971
+ getOwnerIdByScope(scope) {
972
+ const ownerId = this.flowInfoService.templates[scope]?.id;
973
+ if (!ownerId) {
974
+ throw `OwnerId is not found for scope ${scope}`;
975
+ }
976
+ return ownerId;
977
+ }
978
+ getScopeByOwnerId(id) {
979
+ for (const template of Object.values(this.flowInfoService.templates)) {
980
+ if (template.id === id) {
981
+ return template.type;
982
+ }
983
+ }
984
+ return;
985
+ }
986
+ execToRequest(scope, exec) {
987
+ const ownerId = this.getOwnerIdByScope(scope);
988
+ return {
989
+ actions: exec.actions?.map(action => ({ apiName: action.name, ownerId, inputData: action.inputData ?? {} })),
990
+ selectors: exec.selectors &&
991
+ Object.entries(exec.selectors).reduce((trunk, [key, selector]) => ({
992
+ ...trunk,
993
+ [key]: { apiName: selector.name, ownerId, inputData: selector.inputData ?? {} },
994
+ }), {}),
995
+ };
996
+ }
997
+ executeRequest$(request, forceSubscriptions = false) {
998
+ const fullRequest = cloneDeep(request);
999
+ if (fullRequest.actions?.length || forceSubscriptions) {
1000
+ for (const subscription of Object.values(this.subscriptions)) {
1001
+ fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
1002
+ }
1003
+ }
1004
+ const execution$ = this.getFlowSafe().properties.stateful
1005
+ ? this.executeStateful$(fullRequest)
1006
+ : this.executeStateless$(fullRequest);
1007
+ return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
1008
+ }
1009
+ handleSelectorsResponse(selectors) {
1010
+ Object.entries(selectors).forEach(([requestId, selectorResult]) => {
1011
+ if (!selectorResult.success) {
1012
+ this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
1013
+ }
1014
+ const subscription$ = this.subscriptions[requestId]?.data$;
1015
+ if (subscription$) {
1016
+ subscription$.next(selectorResult);
1017
+ }
1018
+ });
1019
+ }
1020
+ initStateful$() {
1021
+ // Subscriptions
1022
+ this.subscribe$(UITemplateType.FLOW_ENGINE, 'CONTEXT', null, { cold: true })
1023
+ .pipe(tap$1(response => {
1024
+ if (response.success) {
1025
+ this.contextService.update(response.result);
1026
+ }
1027
+ }), takeUntil(this.cleanup$))
1028
+ .subscribe();
1029
+ const processorsList = flatten(Object.values(this.processors).map(ownerMap => Object.values(ownerMap ?? {})));
1030
+ const processors = processorsList.length ? processorsList : undefined;
1031
+ const selectors = Object.values(this.subscriptions)
1032
+ .map(({ request }) => request.selectors)
1033
+ .filter(isDefined)
1034
+ .reduce((trunk, selectors) => ({ ...trunk, ...selectors }), {});
1035
+ const request = this.getDefaultExecutionRequestDTO();
1036
+ return this.flowStateApiService
1037
+ .init({
1038
+ quoteId: this.contextService.resolve().headerId,
1039
+ params: this.flowInfoService.params ?? {},
1040
+ actionsOverride: processors?.filter(processor => processor.type === ConfigurationProcessorTypes.ACTION),
1041
+ selectorsOverride: processors?.filter(processor => processor.type === ConfigurationProcessorTypes.SELECTOR),
1042
+ selectors: { ...selectors, ...request.selectors },
1043
+ actions: request.actions,
1044
+ })
1045
+ .pipe(map$1(({ stateId, selectors }) => {
1046
+ this.handleSelectorsResponse(selectors);
1047
+ this.stateId$.next(stateId);
1048
+ }));
1049
+ }
1050
+ executeStateful$(request) {
1051
+ if (!this.stateId$.value) {
1052
+ throw 'Stateful session is not initialized';
1053
+ }
1054
+ return this.flowStateApiService.execute(this.stateId$.value, request).pipe(tap$1(() => {
1055
+ if (request.actions?.length) {
1056
+ this._hasStatefulUnsavedChanges = true;
1057
+ }
1058
+ }), tap$1(response => this.stateId$.next(response.stateId)));
1059
+ }
1060
+ initStateless$() {
1061
+ const { headerId } = this.contextService.resolve();
1062
+ const stateInit$ = this.quoteDraftService.init(headerId, this.flowInfoService.params ?? {}).pipe(switchMap(() => this.executeRequest$(this.getDefaultExecutionRequestDTO())), switchMap(() => this.calculate$()));
1063
+ return stateInit$.pipe(tap$1(() => this.quoteDraftService.finalizeInit()), map$1(noop));
1064
+ }
1065
+ calculate$() {
1066
+ const flowState = this.quoteDraftService.quoteDraft;
1067
+ if (!flowState) {
1068
+ return of(undefined);
1069
+ }
1070
+ /*
1071
+ Don't execute procedures when:
1072
+ * Initializing a standalone product configuration UI, as procedure is execute in /price call
1073
+ * Initializing an empty account (account with no assets)
1074
+ */
1075
+ const isEmptyAccountMode = this.contextService.mode === ConfigurationContextMode.ACCOUNT && !this.quoteDraftService.hasProducts;
1076
+ if (this.quoteDraftService.isStandalone || isEmptyAccountMode) {
1077
+ return of(undefined);
1078
+ }
1079
+ return this.flowConfiguration.calculate$(flowState);
1080
+ }
1081
+ executeStateless$(request) {
1082
+ return of(undefined).pipe(tap$1(() => this.executeStatelessActions(request)), switchMap(() => {
1083
+ /*
1084
+ Skip price calculation in case
1085
+ 1. No actions in the request
1086
+ 2. Initialization process execution (state not initialized yet)
1087
+ */
1088
+ if (!request.actions?.length || !this.isInitialized()) {
1089
+ return of(undefined);
1090
+ }
1091
+ else {
1092
+ return this.calculate$();
1093
+ }
1094
+ }), map$1(() => this.executeStatelessSelectors(request)));
1095
+ }
1096
+ executeStatelessActions(request) {
1097
+ if (!this.quoteDraftService.quoteDraft || !request.actions?.length) {
1098
+ return;
1099
+ }
1100
+ let flowState = this.quoteDraftService.quoteDraft;
1101
+ request.actions.forEach(action => {
1102
+ flowState = this.executeActionScript(flowState, action) ?? flowState;
1103
+ });
1104
+ this.quoteDraftService.updateQuoteDraft(flowState);
1105
+ }
1106
+ executeStatelessSelectors(request) {
1107
+ if (!this.quoteDraftService.quoteDraft) {
1108
+ throw 'QuoteDraft is not initialized';
1109
+ }
1110
+ const flowState = this.quoteDraftService.quoteDraft;
1111
+ return EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
1112
+ try {
1113
+ result.selectors[key] = {
1114
+ success: true,
1115
+ result: this.executeSelectorScript(flowState, selector),
1116
+ };
1117
+ }
1118
+ catch (e) {
1119
+ result.selectors[key] = {
1120
+ success: false,
1121
+ errorMessage: String(e),
1122
+ };
1123
+ }
1124
+ return result;
1125
+ }, { stateId: '', selectors: {} });
1126
+ }
1127
+ getFlowSafe() {
1128
+ if (!this.flowInfoService.flow) {
1129
+ throw 'Flow is not defined';
1130
+ }
1131
+ return this.flowInfoService.flow;
1132
+ }
1133
+ initProcessors$() {
1134
+ const hasOverrides = Boolean(this.customizationService?.getTemplateConfigurationProcessors);
1135
+ const flow = this.getFlowSafe();
1136
+ if (flow.properties.stateful && !hasOverrides) {
1137
+ // Skip initialization as backend will take processors from SF
1138
+ return of(undefined);
1139
+ }
1140
+ const owners$ = Object.values(this.flowInfoService.templates)
1141
+ .map(template => {
1142
+ if (!template) {
1143
+ return;
1144
+ }
1145
+ const localProcessors$ = this.customizationService?.getTemplateConfigurationProcessors?.(template.name) ?? of(null);
1146
+ return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap$1(processors => {
1147
+ const processorsMap = processors.reduce((acc, p) => {
1148
+ acc[p.apiName] = p;
1149
+ return acc;
1150
+ }, {});
1151
+ this.processors[template.id] = processorsMap;
1152
+ }));
1153
+ })
1154
+ .filter(isDefined);
1155
+ if (!owners$.length) {
1156
+ return of(undefined);
1157
+ }
1158
+ return forkJoin(owners$).pipe(map$1(noop));
1159
+ }
1160
+ executeActionScript(request, executable) {
1161
+ const script = this.processors[executable.ownerId]?.[executable.apiName]?.script;
1162
+ if (!script) {
1163
+ const scope = this.getScopeByOwnerId(executable.ownerId);
1164
+ const scopeText = scope ? ` in ${scope}` : '';
1165
+ throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
1166
+ }
1167
+ return this.executeProcessorScript(request, script, executable.inputData);
1168
+ }
1169
+ executeSelectorScript(request, executable) {
1170
+ const script = this.processors[executable.ownerId]?.[executable.apiName]?.script;
1171
+ if (!script) {
1172
+ const scope = this.getScopeByOwnerId(executable.ownerId);
1173
+ const scopeText = scope ? ` in ${scope}` : '';
1174
+ throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
1175
+ }
1176
+ return this.executeProcessorScript(request, script, executable.inputData);
1177
+ }
1178
+ executeProcessorScript(request, script, inputData) {
1179
+ return new Function(`${script}\nreturn transform;`)()({
1180
+ request,
1181
+ inputData: inputData,
1182
+ });
1183
+ }
1184
+ generateRequestId(scope, selectorName, inputData) {
1185
+ const inputDataHash = UUID.hex(JSON.stringify(inputData) || '').slice(0, 8);
1186
+ return `${scope}/${selectorName}/${inputDataHash}`;
1187
+ }
1188
+ getDefaultExecutionRequestDTO() {
1189
+ const request = {
1190
+ actions: [],
1191
+ selectors: {},
1192
+ };
1193
+ if (this.getFlowSafe().properties.standalone) {
1194
+ return request;
1195
+ }
1196
+ const ownerId = this.getOwnerIdByScope(UITemplateType.FLOW_ENGINE);
1197
+ request.actions?.push({
1198
+ apiName: 'INITIALIZE_STATE',
1199
+ ownerId,
1200
+ inputData: {},
1201
+ });
1202
+ return request;
1203
+ }
1204
+ }
1205
+ FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: ContextService }, { token: QuoteDraftService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.ConfigurationProcessorsApiService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }, { token: i6.ToastService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1206
+ FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, providedIn: 'root' });
1207
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, decorators: [{
1208
+ type: Injectable,
1209
+ args: [{ providedIn: 'root' }]
1210
+ }], ctorParameters: function () { return [{ type: ContextService }, { type: QuoteDraftService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.ConfigurationProcessorsApiService }, { type: i1.FlowStateApiService }, { type: i1.QuoteApiService }, { type: i6.ToastService }, { type: undefined, decorators: [{
1211
+ type: Optional
1212
+ }, {
1213
+ type: Inject,
1214
+ args: [FLOW_CUSTOMIZATION]
1215
+ }] }]; } });
1216
+
1217
+ class RuntimeSettingsService {
1218
+ constructor(configurationSettingsApiService) {
1219
+ this.configurationSettingsApiService = configurationSettingsApiService;
1220
+ this.configurationSettings$ = new BehaviorSubject({});
1221
+ this.currencySettings$ = new BehaviorSubject({
1222
+ iso: DEFAULT_CURRENCY_ISO_CODE,
1223
+ symbol: DEFAULT_CURRENCY_SYMBOL,
1224
+ });
1225
+ this.shoppingCartSettings$ = new BehaviorSubject([]);
1226
+ this.getCurrencySymbol = (locale, currency) => {
1227
+ return (0)
1228
+ .toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
1229
+ .replace(/\d/g, '')
1230
+ .trim();
1231
+ };
1232
+ }
1233
+ create() {
1234
+ return this.configurationSettingsApiService.fetchSettings().pipe(map$1(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
1235
+ this.configurationSettings$.next(configurationSettings);
1236
+ this.addShoppingCartSettings(configurationSettings['shopping-cart'] ?? []);
1237
+ this.formattingSettings = this.getFormattingSettings();
1238
+ }), map$1(() => undefined));
1239
+ }
1240
+ initCurrency(iso) {
1241
+ if (iso) {
1242
+ const symbol = this.getCurrencySymbol('en-US', iso);
1243
+ this.currencySettings$.next({ iso, symbol });
1244
+ }
1245
+ }
1246
+ getFormattingSettings() {
1247
+ if (this.formattingSettings) {
1248
+ return this.formattingSettings;
1249
+ }
1250
+ const shoppingCartSettings = this.getConfigurationSettings()['shopping-cart']?.reduce((acc, setting) => {
1251
+ return { ...acc, [setting.id]: setting.properties };
1252
+ }, {});
1253
+ const currencySettings = this.getCurrencySettings();
1254
+ const dateFormat = (validateDateFormat(shoppingCartSettings?.DATE_FORMAT ?? '') && shoppingCartSettings?.DATE_FORMAT) ||
1255
+ DEFAULT_DATE_FORMAT;
1256
+ const decimalSeparator = shoppingCartSettings?.DECIMAL_SEPARATOR;
1257
+ const thousandsSeparator = shoppingCartSettings?.THOUSANDS_SEPARATOR;
1258
+ // the number of decimal places can be 0
1259
+ const priceScale = shoppingCartSettings?.PRICE_SCALE;
1260
+ const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
1261
+ ? Number(priceScale)
1262
+ : DEFAULT_DECIMALS_COUNT;
1263
+ const actionCodeSettings = shoppingCartSettings?.STATUS_LABEL;
1264
+ return {
1265
+ currencySymbol: currencySettings.symbol,
1266
+ dateFormats: getSupportedDateFormats(dateFormat),
1267
+ decimalsCount,
1268
+ decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
1269
+ ? decimalSeparator
1270
+ : DEFAULT_DECIMAL_SEPARATOR,
1271
+ // thousands separator can be a blank value, so it can also be null
1272
+ thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
1273
+ ? thousandsSeparator || ''
1274
+ : DEFAULT_THOUSANDS_SEPARATOR,
1275
+ actionCodeLabels: actionCodeSettings?.length
1276
+ ? actionCodeSettings.reduce((result, setting) => ({ ...result, [setting.status_label]: setting.custom_label }), {})
1277
+ : DEFAULT_ACTION_CODE_LABELS,
1278
+ };
1279
+ }
1280
+ getConfigurationSettings() {
1281
+ return this.configurationSettings$.value;
1282
+ }
1283
+ getShoppingCartSettings() {
1284
+ return this.shoppingCartSettings$.value;
1285
+ }
1286
+ getCurrencySettings() {
1287
+ return this.currencySettings$.value;
1288
+ }
1289
+ parseConfigurationSettings(settings) {
1290
+ return settings.reduce((acc, setting) => {
1291
+ switch (setting.key) {
1292
+ case 'shopping-cart':
1293
+ acc['shopping-cart'] = parseJsonSafely(setting.value, []);
1294
+ break;
1295
+ case 'navigation':
1296
+ acc.navigation = parseJsonSafely(setting.value, {});
1297
+ break;
1298
+ case 'flows':
1299
+ acc.flows = parseJsonSafely(setting.value, []);
1300
+ break;
1301
+ default:
1302
+ acc[setting.key] = setting.value;
1303
+ }
1304
+ return acc;
1305
+ }, {});
1306
+ }
1307
+ addShoppingCartSettings(settings) {
1308
+ // uniqBy removes items with the biggest index
1309
+ const newSettings = uniqBy([...settings, ...this.shoppingCartSettings$.value], 'id');
1310
+ this.shoppingCartSettings$.next(newSettings);
1311
+ }
1312
+ }
1313
+ RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1314
+ RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, providedIn: 'root' });
1315
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
1316
+ type: Injectable,
1317
+ args: [{ providedIn: 'root' }]
1318
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
1319
+
1320
+ class ConfigurationService {
1321
+ constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService, runtimeSettings) {
1322
+ this.quoteDraftService = quoteDraftService;
1323
+ this.runtimeService = runtimeService;
1324
+ this.contextService = contextService;
1325
+ this.configurationApiService = configurationApiService;
1326
+ this.messageService = messageService;
1327
+ this.dialogService = dialogService;
1328
+ this.runtimeSettings = runtimeSettings;
1329
+ this.mode = ConfigurationMode.SEARCH;
1330
+ this.lineItem = new BehaviorSubject(undefined);
1331
+ this.charges = new BehaviorSubject({});
1332
+ this.pricePlans = new BehaviorSubject({});
1333
+ this.procedureContext = new BehaviorSubject({});
1334
+ this.isLoadingSubj$ = new BehaviorSubject(false);
1335
+ this.isLoading$ = this.isLoadingSubj$.asObservable();
1336
+ this.hasUnsavedChanges = false;
1337
+ }
1338
+ reset() {
1339
+ this.hasUnsavedChanges = false;
1340
+ this.runtimeService.reset();
1341
+ this.configurableRamp = undefined;
1342
+ this.lineItem.next(undefined);
1343
+ this.charges.next({});
1344
+ this.pricePlans.next({});
1345
+ }
1346
+ patch$(lineItem, options) {
1347
+ if (!this.lineItem.value) {
1348
+ return throwError(() => new Error(`Source LineItem not found`));
1349
+ }
1350
+ const skipCardinalityCalculation = options?.skipCardinalityCalculation || this.contextSnapshot.properties['#skipCardinalityCalculation'] === 'true';
1351
+ this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem, skipCardinalityCalculation).li;
1352
+ return this.configure().pipe(catchError$1(error => {
1353
+ console.error(error);
1354
+ if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
1355
+ this.messageService.add({ severity: 'error', summary: error });
1356
+ }
1357
+ // bounce back if configuration call has failed
1358
+ this.lineItem.next(this.lineItem.value ? { ...this.lineItem.value } : undefined);
1359
+ return throwError(() => error);
1360
+ }), tap(() => {
1361
+ if (!this.hasUnsavedChanges) {
1362
+ this.hasUnsavedChanges = true;
1363
+ }
1364
+ }));
1365
+ }
1366
+ patch(lineItem, options) {
1367
+ this.patch$(lineItem, options).subscribe();
1368
+ }
1369
+ setConfigurableRamp(lineItem) {
1370
+ this.configurableRamp = lineItem;
1371
+ }
1372
+ get() {
1373
+ return this.lineItem.asObservable().pipe(shareReplay$1());
1374
+ }
1375
+ getSnapshot() {
1376
+ return this.lineItem.value ? { ...this.lineItem.value } : undefined;
1377
+ }
1378
+ getRuntimeModel() {
1379
+ const runtimeModel = this.runtimeService.runtimeModel;
1380
+ if (!runtimeModel) {
1381
+ throw new Error('Runtime model not initialized');
1382
+ }
1383
+ return runtimeModel;
1384
+ }
1385
+ getRuntimeContext() {
1386
+ const runtimeContext = this.runtimeService.runtimeContext;
1387
+ if (!runtimeContext) {
1388
+ throw new Error('Runtime context not initialized');
1389
+ }
1390
+ return runtimeContext;
1391
+ }
1392
+ get contextSnapshot() {
1393
+ return this.contextService.resolve();
1394
+ }
1395
+ get context$() {
1396
+ return this.contextService.resolve$();
1397
+ }
1398
+ get charges$() {
1399
+ return this.charges.asObservable();
1400
+ }
1401
+ get chargesSnapshot() {
1402
+ return this.charges.value;
1403
+ }
1404
+ get pricePlans$() {
1405
+ return this.pricePlans.asObservable();
1406
+ }
1407
+ get pricePlansSnapshot() {
1408
+ return this.pricePlans.value;
1409
+ }
1410
+ get procedureContext$() {
1411
+ return this.procedureContext.asObservable();
1412
+ }
1413
+ get procedureContextSnapshot() {
1414
+ return this.procedureContext.value;
1415
+ }
1416
+ configure() {
1417
+ return this.configureRequest$(this.generateRequest());
1418
+ }
1419
+ configureRequest$(configurationRequest) {
1420
+ const runtimeContext = this.getRuntimeContext();
1421
+ const runtimeModel = this.getRuntimeModel();
1422
+ const uiDefinitionProperties = this.getUIDefinitionProperties();
1423
+ const mainPricingEnabled = runtimeContext.properties?.PricingEnabled;
1424
+ const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
1425
+ const customPriceApi = this.runtimeSettings.getConfigurationSettings()['CUSTOM_PRICE_API'];
1426
+ this.isLoadingSubj$.next(true);
1427
+ const configure$ = pricingEnabled && customPriceApi
1428
+ ? this.configurationApiService.customConfigurePrice({ url: customPriceApi, configurationRequest, runtimeModel })
1429
+ : this.configurationApiService.configureLineItem({
1430
+ configurationRequest,
1431
+ runtimeModel,
1432
+ pricingEnabled,
1433
+ });
1434
+ return configure$.pipe(tap(({ lineItem, context, charges, pricePlans, deletedLineItems, procedureContext }) => {
1435
+ this.contextService.update(context ?? {});
1436
+ this.charges.next(charges ?? {});
1437
+ this.pricePlans.next(pricePlans ?? {});
1438
+ this.procedureContext.next(procedureContext ?? {});
1439
+ if (lineItem) {
1440
+ this.lineItem.next(lineItem);
1441
+ }
1442
+ if (deletedLineItems?.length) {
1443
+ this.showInactiveProductsConfirmation();
1444
+ }
1445
+ this.configurableRamp = lineItem;
1446
+ }), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => new Error(error.error?.message || error.message || JSON.stringify(error)))), finalize$1(() => this.isLoadingSubj$.next(false)));
1447
+ }
1448
+ configureExternal$(props) {
1449
+ return this.runtimeService
1450
+ .init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
1451
+ .pipe(switchMap$1(() => this.configure()), first(), catchError$1(error => {
1452
+ this.messageService.add({ severity: ToastType.error, summary: error });
1453
+ throw error;
1454
+ }), finalize$1(() => this.reset()));
1455
+ }
1456
+ configureGuidedSelling$(data) {
1457
+ return this.configurationApiService
1458
+ .configureLineItem({
1459
+ configurationRequest: getGuidedSellingConfigurationRequest(data, this.contextService.resolve()),
1460
+ })
1461
+ .pipe(catchError$1(error => {
1462
+ if (error instanceof HttpErrorResponse) {
1463
+ this.messageService.add({ severity: ToastType.error, summary: error.error.message || error.error });
1464
+ }
1465
+ throw error;
1466
+ }));
1467
+ }
1468
+ generateRequest() {
1469
+ const runtimeContext = this.getRuntimeContext();
1470
+ const uiDefinitionProperties = this.getUIDefinitionProperties();
1471
+ let lineItem = this.configurableRamp;
1472
+ if (!lineItem) {
1473
+ const { initializationProps } = this.runtimeService ?? {};
1474
+ lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps?.defaultQty);
1475
+ // Set default attributes
1476
+ if (initializationProps?.attributesMap) {
1477
+ const attributes = transform(initializationProps?.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
1478
+ lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
1479
+ }
1480
+ }
1481
+ let request = {
1482
+ lineItem,
1483
+ mode: this.mode,
1484
+ step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
1485
+ attributeDomainMode: 'ALL',
1486
+ context: this.contextService.resolve(),
1487
+ lineItems: this.quoteDraftService.quoteDraft?.currentState || [],
1488
+ asset: this.getAsset(),
1489
+ };
1490
+ request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
1491
+ return request;
1492
+ }
1493
+ getUIDefinitionProperties() {
1494
+ return {
1495
+ ...(this.getRuntimeContext().uiDefinitionContainer?.source.properties ?? {}),
1496
+ ...(this.runtimeService.uiDefinitionProperties ?? {}),
1497
+ };
1498
+ }
1499
+ showInactiveProductsConfirmation() {
1500
+ const confirmationConfig = {
1501
+ title: ' ',
1502
+ description: 'This quote contains inactive products. Do you want to remove them?',
1503
+ primaryButtonLabel: 'Remove products',
1504
+ secondaryButtonLabel: 'Back to Quote',
1505
+ };
1506
+ this.dialogService
1507
+ .open(ConfirmationComponent, {
1508
+ dismissableMask: false,
1509
+ closeOnEscape: false,
1510
+ closable: false,
1511
+ showHeader: true,
1512
+ header: `Inactive Products in Quote`,
1513
+ width: '440px',
1514
+ data: { confirmationConfig },
1515
+ })
1516
+ .onClose.subscribe(result => {
1517
+ if (!result) {
1518
+ const context = this.contextService.resolve();
1519
+ window['VELO_BACK_FN'].apply(null, [context.headerId]);
1520
+ }
1521
+ });
1522
+ }
1523
+ getAsset() {
1524
+ const lineItem = this.configurableRamp;
1525
+ if (!lineItem) {
1526
+ return;
1527
+ }
1528
+ return this.quoteDraftService.quoteDraft?.initialState.find(a => a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId);
1529
+ }
1530
+ }
1531
+ ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1.ConfigurationApiService }, { token: i5.MessageService }, { token: i6$1.DialogService }, { token: RuntimeSettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
1532
+ ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
1533
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, decorators: [{
1534
+ type: Injectable
1535
+ }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6$1.DialogService }, { type: RuntimeSettingsService }]; } });
1536
+
1537
+ class FlowUpdateService {
1538
+ update(rootLineItems, updates, charges) {
1539
+ let remainingUpdates = [...updates];
1540
+ let currentLevel = rootLineItems;
1541
+ while (currentLevel.length && remainingUpdates.length) {
1542
+ currentLevel.forEach(li => {
1543
+ const unhandledUpdates = [];
1544
+ remainingUpdates.forEach(update => {
1545
+ let updated = false;
1546
+ switch (update.dataType) {
1547
+ case 'LINEITEM':
1548
+ updated = this.applyLineItemUpdate(li, update, charges);
1549
+ break;
1550
+ case 'CHARGE':
1551
+ updated = this.applyChargeUpdate(li, update);
1552
+ break;
1553
+ case 'GROUP_CHARGE':
1554
+ updated = this.applyChargeGroupUpdate(li, update);
1555
+ break;
1556
+ default:
1557
+ // Unknown dataType. Do not try to handle it anymore
1558
+ updated = true;
1559
+ }
1560
+ if (!updated) {
1561
+ unhandledUpdates.push(update);
1562
+ }
1563
+ });
1564
+ remainingUpdates = unhandledUpdates;
1565
+ });
1566
+ currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
1567
+ }
1568
+ }
1569
+ delete(lineItems, id) {
1570
+ const idsToRemove = [id];
1571
+ const topLevelLineItem = lineItems.find(li => li.id === id);
1572
+ if (topLevelLineItem) {
1573
+ // find term-related line items (which are only top level)
1574
+ // expired term line items won't be deleted
1575
+ let foundTermLineItem = topLevelLineItem;
1576
+ while (foundTermLineItem) {
1577
+ foundTermLineItem = lineItems.find(li => foundTermLineItem && li.rampInstanceId === foundTermLineItem.id);
1578
+ if (foundTermLineItem) {
1579
+ idsToRemove.push(foundTermLineItem.id);
1580
+ }
1581
+ }
1582
+ }
1583
+ const filtered = lineItems.filter(lineItem => !idsToRemove.includes(lineItem.id));
1584
+ return filtered.map(lineItem => new LineItemWorker(lineItem).remove(id).li);
1585
+ }
1586
+ applyLineItemUpdate(lineItem, update, charges) {
1587
+ if (lineItem.id !== update.id) {
1588
+ return false;
1589
+ }
1590
+ switch (update.attributeType) {
1591
+ case 'QTY':
1592
+ lineItem.qty = update.newValue;
1593
+ break;
1594
+ case 'EFFECTIVE_START_DATE':
1595
+ lineItem.properties['StartDate'] = moment(update.newValue).format('YYYY-MM-DD');
1596
+ break;
1597
+ case 'END_DATE':
1598
+ lineItem.properties['EndDate'] = moment(update.newValue).format('YYYY-MM-DD');
1599
+ break;
1600
+ case 'PRICE_ADJUSTMENT':
1601
+ {
1602
+ const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
1603
+ if (charge) {
1604
+ charge.priceAdjustment = update.newValue;
1605
+ }
1606
+ }
1607
+ break;
1608
+ case 'LIST_PRICE_ADJUSTMENT':
1609
+ case 'MARGIN_ADJUSTMENT':
1610
+ {
1611
+ const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
1612
+ if (charge) {
1613
+ charge.listPriceAdjustment = update.newValue;
1614
+ }
1615
+ }
1616
+ break;
1617
+ case 'COST_ADJUSTMENT':
1618
+ {
1619
+ const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
1620
+ if (charge) {
1621
+ charge.costAdjustment = update.newValue;
1622
+ }
1623
+ }
1624
+ break;
1625
+ default:
1626
+ throw new Error(`Not suppored AttributeType for LineItem update: ${update.attributeType}`);
1627
+ }
1628
+ return true;
1629
+ }
1630
+ applyChargeUpdate(lineItem, update) {
1631
+ const foundCharge = lineItem.chargeItems.find(({ id }) => id === update.id);
1632
+ if (!foundCharge) {
1633
+ return false;
1634
+ }
1635
+ if (update.attributeType === 'PRICE_ADJUSTMENT') {
1636
+ foundCharge.priceAdjustment = update.newValue;
1637
+ }
1638
+ else if (update.attributeType === 'LIST_PRICE_ADJUSTMENT') {
1639
+ foundCharge.listPriceAdjustment = update.newValue;
1640
+ }
1641
+ else {
1642
+ throw new Error(`Not suppored AttributeType for Charge Item update: ${update.attributeType}`);
1643
+ }
1644
+ return true;
1645
+ }
1646
+ applyChargeGroupUpdate(lineItem, update) {
1647
+ const foundChargeGroup = ChargeGroupUtils.findChargeGroupById(update.id, lineItem);
1648
+ if (!foundChargeGroup) {
1649
+ return false;
1650
+ }
1651
+ if (update.attributeType === 'PRICE_ADJUSTMENT') {
1652
+ foundChargeGroup.priceAdjustment = update.newValue;
1653
+ }
1654
+ else if (update.attributeType === 'LIST_PRICE_ADJUSTMENT') {
1655
+ foundChargeGroup.listPriceAdjustment = update.newValue;
1656
+ }
1657
+ else {
1658
+ throw new Error(`Not suppored AttributeType for Charge Group Item update: ${update.attributeType}`);
1659
+ }
1660
+ return true;
1661
+ }
1662
+ }
1663
+ FlowUpdateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1664
+ FlowUpdateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService });
1665
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService, decorators: [{
1666
+ type: Injectable
1667
+ }] });
1668
+
1669
+ class FlowConfigurationService {
1670
+ constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
1671
+ this.proceduresApiService = proceduresApiService;
1672
+ this.contextService = contextService;
1673
+ this.quoteDraftService = quoteDraftService;
1674
+ this.updateService = updateService;
1675
+ this.configurationService = configurationService;
1676
+ this.updatedSubj$ = new Subject();
1677
+ this.updated$ = this.updatedSubj$.asObservable();
1678
+ }
1679
+ calculate$(quoteDraft) {
1680
+ return this.proceduresApiService.apply$(quoteDraft).pipe(tap$1(result => {
1681
+ // sort the result current state based on the quote draft initial state
1682
+ const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
1683
+ result.currentState = result.currentState
1684
+ .slice()
1685
+ .sort((a, b) => initialStateIds.indexOf(a.integrationId) - initialStateIds.indexOf(b.integrationId));
1686
+ this.quoteDraftService.updateQuoteDraft(result);
1687
+ }), map$1(noop));
1688
+ }
1689
+ calculate(quoteDraft) {
1690
+ this.calculate$(quoteDraft).subscribe();
1691
+ }
1692
+ update$(updates) {
1693
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1694
+ if (!quoteDraft) {
1695
+ return of(null);
1696
+ }
1697
+ return of([]).pipe(map$1(() => {
1698
+ const updatedState = cloneDeep(quoteDraft.currentState);
1699
+ this.updateService.update(updatedState, updates, quoteDraft.charges);
1700
+ return updatedState;
1701
+ }), switchMap(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1702
+ }
1703
+ update(updates) {
1704
+ this.update$(updates).subscribe();
1705
+ }
1706
+ revert$(lineItemId) {
1707
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1708
+ const initialCurrentState = this.quoteDraftService.getInitialCurrentState();
1709
+ const currentState = this.quoteDraftService.activeCurrentState;
1710
+ const currentLineItemIndex = currentState.findIndex(({ id }) => id === lineItemId);
1711
+ const currentLineItem = currentState[currentLineItemIndex];
1712
+ const initialLineItem = initialCurrentState.find(({ integrationId }) => integrationId === currentLineItem?.integrationId);
1713
+ if (!quoteDraft || !currentLineItem || !initialLineItem) {
1714
+ return of(null);
1715
+ }
1716
+ const updatedState = cloneDeep(currentState);
1717
+ updatedState.splice(currentLineItemIndex, 1, initialLineItem);
1718
+ return of([]).pipe(tap$1(() => {
1719
+ this.quoteDraftService.setCurrentLineItemState(updatedState);
1720
+ }), switchMap(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1721
+ }
1722
+ revert(lineItemId) {
1723
+ this.revert$(lineItemId).subscribe();
1724
+ }
1725
+ delete$(ids) {
1726
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1727
+ const currentState = this.quoteDraftService.currentState;
1728
+ if (!quoteDraft) {
1729
+ return of(null);
1730
+ }
1731
+ return of([]).pipe(map$1(() => ids.reduce((result, id) => this.updateService.delete(result, id), currentState)), switchMap(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1732
+ }
1733
+ delete(ids) {
1734
+ this.delete$(ids).subscribe();
1735
+ }
1736
+ addTerm$(term) {
1737
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1738
+ if (!quoteDraft) {
1739
+ return of(null);
1740
+ }
1741
+ const updatedState = [...quoteDraft.currentState, term];
1742
+ return of([]).pipe(switchMap(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1743
+ }
1744
+ addToCart$(props) {
1745
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1746
+ if (!quoteDraft) {
1747
+ return of(null);
1748
+ }
1749
+ return this.configurationService.configureExternal$(props).pipe(map$1(lineItem => {
1750
+ const model = this.configurationService.getRuntimeModel();
1751
+ const split = model?.types.find(type => type.name === lineItem.type)?.split ?? false;
1752
+ const lineItems = multiplyLineItems(lineItem, props.qty ?? 1, split);
1753
+ return [...quoteDraft.currentState, ...lineItems];
1754
+ }), switchMap(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1755
+ }
1756
+ get() {
1757
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(() => this.quoteDraftService.activeCurrentState), shareReplay$1());
1758
+ }
1759
+ getSnapshot() {
1760
+ return this.quoteDraftService?.currentState.slice() ?? [];
1761
+ }
1762
+ get charges$() {
1763
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ charges }) => charges));
1764
+ }
1765
+ get pricePlans$() {
1766
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ pricePlans }) => pricePlans));
1767
+ }
1768
+ get activeMetrics$() {
1769
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ activeMetrics }) => activeMetrics));
1770
+ }
1771
+ get chargesSnapshot() {
1772
+ return this.quoteDraftService.quoteDraft?.charges ?? {};
1773
+ }
1774
+ get pricePlansSnapshot() {
1775
+ return this.quoteDraftService.quoteDraft?.pricePlans ?? {};
1776
+ }
1777
+ get activeMetricsSnapshot() {
1778
+ return this.quoteDraftService.quoteDraft?.activeMetrics ?? [];
1779
+ }
1780
+ get contextSnapshot() {
1781
+ return this.contextService.resolve();
1782
+ }
1783
+ get context$() {
1784
+ return this.contextService.resolve$();
1785
+ }
1786
+ handleErrorAndBounceBack() {
1787
+ return (source$) => {
1788
+ return source$.pipe(catchError(error => {
1789
+ console.error(error);
1790
+ // bounce back if configuration call has failed
1791
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1792
+ if (quoteDraft) {
1793
+ this.quoteDraftService.updateQuoteDraft(quoteDraft);
1794
+ this.updatedSubj$.next();
1795
+ }
1796
+ return throwError(() => error);
1797
+ }));
1798
+ };
1799
+ }
1800
+ }
1801
+ FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
1802
+ FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, providedIn: 'root' });
1803
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
1804
+ type: Injectable,
1805
+ args: [{ providedIn: 'root' }]
1806
+ }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1807
+
1808
+ class FlowConfigurationModule {
1809
+ }
1810
+ FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1811
+ FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule });
1812
+ FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, PriceApiService] });
1813
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
1814
+ type: NgModule,
1815
+ args: [{
1816
+ imports: [],
1817
+ providers: [FlowConfigurationService, FlowUpdateService, PriceApiService],
1818
+ }]
1819
+ }] });
1820
+
1821
+ class FlowStateConfigurationService {
1822
+ constructor(flowStateService, flowInfoService, configurationService, flowConfigurationService, flowStateApiService) {
1823
+ this.flowStateService = flowStateService;
1824
+ this.flowInfoService = flowInfoService;
1825
+ this.configurationService = configurationService;
1826
+ this.flowConfigurationService = flowConfigurationService;
1827
+ this.flowStateApiService = flowStateApiService;
1828
+ this.configurationStateId$ = new BehaviorSubject(null);
1829
+ }
1830
+ get configurationStateId() {
1831
+ return this.configurationStateId$.value;
1832
+ }
1833
+ addToCart$(props) {
1834
+ const stateful = this.flowInfoService.flow?.properties.stateful;
1835
+ if (stateful) {
1836
+ const stateId = this.flowStateService.stateId;
1837
+ if (!stateId) {
1838
+ return of();
1839
+ }
1840
+ const lineItem = generateConfigurationLineItem(props, props.qty);
1841
+ return this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap$1(r => this.configurationStateId$.next(r.stateId)), switchMap(() => {
1842
+ if (!this.configurationStateId) {
1843
+ return of();
1844
+ }
1845
+ return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), tap$1(() => this.configurationStateId$.next(null)), map$1(noop));
1846
+ }));
1847
+ }
1848
+ else {
1849
+ return this.flowConfigurationService.addToCart$(props).pipe(map$1(noop));
1850
+ }
1851
+ }
1852
+ }
1853
+ FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowStateService }, { token: FlowInfoService }, { token: ConfigurationService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1854
+ FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, providedIn: 'root' });
1855
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
1856
+ type: Injectable,
1857
+ args: [{ providedIn: 'root' }]
1858
+ }], ctorParameters: function () { return [{ type: FlowStateService }, { type: FlowInfoService }, { type: ConfigurationService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }]; } });
1859
+
1860
+ function calculateMetricByMethod(lineItems, metric, method) {
1861
+ const items = getLineItemsByMethod(lineItems, method);
1862
+ return items.reduce((acc, li) => {
1863
+ let value = li.reduce((accProduct, item) => accProduct + ((item.totalMetrics && item.totalMetrics[metric]) || 0), 0);
1864
+ if (method === 'avg' && li.length > 0) {
1865
+ value /= li.length;
1866
+ }
1867
+ return acc + value;
1868
+ }, 0);
1869
+ }
1870
+ function getLineItemsByMethod(lineItems, method) {
1871
+ switch (method) {
1872
+ case 'first': {
1873
+ return lineItems.filter(li => !li.rampInstanceId).map(item => [item]);
1874
+ }
1875
+ case 'last': {
1876
+ const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
1877
+ const products = rootTermItems.map(lineItem => [
1878
+ lineItem,
1879
+ ...lineItems.filter(li => li.rampInstanceId === lineItem.id),
1880
+ ]);
1881
+ return products
1882
+ .map(items => [...items].sort((a, b) => getDateValue(a.endDate || '') - getDateValue(b.endDate || '')).pop())
1883
+ .filter((li) => Boolean(li))
1884
+ .map(item => [item]);
1885
+ }
1886
+ case 'avg': {
1887
+ const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
1888
+ return rootTermItems.map(lineItem => [lineItem, ...lineItems.filter(li => li.rampInstanceId === lineItem.id)]);
1889
+ }
1890
+ case 'sum': {
1891
+ return lineItems.map(item => [item]);
1892
+ }
1893
+ default: {
1894
+ return lineItems.map(item => [item]);
1895
+ }
1896
+ }
1897
+ }
1898
+ function getDateValue(date) {
1899
+ return date ? new Date(date).getTime() : 0;
1900
+ }
1901
+
1902
+ class MetricsCalculationService {
1903
+ get onMetricsUpdate$() {
1904
+ return this.metricsUpdated$.asObservable();
1905
+ }
1906
+ constructor(quoteDraftService, flowConfiguration, settingsService) {
1907
+ this.quoteDraftService = quoteDraftService;
1908
+ this.flowConfiguration = flowConfiguration;
1909
+ this.settingsService = settingsService;
1910
+ this.metricsUpdated$ = new Subject();
1911
+ this.quoteMetricsSettings = {};
1912
+ this.metricsCalculationMethodMap = {};
1913
+ this.metricsData = {};
1914
+ this.activeMetricRules = [];
1915
+ this.activeMetricRules = this.flowConfiguration.activeMetricsSnapshot.filter(metricRule => metricRule.metrics.some(metric => !!metric.totalName));
1916
+ combineLatest([
1917
+ this.quoteDraftService.currentState$,
1918
+ this.settingsService.fetchSetting('QUOTE_LEVEL_METRIC_CALCULATION_METHOD').pipe(take$1(1)),
1919
+ ]).subscribe(([lineItems, setting]) => {
1920
+ let settingsData = {};
1921
+ try {
1922
+ settingsData = JSON.parse(setting?.value || '{}');
1923
+ }
1924
+ catch (error) {
1925
+ settingsData = {};
1926
+ }
1927
+ this.quoteMetricsSettings = settingsData;
1928
+ this.updateMetrics(lineItems);
1929
+ });
1930
+ }
1931
+ getMetricValue(metric) {
1932
+ return this.metricsData[metric] || 0;
1933
+ }
1934
+ updateMetrics(lineItems) {
1935
+ const metricKeys = this.collectMetricKeys(lineItems).filter(key => !key.includes('Effective_'));
1936
+ this.metricsCalculationMethodMap = this.buildMetricsCalculationMethods(metricKeys, this.metricsCalculationMethodMap);
1937
+ this.metricsData = metricKeys.reduce((acc, key) => ({ ...acc, [key]: this.calculateMetric(lineItems, key) }), {});
1938
+ this.metricsUpdated$.next();
1939
+ }
1940
+ calculateMetric(lineItems, metric) {
1941
+ return calculateMetricByMethod(lineItems, metric, this.metricsCalculationMethodMap[metric] || 'sum');
1942
+ }
1943
+ buildMetricsCalculationMethods(metricKeys, initial) {
1944
+ return metricKeys.reduce((acc, name) => {
1945
+ if (acc[name]) {
1946
+ return acc;
1947
+ }
1948
+ acc = { ...acc, [name]: 'sum' };
1949
+ const metricRule = this.getMetricRuleByTotalMetricName(name);
1950
+ const settingKey = metricRule?.metrics?.find(metric => metric.totalName === name)?.name || name;
1951
+ if (this.quoteMetricsSettings[settingKey]) {
1952
+ acc = { ...acc, [name]: this.quoteMetricsSettings[settingKey] };
1953
+ }
1954
+ return acc;
1955
+ }, initial);
1956
+ }
1957
+ collectMetricKeys(lineItems) {
1958
+ const keys = [];
1959
+ lineItems.forEach(lineItem => {
1960
+ keys.push(...Object.keys(lineItem.totalMetrics || {}));
1961
+ keys.push(...this.collectMetricKeys(lineItem.lineItems));
1962
+ });
1963
+ return uniq(keys);
1964
+ }
1965
+ getMetricRuleByTotalMetricName(name) {
1966
+ return this.activeMetricRules.find(metricRule => metricRule.metrics.find(metric => metric.totalName === name));
1967
+ }
1968
+ }
1969
+ MetricsCalculationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: MetricsCalculationService, deps: [{ token: QuoteDraftService }, { token: FlowConfigurationService }, { token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1970
+ MetricsCalculationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: MetricsCalculationService, providedIn: 'root' });
1971
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: MetricsCalculationService, decorators: [{
1972
+ type: Injectable,
1973
+ args: [{ providedIn: 'root' }]
1974
+ }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: FlowConfigurationService }, { type: i1.ConfigurationSettingsApiService }]; } });
1975
+
1976
+ class ProductImagesService {
1977
+ constructor(productApiService) {
1978
+ this.productApiService = productApiService;
1979
+ this.imagesMap$ = new BehaviorSubject({});
1980
+ }
1981
+ getImageUrl$(productId) {
1982
+ if (this.imagesMap$.value[productId] == null) {
1983
+ this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: '' });
1984
+ this.fetchProductImage(productId);
1985
+ }
1986
+ return this.imagesMap$.pipe(map$1(imagesMap => imagesMap[productId]), distinctUntilChanged());
1987
+ }
1988
+ fetchProductImage(productId) {
1989
+ this.productApiService
1990
+ .fetchImage$(productId)
1991
+ .pipe(map$1(file => URL.createObjectURL(file)), catchError(() => of('')), tap$1(url => this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: url })))
1992
+ .subscribe();
1993
+ }
1994
+ }
1995
+ ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1996
+ ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, providedIn: 'root' });
1997
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, decorators: [{
1998
+ type: Injectable,
1999
+ args: [{ providedIn: 'root' }]
2000
+ }], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
2001
+
2002
+ class RuntimeContextService {
2003
+ constructor(configurationApiService) {
2004
+ this.configurationApiService = configurationApiService;
2005
+ }
2006
+ getRuntimeContext(productId, offeringId) {
2007
+ return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
2008
+ const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
2009
+ const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
2010
+ const { productName, properties } = Array.from(runtimeModel.components.values()).find(c => c.productId === productId) ?? {};
2011
+ const uiDefinitionProperties = uiDefinitionContainer?.source.properties;
2012
+ return {
2013
+ modelId: runtimeData.modelId,
2014
+ uiDefinitionContainer: uiDefinitionContainer,
2015
+ runtimeModel: runtimeModel,
2016
+ runtimeMode: RuntimeMode.PROD,
2017
+ productId: productId,
2018
+ productType: properties?.['displayName'] || productName,
2019
+ offeringId: offeringId,
2020
+ properties: {
2021
+ PricingEnabled: uiDefinitionProperties?.pricingEnabled ? 'true' : 'false',
2022
+ PriceListId: uiDefinitionProperties?.priceList,
2023
+ },
2024
+ };
2025
+ }));
2026
+ }
2027
+ getUIDefinitionContainer(runtimeData) {
2028
+ const containers = runtimeData.uiDefinitions.filter(container => isNotLegacyUIDefinition(container.source));
2029
+ return containers.find(container => container.source.primary) ?? containers[0];
2030
+ }
2031
+ }
2032
+ RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }], target: i0.ɵɵFactoryTarget.Injectable });
2033
+ RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService });
2034
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, decorators: [{
2035
+ type: Injectable
2036
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }]; } });
2037
+
2038
+ class ConfigurationRuntimeService {
2039
+ constructor(apiService, contextService, runtimeContextService) {
2040
+ this.apiService = apiService;
2041
+ this.contextService = contextService;
2042
+ this.runtimeContextService = runtimeContextService;
2043
+ this._isInitialized = false;
2044
+ this.uiDefinitionProperties = {};
2045
+ }
2046
+ reset() {
2047
+ this._isInitialized = false;
2048
+ this._runtimeContext = undefined;
2049
+ this.initializationProps = undefined;
2050
+ this.uiDefinitionProperties = {};
2051
+ }
2052
+ initTestMode(uiDefinitionContainer) {
2053
+ this.uiDefinitionProperties = uiDefinitionContainer.source.properties ?? {};
2054
+ const uiDefinitionExternals = uiDefinitionContainer.source.externals ?? {};
2055
+ return combineLatest([
2056
+ this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
2057
+ this.contextService.initTestMode(),
2058
+ ]).pipe(first(), map(([runtimeData, context]) => {
2059
+ this.contextService.update({
2060
+ properties: {
2061
+ ...this.runtimeContext?.properties,
2062
+ ...context.properties,
2063
+ ModelId: uiDefinitionContainer.modelId,
2064
+ PricingEnabled: this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false',
2065
+ PriceListId: this.uiDefinitionProperties.priceList,
2066
+ offeringId: this.uiDefinitionProperties.offeringId,
2067
+ ...uiDefinitionExternals,
2068
+ },
2069
+ });
2070
+ this._runtimeContext = {
2071
+ modelId: uiDefinitionContainer.modelId,
2072
+ runtimeModel: RuntimeModel.create(runtimeData.types, runtimeData.products),
2073
+ runtimeMode: RuntimeMode.TEST,
2074
+ uiDefinitionContainer,
2075
+ };
2076
+ return this._runtimeContext;
2077
+ }), tap(() => (this._isInitialized = true)));
2078
+ }
2079
+ init(props) {
2080
+ this.initializationProps = props;
2081
+ const context = this.contextService.resolve();
2082
+ return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
2083
+ this.uiDefinitionProperties = runtimeContext.uiDefinitionContainer?.source.properties ?? {};
2084
+ const { PriceListId } = context.properties ?? {};
2085
+ const mergeContext = {
2086
+ ...runtimeContext,
2087
+ properties: {
2088
+ ...runtimeContext.properties,
2089
+ ...context.properties,
2090
+ PricingEnabled: PriceListId ? 'true' : 'false',
2091
+ },
2092
+ };
2093
+ this.id15to18('AccountId', mergeContext.properties);
2094
+ this._runtimeContext = mergeContext;
2095
+ if (context.properties && this._runtimeContext.properties?.StartDate) {
2096
+ this.contextService.update({
2097
+ properties: {
2098
+ ...this._runtimeContext.properties,
2099
+ ...context.properties,
2100
+ },
2101
+ });
2102
+ }
2103
+ return this._runtimeContext;
2104
+ }), tap(() => (this._isInitialized = true)));
2105
+ }
2106
+ overrideUIDefinition(uiDefinitionContainer) {
2107
+ if (!this._runtimeContext) {
2108
+ return;
2109
+ }
2110
+ this._runtimeContext.uiDefinitionContainer = uiDefinitionContainer;
2111
+ this.uiDefinitionProperties = uiDefinitionContainer.source.properties ?? {};
2112
+ }
2113
+ id15to18(propertyName, source) {
2114
+ if (!source) {
2115
+ return;
2116
+ }
2117
+ const value = source[propertyName];
2118
+ if (typeof value === 'string' && value.length === 15) {
2119
+ source[propertyName] = SalesforceIdUtils.generateId18FromId15(value);
2120
+ }
2121
+ }
2122
+ get isInitialized() {
2123
+ return this._isInitialized;
2124
+ }
2125
+ get runtimeModel() {
2126
+ return this.runtimeContext?.runtimeModel;
2127
+ }
2128
+ get runtimeContext() {
2129
+ return this._runtimeContext;
921
2130
  }
922
2131
  }
923
- ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1.ConfigurationApiService }, { token: i5.MessageService }, { token: i6.DialogService }], target: i0.ɵɵFactoryTarget.Injectable });
924
- ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationService });
925
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationService, decorators: [{
2132
+ ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.ConfigurationApiService }, { token: ContextService }, { token: RuntimeContextService }], target: i0.ɵɵFactoryTarget.Injectable });
2133
+ ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService });
2134
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
926
2135
  type: Injectable
927
- }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6.DialogService }]; } });
2136
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
928
2137
 
929
2138
  class ConfigurationState {
930
2139
  constructor(statefulConfigurationApiService, runtimeService, configurationService, toastService) {
@@ -937,17 +2146,17 @@ class ConfigurationState {
937
2146
  this.stateId = null;
938
2147
  }
939
2148
  init$() {
940
- return this.configurationService.configure().pipe(switchMap$1(() => {
2149
+ return this.configurationService.configure().pipe(switchMap(() => {
941
2150
  if (!this.isStatefulConfiguration) {
942
2151
  return of(undefined);
943
2152
  }
944
2153
  const { actions, selectors } = this.runtimeService.runtimeContext?.uiDefinitionContainer ?? {};
945
2154
  return this.statefulConfigurationApiService.init({
946
- request: this.configurationService.generateRequest(),
2155
+ item: this.configurationService.generateRequest(),
947
2156
  actions: actions?.map(action => ({ name: action.apiName, script: action.script })),
948
2157
  selectors: selectors?.map(selector => ({ name: selector.apiName, script: selector.script })),
949
2158
  });
950
- }), tap$1(stateId => (this.stateId = stateId || null)), map$2(() => undefined));
2159
+ }), tap$1(stateId => (this.stateId = stateId || null)), map$1(() => undefined));
951
2160
  }
952
2161
  cleanup() {
953
2162
  this.stateId = null;
@@ -974,13 +2183,13 @@ class ConfigurationState {
974
2183
  inputData,
975
2184
  },
976
2185
  },
977
- }).pipe(map$2(() => this.stateSubj$.value[requestId]), tap$1(() => this.stateSubj$.next(omit(this.stateSubj$.value, requestId))));
2186
+ }).pipe(map$1(() => this.stateSubj$.value[requestId]), tap$1(() => this.stateSubj$.next(omit(this.stateSubj$.value, requestId))));
978
2187
  }
979
2188
  get isStatefulConfiguration() {
980
2189
  return this.runtimeService.uiDefinitionProperties.statefulConfigurationEnabled ?? false;
981
2190
  }
982
2191
  executeStateless$(request) {
983
- return of(undefined).pipe(switchMap$1(() => {
2192
+ return of(undefined).pipe(switchMap(() => {
984
2193
  // Apply actions and execute configuration/price call
985
2194
  // No need to run configuration if no actions in the request
986
2195
  if (!request.actions?.length) {
@@ -1005,7 +2214,7 @@ class ConfigurationState {
1005
2214
  ...this.stateSubj$.value,
1006
2215
  ...selectorsResult,
1007
2216
  });
1008
- }), map$2(() => undefined));
2217
+ }), map$1(() => undefined));
1009
2218
  }
1010
2219
  executeStateful$(request) {
1011
2220
  if (!this.stateId) {
@@ -1024,7 +2233,7 @@ class ConfigurationState {
1024
2233
  updatedState[key] = value.result;
1025
2234
  });
1026
2235
  this.stateSubj$.next(updatedState);
1027
- }), map$2(() => undefined));
2236
+ }), map$1(() => undefined));
1028
2237
  }
1029
2238
  executeActionScript(request, processor) {
1030
2239
  const { actions } = this.runtimeService.runtimeContext?.uiDefinitionContainer ?? {};
@@ -1040,314 +2249,26 @@ class ConfigurationState {
1040
2249
  if (!script) {
1041
2250
  return null;
1042
2251
  }
1043
- return this.executeProcessorScript(request, script, processor.inputData);
1044
- }
1045
- executeProcessorScript(request, script, inputData) {
1046
- return new Function(`${script}\nreturn transform;`)()({
1047
- request,
1048
- inputData: inputData,
1049
- });
1050
- }
1051
- }
1052
- ConfigurationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationState, deps: [{ token: i1.StatefulConfigurationApiService }, { token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: i4.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
1053
- ConfigurationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationState });
1054
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationState, decorators: [{
1055
- type: Injectable
1056
- }], ctorParameters: function () { return [{ type: i1.StatefulConfigurationApiService }, { type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: i4.ToastService }]; } });
1057
-
1058
- function extractMetadata(uiDefinition) {
1059
- return omit(uiDefinition, [
1060
- 'children',
1061
- 'pages',
1062
- 'components',
1063
- ]);
1064
- }
1065
-
1066
- class FlowUpdateService {
1067
- update(rootLineItems, updates, charges) {
1068
- let remainingUpdates = [...updates];
1069
- let currentLevel = rootLineItems;
1070
- while (currentLevel.length && remainingUpdates.length) {
1071
- currentLevel.forEach(li => {
1072
- const unhandledUpdates = [];
1073
- remainingUpdates.forEach(update => {
1074
- let updated = false;
1075
- switch (update.dataType) {
1076
- case 'LINEITEM':
1077
- updated = this.applyLineItemUpdate(li, update, charges);
1078
- break;
1079
- case 'CHARGE':
1080
- updated = this.applyChargeUpdate(li, update);
1081
- break;
1082
- case 'GROUP_CHARGE':
1083
- updated = this.applyChargeGroupUpdate(li, update);
1084
- break;
1085
- default:
1086
- // Unknown dataType. Do not try to handle it anymore
1087
- updated = true;
1088
- }
1089
- if (!updated) {
1090
- unhandledUpdates.push(update);
1091
- }
1092
- });
1093
- remainingUpdates = unhandledUpdates;
1094
- });
1095
- currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
1096
- }
1097
- }
1098
- delete(lineItems, id) {
1099
- const idsToRemove = [id];
1100
- const topLevelLineItem = lineItems.find(li => li.id === id);
1101
- if (topLevelLineItem) {
1102
- // find term-related line items (which are only top level)
1103
- // expired term line items won't be deleted
1104
- let foundTermLineItem = topLevelLineItem;
1105
- while (foundTermLineItem) {
1106
- foundTermLineItem = lineItems.find(li => foundTermLineItem && li.rampInstanceId === foundTermLineItem.id);
1107
- if (foundTermLineItem) {
1108
- idsToRemove.push(foundTermLineItem.id);
1109
- }
1110
- }
1111
- }
1112
- const filtered = lineItems.filter(lineItem => !idsToRemove.includes(lineItem.id));
1113
- return filtered.map(lineItem => new LineItemWorker(lineItem).remove(id).li);
1114
- }
1115
- applyLineItemUpdate(lineItem, update, charges) {
1116
- if (lineItem.id !== update.id) {
1117
- return false;
1118
- }
1119
- switch (update.attributeType) {
1120
- case 'QTY':
1121
- lineItem.qty = update.newValue;
1122
- break;
1123
- case 'EFFECTIVE_START_DATE':
1124
- lineItem.properties['StartDate'] = moment(update.newValue).format('YYYY-MM-DD');
1125
- break;
1126
- case 'END_DATE':
1127
- lineItem.properties['EndDate'] = moment(update.newValue).format('YYYY-MM-DD');
1128
- break;
1129
- case 'PRICE_ADJUSTMENT':
1130
- {
1131
- const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
1132
- if (charge) {
1133
- charge.priceAdjustment = update.newValue;
1134
- }
1135
- }
1136
- break;
1137
- case 'LIST_PRICE_ADJUSTMENT':
1138
- case 'MARGIN_ADJUSTMENT':
1139
- {
1140
- const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
1141
- if (charge) {
1142
- charge.listPriceAdjustment = update.newValue;
1143
- }
1144
- }
1145
- break;
1146
- case 'COST_ADJUSTMENT':
1147
- {
1148
- const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
1149
- if (charge) {
1150
- charge.costAdjustment = update.newValue;
1151
- }
1152
- }
1153
- break;
1154
- default:
1155
- throw new Error(`Not suppored AttributeType for LineItem update: ${update.attributeType}`);
1156
- }
1157
- return true;
1158
- }
1159
- applyChargeUpdate(lineItem, update) {
1160
- const foundCharge = lineItem.chargeItems.find(({ id }) => id === update.id);
1161
- if (!foundCharge) {
1162
- return false;
1163
- }
1164
- if (update.attributeType === 'PRICE_ADJUSTMENT') {
1165
- foundCharge.priceAdjustment = update.newValue;
1166
- }
1167
- else if (update.attributeType === 'LIST_PRICE_ADJUSTMENT') {
1168
- foundCharge.listPriceAdjustment = update.newValue;
1169
- }
1170
- else {
1171
- throw new Error(`Not suppored AttributeType for Charge Item update: ${update.attributeType}`);
1172
- }
1173
- return true;
1174
- }
1175
- applyChargeGroupUpdate(lineItem, update) {
1176
- const foundChargeGroup = ChargeGroupUtils.findChargeGroupById(update.id, lineItem);
1177
- if (!foundChargeGroup) {
1178
- return false;
1179
- }
1180
- if (update.attributeType === 'PRICE_ADJUSTMENT') {
1181
- foundChargeGroup.priceAdjustment = update.newValue;
1182
- }
1183
- else if (update.attributeType === 'LIST_PRICE_ADJUSTMENT') {
1184
- foundChargeGroup.listPriceAdjustment = update.newValue;
1185
- }
1186
- else {
1187
- throw new Error(`Not suppored AttributeType for Charge Group Item update: ${update.attributeType}`);
1188
- }
1189
- return true;
1190
- }
1191
- }
1192
- FlowUpdateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowUpdateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1193
- FlowUpdateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowUpdateService });
1194
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowUpdateService, decorators: [{
1195
- type: Injectable
1196
- }] });
1197
-
1198
- class FlowConfigurationService {
1199
- constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
1200
- this.proceduresApiService = proceduresApiService;
1201
- this.contextService = contextService;
1202
- this.quoteDraftService = quoteDraftService;
1203
- this.updateService = updateService;
1204
- this.configurationService = configurationService;
1205
- }
1206
- calculate$(quoteDraft) {
1207
- return this.proceduresApiService.apply$(quoteDraft).pipe(tap$1(result => {
1208
- // sort the result current state based on the quote draft initial state
1209
- const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
1210
- result.currentState = result.currentState
1211
- .slice()
1212
- .sort((a, b) => initialStateIds.indexOf(a.integrationId) - initialStateIds.indexOf(b.integrationId));
1213
- this.quoteDraftService.updateQuoteDraft(result);
1214
- }), map$2(noop));
1215
- }
1216
- calculate(quoteDraft) {
1217
- this.calculate$(quoteDraft).subscribe();
1218
- }
1219
- update$(updates) {
1220
- const quoteDraft = this.quoteDraftService.quoteDraft;
1221
- if (!quoteDraft) {
1222
- return of(null);
1223
- }
1224
- return of([]).pipe(map$2(() => {
1225
- const updatedState = cloneDeep(quoteDraft.currentState);
1226
- this.updateService.update(updatedState, updates, quoteDraft.charges);
1227
- return updatedState;
1228
- }), switchMap$1(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1229
- }
1230
- update(updates) {
1231
- this.update$(updates).subscribe();
1232
- }
1233
- revert$(lineItemId) {
1234
- const quoteDraft = this.quoteDraftService.quoteDraft;
1235
- const initialCurrentState = this.quoteDraftService.getInitialCurrentState();
1236
- const currentState = this.quoteDraftService.activeCurrentState;
1237
- const currentLineItemIndex = currentState.findIndex(({ id }) => id === lineItemId);
1238
- const currentLineItem = currentState[currentLineItemIndex];
1239
- const initialLineItem = initialCurrentState.find(({ integrationId }) => integrationId === currentLineItem?.integrationId);
1240
- if (!quoteDraft || !currentLineItem || !initialLineItem) {
1241
- return of(null);
1242
- }
1243
- const updatedState = cloneDeep(currentState);
1244
- updatedState.splice(currentLineItemIndex, 1, initialLineItem);
1245
- return of([]).pipe(tap$1(() => {
1246
- this.quoteDraftService.setCurrentLineItemState(updatedState);
1247
- }), switchMap$1(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1248
- }
1249
- revert(lineItemId) {
1250
- this.revert$(lineItemId).subscribe();
1251
- }
1252
- delete$(ids) {
1253
- const quoteDraft = this.quoteDraftService.quoteDraft;
1254
- const currentState = this.quoteDraftService.currentState;
1255
- if (!quoteDraft) {
1256
- return of(null);
1257
- }
1258
- return of([]).pipe(map$2(() => ids.reduce((result, id) => this.updateService.delete(result, id), currentState)), switchMap$1(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1259
- }
1260
- delete(ids) {
1261
- this.delete$(ids).subscribe();
1262
- }
1263
- addTerm$(term) {
1264
- const quoteDraft = this.quoteDraftService.quoteDraft;
1265
- if (!quoteDraft) {
1266
- return of(null);
1267
- }
1268
- const updatedState = [...quoteDraft.currentState, term];
1269
- return of([]).pipe(switchMap$1(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1270
- }
1271
- addToCart$(props) {
1272
- const quoteDraft = this.quoteDraftService.quoteDraft;
1273
- if (!quoteDraft) {
1274
- return of(null);
1275
- }
1276
- return this.configurationService.configureExternal$(props).pipe(map$2(lineItem => {
1277
- const model = this.configurationService.getRuntimeModel();
1278
- const split = model?.types.find(type => type.name === lineItem.type)?.split ?? false;
1279
- const lineItems = multiplyLineItems(lineItem, props.qty ?? 1, split);
1280
- return [...quoteDraft.currentState, ...lineItems];
1281
- }), switchMap$1(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1282
- }
1283
- get() {
1284
- return this.quoteDraftService.quoteDraft$.pipe(map$2(() => this.quoteDraftService.activeCurrentState), shareReplay$1());
1285
- }
1286
- getSnapshot() {
1287
- return this.quoteDraftService?.currentState.slice() ?? [];
1288
- }
1289
- get charges$() {
1290
- return this.quoteDraftService.quoteDraft$.pipe(map$2(({ charges }) => charges));
1291
- }
1292
- get pricePlans$() {
1293
- return this.quoteDraftService.quoteDraft$.pipe(map$2(({ pricePlans }) => pricePlans));
1294
- }
1295
- get activeMetrics$() {
1296
- return this.quoteDraftService.quoteDraft$.pipe(map$2(({ activeMetrics }) => activeMetrics));
1297
- }
1298
- get chargesSnapshot() {
1299
- return this.quoteDraftService.quoteDraft?.charges ?? {};
1300
- }
1301
- get pricePlansSnapshot() {
1302
- return this.quoteDraftService.quoteDraft?.pricePlans ?? {};
1303
- }
1304
- get activeMetricsSnapshot() {
1305
- return this.quoteDraftService.quoteDraft?.activeMetrics ?? [];
1306
- }
1307
- get contextSnapshot() {
1308
- return this.contextService.resolve();
1309
- }
1310
- get context$() {
1311
- return this.contextService.resolve$();
2252
+ return this.executeProcessorScript(request, script, processor.inputData);
1312
2253
  }
1313
- handleErrorAndBounceBack() {
1314
- return (source$) => {
1315
- return source$.pipe(catchError$1(error => {
1316
- console.error(error);
1317
- // bounce back if configuration call has failed
1318
- const quoteDraft = this.quoteDraftService.quoteDraft;
1319
- if (quoteDraft) {
1320
- this.quoteDraftService.updateQuoteDraft(quoteDraft);
1321
- }
1322
- return throwError(() => error);
1323
- }));
1324
- };
2254
+ executeProcessorScript(request, script, inputData) {
2255
+ return new Function(`${script}\nreturn transform;`)()({
2256
+ request,
2257
+ inputData: inputData,
2258
+ });
1325
2259
  }
1326
2260
  }
1327
- FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
1328
- FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationService });
1329
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationService, decorators: [{
2261
+ ConfigurationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationState, deps: [{ token: i1.StatefulConfigurationApiService }, { token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: i6.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
2262
+ ConfigurationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationState });
2263
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationState, decorators: [{
1330
2264
  type: Injectable
1331
- }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1332
-
1333
- class FlowConfigurationModule {
1334
- }
1335
- FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1336
- FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationModule });
1337
- FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, PriceApiService] });
1338
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationModule, decorators: [{
1339
- type: NgModule,
1340
- args: [{
1341
- imports: [],
1342
- providers: [FlowConfigurationService, FlowUpdateService, PriceApiService],
1343
- }]
1344
- }] });
2265
+ }], ctorParameters: function () { return [{ type: i1.StatefulConfigurationApiService }, { type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: i6.ToastService }]; } });
1345
2266
 
1346
2267
  class ConfigurationModule {
1347
2268
  }
1348
- ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1349
- ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule] });
1350
- ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, providers: [
2269
+ ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2270
+ ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule] });
2271
+ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, providers: [
1351
2272
  ContextApiService,
1352
2273
  ProductModelApiService,
1353
2274
  ConfigurationApiService,
@@ -1356,7 +2277,7 @@ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ver
1356
2277
  ConfigurationService,
1357
2278
  ConfigurationState,
1358
2279
  ], imports: [ConfirmationDialogModule] });
1359
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, decorators: [{
2280
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
1360
2281
  type: NgModule,
1361
2282
  args: [{
1362
2283
  imports: [ConfirmationDialogModule],
@@ -1372,269 +2293,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1372
2293
  }]
1373
2294
  }] });
1374
2295
 
1375
- function calculateMetricByMethod(lineItems, metric, method) {
1376
- const items = getLineItemsByMethod(lineItems, method);
1377
- return items.reduce((acc, li) => {
1378
- let value = li.reduce((accProduct, item) => accProduct + ((item.totalMetrics && item.totalMetrics[metric]) || 0), 0);
1379
- if (method === 'avg' && li.length > 0) {
1380
- value /= li.length;
1381
- }
1382
- return acc + value;
1383
- }, 0);
1384
- }
1385
- function getLineItemsByMethod(lineItems, method) {
1386
- switch (method) {
1387
- case 'first': {
1388
- return lineItems.filter(li => !li.rampInstanceId).map(item => [item]);
1389
- }
1390
- case 'last': {
1391
- const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
1392
- const products = rootTermItems.map(lineItem => [
1393
- lineItem,
1394
- ...lineItems.filter(li => li.rampInstanceId === lineItem.id),
1395
- ]);
1396
- return products
1397
- .map(items => [...items].sort((a, b) => getDateValue(a.endDate || '') - getDateValue(b.endDate || '')).pop())
1398
- .filter((li) => Boolean(li))
1399
- .map(item => [item]);
1400
- }
1401
- case 'avg': {
1402
- const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
1403
- return rootTermItems.map(lineItem => [lineItem, ...lineItems.filter(li => li.rampInstanceId === lineItem.id)]);
1404
- }
1405
- case 'sum': {
1406
- return lineItems.map(item => [item]);
1407
- }
1408
- default: {
1409
- return lineItems.map(item => [item]);
1410
- }
1411
- }
1412
- }
1413
- function getDateValue(date) {
1414
- return date ? new Date(date).getTime() : 0;
1415
- }
1416
-
1417
- class MetricsCalculationService {
1418
- get onMetricsUpdate$() {
1419
- return this.metricsUpdated$.asObservable();
1420
- }
1421
- constructor(quoteDraftService, flowConfiguration, settingsService) {
1422
- this.quoteDraftService = quoteDraftService;
1423
- this.flowConfiguration = flowConfiguration;
1424
- this.settingsService = settingsService;
1425
- this.metricsUpdated$ = new Subject();
1426
- this.quoteMetricsSettings = {};
1427
- this.metricsCalculationMethodMap = {};
1428
- this.metricsData = {};
1429
- this.activeMetricRules = [];
1430
- this.activeMetricRules = this.flowConfiguration.activeMetricsSnapshot.filter(metricRule => metricRule.metrics.some(metric => !!metric.totalName));
1431
- combineLatest([
1432
- this.quoteDraftService.currentState$,
1433
- this.settingsService.fetchSetting('QUOTE_LEVEL_METRIC_CALCULATION_METHOD').pipe(take$1(1)),
1434
- ]).subscribe(([lineItems, setting]) => {
1435
- let settingsData = {};
1436
- try {
1437
- settingsData = JSON.parse(setting?.value || '{}');
1438
- }
1439
- catch (error) {
1440
- settingsData = {};
1441
- }
1442
- this.quoteMetricsSettings = settingsData;
1443
- this.updateMetrics(lineItems);
1444
- });
1445
- }
1446
- getMetricValue(metric) {
1447
- return this.metricsData[metric] || 0;
1448
- }
1449
- updateMetrics(lineItems) {
1450
- const metricKeys = this.collectMetricKeys(lineItems).filter(key => !key.includes('Effective_'));
1451
- this.metricsCalculationMethodMap = this.buildMetricsCalculationMethods(metricKeys, this.metricsCalculationMethodMap);
1452
- this.metricsData = metricKeys.reduce((acc, key) => ({ ...acc, [key]: this.calculateMetric(lineItems, key) }), {});
1453
- this.metricsUpdated$.next();
1454
- }
1455
- calculateMetric(lineItems, metric) {
1456
- return calculateMetricByMethod(lineItems, metric, this.metricsCalculationMethodMap[metric] || 'sum');
1457
- }
1458
- buildMetricsCalculationMethods(metricKeys, initial) {
1459
- return metricKeys.reduce((acc, name) => {
1460
- if (acc[name]) {
1461
- return acc;
1462
- }
1463
- acc = { ...acc, [name]: 'sum' };
1464
- const metricRule = this.getMetricRuleByTotalMetricName(name);
1465
- const settingKey = metricRule?.metrics?.find(metric => metric.totalName === name)?.name || name;
1466
- if (this.quoteMetricsSettings[settingKey]) {
1467
- acc = { ...acc, [name]: this.quoteMetricsSettings[settingKey] };
1468
- }
1469
- return acc;
1470
- }, initial);
1471
- }
1472
- collectMetricKeys(lineItems) {
1473
- const keys = [];
1474
- lineItems.forEach(lineItem => {
1475
- keys.push(...Object.keys(lineItem.totalMetrics || {}));
1476
- keys.push(...this.collectMetricKeys(lineItem.lineItems));
1477
- });
1478
- return uniq(keys);
1479
- }
1480
- getMetricRuleByTotalMetricName(name) {
1481
- return this.activeMetricRules.find(metricRule => metricRule.metrics.find(metric => metric.totalName === name));
1482
- }
1483
- }
1484
- MetricsCalculationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: MetricsCalculationService, deps: [{ token: QuoteDraftService }, { token: FlowConfigurationService }, { token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1485
- MetricsCalculationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: MetricsCalculationService, providedIn: 'root' });
1486
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: MetricsCalculationService, decorators: [{
1487
- type: Injectable,
1488
- args: [{ providedIn: 'root' }]
1489
- }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: FlowConfigurationService }, { type: i1.ConfigurationSettingsApiService }]; } });
1490
-
1491
- class ProductImagesService {
1492
- constructor(productApiService) {
1493
- this.productApiService = productApiService;
1494
- this.imagesMap$ = new BehaviorSubject({});
1495
- }
1496
- getImageUrl$(productId) {
1497
- if (this.imagesMap$.value[productId] == null) {
1498
- this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: '' });
1499
- this.fetchProductImage(productId);
1500
- }
1501
- return this.imagesMap$.pipe(map$2(imagesMap => imagesMap[productId]), distinctUntilChanged());
1502
- }
1503
- fetchProductImage(productId) {
1504
- this.productApiService
1505
- .fetchImage$(productId)
1506
- .pipe(map$2(file => URL.createObjectURL(file)), catchError$1(() => of('')), tap$1(url => this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: url })))
1507
- .subscribe();
1508
- }
1509
- }
1510
- ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1511
- ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductImagesService, providedIn: 'root' });
1512
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductImagesService, decorators: [{
1513
- type: Injectable,
1514
- args: [{ providedIn: 'root' }]
1515
- }], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
1516
-
1517
- class RuntimeSettingsService {
1518
- constructor(configurationSettingsApiService) {
1519
- this.configurationSettingsApiService = configurationSettingsApiService;
1520
- this.configurationSettings$ = new BehaviorSubject({});
1521
- this.currencySettings$ = new BehaviorSubject({
1522
- iso: DEFAULT_CURRENCY_ISO_CODE,
1523
- symbol: DEFAULT_CURRENCY_SYMBOL,
1524
- });
1525
- this.getCurrencySymbol = (locale, currency) => {
1526
- return (0)
1527
- .toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
1528
- .replace(/\d/g, '')
1529
- .trim();
1530
- };
1531
- }
1532
- create() {
1533
- return this.configurationSettingsApiService.fetchSettings().pipe(map$2(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
1534
- this.configurationSettings$.next(configurationSettings);
1535
- this.formattingSettings = this.getFormattingSettings();
1536
- }), map$2(() => undefined));
1537
- }
1538
- initCurrency(iso) {
1539
- if (iso) {
1540
- const symbol = this.getCurrencySymbol('en-US', iso);
1541
- this.currencySettings$.next({ iso, symbol });
1542
- }
1543
- }
1544
- getFormattingSettings() {
1545
- if (this.formattingSettings) {
1546
- return this.formattingSettings;
1547
- }
1548
- const shoppingCartSettings = this.getConfigurationSettings()['shopping-cart']?.reduce((acc, setting) => {
1549
- return { ...acc, [setting.id]: setting.properties };
1550
- }, {});
1551
- const currencySettings = this.getCurrencySettings();
1552
- const dateFormat = (validateDateFormat(shoppingCartSettings?.DATE_FORMAT ?? '') && shoppingCartSettings?.DATE_FORMAT) ||
1553
- DEFAULT_DATE_FORMAT;
1554
- const decimalSeparator = shoppingCartSettings?.DECIMAL_SEPARATOR;
1555
- const thousandsSeparator = shoppingCartSettings?.THOUSANDS_SEPARATOR;
1556
- // the number of decimal places can be 0
1557
- const priceScale = shoppingCartSettings?.PRICE_SCALE;
1558
- const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
1559
- ? Number(priceScale)
1560
- : DEFAULT_DECIMALS_COUNT;
1561
- return {
1562
- currencySymbol: currencySettings.symbol,
1563
- dateFormats: getSupportedDateFormats(dateFormat),
1564
- decimalsCount,
1565
- decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
1566
- ? decimalSeparator
1567
- : DEFAULT_DECIMAL_SEPARATOR,
1568
- // thousands separator can be a blank value, so it can also be null
1569
- thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
1570
- ? thousandsSeparator || ''
1571
- : DEFAULT_THOUSANDS_SEPARATOR,
1572
- };
1573
- }
1574
- getConfigurationSettings() {
1575
- return this.configurationSettings$.value;
1576
- }
1577
- getCurrencySettings() {
1578
- return this.currencySettings$.value;
1579
- }
1580
- parseConfigurationSettings(settings) {
1581
- return settings.reduce((acc, setting) => {
1582
- switch (setting.key) {
1583
- case 'shopping-cart':
1584
- acc['shopping-cart'] = parseJsonSafely(setting.value, []);
1585
- break;
1586
- case 'navigation':
1587
- acc.navigation = parseJsonSafely(setting.value, {});
1588
- break;
1589
- case 'flows':
1590
- acc.flows = parseJsonSafely(setting.value, []);
1591
- break;
1592
- default:
1593
- acc[setting.key] = setting.value;
1594
- }
1595
- return acc;
1596
- }, {});
1597
- }
1598
- }
1599
- RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1600
- RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, providedIn: 'root' });
1601
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, decorators: [{
1602
- type: Injectable,
1603
- args: [{ providedIn: 'root' }]
1604
- }], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
1605
-
1606
2296
  const DEFAULT_FORMATTING_SETTINGS = {
1607
2297
  currencySymbol: DEFAULT_CURRENCY_SYMBOL,
1608
2298
  decimalsCount: DEFAULT_DECIMALS_COUNT,
1609
2299
  dateFormats: getSupportedDateFormats(DEFAULT_DATE_FORMAT),
1610
2300
  decimalSeparator: DEFAULT_DECIMAL_SEPARATOR,
1611
2301
  thousandsSeparator: DEFAULT_THOUSANDS_SEPARATOR,
2302
+ actionCodeLabels: DEFAULT_ACTION_CODE_LABELS,
1612
2303
  };
1613
2304
  class SdkCoreModule {
1614
2305
  }
1615
- SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1616
- SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
1617
- SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, providers: [
1618
- ContextService,
1619
- QuoteDraftService,
1620
- ProductImagesService,
1621
- MetricsCalculationService,
1622
- RuntimeSettingsService,
2306
+ SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2307
+ SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
2308
+ SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, providers: [
2309
+ IntegrationState,
2310
+ FlowStateService,
1623
2311
  {
1624
2312
  provide: FORMATTING_SETTINGS_TOKEN,
1625
2313
  useExisting: RuntimeSettingsService,
1626
2314
  },
1627
2315
  ], imports: [ConfigurationModule, FlowConfigurationModule] });
1628
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, decorators: [{
2316
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, decorators: [{
1629
2317
  type: NgModule,
1630
2318
  args: [{
1631
2319
  imports: [ConfigurationModule, FlowConfigurationModule],
1632
2320
  providers: [
1633
- ContextService,
1634
- QuoteDraftService,
1635
- ProductImagesService,
1636
- MetricsCalculationService,
1637
- RuntimeSettingsService,
2321
+ IntegrationState,
2322
+ FlowStateService,
1638
2323
  {
1639
2324
  provide: FORMATTING_SETTINGS_TOKEN,
1640
2325
  useExisting: RuntimeSettingsService,
@@ -1666,9 +2351,9 @@ class CalendarDirective {
1666
2351
  }
1667
2352
  }
1668
2353
  }
1669
- CalendarDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1670
- CalendarDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.8", type: CalendarDirective, selector: "[vlCalendar]", inputs: { vlCalendar: "vlCalendar" }, ngImport: i0 });
1671
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CalendarDirective, decorators: [{
2354
+ CalendarDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2355
+ CalendarDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: CalendarDirective, selector: "[vlCalendar]", inputs: { vlCalendar: "vlCalendar" }, ngImport: i0 });
2356
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarDirective, decorators: [{
1672
2357
  type: Directive,
1673
2358
  args: [{
1674
2359
  selector: '[vlCalendar]',
@@ -1679,10 +2364,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1679
2364
 
1680
2365
  class SdkDirectivesModule {
1681
2366
  }
1682
- SdkDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1683
- SdkDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, declarations: [CalendarDirective], exports: [CalendarDirective] });
1684
- SdkDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule });
1685
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, decorators: [{
2367
+ SdkDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2368
+ SdkDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, declarations: [CalendarDirective], exports: [CalendarDirective] });
2369
+ SdkDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule });
2370
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, decorators: [{
1686
2371
  type: NgModule,
1687
2372
  args: [{
1688
2373
  declarations: [CalendarDirective],
@@ -1701,21 +2386,27 @@ class DatePipe {
1701
2386
  this.destroy$.next();
1702
2387
  this.destroy$.complete();
1703
2388
  }
1704
- transform(date) {
2389
+ transform(date, type = 'date') {
1705
2390
  if (!date) {
1706
2391
  return '';
1707
2392
  }
2393
+ const dateFormat = this.formattingSettings?.dateFormats.datePipeFormat || DEFAULT_DATE_FORMAT;
2394
+ const formatMap = {
2395
+ date: dateFormat,
2396
+ time: DEFAULT_TIME_FORMAT,
2397
+ datetime: `${dateFormat} ${DEFAULT_TIME_FORMAT}`,
2398
+ };
1708
2399
  try {
1709
- return formatDate(date, this.formattingSettings?.dateFormats.datePipeFormat || DEFAULT_DATE_FORMAT, this.locale, this.defaultOptions?.timezone);
2400
+ return formatDate(date, formatMap[type], this.locale, this.defaultOptions?.timezone);
1710
2401
  }
1711
2402
  catch (error) {
1712
2403
  return new Date(date).toString();
1713
2404
  }
1714
2405
  }
1715
2406
  }
1716
- DatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1717
- DatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, name: "vlDate" });
1718
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, decorators: [{
2407
+ DatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2408
+ DatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, name: "vlDate" });
2409
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, decorators: [{
1719
2410
  type: Pipe,
1720
2411
  args: [{
1721
2412
  name: 'vlDate',
@@ -1735,9 +2426,9 @@ class NumberPipe {
1735
2426
  return formatNumber(price, this.formattingSettings?.thousandsSeparator, this.formattingSettings?.decimalSeparator, this.formattingSettings?.decimalsCount);
1736
2427
  }
1737
2428
  }
1738
- NumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1739
- NumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, name: "vlNumber" });
1740
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, decorators: [{
2429
+ NumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2430
+ NumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, name: "vlNumber" });
2431
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, decorators: [{
1741
2432
  type: Pipe,
1742
2433
  args: [{
1743
2434
  name: 'vlNumber',
@@ -1760,25 +2451,42 @@ class PricePipe {
1760
2451
  return `${this.formattingSettings?.currencySymbol || DEFAULT_CURRENCY_SYMBOL}${formatNumber(price, this.formattingSettings?.thousandsSeparator, this.formattingSettings?.decimalSeparator, this.formattingSettings?.decimalsCount)}`;
1761
2452
  }
1762
2453
  }
1763
- PricePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1764
- PricePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, name: "vlPrice" });
1765
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, decorators: [{
2454
+ PricePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2455
+ PricePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, name: "vlPrice" });
2456
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, decorators: [{
1766
2457
  type: Pipe,
1767
2458
  args: [{
1768
2459
  name: 'vlPrice',
1769
2460
  }]
1770
2461
  }] });
1771
2462
 
2463
+ class ActionCodePipe {
2464
+ constructor() {
2465
+ this.formattingSettings = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })?.getFormattingSettings();
2466
+ }
2467
+ transform(actionCode) {
2468
+ return this.formattingSettings?.actionCodeLabels[actionCode] ?? actionCode;
2469
+ }
2470
+ }
2471
+ ActionCodePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2472
+ ActionCodePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, name: "vlActionCode" });
2473
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, decorators: [{
2474
+ type: Pipe,
2475
+ args: [{
2476
+ name: 'vlActionCode',
2477
+ }]
2478
+ }] });
2479
+
1772
2480
  class SdkPipesModule {
1773
2481
  }
1774
- SdkPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1775
- SdkPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, declarations: [NumberPipe, PricePipe, DatePipe], exports: [NumberPipe, PricePipe, DatePipe] });
1776
- SdkPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule });
1777
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, decorators: [{
2482
+ SdkPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2483
+ SdkPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, declarations: [NumberPipe, PricePipe, DatePipe, ActionCodePipe], exports: [NumberPipe, PricePipe, DatePipe, ActionCodePipe] });
2484
+ SdkPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule });
2485
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, decorators: [{
1778
2486
  type: NgModule,
1779
2487
  args: [{
1780
- declarations: [NumberPipe, PricePipe, DatePipe],
1781
- exports: [NumberPipe, PricePipe, DatePipe],
2488
+ declarations: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
2489
+ exports: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
1782
2490
  }]
1783
2491
  }] });
1784
2492
 
@@ -1786,5 +2494,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1786
2494
  * Generated bundle index. Do not edit.
1787
2495
  */
1788
2496
 
1789
- export { CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationState, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
2497
+ export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationState, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, FlowUpdateService, IntegrationState, LineItemWorker, MetricsCalculationService, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateConfigurationLineItem, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
1790
2498
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map