@veloceapps/sdk 5.0.14-GOOGLE → 5.0.15-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/bundles/{veloce-sdk-cms.umd.js → veloceapps-sdk-cms.umd.js} +149 -81
  2. package/bundles/veloceapps-sdk-cms.umd.js.map +1 -0
  3. package/bundles/{veloce-sdk-core.umd.js → veloceapps-sdk-core.umd.js} +765 -543
  4. package/bundles/veloceapps-sdk-core.umd.js.map +1 -0
  5. package/bundles/{veloce-sdk-runtime.umd.js → veloceapps-sdk-runtime.umd.js} +213 -146
  6. package/bundles/veloceapps-sdk-runtime.umd.js.map +1 -0
  7. package/bundles/{veloce-sdk.umd.js → veloceapps-sdk.umd.js} +225 -154
  8. package/bundles/veloceapps-sdk.umd.js.map +1 -0
  9. package/cms/cms.default.d.ts +1 -1
  10. package/cms/components/element-renderer/element-renderer.component.d.ts +1 -1
  11. package/cms/components/preview/preview.component.d.ts +1 -1
  12. package/cms/components/preview/preview.module.d.ts +1 -1
  13. package/cms/injection-tokens.d.ts +1 -1
  14. package/cms/launcher.module.d.ts +3 -3
  15. package/cms/modules/federated/federated.module.d.ts +1 -1
  16. package/cms/package.json +7 -7
  17. package/cms/services/launcher.service.d.ts +1 -1
  18. package/cms/types/configuration.types.d.ts +1 -1
  19. package/cms/utils/element.utils.d.ts +1 -1
  20. package/cms/utils/elements-resolver.d.ts +1 -1
  21. package/{core/veloce-sdk-core.d.ts → cms/veloceapps-sdk-cms.d.ts} +1 -1
  22. package/cms/vendor-map.d.ts +86 -82
  23. package/core/modules/configuration/configuration.module.d.ts +1 -1
  24. package/core/modules/configuration/helpers.d.ts +1 -1
  25. package/core/modules/configuration/services/configuration-runtime.service.d.ts +3 -3
  26. package/core/modules/configuration/services/configuration.service.d.ts +4 -3
  27. package/core/modules/configuration/services/runtime-context.service.d.ts +1 -1
  28. package/core/modules/configuration/types/configuration-runtime.types.d.ts +1 -1
  29. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +5 -4
  30. package/core/modules/flow-configuration/services/flow-update.service.d.ts +1 -1
  31. package/core/package.json +7 -7
  32. package/core/services/context.service.d.ts +2 -2
  33. package/core/services/index.d.ts +1 -0
  34. package/core/services/metric-calculation/metric-calculation.service.d.ts +21 -0
  35. package/core/services/metric-calculation/metric-calculation.types.d.ts +1 -0
  36. package/core/services/metric-calculation/metric-calculation.utils.d.ts +5 -0
  37. package/core/services/product-images.service.d.ts +1 -1
  38. package/core/services/quote-draft.service.d.ts +5 -3
  39. package/core/types/quote-states.types.d.ts +1 -1
  40. package/core/types/runtime.types.d.ts +1 -1
  41. package/core/utils/line-item.utils.d.ts +2 -1
  42. package/core/utils/line-item.worker.d.ts +1 -1
  43. package/{runtime/veloce-sdk-runtime.d.ts → core/veloceapps-sdk-core.d.ts} +1 -1
  44. package/esm2015/cms/cms.default.js +1 -1
  45. package/esm2015/cms/components/element-children/element-children.component.js +3 -3
  46. package/esm2015/cms/components/element-children/element-children.module.js +4 -4
  47. package/esm2015/cms/components/element-renderer/element-renderer.component.js +6 -6
  48. package/esm2015/cms/components/element-renderer/element-renderer.module.js +4 -4
  49. package/esm2015/cms/components/plugin.component.js +3 -3
  50. package/esm2015/cms/components/preview/preview.component.js +6 -6
  51. package/esm2015/cms/components/preview/preview.module.js +6 -6
  52. package/esm2015/cms/directives/custom-template.directive.js +3 -3
  53. package/esm2015/cms/injection-tokens.js +1 -1
  54. package/esm2015/cms/launcher.module.js +8 -8
  55. package/esm2015/cms/modules/federated/federated.component.js +4 -4
  56. package/esm2015/cms/modules/federated/federated.module.js +6 -6
  57. package/esm2015/cms/plugins/configuration.plugin.js +5 -5
  58. package/esm2015/cms/plugins/io.plugin.js +3 -3
  59. package/esm2015/cms/plugins/script.plugin.js +5 -5
  60. package/esm2015/cms/services/dynamic-module.service.js +3 -3
  61. package/esm2015/cms/services/element-context.service.js +3 -3
  62. package/esm2015/cms/services/integration.state.js +3 -3
  63. package/esm2015/cms/services/io-provider.service.js +3 -3
  64. package/esm2015/cms/services/launcher.service.js +6 -5
  65. package/esm2015/cms/services/templates.service.js +3 -3
  66. package/esm2015/cms/types/configuration.types.js +1 -1
  67. package/esm2015/cms/utils/element.utils.js +1 -1
  68. package/esm2015/cms/utils/elements-resolver.js +1 -1
  69. package/esm2015/cms/veloceapps-sdk-cms.js +5 -0
  70. package/esm2015/cms/vendor-map.js +9 -12
  71. package/esm2015/core/core.module.js +7 -7
  72. package/esm2015/core/modules/configuration/configuration.module.js +7 -7
  73. package/esm2015/core/modules/configuration/helpers.js +2 -2
  74. package/esm2015/core/modules/configuration/services/configuration-runtime.service.js +7 -7
  75. package/esm2015/core/modules/configuration/services/configuration.service.js +13 -12
  76. package/esm2015/core/modules/configuration/services/runtime-context.service.js +6 -6
  77. package/esm2015/core/modules/configuration/types/configuration-runtime.types.js +1 -1
  78. package/esm2015/core/modules/flow-configuration/flow-configuration.module.js +6 -6
  79. package/esm2015/core/modules/flow-configuration/services/flow-configuration.service.js +18 -10
  80. package/esm2015/core/modules/flow-configuration/services/flow-update.service.js +5 -5
  81. package/esm2015/core/services/context.service.js +6 -6
  82. package/esm2015/core/services/index.js +2 -1
  83. package/esm2015/core/services/metric-calculation/metric-calculation.service.js +74 -0
  84. package/esm2015/core/services/metric-calculation/metric-calculation.types.js +2 -0
  85. package/esm2015/core/services/metric-calculation/metric-calculation.utils.js +42 -0
  86. package/esm2015/core/services/product-images.service.js +5 -5
  87. package/esm2015/core/services/quote-draft.service.js +20 -10
  88. package/esm2015/core/types/quote-states.types.js +1 -1
  89. package/esm2015/core/types/runtime.types.js +1 -1
  90. package/esm2015/core/utils/line-item.utils.js +14 -3
  91. package/esm2015/core/utils/line-item.worker.js +1 -1
  92. package/esm2015/core/veloceapps-sdk-core.js +5 -0
  93. package/esm2015/runtime/components/component-preview/component-preview.component.js +7 -7
  94. package/esm2015/runtime/components/section-renderer/section-renderer.component.js +4 -4
  95. package/esm2015/runtime/components/ui-runtime/runtime.component.js +8 -8
  96. package/esm2015/runtime/components/ui-runtime-preview/runtime-preview.component.js +8 -8
  97. package/esm2015/runtime/execution/components/children-placeholder/children-placeholder.component.js +8 -8
  98. package/esm2015/runtime/execution/components/context-provider/context-provider.component.js +5 -5
  99. package/esm2015/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.js +4 -4
  100. package/esm2015/runtime/execution/components/federated/federated.component.js +4 -4
  101. package/esm2015/runtime/execution/components/velo-attribute/velo-attribute.component.js +3 -3
  102. package/esm2015/runtime/execution/components/velo-multiselect/velo-multiselect.component.js +3 -3
  103. package/esm2015/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.js +4 -4
  104. package/esm2015/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.js +6 -6
  105. package/esm2015/runtime/execution/components/velo-port-radio/velo-port-radio.component.js +4 -4
  106. package/esm2015/runtime/execution/components/velo-type/velo-type.component.js +5 -5
  107. package/esm2015/runtime/execution/directives/section-script.directive.js +6 -6
  108. package/esm2015/runtime/execution/directives/sf-query.directive.js +5 -5
  109. package/esm2015/runtime/execution/directives/velo-attribute.directive.js +5 -5
  110. package/esm2015/runtime/execution/directives/velo-port.directive.js +21 -21
  111. package/esm2015/runtime/execution/directives/vl-approval.directive.js +5 -5
  112. package/esm2015/runtime/execution/directives/vl-document-attachments.directive.js +5 -5
  113. package/esm2015/runtime/execution/directives/vl-document-templates.directive.js +5 -5
  114. package/esm2015/runtime/execution/directives/vl-quote.directive.js +6 -6
  115. package/esm2015/runtime/execution/directives/vl-ramp.directive.js +6 -6
  116. package/esm2015/runtime/execution/runtime-execution.module.js +10 -10
  117. package/esm2015/runtime/runtime.module.js +10 -10
  118. package/esm2015/runtime/services/cart.service.js +6 -6
  119. package/esm2015/runtime/services/collapsible-state.service.js +3 -3
  120. package/esm2015/runtime/services/configuration.service.js +9 -9
  121. package/esm2015/runtime/services/current-state.service.js +4 -4
  122. package/esm2015/runtime/services/form-scope.service.js +3 -3
  123. package/esm2015/runtime/services/product-model-cache.service.js +5 -5
  124. package/esm2015/runtime/services/runtime-context.service.js +8 -8
  125. package/esm2015/runtime/services/runtime-form.service.js +5 -5
  126. package/esm2015/runtime/services/runtime.service.js +6 -6
  127. package/esm2015/runtime/services/section-helper.service.js +5 -5
  128. package/esm2015/runtime/services/section-scope.service.js +4 -4
  129. package/esm2015/runtime/services/section-store.service.js +4 -4
  130. package/esm2015/runtime/services/section.service.js +9 -9
  131. package/esm2015/runtime/types/bound-data.types.js +1 -1
  132. package/esm2015/runtime/types/runtime.types.js +1 -1
  133. package/esm2015/runtime/types/script-registry.types.js +2 -2
  134. package/esm2015/runtime/utils/line-item.util.js +2 -2
  135. package/esm2015/runtime/utils/section.utils.js +2 -2
  136. package/esm2015/runtime/utils/sections-binder.helper.js +2 -2
  137. package/esm2015/runtime/veloceapps-sdk-runtime.js +5 -0
  138. package/esm2015/src/components/dialog/dialog.component.js +3 -3
  139. package/esm2015/src/components/dialog/dialog.module.js +4 -4
  140. package/esm2015/src/components/doc-gen/doc-gen.component.js +11 -11
  141. package/esm2015/src/components/doc-gen/doc-gen.module.js +6 -6
  142. package/esm2015/src/components/header/cart-overlay/cart-preview.component.js +6 -6
  143. package/esm2015/src/components/header/cart-overlay/cart-preview.module.js +6 -6
  144. package/esm2015/src/components/header/header.component.js +10 -10
  145. package/esm2015/src/components/header/header.module.js +6 -6
  146. package/esm2015/src/components/header/metrics/metrics.component.js +20 -16
  147. package/esm2015/src/components/header/metrics/metrics.definitions.js +6 -6
  148. package/esm2015/src/components/header/metrics/metrics.module.js +6 -6
  149. package/esm2015/src/flow-routing.module.js +4 -4
  150. package/esm2015/src/flow.component.js +7 -7
  151. package/esm2015/src/flow.module.js +9 -9
  152. package/esm2015/src/guards/context.guard.js +6 -6
  153. package/esm2015/src/guards/product-unload.guard.js +5 -5
  154. package/esm2015/src/guards/root.guard.js +3 -3
  155. package/esm2015/src/pages/catalog/catalog.component.js +10 -10
  156. package/esm2015/src/pages/catalog/catalog.module.js +7 -7
  157. package/esm2015/src/pages/debug/debug.component.js +6 -6
  158. package/esm2015/src/pages/debug/debug.module.js +4 -4
  159. package/esm2015/src/pages/empty-account/empty-account.component.js +4 -4
  160. package/esm2015/src/pages/empty-account/empty-account.module.js +7 -7
  161. package/esm2015/src/pages/legacy-product/legacy-product.component.js +9 -9
  162. package/esm2015/src/pages/legacy-product/legacy-product.module.js +6 -6
  163. package/esm2015/src/pages/product/product.component.js +7 -7
  164. package/esm2015/src/pages/product/product.module.js +7 -7
  165. package/esm2015/src/pages/record-not-found/record-not-found.component.js +3 -3
  166. package/esm2015/src/pages/record-not-found/record-not-found.module.js +4 -4
  167. package/esm2015/src/pages/remote/remote.component.js +10 -10
  168. package/esm2015/src/pages/remote/remote.module.js +7 -7
  169. package/esm2015/src/pages/remote/remote.types.js +1 -1
  170. package/esm2015/src/pages/shopping-cart/shopping-cart.component.js +10 -10
  171. package/esm2015/src/pages/shopping-cart/shopping-cart.module.js +7 -7
  172. package/esm2015/src/resolvers/flow.resolver.js +6 -6
  173. package/esm2015/src/resolvers/quote.resolver.js +14 -14
  174. package/esm2015/src/services/doc-gen.service.js +6 -6
  175. package/esm2015/src/services/flow-dialog.service.js +5 -5
  176. package/esm2015/src/services/flow-router.service.js +6 -6
  177. package/esm2015/src/services/flow.service.js +7 -7
  178. package/esm2015/src/types/context-route.types.js +1 -1
  179. package/esm2015/src/types/flow-customization.types.js +1 -1
  180. package/esm2015/src/utils/flow.utils.js +2 -2
  181. package/esm2015/veloceapps-sdk.js +5 -0
  182. package/fesm2015/{veloce-sdk-cms.js → veloceapps-sdk-cms.js} +77 -79
  183. package/fesm2015/veloceapps-sdk-cms.js.map +1 -0
  184. package/fesm2015/{veloce-sdk-core.js → veloceapps-sdk-core.js} +420 -284
  185. package/fesm2015/veloceapps-sdk-core.js.map +1 -0
  186. package/fesm2015/{veloce-sdk-runtime.js → veloceapps-sdk-runtime.js} +148 -148
  187. package/fesm2015/veloceapps-sdk-runtime.js.map +1 -0
  188. package/fesm2015/{veloce-sdk.js → veloceapps-sdk.js} +163 -159
  189. package/fesm2015/veloceapps-sdk.js.map +1 -0
  190. package/package.json +14 -13
  191. package/runtime/components/component-preview/component-preview.component.d.ts +1 -1
  192. package/runtime/components/section-renderer/section-renderer.component.d.ts +1 -1
  193. package/runtime/components/ui-runtime/runtime.component.d.ts +2 -2
  194. package/runtime/components/ui-runtime-preview/runtime-preview.component.d.ts +3 -3
  195. package/runtime/execution/components/children-placeholder/children-placeholder.component.d.ts +1 -1
  196. package/runtime/execution/components/context-provider/context-provider.component.d.ts +2 -2
  197. package/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.d.ts +1 -1
  198. package/runtime/execution/components/federated/federated.component.d.ts +1 -1
  199. package/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.d.ts +1 -1
  200. package/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.d.ts +1 -1
  201. package/runtime/execution/components/velo-port-radio/velo-port-radio.component.d.ts +1 -1
  202. package/runtime/execution/components/velo-type/velo-type.component.d.ts +1 -1
  203. package/runtime/execution/directives/section-script.directive.d.ts +1 -1
  204. package/runtime/execution/directives/sf-query.directive.d.ts +2 -2
  205. package/runtime/execution/directives/velo-attribute.directive.d.ts +1 -1
  206. package/runtime/execution/directives/velo-port.directive.d.ts +1 -1
  207. package/runtime/execution/directives/vl-approval.directive.d.ts +2 -2
  208. package/runtime/execution/directives/vl-document-attachments.directive.d.ts +2 -2
  209. package/runtime/execution/directives/vl-document-templates.directive.d.ts +2 -2
  210. package/runtime/execution/directives/vl-quote.directive.d.ts +2 -2
  211. package/runtime/execution/directives/vl-ramp.directive.d.ts +3 -3
  212. package/runtime/execution/runtime-execution.module.d.ts +5 -5
  213. package/runtime/package.json +7 -7
  214. package/runtime/runtime.module.d.ts +5 -5
  215. package/runtime/services/cart.service.d.ts +3 -3
  216. package/runtime/services/configuration.service.d.ts +3 -3
  217. package/runtime/services/current-state.service.d.ts +1 -1
  218. package/runtime/services/product-model-cache.service.d.ts +2 -2
  219. package/runtime/services/runtime-context.service.d.ts +2 -2
  220. package/runtime/services/runtime-form.service.d.ts +1 -1
  221. package/runtime/services/runtime.service.d.ts +2 -2
  222. package/runtime/services/section-helper.service.d.ts +1 -1
  223. package/runtime/services/section-scope.service.d.ts +1 -1
  224. package/runtime/services/section-store.service.d.ts +1 -1
  225. package/runtime/services/section.service.d.ts +1 -1
  226. package/runtime/types/bound-data.types.d.ts +1 -1
  227. package/runtime/types/runtime.types.d.ts +2 -2
  228. package/runtime/utils/line-item.util.d.ts +1 -1
  229. package/runtime/utils/section.utils.d.ts +1 -1
  230. package/runtime/utils/sections-binder.helper.d.ts +1 -1
  231. package/{veloce-sdk.d.ts → runtime/veloceapps-sdk-runtime.d.ts} +1 -1
  232. package/src/components/doc-gen/doc-gen.component.d.ts +3 -3
  233. package/src/components/doc-gen/doc-gen.module.d.ts +1 -1
  234. package/src/components/header/cart-overlay/cart-preview.component.d.ts +1 -1
  235. package/src/components/header/cart-overlay/cart-preview.module.d.ts +1 -1
  236. package/src/components/header/header.component.d.ts +4 -4
  237. package/src/components/header/header.module.d.ts +1 -1
  238. package/src/components/header/metrics/metrics.component.d.ts +5 -4
  239. package/src/components/header/metrics/metrics.definitions.d.ts +1 -1
  240. package/src/components/header/metrics/metrics.module.d.ts +1 -1
  241. package/src/flow.component.d.ts +2 -2
  242. package/src/flow.module.d.ts +4 -4
  243. package/src/guards/context.guard.d.ts +1 -1
  244. package/src/guards/product-unload.guard.d.ts +1 -1
  245. package/src/pages/catalog/catalog.component.d.ts +3 -3
  246. package/src/pages/catalog/catalog.module.d.ts +2 -2
  247. package/src/pages/debug/debug.component.d.ts +3 -3
  248. package/src/pages/empty-account/empty-account.module.d.ts +2 -2
  249. package/src/pages/legacy-product/legacy-product.component.d.ts +4 -4
  250. package/src/pages/legacy-product/legacy-product.module.d.ts +1 -1
  251. package/src/pages/product/product.component.d.ts +1 -1
  252. package/src/pages/product/product.module.d.ts +2 -2
  253. package/src/pages/remote/remote.component.d.ts +3 -3
  254. package/src/pages/remote/remote.module.d.ts +2 -2
  255. package/src/pages/remote/remote.types.d.ts +1 -1
  256. package/src/pages/shopping-cart/shopping-cart.component.d.ts +3 -3
  257. package/src/pages/shopping-cart/shopping-cart.module.d.ts +2 -2
  258. package/src/resolvers/flow.resolver.d.ts +2 -2
  259. package/src/resolvers/quote.resolver.d.ts +1 -1
  260. package/src/services/doc-gen.service.d.ts +1 -1
  261. package/src/services/flow-dialog.service.d.ts +1 -1
  262. package/src/services/flow-router.service.d.ts +1 -1
  263. package/src/services/flow.service.d.ts +2 -2
  264. package/src/types/context-route.types.d.ts +1 -1
  265. package/src/types/flow-customization.types.d.ts +2 -2
  266. package/src/utils/flow.utils.d.ts +1 -1
  267. package/{cms/veloce-sdk-cms.d.ts → veloceapps-sdk.d.ts} +1 -1
  268. package/bundles/veloce-sdk-cms.umd.js.map +0 -1
  269. package/bundles/veloce-sdk-core.umd.js.map +0 -1
  270. package/bundles/veloce-sdk-runtime.umd.js.map +0 -1
  271. package/bundles/veloce-sdk.umd.js.map +0 -1
  272. package/esm2015/cms/veloce-sdk-cms.js +0 -5
  273. package/esm2015/core/veloce-sdk-core.js +0 -5
  274. package/esm2015/runtime/veloce-sdk-runtime.js +0 -5
  275. package/esm2015/veloce-sdk.js +0 -5
  276. package/fesm2015/veloce-sdk-cms.js.map +0 -1
  277. package/fesm2015/veloce-sdk-core.js.map +0 -1
  278. package/fesm2015/veloce-sdk-runtime.js.map +0 -1
  279. package/fesm2015/veloce-sdk.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@veloce/core'), require('rxjs'), require('rxjs/operators'), require('@veloce/api'), require('lodash'), require('@veloce/components'), require('primeng/api'), require('primeng/dynamicdialog'), require('moment')) :
