@veloceapps/sdk 8.0.0-13 → 8.0.0-131

Sign up to get free protection for your applications and to get access to all the features.
Files changed (330) 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/elements-resolver.d.ts +0 -2
  12. package/cms/utils/index.d.ts +3 -0
  13. package/cms/utils/transpilation-worker.d.ts +13 -0
  14. package/cms/vendor-map.d.ts +26 -13
  15. package/core/README.md +20 -0
  16. package/core/modules/configuration/helpers.d.ts +4 -3
  17. package/core/modules/configuration/services/configuration-runtime.service.d.ts +1 -1
  18. package/core/modules/configuration/services/configuration.service.d.ts +6 -1
  19. package/core/modules/configuration/types/configuration.types.d.ts +4 -0
  20. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +5 -0
  21. package/core/pipes/action-code.pipe.d.ts +8 -0
  22. package/core/pipes/date.pipe.d.ts +2 -1
  23. package/core/pipes/index.d.ts +1 -0
  24. package/core/pipes/pipes.module.d.ts +2 -1
  25. package/core/services/context.service.d.ts +3 -0
  26. package/core/services/flow-info.service.d.ts +27 -0
  27. package/core/services/flow-state-configuration.service.d.ts +20 -0
  28. package/core/services/flow-state.service.d.ts +70 -0
  29. package/core/services/index.d.ts +4 -0
  30. package/core/services/quote-draft.service.d.ts +8 -1
  31. package/core/services/runtime-settings.service.d.ts +4 -1
  32. package/core/types/flow-customization.types.d.ts +22 -0
  33. package/core/types/flow-state.types.d.ts +6 -0
  34. package/core/types/formatting-settings.types.d.ts +2 -0
  35. package/core/types/index.d.ts +3 -0
  36. package/{cms → core}/types/integration.types.d.ts +1 -0
  37. package/core/types/pipe.types.d.ts +1 -0
  38. package/esm2020/cms/cms.actions.mjs +15 -1
  39. package/esm2020/cms/components/element-children/element-children.component.mjs +3 -3
  40. package/esm2020/cms/components/element-children/element-children.module.mjs +4 -4
  41. package/esm2020/cms/components/element-drop-handle/element-drop-handle.component.mjs +3 -3
  42. package/esm2020/cms/components/element-drop-handle/element-drop-handle.module.mjs +4 -4
  43. package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +3 -3
  44. package/esm2020/cms/components/element-renderer/element-renderer.module.mjs +4 -4
  45. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +5 -5
  46. package/esm2020/cms/components/plugin.component.mjs +3 -3
  47. package/esm2020/cms/components/preview/preview.component.mjs +11 -11
  48. package/esm2020/cms/components/preview/preview.module.mjs +6 -6
  49. package/esm2020/cms/components/preview/preview.types.mjs +1 -1
  50. package/esm2020/cms/directives/custom-template.directive.mjs +7 -7
  51. package/esm2020/cms/index.mjs +2 -1
  52. package/esm2020/cms/launcher.module.mjs +7 -7
  53. package/esm2020/cms/modules/federated/federated-host.directive.mjs +3 -3
  54. package/esm2020/cms/modules/federated/federated.component.mjs +3 -3
  55. package/esm2020/cms/modules/federated/federated.module.mjs +4 -4
  56. package/esm2020/cms/modules/migrations/migrations.module.mjs +4 -4
  57. package/esm2020/cms/modules/migrations/services/migrations.service.mjs +3 -3
  58. package/esm2020/cms/modules/runtime/runtime.module.mjs +4 -4
  59. package/esm2020/cms/modules/runtime/services/compilation.service.mjs +12 -8
  60. package/esm2020/cms/modules/runtime/services/runtime-editor.service.mjs +3 -3
  61. package/esm2020/cms/modules/runtime/services/runtime.service.mjs +7 -7
  62. package/esm2020/cms/plugins/configuration.plugin.mjs +3 -3
  63. package/esm2020/cms/plugins/element-hover.plugin.mjs +3 -3
  64. package/esm2020/cms/plugins/io.plugin.mjs +3 -3
  65. package/esm2020/cms/plugins/page.plugin.mjs +3 -3
  66. package/esm2020/cms/plugins/region.plugin.mjs +3 -3
  67. package/esm2020/cms/plugins/script.plugin.mjs +3 -3
  68. package/esm2020/cms/services/element-context.service.mjs +3 -3
  69. package/esm2020/cms/services/index.mjs +1 -2
  70. package/esm2020/cms/services/io-provider.service.mjs +3 -3
  71. package/esm2020/cms/services/resources.service.mjs +3 -3
  72. package/esm2020/cms/services/templates.service.mjs +3 -3
  73. package/esm2020/cms/types/index.mjs +1 -2
  74. package/esm2020/cms/utils/element-metadata-worker.mjs +31 -0
  75. package/esm2020/cms/utils/elements-resolver.mjs +14 -28
  76. package/esm2020/cms/utils/index.mjs +4 -1
  77. package/esm2020/cms/utils/transpilation-worker.mjs +52 -0
  78. package/esm2020/cms/vendor-map.mjs +18 -5
  79. package/esm2020/core/core.module.mjs +12 -17
  80. package/esm2020/core/directives/directives.module.mjs +4 -4
  81. package/esm2020/core/directives/primeng-calendar.directive.mjs +3 -3
  82. package/esm2020/core/modules/configuration/configuration.module.mjs +4 -4
  83. package/esm2020/core/modules/configuration/helpers.mjs +28 -3
  84. package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +11 -14
  85. package/esm2020/core/modules/configuration/services/configuration.service.mjs +29 -10
  86. package/esm2020/core/modules/configuration/services/configuration.state.mjs +5 -5
  87. package/esm2020/core/modules/configuration/services/runtime-context.service.mjs +9 -9
  88. package/esm2020/core/modules/configuration/types/configuration.types.mjs +1 -1
  89. package/esm2020/core/modules/flow-configuration/flow-configuration.module.mjs +4 -4
  90. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +15 -11
  91. package/esm2020/core/modules/flow-configuration/services/flow-update.service.mjs +3 -3
  92. package/esm2020/core/pipes/action-code.pipe.mjs +20 -0
  93. package/esm2020/core/pipes/date.pipe.mjs +13 -7
  94. package/esm2020/core/pipes/index.mjs +2 -1
  95. package/esm2020/core/pipes/number.pipe.mjs +3 -3
  96. package/esm2020/core/pipes/pipes.module.mjs +8 -7
  97. package/esm2020/core/pipes/price.pipe.mjs +3 -3
  98. package/esm2020/core/services/context.service.mjs +32 -5
  99. package/esm2020/core/services/flow-info.service.mjs +94 -0
  100. package/esm2020/core/services/flow-state-configuration.service.mjs +52 -0
  101. package/esm2020/core/services/flow-state.service.mjs +444 -0
  102. package/esm2020/core/services/index.mjs +5 -1
  103. package/esm2020/core/services/integration.state.mjs +37 -0
  104. package/esm2020/core/services/metric-calculation/metric-calculation.service.mjs +3 -3
  105. package/esm2020/core/services/product-images.service.mjs +3 -3
  106. package/esm2020/core/services/quote-draft.service.mjs +32 -7
  107. package/esm2020/core/services/runtime-settings.service.mjs +20 -5
  108. package/esm2020/core/types/flow-customization.types.mjs +3 -0
  109. package/esm2020/core/types/flow-state.types.mjs +2 -0
  110. package/esm2020/core/types/formatting-settings.types.mjs +1 -1
  111. package/esm2020/core/types/index.mjs +4 -1
  112. package/esm2020/core/types/integration.types.mjs +2 -0
  113. package/esm2020/core/types/pipe.types.mjs +2 -0
  114. package/esm2020/src/components/dialog/dialog.component.mjs +3 -3
  115. package/esm2020/src/components/dialog/dialog.module.mjs +4 -4
  116. package/esm2020/src/components/doc-gen/doc-gen.component.mjs +45 -54
  117. package/esm2020/src/components/doc-gen/doc-gen.module.mjs +4 -4
  118. package/esm2020/src/components/flow-header/flow-header.component.mjs +108 -0
  119. package/esm2020/src/components/flow-header/flow-header.module.mjs +19 -0
  120. package/esm2020/src/components/flow-header/index.mjs +2 -0
  121. package/esm2020/src/components/guided-selling/guided-selling.component.mjs +42 -51
  122. package/esm2020/src/components/guided-selling/guided-selling.module.mjs +4 -4
  123. package/esm2020/src/configure-primeng.mjs +33 -0
  124. package/esm2020/src/flow-routing.module.mjs +66 -75
  125. package/esm2020/src/flow.component.mjs +24 -33
  126. package/esm2020/src/flow.module.mjs +11 -9
  127. package/esm2020/src/guards/context.guard.mjs +7 -12
  128. package/esm2020/src/guards/flow.guard.mjs +31 -0
  129. package/esm2020/src/guards/product-unload.guard.mjs +7 -4
  130. package/esm2020/src/guards/root.guard.mjs +17 -13
  131. package/esm2020/src/pages/assets/assets.component.mjs +34 -38
  132. package/esm2020/src/pages/assets/assets.module.mjs +4 -4
  133. package/esm2020/src/pages/catalog/catalog.component.mjs +34 -38
  134. package/esm2020/src/pages/catalog/catalog.module.mjs +4 -4
  135. package/esm2020/src/pages/debug/debug.component.mjs +12 -16
  136. package/esm2020/src/pages/debug/debug.module.mjs +4 -4
  137. package/esm2020/src/pages/empty-account/empty-account.component.mjs +3 -3
  138. package/esm2020/src/pages/empty-account/empty-account.module.mjs +4 -4
  139. package/esm2020/src/pages/product/product.component.mjs +7 -10
  140. package/esm2020/src/pages/product/product.module.mjs +4 -4
  141. package/esm2020/src/pages/record-not-found/record-not-found.component.mjs +3 -3
  142. package/esm2020/src/pages/record-not-found/record-not-found.module.mjs +4 -4
  143. package/esm2020/src/pages/remote/remote.component.mjs +13 -14
  144. package/esm2020/src/pages/remote/remote.module.mjs +4 -4
  145. package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +35 -39
  146. package/esm2020/src/pages/shopping-cart/shopping-cart.module.mjs +4 -4
  147. package/esm2020/src/resolvers/flow.resolver.mjs +37 -51
  148. package/esm2020/src/resolvers/quote.resolver.mjs +40 -65
  149. package/esm2020/src/services/doc-gen.service.mjs +7 -6
  150. package/esm2020/src/services/flow-dialog.service.mjs +22 -7
  151. package/esm2020/src/services/flow-router.service.mjs +31 -10
  152. package/esm2020/src/services/flow.service.mjs +36 -11
  153. package/esm2020/src/services/guided-selling.service.mjs +8 -7
  154. package/esm2020/src/services/index.mjs +3 -1
  155. package/esm2020/src/types/index.mjs +1 -2
  156. package/esm2020/src/utils/flow.utils.mjs +6 -2
  157. package/fesm2015/veloceapps-sdk-cms.mjs +317 -244
  158. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  159. package/fesm2015/veloceapps-sdk-core.mjs +1555 -827
  160. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  161. package/fesm2015/veloceapps-sdk.mjs +744 -1544
  162. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  163. package/fesm2020/veloceapps-sdk-cms.mjs +331 -266
  164. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  165. package/fesm2020/veloceapps-sdk-core.mjs +1868 -1157
  166. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  167. package/fesm2020/veloceapps-sdk.mjs +856 -1655
  168. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  169. package/package.json +7 -13
  170. package/src/components/doc-gen/doc-gen.component.d.ts +8 -12
  171. package/src/components/flow-header/flow-header.component.d.ts +25 -0
  172. package/src/components/flow-header/flow-header.module.d.ts +9 -0
  173. package/src/components/flow-header/index.d.ts +1 -0
  174. package/src/components/guided-selling/guided-selling.component.d.ts +7 -11
  175. package/src/configure-primeng.d.ts +1 -0
  176. package/src/flow-routing.module.d.ts +6 -7
  177. package/src/flow.component.d.ts +7 -11
  178. package/src/flow.module.d.ts +2 -2
  179. package/src/guards/context.guard.d.ts +4 -5
  180. package/src/guards/flow.guard.d.ts +2 -0
  181. package/src/guards/product-unload.guard.d.ts +2 -2
  182. package/src/guards/root.guard.d.ts +0 -1
  183. package/src/pages/assets/assets.component.d.ts +5 -7
  184. package/src/pages/catalog/catalog.component.d.ts +5 -7
  185. package/src/pages/debug/debug.component.d.ts +5 -8
  186. package/src/pages/product/product.component.d.ts +2 -3
  187. package/src/pages/remote/remote.component.d.ts +1 -2
  188. package/src/pages/shopping-cart/shopping-cart.component.d.ts +5 -7
  189. package/src/resolvers/flow.resolver.d.ts +6 -7
  190. package/src/resolvers/quote.resolver.d.ts +6 -12
  191. package/src/services/doc-gen.service.d.ts +1 -1
  192. package/src/services/flow-dialog.service.d.ts +5 -2
  193. package/src/services/flow-router.service.d.ts +4 -2
  194. package/src/services/flow.service.d.ts +4 -2
  195. package/src/services/guided-selling.service.d.ts +1 -1
  196. package/src/services/index.d.ts +2 -0
  197. package/src/types/index.d.ts +0 -1
  198. package/esm2020/cms/services/integration.state.mjs +0 -37
  199. package/esm2020/cms/types/integration.types.mjs +0 -2
  200. package/esm2020/runtime/components/component-preview/component-preview.component.mjs +0 -125
  201. package/esm2020/runtime/components/index.mjs +0 -5
  202. package/esm2020/runtime/components/section-renderer/section-renderer.component.mjs +0 -67
  203. package/esm2020/runtime/components/ui-runtime/runtime.component.mjs +0 -440
  204. package/esm2020/runtime/components/ui-runtime-preview/runtime-preview.component.mjs +0 -108
  205. package/esm2020/runtime/execution/components/children-placeholder/children-placeholder.component.mjs +0 -60
  206. package/esm2020/runtime/execution/components/context-provider/context-provider.component.mjs +0 -39
  207. package/esm2020/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.mjs +0 -67
  208. package/esm2020/runtime/execution/components/federated/federated.component.mjs +0 -74
  209. package/esm2020/runtime/execution/components/velo-attribute/velo-attribute.component.mjs +0 -60
  210. package/esm2020/runtime/execution/components/velo-multiselect/velo-multiselect.component.mjs +0 -130
  211. package/esm2020/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.mjs +0 -72
  212. package/esm2020/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.mjs +0 -97
  213. package/esm2020/runtime/execution/components/velo-port-radio/velo-port-radio.component.mjs +0 -142
  214. package/esm2020/runtime/execution/components/velo-type/velo-type.component.mjs +0 -119
  215. package/esm2020/runtime/execution/directives/section-script.directive.mjs +0 -247
  216. package/esm2020/runtime/execution/directives/sf-query.directive.mjs +0 -35
  217. package/esm2020/runtime/execution/directives/velo-attribute.directive.mjs +0 -88
  218. package/esm2020/runtime/execution/directives/velo-port.directive.mjs +0 -376
  219. package/esm2020/runtime/execution/directives/vl-approval.directive.mjs +0 -23
  220. package/esm2020/runtime/execution/directives/vl-document-attachments.directive.mjs +0 -36
  221. package/esm2020/runtime/execution/directives/vl-document-templates.directive.mjs +0 -60
  222. package/esm2020/runtime/execution/directives/vl-quote.directive.mjs +0 -42
  223. package/esm2020/runtime/execution/directives/vl-ramp.directive.mjs +0 -55
  224. package/esm2020/runtime/execution/runtime-execution.module.mjs +0 -133
  225. package/esm2020/runtime/execution/utils/federated.util.mjs +0 -32
  226. package/esm2020/runtime/index.mjs +0 -5
  227. package/esm2020/runtime/runtime.module.mjs +0 -74
  228. package/esm2020/runtime/services/cart.service.mjs +0 -29
  229. package/esm2020/runtime/services/collapsible-state.service.mjs +0 -34
  230. package/esm2020/runtime/services/configuration.service.mjs +0 -119
  231. package/esm2020/runtime/services/current-state.service.mjs +0 -17
  232. package/esm2020/runtime/services/form-scope.service.mjs +0 -30
  233. package/esm2020/runtime/services/index.mjs +0 -4
  234. package/esm2020/runtime/services/product-model-cache.service.mjs +0 -31
  235. package/esm2020/runtime/services/runtime-context.service.mjs +0 -60
  236. package/esm2020/runtime/services/runtime-form.service.mjs +0 -219
  237. package/esm2020/runtime/services/runtime.service.mjs +0 -115
  238. package/esm2020/runtime/services/section-helper.service.mjs +0 -27
  239. package/esm2020/runtime/services/section-scope.service.mjs +0 -36
  240. package/esm2020/runtime/services/section-store.service.mjs +0 -22
  241. package/esm2020/runtime/services/section.service.mjs +0 -117
  242. package/esm2020/runtime/types/bound-data.types.mjs +0 -7
  243. package/esm2020/runtime/types/index.mjs +0 -3
  244. package/esm2020/runtime/types/quote-states.types.mjs +0 -2
  245. package/esm2020/runtime/types/runtime.types.mjs +0 -2
  246. package/esm2020/runtime/types/script-registry.types.mjs +0 -51
  247. package/esm2020/runtime/utils/line-item.util.mjs +0 -270
  248. package/esm2020/runtime/utils/section.utils.mjs +0 -26
  249. package/esm2020/runtime/utils/sections-binder.helper.mjs +0 -105
  250. package/esm2020/runtime/veloceapps-sdk-runtime.mjs +0 -5
  251. package/esm2020/src/components/header/cart-overlay/cart-preview.component.mjs +0 -119
  252. package/esm2020/src/components/header/cart-overlay/cart-preview.module.mjs +0 -47
  253. package/esm2020/src/components/header/header.component.mjs +0 -355
  254. package/esm2020/src/components/header/header.module.mjs +0 -52
  255. package/esm2020/src/components/header/header.types.mjs +0 -2
  256. package/esm2020/src/components/header/metrics/index.mjs +0 -2
  257. package/esm2020/src/components/header/metrics/metrics.component.mjs +0 -255
  258. package/esm2020/src/components/header/metrics/metrics.definitions.mjs +0 -2
  259. package/esm2020/src/components/header/metrics/metrics.module.mjs +0 -69
  260. package/esm2020/src/pages/legacy-product/legacy-product.component.mjs +0 -137
  261. package/esm2020/src/pages/legacy-product/legacy-product.module.mjs +0 -19
  262. package/esm2020/src/types/flow-customization.types.mjs +0 -3
  263. package/fesm2015/veloceapps-sdk-runtime.mjs +0 -3770
  264. package/fesm2015/veloceapps-sdk-runtime.mjs.map +0 -1
  265. package/fesm2020/veloceapps-sdk-runtime.mjs +0 -3767
  266. package/fesm2020/veloceapps-sdk-runtime.mjs.map +0 -1
  267. package/runtime/README.md +0 -5
  268. package/runtime/components/component-preview/component-preview.component.d.ts +0 -27
  269. package/runtime/components/index.d.ts +0 -4
  270. package/runtime/components/section-renderer/section-renderer.component.d.ts +0 -25
  271. package/runtime/components/ui-runtime/runtime.component.d.ts +0 -53
  272. package/runtime/components/ui-runtime-preview/runtime-preview.component.d.ts +0 -27
  273. package/runtime/execution/components/children-placeholder/children-placeholder.component.d.ts +0 -30
  274. package/runtime/execution/components/context-provider/context-provider.component.d.ts +0 -14
  275. package/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.d.ts +0 -25
  276. package/runtime/execution/components/federated/federated.component.d.ts +0 -36
  277. package/runtime/execution/components/velo-attribute/velo-attribute.component.d.ts +0 -19
  278. package/runtime/execution/components/velo-multiselect/velo-multiselect.component.d.ts +0 -35
  279. package/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.d.ts +0 -22
  280. package/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.d.ts +0 -22
  281. package/runtime/execution/components/velo-port-radio/velo-port-radio.component.d.ts +0 -28
  282. package/runtime/execution/components/velo-type/velo-type.component.d.ts +0 -31
  283. package/runtime/execution/directives/section-script.directive.d.ts +0 -59
  284. package/runtime/execution/directives/sf-query.directive.d.ts +0 -15
  285. package/runtime/execution/directives/velo-attribute.directive.d.ts +0 -26
  286. package/runtime/execution/directives/velo-port.directive.d.ts +0 -74
  287. package/runtime/execution/directives/vl-approval.directive.d.ts +0 -10
  288. package/runtime/execution/directives/vl-document-attachments.directive.d.ts +0 -15
  289. package/runtime/execution/directives/vl-document-templates.directive.d.ts +0 -33
  290. package/runtime/execution/directives/vl-quote.directive.d.ts +0 -14
  291. package/runtime/execution/directives/vl-ramp.directive.d.ts +0 -15
  292. package/runtime/execution/runtime-execution.module.d.ts +0 -25
  293. package/runtime/execution/utils/federated.util.d.ts +0 -6
  294. package/runtime/index.d.ts +0 -4
  295. package/runtime/runtime.module.d.ts +0 -16
  296. package/runtime/services/cart.service.d.ts +0 -15
  297. package/runtime/services/collapsible-state.service.d.ts +0 -15
  298. package/runtime/services/configuration.service.d.ts +0 -20
  299. package/runtime/services/current-state.service.d.ts +0 -8
  300. package/runtime/services/form-scope.service.d.ts +0 -20
  301. package/runtime/services/index.d.ts +0 -3
  302. package/runtime/services/product-model-cache.service.d.ts +0 -14
  303. package/runtime/services/runtime-context.service.d.ts +0 -16
  304. package/runtime/services/runtime-form.service.d.ts +0 -24
  305. package/runtime/services/runtime.service.d.ts +0 -44
  306. package/runtime/services/section-helper.service.d.ts +0 -8
  307. package/runtime/services/section-scope.service.d.ts +0 -14
  308. package/runtime/services/section-store.service.d.ts +0 -11
  309. package/runtime/services/section.service.d.ts +0 -30
  310. package/runtime/types/bound-data.types.d.ts +0 -13
  311. package/runtime/types/index.d.ts +0 -2
  312. package/runtime/types/quote-states.types.d.ts +0 -6
  313. package/runtime/types/runtime.types.d.ts +0 -19
  314. package/runtime/types/script-registry.types.d.ts +0 -13
  315. package/runtime/utils/line-item.util.d.ts +0 -34
  316. package/runtime/utils/section.utils.d.ts +0 -2
  317. package/runtime/utils/sections-binder.helper.d.ts +0 -16
  318. package/src/components/header/cart-overlay/cart-preview.component.d.ts +0 -36
  319. package/src/components/header/cart-overlay/cart-preview.module.d.ts +0 -14
  320. package/src/components/header/header.component.d.ts +0 -70
  321. package/src/components/header/header.module.d.ts +0 -16
  322. package/src/components/header/header.types.d.ts +0 -20
  323. package/src/components/header/metrics/index.d.ts +0 -1
  324. package/src/components/header/metrics/metrics.component.d.ts +0 -67
  325. package/src/components/header/metrics/metrics.definitions.d.ts +0 -1
  326. package/src/components/header/metrics/metrics.module.d.ts +0 -18
  327. package/src/pages/legacy-product/legacy-product.component.d.ts +0 -37
  328. package/src/pages/legacy-product/legacy-product.module.d.ts +0 -9
  329. package/src/types/flow-customization.types.d.ts +0 -12
  330. /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,1638 @@ 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 this.filterByActivePriceList(quoteDraft?.currentState || []).some(li => !li.assetId && !li.openOrderLineItemId);
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 this.filterByActivePriceList(quoteDraft?.currentState || []).some(li => li.assetId || li.openOrderLineItemId);
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;
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);
919
719
  }
