@veloceapps/sdk 5.0.13-0

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 (387) hide show
  1. package/README.md +3 -0
  2. package/bundles/veloceapps-sdk-cms.umd.js +1975 -0
  3. package/bundles/veloceapps-sdk-cms.umd.js.map +1 -0
  4. package/bundles/veloceapps-sdk-core.umd.js +1610 -0
  5. package/bundles/veloceapps-sdk-core.umd.js.map +1 -0
  6. package/bundles/veloceapps-sdk-runtime.umd.js +4349 -0
  7. package/bundles/veloceapps-sdk-runtime.umd.js.map +1 -0
  8. package/bundles/veloceapps-sdk.umd.js +3307 -0
  9. package/bundles/veloceapps-sdk.umd.js.map +1 -0
  10. package/cms/cms.actions.d.ts +28 -0
  11. package/cms/cms.default.d.ts +5 -0
  12. package/cms/cms.elements.d.ts +4 -0
  13. package/cms/components/element-children/element-children.component.d.ts +10 -0
  14. package/cms/components/element-children/element-children.module.d.ts +8 -0
  15. package/cms/components/element-renderer/element-renderer.component.d.ts +36 -0
  16. package/cms/components/element-renderer/element-renderer.module.d.ts +7 -0
  17. package/cms/components/element.component.d.ts +17 -0
  18. package/cms/components/index.d.ts +1 -0
  19. package/cms/components/plugin.component.d.ts +15 -0
  20. package/cms/components/preview/index.d.ts +2 -0
  21. package/cms/components/preview/preview.component.d.ts +34 -0
  22. package/cms/components/preview/preview.module.d.ts +11 -0
  23. package/cms/decorators/element.decorator.d.ts +2 -0
  24. package/cms/decorators/index.d.ts +1 -0
  25. package/cms/directives/custom-template.directive.d.ts +12 -0
  26. package/cms/engine/models/entity.d.ts +11 -0
  27. package/cms/engine/models/plugin.d.ts +5 -0
  28. package/cms/index.d.ts +11 -0
  29. package/cms/injection-tokens.d.ts +11 -0
  30. package/cms/launcher.module.d.ts +10 -0
  31. package/cms/modules/federated/default-options.d.ts +4 -0
  32. package/cms/modules/federated/export.d.ts +1 -0
  33. package/cms/modules/federated/federated.component.d.ts +26 -0
  34. package/cms/modules/federated/federated.module.d.ts +9 -0
  35. package/cms/modules/federated/federated.types.d.ts +30 -0
  36. package/cms/modules/federated/federated.utils.d.ts +1 -0
  37. package/cms/package.json +10 -0
  38. package/cms/plugins/configuration.plugin.d.ts +23 -0
  39. package/cms/plugins/io.plugin.d.ts +9 -0
  40. package/cms/plugins/script.plugin.d.ts +13 -0
  41. package/cms/services/dynamic-module.service.d.ts +15 -0
  42. package/cms/services/element-context.service.d.ts +8 -0
  43. package/cms/services/index.d.ts +3 -0
  44. package/cms/services/integration.state.d.ts +17 -0
  45. package/cms/services/io-provider.service.d.ts +15 -0
  46. package/cms/services/launcher.service.d.ts +18 -0
  47. package/cms/services/templates.service.d.ts +14 -0
  48. package/cms/types/common.types.d.ts +108 -0
  49. package/cms/types/compilation.types.d.ts +6 -0
  50. package/cms/types/configuration.types.d.ts +20 -0
  51. package/cms/types/elements.types.d.ts +2 -0
  52. package/cms/types/index.d.ts +7 -0
  53. package/cms/types/integration.types.d.ts +4 -0
  54. package/cms/types/metrics.types.d.ts +5 -0
  55. package/cms/types/path.types.d.ts +11 -0
  56. package/cms/utils/element.utils.d.ts +17 -0
  57. package/cms/utils/elements-resolver.d.ts +24 -0
  58. package/cms/utils/index.d.ts +3 -0
  59. package/cms/utils/path.utils.d.ts +5 -0
  60. package/cms/veloceapps-sdk-cms.d.ts +5 -0
  61. package/cms/vendor-map.d.ts +708 -0
  62. package/core/core.module.d.ts +8 -0
  63. package/core/index.d.ts +6 -0
  64. package/core/modules/configuration/configuration.module.d.ts +7 -0
  65. package/core/modules/configuration/helpers.d.ts +3 -0
  66. package/core/modules/configuration/index.d.ts +4 -0
  67. package/core/modules/configuration/services/configuration-runtime.service.d.ts +29 -0
  68. package/core/modules/configuration/services/configuration.service.d.ts +45 -0
  69. package/core/modules/configuration/services/runtime-context.service.d.ts +12 -0
  70. package/core/modules/configuration/types/configuration-runtime.types.d.ts +7 -0
  71. package/core/modules/flow-configuration/flow-configuration.module.d.ts +6 -0
  72. package/core/modules/flow-configuration/index.d.ts +4 -0
  73. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +38 -0
  74. package/core/modules/flow-configuration/services/flow-update.service.d.ts +12 -0
  75. package/core/modules/flow-configuration/types/update.types.d.ts +12 -0
  76. package/core/modules/index.d.ts +2 -0
  77. package/core/package.json +10 -0
  78. package/core/services/context.service.d.ts +18 -0
  79. package/core/services/index.d.ts +3 -0
  80. package/core/services/product-images.service.d.ts +12 -0
  81. package/core/services/quote-draft.service.d.ts +62 -0
  82. package/core/types/index.d.ts +3 -0
  83. package/core/types/quote-states.types.d.ts +6 -0
  84. package/core/types/runtime.types.d.ts +31 -0
  85. package/core/types/ui-definition.types.d.ts +26 -0
  86. package/core/utils/index.d.ts +2 -0
  87. package/core/utils/line-item.utils.d.ts +26 -0
  88. package/core/utils/line-item.worker.d.ts +12 -0
  89. package/core/veloceapps-sdk-core.d.ts +5 -0
  90. package/esm2015/cms/cms.actions.js +47 -0
  91. package/esm2015/cms/cms.default.js +6 -0
  92. package/esm2015/cms/cms.elements.js +29 -0
  93. package/esm2015/cms/components/element-children/element-children.component.js +23 -0
  94. package/esm2015/cms/components/element-children/element-children.module.js +18 -0
  95. package/esm2015/cms/components/element-renderer/element-renderer.component.js +169 -0
  96. package/esm2015/cms/components/element-renderer/element-renderer.module.js +16 -0
  97. package/esm2015/cms/components/element.component.js +44 -0
  98. package/esm2015/cms/components/index.js +2 -0
  99. package/esm2015/cms/components/plugin.component.js +16 -0
  100. package/esm2015/cms/components/preview/index.js +3 -0
  101. package/esm2015/cms/components/preview/preview.component.js +108 -0
  102. package/esm2015/cms/components/preview/preview.module.js +23 -0
  103. package/esm2015/cms/decorators/element.decorator.js +6 -0
  104. package/esm2015/cms/decorators/index.js +2 -0
  105. package/esm2015/cms/directives/custom-template.directive.js +25 -0
  106. package/esm2015/cms/engine/models/entity.js +18 -0
  107. package/esm2015/cms/engine/models/plugin.js +6 -0
  108. package/esm2015/cms/index.js +11 -0
  109. package/esm2015/cms/injection-tokens.js +8 -0
  110. package/esm2015/cms/launcher.module.js +23 -0
  111. package/esm2015/cms/modules/federated/default-options.js +5 -0
  112. package/esm2015/cms/modules/federated/export.js +2 -0
  113. package/esm2015/cms/modules/federated/federated.component.js +82 -0
  114. package/esm2015/cms/modules/federated/federated.module.js +19 -0
  115. package/esm2015/cms/modules/federated/federated.types.js +2 -0
  116. package/esm2015/cms/modules/federated/federated.utils.js +37 -0
  117. package/esm2015/cms/plugins/configuration.plugin.js +98 -0
  118. package/esm2015/cms/plugins/io.plugin.js +37 -0
  119. package/esm2015/cms/plugins/script.plugin.js +66 -0
  120. package/esm2015/cms/services/dynamic-module.service.js +33 -0
  121. package/esm2015/cms/services/element-context.service.js +10 -0
  122. package/esm2015/cms/services/index.js +4 -0
  123. package/esm2015/cms/services/integration.state.js +40 -0
  124. package/esm2015/cms/services/io-provider.service.js +51 -0
  125. package/esm2015/cms/services/launcher.service.js +57 -0
  126. package/esm2015/cms/services/templates.service.js +31 -0
  127. package/esm2015/cms/types/common.types.js +2 -0
  128. package/esm2015/cms/types/compilation.types.js +2 -0
  129. package/esm2015/cms/types/configuration.types.js +2 -0
  130. package/esm2015/cms/types/elements.types.js +2 -0
  131. package/esm2015/cms/types/index.js +8 -0
  132. package/esm2015/cms/types/integration.types.js +2 -0
  133. package/esm2015/cms/types/metrics.types.js +2 -0
  134. package/esm2015/cms/types/path.types.js +2 -0
  135. package/esm2015/cms/utils/element.utils.js +161 -0
  136. package/esm2015/cms/utils/elements-resolver.js +147 -0
  137. package/esm2015/cms/utils/index.js +4 -0
  138. package/esm2015/cms/utils/path.utils.js +67 -0
  139. package/esm2015/cms/veloceapps-sdk-cms.js +5 -0
  140. package/esm2015/cms/vendor-map.js +34 -0
  141. package/esm2015/core/core.module.js +18 -0
  142. package/esm2015/core/index.js +7 -0
  143. package/esm2015/core/modules/configuration/configuration.module.js +34 -0
  144. package/esm2015/core/modules/configuration/helpers.js +10 -0
  145. package/esm2015/core/modules/configuration/index.js +5 -0
  146. package/esm2015/core/modules/configuration/services/configuration-runtime.service.js +92 -0
  147. package/esm2015/core/modules/configuration/services/configuration.service.js +173 -0
  148. package/esm2015/core/modules/configuration/services/runtime-context.service.js +51 -0
  149. package/esm2015/core/modules/configuration/types/configuration-runtime.types.js +2 -0
  150. package/esm2015/core/modules/flow-configuration/flow-configuration.module.js +18 -0
  151. package/esm2015/core/modules/flow-configuration/index.js +5 -0
  152. package/esm2015/core/modules/flow-configuration/services/flow-configuration.service.js +135 -0
  153. package/esm2015/core/modules/flow-configuration/services/flow-update.service.js +129 -0
  154. package/esm2015/core/modules/flow-configuration/types/update.types.js +2 -0
  155. package/esm2015/core/modules/index.js +3 -0
  156. package/esm2015/core/services/context.service.js +50 -0
  157. package/esm2015/core/services/index.js +4 -0
  158. package/esm2015/core/services/product-images.service.js +30 -0
  159. package/esm2015/core/services/quote-draft.service.js +207 -0
  160. package/esm2015/core/types/index.js +4 -0
  161. package/esm2015/core/types/quote-states.types.js +2 -0
  162. package/esm2015/core/types/runtime.types.js +16 -0
  163. package/esm2015/core/types/ui-definition.types.js +2 -0
  164. package/esm2015/core/utils/index.js +3 -0
  165. package/esm2015/core/utils/line-item.utils.js +100 -0
  166. package/esm2015/core/utils/line-item.worker.js +19 -0
  167. package/esm2015/core/veloceapps-sdk-core.js +5 -0
  168. package/esm2015/index.js +2 -0
  169. package/esm2015/runtime/components/component-preview/component-preview.component.js +125 -0
  170. package/esm2015/runtime/components/index.js +5 -0
  171. package/esm2015/runtime/components/section-renderer/section-renderer.component.js +71 -0
  172. package/esm2015/runtime/components/ui-runtime/runtime.component.js +429 -0
  173. package/esm2015/runtime/components/ui-runtime-preview/runtime-preview.component.js +109 -0
  174. package/esm2015/runtime/execution/components/children-placeholder/children-placeholder.component.js +68 -0
  175. package/esm2015/runtime/execution/components/context-provider/context-provider.component.js +36 -0
  176. package/esm2015/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.js +72 -0
  177. package/esm2015/runtime/execution/components/federated/federated.component.js +81 -0
  178. package/esm2015/runtime/execution/components/velo-attribute/velo-attribute.component.js +65 -0
  179. package/esm2015/runtime/execution/components/velo-multiselect/velo-multiselect.component.js +136 -0
  180. package/esm2015/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.js +80 -0
  181. package/esm2015/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.js +101 -0
  182. package/esm2015/runtime/execution/components/velo-port-radio/velo-port-radio.component.js +150 -0
  183. package/esm2015/runtime/execution/components/velo-type/velo-type.component.js +121 -0
  184. package/esm2015/runtime/execution/directives/section-script.directive.js +242 -0
  185. package/esm2015/runtime/execution/directives/sf-query.directive.js +34 -0
  186. package/esm2015/runtime/execution/directives/velo-attribute.directive.js +86 -0
  187. package/esm2015/runtime/execution/directives/velo-port.directive.js +373 -0
  188. package/esm2015/runtime/execution/directives/vl-approval.directive.js +22 -0
  189. package/esm2015/runtime/execution/directives/vl-document-attachments.directive.js +35 -0
  190. package/esm2015/runtime/execution/directives/vl-document-templates.directive.js +59 -0
  191. package/esm2015/runtime/execution/directives/vl-quote.directive.js +41 -0
  192. package/esm2015/runtime/execution/directives/vl-ramp.directive.js +51 -0
  193. package/esm2015/runtime/execution/runtime-execution.module.js +163 -0
  194. package/esm2015/runtime/execution/utils/federated.util.js +37 -0
  195. package/esm2015/runtime/index.js +5 -0
  196. package/esm2015/runtime/runtime.module.js +104 -0
  197. package/esm2015/runtime/services/cart.service.js +27 -0
  198. package/esm2015/runtime/services/collapsible-state.service.js +34 -0
  199. package/esm2015/runtime/services/configuration.service.js +102 -0
  200. package/esm2015/runtime/services/current-state.service.js +17 -0
  201. package/esm2015/runtime/services/form-scope.service.js +30 -0
  202. package/esm2015/runtime/services/index.js +4 -0
  203. package/esm2015/runtime/services/product-model-cache.service.js +30 -0
  204. package/esm2015/runtime/services/runtime-context.service.js +56 -0
  205. package/esm2015/runtime/services/runtime-form.service.js +224 -0
  206. package/esm2015/runtime/services/runtime.service.js +108 -0
  207. package/esm2015/runtime/services/section-helper.service.js +27 -0
  208. package/esm2015/runtime/services/section-scope.service.js +36 -0
  209. package/esm2015/runtime/services/section-store.service.js +22 -0
  210. package/esm2015/runtime/services/section.service.js +124 -0
  211. package/esm2015/runtime/types/bound-data.types.js +7 -0
  212. package/esm2015/runtime/types/index.js +2 -0
  213. package/esm2015/runtime/types/runtime.types.js +2 -0
  214. package/esm2015/runtime/types/script-registry.types.js +51 -0
  215. package/esm2015/runtime/utils/line-item.util.js +273 -0
  216. package/esm2015/runtime/utils/section.utils.js +26 -0
  217. package/esm2015/runtime/utils/sections-binder.helper.js +105 -0
  218. package/esm2015/runtime/veloceapps-sdk-runtime.js +5 -0
  219. package/esm2015/src/components/dialog/dialog.component.js +30 -0
  220. package/esm2015/src/components/dialog/dialog.module.js +19 -0
  221. package/esm2015/src/components/dialog/dialog.types.js +2 -0
  222. package/esm2015/src/components/doc-gen/doc-gen.component.js +109 -0
  223. package/esm2015/src/components/doc-gen/doc-gen.module.js +19 -0
  224. package/esm2015/src/components/header/cart-overlay/cart-preview.component.js +122 -0
  225. package/esm2015/src/components/header/cart-overlay/cart-preview.module.js +46 -0
  226. package/esm2015/src/components/header/header.component.js +310 -0
  227. package/esm2015/src/components/header/header.module.js +50 -0
  228. package/esm2015/src/components/header/header.types.js +2 -0
  229. package/esm2015/src/components/header/metrics/index.js +2 -0
  230. package/esm2015/src/components/header/metrics/metrics.component.js +216 -0
  231. package/esm2015/src/components/header/metrics/metrics.definitions.js +9 -0
  232. package/esm2015/src/components/header/metrics/metrics.module.js +67 -0
  233. package/esm2015/src/constants.js +2 -0
  234. package/esm2015/src/flow-routing.module.js +137 -0
  235. package/esm2015/src/flow.component.js +45 -0
  236. package/esm2015/src/flow.module.js +60 -0
  237. package/esm2015/src/guards/context.guard.js +84 -0
  238. package/esm2015/src/guards/index.js +2 -0
  239. package/esm2015/src/guards/product-unload.guard.js +43 -0
  240. package/esm2015/src/guards/root.guard.js +41 -0
  241. package/esm2015/src/index.js +7 -0
  242. package/esm2015/src/pages/catalog/catalog.component.js +117 -0
  243. package/esm2015/src/pages/catalog/catalog.module.js +20 -0
  244. package/esm2015/src/pages/debug/debug.component.js +61 -0
  245. package/esm2015/src/pages/debug/debug.module.js +48 -0
  246. package/esm2015/src/pages/empty-account/empty-account.component.js +17 -0
  247. package/esm2015/src/pages/empty-account/empty-account.module.js +20 -0
  248. package/esm2015/src/pages/legacy-product/legacy-product.component.js +132 -0
  249. package/esm2015/src/pages/legacy-product/legacy-product.module.js +21 -0
  250. package/esm2015/src/pages/product/product.component.js +108 -0
  251. package/esm2015/src/pages/product/product.module.js +20 -0
  252. package/esm2015/src/pages/record-not-found/record-not-found.component.js +29 -0
  253. package/esm2015/src/pages/record-not-found/record-not-found.module.js +20 -0
  254. package/esm2015/src/pages/remote/remote.component.js +353 -0
  255. package/esm2015/src/pages/remote/remote.module.js +20 -0
  256. package/esm2015/src/pages/remote/remote.types.js +2 -0
  257. package/esm2015/src/pages/shopping-cart/shopping-cart.component.js +117 -0
  258. package/esm2015/src/pages/shopping-cart/shopping-cart.module.js +20 -0
  259. package/esm2015/src/resolvers/flow.resolver.js +62 -0
  260. package/esm2015/src/resolvers/quote.resolver.js +74 -0
  261. package/esm2015/src/services/doc-gen.service.js +33 -0
  262. package/esm2015/src/services/flow-dialog.service.js +123 -0
  263. package/esm2015/src/services/flow-router.service.js +136 -0
  264. package/esm2015/src/services/flow.service.js +77 -0
  265. package/esm2015/src/services/index.js +2 -0
  266. package/esm2015/src/types/context-route.types.js +2 -0
  267. package/esm2015/src/types/flow-customization.types.js +3 -0
  268. package/esm2015/src/types/index.js +3 -0
  269. package/esm2015/src/types/route.types.js +2 -0
  270. package/esm2015/src/utils/flow.utils.js +22 -0
  271. package/esm2015/src/utils/index.js +2 -0
  272. package/esm2015/veloceapps-sdk.js +5 -0
  273. package/fesm2015/veloceapps-sdk-cms.js +1443 -0
  274. package/fesm2015/veloceapps-sdk-cms.js.map +1 -0
  275. package/fesm2015/veloceapps-sdk-core.js +1035 -0
  276. package/fesm2015/veloceapps-sdk-core.js.map +1 -0
  277. package/fesm2015/veloceapps-sdk-runtime.js +3896 -0
  278. package/fesm2015/veloceapps-sdk-runtime.js.map +1 -0
  279. package/fesm2015/veloceapps-sdk.js +2758 -0
  280. package/fesm2015/veloceapps-sdk.js.map +1 -0
  281. package/index.d.ts +1 -0
  282. package/package.json +50 -0
  283. package/runtime/components/component-preview/component-preview.component.d.ts +27 -0
  284. package/runtime/components/index.d.ts +4 -0
  285. package/runtime/components/section-renderer/section-renderer.component.d.ts +25 -0
  286. package/runtime/components/ui-runtime/runtime.component.d.ts +53 -0
  287. package/runtime/components/ui-runtime-preview/runtime-preview.component.d.ts +27 -0
  288. package/runtime/execution/components/children-placeholder/children-placeholder.component.d.ts +30 -0
  289. package/runtime/execution/components/context-provider/context-provider.component.d.ts +14 -0
  290. package/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.d.ts +25 -0
  291. package/runtime/execution/components/federated/federated.component.d.ts +36 -0
  292. package/runtime/execution/components/velo-attribute/velo-attribute.component.d.ts +19 -0
  293. package/runtime/execution/components/velo-multiselect/velo-multiselect.component.d.ts +35 -0
  294. package/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.d.ts +22 -0
  295. package/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.d.ts +22 -0
  296. package/runtime/execution/components/velo-port-radio/velo-port-radio.component.d.ts +28 -0
  297. package/runtime/execution/components/velo-type/velo-type.component.d.ts +31 -0
  298. package/runtime/execution/directives/section-script.directive.d.ts +59 -0
  299. package/runtime/execution/directives/sf-query.directive.d.ts +15 -0
  300. package/runtime/execution/directives/velo-attribute.directive.d.ts +26 -0
  301. package/runtime/execution/directives/velo-port.directive.d.ts +74 -0
  302. package/runtime/execution/directives/vl-approval.directive.d.ts +10 -0
  303. package/runtime/execution/directives/vl-document-attachments.directive.d.ts +15 -0
  304. package/runtime/execution/directives/vl-document-templates.directive.d.ts +33 -0
  305. package/runtime/execution/directives/vl-quote.directive.d.ts +14 -0
  306. package/runtime/execution/directives/vl-ramp.directive.d.ts +15 -0
  307. package/runtime/execution/runtime-execution.module.d.ts +27 -0
  308. package/runtime/execution/utils/federated.util.d.ts +6 -0
  309. package/runtime/index.d.ts +4 -0
  310. package/runtime/package.json +10 -0
  311. package/runtime/runtime.module.d.ts +18 -0
  312. package/runtime/services/cart.service.d.ts +15 -0
  313. package/runtime/services/collapsible-state.service.d.ts +15 -0
  314. package/runtime/services/configuration.service.d.ts +19 -0
  315. package/runtime/services/current-state.service.d.ts +8 -0
  316. package/runtime/services/form-scope.service.d.ts +20 -0
  317. package/runtime/services/index.d.ts +3 -0
  318. package/runtime/services/product-model-cache.service.d.ts +14 -0
  319. package/runtime/services/runtime-context.service.d.ts +16 -0
  320. package/runtime/services/runtime-form.service.d.ts +24 -0
  321. package/runtime/services/runtime.service.d.ts +43 -0
  322. package/runtime/services/section-helper.service.d.ts +8 -0
  323. package/runtime/services/section-scope.service.d.ts +14 -0
  324. package/runtime/services/section-store.service.d.ts +11 -0
  325. package/runtime/services/section.service.d.ts +30 -0
  326. package/runtime/types/bound-data.types.d.ts +13 -0
  327. package/runtime/types/index.d.ts +1 -0
  328. package/runtime/types/runtime.types.d.ts +19 -0
  329. package/runtime/types/script-registry.types.d.ts +13 -0
  330. package/runtime/utils/line-item.util.d.ts +34 -0
  331. package/runtime/utils/section.utils.d.ts +2 -0
  332. package/runtime/utils/sections-binder.helper.d.ts +16 -0
  333. package/runtime/veloceapps-sdk-runtime.d.ts +5 -0
  334. package/src/components/dialog/dialog.component.d.ts +13 -0
  335. package/src/components/dialog/dialog.module.d.ts +9 -0
  336. package/src/components/dialog/dialog.types.d.ts +6 -0
  337. package/src/components/doc-gen/doc-gen.component.d.ts +26 -0
  338. package/src/components/doc-gen/doc-gen.module.d.ts +9 -0
  339. package/src/components/header/cart-overlay/cart-preview.component.d.ts +36 -0
  340. package/src/components/header/cart-overlay/cart-preview.module.d.ts +14 -0
  341. package/src/components/header/header.component.d.ts +64 -0
  342. package/src/components/header/header.module.d.ts +15 -0
  343. package/src/components/header/header.types.d.ts +20 -0
  344. package/src/components/header/metrics/index.d.ts +1 -0
  345. package/src/components/header/metrics/metrics.component.d.ts +49 -0
  346. package/src/components/header/metrics/metrics.definitions.d.ts +4 -0
  347. package/src/components/header/metrics/metrics.module.d.ts +17 -0
  348. package/src/constants.d.ts +1 -0
  349. package/src/flow-routing.module.d.ts +13 -0
  350. package/src/flow.component.d.ts +23 -0
  351. package/src/flow.module.d.ts +16 -0
  352. package/src/guards/context.guard.d.ts +19 -0
  353. package/src/guards/index.d.ts +1 -0
  354. package/src/guards/product-unload.guard.d.ts +17 -0
  355. package/src/guards/root.guard.d.ts +15 -0
  356. package/src/index.d.ts +6 -0
  357. package/src/pages/catalog/catalog.component.d.ts +32 -0
  358. package/src/pages/catalog/catalog.module.d.ts +10 -0
  359. package/src/pages/debug/debug.component.d.ts +25 -0
  360. package/src/pages/debug/debug.module.d.ts +14 -0
  361. package/src/pages/empty-account/empty-account.component.d.ts +5 -0
  362. package/src/pages/empty-account/empty-account.module.d.ts +10 -0
  363. package/src/pages/legacy-product/legacy-product.component.d.ts +37 -0
  364. package/src/pages/legacy-product/legacy-product.module.d.ts +10 -0
  365. package/src/pages/product/product.component.d.ts +32 -0
  366. package/src/pages/product/product.module.d.ts +10 -0
  367. package/src/pages/record-not-found/record-not-found.component.d.ts +11 -0
  368. package/src/pages/record-not-found/record-not-found.module.d.ts +9 -0
  369. package/src/pages/remote/remote.component.d.ts +47 -0
  370. package/src/pages/remote/remote.module.d.ts +10 -0
  371. package/src/pages/remote/remote.types.d.ts +4 -0
  372. package/src/pages/shopping-cart/shopping-cart.component.d.ts +32 -0
  373. package/src/pages/shopping-cart/shopping-cart.module.d.ts +10 -0
  374. package/src/resolvers/flow.resolver.d.ts +16 -0
  375. package/src/resolvers/quote.resolver.d.ts +20 -0
  376. package/src/services/doc-gen.service.d.ts +13 -0
  377. package/src/services/flow-dialog.service.d.ts +26 -0
  378. package/src/services/flow-router.service.d.ts +36 -0
  379. package/src/services/flow.service.d.ts +17 -0
  380. package/src/services/index.d.ts +1 -0
  381. package/src/types/context-route.types.d.ts +5 -0
  382. package/src/types/flow-customization.types.d.ts +11 -0
  383. package/src/types/index.d.ts +2 -0
  384. package/src/types/route.types.d.ts +9 -0
  385. package/src/utils/flow.utils.d.ts +8 -0
  386. package/src/utils/index.d.ts +1 -0
  387. package/veloceapps-sdk.d.ts +5 -0