3
- typeof define === 'function' && define.amd ? define('@veloce/sdk/core', ['exports', '@angular/core', '@veloce/core', 'rxjs', 'rxjs/operators', '@veloce/api', 'lodash', '@veloce/components', 'primeng/api', 'primeng/dynamicdialog', 'moment'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.veloce = global.veloce || {}, global.veloce.sdk = global.veloce.sdk || {}, global.veloce.sdk.core = {}), global.ng.core, global["@veloce/core"], global.rxjs, global.rxjs.operators, global["@veloce/api"], global.lodash, global["@veloce/components"], global["primeng/api"], global["primeng/dynamicdialog"], global.moment));
5
- })(this, (function (exports, i0, core, rxjs, operators, i1, lodash, components, i4, i5, moment) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@veloceapps/core'), require('rxjs'), require('rxjs/operators'), require('@veloceapps/api'), require('lodash'), require('@veloceapps/components'), require('primeng/api'), require('primeng/dynamicdialog'), require('moment')) :
3
+ typeof define === 'function' && define.amd ? define('@veloceapps/sdk/core', ['exports', '@angular/core', '@veloceapps/core', 'rxjs', 'rxjs/operators', '@veloceapps/api', 'lodash', '@veloceapps/components', 'primeng/api', 'primeng/dynamicdialog', 'moment'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.veloceapps = global.veloceapps || {}, global.veloceapps.sdk = global.veloceapps.sdk || {}, global.veloceapps.sdk.core = {}), global.ng.core, global["@veloceapps/core"], global.rxjs, global.rxjs.operators, global["@veloceapps/api"], global.lodash, global["@veloceapps/components"], global["primeng/api"], global["primeng/dynamicdialog"], global.moment));
5
+ })(this, (function (exports, i0, core, rxjs, operators, i1, lodash, components, i5, i6, moment) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -26,8 +26,8 @@
26
26
 
27
27
  var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
28
  var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
29
- var i4__namespace = /*#__PURE__*/_interopNamespace(i4);
30
29
  var i5__namespace = /*#__PURE__*/_interopNamespace(i5);
30
+ var i6__namespace = /*#__PURE__*/_interopNamespace(i6);
31
31
  var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
32
32
 
33
33
  var getDefaultLineItem = function (context, uiDefinitionProperties, qty) {
@@ -40,7 +40,7 @@
40
40
  return lineItem;
41
41
  };
42
42
 
43
- /*! *****************************************************************************
43
+ /******************************************************************************
44
44
  Copyright (c) Microsoft Corporation.
45
45
 
46
46
  Permission to use, copy, modify, and/or distribute this software for any
@@ -107,6 +107,64 @@
107
107
  function __param(paramIndex, decorator) {
108
108
  return function (target, key) { decorator(target, key, paramIndex); };
109
109
  }
110
+ function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
111
+ function accept(f) { if (f !== void 0 && typeof f !== "function")
112
+ throw new TypeError("Function expected"); return f; }
113
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
114
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
115
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
116
+ var _, done = false;
117
+ for (var i = decorators.length - 1; i >= 0; i--) {
118
+ var context = {};
119
+ for (var p in contextIn)
120
+ context[p] = p === "access" ? {} : contextIn[p];
121
+ for (var p in contextIn.access)
122
+ context.access[p] = contextIn.access[p];
123
+ context.addInitializer = function (f) { if (done)
124
+ throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
125
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
126
+ if (kind === "accessor") {
127
+ if (result === void 0)
128
+ continue;
129
+ if (result === null || typeof result !== "object")
130
+ throw new TypeError("Object expected");
131
+ if (_ = accept(result.get))
132
+ descriptor.get = _;
133
+ if (_ = accept(result.set))
134
+ descriptor.set = _;
135
+ if (_ = accept(result.init))
136
+ initializers.push(_);
137
+ }
138
+ else if (_ = accept(result)) {
139
+ if (kind === "field")
140
+ initializers.push(_);
141
+ else
142
+ descriptor[key] = _;
143
+ }
144
+ }
145
+ if (target)
146
+ Object.defineProperty(target, contextIn.name, descriptor);
147
+ done = true;
148
+ }
149
+ ;
150
+ function __runInitializers(thisArg, initializers, value) {
151
+ var useValue = arguments.length > 2;
152
+ for (var i = 0; i < initializers.length; i++) {
153
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
154
+ }
155
+ return useValue ? value : void 0;
156
+ }
157
+ ;
158
+ function __propKey(x) {
159
+ return typeof x === "symbol" ? x : "".concat(x);
160
+ }
161
+ ;
162
+ function __setFunctionName(f, name, prefix) {
163
+ if (typeof name === "symbol")
164
+ name = name.description ? "[".concat(name.description, "]") : "";
165
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
166
+ }
167
+ ;
110
168
  function __metadata(metadataKey, metadataValue) {
111
169
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
112
170
  return Reflect.metadata(metadataKey, metadataValue);
@@ -138,7 +196,7 @@
138
196
  function step(op) {
139
197
  if (f)
140
198
  throw new TypeError("Generator is already executing.");
141
- while (_)
199
+ while (g && (g = 0, op[0] && (_ = 0)), _)
142
200
  try {
143
201
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
144
202
  return t;
@@ -202,7 +260,11 @@
202
260
  var __createBinding = Object.create ? (function (o, m, k, k2) {
203
261
  if (k2 === undefined)
204
262
  k2 = k;
205
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
263
+ var desc = Object.getOwnPropertyDescriptor(m, k);
264
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
265
+ desc = { enumerable: true, get: function () { return m[k]; } };
266
+ }
267
+ Object.defineProperty(o, k2, desc);
206
268
  }) : (function (o, m, k, k2) {
207
269
  if (k2 === undefined)
208
270
  k2 = k;
@@ -302,7 +364,7 @@
302
364
  function __asyncDelegator(o) {
303
365
  var i, p;
304
366
  return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
305
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
367
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
306
368
  }
307
369
  function __asyncValues(o) {
308
370
  if (!Symbol.asyncIterator)
@@ -357,6 +419,11 @@
357
419
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
358
420
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
359
421
  }
422
+ function __classPrivateFieldIn(state, receiver) {
423
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
424
+ throw new TypeError("Cannot use 'in' operator on non-object");
425
+ return typeof state === "function" ? receiver === state : state.has(receiver);
426
+ }
360
427
 
361
428
  exports.RuntimeMode = void 0;
362
429
  (function (RuntimeMode) {
@@ -416,611 +483,604 @@
416
483
  };
417
484
  return ContextService;
418
485
  }());
419
- ContextService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ContextService, deps: [{ token: i1__namespace.ContextApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
420
- ContextService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ContextService, providedIn: 'root' });
421
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ContextService, decorators: [{
486
+ ContextService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ContextService, deps: [{ token: i1__namespace.ContextApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
487
+ ContextService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ContextService, providedIn: 'root' });
488
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ContextService, decorators: [{
422
489
  type: i0.Injectable,
423
490
  args: [{ providedIn: 'root' }]
424
491
  }], ctorParameters: function () { return [{ type: i1__namespace.ContextApiService }]; } });
425
492
 
426
- var ProductImagesService = /** @class */ (function () {
427
- function ProductImagesService(productApiService) {
428
- this.productApiService = productApiService;
429
- this.imagesMap$ = new rxjs.BehaviorSubject({});
493
+ var RuntimeContextService = /** @class */ (function () {
494
+ function RuntimeContextService(configurationApiService) {
495
+ this.configurationApiService = configurationApiService;
430
496
  }
431
- ProductImagesService.prototype.getImageUrl$ = function (productId) {
497
+ RuntimeContextService.prototype.getRuntimeContext = function (productId, offeringId) {
498
+ var _this = this;
499
+ return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(operators.map(function (runtimeData) {
500
+ var _a, _b, _c;
501
+ var uiDefinition = _this.getUIDefinition(runtimeData);
502
+ var runtimeModel = core.RuntimeModel.create(runtimeData.types, runtimeData.products);
503
+ var _d = (_a = Array.from(runtimeModel.components.values()).find(function (c) { return c.productId === productId; })) !== null && _a !== void 0 ? _a : {}, productName = _d.productName, properties = _d.properties;
504
+ return {
505
+ modelId: runtimeData.modelId,
506
+ uiDefinition: uiDefinition,
507
+ runtimeModel: runtimeModel,
508
+ runtimeMode: exports.RuntimeMode.PROD,
509
+ productId: productId,
510
+ productType: (properties === null || properties === void 0 ? void 0 : properties.displayName) || productName,
511
+ offeringId: offeringId,
512
+ properties: {
513
+ PricingEnabled: ((_b = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.properties) === null || _b === void 0 ? void 0 : _b.pricingEnabled) ? 'true' : 'false',
514
+ PriceListId: (_c = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.properties) === null || _c === void 0 ? void 0 : _c.priceList,
515
+ },
516
+ };
517
+ }));
518
+ };
519
+ RuntimeContextService.prototype.getUIDefinition = function (runtimeData) {
432
520
  var _a;
433
- if (this.imagesMap$.value[productId] == null) {
434
- this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), (_a = {}, _a[productId] = '', _a)));
435
- this.fetchProductImage(productId);
521
+ var rawUiDefinitions;
522
+ try {
523
+ rawUiDefinitions = JSON.parse(runtimeData.uiDefinitionsSource);
436
524
  }
437
- return this.imagesMap$.pipe(rxjs.map(function (imagesMap) { return imagesMap[productId]; }), rxjs.distinctUntilChanged());
438
- };
439
- ProductImagesService.prototype.fetchProductImage = function (productId) {
440
- var _this = this;
441
- this.productApiService
442
- .fetchImage$(productId)
443
- .pipe(rxjs.map(function (file) { return URL.createObjectURL(file); }), rxjs.catchError(function () { return rxjs.of(''); }), rxjs.tap(function (url) {
444
- var _a;
445
- return _this.imagesMap$.next(Object.assign(Object.assign({}, _this.imagesMap$.value), (_a = {}, _a[productId] = url, _a)));
446
- }))
447
- .subscribe();
525
+ catch (e) {
526
+ return;
527
+ }
528
+ var uiDefinitions = rawUiDefinitions.filter(function (uiDef) { return uiDef.version; });
529
+ var uiDefinition = (_a = uiDefinitions.find(function (uiDef) { return uiDef.primary; })) !== null && _a !== void 0 ? _a : uiDefinitions[0];
530
+ return uiDefinition;
448
531
  };
449
- return ProductImagesService;
532
+ return RuntimeContextService;
450
533
  }());
451
- ProductImagesService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ProductImagesService, deps: [{ token: i1__namespace.ProductApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
452
- ProductImagesService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ProductImagesService, providedIn: 'root' });
453
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ProductImagesService, decorators: [{
454
- type: i0.Injectable,
455
- args: [{ providedIn: 'root' }]
456
- }], ctorParameters: function () { return [{ type: i1__namespace.ProductApiService }]; } });
534
+ RuntimeContextService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeContextService, deps: [{ token: i1__namespace.ConfigurationApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
535
+ RuntimeContextService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeContextService });
536
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeContextService, decorators: [{
537
+ type: i0.Injectable
538
+ }], ctorParameters: function () { return [{ type: i1__namespace.ConfigurationApiService }]; } });
457
539
 