920
- return this.quoteDraftService.quoteDraft?.initialState.find(a => a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId);
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 &&
1076
+ !this.quoteDraftService.hasProducts &&
1077
+ !this.quoteDraftService.hasAssets &&
1078
+ !this.quoteDraftService.quoteDraft?.initialState.length;
1079
+ if (this.quoteDraftService.isStandalone || isEmptyAccountMode) {
1080
+ return of(undefined);
1081
+ }
1082
+ return this.flowConfiguration.calculate$(flowState);
1083
+ }
1084
+ executeStateless$(request) {
1085
+ return of(undefined).pipe(tap$1(() => this.executeStatelessActions(request)), switchMap(() => {
1086
+ /*
1087
+ Skip price calculation in case
1088
+ 1. No actions in the request
1089
+ 2. Initialization process execution (state not initialized yet)
1090
+ */
1091
+ if (!request.actions?.length || !this.isInitialized()) {
1092
+ return of(undefined);
1093
+ }
1094
+ else {
1095
+ return this.calculate$();
1096
+ }
1097
+ }), map$1(() => this.executeStatelessSelectors(request)));
1098
+ }
1099
+ executeStatelessActions(request) {
1100
+ if (!this.quoteDraftService.quoteDraft || !request.actions?.length) {
1101
+ return;
1102
+ }
1103
+ let flowState = this.quoteDraftService.quoteDraft;
1104
+ request.actions.forEach(action => {
1105
+ flowState = this.executeActionScript(flowState, action) ?? flowState;
1106
+ });
1107
+ this.quoteDraftService.updateQuoteDraft(flowState);
1108
+ }
1109
+ executeStatelessSelectors(request) {
1110
+ if (!this.quoteDraftService.quoteDraft) {
1111
+ throw 'QuoteDraft is not initialized';
1112
+ }
1113
+ const flowState = this.quoteDraftService.quoteDraft;
1114
+ return EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
1115
+ try {
1116
+ result.selectors[key] = {
1117
+ success: true,
1118
+ result: this.executeSelectorScript(flowState, selector),
1119
+ };
1120
+ }
1121
+ catch (e) {
1122
+ result.selectors[key] = {
1123
+ success: false,
1124
+ errorMessage: String(e),
1125
+ };
1126
+ }
1127
+ return result;
1128
+ }, { stateId: '', selectors: {} });
1129
+ }
1130
+ getFlowSafe() {
1131
+ if (!this.flowInfoService.flow) {
1132
+ throw 'Flow is not defined';
1133
+ }
1134
+ return this.flowInfoService.flow;
1135
+ }
1136
+ initProcessors$() {
1137
+ const hasOverrides = Boolean(this.customizationService?.getTemplateConfigurationProcessors);
1138
+ const flow = this.getFlowSafe();
1139
+ if (flow.properties.stateful && !hasOverrides) {
1140
+ // Skip initialization as backend will take processors from SF
1141
+ return of(undefined);
1142
+ }
1143
+ const owners$ = Object.values(this.flowInfoService.templates)
1144
+ .map(template => {
1145
+ if (!template) {
1146
+ return;
1147
+ }
1148
+ const localProcessors$ = this.customizationService?.getTemplateConfigurationProcessors?.(template.name) ?? of(null);
1149
+ return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap$1(processors => {
1150
+ const processorsMap = processors.reduce((acc, p) => {
1151
+ acc[p.apiName] = p;
1152
+ return acc;
1153
+ }, {});
1154
+ this.processors[template.id] = processorsMap;
1155
+ }));
1156
+ })
1157
+ .filter(isDefined);
1158
+ if (!owners$.length) {
1159
+ return of(undefined);
1160
+ }
1161
+ return forkJoin(owners$).pipe(map$1(noop));
1162
+ }
1163
+ executeActionScript(request, executable) {
1164
+ const script = this.processors[executable.ownerId]?.[executable.apiName]?.script;
1165
+ if (!script) {
1166
+ const scope = this.getScopeByOwnerId(executable.ownerId);
1167
+ const scopeText = scope ? ` in ${scope}` : '';
1168
+ throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
1169
+ }
1170
+ return this.executeProcessorScript(request, script, executable.inputData);
1171
+ }
1172
+ executeSelectorScript(request, executable) {
1173
+ const script = this.processors[executable.ownerId]?.[executable.apiName]?.script;
1174
+ if (!script) {
1175
+ const scope = this.getScopeByOwnerId(executable.ownerId);
1176
+ const scopeText = scope ? ` in ${scope}` : '';
1177
+ throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
1178
+ }
1179
+ return this.executeProcessorScript(request, script, executable.inputData);
1180
+ }
1181
+ executeProcessorScript(request, script, inputData) {
1182
+ return new Function(`${script}\nreturn transform;`)()({
1183
+ request,
1184
+ inputData: inputData,
1185
+ });
1186
+ }
1187
+ generateRequestId(scope, selectorName, inputData) {
1188
+ const inputDataHash = UUID.hex(JSON.stringify(inputData) || '').slice(0, 8);
1189
+ return `${scope}/${selectorName}/${inputDataHash}`;
1190
+ }
1191
+ getDefaultExecutionRequestDTO() {
1192
+ const request = {
1193
+ actions: [],
1194
+ selectors: {},
1195
+ };
1196
+ if (this.getFlowSafe().properties.standalone) {
1197
+ return request;
1198
+ }
1199
+ const ownerId = this.getOwnerIdByScope(UITemplateType.FLOW_ENGINE);
1200
+ request.actions?.push({
1201
+ apiName: 'INITIALIZE_STATE',
1202
+ ownerId,
1203
+ inputData: {},
1204
+ });
1205
+ return request;
1206
+ }
1207
+ }
1208
+ 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 });
1209
+ FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, providedIn: 'root' });
1210
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, decorators: [{
1211
+ type: Injectable,
1212
+ args: [{ providedIn: 'root' }]
1213
+ }], 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: [{
1214
+ type: Optional
1215
+ }, {
1216
+ type: Inject,
1217
+ args: [FLOW_CUSTOMIZATION]
1218
+ }] }]; } });
1219
+
1220
+ class RuntimeSettingsService {
1221
+ constructor(configurationSettingsApiService) {
1222
+ this.configurationSettingsApiService = configurationSettingsApiService;
1223
+ this.configurationSettings$ = new BehaviorSubject({});
1224
+ this.currencySettings$ = new BehaviorSubject({
1225
+ iso: DEFAULT_CURRENCY_ISO_CODE,
1226
+ symbol: DEFAULT_CURRENCY_SYMBOL,
1227
+ });
1228
+ this.shoppingCartSettings$ = new BehaviorSubject([]);
1229
+ this.getCurrencySymbol = (locale, currency) => {
1230
+ return (0)
1231
+ .toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
1232
+ .replace(/\d/g, '')
1233
+ .trim();
1234
+ };
1235
+ }
1236
+ create() {
1237
+ return this.configurationSettingsApiService.fetchSettings().pipe(map$1(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
1238
+ this.configurationSettings$.next(configurationSettings);
1239
+ this.addShoppingCartSettings(configurationSettings['shopping-cart'] ?? []);
1240
+ this.formattingSettings = this.getFormattingSettings();
1241
+ }), map$1(() => undefined));
1242
+ }
1243
+ initCurrency(iso) {
1244
+ if (iso) {
1245
+ const symbol = this.getCurrencySymbol('en-US', iso);
1246
+ this.currencySettings$.next({ iso, symbol });
1247
+ }
1248
+ }
1249
+ getFormattingSettings() {
1250
+ if (this.formattingSettings) {
1251
+ return this.formattingSettings;
1252
+ }
1253
+ const shoppingCartSettings = this.getConfigurationSettings()['shopping-cart']?.reduce((acc, setting) => {
1254
+ return { ...acc, [setting.id]: setting.properties };
1255
+ }, {});
1256
+ const currencySettings = this.getCurrencySettings();
1257
+ const dateFormat = (validateDateFormat(shoppingCartSettings?.DATE_FORMAT ?? '') && shoppingCartSettings?.DATE_FORMAT) ||
1258
+ DEFAULT_DATE_FORMAT;
1259
+ const decimalSeparator = shoppingCartSettings?.DECIMAL_SEPARATOR;
1260
+ const thousandsSeparator = shoppingCartSettings?.THOUSANDS_SEPARATOR;
1261
+ // the number of decimal places can be 0
1262
+ const priceScale = shoppingCartSettings?.PRICE_SCALE;
1263
+ const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
1264
+ ? Number(priceScale)
1265
+ : DEFAULT_DECIMALS_COUNT;
1266
+ const actionCodeSettings = shoppingCartSettings?.STATUS_LABEL;
1267
+ return {
1268
+ currencySymbol: currencySettings.symbol,
1269
+ dateFormats: getSupportedDateFormats(dateFormat),
1270
+ decimalsCount,
1271
+ decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
1272
+ ? decimalSeparator
1273
+ : DEFAULT_DECIMAL_SEPARATOR,
1274
+ // thousands separator can be a blank value, so it can also be null
1275
+ thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
1276
+ ? thousandsSeparator || ''
1277
+ : DEFAULT_THOUSANDS_SEPARATOR,
1278
+ actionCodeLabels: actionCodeSettings?.length
1279
+ ? actionCodeSettings.reduce((result, setting) => ({ ...result, [setting.status_label]: setting.custom_label }), {})
1280
+ : DEFAULT_ACTION_CODE_LABELS,
1281
+ };
1282
+ }
1283
+ getConfigurationSettings() {
1284
+ return this.configurationSettings$.value;
1285
+ }
1286
+ getShoppingCartSettings() {
1287
+ return this.shoppingCartSettings$.value;
1288
+ }
1289
+ getCurrencySettings() {
1290
+ return this.currencySettings$.value;
1291
+ }
1292
+ parseConfigurationSettings(settings) {
1293
+ return settings.reduce((acc, setting) => {
1294
+ switch (setting.key) {
1295
+ case 'shopping-cart':
1296
+ acc['shopping-cart'] = parseJsonSafely(setting.value, []);
1297
+ break;
1298
+ case 'navigation':
1299
+ acc.navigation = parseJsonSafely(setting.value, {});
1300
+ break;
1301
+ case 'flows':
1302
+ acc.flows = parseJsonSafely(setting.value, []);
1303
+ break;
1304
+ default:
1305
+ acc[setting.key] = setting.value;
1306
+ }
1307
+ return acc;
1308
+ }, {});
1309
+ }
1310
+ addShoppingCartSettings(settings) {
1311
+ // uniqBy removes items with the biggest index
1312
+ const newSettings = uniqBy([...settings, ...this.shoppingCartSettings$.value], 'id');
1313
+ this.shoppingCartSettings$.next(newSettings);
1314
+ }
1315
+ }
1316
+ RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1317
+ RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, providedIn: 'root' });
1318
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
1319
+ type: Injectable,
1320
+ args: [{ providedIn: 'root' }]
1321
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
1322
+
1323
+ class ConfigurationService {
1324
+ constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService, runtimeSettings) {
1325
+ this.quoteDraftService = quoteDraftService;
1326
+ this.runtimeService = runtimeService;
1327
+ this.contextService = contextService;
1328
+ this.configurationApiService = configurationApiService;
1329
+ this.messageService = messageService;
1330
+ this.dialogService = dialogService;
1331
+ this.runtimeSettings = runtimeSettings;
1332
+ this.mode = ConfigurationMode.SEARCH;
1333
+ this.lineItem = new BehaviorSubject(undefined);
1334
+ this.charges = new BehaviorSubject({});
1335
+ this.pricePlans = new BehaviorSubject({});
1336
+ this.procedureContext = new BehaviorSubject({});
1337
+ this.isLoadingSubj$ = new BehaviorSubject(false);
1338
+ this.isLoading$ = this.isLoadingSubj$.asObservable();
1339
+ this.hasUnsavedChanges = false;
1340
+ }
1341
+ reset() {
1342
+ this.hasUnsavedChanges = false;
1343
+ this.runtimeService.reset();
1344
+ this.configurableRamp = undefined;
1345
+ this.lineItem.next(undefined);
1346
+ this.charges.next({});
1347
+ this.pricePlans.next({});
1348
+ }
1349
+ patch$(lineItem, options) {
1350
+ if (!this.lineItem.value) {
1351
+ return throwError(() => new Error(`Source LineItem not found`));
1352
+ }
1353
+ const skipCardinalityCalculation = options?.skipCardinalityCalculation || this.contextSnapshot.properties['#skipCardinalityCalculation'] === 'true';
1354
+ this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem, skipCardinalityCalculation).li;
1355
+ return this.configure().pipe(catchError$1(error => {
1356
+ console.error(error);
1357
+ if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
1358
+ this.messageService.add({ severity: 'error', summary: error });
1359
+ }
1360
+ // bounce back if configuration call has failed
1361
+ this.lineItem.next(this.lineItem.value ? { ...this.lineItem.value } : undefined);
1362
+ return throwError(() => error);
1363
+ }), tap(() => {
1364
+ if (!this.hasUnsavedChanges) {
1365
+ this.hasUnsavedChanges = true;
1366
+ }
1367
+ }));
1368
+ }
1369
+ patch(lineItem, options) {
1370
+ this.patch$(lineItem, options).subscribe();
1371
+ }
1372
+ setConfigurableRamp(lineItem) {
1373
+ this.configurableRamp = lineItem;
1374
+ }
1375
+ get() {
1376
+ return this.lineItem.asObservable().pipe(shareReplay$1());
1377
+ }
1378
+ getSnapshot() {
1379
+ return this.lineItem.value ? { ...this.lineItem.value } : undefined;
1380
+ }
1381
+ getRuntimeModel() {
1382
+ const runtimeModel = this.runtimeService.runtimeModel;
1383
+ if (!runtimeModel) {
1384
+ throw new Error('Runtime model not initialized');
1385
+ }
1386
+ return runtimeModel;
1387
+ }
1388
+ getRuntimeContext() {
1389
+ const runtimeContext = this.runtimeService.runtimeContext;
1390
+ if (!runtimeContext) {
1391
+ throw new Error('Runtime context not initialized');
1392
+ }
1393
+ return runtimeContext;
1394
+ }
1395
+ get contextSnapshot() {
1396
+ return this.contextService.resolve();
1397
+ }
1398
+ get context$() {
1399
+ return this.contextService.resolve$();
1400
+ }
1401
+ get charges$() {
1402
+ return this.charges.asObservable();
1403
+ }
1404
+ get chargesSnapshot() {
1405
+ return this.charges.value;
1406
+ }
1407
+ get pricePlans$() {
1408
+ return this.pricePlans.asObservable();
1409
+ }
1410
+ get pricePlansSnapshot() {
1411
+ return this.pricePlans.value;
1412
+ }
1413
+ get procedureContext$() {
1414
+ return this.procedureContext.asObservable();
1415
+ }
1416
+ get procedureContextSnapshot() {
1417
+ return this.procedureContext.value;
1418
+ }
1419
+ configure() {
1420
+ return this.configureRequest$(this.generateRequest());
1421
+ }
1422
+ configureRequest$(configurationRequest) {
1423
+ const runtimeContext = this.getRuntimeContext();
1424
+ const runtimeModel = this.getRuntimeModel();
1425
+ const uiDefinitionProperties = this.getUIDefinitionProperties();
1426
+ const mainPricingEnabled = runtimeContext.properties?.PricingEnabled;
1427
+ const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
1428
+ const customPriceApi = this.runtimeSettings.getConfigurationSettings()['CUSTOM_PRICE_API'];
1429
+ this.isLoadingSubj$.next(true);
1430
+ const configure$ = pricingEnabled && customPriceApi
1431
+ ? this.configurationApiService.customConfigurePrice({ url: customPriceApi, configurationRequest, runtimeModel })
1432
+ : this.configurationApiService.configureLineItem({
1433
+ configurationRequest,
1434
+ runtimeModel,
1435
+ pricingEnabled,
1436
+ });
1437
+ return configure$.pipe(tap(({ lineItem, context, charges, pricePlans, deletedLineItems, procedureContext }) => {
1438
+ this.contextService.update(context ?? {});
1439
+ this.charges.next(charges ?? {});
1440
+ this.pricePlans.next(pricePlans ?? {});
1441
+ this.procedureContext.next(procedureContext ?? {});
1442
+ if (lineItem) {
1443
+ this.lineItem.next(lineItem);
1444
+ }
1445
+ if (deletedLineItems?.length) {
1446
+ this.showInactiveProductsConfirmation();
1447
+ }
1448
+ this.configurableRamp = lineItem;
1449
+ }), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => new Error(error.error?.message || error.message || JSON.stringify(error)))), finalize$1(() => this.isLoadingSubj$.next(false)));
1450
+ }
1451
+ configureExternal$(props) {
1452
+ return this.runtimeService
1453
+ .init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
1454
+ .pipe(switchMap$1(() => this.configure()), first(), catchError$1(error => {
1455
+ this.messageService.add({ severity: ToastType.error, summary: error });
1456
+ throw error;
1457
+ }), finalize$1(() => this.reset()));
1458
+ }
1459
+ configureGuidedSelling$(data) {
1460
+ return this.configurationApiService
1461
+ .configureLineItem({
1462
+ configurationRequest: getGuidedSellingConfigurationRequest(data, this.contextService.resolve()),
1463
+ })
1464
+ .pipe(catchError$1(error => {
1465
+ if (error instanceof HttpErrorResponse) {
1466
+ this.messageService.add({ severity: ToastType.error, summary: error.error.message || error.error });
1467
+ }
1468
+ throw error;
1469
+ }));
1470
+ }
1471
+ generateRequest() {
1472
+ const runtimeContext = this.getRuntimeContext();
1473
+ const uiDefinitionProperties = this.getUIDefinitionProperties();
1474
+ let lineItem = this.configurableRamp;
1475
+ if (!lineItem) {
1476
+ const { initializationProps } = this.runtimeService ?? {};
1477
+ lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps?.defaultQty);
1478
+ // Set default attributes
1479
+ if (initializationProps?.attributesMap) {
1480
+ const attributes = transform(initializationProps?.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
1481
+ lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
1482
+ }
1483
+ }
1484
+ let request = {
1485
+ lineItem,
1486
+ mode: this.mode,
1487
+ step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
1488
+ attributeDomainMode: 'ALL',
1489
+ context: this.contextService.resolve(),
1490
+ lineItems: this.quoteDraftService.quoteDraft?.currentState || [],
1491
+ asset: this.getAsset(),
1492
+ };
1493
+ request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
1494
+ return request;
1495
+ }
1496
+ getUIDefinitionProperties() {
1497
+ return {
1498
+ ...(this.getRuntimeContext().uiDefinitionContainer?.source.properties ?? {}),
1499
+ ...(this.runtimeService.uiDefinitionProperties ?? {}),
1500
+ };
1501
+ }
1502
+ showInactiveProductsConfirmation() {
1503
+ const confirmationConfig = {
1504
+ title: ' ',
1505
+ description: 'This quote contains inactive products. Do you want to remove them?',
1506
+ primaryButtonLabel: 'Remove products',
1507
+ secondaryButtonLabel: 'Back to Quote',
1508
+ };
1509
+ this.dialogService
1510
+ .open(ConfirmationComponent, {
1511
+ dismissableMask: false,
1512
+ closeOnEscape: false,
1513
+ closable: false,
1514
+ showHeader: true,
1515
+ header: `Inactive Products in Quote`,
1516
+ width: '440px',
1517
+ data: { confirmationConfig },
1518
+ })
1519
+ .onClose.subscribe(result => {
1520
+ if (!result) {
1521
+ const context = this.contextService.resolve();
1522
+ window['VELO_BACK_FN'].apply(null, [context.headerId]);
1523
+ }
1524
+ });
1525
+ }
1526
+ getAsset() {
1527
+ const lineItem = this.configurableRamp;
1528
+ if (!lineItem) {
1529
+ return;
1530
+ }
1531
+ return this.quoteDraftService.quoteDraft?.initialState.find(a => a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId);
1532
+ }
1533
+ }
1534
+ 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 });
1535
+ ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
1536
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, decorators: [{
1537
+ type: Injectable
1538
+ }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6$1.DialogService }, { type: RuntimeSettingsService }]; } });
1539
+
1540
+ class FlowUpdateService {
1541
+ update(rootLineItems, updates, charges) {
1542
+ let remainingUpdates = [...updates];
1543
+ let currentLevel = rootLineItems;
1544
+ while (currentLevel.length && remainingUpdates.length) {
1545
+ currentLevel.forEach(li => {
1546
+ const unhandledUpdates = [];
1547
+ remainingUpdates.forEach(update => {
1548
+ let updated = false;
1549
+ switch (update.dataType) {
1550
+ case 'LINEITEM':
1551
+ updated = this.applyLineItemUpdate(li, update, charges);
1552
+ break;
1553
+ case 'CHARGE':
1554
+ updated = this.applyChargeUpdate(li, update);
1555
+ break;
1556
+ case 'GROUP_CHARGE':
1557
+ updated = this.applyChargeGroupUpdate(li, update);
1558
+ break;
1559
+ default:
1560
+ // Unknown dataType. Do not try to handle it anymore
1561
+ updated = true;
1562
+ }
1563
+ if (!updated) {
1564
+ unhandledUpdates.push(update);
1565
+ }
1566
+ });
1567
+ remainingUpdates = unhandledUpdates;
1568
+ });
1569
+ currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
1570
+ }
1571
+ }
1572
+ delete(lineItems, id) {
1573
+ const idsToRemove = [id];
1574
+ const topLevelLineItem = lineItems.find(li => li.id === id);
1575
+ if (topLevelLineItem) {
1576
+ // find term-related line items (which are only top level)
1577
+ // expired term line items won't be deleted
1578
+ let foundTermLineItem = topLevelLineItem;
1579
+ while (foundTermLineItem) {
1580
+ foundTermLineItem = lineItems.find(li => foundTermLineItem && li.rampInstanceId === foundTermLineItem.id);
1581
+ if (foundTermLineItem) {
1582
+ idsToRemove.push(foundTermLineItem.id);
1583
+ }
1584
+ }
1585
+ }
1586
+ const filtered = lineItems.filter(lineItem => !idsToRemove.includes(lineItem.id));
1587
+ return filtered.map(lineItem => new LineItemWorker(lineItem).remove(id).li);
1588
+ }
1589
+ applyLineItemUpdate(lineItem, update, charges) {
1590
+ if (lineItem.id !== update.id) {
1591
+ return false;
1592
+ }
1593
+ switch (update.attributeType) {
1594
+ case 'QTY':
1595
+ lineItem.qty = update.newValue;
1596
+ break;
1597
+ case 'EFFECTIVE_START_DATE':
1598
+ lineItem.properties['StartDate'] = moment(update.newValue).format('YYYY-MM-DD');
1599
+ break;
1600
+ case 'END_DATE':
1601
+ lineItem.properties['EndDate'] = moment(update.newValue).format('YYYY-MM-DD');
1602
+ break;
1603
+ case 'PRICE_ADJUSTMENT':
1604
+ {
1605
+ const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
1606
+ if (charge) {
1607
+ charge.priceAdjustment = update.newValue;
1608
+ }
1609
+ }
1610
+ break;
1611
+ case 'LIST_PRICE_ADJUSTMENT':
1612
+ case 'MARGIN_ADJUSTMENT':
1613
+ {
1614
+ const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
1615
+ if (charge) {
1616
+ charge.listPriceAdjustment = update.newValue;
1617
+ }
1618
+ }
1619
+ break;
1620
+ case 'COST_ADJUSTMENT':
1621
+ {
1622
+ const charge = lineItem.chargeItems.find(charge => (charges || {})[charge.chargeId]?.main);
1623
+ if (charge) {
1624
+ charge.costAdjustment = update.newValue;
1625
+ }
1626
+ }
1627
+ break;
1628
+ default:
1629
+ throw new Error(`Not suppored AttributeType for LineItem update: ${update.attributeType}`);
1630
+ }
1631
+ return true;
1632
+ }
1633
+ applyChargeUpdate(lineItem, update) {
1634
+ const foundCharge = lineItem.chargeItems.find(({ id }) => id === update.id);
1635
+ if (!foundCharge) {
1636
+ return false;
1637
+ }
1638
+ if (update.attributeType === 'PRICE_ADJUSTMENT') {
1639
+ foundCharge.priceAdjustment = update.newValue;
1640
+ }
1641
+ else if (update.attributeType === 'LIST_PRICE_ADJUSTMENT') {
1642
+ foundCharge.listPriceAdjustment = update.newValue;
1643
+ }
1644
+ else {
1645
+ throw new Error(`Not suppored AttributeType for Charge Item update: ${update.attributeType}`);
1646
+ }
1647
+ return true;
1648
+ }
1649
+ applyChargeGroupUpdate(lineItem, update) {
1650
+ const foundChargeGroup = ChargeGroupUtils.findChargeGroupById(update.id, lineItem);
1651
+ if (!foundChargeGroup) {
1652
+ return false;
1653
+ }
1654
+ if (update.attributeType === 'PRICE_ADJUSTMENT') {
1655
+ foundChargeGroup.priceAdjustment = update.newValue;
1656
+ }
1657
+ else if (update.attributeType === 'LIST_PRICE_ADJUSTMENT') {
1658
+ foundChargeGroup.listPriceAdjustment = update.newValue;
1659
+ }
1660
+ else {
1661
+ throw new Error(`Not suppored AttributeType for Charge Group Item update: ${update.attributeType}`);
1662
+ }
1663
+ return true;
1664
+ }
1665
+ }
1666
+ FlowUpdateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1667
+ FlowUpdateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService });
1668
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService, decorators: [{
1669
+ type: Injectable
1670
+ }] });
1671
+
1672
+ class FlowConfigurationService {
1673
+ constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
1674
+ this.proceduresApiService = proceduresApiService;
1675
+ this.contextService = contextService;
1676
+ this.quoteDraftService = quoteDraftService;
1677
+ this.updateService = updateService;
1678
+ this.configurationService = configurationService;
1679
+ this.updatedSubj$ = new Subject();
1680
+ this.updated$ = this.updatedSubj$.asObservable();
1681
+ }
1682
+ calculate$(quoteDraft) {
1683
+ return this.proceduresApiService.apply$(quoteDraft).pipe(tap$1(result => {
1684
+ // sort the result current state based on the quote draft initial state
1685
+ const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
1686
+ result.currentState = result.currentState
1687
+ .slice()
1688
+ .sort((a, b) => initialStateIds.indexOf(a.integrationId) - initialStateIds.indexOf(b.integrationId));
1689
+ this.quoteDraftService.updateQuoteDraft(result);
1690
+ }), map$1(noop));
1691
+ }
1692
+ calculate(quoteDraft) {
1693
+ this.calculate$(quoteDraft).subscribe();
1694
+ }
1695
+ update$(updates) {
1696
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1697
+ if (!quoteDraft) {
1698
+ return of(null);
1699
+ }
1700
+ return of([]).pipe(map$1(() => {
1701
+ const updatedState = cloneDeep(quoteDraft.currentState);
1702
+ this.updateService.update(updatedState, updates, quoteDraft.charges);
1703
+ return updatedState;
1704
+ }), switchMap(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1705
+ }
1706
+ update(updates) {
1707
+ this.update$(updates).subscribe();
1708
+ }
1709
+ revert$(lineItemId) {
1710
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1711
+ const initialCurrentState = this.quoteDraftService.getInitialCurrentState();
1712
+ const currentState = this.quoteDraftService.activeCurrentState;
1713
+ const currentLineItemIndex = currentState.findIndex(({ id }) => id === lineItemId);
1714
+ const currentLineItem = currentState[currentLineItemIndex];
1715
+ const initialLineItem = initialCurrentState.find(({ integrationId }) => integrationId === currentLineItem?.integrationId);
1716
+ if (!quoteDraft || !currentLineItem || !initialLineItem) {
1717
+ return of(null);
1718
+ }
1719
+ const updatedState = cloneDeep(currentState);
1720
+ updatedState.splice(currentLineItemIndex, 1, initialLineItem);
1721
+ return of([]).pipe(tap$1(() => {
1722
+ this.quoteDraftService.setCurrentLineItemState(updatedState);
1723
+ }), switchMap(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1724
+ }
1725
+ revert(lineItemId) {
1726
+ this.revert$(lineItemId).subscribe();
1727
+ }
1728
+ delete$(ids) {
1729
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1730
+ const currentState = this.quoteDraftService.currentState;
1731
+ if (!quoteDraft) {
1732
+ return of(null);
1733
+ }
1734
+ 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());
1735
+ }
1736
+ delete(ids) {
1737
+ this.delete$(ids).subscribe();
1738
+ }
1739
+ addTerm$(term) {
1740
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1741
+ if (!quoteDraft) {
1742
+ return of(null);
1743
+ }
1744
+ const updatedState = [...quoteDraft.currentState, term];
1745
+ return of([]).pipe(switchMap(() => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1746
+ }
1747
+ addToCart$(props) {
1748
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1749
+ if (!quoteDraft) {
1750
+ return of(null);
1751
+ }
1752
+ return this.configurationService.configureExternal$(props).pipe(map$1(lineItem => {
1753
+ const model = this.configurationService.getRuntimeModel();
1754
+ const split = model?.types.find(type => type.name === lineItem.type)?.split ?? false;
1755
+ const lineItems = multiplyLineItems(lineItem, props.qty ?? 1, split);
1756
+ return [...quoteDraft.currentState, ...lineItems];
1757
+ }), switchMap(updatedState => this.calculate$({ ...quoteDraft, currentState: updatedState })), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1758
+ }
1759
+ get() {
1760
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(() => this.quoteDraftService.activeCurrentState), shareReplay$1());
1761
+ }
1762
+ getSnapshot() {
1763
+ return this.quoteDraftService?.currentState.slice() ?? [];
1764
+ }
1765
+ get charges$() {
1766
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ charges }) => charges));
1767
+ }
1768
+ get pricePlans$() {
1769
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ pricePlans }) => pricePlans));
1770
+ }
1771
+ get activeMetrics$() {
1772
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ activeMetrics }) => activeMetrics));
1773
+ }
1774
+ get chargesSnapshot() {
1775
+ return this.quoteDraftService.quoteDraft?.charges ?? {};
1776
+ }
1777
+ get pricePlansSnapshot() {
1778
+ return this.quoteDraftService.quoteDraft?.pricePlans ?? {};
1779
+ }
1780
+ get activeMetricsSnapshot() {
1781
+ return this.quoteDraftService.quoteDraft?.activeMetrics ?? [];
1782
+ }
1783
+ get contextSnapshot() {
1784
+ return this.contextService.resolve();
1785
+ }
1786
+ get context$() {
1787
+ return this.contextService.resolve$();
1788
+ }
1789
+ handleErrorAndBounceBack() {
1790
+ return (source$) => {
1791
+ return source$.pipe(catchError(error => {
1792
+ console.error(error);
1793
+ // bounce back if configuration call has failed
1794
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1795
+ if (quoteDraft) {
1796
+ this.quoteDraftService.updateQuoteDraft(quoteDraft);
1797
+ this.updatedSubj$.next();
1798
+ }
1799
+ return throwError(() => error);
1800
+ }));
1801
+ };
1802
+ }
1803
+ }
1804
+ 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 });
1805
+ FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, providedIn: 'root' });
1806
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
1807
+ type: Injectable,
1808
+ args: [{ providedIn: 'root' }]
1809
+ }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1810
+
1811
+ class FlowConfigurationModule {
1812
+ }
1813
+ FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1814
+ FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule });
1815
+ FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, PriceApiService] });
1816
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
1817
+ type: NgModule,
1818
+ args: [{
1819
+ imports: [],
1820
+ providers: [FlowConfigurationService, FlowUpdateService, PriceApiService],
1821
+ }]
1822
+ }] });
1823
+
1824
+ class FlowStateConfigurationService {
1825
+ constructor(flowStateService, flowInfoService, configurationService, flowConfigurationService, flowStateApiService) {
1826
+ this.flowStateService = flowStateService;
1827
+ this.flowInfoService = flowInfoService;
1828
+ this.configurationService = configurationService;
1829
+ this.flowConfigurationService = flowConfigurationService;
1830
+ this.flowStateApiService = flowStateApiService;
1831
+ this.configurationStateId$ = new BehaviorSubject(null);
1832
+ }
1833
+ get configurationStateId() {
1834
+ return this.configurationStateId$.value;
1835
+ }
1836
+ addToCart$(props) {
1837
+ const stateful = this.flowInfoService.flow?.properties.stateful;
1838
+ if (stateful) {
1839
+ const stateId = this.flowStateService.stateId;
1840
+ if (!stateId) {
1841
+ return of();
1842
+ }
1843
+ const lineItem = generateConfigurationLineItem(props, props.qty);
1844
+ return this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap$1(r => this.configurationStateId$.next(r.stateId)), switchMap(() => {
1845
+ if (!this.configurationStateId) {
1846
+ return of();
1847
+ }
1848
+ return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), tap$1(() => this.configurationStateId$.next(null)), map$1(noop));
1849
+ }));
1850
+ }
1851
+ else {
1852
+ return this.flowConfigurationService.addToCart$(props).pipe(map$1(noop));
1853
+ }
1854
+ }
1855
+ }
1856
+ 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 });
1857
+ FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, providedIn: 'root' });
1858
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
1859
+ type: Injectable,
1860
+ args: [{ providedIn: 'root' }]
1861
+ }], ctorParameters: function () { return [{ type: FlowStateService }, { type: FlowInfoService }, { type: ConfigurationService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }]; } });
1862
+
1863
+ function calculateMetricByMethod(lineItems, metric, method) {
1864
+ const items = getLineItemsByMethod(lineItems, method);
1865
+ return items.reduce((acc, li) => {
1866
+ let value = li.reduce((accProduct, item) => accProduct + ((item.totalMetrics && item.totalMetrics[metric]) || 0), 0);
1867
+ if (method === 'avg' && li.length > 0) {
1868
+ value /= li.length;
1869
+ }
1870
+ return acc + value;
1871
+ }, 0);
1872
+ }
1873
+ function getLineItemsByMethod(lineItems, method) {
1874
+ switch (method) {
1875
+ case 'first': {
1876
+ return lineItems.filter(li => !li.rampInstanceId).map(item => [item]);
1877
+ }
1878
+ case 'last': {
1879
+ const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
1880
+ const products = rootTermItems.map(lineItem => [
1881
+ lineItem,
1882
+ ...lineItems.filter(li => li.rampInstanceId === lineItem.id),
1883
+ ]);
1884
+ return products
1885
+ .map(items => [...items].sort((a, b) => getDateValue(a.endDate || '') - getDateValue(b.endDate || '')).pop())
1886
+ .filter((li) => Boolean(li))
1887
+ .map(item => [item]);
1888
+ }
1889
+ case 'avg': {
1890
+ const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
1891
+ return rootTermItems.map(lineItem => [lineItem, ...lineItems.filter(li => li.rampInstanceId === lineItem.id)]);
1892
+ }
1893
+ case 'sum': {
1894
+ return lineItems.map(item => [item]);
1895
+ }
1896
+ default: {
1897
+ return lineItems.map(item => [item]);
1898
+ }
1899
+ }
1900
+ }
1901
+ function getDateValue(date) {
1902
+ return date ? new Date(date).getTime() : 0;
1903
+ }
1904
+
1905
+ class MetricsCalculationService {
1906
+ get onMetricsUpdate$() {
1907
+ return this.metricsUpdated$.asObservable();
1908
+ }
1909
+ constructor(quoteDraftService, flowConfiguration, settingsService) {
1910
+ this.quoteDraftService = quoteDraftService;
1911
+ this.flowConfiguration = flowConfiguration;
1912
+ this.settingsService = settingsService;
1913
+ this.metricsUpdated$ = new Subject();
1914
+ this.quoteMetricsSettings = {};
1915
+ this.metricsCalculationMethodMap = {};
1916
+ this.metricsData = {};
1917
+ this.activeMetricRules = [];
1918
+ this.activeMetricRules = this.flowConfiguration.activeMetricsSnapshot.filter(metricRule => metricRule.metrics.some(metric => !!metric.totalName));
1919
+ combineLatest([
1920
+ this.quoteDraftService.currentState$,
1921
+ this.settingsService.fetchSetting('QUOTE_LEVEL_METRIC_CALCULATION_METHOD').pipe(take$1(1)),
1922
+ ]).subscribe(([lineItems, setting]) => {
1923
+ let settingsData = {};
1924
+ try {
1925
+ settingsData = JSON.parse(setting?.value || '{}');
1926
+ }
1927
+ catch (error) {
1928
+ settingsData = {};
1929
+ }
1930
+ this.quoteMetricsSettings = settingsData;
1931
+ this.updateMetrics(lineItems);
1932
+ });
1933
+ }
1934
+ getMetricValue(metric) {
1935
+ return this.metricsData[metric] || 0;
1936
+ }
1937
+ updateMetrics(lineItems) {
1938
+ const metricKeys = this.collectMetricKeys(lineItems).filter(key => !key.includes('Effective_'));
1939
+ this.metricsCalculationMethodMap = this.buildMetricsCalculationMethods(metricKeys, this.metricsCalculationMethodMap);
1940
+ this.metricsData = metricKeys.reduce((acc, key) => ({ ...acc, [key]: this.calculateMetric(lineItems, key) }), {});
1941
+ this.metricsUpdated$.next();
1942
+ }
1943
+ calculateMetric(lineItems, metric) {
1944
+ return calculateMetricByMethod(lineItems, metric, this.metricsCalculationMethodMap[metric] || 'sum');
1945
+ }
1946
+ buildMetricsCalculationMethods(metricKeys, initial) {
1947
+ return metricKeys.reduce((acc, name) => {
1948
+ if (acc[name]) {
1949
+ return acc;
1950
+ }
1951
+ acc = { ...acc, [name]: 'sum' };
1952
+ const metricRule = this.getMetricRuleByTotalMetricName(name);
1953
+ const settingKey = metricRule?.metrics?.find(metric => metric.totalName === name)?.name || name;
1954
+ if (this.quoteMetricsSettings[settingKey]) {
1955
+ acc = { ...acc, [name]: this.quoteMetricsSettings[settingKey] };
1956
+ }
1957
+ return acc;
1958
+ }, initial);
1959
+ }
1960
+ collectMetricKeys(lineItems) {
1961
+ const keys = [];
1962
+ lineItems.forEach(lineItem => {
1963
+ keys.push(...Object.keys(lineItem.totalMetrics || {}));
1964
+ keys.push(...this.collectMetricKeys(lineItem.lineItems));
1965
+ });
1966
+ return uniq(keys);
1967
+ }
1968
+ getMetricRuleByTotalMetricName(name) {
1969
+ return this.activeMetricRules.find(metricRule => metricRule.metrics.find(metric => metric.totalName === name));
1970
+ }
1971
+ }
1972
+ 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 });
1973
+ MetricsCalculationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: MetricsCalculationService, providedIn: 'root' });
1974
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: MetricsCalculationService, decorators: [{
1975
+ type: Injectable,
1976
+ args: [{ providedIn: 'root' }]
1977
+ }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: FlowConfigurationService }, { type: i1.ConfigurationSettingsApiService }]; } });
1978
+
1979
+ class ProductImagesService {
1980
+ constructor(productApiService) {
1981
+ this.productApiService = productApiService;
1982
+ this.imagesMap$ = new BehaviorSubject({});
1983
+ }
1984
+ getImageUrl$(productId) {
1985
+ if (this.imagesMap$.value[productId] == null) {
1986
+ this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: '' });
1987
+ this.fetchProductImage(productId);
1988
+ }
1989
+ return this.imagesMap$.pipe(map$1(imagesMap => imagesMap[productId]), distinctUntilChanged());
1990
+ }
1991
+ fetchProductImage(productId) {
1992
+ this.productApiService
1993
+ .fetchImage$(productId)
1994
+ .pipe(map$1(file => URL.createObjectURL(file)), catchError(() => of('')), tap$1(url => this.imagesMap$.next({ ...this.imagesMap$.value, [productId]: url })))
1995
+ .subscribe();
1996
+ }
1997
+ }
1998
+ ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1999
+ ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, providedIn: 'root' });
2000
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, decorators: [{
2001
+ type: Injectable,
2002
+ args: [{ providedIn: 'root' }]
2003
+ }], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
2004
+
2005
+ class RuntimeContextService {
2006
+ constructor(configurationApiService) {
2007
+ this.configurationApiService = configurationApiService;
2008
+ }
2009
+ getRuntimeContext(productId, offeringId) {
2010
+ return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
2011
+ const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
2012
+ const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
2013
+ const { productName, properties } = Array.from(runtimeModel.components.values()).find(c => c.productId === productId) ?? {};
2014
+ const uiDefinitionProperties = uiDefinitionContainer?.source.properties;
2015
+ return {
2016
+ modelId: runtimeData.modelId,
2017
+ uiDefinitionContainer: uiDefinitionContainer,
2018
+ runtimeModel: runtimeModel,
2019
+ runtimeMode: RuntimeMode.PROD,
2020
+ productId: productId,
2021
+ productType: properties?.['displayName'] || productName,
2022
+ offeringId: offeringId,
2023
+ properties: {
2024
+ PricingEnabled: uiDefinitionProperties?.pricingEnabled ? 'true' : 'false',
2025
+ PriceListId: uiDefinitionProperties?.priceList,
2026
+ },
2027
+ };
2028
+ }));
2029
+ }
2030
+ getUIDefinitionContainer(runtimeData) {
2031
+ const containers = runtimeData.uiDefinitions.filter(container => isNotLegacyUIDefinition(container.source));
2032
+ return containers.find(container => container.source.primary) ?? containers[0];
2033
+ }
2034
+ }
2035
+ RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }], target: i0.ɵɵFactoryTarget.Injectable });
2036
+ RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService });
2037
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, decorators: [{
2038
+ type: Injectable
2039
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }]; } });
2040
+
2041
+ class ConfigurationRuntimeService {
2042
+ constructor(apiService, contextService, runtimeContextService) {
2043
+ this.apiService = apiService;
2044
+ this.contextService = contextService;
2045
+ this.runtimeContextService = runtimeContextService;
2046
+ this._isInitialized = false;
2047
+ this.uiDefinitionProperties = {};
2048
+ }
2049
+ reset() {
2050
+ this._isInitialized = false;
2051
+ this._runtimeContext = undefined;
2052
+ this.initializationProps = undefined;
2053
+ this.uiDefinitionProperties = {};
2054
+ }
2055
+ initTestMode(uiDefinitionContainer) {
2056
+ this.uiDefinitionProperties = uiDefinitionContainer.source.properties ?? {};
2057
+ const uiDefinitionExternals = uiDefinitionContainer.source.externals ?? {};
2058
+ return combineLatest([
2059
+ this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
2060
+ this.contextService.initTestMode(),
2061
+ ]).pipe(first(), map(([runtimeData, context]) => {
2062
+ this.contextService.update({
2063
+ properties: {
2064
+ ...this.runtimeContext?.properties,
2065
+ ...context.properties,
2066
+ ModelId: uiDefinitionContainer.modelId,
2067
+ PricingEnabled: this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false',
2068
+ PriceListId: this.uiDefinitionProperties.priceList,
2069
+ offeringId: this.uiDefinitionProperties.offeringId,
2070
+ ...uiDefinitionExternals,
2071
+ },
2072
+ });
2073
+ this._runtimeContext = {
2074
+ modelId: uiDefinitionContainer.modelId,
2075
+ runtimeModel: RuntimeModel.create(runtimeData.types, runtimeData.products),
2076
+ runtimeMode: RuntimeMode.TEST,
2077
+ uiDefinitionContainer,
2078
+ };
2079
+ return this._runtimeContext;
2080
+ }), tap(() => (this._isInitialized = true)));
2081
+ }
2082
+ init(props) {
2083
+ this.initializationProps = props;
2084
+ const context = this.contextService.resolve();
2085
+ return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
2086
+ this.uiDefinitionProperties = runtimeContext.uiDefinitionContainer?.source.properties ?? {};
2087
+ const { PriceListId } = context.properties ?? {};
2088
+ const mergeContext = {
2089
+ ...runtimeContext,
2090
+ properties: {
2091
+ ...runtimeContext.properties,
2092
+ ...context.properties,
2093
+ PricingEnabled: PriceListId ? 'true' : 'false',
2094
+ },
2095
+ };
2096
+ this.id15to18('AccountId', mergeContext.properties);
2097
+ this._runtimeContext = mergeContext;
2098
+ if (context.properties && this._runtimeContext.properties?.StartDate) {
2099
+ this.contextService.update({
2100
+ properties: {
2101
+ ...this._runtimeContext.properties,
2102
+ ...context.properties,
2103
+ },
2104
+ });
2105
+ }
2106
+ return this._runtimeContext;
2107
+ }), tap(() => (this._isInitialized = true)));
2108
+ }
2109
+ overrideUIDefinition(uiDefinitionContainer) {
2110
+ if (!this._runtimeContext) {
2111
+ return;
2112
+ }
2113
+ this._runtimeContext.uiDefinitionContainer = uiDefinitionContainer;
2114
+ this.uiDefinitionProperties = uiDefinitionContainer.source.properties ?? {};
2115
+ }
2116
+ id15to18(propertyName, source) {
2117
+ if (!source) {
2118
+ return;
2119
+ }
2120
+ const value = source[propertyName];
2121
+ if (typeof value === 'string' && value.length === 15) {
2122
+ source[propertyName] = SalesforceIdUtils.generateId18FromId15(value);
2123
+ }
2124
+ }
2125
+ get isInitialized() {
2126
+ return this._isInitialized;
2127
+ }
2128
+ get runtimeModel() {
2129
+ return this.runtimeContext?.runtimeModel;
2130
+ }
2131
+ get runtimeContext() {
2132
+ return this._runtimeContext;
921
2133
  }
