@veloceapps/sdk 12.0.0-17 → 12.0.0-19

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 (348) hide show
  1. package/cms/cms.actions.d.ts +154 -0
  2. package/cms/cms.default.d.ts +5 -0
  3. package/cms/cms.elements.d.ts +4 -0
  4. package/cms/cms.layouts.d.ts +4 -0
  5. package/cms/components/element-children/element-children.component.d.ts +22 -0
  6. package/cms/components/element-children/element-children.module.d.ts +11 -0
  7. package/cms/components/element-drop-handle/element-drop-handle.component.d.ts +12 -0
  8. package/cms/components/element-drop-handle/element-drop-handle.module.d.ts +9 -0
  9. package/cms/components/element-renderer/element-renderer.component.d.ts +29 -0
  10. package/cms/components/element-renderer/element-renderer.module.d.ts +7 -0
  11. package/cms/components/element-tools-panel/element-tools-panel.component.d.ts +14 -0
  12. package/cms/components/element.component.d.ts +17 -0
  13. package/cms/components/index.d.ts +1 -0
  14. package/cms/components/plugin.component.d.ts +15 -0
  15. package/cms/components/preview/index.d.ts +3 -0
  16. package/cms/components/preview/preview.component.d.ts +32 -0
  17. package/cms/components/preview/preview.module.d.ts +13 -0
  18. package/cms/components/preview/preview.types.d.ts +20 -0
  19. package/cms/decorators/element.decorator.d.ts +2 -0
  20. package/cms/decorators/index.d.ts +1 -0
  21. package/cms/definitions/index.d.ts +1 -0
  22. package/cms/definitions/ui-builder.definitions.d.ts +6 -0
  23. package/cms/directives/custom-template.directive.d.ts +17 -0
  24. package/cms/engine/models/entity.d.ts +11 -0
  25. package/cms/engine/models/plugin.d.ts +5 -0
  26. package/cms/index.d.ts +15 -921
  27. package/cms/injection-tokens.d.ts +9 -0
  28. package/cms/launcher.module.d.ts +12 -0
  29. package/cms/modules/federated/default-options.d.ts +4 -0
  30. package/cms/modules/federated/export.d.ts +1 -0
  31. package/cms/modules/federated/federated-host.directive.d.ts +8 -0
  32. package/cms/modules/federated/federated.component.d.ts +25 -0
  33. package/cms/modules/federated/federated.module.d.ts +10 -0
  34. package/cms/modules/federated/federated.types.d.ts +26 -0
  35. package/cms/modules/migrations/index.d.ts +2 -0
  36. package/cms/modules/migrations/migrations.d.ts +2 -0
  37. package/cms/modules/migrations/migrations.module.d.ts +6 -0
  38. package/cms/modules/migrations/services/migrations.service.d.ts +10 -0
  39. package/cms/modules/migrations/types/migrations.types.d.ts +2 -0
  40. package/cms/modules/runtime/index.d.ts +3 -0
  41. package/cms/modules/runtime/runtime.module.d.ts +8 -0
  42. package/cms/modules/runtime/services/compilation.service.d.ts +19 -0
  43. package/cms/modules/runtime/services/runtime-editor.service.d.ts +20 -0
  44. package/cms/modules/runtime/services/runtime.service.d.ts +33 -0
  45. package/cms/modules/runtime/tokens.d.ts +3 -0
  46. package/cms/modules/runtime/types/compilation.types.d.ts +8 -0
  47. package/cms/modules/runtime/types/runtime.actions.d.ts +12 -0
  48. package/cms/plugins/element-hover.plugin.d.ts +33 -0
  49. package/cms/plugins/io.plugin.d.ts +9 -0
  50. package/cms/plugins/page.plugin.d.ts +15 -0
  51. package/cms/plugins/region.plugin.d.ts +17 -0
  52. package/cms/plugins/script.plugin.d.ts +10 -0
  53. package/cms/services/element-context.service.d.ts +7 -0
  54. package/cms/services/index.d.ts +2 -0
  55. package/cms/services/io-provider.service.d.ts +15 -0
  56. package/cms/services/resources.service.d.ts +21 -0
  57. package/cms/services/templates.service.d.ts +14 -0
  58. package/cms/types/common.types.d.ts +130 -0
  59. package/cms/types/elements.types.d.ts +2 -0
  60. package/cms/types/index.d.ts +6 -0
  61. package/cms/types/layouts.types.d.ts +102 -0
  62. package/cms/types/pages.types.d.ts +1 -0
  63. package/cms/types/path.types.d.ts +11 -0
  64. package/cms/utils/element-metadata-worker.d.ts +11 -0
  65. package/cms/utils/element.utils.d.ts +20 -0
  66. package/cms/utils/elements-resolver.d.ts +28 -0
  67. package/cms/utils/encoding.utils.d.ts +2 -0
  68. package/cms/utils/index.d.ts +9 -0
  69. package/cms/utils/inject.d.ts +1 -0
  70. package/cms/utils/path.utils.d.ts +3 -0
  71. package/cms/utils/script.utils.d.ts +2 -0
  72. package/cms/utils/transpilation-worker.d.ts +13 -0
  73. package/cms/utils/ui-builder-layout.utils.d.ts +4 -0
  74. package/cms/utils/ui-definition.utils.d.ts +6 -0
  75. package/cms/vendor-map.d.ts +86 -0
  76. package/core/core.module.d.ts +10 -0
  77. package/core/directives/directives.module.d.ts +7 -0
  78. package/core/directives/index.d.ts +2 -0
  79. package/core/directives/primeng-calendar.directive.d.ts +14 -0
  80. package/core/index.d.ts +8 -525
  81. package/core/modules/configuration/configuration.module.d.ts +8 -0
  82. package/core/modules/configuration/index.d.ts +6 -0
  83. package/core/modules/configuration/services/configuration-runtime.service.d.ts +17 -0
  84. package/core/modules/configuration/services/configuration-state.service.d.ts +60 -0
  85. package/core/modules/configuration/services/configuration.service.d.ts +36 -0
  86. package/core/modules/configuration/services/guided-selling.service.d.ts +15 -0
  87. package/core/modules/configuration/services/test-mode-configuration.service.d.ts +26 -0
  88. package/core/modules/configuration/types/configuration-runtime.types.d.ts +3 -0
  89. package/core/modules/configuration/types/configuration.types.d.ts +20 -0
  90. package/core/modules/configuration/types/index.d.ts +2 -0
  91. package/core/modules/flow-configuration/flow-configuration.module.d.ts +7 -0
  92. package/core/modules/flow-configuration/index.d.ts +1 -0
  93. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +23 -0
  94. package/core/modules/index.d.ts +2 -0
  95. package/core/operators/filter-successful-execute.operator.d.ts +3 -0
  96. package/core/operators/index.d.ts +1 -0
  97. package/core/pipes/action-code.pipe.d.ts +8 -0
  98. package/core/pipes/date.pipe.d.ts +13 -0
  99. package/core/pipes/index.d.ts +5 -0
  100. package/core/pipes/number.pipe.d.ts +10 -0
  101. package/core/pipes/pipes.module.d.ts +10 -0
  102. package/core/pipes/price.pipe.d.ts +10 -0
  103. package/core/services/catalog-products.service.d.ts +11 -0
  104. package/core/services/flow-info.service.d.ts +44 -0
  105. package/core/services/flow-state-configuration.service.d.ts +25 -0
  106. package/core/services/flow-state.service.d.ts +70 -0
  107. package/core/services/index.d.ts +8 -0
  108. package/core/services/integration.state.d.ts +16 -0
  109. package/core/services/product-images.service.d.ts +12 -0
  110. package/core/services/runtime-settings.service.d.ts +24 -0
  111. package/core/services/sales-transaction.service.d.ts +27 -0
  112. package/core/types/flow-customization.types.d.ts +10 -0
  113. package/core/types/flow-state.types.d.ts +12 -0
  114. package/core/types/formatting-settings.types.d.ts +13 -0
  115. package/core/types/index.d.ts +5 -0
  116. package/core/types/integration.types.d.ts +10 -0
  117. package/core/types/pipe.types.d.ts +1 -0
  118. package/core/types/ui-definition.types.d.ts +1 -0
  119. package/core/utils/index.d.ts +4 -0
  120. package/core/utils/pcm.utils.d.ts +5 -0
  121. package/core/utils/transaction-item.utils.d.ts +10 -0
  122. package/core/utils/transaction-item.worker.d.ts +8 -0
  123. package/core/utils/ui-definition.utils.d.ts +2 -0
  124. package/esm2020/cms/cms.actions.mjs +151 -0
  125. package/esm2020/cms/cms.default.mjs +5 -0
  126. package/esm2020/cms/cms.elements.mjs +52 -0
  127. package/esm2020/cms/cms.layouts.mjs +239 -0
  128. package/esm2020/cms/components/element-children/element-children.component.mjs +41 -0
  129. package/esm2020/cms/components/element-children/element-children.module.mjs +21 -0
  130. package/esm2020/cms/components/element-drop-handle/element-drop-handle.component.mjs +28 -0
  131. package/esm2020/cms/components/element-drop-handle/element-drop-handle.module.mjs +19 -0
  132. package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +117 -0
  133. package/esm2020/cms/components/element-renderer/element-renderer.module.mjs +16 -0
  134. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +35 -0
  135. package/esm2020/cms/components/element.component.mjs +45 -0
  136. package/esm2020/cms/components/index.mjs +2 -0
  137. package/esm2020/cms/components/plugin.component.mjs +17 -0
  138. package/esm2020/cms/components/preview/index.mjs +4 -0
  139. package/esm2020/cms/components/preview/preview.component.mjs +75 -0
  140. package/esm2020/cms/components/preview/preview.module.mjs +42 -0
  141. package/esm2020/cms/components/preview/preview.types.mjs +2 -0
  142. package/esm2020/cms/decorators/element.decorator.mjs +6 -0
  143. package/esm2020/cms/decorators/index.mjs +2 -0
  144. package/esm2020/cms/definitions/index.mjs +2 -0
  145. package/esm2020/cms/definitions/ui-builder.definitions.mjs +18 -0
  146. package/esm2020/cms/directives/custom-template.directive.mjs +38 -0
  147. package/esm2020/cms/engine/models/entity.mjs +17 -0
  148. package/esm2020/cms/engine/models/plugin.mjs +6 -0
  149. package/esm2020/cms/index.mjs +16 -0
  150. package/esm2020/cms/injection-tokens.mjs +7 -0
  151. package/esm2020/cms/launcher.module.mjs +24 -0
  152. package/esm2020/cms/modules/federated/default-options.mjs +5 -0
  153. package/esm2020/cms/modules/federated/export.mjs +2 -0
  154. package/esm2020/cms/modules/federated/federated-host.directive.mjs +16 -0
  155. package/esm2020/cms/modules/federated/federated.component.mjs +74 -0
  156. package/esm2020/cms/modules/federated/federated.module.mjs +20 -0
  157. package/esm2020/cms/modules/federated/federated.types.mjs +2 -0
  158. package/esm2020/cms/modules/migrations/index.mjs +3 -0
  159. package/esm2020/cms/modules/migrations/migrations.mjs +22 -0
  160. package/esm2020/cms/modules/migrations/migrations.module.mjs +15 -0
  161. package/esm2020/cms/modules/migrations/services/migrations.service.mjs +47 -0
  162. package/esm2020/cms/modules/migrations/types/migrations.types.mjs +2 -0
  163. package/esm2020/cms/modules/runtime/index.mjs +4 -0
  164. package/esm2020/cms/modules/runtime/runtime.module.mjs +32 -0
  165. package/esm2020/cms/modules/runtime/services/compilation.service.mjs +93 -0
  166. package/esm2020/cms/modules/runtime/services/runtime-editor.service.mjs +30 -0
  167. package/esm2020/cms/modules/runtime/services/runtime.service.mjs +117 -0
  168. package/esm2020/cms/modules/runtime/tokens.mjs +3 -0
  169. package/esm2020/cms/modules/runtime/types/compilation.types.mjs +2 -0
  170. package/esm2020/cms/modules/runtime/types/runtime.actions.mjs +2 -0
  171. package/esm2020/cms/plugins/element-hover.plugin.mjs +121 -0
  172. package/esm2020/cms/plugins/io.plugin.mjs +45 -0
  173. package/esm2020/cms/plugins/page.plugin.mjs +37 -0
  174. package/esm2020/cms/plugins/region.plugin.mjs +59 -0
  175. package/esm2020/cms/plugins/script.plugin.mjs +31 -0
  176. package/esm2020/cms/services/element-context.service.mjs +10 -0
  177. package/esm2020/cms/services/index.mjs +3 -0
  178. package/esm2020/cms/services/io-provider.service.mjs +53 -0
  179. package/esm2020/cms/services/resources.service.mjs +71 -0
  180. package/esm2020/cms/services/templates.service.mjs +32 -0
  181. package/esm2020/cms/types/common.types.mjs +2 -0
  182. package/esm2020/cms/types/elements.types.mjs +2 -0
  183. package/esm2020/cms/types/index.mjs +7 -0
  184. package/esm2020/cms/types/layouts.types.mjs +71 -0
  185. package/esm2020/cms/types/pages.types.mjs +2 -0
  186. package/esm2020/cms/types/path.types.mjs +2 -0
  187. package/esm2020/cms/utils/element-metadata-worker.mjs +31 -0
  188. package/esm2020/cms/utils/element.utils.mjs +182 -0
  189. package/esm2020/cms/utils/elements-resolver.mjs +206 -0
  190. package/esm2020/cms/utils/encoding.utils.mjs +29 -0
  191. package/esm2020/cms/utils/index.mjs +10 -0
  192. package/esm2020/cms/utils/inject.mjs +27 -0
  193. package/esm2020/cms/utils/path.utils.mjs +44 -0
  194. package/esm2020/cms/utils/script.utils.mjs +46 -0
  195. package/esm2020/cms/utils/transpilation-worker.mjs +52 -0
  196. package/esm2020/cms/utils/ui-builder-layout.utils.mjs +46 -0
  197. package/esm2020/cms/utils/ui-definition.utils.mjs +85 -0
  198. package/esm2020/cms/veloceapps-sdk-cms.mjs +5 -0
  199. package/esm2020/cms/vendor-map.mjs +83 -0
  200. package/esm2020/core/core.module.mjs +54 -0
  201. package/esm2020/core/directives/directives.module.mjs +16 -0
  202. package/esm2020/core/directives/index.mjs +3 -0
  203. package/esm2020/core/directives/primeng-calendar.directive.mjs +41 -0
  204. package/esm2020/core/index.mjs +9 -0
  205. package/esm2020/core/modules/configuration/configuration.module.mjs +34 -0
  206. package/esm2020/core/modules/configuration/index.mjs +7 -0
  207. package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +29 -0
  208. package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +381 -0
  209. package/esm2020/core/modules/configuration/services/configuration.service.mjs +159 -0
  210. package/esm2020/core/modules/configuration/services/guided-selling.service.mjs +62 -0
  211. package/esm2020/core/modules/configuration/services/test-mode-configuration.service.mjs +97 -0
  212. package/esm2020/core/modules/configuration/types/configuration-runtime.types.mjs +2 -0
  213. package/esm2020/core/modules/configuration/types/configuration.types.mjs +2 -0
  214. package/esm2020/core/modules/configuration/types/index.mjs +3 -0
  215. package/esm2020/core/modules/flow-configuration/flow-configuration.module.mjs +17 -0
  216. package/esm2020/core/modules/flow-configuration/index.mjs +2 -0
  217. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +80 -0
  218. package/esm2020/core/modules/index.mjs +3 -0
  219. package/esm2020/core/operators/filter-successful-execute.operator.mjs +5 -0
  220. package/esm2020/core/operators/index.mjs +2 -0
  221. package/esm2020/core/pipes/action-code.pipe.mjs +20 -0
  222. package/esm2020/core/pipes/date.pipe.mjs +44 -0
  223. package/esm2020/core/pipes/index.mjs +6 -0
  224. package/esm2020/core/pipes/number.pipe.mjs +27 -0
  225. package/esm2020/core/pipes/pipes.module.mjs +19 -0
  226. package/esm2020/core/pipes/price.pipe.mjs +30 -0
  227. package/esm2020/core/services/catalog-products.service.mjs +25 -0
  228. package/esm2020/core/services/flow-info.service.mjs +146 -0
  229. package/esm2020/core/services/flow-state-configuration.service.mjs +120 -0
  230. package/esm2020/core/services/flow-state.service.mjs +417 -0
  231. package/esm2020/core/services/index.mjs +9 -0
  232. package/esm2020/core/services/integration.state.mjs +36 -0
  233. package/esm2020/core/services/product-images.service.mjs +30 -0
  234. package/esm2020/core/services/runtime-settings.service.mjs +112 -0
  235. package/esm2020/core/services/sales-transaction.service.mjs +67 -0
  236. package/esm2020/core/types/flow-customization.types.mjs +3 -0
  237. package/esm2020/core/types/flow-state.types.mjs +2 -0
  238. package/esm2020/core/types/formatting-settings.types.mjs +3 -0
  239. package/esm2020/core/types/index.mjs +6 -0
  240. package/esm2020/core/types/integration.types.mjs +2 -0
  241. package/esm2020/core/types/pipe.types.mjs +2 -0
  242. package/esm2020/core/types/ui-definition.types.mjs +2 -0
  243. package/esm2020/core/utils/index.mjs +5 -0
  244. package/esm2020/core/utils/pcm.utils.mjs +15 -0
  245. package/esm2020/core/utils/transaction-item.utils.mjs +144 -0
  246. package/esm2020/core/utils/transaction-item.worker.mjs +16 -0
  247. package/esm2020/core/utils/ui-definition.utils.mjs +9 -0
  248. package/esm2020/core/veloceapps-sdk-core.mjs +5 -0
  249. package/esm2020/index.mjs +2 -0
  250. package/esm2020/src/components/dialog/dialog.component.mjs +36 -0
  251. package/esm2020/src/components/dialog/dialog.module.mjs +19 -0
  252. package/esm2020/src/components/dialog/dialog.types.mjs +2 -0
  253. package/esm2020/src/components/flow-header/flow-header.component.mjs +107 -0
  254. package/esm2020/src/components/flow-header/flow-header.module.mjs +19 -0
  255. package/esm2020/src/components/flow-header/index.mjs +2 -0
  256. package/esm2020/src/components/guided-selling/guided-selling.component.mjs +107 -0
  257. package/esm2020/src/components/guided-selling/guided-selling.module.mjs +19 -0
  258. package/esm2020/src/configure-primeng.mjs +33 -0
  259. package/esm2020/src/constants.mjs +2 -0
  260. package/esm2020/src/flow-routing.module.mjs +97 -0
  261. package/esm2020/src/flow.component.mjs +39 -0
  262. package/esm2020/src/flow.module.mjs +60 -0
  263. package/esm2020/src/guards/flow.guard.mjs +35 -0
  264. package/esm2020/src/guards/product-unload.guard.mjs +49 -0
  265. package/esm2020/src/guards/root.guard.mjs +46 -0
  266. package/esm2020/src/index.mjs +5 -0
  267. package/esm2020/src/pages/assets/assets.component.mjs +106 -0
  268. package/esm2020/src/pages/assets/assets.module.mjs +20 -0
  269. package/esm2020/src/pages/catalog/catalog.component.mjs +106 -0
  270. package/esm2020/src/pages/catalog/catalog.module.mjs +20 -0
  271. package/esm2020/src/pages/debug/debug.component.mjs +49 -0
  272. package/esm2020/src/pages/debug/debug.module.mjs +46 -0
  273. package/esm2020/src/pages/product/product.component.mjs +55 -0
  274. package/esm2020/src/pages/product/product.module.mjs +20 -0
  275. package/esm2020/src/pages/record-not-found/record-not-found.component.mjs +27 -0
  276. package/esm2020/src/pages/record-not-found/record-not-found.module.mjs +20 -0
  277. package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +106 -0
  278. package/esm2020/src/pages/shopping-cart/shopping-cart.module.mjs +20 -0
  279. package/esm2020/src/resolvers/flow.resolver.mjs +50 -0
  280. package/esm2020/src/resolvers/pcm-model.resolver.mjs +12 -0
  281. package/esm2020/src/resolvers/sales-transaction.resolver.mjs +64 -0
  282. package/esm2020/src/resolvers/ui-definition.resolver.mjs +44 -0
  283. package/esm2020/src/services/flow-dialog.service.mjs +91 -0
  284. package/esm2020/src/services/flow-router.service.mjs +173 -0
  285. package/esm2020/src/services/flow.service.mjs +102 -0
  286. package/esm2020/src/services/guided-selling.service.mjs +34 -0
  287. package/esm2020/src/services/index.mjs +4 -0
  288. package/esm2020/src/types/index.mjs +2 -0
  289. package/esm2020/src/types/route.types.mjs +2 -0
  290. package/esm2020/veloceapps-sdk.mjs +5 -0
  291. package/fesm2015/veloceapps-sdk-cms.mjs +2514 -0
  292. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -0
  293. package/fesm2015/veloceapps-sdk-core.mjs +2084 -0
  294. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -0
  295. package/fesm2015/veloceapps-sdk.mjs +1598 -0
  296. package/fesm2015/veloceapps-sdk.mjs.map +1 -0
  297. package/fesm2020/veloceapps-sdk-cms.mjs +2613 -0
  298. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -0
  299. package/{fesm2022 → fesm2020}/veloceapps-sdk-core.mjs +133 -145
  300. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -0
  301. package/{fesm2022 → fesm2020}/veloceapps-sdk.mjs +192 -186
  302. package/fesm2020/veloceapps-sdk.mjs.map +1 -0
  303. package/index.d.ts +1 -330
  304. package/package.json +34 -17
  305. package/src/components/dialog/dialog.component.d.ts +13 -0
  306. package/src/components/dialog/dialog.module.d.ts +9 -0
  307. package/src/components/dialog/dialog.types.d.ts +7 -0
  308. package/src/components/flow-header/flow-header.component.d.ts +25 -0
  309. package/src/components/flow-header/flow-header.module.d.ts +9 -0
  310. package/src/components/flow-header/index.d.ts +1 -0
  311. package/src/components/guided-selling/guided-selling.component.d.ts +25 -0
  312. package/src/components/guided-selling/guided-selling.module.d.ts +9 -0
  313. package/src/configure-primeng.d.ts +1 -0
  314. package/src/constants.d.ts +1 -0
  315. package/src/flow-routing.module.d.ts +11 -0
  316. package/src/flow.component.d.ts +21 -0
  317. package/src/flow.module.d.ts +16 -0
  318. package/src/guards/flow.guard.d.ts +2 -0
  319. package/src/guards/product-unload.guard.d.ts +16 -0
  320. package/src/guards/root.guard.d.ts +14 -0
  321. package/src/index.d.ts +4 -0
  322. package/src/pages/assets/assets.component.d.ts +31 -0
  323. package/src/pages/assets/assets.module.d.ts +10 -0
  324. package/src/pages/catalog/catalog.component.d.ts +31 -0
  325. package/src/pages/catalog/catalog.module.d.ts +10 -0
  326. package/src/pages/debug/debug.component.d.ts +21 -0
  327. package/src/pages/debug/debug.module.d.ts +14 -0
  328. package/src/pages/product/product.component.d.ts +24 -0
  329. package/src/pages/product/product.module.d.ts +10 -0
  330. package/src/pages/record-not-found/record-not-found.component.d.ts +12 -0
  331. package/src/pages/record-not-found/record-not-found.module.d.ts +9 -0
  332. package/src/pages/shopping-cart/shopping-cart.component.d.ts +31 -0
  333. package/src/pages/shopping-cart/shopping-cart.module.d.ts +10 -0
  334. package/src/resolvers/flow.resolver.d.ts +14 -0
  335. package/src/resolvers/pcm-model.resolver.d.ts +3 -0
  336. package/src/resolvers/sales-transaction.resolver.d.ts +18 -0
  337. package/src/resolvers/ui-definition.resolver.d.ts +3 -0
  338. package/src/services/flow-dialog.service.d.ts +23 -0
  339. package/src/services/flow-router.service.d.ts +42 -0
  340. package/src/services/flow.service.d.ts +21 -0
  341. package/src/services/guided-selling.service.d.ts +13 -0
  342. package/src/services/index.d.ts +3 -0
  343. package/src/types/index.d.ts +1 -0
  344. package/src/types/route.types.d.ts +4 -0
  345. package/fesm2022/veloceapps-sdk-cms.mjs +0 -2611
  346. package/fesm2022/veloceapps-sdk-cms.mjs.map +0 -1
  347. package/fesm2022/veloceapps-sdk-core.mjs.map +0 -1
  348. package/fesm2022/veloceapps-sdk.mjs.map +0 -1
