@flarehr/apollo-benefits 0.1.106 → 0.3.53396

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 (219) hide show
  1. package/README.md +19 -0
  2. package/dist/assets/@splitsoftware-7d799540.js +18 -0
  3. package/dist/assets/all_tab_color-548783b9.svg +21 -0
  4. package/dist/assets/all_tab_gray-a5051313.svg +6 -0
  5. package/dist/assets/check-57fe1dcb.svg +15 -0
  6. package/dist/assets/datadog-c7ede347.js +5 -0
  7. package/dist/assets/date-fns-c5d8fbc0.js +1 -0
  8. package/dist/assets/default_backdrop-fdd955b8.png +0 -0
  9. package/dist/assets/external_link-599a0aec.svg +3 -0
  10. package/dist/assets/external_link_white-55111b2e.svg +3 -0
  11. package/dist/assets/framer-motion-bb8d6b82.js +1 -0
  12. package/dist/assets/index-87923fdc.js +35 -0
  13. package/dist/assets/index-cfa25e28.css +1 -0
  14. package/dist/assets/index-ee9d2045.js +5 -0
  15. package/dist/assets/lodash-5d893f8c.js +1 -0
  16. package/dist/assets/logo-a34e9b4b.png +0 -0
  17. package/dist/assets/oidc-client-6f6e47c2.js +101 -0
  18. package/dist/assets/padlock-8c081120.svg +26 -0
  19. package/dist/assets/suitcase-6471ad05.svg +17 -0
  20. package/dist/assets/vendor-2d0139ca.js +788 -0
  21. package/dist/assets/warning-a7f1af23.svg +14 -0
  22. package/dist/assets/welcome_image_mobile-dbde6c80.png +0 -0
  23. package/dist/assets/welcome_image_v2-869c59e4.png +0 -0
  24. package/dist/assets/wellbeing_banner-6903d615.png +0 -0
  25. package/dist/assets/workplace_link_banner_mobile-6ebaa24b.png +0 -0
  26. package/dist/assets/workplace_link_banner_v2-c81ed849.png +0 -0
  27. package/dist/config.json +14 -0
  28. package/dist/favicon.ico +0 -0
  29. package/dist/icons/android-chrome-192x192.png +0 -0
  30. package/dist/icons/android-chrome-512x512.png +0 -0
  31. package/dist/icons/apple-touch-icon.png +0 -0
  32. package/dist/icons/favicon-16x16.png +0 -0
  33. package/dist/icons/favicon-32x32.png +0 -0
  34. package/dist/index.html +114 -0
  35. package/dist/manifest.json +21 -0
  36. package/dist/sw-esm.js +16 -0
  37. package/package.json +129 -60
  38. package/LICENSE +0 -21
  39. package/dist/lib/apollo-benefits/apollo-benefits.esm.js +0 -1
  40. package/dist/lib/apollo-benefits/assets/car-placeholder.svg +0 -5
  41. package/dist/lib/apollo-benefits/assets/check.svg +0 -13
  42. package/dist/lib/apollo-benefits/index.esm.js +0 -0
  43. package/dist/lib/apollo-benefits/p-06a1f65f.js +0 -1
  44. package/dist/lib/apollo-benefits/p-077d7f8d.entry.js +0 -1
  45. package/dist/lib/apollo-benefits/p-0a21a709.entry.js +0 -1
  46. package/dist/lib/apollo-benefits/p-14054f15.js +0 -1
  47. package/dist/lib/apollo-benefits/p-24a37d64.js +0 -1
  48. package/dist/lib/apollo-benefits/p-2b3f3b72.entry.js +0 -1
  49. package/dist/lib/apollo-benefits/p-3111d565.entry.js +0 -1
  50. package/dist/lib/apollo-benefits/p-327396fa.entry.js +0 -1
  51. package/dist/lib/apollo-benefits/p-3af26279.entry.js +0 -1
  52. package/dist/lib/apollo-benefits/p-3d4d2683.js +0 -1
  53. package/dist/lib/apollo-benefits/p-4474bcf8.entry.js +0 -1
  54. package/dist/lib/apollo-benefits/p-50fe790f.js +0 -1
  55. package/dist/lib/apollo-benefits/p-53bcbd1d.js +0 -1
  56. package/dist/lib/apollo-benefits/p-64a2b03a.entry.js +0 -1
  57. package/dist/lib/apollo-benefits/p-68c136da.js +0 -1
  58. package/dist/lib/apollo-benefits/p-6bd16f5b.js +0 -1
  59. package/dist/lib/apollo-benefits/p-71dbc8ff.entry.js +0 -1
  60. package/dist/lib/apollo-benefits/p-774d9bc5.entry.js +0 -1
  61. package/dist/lib/apollo-benefits/p-7a2ca86d.entry.js +0 -1
  62. package/dist/lib/apollo-benefits/p-7a572b50.js +0 -1
  63. package/dist/lib/apollo-benefits/p-7c2cd94a.entry.js +0 -1
  64. package/dist/lib/apollo-benefits/p-839493d7.entry.js +0 -1
  65. package/dist/lib/apollo-benefits/p-acf61bdc.js +0 -1
  66. package/dist/lib/apollo-benefits/p-b33fc683.js +0 -1
  67. package/dist/lib/apollo-benefits/p-beb8f728.entry.js +0 -1
  68. package/dist/lib/apollo-benefits/p-d7bea1d9.entry.js +0 -1
  69. package/dist/lib/apollo-benefits/p-ddb176cb.entry.js +0 -1
  70. package/dist/lib/apollo-benefits/p-e241f55b.entry.js +0 -1
  71. package/dist/lib/apollo-benefits/p-ef8ea713.entry.js +0 -1
  72. package/dist/lib/apollo-benefits/p-f603197d.js +0 -15
  73. package/dist/lib/cjs/active-router-0ecaf2b8.js +0 -75
  74. package/dist/lib/cjs/ap-ben-choose-vehicle-section_4.cjs.entry.js +0 -2684
  75. package/dist/lib/cjs/ap-ben-complete-section_4.cjs.entry.js +0 -108
  76. package/dist/lib/cjs/ap-ben-notifications-section.cjs.entry.js +0 -238
  77. package/dist/lib/cjs/apollo-benefits.cjs.js +0 -25
  78. package/dist/lib/cjs/app-globals-67583b8b.js +0 -12
  79. package/dist/lib/cjs/async-6a7926f0.js +0 -753
  80. package/dist/lib/cjs/cars-calculator-app.cjs.entry.js +0 -52
  81. package/dist/lib/cjs/cars-calculator.service-11b0cd88.js +0 -901
  82. package/dist/lib/cjs/context-consumer.cjs.entry.js +0 -29
  83. package/dist/lib/cjs/datorama-akita-31d23240.js +0 -2551
  84. package/dist/lib/cjs/delay-d31618c3.js +0 -206
  85. package/dist/lib/cjs/distinctUntilChanged-e8538790.js +0 -371
  86. package/dist/lib/cjs/dom-utils-b8befdd5.js +0 -63
  87. package/dist/lib/cjs/fl-button.cjs.entry.js +0 -30
  88. package/dist/lib/cjs/fl-dropdown-async_2.cjs.entry.js +0 -467
  89. package/dist/lib/cjs/fl-dropdown.cjs.entry.js +0 -232
  90. package/dist/lib/cjs/fl-loading-indicator.cjs.entry.js +0 -26
  91. package/dist/lib/cjs/fl-style-guide.cjs.entry.js +0 -91
  92. package/dist/lib/cjs/index-f1fadf90.js +0 -1735
  93. package/dist/lib/cjs/index.cjs.js +0 -2
  94. package/dist/lib/cjs/loader.cjs.js +0 -27
  95. package/dist/lib/cjs/location-utils-36fe7e5e.js +0 -237
  96. package/dist/lib/cjs/match-path-be4ea5f6.js +0 -279
  97. package/dist/lib/cjs/session.query-d61ba7ec.js +0 -1731
  98. package/dist/lib/cjs/stencil-async-content.cjs.entry.js +0 -32
  99. package/dist/lib/cjs/stencil-route-link.cjs.entry.js +0 -78
  100. package/dist/lib/cjs/stencil-route-switch.cjs.entry.js +0 -104
  101. package/dist/lib/cjs/stencil-route-title.cjs.entry.js +0 -32
  102. package/dist/lib/cjs/stencil-route.cjs.entry.js +0 -97
  103. package/dist/lib/cjs/stencil-router-prompt.cjs.entry.js +0 -59
  104. package/dist/lib/cjs/stencil-router-redirect.cjs.entry.js +0 -32
  105. package/dist/lib/cjs/stencil-router.cjs.entry.js +0 -640
  106. package/dist/lib/collection/assets/image/complete.svg +0 -122
  107. package/dist/lib/collection/collection-manifest.json +0 -53
  108. package/dist/lib/collection/components/cars-calculator-app/api/api-client.js +0 -5
  109. package/dist/lib/collection/components/cars-calculator-app/api/cars-calculator.api.js +0 -45
  110. package/dist/lib/collection/components/cars-calculator-app/cars-calculator-app.css +0 -22
  111. package/dist/lib/collection/components/cars-calculator-app/cars-calculator-app.js +0 -93
  112. package/dist/lib/collection/components/cars-calculator-app/modal-section/modal-section.css +0 -0
  113. package/dist/lib/collection/components/cars-calculator-app/modal-section/modal-section.js +0 -144
  114. package/dist/lib/collection/components/cars-calculator-app/notifications-section/notifications-section.js +0 -25
  115. package/dist/lib/collection/components/cars-calculator-app/pages/assets/car-placeholder.svg +0 -5
  116. package/dist/lib/collection/components/cars-calculator-app/pages/assets/check.svg +0 -13
  117. package/dist/lib/collection/components/cars-calculator-app/pages/choose-vehicle-section.component.js +0 -193
  118. package/dist/lib/collection/components/cars-calculator-app/pages/complete-section.component.js +0 -38
  119. package/dist/lib/collection/components/cars-calculator-app/pages/cost-breakdown-section.component.js +0 -47
  120. package/dist/lib/collection/components/cars-calculator-app/pages/model-variants-section.component.css +0 -34
  121. package/dist/lib/collection/components/cars-calculator-app/pages/model-variants-section.component.js +0 -64
  122. package/dist/lib/collection/components/cars-calculator-app/pages/personal-info-section.component.js +0 -66
  123. package/dist/lib/collection/components/cars-calculator-app/pages/quote-result-section.component.js +0 -86
  124. package/dist/lib/collection/components/cars-calculator-app/pages/submit-quote-section.component.js +0 -75
  125. package/dist/lib/collection/components/cars-calculator-app/services/app-configuration.service.js +0 -13
  126. package/dist/lib/collection/components/cars-calculator-app/services/cars-calculator.service.js +0 -103
  127. package/dist/lib/collection/components/cars-calculator-app/services/notifications.service.js +0 -37
  128. package/dist/lib/collection/components/cars-calculator-app/services/notifications.store.js +0 -3
  129. package/dist/lib/collection/components/cars-calculator-app/services/session.query.js +0 -35
  130. package/dist/lib/collection/components/cars-calculator-app/services/session.store.js +0 -78
  131. package/dist/lib/collection/global/config.js +0 -2
  132. package/dist/lib/collection/global/main.dev.js +0 -5
  133. package/dist/lib/collection/global/main.js +0 -5
  134. package/dist/lib/collection/index.js +0 -2
  135. package/dist/lib/collection/utils/config.js +0 -2
  136. package/dist/lib/collection/utils/index.js +0 -15
  137. package/dist/lib/collection/utils/lazy.js +0 -29
  138. package/dist/lib/esm/active-router-7c2ca849.js +0 -73
  139. package/dist/lib/esm/ap-ben-choose-vehicle-section_4.entry.js +0 -2677
  140. package/dist/lib/esm/ap-ben-complete-section_4.entry.js +0 -101
  141. package/dist/lib/esm/ap-ben-notifications-section.entry.js +0 -234
  142. package/dist/lib/esm/apollo-benefits.js +0 -23
  143. package/dist/lib/esm/app-globals-65714cca.js +0 -10
  144. package/dist/lib/esm/async-68e9cad7.js +0 -738
  145. package/dist/lib/esm/cars-calculator-app.entry.js +0 -48
  146. package/dist/lib/esm/cars-calculator.service-2cde6288.js +0 -894
  147. package/dist/lib/esm/context-consumer.entry.js +0 -25
  148. package/dist/lib/esm/datorama-akita-c87196a0.js +0 -2545
  149. package/dist/lib/esm/delay-115d4292.js +0 -200
  150. package/dist/lib/esm/distinctUntilChanged-bf69e0f8.js +0 -363
  151. package/dist/lib/esm/dom-utils-109a7d75.js +0 -55
  152. package/dist/lib/esm/fl-button.entry.js +0 -26
  153. package/dist/lib/esm/fl-dropdown-async_2.entry.js +0 -462
  154. package/dist/lib/esm/fl-dropdown.entry.js +0 -228
  155. package/dist/lib/esm/fl-loading-indicator.entry.js +0 -22
  156. package/dist/lib/esm/fl-style-guide.entry.js +0 -87
  157. package/dist/lib/esm/index-19c4d245.js +0 -1703
  158. package/dist/lib/esm/index.js +0 -1
  159. package/dist/lib/esm/loader.js +0 -23
  160. package/dist/lib/esm/location-utils-312665d3.js +0 -226
  161. package/dist/lib/esm/match-path-4b5c7d98.js +0 -276
  162. package/dist/lib/esm/polyfills/core-js.js +0 -11
  163. package/dist/lib/esm/polyfills/css-shim.js +0 -1
  164. package/dist/lib/esm/polyfills/dom.js +0 -79
  165. package/dist/lib/esm/polyfills/es5-html-element.js +0 -1
  166. package/dist/lib/esm/polyfills/index.js +0 -34
  167. package/dist/lib/esm/polyfills/system.js +0 -6
  168. package/dist/lib/esm/session.query-0f1c9503.js +0 -1719
  169. package/dist/lib/esm/stencil-async-content.entry.js +0 -28
  170. package/dist/lib/esm/stencil-route-link.entry.js +0 -74
  171. package/dist/lib/esm/stencil-route-switch.entry.js +0 -100
  172. package/dist/lib/esm/stencil-route-title.entry.js +0 -28
  173. package/dist/lib/esm/stencil-route.entry.js +0 -93
  174. package/dist/lib/esm/stencil-router-prompt.entry.js +0 -55
  175. package/dist/lib/esm/stencil-router-redirect.entry.js +0 -28
  176. package/dist/lib/esm/stencil-router.entry.js +0 -636
  177. package/dist/lib/index.cjs.js +0 -1
  178. package/dist/lib/index.js +0 -1
  179. package/dist/lib/loader/cdn.js +0 -3
  180. package/dist/lib/loader/index.cjs.js +0 -3
  181. package/dist/lib/loader/index.d.ts +0 -13
  182. package/dist/lib/loader/index.es2017.js +0 -3
  183. package/dist/lib/loader/index.js +0 -4
  184. package/dist/lib/loader/package.json +0 -10
  185. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/button/button.css +0 -45
  186. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/dropdown/dropdown.css +0 -9
  187. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/dropdown-async/dropdown-async.css +0 -9
  188. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/loading-indicator/loading-indicator.css +0 -141
  189. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/promise-button/promise-button.css +0 -5
  190. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/style-guide/style-guide.css +0 -0
  191. package/dist/lib/node_modules/@stencil/router/dist/collection/components/route/route.css +0 -3
  192. package/dist/lib/types/components/cars-calculator-app/api/api-client.d.ts +0 -2
  193. package/dist/lib/types/components/cars-calculator-app/api/cars-calculator.api.d.ts +0 -96
  194. package/dist/lib/types/components/cars-calculator-app/cars-calculator-app.d.ts +0 -15
  195. package/dist/lib/types/components/cars-calculator-app/modal-section/modal-section.d.ts +0 -16
  196. package/dist/lib/types/components/cars-calculator-app/notifications-section/notifications-section.d.ts +0 -5
  197. package/dist/lib/types/components/cars-calculator-app/pages/choose-vehicle-section.component.d.ts +0 -23
  198. package/dist/lib/types/components/cars-calculator-app/pages/complete-section.component.d.ts +0 -5
  199. package/dist/lib/types/components/cars-calculator-app/pages/cost-breakdown-section.component.d.ts +0 -6
  200. package/dist/lib/types/components/cars-calculator-app/pages/model-variants-section.component.d.ts +0 -12
  201. package/dist/lib/types/components/cars-calculator-app/pages/personal-info-section.component.d.ts +0 -10
  202. package/dist/lib/types/components/cars-calculator-app/pages/quote-result-section.component.d.ts +0 -13
  203. package/dist/lib/types/components/cars-calculator-app/pages/submit-quote-section.component.d.ts +0 -10
  204. package/dist/lib/types/components/cars-calculator-app/services/app-configuration.service.d.ts +0 -7
  205. package/dist/lib/types/components/cars-calculator-app/services/cars-calculator.service.d.ts +0 -11
  206. package/dist/lib/types/components/cars-calculator-app/services/notifications.service.d.ts +0 -15
  207. package/dist/lib/types/components/cars-calculator-app/services/notifications.store.d.ts +0 -14
  208. package/dist/lib/types/components/cars-calculator-app/services/session.query.d.ts +0 -25
  209. package/dist/lib/types/components/cars-calculator-app/services/session.store.d.ts +0 -74
  210. package/dist/lib/types/components.d.ts +0 -170
  211. package/dist/lib/types/global/config.d.ts +0 -2
  212. package/dist/lib/types/global/main.d.ts +0 -1
  213. package/dist/lib/types/global/main.dev.d.ts +0 -1
  214. package/dist/lib/types/index.d.ts +0 -2
  215. package/dist/lib/types/stencil-public-runtime.d.ts +0 -1555
  216. package/dist/lib/types/utils/config.d.ts +0 -2
  217. package/dist/lib/types/utils/index.d.ts +0 -7
  218. package/dist/lib/types/utils/lazy.d.ts +0 -12
  219. package/readme.md +0 -1