922
2134
  }
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: [{
2135
+ 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 });
2136
+ ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService });
2137
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
926
2138
  type: Injectable
927
- }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6.DialogService }]; } });
2139
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
928
2140
 
929
2141
  class ConfigurationState {
930
2142
  constructor(statefulConfigurationApiService, runtimeService, configurationService, toastService) {
@@ -937,17 +2149,17 @@ class ConfigurationState {
937
2149
  this.stateId = null;
938
2150
  }
939
2151
  init$() {
940
- return this.configurationService.configure().pipe(switchMap$1(() => {
2152
+ return this.configurationService.configure().pipe(switchMap(() => {
941
2153
  if (!this.isStatefulConfiguration) {
942
2154
  return of(undefined);
943
2155
  }
944
2156
  const { actions, selectors } = this.runtimeService.runtimeContext?.uiDefinitionContainer ?? {};
945
2157
  return this.statefulConfigurationApiService.init({
946
- request: this.configurationService.generateRequest(),
2158
+ item: this.configurationService.generateRequest(),
947
2159
  actions: actions?.map(action => ({ name: action.apiName, script: action.script })),
948
2160
  selectors: selectors?.map(selector => ({ name: selector.apiName, script: selector.script })),
949
2161
  });
950
- }), tap$1(stateId => (this.stateId = stateId || null)), map$2(() => undefined));
2162
+ }), tap$1(stateId => (this.stateId = stateId || null)), map$1(() => undefined));
951
2163
  }
952
2164
  cleanup() {
953
2165
  this.stateId = null;
@@ -974,13 +2186,13 @@ class ConfigurationState {
974
2186
  inputData,
975
2187
  },
976
2188
  },
977
- }).pipe(map$2(() => this.stateSubj$.value[requestId]), tap$1(() => this.stateSubj$.next(omit(this.stateSubj$.value, requestId))));
2189
+ }).pipe(map$1(() => this.stateSubj$.value[requestId]), tap$1(() => this.stateSubj$.next(omit(this.stateSubj$.value, requestId))));
978
2190
  }