@@ -0,0 +1,2084 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, InjectionToken, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
3
+ import { isDefined, UUID, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, DEFAULT_ACTION_CODE_LABELS, parseJsonSafely, UITemplateType, SalesforceIdUtils, ConfigurationProcessorTypes, EntityUtil, extractErrorDetails, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
4
+ import * as i3 from '@veloceapps/api';
5
+ import { ApiModule } from '@veloceapps/api';
6
+ import * as i6 from '@veloceapps/components';
7
+ import { ToastType, ConfirmationDialogModule } from '@veloceapps/components';
8
+ import { tap, BehaviorSubject, map, filter, switchMap, of, forkJoin, throwError, noop, Subject, catchError, combineLatest, finalize, buffer, debounceTime, share, take, distinctUntilChanged, shareReplay, takeUntil, first } from 'rxjs';
9
+ import * as i1 from '@veloceapps/api/v2';
10
+ import { flatten, omit, uniqBy, cloneDeep, assign, isEqual } from 'lodash';
11
+ import { filter as filter$1, map as map$1, tap as tap$1, catchError as catchError$1, finalize as finalize$1 } from 'rxjs/operators';
12
+ import * as i2 from 'primeng/api';
13
+ import { NgControl } from '@angular/forms';
14
+ import { DATE_PIPE_DEFAULT_OPTIONS, formatDate } from '@angular/common';
15
+
16
+ class ConfigurationRuntimeService {
17
+ constructor(pcmApiService) {
18
+ this.pcmApiService = pcmApiService;
19
+ this.uiDefinitionContainer = null;
20
+ }
21
+ get uiDefinitionProps() {
22
+ var _a, _b;
23
+ return (_b = (_a = this.uiDefinitionContainer) === null || _a === void 0 ? void 0 : _a.source.properties) !== null && _b !== void 0 ? _b : {};
24
+ }
25
+ reset() {
26
+ this.uiDefinitionContainer = null;
27
+ this.initializationProps = undefined;
28
+ this.pcmModel = undefined;
29
+ }
30
+ init$(props) {
31
+ this.initializationProps = props;
32
+ return this.pcmApiService.fetchPCMByProductId(props.productId).pipe(tap(pcmModel => (this.pcmModel = pcmModel)));
33
+ }
34
+ }
35
+ ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.PCMApiService }], target: i0.ɵɵFactoryTarget.Injectable });
36
+ ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService });
37
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
38
+ type: Injectable
39
+ }], ctorParameters: function () { return [{ type: i1.PCMApiService }]; } });
40
+
41
+ class PCMUtils {
42
+ static mapByPrcId(pcm) {
43
+ const map = {};
44
+ if (pcm.productRelatedComponent) {
45
+ map[pcm.productRelatedComponent.id] = pcm;
46
+ }
47
+ for (const group of pcm.productComponentGroups) {
48
+ for (const gc of group.components) {
49
+ Object.assign(map, PCMUtils.mapByPrcId(gc));
50
+ }
51
+ }
52
+ return map;
53
+ }
54
+ }
55
+
56
+ const findTransactionItem = (id, items) => {
57
+ return findTransactionItemWithComparator(items, (ti) => ti.id === id);
58
+ };
59
+ const findTransactionItemWithComparator = (items, comparator) => {
60
+ let currentLevel = items;
61
+ while (currentLevel.length) {
62
+ const found = currentLevel.find(comparator);
63
+ if (found) {
64
+ return found;
65
+ }
66
+ currentLevel = flatten(currentLevel.map(parent => parent.children));
67
+ }
68
+ return;
69
+ };
70
+ const insertTransactionItem = (item, parentId, toInsert) => {
71
+ const insertData = item.id === parentId ? [toInsert] : [];
72
+ return Object.assign(Object.assign({}, item), { children: [
73
+ ...insertData,
74
+ ...item.children.map(ti => {
75
+ return insertTransactionItem(ti, parentId, toInsert);
76
+ }),
77
+ ] });
78
+ };
79
+ const removeTransactionItem = (item, idToRemove) => {
80
+ return Object.assign(Object.assign({}, item), { children: item.children
81
+ .map(ti => {
82
+ if (ti.id === idToRemove) {
83
+ return;
84
+ }
85
+ else if (ti.children.length) {
86
+ return removeTransactionItem(ti, idToRemove);
87
+ }
88
+ return ti;
89
+ })
90
+ .filter(isDefined) });
91
+ };
92
+ const replaceTransactionItem = (item, replaceTo) => {
93
+ if (item.id === replaceTo.id) {
94
+ return Object.assign({}, replaceTo);
95
+ }
96
+ return Object.assign(Object.assign({}, item), { children: item.children.map(ti => replaceTransactionItem(ti, replaceTo)) });
97
+ };
98
+ const generateTransactionItem = (option, salesTransactionId, qty, parentTi) => {
99
+ const newItem = generateTransactionItemFromPCM(option, salesTransactionId, parentTi);
100
+ // propagate Proportional quantities to children
101
+ const updatedNewItem = updateQuantity(newItem, qty !== null && qty !== void 0 ? qty : newItem.qty, option, parentTi === null || parentTi === void 0 ? void 0 : parentTi.qty);
102
+ return updatedNewItem;
103
+ };
104
+ const generateTransactionItemFromPCM = (option, salesTransactionId, parentTi) => {
105
+ var _a, _b, _c, _d, _e;
106
+ const childId = UUID.UUID();
107
+ const newItem = {
108
+ id: childId,
109
+ productId: option.id,
110
+ productName: option.name,
111
+ productCode: option.productCode,
112
+ productRelatedComponentId: (_a = option.productRelatedComponent) === null || _a === void 0 ? void 0 : _a.id,
113
+ constraintEngineNodeStatus: {
114
+ attributes: [],
115
+ cfgStatus: 'User',
116
+ },
117
+ stiAttributes: [],
118
+ attributes: {
119
+ ParentReference: salesTransactionId,
120
+ ItemPath: option.id,
121
+ SalesTransactionItemSource: childId,
122
+ SalesTransactionItemParent: salesTransactionId,
123
+ ProductSellingModel: (_c = (_b = option.productSellingModelOptions) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.productSellingModel.id,
124
+ },
125
+ qty: (_e = (_d = option.productRelatedComponent) === null || _d === void 0 ? void 0 : _d.quantity) !== null && _e !== void 0 ? _e : 1,
126
+ };
127
+ if (parentTi) {
128
+ newItem.parentId = parentTi.id;
129
+ }
130
+ newItem.children = option.productComponentGroups.reduce((acc, group) => {
131
+ group.components.forEach(component => {
132
+ var _a, _b;
133
+ if (((_a = component.productRelatedComponent) === null || _a === void 0 ? void 0 : _a.isComponentRequired) ||
134
+ ((_b = component.productRelatedComponent) === null || _b === void 0 ? void 0 : _b.isDefaultComponent)) {
135
+ acc.push(generateTransactionItemFromPCM(component, salesTransactionId, newItem));
136
+ }
137
+ });
138
+ return acc;
139
+ }, []);
140
+ return newItem;
141
+ };
142
+ const flattenTransactionItem = (ti) => {
143
+ const result = [];
144
+ const traverse = (item) => {
145
+ if (!item)
146
+ return;
147
+ result.push(item);
148
+ if (Array.isArray(item.children) && item.children.length) {
149
+ for (const child of item.children) {
150
+ traverse(child);
151
+ }
152
+ }
153
+ };
154
+ traverse(ti);
155
+ return result;
156
+ };
157
+ const updateQuantity = (ti, qty, pcm, parentQty = 1) => {
158
+ const pcmMap = PCMUtils.mapByPrcId(pcm);
159
+ const calcNewQty = (item, parentPrevQty, parentNewQty, parentPcm, inputQty, isDirectChange) => {
160
+ var _a;
161
+ const scaleMethod = (_a = parentPcm === null || parentPcm === void 0 ? void 0 : parentPcm.productRelatedComponent) === null || _a === void 0 ? void 0 : _a.quantityScaleMethod;
162
+ if (isDirectChange) {
163
+ return scaleMethod === 'Proportional' ? parentPrevQty * inputQty : inputQty;
164
+ }
165
+ else {
166
+ return scaleMethod === 'Proportional' ? (item.qty / parentPrevQty) * parentNewQty : item.qty;
167
+ }
168
+ };
169
+ const updateItem = (item, parentPrevQty, parentNewQty, isDirectChange) => {
170
+ const pcm = pcmMap[item.productRelatedComponentId];
171
+ let nextQty = item.qty;
172
+ if (item.id === ti.id || isDirectChange) {
173
+ nextQty = calcNewQty(item, parentPrevQty, parentNewQty, pcm, qty, true);
174
+ }
175
+ else if (parentPrevQty !== parentNewQty) {
176
+ nextQty = calcNewQty(item, parentPrevQty, parentNewQty, pcm, qty, false);
177
+ }
178
+ const sti = Object.assign(Object.assign({}, item), { qty: nextQty, children: item.children.map(child => updateItem(child, item.qty, nextQty, false)) });
179
+ if (nextQty !== item.qty) {
180
+ sti.constraintEngineNodeStatus = Object.assign(Object.assign({}, sti.constraintEngineNodeStatus), { cfgStatus: 'User' });
181
+ }
182
+ return sti;
183
+ };
184
+ return updateItem(ti, parentQty, parentQty, false);
185
+ };
186
+
187
+ class TransactionItemWorker {
188
+ constructor(src) {
189
+ this.ti = Object.assign({}, src);
190
+ }
191
+ insert(parentId, toInsert) {
192
+ return new TransactionItemWorker(insertTransactionItem(this.ti, parentId, toInsert));
193
+ }
194
+ remove(id) {
195
+ return new TransactionItemWorker(removeTransactionItem(this.ti, id));
196
+ }
197
+ replace(toReplace) {
198
+ return new TransactionItemWorker(replaceTransactionItem(this.ti, toReplace));
199
+ }
200
+ }
201
+
202
+ function extractMetadata(uiDefinition) {
203
+ return omit(uiDefinition, [
204
+ 'children',
205
+ 'pages',
206
+ 'components',
207
+ ]);
208
+ }
209
+
210
+ const FLOW_CUSTOMIZATION = new InjectionToken('FLOW_CUSTOMIZATION');
211
+
212
+ class RuntimeSettingsService {
213
+ constructor(configurationSettingsApiService) {
214
+ this.configurationSettingsApiService = configurationSettingsApiService;
215
+ this.configurationSettings$ = new BehaviorSubject({});
216
+ this.currencySettings$ = new BehaviorSubject({
217
+ iso: DEFAULT_CURRENCY_ISO_CODE,
218
+ symbol: DEFAULT_CURRENCY_SYMBOL,
219
+ });
220
+ this.shoppingCartSettings$ = new BehaviorSubject([]);
221
+ this.getCurrencySymbol = (locale, currency) => {
222
+ return (0)
223
+ .toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
224
+ .replace(/\d/g, '')
225
+ .trim();
226
+ };
227
+ }
228
+ create() {
229
+ return this.configurationSettingsApiService.fetchSettings().pipe(map(settings => this.parseConfigurationSettings(settings)), tap(configurationSettings => {
230
+ var _a;
231
+ this.configurationSettings$.next(configurationSettings);
232
+ this.addShoppingCartSettings((_a = configurationSettings['shopping-cart']) !== null && _a !== void 0 ? _a : []);
233
+ this.formattingSettings = this.getFormattingSettings();
234
+ }), map(() => undefined));
235
+ }
236
+ initCurrency(iso) {
237
+ if (iso) {
238
+ const symbol = this.getCurrencySymbol('en-US', iso);
239
+ this.currencySettings$.next({ iso, symbol });
240
+ if (this.formattingSettings) {
241
+ this.formattingSettings.currencySymbol = symbol;
242
+ }
243
+ }
244
+ }
245
+ getFormattingSettings() {
246
+ var _a, _b;
247
+ if (this.formattingSettings) {
248
+ return this.formattingSettings;
249
+ }
250
+ const shoppingCartSettings = (_a = this.getConfigurationSettings()['shopping-cart']) === null || _a === void 0 ? void 0 : _a.reduce((acc, setting) => {
251
+ return Object.assign(Object.assign({}, acc), { [setting.id]: setting.properties });
252
+ }, {});
253
+ const currencySettings = this.getCurrencySettings();
254
+ const dateFormat = (validateDateFormat((_b = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DATE_FORMAT) !== null && _b !== void 0 ? _b : '') && (shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DATE_FORMAT)) ||
255
+ DEFAULT_DATE_FORMAT;
256
+ const decimalSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DECIMAL_SEPARATOR;
257
+ const thousandsSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.THOUSANDS_SEPARATOR;
258
+ // the number of decimal places can be 0
259
+ const priceScale = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.PRICE_SCALE;
260
+ const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
261
+ ? Number(priceScale)
262
+ : DEFAULT_DECIMALS_COUNT;
263
+ const actionCodeSettings = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.STATUS_LABEL;
264
+ return {
265
+ currencySymbol: currencySettings.symbol,
266
+ dateFormats: getSupportedDateFormats(dateFormat),
267
+ decimalsCount,
268
+ decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
269
+ ? decimalSeparator
270
+ : DEFAULT_DECIMAL_SEPARATOR,
271
+ // thousands separator can be a blank value, so it can also be null
272
+ thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
273
+ ? thousandsSeparator || ''
274
+ : DEFAULT_THOUSANDS_SEPARATOR,
275
+ actionCodeLabels: (actionCodeSettings === null || actionCodeSettings === void 0 ? void 0 : actionCodeSettings.length)
276
+ ? actionCodeSettings.reduce((result, setting) => (Object.assign(Object.assign({}, result), { [setting.status_label]: setting.custom_label })), {})
277
+ : DEFAULT_ACTION_CODE_LABELS,
278
+ };
279
+ }
280
+ getConfigurationSettings() {
281
+ return this.configurationSettings$.value;
282
+ }
283
+ getShoppingCartSettings() {
284
+ return this.shoppingCartSettings$.value;
285
+ }
286
+ getCurrencySettings() {
287
+ return this.currencySettings$.value;
288
+ }
289
+ parseConfigurationSettings(settings) {
290
+ return settings.reduce((acc, setting) => {
291
+ switch (setting.key) {
292
+ case 'shopping-cart':
293
+ acc['shopping-cart'] = parseJsonSafely(setting.value, []);
294
+ break;
295
+ case 'navigation':
296
+ acc.navigation = parseJsonSafely(setting.value, {});
297
+ break;
298
+ case 'flows':
299
+ acc.flows = parseJsonSafely(setting.value, []);
300
+ break;
301
+ default:
302
+ acc[setting.key] = setting.value;
303
+ }
304
+ return acc;
305
+ }, {});
306
+ }
307
+ addShoppingCartSettings(settings) {
308
+ // uniqBy removes items with the biggest index
309
+ const newSettings = uniqBy([...settings, ...this.shoppingCartSettings$.value], 'id');
310
+ this.shoppingCartSettings$.next(newSettings);
311
+ }
312
+ }
313
+ RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
314
+ RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService });
315
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
316
+ type: Injectable
317
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
318
+
319
+ class FlowInfoService {
320
+ constructor(runtimeSettingsService, templatesAdminApiService, customizationService) {
321
+ this.runtimeSettingsService = runtimeSettingsService;
322
+ this.templatesAdminApiService = templatesAdminApiService;
323
+ this.customizationService = customizationService;
324
+ this.defaultTemplates = {
325
+ flowEngine: 'Flow Engine',
326
+ };
327
+ this.flowSubj$ = new BehaviorSubject(null);
328
+ this.templatesSubj$ = new BehaviorSubject({});
329
+ this.contextSubj$ = new BehaviorSubject(null);
330
+ this.flow$ = this.flowSubj$.asObservable();
331
+ this.templates$ = this.templatesSubj$.asObservable();
332
+ }
333
+ get flow() {
334
+ if (!this.flowSubj$.value) {
335
+ throw new Error(`Flow not initialized yet`);
336
+ }
337
+ return this.flowSubj$.value;
338
+ }
339
+ get isFlowInitialized() {
340
+ return Boolean(this.flowSubj$.value);
341
+ }
342
+ get context() {
343
+ if (!this.contextSubj$.value) {
344
+ throw new Error('Context is not initialized yet!');
345
+ }
346
+ return Object.assign({}, this.contextSubj$.value);
347
+ }
348
+ get context$() {
349
+ return this.contextSubj$.asObservable().pipe(filter(isDefined));
350
+ }
351
+ get templates() {
352
+ return this.templatesSubj$.value;
353
+ }
354
+ get isFlowEngineInitialized$() {
355
+ return this.templates$.pipe(map(v => Boolean(v.FLOW_ENGINE)));
356
+ }
357
+ get isStateful() {
358
+ var _a;
359
+ return !!((_a = this.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful);
360
+ }
361
+ reset() {
362
+ this.flowSubj$.next(null);
363
+ this.templatesSubj$.next({});
364
+ this.contextSubj$.next(null);
365
+ }
366
+ init$(flowId, routeQueryParams) {
367
+ return this.initFlow$(flowId, routeQueryParams).pipe(switchMap(() => this.initFlowTemplates$()));
368
+ }
369
+ updateContext(update) {
370
+ this.contextSubj$.next(Object.assign(Object.assign({}, this.context), update));
371
+ }
372
+ initFlow$(flowId, routeQueryParams) {
373
+ var _a;
374
+ const flow = (_a = this.runtimeSettingsService.getConfigurationSettings()['flows']) === null || _a === void 0 ? void 0 : _a.find(({ id }) => flowId === id);
375
+ if (!flow) {
376
+ this.flowSubj$.next(null);
377
+ throw new Error(`Flow with flowId=${flowId} is not defined`);
378
+ }
379
+ const headerId = routeQueryParams['headerId'];
380
+ if (typeof headerId !== 'string') {
381
+ throw new Error(`Please provide 'headerId'`);
382
+ }
383
+ const mode = this.getFlowContextMode(headerId);
384
+ // Restrict if mode is not defined
385
+ if (mode == null) {
386
+ throw new Error('Mode is undefined');
387
+ }
388
+ this.contextSubj$.next(Object.assign(Object.assign(Object.assign({}, flow.properties.queryParams), routeQueryParams), { mode }));
389
+ this.flowSubj$.next(flow);
390
+ return of(undefined);
391
+ }
392
+ initFlowTemplates$() {
393
+ var _a, _b, _c;
394
+ return forkJoin([
395
+ this.templatesAdminApiService.fetchTemplates$(),
396
+ (_c = (_b = (_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplates) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : of([]),
397
+ ]).pipe(map(([templates, localTemplates]) => {
398
+ var _a, _b;
399
+ const newValue = {};
400
+ Object.entries(Object.assign(Object.assign({}, this.defaultTemplates), ((_b = (_a = this.flow) === null || _a === void 0 ? void 0 : _a.properties.templates) !== null && _b !== void 0 ? _b : {}))).forEach(([key, name]) => {
401
+ var _a;
402
+ const type = this.remapTemplateName(key);
403
+ if (type) {
404
+ newValue[type] =
405
+ (_a = localTemplates.find(template => template.name === name && template.type === type)) !== null && _a !== void 0 ? _a : templates.find(template => template.name === name && template.type === type);
406
+ }
407
+ });
408
+ this.templatesSubj$.next(newValue);
409
+ }));
410
+ }
411
+ remapTemplateName(templateType) {
412
+ switch (templateType) {
413
+ case 'flowEngine':
414
+ return UITemplateType.FLOW_ENGINE;
415
+ default:
416
+ break;
417
+ }
418
+ switch (templateType) {
419
+ case 'assets':
420
+ case 'shoppingCart':
421
+ // No separate Assets template at the moment
422
+ return UITemplateType.SHOPPING_CART;
423
+ case 'catalog':
424
+ return UITemplateType.CATALOG;
425
+ case 'guidedSelling':
426
+ return UITemplateType.GUIDED_SELLING;
427
+ case 'flowHeader':
428
+ return UITemplateType.FLOW_HEADER;
429
+ default:
430
+ break;
431
+ }
432
+ return undefined;
433
+ }
434
+ getFlowContextMode(headerId) {
435
+ const objectName = SalesforceIdUtils.getSfObjectNameById(headerId);
436
+ if (!objectName) {
437
+ return;
438
+ }
439
+ return objectName.toUpperCase();
440
+ }
441
+ }
442
+ FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: RuntimeSettingsService }, { token: i1.UITemplatesAdminApiService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
443
+ FlowInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService });
444
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, decorators: [{
445
+ type: Injectable
446
+ }], ctorParameters: function () {
447
+ return [{ type: RuntimeSettingsService }, { type: i1.UITemplatesAdminApiService }, { type: undefined, decorators: [{
448
+ type: Optional
449
+ }, {
450
+ type: Inject,
451
+ args: [FLOW_CUSTOMIZATION]
452
+ }] }];
453
+ } });
454
+
455
+ class TestModeConfigurationService {
456
+ constructor(flowInfoService, configurationService, configurationRuntimeService, salesTransactionService, runtimeSettingsService, sfApiService) {
457
+ this.flowInfoService = flowInfoService;
458
+ this.configurationService = configurationService;
459
+ this.configurationRuntimeService = configurationRuntimeService;
460
+ this.salesTransactionService = salesTransactionService;
461
+ this.runtimeSettingsService = runtimeSettingsService;
462
+ this.sfApiService = sfApiService;
463
+ this.isInitialized = false;
464
+ }
465
+ initTestMode$(uiDefinitionContainer, options) {
466
+ var _a;
467
+ this.configurationRuntimeService.uiDefinitionContainer = uiDefinitionContainer;
468
+ if (this.checkInitialized(uiDefinitionContainer)) {
469
+ this.configurationRuntimeService.pcmModel = this.pcmModel;
470
+ return of(undefined);
471
+ }
472
+ this.configurationService.reset();
473
+ const { productId, quoteId, flowId } = (_a = uiDefinitionContainer.source.properties) !== null && _a !== void 0 ? _a : {};
474
+ if (!productId) {
475
+ return throwError(() => 'Unable to start the Configuration Preview: Product is missing.');
476
+ }
477
+ if (!quoteId) {
478
+ return throwError(() => `Unable to start the Configuration Preview: Quote is missing.`);
479
+ }
480
+ if (!flowId) {
481
+ return throwError(() => `Unable to start the Configuration Preview: Flow is missing.`);
482
+ }
483
+ return this.runtimeSettingsService.create().pipe(switchMap(() => this.flowInfoService.init$(flowId, { productId, headerId: quoteId, testMode: true })), switchMap(() => this.configurationRuntimeService.init$({ productId })), tap(pcmModel => (this.pcmModel = pcmModel)), switchMap(() => {
484
+ if (options === null || options === void 0 ? void 0 : options.customizationMode) {
485
+ return of(undefined);
486
+ }
487
+ return this.initConfiguration$(quoteId);
488
+ }), tap(() => (this.isInitialized = true)), map(noop));
489
+ }
490
+ initConfiguration$(quoteId) {
491
+ return this.getPriceBookId(quoteId).pipe(map(priceBookId => this.getTestTransactionContext(quoteId, priceBookId)), tap(state => this.salesTransactionService.setState(state)), switchMap(() => this.configurationService.init$()), switchMap(() => this.configurationService.state
492
+ ? this.configurationService.configure$(this.configurationService.state)
493
+ : of(undefined)), map(noop));
494
+ }
495
+ getPriceBookId(quoteId) {
496
+ return this.sfApiService
497
+ .query({ count: 1, fields: ['Pricebook2Id'], rawCondition: `Id = '${quoteId}'` }, 'Quote')
498
+ .pipe(map(r => { var _a, _b; return (_b = (_a = r === null || r === void 0 ? void 0 : r[0]) === null || _a === void 0 ? void 0 : _a.Pricebook2Id) !== null && _b !== void 0 ? _b : null; }));
499
+ }
500
+ getTestTransactionContext(quoteId, priceBookId) {
501
+ var _a;
502
+ const dateStr = (_a = new Date().toISOString().split('T')[0]) !== null && _a !== void 0 ? _a : '';
503
+ const testTransaction = {
504
+ id: quoteId,
505
+ businessObjectType: 'Quote',
506
+ salesTransactionItems: [],
507
+ salesTransactionName: 'Test Quote',
508
+ account: '',
509
+ quoteAccount: '',
510
+ pricebook: '',
511
+ status: 'Draft',
512
+ totalAmount: 0,
513
+ subtotal: 0,
514
+ activatedDate: dateStr,
515
+ effectiveDate: dateStr,
516
+ startDate: dateStr,
517
+ attributes: {},
518
+ nodes: {},
519
+ };
520
+ if (priceBookId) {
521
+ testTransaction.pricebook = priceBookId;
522
+ }
523
+ return {
524
+ salesTransaction: testTransaction,
525
+ transactionId: quoteId,
526
+ businessObjectType: 'Quote',
527
+ nodes: {},
528
+ id: UUID.UUID(),
529
+ attributes: {},
530
+ };
531
+ }
532
+ checkInitialized(uiDefinitionContainer) {
533
+ var _a;
534
+ return this.isInitialized && !!((_a = uiDefinitionContainer.source.properties) === null || _a === void 0 ? void 0 : _a.persistTestState);
535
+ }
536
+ }
537
+ TestModeConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, deps: [{ token: FlowInfoService }, { token: ConfigurationService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }, { token: RuntimeSettingsService }, { token: i1.SalesforceApiService }], target: i0.ɵɵFactoryTarget.Injectable });
538
+ TestModeConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService });
539
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, decorators: [{
540
+ type: Injectable
541
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: ConfigurationService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: RuntimeSettingsService }, { type: i1.SalesforceApiService }]; } });
542
+
543
+ class GuidedSellingService {
544
+ constructor(orchestrationsApiService) {
545
+ this.orchestrationsApiService = orchestrationsApiService;
546
+ this.guidedSellingResult$ = new BehaviorSubject({});
547
+ }
548
+ get guidedSellingResult() {
549
+ return this.guidedSellingResult$.value;
550
+ }
551
+ configureGuidedSelling$(data) {
552
+ return this.orchestrationsApiService
553
+ .apply$({
554
+ transactionContext: this.getTransactionContext(data.attributesMap),
555
+ orchestrationName: data.orchestrationName,
556
+ })
557
+ .pipe(map(transactionContext => {
558
+ var _a, _b;
559
+ const guidedSellingNode = (_a = transactionContext.nodes['GuidedSelling']) === null || _a === void 0 ? void 0 : _a[0];
560
+ const guidedSellingResult = ((_b = guidedSellingNode === null || guidedSellingNode === void 0 ? void 0 : guidedSellingNode.attributes) === null || _b === void 0 ? void 0 : _b['result']) || {};
561
+ this.guidedSellingResult$.next(guidedSellingResult);
562
+ return guidedSellingResult;
563
+ }));
564
+ }
565
+ clearGuidedSelling$() {
566
+ this.guidedSellingResult$.next({});
567
+ }
568
+ getTransactionContext(guidedSellingAttributes) {
569
+ const testTransaction = {
570
+ id: UUID.UUID(),
571
+ businessObjectType: 'Quote',
572
+ salesTransactionItems: [],
573
+ attributes: {},
574
+ };
575
+ return {
576
+ salesTransaction: testTransaction,
577
+ transactionId: UUID.UUID(),
578
+ businessObjectType: 'Quote',
579
+ nodes: {
580
+ GuidedSelling: [
581
+ {
582
+ id: UUID.UUID(),
583
+ attributes: {},
584
+ nodes: {},
585
+ properties: { guidedSellingAttributes },
586
+ },
587
+ ],
588
+ },
589
+ id: UUID.UUID(),
590
+ attributes: {},
591
+ };
592
+ }
593
+ }
594
+ GuidedSellingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService, deps: [{ token: i1.OrchestrationsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
595
+ GuidedSellingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService });
596
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService, decorators: [{
597
+ type: Injectable
598
+ }], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }]; } });
599
+
600
+ class SalesTransactionService {
601
+ get isInitialized$() {
602
+ return this.isInitializedSubj$.asObservable();
603
+ }
604
+ get isInitialized() {
605
+ return this.isInitializedSubj$.getValue();
606
+ }
607
+ set hasUnsavedChanges(value) {
608
+ var _a, _b;
609
+ this.hasUnsavedChangesSubj$.next(value);
610
+ if (!this.hasUnsavedChanges) {
611
+ this.initialState = (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.salesTransaction.salesTransactionItems) !== null && _b !== void 0 ? _b : [];
612
+ }
613
+ }
614
+ get hasUnsavedChanges() {
615
+ return this.hasUnsavedChangesSubj$.getValue();
616
+ }
617
+ get state() {
618
+ return this.stateSubj$.getValue();
619
+ }
620
+ get hasProducts() {
621
+ var _a;
622
+ return Boolean((_a = this.state) === null || _a === void 0 ? void 0 : _a.salesTransaction.salesTransactionItems.length);
623
+ }
624
+ constructor(salesTransactionApiService) {
625
+ this.salesTransactionApiService = salesTransactionApiService;
626
+ this.stateSubj$ = new BehaviorSubject(null);
627
+ this.isInitializedSubj$ = new BehaviorSubject(false);
628
+ this.hasUnsavedChangesSubj$ = new BehaviorSubject(false);
629
+ this.initialState = [];
630
+ this.hasUnsavedChanges$ = this.hasUnsavedChangesSubj$.asObservable();
631
+ this.state$ = this.stateSubj$.asObservable().pipe(filter(isDefined));
632
+ }
633
+ init(headerId, params) {
634
+ return this.salesTransactionApiService.query(headerId, params).pipe(tap(res => {
635
+ if (!res.salesTransaction) {
636
+ throw new Error('SalesTransaction is not defined. Please check Query Orchestration.');
637
+ }
638
+ this.stateSubj$.next(res);
639
+ }));
640
+ }
641
+ finalizeInit() {
642
+ this.isInitializedSubj$.next(true);
643
+ this.hasUnsavedChanges = false;
644
+ }
645
+ reset() {
646
+ this.stateSubj$.next(null);
647
+ this.isInitializedSubj$.next(false);
648
+ this.hasUnsavedChangesSubj$.next(false);
649
+ }
650
+ getInitialState() {
651
+ return this.initialState;
652
+ }
653
+ setState(state) {
654
+ this.stateSubj$.next(state);
655
+ }
656
+ }
657
+ SalesTransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, deps: [{ token: i1.SalesTransactionApiService }], target: i0.ɵɵFactoryTarget.Injectable });
658
+ SalesTransactionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService });
659
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, decorators: [{
660
+ type: Injectable
661
+ }], ctorParameters: function () { return [{ type: i1.SalesTransactionApiService }]; } });
662
+
663
+ class FlowConfigurationService {
664
+ constructor(orchestrationsApiService, salesTransactionService, flowInfoService) {
665
+ this.orchestrationsApiService = orchestrationsApiService;
666
+ this.salesTransactionService = salesTransactionService;
667
+ this.flowInfoService = flowInfoService;
668
+ this.updatedSubj$ = new Subject();
669
+ this.updated$ = this.updatedSubj$.asObservable();
670
+ }
671
+ calculate$(state) {
672
+ return this.orchestrationsApiService
673
+ .apply$({ transactionContext: state, flowId: this.flowInfoService.flow.id })
674
+ .pipe(tap(result => this.salesTransactionService.setState(result)), map(noop));
675
+ }
676
+ calculate(state) {
677
+ this.calculate$(state).subscribe();
678
+ }
679
+ revert$(transactionItemId) {
680
+ var _a;
681
+ const state = this.salesTransactionService.state;
682
+ const initialState = this.salesTransactionService.getInitialState();
683
+ const currentState = (_a = state === null || state === void 0 ? void 0 : state.salesTransaction.salesTransactionItems) !== null && _a !== void 0 ? _a : [];
684
+ const currentItemIndex = currentState.findIndex(({ id }) => id === transactionItemId);
685
+ const currentItem = currentState[currentItemIndex];
686
+ const initialItem = initialState.find(({ integrationId }) => integrationId === (currentItem === null || currentItem === void 0 ? void 0 : currentItem.integrationId));
687
+ if (!state || !currentItem || !initialItem) {
688
+ return of(null);
689
+ }
690
+ const updatedState = cloneDeep(currentState);
691
+ updatedState.splice(currentItemIndex, 1, initialItem);
692
+ return of([]).pipe(map(() => (Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: updatedState }) }))), tap(newState => this.salesTransactionService.setState(newState)), switchMap(newState => this.calculate$(newState)), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
693
+ }
694
+ revert(transactionItemId) {
695
+ this.revert$(transactionItemId).subscribe();
696
+ }
697
+ delete$(ids) {
698
+ const state = this.salesTransactionService.state;
699
+ if (!state) {
700
+ return of(null);
701
+ }
702
+ return of([]).pipe(map(() => state.salesTransaction.salesTransactionItems.filter(({ id }) => !ids.includes(id))), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: updatedState }) }))), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
703
+ }
704
+ delete(ids) {
705
+ this.delete$(ids).subscribe();
706
+ }
707
+ handleErrorAndBounceBack() {
708
+ return (source$) => {
709
+ return source$.pipe(catchError(error => {
710
+ console.error(error);
711
+ // bounce back if configuration call has failed
712
+ const state = this.salesTransactionService.state;
713
+ if (state) {
714
+ this.salesTransactionService.setState(state);
715
+ this.updatedSubj$.next();
716
+ }
717
+ return throwError(() => error);
718
+ }));
719
+ };
720
+ }
721
+ }
722
+ FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.OrchestrationsApiService }, { token: SalesTransactionService }, { token: FlowInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
723
+ FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
724
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
725
+ type: Injectable
726
+ }], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }, { type: SalesTransactionService }, { type: FlowInfoService }]; } });
727
+
728
+ class FlowStateService {
729
+ constructor(flowConfiguration, flowInfoService, flowStateApiService, processorsApiService, salesTransactionApiService, salesTransactionService, toastService, customizationService) {
730
+ this.flowConfiguration = flowConfiguration;
731
+ this.flowInfoService = flowInfoService;
732
+ this.flowStateApiService = flowStateApiService;
733
+ this.processorsApiService = processorsApiService;
734
+ this.salesTransactionApiService = salesTransactionApiService;
735
+ this.salesTransactionService = salesTransactionService;
736
+ this.toastService = toastService;
737
+ this.customizationService = customizationService;
738
+ this.NOT_INITIALIZED = Symbol();
739
+ this.EXECUTION_BUFFER_TIME = 100;
740
+ this.executedFunctions = {};
741
+ this.stateId$ = new BehaviorSubject(null);
742
+ this.initialStatefulData = {};
743
+ this.trackedStatefulChangesMap = new Map();
744
+ this.processors = {};
745
+ this.subscriptions = {};
746
+ this.flowStore = {};
747
+ this.executionInProgress$ = new BehaviorSubject(false);
748
+ this.statefulRequestStream$ = new Subject();
749
+ this.cleanup$ = new Subject();
750
+ this.statefulExecutionRequest$ = this.initBufferedRequest$();
751
+ /*
752
+ In stateless mode watch State changes and call executeRequest so that
753
+ all subscriptions get their updates according to updated State
754
+ */
755
+ this.isInitialized$()
756
+ .pipe(filter(Boolean), filter(() => !this.flowInfoService.flow.properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
757
+ .subscribe();
758
+ }
759
+ init$() {
760
+ if (this.flowInfoService.flow.properties.stateful) {
761
+ return this.initProcessors$().pipe(switchMap(() => this.initStateful$()));
762
+ }
763
+ else {
764
+ return forkJoin([this.initStateless$(), this.initProcessors$()]).pipe(map(noop));
765
+ }
766
+ }
767
+ reset() {
768
+ Object.values(this.subscriptions).forEach(({ data$ }) => data$.complete());
769
+ this.subscriptions = {};
770
+ if (this.stateId$.value) {
771
+ this.flowStateApiService.cancel(this.stateId$.value).subscribe();
772
+ this.stateId$.next(null);
773
+ }
774
+ this.processors = {};
775
+ this.flowStore = {};
776
+ this.cleanup$.next();
777
+ }
778
+ get hasUnsavedChanges() {
779
+ return this.flowInfoService.flow.properties.stateful
780
+ ? Array.from(this.trackedStatefulChangesMap.values()).some(Boolean)
781
+ : this.salesTransactionService.hasUnsavedChanges;
782
+ }
783
+ get stateId() {
784
+ return this.stateId$.value;
785
+ }
786
+ get isExecutionInProgress$() {
787
+ return this.executionInProgress$.asObservable();
788
+ }
789
+ isInitialized$() {
790
+ return combineLatest([this.stateId$, this.salesTransactionService.isInitialized$]).pipe(map(values => values.some(Boolean)));
791
+ }
792
+ isInitialized() {
793
+ return Boolean(this.stateId$.value) || this.salesTransactionService.isInitialized;
794
+ }
795
+ execute$(scope, exec) {
796
+ const request = this.execToRequest(scope, exec);
797
+ return this.executeRequest$(request).pipe(map(result => {
798
+ // Keep only requested results
799
+ const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
800
+ var _a;
801
+ if ((_a = exec.selectors) === null || _a === void 0 ? void 0 : _a[requestId]) {
802
+ trunk[requestId] = result;
803
+ }
804
+ return trunk;
805
+ }, {});
806
+ return actualSelectors;
807
+ }));
808
+ }
809
+ dispatch$(scope, action, inputData) {
810
+ const exec = {
811
+ actions: [{ name: action, inputData }],
812
+ };
813
+ const request = this.execToRequest(scope, exec);
814
+ return this.executeRequest$(request).pipe(map(noop));
815
+ }
816
+ select$(scope, selectorName, inputData) {
817
+ const requestId = this.generateRequestId(scope, selectorName, inputData);
818
+ const request = this.execToRequest(scope, {
819
+ selectors: {
820
+ [requestId]: {
821
+ name: selectorName,
822
+ inputData,
823
+ },
824
+ },
825
+ });
826
+ return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
827
+ }
828
+ subscribe$(scope, selectorName, inputData, options) {
829
+ const requestId = this.generateRequestId(scope, selectorName, inputData);
830
+ let subscription = this.subscriptions[requestId];
831
+ if (!subscription) {
832
+ const request = this.execToRequest(scope, {
833
+ selectors: {
834
+ [requestId]: {
835
+ name: selectorName,
836
+ inputData,
837
+ },
838
+ },
839
+ });
840
+ subscription = {
841
+ request,
842
+ data$: new BehaviorSubject(this.NOT_INITIALIZED),
843
+ };
844
+ this.subscriptions[requestId] = subscription;
845
+ if (options === null || options === void 0 ? void 0 : options.trackedChanges) {
846
+ this.trackedStatefulChangesMap.set(requestId, false);
847
+ }
848
+ if (!(options === null || options === void 0 ? void 0 : options.cold)) {
849
+ this.executeRequest$(request).subscribe();
850
+ }
851
+ }
852
+ return subscription.data$.pipe(filter(data => data != this.NOT_INITIALIZED), map(data => data), finalize(() => {
853
+ var _a;
854
+ if (!((_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$.observed)) {
855
+ delete this.subscriptions[requestId];
856
+ }
857
+ }));
858
+ }
859
+ save$() {
860
+ if (this.flowInfoService.flow.properties.stateful) {
861
+ if (this.stateId$.value) {
862
+ return this.flowStateApiService.save(this.stateId$.value).pipe(map(({ quoteId }) => ({ id: quoteId })), tap(() => {
863
+ Array.from(this.trackedStatefulChangesMap.keys()).forEach(key => {
864
+ this.trackedStatefulChangesMap.set(key, false);
865
+ });
866
+ }));
867
+ }
868
+ }
869
+ else {
870
+ const state = this.salesTransactionService.state;
871
+ if (state) {
872
+ const request = {
873
+ transactionContext: state,
874
+ flowId: this.flowInfoService.flow.id,
875
+ };
876
+ return this.salesTransactionApiService.save(request).pipe(map(id => ({ id })));
877
+ }
878
+ }
879
+ return of({ id: '' });
880
+ }
881
+ getFlowStore() {
882
+ return this.flowStore;
883
+ }
884
+ getOwnerIdByScope(scope) {
885
+ var _a;
886
+ const ownerId = (_a = this.flowInfoService.templates[scope]) === null || _a === void 0 ? void 0 : _a.id;
887
+ if (!ownerId) {
888
+ throw `OwnerId is not found for scope ${scope}`;
889
+ }
890
+ return ownerId;
891
+ }
892
+ getScopeByOwnerId(id) {
893
+ for (const template of Object.values(this.flowInfoService.templates)) {
894
+ if (template.id === id) {
895
+ return template.type;
896
+ }
897
+ }
898
+ return;
899
+ }
900
+ execToRequest(scope, exec) {
901
+ var _a;
902
+ const ownerId = this.getOwnerIdByScope(scope);
903
+ return {
904
+ actions: (_a = exec.actions) === null || _a === void 0 ? void 0 : _a.map(action => { var _a; return ({ apiName: action.name, ownerId, inputData: (_a = action.inputData) !== null && _a !== void 0 ? _a : {} }); }),
905
+ selectors: exec.selectors &&
906
+ Object.entries(exec.selectors).reduce((trunk, [key, selector]) => {
907
+ var _a;
908
+ return (Object.assign(Object.assign({}, trunk), { [key]: { apiName: selector.name, ownerId, inputData: (_a = selector.inputData) !== null && _a !== void 0 ? _a : {} } }));
909
+ }, {}),
910
+ };
911
+ }
912
+ executeRequest$(request, forceSubscriptions = false) {
913
+ var _a;
914
+ const fullRequest = cloneDeep(request);
915
+ if (((_a = fullRequest.actions) === null || _a === void 0 ? void 0 : _a.length) || forceSubscriptions) {
916
+ for (const subscription of Object.values(this.subscriptions)) {
917
+ fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
918
+ }
919
+ }
920
+ const execution$ = this.flowInfoService.flow.properties.stateful
921
+ ? this.executeStateful$(fullRequest)
922
+ : this.executeStateless$(fullRequest);
923
+ return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
924
+ }
925
+ handleSelectorsResponse(selectors) {
926
+ Object.entries(selectors).forEach(([requestId, selectorResult]) => {
927
+ var _a;
928
+ if (!selectorResult.success) {
929
+ this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
930
+ }
931
+ const subscription$ = (_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$;
932
+ if (subscription$ && subscription$.value !== selectorResult) {
933
+ this.checkStatefulChanges(requestId, selectorResult);
934
+ subscription$.next(selectorResult);
935
+ }
936
+ });
937
+ }
938
+ initStateful$() {
939
+ const processorsList = flatten(Object.values(this.processors).map(ownerMap => Object.values(ownerMap !== null && ownerMap !== void 0 ? ownerMap : {})));
940
+ const processors = processorsList.length ? processorsList : undefined;
941
+ const selectors = Object.values(this.subscriptions)
942
+ .map(({ request }) => request.selectors)
943
+ .filter(isDefined)
944
+ .reduce((trunk, selectors) => (Object.assign(Object.assign({}, trunk), selectors)), {});
945
+ return this.flowStateApiService
946
+ .init({
947
+ quoteId: this.flowInfoService.context.headerId,
948
+ params: this.flowInfoService.context,
949
+ actionsOverride: processors === null || processors === void 0 ? void 0 : processors.filter(processor => processor.type === ConfigurationProcessorTypes.ACTION),
950
+ selectorsOverride: processors === null || processors === void 0 ? void 0 : processors.filter(processor => processor.type === ConfigurationProcessorTypes.SELECTOR),
951
+ selectors: selectors,
952
+ })
953
+ .pipe(map(({ stateId, selectors }) => {
954
+ this.handleSelectorsResponse(selectors);
955
+ this.stateId$.next(stateId);
956
+ }));
957
+ }
958
+ initBufferedRequest$() {
959
+ return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap(requests => {
960
+ if (!this.stateId$.value) {
961
+ throw 'Stateful session is not initialized';
962
+ }
963
+ // merge buffered requests
964
+ const request = {
965
+ actions: requests.flatMap(({ actions }) => actions).filter(isDefined),
966
+ selectors: requests
967
+ .map(({ selectors }) => selectors)
968
+ .filter(isDefined)
969
+ .reduce((acc, selectorsMap) => Object.assign(acc, selectorsMap), {}),
970
+ };
971
+ this.executionInProgress$.next(true);
972
+ return this.flowStateApiService.execute(this.stateId$.value, request);
973
+ }), tap(({ stateId }) => this.stateId$.next(stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError(e => {
974
+ this.executionInProgress$.next(false);
975
+ return throwError(() => e);
976
+ }));
977
+ }
978
+ executeStateful$(request) {
979
+ return this.executionInProgress$.pipe(filter(inProgress => !inProgress), take(1), switchMap(() =>
980
+ // make sure stream switches to statefulExecutionRequest$ before pushing an execution request
981
+ combineLatest([
982
+ this.statefulExecutionRequest$,
983
+ of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
984
+ ])), map(([response]) => response), take(1));
985
+ }
986
+ initStateless$() {
987
+ return this.salesTransactionService.init(this.flowInfoService.context.headerId, this.flowInfoService.context).pipe(switchMap(state => this.flowConfiguration.calculate$(state)), tap(() => this.salesTransactionService.finalizeInit()), map(noop));
988
+ }
989
+ executeStateless$(request) {
990
+ this.executionInProgress$.next(true);
991
+ return of(undefined).pipe(tap(() => this.executeStatelessActions(request)), switchMap(() => {
992
+ var _a;
993
+ /*
994
+ Skip price calculation in case
995
+ 1. No actions in the request
996
+ 2. Initialization process execution (state not initialized yet)
997
+ */
998
+ const { state } = this.salesTransactionService;
999
+ if (!state || !((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length) || !this.isInitialized()) {
1000
+ return of(undefined);
1001
+ }
1002
+ else {
1003
+ return this.flowConfiguration.calculate$(state);
1004
+ }
1005
+ }), map(() => this.executeStatelessSelectors(request)), tap(() => this.executionInProgress$.next(false)), catchError(e => {
1006
+ this.executionInProgress$.next(false);
1007
+ return throwError(() => e);
1008
+ }));
1009
+ }
1010
+ executeStatelessActions(request) {
1011
+ var _a;
1012
+ const state = this.salesTransactionService.state;
1013
+ if (!state || !((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
1014
+ return;
1015
+ }
1016
+ let flowState = state;
1017
+ request.actions.forEach(action => {
1018
+ var _a;
1019
+ try {
1020
+ flowState = (_a = this.executeActionScript(flowState, action)) !== null && _a !== void 0 ? _a : flowState;
1021
+ }
1022
+ catch (e) {
1023
+ console.error(e);
1024
+ this.toastService.add({ severity: ToastType.error, summary: String(e) });
1025
+ throw e;
1026
+ }
1027
+ });
1028
+ this.salesTransactionService.setState(flowState);
1029
+ }
1030
+ executeStatelessSelectors(request) {
1031
+ var _a;
1032
+ if (!this.salesTransactionService.state) {
1033
+ throw 'State is not initialized';
1034
+ }
1035
+ const flowState = this.salesTransactionService.state;
1036
+ return EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
1037
+ try {
1038
+ result.selectors[key] = {
1039
+ success: true,
1040
+ result: this.executeSelectorScript(flowState, selector),
1041
+ };
1042
+ }
1043
+ catch (e) {
1044
+ console.error(e);
1045
+ result.selectors[key] = {
1046
+ success: false,
1047
+ errorMessage: String(e),
1048
+ };
1049
+ }
1050
+ return result;
1051
+ }, { stateId: '', selectors: {} });
1052
+ }
1053
+ initProcessors$() {
1054
+ var _a;
1055
+ const hasOverrides = Boolean((_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplateConfigurationProcessors);
1056
+ if (this.flowInfoService.flow.properties.stateful && !hasOverrides) {
1057
+ // Skip initialization as backend will take processors from SF
1058
+ return of(undefined);
1059
+ }
1060
+ const owners$ = Object.values(this.flowInfoService.templates)
1061
+ .map(template => {
1062
+ var _a, _b, _c;
1063
+ if (!template) {
1064
+ return;
1065
+ }
1066
+ const localProcessors$ = (_c = (_b = (_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplateConfigurationProcessors) === null || _b === void 0 ? void 0 : _b.call(_a, template.name)) !== null && _c !== void 0 ? _c : of(null);
1067
+ return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap(processors => {
1068
+ const processorsMap = processors.reduce((acc, p) => {
1069
+ acc[p.apiName] = p;
1070
+ return acc;
1071
+ }, {});
1072
+ this.processors[template.id] = processorsMap;
1073
+ }));
1074
+ })
1075
+ .filter(isDefined);
1076
+ if (!owners$.length) {
1077
+ return of(undefined);
1078
+ }
1079
+ return forkJoin(owners$).pipe(map(noop));
1080
+ }
1081
+ executeActionScript(request, executable) {
1082
+ var _a;
1083
+ const configurationProcessor = (_a = this.processors[executable.ownerId]) === null || _a === void 0 ? void 0 : _a[executable.apiName];
1084
+ if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
1085
+ const scope = this.getScopeByOwnerId(executable.ownerId);
1086
+ const scopeText = scope ? ` in ${scope}` : '';
1087
+ throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
1088
+ }
1089
+ return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
1090
+ }
1091
+ executeSelectorScript(request, executable) {
1092
+ var _a;
1093
+ const configurationProcessor = (_a = this.processors[executable.ownerId]) === null || _a === void 0 ? void 0 : _a[executable.apiName];
1094
+ if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
1095
+ const scope = this.getScopeByOwnerId(executable.ownerId);
1096
+ const scopeText = scope ? ` in ${scope}` : '';
1097
+ throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
1098
+ }
1099
+ return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
1100
+ }
1101
+ executeProcessorScript(request, configurationProcessor, inputData) {
1102
+ var _a;
1103
+ const scope = this.getScopeByOwnerId((_a = configurationProcessor.ownerId) !== null && _a !== void 0 ? _a : '');
1104
+ let functionToExecute = this.executedFunctions[scope + configurationProcessor.apiName];
1105
+ if (!functionToExecute) {
1106
+ const script = `${configurationProcessor.script}\nreturn transform;`;
1107
+ const sourceMap = `\n//# sourceURL=${scope ? scope + '/' : ''}${configurationProcessor.apiName}.js`;
1108
+ functionToExecute = new Function(script + sourceMap)();
1109
+ this.executedFunctions[scope + configurationProcessor.apiName] = functionToExecute;
1110
+ }
1111
+ return functionToExecute({
1112
+ request,
1113
+ inputData,
1114
+ flowStore: this.flowStore,
1115
+ });
1116
+ }
1117
+ generateRequestId(scope, selectorName, inputData) {
1118
+ const inputDataHash = UUID.hex(JSON.stringify(inputData) || '').slice(0, 8);
1119
+ return `${scope}/${selectorName}/${inputDataHash}`;
1120
+ }
1121
+ checkStatefulChanges(requestId, selectorResult) {
1122
+ if (this.trackedStatefulChangesMap.has(requestId)) {
1123
+ if (!this.initialStatefulData[requestId]) {
1124
+ this.initialStatefulData[requestId] = selectorResult;
1125
+ }
1126
+ const hasChanges = !isEqual(this.initialStatefulData[requestId], selectorResult);
1127
+ this.trackedStatefulChangesMap.set(requestId, hasChanges);
1128
+ }
1129
+ }
1130
+ }
1131
+ FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: FlowConfigurationService }, { token: FlowInfoService }, { token: i3.FlowStateApiService }, { token: i1.ConfigurationProcessorsApiService }, { token: i1.SalesTransactionApiService }, { token: SalesTransactionService }, { token: i6.ToastService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1132
+ FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService });
1133
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, decorators: [{
1134
+ type: Injectable
1135
+ }], ctorParameters: function () {
1136
+ return [{ type: FlowConfigurationService }, { type: FlowInfoService }, { type: i3.FlowStateApiService }, { type: i1.ConfigurationProcessorsApiService }, { type: i1.SalesTransactionApiService }, { type: SalesTransactionService }, { type: i6.ToastService }, { type: undefined, decorators: [{
1137
+ type: Optional
1138
+ }, {
1139
+ type: Inject,
1140
+ args: [FLOW_CUSTOMIZATION]
1141
+ }] }];
1142
+ } });
1143
+
1144
+ class FlowStateConfigurationService {
1145
+ constructor(flowInfoService, flowStateService, configurationService, salesTransactionService, flowConfigurationService, pcmApiService) {
1146
+ this.flowInfoService = flowInfoService;
1147
+ this.flowStateService = flowStateService;
1148
+ this.configurationService = configurationService;
1149
+ this.salesTransactionService = salesTransactionService;
1150
+ this.flowConfigurationService = flowConfigurationService;
1151
+ this.pcmApiService = pcmApiService;
1152
+ this.pcmCache = {};
1153
+ }
1154
+ updateQuantity$(props) {
1155
+ var _a, _b, _c;
1156
+ const allItems = (_c = (_b = (_a = this.salesTransactionService.state) === null || _a === void 0 ? void 0 : _a.salesTransaction) === null || _b === void 0 ? void 0 : _b.salesTransactionItems) !== null && _c !== void 0 ? _c : [];
1157
+ const ti = allItems.find(item => item.id === props.id);
1158
+ if (!ti) {
1159
+ return of(undefined);
1160
+ }
1161
+ return this.getPCMProduct$(ti.productId).pipe(map(pcm => updateQuantity(ti, props.qty, pcm)), switchMap(updatedTi => {
1162
+ const state = this.salesTransactionService.state;
1163
+ if (!state) {
1164
+ return of(undefined);
1165
+ }
1166
+ const updatedState = Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: state.salesTransaction.salesTransactionItems.map(item => {
1167
+ return updatedTi.id === item.id ? updatedTi : item;
1168
+ }) }) });
1169
+ return this.flowConfigurationService.calculate$(updatedState);
1170
+ }), switchMap(() => this.flowStateService.executeRequest$({}, true)), map(noop));
1171
+ }
1172
+ addToCart$(props) {
1173
+ var _a;
1174
+ let request$;
1175
+ const stateful = (_a = this.flowInfoService.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful;
1176
+ if (stateful) {
1177
+ const stateId = this.flowStateService.stateId;
1178
+ if (!stateId) {
1179
+ request$ = of();
1180
+ }
1181
+ else {
1182
+ // TODO: Implement
1183
+ request$ = of();
1184
+ }
1185
+ }
1186
+ else {
1187
+ request$ = this.configureExternal$(props);
1188
+ }
1189
+ return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map(noop));
1190
+ }
1191
+ configureExternal$(props) {
1192
+ return this.getPCMProduct$(props.productId).pipe(switchMap(pcm => {
1193
+ var _a, _b, _c;
1194
+ const { state } = this.salesTransactionService;
1195
+ if (!state) {
1196
+ return of();
1197
+ }
1198
+ const stateToConfigure = Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: [
1199
+ Object.assign(Object.assign({}, generateTransactionItem(pcm, (_a = this.configurationService.state) === null || _a === void 0 ? void 0 : _a.salesTransaction.id, (_b = props.qty) !== null && _b !== void 0 ? _b : 1)), { stiAttributes: Object.entries((_c = props.attributesMap) !== null && _c !== void 0 ? _c : {}).map(([attributeName, value]) => ({
1200
+ attributeName,
1201
+ value,
1202
+ })) }),
1203
+ ] }) });
1204
+ return this.configurationService.justConfigureRequest$(stateToConfigure).pipe(switchMap(configurationResult => {
1205
+ const state = this.salesTransactionService.state;
1206
+ const addedProduct = configurationResult.salesTransaction.salesTransactionItems[0];
1207
+ if (!state || !addedProduct) {
1208
+ return of();
1209
+ }
1210
+ return this.flowConfigurationService.calculate$(Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: [...state.salesTransaction.salesTransactionItems, addedProduct] }) }));
1211
+ }));
1212
+ }));
1213
+ }
1214
+ getPCMProduct$(productId) {
1215
+ const cached = this.pcmCache[productId];
1216
+ if (cached) {
1217
+ return of(cached);
1218
+ }
1219
+ return this.pcmApiService
1220
+ .fetchPCMByProductId(productId)
1221
+ .pipe(tap(pcmProduct => (this.pcmCache[productId] = pcmProduct)));
1222
+ }
1223
+ }
1224
+ FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token: FlowStateService }, { token: ConfigurationService }, { token: SalesTransactionService }, { token: FlowConfigurationService }, { token: i1.PCMApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1225
+ FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService });
1226
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
1227
+ type: Injectable
1228
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowStateService }, { type: ConfigurationService }, { type: SalesTransactionService }, { type: FlowConfigurationService }, { type: i1.PCMApiService }]; } });
1229
+
1230
+ class IntegrationState {
1231
+ constructor() {
1232
+ this.stateSubj$ = new BehaviorSubject({});
1233
+ this.action$ = new Subject();
1234
+ }
1235
+ get state$() {
1236
+ return this.stateSubj$.asObservable();
1237
+ }
1238
+ get state() {
1239
+ return this.stateSubj$.getValue();
1240
+ }
1241
+ patchState(update) {
1242
+ this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
1243
+ }
1244
+ dispatch(action) {
1245
+ this.action$.next(action);
1246
+ }
1247
+ listen$(actionType) {
1248
+ return this.action$.pipe(filter(action => action.type === actionType), map(action => action.payload));
1249
+ }
1250
+ listenAll$() {
1251
+ return this.action$.asObservable();
1252
+ }
1253
+ reset() {
1254
+ this.stateSubj$.next({});
1255
+ }
1256
+ }
1257
+ IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1258
+ IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState });
1259
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, decorators: [{
1260
+ type: Injectable
1261
+ }] });
1262
+
1263
+ class ProductImagesService {
1264
+ constructor(productsAdminApiService) {
1265
+ this.productsAdminApiService = productsAdminApiService;
1266
+ this.imagesMap$ = new BehaviorSubject({});
1267
+ }
1268
+ getImageUrl$(productId) {
1269
+ if (this.imagesMap$.value[productId] == null) {
1270
+ this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: '' }));
1271
+ this.fetchProductImage(productId);
1272
+ }
1273
+ return this.imagesMap$.pipe(map(imagesMap => { var _a; return (_a = imagesMap[productId]) !== null && _a !== void 0 ? _a : null; }), distinctUntilChanged());
1274
+ }
1275
+ fetchProductImage(productId) {
1276
+ this.productsAdminApiService
1277
+ .fetchImage$(productId)
1278
+ .pipe(map(file => URL.createObjectURL(file)), catchError(() => of('')), tap(url => this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: url }))))
1279
+ .subscribe();
1280
+ }
1281
+ }
1282
+ ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductsAdminApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1283
+ ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService });
1284
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, decorators: [{
1285
+ type: Injectable
1286
+ }], ctorParameters: function () { return [{ type: i1.ProductsAdminApiService }]; } });
1287
+
1288
+ class CatalogProductsService {
1289
+ constructor() {
1290
+ this.stateSubj$ = new BehaviorSubject(null);
1291
+ this.state$ = this.stateSubj$.asObservable().pipe(filter(isDefined));
1292
+ }
1293
+ get state() {
1294
+ return this.stateSubj$.getValue();
1295
+ }
1296
+ reset() {
1297
+ this.stateSubj$.next(null);
1298
+ }
1299
+ setState(state) {
1300
+ this.stateSubj$.next(state);
1301
+ }
1302
+ }
1303
+ CatalogProductsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1304
+ CatalogProductsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService });
1305
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService, decorators: [{
1306
+ type: Injectable
1307
+ }] });
1308
+
1309
+ class ConfigurationService {
1310
+ constructor(flowInfoService, messageService, configurationRuntimeService, salesTransactionService, orchestrationsApiService, guidedSellingService) {
1311
+ this.flowInfoService = flowInfoService;
1312
+ this.messageService = messageService;
1313
+ this.configurationRuntimeService = configurationRuntimeService;
1314
+ this.salesTransactionService = salesTransactionService;
1315
+ this.orchestrationsApiService = orchestrationsApiService;
1316
+ this.guidedSellingService = guidedSellingService;
1317
+ this.hasUnsavedChanges = false;
1318
+ this.configurationStateSubj$ = new BehaviorSubject(null);
1319
+ this.previousConfigurationStateSubj$ = new BehaviorSubject(null);
1320
+ this.isLoadingSubj$ = new BehaviorSubject(false);
1321
+ this.isLoading$ = this.isLoadingSubj$.asObservable();
1322
+ }
1323
+ get state$() {
1324
+ return this.configurationStateSubj$.asObservable().pipe(filter$1(isDefined));
1325
+ }
1326
+ get state() {
1327
+ return this.configurationStateSubj$.getValue();
1328
+ }
1329
+ get previousState() {
1330
+ return this.previousConfigurationStateSubj$.getValue();
1331
+ }
1332
+ get root$() {
1333
+ return this.state$.pipe(map$1(state => state.salesTransaction.salesTransactionItems[0]), filter$1(isDefined));
1334
+ }
1335
+ get root() {
1336
+ var _a, _b;
1337
+ return (_b = (_a = this.configurationStateSubj$.getValue()) === null || _a === void 0 ? void 0 : _a.salesTransaction.salesTransactionItems[0]) !== null && _b !== void 0 ? _b : null;
1338
+ }
1339
+ reset() {
1340
+ this.hasUnsavedChanges = false;
1341
+ this.configurationStateSubj$.next(null);
1342
+ this.previousConfigurationStateSubj$.next(null);
1343
+ }
1344
+ init$() {
1345
+ var _a, _b;
1346
+ const { state } = this.salesTransactionService;
1347
+ const { standalone } = this.flowInfoService.flow.properties;
1348
+ const { productId, transactionItemId, newProductQty } = this.flowInfoService.context;
1349
+ if (!state || !productId) {
1350
+ return of(undefined);
1351
+ }
1352
+ const salesTransactionItems = (_a = state === null || state === void 0 ? void 0 : state.salesTransaction.salesTransactionItems) !== null && _a !== void 0 ? _a : [];
1353
+ let isRootGenerated = false;
1354
+ let transactionItem = salesTransactionItems.find(item => item.id === transactionItemId);
1355
+ if (!transactionItem && standalone) {
1356
+ transactionItem = salesTransactionItems.find(item => item.productId === productId);
1357
+ }
1358
+ if (!transactionItem) {
1359
+ const quantity = typeof newProductQty === 'number' && newProductQty > 0 ? newProductQty : undefined;
1360
+ transactionItem = generateTransactionItem(this.getPCMModel(), (_b = this.state) === null || _b === void 0 ? void 0 : _b.salesTransaction.id, quantity);
1361
+ isRootGenerated = true;
1362
+ }
1363
+ const guidedSellingResult = this.guidedSellingService.guidedSellingResult;
1364
+ if (transactionItem && Object.keys(guidedSellingResult).length && isRootGenerated) {
1365
+ transactionItem.stiAttributes = Object.entries(guidedSellingResult).map(([attributeName, value]) => ({
1366
+ attributeName,
1367
+ value,
1368
+ }));
1369
+ }
1370
+ const configurationState = Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: transactionItem ? [transactionItem] : [] }) });
1371
+ return (isRootGenerated ? this.configure$(configurationState) : of(configurationState)).pipe(tap$1(configurationState => {
1372
+ this.configurationStateSubj$.next(configurationState);
1373
+ this.previousConfigurationStateSubj$.next(configurationState);
1374
+ }), map$1(noop));
1375
+ }
1376
+ patch$(transactionItem) {
1377
+ const { state, root } = this;
1378
+ if (!state) {
1379
+ return throwError(() => new Error(`Configuration State is not initialized`));
1380
+ }
1381
+ if (!root) {
1382
+ return throwError(() => new Error(`Root SalesTransactionItem not found`));
1383
+ }
1384
+ const newRoot = new TransactionItemWorker(root).replace(transactionItem).ti;
1385
+ const newTransactionContext = Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: [newRoot] }) });
1386
+ return this.configure$(newTransactionContext).pipe(catchError$1(error => {
1387
+ console.error(error);
1388
+ if (!this.configurationRuntimeService.uiDefinitionProps.suppressToastMessages) {
1389
+ this.messageService.add({ severity: 'error', summary: error });
1390
+ }
1391
+ return throwError(() => error);
1392
+ }), tap$1(() => {
1393
+ if (!this.hasUnsavedChanges) {
1394
+ this.hasUnsavedChanges = true;
1395
+ }
1396
+ }), map$1(noop));
1397
+ }
1398
+ patch(transactionItem) {
1399
+ this.patch$(transactionItem).subscribe();
1400
+ }
1401
+ configure$(transactionContext) {
1402
+ this.isLoadingSubj$.next(true);
1403
+ return this.justConfigureRequest$(transactionContext).pipe(tap$1(result => {
1404
+ this.configurationStateSubj$.next(result);
1405
+ this.previousConfigurationStateSubj$.next(cloneDeep(result));
1406
+ }), catchError$1(e => {
1407
+ const resetState = this.previousConfigurationStateSubj$.getValue();
1408
+ if (resetState) {
1409
+ this.previousConfigurationStateSubj$.next(cloneDeep(resetState));
1410
+ this.configurationStateSubj$.next(resetState);
1411
+ }
1412
+ return throwError(() => e);
1413
+ }), finalize$1(() => this.isLoadingSubj$.next(false)));
1414
+ }
1415
+ justConfigureRequest$(transactionContext) {
1416
+ const request = {
1417
+ transactionContext,
1418
+ flowId: this.flowInfoService.flow.id,
1419
+ };
1420
+ return this.orchestrationsApiService.apply$(request).pipe(catchError$1(error => throwError(() => {
1421
+ if (error.error) {
1422
+ return extractErrorDetails(error.error).join('. ');
1423
+ }
1424
+ return error.message || JSON.stringify(error);
1425
+ })));
1426
+ }
1427
+ getPCMModel() {
1428
+ const pcmModel = this.configurationRuntimeService.pcmModel;
1429
+ if (!pcmModel) {
1430
+ throw new Error('PCM model not initialized');
1431
+ }
1432
+ return pcmModel;
1433
+ }
1434
+ }
1435
+ ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: FlowInfoService }, { token: i2.MessageService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }, { token: i1.OrchestrationsApiService }, { token: GuidedSellingService }], target: i0.ɵɵFactoryTarget.Injectable });
1436
+ ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
1437
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, decorators: [{
1438
+ type: Injectable
1439
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: i2.MessageService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: i1.OrchestrationsApiService }, { type: GuidedSellingService }]; } });
1440
+
1441
+ class ConfigurationStateService {
1442
+ constructor(configurationRuntimeService, configurationService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, salesTransactionService, salesTransactionApiService, toastService, pcmApiService) {
1443
+ this.configurationRuntimeService = configurationRuntimeService;
1444
+ this.configurationService = configurationService;
1445
+ this.flowStateService = flowStateService;
1446
+ this.flowInfoService = flowInfoService;
1447
+ this.flowConfigurationService = flowConfigurationService;
1448
+ this.flowStateApiService = flowStateApiService;
1449
+ this.salesTransactionService = salesTransactionService;
1450
+ this.salesTransactionApiService = salesTransactionApiService;
1451
+ this.toastService = toastService;
1452
+ this.pcmApiService = pcmApiService;
1453
+ this.isInitialized$ = new BehaviorSubject(false);
1454
+ this.canceledConfiguration$ = new Subject();
1455
+ this.NOT_INITIALIZED = Symbol();
1456
+ this.EXECUTION_BUFFER_TIME = 100;
1457
+ this.executedFunctions = {};
1458
+ this.stateId = null;
1459
+ this.ownerId = '';
1460
+ this.subscriptions = {};
1461
+ this.configurationStore = {};
1462
+ this.executionInProgress$ = new BehaviorSubject(false);
1463
+ this.statefulRequestStream$ = new Subject();
1464
+ this.statelessExecutionRequest$ = null;
1465
+ this.statefulExecutionRequest$ = this.initBufferedRequest$();
1466
+ }
1467
+ get isExecutionInProgress$() {
1468
+ return this.executionInProgress$.asObservable();
1469
+ }
1470
+ init$() {
1471
+ let request$;
1472
+ if (this.flowStateService.stateId && this.isStatefulConfiguration) {
1473
+ request$ = this.initStateful$();
1474
+ }
1475
+ else {
1476
+ request$ = this.configurationService.init$();
1477
+ }
1478
+ return request$.pipe(take(1), tap(() => {
1479
+ this.isInitialized$.next(true);
1480
+ this.canceledConfiguration$ = new Subject();
1481
+ }));
1482
+ }
1483
+ cleanup() {
1484
+ Object.values(this.subscriptions).forEach(({ data$ }) => data$.complete());
1485
+ this.subscriptions = {};
1486
+ if (this.stateId) {
1487
+ this.cancelConfiguration();
1488
+ }
1489
+ this.configurationStore = {};
1490
+ this.executedFunctions = {};
1491
+ this.configurationService.reset();
1492
+ this.configurationRuntimeService.reset();
1493
+ }
1494
+ execute$(exec) {
1495
+ const request = this.execToRequest(exec);
1496
+ return this.executeRequest$(request).pipe(map(result => {
1497
+ // Keep only requested results
1498
+ const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
1499
+ var _a;
1500
+ if ((_a = exec.selectors) === null || _a === void 0 ? void 0 : _a[requestId]) {
1501
+ trunk[requestId] = result;
1502
+ }
1503
+ return trunk;
1504
+ }, {});
1505
+ return actualSelectors;
1506
+ }));
1507
+ }
1508
+ dispatch$(actionName, inputData = {}) {
1509
+ const exec = {
1510
+ actions: [{ name: actionName, inputData }],
1511
+ };
1512
+ const request = this.execToRequest(exec);
1513
+ const executionRequest$ = this.executeRequest$(request);
1514
+ if (this.isStatefulConfiguration) {
1515
+ return executionRequest$;
1516
+ }
1517
+ // prevent parallel configuration requests in stateless mode
1518
+ if (!this.statelessExecutionRequest$) {
1519
+ this.statelessExecutionRequest$ = executionRequest$.pipe(shareReplay(), take(1), finalize(() => (this.statelessExecutionRequest$ = null)));
1520
+ }
1521
+ return this.statelessExecutionRequest$;
1522
+ }
1523
+ select$(selectorName, inputData = {}) {
1524
+ const requestId = UUID.UUID();
1525
+ const request = this.execToRequest({
1526
+ selectors: {
1527
+ [requestId]: {
1528
+ name: selectorName,
1529
+ inputData,
1530
+ },
1531
+ },
1532
+ });
1533
+ return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
1534
+ }
1535
+ subscribe$(selectorName, inputData = {}, options) {
1536
+ const requestId = UUID.UUID();
1537
+ let subscription = this.subscriptions[requestId];
1538
+ if (!subscription) {
1539
+ const request = this.execToRequest({
1540
+ selectors: {
1541
+ [requestId]: {
1542
+ name: selectorName,
1543
+ inputData,
1544
+ },
1545
+ },
1546
+ });
1547
+ subscription = {
1548
+ request,
1549
+ data$: new BehaviorSubject(this.NOT_INITIALIZED),
1550
+ };
1551
+ this.subscriptions[requestId] = subscription;
1552
+ if (!(options === null || options === void 0 ? void 0 : options.cold)) {
1553
+ this.executeRequest$(request).subscribe();
1554
+ }
1555
+ }
1556
+ return subscription.data$.pipe(filter(data => data != this.NOT_INITIALIZED), map(data => data), distinctUntilChanged(), finalize(() => {
1557
+ var _a;
1558
+ if (!((_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$.observed)) {
1559
+ delete this.subscriptions[requestId];
1560
+ }
1561
+ }), takeUntil(this.canceledConfiguration$));
1562
+ }
1563
+ saveConfiguration() {
1564
+ var _a, _b;
1565
+ if (this.isStatefulConfiguration) {
1566
+ return this.flowStateApiService.saveConfiguration((_a = this.flowStateService.stateId) !== null && _a !== void 0 ? _a : '', (_b = this.stateId) !== null && _b !== void 0 ? _b : '').pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map(() => r))), map(r => ({ id: r.quoteId })));
1567
+ }
1568
+ const state = this.salesTransactionService.state;
1569
+ if (!state) {
1570
+ return of({ id: '' });
1571
+ }
1572
+ const { standalone } = this.flowInfoService.flow.properties;
1573
+ const transactionContext = this.salesTransactionService.state;
1574
+ const configurationRoot = this.configurationService.root;
1575
+ if (!transactionContext || !configurationRoot) {
1576
+ return of({ id: '' });
1577
+ }
1578
+ const stateItems = transactionContext.salesTransaction.salesTransactionItems;
1579
+ const isNewTransactionItem = stateItems.every(ti => ti.id !== configurationRoot.id);
1580
+ let salesTransactionItems;
1581
+ if (isNewTransactionItem) {
1582
+ salesTransactionItems = [...stateItems, configurationRoot];
1583
+ }
1584
+ else {
1585
+ salesTransactionItems = stateItems.map(ti => (ti.id === configurationRoot.id ? configurationRoot : ti));
1586
+ }
1587
+ const newState = Object.assign(Object.assign({}, transactionContext), { salesTransaction: Object.assign(Object.assign({}, transactionContext.salesTransaction), { salesTransactionItems }) });
1588
+ if (standalone) {
1589
+ const request = {
1590
+ transactionContext: newState,
1591
+ flowId: this.flowInfoService.flow.id,
1592
+ };
1593
+ return this.salesTransactionApiService.save(request).pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map(() => r))), map(id => ({ id })));
1594
+ }
1595
+ return this.flowConfigurationService.calculate$(newState).pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map(() => ({ id: '' })));
1596
+ }
1597
+ cancelConfiguration() {
1598
+ var _a, _b;
1599
+ if (!this.isInitialized$.value) {
1600
+ return of(undefined);
1601
+ }
1602
+ this.canceledConfiguration$.next();
1603
+ this.canceledConfiguration$.complete();
1604
+ this.subscriptions = {};
1605
+ this.isInitialized$.next(false);
1606
+ if (!this.isInitialized$.value || !this.isStatefulConfiguration) {
1607
+ return of(undefined);
1608
+ }
1609
+ return this.flowStateApiService.cancelConfiguration((_a = this.flowStateService.stateId) !== null && _a !== void 0 ? _a : '', (_b = this.stateId) !== null && _b !== void 0 ? _b : '');
1610
+ }
1611
+ get isStatefulConfiguration() {
1612
+ var _a, _b;
1613
+ return (_b = (_a = this.flowInfoService.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful) !== null && _b !== void 0 ? _b : false;
1614
+ }
1615
+ initStateful$() {
1616
+ var _a, _b, _c, _d;
1617
+ this.ownerId = (_b = (_a = this.configurationRuntimeService.uiDefinitionContainer) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : '';
1618
+ const { productId, transactionItemId } = this.flowInfoService.context;
1619
+ if (!productId || !this.flowStateService.stateId) {
1620
+ return of(undefined);
1621
+ }
1622
+ const container = this.configurationRuntimeService.uiDefinitionContainer;
1623
+ let request$;
1624
+ if (!transactionItemId) {
1625
+ request$ = this.pcmApiService.fetchPCMByProductId(productId).pipe(switchMap(pcm => {
1626
+ var _a, _b, _c;
1627
+ return this.flowStateApiService.newConfiguration(this.flowStateService.stateId || '', {
1628
+ transactionItem: generateTransactionItem(pcm, (_a = this.configurationService.state) === null || _a === void 0 ? void 0 : _a.salesTransaction.id),
1629
+ actionsOverride: (_b = container === null || container === void 0 ? void 0 : container.actions) === null || _b === void 0 ? void 0 : _b.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
1630
+ selectorsOverride: (_c = container === null || container === void 0 ? void 0 : container.selectors) === null || _c === void 0 ? void 0 : _c.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
1631
+ });
1632
+ }));
1633
+ }
1634
+ else {
1635
+ request$ = this.flowStateApiService.startConfiguration(this.flowStateService.stateId, {
1636
+ transactionItemId,
1637
+ actionsOverride: (_c = container === null || container === void 0 ? void 0 : container.actions) === null || _c === void 0 ? void 0 : _c.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
1638
+ selectorsOverride: (_d = container === null || container === void 0 ? void 0 : container.selectors) === null || _d === void 0 ? void 0 : _d.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
1639
+ });
1640
+ }
1641
+ return request$.pipe(map(r => {
1642
+ this.stateId = r.stateId;
1643
+ return undefined;
1644
+ }));
1645
+ }
1646
+ execToRequest(exec) {
1647
+ var _a;
1648
+ return {
1649
+ actions: (_a = exec.actions) === null || _a === void 0 ? void 0 : _a.map(action => {
1650
+ var _a;
1651
+ return ({
1652
+ apiName: action.name,
1653
+ ownerId: this.ownerId,
1654
+ inputData: (_a = action.inputData) !== null && _a !== void 0 ? _a : {},
1655
+ });
1656
+ }),
1657
+ selectors: exec.selectors &&
1658
+ Object.entries(exec.selectors).reduce((trunk, [key, selector]) => {
1659
+ var _a;
1660
+ return (Object.assign(Object.assign({}, trunk), { [key]: { apiName: selector.name, ownerId: this.ownerId, inputData: (_a = selector.inputData) !== null && _a !== void 0 ? _a : {} } }));
1661
+ }, {}),
1662
+ };
1663
+ }
1664
+ handleSelectorsResponse(selectors) {
1665
+ Object.entries(selectors).forEach(([requestId, selectorResult]) => {
1666
+ var _a;
1667
+ if (!selectorResult.success) {
1668
+ this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
1669
+ }
1670
+ const subscription$ = (_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$;
1671
+ if (subscription$) {
1672
+ subscription$.next(selectorResult);
1673
+ }
1674
+ });
1675
+ }
1676
+ executeRequest$(req, forceSubscriptions) {
1677
+ var _a;
1678
+ const fullRequest = cloneDeep(req);
1679
+ if (((_a = fullRequest.actions) === null || _a === void 0 ? void 0 : _a.length) || forceSubscriptions) {
1680
+ for (const subscription of Object.values(this.subscriptions)) {
1681
+ fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
1682
+ }
1683
+ }
1684
+ let execution$;
1685
+ if (this.isStatefulConfiguration) {
1686
+ execution$ = this.executeStateful$(fullRequest);
1687
+ }
1688
+ else {
1689
+ execution$ = this.executeStateless$(fullRequest);
1690
+ }
1691
+ return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
1692
+ }
1693
+ executeStateless$(request) {
1694
+ this.executionInProgress$.next(true);
1695
+ return this.configurationService.state$.pipe(first(), switchMap(state => {
1696
+ var _a;
1697
+ // Apply actions and execute configuration/price call
1698
+ // No need to run configuration if no actions in the request
1699
+ if (!((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
1700
+ return of(undefined);
1701
+ }
1702
+ request.actions.forEach(action => {
1703
+ var _a;
1704
+ state = (_a = this.executeActionScript(state, action)) !== null && _a !== void 0 ? _a : state;
1705
+ });
1706
+ return this.configurationService.configure$(state);
1707
+ }), map(() => {
1708
+ // Run selectors and apply them to the state
1709
+ const configurationState = this.configurationService.state;
1710
+ if (!configurationState) {
1711
+ return { stateId: '', selectors: {} };
1712
+ }
1713
+ return this.runStatelessSelectors(request, configurationState);
1714
+ }), tap(() => this.executionInProgress$.next(false)), catchError(error => {
1715
+ const configurationState = this.configurationService.previousState;
1716
+ if (configurationState) {
1717
+ const selectorsResult = this.runStatelessSelectors(request, configurationState);
1718
+ this.handleSelectorsResponse(selectorsResult.selectors);
1719
+ }
1720
+ this.executionInProgress$.next(false);
1721
+ if (!this.configurationRuntimeService.uiDefinitionProps.suppressToastMessages) {
1722
+ this.toastService.add({ severity: ToastType.error, summary: String(error) });
1723
+ }
1724
+ return throwError(() => error);
1725
+ }));
1726
+ }
1727
+ initBufferedRequest$() {
1728
+ return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap(requests => {
1729
+ if (!this.flowStateService.stateId || !this.stateId) {
1730
+ throw 'Stateful session is not initialized';
1731
+ }
1732
+ // merge buffered requests
1733
+ const request = {
1734
+ actions: requests.flatMap(({ actions }) => actions).filter(isDefined),
1735
+ selectors: requests
1736
+ .map(({ selectors }) => selectors)
1737
+ .filter(isDefined)
1738
+ .reduce((acc, selectorsMap) => Object.assign(acc, selectorsMap), {}),
1739
+ };
1740
+ this.executionInProgress$.next(true);
1741
+ return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request);
1742
+ }), tap(({ stateId }) => (this.stateId = stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError(e => {
1743
+ this.executionInProgress$.next(false);
1744
+ return throwError(() => e);
1745
+ }));
1746
+ }
1747
+ executeStateful$(request) {
1748
+ return this.executionInProgress$.pipe(filter(inProgress => !inProgress), take(1), switchMap(() =>
1749
+ // make sure stream switches to statefulExecutionRequest$ before pushing an execution request
1750
+ combineLatest([
1751
+ this.statefulExecutionRequest$,
1752
+ of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
1753
+ ])), map(([response]) => response), take(1));
1754
+ }
1755
+ executeActionScript(request, processor) {
1756
+ var _a;
1757
+ const { actions } = (_a = this.configurationRuntimeService.uiDefinitionContainer) !== null && _a !== void 0 ? _a : {};
1758
+ const configurationProcessor = actions === null || actions === void 0 ? void 0 : actions.find(action => action.apiName === processor.apiName);
1759
+ if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
1760
+ throw `ConfigurationProcessor ${processor.apiName} not found`;
1761
+ }
1762
+ return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
1763
+ }
1764
+ executeSelectorScript(request, processor) {
1765
+ var _a;
1766
+ const { selectors } = (_a = this.configurationRuntimeService.uiDefinitionContainer) !== null && _a !== void 0 ? _a : {};
1767
+ const configurationProcessor = selectors === null || selectors === void 0 ? void 0 : selectors.find(selector => selector.apiName === processor.apiName);
1768
+ if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
1769
+ throw `ConfigurationProcessor ${processor.apiName} not found`;
1770
+ }
1771
+ return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
1772
+ }
1773
+ executeProcessorScript(request, configurationProcessor, inputData) {
1774
+ let functionToExecute = this.executedFunctions[configurationProcessor.apiName];
1775
+ if (!functionToExecute) {
1776
+ const script = `${configurationProcessor.script}\nreturn transform;`;
1777
+ const sourceMap = `\n//# sourceURL=${configurationProcessor.apiName}.js`;
1778
+ functionToExecute = new Function(script + sourceMap)();
1779
+ this.executedFunctions[configurationProcessor.apiName] = functionToExecute;
1780
+ }
1781
+ return functionToExecute({
1782
+ request,
1783
+ inputData,
1784
+ flowStore: this.flowStateService.getFlowStore(),
1785
+ configurationStore: this.configurationStore,
1786
+ });
1787
+ }
1788
+ runStatelessSelectors(request, configurationState) {
1789
+ var _a;
1790
+ return EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
1791
+ try {
1792
+ result.selectors[key] = {
1793
+ success: true,
1794
+ result: this.executeSelectorScript(configurationState, selector),
1795
+ };
1796
+ }
1797
+ catch (e) {
1798
+ console.error(e);
1799
+ result.selectors[key] = {
1800
+ success: false,
1801
+ errorMessage: String(e),
1802
+ };
1803
+ }
1804
+ return result;
1805
+ }, { stateId: '', selectors: {} });
1806
+ }
1807
+ }
1808
+ ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i3.FlowStateApiService }, { token: SalesTransactionService }, { token: i1.SalesTransactionApiService }, { token: i6.ToastService }, { token: i1.PCMApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1809
+ ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
1810
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, decorators: [{
1811
+ type: Injectable
1812
+ }], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: FlowStateService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i3.FlowStateApiService }, { type: SalesTransactionService }, { type: i1.SalesTransactionApiService }, { type: i6.ToastService }, { type: i1.PCMApiService }]; } });
1813
+
1814
+ class ConfigurationModule {
1815
+ }
1816
+ ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1817
+ ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule, ApiModule] });
1818
+ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, providers: [
1819
+ ConfigurationService,
1820
+ ConfigurationStateService,
1821
+ ConfigurationRuntimeService,
1822
+ TestModeConfigurationService,
1823
+ GuidedSellingService,
1824
+ ], imports: [ConfirmationDialogModule, ApiModule] });
1825
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
1826
+ type: NgModule,
1827
+ args: [{
1828
+ imports: [ConfirmationDialogModule, ApiModule],
1829
+ providers: [
1830
+ ConfigurationService,
1831
+ ConfigurationStateService,
1832
+ ConfigurationRuntimeService,
1833
+ TestModeConfigurationService,
1834
+ GuidedSellingService,
1835
+ ],
1836
+ }]
1837
+ }] });
1838
+
1839
+ class FlowConfigurationModule {
1840
+ }
1841
+ FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1842
+ FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, imports: [ApiModule] });
1843
+ FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService], imports: [ApiModule] });
1844
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
1845
+ type: NgModule,
1846
+ args: [{
1847
+ imports: [ApiModule],
1848
+ providers: [FlowConfigurationService],
1849
+ }]
1850
+ }] });
1851
+
1852
+ const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
1853
+
1854
+ const UI_DEFINITION_VERSION = 3;
1855
+
1856
+ const DEFAULT_FORMATTING_SETTINGS = {
1857
+ currencySymbol: DEFAULT_CURRENCY_SYMBOL,
1858
+ decimalsCount: DEFAULT_DECIMALS_COUNT,
1859
+ dateFormats: getSupportedDateFormats(DEFAULT_DATE_FORMAT),
1860
+ decimalSeparator: DEFAULT_DECIMAL_SEPARATOR,
1861
+ thousandsSeparator: DEFAULT_THOUSANDS_SEPARATOR,
1862
+ actionCodeLabels: DEFAULT_ACTION_CODE_LABELS,
1863
+ };
1864
+ class SdkCoreModule {
1865
+ }
1866
+ SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1867
+ SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
1868
+ SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, providers: [
1869
+ FlowInfoService,
1870
+ ProductImagesService,
1871
+ IntegrationState,
1872
+ FlowStateService,
1873
+ FlowStateConfigurationService,
1874
+ RuntimeSettingsService,
1875
+ SalesTransactionService,
1876
+ CatalogProductsService,
1877
+ {
1878
+ provide: FORMATTING_SETTINGS_TOKEN,
1879
+ useExisting: RuntimeSettingsService,
1880
+ },
1881
+ ], imports: [ConfigurationModule, FlowConfigurationModule] });
1882
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, decorators: [{
1883
+ type: NgModule,
1884
+ args: [{
1885
+ imports: [ConfigurationModule, FlowConfigurationModule],
1886
+ providers: [
1887
+ FlowInfoService,
1888
+ ProductImagesService,
1889
+ IntegrationState,
1890
+ FlowStateService,
1891
+ FlowStateConfigurationService,
1892
+ RuntimeSettingsService,
1893
+ SalesTransactionService,
1894
+ CatalogProductsService,
1895
+ {
1896
+ provide: FORMATTING_SETTINGS_TOKEN,
1897
+ useExisting: RuntimeSettingsService,
1898
+ },
1899
+ ],
1900
+ }]
1901
+ }] });
1902
+
1903
+ class CalendarDirective {
1904
+ constructor() {
1905
+ var _a;
1906
+ this.ngControl = inject(NgControl, { host: true, optional: true });
1907
+ this.formattingSettings = (_a = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })) === null || _a === void 0 ? void 0 : _a.getFormattingSettings();
1908
+ this.destroy$ = new Subject();
1909
+ }
1910
+ set vlCalendar(calendar) {
1911
+ this.calendar = calendar;
1912
+ }
1913
+ ngOnDestroy() {
1914
+ this.destroy$.next();
1915
+ this.destroy$.complete();
1916
+ }
1917
+ ngOnInit() {
1918
+ var _a, _b;
1919
+ if (this.calendar) {
1920
+ this.calendar.dateFormat = (_b = (_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.dateFormats.primengFormat) !== null && _b !== void 0 ? _b : DEFAULT_DATE_FORMAT;
1921
+ if (this.ngControl && this.ngControl.control) {
1922
+ const control = this.ngControl.control;
1923
+ control.setValue(control.value, { emitEvent: false });
1924
+ }
1925
+ }
1926
+ }
1927
+ }
1928
+ CalendarDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1929
+ CalendarDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: CalendarDirective, selector: "[vlCalendar]", inputs: { vlCalendar: "vlCalendar" }, ngImport: i0 });
1930
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarDirective, decorators: [{
1931
+ type: Directive,
1932
+ args: [{
1933
+ selector: '[vlCalendar]',
1934
+ }]
1935
+ }], propDecorators: { vlCalendar: [{
1936
+ type: Input
1937
+ }] } });
1938
+
1939
+ class SdkDirectivesModule {
1940
+ }
1941
+ SdkDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1942
+ SdkDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, declarations: [CalendarDirective], exports: [CalendarDirective] });
1943
+ SdkDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule });
1944
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, decorators: [{
1945
+ type: NgModule,
1946
+ args: [{
1947
+ declarations: [CalendarDirective],
1948
+ exports: [CalendarDirective],
1949
+ }]
1950
+ }] });
1951
+
1952
+ function filterSuccessfulExecute() {
1953
+ return (source) => source.pipe(filter((result) => result.success), map(r => r.result));
1954
+ }
1955
+
1956
+ class DatePipe {
1957
+ constructor() {
1958
+ var _a;
1959
+ this.locale = inject(LOCALE_ID);
1960
+ this.defaultOptions = inject(DATE_PIPE_DEFAULT_OPTIONS, { optional: true });
1961
+ this.formattingSettings = (_a = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })) === null || _a === void 0 ? void 0 : _a.getFormattingSettings();
1962
+ this.destroy$ = new Subject();
1963
+ }
1964
+ ngOnDestroy() {
1965
+ this.destroy$.next();
1966
+ this.destroy$.complete();
1967
+ }
1968
+ transform(date, type = 'date') {
1969
+ var _a, _b;
1970
+ if (!date) {
1971
+ return '';
1972
+ }
1973
+ const dateFormat = ((_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.dateFormats.datePipeFormat) || DEFAULT_DATE_FORMAT;
1974
+ const formatMap = {
1975
+ date: dateFormat,
1976
+ time: DEFAULT_TIME_FORMAT,
1977
+ datetime: `${dateFormat} ${DEFAULT_TIME_FORMAT}`,
1978
+ };
1979
+ try {
1980
+ return formatDate(date, formatMap[type], this.locale, (_b = this.defaultOptions) === null || _b === void 0 ? void 0 : _b.timezone);
1981
+ }
1982
+ catch (error) {
1983
+ return new Date(date).toString();
1984
+ }
1985
+ }
1986
+ }
1987
+ DatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1988
+ DatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, name: "vlDate" });
1989
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, decorators: [{
1990
+ type: Pipe,
1991
+ args: [{
1992
+ name: 'vlDate',
1993
+ }]
1994
+ }] });
1995
+
1996
+ class NumberPipe {
1997
+ constructor() {
1998
+ var _a;
1999
+ this.formattingSettings = (_a = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })) === null || _a === void 0 ? void 0 : _a.getFormattingSettings();
2000
+ this.destroy$ = new Subject();
2001
+ }
2002
+ ngOnDestroy() {
2003
+ this.destroy$.next();
2004
+ this.destroy$.complete();
2005
+ }
2006
+ transform(price) {
2007
+ var _a, _b, _c;
2008
+ return formatNumber(price, (_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.thousandsSeparator, (_b = this.formattingSettings) === null || _b === void 0 ? void 0 : _b.decimalSeparator, (_c = this.formattingSettings) === null || _c === void 0 ? void 0 : _c.decimalsCount);
2009
+ }
2010
+ }
2011
+ NumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2012
+ NumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, name: "vlNumber" });
2013
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, decorators: [{
2014
+ type: Pipe,
2015
+ args: [{
2016
+ name: 'vlNumber',
2017
+ }]
2018
+ }] });
2019
+
2020
+ class PricePipe {
2021
+ constructor() {
2022
+ var _a;
2023
+ this.formattingSettings = (_a = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })) === null || _a === void 0 ? void 0 : _a.getFormattingSettings();
2024
+ this.destroy$ = new Subject();
2025
+ }
2026
+ ngOnDestroy() {
2027
+ this.destroy$.next();
2028
+ this.destroy$.complete();
2029
+ }
2030
+ transform(price) {
2031
+ var _a, _b, _c, _d;
2032
+ if (price == null || price === '') {
2033
+ return '';
2034
+ }
2035
+ return `${((_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.currencySymbol) || DEFAULT_CURRENCY_SYMBOL}${formatNumber(price, (_b = this.formattingSettings) === null || _b === void 0 ? void 0 : _b.thousandsSeparator, (_c = this.formattingSettings) === null || _c === void 0 ? void 0 : _c.decimalSeparator, (_d = this.formattingSettings) === null || _d === void 0 ? void 0 : _d.decimalsCount)}`;
2036
+ }
2037
+ }
2038
+ PricePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2039
+ PricePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, name: "vlPrice" });
2040
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, decorators: [{
2041
+ type: Pipe,
2042
+ args: [{
2043
+ name: 'vlPrice',
2044
+ }]
2045
+ }] });
2046
+
2047
+ class ActionCodePipe {
2048
+ constructor() {
2049
+ var _a;
2050
+ this.formattingSettings = (_a = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })) === null || _a === void 0 ? void 0 : _a.getFormattingSettings();
2051
+ }
2052
+ transform(actionCode) {
2053
+ var _a, _b;
2054
+ return (_b = (_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.actionCodeLabels[actionCode]) !== null && _b !== void 0 ? _b : actionCode;
2055
+ }
2056
+ }
2057
+ ActionCodePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2058
+ ActionCodePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, name: "vlActionCode" });
2059
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, decorators: [{
2060
+ type: Pipe,
2061
+ args: [{
2062
+ name: 'vlActionCode',
2063
+ }]
2064
+ }] });
2065
+
2066
+ class SdkPipesModule {
2067
+ }
2068
+ SdkPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2069
+ SdkPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, declarations: [NumberPipe, PricePipe, DatePipe, ActionCodePipe], exports: [NumberPipe, PricePipe, DatePipe, ActionCodePipe] });
2070
+ SdkPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule });
2071
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, decorators: [{
2072
+ type: NgModule,
2073
+ args: [{
2074
+ declarations: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
2075
+ exports: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
2076
+ }]
2077
+ }] });
2078
+
2079
+ /**
2080
+ * Generated bundle index. Do not edit.
2081
+ */
2082
+
2083
+ export { ActionCodePipe, CalendarDirective, CatalogProductsService, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, GuidedSellingService, IntegrationState, NumberPipe, PCMUtils, PricePipe, ProductImagesService, RuntimeSettingsService, SalesTransactionService, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, TestModeConfigurationService, TransactionItemWorker, UI_DEFINITION_VERSION, extractMetadata, filterSuccessfulExecute, findTransactionItem, findTransactionItemWithComparator, flattenTransactionItem, generateTransactionItem, generateTransactionItemFromPCM, insertTransactionItem, removeTransactionItem, replaceTransactionItem, updateQuantity };
2084
+ //# sourceMappingURL=veloceapps-sdk-core.mjs.map