458
- var QuoteDraftService = /** @class */ (function () {
459
- function QuoteDraftService(context, quoteApiService, priceApiService) {
460
- var _this = this;
461
- this.context = context;
462
- this.quoteApiService = quoteApiService;
463
- this.priceApiService = priceApiService;
464
- this.quoteSubj$ = new rxjs.BehaviorSubject(null);
465
- this.resetSubj$ = new rxjs.BehaviorSubject(true);
466
- this.isInitializedSubj$ = new rxjs.BehaviorSubject(false);
467
- this.initialCurrentState = [];
468
- this.allPriceLists = [];
469
- this.assetPriceLists = [];
470
- this.hasUnsavedChanges = false;
471
- this.reset$ = this.resetSubj$.asObservable();
472
- this.activePriceList$ = this.context.resolve$().pipe(operators.map(function (ctx) { return _this.allPriceLists.find(function (priceList) { return priceList.id === ctx.properties.PriceListId; }); }), operators.map(function (priceList) { return priceList !== null && priceList !== void 0 ? priceList : null; }));
473
- this.isInitializedSubj$
474
- .pipe(operators.filter(function (isInitialized) { return isInitialized; }), operators.switchMap(function () { return _this.quoteSubj$.asObservable(); }), operators.skip(1), operators.tap(function (quote) { return _this.markAsUpdated(quote); }))
475
- .subscribe();
540
+ var ConfigurationRuntimeService = /** @class */ (function () {
541
+ function ConfigurationRuntimeService(apiService, contextService, runtimeContextService) {
542
+ this.apiService = apiService;
543
+ this.contextService = contextService;
544
+ this.runtimeContextService = runtimeContextService;
545
+ this._isInitialized = false;
546
+ this.uiDefinitionProperties = {};
476
547
  }
477
- Object.defineProperty(QuoteDraftService.prototype, "isInitialized", {
478
- get: function () {
479
- return this.isInitializedSubj$.getValue();
480
- },
481
- set: function (value) {
482
- if (this.isInitialized !== value) {
483
- this.isInitializedSubj$.next(value);
484
- }
485
- },
486
- enumerable: false,
487
- configurable: true
488
- });
489
- Object.defineProperty(QuoteDraftService.prototype, "hasAssets$", {
490
- get: function () {
491
- var _this = this;
492
- return this.quoteSubj$.pipe(operators.map(function () { return _this.hasAssets; }));
493
- },
494
- enumerable: false,
495
- configurable: true
496
- });
497
- Object.defineProperty(QuoteDraftService.prototype, "hasAssets", {
498
- get: function () {
499
- var quoteDraft = this.quoteSubj$.value;
500
- return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
501
- },
502
- enumerable: false,
503
- configurable: true
504
- });
505
- QuoteDraftService.prototype.reset = function () {
506
- this.resetSubj$.next(true);
507
- this.quoteSubj$.next(null);
508
- this.initialCurrentState = [];
548
+ ConfigurationRuntimeService.prototype.reset = function () {
549
+ this._isInitialized = false;
550
+ this._runtimeContext = undefined;
551
+ this._assets = undefined;
552
+ this.initializationProps = undefined;
553
+ this.uiDefinitionProperties = {};
509
554
  };
510
- QuoteDraftService.prototype.init = function (quoteId, params) {
555
+ ConfigurationRuntimeService.prototype.initTestMode = function (modelId, uiDefinition) {
511
556
  var _this = this;
512
- return rxjs.zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()).pipe(operators.tap(function (_c) {
513
- var _d = __read(_c, 2), quote = _d[0], allPriceLists = _d[1];
514
- _this.allPriceLists = allPriceLists;
515
- _this.quoteSubj$.next(quote);
516
- _this.initialCurrentState = quote.currentState;
517
- _this.context.update(quote.context);
518
- _this.populateActivePriceLists$();
519
- }), operators.map(function () { return rxjs.noop(); }), operators.take(1));
557
+ var _a, _b;
558
+ this.uiDefinitionProperties = (_a = uiDefinition.properties) !== null && _a !== void 0 ? _a : {};
559
+ var uiDefinitionExternals = (_b = uiDefinition.externals) !== null && _b !== void 0 ? _b : {};
560
+ return rxjs.combineLatest([
561
+ this.apiService.getRuntimeDataByModelId(modelId),
562
+ this.contextService.create('TestId', core.ConfigurationContextMode.TEST),
563
+ ]).pipe(operators.first(), operators.tap(function (_e) {
564
+ var _f = __read(_e, 2), runtimeData = _f[0], context = _f[1];
565
+ var _a;
566
+ _this._runtimeContext = {
567
+ modelId: modelId,
568
+ runtimeModel: core.RuntimeModel.create(runtimeData.types, runtimeData.products),
569
+ runtimeMode: exports.RuntimeMode.TEST,
570
+ };
571
+ _this.contextService.update({
572
+ properties: Object.assign(Object.assign(Object.assign(Object.assign({}, (_a = _this.runtimeContext) === null || _a === void 0 ? void 0 : _a.properties), context.properties), { ModelId: modelId, RuntimeMode: core.ConfigurationContextMode.TEST, PricingEnabled: _this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false', StartDate: new Date().toISOString().substring(0, 10), PriceListId: _this.uiDefinitionProperties.priceList, standalone: 'true' }), uiDefinitionExternals),
573
+ });
574
+ _this._isInitialized = true;
575
+ }));
520
576
  };
521
- QuoteDraftService.prototype.setCurrentLineItemState = function (lineItems) {
522
- var quoteDraft = this.quoteSubj$.value;
523
- if (!quoteDraft) {
524
- return;
525
- }
526
- this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: lineItems }));
577
+ ConfigurationRuntimeService.prototype.init = function (props) {
578
+ var _this = this;
579
+ this.initializationProps = props;
580
+ this._assets = props.assets;
581
+ var context = this.contextService.resolve();
582
+ return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(operators.tap(function (runtimeContext) {
583
+ var _a, _b, _c, _d;
584
+ _this.uiDefinitionProperties = (_b = (_a = runtimeContext.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) !== null && _b !== void 0 ? _b : {};
585
+ var PriceListId = ((_c = context.properties) !== null && _c !== void 0 ? _c : {}).PriceListId;
586
+ var mergeContext = Object.assign(Object.assign({}, runtimeContext), { properties: Object.assign(Object.assign(Object.assign({}, runtimeContext.properties), context.properties), { PricingEnabled: PriceListId ? 'true' : 'false' }) });
587
+ _this.id15to18('AccountId', mergeContext.properties);
588
+ _this._runtimeContext = mergeContext;
589
+ if (context.properties && ((_d = _this._runtimeContext.properties) === null || _d === void 0 ? void 0 : _d.StartDate)) {
590
+ _this.contextService.update({
591
+ properties: Object.assign(Object.assign({}, _this._runtimeContext.properties), context.properties),
592
+ });
593
+ }
594
+ _this._isInitialized = true;
595
+ }));
527
596
  };
528
- QuoteDraftService.prototype.updateQuoteDraft = function (update) {
529
- var quoteDraft = this.quoteSubj$.value;
530
- if (!quoteDraft) {
597
+ ConfigurationRuntimeService.prototype.id15to18 = function (propertyName, source) {
598
+ if (!source) {
531
599
  return;
532
600
  }
533
- if (update.context) {
534
- this.context.set(update.context);
601
+ var value = source[propertyName];
602
+ if (typeof value === 'string' && value.length === 15) {
603
+ source[propertyName] = core.SalesforceIdUtils.generateId18FromId15(value);
535
604
  }
536
- this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), update));
537
605
  };
538
- QuoteDraftService.prototype.updateByPriceSummary = function (priceSummary) {
539
- var quoteDraft = this.quoteSubj$.value;
540
- if (!quoteDraft) {
541
- return;
542
- }
543
- var updatedCurrentState = this.currentState.map(function (lineItem) {
544
- var updated = priceSummary.lineItems.find(function (li) { return li.id === lineItem.id; });
545
- return updated !== null && updated !== void 0 ? updated : lineItem;
546
- });
547
- this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedCurrentState, totalPrices: priceSummary.totalPrices, approvalItems: priceSummary.approvalItems }));
606
+ ConfigurationRuntimeService.prototype.getAsset = function (lineItem) {
607
+ return this._assets && this._assets.find(function (a) { return a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId; });
548
608
  };
549
- Object.defineProperty(QuoteDraftService.prototype, "quoteDraft$", {
550
- get: function () {
551
- var _this = this;
552
- return rxjs.combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(operators.map(function () { return _this.quoteDraft; }), operators.filter(function (quote) { return Boolean(quote); }), operators.shareReplay());
553
- },
554
- enumerable: false,
555
- configurable: true
556
- });
557
- Object.defineProperty(QuoteDraftService.prototype, "quoteDraft", {
558
- get: function () {
559
- var quote = this.quoteSubj$.value;
560
- if (!quote) {
561
- return null;
562
- }
563
- return Object.assign(Object.assign({}, quote), { context: this.context.resolve() });
564
- },
565
- enumerable: false,
566
- configurable: true
567
- });
568
- Object.defineProperty(QuoteDraftService.prototype, "quoteDraftForActivePriceList", {
609
+ Object.defineProperty(ConfigurationRuntimeService.prototype, "isInitialized", {
569
610
  get: function () {
570
- var quoteDraft = this.quoteDraft;
571
- if (!quoteDraft) {
572
- return null;
573
- }
574
- return Object.assign(Object.assign({}, quoteDraft), { initialState: this.filterByActivePriceList(quoteDraft.initialState), currentState: this.filterByActivePriceList(quoteDraft.currentState) });
611
+ return this._isInitialized;
575
612
  },
576
613
  enumerable: false,
577
614
  configurable: true
578
615
  });
579
- Object.defineProperty(QuoteDraftService.prototype, "currentState$", {
616
+ Object.defineProperty(ConfigurationRuntimeService.prototype, "runtimeModel", {
580
617
  get: function () {
581
- return this.quoteDraft$.pipe(operators.map(function (quote) { return quote.currentState; }));
618
+ var _a;
619
+ return (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.runtimeModel;
582
620
  },
583
621
  enumerable: false,
584
622
  configurable: true
585
623
  });
586
- Object.defineProperty(QuoteDraftService.prototype, "currentState", {
624
+ Object.defineProperty(ConfigurationRuntimeService.prototype, "runtimeContext", {
587
625
  get: function () {
588
- var _a, _b;
589
- return (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
626
+ return this._runtimeContext;
590
627
  },
591
628
  enumerable: false,
592
629
  configurable: true
593
630
  });
594
- Object.defineProperty(QuoteDraftService.prototype, "activeCurrentState$", {
595
- /**
596
- * Stream of activeCurrentState
597
- */
598
- get: function () {
599
- var _this = this;
600
- return this.quoteDraft$.pipe(operators.map(function () { return _this.activeCurrentState; }));
601
- },
602
- enumerable: false,
603
- configurable: true
631
+ return ConfigurationRuntimeService;
632
+ }());
633
+ ConfigurationRuntimeService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationRuntimeService, deps: [{ token: i1__namespace.ConfigurationApiService }, { token: ContextService }, { token: RuntimeContextService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
634
+ ConfigurationRuntimeService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationRuntimeService });
635
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationRuntimeService, decorators: [{
636
+ type: i0.Injectable
637
+ }], ctorParameters: function () { return [{ type: i1__namespace.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
638
+
639
+ var findLineItem = function (id, lineItems) {
640
+ return findLineItemWithComparator(lineItems, function (li) { return li.id === id; });
641
+ };
642
+ var findLineItemWithComparator = function (lineItems, comparator) {
643
+ var currentLevel = lineItems;
644
+ while (currentLevel.length) {
645
+ var found = currentLevel.find(comparator);
646
+ if (found) {
647
+ return found;
648
+ }
649
+ currentLevel = lodash.flatten(currentLevel.map(function (parent) { return parent.lineItems; }));
650
+ }
651
+ return;
652
+ };
653
+ var insertLineItem = function (lineItem, parentId, toInsert) {
654
+ var insertData = lineItem.id === parentId ? [toInsert] : [];
655
+ return Object.assign(Object.assign({}, lineItem), { lineItems: __spreadArray(__spreadArray([], __read(insertData)), __read(lineItem.lineItems.map(function (li) {
656
+ return insertLineItem(li, parentId, toInsert);
657
+ }))) });
658
+ };
659
+ var removeLineItem = function (lineItem, idToRemove) {
660
+ return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems
661
+ .map(function (li) {
662
+ if (li.id === idToRemove) {
663
+ return;
664
+ }
665
+ else if (li.lineItems.length) {
666
+ return removeLineItem(li, idToRemove);
667
+ }
668
+ return li;
669
+ })
670
+ .filter(function (r) { return !!r; }) });
671
+ };
672
+ var replaceLineItem = function (lineItem, replaceTo) {
673
+ if (lineItem.id === replaceTo.id) {
674
+ return Object.assign({}, replaceTo);
675
+ }
676
+ return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(function (li) {
677
+ if (li.id === replaceTo.id) {
678
+ return replaceTo;
679
+ }
680
+ else if (li.lineItems.length) {
681
+ return replaceLineItem(li, replaceTo);
682
+ }
683
+ return li;
684
+ }) });
685
+ };
686
+ var mapAttributes = function (attributes) {
687
+ return attributes.reduce(function (acc, _c) {
688
+ var _d;
689
+ var name = _c.name, value = _c.value;
690
+ return (Object.assign(Object.assign({}, acc), (_d = {}, _d[name] = value, _d)));
691
+ }, {});
692
+ };
693
+ var getAttributes = function (attributes, names) {
694
+ if (names === void 0) { names = []; }
695
+ var filtered = attributes.filter(function (_c) {
696
+ var name = _c.name;
697
+ return names.includes(name);
604
698
  });
605
- Object.defineProperty(QuoteDraftService.prototype, "activeCurrentState", {
606
- /**
607
- * activeCurrentState is currentState passed through additional filters
608
- */
609
- get: function () {
610
- var _a, _b;
611
- var currentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
612
- currentState = this.filterByActivePriceList(currentState);
613
- return currentState;
614
- },
615
- enumerable: false,
616
- configurable: true
699
+ return lodash.sortBy(filtered, [function (_c) {
700
+ var name = _c.name;
701
+ return names.indexOf(name);
702
+ }]);
703
+ };
704
+ var upsertAttributes = function (originalAttributes, attributesToUpsert) {
705
+ return attributesToUpsert.reduce(function (acc, _c) {
706
+ var name = _c.name, value = _c.value;
707
+ var _d = __read(getAttributes(acc, [name]), 1), origAttr = _d[0];
708
+ return __spreadArray(__spreadArray([], __read(acc.filter(function (attr) { return attr.name !== name; }))), [
709
+ Object.assign(Object.assign({}, (origAttr !== null && origAttr !== void 0 ? origAttr : { name: name })), { cfgStatus: 'User', value: value }),
710
+ ]);
711
+ }, originalAttributes);
712
+ };
713
+ var patchAttributes = function (rootLineItem, id, attrs) {
714
+ var lineItem = findLineItem(id, [rootLineItem]);
715
+ if (!lineItem) {
716
+ return rootLineItem;
717
+ }
718
+ var attributes = upsertAttributes(lineItem.attributes, attrs);
719
+ return replaceLineItem(rootLineItem, Object.assign(Object.assign({}, lineItem), { attributes: attributes }));
720
+ };
721
+ var getAttributeValue = function (attributes, name) { var _a; return (_a = attributes.find(function (attr) { return attr.name === name; })) === null || _a === void 0 ? void 0 : _a.value; };
722
+ var generateLineItem = function (port, type, parentId, attributes, lineItems) {
723
+ if (attributes === void 0) { attributes = []; }
724
+ if (lineItems === void 0) { lineItems = []; }
725
+ return {
726
+ id: core.UUID.UUID(),
727
+ port: port,
728
+ type: type,
729
+ actionCode: 'ADD',
730
+ cfgStatus: 'New',
731
+ attributes: attributes.map(function (_c) {
732
+ var name = _c.name, value = _c.value;
733
+ return ({ cfgStatus: 'User', name: name, value: value });
734
+ }),
735
+ lineItems: lineItems,
736
+ parentId: parentId,
737
+ qty: 1,
738
+ };
739
+ };
740
+ var getRecommendedPrices = function (portDomain, type) {
741
+ var _a, _b;
742
+ var domainType = portDomain.domainTypes.find(function (_c) {
743
+ var name = _c.name;
744
+ return name === type;
617
745
  });
618
- Object.defineProperty(QuoteDraftService.prototype, "activeInitialState$", {
619
- /**
620
- * Stream of activeInitialState
621
- */
746
+ var _c = __read((_b = (_a = domainType === null || domainType === void 0 ? void 0 : domainType.recommendedPrices) === null || _a === void 0 ? void 0 : _a.filter(function (_c) {
747
+ var chargeMethod = _c.chargeMethod;
748
+ return chargeMethod === 'ONE_TIME';
749
+ }).reduce(function (acc, rp) {
750
+ var _c = __read(acc, 2), netPrice = _c[0], listPrice = _c[1];
751
+ return [netPrice + rp.netPrice, listPrice + rp.listPrice];
752
+ }, [0, 0])) !== null && _b !== void 0 ? _b : [0, 0], 2), net = _c[0], list = _c[1];
753
+ return { net: net, list: list };
754
+ };
755
+ var multiplyLineItems = function (lineItem, qty, split) {
756
+ if (split) {
757
+ var unifyIds_1 = function (lineItem) { return (Object.assign(Object.assign({}, lineItem), { id: core.UUID.UUID(), lineItems: lineItem.lineItems.map(unifyIds_1) })); };
758
+ return lodash.map(new Array(qty), function () { return unifyIds_1(lineItem); });
759
+ }
760
+ else {
761
+ return [
762
+ Object.assign(Object.assign({}, lineItem), { qty: qty }),
763
+ ];
764
+ }
765
+ };
766
+
767
+ var lineItem_utils = /*#__PURE__*/Object.freeze({
768
+ __proto__: null,
769
+ findLineItem: findLineItem,
770
+ findLineItemWithComparator: findLineItemWithComparator,
771
+ insertLineItem: insertLineItem,
772
+ removeLineItem: removeLineItem,
773
+ replaceLineItem: replaceLineItem,
774
+ mapAttributes: mapAttributes,
775
+ getAttributes: getAttributes,
776
+ upsertAttributes: upsertAttributes,
777
+ patchAttributes: patchAttributes,
778
+ getAttributeValue: getAttributeValue,
779
+ generateLineItem: generateLineItem,
780
+ getRecommendedPrices: getRecommendedPrices,
781
+ multiplyLineItems: multiplyLineItems
782
+ });
783
+
784
+ var LineItemWorker = /** @class */ (function () {
785
+ function LineItemWorker(src) {
786
+ this.li = Object.assign({}, src);
787
+ }
788
+ LineItemWorker.prototype.insert = function (parentId, toInsert) {
789
+ return new LineItemWorker(insertLineItem(this.li, parentId, toInsert));
790
+ };
791
+ LineItemWorker.prototype.remove = function (id) {
792
+ return new LineItemWorker(removeLineItem(this.li, id));
793
+ };
794
+ LineItemWorker.prototype.replace = function (toReplace) {
795
+ return new LineItemWorker(replaceLineItem(this.li, toReplace));
796
+ };
797
+ LineItemWorker.prototype.patchAttribute = function (attrs, id) {
798
+ return new LineItemWorker(patchAttributes(this.li, id !== null && id !== void 0 ? id : this.li.id, attrs));
799
+ };
800
+ return LineItemWorker;
801
+ }());
802
+
803
+ var QuoteDraftService = /** @class */ (function () {
804
+ function QuoteDraftService(context, quoteApiService, priceApiService) {
805
+ var _this = this;
806
+ this.context = context;
807
+ this.quoteApiService = quoteApiService;
808
+ this.priceApiService = priceApiService;
809
+ this.quoteSubj$ = new rxjs.BehaviorSubject(null);
810
+ this.resetSubj$ = new rxjs.BehaviorSubject(true);
811
+ this.isInitializedSubj$ = new rxjs.BehaviorSubject(false);
812
+ this.initialCurrentState = [];
813
+ this._hasUnsavedChanges = false;
814
+ this.allPriceLists = [];
815
+ this.assetPriceLists = [];
816
+ this.reset$ = this.resetSubj$.asObservable();
817
+ this.activePriceList$ = this.context.resolve$().pipe(operators.map(function (ctx) { return _this.allPriceLists.find(function (priceList) { return priceList.id === ctx.properties.PriceListId; }); }), operators.map(function (priceList) { return priceList !== null && priceList !== void 0 ? priceList : null; }));
818
+ this.isInitializedSubj$
819
+ .pipe(operators.filter(function (isInitialized) { return isInitialized; }), operators.switchMap(function () { return _this.quoteSubj$.asObservable(); }), operators.skip(1), operators.tap(function (quote) { return _this.markAsUpdated(quote); }))
820
+ .subscribe();
821
+ }
822
+ Object.defineProperty(QuoteDraftService.prototype, "isInitialized", {
622
823
  get: function () {
623
- var _this = this;
624
- return this.quoteDraft$.pipe(operators.map(function () { return _this.activeInitialState; }));
824
+ return this.isInitializedSubj$.getValue();
825
+ },
826
+ set: function (value) {
827
+ if (this.isInitialized !== value) {
828
+ this.isInitializedSubj$.next(value);
829
+ }
625
830
  },
626
831
  enumerable: false,
627
832
  configurable: true
628
833
  });
629
- Object.defineProperty(QuoteDraftService.prototype, "activeInitialState", {
630
- /**
631
- * activeInitialState is initialState passed through additional filters
632
- */
834
+ Object.defineProperty(QuoteDraftService.prototype, "hasUnsavedChanges", {
633
835
  get: function () {
836
+ return this._hasUnsavedChanges;
837
+ },
838
+ set: function (value) {
634
839
  var _a, _b;
635
- var ctx = this.context.resolve();
636
- var initialState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState) !== null && _b !== void 0 ? _b : [];
637
- if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
638
- initialState = this.filterByActivePriceList(initialState);
840
+ this._hasUnsavedChanges = value;
841
+ if (!this._hasUnsavedChanges) {
842
+ this.initialCurrentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
639
843
  }
640
- return initialState;
641
844
  },
642
845
  enumerable: false,
643
846
  configurable: true
644
847
  });
645
- Object.defineProperty(QuoteDraftService.prototype, "isStandalone", {
848
+ Object.defineProperty(QuoteDraftService.prototype, "hasAssets$", {
646
849
  get: function () {
647
- return this.context.resolve().properties.standalone === 'true';
850
+ var _this = this;
851
+ return this.quoteSubj$.pipe(operators.map(function () { return _this.hasAssets; }));
648
852
  },
649
853
  enumerable: false,
650
854
  configurable: true
651
855
  });
652
- Object.defineProperty(QuoteDraftService.prototype, "isStandalone$", {
856
+ Object.defineProperty(QuoteDraftService.prototype, "hasAssets", {
653
857
  get: function () {
654
- var _this = this;
655
- return this.context.resolve$().pipe(operators.map(function () { return _this.isStandalone; }));
858
+ var quoteDraft = this.quoteSubj$.value;
859
+ return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
656
860
  },
657
861
  enumerable: false,
658
862
  configurable: true
659
863
  });
660
- QuoteDraftService.prototype.getInitialCurrentState = function () {
661
- return this.initialCurrentState;
864
+ QuoteDraftService.prototype.reset = function () {
865
+ this.resetSubj$.next(true);
866
+ this.quoteSubj$.next(null);
867
+ this.hasUnsavedChanges = false;
662
868
  };
663
- QuoteDraftService.prototype.isEditMode$ = function () {
869
+ QuoteDraftService.prototype.init = function (quoteId, params) {
664
870
  var _this = this;
665
- return this.context.resolve$().pipe(operators.map(function () { return _this.isEditMode(); }));
871
+ return rxjs.zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()).pipe(operators.tap(function (_c) {
872
+ var _d = __read(_c, 2), quote = _d[0], allPriceLists = _d[1];
873
+ _this.allPriceLists = allPriceLists;
874
+ _this.quoteSubj$.next(quote);
875
+ _this.context.update(quote.context);
876
+ _this.populateActivePriceLists$();
877
+ }), operators.map(function () { return rxjs.noop(); }), operators.take(1));
666
878
  };
667
- QuoteDraftService.prototype.isEditMode = function () {
668
- var context = this.context.resolve();
669
- if (context.mode === core.ConfigurationContextMode.ACCOUNT) {
670
- return true;
671
- }
672
- if (context.mode === core.ConfigurationContextMode.QUOTE) {
673
- return context.properties.Status === 'Draft';
879
+ QuoteDraftService.prototype.setCurrentLineItemState = function (lineItems) {
880
+ var quoteDraft = this.quoteSubj$.value;
881
+ if (!quoteDraft) {
882
+ return;
674
883
  }
675
- return false;
676
- };
677
- QuoteDraftService.prototype.updateActivePriceList = function (priceListId) {
678
- this.context.update({ properties: { PriceListId: priceListId } });
884
+ this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: lineItems }));
679
885
  };
680
- QuoteDraftService.prototype.populateActivePriceLists$ = function () {
681
- var _this = this;
682
- var ctx = this.context.resolve();
683
- var quoteDraft = this.quoteDraft;
886
+ QuoteDraftService.prototype.updateQuoteDraft = function (update) {
887
+ var quoteDraft = this.quoteSubj$.value;
684
888
  if (!quoteDraft) {
685
889
  return;
686
890
  }
687
- // In ACCOUNT mode populate price lists from related assets
688
- if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
689
- // Populate list of price lists
690
- this.assetPriceLists = quoteDraft.currentState
691
- .map(function (_c) {
692
- var priceListId = _c.priceListId;
693
- return priceListId;
694
- })
695
- .reduce(function (trunk, priceListId) {
696
- var _a, _b;
697
- if (!priceListId || trunk.some(function (item) { return item.id === priceListId; })) {
698
- return trunk;
699
- }
700
- return __spreadArray(__spreadArray([], __read(trunk)), [
701
- { id: priceListId, name: (_b = (_a = _this.allPriceLists.find(function (item) { return item.id === priceListId; })) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '' },
702
- ]);
703
- }, []);
704
- }
705
- };
706
- QuoteDraftService.prototype.filterByActivePriceList = function (lineItems) {
707
- var ctx = this.context.resolve();
708
- return lineItems.filter(function (li) { return !li.priceListId || li.priceListId === ctx.properties.PriceListId; });
709
- };
710
- QuoteDraftService.prototype.markAsUpdated = function (quote) {
711
- if ((quote === null || quote === void 0 ? void 0 : quote.context.properties.mode) === core.ConfigurationContextMode.ACCOUNT) {
712
- this.hasUnsavedChanges = !!quote && !quote.currentState.every(function (li) { return li.actionCode === 'EXIST'; });
713
- }
714
- else {
715
- this.hasUnsavedChanges = true;
891
+ if (update.context) {
892
+ this.context.set(update.context);
716
893
  }
894
+ this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), update));
717
895
  };
718
- return QuoteDraftService;
719
- }());
720
- QuoteDraftService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1__namespace.QuoteApiService }, { token: i1__namespace.PriceApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
721
- QuoteDraftService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, providedIn: 'root' });
722
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, decorators: [{
723
- type: i0.Injectable,
724
- args: [{ providedIn: 'root' }]
725
- }], ctorParameters: function () { return [{ type: ContextService }, { type: i1__namespace.QuoteApiService }, { type: i1__namespace.PriceApiService }]; } });
726
-
727
- var RuntimeContextService = /** @class */ (function () {
728
- function RuntimeContextService(configurationApiService) {
729
- this.configurationApiService = configurationApiService;
730
- }
731
- RuntimeContextService.prototype.getRuntimeContext = function (productId, offeringId) {
732
- var _this = this;
733
- return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(operators.map(function (runtimeData) {
734
- var _a, _b, _c;
735
- var uiDefinition = _this.getUIDefinition(runtimeData);
736
- var runtimeModel = core.RuntimeModel.create(runtimeData.types, runtimeData.products);
737
- var _d = (_a = Array.from(runtimeModel.components.values()).find(function (c) { return c.productId === productId; })) !== null && _a !== void 0 ? _a : {}, productName = _d.productName, properties = _d.properties;
738
- return {
739
- modelId: runtimeData.modelId,
740
- uiDefinition: uiDefinition,
741
- runtimeModel: runtimeModel,
742
- runtimeMode: exports.RuntimeMode.PROD,
743
- productId: productId,
744
- productType: (properties === null || properties === void 0 ? void 0 : properties.displayName) || productName,
745
- offeringId: offeringId,
746
- properties: {
747
- PricingEnabled: ((_b = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.properties) === null || _b === void 0 ? void 0 : _b.pricingEnabled) ? 'true' : 'false',
748
- PriceListId: (_c = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.properties) === null || _c === void 0 ? void 0 : _c.priceList,
749
- },
750
- };
751
- }));
752
- };
753
- RuntimeContextService.prototype.getUIDefinition = function (runtimeData) {
754
- var _a;
755
- var rawUiDefinitions;
756
- try {
757
- rawUiDefinitions = JSON.parse(runtimeData.uiDefinitionsSource);
758
- }
759
- catch (e) {
896
+ QuoteDraftService.prototype.updateByPriceSummary = function (priceSummary) {
897
+ var quoteDraft = this.quoteSubj$.value;
898
+ if (!quoteDraft) {
760
899
  return;
761
900
  }
762
- var uiDefinitions = rawUiDefinitions.filter(function (uiDef) { return uiDef.version; });
763
- var uiDefinition = (_a = uiDefinitions.find(function (uiDef) { return uiDef.primary; })) !== null && _a !== void 0 ? _a : uiDefinitions[0];
764
- return uiDefinition;
765
- };
766
- return RuntimeContextService;
767
- }());
768
- RuntimeContextService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: RuntimeContextService, deps: [{ token: i1__namespace.ConfigurationApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
769
- RuntimeContextService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: RuntimeContextService });
770
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: RuntimeContextService, decorators: [{
771
- type: i0.Injectable
772
- }], ctorParameters: function () { return [{ type: i1__namespace.ConfigurationApiService }]; } });
773
-
774
- var ConfigurationRuntimeService = /** @class */ (function () {
775
- function ConfigurationRuntimeService(apiService, contextService, runtimeContextService) {
776
- this.apiService = apiService;
777
- this.contextService = contextService;
778
- this.runtimeContextService = runtimeContextService;
779
- this._isInitialized = false;
780
- this.uiDefinitionProperties = {};
781
- }
782
- ConfigurationRuntimeService.prototype.reset = function () {
783
- this._isInitialized = false;
784
- this._runtimeContext = undefined;
785
- this._assets = undefined;
786
- this.initializationProps = undefined;
787
- this.uiDefinitionProperties = {};
788
- };
789
- ConfigurationRuntimeService.prototype.initTestMode = function (modelId, uiDefinition) {
790
- var _this = this;
791
- var _a, _b;
792
- this.uiDefinitionProperties = (_a = uiDefinition.properties) !== null && _a !== void 0 ? _a : {};
793
- var uiDefinitionExternals = (_b = uiDefinition.externals) !== null && _b !== void 0 ? _b : {};
794
- return rxjs.combineLatest([
795
- this.apiService.getRuntimeDataByModelId(modelId),
796
- this.contextService.create('TestId', core.ConfigurationContextMode.TEST),
797
- ]).pipe(operators.first(), operators.tap(function (_e) {
798
- var _f = __read(_e, 2), runtimeData = _f[0], context = _f[1];
799
- var _a;
800
- _this._runtimeContext = {
801
- modelId: modelId,
802
- runtimeModel: core.RuntimeModel.create(runtimeData.types, runtimeData.products),
803
- runtimeMode: exports.RuntimeMode.TEST,
804
- };
805
- _this.contextService.update({
806
- properties: Object.assign(Object.assign(Object.assign(Object.assign({}, (_a = _this.runtimeContext) === null || _a === void 0 ? void 0 : _a.properties), context.properties), { ModelId: modelId, RuntimeMode: core.ConfigurationContextMode.TEST, PricingEnabled: _this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false', StartDate: new Date().toISOString().substring(0, 10), PriceListId: _this.uiDefinitionProperties.priceList, standalone: 'true' }), uiDefinitionExternals),
807
- });
808
- _this._isInitialized = true;
809
- }));
901
+ var updatedCurrentState = this.currentState.map(function (lineItem) {
902
+ var updated = priceSummary.lineItems.find(function (li) { return li.id === lineItem.id; });
903
+ return updated !== null && updated !== void 0 ? updated : lineItem;
904
+ });
905
+ this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedCurrentState, totalPrices: priceSummary.totalPrices, approvalItems: priceSummary.approvalItems }));
810
906
  };
811
- ConfigurationRuntimeService.prototype.init = function (props) {
812
- var _this = this;
813
- this.initializationProps = props;
814
- this._assets = props.assets;
815
- var context = this.contextService.resolve();
816
- return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(operators.tap(function (runtimeContext) {
817
- var _a, _b, _c, _d;
818
- _this.uiDefinitionProperties = (_b = (_a = runtimeContext.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) !== null && _b !== void 0 ? _b : {};
819
- var PriceListId = ((_c = context.properties) !== null && _c !== void 0 ? _c : {}).PriceListId;
820
- var mergeContext = Object.assign(Object.assign({}, runtimeContext), { properties: Object.assign(Object.assign(Object.assign({}, runtimeContext.properties), context.properties), { PricingEnabled: PriceListId ? 'true' : 'false' }) });
821
- _this.id15to18('AccountId', mergeContext.properties);
822
- _this._runtimeContext = mergeContext;
823
- if (context.properties && ((_d = _this._runtimeContext.properties) === null || _d === void 0 ? void 0 : _d.StartDate)) {
824
- _this.contextService.update({
825
- properties: Object.assign(Object.assign({}, _this._runtimeContext.properties), context.properties),
826
- });
907
+ Object.defineProperty(QuoteDraftService.prototype, "quoteDraft$", {
908
+ get: function () {
909
+ var _this = this;
910
+ return rxjs.combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(operators.map(function () { return _this.quoteDraft; }), operators.filter(function (quote) { return Boolean(quote); }), operators.shareReplay());
911
+ },
912
+ enumerable: false,
913
+ configurable: true
914
+ });
915
+ Object.defineProperty(QuoteDraftService.prototype, "quoteDraft", {
916
+ get: function () {
917
+ var quote = this.quoteSubj$.value;
918
+ if (!quote) {
919
+ return null;
827
920
  }
828
- _this._isInitialized = true;
829
- }));
830
- };
831
- ConfigurationRuntimeService.prototype.id15to18 = function (propertyName, source) {
832
- if (!source) {
833
- return;
834
- }
835
- var value = source[propertyName];
836
- if (typeof value === 'string' && value.length === 15) {
837
- source[propertyName] = core.SalesforceIdUtils.generateId18FromId15(value);
838
- }
839
- };
840
- ConfigurationRuntimeService.prototype.getAsset = function (lineItem) {
841
- return this._assets && this._assets.find(function (a) { return a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId; });
842
- };
843
- Object.defineProperty(ConfigurationRuntimeService.prototype, "isInitialized", {
921
+ return Object.assign(Object.assign({}, quote), { context: this.context.resolve() });
922
+ },
923
+ enumerable: false,
924
+ configurable: true
925
+ });
926
+ Object.defineProperty(QuoteDraftService.prototype, "quoteDraftForActivePriceList", {
844
927
  get: function () {
845
- return this._isInitialized;
928
+ var quoteDraft = this.quoteDraft;
929
+ if (!quoteDraft) {
930
+ return null;
931
+ }
932
+ return Object.assign(Object.assign({}, quoteDraft), { initialState: this.filterByActivePriceList(quoteDraft.initialState), currentState: this.filterByActivePriceList(quoteDraft.currentState) });
846
933
  },
847
934
  enumerable: false,
848
935
  configurable: true
849
936
  });
850
- Object.defineProperty(ConfigurationRuntimeService.prototype, "runtimeModel", {
937
+ Object.defineProperty(QuoteDraftService.prototype, "currentState$", {
851
938
  get: function () {
852
- var _a;
853
- return (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.runtimeModel;
939
+ return this.quoteDraft$.pipe(operators.map(function (quote) { return quote.currentState; }));
854
940
  },
855
941
  enumerable: false,
856
942
  configurable: true
857
943
  });
858
- Object.defineProperty(ConfigurationRuntimeService.prototype, "runtimeContext", {
944
+ Object.defineProperty(QuoteDraftService.prototype, "currentState", {
859
945
  get: function () {
860
- return this._runtimeContext;
946
+ var _a, _b;
947
+ return (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
861
948
  },
862
949
  enumerable: false,
863
950
  configurable: true
864
951
  });
865
- return ConfigurationRuntimeService;
866
- }());
867
- ConfigurationRuntimeService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationRuntimeService, deps: [{ token: i1__namespace.ConfigurationApiService }, { token: ContextService }, { token: RuntimeContextService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
868
- ConfigurationRuntimeService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationRuntimeService });
869
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationRuntimeService, decorators: [{
870
- type: i0.Injectable
871
- }], ctorParameters: function () { return [{ type: i1__namespace.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
872
-
873
- var findLineItem = function (id, lineItems) {
874
- return findLineItemWithComparator(lineItems, function (li) { return li.id === id; });
875
- };
876
- var findLineItemWithComparator = function (lineItems, comparator) {
877
- var currentLevel = lineItems;
878
- while (currentLevel.length) {
879
- var found = currentLevel.find(comparator);
880
- if (found) {
881
- return found;
882
- }
883
- currentLevel = lodash.flatten(currentLevel.map(function (parent) { return parent.lineItems; }));
884
- }
885
- return;
886
- };
887
- var insertLineItem = function (lineItem, parentId, toInsert) {
888
- var insertData = lineItem.id === parentId ? [toInsert] : [];
889
- return Object.assign(Object.assign({}, lineItem), { lineItems: __spreadArray(__spreadArray([], __read(insertData)), __read(lineItem.lineItems.map(function (li) {
890
- return insertLineItem(li, parentId, toInsert);
891
- }))) });
892
- };
893
- var removeLineItem = function (lineItem, idToRemove) {
894
- return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems
895
- .map(function (li) {
896
- if (li.id === idToRemove) {
897
- return;
898
- }
899
- else if (li.lineItems.length) {
900
- return removeLineItem(li, idToRemove);
901
- }
902
- return li;
903
- })
904
- .filter(function (r) { return !!r; }) });
905
- };
906
- var replaceLineItem = function (lineItem, replaceTo) {
907
- if (lineItem.id === replaceTo.id) {
908
- return Object.assign({}, replaceTo);
909
- }
910
- return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(function (li) {
911
- if (li.id === replaceTo.id) {
912
- return replaceTo;
913
- }
914
- else if (li.lineItems.length) {
915
- return replaceLineItem(li, replaceTo);
952
+ Object.defineProperty(QuoteDraftService.prototype, "activeCurrentState$", {
953
+ /**
954
+ * Stream of activeCurrentState
955
+ */
956
+ get: function () {
957
+ var _this = this;
958
+ return this.quoteDraft$.pipe(operators.map(function () { return _this.activeCurrentState; }));
959
+ },
960
+ enumerable: false,
961
+ configurable: true
962
+ });
963
+ Object.defineProperty(QuoteDraftService.prototype, "activeCurrentState", {
964
+ /**
965
+ * activeCurrentState is currentState passed through additional filters
966
+ */
967
+ get: function () {
968
+ var _a, _b;
969
+ var currentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
970
+ currentState = this.filterByActivePriceList(currentState);
971
+ return currentState;
972
+ },
973
+ enumerable: false,
974
+ configurable: true
975
+ });
976
+ Object.defineProperty(QuoteDraftService.prototype, "activeInitialState$", {
977
+ /**
978
+ * Stream of activeInitialState
979
+ */
980
+ get: function () {
981
+ var _this = this;
982
+ return this.quoteDraft$.pipe(operators.map(function () { return _this.activeInitialState; }));
983
+ },
984
+ enumerable: false,
985
+ configurable: true
986
+ });
987
+ Object.defineProperty(QuoteDraftService.prototype, "activeInitialState", {
988
+ /**
989
+ * activeInitialState is initialState passed through additional filters
990
+ */
991
+ get: function () {
992
+ var _a, _b;
993
+ var ctx = this.context.resolve();
994
+ var initialState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState) !== null && _b !== void 0 ? _b : [];
995
+ if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
996
+ initialState = this.filterByActivePriceList(initialState);
916
997
  }
917
- return li;
918
- }) });
919
- };
920
- var mapAttributes = function (attributes) {
921
- return attributes.reduce(function (acc, _c) {
922
- var _d;
923
- var name = _c.name, value = _c.value;
924
- return (Object.assign(Object.assign({}, acc), (_d = {}, _d[name] = value, _d)));
925
- }, {});
926
- };
927
- var getAttributes = function (attributes, names) {
928
- if (names === void 0) { names = []; }
929
- var filtered = attributes.filter(function (_c) {
930
- var name = _c.name;
931
- return names.includes(name);
998
+ return initialState;
999
+ },
1000
+ enumerable: false,
1001
+ configurable: true
932
1002
  });
933
- return lodash.sortBy(filtered, [function (_c) {
934
- var name = _c.name;
935
- return names.indexOf(name);
936
- }]);
937
- };
938
- var upsertAttributes = function (originalAttributes, attributesToUpsert) {
939
- return attributesToUpsert.reduce(function (acc, _c) {
940
- var name = _c.name, value = _c.value;
941
- var _d = __read(getAttributes(acc, [name]), 1), origAttr = _d[0];
942
- return __spreadArray(__spreadArray([], __read(acc.filter(function (attr) { return attr.name !== name; }))), [
943
- Object.assign(Object.assign({}, (origAttr !== null && origAttr !== void 0 ? origAttr : { name: name })), { cfgStatus: 'User', value: value }),
944
- ]);
945
- }, originalAttributes);
946
- };
947
- var patchAttributes = function (rootLineItem, id, attrs) {
948
- var lineItem = findLineItem(id, [rootLineItem]);
949
- if (!lineItem) {
950
- return rootLineItem;
951
- }
952
- var attributes = upsertAttributes(lineItem.attributes, attrs);
953
- return replaceLineItem(rootLineItem, Object.assign(Object.assign({}, lineItem), { attributes: attributes }));
954
- };
955
- var getAttributeValue = function (attributes, name) { var _a; return (_a = attributes.find(function (attr) { return attr.name === name; })) === null || _a === void 0 ? void 0 : _a.value; };
956
- var generateLineItem = function (port, type, parentId, attributes, lineItems) {
957
- if (attributes === void 0) { attributes = []; }
958
- if (lineItems === void 0) { lineItems = []; }
959
- return {
960
- id: core.UUID.UUID(),
961
- port: port,
962
- type: type,
963
- actionCode: 'ADD',
964
- cfgStatus: 'New',
965
- attributes: attributes.map(function (_c) {
966
- var name = _c.name, value = _c.value;
967
- return ({ cfgStatus: 'User', name: name, value: value });
968
- }),
969
- lineItems: lineItems,
970
- parentId: parentId,
971
- qty: 1,
972
- };
973
- };
974
- var getRecommendedPrices = function (portDomain, type) {
975
- var _a, _b;
976
- var domainType = portDomain.domainTypes.find(function (_c) {
977
- var name = _c.name;
978
- return name === type;
1003
+ Object.defineProperty(QuoteDraftService.prototype, "isStandalone", {
1004
+ get: function () {
1005
+ return this.context.resolve().properties.standalone === 'true';
1006
+ },
1007
+ enumerable: false,
1008
+ configurable: true
979
1009
  });
980
- var _c = __read((_b = (_a = domainType === null || domainType === void 0 ? void 0 : domainType.recommendedPrices) === null || _a === void 0 ? void 0 : _a.filter(function (_c) {
981
- var chargeMethod = _c.chargeMethod;
982
- return chargeMethod === 'ONE_TIME';
983
- }).reduce(function (acc, rp) {
984
- var _c = __read(acc, 2), netPrice = _c[0], listPrice = _c[1];
985
- return [netPrice + rp.netPrice, listPrice + rp.listPrice];
986
- }, [0, 0])) !== null && _b !== void 0 ? _b : [0, 0], 2), net = _c[0], list = _c[1];
987
- return { net: net, list: list };
988
- };
989
-
990
- var lineItem_utils = /*#__PURE__*/Object.freeze({
991
- __proto__: null,
992
- findLineItem: findLineItem,
993
- findLineItemWithComparator: findLineItemWithComparator,
994
- insertLineItem: insertLineItem,
995
- removeLineItem: removeLineItem,
996
- replaceLineItem: replaceLineItem,
997
- mapAttributes: mapAttributes,
998
- getAttributes: getAttributes,
999
- upsertAttributes: upsertAttributes,
1000
- patchAttributes: patchAttributes,
1001
- getAttributeValue: getAttributeValue,
1002
- generateLineItem: generateLineItem,
1003
- getRecommendedPrices: getRecommendedPrices
1004
- });
1005
-
1006
- var LineItemWorker = /** @class */ (function () {
1007
- function LineItemWorker(src) {
1008
- this.li = Object.assign({}, src);
1009
- }
1010
- LineItemWorker.prototype.insert = function (parentId, toInsert) {
1011
- return new LineItemWorker(insertLineItem(this.li, parentId, toInsert));
1010
+ Object.defineProperty(QuoteDraftService.prototype, "isStandalone$", {
1011
+ get: function () {
1012
+ var _this = this;
1013
+ return this.context.resolve$().pipe(operators.map(function () { return _this.isStandalone; }));
1014
+ },
1015
+ enumerable: false,
1016
+ configurable: true
1017
+ });
1018
+ QuoteDraftService.prototype.getInitialCurrentState = function () {
1019
+ return this.initialCurrentState;
1012
1020
  };
1013
- LineItemWorker.prototype.remove = function (id) {
1014
- return new LineItemWorker(removeLineItem(this.li, id));
1021
+ QuoteDraftService.prototype.isEditMode$ = function () {
1022
+ var _this = this;
1023
+ return this.context.resolve$().pipe(operators.map(function () { return _this.isEditMode(); }));
1015
1024
  };
1016
- LineItemWorker.prototype.replace = function (toReplace) {
1017
- return new LineItemWorker(replaceLineItem(this.li, toReplace));
1025
+ QuoteDraftService.prototype.isEditMode = function () {
1026
+ var context = this.context.resolve();
1027
+ if (context.mode === core.ConfigurationContextMode.ACCOUNT) {
1028
+ return true;
1029
+ }
1030
+ if (context.mode === core.ConfigurationContextMode.QUOTE) {
1031
+ return context.properties.Status === 'Draft';
1032
+ }
1033
+ return false;
1018
1034
  };
1019
- LineItemWorker.prototype.patchAttribute = function (attrs, id) {
1020
- return new LineItemWorker(patchAttributes(this.li, id !== null && id !== void 0 ? id : this.li.id, attrs));
1035
+ QuoteDraftService.prototype.updateActivePriceList = function (priceListId) {
1036
+ this.context.update({ properties: { PriceListId: priceListId } });
1021
1037
  };
1022
- return LineItemWorker;
1038
+ QuoteDraftService.prototype.populateActivePriceLists$ = function () {
1039
+ var _this = this;
1040
+ var ctx = this.context.resolve();
1041
+ var quoteDraft = this.quoteDraft;
1042
+ if (!quoteDraft) {
1043
+ return;
1044
+ }
1045
+ // In ACCOUNT mode populate price lists from related assets
1046
+ if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
1047
+ // Populate list of price lists
1048
+ this.assetPriceLists = quoteDraft.currentState
1049
+ .map(function (_c) {
1050
+ var priceListId = _c.priceListId;
1051
+ return priceListId;
1052
+ })
1053
+ .reduce(function (trunk, priceListId) {
1054
+ var _a, _b;
1055
+ if (!priceListId || trunk.some(function (item) { return item.id === priceListId; })) {
1056
+ return trunk;
1057
+ }
1058
+ return __spreadArray(__spreadArray([], __read(trunk)), [
1059
+ { id: priceListId, name: (_b = (_a = _this.allPriceLists.find(function (item) { return item.id === priceListId; })) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '' },
1060
+ ]);
1061
+ }, []);
1062
+ }
1063
+ };
1064
+ QuoteDraftService.prototype.filterByActivePriceList = function (lineItems) {
1065
+ var ctx = this.context.resolve();
1066
+ return lineItems.filter(function (li) { return !li.priceListId || li.priceListId === ctx.properties.PriceListId; });
1067
+ };
1068
+ QuoteDraftService.prototype.markAsUpdated = function (quote) {
1069
+ if ((quote === null || quote === void 0 ? void 0 : quote.context.properties.mode) === core.ConfigurationContextMode.ACCOUNT) {
1070
+ this.hasUnsavedChanges = !!quote && !quote.currentState.every(function (li) { return li.actionCode === 'EXIST'; });
1071
+ }
1072
+ else {
1073
+ this.hasUnsavedChanges = !lodash.isEqual(this.initialCurrentState, quote === null || quote === void 0 ? void 0 : quote.currentState);
1074
+ }
1075
+ };
1076
+ return QuoteDraftService;
1023
1077
  }());
1078
+ QuoteDraftService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1__namespace.QuoteApiService }, { token: i1__namespace.PriceApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1079
+ QuoteDraftService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: QuoteDraftService, providedIn: 'root' });
1080
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: QuoteDraftService, decorators: [{
1081
+ type: i0.Injectable,
1082
+ args: [{ providedIn: 'root' }]
1083
+ }], ctorParameters: function () { return [{ type: ContextService }, { type: i1__namespace.QuoteApiService }, { type: i1__namespace.PriceApiService }]; } });
1024
1084
 
1025
1085
  var ConfigurationService = /** @class */ (function () {
1026
1086
  function ConfigurationService(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService) {
@@ -1205,11 +1265,11 @@
1205
1265
  };
1206
1266
  return ConfigurationService;
1207
1267
  }());
1208
- ConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1__namespace.ConfigurationApiService }, { token: i4__namespace.MessageService }, { token: i5__namespace.DialogService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1209
- ConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationService });
1210
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationService, decorators: [{
1268
+ ConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1__namespace.ConfigurationApiService }, { token: i5__namespace.MessageService }, { token: i6__namespace.DialogService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1269
+ ConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationService });
1270
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationService, decorators: [{
1211
1271
  type: i0.Injectable
1212
- }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1__namespace.ConfigurationApiService }, { type: i4__namespace.MessageService }, { type: i5__namespace.DialogService }]; } });
1272
+ }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1__namespace.ConfigurationApiService }, { type: i5__namespace.MessageService }, { type: i6__namespace.DialogService }]; } });
1213
1273
 
1214
1274
  var FlowUpdateService = /** @class */ (function () {
1215
1275
  function FlowUpdateService() {
@@ -1335,9 +1395,9 @@
1335
1395
  };
1336
1396
  return FlowUpdateService;
1337
1397
  }());
1338
- FlowUpdateService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowUpdateService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1339
- FlowUpdateService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowUpdateService });
1340
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowUpdateService, decorators: [{
1398
+ FlowUpdateService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowUpdateService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1399
+ FlowUpdateService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowUpdateService });
1400
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowUpdateService, decorators: [{
1341
1401
  type: i0.Injectable
1342
1402
  }] });
1343
1403
 
@@ -1431,7 +1491,13 @@
1431
1491
  if (!quoteDraft) {
1432
1492
  return rxjs.of(null);
1433
1493
  }
1434
- return this.configurationService.configureExternal$(productId, qty).pipe(rxjs.map(function (lineItem) { return __spreadArray(__spreadArray([], __read(quoteDraft.currentState)), [lineItem]); }), rxjs.switchMap(function (updatedState) { return _this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState })); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack());
1494
+ return this.configurationService.configureExternal$(productId, qty).pipe(rxjs.map(function (lineItem) {
1495
+ var _a, _b;
1496
+ var model = _this.configurationService.getRuntimeModel();
1497
+ var split = (_b = (_a = model === null || model === void 0 ? void 0 : model.types.find(function (type) { return type.name === lineItem.type; })) === null || _a === void 0 ? void 0 : _a.split) !== null && _b !== void 0 ? _b : false;
1498
+ var lineItems = multiplyLineItems(lineItem, qty !== null && qty !== void 0 ? qty : 1, split);
1499
+ return __spreadArray(__spreadArray([], __read(quoteDraft.currentState)), __read(lineItems));
1500
+ }), rxjs.switchMap(function (updatedState) { return _this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState })); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack());
1435
1501
  };
1436
1502
  FlowConfigurationService.prototype.get = function () {
1437
1503
  var _this = this;
@@ -1507,9 +1573,9 @@
1507
1573
  };
1508
1574
  return FlowConfigurationService;
1509
1575
  }());
1510
- FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, deps: [{ token: i1__namespace.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1511
- FlowConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService });
1512
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, decorators: [{
1576
+ FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationService, deps: [{ token: i1__namespace.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1577
+ FlowConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationService });
1578
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationService, decorators: [{
1513
1579
  type: i0.Injectable
1514
1580
  }], ctorParameters: function () { return [{ type: i1__namespace.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1515
1581
 
@@ -1518,10 +1584,10 @@
1518
1584
  }
1519
1585
  return FlowConfigurationModule;
1520
1586
  }());
1521
- FlowConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1522
- FlowConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationModule });
1523
- FlowConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, i1.PriceApiService], imports: [[]] });
1524
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationModule, decorators: [{
1587
+ FlowConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1588
+ FlowConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule });
1589
+ FlowConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, i1.PriceApiService], imports: [[]] });
1590
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule, decorators: [{
1525
1591
  type: i0.NgModule,
1526
1592
  args: [{
1527
1593
  imports: [],
@@ -1534,9 +1600,9 @@
1534
1600
  }
1535
1601
  return ConfigurationModule;
1536
1602
  }());
1537
- ConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1538
- ConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationModule, imports: [components.ConfirmationDialogModule] });
1539
- ConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationModule, providers: [
1603
+ ConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1604
+ ConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, imports: [components.ConfirmationDialogModule] });
1605
+ ConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, providers: [
1540
1606
  i1.ContextApiService,
1541
1607
  i1.ProductModelApiService,
1542
1608
  i1.ConfigurationApiService,
@@ -1544,7 +1610,7 @@
1544
1610
  RuntimeContextService,
1545
1611
  ConfigurationService,
1546
1612
  ], imports: [[components.ConfirmationDialogModule]] });