979
2191
  get isStatefulConfiguration() {
980
2192
  return this.runtimeService.uiDefinitionProperties.statefulConfigurationEnabled ?? false;
981
2193
  }
982
2194
  executeStateless$(request) {
983
- return of(undefined).pipe(switchMap$1(() => {
2195
+ return of(undefined).pipe(switchMap(() => {
984
2196
  // Apply actions and execute configuration/price call
985
2197
  // No need to run configuration if no actions in the request
986
2198
  if (!request.actions?.length) {
@@ -1005,7 +2217,7 @@ class ConfigurationState {
1005
2217
  ...this.stateSubj$.value,
1006
2218
  ...selectorsResult,
1007
2219
  });
1008
- }), map$2(() => undefined));
2220
+ }), map$1(() => undefined));
1009
2221
  }
1010
2222
  executeStateful$(request) {
1011
2223
  if (!this.stateId) {
@@ -1024,7 +2236,7 @@ class ConfigurationState {
1024
2236
  updatedState[key] = value.result;
1025
2237
  });
1026
2238
  this.stateSubj$.next(updatedState);
1027
- }), map$2(() => undefined));
2239
+ }), map$1(() => undefined));
1028
2240
  }
1029
2241
  executeActionScript(request, processor) {
1030
2242
  const { actions } = this.runtimeService.runtimeContext?.uiDefinitionContainer ?? {};
@@ -1040,314 +2252,26 @@ class ConfigurationState {
1040
2252
  if (!script) {
1041
2253
  return null;
1042
2254
  }
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$();
2255
+ return this.executeProcessorScript(request, script, processor.inputData);
1312
2256
  }
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
- };
2257
+ executeProcessorScript(request, script, inputData) {
2258
+ return new Function(`${script}\nreturn transform;`)()({
2259
+ request,
2260
+ inputData: inputData,
2261
+ });
1325
2262
  }