@@ -0,0 +1,3896 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, ViewContainerRef, Component, Input, ViewChild, Inject, EventEmitter, TemplateRef, ChangeDetectionStrategy, Output, Directive, HostBinding, NgModule, ViewChildren, ViewEncapsulation } from '@angular/core';
3
+ import * as i4 from '@angular/forms';
4
+ import { FormGroup, FormControl, NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
5
+ import * as i7 from '@veloceapps/core';
6
+ import { EntityUtil, UUID, SectionPathUtil, TypeValidators, ConfigurationMode, RuntimeModel, OrderByPipe, PricingUtils, PagedEntity, CoreModule, SalesforceIdUtils, SearchFilterPipe, ConfigurationContextMode } from '@veloceapps/core';
7
+ import * as i2 from '@veloceapps/sdk/core';
8
+ import { RuntimeMode, RuntimeStep, SdkCoreModule } from '@veloceapps/sdk/core';
9
+ import * as rxjs from 'rxjs';
10
+ import { Subject, BehaviorSubject, of, merge, combineLatest } from 'rxjs';
11
+ import * as _ from 'lodash';
12
+ import { keys, isUndefined, isNull, isString, isDate, set, values } from 'lodash';
13
+ import * as rxjsOperators from 'rxjs/operators';
14
+ import { map, take, tap, shareReplay, takeUntil } from 'rxjs/operators';
15
+ import * as i8 from '@veloceapps/components';
16
+ import { ConfirmationComponent, LoaderModule } from '@veloceapps/components';
17
+ import * as i1 from '@veloceapps/api';
18
+ import { ApiModule } from '@veloceapps/api';
19
+ import * as i3 from 'primeng/dynamicdialog';
20
+ import { DialogService } from 'primeng/dynamicdialog';
21
+ import * as i3$1 from 'primeng/api';
22
+ import { MessageService } from 'primeng/api';
23
+ import { __awaiter, __decorate } from 'tslib';
24
+ import { ScrollingModule as ScrollingModule$1 } from '@angular/cdk-experimental/scrolling';
25
+ import { ScrollingModule } from '@angular/cdk/scrolling';
26
+ import * as i5 from '@angular/common';
27
+ import { CurrencyPipe, DOCUMENT, CommonModule, DatePipe } from '@angular/common';
28
+ import '@angular/compiler';
29
+ import { VeloceElementsModule } from '@veloce/elements';
30
+ import * as i5$1 from 'ngx-bootstrap/popover';
31
+ import { PopoverModule } from 'ngx-bootstrap/popover';
32
+ import { TemplatePortal } from '@angular/cdk/portal';
33
+ import * as i1$1 from '@angular/cdk/overlay';
34
+ import * as moment from 'moment';
35
+ import { HttpErrorResponse } from '@angular/common/http';
36
+
37
+ class CollapsibleStateService {
38
+ constructor() {
39
+ this._collapsedSections = {}; // By Line Item Id
40
+ this.collapseSectionSubject = new Subject();
41
+ this.collapseSectionEvent = this.collapseSectionSubject.asObservable();
42
+ }
43
+ toggleCollapse(sectionId, silently) {
44
+ this._collapsedSections[sectionId] = !this.isCollapsedSection(sectionId);
45
+ if (!silently) {
46
+ this.collapseSectionSubject.next([sectionId, this._collapsedSections[sectionId]]);
47
+ }
48
+ }
49
+ collapse(sectionId) {
50
+ this._collapsedSections[sectionId] = true;
51
+ }
52
+ expand(sectionId) {
53
+ this._collapsedSections[sectionId] = false;
54
+ }
55
+ clearState(sectionId) {
56
+ delete this._collapsedSections[sectionId];
57
+ }
58
+ isCollapsedSection(sectionId) {
59
+ return this._collapsedSections[sectionId];
60
+ }
61
+ }
62
+ CollapsibleStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CollapsibleStateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
63
+ CollapsibleStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CollapsibleStateService });
64
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CollapsibleStateService, decorators: [{
65
+ type: Injectable
66
+ }], ctorParameters: function () { return []; } });
67
+
68
+ class ScriptRegistry {
69
+ constructor() {
70
+ this.store = new Map();
71
+ this.scope = new Map();
72
+ }
73
+ exists(scriptId) {
74
+ const sectionIds = this.store.get(scriptId);
75
+ return !EntityUtil.isEmpty(sectionIds);
76
+ }
77
+ isRegistered(scriptId, sectionId) {
78
+ const sectionIds = this.store.get(scriptId);
79
+ return !EntityUtil.isEmpty(sectionIds) && (sectionIds === null || sectionIds === void 0 ? void 0 : sectionIds.findIndex(entryId => entryId === sectionId)) !== -1;
80
+ }
81
+ doRegister(scriptId, sectionId) {
82
+ const sectionIds = this.store.get(scriptId);
83
+ if (!EntityUtil.isPresent(sectionIds)) {
84
+ this.store.set(scriptId, [sectionId]);
85
+ }
86
+ else if ((sectionIds === null || sectionIds === void 0 ? void 0 : sectionIds.findIndex(entryId => entryId === sectionId)) === -1) {
87
+ sectionIds.push(sectionId);
88
+ }
89
+ }
90
+ unRegister(scriptId, sectionId) {
91
+ const sectionIds = this.store.get(scriptId);
92
+ if (!sectionIds) {
93
+ return;
94
+ }
95
+ const index = sectionIds === null || sectionIds === void 0 ? void 0 : sectionIds.findIndex(entryId => entryId === sectionId);
96
+ if (index !== -1) {
97
+ sectionIds.splice(index, 1);
98
+ // Remove orphan
99
+ if (sectionIds.length < 1) {
100
+ this.store.delete(scriptId);
101
+ }
102
+ }
103
+ }
104
+ hasGlobalForScript(globalId) {
105
+ return this.scope.has(globalId);
106
+ }
107
+ getGlobalForScript(globalId) {
108
+ return this.scope.get(globalId);
109
+ }
110
+ setGlobalForScript(globalId, globalVariable) {
111
+ this.scope.set(globalId, globalVariable);
112
+ }
113
+ removeGlobalForScript(globalId) {
114
+ this.scope.delete(globalId);
115
+ }
116
+ }
117
+
118
+ // TODO ALE RENAME TO SESSION SCOPE
119
+ class FormScopeService {
120
+ constructor() {
121
+ this.scriptRegistry = new ScriptRegistry();
122
+ this.scriptSessionScope = {};
123
+ this.formSubmitSubject = new Subject();
124
+ this._form = new FormGroup({});
125
+ this.formSubmitEvent = this.formSubmitSubject.asObservable();
126
+ }
127
+ get form() {
128
+ return this._form;
129
+ }
130
+ set form(value) {
131
+ this._form = value;
132
+ }
133
+ publishFormUpdate(value) {
134
+ this.formSubmitSubject.next(value);
135
+ }
136
+ }
137
+ FormScopeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FormScopeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
138
+ FormScopeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FormScopeService });
139
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FormScopeService, decorators: [{
140
+ type: Injectable
141
+ }], ctorParameters: function () { return []; } });
142
+
143
+ var BoundDataType;
144
+ (function (BoundDataType) {
145
+ BoundDataType[BoundDataType["TYPE"] = 0] = "TYPE";
146
+ BoundDataType[BoundDataType["ATTRIBUTE"] = 1] = "ATTRIBUTE";
147
+ BoundDataType[BoundDataType["PORT"] = 2] = "PORT";
148
+ })(BoundDataType || (BoundDataType = {}));
149
+
150
+ class LineItemPath {
151
+ constructor(path) {
152
+ this._relativePath = '';
153
+ this._relativeAbstractPath = '';
154
+ this._abstractPath = '';
155
+ this.path = path.toLowerCase();
156
+ }
157
+ set relativePath(relativePath) {
158
+ this._relativePath = relativePath.toLowerCase();
159
+ }
160
+ get relativePath() {
161
+ return this._relativePath;
162
+ }
163
+ set abstractPath(abstractPath) {
164
+ this._abstractPath = abstractPath.toLowerCase();
165
+ }
166
+ get abstractPath() {
167
+ return this._abstractPath || this.path;
168
+ }
169
+ set relativeAbstractPath(relativeAbstractPath) {
170
+ this._relativeAbstractPath = relativeAbstractPath.toLowerCase();
171
+ }
172
+ isEqualTo(sectionPath) {
173
+ if (!sectionPath || !this.path || !sectionPath.path) {
174
+ return false;
175
+ }
176
+ const otherPath = sectionPath.path.toLowerCase();
177
+ const isEqual = this.path === otherPath || this._relativePath === otherPath || this._relativeAbstractPath === otherPath;
178
+ //TODO ALE SORT OUT SEARCH
179
+ if (!isEqual) {
180
+ const abstractPathMatch = this._abstractPath === sectionPath.abstractPath.toLowerCase();
181
+ const relativePathMatch = this._relativePath
182
+ ? this._relativePath === sectionPath.relativePath.toLowerCase()
183
+ : false;
184
+ const relativeAbstractPathMatch = this._relativeAbstractPath && sectionPath.relativeAbstractPath
185
+ ? sectionPath.relativeAbstractPath.toLowerCase() === sectionPath.relativePath.toLowerCase() &&
186
+ this._relativeAbstractPath === sectionPath.relativePath.toLowerCase()
187
+ : false;
188
+ return abstractPathMatch && (relativePathMatch || relativeAbstractPathMatch);
189
+ }
190
+ return isEqual;
191
+ }
192
+ }
193
+ class LineItemUtil {
194
+ static removeDeletedItems(original) {
195
+ var _a;
196
+ const root = EntityUtil.clone(original);
197
+ if (root) {
198
+ let items = [root];
199
+ for (let i = 0; i < items.length; i++) {
200
+ const item = items[i];
201
+ item.lineItems = ((_a = item.lineItems) !== null && _a !== void 0 ? _a : []).filter(l => l.actionCode !== 'DELETE');
202
+ items = items.concat(item.lineItems);
203
+ }
204
+ }
205
+ return root;
206
+ }
207
+ static replaceLineItemKeys(rootLineItem) {
208
+ const replaceFn = (item) => {
209
+ item.id = item.id ? 'DUMMY-' + item.id : item.id;
210
+ item.rootId = item.rootId ? 'DUMMY-' + item.rootId : item.rootId;
211
+ item.parentId = item.parentId ? 'DUMMY-' + item.parentId : item.parentId;
212
+ item.offeringInstanceId = item.offeringInstanceId ? 'DUMMY-' + item.offeringInstanceId : void 0;
213
+ item.offeringItemId = item.offeringItemId ? 'DUMMY-' + item.offeringItemId : void 0;
214
+ item.rampInstanceId = item.rampInstanceId ? 'DUMMY-' + item.rampInstanceId : void 0;
215
+ };
216
+ const traverseFn = (lineItem, callbackFn) => {
217
+ if (lineItem.lineItems && lineItem.lineItems.length > 0) {
218
+ lineItem.lineItems.forEach(childLineItem => {
219
+ callbackFn.apply(null, [childLineItem]);
220
+ traverseFn.apply(null, [childLineItem, callbackFn]);
221
+ });
222
+ }
223
+ };
224
+ replaceFn.apply(null, [rootLineItem]);
225
+ // rootLineItem.rootId = rootLineItem.id;
226
+ traverseFn.apply(null, [rootLineItem, replaceFn]);
227
+ }
228
+ static enrichPricingInfo(source, pricingDto) {
229
+ var _a;
230
+ const result = Object.assign({}, source);
231
+ if (pricingDto) {
232
+ result.productName = ((_a = pricingDto.properties) === null || _a === void 0 ? void 0 : _a.displayName) || pricingDto.productName;
233
+ result.type = pricingDto.type;
234
+ result.rootId = pricingDto.rootId;
235
+ result.assetId = pricingDto.assetId;
236
+ result.openOrderLineItemId = pricingDto.openOrderLineItemId;
237
+ result.activated = pricingDto.activated;
238
+ result.actionCode = pricingDto.actionCode;
239
+ result.serviceStartDate = pricingDto.serviceStartDate;
240
+ result.effectiveDate = pricingDto.effectiveDate;
241
+ result.startDate = pricingDto.startDate;
242
+ result.endDate = pricingDto.endDate;
243
+ result.offeringId = pricingDto.offeringId;
244
+ result.offeringItemId = pricingDto.offeringItemId;
245
+ result.offeringInstanceId = pricingDto.offeringInstanceId;
246
+ result.rampInstanceId = pricingDto.rampInstanceId;
247
+ result.planId = pricingDto.planId;
248
+ if (!result.chargeItems) {
249
+ result.chargeItems = pricingDto.chargeItems;
250
+ }
251
+ result.chargeGroupItems = [];
252
+ }
253
+ if (source.lineItems && source.lineItems.length > 0) {
254
+ result.lineItems = [];
255
+ source.lineItems.forEach((childSource) => {
256
+ const childDto = pricingDto && pricingDto.lineItems && pricingDto.lineItems.find(c => childSource.id === c.id);
257
+ const childItem = LineItemUtil.enrichPricingInfo(childSource, childDto);
258
+ result.lineItems.push(childItem);
259
+ });
260
+ }
261
+ return result;
262
+ }
263
+ static getLineItemPath(lineItem, rootLineItem) {
264
+ let path;
265
+ if (!lineItem.parentId) {
266
+ path = new LineItemPath('/' + lineItem.type);
267
+ path.abstractPath = path.path;
268
+ path.relativePath = path.path;
269
+ path.relativeAbstractPath = path.path;
270
+ }
271
+ else {
272
+ //TOODO ALE SORT OUT PATENT ITEM
273
+ const parentItem = EntityUtil.findByFieldHierarchically('id', lineItem.parentId, [rootLineItem], 'lineItems');
274
+ const portType = lineItem.port && (parentItem === null || parentItem === void 0 ? void 0 : parentItem.portDomains[lineItem.port].type);
275
+ const parentPath = parentItem && LineItemUtil.getLineItemPath(parentItem, rootLineItem);
276
+ if (parentPath) {
277
+ path = new LineItemPath(parentPath.path + '/ports/' + lineItem.port + '/' + lineItem.type);
278
+ path.abstractPath = parentPath.abstractPath + '/ports/' + (lineItem.port + '/' + portType);
279
+ path.relativePath = '/' + lineItem.type;
280
+ path.relativeAbstractPath = '/' + portType;
281
+ }
282
+ else {
283
+ throw 'Could not construct line item path';
284
+ }
285
+ }
286
+ return path;
287
+ }
288
+ static findById(parentId, lineItems) {
289
+ return EntityUtil.findByFieldHierarchically('id', parentId, lineItems, 'lineItems');
290
+ }
291
+ static countAttributeValues(scale, attributeDomain) {
292
+ const precision = LineItemUtil.precision(scale);
293
+ let count = 0;
294
+ attributeDomain.forEach(d => (count += d.max - d.min + precision));
295
+ return count;
296
+ }
297
+ static precision(scale) {
298
+ if (!scale) {
299
+ return 1;
300
+ }
301
+ let s = '1';
302
+ while (s.length < scale) {
303
+ s = '0' + s;
304
+ }
305
+ return Number('0.' + s);
306
+ }
307
+ static splitDomainToValues(scale, attributeDomain) {
308
+ const precision = this.precision(scale);
309
+ let values = [];
310
+ attributeDomain.forEach(interval => (values = values.concat(LineItemUtil.splitIntervalToValues(precision, interval))));
311
+ return values;
312
+ }
313
+ static splitIntervalToValues(precision, interval) {
314
+ const values = [];
315
+ for (let i = interval.min; i <= interval.max; i += precision) {
316
+ values.push(i);
317
+ }
318
+ return values;
319
+ }
320
+ static findLineItemsByPath(runtimeModel, lineItem, path) {
321
+ if (!runtimeModel.isEquals(lineItem.type, path.types[0])) {
322
+ return [];
323
+ }
324
+ let lineItems = [lineItem];
325
+ for (let i = 1; i < path.types.length; i++) {
326
+ const portName = path.ports[i - 1];
327
+ const typeName = path.types[i];
328
+ lineItems = LineItemUtil.findLineItemChildren(runtimeModel, lineItems, portName, typeName);
329
+ }
330
+ return lineItems;
331
+ }
332
+ static findLineItemChildren(runtimeModel, lineItems, portName, typeName) {
333
+ var _a;
334
+ const result = [];
335
+ for (const lineItem of lineItems) {
336
+ for (const childItem of lineItem.lineItems) {
337
+ if (((_a = childItem.port) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === portName.toLowerCase() &&
338
+ runtimeModel.isEquals(childItem.type, typeName)) {
339
+ result.push(childItem);
340
+ }
341
+ }
342
+ }
343
+ return result;
344
+ }
345
+ static findLineItemsByType(runtimeModel, lineItem, typeName) {
346
+ const result = [];
347
+ let lineItems = [lineItem];
348
+ for (let i = 0; i < lineItems.length; i++) {
349
+ const lineItem = lineItems[i];
350
+ if (runtimeModel.isEquals(lineItem.type, typeName)) {
351
+ result.push(lineItem);
352
+ }
353
+ lineItems = lineItems.concat(lineItem.lineItems);
354
+ }
355
+ return result;
356
+ }
357
+ static findLineItemForValue(model, valueOption) {
358
+ if (!EntityUtil.isPresent(model) || !EntityUtil.isPresent(model.lineItems)) {
359
+ return;
360
+ }
361
+ return model.lineItems.find(li => li.type && li.type.toLowerCase() === valueOption.toLowerCase());
362
+ }
363
+ // TODO: add Product typings
364
+ static create(product, qty) {
365
+ var _a;
366
+ return {
367
+ id: UUID.UUID(),
368
+ type: product.typeName,
369
+ name: ((_a = product.properties) === null || _a === void 0 ? void 0 : _a.displayName) || product.name,
370
+ productName: product.name,
371
+ productId: product.id,
372
+ cfgStatus: 'User',
373
+ actionCode: 'ADD',
374
+ qty: qty || 1,
375
+ };
376
+ }
377
+ static upsert(value, collection) {
378
+ const index = collection.findIndex(item => item.id === value.id);
379
+ if (index > -1) {
380
+ collection[index] = value;
381
+ }
382
+ else {
383
+ collection.push(value);
384
+ }
385
+ }
386
+ static compareSortOrder(a, b) {
387
+ const orderA = Number(a.properties['SortOrder']);
388
+ const orderB = Number(b.properties['SortOrder']);
389
+ if (!orderA && !orderB) {
390
+ return LineItemUtil.compareProductName(a, b);
391
+ }
392
+ if (!orderA) {
393
+ return 1;
394
+ }
395
+ else if (!orderB) {
396
+ return -1;
397
+ }
398
+ const result = orderA - orderB;
399
+ if (result === 0) {
400
+ return LineItemUtil.compareProductName(a, b);
401
+ }
402
+ return result;
403
+ }
404
+ static sort(lineItems) {
405
+ if (lineItems) {
406
+ lineItems.sort((a, b) => LineItemUtil.compareSortOrder(a, b));
407
+ lineItems.forEach(i => LineItemUtil.sort(i.lineItems));
408
+ }
409
+ }
410
+ static compareProductName(a, b) {
411
+ var _a, _b;
412
+ if (a.productName) {
413
+ return ((_a = a.productName) !== null && _a !== void 0 ? _a : '').localeCompare((_b = b.productName) !== null && _b !== void 0 ? _b : '');
414
+ }
415
+ else if (b.productName) {
416
+ return 1;
417
+ }
418
+ return 0;
419
+ }
420
+ }
421
+
422
+ class SectionsBinderHelper {
423
+ static setLineItemsPath(runtimeModel, rootLineItem, sections, sourceSections, filterFn, pricingEnabled) {
424
+ const filtered = sections.filter(filterFn);
425
+ filtered.forEach(section => {
426
+ const path = section.boundData.path;
427
+ let foundLineItems;
428
+ if (path.relative) {
429
+ foundLineItems = LineItemUtil.findLineItemsByType(runtimeModel, rootLineItem, path.types[0]);
430
+ }
431
+ else {
432
+ const remainder = rootLineItem.path ? SectionPathUtil.cut(runtimeModel, path, rootLineItem.path) : undefined;
433
+ if (!remainder) {
434
+ return [];
435
+ }
436
+ foundLineItems = LineItemUtil.findLineItemsByPath(runtimeModel, rootLineItem, remainder);
437
+ }
438
+ if (section.boundData.entityType === BoundDataType[BoundDataType.TYPE]) {
439
+ SectionsBinderHelper.bindMatchingLineItems(runtimeModel, foundLineItems, section, sections, sourceSections, pricingEnabled);
440
+ }
441
+ else if (section.boundData.entityType === BoundDataType[BoundDataType.ATTRIBUTE]) {
442
+ foundLineItems = foundLineItems.filter(item => item.attributes &&
443
+ item.attributes.findIndex(a => a.name.toLowerCase() === section.boundData.name.toLowerCase()) !== -1);
444
+ foundLineItems.forEach(lineItem => {
445
+ SectionsBinderHelper.bindLineItem(section, sections, sourceSections, lineItem, pricingEnabled);
446
+ });
447
+ }
448
+ else if (section.boundData.entityType === BoundDataType[BoundDataType.PORT]) {
449
+ foundLineItems = foundLineItems.filter(item => item.portDomains && item.portDomains[section.boundData.name]);
450
+ SectionsBinderHelper.bindMatchingLineItems(runtimeModel, foundLineItems, section, sections, sourceSections, pricingEnabled);
451
+ }
452
+ return;
453
+ });
454
+ return sections;
455
+ }
456
+ static isAddAllowed(model, portName, quantityToAdd = 1) {
457
+ const quantity = this.getQuantity(model, portName);
458
+ return quantity + quantityToAdd <= +this.getPortMax(model, portName);
459
+ }
460
+ static isRemoveAllowed(model, portName, quantityToRemove = 1) {
461
+ const quantity = this.getQuantity(model, portName);
462
+ return quantity - quantityToRemove >= +this.getPortMin(model, portName);
463
+ }
464
+ static getMaxAllowed(lineItem, portName) {
465
+ return +this.getPortMax(lineItem, portName) - this.getQuantity(lineItem, portName);
466
+ }
467
+ static getQuantityGroupByValue(model, portName) {
468
+ const quantities = {};
469
+ if (model && portName) {
470
+ model.lineItems
471
+ .filter(li => li.port === portName)
472
+ .forEach(li => {
473
+ let quantity = (EntityUtil.isPresent(li.qty) && li.qty) || 1;
474
+ if (EntityUtil.isPresent(quantities[li.type])) {
475
+ quantity += quantities[li.type];
476
+ }
477
+ quantities[li.type] = quantity;
478
+ });
479
+ }
480
+ return quantities;
481
+ }
482
+ static bindMatchingLineItems(runtimeModel, foundLineItems, section, sections, sourceSections, pricingEnabled) {
483
+ foundLineItems.forEach(lineItem => {
484
+ const boundSection = SectionsBinderHelper.bindLineItem(section, sections, sourceSections, lineItem, pricingEnabled);
485
+ SectionsBinderHelper.setLineItemsPath(runtimeModel, lineItem, sections, sourceSections, (sec) => {
486
+ return sec.boundData && sec.parentId === boundSection.id;
487
+ }, pricingEnabled);
488
+ });
489
+ }
490
+ static bindLineItem(section, sections, sourceSections, lineItem, pricingEnabled) {
491
+ const boundSection = section.model ? SectionsBinderHelper.doClone(section, sections, sourceSections) : section;
492
+ boundSection.model = lineItem;
493
+ boundSection.pricingEnabled = pricingEnabled;
494
+ return boundSection;
495
+ }
496
+ static doClone(source, sections, sourceSections, parent) {
497
+ const sourceClass = sourceSections.find(s => s.classId === source.classId);
498
+ const clone = EntityUtil.clone(sourceClass);
499
+ clone.id = UUID.UUID();
500
+ clone.parentId = parent ? parent.id : source.parentId;
501
+ sections.splice(sections.findIndex(s => s.id === source.id) + 1, 0, clone);
502
+ sourceSections
503
+ .filter(s => s.parentId === sourceClass.id)
504
+ .forEach(s => SectionsBinderHelper.doClone(s, sections, sourceSections, clone));
505
+ return clone;
506
+ }
507
+ static getQuantity(model, portName) {
508
+ let quantity = 0;
509
+ model.lineItems
510
+ .filter(li => li.port === portName)
511
+ .forEach(li => {
512
+ quantity += li.qty;
513
+ });
514
+ return quantity;
515
+ }
516
+ static getPortMax(model, portName) {
517
+ return model.portDomains[portName].maxCard;
518
+ }
519
+ static getPortMin(model, portName) {
520
+ return model.portDomains[portName].minCard;
521
+ }
522
+ }
523
+
524
+ class RuntimeFormService {
525
+ constructor() {
526
+ this.sections = [];
527
+ }
528
+ initForm(sections, solutionLineItem) {
529
+ this.sections = sections;
530
+ this.solutionLineItem = solutionLineItem;
531
+ const form = new FormGroup({});
532
+ sections
533
+ .filter(section => section.model && section.template && section.boundData)
534
+ .forEach(section => {
535
+ this.populateSectionValue(section);
536
+ this.populateSectionPrice(section);
537
+ this.populateFormControls(section, form);
538
+ });
539
+ return form;
540
+ }
541
+ populateSectionValue(section) {
542
+ var _a, _b, _c, _d, _e, _f, _g;
543
+ let value;
544
+ let valueOptions = [];
545
+ let displayValues = {};
546
+ let properties = {};
547
+ if (FormServiceUtils.isPortSection(section)) {
548
+ const portDomain = (_a = section.model) === null || _a === void 0 ? void 0 : _a.portDomains[section.boundData.name];
549
+ valueOptions = (_b = portDomain === null || portDomain === void 0 ? void 0 : portDomain.domainTypes.map(dt => dt.name)) !== null && _b !== void 0 ? _b : [];
550
+ properties =
551
+ (_c = portDomain === null || portDomain === void 0 ? void 0 : portDomain.domainTypes.reduce(function (map, dt) {
552
+ map[dt.name] = dt.properties;
553
+ return map;
554
+ }, {})) !== null && _c !== void 0 ? _c : {};
555
+ displayValues =
556
+ (_d = portDomain === null || portDomain === void 0 ? void 0 : portDomain.domainTypes.reduce(function (map, dt) {
557
+ map[dt.name] = dt.displayName;
558
+ return map;
559
+ }, {})) !== null && _d !== void 0 ? _d : {};
560
+ value = (_e = section.model) === null || _e === void 0 ? void 0 : _e.lineItems.map(li => li.type);
561
+ }
562
+ if (FormServiceUtils.isAttributeSection(section)) {
563
+ const attribute = (_f = section.model) === null || _f === void 0 ? void 0 : _f.attributes.find(attr => attr.name.toLowerCase() === section.boundData.name.toLowerCase());
564
+ if (attribute) {
565
+ value = attribute.value;
566
+ }
567
+ const attributeDomain = (_g = section.model) === null || _g === void 0 ? void 0 : _g.attributeDomains[section.boundData.name];
568
+ if (!(attribute === null || attribute === void 0 ? void 0 : attribute.type.match('GENERIC|BOOLEAN')) && attributeDomain) {
569
+ const count = attribute && attribute.scale != null
570
+ ? LineItemUtil.countAttributeValues(attribute.scale, attributeDomain)
571
+ : undefined;
572
+ if (attribute && attribute.scale != null && count && count <= 100) {
573
+ valueOptions = LineItemUtil.splitDomainToValues(attribute.scale, attributeDomain);
574
+ }
575
+ else {
576
+ valueOptions = attributeDomain;
577
+ }
578
+ }
579
+ else if (attributeDomain) {
580
+ valueOptions = attributeDomain;
581
+ }
582
+ }
583
+ if (!EntityUtil.isPresent(value)) {
584
+ value = '';
585
+ }
586
+ section.sectionValue = {
587
+ value,
588
+ valueOptions,
589
+ displayValues,
590
+ properties,
591
+ };
592
+ }
593
+ populateSectionPrice(section) {
594
+ var _a;
595
+ const priceValue = { priceOptions: {} };
596
+ if (FormServiceUtils.isPortSection(section)) {
597
+ const portDomain = (_a = section.model) === null || _a === void 0 ? void 0 : _a.portDomains[section.boundData.name];
598
+ if (portDomain) {
599
+ portDomain.domainTypes.forEach(dt => {
600
+ if (dt.recommendedPrices && dt.recommendedPrices.length > 0) {
601
+ priceValue.priceOptions[dt.name] = dt.recommendedPrices;
602
+ }
603
+ else {
604
+ delete priceValue.priceOptions[dt.name];
605
+ }
606
+ });
607
+ }
608
+ }
609
+ section.priceValue = priceValue;
610
+ }
611
+ populateFormControls(section, form) {
612
+ form.controls[section.id] = this.createFormControl(section);
613
+ if (FormServiceUtils.isPortSection(section) || FormServiceUtils.isTypeSection(section)) {
614
+ form.controls[section.id.concat('qty')] = this.createQtyControl(section);
615
+ }
616
+ }
617
+ createFormControl(section) {
618
+ var _a;
619
+ const value = FormServiceUtils.isPortSection(section) ? void 0 : (_a = section.sectionValue) === null || _a === void 0 ? void 0 : _a.value;
620
+ return new FormControl(value, this.getFormControlValidators(section));
621
+ }
622
+ createQtyControl(section) {
623
+ var _a, _b, _c;
624
+ const isTypeSection = FormServiceUtils.isTypeSection(section);
625
+ const validators = [];
626
+ const maxAllowed = this.getMaxAllowed(section);
627
+ //TODO TEMPORARY SOLUTION (WILL BE DISABLED ONCE RADIO CONTROLS IMPLEMENTED)
628
+ if (maxAllowed > 0) {
629
+ validators.push(this.getQuantityValidator(maxAllowed, isTypeSection ? (_b = (_a = section.model) === null || _a === void 0 ? void 0 : _a.qty) !== null && _b !== void 0 ? _b : 0 : 0));
630
+ }
631
+ const qtyValue = isTypeSection ? (_c = section.model) === null || _c === void 0 ? void 0 : _c.qty : 1;
632
+ return new FormControl(qtyValue, validators);
633
+ }
634
+ getMaxAllowed(section) {
635
+ let lineItem = section.model;
636
+ let portName = section.boundData.name;
637
+ if (FormServiceUtils.isTypeSection(section)) {
638
+ if (section.model && EntityUtil.isPresent(section.model.parentId) && this.solutionLineItem) {
639
+ if (section.model.parentId) {
640
+ lineItem = LineItemUtil.findById(section.model.parentId, [this.solutionLineItem]);
641
+ }
642
+ portName = section.model.port;
643
+ }
644
+ else {
645
+ return 0;
646
+ }
647
+ }
648
+ if (!lineItem) {
649
+ return 0;
650
+ }
651
+ return SectionsBinderHelper.getMaxAllowed(lineItem, portName);
652
+ }
653
+ //TODO ALE TO SUPPORT EMPTY VALUES FOR INTERVAL ATTRIBUTES OUT OF DOMAIN
654
+ getFormControlValidators(section) {
655
+ if (!FormServiceUtils.isAttributeSection(section)) {
656
+ return null;
657
+ }
658
+ const validators = [];
659
+ const parentLineItem = section.model && this.solutionLineItem && FormServiceUtils.findParent(section.model.id, [this.solutionLineItem]);
660
+ const attribute = parentLineItem &&
661
+ parentLineItem.attributes.find(attr => attr.name.toLowerCase() === section.boundData.name.toLowerCase());
662
+ if (!attribute || !attribute.type) {
663
+ return null;
664
+ }
665
+ const primitiveTypesValidators = {
666
+ INT: TypeValidators.integerValidator(),
667
+ 'DOUBLE|DECIMAL': TypeValidators.decimalValidator(10),
668
+ };
669
+ keys(primitiveTypesValidators).forEach(types => {
670
+ if (types.match(attribute.type)) {
671
+ const validator = primitiveTypesValidators[types];
672
+ validators.push(validator);
673
+ }
674
+ });
675
+ if (!attribute.type.match('GENERIC|BOOLEAN|MULTIPLE')) {
676
+ const sectionLabel = section.label;
677
+ const intervalValidator = function (control) {
678
+ var _a;
679
+ if (isUndefined(control.value) || isNull(control.value) || isNaN(+control.value)) {
680
+ return { interval: { message: sectionLabel + ' is not in domain' } };
681
+ }
682
+ if (!isUndefined(control.value) && isString(control.value) && control.value.length === 0) {
683
+ return null;
684
+ }
685
+ const attributeDomain = (_a = section.model) === null || _a === void 0 ? void 0 : _a.attributeDomains[section.boundData.name];
686
+ const valid = attributeDomain === null || attributeDomain === void 0 ? void 0 : attributeDomain.some(valueOption => {
687
+ const min = +valueOption.min;
688
+ const max = +valueOption.max;
689
+ return +control.value <= max && +control.value >= min;
690
+ });
691
+ if (!valid) {
692
+ return { interval: { message: sectionLabel + ' is not in domain' } };
693
+ }
694
+ return null;
695
+ };
696
+ validators.push(intervalValidator);
697
+ }
698
+ if (section.required) {
699
+ validators.push(TypeValidators.requiredValidator(section.label + ' is required '));
700
+ }
701
+ return validators.length !== 0 ? validators : null;
702
+ }
703
+ getQuantityValidator(max, originalQty) {
704
+ return (control) => {
705
+ if (!control.value) {
706
+ return { quantity: { message: 'Required' } };
707
+ }
708
+ else if (isNaN(+control.value) || +control.value < 1) {
709
+ return { quantity: { message: 'Invalid value' } };
710
+ }
711
+ else if (+control.value > max + originalQty) {
712
+ return { quantity: { message: 'Max quantity ' + (max + originalQty) } };
713
+ }
714
+ else {
715
+ return null;
716
+ }
717
+ };
718
+ }
719
+ }
720
+ RuntimeFormService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeFormService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
721
+ RuntimeFormService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeFormService });
722
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeFormService, decorators: [{
723
+ type: Injectable
724
+ }] });
725
+ class FormServiceUtils {
726
+ static isPortSection(section) {
727
+ return section && section.boundData && section.boundData.entityType === BoundDataType[BoundDataType.PORT];
728
+ }
729
+ static isTypeSection(section) {
730
+ return section && section.boundData && section.boundData.entityType === BoundDataType[BoundDataType.TYPE];
731
+ }
732
+ static isAttributeSection(section) {
733
+ return section && section.boundData && section.boundData.entityType === BoundDataType[BoundDataType.ATTRIBUTE];
734
+ }
735
+ static findParent(parentId, lineItems) {
736
+ return EntityUtil.findByFieldHierarchically('id', parentId, lineItems, 'lineItems');
737
+ }
738
+ }
739
+
740
+ class ConfigurationService {
741
+ constructor(configurationApiService, contextService, dialogService) {
742
+ this.configurationApiService = configurationApiService;
743
+ this.contextService = contextService;
744
+ this.dialogService = dialogService;
745
+ }
746
+ configure(runtimeContext, states, resolve) {
747
+ var _a;
748
+ const lineItem = (states && states.configurableRamp) || this.getDefaultLineItem(runtimeContext);
749
+ const configurationMode = resolve ? ConfigurationMode.RESOLVE : ConfigurationMode.SEARCH;
750
+ const configurationRequest = this.createRequest(lineItem, runtimeContext, configurationMode);
751
+ configurationRequest.lineItems = states.currentState || [];
752
+ configurationRequest.asset = states.asset;
753
+ const runtimeModel = runtimeContext.runtimeModel;
754
+ const pricingEnabled = (_a = runtimeContext.uiDefinition) === null || _a === void 0 ? void 0 : _a.pricingEnabled;
755
+ return this.configurationApiService
756
+ .configureLineItem({
757
+ configurationRequest,
758
+ runtimeModel,
759
+ pricingEnabled,
760
+ })
761
+ .pipe(map(({ lineItem, context, deletedLineItems }) => {
762
+ if (context) {
763
+ this.contextService.update({ properties: context.properties });
764
+ }
765
+ if (deletedLineItems === null || deletedLineItems === void 0 ? void 0 : deletedLineItems.length) {
766
+ this.showInactiveProductsConfirmation();
767
+ }
768
+ return lineItem;
769
+ }));
770
+ }
771
+ createRequest(lineItem, runtimeContext, configurationMode) {
772
+ var _a, _b, _c, _d, _e;
773
+ if (runtimeContext.runtimeMode === RuntimeMode.TEST) {
774
+ const properties = Object.assign(Object.assign({}, runtimeContext.properties), { ModelId: runtimeContext.modelId, RuntimeMode: 'TEST', PricingEnabled: String((_a = runtimeContext.uiDefinition) === null || _a === void 0 ? void 0 : _a.pricingEnabled), StartDate: (_c = (_b = runtimeContext.properties) === null || _b === void 0 ? void 0 : _b.StartDate) !== null && _c !== void 0 ? _c : new Date().toISOString().substring(0, 10), PriceListId: (_d = runtimeContext.uiDefinition) === null || _d === void 0 ? void 0 : _d.priceList });
775
+ this.contextService.update({ properties });
776
+ }
777
+ else {
778
+ const context = this.contextService.resolve();
779
+ if (context.properties && ((_e = runtimeContext.properties) === null || _e === void 0 ? void 0 : _e.StartDate)) {
780
+ this.contextService.update({
781
+ properties: Object.assign(Object.assign({}, context.properties), runtimeContext.properties),
782
+ });
783
+ }
784
+ }
785
+ return {
786
+ lineItem,
787
+ mode: configurationMode,
788
+ step: runtimeContext.invocationContext && runtimeContext.invocationContext.runtimeStep,
789
+ attributeDomainMode: 'ALL',
790
+ context: this.contextService.resolve(),
791
+ };
792
+ }
793
+ getDefaultLineItem(context) {
794
+ var _a, _b, _c, _d;
795
+ const id = UUID.UUID();
796
+ const lineItem = Object.assign({ id, type: (_b = (_a = context.uiDefinition) === null || _a === void 0 ? void 0 : _a.rootType) !== null && _b !== void 0 ? _b : '', cfgStatus: 'Default', qty: 1, productName: ((_c = context.properties) === null || _c === void 0 ? void 0 : _c.displayName) || context.productName, productId: (_d = context.productId) !== null && _d !== void 0 ? _d : '', offeringId: context.offeringId }, (context.offeringId
797
+ ? { offeringId: context.offeringId, offeringInstanceId: context.offeringInstanceId || id }
798
+ : {}));
799
+ return lineItem;
800
+ }
801
+ showInactiveProductsConfirmation() {
802
+ this.dialogService
803
+ .open(ConfirmationComponent, {
804
+ dismissableMask: false,
805
+ closeOnEscape: false,
806
+ closable: false,
807
+ showHeader: true,
808
+ header: `Inactive Products in Quote`,
809
+ width: '440px',
810
+ data: {
811
+ confirmationConfig: {
812
+ title: ' ',
813
+ description: 'This quote contains inactive products. Do you want to remove them?',
814
+ submitBtn: 'Remove products',
815
+ cancelBtn: 'Back to Quote',
816
+ },
817
+ },
818
+ })
819
+ .onClose.subscribe(result => {
820
+ if (!result) {
821
+ const context = this.contextService.resolve();
822
+ window['VELO_BACK_FN'].apply(null, [context.headerId]);
823
+ }
824
+ });
825
+ }
826
+ }
827
+ ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationService, deps: [{ token: i1.ConfigurationApiService }, { token: i2.ContextService }, { token: i3.DialogService }], target: i0.ɵɵFactoryTarget.Injectable });
828
+ ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationService });
829
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationService, decorators: [{
830
+ type: Injectable
831
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: i2.ContextService }, { type: i3.DialogService }]; } });
832
+
833
+ class RuntimeService {
834
+ constructor(configurationService, contextService, messageService) {
835
+ this.configurationService = configurationService;
836
+ this.contextService = contextService;
837
+ this.messageService = messageService;
838
+ this.solutionReadySubject = new Subject();
839
+ this.onSolutionReadyEvent = this.solutionReadySubject.asObservable();
840
+ this.solutionUpdateStartedSubject = new Subject();
841
+ this.onSolutionUpdateStartedEvent = this.solutionUpdateStartedSubject.asObservable();
842
+ this.solutionUpdatedSubject = new Subject();
843
+ this.onSolutionUpdatedEvent = this.solutionUpdatedSubject.asObservable();
844
+ this.solutionProcessedSubject = new Subject();
845
+ this.onSolutionProcessed = this.solutionProcessedSubject.asObservable();
846
+ this.solutionStopSubject = new Subject();
847
+ this.onSolutionStopEvent = this.solutionStopSubject.asObservable();
848
+ this.solutionCancelSubject = new Subject();
849
+ this.onSolutionCancelEvent = this.solutionCancelSubject.asObservable();
850
+ this.uiRefreshSubject = new Subject();
851
+ this.onUIRefreshEvent = this.uiRefreshSubject.asObservable();
852
+ }
853
+ displayErrorMessage(error) {
854
+ var _a;
855
+ this.messageService.add({
856
+ severity: 'error',
857
+ summary: ((_a = error.error) === null || _a === void 0 ? void 0 : _a.message) || error.message || JSON.stringify(error),
858
+ });
859
+ }
860
+ startRuntime(context, states, resolve) {
861
+ this.setRuntimeContext(context);
862
+ this.setRuntimeStep(RuntimeStep.START);
863
+ this.configurationService
864
+ .configure(context, states, resolve)
865
+ .pipe(take(1))
866
+ .subscribe(lineItem => {
867
+ this.solutionReadySubject.next(lineItem);
868
+ }, error => {
869
+ this.displayErrorMessage(error);
870
+ this.solutionUpdatedSubject.next(error);
871
+ });
872
+ }
873
+ updateRuntime(states, configurationContextProperties) {
874
+ if (!this.runtimeContext) {
875
+ return;
876
+ }
877
+ this.solutionUpdateStartedSubject.next();
878
+ this.setRuntimeStep(RuntimeStep.UPDATE);
879
+ this.updateRuntimeContext(configurationContextProperties);
880
+ this.configurationService
881
+ .configure(this.runtimeContext, states)
882
+ .pipe(take(1))
883
+ .subscribe(lineItem => {
884
+ const context = this.contextService.resolve();
885
+ this.updateRuntimeContext(context.properties);
886
+ this.solutionUpdatedSubject.next(lineItem);
887
+ }, error => {
888
+ this.displayErrorMessage(error);
889
+ this.solutionUpdatedSubject.next(error);
890
+ });
891
+ }
892
+ stopRuntime(solutionLineItem) {
893
+ this.solutionStopSubject.next(solutionLineItem);
894
+ }
895
+ cancelRuntime() {
896
+ this.solutionCancelSubject.next();
897
+ }
898
+ setRuntimeContext(runtimeContext) {
899
+ this.runtimeContext = runtimeContext;
900
+ }
901
+ getRuntimeContext() {
902
+ return this.runtimeContext;
903
+ }
904
+ solutionProcessed(lineItem) {
905
+ this.solutionProcessedSubject.next(lineItem);
906
+ }
907
+ refreshUI(uiDefinition) {
908
+ if (!this.runtimeContext) {
909
+ return;
910
+ }
911
+ this.runtimeContext = Object.assign(Object.assign({}, this.runtimeContext), { uiDefinition });
912
+ this.uiRefreshSubject.next();
913
+ }
914
+ updateRuntimeContext(configurationContextProperties) {
915
+ if (!this.runtimeContext || !configurationContextProperties) {
916
+ return;
917
+ }
918
+ this.runtimeContext = Object.assign(Object.assign({}, this.runtimeContext), { properties: configurationContextProperties });
919
+ }
920
+ setRuntimeStep(runtimeStep) {
921
+ if (!this.runtimeContext) {
922
+ return;
923
+ }
924
+ this.runtimeContext.invocationContext = Object.assign(Object.assign({}, this.runtimeContext.invocationContext), { runtimeStep });
925
+ }
926
+ }
927
+ RuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeService, deps: [{ token: ConfigurationService }, { token: i2.ContextService }, { token: i3$1.MessageService }], target: i0.ɵɵFactoryTarget.Injectable });
928
+ RuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeService });
929
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeService, decorators: [{
930
+ type: Injectable
931
+ }], ctorParameters: function () { return [{ type: ConfigurationService }, { type: i2.ContextService }, { type: i3$1.MessageService }]; } });
932
+
933
+ class ShoppingCartService {
934
+ constructor(priceApiService, contextService, quoteService) {
935
+ this.priceApiService = priceApiService;
936
+ this.contextService = contextService;
937
+ this.quoteService = quoteService;
938
+ }
939
+ setCartExternally(currentState) {
940
+ const context = this.contextService.resolve();
941
+ return this.priceApiService.calculate({ context, currentState }).pipe(take(1), tap(({ lineItems }) => {
942
+ this.quoteService.setCurrentLineItemState(lineItems);
943
+ }));
944
+ }
945
+ getCurrentState() {
946
+ return this.quoteService.currentState;
947
+ }
948
+ }
949
+ ShoppingCartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ShoppingCartService, deps: [{ token: i1.PriceApiService }, { token: i2.ContextService }, { token: i2.QuoteDraftService }], target: i0.ɵɵFactoryTarget.Injectable });
950
+ ShoppingCartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ShoppingCartService });
951
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ShoppingCartService, decorators: [{
952
+ type: Injectable
953
+ }], ctorParameters: function () { return [{ type: i1.PriceApiService }, { type: i2.ContextService }, { type: i2.QuoteDraftService }]; } });
954
+
955
+ class CurrentStateService {
956
+ constructor() {
957
+ this.currentState = [];
958
+ }
959
+ update(state) {
960
+ this.currentState = state;
961
+ }
962
+ }
963
+ CurrentStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CurrentStateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
964
+ CurrentStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CurrentStateService, providedIn: 'root' });
965
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: CurrentStateService, decorators: [{
966
+ type: Injectable,
967
+ args: [{ providedIn: 'root' }]
968
+ }] });
969
+
970
+ class ProductModelCacheService {
971
+ constructor(productModelApiService) {
972
+ this.productModelApiService = productModelApiService;
973
+ this.cachedModel = new Map();
974
+ }
975
+ getProductModel(currentModelId, version) {
976
+ if (!this.cachedModel.has(currentModelId) || version) {
977
+ this.clearCache();
978
+ this.cachedModel.set(currentModelId, this.productModelApiService.load(currentModelId, version).pipe(shareReplay(1)));
979
+ }
980
+ return this.cachedModel.get(currentModelId);
981
+ }
982
+ getCachedModel() {
983
+ const ids = Array.from(this.cachedModel.keys());
984
+ return this.cachedModel.get(ids[0]);
985
+ }
986
+ clearCache() {
987
+ this.cachedModel.clear();
988
+ }
989
+ }
990
+ ProductModelCacheService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ProductModelCacheService, deps: [{ token: i1.ProductModelApiService }], target: i0.ɵɵFactoryTarget.Injectable });
991
+ ProductModelCacheService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ProductModelCacheService });
992
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ProductModelCacheService, decorators: [{
993
+ type: Injectable
994
+ }], ctorParameters: function () { return [{ type: i1.ProductModelApiService }]; } });
995
+
996
+ class RuntimeContextService {
997
+ constructor(configurationApiService, messageService, contextService) {
998
+ this.configurationApiService = configurationApiService;
999
+ this.messageService = messageService;
1000
+ this.contextService = contextService;
1001
+ }
1002
+ getRuntimeContext(productId, offeringId) {
1003
+ return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
1004
+ var _a;
1005
+ const uiDefinition = this.getUIDefinition(runtimeData.uiDefinitions);
1006
+ const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
1007
+ const { productName, properties } = (_a = Array.from(runtimeModel.components.values()).find(c => c.productId === productId)) !== null && _a !== void 0 ? _a : {};
1008
+ return {
1009
+ modelId: runtimeData.modelId,
1010
+ uiDefinition: uiDefinition,
1011
+ runtimeModel: runtimeModel,
1012
+ runtimeMode: RuntimeMode.PROD,
1013
+ productId: productId,
1014
+ productType: (properties === null || properties === void 0 ? void 0 : properties.displayName) || productName,
1015
+ offeringId: offeringId,
1016
+ properties: {
1017
+ PricingEnabled: uiDefinition.pricingEnabled ? 'true' : 'false',
1018
+ },
1019
+ };
1020
+ }));
1021
+ }
1022
+ getUIDefinition(uiDefinitions = []) {
1023
+ const { uiDefinitionId } = this.contextService.resolve();
1024
+ const findByFn = (uiDef) => (uiDefinitionId ? uiDefinitionId === uiDef.id : uiDef.primary);
1025
+ const uiDefinition = uiDefinitions.find(findByFn) || (uiDefinitions.length === 1 && Object.assign({}, uiDefinitions[0]));
1026
+ if (!uiDefinition) {
1027
+ const errMsg = `Unable to find ${uiDefinitionId ? uiDefinitionId : 'Default'} UI`;
1028
+ this.messageService.add({
1029
+ severity: 'error',
1030
+ summary: 'ERROR',
1031
+ });
1032
+ throw new Error(errMsg);
1033
+ }
1034
+ SectionPathUtil.updateSectionsPath(uiDefinition.sections);
1035
+ return uiDefinition;
1036
+ }
1037
+ }
1038
+ RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }, { token: i3$1.MessageService }, { token: i2.ContextService }], target: i0.ɵɵFactoryTarget.Injectable });
1039
+ RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeContextService });
1040
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeContextService, decorators: [{
1041
+ type: Injectable
1042
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: i3$1.MessageService }, { type: i2.ContextService }]; } });
1043
+
1044
+ class SectionStoreService {
1045
+ constructor() {
1046
+ this._componentFactories = [];
1047
+ }
1048
+ set componentFactories(data) {
1049
+ this._componentFactories = data;
1050
+ }
1051
+ get componentFactories() {
1052
+ return this._componentFactories;
1053
+ }
1054
+ getComponentFactory(section) {
1055
+ return this.componentFactories.find(f => f.selector === section.dynamicSelector);
1056
+ }
1057
+ }
1058
+ SectionStoreService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionStoreService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1059
+ SectionStoreService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionStoreService });
1060
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionStoreService, decorators: [{
1061
+ type: Injectable
1062
+ }] });
1063
+
1064
+ class SectionScopeService {
1065
+ constructor() {
1066
+ this.indent = 1;
1067
+ this.templates = new BehaviorSubject([]);
1068
+ }
1069
+ get section() {
1070
+ return this._section;
1071
+ }
1072
+ set section(value) {
1073
+ this._section = value;
1074
+ this.indent = this.getIndent(value);
1075
+ }
1076
+ getIndent(section) {
1077
+ if (!section || !section.parentId) {
1078
+ return 1;
1079
+ }
1080
+ else {
1081
+ let current = section;
1082
+ let indent = 1;
1083
+ while (current && current.parent) {
1084
+ current = current.parent;
1085
+ indent++;
1086
+ }
1087
+ return indent;
1088
+ }
1089
+ }
1090
+ }
1091
+ SectionScopeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionScopeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1092
+ SectionScopeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionScopeService });
1093
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionScopeService, decorators: [{
1094
+ type: Injectable
1095
+ }] });
1096
+
1097
+ class ExecutionSectionRendererComponent {
1098
+ constructor(_injector, _m, sectionScope, sectionStore) {
1099
+ this._injector = _injector;
1100
+ this._m = _m;
1101
+ this.sectionScope = sectionScope;
1102
+ this.sectionStore = sectionStore;
1103
+ this.componentRef = null;
1104
+ }
1105
+ set section(value) {
1106
+ this._section = value;
1107
+ this.sectionScope.section = value;
1108
+ }
1109
+ get section() {
1110
+ return this._section;
1111
+ }
1112
+ ngOnInit() {
1113
+ this.renderSection();
1114
+ }
1115
+ ngAfterViewInit() {
1116
+ var _a, _b;
1117
+ if (this.componentRef) {
1118
+ this.sectionScope.templates.next((_b = (_a = this.componentRef.instance['templates']) === null || _a === void 0 ? void 0 : _a.toArray()) !== null && _b !== void 0 ? _b : []);
1119
+ }
1120
+ }
1121
+ ngOnDestroy() {
1122
+ if (this.componentRef) {
1123
+ this.componentRef.destroy();
1124
+ this.componentRef = null;
1125
+ }
1126
+ }
1127
+ renderSection() {
1128
+ var _a;
1129
+ if (this.componentRef) {
1130
+ this.componentRef.destroy();
1131
+ this.componentRef = null;
1132
+ }
1133
+ const componentFactory = this.sectionStore.getComponentFactory(this._section);
1134
+ if (!componentFactory) {
1135
+ return;
1136
+ }
1137
+ this.componentRef = componentFactory.create(this._injector, [], null, this._m);
1138
+ this.componentRef.location.nativeElement.setAttribute('sectionId', `${(_a = this._section.model) === null || _a === void 0 ? void 0 : _a.id}${this._section.label}`);
1139
+ this.componentRef.instance['form'] = this.form;
1140
+ this.componentRef.instance['section'] = this.section;
1141
+ this.container.insert(this.componentRef.hostView);
1142
+ }
1143
+ }
1144
+ ExecutionSectionRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ExecutionSectionRendererComponent, deps: [{ token: i0.Injector }, { token: i0.NgModuleRef }, { token: SectionScopeService }, { token: SectionStoreService }], target: i0.ɵɵFactoryTarget.Component });
1145
+ ExecutionSectionRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: ExecutionSectionRendererComponent, selector: "section-renderer", inputs: { section: "section", form: "form" }, providers: [SectionScopeService], viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: "<ng-template #container></ng-template>", styles: [":host{display:contents}\n"] });
1146
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ExecutionSectionRendererComponent, decorators: [{
1147
+ type: Component,
1148
+ args: [{
1149
+ // eslint-disable-next-line @angular-eslint/component-selector
1150
+ selector: 'section-renderer',
1151
+ templateUrl: 'execution-section-renderer.component.html',
1152
+ styleUrls: ['execution-section-renderer.component.scss'],
1153
+ providers: [SectionScopeService],
1154
+ }]
1155
+ }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.NgModuleRef }, { type: SectionScopeService }, { type: SectionStoreService }]; }, propDecorators: { section: [{
1156
+ type: Input
1157
+ }], form: [{
1158
+ type: Input
1159
+ }], container: [{
1160
+ type: ViewChild,
1161
+ args: ['container', { read: ViewContainerRef, static: true }]
1162
+ }] } });
1163
+
1164
+ class ChildrenPlaceholderComponent {
1165
+ constructor(sectionScope, formScope, collapsibleState) {
1166
+ this.sectionScope = sectionScope;
1167
+ this.formScope = formScope;
1168
+ this.collapsibleState = collapsibleState;
1169
+ this._children = [];
1170
+ this.collapsed = false;
1171
+ }
1172
+ ngOnInit() {
1173
+ this.section = this.sectionScope.section;
1174
+ this.form = this.formScope.form;
1175
+ this.collapsed = this.section.model ? this.collapsibleState.isCollapsedSection(this.section.model.id) : true;
1176
+ this.sub = this.collapsibleState.collapseSectionEvent.subscribe(e => {
1177
+ var _a;
1178
+ const lineItemId = e[0];
1179
+ if (((_a = this.section.model) === null || _a === void 0 ? void 0 : _a.id) === lineItemId) {
1180
+ this.collapsed = e[1];
1181
+ }
1182
+ });
1183
+ this.setChildren();
1184
+ }
1185
+ ngOnChanges(changes) {
1186
+ var _a, _b;
1187
+ if (!this.children || ((_a = changes.children) === null || _a === void 0 ? void 0 : _a.currentValue) !== ((_b = changes.children) === null || _b === void 0 ? void 0 : _b.previousValue)) {
1188
+ this.setChildren();
1189
+ }
1190
+ }
1191
+ setChildren() {
1192
+ this._children = this.children ? this.children : this.section.children;
1193
+ }
1194
+ ngOnDestroy() {
1195
+ this.sub.unsubscribe();
1196
+ }
1197
+ }
1198
+ ChildrenPlaceholderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ChildrenPlaceholderComponent, deps: [{ token: SectionScopeService }, { token: FormScopeService }, { token: CollapsibleStateService }], target: i0.ɵɵFactoryTarget.Component });
1199
+ ChildrenPlaceholderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: ChildrenPlaceholderComponent, selector: "children-placeholder", inputs: { children: "children" }, providers: [OrderByPipe], usesOnChanges: true, ngImport: i0, template: "<ng-container *ngIf=\"!collapsed\">\n <ng-container *ngFor=\"let child of _children\">\n <section-renderer [section]=\"child\" [form]=\"form\" *ngIf=\"!child.hidden\"></section-renderer>\n </ng-container>\n</ng-container>\n", components: [{ type: ExecutionSectionRendererComponent, selector: "section-renderer", inputs: ["section", "form"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
1200
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ChildrenPlaceholderComponent, decorators: [{
1201
+ type: Component,
1202
+ args: [{
1203
+ // eslint-disable-next-line @angular-eslint/component-selector
1204
+ selector: 'children-placeholder',
1205
+ templateUrl: 'children-placeholder.component.html',
1206
+ providers: [OrderByPipe],
1207
+ }]
1208
+ }], ctorParameters: function () { return [{ type: SectionScopeService }, { type: FormScopeService }, { type: CollapsibleStateService }]; }, propDecorators: { children: [{
1209
+ type: Input
1210
+ }] } });
1211
+ class TemplateComponent extends ChildrenPlaceholderComponent {
1212
+ }
1213
+ TemplateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TemplateComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1214
+ TemplateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TemplateComponent, selector: "template-component", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"!collapsed\">\n <ng-container *ngFor=\"let child of _children\">\n <section-renderer [section]=\"child\" [form]=\"form\" *ngIf=\"!child.hidden\"></section-renderer>\n </ng-container>\n</ng-container>\n", components: [{ type: ExecutionSectionRendererComponent, selector: "section-renderer", inputs: ["section", "form"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
1215
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TemplateComponent, decorators: [{
1216
+ type: Component,
1217
+ args: [{
1218
+ // eslint-disable-next-line @angular-eslint/component-selector
1219
+ selector: 'template-component',
1220
+ templateUrl: 'children-placeholder.component.html',
1221
+ }]
1222
+ }] });
1223
+
1224
+ class ContextProviderComponent {
1225
+ constructor(runtimeService) {
1226
+ this.runtimeService = runtimeService;
1227
+ this.types = [];
1228
+ this.products = {};
1229
+ }
1230
+ ngOnInit() {
1231
+ const context = this.runtimeService.getRuntimeContext();
1232
+ if (!context) {
1233
+ return;
1234
+ }
1235
+ this.runtimeService.setRuntimeContext(Object.assign(Object.assign({}, context), { runtimeModel: RuntimeModel.create(this.types, this.products) }));
1236
+ }
1237
+ }
1238
+ ContextProviderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ContextProviderComponent, deps: [{ token: RuntimeService }], target: i0.ɵɵFactoryTarget.Component });
1239
+ ContextProviderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: ContextProviderComponent, selector: "vl-context-provider", inputs: { types: "types", products: "products" }, ngImport: i0, template: '', isInline: true });
1240
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ContextProviderComponent, decorators: [{
1241
+ type: Component,
1242
+ args: [{
1243
+ selector: 'vl-context-provider',
1244
+ template: '',
1245
+ }]
1246
+ }], ctorParameters: function () { return [{ type: RuntimeService, decorators: [{
1247
+ type: Inject,
1248
+ args: [RuntimeService]
1249
+ }] }]; }, propDecorators: { types: [{
1250
+ type: Input
1251
+ }], products: [{
1252
+ type: Input
1253
+ }] } });
1254
+
1255
+ const moduleMap = {};
1256
+ function loadRemoteEntry(remoteEntry) {
1257
+ return new Promise((resolve, reject) => {
1258
+ if (moduleMap[remoteEntry]) {
1259
+ resolve();
1260
+ return;
1261
+ }
1262
+ const script = document.createElement('script');
1263
+ script.src = remoteEntry;
1264
+ script.onerror = reject;
1265
+ script.onload = () => {
1266
+ moduleMap[remoteEntry] = true;
1267
+ resolve(); // window is the global namespace
1268
+ };
1269
+ document.body.append(script);
1270
+ });
1271
+ }
1272
+ function lookupExposedModule(remoteName, exposedModule) {
1273
+ return __awaiter(this, void 0, void 0, function* () {
1274
+ // Initializes the share scope. This fills it with known provided modules from this build and all remotes
1275
+ yield __webpack_init_sharing__('default');
1276
+ const container = window[remoteName]; // or get the container somewhere else
1277
+ // Initialize the container, it may provide shared modules
1278
+ yield container.init(__webpack_share_scopes__.default);
1279
+ const factory = yield container.get(exposedModule);
1280
+ const Module = factory();
1281
+ return Module;
1282
+ });
1283
+ }
1284
+ function loadRemoteModule(options) {
1285
+ return __awaiter(this, void 0, void 0, function* () {
1286
+ yield loadRemoteEntry(options.remoteEntry);
1287
+ return yield lookupExposedModule(options.remoteName, options.exposedModule);
1288
+ });
1289
+ }
1290
+
1291
+ var IntegrationEvent;
1292
+ (function (IntegrationEvent) {
1293
+ IntegrationEvent["Init"] = "Init";
1294
+ })(IntegrationEvent || (IntegrationEvent = {}));
1295
+ class FederatedComponent {
1296
+ constructor(injector, compiler, appRef, renderer) {
1297
+ this.injector = injector;
1298
+ this.compiler = compiler;
1299
+ this.appRef = appRef;
1300
+ this.renderer = renderer;
1301
+ this.integrationEvent = new EventEmitter();
1302
+ this.moduleReady = false;
1303
+ }
1304
+ ngAfterViewInit() {
1305
+ if (!this.remoteEntry || !this.remoteName || !this.exposedModule) {
1306
+ return;
1307
+ }
1308
+ loadRemoteModule({
1309
+ remoteEntry: this.remoteEntry,
1310
+ remoteName: this.remoteName,
1311
+ exposedModule: this.exposedModule,
1312
+ }).then(federated => {
1313
+ this.compiler.compileModuleAsync(federated[this.exposedModule]).then(moduleFactory => {
1314
+ var _a;
1315
+ const rootModuleRef = moduleFactory.create(this.injector);
1316
+ const rootComponentFactory = rootModuleRef.componentFactoryResolver.resolveComponentFactory(federated[this.exposedModule].rootComponent);
1317
+ const node = document.createElement('div');
1318
+ const { instance, hostView } = rootComponentFactory.create(this.injector, [], node);
1319
+ this.instance = instance;
1320
+ this.instance.data = this.data;
1321
+ this.instance.eventData = this.eventData;
1322
+ this.instance.integrationEvent = this.integrationEvent;
1323
+ this.renderer.appendChild((_a = this.moduleHostRef) === null || _a === void 0 ? void 0 : _a.nativeElement, node);
1324
+ this.appRef.attachView(hostView);
1325
+ });
1326
+ });
1327
+ }
1328
+ ngOnChanges(changes) {
1329
+ if (!this.instance) {
1330
+ return;
1331
+ }
1332
+ this.instance.ngOnChanges(changes);
1333
+ }
1334
+ }
1335
+ FederatedComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FederatedComponent, deps: [{ token: i0.Injector }, { token: i0.Compiler }, { token: i0.ApplicationRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
1336
+ FederatedComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: FederatedComponent, selector: "veloce-host-federated", inputs: { remoteEntry: "remoteEntry", remoteName: "remoteName", exposedModule: "exposedModule", data: "data", eventData: "eventData" }, outputs: { integrationEvent: "integrationEvent" }, viewQueries: [{ propertyName: "federatedComponent", first: true, predicate: ["federatedComponent"], descendants: true, read: ViewContainerRef }, { propertyName: "foo", first: true, predicate: ["foo"], descendants: true, read: TemplateRef }, { propertyName: "moduleHostRef", first: true, predicate: ["moduleHost"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div #moduleHost></div>\n", styles: [":host{display:block}div{height:100%}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1337
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FederatedComponent, decorators: [{
1338
+ type: Component,
1339
+ args: [{
1340
+ // eslint-disable-next-line @angular-eslint/component-selector
1341
+ selector: 'veloce-host-federated',
1342
+ templateUrl: './federated.component.html',
1343
+ styleUrls: ['./federated.component.scss'],
1344
+ changeDetection: ChangeDetectionStrategy.OnPush,
1345
+ }]
1346
+ }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.Compiler }, { type: i0.ApplicationRef }, { type: i0.Renderer2 }]; }, propDecorators: { federatedComponent: [{
1347
+ type: ViewChild,
1348
+ args: ['federatedComponent', { read: ViewContainerRef }]
1349
+ }], foo: [{
1350
+ type: ViewChild,
1351
+ args: ['foo', { read: TemplateRef }]
1352
+ }], moduleHostRef: [{
1353
+ type: ViewChild,
1354
+ args: ['moduleHost', { static: false }]
1355
+ }], remoteEntry: [{
1356
+ type: Input
1357
+ }], remoteName: [{
1358
+ type: Input
1359
+ }], exposedModule: [{
1360
+ type: Input
1361
+ }], data: [{
1362
+ type: Input
1363
+ }], eventData: [{
1364
+ type: Input
1365
+ }], integrationEvent: [{
1366
+ type: Output
1367
+ }] } });
1368
+
1369
+ //TODO ALE WE ARE EXTENDING COMPONENT HERE IN PORTS WE ARE EXTENDING DEDICATED CLASS!! TYPES HANDLER IS NO IMPLEMENTED YET
1370
+ class VeloAttributeDirective {
1371
+ constructor(formScope, sectionScope) {
1372
+ this.formScope = formScope;
1373
+ this.sectionScope = sectionScope;
1374
+ this.valueQuantities = {};
1375
+ this.form = this.formScope.form;
1376
+ this.section = this.sectionScope.section;
1377
+ }
1378
+ ngOnInit() {
1379
+ this.initQuantity();
1380
+ }
1381
+ handleChange(valueOption) {
1382
+ const updateData = {
1383
+ id: this.section.id,
1384
+ action: 'update',
1385
+ valueOption,
1386
+ };
1387
+ this.formScope.publishFormUpdate(updateData);
1388
+ }
1389
+ handleChangDate(valueOption) {
1390
+ const oldValue = this.form.controls[this.section.id].value || '';
1391
+ const newValue = isDate(valueOption) ? valueOption.toLocaleDateString('en-us') : '';
1392
+ if (oldValue !== newValue) {
1393
+ this.handleChange(newValue);
1394
+ }
1395
+ }
1396
+ handleRemove() {
1397
+ const updateData = {
1398
+ id: this.section.id,
1399
+ action: 'remove',
1400
+ };
1401
+ this.formScope.publishFormUpdate(updateData);
1402
+ }
1403
+ // TODO ALE THIS IS SPECIFIC STEPPER FUNCTIONS
1404
+ nextVal() {
1405
+ const currentIndex = this.getCurrentValueIndex();
1406
+ const nextValIndex = currentIndex + 1;
1407
+ if (currentIndex != -1 &&
1408
+ this.section.sectionValue &&
1409
+ this.section.sectionValue.valueOptions.length >= nextValIndex) {
1410
+ this.handleChange(this.section.sectionValue.valueOptions[nextValIndex]);
1411
+ }
1412
+ }
1413
+ prevVal() {
1414
+ const currentIndex = this.getCurrentValueIndex();
1415
+ const prevValIndex = currentIndex - 1;
1416
+ if (currentIndex != -1 &&
1417
+ this.section.sectionValue &&
1418
+ this.section.sectionValue.valueOptions.length >= prevValIndex) {
1419
+ this.handleChange(this.section.sectionValue.valueOptions[prevValIndex]);
1420
+ }
1421
+ }
1422
+ initQuantity() {
1423
+ this.valueQuantities = this.section.model
1424
+ ? SectionsBinderHelper.getQuantityGroupByValue(this.section.model, this.section.boundData.name)
1425
+ : {};
1426
+ }
1427
+ getCurrentValueIndex() {
1428
+ const index = -1;
1429
+ const valueOptions = this.section.sectionValue && this.section.sectionValue.valueOptions;
1430
+ const currentValue = this.form.controls[this.section.id].value;
1431
+ if (valueOptions && EntityUtil.isPresent(currentValue)) {
1432
+ return valueOptions.findIndex(valueOption => currentValue === valueOption);
1433
+ }
1434
+ return index;
1435
+ }
1436
+ }
1437
+ VeloAttributeDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloAttributeDirective, deps: [{ token: FormScopeService }, { token: SectionScopeService }], target: i0.ɵɵFactoryTarget.Directive });
1438
+ VeloAttributeDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: VeloAttributeDirective, selector: "velo-attribute-directive", exportAs: ["attributeApi"], ngImport: i0 });
1439
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloAttributeDirective, decorators: [{
1440
+ type: Directive,
1441
+ args: [{
1442
+ // eslint-disable-next-line @angular-eslint/directive-selector
1443
+ selector: 'velo-attribute-directive',
1444
+ exportAs: 'attributeApi',
1445
+ }]
1446
+ }], ctorParameters: function () { return [{ type: FormScopeService }, { type: SectionScopeService }]; } });
1447
+
1448
+ class MultiselectComponent {
1449
+ constructor(elRef, viewContainerRef, overlay) {
1450
+ this.elRef = elRef;
1451
+ this.viewContainerRef = viewContainerRef;
1452
+ this.overlay = overlay;
1453
+ this.selectionChange = new EventEmitter();
1454
+ this.selected = [];
1455
+ this.displayValue = '';
1456
+ this.touched = false;
1457
+ this.disabled = false;
1458
+ this.opened = false;
1459
+ this.onChange = () => {
1460
+ return;
1461
+ };
1462
+ this.onTouched = () => {
1463
+ return;
1464
+ };
1465
+ }
1466
+ ngOnDestroy() {
1467
+ this.destroyDropdown();
1468
+ }
1469
+ writeValue(selected) {
1470
+ this.selected = selected;
1471
+ this.getDisplayValue();
1472
+ }
1473
+ registerOnChange(onChange) {
1474
+ this.onChange = onChange;
1475
+ }
1476
+ registerOnTouched(onTouched) {
1477
+ this.onTouched = onTouched;
1478
+ }
1479
+ setDisabledState(disabled) {
1480
+ this.disabled = disabled;
1481
+ }
1482
+ handleSelection(value) {
1483
+ const selectedItem = this.selected.find(item => item === value);
1484
+ if (selectedItem) {
1485
+ this.selected = this.selected.filter(item => item !== value);
1486
+ }
1487
+ else {
1488
+ this.selected = [...this.selected, value];
1489
+ }
1490
+ this.getDisplayValue();
1491
+ this.selectionChange.emit(this.selected);
1492
+ this.onChange(this.selected);
1493
+ }
1494
+ toggleOpened() {
1495
+ this.opened ? this.destroyDropdown() : this.openDropdown();
1496
+ }
1497
+ getDisplayValue() {
1498
+ const joinedValue = this.selected.join(', ');
1499
+ this.displayValue = joinedValue.length > 24 ? `${this.selected.length} options selected` : joinedValue;
1500
+ }
1501
+ openDropdown() {
1502
+ this.opened = true;
1503
+ this.overlayRef = this.overlay.create({
1504
+ hasBackdrop: true,
1505
+ backdropClass: 'cdk-overlay-transparent-backdrop',
1506
+ scrollStrategy: this.overlay.scrollStrategies.close(),
1507
+ positionStrategy: this.overlay
1508
+ .position()
1509
+ .flexibleConnectedTo(this.elRef)
1510
+ .withPositions([
1511
+ {
1512
+ originX: 'end',
1513
+ originY: 'bottom',
1514
+ overlayX: 'end',
1515
+ overlayY: 'top',
1516
+ offsetY: 8,
1517
+ },
1518
+ ]),
1519
+ });
1520
+ const templatePortal = new TemplatePortal(this.overlayTemplate, this.viewContainerRef);
1521
+ this.overlayRef.attach(templatePortal);
1522
+ this.dropdownClosingActionsSub = this.dropdownClosingActions().subscribe(() => this.destroyDropdown());
1523
+ }
1524
+ dropdownClosingActions() {
1525
+ if (!this.overlayRef) {
1526
+ return of();
1527
+ }
1528
+ const backdropClick$ = this.overlayRef.backdropClick();
1529
+ const detachment$ = this.overlayRef.detachments();
1530
+ return merge(backdropClick$, detachment$);
1531
+ }
1532
+ destroyDropdown() {
1533
+ var _a;
1534
+ if (!this.overlayRef || !this.opened) {
1535
+ return;
1536
+ }
1537
+ (_a = this.dropdownClosingActionsSub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
1538
+ this.opened = false;
1539
+ this.overlayRef.detach();
1540
+ }
1541
+ }
1542
+ MultiselectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: MultiselectComponent, deps: [{ token: i0.ElementRef }, { token: i0.ViewContainerRef }, { token: i1$1.Overlay }], target: i0.ɵɵFactoryTarget.Component });
1543
+ MultiselectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: MultiselectComponent, selector: "velo-multiselect", inputs: { options: "options" }, outputs: { selectionChange: "selectionChange" }, host: { properties: { "class.opened": "this.opened" } }, providers: [
1544
+ {
1545
+ provide: NG_VALUE_ACCESSOR,
1546
+ multi: true,
1547
+ useExisting: MultiselectComponent,
1548
+ },
1549
+ ], viewQueries: [{ propertyName: "overlayTemplate", first: true, predicate: ["overlayTemplate"], descendants: true }], ngImport: i0, template: "<div class=\"value-wrapper\" (click)=\"toggleOpened()\">\n <span class=\"value\">{{ displayValue }}</span>\n <i class=\"fa fa-chevron-down\"></i>\n</div>\n\n<ng-template #overlayTemplate>\n <div class=\"dropdown\">\n <div class=\"checkbox-select\" *ngFor=\"let option of options\">\n <label>\n <input\n type=\"checkbox\"\n [checked]=\"selected.includes(option)\"\n (change)=\"handleSelection(option)\"\n [value]=\"option\"\n />\n\n <i class=\"input-helper\"></i>\n {{ option }}\n </label>\n </div>\n </div>\n</ng-template>\n", styles: [":host{display:block;width:172px}:host[disabled] .value-wrapper{pointer-events:none;background:rgba(0,0,0,.06);border-color:#0003}:host.opened .value-wrapper{border-color:#0e8fff}:host.opened i{transform:rotate(180deg)}:host .value-wrapper{cursor:pointer;display:flex;align-items:center;justify-content:space-between;height:34px;padding:0 10px;border:1px solid #ddd;border-radius:3px;background:#fff}:host .value-wrapper .value{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dropdown{width:172px;max-height:200px;background:#fff;border:1px solid #ddd;border-radius:3px;overflow:auto}.dropdown .checkbox-select{padding:0 10px;width:100%}.dropdown .checkbox-select label{width:100%;height:36px;line-height:36px}.dropdown .checkbox-select .input-helper:before{top:10px}.dropdown .checkbox-select .input-helper:after{top:12px}.dropdown .checkbox-select:hover{background:#d5dddf}\n"], directives: [{ type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
1550
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: MultiselectComponent, decorators: [{
1551
+ type: Component,
1552
+ args: [{
1553
+ // eslint-disable-next-line @angular-eslint/component-selector
1554
+ selector: 'velo-multiselect',
1555
+ templateUrl: 'velo-multiselect.component.html',
1556
+ styleUrls: ['./velo-multiselect.component.scss'],
1557
+ providers: [
1558
+ {
1559
+ provide: NG_VALUE_ACCESSOR,
1560
+ multi: true,
1561
+ useExisting: MultiselectComponent,
1562
+ },
1563
+ ],
1564
+ }]
1565
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ViewContainerRef }, { type: i1$1.Overlay }]; }, propDecorators: { options: [{
1566
+ type: Input
1567
+ }], selectionChange: [{
1568
+ type: Output
1569
+ }], overlayTemplate: [{
1570
+ type: ViewChild,
1571
+ args: ['overlayTemplate']
1572
+ }], opened: [{
1573
+ type: HostBinding,
1574
+ args: ['class.opened']
1575
+ }] } });
1576
+
1577
+ class VeloAttributeComponent extends VeloAttributeDirective {
1578
+ constructor(formScope, sectionScope) {
1579
+ var _a, _b;
1580
+ super(formScope, sectionScope);
1581
+ this.controlName = this.section.id;
1582
+ this.displayName = this.getDisplayName();
1583
+ this.isMultiselect =
1584
+ ((_b = (_a = this.section.model) === null || _a === void 0 ? void 0 : _a.attributes.find(attr => attr.name === this.section.boundData.entity.name)) === null || _b === void 0 ? void 0 : _b.type) ===
1585
+ 'MULTIPLE';
1586
+ }
1587
+ getValueOptions(valueOptions) {
1588
+ return this.isBooleanType(valueOptions) ? [0, 1] : valueOptions;
1589
+ }
1590
+ getValueText(valueOptions, value) {
1591
+ if (this.isBooleanType(valueOptions)) {
1592
+ return value === 0 ? 'False' : 'True';
1593
+ }
1594
+ return value;
1595
+ }
1596
+ handleMultiselectChange(value) {
1597
+ var _a;
1598
+ const formControl = this.form.get(this.controlName);
1599
+ if (!formControl) {
1600
+ return;
1601
+ }
1602
+ const currentValue = (_a = formControl.value) !== null && _a !== void 0 ? _a : [];
1603
+ const newValue = currentValue.includes(value) ? currentValue.filter(v => v !== value) : [...currentValue, value];
1604
+ formControl.setValue(newValue);
1605
+ super.handleChange();
1606
+ }
1607
+ handleMultipleDropdownChange(event) {
1608
+ const formControl = this.form.get(this.controlName);
1609
+ if (!formControl) {
1610
+ return;
1611
+ }
1612
+ formControl.setValue(event);
1613
+ super.handleChange();
1614
+ }
1615
+ isBooleanType(value) {
1616
+ return Array.isArray(value) && value.length === 1 && value[0].min === 0 && value[0].max === 1;
1617
+ }
1618
+ getDisplayName() {
1619
+ var _a, _b;
1620
+ return ((((_a = this.section.model) === null || _a === void 0 ? void 0 : _a.properties) && this.section.model.properties['displayName']) || ((_b = this.section.model) === null || _b === void 0 ? void 0 : _b.type) || '');
1621
+ }
1622
+ }
1623
+ VeloAttributeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloAttributeComponent, deps: [{ token: FormScopeService }, { token: SectionScopeService }], target: i0.ɵɵFactoryTarget.Component });
1624
+ VeloAttributeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: VeloAttributeComponent, selector: "velo-attribute", usesInheritance: true, ngImport: i0, template: "<div class=\"form-group div-inline\" [formGroup]=\"form\">\n <div class=\"input-form-input div-inline\" [class.input-form-input--required]=\"section.required\">\n <label>\n <ng-container *ngIf=\"section.required\"> * </ng-container>\n\n {{ section.label }}\n </label>\n <div [ngSwitch]=\"section.controlType\" class=\"form-control-wrapper\">\n <div *ngSwitchCase=\"'DROPDOWN'\">\n <select\n [id]=\"controlName\"\n [formControlName]=\"controlName\"\n class=\"form-control\"\n (change)=\"handleChange()\"\n [attr.disabled]=\"section.readOnly ? true : null\"\n >\n <option\n *ngFor=\"let valueOption of getValueOptions(section.sectionValue?.valueOptions) || []\"\n [ngValue]=\"valueOption\"\n >\n {{ getValueText(section.sectionValue?.valueOptions, valueOption) }}\n </option>\n </select>\n </div>\n\n <div *ngSwitchCase=\"'MULTISELECT'\">\n <velo-multiselect\n [id]=\"controlName\"\n [formControlName]=\"controlName\"\n [options]=\"getValueOptions(section.sectionValue?.valueOptions)\"\n [attr.disabled]=\"section.readOnly ? true : null\"\n (selectionChange)=\"handleMultipleDropdownChange($event)\"\n ></velo-multiselect>\n </div>\n\n <div *ngSwitchCase=\"'RADIO'\">\n <div\n *ngFor=\"let valueOption of getValueOptions(section.sectionValue?.valueOptions)\"\n class=\"radio-button\"\n [attr.disabled]=\"section.readOnly ? true : null\"\n >\n <label>\n <input\n type=\"radio\"\n [id]=\"controlName\"\n [formControlName]=\"controlName\"\n [value]=\"valueOption\"\n (change)=\"handleChange()\"\n [attr.disabled]=\"section.readOnly ? true : null\"\n />\n <i class=\"input-helper\"></i>\n {{ getValueText(section.sectionValue?.valueOptions, valueOption) }}\n </label>\n </div>\n </div>\n\n <div *ngSwitchCase=\"'CHECKBOX'\">\n <ng-container *ngIf=\"!isMultiselect; else multiselect\">\n <div class=\"checkbox-select\" [attr.disabled]=\"section.readOnly ? true : null\">\n <label>\n <input\n type=\"checkbox\"\n [id]=\"controlName\"\n [formControlName]=\"controlName\"\n [checked]=\"section.sectionValue?.value === 1\"\n (change)=\"handleChange()\"\n [attr.disabled]=\"section.readOnly ? true : null\"\n />\n\n <i class=\"input-helper\"></i>\n &nbsp;\n </label>\n </div>\n </ng-container>\n\n <ng-template #multiselect>\n <div\n *ngFor=\"let valueOption of getValueOptions(section.sectionValue?.valueOptions)\"\n class=\"checkbox-select\"\n [attr.disabled]=\"section.readOnly ? true : null\"\n >\n <label>\n <input\n type=\"checkbox\"\n [id]=\"controlName\"\n [checked]=\"section.sectionValue?.value.includes(valueOption)\"\n (change)=\"handleMultiselectChange(valueOption)\"\n [value]=\"valueOption\"\n [attr.disabled]=\"section.readOnly ? true : null\"\n />\n\n <i class=\"input-helper\"></i>\n {{ valueOption }}\n </label>\n </div>\n </ng-template>\n </div>\n\n <div *ngSwitchCase=\"'DATE'\">\n <input\n type=\"text\"\n class=\"form-control\"\n [id]=\"controlName\"\n [formControlName]=\"controlName\"\n [attr.disabled]=\"section.readOnly ? true : null\"\n (bsValueChange)=\"handleChangDate($event)\"\n bsDatepicker\n />\n </div>\n\n <div *ngSwitchDefault>\n <input\n type=\"text\"\n class=\"form-control\"\n [id]=\"controlName\"\n [formControlName]=\"controlName\"\n (blur)=\"form.controls[controlName].dirty && handleChange()\"\n [attr.disabled]=\"section.readOnly ? true : null\"\n />\n </div>\n\n <!-- Add validation messages -->\n <!-- <div validation-messages [form]=\"form\" [controlId]=\"controlName\" [showForPristine]=\"true\"></div> -->\n </div>\n </div>\n</div>\n", components: [{ type: MultiselectComponent, selector: "velo-multiselect", inputs: ["options"], outputs: ["selectionChange"] }], directives: [{ type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i5.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i4.RadioControlValueAccessor, selector: "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", inputs: ["name", "formControlName", "value"] }, { type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { type: i5.NgSwitchDefault, selector: "[ngSwitchDefault]" }] });
1625
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloAttributeComponent, decorators: [{
1626
+ type: Component,
1627
+ args: [{
1628
+ // eslint-disable-next-line @angular-eslint/component-selector
1629
+ selector: 'velo-attribute',
1630
+ templateUrl: 'velo-attribute.component.html',
1631
+ }]
1632
+ }], ctorParameters: function () { return [{ type: FormScopeService }, { type: SectionScopeService }]; } });
1633
+
1634
+ class VeloPortCheckBoxComponent {
1635
+ constructor(formScope, sectionScope) {
1636
+ var _a;
1637
+ this.formScope = formScope;
1638
+ this.sectionScope = sectionScope;
1639
+ this.showSelectAll = false;
1640
+ this.form = this.formScope.form;
1641
+ this.section = this.sectionScope.section;
1642
+ this.controlName = this.section.id;
1643
+ (_a = this.section.sectionValue) === null || _a === void 0 ? void 0 : _a.valueOptions.forEach(item => {
1644
+ if (this.hasValueFor(item)) {
1645
+ this.form.controls[this.controlName].setValue(item);
1646
+ }
1647
+ });
1648
+ }
1649
+ handleChange(valueOption) {
1650
+ const updateData = {
1651
+ id: this.section.id,
1652
+ action: this.hasValueFor(valueOption)
1653
+ ? 'remove'
1654
+ : this.section.model && SectionsBinderHelper.isAddAllowed(this.section.model, this.section.boundData.name)
1655
+ ? 'create'
1656
+ : 'update',
1657
+ valueOption,
1658
+ };
1659
+ this.formScope.publishFormUpdate(updateData);
1660
+ }
1661
+ hasValueFor(valueOption) {
1662
+ return !!this.findLineItemForValue(valueOption);
1663
+ }
1664
+ selectAllChange() {
1665
+ var _a;
1666
+ const portDomain = (_a = this.section.model) === null || _a === void 0 ? void 0 : _a.portDomains[this.section.boundData.name];
1667
+ const updateData = {
1668
+ id: this.section.id,
1669
+ action: 'upsert',
1670
+ selectedValueOptions: this.isAllSelected() ? [] : portDomain ? portDomain.domainTypes.map(t => t.name) : [],
1671
+ };
1672
+ this.formScope.publishFormUpdate(updateData);
1673
+ }
1674
+ isAllSelected() {
1675
+ var _a, _b;
1676
+ const selected = (_a = this.section.model) === null || _a === void 0 ? void 0 : _a.lineItems.filter(li => li.port && li.port === this.section.boundData.name);
1677
+ const portDomain = (_b = this.section.model) === null || _b === void 0 ? void 0 : _b.portDomains[this.section.boundData.name];
1678
+ return portDomain ? portDomain.domainTypes.length === (selected === null || selected === void 0 ? void 0 : selected.length) : false;
1679
+ }
1680
+ getMessages(valueOption) {
1681
+ var _a, _b, _c;
1682
+ if ((_a = this.section.model) === null || _a === void 0 ? void 0 : _a.lineItems) {
1683
+ return (_c = (_b = this.findLineItemForValue(valueOption)) === null || _b === void 0 ? void 0 : _b.messages) !== null && _c !== void 0 ? _c : [];
1684
+ }
1685
+ return [];
1686
+ }
1687
+ findLineItemForValue(valueOption) {
1688
+ var _a;
1689
+ return (((_a = this.section.model) === null || _a === void 0 ? void 0 : _a.lineItems) &&
1690
+ this.section.model.lineItems.find(li => li.type && li.type.toLowerCase() === valueOption.toLowerCase()));
1691
+ }
1692
+ }
1693
+ VeloPortCheckBoxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloPortCheckBoxComponent, deps: [{ token: FormScopeService }, { token: SectionScopeService }], target: i0.ɵɵFactoryTarget.Component });
1694
+ VeloPortCheckBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: VeloPortCheckBoxComponent, selector: "velo-port-checkbox", inputs: { showSelectAll: "showSelectAll" }, ngImport: i0, template: "<div [formGroup]=\"form\">\n <!--TODO ALE replace divs with ng-templates-->\n <div *ngIf=\"showSelectAll\">\n <div class=\"row no-gutter clearfix\">\n <div class=\"col-md-12\">\n <div class=\"content\">\n <div class=\"container-box container-box-bordered container-box-checkbox collapsed\">\n <div class=\"box-title\">\n <div class=\"header clearfix\">\n <div class=\"checkbox-select\">\n <label>\n <input type=\"checkbox\" (change)=\"selectAllChange()\" [checked]=\"isAllSelected()\" />\n\n <i class=\"input-helper\"></i>\n Select All\n </label>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div *ngFor=\"let valueOption of section.sectionValue?.valueOptions\">\n <div class=\"unchecked\">\n <div class=\"row no-gutter clearfix\">\n <div class=\"col-md-12\">\n <div class=\"content\">\n <div class=\"container-box container-box-bordered container-box-checkbox collapsed\">\n <div class=\"box-title\" (click)=\"handleChange(valueOption)\">\n <div class=\"header clearfix\">\n <div class=\"checkbox-select\">\n <label>\n <input\n type=\"checkbox\"\n [class.checkbox--checked]=\"valueOption === form.controls[controlName].value\"\n />\n\n <i class=\"input-helper\"></i>\n {{section.sectionValue?.displayValues?.[valueOption] || valueOption}}\n </label>\n </div>\n </div>\n\n <div class=\"box-actions\" *ngIf=\"hasValueFor(valueOption)\">\n <ng-template #msgTemplate>\n <div class=\"runtime-info-message\">\n <ul class=\"message-text\">\n <li *ngFor=\"let message of getMessages(valueOption)\">{{ message }}</li>\n </ul>\n </div>\n </ng-template>\n <div\n class=\"box-action-button\"\n *ngIf=\"getMessages(valueOption).length > 0\"\n [popover]=\"msgTemplate\"\n placement=\"left\"\n container=\"body\"\n [isOpen]=\"true\"\n >\n <a href=\"javascript:void(0);\">\n <i class=\"fa fa-info check-icon\"></i>\n </a>\n </div>\n </div>\n </div>\n <div class=\"box-content-wrapper\">\n <div class=\"box-content\">&nbsp;</div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</div>\n<ng-content></ng-content>\n", directives: [{ type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5$1.PopoverDirective, selector: "[popover]", inputs: ["outsideClick", "containerClass", "isOpen", "adaptivePosition", "popover", "popoverContext", "popoverTitle", "placement", "triggers", "container", "delay"], outputs: ["onShown", "onHidden"], exportAs: ["bs-popover"] }] });
1695
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloPortCheckBoxComponent, decorators: [{
1696
+ type: Component,
1697
+ args: [{
1698
+ // eslint-disable-next-line @angular-eslint/component-selector
1699
+ selector: 'velo-port-checkbox',
1700
+ templateUrl: 'velo-port-checkbox.component.html',
1701
+ }]
1702
+ }], ctorParameters: function () { return [{ type: FormScopeService }, { type: SectionScopeService }]; }, propDecorators: { showSelectAll: [{
1703
+ type: Input
1704
+ }] } });
1705
+
1706
+ class VeloPortDropdownComponent {
1707
+ constructor(formScope, sectionScope) {
1708
+ var _a;
1709
+ this.formScope = formScope;
1710
+ this.sectionScope = sectionScope;
1711
+ this.prices = {};
1712
+ this.form = this.formScope.form;
1713
+ this.section = this.sectionScope.section;
1714
+ this.controlName = this.section.id;
1715
+ this.qtyControlName = this.section.id + 'qty';
1716
+ if (this.section.pricingEnabled) {
1717
+ (_a = this.section.sectionValue) === null || _a === void 0 ? void 0 : _a.valueOptions.forEach(valueOption => {
1718
+ this.prices[valueOption] = this.findPriceItemsForValue(valueOption);
1719
+ });
1720
+ }
1721
+ }
1722
+ isAddAllowed() {
1723
+ if (!EntityUtil.isPresent(this.form.controls[this.controlName].value)) {
1724
+ return false;
1725
+ }
1726
+ return this.section.model
1727
+ ? SectionsBinderHelper.isAddAllowed(this.section.model, this.section.boundData.name)
1728
+ : false;
1729
+ }
1730
+ handleCreate() {
1731
+ if (this.form.invalid || !this.isAddAllowed()) {
1732
+ return;
1733
+ }
1734
+ const updateData = {
1735
+ id: this.section.id,
1736
+ action: 'create',
1737
+ };
1738
+ this.formScope.publishFormUpdate(updateData);
1739
+ }
1740
+ findPriceItemsForValue(valueOption) {
1741
+ var _a;
1742
+ let prices = [];
1743
+ if (valueOption) {
1744
+ const portDomain = (_a = this.section.model) === null || _a === void 0 ? void 0 : _a.portDomains[this.section.boundData.name];
1745
+ const domainType = portDomain === null || portDomain === void 0 ? void 0 : portDomain.domainTypes.find(d => d.name.toLowerCase() === valueOption.toLowerCase());
1746
+ if (domainType && domainType.recommendedPrices) {
1747
+ prices = domainType.recommendedPrices;
1748
+ }
1749
+ }
1750
+ const oneTime = {
1751
+ chargeMethod: 'ONE_TIME',
1752
+ netPrice: 0,
1753
+ listPrice: 0,
1754
+ chargeType: '',
1755
+ };
1756
+ const recurring = {
1757
+ chargeMethod: 'RECURRING',
1758
+ netPrice: 0,
1759
+ listPrice: 0,
1760
+ chargeType: '',
1761
+ };
1762
+ prices.forEach(p => {
1763
+ if (p.chargeMethod === oneTime.chargeMethod) {
1764
+ this.add(oneTime, p);
1765
+ }
1766
+ if (p.chargeMethod === recurring.chargeMethod) {
1767
+ this.add(recurring, p);
1768
+ }
1769
+ });
1770
+ const result = [];
1771
+ if (oneTime.listPrice > 0) {
1772
+ result.push(oneTime);
1773
+ }
1774
+ if (recurring.listPrice > 0) {
1775
+ result.push(recurring);
1776
+ }
1777
+ return result;
1778
+ }
1779
+ add(target, src) {
1780
+ target.netPrice = target.netPrice + src.netPrice;
1781
+ target.listPrice = target.listPrice + src.listPrice;
1782
+ if (src.explanation) {
1783
+ target.explanation = src.explanation;
1784
+ }
1785
+ }
1786
+ }
1787
+ VeloPortDropdownComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloPortDropdownComponent, deps: [{ token: FormScopeService }, { token: SectionScopeService }], target: i0.ɵɵFactoryTarget.Component });
1788
+ VeloPortDropdownComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: VeloPortDropdownComponent, selector: "velo-port-dropdown", ngImport: i0, template: "<div class=\"form-group col-md-12\" [formGroup]=\"form\">\n <div class=\"input-form-input div-inline\">\n <label [for]=\"controlName\">{{ section.label }}</label>\n <div class=\"form-control-wrapper\">\n <select [id]=\"controlName\" [formControlName]=\"controlName\" class=\"form-control\">\n <option *ngFor=\"let valueOption of section.sectionValue?.valueOptions\" [ngValue]=\"valueOption\">\n {{section.sectionValue?.displayValues?.[valueOption] || valueOption}}\n <span *ngIf=\"prices[valueOption] && prices[valueOption].length > 0\">\n <span>${{ prices[valueOption][0].netPrice }}</span>\n <span *ngIf=\"prices[valueOption].length > 1\">\n <span>, </span>\n <span>${{ prices[valueOption][1].netPrice }}</span>\n </span>\n </span>\n </option>\n </select>\n </div>\n </div>\n <div class=\"input-form-input div-inline quantity-form-input\">\n <label [for]=\"qtyControlName\"> Quantity </label>\n <div class=\"form-control-wrapper\">\n <input [id]=\"qtyControlName\" [formControlName]=\"qtyControlName\" type=\"text\" class=\"form-control\" size=\"3\" />\n\n <div\n class=\"validation-message\"\n [hidden]=\"form.controls[qtyControlName].valid || form.controls[qtyControlName].pristine\"\n >\n <div *ngFor=\"let key of form.controls[qtyControlName].errors | values\">\n <span> {{form.controls[qtyControlName]?.errors?.[key].message}}</span>\n </div>\n </div>\n\n <a href=\"javascript:void(0);\" (click)=\"handleCreate()\">\n <div class=\"add-config-control\" [attr.disabled]=\"form.valid && isAddAllowed() ? null : true\">\n <i class=\"fa fa-plus plus-icon\"></i>\n </div>\n </a>\n </div>\n </div>\n</div>\n<ng-content></ng-content>\n", directives: [{ type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }], pipes: { "values": i7.ValuesPipe } });
1789
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloPortDropdownComponent, decorators: [{
1790
+ type: Component,
1791
+ args: [{
1792
+ // eslint-disable-next-line @angular-eslint/component-selector
1793
+ selector: 'velo-port-dropdown',
1794
+ templateUrl: 'velo-port-dropdown.component.html',
1795
+ }]
1796
+ }], ctorParameters: function () { return [{ type: FormScopeService }, { type: SectionScopeService }]; } });
1797
+
1798
+ class VeloPortRadioComponent {
1799
+ constructor(formScope, sectionScope) {
1800
+ this.formScope = formScope;
1801
+ this.sectionScope = sectionScope;
1802
+ this.prices = {};
1803
+ this.form = this.formScope.form;
1804
+ this.section = this.sectionScope.section;
1805
+ this.controlName = this.section.id;
1806
+ }
1807
+ ngOnInit() {
1808
+ var _a;
1809
+ this.initPriceItems();
1810
+ (_a = this.section.sectionValue) === null || _a === void 0 ? void 0 : _a.valueOptions.forEach(item => {
1811
+ if (this.hasValueFor(item)) {
1812
+ this.form.controls[this.controlName].setValue(item);
1813
+ }
1814
+ });
1815
+ }
1816
+ handleChange(event, valueOption) {
1817
+ event.preventDefault();
1818
+ event.stopPropagation();
1819
+ const updateData = {
1820
+ id: this.section.id,
1821
+ action: this.hasPreviousValue() ? 'update' : 'create',
1822
+ valueOption,
1823
+ };
1824
+ this.form.controls[this.controlName].setValue(valueOption);
1825
+ this.form.controls[this.controlName].markAsDirty();
1826
+ this.formScope.publishFormUpdate(updateData);
1827
+ }
1828
+ hasValueFor(valueOption) {
1829
+ return !!this.findLineItemForValue(valueOption);
1830
+ }
1831
+ getMessages(valueOption) {
1832
+ var _a;
1833
+ const lineItem = this.findLineItemForValue(valueOption);
1834
+ if (((_a = this.section.model) === null || _a === void 0 ? void 0 : _a.lineItems) && lineItem) {
1835
+ return lineItem.messages;
1836
+ }
1837
+ return [];
1838
+ }
1839
+ toString(price) {
1840
+ let result = '';
1841
+ if (price.listPrice > price.netPrice) {
1842
+ result += '<strike>' + price.listPrice + '</strike>';
1843
+ }
1844
+ result += price.netPrice;
1845
+ if (price.explanation) {
1846
+ result += '(' + price.explanation + ')';
1847
+ }
1848
+ return result;
1849
+ }
1850
+ hasPreviousValue() {
1851
+ var _a;
1852
+ const previous = (_a = this.section.model) === null || _a === void 0 ? void 0 : _a.lineItems.filter(li => li.port && li.port === this.section.boundData.name);
1853
+ return previous ? previous.length > 0 : false;
1854
+ }
1855
+ findLineItemForValue(valueOption) {
1856
+ return this.section.model ? LineItemUtil.findLineItemForValue(this.section.model, valueOption) : undefined;
1857
+ }
1858
+ initPriceItems() {
1859
+ var _a;
1860
+ this.prices = {};
1861
+ if (this.section.pricingEnabled) {
1862
+ (_a = this.section.sectionValue) === null || _a === void 0 ? void 0 : _a.valueOptions.forEach(valueOption => {
1863
+ this.prices[valueOption] = this.findPriceItemsForValue(valueOption);
1864
+ });
1865
+ }
1866
+ }
1867
+ findPriceItemsForValue(valueOption) {
1868
+ var _a, _b;
1869
+ let prices = [];
1870
+ if (valueOption) {
1871
+ const lineItem = ((_a = this.section.model) === null || _a === void 0 ? void 0 : _a.lineItems) &&
1872
+ this.section.model.lineItems.find(li => li.type && li.type.toLowerCase() === valueOption.toLowerCase());
1873
+ if (lineItem && lineItem.chargeItems) {
1874
+ prices = lineItem.chargeItems.map(pi => {
1875
+ const price = {
1876
+ listPrice: pi.listPrice,
1877
+ netPrice: pi.netPrice,
1878
+ chargeMethod: pi.chargeMethod,
1879
+ chargeType: pi.chargeType,
1880
+ };
1881
+ return price;
1882
+ });
1883
+ }
1884
+ else {
1885
+ const portDomain = (_b = this.section.model) === null || _b === void 0 ? void 0 : _b.portDomains[this.section.boundData.name];
1886
+ const domainType = portDomain === null || portDomain === void 0 ? void 0 : portDomain.domainTypes.find(d => d.name.toLowerCase() === valueOption.toLowerCase());
1887
+ if (domainType && domainType.recommendedPrices) {
1888
+ prices = domainType.recommendedPrices;
1889
+ }
1890
+ }
1891
+ }
1892
+ const oneTime = {
1893
+ chargeMethod: 'ONE_TIME',
1894
+ netPrice: 0,
1895
+ listPrice: 0,
1896
+ chargeType: '',
1897
+ };
1898
+ const recurring = {
1899
+ chargeMethod: 'RECURRING',
1900
+ netPrice: 0,
1901
+ listPrice: 0,
1902
+ chargeType: '',
1903
+ };
1904
+ prices.forEach(p => {
1905
+ if (p.chargeMethod === oneTime.chargeMethod) {
1906
+ this.add(oneTime, p);
1907
+ }
1908
+ if (p.chargeMethod === recurring.chargeMethod) {
1909
+ this.add(recurring, p);
1910
+ }
1911
+ });
1912
+ const result = [];
1913
+ if (oneTime.listPrice > 0) {
1914
+ result.push(oneTime);
1915
+ }
1916
+ if (recurring.listPrice > 0) {
1917
+ result.push(recurring);
1918
+ }
1919
+ return result;
1920
+ }
1921
+ add(target, src) {
1922
+ target.netPrice = target.netPrice + src.netPrice;
1923
+ target.listPrice = target.listPrice + src.listPrice;
1924
+ if (src.explanation) {
1925
+ target.explanation = src.explanation;
1926
+ }
1927
+ }
1928
+ }
1929
+ VeloPortRadioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloPortRadioComponent, deps: [{ token: FormScopeService }, { token: SectionScopeService }], target: i0.ɵɵFactoryTarget.Component });
1930
+ VeloPortRadioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: VeloPortRadioComponent, selector: "velo-port-radio", ngImport: i0, template: "<div [formGroup]=\"form\">\n <!--TODO ALE replace divs with ng-templates-->\n <ng-container *ngFor=\"let valueOption of section.sectionValue?.valueOptions\">\n <div class=\"unchecked\">\n <div class=\"row no-gutter clearfix\">\n <div class=\"col-md-12\">\n <div class=\"content\">\n <div class=\"container-box container-box-bordered container-box-radio\">\n <div class=\"box-title\" (click)=\"handleChange($event, valueOption)\">\n <div class=\"header clearfix\">\n <div class=\"radio-button\">\n <label>\n <input type=\"radio\" [id]=\"controlName\" [value]=\"valueOption\" [formControlName]=\"controlName\" />\n\n <i class=\"input-helper\"></i>\n\n {{ section.sectionValue?.displayValues?.[valueOption] || valueOption }}\n\n <span *ngIf=\"prices[valueOption] && prices[valueOption].length > 0\">\n <span>${{ prices[valueOption][0].netPrice }}</span>\n\n <span *ngIf=\"prices[valueOption].length > 1\">\n <span>, </span>\n\n <span>${{ prices[valueOption][1].netPrice }}</span>\n </span>\n </span>\n </label>\n <span *ngIf=\"prices[valueOption] && prices[valueOption].length > 0\">\n <div>{{ prices[valueOption][0].explanation }}</div>\n\n <span *ngIf=\"prices[valueOption].length > 1 && prices[valueOption][1].explanation\">\n <div>{{ prices[valueOption][1].explanation }}</div>\n </span>\n </span>\n </div>\n </div>\n </div>\n </div>\n\n <ng-content></ng-content>\n </div>\n </div>\n </div>\n </div>\n </ng-container>\n</div>\n<ng-content></ng-content>\n", directives: [{ type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4.RadioControlValueAccessor, selector: "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", inputs: ["name", "formControlName", "value"] }, { type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
1931
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloPortRadioComponent, decorators: [{
1932
+ type: Component,
1933
+ args: [{
1934
+ // tslint:disable-next-line:component-selector
1935
+ // eslint-disable-next-line @angular-eslint/component-selector
1936
+ selector: 'velo-port-radio',
1937
+ templateUrl: 'velo-port-radio.component.html',
1938
+ }]
1939
+ }], ctorParameters: function () { return [{ type: FormScopeService }, { type: SectionScopeService }]; } });
1940
+
1941
+ class VeloTypeComponent {
1942
+ constructor(formScope, collapsibleState, sectionScope, messageService) {
1943
+ var _a, _b;
1944
+ this.formScope = formScope;
1945
+ this.collapsibleState = collapsibleState;
1946
+ this.sectionScope = sectionScope;
1947
+ this.messageService = messageService;
1948
+ this.messageBucketId = 'ui-runtime';
1949
+ this.indent = 1;
1950
+ this.prices = [];
1951
+ this.form = this.formScope.form;
1952
+ this.section = this.sectionScope.section;
1953
+ this.indent = this.sectionScope.indent;
1954
+ this.controlName = this.section.id;
1955
+ this.qtyControlName = this.section.id + 'qty';
1956
+ this.displayName =
1957
+ (((_a = this.section.model) === null || _a === void 0 ? void 0 : _a.properties) && this.section.model.properties.displayName) || ((_b = this.section.model) === null || _b === void 0 ? void 0 : _b.type) || '';
1958
+ }
1959
+ ngOnInit() {
1960
+ var _a, _b;
1961
+ if (this.section.pricingEnabled) {
1962
+ this.prices = this.getPrices();
1963
+ }
1964
+ if (this.section.controlType === 'MESSAGE') {
1965
+ this.messageService.clear(this.messageBucketId);
1966
+ (_b = (_a = this.section.model) === null || _a === void 0 ? void 0 : _a.messages) === null || _b === void 0 ? void 0 : _b.forEach(message => {
1967
+ this.messageService.add({ key: this.messageBucketId, summary: message });
1968
+ });
1969
+ }
1970
+ }
1971
+ handleRemove() {
1972
+ const updateData = {
1973
+ id: this.section.id,
1974
+ action: 'remove',
1975
+ };
1976
+ this.formScope.publishFormUpdate(updateData);
1977
+ }
1978
+ handleQuantityUpdate() {
1979
+ const updateData = {
1980
+ id: this.section.id,
1981
+ action: 'qtyUpdate',
1982
+ };
1983
+ this.formScope.publishFormUpdate(updateData);
1984
+ }
1985
+ toggleCollapse() {
1986
+ if (this.section.model) {
1987
+ this.collapsibleState.toggleCollapse(this.section.model.id);
1988
+ }
1989
+ }
1990
+ getPrices() {
1991
+ var _a;
1992
+ let prices = [];
1993
+ if ((_a = this.section.model) === null || _a === void 0 ? void 0 : _a.chargeItems) {
1994
+ prices = this.section.model.chargeItems.map(pi => {
1995
+ const price = {
1996
+ listPrice: pi.listPrice,
1997
+ netPrice: pi.netPrice,
1998
+ chargeMethod: pi.chargeMethod,
1999
+ chargeType: pi.chargeType,
2000
+ };
2001
+ return price;
2002
+ });
2003
+ }
2004
+ const oneTime = {
2005
+ chargeMethod: 'ONE_TIME',
2006
+ netPrice: 0,
2007
+ listPrice: 0,
2008
+ chargeType: '',
2009
+ };
2010
+ const recurring = {
2011
+ chargeMethod: 'RECURRING',
2012
+ netPrice: 0,
2013
+ listPrice: 0,
2014
+ chargeType: '',
2015
+ };
2016
+ prices.forEach(p => {
2017
+ if (p.chargeMethod === oneTime.chargeMethod) {
2018
+ this.add(oneTime, p);
2019
+ }
2020
+ if (p.chargeMethod === recurring.chargeMethod) {
2021
+ this.add(recurring, p);
2022
+ }
2023
+ });
2024
+ const result = [];
2025
+ if (oneTime.listPrice > 0) {
2026
+ result.push(oneTime);
2027
+ }
2028
+ if (recurring.listPrice > 0) {
2029
+ result.push(recurring);
2030
+ }
2031
+ return result;
2032
+ }
2033
+ add(target, src) {
2034
+ target.netPrice = target.netPrice + src.netPrice;
2035
+ target.listPrice = target.listPrice + src.listPrice;
2036
+ if (src.explanation) {
2037
+ target.explanation = src.explanation;
2038
+ }
2039
+ }
2040
+ }
2041
+ VeloTypeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloTypeComponent, deps: [{ token: FormScopeService }, { token: CollapsibleStateService }, { token: SectionScopeService }, { token: i3$1.MessageService }], target: i0.ɵɵFactoryTarget.Component });
2042
+ VeloTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: VeloTypeComponent, selector: "velo-type", ngImport: i0, template: "<div class=\"container-box div-block collapsed container-box-bordered\" [formGroup]=\"form\">\n <div class=\"box-title\">\n <div class=\"header clearfix\">\n <div>\n <div class=\"header-label div-inline\">\n {{ displayName }}\n <span *ngIf=\"prices.length > 0\">\n <span>${{ prices[0].netPrice }}</span>\n <span *ngIf=\"prices.length > 1\">\n <span>, </span>\n <span>${{ prices[1].netPrice }}</span>\n </span>\n </span>\n </div>\n\n <div class=\"header-qty-container input-form-input\">\n <input\n [id]=\"qtyControlName\"\n [formControlName]=\"qtyControlName\"\n (blur)=\"form.controls[qtyControlName].valid && handleQuantityUpdate()\"\n type=\"text\"\n class=\"form-control\"\n size=\"3\"\n />\n <div class=\"validation-message\">\n <div *ngFor=\"let key of form.controls[qtyControlName].errors | values\">\n <span>\n {{ form.controls[qtyControlName]?.errors?.[key].message }}\n </span>\n </div>\n <span *ngIf=\"form.controls[qtyControlName].valid\"> &nbsp; </span>\n </div>\n <span *ngIf=\"prices.length > 0\">\n <div>{{ prices[0].explanation }}</div>\n <span *ngIf=\"prices.length > 1 && prices[1].explanation\">\n <div>{{ prices[1].explanation }}</div>\n </span>\n </span>\n </div>\n </div>\n </div>\n\n <div class=\"box-actions\">\n <ng-container *ngIf=\"section.controlType !== 'MESSAGE'\">\n <ng-template #msgTemplate>\n <div class=\"runtime-info-message\">\n <ul class=\"message-text\">\n <li *ngFor=\"let message of section.model?.messages\">{{ message }}</li>\n </ul>\n </div>\n </ng-template>\n\n <div\n class=\"box-action-button\"\n *ngIf=\"(section.model?.messages?.length ?? 0) > 0\"\n [popover]=\"msgTemplate\"\n placement=\"left\"\n container=\"body\"\n [isOpen]=\"true\"\n >\n <a href=\"javascript:void(0);\">\n <i class=\"fa fa-info check-icon\"></i>\n </a>\n </div>\n </ng-container>\n\n <div\n class=\"box-action-button\"\n (click)=\"toggleCollapse()\"\n [hidden]=\"!section.children || section.children.length < 1\"\n >\n <a><i class=\"fa fa-chevron-down check-icon\"></i></a>\n </div>\n\n <div class=\"box-action-button\" (click)=\"handleRemove()\">\n <a><i class=\"fa fa-trash-o check-icon\"></i></a>\n </div>\n </div>\n </div>\n\n <ng-content></ng-content>\n</div>\n", directives: [{ type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5$1.PopoverDirective, selector: "[popover]", inputs: ["outsideClick", "containerClass", "isOpen", "adaptivePosition", "popover", "popoverContext", "popoverTitle", "placement", "triggers", "container", "delay"], outputs: ["onShown", "onHidden"], exportAs: ["bs-popover"] }], pipes: { "values": i7.ValuesPipe } });
2043
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloTypeComponent, decorators: [{
2044
+ type: Component,
2045
+ args: [{
2046
+ // eslint-disable-next-line @angular-eslint/component-selector
2047
+ selector: 'velo-type',
2048
+ templateUrl: 'velo-type.component.html',
2049
+ }]
2050
+ }], ctorParameters: function () { return [{ type: FormScopeService }, { type: CollapsibleStateService }, { type: SectionScopeService }, { type: i3$1.MessageService }]; } });
2051
+
2052
+ class SfQueryDirective {
2053
+ constructor(apiService) {
2054
+ this.apiService = apiService;
2055
+ }
2056
+ query(searchRequest, objectName) {
2057
+ return this.apiService.query(searchRequest, objectName).toPromise();
2058
+ }
2059
+ describe(objectName, fieldName) {
2060
+ return this.apiService.describe(objectName, fieldName).toPromise();
2061
+ }
2062
+ describe2(objectName, fieldsNames) {
2063
+ return this.apiService.describe2(objectName, fieldsNames).toPromise();
2064
+ }
2065
+ apexGetRequest(path, params) {
2066
+ return this.apiService.apexGetRequest(path, params).toPromise();
2067
+ }
2068
+ apexPostRequest(path, body) {
2069
+ return this.apiService.apexPostRequest(path, body).toPromise();
2070
+ }
2071
+ }
2072
+ SfQueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SfQueryDirective, deps: [{ token: i1.SalesforceApiService }], target: i0.ɵɵFactoryTarget.Directive });
2073
+ SfQueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: SfQueryDirective, selector: "sf-query", exportAs: ["sfApi"], ngImport: i0 });
2074
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SfQueryDirective, decorators: [{
2075
+ type: Directive,
2076
+ args: [{
2077
+ // eslint-disable-next-line @angular-eslint/directive-selector
2078
+ selector: 'sf-query',
2079
+ exportAs: 'sfApi',
2080
+ }]
2081
+ }], ctorParameters: function () { return [{ type: i1.SalesforceApiService }]; } });
2082
+
2083
+ class SectionHelperService {
2084
+ static findSectionForValue(section, valueOption) {
2085
+ if (!EntityUtil.isPresent(section) || !EntityUtil.isPresent(section.children) || EntityUtil.isBlank(valueOption)) {
2086
+ return;
2087
+ }
2088
+ const found = EntityUtil.filterHierarchically(section.children, 'children', ({ model }) => model && model.type.toLowerCase() === valueOption.toLowerCase());
2089
+ return found && found.pop();
2090
+ }
2091
+ getTotalPrices(section) {
2092
+ if (!section || !section.model || !section.model.chargeGroupItems) {
2093
+ return new Map();
2094
+ }
2095
+ return PricingUtils.sumPriceByProperty(section.model.chargeGroupItems, 'netPrice', [
2096
+ 'chargeMethod',
2097
+ 'sellingFrequency',
2098
+ ]);
2099
+ }
2100
+ }
2101
+ SectionHelperService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionHelperService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2102
+ SectionHelperService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionHelperService });
2103
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionHelperService, decorators: [{
2104
+ type: Injectable
2105
+ }] });
2106
+
2107
+ class SectionContextAware {
2108
+ constructor(formScope, sectionScope) {
2109
+ this.formScope = formScope;
2110
+ this.sectionScope = sectionScope;
2111
+ }
2112
+ ngOnInit() {
2113
+ this.form = this.formScope.form;
2114
+ this.section = this.sectionScope.section;
2115
+ this.initControlNames();
2116
+ }
2117
+ initControlNames() {
2118
+ this.controlName = this.section.id;
2119
+ this.qtyControlName = this.section.id + 'qty';
2120
+ }
2121
+ //TODO ALE CONSIDER STORE INSTEAD OF CALCULATE EVERY TIME
2122
+ isAddAllowed(quantityToAdd = 1) {
2123
+ return this.section.model
2124
+ ? SectionsBinderHelper.isAddAllowed(this.section.model, this.section.boundData.name, quantityToAdd)
2125
+ : false;
2126
+ }
2127
+ isRemoveAllowed(quantityToRemove = 1) {
2128
+ return this.section.model
2129
+ ? SectionsBinderHelper.isRemoveAllowed(this.section.model, this.section.boundData.name, quantityToRemove)
2130
+ : false;
2131
+ }
2132
+ handleCreate(valueOption) {
2133
+ if (!this.isAddAllowed()) {
2134
+ return;
2135
+ }
2136
+ const updateData = {
2137
+ id: this.section.id,
2138
+ action: 'create',
2139
+ valueOption: EntityUtil.isPresent(valueOption) ? valueOption : void 0,
2140
+ };
2141
+ this.formScope.publishFormUpdate(updateData);
2142
+ }
2143
+ handleChange(valueOption) {
2144
+ const updateData = {
2145
+ id: this.section.id,
2146
+ action: 'update',
2147
+ valueOption: EntityUtil.isPresent(valueOption) ? valueOption : void 0,
2148
+ };
2149
+ this.formScope.publishFormUpdate(updateData);
2150
+ }
2151
+ handleQtyChange(valueOption) {
2152
+ const updateData = {
2153
+ id: this.section.id,
2154
+ action: 'qtyUpdate',
2155
+ valueOption: valueOption,
2156
+ };
2157
+ this.formScope.publishFormUpdate(updateData);
2158
+ }
2159
+ handleRemove(valueOption) {
2160
+ const updateData = {
2161
+ id: this.section.id,
2162
+ action: 'remove',
2163
+ valueOption: valueOption,
2164
+ };
2165
+ this.formScope.publishFormUpdate(updateData);
2166
+ }
2167
+ handleCopy(valueOption) {
2168
+ const updateData = {
2169
+ id: this.section.id,
2170
+ action: 'copy',
2171
+ valueOption: valueOption,
2172
+ };
2173
+ this.formScope.publishFormUpdate(updateData);
2174
+ }
2175
+ }
2176
+ SectionContextAware.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionContextAware, deps: [{ token: FormScopeService }, { token: SectionScopeService }], target: i0.ɵɵFactoryTarget.Directive });
2177
+ SectionContextAware.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: SectionContextAware, ngImport: i0 });
2178
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionContextAware, decorators: [{
2179
+ type: Directive
2180
+ }], ctorParameters: function () { return [{ type: FormScopeService }, { type: SectionScopeService }]; } });
2181
+ class LineItemDirective {
2182
+ constructor(formScope, sectionScope, configurationService) {
2183
+ this.formScope = formScope;
2184
+ this.sectionScope = sectionScope;
2185
+ this.configurationService = configurationService;
2186
+ }
2187
+ ngOnInit() {
2188
+ this.section = this.sectionScope.section;
2189
+ this.lineItem = this.section.model;
2190
+ }
2191
+ handlePatch(rootLineItem) {
2192
+ const updateData = {
2193
+ id: this.sectionScope.section.id,
2194
+ action: 'patch',
2195
+ valueOption: rootLineItem,
2196
+ };
2197
+ this.formScope.publishFormUpdate(updateData);
2198
+ }
2199
+ configure(runtimeContext, configurableRamp) {
2200
+ return this.configurationService
2201
+ .configure(runtimeContext, { configurableRamp })
2202
+ .pipe(take(1))
2203
+ .toPromise();
2204
+ }
2205
+ }
2206
+ LineItemDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LineItemDirective, deps: [{ token: FormScopeService }, { token: SectionScopeService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Directive });
2207
+ LineItemDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: LineItemDirective, selector: "line-item", exportAs: ["liApi"], ngImport: i0 });
2208
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LineItemDirective, decorators: [{
2209
+ type: Directive,
2210
+ args: [{
2211
+ // eslint-disable-next-line @angular-eslint/directive-selector
2212
+ selector: 'line-item',
2213
+ exportAs: 'liApi',
2214
+ }]
2215
+ }], ctorParameters: function () { return [{ type: FormScopeService }, { type: SectionScopeService }, { type: ConfigurationService }]; } });
2216
+ class VeloPortDirective extends SectionContextAware {
2217
+ constructor(formScope, sectionScope) {
2218
+ super(formScope, sectionScope);
2219
+ this.valueQuantities = {};
2220
+ }
2221
+ handlePriceAdjustment(action, valueOption, amount) {
2222
+ const updateData = {
2223
+ id: this.section.id,
2224
+ action,
2225
+ valueOption,
2226
+ options: { amount },
2227
+ };
2228
+ this.formScope.publishFormUpdate(updateData);
2229
+ }
2230
+ ngOnInit() {
2231
+ super.ngOnInit();
2232
+ this.initQuantity();
2233
+ }
2234
+ handleUpsert(valueOption, event) {
2235
+ if (EntityUtil.isPresent(this.valueQuantities[valueOption]) && EntityUtil.isPresent(event)) {
2236
+ event === null || event === void 0 ? void 0 : event.preventDefault();
2237
+ return;
2238
+ }
2239
+ else if (Object.keys(this.valueQuantities).length > 0) {
2240
+ this.handleChange(valueOption);
2241
+ }
2242
+ else {
2243
+ this.handleCreate(valueOption);
2244
+ }
2245
+ }
2246
+ isActive(valueOption) {
2247
+ return EntityUtil.isPresent(this.valueQuantities[valueOption]);
2248
+ }
2249
+ initQuantity() {
2250
+ this.valueQuantities = this.section.model
2251
+ ? SectionsBinderHelper.getQuantityGroupByValue(this.section.model, this.section.boundData.name)
2252
+ : {};
2253
+ }
2254
+ //Quantity Stepper Functions
2255
+ handleNextVal(valueOption) {
2256
+ let initQty = this.valueQuantities[valueOption] || 0;
2257
+ if (this.isAddAllowed()) {
2258
+ if (initQty > 0) {
2259
+ const typeSection = SectionHelperService.findSectionForValue(this.section, valueOption);
2260
+ if (typeSection) {
2261
+ this.form.controls[typeSection.id + 'qty'].setValue(++initQty);
2262
+ this.handleQtyChange(valueOption);
2263
+ }
2264
+ }
2265
+ else {
2266
+ this.handleCreate(valueOption);
2267
+ }
2268
+ }
2269
+ }
2270
+ handlePrevVal(valueOption) {
2271
+ let initQty = this.valueQuantities[valueOption] || 0;
2272
+ if (this.isRemoveAllowed()) {
2273
+ if (initQty < 2) {
2274
+ this.handleRemove(valueOption);
2275
+ }
2276
+ else {
2277
+ const typeSection = SectionHelperService.findSectionForValue(this.section, valueOption);
2278
+ if (typeSection) {
2279
+ this.form.controls[typeSection.id + 'qty'].setValue(--initQty);
2280
+ this.handleQtyChange(valueOption);
2281
+ }
2282
+ }
2283
+ }
2284
+ }
2285
+ handleManualQtyChange(valueOption, qtyVal) {
2286
+ const initQty = this.valueQuantities[valueOption] || 0;
2287
+ if (isNaN(+qtyVal) || +qtyVal < 0 || initQty === +qtyVal) {
2288
+ return;
2289
+ }
2290
+ const newQty = +qtyVal;
2291
+ if (initQty === 0) {
2292
+ if (this.isAddAllowed(newQty)) {
2293
+ this.form.controls[this.qtyControlName].setValue(newQty);
2294
+ this.handleCreate(valueOption);
2295
+ }
2296
+ }
2297
+ else if (newQty === 0) {
2298
+ if (this.isRemoveAllowed()) {
2299
+ this.handleRemove(valueOption);
2300
+ }
2301
+ }
2302
+ else {
2303
+ const typeSection = SectionHelperService.findSectionForValue(this.section, valueOption);
2304
+ if (typeSection) {
2305
+ const dif = newQty - initQty;
2306
+ const isAllowed = dif > 0 ? this.isAddAllowed(dif) : this.isRemoveAllowed(dif * -1);
2307
+ if (isAllowed) {
2308
+ this.form.controls[typeSection.id + 'qty'].setValue(newQty);
2309
+ this.handleQtyChange(valueOption);
2310
+ }
2311
+ }
2312
+ }
2313
+ }
2314
+ handleNetPriceAdjustment(valueOption, amount) {
2315
+ this.handlePriceAdjustment('adjustNetPrice', valueOption, amount);
2316
+ }
2317
+ handleListPriceAdjustment(valueOption, amount) {
2318
+ this.handlePriceAdjustment('adjustListPrice', valueOption, amount);
2319
+ }
2320
+ }
2321
+ VeloPortDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloPortDirective, deps: [{ token: FormScopeService }, { token: SectionScopeService }], target: i0.ɵɵFactoryTarget.Directive });
2322
+ VeloPortDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: VeloPortDirective, selector: "velo-port", exportAs: ["portApi"], usesInheritance: true, ngImport: i0 });
2323
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloPortDirective, decorators: [{
2324
+ type: Directive,
2325
+ args: [{
2326
+ // eslint-disable-next-line @angular-eslint/directive-selector
2327
+ selector: 'velo-port',
2328
+ exportAs: 'portApi',
2329
+ }]
2330
+ }], ctorParameters: function () { return [{ type: FormScopeService }, { type: SectionScopeService }]; } });
2331
+ class VeloDropdownComponent extends SectionContextAware {
2332
+ constructor(formScope, sectionScope) {
2333
+ super(formScope, sectionScope);
2334
+ }
2335
+ }
2336
+ VeloDropdownComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloDropdownComponent, deps: [{ token: FormScopeService }, { token: SectionScopeService }], target: i0.ɵɵFactoryTarget.Component });
2337
+ VeloDropdownComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: VeloDropdownComponent, selector: "velo-dropdown", usesInheritance: true, ngImport: i0, template: `
2338
+ <div class="input-form-input div-inline" [formGroup]="form">
2339
+ <label [for]="controlName">{{ section.label }}</label>
2340
+ <div class="form-control-wrapper">
2341
+ <select [id]="controlName" [formControlName]="controlName" class="form-control">
2342
+ <option *ngFor="let valueOption of section.sectionValue?.valueOptions" [ngValue]="valueOption">
2343
+ {{ section.sectionValue?.displayValues?.[valueOption] || valueOption }}
2344
+ </option>
2345
+ </select>
2346
+ </div>
2347
+ </div>
2348
+ `, isInline: true, directives: [{ type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }] });
2349
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloDropdownComponent, decorators: [{
2350
+ type: Component,
2351
+ args: [{
2352
+ moduleId: module.id,
2353
+ // eslint-disable-next-line @angular-eslint/component-selector
2354
+ selector: 'velo-dropdown',
2355
+ template: `
2356
+ <div class="input-form-input div-inline" [formGroup]="form">
2357
+ <label [for]="controlName">{{ section.label }}</label>
2358
+ <div class="form-control-wrapper">
2359
+ <select [id]="controlName" [formControlName]="controlName" class="form-control">
2360
+ <option *ngFor="let valueOption of section.sectionValue?.valueOptions" [ngValue]="valueOption">
2361
+ {{ section.sectionValue?.displayValues?.[valueOption] || valueOption }}
2362
+ </option>
2363
+ </select>
2364
+ </div>
2365
+ </div>
2366
+ `,
2367
+ }]
2368
+ }], ctorParameters: function () { return [{ type: FormScopeService }, { type: SectionScopeService }]; } });
2369
+ class VeloQuantityComponent extends SectionContextAware {
2370
+ constructor(formScope, sectionScope) {
2371
+ super(formScope, sectionScope);
2372
+ }
2373
+ }
2374
+ VeloQuantityComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloQuantityComponent, deps: [{ token: FormScopeService }, { token: SectionScopeService }], target: i0.ɵɵFactoryTarget.Component });
2375
+ VeloQuantityComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: VeloQuantityComponent, selector: "velo-quantity", usesInheritance: true, ngImport: i0, template: `
2376
+ <div class="input-form-input div-inline quantity-form-input" [formGroup]="form">
2377
+ <label [for]="qtyControlName"> Quantity </label>
2378
+ <div class="form-control-wrapper">
2379
+ <input
2380
+ [id]="controlName"
2381
+ [formControlName]="qtyControlName"
2382
+ [attr.disabled]="isAddAllowed() === true ? null : true"
2383
+ type="text"
2384
+ class="form-control"
2385
+ size="3"
2386
+ />
2387
+
2388
+ <div
2389
+ class="validation-message"
2390
+ [hidden]="form.controls[qtyControlName].valid || form.controls[qtyControlName].pristine"
2391
+ >
2392
+ <div *ngFor="let key of form.controls[qtyControlName].errors | values">
2393
+ <span> {{ form.controls[qtyControlName].errors?.[key].message }}</span>
2394
+ </div>
2395
+ </div>
2396
+ </div>
2397
+ </div>
2398
+ `, isInline: true, directives: [{ type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "values": i7.ValuesPipe } });
2399
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloQuantityComponent, decorators: [{
2400
+ type: Component,
2401
+ args: [{
2402
+ moduleId: module.id,
2403
+ // eslint-disable-next-line @angular-eslint/component-selector
2404
+ selector: 'velo-quantity',
2405
+ template: `
2406
+ <div class="input-form-input div-inline quantity-form-input" [formGroup]="form">
2407
+ <label [for]="qtyControlName"> Quantity </label>
2408
+ <div class="form-control-wrapper">
2409
+ <input
2410
+ [id]="controlName"
2411
+ [formControlName]="qtyControlName"
2412
+ [attr.disabled]="isAddAllowed() === true ? null : true"
2413
+ type="text"
2414
+ class="form-control"
2415
+ size="3"
2416
+ />
2417
+
2418
+ <div
2419
+ class="validation-message"
2420
+ [hidden]="form.controls[qtyControlName].valid || form.controls[qtyControlName].pristine"
2421
+ >
2422
+ <div *ngFor="let key of form.controls[qtyControlName].errors | values">
2423
+ <span> {{ form.controls[qtyControlName].errors?.[key].message }}</span>
2424
+ </div>
2425
+ </div>
2426
+ </div>
2427
+ </div>
2428
+ `,
2429
+ }]
2430
+ }], ctorParameters: function () { return [{ type: FormScopeService }, { type: SectionScopeService }]; } });
2431
+ class VeloQuantityButtonComponent extends SectionContextAware {
2432
+ constructor(formScope, sectionScope) {
2433
+ super(formScope, sectionScope);
2434
+ }
2435
+ }
2436
+ VeloQuantityButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloQuantityButtonComponent, deps: [{ token: FormScopeService }, { token: SectionScopeService }], target: i0.ɵɵFactoryTarget.Component });
2437
+ VeloQuantityButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: VeloQuantityButtonComponent, selector: "velo-quantity-button", usesInheritance: true, ngImport: i0, template: `
2438
+ <div class="input-form-input div-inline quantity-form-input">
2439
+ <div class="form-control-wrapper">
2440
+ <a href="javascript:void(0);" (click)="handleCreate()">
2441
+ <div class="add-config-control" [attr.disabled]="isAddAllowed() === true ? null : true">
2442
+ <i class="fa fa-plus plus-icon"></i>
2443
+ </div>
2444
+ </a>
2445
+ </div>
2446
+ </div>
2447
+ `, isInline: true });
2448
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VeloQuantityButtonComponent, decorators: [{
2449
+ type: Component,
2450
+ args: [{
2451
+ moduleId: module.id,
2452
+ // eslint-disable-next-line @angular-eslint/component-selector
2453
+ selector: 'velo-quantity-button',
2454
+ template: `
2455
+ <div class="input-form-input div-inline quantity-form-input">
2456
+ <div class="form-control-wrapper">
2457
+ <a href="javascript:void(0);" (click)="handleCreate()">
2458
+ <div class="add-config-control" [attr.disabled]="isAddAllowed() === true ? null : true">
2459
+ <i class="fa fa-plus plus-icon"></i>
2460
+ </div>
2461
+ </a>
2462
+ </div>
2463
+ </div>
2464
+ `,
2465
+ }]
2466
+ }], ctorParameters: function () { return [{ type: FormScopeService }, { type: SectionScopeService }]; } });
2467
+
2468
+ class VlApprovalDirective {
2469
+ constructor(repo) {
2470
+ this.repo = repo;
2471
+ }
2472
+ submitQuote(quoteDraft) {
2473
+ return this.repo.submitQuote(quoteDraft).toPromise();
2474
+ }
2475
+ }
2476
+ VlApprovalDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VlApprovalDirective, deps: [{ token: i1.QuoteApiService }], target: i0.ɵɵFactoryTarget.Directive });
2477
+ VlApprovalDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: VlApprovalDirective, selector: "vl-approval", exportAs: ["approvalApi"], ngImport: i0 });
2478
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VlApprovalDirective, decorators: [{
2479
+ type: Directive,
2480
+ args: [{
2481
+ // eslint-disable-next-line @angular-eslint/directive-selector
2482
+ selector: 'vl-approval',
2483
+ exportAs: 'approvalApi',
2484
+ }]
2485
+ }], ctorParameters: function () { return [{ type: i1.QuoteApiService }]; } });
2486
+
2487
+ class VlDocumentAttachmentsDirective {
2488
+ constructor(service) {
2489
+ this.service = service;
2490
+ }
2491
+ getAttachments(searchRequest) {
2492
+ return this.service.getAttachments(searchRequest).toPromise();
2493
+ }
2494
+ createAttachment(attachment, file, reportProgress) {
2495
+ const observable = this.service.createAttachment(attachment, file, reportProgress);
2496
+ return reportProgress ? observable : observable.toPromise();
2497
+ }
2498
+ updateAttachment(id, attachment) {
2499
+ return this.service.updateAttachment(id, attachment).toPromise();
2500
+ }
2501
+ getAttachmentFile(id, isPreventDownload) {
2502
+ return this.service.getAttachmentFile(id, isPreventDownload).toPromise();
2503
+ }
2504
+ removeAttachment(id) {
2505
+ return this.service.removeAttachment(id).toPromise();
2506
+ }
2507
+ }
2508
+ VlDocumentAttachmentsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VlDocumentAttachmentsDirective, deps: [{ token: i1.DocumentAttachmentApiService }], target: i0.ɵɵFactoryTarget.Directive });
2509
+ VlDocumentAttachmentsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: VlDocumentAttachmentsDirective, selector: "vl-document-attachments", exportAs: ["documentAttachmentsApi"], ngImport: i0 });
2510
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VlDocumentAttachmentsDirective, decorators: [{
2511
+ type: Directive,
2512
+ args: [{
2513
+ // eslint-disable-next-line @angular-eslint/directive-selector
2514
+ selector: 'vl-document-attachments',
2515
+ exportAs: 'documentAttachmentsApi',
2516
+ }]
2517
+ }], ctorParameters: function () { return [{ type: i1.DocumentAttachmentApiService }]; } });
2518
+
2519
+ class VlDocumentTemplatesDirective {
2520
+ constructor(documentTemplatesApiService) {
2521
+ this.documentTemplatesApiService = documentTemplatesApiService;
2522
+ /**
2523
+ * @deprecated Use `generateDocument` instead
2524
+ */
2525
+ // eslint-disable-next-line @typescript-eslint/member-ordering
2526
+ this.generateDocumentNew = this.generateDocument;
2527
+ }
2528
+ getTemplates(tag) {
2529
+ return this.documentTemplatesApiService.getTemplates(tag).toPromise();
2530
+ }
2531
+ upsertTemplate(template, templateFile) {
2532
+ return this.documentTemplatesApiService
2533
+ .upsertTemplate(template, templateFile)
2534
+ .toPromise();
2535
+ }
2536
+ removeTemplate(id) {
2537
+ return this.documentTemplatesApiService.removeTemplate(id).toPromise();
2538
+ }
2539
+ cloneTemplate(id) {
2540
+ return this.documentTemplatesApiService.cloneTemplate(id).toPromise();
2541
+ }
2542
+ downloadTemplate(id) {
2543
+ return this.documentTemplatesApiService.downloadTemplateFile(id).toPromise();
2544
+ }
2545
+ generateDocument(template, quoteDraft, params) {
2546
+ return this.documentTemplatesApiService.generateDocument(template, quoteDraft, params).pipe(take(1));
2547
+ }
2548
+ generateDocumentData(template, quoteDraft, params) {
2549
+ return this.documentTemplatesApiService.generateDocumentData(template, quoteDraft, params).pipe(take(1));
2550
+ }
2551
+ getAttachments(searchRequest) {
2552
+ return this.documentTemplatesApiService.getAttachments(searchRequest).toPromise();
2553
+ }
2554
+ getAttachmentFile(id) {
2555
+ return this.documentTemplatesApiService.getAttachmentFile(id).toPromise();
2556
+ }
2557
+ createAttachment(attachment, file) {
2558
+ return this.documentTemplatesApiService.createAttachment(attachment, file).toPromise();
2559
+ }
2560
+ removeAttachment(id) {
2561
+ return this.documentTemplatesApiService.removeAttachment(id).toPromise();
2562
+ }
2563
+ }
2564
+ VlDocumentTemplatesDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VlDocumentTemplatesDirective, deps: [{ token: i1.DocumentTemplatesApiService }], target: i0.ɵɵFactoryTarget.Directive });
2565
+ VlDocumentTemplatesDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: VlDocumentTemplatesDirective, selector: "[vlQuoteTemplates]", exportAs: ["quoteTemplateApi"], ngImport: i0 });
2566
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VlDocumentTemplatesDirective, decorators: [{
2567
+ type: Directive,
2568
+ args: [{
2569
+ selector: '[vlQuoteTemplates]',
2570
+ exportAs: 'quoteTemplateApi',
2571
+ }]
2572
+ }], ctorParameters: function () { return [{ type: i1.DocumentTemplatesApiService }]; } });
2573
+
2574
+ class VlQuoteDirective {
2575
+ constructor(quoteApiService, runtimeService) {
2576
+ this.quoteApiService = quoteApiService;
2577
+ this.runtimeService = runtimeService;
2578
+ }
2579
+ getQuote(quoteId) {
2580
+ return this.quoteApiService.getQuoteDraft(quoteId).toPromise();
2581
+ }
2582
+ upsertQuote(quoteDraft) {
2583
+ return this.quoteApiService.upsertQuote(quoteDraft).toPromise();
2584
+ }
2585
+ configureQuote(quoteDraft, rootLineItemId) {
2586
+ var _a;
2587
+ const rootLineItem = EntityUtil.findById(rootLineItemId, quoteDraft.currentState);
2588
+ const asset = (_a = quoteDraft.initialState) === null || _a === void 0 ? void 0 : _a.find(a => a.id === rootLineItem.assetId);
2589
+ const { context } = quoteDraft;
2590
+ const states = {
2591
+ configurableRamp: LineItemUtil.removeDeletedItems(rootLineItem),
2592
+ currentState: quoteDraft.currentState,
2593
+ asset,
2594
+ };
2595
+ this.runtimeService.updateRuntime(states, context.properties);
2596
+ }
2597
+ }
2598
+ VlQuoteDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VlQuoteDirective, deps: [{ token: i1.QuoteApiService }, { token: RuntimeService }], target: i0.ɵɵFactoryTarget.Directive });
2599
+ VlQuoteDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: VlQuoteDirective, selector: "vl-quote", exportAs: ["quoteApi"], ngImport: i0 });
2600
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VlQuoteDirective, decorators: [{
2601
+ type: Directive,
2602
+ args: [{
2603
+ // eslint-disable-next-line @angular-eslint/directive-selector
2604
+ selector: 'vl-quote',
2605
+ exportAs: 'quoteApi',
2606
+ }]
2607
+ }], ctorParameters: function () { return [{ type: i1.QuoteApiService }, { type: RuntimeService }]; } });
2608
+
2609
+ class VlRampDirective {
2610
+ constructor(contextService, rampApiService, priceApiService) {
2611
+ this.contextService = contextService;
2612
+ this.rampApiService = rampApiService;
2613
+ this.priceApiService = priceApiService;
2614
+ }
2615
+ createRamp(sourceItems, currentRamps, term) {
2616
+ const context = this.contextService.resolve();
2617
+ return this.rampApiService
2618
+ .next({
2619
+ context,
2620
+ sourceItems,
2621
+ currentItems: currentRamps || [],
2622
+ term,
2623
+ })
2624
+ .pipe(tap(data => {
2625
+ if (data.context) {
2626
+ this.contextService.update({
2627
+ properties: Object.assign({}, data.context.properties),
2628
+ });
2629
+ }
2630
+ }))
2631
+ .toPromise();
2632
+ }
2633
+ calculateRampTermByEndDate(lineItem, endDate) {
2634
+ return this.priceApiService
2635
+ .getSellingTermByEndDate(lineItem.planId, lineItem.offeringId, lineItem.startDate, endDate, lineItem.sellingFrequencyUnit, lineItem.sellingFrequencyDuration)
2636
+ .toPromise();
2637
+ }
2638
+ calculateRampTermByTerm(lineItem, term) {
2639
+ return this.priceApiService
2640
+ .getSellingTermByTerm(lineItem.planId, lineItem.offeringId, lineItem.startDate, term, lineItem.sellingFrequencyUnit, lineItem.sellingFrequencyDuration)
2641
+ .toPromise();
2642
+ }
2643
+ }
2644
+ VlRampDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VlRampDirective, deps: [{ token: i2.ContextService }, { token: i1.RampApiService }, { token: i1.PriceApiService }], target: i0.ɵɵFactoryTarget.Directive });
2645
+ VlRampDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: VlRampDirective, selector: "vl-ramp", exportAs: ["rampApi"], ngImport: i0 });
2646
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: VlRampDirective, decorators: [{
2647
+ type: Directive,
2648
+ args: [{
2649
+ // eslint-disable-next-line @angular-eslint/directive-selector
2650
+ selector: 'vl-ramp',
2651
+ exportAs: 'rampApi',
2652
+ }]
2653
+ }], ctorParameters: function () { return [{ type: i2.ContextService }, { type: i1.RampApiService }, { type: i1.PriceApiService }]; } });
2654
+
2655
+ const SHA1$1 = UUID.SHA1();
2656
+ const SCRIPT_GLOBAL_NAME = `$velo`;
2657
+ class SectionScriptDirective {
2658
+ constructor(_document, sfQueryDirective, lineItemDirective, quoteDirective, documentTemplatesDirective, rampDirective, approvalDirective, documentAttachmentsDirective, formScope, sectionScope, renderer, formBuilder, runtimeService, cdr, cartService, contextService, currentStateService, quoteService) {
2659
+ this._document = _document;
2660
+ this.sfQueryDirective = sfQueryDirective;
2661
+ this.lineItemDirective = lineItemDirective;
2662
+ this.quoteDirective = quoteDirective;
2663
+ this.documentTemplatesDirective = documentTemplatesDirective;
2664
+ this.rampDirective = rampDirective;
2665
+ this.approvalDirective = approvalDirective;
2666
+ this.documentAttachmentsDirective = documentAttachmentsDirective;
2667
+ this.formScope = formScope;
2668
+ this.sectionScope = sectionScope;
2669
+ this.renderer = renderer;
2670
+ this.formBuilder = formBuilder;
2671
+ this.runtimeService = runtimeService;
2672
+ this.cdr = cdr;
2673
+ this.cartService = cartService;
2674
+ this.contextService = contextService;
2675
+ this.currentStateService = currentStateService;
2676
+ this.quoteService = quoteService;
2677
+ this.scriptId = '';
2678
+ this.sessionScope = {};
2679
+ }
2680
+ ngOnInit() {
2681
+ if (!this.scriptExists()) {
2682
+ return;
2683
+ }
2684
+ this.scriptId = this.generateScriptId();
2685
+ this.registry = this.getScriptRegistry();
2686
+ this.sessionScope = this.getSessionScope();
2687
+ if (!this.registry.exists(this.scriptId)) {
2688
+ this.appendScriptElementToDom();
2689
+ }
2690
+ this.initScript();
2691
+ this.registry.doRegister(this.scriptId, this.sectionScope.section.id);
2692
+ }
2693
+ ngAfterViewInit() {
2694
+ var _a;
2695
+ const sharedScriptGlobal = (_a = this.registry) === null || _a === void 0 ? void 0 : _a.getGlobalForScript(this.sectionScope.section.id);
2696
+ if (sharedScriptGlobal) {
2697
+ this.methodApply('afterViewInit', sharedScriptGlobal);
2698
+ }
2699
+ }
2700
+ ngOnDestroy() {
2701
+ if (!this.scriptId) {
2702
+ return;
2703
+ }
2704
+ this.registry.unRegister(this.scriptId, this.sectionScope.section.id);
2705
+ if (!this.registry.exists(this.scriptId)) {
2706
+ this.removeScript();
2707
+ this.registry.removeGlobalForScript(this.scriptId);
2708
+ }
2709
+ }
2710
+ get scope() {
2711
+ if (!this.scriptId || !this.sectionScope.section) {
2712
+ return {};
2713
+ }
2714
+ return Object.assign({}, this.registry.getGlobalForScript(this.sectionScope.section.id) || {}, this.sessionScope);
2715
+ }
2716
+ scriptExists() {
2717
+ var _a, _b, _c, _d;
2718
+ return ((_d = (_c = (_b = (_a = this.sectionScope) === null || _a === void 0 ? void 0 : _a.section) === null || _b === void 0 ? void 0 : _b.script) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0;
2719
+ }
2720
+ encodeScriptBody() {
2721
+ return this.sectionScope.section.script ? atob(this.sectionScope.section.script) : '';
2722
+ }
2723
+ generateScriptId() {
2724
+ return '_' + SHA1$1.hex(this.encodeScriptBody());
2725
+ }
2726
+ getScriptRegistry() {
2727
+ return this.formScope.scriptRegistry;
2728
+ }
2729
+ getSessionScope() {
2730
+ return this.formScope.scriptSessionScope;
2731
+ }
2732
+ initScript() {
2733
+ let sharedScriptGlobal = this.registry.getGlobalForScript(this.sectionScope.section.id);
2734
+ if (!EntityUtil.isPresent(sharedScriptGlobal)) {
2735
+ sharedScriptGlobal = {};
2736
+ this.registry.setGlobalForScript(this.sectionScope.section.id, sharedScriptGlobal);
2737
+ }
2738
+ this.methodApply('init', sharedScriptGlobal);
2739
+ }
2740
+ removeScript() {
2741
+ const sharedScriptGlobal = this.registry.getGlobalForScript(this.sectionScope.section.id);
2742
+ this.methodApply('destroy', sharedScriptGlobal);
2743
+ this.removeScriptElementFromDom();
2744
+ }
2745
+ appendScriptElementToDom() {
2746
+ const script = this.scriptFromTemplate(this.encodeScriptBody(), this.scriptId, this.sectionScope.section);
2747
+ this.scriptElement = this.renderer.createElement('script');
2748
+ this.scriptElement.type = `text/javascript`;
2749
+ this.scriptElement.text = script;
2750
+ this.scriptElement.setAttribute('id', this.scriptId);
2751
+ this.renderer.appendChild(this._document.body, this.scriptElement);
2752
+ }
2753
+ removeScriptElementFromDom() {
2754
+ if (!this.scriptElement) {
2755
+ this.scriptElement = this._document.getElementById(this.scriptId);
2756
+ }
2757
+ this.scriptElement.remove();
2758
+ }
2759
+ scriptFromTemplate(scriptBody, scriptId, section) {
2760
+ return `var ${scriptId} = (function (${SCRIPT_GLOBAL_NAME}, form, { section, templates }, sessionScope, formBuilder, runtimeContext, cdr, apis) {
2761
+ ${SCRIPT_GLOBAL_NAME}["form"] = form;
2762
+ ${SCRIPT_GLOBAL_NAME}["section"] = section;
2763
+ ${SCRIPT_GLOBAL_NAME}["templates"] = templates;
2764
+ ${SCRIPT_GLOBAL_NAME}["sessionScope"] = sessionScope;
2765
+ ${SCRIPT_GLOBAL_NAME}["formBuilder"] = formBuilder;
2766
+ ${SCRIPT_GLOBAL_NAME}["runtimeContext"] = runtimeContext;
2767
+ ${SCRIPT_GLOBAL_NAME}["cdr"] = cdr;
2768
+ ${SCRIPT_GLOBAL_NAME}["apis"] = apis;
2769
+
2770
+ ${scriptBody}
2771
+ return ${SCRIPT_GLOBAL_NAME};
2772
+ });
2773
+
2774
+ //# sourceURL=${_.kebabCase(section.label)}.js`;
2775
+ }
2776
+ methodApply(methodName, sharedScriptGlobal) {
2777
+ const args = [
2778
+ sharedScriptGlobal,
2779
+ this.formScope.form,
2780
+ this.sectionScope,
2781
+ this.sessionScope,
2782
+ this.formBuilder,
2783
+ this.runtimeService.getRuntimeContext(),
2784
+ this.cdr,
2785
+ this.getExposedApis(),
2786
+ ];
2787
+ const fnInit = window[`${this.scriptId}`](...args);
2788
+ fnInit && fnInit[methodName] && fnInit[methodName].apply();
2789
+ }
2790
+ getExposedApis() {
2791
+ return {
2792
+ 'sf-query': this.sfQueryDirective,
2793
+ 'line-item': this.lineItemDirective,
2794
+ 'quote-directive': this.quoteDirective,
2795
+ 'templates-directive': this.documentTemplatesDirective,
2796
+ 'attachments-directive': this.documentAttachmentsDirective,
2797
+ 'ramp-directive': this.rampDirective,
2798
+ 'approval-directive': this.approvalDirective,
2799
+ entityUtil: EntityUtil,
2800
+ moment,
2801
+ lodash: _,
2802
+ rxjs: Object.assign(Object.assign({}, rxjsOperators), rxjs),
2803
+ PagedEntity,
2804
+ pipes: {
2805
+ currency: CurrencyPipe,
2806
+ },
2807
+ solutionUpdateStarted: this.runtimeService.onSolutionUpdateStartedEvent,
2808
+ solutionUpdated: this.runtimeService.onSolutionProcessed,
2809
+ cartService: this.cartService,
2810
+ configurationContextService: this.contextService,
2811
+ quoteDraft: this.quoteService.quoteDraft,
2812
+ currentStateService: this.currentStateService,
2813
+ };
2814
+ }
2815
+ }
2816
+ SectionScriptDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionScriptDirective, deps: [{ token: DOCUMENT }, { token: SfQueryDirective }, { token: LineItemDirective }, { token: VlQuoteDirective }, { token: VlDocumentTemplatesDirective }, { token: VlRampDirective }, { token: VlApprovalDirective }, { token: VlDocumentAttachmentsDirective }, { token: FormScopeService }, { token: SectionScopeService }, { token: i0.Renderer2 }, { token: i4.FormBuilder }, { token: RuntimeService }, { token: i0.ChangeDetectorRef }, { token: ShoppingCartService }, { token: i2.ContextService }, { token: CurrentStateService }, { token: i2.QuoteDraftService }], target: i0.ɵɵFactoryTarget.Directive });
2817
+ SectionScriptDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.15", type: SectionScriptDirective, selector: "section-script", providers: [
2818
+ SfQueryDirective,
2819
+ LineItemDirective,
2820
+ VlQuoteDirective,
2821
+ VlDocumentTemplatesDirective,
2822
+ VlRampDirective,
2823
+ VlApprovalDirective,
2824
+ VlDocumentAttachmentsDirective,
2825
+ ], exportAs: ["scriptApi"], ngImport: i0 });
2826
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionScriptDirective, decorators: [{
2827
+ type: Directive,
2828
+ args: [{
2829
+ // eslint-disable-next-line @angular-eslint/directive-selector
2830
+ selector: 'section-script',
2831
+ exportAs: 'scriptApi',
2832
+ providers: [
2833
+ SfQueryDirective,
2834
+ LineItemDirective,
2835
+ VlQuoteDirective,
2836
+ VlDocumentTemplatesDirective,
2837
+ VlRampDirective,
2838
+ VlApprovalDirective,
2839
+ VlDocumentAttachmentsDirective,
2840
+ ],
2841
+ }]
2842
+ }], ctorParameters: function () { return [{ type: Document, decorators: [{
2843
+ type: Inject,
2844
+ args: [DOCUMENT]
2845
+ }] }, { type: SfQueryDirective, decorators: [{
2846
+ type: Inject,
2847
+ args: [SfQueryDirective]
2848
+ }] }, { type: LineItemDirective, decorators: [{
2849
+ type: Inject,
2850
+ args: [LineItemDirective]
2851
+ }] }, { type: VlQuoteDirective, decorators: [{
2852
+ type: Inject,
2853
+ args: [VlQuoteDirective]
2854
+ }] }, { type: VlDocumentTemplatesDirective, decorators: [{
2855
+ type: Inject,
2856
+ args: [VlDocumentTemplatesDirective]
2857
+ }] }, { type: VlRampDirective, decorators: [{
2858
+ type: Inject,
2859
+ args: [VlRampDirective]
2860
+ }] }, { type: VlApprovalDirective, decorators: [{
2861
+ type: Inject,
2862
+ args: [VlApprovalDirective]
2863
+ }] }, { type: VlDocumentAttachmentsDirective, decorators: [{
2864
+ type: Inject,
2865
+ args: [VlDocumentAttachmentsDirective]
2866
+ }] }, { type: FormScopeService }, { type: SectionScopeService }, { type: i0.Renderer2 }, { type: i4.FormBuilder }, { type: RuntimeService }, { type: i0.ChangeDetectorRef }, { type: ShoppingCartService }, { type: i2.ContextService }, { type: CurrentStateService }, { type: i2.QuoteDraftService }]; } });
2867
+
2868
+ class RuntimeExecutionModule {
2869
+ }
2870
+ RuntimeExecutionModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeExecutionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2871
+ RuntimeExecutionModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeExecutionModule, declarations: [ExecutionSectionRendererComponent,
2872
+ ChildrenPlaceholderComponent,
2873
+ SectionScriptDirective,
2874
+ VeloPortDirective,
2875
+ LineItemDirective,
2876
+ VeloDropdownComponent,
2877
+ VeloQuantityButtonComponent,
2878
+ VeloQuantityComponent,
2879
+ VeloAttributeDirective,
2880
+ MultiselectComponent,
2881
+ VeloAttributeComponent,
2882
+ VeloPortRadioComponent,
2883
+ VeloTypeComponent,
2884
+ VeloPortDropdownComponent,
2885
+ VeloPortCheckBoxComponent,
2886
+ FederatedComponent,
2887
+ TemplateComponent,
2888
+ ContextProviderComponent], imports: [CommonModule,
2889
+ FormsModule,
2890
+ ReactiveFormsModule,
2891
+ CoreModule,
2892
+ ApiModule,
2893
+ VeloceElementsModule,
2894
+ PopoverModule,
2895
+ LoaderModule,
2896
+ SdkCoreModule], exports: [FormsModule,
2897
+ ReactiveFormsModule,
2898
+ ChildrenPlaceholderComponent,
2899
+ SectionScriptDirective,
2900
+ LineItemDirective,
2901
+ VeloPortDirective,
2902
+ VeloAttributeDirective,
2903
+ MultiselectComponent,
2904
+ VeloAttributeComponent,
2905
+ VeloPortRadioComponent,
2906
+ VeloTypeComponent,
2907
+ VeloPortDropdownComponent,
2908
+ VeloPortCheckBoxComponent,
2909
+ FederatedComponent,
2910
+ TemplateComponent,
2911
+ ContextProviderComponent] });
2912
+ RuntimeExecutionModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeExecutionModule, providers: [
2913
+ ShoppingCartService,
2914
+ RuntimeService,
2915
+ ConfigurationService,
2916
+ RuntimeContextService,
2917
+ RuntimeFormService,
2918
+ CurrentStateService,
2919
+ ProductModelCacheService,
2920
+ DatePipe,
2921
+ SectionStoreService,
2922
+ ], imports: [[
2923
+ CommonModule,
2924
+ FormsModule,
2925
+ ReactiveFormsModule,
2926
+ CoreModule,
2927
+ ApiModule,
2928
+ VeloceElementsModule,
2929
+ PopoverModule,
2930
+ LoaderModule,
2931
+ SdkCoreModule,
2932
+ ], FormsModule,
2933
+ ReactiveFormsModule] });
2934
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeExecutionModule, decorators: [{
2935
+ type: NgModule,
2936
+ args: [{
2937
+ declarations: [
2938
+ ExecutionSectionRendererComponent,
2939
+ ChildrenPlaceholderComponent,
2940
+ SectionScriptDirective,
2941
+ VeloPortDirective,
2942
+ LineItemDirective,
2943
+ VeloDropdownComponent,
2944
+ VeloQuantityButtonComponent,
2945
+ VeloQuantityComponent,
2946
+ VeloAttributeDirective,
2947
+ MultiselectComponent,
2948
+ VeloAttributeComponent,
2949
+ VeloPortRadioComponent,
2950
+ VeloTypeComponent,
2951
+ VeloPortDropdownComponent,
2952
+ VeloPortCheckBoxComponent,
2953
+ FederatedComponent,
2954
+ TemplateComponent,
2955
+ ContextProviderComponent,
2956
+ ],
2957
+ providers: [
2958
+ ShoppingCartService,
2959
+ RuntimeService,
2960
+ ConfigurationService,
2961
+ RuntimeContextService,
2962
+ RuntimeFormService,
2963
+ CurrentStateService,
2964
+ ProductModelCacheService,
2965
+ DatePipe,
2966
+ SectionStoreService,
2967
+ ],
2968
+ imports: [
2969
+ CommonModule,
2970
+ FormsModule,
2971
+ ReactiveFormsModule,
2972
+ CoreModule,
2973
+ ApiModule,
2974
+ VeloceElementsModule,
2975
+ PopoverModule,
2976
+ LoaderModule,
2977
+ SdkCoreModule,
2978
+ ],
2979
+ exports: [
2980
+ FormsModule,
2981
+ ReactiveFormsModule,
2982
+ ChildrenPlaceholderComponent,
2983
+ SectionScriptDirective,
2984
+ LineItemDirective,
2985
+ VeloPortDirective,
2986
+ VeloAttributeDirective,
2987
+ MultiselectComponent,
2988
+ VeloAttributeComponent,
2989
+ VeloPortRadioComponent,
2990
+ VeloTypeComponent,
2991
+ VeloPortDropdownComponent,
2992
+ VeloPortCheckBoxComponent,
2993
+ FederatedComponent,
2994
+ TemplateComponent,
2995
+ ContextProviderComponent,
2996
+ ],
2997
+ }]
2998
+ }] });
2999
+
3000
+ const SHA1 = UUID.SHA1();
3001
+ class BaseSectionComponent {
3002
+ }
3003
+ BaseSectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BaseSectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3004
+ BaseSectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: BaseSectionComponent, selector: "ng-component", inputs: { form: "form", section: "section" }, viewQueries: [{ propertyName: "templates", predicate: ["customTemplate"], descendants: true }], ngImport: i0, template: '', isInline: true });
3005
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BaseSectionComponent, decorators: [{
3006
+ type: Component,
3007
+ args: [{ template: '' }]
3008
+ }], propDecorators: { form: [{
3009
+ type: Input
3010
+ }], section: [{
3011
+ type: Input
3012
+ }], templates: [{
3013
+ type: ViewChildren,
3014
+ args: ['customTemplate']
3015
+ }] } });
3016
+ class SectionsService {
3017
+ constructor(compiler, m, sectionStore) {
3018
+ this.compiler = compiler;
3019
+ this.m = m;
3020
+ this.sectionStore = sectionStore;
3021
+ this.moduleType = null;
3022
+ this.moduleInstance = null;
3023
+ }
3024
+ compileModule(sections, isViewEncapsulated) {
3025
+ const uniqueSections = this.getUniqueSections(sections);
3026
+ this.moduleType = this.getModuleType(uniqueSections, isViewEncapsulated);
3027
+ this.moduleInstance = this.compiler.compileModuleAndAllComponentsSync(this.moduleType);
3028
+ this.sectionStore.componentFactories = this.moduleInstance.componentFactories;
3029
+ }
3030
+ destroy() {
3031
+ if (this.moduleInstance) {
3032
+ this.sectionStore.componentFactories = [];
3033
+ this.moduleInstance = null;
3034
+ }
3035
+ if (this.moduleType) {
3036
+ this.compiler.clearCacheFor(this.moduleType);
3037
+ this.moduleType = null;
3038
+ }
3039
+ }
3040
+ getDecoratedComponents(sections, isViewEncapsulated = false) {
3041
+ const result = [];
3042
+ sections.forEach(section => {
3043
+ var _a;
3044
+ const transpiledTemplate = this.getTranspiledTemplate(section);
3045
+ const DynamicComponent = Component({
3046
+ selector: section.dynamicSelector,
3047
+ template: transpiledTemplate,
3048
+ styles: [atob(section.styles || '')],
3049
+ providers: [SectionHelperService],
3050
+ encapsulation: isViewEncapsulated ? ViewEncapsulation.ShadowDom : ViewEncapsulation.Emulated,
3051
+ jit: true,
3052
+ })(class C extends BaseSectionComponent {
3053
+ });
3054
+ this.applySelectorField(DynamicComponent, (_a = section.dynamicSelector) !== null && _a !== void 0 ? _a : '');
3055
+ result.push(DynamicComponent);
3056
+ });
3057
+ return result;
3058
+ }
3059
+ getModuleType(sections, isViewEncapsulated) {
3060
+ const decoratedComponents = this.getDecoratedComponents(sections, isViewEncapsulated);
3061
+ let DynamicModule = class DynamicModule {
3062
+ };
3063
+ DynamicModule = __decorate([
3064
+ NgModule({
3065
+ imports: [
3066
+ CommonModule,
3067
+ RuntimeExecutionModule,
3068
+ CoreModule,
3069
+ VeloceElementsModule,
3070
+ ScrollingModule,
3071
+ ScrollingModule$1,
3072
+ ],
3073
+ declarations: [decoratedComponents],
3074
+ jit: true,
3075
+ })
3076
+ ], DynamicModule);
3077
+ return DynamicModule;
3078
+ }
3079
+ applySelectorField(target, dynamicSelector) {
3080
+ set(target, '$$dynamicSelector', dynamicSelector);
3081
+ }
3082
+ getUniqueSections(sections) {
3083
+ const uniqueSections = {};
3084
+ sections.forEach(section => {
3085
+ section.hash = SHA1.hex(section.template);
3086
+ const existingSection = section.hash ? uniqueSections[section.hash] : undefined;
3087
+ if (existingSection && existingSection.template === section.template) {
3088
+ section.dynamicSelector = existingSection.dynamicSelector;
3089
+ }
3090
+ else if (section.hash) {
3091
+ section.dynamicSelector = `section-${section.id}`;
3092
+ uniqueSections[section.hash] = section;
3093
+ }
3094
+ });
3095
+ return values(uniqueSections);
3096
+ }
3097
+ getTranspiledTemplate(section) {
3098
+ let template = section.template ? atob(section.template) : '';
3099
+ if (!EntityUtil.isEmpty(section.script) && template.indexOf('<section-script') === -1) {
3100
+ template = `<section-script></section-script>`.concat(template);
3101
+ }
3102
+ return template;
3103
+ }
3104
+ }
3105
+ SectionsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionsService, deps: [{ token: i0.Compiler }, { token: i0.NgModuleRef }, { token: SectionStoreService }], target: i0.ɵɵFactoryTarget.Injectable });
3106
+ SectionsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionsService });
3107
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionsService, decorators: [{
3108
+ type: Injectable
3109
+ }], ctorParameters: function () { return [{ type: i0.Compiler }, { type: i0.NgModuleRef }, { type: SectionStoreService }]; } });
3110
+
3111
+ class SectionRendererComponent {
3112
+ constructor(_injector, _m, sectionScope, sectionStore) {
3113
+ this._injector = _injector;
3114
+ this._m = _m;
3115
+ this.sectionScope = sectionScope;
3116
+ this.sectionStore = sectionStore;
3117
+ this.componentRef = null;
3118
+ }
3119
+ set section(value) {
3120
+ this._section = value;
3121
+ this.sectionScope.section = value;
3122
+ }
3123
+ get section() {
3124
+ return this._section;
3125
+ }
3126
+ ngOnInit() {
3127
+ this.renderSection();
3128
+ }
3129
+ ngAfterViewInit() {
3130
+ var _a, _b;
3131
+ if (this.componentRef) {
3132
+ this.sectionScope.templates.next((_b = (_a = this.componentRef.instance['templates']) === null || _a === void 0 ? void 0 : _a.toArray()) !== null && _b !== void 0 ? _b : []);
3133
+ }
3134
+ }
3135
+ ngOnDestroy() {
3136
+ if (this.componentRef) {
3137
+ this.componentRef.destroy();
3138
+ this.componentRef = null;
3139
+ }
3140
+ }
3141
+ renderSection() {
3142
+ var _a;
3143
+ if (this.componentRef) {
3144
+ this.componentRef.destroy();
3145
+ this.componentRef = null;
3146
+ }
3147
+ const componentFactory = this.sectionStore.getComponentFactory(this._section);
3148
+ if (!componentFactory) {
3149
+ return;
3150
+ }
3151
+ this.componentRef = componentFactory.create(this._injector, [], null, this._m);
3152
+ this.componentRef.location.nativeElement.setAttribute('sectionId', `${(_a = this._section.model) === null || _a === void 0 ? void 0 : _a.id}${this._section.label}`);
3153
+ this.componentRef.instance['form'] = this.form;
3154
+ this.componentRef.instance['section'] = this.section;
3155
+ this.container.insert(this.componentRef.hostView);
3156
+ }
3157
+ }
3158
+ SectionRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionRendererComponent, deps: [{ token: i0.Injector }, { token: i0.NgModuleRef }, { token: SectionScopeService }, { token: SectionStoreService }], target: i0.ɵɵFactoryTarget.Component });
3159
+ SectionRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: SectionRendererComponent, selector: "vl-section-renderer", inputs: { section: "section", form: "form" }, providers: [SectionScopeService], viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: "<ng-template #container></ng-template>", styles: [":host{display:contents}\n"] });
3160
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SectionRendererComponent, decorators: [{
3161
+ type: Component,
3162
+ args: [{
3163
+ selector: 'vl-section-renderer',
3164
+ templateUrl: 'section-renderer.component.html',
3165
+ styleUrls: ['section-renderer.component.scss'],
3166
+ providers: [SectionScopeService],
3167
+ }]
3168
+ }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.NgModuleRef }, { type: SectionScopeService }, { type: SectionStoreService }]; }, propDecorators: { section: [{
3169
+ type: Input
3170
+ }], form: [{
3171
+ type: Input
3172
+ }], container: [{
3173
+ type: ViewChild,
3174
+ args: ['container', { read: ViewContainerRef, static: true }]
3175
+ }] } });
3176
+
3177
+ const defaultTemplate = btoa('<template-component></template-component>');
3178
+ class ComponentPreviewComponent {
3179
+ constructor(sectionsService, runtimeFormService, formScope, runtimeService, cdr) {
3180
+ this.sectionsService = sectionsService;
3181
+ this.runtimeFormService = runtimeFormService;
3182
+ this.formScope = formScope;
3183
+ this.runtimeService = runtimeService;
3184
+ this.cdr = cdr;
3185
+ this.form = new FormGroup({});
3186
+ this.showPreview = false;
3187
+ this.isNoPreviewAvailable = false;
3188
+ this.isPreviewFailed = false;
3189
+ }
3190
+ ngOnChanges(changes) {
3191
+ if (changes.data) {
3192
+ this.sectionsService.destroy();
3193
+ this.showPreview = false;
3194
+ this.isNoPreviewAvailable = false;
3195
+ this.isPreviewFailed = false;
3196
+ setTimeout(() => {
3197
+ var _a, _b;
3198
+ try {
3199
+ this.runPreview(this.data);
3200
+ this.cdr.detectChanges();
3201
+ }
3202
+ catch (e) {
3203
+ console.error((_b = (_a = e === null || e === void 0 ? void 0 : e.stack) !== null && _a !== void 0 ? _a : e === null || e === void 0 ? void 0 : e.error) !== null && _b !== void 0 ? _b : 'Error occured');
3204
+ this.showPreview = false;
3205
+ this.isPreviewFailed = true;
3206
+ this.cdr.detectChanges();
3207
+ }
3208
+ });
3209
+ }
3210
+ }
3211
+ runPreview(data) {
3212
+ var _a;
3213
+ const section = data.section && JSON.parse(data.section);
3214
+ if (!section) {
3215
+ this.isNoPreviewAvailable = true;
3216
+ return;
3217
+ }
3218
+ const model = Object.assign(Object.assign({}, ((_a = section === null || section === void 0 ? void 0 : section.model) !== null && _a !== void 0 ? _a : {
3219
+ attributes: [],
3220
+ lineItems: [],
3221
+ })), { id: UUID.UUID() });
3222
+ const componentSection = Object.assign(Object.assign({}, section), { script: data.componentScript ? btoa(data.componentScript) : '', styles: data.componentStyles ? btoa(data.componentStyles) : '', template: data.componentTemplate ? btoa(data.componentTemplate) : '', properties: data.componentProperties ? JSON.stringify(data.componentProperties) : {}, id: UUID.UUID(), model });
3223
+ const storySection = {
3224
+ id: UUID.UUID(),
3225
+ template: data.template ? btoa(data.template) : defaultTemplate,
3226
+ styles: data.styles ? btoa(data.styles) : '',
3227
+ script: data.script ? btoa(data.script) : '',
3228
+ children: [componentSection],
3229
+ model,
3230
+ };
3231
+ const sections = [storySection, componentSection];
3232
+ this.form = this.formScope.form = this.runtimeFormService.initForm(sections, model);
3233
+ this.createRuntimeContext(componentSection);
3234
+ this.sectionsService.compileModule(sections);
3235
+ this.section = storySection;
3236
+ this.showPreview = true;
3237
+ }
3238
+ createRuntimeContext(section) {
3239
+ const runtimeModel = RuntimeModel.create([], {});
3240
+ const rootType = Array.from(runtimeModel.components.values()).find(c => {
3241
+ var _a;
3242
+ return ((_a = section.model) === null || _a === void 0 ? void 0 : _a.type) &&
3243
+ runtimeModel.isEquals(c.typeName, section.model.type) &&
3244
+ EntityUtil.isPresent(c.productId);
3245
+ });
3246
+ const contextProductId = rootType ? rootType.productId : undefined;
3247
+ const context = {
3248
+ modelId: '',
3249
+ runtimeModel,
3250
+ runtimeMode: RuntimeMode.TEST,
3251
+ productId: contextProductId,
3252
+ properties: {},
3253
+ };
3254
+ this.runtimeService.setRuntimeContext(context);
3255
+ }
3256
+ }
3257
+ ComponentPreviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ComponentPreviewComponent, deps: [{ token: SectionsService }, { token: RuntimeFormService }, { token: FormScopeService }, { token: RuntimeService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
3258
+ ComponentPreviewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: ComponentPreviewComponent, selector: "vl-component-preview", inputs: { data: "data" }, providers: [
3259
+ SectionsService,
3260
+ FormScopeService,
3261
+ CollapsibleStateService,
3262
+ RuntimeFormService,
3263
+ FormScopeService,
3264
+ RuntimeService,
3265
+ ], usesOnChanges: true, ngImport: i0, template: "<ng-container *ngIf=\"showPreview\">\n <vl-section-renderer [section]=\"section!\" [form]=\"form\"></vl-section-renderer>\n</ng-container>\n\n<span class=\"info\" *ngIf=\"isNoPreviewAvailable\">No preview available</span>\n<span class=\"info error\" *ngIf=\"isPreviewFailed\">Preview has failed</span>\n", styles: ["@charset \"UTF-8\";body.veloce-apex-index,body.veloce-index,body.sfdcBody{overflow:hidden;margin:0;padding:0}:host ::ng-deep .velo-app .modal.in .modal-dialog.runtime-modal{margin-left:5%;margin-right:5%;padding:0;position:relative;width:auto}:host ::ng-deep .modal-body.runtime-modal.main-container{height:100%;margin:0;padding:0}:host ::ng-deep .modal-body.runtime-modal.main-container .content-wrapper{display:flex;flex-direction:column;height:100%}:host ::ng-deep .modal-body.runtime-modal.main-container .sections-wrapper{display:flex;flex-direction:column;flex-grow:1;padding:0}:host ::ng-deep .modal-body.runtime-modal.main-container .sections-wrapper .modal-body.runtime-modal.container-fluid{height:100%;margin:0;padding:0;overflow:auto}:host ::ng-deep .modal-body.runtime-modal.main-container .sections-wrapper .modal-body.runtime-modal.container-fluid .input-form.form-horizontal,:host ::ng-deep .modal-body.runtime-modal.main-container .sections-wrapper .modal-body.runtime-modal.container-fluid .input-form.form-horizontal .form-horizontal,:host ::ng-deep .modal-body.runtime-modal.main-container .sections-wrapper .modal-body.runtime-modal.container-fluid section-script>:first-child{height:100%}:host ::ng-deep .runtime-modal .modal-content,:host ::ng-deep .gu-mirror .modal-content{background-color:--vl-input-background}:host ::ng-deep .runtime-modal .modal-content .modal-header-menu ul li a,:host ::ng-deep .gu-mirror .modal-content .modal-header-menu ul li a{color:#333333b3;font-weight:600;text-transform:uppercase;letter-spacing:.85px;font-size:10px}:host ::ng-deep .runtime-modal .modal-content .modal-header-menu ul li a.active,:host ::ng-deep .gu-mirror .modal-content .modal-header-menu ul li a.active{color:#333}:host ::ng-deep .runtime-modal .modal-content .modal-header-menu ul li a.disabled,:host ::ng-deep .gu-mirror .modal-content .modal-header-menu ul li a.disabled{color:#33333380}:host ::ng-deep .runtime-modal .modal-content .modal-header-menu ul li a.active:after,:host ::ng-deep .gu-mirror .modal-content .modal-header-menu ul li a.active:after{background-color:#f36;bottom:-1px;content:\"\";height:1px;left:0;position:absolute;width:100%}:host ::ng-deep .runtime-modal .modal-content .modal-header,:host ::ng-deep .gu-mirror .modal-content .modal-header{background:transparent;color:#fff}:host ::ng-deep .runtime-modal .runtime-group-divider,:host ::ng-deep .gu-mirror .runtime-group-divider{border-bottom:1px solid #e5e5e5}:host ::ng-deep .runtime-modal .input-form-input,:host ::ng-deep .gu-mirror .input-form-input{position:relative;padding-left:0;padding-top:0}:host ::ng-deep .runtime-modal .input-form-input--required>label,:host ::ng-deep .gu-mirror .input-form-input--required>label{color:#ff4233;font-weight:bold}:host ::ng-deep .form-control-wrapper{position:relative}:host ::ng-deep .add-config-control:hover{background-color:#e96099;color:#fff;border:1px solid transparent}:host ::ng-deep .remove-config-control:hover{background-color:#828c9e;color:#fff}:host ::ng-deep .add-config-control[disabled],:host ::ng-deep .remove-config-control[disabled]{background-color:transparent;color:#ccc;border:1px dashed #ccc}:host ::ng-deep .add-config-control[disabled]:hover,:host ::ng-deep .remove-config-control[disabled]:hover{cursor:default}:host ::ng-deep .add-config-control{height:36px;width:36px;line-height:36px;font-size:14px;text-align:center;border-radius:50%;float:left;position:absolute;top:0;right:-57px;z-index:500;background-color:#e3337c;color:#fff;border:1px solid #e3337c;transition:all .5s ease 0s}:host ::ng-deep .add-config-control .plus-icon{line-height:36px}:host ::ng-deep .remove-config-control{height:36px;width:36px;line-height:36px;font-size:14px;text-align:center;margin-right:25px;border-radius:50%;float:left;position:absolute;top:33px;right:51px;z-index:500;background-color:transparent;color:#687285;border:1px solid transparent;transition:all .5s ease 0s}:host ::ng-deep .remove-config-control .plus-icon{line-height:36px}:host ::ng-deep .sidebar .new-wrapper{min-height:96px;margin-bottom:25px}:host ::ng-deep .sidebar .new-wrapper .add-container .add-card{left:0;margin-left:15px}:host ::ng-deep .ui-settings{height:100%;display:flex;flex-direction:column}:host ::ng-deep .runtime-modal .form-horizontal form,:host ::ng-deep .gu-mirror form{margin:0}:host ::ng-deep .runtime-modal .form-horizontal .form-group,:host ::ng-deep .gu-mirror .form-group{margin:0;padding:0}:host ::ng-deep .runtime-modal .form-horizontal .control.form-group,:host ::ng-deep .gu-mirror .control.form-group{margin-bottom:25px}:host ::ng-deep .runtime-modal .form-horizontal .form-control-wrapper,:host ::ng-deep .gu-mirror .form-control-wrapper{min-width:172px;margin-bottom:25px}:host ::ng-deep .runtime-modal .form-horizontal .quantity-form-input .form-control-wrapper,:host ::ng-deep .gu-mirror .quantity-form-input .form-control-wrapper{min-width:50px}:host ::ng-deep .runtime-modal .form-horizontal .quantity-form-input .form-control-wrapper .form-control,:host ::ng-deep .gu-mirror .quantity-form-input .form-control-wrapper .form-control{width:50px}:host ::ng-deep .runtime-left-side{height:calc(100% - 97px);background:#fff;padding:48px 56px 0}:host ::ng-deep .ui-controls-group{margin-left:-8px;margin-right:-8px}:host ::ng-deep .ui-controls-group .ui-control-type:hover{border-color:#3384ff}:host ::ng-deep .ui-controls-group .ui-control-type{position:relative;min-width:140px;float:left;border-radius:3px;border:1px solid #c4c4c4;background-color:#fff;width:calc(50% - 16px);padding:12px 13px;margin-bottom:16px;margin-right:8px;margin-left:8px;cursor:pointer}:host ::ng-deep .ui-controls-group .ui-control-type span{padding-left:3px}:host ::ng-deep .sidebar-header{letter-spacing:-.5px;padding-bottom:24px;padding-top:0;line-height:32px;font-size:24px;font-weight:700;color:#333}:host ::ng-deep .sidebar-header small{display:block;color:#333;font-size:11px;font-weight:300;line-height:20px;margin:0}:host ::ng-deep .sidebar-menu-list{color:#333333b3;margin:0;width:100%;list-style:none;font-size:12px}:host ::ng-deep .sidebar-menu-list li.active a,:host ::ng-deep .sidebar-menu-list li.active i{color:#005ee3}:host ::ng-deep .sidebar-menu-list li:hover{cursor:pointer}:host ::ng-deep .sidebar-menu-list li{text-align:right;padding-left:16px}:host ::ng-deep .sidebar-menu-list li a{padding:0 8px;margin-left:-8px;cursor:pointer;white-space:nowrap;color:inherit;font-weight:700;display:inline-block;line-height:32px}:host ::ng-deep .sidebar-menu-list li i{display:none;padding-right:5px}:host ::ng-deep .runtime-builder-content{min-height:100%}:host ::ng-deep .runtime-builder-content .input-form{margin:0;padding:18px 11px 0}:host ::ng-deep .runtime-builder-content .input-form .form-group{border:3px dashed transparent}:host ::ng-deep .runtime-builder-content .input-form .form-group:hover{border:3px dashed #dedede}:host ::ng-deep .runtime-right-side{background:#fff}:host ::ng-deep .sidebar-section .section-title{color:#a1a1a1;background:#fff;position:relative;display:inline-block;padding-right:16px;text-transform:uppercase;font-size:10px;letter-spacing:.2px}:host ::ng-deep .sidebar-section:before{content:\" \";position:absolute;top:50%;left:0;right:0;border-top:1px solid #e6e6e6}:host ::ng-deep .sidebar-section{position:relative;margin-top:16px;margin-bottom:16px}:host ::ng-deep .sidebar-section .section-title{color:#a1a1a1;background-color:var(--vl-input-background);position:relative;display:inline-block;padding-right:16px;padding-left:8px;text-transform:uppercase;font-size:6px;letter-spacing:.2px}:host ::ng-deep .section-wrapper{top:-21px;position:absolute;right:0;left:12px}:host ::ng-deep .container-box.container-box-bordered{border:1px solid rgba(0,0,0,.2);margin-bottom:25px;padding-left:25px}:host ::ng-deep .container-box.container-box-radio{margin-left:0}:host ::ng-deep .container-box.container-box-radio:hover,:host ::ng-deep .container-box.container-box-checkbox:hover{cursor:pointer}:host ::ng-deep .container-box{position:relative;overflow:auto;border:1px solid transparent;background:var(--vl-input-background)}:host ::ng-deep .container-box .container-box{border:1px solid rgba(0,0,0,.2);margin-left:25px;margin-right:25px;margin-bottom:25px}:host ::ng-deep .container-box .container-box:hover{border-color:var(--vl-primary-color)}:host ::ng-deep .container-box .box-title .header .header-label{color:#333;margin:0;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.2px;line-height:75px}:host ::ng-deep .container-box .box-title .header .header-label small{padding-left:21px;color:#757575;font-weight:400;font-size:10px;line-height:75px}:host ::ng-deep .container-box .box-title .header .header-qty-container,:host ::ng-deep .container-box .box-title .header .radio-button,:host ::ng-deep .container-box .box-title .header .checkbox-select{display:table-cell;vertical-align:middle;height:75px;padding-left:21px}:host ::ng-deep .container-box .box-title .header .header-qty-container .form-control,:host ::ng-deep .container-box .box-title .header .radio-button .form-control,:host ::ng-deep .container-box .box-title .header .checkbox-select .form-control{height:auto;color:#333;width:50px;border:1px solid #dddddd}:host ::ng-deep .container-box .box-title .header .header-qty-container .form-control:focus,:host ::ng-deep .container-box .box-title .header .radio-button .form-control:focus,:host ::ng-deep .container-box .box-title .header .checkbox-select .form-control:focus{border:1px solid #c4c4c4}:host ::ng-deep .container-box .box-title .header .header-qty-container .validation-message,:host ::ng-deep .container-box .box-title .header .radio-button .validation-message,:host ::ng-deep .container-box .box-title .header .checkbox-select .validation-message{position:absolute;margin-top:3px}:host ::ng-deep .container-box .box-title .header .radio-button,:host ::ng-deep .container-box .box-title .header .checkbox-select{padding-left:0;vertical-align:middle}:host ::ng-deep .container-box .box-content{padding:25px 0 25px 33px}:host ::ng-deep .container-box .timeline-item{clear:both;display:block;width:100%;position:relative}:host ::ng-deep .container-box .timeline-item:before{display:block!important;content:\"\";position:absolute;left:25px;top:-25px;bottom:25px;width:1px;border-left:1px dashed rgba(0,0,0,.2)}:host ::ng-deep .container-box .timeline-item .icon{background:#90c7ec;width:35px;height:35px;border-radius:50%;position:absolute;left:24px;top:4px}:host ::ng-deep .container-box .timeline-item .icon .fa.fa-upload{left:11px;top:10px}:host ::ng-deep .container-box .timeline-item .icon .fa{color:#fff;position:absolute}:host ::ng-deep .container-box .timeline-item .message .content{float:left;width:80%}:host ::ng-deep .container-box .container-group-control{background:transparent;text-transform:uppercase}:host ::ng-deep .container-box-custom{margin-bottom:25px}:host ::ng-deep .unchecked .container-box{border-color:#0003}:host ::ng-deep .unchecked .container-box:hover{border-color:var(--vl-primary-color)}:host ::ng-deep .unchecked.timeline-item .icon-circle{background-color:#6e6e6e}:host ::ng-deep .collapsed .box-content-wrapper{opacity:0;display:none;transition:max-height .3s .1s}:host ::ng-deep .box-content-wrapper{transition:opacity .5s .1s;display:block;opacity:1}:host ::ng-deep .box-actions{position:absolute;right:25px;z-index:2;top:21px;opacity:1;transition:height .3s ease-out,opacity .5s .1s}:host ::ng-deep .box-action-button{height:32px;width:32px;line-height:32px;font-size:12px;text-align:center;float:left;margin-left:5px;border-radius:50%;transition:all .25s ease 0s}:host ::ng-deep .box-action-button a{color:#0000008a}:host ::ng-deep .box-action-button .check-icon{line-height:32px}:host ::ng-deep .box-actions-group{top:18px;right:45px}:host ::ng-deep .box-action-button:hover,:host ::ng-deep .box-action-button:focus{background-color:#0000001a;cursor:pointer;outline:none}:host ::ng-deep .box-action-button:active{background-color:#0003;cursor:pointer}:host ::ng-deep .box-action-button.active{background-color:#0000001a}:host ::ng-deep .div-block{clear:both;display:block}:host ::ng-deep .div-inline{float:left}:host ::ng-deep .checkbox-select{position:relative;display:block}:host ::ng-deep .checkbox-select label{color:#333;margin:0;line-height:16px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.2px;padding-left:25px;position:relative;min-height:16px;cursor:pointer}:host ::ng-deep .checkbox-select input[type=checkbox]{position:absolute;width:16px;height:16px;top:0;left:0;z-index:1;cursor:pointer;opacity:0;filter:alpha(opacity=0);margin:0;line-height:normal}:host ::ng-deep .checkbox-select .input-helper:before{position:absolute;content:\"\";top:-1px;width:12px;height:12px;border-radius:2px;left:0;border:2px solid rgba(0,0,0,.54);transition:all;transition-duration:.25s}:host ::ng-deep .checkbox-select .input-helper:after{font-weight:100;line-height:12px;font-size:10px;color:#fff;font-family:FontAwesome;position:absolute;content:\"\\f00c\";width:12px;height:12px;background:#0065ff;border-radius:0;top:1px;left:2px;transform:scale(0);transition:all;transition-duration:.15s}:host ::ng-deep .checkbox-select input[type=checkbox]:checked+.input-helper:before,:host ::ng-deep .checkbox-select input[type=checkbox].checkbox--checked+.input-helper:before{border-color:var(--vl-primary-color)}:host ::ng-deep .checkbox-select input[type=checkbox]:checked+.input-helper:after,:host ::ng-deep .checkbox-select input[type=checkbox].checkbox--checked+.input-helper:after{transform:scale(1)}:host ::ng-deep .radio-button{position:relative;display:block}:host ::ng-deep .radio-button label{color:#333;margin:0;line-height:16px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.2px;padding-left:25px;position:relative;min-height:16px;cursor:pointer}:host ::ng-deep .radio-button input[type=radio]{position:absolute;width:16px;height:16px;top:0;left:0;z-index:1;cursor:pointer;opacity:0;filter:alpha(opacity=0);margin:0;line-height:normal}:host ::ng-deep .radio-button .input-helper:before{position:absolute;content:\"\";top:-1px;width:12px;height:12px;border-radius:50%;left:0;border:2px solid rgba(0,0,0,.54);transition:all;transition-duration:.25s}:host ::ng-deep .radio-button .input-helper:after{position:absolute;content:\"\";width:6px;height:6px;background:var(--vl-primary-color);border-radius:50%;top:4px;left:5px;transform:scale(0);transition:all;transition-duration:.25s}:host ::ng-deep .radio-button input[type=radio]:checked+.input-helper:before{border-color:var(--vl-primary-color)}:host ::ng-deep .radio-button input[type=radio]:checked+.input-helper:after{transform:scale(1)}:host ::ng-deep .radio-button[disabled] input[type=radio]+.input-helper:before,:host ::ng-deep .checkbox-select[disabled] input[type=radio]+.input-helper:before{border-color:#0003}:host ::ng-deep .radio-button[disabled] input[type=checkbox]+.input-helper:before,:host ::ng-deep .checkbox-select[disabled] input[type=checkbox]+.input-helper:before{border-color:#0003}:host ::ng-deep .radio-button[disabled] input[type=radio]+.input-helper:after,:host ::ng-deep .checkbox-select[disabled] input[type=radio]+.input-helper:after{background:rgba(0,0,0,.2)}:host ::ng-deep .radio-button[disabled] input[type=checkbox]+.input-helper:after,:host ::ng-deep .checkbox-select[disabled] input[type=checkbox]+.input-helper:after{background:rgba(0,0,0,.2)}:host ::ng-deep .form-control-wrapper .checkbox-select,:host ::ng-deep .form-control-wrapper .radio-button{padding-top:10px}:host ::ng-deep .shopping-bag-sidebar.open{transform:translate(-100%)}:host ::ng-deep .shopping-bag-sidebar{position:fixed;top:0;bottom:0;z-index:1051;width:420px;right:-420px;background-color:#2a2b30;transition:.3s transform}:host ::ng-deep .shopping-bag-sidebar .close-shopping-cart{color:#abacae;position:absolute;top:20%;width:50px;height:50px;line-height:50px;text-align:center;right:100%;left:auto;background:#2a2b30;border-radius:3px 0 0 3px;display:block}:host ::ng-deep .shopping-bag-sidebar .close-shopping-cart:before{font-family:FontAwesome;content:\"\\f291\"}:host ::ng-deep .shopping-bag-sidebar .close-shopping-cart:hover{text-decoration:none;color:#abacae}:host ::ng-deep .shopping-bag-sidebar .close-shopping-cart:active,:host ::ng-deep .shopping-bag-sidebar .close-shopping-cart:focus,:host ::ng-deep .shopping-bag-sidebar .close-shopping-cart:visited{text-decoration:none;color:#abacae}:host ::ng-deep .shopping-bag-sidebar .cart-count{font-size:9px;font-weight:bold;line-height:15px;position:absolute;top:50%;right:8px;width:15px;height:15px;margin:-16px 0 0;text-align:center;color:#fff;border-radius:50%;background:var(--vl-primary-color)}:host ::ng-deep .shopping-bag-sidebar .shopping-bag-container{overflow:auto;display:block;height:100%;padding:0 25px}:host ::ng-deep .shopping-bag-sidebar .shopping-bag-item{color:#abacae;background-color:#000;position:relative;overflow:auto;margin-bottom:10px}:host ::ng-deep .shopping-bag-sidebar .shopping-bag-item .item-title{position:relative;padding-right:25px;padding-left:25px}:host ::ng-deep .shopping-bag-sidebar .shopping-bag-item .item-title .header{float:left;color:#abacae;margin:0;line-height:48px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.2px}:host ::ng-deep .shopping-bag-sidebar .shopping-bag-item .item-title .box-actions{height:48px;float:right;top:0}:host ::ng-deep .shopping-bag-sidebar .shopping-bag-item .item-title .box-action-button{height:32px;width:32px;line-height:32px;font-size:10px;font-weight:700;margin-top:8px;text-align:center;transition:all .25s ease 0s;color:#fff;background-color:var(--vl-primary-color)}:host ::ng-deep .shopping-bag-sidebar .shopping-bag-title{color:#cecece;font-size:11px;text-transform:uppercase;line-height:64px;font-weight:600;padding-top:0;margin-top:25px;margin-bottom:25px;text-align:right}:host ::ng-deep .container-box.hovered:before,:host ::ng-deep .box-title.hovered:before,:host ::ng-deep .container-box.selected:before,:host ::ng-deep .box-title.selected:before{top:0;right:0;left:0;bottom:0}:host ::ng-deep .selectable{position:relative;cursor:pointer}:host ::ng-deep .container-box.hovered:before{border-color:transparent}:host ::ng-deep .container-box.hovered{border-color:var(--vl-primary-color)}:host ::ng-deep .container-box.selected:before{border-color:transparent}:host ::ng-deep .container-box.selected{border-color:var(--vl-primary-color)}:host ::ng-deep .hovered:before{display:block!important;position:absolute;content:\" \";top:-15px;bottom:15px;left:-15px;right:15px;border:1px solid var(--vl-primary-color)}:host ::ng-deep .hovered .box-action-button{opacity:1!important}:host ::ng-deep .opacity-1{opacity:1!important}:host ::ng-deep .overflow-y--auto{overflow-y:auto}:host ::ng-deep .gu-mirror{position:fixed!important;margin:0!important;z-index:9999!important;opacity:.8;-ms-filter:\"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)\";filter:alpha(opacity=80)}:host ::ng-deep .gu-hide{display:none!important}:host ::ng-deep .gu-unselectable{-webkit-user-select:none!important;-moz-user-select:none!important;-ms-user-select:none!important;user-select:none!important}:host ::ng-deep .gu-transit{opacity:.2;-ms-filter:\"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)\";filter:alpha(opacity=20)}:host ::ng-deep .top-nav-msg{margin-top:-30px}:host ::ng-deep .runtime-info-message ul{margin-bottom:0;list-style:none}:host ::ng-deep .runtime-info-message ul li{margin-bottom:10px}:host ::ng-deep .runtime-info-message ul li:last-child{margin-bottom:0}:host ::ng-deep .runtime-info-message .message-text{font-family:\"Open Sans\",Tahoma,sans-serif!important;overflow:hidden;padding:0;font-size:11px}:host ::ng-deep .runtime-attributes-popover .popover-arrow{display:none}:host ::ng-deep .runtime-attributes-popover .popover-content{padding:0}:host ::ng-deep .runtime-attributes-popover .runtime-content-wrapper{padding:0}:host ::ng-deep .runtime-attributes-popover .container-box-custom{margin-bottom:0}:host ::ng-deep .runtime-attributes-popover .input-form{margin:0;padding:0}:host ::ng-deep .runtime-attributes-popover .input-form form{margin-bottom:0}:host ::ng-deep .runtime-attributes-popover .input-form form .div-inline{display:block;float:none}:host ::ng-deep .runtime-attributes-popover .input-form form .form-group{padding:0;margin:0}:host ::ng-deep .runtime-attributes-popover .container-box .box-content{padding:0}:host ::ng-deep .v-custom-title,:host ::ng-deep .v-custom-description,:host ::ng-deep .v-custom-image{display:none}:host ::ng-deep .dropdown{position:relative}:host ::ng-deep .dropdown-toggle:focus{outline:0}:host ::ng-deep .dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;font-size:14px;text-align:left;list-style:none;background-color:#fff;background-clip:padding-box;border:1px solid #ccc;border:1px solid rgba(0,0,0,.15);border-radius:4px;box-shadow:0 6px 12px #0000002d}:host ::ng-deep .dropdown-menu.pull-right{right:0;left:auto}:host ::ng-deep .dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}:host ::ng-deep .dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:400;line-height:1.42857143;color:#333;white-space:nowrap}:host ::ng-deep .dropdown-menu>li>a:hover,:host ::ng-deep .dropdown-menu>li>a:focus{color:#262626;text-decoration:none;background-color:#f5f5f5}:host ::ng-deep .dropdown-menu>.active>a,:host ::ng-deep .dropdown-menu>.active>a:hover,:host ::ng-deep .dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;background-color:#337ab7;outline:0}:host ::ng-deep .dropdown-menu>.disabled>a,:host ::ng-deep .dropdown-menu>.disabled>a:hover,:host ::ng-deep .dropdown-menu>.disabled>a:focus{color:#777}:host ::ng-deep .dropdown-menu>.disabled>a:hover,:host ::ng-deep .dropdown-menu>.disabled>a:focus{text-decoration:none;cursor:not-allowed;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}:host ::ng-deep .open>.dropdown-menu{display:block}:host ::ng-deep .open>a{outline:0}:host ::ng-deep .dropdown-menu-right{right:0;left:auto}:host ::ng-deep .dropdown-menu-left{right:auto;left:0}:host ::ng-deep .dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.42857143;color:#777;white-space:nowrap}:host ::ng-deep .dropdown-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:990}\n", ".info{color:var(--vl-text-color-secondary);font-weight:300;font-size:13px;line-height:20px}.info.error{color:var(--vl-error-color)}\n"], components: [{ type: SectionRendererComponent, selector: "vl-section-renderer", inputs: ["section", "form"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
3266
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ComponentPreviewComponent, decorators: [{
3267
+ type: Component,
3268
+ args: [{
3269
+ selector: 'vl-component-preview',
3270
+ templateUrl: './component-preview.component.html',
3271
+ styleUrls: ['../ui-runtime/runtime-legacy-styles.scss', './component-preview.component.scss'],
3272
+ changeDetection: ChangeDetectionStrategy.OnPush,
3273
+ providers: [
3274
+ SectionsService,
3275
+ FormScopeService,
3276
+ CollapsibleStateService,
3277
+ RuntimeFormService,
3278
+ FormScopeService,
3279
+ RuntimeService,
3280
+ ],
3281
+ }]
3282
+ }], ctorParameters: function () { return [{ type: SectionsService }, { type: RuntimeFormService }, { type: FormScopeService }, { type: RuntimeService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { data: [{
3283
+ type: Input
3284
+ }] } });
3285
+
3286
+ const getSectionTree = (src) => {
3287
+ const sections = EntityUtil.clone(src);
3288
+ const sectionIdMap = new Map();
3289
+ sections.forEach(section => sectionIdMap.set(section.id, section));
3290
+ const sectionTree = [];
3291
+ sections.forEach(section => {
3292
+ if (section.parentId) {
3293
+ const parentSection = sectionIdMap.get(section.parentId);
3294
+ if (parentSection) {
3295
+ const sectionFromMap = sectionIdMap.get(section.id);
3296
+ if (sectionFromMap) {
3297
+ parentSection.addChild(sectionFromMap);
3298
+ }
3299
+ }
3300
+ }
3301
+ else {
3302
+ const s = sectionIdMap.get(section.id);
3303
+ if (s) {
3304
+ sectionTree.push(s);
3305
+ }
3306
+ }
3307
+ });
3308
+ return sectionTree;
3309
+ };
3310
+
3311
+ class RuntimeComponent {
3312
+ constructor(sectionsService, formScope, collapsibleState, formService, runtimeService, messageService, contextService, orderByPipe, searchFilterPipe, cdr) {
3313
+ this.sectionsService = sectionsService;
3314
+ this.formScope = formScope;
3315
+ this.collapsibleState = collapsibleState;
3316
+ this.formService = formService;
3317
+ this.runtimeService = runtimeService;
3318
+ this.messageService = messageService;
3319
+ this.contextService = contextService;
3320
+ this.orderByPipe = orderByPipe;
3321
+ this.searchFilterPipe = searchFilterPipe;
3322
+ this.cdr = cdr;
3323
+ this.messageBucketId = 'ui.runtime';
3324
+ this.sortedSections = [];
3325
+ this.staticSections = [];
3326
+ this.form = new FormGroup({});
3327
+ this.solutionIsReady = false;
3328
+ this.unsubscribe = new Subject();
3329
+ this.solutionUpdated = new EventEmitter();
3330
+ }
3331
+ adjustPrice(valueOption, section, solutionLineItem, patch) {
3332
+ const parentLineItem = section.model && LineItemUtil.findById(section.model.id, [solutionLineItem]);
3333
+ if (!parentLineItem) {
3334
+ return;
3335
+ }
3336
+ parentLineItem.lineItems = parentLineItem.lineItems.map(lineItem => {
3337
+ const { productId, chargeItems } = lineItem;
3338
+ if (productId !== valueOption) {
3339
+ return lineItem;
3340
+ }
3341
+ const chargeItem = chargeItems.shift();
3342
+ const updatedChargeItem = Object.assign(Object.assign({}, chargeItem), patch);
3343
+ return Object.assign(Object.assign({}, lineItem), { chargeItems: [updatedChargeItem, ...chargeItems] });
3344
+ });
3345
+ this.updateRuntime(solutionLineItem);
3346
+ }
3347
+ ngOnInit() {
3348
+ this.formScope.formSubmitEvent.pipe(takeUntil(this.unsubscribe)).subscribe((e) => {
3349
+ var _a, _b, _c, _d, _e, _f, _g;
3350
+ try {
3351
+ this.form.updateValueAndValidity();
3352
+ const solutionLineItem = EntityUtil.clone(this.solutionLineItem);
3353
+ const section = this.findSection(e.id);
3354
+ if (!section) {
3355
+ throw 'Section not found';
3356
+ }
3357
+ const entityType = section.boundData.entityType;
3358
+ if (entityType === BoundDataType[BoundDataType.PORT] || entityType === BoundDataType[BoundDataType.TYPE]) {
3359
+ if (e.action === 'patch' && EntityUtil.isPresent(e.valueOption)) {
3360
+ const valueOption = e['valueOption'];
3361
+ if (!((_a = section.model) === null || _a === void 0 ? void 0 : _a.parentId)) {
3362
+ this.collapsibleState.clearState(section.id);
3363
+ this.updateRuntime(valueOption);
3364
+ }
3365
+ else {
3366
+ const parentLineItem = LineItemUtil.findById(section.model.parentId, [solutionLineItem]);
3367
+ if (parentLineItem) {
3368
+ const indx = parentLineItem.lineItems.findIndex(item => { var _a; return item.id === ((_a = section.model) === null || _a === void 0 ? void 0 : _a.id); });
3369
+ parentLineItem.lineItems.splice(indx, 1, valueOption);
3370
+ this.collapsibleState.clearState(section.id);
3371
+ this.updateRuntime(solutionLineItem);
3372
+ }
3373
+ }
3374
+ }
3375
+ }
3376
+ if (entityType === BoundDataType[BoundDataType.PORT]) {
3377
+ if (e.action === 'upsert') {
3378
+ const parentLineItem = section.model && LineItemUtil.findById(section.model.id, [solutionLineItem]);
3379
+ if (parentLineItem) {
3380
+ parentLineItem.lineItems.forEach(i => {
3381
+ if (e.selectedValueOptions &&
3382
+ e.selectedValueOptions.findIndex(v => v.toLowerCase() === i.type.toLowerCase()) < 0) {
3383
+ this.updateCardinalityVariable(parentLineItem, i, 0);
3384
+ }
3385
+ });
3386
+ const lineItems = parentLineItem === null || parentLineItem === void 0 ? void 0 : parentLineItem.lineItems.filter(i => e.selectedValueOptions &&
3387
+ e.selectedValueOptions.findIndex(v => v.toLowerCase() === i.type.toLowerCase()) > -1);
3388
+ (_b = e.selectedValueOptions) === null || _b === void 0 ? void 0 : _b.forEach(v => {
3389
+ if ((lineItems === null || lineItems === void 0 ? void 0 : lineItems.findIndex(item => item.type.toLowerCase() === v.toLowerCase())) === -1) {
3390
+ const lineItem = this.createLineItem(section, v, parentLineItem);
3391
+ this.updateCardinalityVariable(parentLineItem, lineItem);
3392
+ lineItems.push(lineItem);
3393
+ }
3394
+ });
3395
+ this.updateRuntime(solutionLineItem);
3396
+ }
3397
+ }
3398
+ if (e.action === 'create') {
3399
+ const parentLineItem = section.model && LineItemUtil.findById(section.model.id, [solutionLineItem]);
3400
+ if (parentLineItem) {
3401
+ const valueOption = e.valueOption;
3402
+ const lineItem = this.createLineItem(section, valueOption, parentLineItem);
3403
+ parentLineItem.lineItems.push(lineItem);
3404
+ this.updateCardinalityVariable(parentLineItem, lineItem);
3405
+ this.updateRuntime(solutionLineItem);
3406
+ }
3407
+ }
3408
+ if (e.action === 'copy') {
3409
+ const parentLineItem = section.model && LineItemUtil.findById(section.model.id, [solutionLineItem]);
3410
+ if (parentLineItem) {
3411
+ const valueOption = e.valueOption;
3412
+ const lineItemToCopy = parentLineItem.lineItems.find(li => li.id === valueOption);
3413
+ if (lineItemToCopy) {
3414
+ const lineItem = Object.assign(Object.assign({}, lineItemToCopy), { id: '' });
3415
+ parentLineItem.lineItems.push(lineItem);
3416
+ this.updateCardinalityVariable(parentLineItem, lineItem);
3417
+ this.updateRuntime(solutionLineItem);
3418
+ }
3419
+ }
3420
+ }
3421
+ if (e.action === 'update') {
3422
+ const parentLineItem = section.model && LineItemUtil.findById(section.model.id, [solutionLineItem]);
3423
+ if (parentLineItem) {
3424
+ //Assuming that radio control is the only control, that 'updates' values
3425
+ const previous = (_c = section.model) === null || _c === void 0 ? void 0 : _c.lineItems.filter(li => li.port && li.port === section.boundData.name)[0];
3426
+ if (previous) {
3427
+ this.updateCardinalityVariable(parentLineItem, previous, 0);
3428
+ }
3429
+ const index = parentLineItem.lineItems.findIndex(li => li.id === (previous === null || previous === void 0 ? void 0 : previous.id));
3430
+ const lineItem = {
3431
+ id: UUID.UUID(),
3432
+ qty: previous === null || previous === void 0 ? void 0 : previous.qty,
3433
+ port: previous === null || previous === void 0 ? void 0 : previous.port,
3434
+ type: EntityUtil.isPresent(e.valueOption) ? e.valueOption : this.form.controls[e.id].value,
3435
+ cfgStatus: 'New',
3436
+ parentId: previous === null || previous === void 0 ? void 0 : previous.parentId,
3437
+ };
3438
+ this.updateCardinalityVariable(parentLineItem, lineItem);
3439
+ parentLineItem.lineItems[index] = lineItem;
3440
+ this.updateRuntime(solutionLineItem);
3441
+ }
3442
+ }
3443
+ if (e.action === 'remove') {
3444
+ const parentLineItem = section.model && LineItemUtil.findById(section.model.id, [solutionLineItem]);
3445
+ if (parentLineItem &&
3446
+ SectionsBinderHelper.isRemoveAllowed(parentLineItem, section.boundData.name, (_d = section.model) === null || _d === void 0 ? void 0 : _d.qty)) {
3447
+ const index = parentLineItem.lineItems.findIndex(item => { var _a; return item.type.toLowerCase() === ((_a = e.valueOption) === null || _a === void 0 ? void 0 : _a.toLowerCase()); });
3448
+ if (index > -1) {
3449
+ const removed = parentLineItem.lineItems.splice(index, 1)[0];
3450
+ this.updateCardinalityVariable(parentLineItem, removed, 0);
3451
+ this.updateRuntime(solutionLineItem);
3452
+ }
3453
+ }
3454
+ }
3455
+ if (e.action === 'qtyUpdate') {
3456
+ const typeSection = e.valueOption
3457
+ ? SectionHelperService.findSectionForValue(section, e.valueOption)
3458
+ : undefined;
3459
+ const typeLineItem = (typeSection === null || typeSection === void 0 ? void 0 : typeSection.model) && LineItemUtil.findById(typeSection.model.id, [solutionLineItem]);
3460
+ if (typeSection && typeLineItem) {
3461
+ typeLineItem.qty = +this.form.controls[typeSection.id + 'qty'].value;
3462
+ typeLineItem.cfgStatus = 'User';
3463
+ this.updateRuntime(solutionLineItem);
3464
+ }
3465
+ }
3466
+ if (e.action === 'adjustNetPrice') {
3467
+ const { valueOption, options } = e;
3468
+ const { amount } = options !== null && options !== void 0 ? options : {};
3469
+ const priceAdjustment = {
3470
+ type: 'OVERRIDE_AMOUNT',
3471
+ explanation: 'Manual net price adjustment',
3472
+ formula: '',
3473
+ amount,
3474
+ };
3475
+ this.adjustPrice(valueOption, section, solutionLineItem, { priceAdjustment });
3476
+ }
3477
+ if (e.action === 'adjustListPrice') {
3478
+ const { valueOption, options } = e;
3479
+ const { amount } = options !== null && options !== void 0 ? options : {};
3480
+ const listPriceAdjustment = {
3481
+ type: 'OVERRIDE_AMOUNT',
3482
+ explanation: 'Manual list price adjustment',
3483
+ formula: '',
3484
+ amount,
3485
+ };
3486
+ this.adjustPrice(valueOption, section, solutionLineItem, { listPriceAdjustment });
3487
+ }
3488
+ }
3489
+ if (entityType === BoundDataType[BoundDataType.TYPE]) {
3490
+ if (e.action === 'remove') {
3491
+ const parentLineItem = ((_e = section.model) === null || _e === void 0 ? void 0 : _e.parentId) && LineItemUtil.findById(section.model.parentId, [solutionLineItem]);
3492
+ if (parentLineItem &&
3493
+ section.model &&
3494
+ section.model.port &&
3495
+ SectionsBinderHelper.isRemoveAllowed(parentLineItem, section.model.port, (_f = section.model) === null || _f === void 0 ? void 0 : _f.qty)) {
3496
+ const index = parentLineItem.lineItems.findIndex(item => { var _a; return item.id === ((_a = section.model) === null || _a === void 0 ? void 0 : _a.id); });
3497
+ if (index > -1) {
3498
+ const removed = parentLineItem.lineItems.splice(index, 1)[0];
3499
+ this.updateCardinalityVariable(parentLineItem, removed, 0);
3500
+ this.collapsibleState.clearState(section.id);
3501
+ this.updateRuntime(solutionLineItem);
3502
+ }
3503
+ }
3504
+ }
3505
+ if (e.action === 'qtyUpdate') {
3506
+ const typeLineItem = section.model && LineItemUtil.findById(section.model.id, [solutionLineItem]);
3507
+ if (typeLineItem) {
3508
+ const qty = +this.form.controls[e.id + 'qty'].value;
3509
+ if (typeLineItem.parentId) {
3510
+ const parentLineItem = LineItemUtil.findById(typeLineItem.parentId, [solutionLineItem]);
3511
+ if (parentLineItem) {
3512
+ this.updateCardinalityVariable(parentLineItem, typeLineItem, qty);
3513
+ }
3514
+ }
3515
+ typeLineItem.qty = qty;
3516
+ typeLineItem.cfgStatus = 'User';
3517
+ this.updateRuntime(solutionLineItem);
3518
+ }
3519
+ }
3520
+ }
3521
+ if (entityType === BoundDataType[BoundDataType.ATTRIBUTE]) {
3522
+ if (e.action === 'update') {
3523
+ const parentLineItem = section.model && LineItemUtil.findById(section.model.id, [solutionLineItem]);
3524
+ const attribute = parentLineItem === null || parentLineItem === void 0 ? void 0 : parentLineItem.attributes.find(attr => attr.name.toLowerCase() === section.boundData.name.toLowerCase());
3525
+ if (attribute) {
3526
+ //Explicitly set value always win
3527
+ let value = typeof e.valueOption !== 'undefined' ? e.valueOption : this.form.controls[e.id].value;
3528
+ if (attribute.type === 'BOOLEAN') {
3529
+ value = value ? 1 : 0;
3530
+ }
3531
+ attribute.value = value;
3532
+ attribute.cfgStatus = 'User';
3533
+ this.updateRuntime(solutionLineItem);
3534
+ }
3535
+ }
3536
+ }
3537
+ }
3538
+ catch (e) {
3539
+ console.log(e);
3540
+ this.messageService.add({ key: this.messageBucketId, summary: `Configuration failed ${(_g = e) === null || _g === void 0 ? void 0 : _g.message}` });
3541
+ }
3542
+ });
3543
+ this.runtimeService.onSolutionReadyEvent
3544
+ .pipe(takeUntil(this.unsubscribe))
3545
+ .subscribe(lineItem => this.onSolutionReady(lineItem));
3546
+ this.runtimeService.onSolutionUpdatedEvent
3547
+ .pipe(takeUntil(this.unsubscribe))
3548
+ .subscribe((data) => {
3549
+ if (!(data instanceof HttpErrorResponse)) {
3550
+ return this.handleSolutionUpdate(data);
3551
+ }
3552
+ this.handleSolutionFailedUpdate(data);
3553
+ });
3554
+ this.runtimeService.onUIRefreshEvent.pipe(takeUntil(this.unsubscribe)).subscribe(() => {
3555
+ var _a;
3556
+ const { uiDefinition } = (_a = this.runtimeService.getRuntimeContext()) !== null && _a !== void 0 ? _a : {};
3557
+ this.runtimeContext.uiDefinition = uiDefinition;
3558
+ this.formScope.scriptSessionScope = {};
3559
+ this.startRuntime();
3560
+ });
3561
+ }
3562
+ onSolutionReady(lineItem) {
3563
+ var _a;
3564
+ const context = this.runtimeService.getRuntimeContext();
3565
+ const configurationContext = this.contextService.resolve();
3566
+ const mergeContext = Object.assign(Object.assign({}, context), { properties: Object.assign(Object.assign({}, context.properties), configurationContext.properties) });
3567
+ const accountId = (_a = mergeContext.properties) === null || _a === void 0 ? void 0 : _a.AccountId;
3568
+ if (accountId && accountId.length === 15) {
3569
+ this.runtimeContext = Object.assign(Object.assign({}, mergeContext), { properties: Object.assign(Object.assign({}, mergeContext.properties), { AccountId: SalesforceIdUtils.generateId18FromId15(accountId) }) });
3570
+ }
3571
+ else {
3572
+ this.runtimeContext = mergeContext;
3573
+ }
3574
+ this.solutionLineItem = lineItem;
3575
+ this.runtimeService.setRuntimeContext(this.runtimeContext);
3576
+ this.startRuntime();
3577
+ }
3578
+ handleSolutionUpdate(updatedLineItem) {
3579
+ this.solutionLineItem = updatedLineItem;
3580
+ this.processSolution(true);
3581
+ this.runtimeService.solutionProcessed(this.solutionLineItem);
3582
+ this.cdr.detectChanges();
3583
+ }
3584
+ handleSolutionFailedUpdate(error) {
3585
+ var _a;
3586
+ const hasErrorMessage = EntityUtil.isPresent(error.error) && EntityUtil.isPresent(error.error.message);
3587
+ const message = hasErrorMessage ? error.error.message : 'Configuration failed';
3588
+ const { isHandlingConfigurationErrors } = (_a = this.runtimeContext.uiDefinition) !== null && _a !== void 0 ? _a : {};
3589
+ if (isHandlingConfigurationErrors) {
3590
+ this.messageService.add({ key: this.messageBucketId, summary: message });
3591
+ }
3592
+ this.solutionLineItem = Object.assign(Object.assign({}, this.solutionLineItem), { messages: [...this.solutionLineItem.messages, `E:${message}`] });
3593
+ this.processSolution(true, true);
3594
+ this.runtimeService.solutionProcessed(this.solutionLineItem);
3595
+ this.cdr.detectChanges();
3596
+ }
3597
+ updateCardinalityVariable(parent, updated, newQuantity) {
3598
+ var _a;
3599
+ const portDomain = updated.port ? parent.portDomains[updated.port] : undefined;
3600
+ const domainType = portDomain === null || portDomain === void 0 ? void 0 : portDomain.domainTypes.find(t => t.name === updated.type);
3601
+ const cardinality = (_a = domainType === null || domainType === void 0 ? void 0 : domainType.cardinality) !== null && _a !== void 0 ? _a : 0;
3602
+ let qty;
3603
+ if (!Number.isFinite(domainType === null || domainType === void 0 ? void 0 : domainType.cardinality)) {
3604
+ qty = Number.isFinite(newQuantity) ? newQuantity : updated.qty;
3605
+ }
3606
+ else {
3607
+ qty = EntityUtil.isPresent(newQuantity)
3608
+ ? cardinality - updated.qty + newQuantity
3609
+ : cardinality + updated.qty;
3610
+ }
3611
+ const cardinalityName = '#CV-' + updated.type + '@' + updated.port;
3612
+ let cardinalityVariable = parent.attributes.find(a => a.name === cardinalityName);
3613
+ if (!cardinalityVariable) {
3614
+ cardinalityVariable = {
3615
+ id: UUID.UUID(),
3616
+ name: cardinalityName,
3617
+ };
3618
+ parent.attributes.push(cardinalityVariable);
3619
+ }
3620
+ cardinalityVariable.value = qty;
3621
+ cardinalityVariable.cfgStatus = 'User';
3622
+ }
3623
+ createLineItem(section, valueOption, parentLineItem) {
3624
+ return {
3625
+ qty: +this.form.controls[section.id + 'qty'].value,
3626
+ port: section.boundData.name,
3627
+ type: EntityUtil.isPresent(valueOption) ? valueOption : this.form.controls[section.id].value,
3628
+ cfgStatus: 'New',
3629
+ parentId: parentLineItem === null || parentLineItem === void 0 ? void 0 : parentLineItem.id,
3630
+ };
3631
+ }
3632
+ ngOnDestroy() {
3633
+ this.unsubscribe.next();
3634
+ this.sectionsService.destroy();
3635
+ }
3636
+ startRuntime() {
3637
+ var _a, _b, _c;
3638
+ const uiDefinition = this.runtimeContext.uiDefinition;
3639
+ const defaultTab = (_a = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.tabs) === null || _a === void 0 ? void 0 : _a.find(tab => tab.isDefault);
3640
+ this.activeUITab = EntityUtil.isPresent(defaultTab) ? defaultTab : (_b = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.tabs) === null || _b === void 0 ? void 0 : _b[0];
3641
+ this.sectionsService.compileModule((_c = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.sections) !== null && _c !== void 0 ? _c : [], uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.isViewEncapsulated);
3642
+ this.processSolution();
3643
+ this.solutionIsReady = true;
3644
+ this.cdr.detectChanges();
3645
+ }
3646
+ updateRuntime(lineItem) {
3647
+ this.solutionUpdated.emit(lineItem);
3648
+ }
3649
+ addToCart() {
3650
+ const lineItem = EntityUtil.clone(this.solutionLineItem);
3651
+ this.runtimeService.stopRuntime(lineItem);
3652
+ }
3653
+ processSolution(isUpdate, isError) {
3654
+ var _a, _b, _c, _d, _e, _f;
3655
+ //1. Bind sections to solution
3656
+ let sections = (_b = EntityUtil.clone((_a = this.runtimeContext.uiDefinition) === null || _a === void 0 ? void 0 : _a.sections)) !== null && _b !== void 0 ? _b : [];
3657
+ const sourceSections = (_d = EntityUtil.clone((_c = this.runtimeContext.uiDefinition) === null || _c === void 0 ? void 0 : _c.sections)) !== null && _d !== void 0 ? _d : [];
3658
+ this.updateLineItemsSectionPath(this.solutionLineItem);
3659
+ SectionsBinderHelper.setLineItemsPath(this.runtimeContext.runtimeModel, this.solutionLineItem, sections, sourceSections, (sec) => !sec.parentId && sec.boundData, (_f = (_e = this.runtimeContext.uiDefinition) === null || _e === void 0 ? void 0 : _e.pricingEnabled) !== null && _f !== void 0 ? _f : false);
3660
+ sections = sections.filter(s => s.model && s.template);
3661
+ //2. Init form
3662
+ this.form = this.formService.initForm(sections, this.solutionLineItem);
3663
+ this.formScope.form = this.form;
3664
+ this.sortedSections = this.filterAndSort(getSectionTree(sections.filter(s => !s.isStatic)));
3665
+ if (!isUpdate) {
3666
+ this.staticSections = this.filterAndSort(getSectionTree(sections.filter(s => s.isStatic)));
3667
+ }
3668
+ if (!isError) {
3669
+ this.messageService.clear(this.messageBucketId);
3670
+ }
3671
+ }
3672
+ hideModal() {
3673
+ this.runtimeService.cancelRuntime();
3674
+ }
3675
+ updateLineItemsSectionPath(lineItem, parent) {
3676
+ const path = {
3677
+ types: parent ? parent.types.concat([lineItem.type]) : [lineItem.type],
3678
+ ports: parent ? parent.ports.concat(lineItem.port ? [lineItem.port] : []) : [],
3679
+ };
3680
+ lineItem.path = path;
3681
+ for (const child of lineItem.lineItems) {
3682
+ this.updateLineItemsSectionPath(child, lineItem.path);
3683
+ }
3684
+ }
3685
+ filterAndSort(sections) {
3686
+ var _a;
3687
+ const filtered = this.searchFilterPipe.transform(sections, (_a = this.activeUITab) === null || _a === void 0 ? void 0 : _a.id, 'page');
3688
+ const ordered = this.orderByPipe.transform(filtered, 'order', 'asc');
3689
+ return ordered;
3690
+ }
3691
+ findSection(id) {
3692
+ return EntityUtil.findByFieldHierarchically('id', id, [...this.sortedSections, ...this.staticSections], 'children');
3693
+ }
3694
+ }
3695
+ RuntimeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeComponent, deps: [{ token: SectionsService }, { token: FormScopeService }, { token: CollapsibleStateService }, { token: RuntimeFormService }, { token: RuntimeService }, { token: MessageService }, { token: i2.ContextService }, { token: i7.OrderByPipe }, { token: i7.SearchFilterPipe }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
3696
+ RuntimeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: RuntimeComponent, selector: "vl-runtime", outputs: { solutionUpdated: "solutionUpdated" }, providers: [FormScopeService, CollapsibleStateService, OrderByPipe, SearchFilterPipe], ngImport: i0, template: "<vl-loader label=\"Loading UI\" *ngIf=\"!solutionIsReady; else content\"></vl-loader>\n\n<ng-template #content>\n <div\n class=\"sidebar-tabs\"\n [ngClass]=\"{ hidden: !runtimeContext?.uiDefinition?.defaultPanels }\"\n #uiTabs=\"sidebarTabs\"\n sidebarTabs=\"{{ activeUITab?.id }}\"\n id=\"vl-default-sidebar-tabs\"\n >\n <ul>\n <li\n *ngFor=\"let tab of runtimeContext?.uiDefinition?.tabs | orderBy: 'order':'asc'\"\n [ngClass]=\"{ active: uiTabs.activeTab === tab.id }\"\n (click)=\"uiTabs.switchTab(tab.id)\"\n >\n <a href=\"javascript:void(0);\">{{ tab.name }}</a>\n </li>\n </ul>\n </div>\n\n <div class=\"sections-wrapper\">\n <form role=\"form\" name=\"form\" class=\"form-horizontal\" [formGroup]=\"form\" novalidate autocomplete=\"off\">\n <ng-container *ngFor=\"let section of staticSections; let i = index\">\n <ng-container *ngIf=\"section.model && section.template && !section.hidden\">\n <vl-section-renderer [section]=\"section\" [form]=\"form\"></vl-section-renderer>\n </ng-container>\n </ng-container>\n\n <ng-container *ngFor=\"let section of sortedSections; let i = index\">\n <ng-container *ngIf=\"section.model && section.template && !section.hidden\">\n <vl-section-renderer [section]=\"section\" [form]=\"form\"></vl-section-renderer>\n </ng-container>\n </ng-container>\n </form>\n\n <div\n class=\"modal-footer\"\n *ngIf=\"runtimeContext?.runtimeMode === 1\"\n id=\"vl-runtime-default-footer\"\n [ngClass]=\"{ hidden: !runtimeContext?.uiDefinition?.defaultPanels }\"\n >\n <div class=\"col-md-12 input-form-input\">\n <a href=\"javascript:void(0);\" class=\"btn btn-default\" (click)=\"form.valid && addToCart()\" id=\"add-to-cart-btn\"\n >Add to cart</a\n >\n <a href=\"javascript:void(0);\" class=\"btn btn-link\" (click)=\"hideModal()\" id=\"cancel-btn\">Cancel</a>\n </div>\n </div>\n </div>\n</ng-template>\n", styles: ["@charset \"UTF-8\";body.veloce-apex-index,body.veloce-index,body.sfdcBody{overflow:hidden;margin:0;padding:0}:host ::ng-deep .velo-app .modal.in .modal-dialog.runtime-modal{margin-left:5%;margin-right:5%;padding:0;position:relative;width:auto}:host ::ng-deep .modal-body.runtime-modal.main-container{height:100%;margin:0;padding:0}:host ::ng-deep .modal-body.runtime-modal.main-container .content-wrapper{display:flex;flex-direction:column;height:100%}:host ::ng-deep .modal-body.runtime-modal.main-container .sections-wrapper{display:flex;flex-direction:column;flex-grow:1;padding:0}:host ::ng-deep .modal-body.runtime-modal.main-container .sections-wrapper .modal-body.runtime-modal.container-fluid{height:100%;margin:0;padding:0;overflow:auto}:host ::ng-deep .modal-body.runtime-modal.main-container .sections-wrapper .modal-body.runtime-modal.container-fluid .input-form.form-horizontal,:host ::ng-deep .modal-body.runtime-modal.main-container .sections-wrapper .modal-body.runtime-modal.container-fluid .input-form.form-horizontal .form-horizontal,:host ::ng-deep .modal-body.runtime-modal.main-container .sections-wrapper .modal-body.runtime-modal.container-fluid section-script>:first-child{height:100%}:host ::ng-deep .runtime-modal .modal-content,:host ::ng-deep .gu-mirror .modal-content{background-color:--vl-input-background}:host ::ng-deep .runtime-modal .modal-content .modal-header-menu ul li a,:host ::ng-deep .gu-mirror .modal-content .modal-header-menu ul li a{color:#333333b3;font-weight:600;text-transform:uppercase;letter-spacing:.85px;font-size:10px}:host ::ng-deep .runtime-modal .modal-content .modal-header-menu ul li a.active,:host ::ng-deep .gu-mirror .modal-content .modal-header-menu ul li a.active{color:#333}:host ::ng-deep .runtime-modal .modal-content .modal-header-menu ul li a.disabled,:host ::ng-deep .gu-mirror .modal-content .modal-header-menu ul li a.disabled{color:#33333380}:host ::ng-deep .runtime-modal .modal-content .modal-header-menu ul li a.active:after,:host ::ng-deep .gu-mirror .modal-content .modal-header-menu ul li a.active:after{background-color:#f36;bottom:-1px;content:\"\";height:1px;left:0;position:absolute;width:100%}:host ::ng-deep .runtime-modal .modal-content .modal-header,:host ::ng-deep .gu-mirror .modal-content .modal-header{background:transparent;color:#fff}:host ::ng-deep .runtime-modal .runtime-group-divider,:host ::ng-deep .gu-mirror .runtime-group-divider{border-bottom:1px solid #e5e5e5}:host ::ng-deep .runtime-modal .input-form-input,:host ::ng-deep .gu-mirror .input-form-input{position:relative;padding-left:0;padding-top:0}:host ::ng-deep .runtime-modal .input-form-input--required>label,:host ::ng-deep .gu-mirror .input-form-input--required>label{color:#ff4233;font-weight:bold}:host ::ng-deep .form-control-wrapper{position:relative}:host ::ng-deep .add-config-control:hover{background-color:#e96099;color:#fff;border:1px solid transparent}:host ::ng-deep .remove-config-control:hover{background-color:#828c9e;color:#fff}:host ::ng-deep .add-config-control[disabled],:host ::ng-deep .remove-config-control[disabled]{background-color:transparent;color:#ccc;border:1px dashed #ccc}:host ::ng-deep .add-config-control[disabled]:hover,:host ::ng-deep .remove-config-control[disabled]:hover{cursor:default}:host ::ng-deep .add-config-control{height:36px;width:36px;line-height:36px;font-size:14px;text-align:center;border-radius:50%;float:left;position:absolute;top:0;right:-57px;z-index:500;background-color:#e3337c;color:#fff;border:1px solid #e3337c;transition:all .5s ease 0s}:host ::ng-deep .add-config-control .plus-icon{line-height:36px}:host ::ng-deep .remove-config-control{height:36px;width:36px;line-height:36px;font-size:14px;text-align:center;margin-right:25px;border-radius:50%;float:left;position:absolute;top:33px;right:51px;z-index:500;background-color:transparent;color:#687285;border:1px solid transparent;transition:all .5s ease 0s}:host ::ng-deep .remove-config-control .plus-icon{line-height:36px}:host ::ng-deep .sidebar .new-wrapper{min-height:96px;margin-bottom:25px}:host ::ng-deep .sidebar .new-wrapper .add-container .add-card{left:0;margin-left:15px}:host ::ng-deep .ui-settings{height:100%;display:flex;flex-direction:column}:host ::ng-deep .runtime-modal .form-horizontal form,:host ::ng-deep .gu-mirror form{margin:0}:host ::ng-deep .runtime-modal .form-horizontal .form-group,:host ::ng-deep .gu-mirror .form-group{margin:0;padding:0}:host ::ng-deep .runtime-modal .form-horizontal .control.form-group,:host ::ng-deep .gu-mirror .control.form-group{margin-bottom:25px}:host ::ng-deep .runtime-modal .form-horizontal .form-control-wrapper,:host ::ng-deep .gu-mirror .form-control-wrapper{min-width:172px;margin-bottom:25px}:host ::ng-deep .runtime-modal .form-horizontal .quantity-form-input .form-control-wrapper,:host ::ng-deep .gu-mirror .quantity-form-input .form-control-wrapper{min-width:50px}:host ::ng-deep .runtime-modal .form-horizontal .quantity-form-input .form-control-wrapper .form-control,:host ::ng-deep .gu-mirror .quantity-form-input .form-control-wrapper .form-control{width:50px}:host ::ng-deep .runtime-left-side{height:calc(100% - 97px);background:#fff;padding:48px 56px 0}:host ::ng-deep .ui-controls-group{margin-left:-8px;margin-right:-8px}:host ::ng-deep .ui-controls-group .ui-control-type:hover{border-color:#3384ff}:host ::ng-deep .ui-controls-group .ui-control-type{position:relative;min-width:140px;float:left;border-radius:3px;border:1px solid #c4c4c4;background-color:#fff;width:calc(50% - 16px);padding:12px 13px;margin-bottom:16px;margin-right:8px;margin-left:8px;cursor:pointer}:host ::ng-deep .ui-controls-group .ui-control-type span{padding-left:3px}:host ::ng-deep .sidebar-header{letter-spacing:-.5px;padding-bottom:24px;padding-top:0;line-height:32px;font-size:24px;font-weight:700;color:#333}:host ::ng-deep .sidebar-header small{display:block;color:#333;font-size:11px;font-weight:300;line-height:20px;margin:0}:host ::ng-deep .sidebar-menu-list{color:#333333b3;margin:0;width:100%;list-style:none;font-size:12px}:host ::ng-deep .sidebar-menu-list li.active a,:host ::ng-deep .sidebar-menu-list li.active i{color:#005ee3}:host ::ng-deep .sidebar-menu-list li:hover{cursor:pointer}:host ::ng-deep .sidebar-menu-list li{text-align:right;padding-left:16px}:host ::ng-deep .sidebar-menu-list li a{padding:0 8px;margin-left:-8px;cursor:pointer;white-space:nowrap;color:inherit;font-weight:700;display:inline-block;line-height:32px}:host ::ng-deep .sidebar-menu-list li i{display:none;padding-right:5px}:host ::ng-deep .runtime-builder-content{min-height:100%}:host ::ng-deep .runtime-builder-content .input-form{margin:0;padding:18px 11px 0}:host ::ng-deep .runtime-builder-content .input-form .form-group{border:3px dashed transparent}:host ::ng-deep .runtime-builder-content .input-form .form-group:hover{border:3px dashed #dedede}:host ::ng-deep .runtime-right-side{background:#fff}:host ::ng-deep .sidebar-section .section-title{color:#a1a1a1;background:#fff;position:relative;display:inline-block;padding-right:16px;text-transform:uppercase;font-size:10px;letter-spacing:.2px}:host ::ng-deep .sidebar-section:before{content:\" \";position:absolute;top:50%;left:0;right:0;border-top:1px solid #e6e6e6}:host ::ng-deep .sidebar-section{position:relative;margin-top:16px;margin-bottom:16px}:host ::ng-deep .sidebar-section .section-title{color:#a1a1a1;background-color:var(--vl-input-background);position:relative;display:inline-block;padding-right:16px;padding-left:8px;text-transform:uppercase;font-size:6px;letter-spacing:.2px}:host ::ng-deep .section-wrapper{top:-21px;position:absolute;right:0;left:12px}:host ::ng-deep .container-box.container-box-bordered{border:1px solid rgba(0,0,0,.2);margin-bottom:25px;padding-left:25px}:host ::ng-deep .container-box.container-box-radio{margin-left:0}:host ::ng-deep .container-box.container-box-radio:hover,:host ::ng-deep .container-box.container-box-checkbox:hover{cursor:pointer}:host ::ng-deep .container-box{position:relative;overflow:auto;border:1px solid transparent;background:var(--vl-input-background)}:host ::ng-deep .container-box .container-box{border:1px solid rgba(0,0,0,.2);margin-left:25px;margin-right:25px;margin-bottom:25px}:host ::ng-deep .container-box .container-box:hover{border-color:var(--vl-primary-color)}:host ::ng-deep .container-box .box-title .header .header-label{color:#333;margin:0;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.2px;line-height:75px}:host ::ng-deep .container-box .box-title .header .header-label small{padding-left:21px;color:#757575;font-weight:400;font-size:10px;line-height:75px}:host ::ng-deep .container-box .box-title .header .header-qty-container,:host ::ng-deep .container-box .box-title .header .radio-button,:host ::ng-deep .container-box .box-title .header .checkbox-select{display:table-cell;vertical-align:middle;height:75px;padding-left:21px}:host ::ng-deep .container-box .box-title .header .header-qty-container .form-control,:host ::ng-deep .container-box .box-title .header .radio-button .form-control,:host ::ng-deep .container-box .box-title .header .checkbox-select .form-control{height:auto;color:#333;width:50px;border:1px solid #dddddd}:host ::ng-deep .container-box .box-title .header .header-qty-container .form-control:focus,:host ::ng-deep .container-box .box-title .header .radio-button .form-control:focus,:host ::ng-deep .container-box .box-title .header .checkbox-select .form-control:focus{border:1px solid #c4c4c4}:host ::ng-deep .container-box .box-title .header .header-qty-container .validation-message,:host ::ng-deep .container-box .box-title .header .radio-button .validation-message,:host ::ng-deep .container-box .box-title .header .checkbox-select .validation-message{position:absolute;margin-top:3px}:host ::ng-deep .container-box .box-title .header .radio-button,:host ::ng-deep .container-box .box-title .header .checkbox-select{padding-left:0;vertical-align:middle}:host ::ng-deep .container-box .box-content{padding:25px 0 25px 33px}:host ::ng-deep .container-box .timeline-item{clear:both;display:block;width:100%;position:relative}:host ::ng-deep .container-box .timeline-item:before{display:block!important;content:\"\";position:absolute;left:25px;top:-25px;bottom:25px;width:1px;border-left:1px dashed rgba(0,0,0,.2)}:host ::ng-deep .container-box .timeline-item .icon{background:#90c7ec;width:35px;height:35px;border-radius:50%;position:absolute;left:24px;top:4px}:host ::ng-deep .container-box .timeline-item .icon .fa.fa-upload{left:11px;top:10px}:host ::ng-deep .container-box .timeline-item .icon .fa{color:#fff;position:absolute}:host ::ng-deep .container-box .timeline-item .message .content{float:left;width:80%}:host ::ng-deep .container-box .container-group-control{background:transparent;text-transform:uppercase}:host ::ng-deep .container-box-custom{margin-bottom:25px}:host ::ng-deep .unchecked .container-box{border-color:#0003}:host ::ng-deep .unchecked .container-box:hover{border-color:var(--vl-primary-color)}:host ::ng-deep .unchecked.timeline-item .icon-circle{background-color:#6e6e6e}:host ::ng-deep .collapsed .box-content-wrapper{opacity:0;display:none;transition:max-height .3s .1s}:host ::ng-deep .box-content-wrapper{transition:opacity .5s .1s;display:block;opacity:1}:host ::ng-deep .box-actions{position:absolute;right:25px;z-index:2;top:21px;opacity:1;transition:height .3s ease-out,opacity .5s .1s}:host ::ng-deep .box-action-button{height:32px;width:32px;line-height:32px;font-size:12px;text-align:center;float:left;margin-left:5px;border-radius:50%;transition:all .25s ease 0s}:host ::ng-deep .box-action-button a{color:#0000008a}:host ::ng-deep .box-action-button .check-icon{line-height:32px}:host ::ng-deep .box-actions-group{top:18px;right:45px}:host ::ng-deep .box-action-button:hover,:host ::ng-deep .box-action-button:focus{background-color:#0000001a;cursor:pointer;outline:none}:host ::ng-deep .box-action-button:active{background-color:#0003;cursor:pointer}:host ::ng-deep .box-action-button.active{background-color:#0000001a}:host ::ng-deep .div-block{clear:both;display:block}:host ::ng-deep .div-inline{float:left}:host ::ng-deep .checkbox-select{position:relative;display:block}:host ::ng-deep .checkbox-select label{color:#333;margin:0;line-height:16px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.2px;padding-left:25px;position:relative;min-height:16px;cursor:pointer}:host ::ng-deep .checkbox-select input[type=checkbox]{position:absolute;width:16px;height:16px;top:0;left:0;z-index:1;cursor:pointer;opacity:0;filter:alpha(opacity=0);margin:0;line-height:normal}:host ::ng-deep .checkbox-select .input-helper:before{position:absolute;content:\"\";top:-1px;width:12px;height:12px;border-radius:2px;left:0;border:2px solid rgba(0,0,0,.54);transition:all;transition-duration:.25s}:host ::ng-deep .checkbox-select .input-helper:after{font-weight:100;line-height:12px;font-size:10px;color:#fff;font-family:FontAwesome;position:absolute;content:\"\\f00c\";width:12px;height:12px;background:#0065ff;border-radius:0;top:1px;left:2px;transform:scale(0);transition:all;transition-duration:.15s}:host ::ng-deep .checkbox-select input[type=checkbox]:checked+.input-helper:before,:host ::ng-deep .checkbox-select input[type=checkbox].checkbox--checked+.input-helper:before{border-color:var(--vl-primary-color)}:host ::ng-deep .checkbox-select input[type=checkbox]:checked+.input-helper:after,:host ::ng-deep .checkbox-select input[type=checkbox].checkbox--checked+.input-helper:after{transform:scale(1)}:host ::ng-deep .radio-button{position:relative;display:block}:host ::ng-deep .radio-button label{color:#333;margin:0;line-height:16px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.2px;padding-left:25px;position:relative;min-height:16px;cursor:pointer}:host ::ng-deep .radio-button input[type=radio]{position:absolute;width:16px;height:16px;top:0;left:0;z-index:1;cursor:pointer;opacity:0;filter:alpha(opacity=0);margin:0;line-height:normal}:host ::ng-deep .radio-button .input-helper:before{position:absolute;content:\"\";top:-1px;width:12px;height:12px;border-radius:50%;left:0;border:2px solid rgba(0,0,0,.54);transition:all;transition-duration:.25s}:host ::ng-deep .radio-button .input-helper:after{position:absolute;content:\"\";width:6px;height:6px;background:var(--vl-primary-color);border-radius:50%;top:4px;left:5px;transform:scale(0);transition:all;transition-duration:.25s}:host ::ng-deep .radio-button input[type=radio]:checked+.input-helper:before{border-color:var(--vl-primary-color)}:host ::ng-deep .radio-button input[type=radio]:checked+.input-helper:after{transform:scale(1)}:host ::ng-deep .radio-button[disabled] input[type=radio]+.input-helper:before,:host ::ng-deep .checkbox-select[disabled] input[type=radio]+.input-helper:before{border-color:#0003}:host ::ng-deep .radio-button[disabled] input[type=checkbox]+.input-helper:before,:host ::ng-deep .checkbox-select[disabled] input[type=checkbox]+.input-helper:before{border-color:#0003}:host ::ng-deep .radio-button[disabled] input[type=radio]+.input-helper:after,:host ::ng-deep .checkbox-select[disabled] input[type=radio]+.input-helper:after{background:rgba(0,0,0,.2)}:host ::ng-deep .radio-button[disabled] input[type=checkbox]+.input-helper:after,:host ::ng-deep .checkbox-select[disabled] input[type=checkbox]+.input-helper:after{background:rgba(0,0,0,.2)}:host ::ng-deep .form-control-wrapper .checkbox-select,:host ::ng-deep .form-control-wrapper .radio-button{padding-top:10px}:host ::ng-deep .shopping-bag-sidebar.open{transform:translate(-100%)}:host ::ng-deep .shopping-bag-sidebar{position:fixed;top:0;bottom:0;z-index:1051;width:420px;right:-420px;background-color:#2a2b30;transition:.3s transform}:host ::ng-deep .shopping-bag-sidebar .close-shopping-cart{color:#abacae;position:absolute;top:20%;width:50px;height:50px;line-height:50px;text-align:center;right:100%;left:auto;background:#2a2b30;border-radius:3px 0 0 3px;display:block}:host ::ng-deep .shopping-bag-sidebar .close-shopping-cart:before{font-family:FontAwesome;content:\"\\f291\"}:host ::ng-deep .shopping-bag-sidebar .close-shopping-cart:hover{text-decoration:none;color:#abacae}:host ::ng-deep .shopping-bag-sidebar .close-shopping-cart:active,:host ::ng-deep .shopping-bag-sidebar .close-shopping-cart:focus,:host ::ng-deep .shopping-bag-sidebar .close-shopping-cart:visited{text-decoration:none;color:#abacae}:host ::ng-deep .shopping-bag-sidebar .cart-count{font-size:9px;font-weight:bold;line-height:15px;position:absolute;top:50%;right:8px;width:15px;height:15px;margin:-16px 0 0;text-align:center;color:#fff;border-radius:50%;background:var(--vl-primary-color)}:host ::ng-deep .shopping-bag-sidebar .shopping-bag-container{overflow:auto;display:block;height:100%;padding:0 25px}:host ::ng-deep .shopping-bag-sidebar .shopping-bag-item{color:#abacae;background-color:#000;position:relative;overflow:auto;margin-bottom:10px}:host ::ng-deep .shopping-bag-sidebar .shopping-bag-item .item-title{position:relative;padding-right:25px;padding-left:25px}:host ::ng-deep .shopping-bag-sidebar .shopping-bag-item .item-title .header{float:left;color:#abacae;margin:0;line-height:48px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.2px}:host ::ng-deep .shopping-bag-sidebar .shopping-bag-item .item-title .box-actions{height:48px;float:right;top:0}:host ::ng-deep .shopping-bag-sidebar .shopping-bag-item .item-title .box-action-button{height:32px;width:32px;line-height:32px;font-size:10px;font-weight:700;margin-top:8px;text-align:center;transition:all .25s ease 0s;color:#fff;background-color:var(--vl-primary-color)}:host ::ng-deep .shopping-bag-sidebar .shopping-bag-title{color:#cecece;font-size:11px;text-transform:uppercase;line-height:64px;font-weight:600;padding-top:0;margin-top:25px;margin-bottom:25px;text-align:right}:host ::ng-deep .container-box.hovered:before,:host ::ng-deep .box-title.hovered:before,:host ::ng-deep .container-box.selected:before,:host ::ng-deep .box-title.selected:before{top:0;right:0;left:0;bottom:0}:host ::ng-deep .selectable{position:relative;cursor:pointer}:host ::ng-deep .container-box.hovered:before{border-color:transparent}:host ::ng-deep .container-box.hovered{border-color:var(--vl-primary-color)}:host ::ng-deep .container-box.selected:before{border-color:transparent}:host ::ng-deep .container-box.selected{border-color:var(--vl-primary-color)}:host ::ng-deep .hovered:before{display:block!important;position:absolute;content:\" \";top:-15px;bottom:15px;left:-15px;right:15px;border:1px solid var(--vl-primary-color)}:host ::ng-deep .hovered .box-action-button{opacity:1!important}:host ::ng-deep .opacity-1{opacity:1!important}:host ::ng-deep .overflow-y--auto{overflow-y:auto}:host ::ng-deep .gu-mirror{position:fixed!important;margin:0!important;z-index:9999!important;opacity:.8;-ms-filter:\"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)\";filter:alpha(opacity=80)}:host ::ng-deep .gu-hide{display:none!important}:host ::ng-deep .gu-unselectable{-webkit-user-select:none!important;-moz-user-select:none!important;-ms-user-select:none!important;user-select:none!important}:host ::ng-deep .gu-transit{opacity:.2;-ms-filter:\"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)\";filter:alpha(opacity=20)}:host ::ng-deep .top-nav-msg{margin-top:-30px}:host ::ng-deep .runtime-info-message ul{margin-bottom:0;list-style:none}:host ::ng-deep .runtime-info-message ul li{margin-bottom:10px}:host ::ng-deep .runtime-info-message ul li:last-child{margin-bottom:0}:host ::ng-deep .runtime-info-message .message-text{font-family:\"Open Sans\",Tahoma,sans-serif!important;overflow:hidden;padding:0;font-size:11px}:host ::ng-deep .runtime-attributes-popover .popover-arrow{display:none}:host ::ng-deep .runtime-attributes-popover .popover-content{padding:0}:host ::ng-deep .runtime-attributes-popover .runtime-content-wrapper{padding:0}:host ::ng-deep .runtime-attributes-popover .container-box-custom{margin-bottom:0}:host ::ng-deep .runtime-attributes-popover .input-form{margin:0;padding:0}:host ::ng-deep .runtime-attributes-popover .input-form form{margin-bottom:0}:host ::ng-deep .runtime-attributes-popover .input-form form .div-inline{display:block;float:none}:host ::ng-deep .runtime-attributes-popover .input-form form .form-group{padding:0;margin:0}:host ::ng-deep .runtime-attributes-popover .container-box .box-content{padding:0}:host ::ng-deep .v-custom-title,:host ::ng-deep .v-custom-description,:host ::ng-deep .v-custom-image{display:none}:host ::ng-deep .dropdown{position:relative}:host ::ng-deep .dropdown-toggle:focus{outline:0}:host ::ng-deep .dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;font-size:14px;text-align:left;list-style:none;background-color:#fff;background-clip:padding-box;border:1px solid #ccc;border:1px solid rgba(0,0,0,.15);border-radius:4px;box-shadow:0 6px 12px #0000002d}:host ::ng-deep .dropdown-menu.pull-right{right:0;left:auto}:host ::ng-deep .dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}:host ::ng-deep .dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:400;line-height:1.42857143;color:#333;white-space:nowrap}:host ::ng-deep .dropdown-menu>li>a:hover,:host ::ng-deep .dropdown-menu>li>a:focus{color:#262626;text-decoration:none;background-color:#f5f5f5}:host ::ng-deep .dropdown-menu>.active>a,:host ::ng-deep .dropdown-menu>.active>a:hover,:host ::ng-deep .dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;background-color:#337ab7;outline:0}:host ::ng-deep .dropdown-menu>.disabled>a,:host ::ng-deep .dropdown-menu>.disabled>a:hover,:host ::ng-deep .dropdown-menu>.disabled>a:focus{color:#777}:host ::ng-deep .dropdown-menu>.disabled>a:hover,:host ::ng-deep .dropdown-menu>.disabled>a:focus{text-decoration:none;cursor:not-allowed;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}:host ::ng-deep .open>.dropdown-menu{display:block}:host ::ng-deep .open>a{outline:0}:host ::ng-deep .dropdown-menu-right{right:0;left:auto}:host ::ng-deep .dropdown-menu-left{right:auto;left:0}:host ::ng-deep .dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.42857143;color:#777;white-space:nowrap}:host ::ng-deep .dropdown-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:990}\n", ":host{height:100%;display:flex;flex-direction:column}.sections-wrapper{flex-grow:1;display:flex;flex-direction:column}form{flex-grow:1;display:flex;flex-direction:column}.hidden{display:none}\n"], components: [{ type: i8.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }, { type: SectionRendererComponent, selector: "vl-section-renderer", inputs: ["section", "form"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i7.SidebarTabsDirective, selector: "[sidebarTabs]", inputs: ["sidebarTabs"], exportAs: ["sidebarTabs"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }], pipes: { "orderBy": i7.OrderByPipe } });
3697
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeComponent, decorators: [{
3698
+ type: Component,
3699
+ args: [{
3700
+ selector: 'vl-runtime',
3701
+ moduleId: module.id,
3702
+ templateUrl: 'runtime.component.html',
3703
+ styleUrls: ['./runtime-legacy-styles.scss', 'runtime.component.scss'],
3704
+ providers: [FormScopeService, CollapsibleStateService, OrderByPipe, SearchFilterPipe],
3705
+ }]
3706
+ }], ctorParameters: function () { return [{ type: SectionsService }, { type: FormScopeService }, { type: CollapsibleStateService }, { type: RuntimeFormService }, { type: RuntimeService }, { type: i3$1.MessageService, decorators: [{
3707
+ type: Inject,
3708
+ args: [MessageService]
3709
+ }] }, { type: i2.ContextService }, { type: i7.OrderByPipe }, { type: i7.SearchFilterPipe }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { solutionUpdated: [{
3710
+ type: Output
3711
+ }] } });
3712
+
3713
+ class RuntimePreviewComponent {
3714
+ constructor(runtimeService, modelCacheService, configurationApiService, contextService) {
3715
+ this.runtimeService = runtimeService;
3716
+ this.modelCacheService = modelCacheService;
3717
+ this.configurationApiService = configurationApiService;
3718
+ this.contextService = contextService;
3719
+ this.destroy$ = new Subject();
3720
+ }
3721
+ set uiDefinition(value) {
3722
+ this._uiDefinition = value;
3723
+ this.initDefinition(value);
3724
+ }
3725
+ ngOnInit() {
3726
+ if (!this.modelId) {
3727
+ return;
3728
+ }
3729
+ this.modelCacheService
3730
+ .getProductModel(this.modelId)
3731
+ .pipe(takeUntil(this.destroy$))
3732
+ .subscribe(container => {
3733
+ this.productModelContainer = container;
3734
+ if (this._uiDefinition) {
3735
+ this.initDefinition(this._uiDefinition);
3736
+ }
3737
+ });
3738
+ }
3739
+ ngOnDestroy() {
3740
+ this.destroy$.next();
3741
+ this.destroy$.complete();
3742
+ }
3743
+ initDefinition(uiDefinition) {
3744
+ if (!this.productModelContainer) {
3745
+ return;
3746
+ }
3747
+ const initialisedUiDefinition = EntityUtil.clone(uiDefinition);
3748
+ const externals = this.productModelContainer.main.externals;
3749
+ if (externals) {
3750
+ initialisedUiDefinition.externals = externals.reduce((trunk, variable) => {
3751
+ var _a, _b;
3752
+ return Object.assign(Object.assign({}, trunk), { [variable.name]: (_b = (_a = initialisedUiDefinition.externals) === null || _a === void 0 ? void 0 : _a[variable.name]) !== null && _b !== void 0 ? _b : '' });
3753
+ }, {});
3754
+ }
3755
+ else {
3756
+ delete initialisedUiDefinition.externals;
3757
+ }
3758
+ this.initialisedUiDefinition = initialisedUiDefinition;
3759
+ this.launchRuntime();
3760
+ }
3761
+ onSolutionUpdated(lineItem) {
3762
+ this.runtimeService.updateRuntime({ configurableRamp: lineItem });
3763
+ }
3764
+ launchRuntime() {
3765
+ if (!this.modelId || !this.initialisedUiDefinition) {
3766
+ return;
3767
+ }
3768
+ SectionPathUtil.updateSectionsPath(this.initialisedUiDefinition.sections);
3769
+ const uiDefinition = EntityUtil.clone(this.initialisedUiDefinition);
3770
+ combineLatest([
3771
+ this.configurationApiService.getRuntimeDataByModelId(this.modelId),
3772
+ this.contextService.create('TestId', ConfigurationContextMode.TEST),
3773
+ ]).subscribe(([runtimeData]) => {
3774
+ var _a;
3775
+ const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
3776
+ const rootType = Array.from(runtimeModel.components.values()).find(c => uiDefinition.rootType &&
3777
+ runtimeModel.isEquals(c.typeName, uiDefinition.rootType) &&
3778
+ EntityUtil.isPresent(c.productId));
3779
+ if (rootType === null || rootType === void 0 ? void 0 : rootType.typeName) {
3780
+ uiDefinition.rootType = rootType.typeName;
3781
+ }
3782
+ const contextProductId = rootType ? rootType.productId : undefined;
3783
+ const context = {
3784
+ modelId: (_a = this.modelId) !== null && _a !== void 0 ? _a : '',
3785
+ uiDefinition: uiDefinition,
3786
+ runtimeModel,
3787
+ runtimeMode: RuntimeMode.TEST,
3788
+ productId: contextProductId,
3789
+ properties: uiDefinition.externals,
3790
+ };
3791
+ this.runtimeService.startRuntime(context, {});
3792
+ });
3793
+ }
3794
+ }
3795
+ RuntimePreviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimePreviewComponent, deps: [{ token: RuntimeService }, { token: ProductModelCacheService }, { token: i1.ConfigurationApiService }, { token: i2.ContextService }], target: i0.ɵɵFactoryTarget.Component });
3796
+ RuntimePreviewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: RuntimePreviewComponent, selector: "vl-runtime-preview", inputs: { modelId: "modelId", uiDefinition: "uiDefinition" }, ngImport: i0, template: "<vl-runtime (solutionUpdated)=\"onSolutionUpdated($event)\"></vl-runtime>\n", styles: [":host{flex-grow:1}\n"], components: [{ type: RuntimeComponent, selector: "vl-runtime", outputs: ["solutionUpdated"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
3797
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimePreviewComponent, decorators: [{
3798
+ type: Component,
3799
+ args: [{
3800
+ selector: 'vl-runtime-preview',
3801
+ templateUrl: 'runtime-preview.component.html',
3802
+ styleUrls: ['runtime-preview.component.scss'],
3803
+ changeDetection: ChangeDetectionStrategy.OnPush,
3804
+ }]
3805
+ }], ctorParameters: function () { return [{ type: RuntimeService }, { type: ProductModelCacheService }, { type: i1.ConfigurationApiService }, { type: i2.ContextService }]; }, propDecorators: { modelId: [{
3806
+ type: Input
3807
+ }], uiDefinition: [{
3808
+ type: Input
3809
+ }] } });
3810
+
3811
+ class RuntimeModule {
3812
+ }
3813
+ RuntimeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3814
+ RuntimeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeModule, declarations: [RuntimeComponent, RuntimePreviewComponent, SectionRendererComponent, ComponentPreviewComponent], imports: [CommonModule,
3815
+ FormsModule,
3816
+ ReactiveFormsModule,
3817
+ CoreModule,
3818
+ ApiModule,
3819
+ VeloceElementsModule,
3820
+ PopoverModule,
3821
+ LoaderModule,
3822
+ SdkCoreModule], exports: [FormsModule,
3823
+ ReactiveFormsModule,
3824
+ RuntimeComponent,
3825
+ RuntimePreviewComponent,
3826
+ SectionRendererComponent,
3827
+ ComponentPreviewComponent] });
3828
+ RuntimeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeModule, providers: [
3829
+ ShoppingCartService,
3830
+ RuntimeService,
3831
+ ConfigurationService,
3832
+ RuntimeContextService,
3833
+ RuntimeFormService,
3834
+ CurrentStateService,
3835
+ ProductModelCacheService,
3836
+ DatePipe,
3837
+ SectionsService,
3838
+ SectionStoreService,
3839
+ DialogService,
3840
+ ], imports: [[
3841
+ CommonModule,
3842
+ FormsModule,
3843
+ ReactiveFormsModule,
3844
+ CoreModule,
3845
+ ApiModule,
3846
+ VeloceElementsModule,
3847
+ PopoverModule,
3848
+ LoaderModule,
3849
+ SdkCoreModule,
3850
+ ], FormsModule,
3851
+ ReactiveFormsModule] });
3852
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RuntimeModule, decorators: [{
3853
+ type: NgModule,
3854
+ args: [{
3855
+ declarations: [RuntimeComponent, RuntimePreviewComponent, SectionRendererComponent, ComponentPreviewComponent],
3856
+ providers: [
3857
+ ShoppingCartService,
3858
+ RuntimeService,
3859
+ ConfigurationService,
3860
+ RuntimeContextService,
3861
+ RuntimeFormService,
3862
+ CurrentStateService,
3863
+ ProductModelCacheService,
3864
+ DatePipe,
3865
+ SectionsService,
3866
+ SectionStoreService,
3867
+ DialogService,
3868
+ ],
3869
+ imports: [
3870
+ CommonModule,
3871
+ FormsModule,
3872
+ ReactiveFormsModule,
3873
+ CoreModule,
3874
+ ApiModule,
3875
+ VeloceElementsModule,
3876
+ PopoverModule,
3877
+ LoaderModule,
3878
+ SdkCoreModule,
3879
+ ],
3880
+ exports: [
3881
+ FormsModule,
3882
+ ReactiveFormsModule,
3883
+ RuntimeComponent,
3884
+ RuntimePreviewComponent,
3885
+ SectionRendererComponent,
3886
+ ComponentPreviewComponent,
3887
+ ],
3888
+ }]
3889
+ }] });
3890
+
3891
+ /**
3892
+ * Generated bundle index. Do not edit.
3893
+ */
3894
+
3895
+ export { ComponentPreviewComponent, CurrentStateService, RuntimeComponent, RuntimeContextService, RuntimeModule, RuntimePreviewComponent, RuntimeService, SectionRendererComponent };
3896
+ //# sourceMappingURL=veloceapps-sdk-runtime.js.map