1547
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationModule, decorators: [{
1613
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, decorators: [{
1548
1614
  type: i0.NgModule,
1549
1615
  args: [{
1550
1616
  imports: [components.ConfirmationDialogModule],
@@ -1559,19 +1625,173 @@
1559
1625
  }]
1560
1626
  }] });
1561
1627
 
1628
+ function calculateMetricByMethod(lineItems, metric, method) {
1629
+ var items = getLineItemsByMethod(lineItems, method);
1630
+ return items.reduce(function (acc, li) {
1631
+ var value = li.reduce(function (accProduct, item) { return accProduct + ((item.totalMetrics && item.totalMetrics[metric]) || 0); }, 0);
1632
+ if (method === 'avg' && li.length > 0) {
1633
+ value /= li.length;
1634
+ }
1635
+ return acc + value;
1636
+ }, 0);
1637
+ }
1638
+ function getLineItemsByMethod(lineItems, method) {
1639
+ switch (method) {
1640
+ case 'first': {
1641
+ return lineItems.filter(function (li) { return !li.rampInstanceId; }).map(function (item) { return [item]; });
1642
+ }
1643
+ case 'last': {
1644
+ var rootTermItems = lineItems.filter(function (li) { return !li.rampInstanceId; });
1645
+ var products = rootTermItems.map(function (lineItem) { return __spreadArray([
1646
+ lineItem
1647
+ ], __read(lineItems.filter(function (li) { return li.rampInstanceId === lineItem.id; }))); });
1648
+ return products
1649
+ .map(function (items) { return __spreadArray([], __read(items)).sort(function (a, b) { return getDateValue(a.endDate || '') - getDateValue(b.endDate || ''); }).pop(); })
1650
+ .filter(function (li) { return Boolean(li); })
1651
+ .map(function (item) { return [item]; });
1652
+ }
1653
+ case 'avg': {
1654
+ var rootTermItems = lineItems.filter(function (li) { return !li.rampInstanceId; });
1655
+ return rootTermItems.map(function (lineItem) { return __spreadArray([lineItem], __read(lineItems.filter(function (li) { return li.rampInstanceId === lineItem.id; }))); });
1656
+ }
1657
+ case 'sum': {
1658
+ return lineItems.map(function (item) { return [item]; });
1659
+ }
1660
+ default: {
1661
+ return lineItems.map(function (item) { return [item]; });
1662
+ }
1663
+ }
1664
+ }
1665
+ function getDateValue(date) {
1666
+ return date ? new Date(date).getTime() : 0;
1667
+ }
1668
+
1669
+ var MetricsCalculationService = /** @class */ (function () {
1670
+ function MetricsCalculationService(quoteDraftService, settingsService) {
1671
+ var _this = this;
1672
+ this.quoteDraftService = quoteDraftService;
1673
+ this.settingsService = settingsService;
1674
+ this.metricsUpdated$ = new rxjs.Subject();
1675
+ this.quoteMetricsSettings = {};
1676
+ this.metricsCalculationMethodMap = {};
1677
+ this.metricsData = {};
1678
+ rxjs.combineLatest([
1679
+ this.quoteDraftService.currentState$,
1680
+ this.settingsService.fetchSetting('QUOTE_LEVEL_METRIC_CALCULATION_METHOD').pipe(rxjs.take(1)),
1681
+ ]).subscribe(function (_a) {
1682
+ var _b = __read(_a, 2), lineItems = _b[0], setting = _b[1];
1683
+ var settingsData = {};
1684
+ try {
1685
+ settingsData = JSON.parse((setting === null || setting === void 0 ? void 0 : setting.value) || '{}');
1686
+ }
1687
+ catch (error) {
1688
+ settingsData = {};
1689
+ }
1690
+ _this.quoteMetricsSettings = settingsData;
1691
+ _this.updateMetrics(lineItems);
1692
+ });
1693
+ }
1694
+ Object.defineProperty(MetricsCalculationService.prototype, "onMetricsUpdate$", {
1695
+ get: function () {
1696
+ return this.metricsUpdated$.asObservable();
1697
+ },
1698
+ enumerable: false,
1699
+ configurable: true
1700
+ });
1701
+ MetricsCalculationService.prototype.getMetricValue = function (metric) {
1702
+ return this.metricsData[metric] || 0;
1703
+ };
1704
+ MetricsCalculationService.prototype.updateMetrics = function (lineItems) {
1705
+ var _this = this;
1706
+ var metricKeys = this.collectMetricKeys(lineItems).filter(function (key) { return !key.includes('Effective_'); });
1707
+ this.metricsCalculationMethodMap = this.buildMetricsCalculationMethods(metricKeys, this.metricsCalculationMethodMap);
1708
+ this.metricsData = metricKeys.reduce(function (acc, key) {
1709
+ var _a;
1710
+ return (Object.assign(Object.assign({}, acc), (_a = {}, _a[key] = _this.calculateMetric(lineItems, key), _a)));
1711
+ }, {});
1712
+ this.metricsUpdated$.next();
1713
+ };
1714
+ MetricsCalculationService.prototype.calculateMetric = function (lineItems, metric) {
1715
+ return calculateMetricByMethod(lineItems, metric, this.metricsCalculationMethodMap[metric] || 'sum');
1716
+ };
1717
+ MetricsCalculationService.prototype.buildMetricsCalculationMethods = function (metricKeys, initial) {
1718
+ var _this = this;
1719
+ return metricKeys.reduce(function (acc, name) {
1720
+ var _a, _b;
1721
+ if (acc[name]) {
1722
+ return acc;
1723
+ }
1724
+ acc = Object.assign(Object.assign({}, acc), (_a = {}, _a[name] = 'sum', _a));
1725
+ var settingKey = name.replace(/VDM_|Total_/g, '');
1726
+ if (_this.quoteMetricsSettings[settingKey]) {
1727
+ acc = Object.assign(Object.assign({}, acc), (_b = {}, _b[name] = _this.quoteMetricsSettings[settingKey], _b));
1728
+ }
1729
+ return acc;
1730
+ }, initial);
1731
+ };
1732
+ MetricsCalculationService.prototype.collectMetricKeys = function (lineItems) {
1733
+ var _this = this;
1734
+ var keys = [];
1735
+ lineItems.forEach(function (lineItem) {
1736
+ keys.push.apply(keys, __spreadArray([], __read(Object.keys(lineItem.totalMetrics || {}))));
1737
+ keys.push.apply(keys, __spreadArray([], __read(_this.collectMetricKeys(lineItem.lineItems))));
1738
+ });
1739
+ return lodash.uniq(keys);
1740
+ };
1741
+ return MetricsCalculationService;
1742
+ }());
1743
+ MetricsCalculationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MetricsCalculationService, deps: [{ token: QuoteDraftService }, { token: i1__namespace.ConfigurationSettingsApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1744
+ MetricsCalculationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MetricsCalculationService, providedIn: 'root' });
1745
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MetricsCalculationService, decorators: [{
1746
+ type: i0.Injectable,
1747
+ args: [{ providedIn: 'root' }]
1748
+ }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: i1__namespace.ConfigurationSettingsApiService }]; } });
1749
+
1750
+ var ProductImagesService = /** @class */ (function () {
1751
+ function ProductImagesService(productApiService) {
1752
+ this.productApiService = productApiService;
1753
+ this.imagesMap$ = new rxjs.BehaviorSubject({});
1754
+ }
1755
+ ProductImagesService.prototype.getImageUrl$ = function (productId) {
1756
+ var _a;
1757
+ if (this.imagesMap$.value[productId] == null) {
1758
+ this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), (_a = {}, _a[productId] = '', _a)));
1759
+ this.fetchProductImage(productId);
1760
+ }
1761
+ return this.imagesMap$.pipe(rxjs.map(function (imagesMap) { return imagesMap[productId]; }), rxjs.distinctUntilChanged());
1762
+ };
1763
+ ProductImagesService.prototype.fetchProductImage = function (productId) {
1764
+ var _this = this;
1765
+ this.productApiService
1766
+ .fetchImage$(productId)
1767
+ .pipe(rxjs.map(function (file) { return URL.createObjectURL(file); }), rxjs.catchError(function () { return rxjs.of(''); }), rxjs.tap(function (url) {
1768
+ var _a;
1769
+ return _this.imagesMap$.next(Object.assign(Object.assign({}, _this.imagesMap$.value), (_a = {}, _a[productId] = url, _a)));
1770
+ }))
1771
+ .subscribe();
1772
+ };
1773
+ return ProductImagesService;
1774
+ }());
1775
+ ProductImagesService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ProductImagesService, deps: [{ token: i1__namespace.ProductApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1776
+ ProductImagesService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ProductImagesService, providedIn: 'root' });
1777
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ProductImagesService, decorators: [{
1778
+ type: i0.Injectable,
1779
+ args: [{ providedIn: 'root' }]
1780
+ }], ctorParameters: function () { return [{ type: i1__namespace.ProductApiService }]; } });
1781
+
1562
1782
  var SdkCoreModule = /** @class */ (function () {
1563
1783
  function SdkCoreModule() {
1564
1784
  }
1565
1785
  return SdkCoreModule;
1566
1786
  }());