1326
2263
  }
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: [{
2264
+ 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 });
2265
+ ConfigurationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationState });
2266
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationState, decorators: [{
1330
2267
  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
- }] });
2268
+ }], ctorParameters: function () { return [{ type: i1.StatefulConfigurationApiService }, { type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: i6.ToastService }]; } });
1345
2269
 
1346
2270
  class ConfigurationModule {
1347
2271
  }
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: [
2272
+ ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2273
+ ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule] });
2274
+ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, providers: [
1351
2275
  ContextApiService,
1352
2276
  ProductModelApiService,
1353
2277
  ConfigurationApiService,
@@ -1356,7 +2280,7 @@ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ver
1356
2280
  ConfigurationService,
1357
2281
  ConfigurationState,
1358
2282
  ], imports: [ConfirmationDialogModule] });
1359
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, decorators: [{
2283
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
1360
2284
  type: NgModule,
1361
2285
  args: [{
1362
2286
  imports: [ConfirmationDialogModule],
@@ -1372,269 +2296,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1372
2296
  }]
1373
2297
  }] });
1374
2298
 
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
2299
  const DEFAULT_FORMATTING_SETTINGS = {
1607
2300
  currencySymbol: DEFAULT_CURRENCY_SYMBOL,
1608
2301
  decimalsCount: DEFAULT_DECIMALS_COUNT,
1609
2302
  dateFormats: getSupportedDateFormats(DEFAULT_DATE_FORMAT),
1610
2303
  decimalSeparator: DEFAULT_DECIMAL_SEPARATOR,
1611
2304
  thousandsSeparator: DEFAULT_THOUSANDS_SEPARATOR,
2305
+ actionCodeLabels: DEFAULT_ACTION_CODE_LABELS,
1612
2306
  };