@@ -1,901 +0,0 @@
1
- 'use strict';
2
-
3
- const session_query = require('./session.query-d61ba7ec.js');
4
-
5
- /**
6
- * @since 2.0.0
7
- */
8
- function pipe(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no, op, pq, qr, rs, st) {
9
- switch (arguments.length) {
10
- case 1:
11
- return a;
12
- case 2:
13
- return ab(a);
14
- case 3:
15
- return bc(ab(a));
16
- case 4:
17
- return cd(bc(ab(a)));
18
- case 5:
19
- return de(cd(bc(ab(a))));
20
- case 6:
21
- return ef(de(cd(bc(ab(a)))));
22
- case 7:
23
- return fg(ef(de(cd(bc(ab(a))))));
24
- case 8:
25
- return gh(fg(ef(de(cd(bc(ab(a)))))));
26
- case 9:
27
- return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
28
- case 10:
29
- return ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))));
30
- case 11:
31
- return jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))));
32
- case 12:
33
- return kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))));
34
- case 13:
35
- return lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))));
36
- case 14:
37
- return mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))));
38
- case 15:
39
- return no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))));
40
- case 16:
41
- return op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))));
42
- case 17:
43
- return pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))));
44
- case 18:
45
- return qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))));
46
- case 19:
47
- return rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))))));
48
- case 20:
49
- return st(rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))))));
50
- }
51
- return;
52
- }
53
-
54
- // TODO: remove module in v3
55
- /**
56
- * Use [`pipe`](https://gcanti.github.io/fp-ts/modules/function.ts.html#flow) from `function` module instead.
57
- *
58
- * @since 2.0.0
59
- */
60
- var pipe$1 = pipe;
61
-
62
- function getOrDefault(option, value) {
63
- return pipe$1(option, session_query.getOrElse(() => value));
64
- }
65
- function getOrError(option) {
66
- return pipe$1(option, session_query.getOrElse(() => {
67
- throw new Error('Option value is none.');
68
- }));
69
- }
70
- function toSelectInputOptionsArray(list) {
71
- return list.map((s) => ({ label: String(s), value: s }));
72
- }
73
-
74
- var __assign = (undefined && undefined.__assign) || function () {
75
- __assign = Object.assign || function(t) {
76
- for (var s, i = 1, n = arguments.length; i < n; i++) {
77
- s = arguments[i];
78
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
79
- t[p] = s[p];
80
- }
81
- return t;
82
- };
83
- return __assign.apply(this, arguments);
84
- };
85
- var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
86
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
87
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
88
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
89
- r[k] = a[j];
90
- return r;
91
- };
92
- var mix = function (one, two, mergeArrays) {
93
- if (mergeArrays === void 0) { mergeArrays = false; }
94
- if (!one || !two || typeof one !== "object" || typeof two !== "object")
95
- return one;
96
- var clone = __assign({}, one);
97
- for (var prop in two) {
98
- if (two.hasOwnProperty(prop)) {
99
- if (two[prop] instanceof Array && one[prop] instanceof Array) {
100
- clone[prop] = mergeArrays ? __spreadArrays(one[prop], two[prop]) : two[prop];
101
- }
102
- else if (typeof two[prop] === "object" && typeof one[prop] === "object") {
103
- clone[prop] = mix(one[prop], two[prop], mergeArrays);
104
- }
105
- else {
106
- clone[prop] = two[prop];
107
- }
108
- }
109
- }
110
- return clone;
111
- };
112
-
113
- var __spreadArrays$1 = (undefined && undefined.__spreadArrays) || function () {
114
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
115
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
116
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
117
- r[k] = a[j];
118
- return r;
119
- };
120
- var config = {
121
- // Default options
122
- defaults: {},
123
- // Error type
124
- errorType: null,
125
- // Polyfills
126
- polyfills: {
127
- fetch: null,
128
- FormData: null,
129
- URLSearchParams: null,
130
- performance: null,
131
- PerformanceObserver: null,
132
- AbortController: null
133
- },
134
- polyfill: function (p, _a) {
135
- var _b = _a === void 0 ? {} : _a, _c = _b.doThrow, doThrow = _c === void 0 ? true : _c, _d = _b.instance, instance = _d === void 0 ? false : _d;
136
- var args = [];
137
- for (var _i = 2; _i < arguments.length; _i++) {
138
- args[_i - 2] = arguments[_i];
139
- }
140
- var res = this.polyfills[p] ||
141
- (typeof self !== "undefined" ? self[p] : null) ||
142
- (typeof global !== "undefined" ? global[p] : null);
143
- if (doThrow && !res)
144
- throw new Error(p + " is not defined");
145
- return instance && res ? new (res.bind.apply(res, __spreadArrays$1([void 0], args)))() : res;
146
- }
147
- };
148
-
149
- var onMatch = function (entries, name, callback, _performance) {
150
- if (!entries.getEntriesByName)
151
- return false;
152
- var matches = entries.getEntriesByName(name);
153
- if (matches && matches.length > 0) {
154
- callback(matches.reverse()[0]);
155
- if (_performance.clearMeasures)
156
- _performance.clearMeasures(name);
157
- perfs.callbacks.delete(name);
158
- if (perfs.callbacks.size < 1) {
159
- perfs.observer.disconnect();
160
- if (_performance.clearResourceTimings) {
161
- _performance.clearResourceTimings();
162
- }
163
- }
164
- return true;
165
- }
166
- return false;
167
- };
168
- var lazyObserver = function (_performance, _observer) {
169
- if (!perfs.observer && _performance && _observer) {
170
- perfs.observer = new _observer(function (entries) {
171
- perfs.callbacks.forEach(function (callback, name) {
172
- onMatch(entries, name, callback, _performance);
173
- });
174
- });
175
- if (_performance.clearResourceTimings)
176
- _performance.clearResourceTimings();
177
- }
178
- return perfs.observer;
179
- };
180
- var perfs = {
181
- callbacks: new Map(),
182
- observer: null,
183
- observe: function (name, callback) {
184
- if (!name || !callback)
185
- return;
186
- var _performance = config.polyfill("performance", { doThrow: false });
187
- var _observer = config.polyfill("PerformanceObserver", { doThrow: false });
188
- if (!lazyObserver(_performance, _observer))
189
- return;
190
- if (!onMatch(_performance, name, callback, _performance)) {
191
- if (perfs.callbacks.size < 1)
192
- perfs.observer.observe({ entryTypes: ["resource", "measure"] });
193
- perfs.callbacks.set(name, callback);
194
- }
195
- }
196
- };
197
-
198
- var middlewareHelper = function (middlewares) { return function (fetchFunction) {
199
- return (middlewares.length === 0 ?
200
- fetchFunction :
201
- middlewares.length === 1 ?
202
- middlewares[0](fetchFunction) :
203
- middlewares.reduceRight(function (acc, curr, idx) {
204
- return (idx === middlewares.length - 2) ? curr(acc(fetchFunction)) : curr(acc);
205
- }));
206
- }; };
207
-
208
- var WretchErrorWrapper = /** @class */ (function () {
209
- function WretchErrorWrapper(error) {
210
- this.error = error;
211
- }
212
- return WretchErrorWrapper;
213
- }());
214
- var resolver = function (wretcher) {
215
- var url = wretcher._url, _catchers = wretcher._catchers, resolvers = wretcher._resolvers, middlewares = wretcher._middlewares, opts = wretcher._options;
216
- var catchers = new Map(_catchers);
217
- var finalOptions = mix(config.defaults, opts);
218
- var fetchController = config.polyfill("AbortController", { doThrow: false, instance: true });
219
- if (!finalOptions["signal"] && fetchController) {
220
- finalOptions["signal"] = fetchController.signal;
221
- }
222
- // Request timeout
223
- var timeout = {
224
- ref: null,
225
- clear: function () {
226
- if (timeout.ref) {
227
- clearTimeout(timeout.ref);
228
- timeout.ref = null;
229
- }
230
- }
231
- };
232
- // The generated fetch request
233
- var fetchRequest = middlewareHelper(middlewares)(config.polyfill("fetch"))(url, finalOptions);
234
- // Throws on an http error
235
- var throwingPromise = fetchRequest
236
- .catch(function (error) {
237
- throw new WretchErrorWrapper(error);
238
- })
239
- .then(function (response) {
240
- timeout.clear();
241
- if (!response.ok) {
242
- return response[config.errorType || "text"]().then(function (msg) {
243
- // Enhances the error object
244
- var err = new Error(msg);
245
- err[config.errorType || "text"] = msg;
246
- err["status"] = response.status;
247
- err["response"] = response;
248
- throw err;
249
- });
250
- }
251
- return response;
252
- });
253
- // Wraps the Promise in order to dispatch the error to a matching catcher
254
- var catchersWrapper = function (promise) {
255
- return promise.catch(function (err) {
256
- timeout.clear();
257
- var error = err instanceof WretchErrorWrapper ? err.error : err;
258
- if (err instanceof WretchErrorWrapper && catchers.has("__fromFetch"))
259
- return catchers.get("__fromFetch")(error, wretcher);
260
- else if (catchers.has(error.status))
261
- return catchers.get(error.status)(error, wretcher);
262
- else if (catchers.has(error.name))
263
- return catchers.get(error.name)(error, wretcher);
264
- else
265
- throw error;
266
- });
267
- };
268
- var bodyParser = function (funName) { return function (cb) { return funName ?
269
- // If a callback is provided, then callback with the body result otherwise return the parsed body itself.
270
- catchersWrapper(throwingPromise.then(function (_) { return _ && _[funName](); }).then(function (_) { return cb ? cb(_) : _; })) :
271
- // No body parsing method - return the response
272
- catchersWrapper(throwingPromise.then(function (_) { return cb ? cb(_) : _; })); }; };
273
- var responseChain = {
274
- /**
275
- * Retrieves the raw result as a promise.
276
- */
277
- res: bodyParser(null),
278
- /**
279
- * Retrieves the result as a parsed JSON object.
280
- */
281
- json: bodyParser("json"),
282
- /**
283
- * Retrieves the result as a Blob object.
284
- */
285
- blob: bodyParser("blob"),
286
- /**
287
- * Retrieves the result as a FormData object.
288
- */
289
- formData: bodyParser("formData"),
290
- /**
291
- * Retrieves the result as an ArrayBuffer object.
292
- */
293
- arrayBuffer: bodyParser("arrayBuffer"),
294
- /**
295
- * Retrieves the result as a string.
296
- */
297
- text: bodyParser("text"),
298
- /**
299
- * Performs a callback on the API performance timings of the request.
300
- *
301
- * Warning: Still experimental on browsers and node.js
302
- */
303
- perfs: function (cb) {
304
- fetchRequest.then(function (res) { return perfs.observe(res.url, cb); });
305
- return responseChain;
306
- },
307
- /**
308
- * Aborts the request after a fixed time.
309
- *
310
- * @param time Time in milliseconds
311
- * @param controller A custom controller
312
- */
313
- setTimeout: function (time, controller) {
314
- if (controller === void 0) { controller = fetchController; }
315
- timeout.clear();
316
- timeout.ref = setTimeout(function () { return controller.abort(); }, time);
317
- return responseChain;
318
- },
319
- /**
320
- * Returns the automatically generated AbortController alongside the current wretch response as a pair.
321
- */
322
- controller: function () { return [fetchController, responseChain]; },
323
- /**
324
- * Catches an http response with a specific error code or name and performs a callback.
325
- */
326
- error: function (errorId, cb) {
327
- catchers.set(errorId, cb);
328
- return responseChain;
329
- },
330
- /**
331
- * Catches a bad request (http code 400) and performs a callback.
332
- */
333
- badRequest: function (cb) { return responseChain.error(400, cb); },
334
- /**
335
- * Catches an unauthorized request (http code 401) and performs a callback.
336
- */
337
- unauthorized: function (cb) { return responseChain.error(401, cb); },
338
- /**
339
- * Catches a forbidden request (http code 403) and performs a callback.
340
- */
341
- forbidden: function (cb) { return responseChain.error(403, cb); },
342
- /**
343
- * Catches a "not found" request (http code 404) and performs a callback.
344
- */
345
- notFound: function (cb) { return responseChain.error(404, cb); },
346
- /**
347
- * Catches a timeout (http code 408) and performs a callback.
348
- */
349
- timeout: function (cb) { return responseChain.error(408, cb); },
350
- /**
351
- * Catches an internal server error (http code 500) and performs a callback.
352
- */
353
- internalError: function (cb) { return responseChain.error(500, cb); },
354
- /**
355
- * Catches errors thrown when calling the fetch function and performs a callback.
356
- */
357
- fetchError: function (cb) { return responseChain.error("__fromFetch", cb); },
358
- /**
359
- * Catches an AbortError and performs a callback.
360
- */
361
- onAbort: function (cb) { return responseChain.error("AbortError", cb); }
362
- };
363
- return resolvers.reduce(function (chain, r) { return r(chain, wretcher); }, responseChain);
364
- };
365
-
366
- var __assign$1 = (undefined && undefined.__assign) || function () {
367
- __assign$1 = Object.assign || function(t) {
368
- for (var s, i = 1, n = arguments.length; i < n; i++) {
369
- s = arguments[i];
370
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
371
- t[p] = s[p];
372
- }
373
- return t;
374
- };
375
- return __assign$1.apply(this, arguments);
376
- };
377
- var __spreadArrays$2 = (undefined && undefined.__spreadArrays) || function () {
378
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
379
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
380
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
381
- r[k] = a[j];
382
- return r;
383
- };
384
- var JSON_MIME = "application/json";
385
- var CONTENT_TYPE_HEADER = "Content-Type";
386
- /**
387
- * The Wretcher class used to perform easy fetch requests.
388
- *
389
- * Immutability : almost every method of this class return a fresh Wretcher object.
390
- */
391
- var Wretcher = /** @class */ (function () {
392
- function Wretcher(_url, _options, _catchers, _resolvers, _middlewares, _deferredChain) {
393
- if (_catchers === void 0) { _catchers = new Map(); }
394
- if (_resolvers === void 0) { _resolvers = []; }
395
- if (_middlewares === void 0) { _middlewares = []; }
396
- if (_deferredChain === void 0) { _deferredChain = []; }
397
- this._url = _url;
398
- this._options = _options;
399
- this._catchers = _catchers;
400
- this._resolvers = _resolvers;
401
- this._middlewares = _middlewares;
402
- this._deferredChain = _deferredChain;
403
- }
404
- Wretcher.factory = function (url, options) {
405
- if (url === void 0) { url = ""; }
406
- if (options === void 0) { options = {}; }
407
- return new Wretcher(url, options);
408
- };
409
- Wretcher.prototype.selfFactory = function (_a) {
410
- var _b = _a === void 0 ? {} : _a, _c = _b.url, url = _c === void 0 ? this._url : _c, _d = _b.options, options = _d === void 0 ? this._options : _d, _e = _b.catchers, catchers = _e === void 0 ? this._catchers : _e, _f = _b.resolvers, resolvers = _f === void 0 ? this._resolvers : _f, _g = _b.middlewares, middlewares = _g === void 0 ? this._middlewares : _g, _h = _b.deferredChain, deferredChain = _h === void 0 ? this._deferredChain : _h;
411
- return new Wretcher(url, __assign$1({}, options), new Map(catchers), __spreadArrays$2(resolvers), __spreadArrays$2(middlewares), __spreadArrays$2(deferredChain));
412
- };
413
- /**
414
- * Sets the default fetch options used for every subsequent fetch call.
415
- * @param options New default options
416
- * @param mixin If true, mixes in instead of replacing the existing options
417
- */
418
- Wretcher.prototype.defaults = function (options, mixin) {
419
- if (mixin === void 0) { mixin = false; }
420
- config.defaults = mixin ? mix(config.defaults, options) : options;
421
- return this;
422
- };
423
- /**
424
- * Sets the method (text, json ...) used to parse the data contained in the response body in case of an HTTP error.
425
- *
426
- * Persists for every subsequent requests.
427
- *
428
- * Default is "text".
429
- */
430
- Wretcher.prototype.errorType = function (method) {
431
- config.errorType = method;
432
- return this;
433
- };
434
- /**
435
- * Sets the non-global polyfills which will be used for every subsequent calls.
436
- *
437
- * Needed for libraries like [fetch-ponyfill](https://github.com/qubyte/fetch-ponyfill).
438
- *
439
- * @param polyfills An object containing the polyfills.
440
- */
441
- Wretcher.prototype.polyfills = function (polyfills) {
442
- config.polyfills = __assign$1(__assign$1({}, config.polyfills), polyfills);
443
- return this;
444
- };
445
- /**
446
- * Returns a new Wretcher object with the argument url appended and the same options.
447
- * @param url String url
448
- * @param replace Boolean If true, replaces the current url instead of appending
449
- */
450
- Wretcher.prototype.url = function (url, replace) {
451
- if (replace === void 0) { replace = false; }
452
- if (replace)
453
- return this.selfFactory({ url: url });
454
- var split = this._url.split("?");
455
- return this.selfFactory({
456
- url: split.length > 1 ?
457
- split[0] + url + "?" + split[1] :
458
- this._url + url
459
- });
460
- };
461
- /**
462
- * Returns a new Wretcher object with the same url and new options.
463
- * @param options New options
464
- * @param mixin If true, mixes in instead of replacing the existing options
465
- */
466
- Wretcher.prototype.options = function (options, mixin) {
467
- if (mixin === void 0) { mixin = true; }
468
- return this.selfFactory({ options: mixin ? mix(this._options, options) : options });
469
- };
470
- /**
471
- * Converts a javascript object to query parameters,
472
- * then appends this query string to the current url.
473
- *
474
- * If given a string, use the string as the query verbatim.
475
- *
476
- * ```
477
- * let w = wretch("http://example.com") // url is http://example.com
478
- *
479
- * // Chain query calls
480
- * w = w.query({ a: 1, b : 2 }) // url is now http://example.com?a=1&b=2
481
- * w = w.query("foo-bar-baz-woz") // url is now http://example.com?a=1&b=2&foo-bar-baz-woz
482
- *
483
- * // Pass true as the second argument to replace existing query parameters
484
- * w = w.query("c=3&d=4", true) // url is now http://example.com?c=3&d=4
485
- * ```
486
- *
487
- * @param qp An object which will be converted, or a string which will be used verbatim.
488
- */
489
- Wretcher.prototype.query = function (qp, replace) {
490
- if (replace === void 0) { replace = false; }
491
- return this.selfFactory({ url: appendQueryParams(this._url, qp, replace) });
492
- };
493
- /**
494
- * Set request headers.
495
- * @param headerValues An object containing header keys and values
496
- */
497
- Wretcher.prototype.headers = function (headerValues) {
498
- return this.selfFactory({ options: mix(this._options, { headers: headerValues || {} }) });
499
- };
500
- /**
501
- * Shortcut to set the "Accept" header.
502
- * @param headerValue Header value
503
- */
504
- Wretcher.prototype.accept = function (headerValue) {
505
- return this.headers({ Accept: headerValue });
506
- };
507
- /**
508
- * Shortcut to set the "Content-Type" header.
509
- * @param headerValue Header value
510
- */
511
- Wretcher.prototype.content = function (headerValue) {
512
- var _a;
513
- return this.headers((_a = {}, _a[CONTENT_TYPE_HEADER] = headerValue, _a));
514
- };
515
- /**
516
- * Shortcut to set the "Authorization" header.
517
- * @param headerValue Header value
518
- */
519
- Wretcher.prototype.auth = function (headerValue) {
520
- return this.headers({ Authorization: headerValue });
521
- };
522
- /**
523
- * Adds a default catcher which will be called on every subsequent request error when the error code matches.
524
- * @param errorId Error code or name
525
- * @param catcher: The catcher method
526
- */
527
- Wretcher.prototype.catcher = function (errorId, catcher) {
528
- var newMap = new Map(this._catchers);
529
- newMap.set(errorId, catcher);
530
- return this.selfFactory({ catchers: newMap });
531
- };
532
- /**
533
- * Associates a custom signal with the request.
534
- * @param controller : An AbortController
535
- */
536
- Wretcher.prototype.signal = function (controller) {
537
- return this.selfFactory({ options: __assign$1(__assign$1({}, this._options), { signal: controller.signal }) });
538
- };
539
- /**
540
- * Program a resolver to perform response chain tasks automatically.
541
- * @param doResolve : Resolver callback
542
- */
543
- Wretcher.prototype.resolve = function (doResolve, clear) {
544
- if (clear === void 0) { clear = false; }
545
- return this.selfFactory({ resolvers: clear ? [doResolve] : __spreadArrays$2(this._resolvers, [doResolve]) });
546
- };
547
- /**
548
- * Defer wretcher methods that will be chained and called just before the request is performed.
549
- */
550
- Wretcher.prototype.defer = function (callback, clear) {
551
- if (clear === void 0) { clear = false; }
552
- return this.selfFactory({
553
- deferredChain: clear ? [callback] : __spreadArrays$2(this._deferredChain, [callback])
554
- });
555
- };
556
- /**
557
- * Add middlewares to intercept a request before being sent.
558
- */
559
- Wretcher.prototype.middlewares = function (middlewares, clear) {
560
- if (clear === void 0) { clear = false; }
561
- return this.selfFactory({
562
- middlewares: clear ? middlewares : __spreadArrays$2(this._middlewares, middlewares)
563
- });
564
- };
565
- Wretcher.prototype.method = function (method, options, body) {
566
- if (options === void 0) { options = {}; }
567
- if (body === void 0) { body = null; }
568
- var headers = this._options.headers;
569
- var baseWretcher = !body ? this :
570
- typeof body === "object" && (!headers ||
571
- Object.entries(headers).every(function (_a) {
572
- var k = _a[0], v = _a[1];
573
- return k.toLowerCase() !== CONTENT_TYPE_HEADER.toLowerCase() ||
574
- v.startsWith(JSON_MIME);
575
- })) ? this.json(body) :
576
- this.body(body);
577
- baseWretcher = baseWretcher.options(__assign$1(__assign$1({}, options), { method: method }));
578
- var deferredWretcher = baseWretcher._deferredChain.reduce(function (acc, curr) { return curr(acc, acc._url, acc._options); }, baseWretcher);
579
- return resolver(deferredWretcher);
580
- };
581
- /**
582
- * Performs a get request.
583
- */
584
- Wretcher.prototype.get = function (options) {
585
- return this.method("GET", options);
586
- };
587
- /**
588
- * Performs a delete request.
589
- */
590
- Wretcher.prototype.delete = function (options) {
591
- return this.method("DELETE", options);
592
- };
593
- /**
594
- * Performs a put request.
595
- */
596
- Wretcher.prototype.put = function (body, options) {
597
- return this.method("PUT", options, body);
598
- };
599
- /**
600
- * Performs a post request.
601
- */
602
- Wretcher.prototype.post = function (body, options) {
603
- return this.method("POST", options, body);
604
- };
605
- /**
606
- * Performs a patch request.
607
- */
608
- Wretcher.prototype.patch = function (body, options) {
609
- return this.method("PATCH", options, body);
610
- };
611
- /**
612
- * Performs a head request.
613
- */
614
- Wretcher.prototype.head = function (options) {
615
- return this.method("HEAD", options);
616
- };
617
- /**
618
- * Performs an options request
619
- */
620
- Wretcher.prototype.opts = function (options) {
621
- return this.method("OPTIONS", options);
622
- };
623
- /**
624
- * Replay a request.
625
- */
626
- Wretcher.prototype.replay = function (options) {
627
- return this.method(this._options.method, options);
628
- };
629
- /**
630
- * Sets the request body with any content.
631
- * @param contents The body contents
632
- */
633
- Wretcher.prototype.body = function (contents) {
634
- return this.selfFactory({ options: __assign$1(__assign$1({}, this._options), { body: contents }) });
635
- };
636
- /**
637
- * Sets the content type header, stringifies an object and sets the request body.
638
- * @param jsObject An object which will be serialized into a JSON
639
- */
640
- Wretcher.prototype.json = function (jsObject) {
641
- var _a;
642
- var preservedContentType = (_a = Object.entries(this._options.headers || {}).find(function (_a) {
643
- var k = _a[0], v = _a[1];
644
- return k.toLowerCase() === CONTENT_TYPE_HEADER.toLowerCase() && v.startsWith(JSON_MIME);
645
- })) === null || _a === void 0 ? void 0 : _a[1];
646
- return this.content(preservedContentType || JSON_MIME).body(JSON.stringify(jsObject));
647
- };
648
- /**
649
- * Converts the javascript object to a FormData and sets the request body.
650
- * @param formObject An object which will be converted to a FormData
651
- * @param recursive If `true`, will recurse through all nested objects
652
- * Can be set as an array of string to exclude specific keys.
653
- * See https://github.com/elbywan/wretch/issues/68 for more details.
654
- */
655
- Wretcher.prototype.formData = function (formObject, recursive) {
656
- if (recursive === void 0) { recursive = false; }
657
- return this.body(convertFormData(formObject, recursive));
658
- };
659
- /**
660
- * Converts the input to an url encoded string and sets the content-type header and body.
661
- * If the input argument is already a string, skips the conversion part.
662
- *
663
- * @param input An object to convert into an url encoded string or an already encoded string
664
- */
665
- Wretcher.prototype.formUrl = function (input) {
666
- return this
667
- .body(typeof input === "string" ? input : convertFormUrl(input))
668
- .content("application/x-www-form-urlencoded");
669
- };
670
- return Wretcher;
671
- }());
672
- // Internal helpers
673
- var appendQueryParams = function (url, qp, replace) {
674
- var queryString;
675
- if (typeof qp === "string") {
676
- queryString = qp;
677
- }
678
- else {
679
- var usp = config.polyfill("URLSearchParams", { instance: true });
680
- for (var key in qp) {
681
- if (qp[key] instanceof Array) {
682
- for (var _i = 0, _a = qp[key]; _i < _a.length; _i++) {
683
- var val = _a[_i];
684
- usp.append(key, val);
685
- }
686
- }
687
- else {
688
- usp.append(key, qp[key]);
689
- }
690
- }
691
- queryString = usp.toString();
692
- }
693
- var split = url.split("?");
694
- if (replace || split.length < 2)
695
- return split[0] + "?" + queryString;
696
- return url + "&" + queryString;
697
- };
698
- function convertFormData(formObject, recursive, formData, ancestors) {
699
- if (recursive === void 0) { recursive = false; }
700
- if (formData === void 0) { formData = config.polyfill("FormData", { instance: true }); }
701
- if (ancestors === void 0) { ancestors = []; }
702
- Object.entries(formObject).forEach(function (_a) {
703
- var key = _a[0], value = _a[1];
704
- var formKey = ancestors.reduce(function (acc, ancestor) { return (acc ? acc + "[" + ancestor + "]" : ancestor); }, null);
705
- formKey = formKey ? formKey + "[" + key + "]" : key;
706
- if (value instanceof Array) {
707
- for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
708
- var item = value_1[_i];
709
- formData.append(formKey + "[]", item);
710
- }
711
- }
712
- else if (recursive &&
713
- typeof value === "object" &&
714
- (!(recursive instanceof Array) ||
715
- !recursive.includes(key))) {
716
- if (value !== null) {
717
- convertFormData(value, recursive, formData, __spreadArrays$2(ancestors, [key]));
718
- }
719
- }
720
- else {
721
- formData.append(formKey, value);
722
- }
723
- });
724
- return formData;
725
- }
726
- function encodeQueryValue(key, value) {
727
- return encodeURIComponent(key) +
728
- "=" +
729
- encodeURIComponent(typeof value === "object" ?
730
- JSON.stringify(value) :
731
- "" + value);
732
- }
733
- function convertFormUrl(formObject) {
734
- return Object.keys(formObject)
735
- .map(function (key) {
736
- var value = formObject[key];
737
- if (value instanceof Array) {
738
- return value.map(function (v) { return encodeQueryValue(key, v); }).join("&");
739
- }
740
- return encodeQueryValue(key, value);
741
- })
742
- .join("&");
743
- }
744
-
745
- var factory = Wretcher.factory;
746
- factory["default"] = Wretcher.factory;
747
-
748
- function backendApiClient() {
749
- return factory(session_query.appConfigurationService.apiBaseUrl);
750
- }
751
-
752
- class CarsCalculatorApi {
753
- async getCarsMakes() {
754
- const res = (await backendApiClient().url('/makes').get().json());
755
- return res.qt_makes;
756
- }
757
- async getCarsModels(makeId) {
758
- const res = (await backendApiClient()
759
- .url(`/makes/${makeId}/models`)
760
- .get()
761
- .json());
762
- return res.qt_models;
763
- }
764
- async getCarsModelYears(modelId) {
765
- return backendApiClient().url(`/models/${modelId}/years`).get().json();
766
- }
767
- async getCarsModelBodyTypes(modelId, year) {
768
- const res = (await backendApiClient()
769
- .url(`/models/${modelId}/years/${year}/body-types`)
770
- .get()
771
- .json());
772
- return res.qt_body_types;
773
- }
774
- async getCarsModelVariant(modelId, year, bodyTypeId) {
775
- const res = (await backendApiClient()
776
- .url(`/models/${modelId}/years/${year}/body-types/${bodyTypeId}/variants`)
777
- .get()
778
- .json());
779
- return res.qt_variants;
780
- }
781
- async getCarsVariantPhotos(variantId) {
782
- const res = (await backendApiClient()
783
- .url(`/variants/${variantId}/photos`)
784
- .get()
785
- .json());
786
- return res.qt_variant_photos;
787
- }
788
- async postCarsQuoteResult(req) {
789
- return (await backendApiClient().url(`/quote`).post(req).json());
790
- }
791
- async postQuoteInfoAsync(req) {
792
- return backendApiClient().url(`/enquiry`).post(req).text();
793
- }
794
- }
795
- const backendApi = new CarsCalculatorApi();
796
-
797
- class CarsCalculatorService {
798
- constructor() {
799
- session_query.sessionQuery
800
- .select(['user', 'vehicle'])
801
- .subscribe((state) => this.attemptQuoteCalculationAsync(state.user, state.vehicle));
802
- }
803
- selectVariant(variant) {
804
- session_query.sessionStore.update((state) => ({
805
- vehicle: Object.assign(Object.assign({}, state.vehicle), { selectedVariant: variant })
806
- }));
807
- }
808
- generateCarsEnquiryRequest() {
809
- const vehicle = session_query.sessionQuery.vehicle;
810
- const variant = getOrError(vehicle.selectedVariant);
811
- const result = session_query.sessionQuery.result;
812
- const details = session_query.sessionQuery.userDetails;
813
- return {
814
- chosenVariant: {
815
- variant_id: variant.variantId,
816
- short_description: variant.description,
817
- build_year: variant.buildYear,
818
- model_month: variant.modelMonth,
819
- list_price_gross: variant.listPriceGross
820
- },
821
- websiteQuote: {
822
- afterTaxEffectPerPayCycle: getOrError(result.afterTaxEffectPerPayCycle),
823
- totalTaxSavings: getOrError(result.taxSaving),
824
- residualValueGross: getOrError(result.residualValue),
825
- financedAmount: getOrError(result.financedAmount),
826
- fuel: getOrError(result.fuel),
827
- serviceAndMaintenance: getOrError(result.serviceAndMaintenance),
828
- registrationAndCtp: getOrError(result.registrationAndCtp),
829
- comprehensiveInsurance: getOrError(result.comprehensiveInsurance),
830
- managementFee: getOrError(result.managementFee)
831
- },
832
- contactDetails: {
833
- firstName: getOrError(details.userFirstName),
834
- lastName: getOrError(details.userLastName),
835
- email: getOrError(details.emailAddress),
836
- mobileNumber: getOrError(details.contactNumber),
837
- employerName: getOrError(details.employerName)
838
- }
839
- };
840
- }
841
- async attemptQuoteCalculationAsync(user, vehicle) {
842
- const isAllInformationAvailable = session_query.isSome(user.annualKms) &&
843
- session_query.isSome(user.annualSalary) &&
844
- session_query.isSome(user.paymentPeriod) &&
845
- session_query.isSome(user.state) &&
846
- session_query.isSome(user.term) &&
847
- session_query.isSome(vehicle.selectedVariant);
848
- if (!isAllInformationAvailable) {
849
- return;
850
- }
851
- session_query.sessionStore.updateQuote({
852
- afterTaxEffectPerPayCycle: session_query.none,
853
- taxSaving: session_query.none,
854
- residualValue: session_query.none,
855
- financedAmount: session_query.none,
856
- fuel: session_query.none,
857
- serviceAndMaintenance: session_query.none,
858
- registrationAndCtp: session_query.none,
859
- comprehensiveInsurance: session_query.none,
860
- managementFee: session_query.none,
861
- quoteState: 'Calculation pending'
862
- });
863
- const variant = getOrError(vehicle.selectedVariant);
864
- const isUsedCarRequested = getOrError(vehicle.isUsedCarRequested);
865
- const price = isUsedCarRequested
866
- ? getOrError(vehicle.approximatePrice)
867
- : variant.listPriceGross;
868
- const req = {
869
- variantId: variant.variantId,
870
- isUsedCarRequested: getOrError(vehicle.isUsedCarRequested),
871
- approximatePrice: price,
872
- annualSalaryGross: getOrError(user.annualSalary),
873
- payPeriod: getOrError(user.paymentPeriod),
874
- annualKm: getOrError(user.annualKms),
875
- state: getOrError(user.state),
876
- leaseTermInYears: getOrError(user.term)
877
- };
878
- const response = await backendApi.postCarsQuoteResult(req);
879
- const quoteResult = {
880
- afterTaxEffectPerPayCycle: session_query.some(response.afterTaxEffectPerPayCycle),
881
- taxSaving: session_query.some(response.totalTaxSavings),
882
- residualValue: session_query.some(response.residualValueGross),
883
- financedAmount: session_query.some(response.financedAmount),
884
- fuel: session_query.some(response.fuel),
885
- serviceAndMaintenance: session_query.some(response.serviceAndMaintenance),
886
- registrationAndCtp: session_query.some(response.registrationAndCtp),
887
- comprehensiveInsurance: session_query.some(response.comprehensiveInsurance),
888
- managementFee: session_query.some(response.managementFee),
889
- quoteState: 'Calculated'
890
- };
891
- session_query.sessionStore.updateQuote(quoteResult);
892
- }
893
- }
894
- const carsCalculatorService = new CarsCalculatorService();
895
-
896
- exports.backendApi = backendApi;
897
- exports.carsCalculatorService = carsCalculatorService;
898
- exports.getOrDefault = getOrDefault;
899
- exports.getOrError = getOrError;
900
- exports.pipe = pipe;
901
- exports.toSelectInputOptionsArray = toSelectInputOptionsArray;