1567
- SdkCoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SdkCoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1568
- SdkCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
1569
- SdkCoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SdkCoreModule, providers: [ContextService, QuoteDraftService, ProductImagesService], imports: [[ConfigurationModule, FlowConfigurationModule]] });
1570
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SdkCoreModule, decorators: [{
1787
+ SdkCoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SdkCoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1788
+ SdkCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
1789
+ SdkCoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SdkCoreModule, providers: [ContextService, QuoteDraftService, ProductImagesService, MetricsCalculationService], imports: [[ConfigurationModule, FlowConfigurationModule]] });
1790
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SdkCoreModule, decorators: [{
1571
1791
  type: i0.NgModule,
1572
1792
  args: [{
1573
1793
  imports: [ConfigurationModule, FlowConfigurationModule],
1574
- providers: [ContextService, QuoteDraftService, ProductImagesService],
1794
+ providers: [ContextService, QuoteDraftService, ProductImagesService, MetricsCalculationService],
1575
1795
  }]
1576
1796
  }] });
1577
1797
 
@@ -1586,6 +1806,7 @@
1586
1806
  exports.FlowConfigurationService = FlowConfigurationService;
1587
1807
  exports.FlowUpdateService = FlowUpdateService;
1588
1808
  exports.LineItemWorker = LineItemWorker;
1809
+ exports.MetricsCalculationService = MetricsCalculationService;
1589
1810
  exports.ProductImagesService = ProductImagesService;
1590
1811
  exports.QuoteDraftService = QuoteDraftService;
1591
1812
  exports.SdkCoreModule = SdkCoreModule;
@@ -1599,6 +1820,7 @@
1599
1820
  exports.insertLineItem = insertLineItem;
1600
1821
  exports.lineItemUtils = lineItem_utils;
1601
1822
  exports.mapAttributes = mapAttributes;
1823
+ exports.multiplyLineItems = multiplyLineItems;
1602
1824
  exports.patchAttributes = patchAttributes;
1603
1825
  exports.removeLineItem = removeLineItem;
1604
1826
  exports.replaceLineItem = replaceLineItem;
@@ -1607,4 +1829,4 @@
1607
1829
  Object.defineProperty(exports, '__esModule', { value: true });
1608
1830
 
1609
1831
  }));
1610
- //# sourceMappingURL=veloce-sdk-core.umd.js.map
1832
+ //# sourceMappingURL=veloceapps-sdk-core.umd.js.map