1613
2307
  class SdkCoreModule {
1614
2308
  }
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,
2309
+ SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2310
+ SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
2311
+ SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, providers: [
2312
+ IntegrationState,
2313
+ FlowStateService,
1623
2314
  {
1624
2315
  provide: FORMATTING_SETTINGS_TOKEN,
1625
2316
  useExisting: RuntimeSettingsService,
1626
2317
  },
1627
2318
  ], imports: [ConfigurationModule, FlowConfigurationModule] });
1628
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, decorators: [{
2319
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, decorators: [{
1629
2320
  type: NgModule,
1630
2321
  args: [{
1631
2322
  imports: [ConfigurationModule, FlowConfigurationModule],
1632
2323
  providers: [
1633
- ContextService,
1634
- QuoteDraftService,
1635
- ProductImagesService,
1636
- MetricsCalculationService,
1637
- RuntimeSettingsService,
2324
+ IntegrationState,
2325
+ FlowStateService,
1638
2326
  {
1639
2327
  provide: FORMATTING_SETTINGS_TOKEN,
1640
2328
  useExisting: RuntimeSettingsService,
@@ -1666,9 +2354,9 @@ class CalendarDirective {
1666
2354
  }
1667
2355
  }
1668
2356
  }
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: [{
2357
+ CalendarDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2358
+ CalendarDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: CalendarDirective, selector: "[vlCalendar]", inputs: { vlCalendar: "vlCalendar" }, ngImport: i0 });
2359
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarDirective, decorators: [{
1672
2360
  type: Directive,
1673
2361
  args: [{
1674
2362
  selector: '[vlCalendar]',
@@ -1679,10 +2367,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1679
2367
 
1680
2368
  class SdkDirectivesModule {
1681
2369
  }
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: [{
2370
+ SdkDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2371
+ SdkDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, declarations: [CalendarDirective], exports: [CalendarDirective] });
2372
+ SdkDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule });
2373
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, decorators: [{
1686
2374
  type: NgModule,
1687
2375
  args: [{
1688
2376
  declarations: [CalendarDirective],
@@ -1701,21 +2389,27 @@ class DatePipe {
1701
2389
  this.destroy$.next();
1702
2390
  this.destroy$.complete();
1703
2391
  }
1704
- transform(date) {
2392
+ transform(date, type = 'date') {
1705
2393
  if (!date) {
1706
2394
  return '';
1707
2395
  }
2396
+ const dateFormat = this.formattingSettings?.dateFormats.datePipeFormat || DEFAULT_DATE_FORMAT;
2397
+ const formatMap = {
2398
+ date: dateFormat,
2399
+ time: DEFAULT_TIME_FORMAT,
2400
+ datetime: `${dateFormat} ${DEFAULT_TIME_FORMAT}`,
2401
+ };
1708
2402
  try {
1709
- return formatDate(date, this.formattingSettings?.dateFormats.datePipeFormat || DEFAULT_DATE_FORMAT, this.locale, this.defaultOptions?.timezone);
2403
+ return formatDate(date, formatMap[type], this.locale, this.defaultOptions?.timezone);
1710
2404
  }
1711
2405
  catch (error) {
1712
2406
  return new Date(date).toString();
1713
2407
  }
1714
2408
  }
1715
2409
  }
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: [{
2410
+ DatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2411
+ DatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, name: "vlDate" });
2412
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, decorators: [{
1719
2413
  type: Pipe,
1720
2414
  args: [{
1721
2415
  name: 'vlDate',
@@ -1735,9 +2429,9 @@ class NumberPipe {
1735
2429
  return formatNumber(price, this.formattingSettings?.thousandsSeparator, this.formattingSettings?.decimalSeparator, this.formattingSettings?.decimalsCount);
1736
2430
  }
1737
2431
  }
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: [{
2432
+ NumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2433
+ NumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, name: "vlNumber" });
2434
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, decorators: [{
1741
2435
  type: Pipe,
1742
2436
  args: [{
1743
2437
  name: 'vlNumber',
@@ -1760,25 +2454,42 @@ class PricePipe {
1760
2454
  return `${this.formattingSettings?.currencySymbol || DEFAULT_CURRENCY_SYMBOL}${formatNumber(price, this.formattingSettings?.thousandsSeparator, this.formattingSettings?.decimalSeparator, this.formattingSettings?.decimalsCount)}`;
1761
2455
  }
1762
2456
  }
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: [{
2457
+ PricePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2458
+ PricePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, name: "vlPrice" });
2459
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, decorators: [{
1766
2460
  type: Pipe,
1767
2461
  args: [{
1768
2462
  name: 'vlPrice',
1769
2463
  }]
1770
2464
  }] });
1771
2465
 
2466
+ class ActionCodePipe {
2467
+ constructor() {
2468
+ this.formattingSettings = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })?.getFormattingSettings();
2469
+ }
2470
+ transform(actionCode) {
2471
+ return this.formattingSettings?.actionCodeLabels[actionCode] ?? actionCode;
2472
+ }
2473
+ }
2474
+ ActionCodePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2475
+ ActionCodePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, name: "vlActionCode" });
2476
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, decorators: [{
2477
+ type: Pipe,
2478
+ args: [{
2479
+ name: 'vlActionCode',
2480
+ }]
2481
+ }] });
2482
+
1772
2483
  class SdkPipesModule {
1773
2484
  }
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: [{
2485
+ SdkPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2486
+ 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] });
2487
+ SdkPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule });
2488
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, decorators: [{
1778
2489
  type: NgModule,
1779
2490
  args: [{
1780
- declarations: [NumberPipe, PricePipe, DatePipe],
1781
- exports: [NumberPipe, PricePipe, DatePipe],
2491
+ declarations: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
2492
+ exports: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
1782
2493
  }]
1783
2494
  }] });
1784
2495
 
@@ -1786,5 +2497,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1786
2497
  * Generated bundle index. Do not edit.
1787
2498
  */
1788
2499
 
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 };
2500
+ 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
2501
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map