@flarehr/apollo-benefits 1.2.100 → 1.3.112

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 (375) hide show
  1. package/README.md +19 -0
  2. package/dist/assets/@splitsoftware-3446d8d5.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-2f3733dd.js +5 -0
  7. package/dist/assets/date-fns-cebe152d.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/framer-motion-a9ae3803.js +1 -0
  11. package/dist/assets/index-c625490e.js +35 -0
  12. package/dist/assets/index-e0d31eb5.js +5 -0
  13. package/dist/assets/index-ed3c23ba.css +1 -0
  14. package/dist/assets/lodash-5d893f8c.js +1 -0
  15. package/dist/assets/logo-a34e9b4b.png +0 -0
  16. package/dist/assets/oidc-client-6f6e47c2.js +101 -0
  17. package/dist/assets/padlock-8c081120.svg +26 -0
  18. package/dist/assets/suitcase-6471ad05.svg +17 -0
  19. package/dist/assets/vendor-00105f87.js +792 -0
  20. package/dist/assets/warning-a7f1af23.svg +14 -0
  21. package/dist/assets/welcome_image_mobile-dbde6c80.png +0 -0
  22. package/dist/assets/welcome_image_v2-869c59e4.png +0 -0
  23. package/dist/assets/wellbeing_banner-6903d615.png +0 -0
  24. package/dist/assets/workplace_link_banner_mobile-6ebaa24b.png +0 -0
  25. package/dist/assets/workplace_link_banner_v2-c81ed849.png +0 -0
  26. package/dist/config.json +14 -0
  27. package/dist/favicon.ico +0 -0
  28. package/dist/icons/android-chrome-192x192.png +0 -0
  29. package/dist/icons/android-chrome-512x512.png +0 -0
  30. package/dist/icons/apple-touch-icon.png +0 -0
  31. package/dist/icons/favicon-16x16.png +0 -0
  32. package/dist/icons/favicon-32x32.png +0 -0
  33. package/dist/index.html +115 -0
  34. package/dist/manifest.json +21 -0
  35. package/dist/sw-esm.js +16 -0
  36. package/package.json +127 -69
  37. package/LICENSE +0 -21
  38. package/dist/lib/apollo-benefits/apollo-benefits.esm.js +0 -1
  39. package/dist/lib/apollo-benefits/assets/Hero_Background.png +0 -0
  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/common-assets/icon-info.svg +0 -4
  43. package/dist/lib/apollo-benefits/index.esm.js +0 -0
  44. package/dist/lib/apollo-benefits/p-054d1471.js +0 -1
  45. package/dist/lib/apollo-benefits/p-066d8e7b.js +0 -15
  46. package/dist/lib/apollo-benefits/p-08376428.entry.js +0 -1
  47. package/dist/lib/apollo-benefits/p-1d7ab1b9.entry.js +0 -1
  48. package/dist/lib/apollo-benefits/p-25a89275.entry.js +0 -1
  49. package/dist/lib/apollo-benefits/p-26d363c9.entry.js +0 -1
  50. package/dist/lib/apollo-benefits/p-337ce3df.js +0 -1
  51. package/dist/lib/apollo-benefits/p-3dc9a379.js +0 -1
  52. package/dist/lib/apollo-benefits/p-4376366b.js +0 -46
  53. package/dist/lib/apollo-benefits/p-4e2d34f4.entry.js +0 -1
  54. package/dist/lib/apollo-benefits/p-50bbf713.js +0 -1
  55. package/dist/lib/apollo-benefits/p-53c5e861.entry.js +0 -1
  56. package/dist/lib/apollo-benefits/p-556fdb43.js +0 -1
  57. package/dist/lib/apollo-benefits/p-57d4702d.entry.js +0 -1
  58. package/dist/lib/apollo-benefits/p-58ee670f.js +0 -1
  59. package/dist/lib/apollo-benefits/p-6a54654f.entry.js +0 -11
  60. package/dist/lib/apollo-benefits/p-6bd33850.js +0 -1
  61. package/dist/lib/apollo-benefits/p-79c3b633.entry.js +0 -1
  62. package/dist/lib/apollo-benefits/p-7f3a2f3b.entry.js +0 -1
  63. package/dist/lib/apollo-benefits/p-82d42c2b.js +0 -1
  64. package/dist/lib/apollo-benefits/p-9b3e978e.js +0 -1
  65. package/dist/lib/apollo-benefits/p-a1dd0cba.entry.js +0 -1
  66. package/dist/lib/apollo-benefits/p-aa379cfe.entry.js +0 -1
  67. package/dist/lib/apollo-benefits/p-aaf0e527.entry.js +0 -1
  68. package/dist/lib/apollo-benefits/p-b0b9425b.js +0 -1
  69. package/dist/lib/apollo-benefits/p-d0ef83f8.entry.js +0 -1
  70. package/dist/lib/apollo-benefits/p-db4a65f0.entry.js +0 -1
  71. package/dist/lib/apollo-benefits/p-dc67f942.entry.js +0 -1
  72. package/dist/lib/apollo-benefits/p-e1fd79bb.entry.js +0 -1
  73. package/dist/lib/apollo-benefits/p-ea120e31.js +0 -1
  74. package/dist/lib/apollo-benefits/p-ef5f33ca.js +0 -1
  75. package/dist/lib/apollo-benefits/p-f5254031.js +0 -1
  76. package/dist/lib/apollo-benefits/p-f63d9d89.js +0 -1
  77. package/dist/lib/apollo-benefits/p-fcfa5255.entry.js +0 -1
  78. package/dist/lib/cjs/Option-98dab0b8.js +0 -1988
  79. package/dist/lib/cjs/active-router-90429847.js +0 -75
  80. package/dist/lib/cjs/ap-ben-asset_5.cjs.entry.js +0 -1856
  81. package/dist/lib/cjs/ap-ben-benefit-card.cjs.entry.js +0 -45
  82. package/dist/lib/cjs/ap-ben-benefit-list-item.cjs.entry.js +0 -56
  83. package/dist/lib/cjs/ap-ben-benefit-url_27.cjs.entry.js +0 -48767
  84. package/dist/lib/cjs/ap-ben-benefits-list_3.cjs.entry.js +0 -55
  85. package/dist/lib/cjs/ap-ben-benefits-page.cjs.entry.js +0 -55
  86. package/dist/lib/cjs/ap-ben-choose-vehicle-section_4.cjs.entry.js +0 -2779
  87. package/dist/lib/cjs/ap-ben-notifications-section.cjs.entry.js +0 -243
  88. package/dist/lib/cjs/ap-ben-oidc-callback-page.cjs.entry.js +0 -40
  89. package/dist/lib/cjs/apollo-benefits.cjs.js +0 -25
  90. package/dist/lib/cjs/app-globals-e04ab04b.js +0 -12
  91. package/dist/lib/cjs/authentication.service-11c30071.js +0 -237
  92. package/dist/lib/cjs/benefits.api-b46ee2ea.js +0 -35
  93. package/dist/lib/cjs/cars-calculator-app.cjs.entry.js +0 -60
  94. package/dist/lib/cjs/cars-calculator.service-a8beab79.js +0 -166
  95. package/dist/lib/cjs/context-consumer.cjs.entry.js +0 -29
  96. package/dist/lib/cjs/datorama-akita-792b4d1d.js +0 -2553
  97. package/dist/lib/cjs/delay-e91dba76.js +0 -206
  98. package/dist/lib/cjs/event-tracking.service-6f723d9c.js +0 -155
  99. package/dist/lib/cjs/event-tracking.service-d6f9a51c.js +0 -259
  100. package/dist/lib/cjs/filter-c38164e6.js +0 -378
  101. package/dist/lib/cjs/fl-dropdown-async.cjs.entry.js +0 -422
  102. package/dist/lib/cjs/fl-dropdown.cjs.entry.js +0 -232
  103. package/dist/lib/cjs/fl-style-guide.cjs.entry.js +0 -91
  104. package/dist/lib/cjs/index-4f00f593.js +0 -994
  105. package/dist/lib/cjs/index-6e643fec.js +0 -1734
  106. package/dist/lib/cjs/index-889ce6c6.js +0 -27
  107. package/dist/lib/cjs/index.cjs.js +0 -2
  108. package/dist/lib/cjs/loader.cjs.js +0 -27
  109. package/dist/lib/cjs/scheduleArray-0ba3d6f8.js +0 -753
  110. package/dist/lib/cjs/stencil-async-content.cjs.entry.js +0 -32
  111. package/dist/lib/cjs/stencil-route-title.cjs.entry.js +0 -32
  112. package/dist/lib/cjs/stencil-router-prompt.cjs.entry.js +0 -59
  113. package/dist/lib/cjs/stencil-router-redirect.cjs.entry.js +0 -32
  114. package/dist/lib/cjs/view.service-ec43dea6.js +0 -21
  115. package/dist/lib/collection/assets/image/complete.svg +0 -122
  116. package/dist/lib/collection/collection-manifest.json +0 -81
  117. package/dist/lib/collection/components/benefits-app/apis/api-client.js +0 -16
  118. package/dist/lib/collection/components/benefits-app/apis/benefits-api/benefits-api.dto.js +0 -16
  119. package/dist/lib/collection/components/benefits-app/apis/benefits-api/benefits.api.js +0 -30
  120. package/dist/lib/collection/components/benefits-app/apis/event-tracking-api/event-tracking-api.dto.js +0 -1
  121. package/dist/lib/collection/components/benefits-app/apis/event-tracking-api/event-tracking-api.js +0 -7
  122. package/dist/lib/collection/components/benefits-app/apis/user-api/user-api.dto.js +0 -8
  123. package/dist/lib/collection/components/benefits-app/apis/user-api/user.api.js +0 -16
  124. package/dist/lib/collection/components/benefits-app/benefits-app.css +0 -399
  125. package/dist/lib/collection/components/benefits-app/benefits-app.js +0 -216
  126. package/dist/lib/collection/components/benefits-app/pages/benefits-page/benefits-list/benefit-list-item.css +0 -23
  127. package/dist/lib/collection/components/benefits-app/pages/benefits-page/benefits-list/benefits-list-item.js +0 -80
  128. package/dist/lib/collection/components/benefits-app/pages/benefits-page/benefits-list/benefits-list.js +0 -32
  129. package/dist/lib/collection/components/benefits-app/pages/benefits-page/benefits-page.js +0 -47
  130. package/dist/lib/collection/components/benefits-app/pages/benefits-page/hero-banner/assets/Hero_Background.png +0 -0
  131. package/dist/lib/collection/components/benefits-app/pages/benefits-page/hero-banner/hero-banner.css +0 -8
  132. package/dist/lib/collection/components/benefits-app/pages/benefits-page/hero-banner/hero-banner.js +0 -53
  133. package/dist/lib/collection/components/benefits-app/pages/benefits-page/promoted-benefits/benefit-card.css +0 -3
  134. package/dist/lib/collection/components/benefits-app/pages/benefits-page/promoted-benefits/benefit-card.js +0 -62
  135. package/dist/lib/collection/components/benefits-app/pages/benefits-page/promoted-benefits/promoted-benefits.js +0 -33
  136. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/api/manage-benefits-api.dto.js +0 -36
  137. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/api/manage-benefits.api.js +0 -23
  138. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/confirm-dialog.js +0 -158
  139. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/benefit-url.css +0 -8
  140. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/benefit-url.js +0 -126
  141. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/edit-benefit-form.js +0 -138
  142. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/upload-benefit-icon.css +0 -24
  143. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/upload-benefit-icon.js +0 -102
  144. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/upload-file.css +0 -18
  145. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/upload-file.js +0 -120
  146. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-page.js +0 -154
  147. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit.query.js +0 -18
  148. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit.service.js +0 -155
  149. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/empty-benefits.js +0 -36
  150. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/manage-benefits-header-row.js +0 -13
  151. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/manage-benefits-page.css +0 -3
  152. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/manage-benefits-page.js +0 -88
  153. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/manage-benefits-page.routes.js +0 -24
  154. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/manage-benefits.service.js +0 -37
  155. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/managed-benefit-item/managed-benefit-item.css +0 -10
  156. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/managed-benefit-item/managed-benefit-item.js +0 -89
  157. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/store/manage-benefits.query.js +0 -11
  158. package/dist/lib/collection/components/benefits-app/pages/manage-benefits-page/store/manage-benefits.store.js +0 -51
  159. package/dist/lib/collection/components/benefits-app/pages/role-management-page/api/role-management.api.js +0 -21
  160. package/dist/lib/collection/components/benefits-app/pages/role-management-page/role-editors-section/role-editors-section.js +0 -104
  161. package/dist/lib/collection/components/benefits-app/pages/role-management-page/role-management-page.js +0 -50
  162. package/dist/lib/collection/components/benefits-app/pages/role-management-page/role-management.service.js +0 -44
  163. package/dist/lib/collection/components/benefits-app/pages/role-management-page/role-owner-section/role-owner-section.js +0 -40
  164. package/dist/lib/collection/components/benefits-app/pages/role-management-page/store/role-management.query.js +0 -13
  165. package/dist/lib/collection/components/benefits-app/pages/role-management-page/store/role-management.store.js +0 -42
  166. package/dist/lib/collection/components/benefits-app/services/benefits-app.service.js +0 -36
  167. package/dist/lib/collection/components/benefits-app/services/benefits.service.js +0 -11
  168. package/dist/lib/collection/components/benefits-app/services/event-tracking.service.js +0 -40
  169. package/dist/lib/collection/components/benefits-app/services/navigation.service.js +0 -34
  170. package/dist/lib/collection/components/benefits-app/store/benefits-app.query.js +0 -13
  171. package/dist/lib/collection/components/benefits-app/store/benefits-app.store.js +0 -24
  172. package/dist/lib/collection/components/benefits-app-host/benefits-app-host.js +0 -48
  173. package/dist/lib/collection/components/benefits-app-host/loading-page.js +0 -9
  174. package/dist/lib/collection/components/benefits-app-host/oidc-callback-page/oidc-callback-page.js +0 -65
  175. package/dist/lib/collection/components/benefits-app-host/oidc-callback-page/oidc-callback-page.routes.js +0 -11
  176. package/dist/lib/collection/components/benefits-app-host/services/app-configuration.query.js +0 -18
  177. package/dist/lib/collection/components/benefits-app-host/services/app-configuration.service.js +0 -23
  178. package/dist/lib/collection/components/benefits-app-host/services/authentication.query.js +0 -21
  179. package/dist/lib/collection/components/benefits-app-host/services/authentication.service.js +0 -96
  180. package/dist/lib/collection/components/benefits-app-host/services/session.store.js +0 -33
  181. package/dist/lib/collection/components/cars-calculator-app/api/api-client.js +0 -5
  182. package/dist/lib/collection/components/cars-calculator-app/api/cars-calculator-events.model.js +0 -1
  183. package/dist/lib/collection/components/cars-calculator-app/api/cars-calculator.api.js +0 -45
  184. package/dist/lib/collection/components/cars-calculator-app/api/event-tracking.api.js +0 -7
  185. package/dist/lib/collection/components/cars-calculator-app/cars-calculator-app.css +0 -22
  186. package/dist/lib/collection/components/cars-calculator-app/cars-calculator-app.js +0 -97
  187. package/dist/lib/collection/components/cars-calculator-app/notifications-section/notifications-section.js +0 -25
  188. package/dist/lib/collection/components/cars-calculator-app/pages/asset.component.js +0 -27
  189. package/dist/lib/collection/components/cars-calculator-app/pages/assets/car-placeholder.svg +0 -5
  190. package/dist/lib/collection/components/cars-calculator-app/pages/assets/check.svg +0 -13
  191. package/dist/lib/collection/components/cars-calculator-app/pages/choose-vehicle-section.component.js +0 -234
  192. package/dist/lib/collection/components/cars-calculator-app/pages/common-assets/icon-info.svg +0 -4
  193. package/dist/lib/collection/components/cars-calculator-app/pages/complete-section.component.js +0 -38
  194. package/dist/lib/collection/components/cars-calculator-app/pages/cost-breakdown-section.component.js +0 -45
  195. package/dist/lib/collection/components/cars-calculator-app/pages/model-variants-section.component.css +0 -34
  196. package/dist/lib/collection/components/cars-calculator-app/pages/model-variants-section.component.js +0 -93
  197. package/dist/lib/collection/components/cars-calculator-app/pages/personal-info-section.component.js +0 -71
  198. package/dist/lib/collection/components/cars-calculator-app/pages/quote-result-section.component.js +0 -117
  199. package/dist/lib/collection/components/cars-calculator-app/pages/submit-quote-section.component.js +0 -87
  200. package/dist/lib/collection/components/cars-calculator-app/services/app-configuration.service.js +0 -13
  201. package/dist/lib/collection/components/cars-calculator-app/services/cars-calculator.service.js +0 -117
  202. package/dist/lib/collection/components/cars-calculator-app/services/event-tracking.service.js +0 -37
  203. package/dist/lib/collection/components/cars-calculator-app/services/notifications.service.js +0 -37
  204. package/dist/lib/collection/components/cars-calculator-app/services/notifications.store.js +0 -3
  205. package/dist/lib/collection/components/cars-calculator-app/services/session.query.js +0 -38
  206. package/dist/lib/collection/components/cars-calculator-app/services/session.store.js +0 -80
  207. package/dist/lib/collection/components/cars-calculator-app/services/view.service.js +0 -16
  208. package/dist/lib/collection/components/shared/file-icon/file-icon.css +0 -15
  209. package/dist/lib/collection/components/shared/file-icon/file-icon.js +0 -84
  210. package/dist/lib/collection/components/shared/icon.js +0 -77
  211. package/dist/lib/collection/components/shared/icons-library.js +0 -11
  212. package/dist/lib/collection/components/shared/modal-section.js +0 -138
  213. package/dist/lib/collection/components/shared/tooltip.css +0 -3
  214. package/dist/lib/collection/components/shared/tooltip.js +0 -115
  215. package/dist/lib/collection/components/shared/ui-container/ui-container.css +0 -39
  216. package/dist/lib/collection/components/shared/ui-container/ui-container.js +0 -27
  217. package/dist/lib/collection/global/config.js +0 -2
  218. package/dist/lib/collection/global/main.dev.js +0 -31
  219. package/dist/lib/collection/global/main.js +0 -5
  220. package/dist/lib/collection/index.js +0 -2
  221. package/dist/lib/collection/utils/config.js +0 -2
  222. package/dist/lib/collection/utils/index.js +0 -28
  223. package/dist/lib/collection/utils/lazy.js +0 -29
  224. package/dist/lib/collection/utils/promise.js +0 -7
  225. package/dist/lib/esm/Option-53ef163a.js +0 -1982
  226. package/dist/lib/esm/active-router-134fe07f.js +0 -73
  227. package/dist/lib/esm/ap-ben-asset_5.entry.js +0 -1848
  228. package/dist/lib/esm/ap-ben-benefit-card.entry.js +0 -41
  229. package/dist/lib/esm/ap-ben-benefit-list-item.entry.js +0 -52
  230. package/dist/lib/esm/ap-ben-benefit-url_27.entry.js +0 -48737
  231. package/dist/lib/esm/ap-ben-benefits-list_3.entry.js +0 -49
  232. package/dist/lib/esm/ap-ben-benefits-page.entry.js +0 -51
  233. package/dist/lib/esm/ap-ben-choose-vehicle-section_4.entry.js +0 -2772
  234. package/dist/lib/esm/ap-ben-notifications-section.entry.js +0 -239
  235. package/dist/lib/esm/ap-ben-oidc-callback-page.entry.js +0 -36
  236. package/dist/lib/esm/apollo-benefits.js +0 -23
  237. package/dist/lib/esm/app-globals-ff43b669.js +0 -10
  238. package/dist/lib/esm/authentication.service-4dbff8a5.js +0 -232
  239. package/dist/lib/esm/benefits.api-5a0c5fa7.js +0 -33
  240. package/dist/lib/esm/cars-calculator-app.entry.js +0 -56
  241. package/dist/lib/esm/cars-calculator.service-1278f563.js +0 -163
  242. package/dist/lib/esm/context-consumer.entry.js +0 -25
  243. package/dist/lib/esm/datorama-akita-e42d9911.js +0 -2547
  244. package/dist/lib/esm/delay-d08c267f.js +0 -200
  245. package/dist/lib/esm/event-tracking.service-27d79066.js +0 -253
  246. package/dist/lib/esm/event-tracking.service-429d997c.js +0 -146
  247. package/dist/lib/esm/filter-aeb65cac.js +0 -370
  248. package/dist/lib/esm/fl-dropdown-async.entry.js +0 -418
  249. package/dist/lib/esm/fl-dropdown.entry.js +0 -228
  250. package/dist/lib/esm/fl-style-guide.entry.js +0 -87
  251. package/dist/lib/esm/index-1351f893.js +0 -979
  252. package/dist/lib/esm/index-8676bf1e.js +0 -22
  253. package/dist/lib/esm/index-d4b319a7.js +0 -1702
  254. package/dist/lib/esm/index.js +0 -1
  255. package/dist/lib/esm/loader.js +0 -23
  256. package/dist/lib/esm/polyfills/core-js.js +0 -11
  257. package/dist/lib/esm/polyfills/css-shim.js +0 -1
  258. package/dist/lib/esm/polyfills/dom.js +0 -79
  259. package/dist/lib/esm/polyfills/es5-html-element.js +0 -1
  260. package/dist/lib/esm/polyfills/index.js +0 -34
  261. package/dist/lib/esm/polyfills/system.js +0 -6
  262. package/dist/lib/esm/scheduleArray-b9669898.js +0 -738
  263. package/dist/lib/esm/stencil-async-content.entry.js +0 -28
  264. package/dist/lib/esm/stencil-route-title.entry.js +0 -28
  265. package/dist/lib/esm/stencil-router-prompt.entry.js +0 -55
  266. package/dist/lib/esm/stencil-router-redirect.entry.js +0 -28
  267. package/dist/lib/esm/view.service-6adbec31.js +0 -19
  268. package/dist/lib/index.cjs.js +0 -1
  269. package/dist/lib/index.js +0 -1
  270. package/dist/lib/loader/cdn.js +0 -3
  271. package/dist/lib/loader/index.cjs.js +0 -3
  272. package/dist/lib/loader/index.d.ts +0 -13
  273. package/dist/lib/loader/index.es2017.js +0 -3
  274. package/dist/lib/loader/index.js +0 -4
  275. package/dist/lib/loader/package.json +0 -10
  276. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/button/button.css +0 -118
  277. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/dropdown/dropdown.css +0 -9
  278. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/dropdown-async/dropdown-async.css +0 -9
  279. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/loading-indicator/loading-indicator.css +0 -141
  280. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/promise-button/promise-button.css +0 -5
  281. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/style-guide/style-guide.css +0 -0
  282. package/dist/lib/node_modules/@stencil/router/dist/collection/components/route/route.css +0 -3
  283. package/dist/lib/types/components/benefits-app/apis/api-client.d.ts +0 -7
  284. package/dist/lib/types/components/benefits-app/apis/benefits-api/benefits-api.dto.d.ts +0 -44
  285. package/dist/lib/types/components/benefits-app/apis/benefits-api/benefits.api.d.ts +0 -9
  286. package/dist/lib/types/components/benefits-app/apis/event-tracking-api/event-tracking-api.d.ts +0 -6
  287. package/dist/lib/types/components/benefits-app/apis/event-tracking-api/event-tracking-api.dto.d.ts +0 -18
  288. package/dist/lib/types/components/benefits-app/apis/user-api/user-api.dto.d.ts +0 -30
  289. package/dist/lib/types/components/benefits-app/apis/user-api/user.api.d.ts +0 -8
  290. package/dist/lib/types/components/benefits-app/benefits-app.d.ts +0 -22
  291. package/dist/lib/types/components/benefits-app/pages/benefits-page/benefits-list/benefits-list-item.d.ts +0 -10
  292. package/dist/lib/types/components/benefits-app/pages/benefits-page/benefits-list/benefits-list.d.ts +0 -5
  293. package/dist/lib/types/components/benefits-app/pages/benefits-page/benefits-page.d.ts +0 -10
  294. package/dist/lib/types/components/benefits-app/pages/benefits-page/hero-banner/hero-banner.d.ts +0 -5
  295. package/dist/lib/types/components/benefits-app/pages/benefits-page/promoted-benefits/benefit-card.d.ts +0 -8
  296. package/dist/lib/types/components/benefits-app/pages/benefits-page/promoted-benefits/promoted-benefits.d.ts +0 -5
  297. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/api/manage-benefits-api.dto.d.ts +0 -39
  298. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/api/manage-benefits.api.d.ts +0 -9
  299. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/confirm-dialog.d.ts +0 -16
  300. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/benefit-url.d.ts +0 -21
  301. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/edit-benefit-form.d.ts +0 -12
  302. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/upload-benefit-icon.d.ts +0 -16
  303. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-form/upload-file.d.ts +0 -17
  304. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit-page.d.ts +0 -24
  305. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit.query.d.ts +0 -16
  306. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/edit-benefit-page/edit-benefit.service.d.ts +0 -20
  307. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/empty-benefits.d.ts +0 -5
  308. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/manage-benefits-header-row.d.ts +0 -3
  309. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/manage-benefits-page.d.ts +0 -16
  310. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/manage-benefits-page.routes.d.ts +0 -6
  311. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/manage-benefits.service.d.ts +0 -8
  312. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/managed-benefit-item/managed-benefit-item.d.ts +0 -11
  313. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/store/manage-benefits.query.d.ts +0 -10
  314. package/dist/lib/types/components/benefits-app/pages/manage-benefits-page/store/manage-benefits.store.d.ts +0 -51
  315. package/dist/lib/types/components/benefits-app/pages/role-management-page/api/role-management.api.d.ts +0 -7
  316. package/dist/lib/types/components/benefits-app/pages/role-management-page/role-editors-section/role-editors-section.d.ts +0 -15
  317. package/dist/lib/types/components/benefits-app/pages/role-management-page/role-management-page.d.ts +0 -9
  318. package/dist/lib/types/components/benefits-app/pages/role-management-page/role-management.service.d.ts +0 -11
  319. package/dist/lib/types/components/benefits-app/pages/role-management-page/role-owner-section/role-owner-section.d.ts +0 -5
  320. package/dist/lib/types/components/benefits-app/pages/role-management-page/store/role-management.query.d.ts +0 -12
  321. package/dist/lib/types/components/benefits-app/pages/role-management-page/store/role-management.store.d.ts +0 -17
  322. package/dist/lib/types/components/benefits-app/services/benefits-app.service.d.ts +0 -13
  323. package/dist/lib/types/components/benefits-app/services/benefits.service.d.ts +0 -8
  324. package/dist/lib/types/components/benefits-app/services/event-tracking.service.d.ts +0 -11
  325. package/dist/lib/types/components/benefits-app/services/navigation.service.d.ts +0 -14
  326. package/dist/lib/types/components/benefits-app/store/benefits-app.query.d.ts +0 -12
  327. package/dist/lib/types/components/benefits-app/store/benefits-app.store.d.ts +0 -31
  328. package/dist/lib/types/components/benefits-app-host/benefits-app-host.d.ts +0 -9
  329. package/dist/lib/types/components/benefits-app-host/loading-page.d.ts +0 -3
  330. package/dist/lib/types/components/benefits-app-host/oidc-callback-page/oidc-callback-page.d.ts +0 -8
  331. package/dist/lib/types/components/benefits-app-host/oidc-callback-page/oidc-callback-page.routes.d.ts +0 -1
  332. package/dist/lib/types/components/benefits-app-host/services/app-configuration.query.d.ts +0 -11
  333. package/dist/lib/types/components/benefits-app-host/services/app-configuration.service.d.ts +0 -9
  334. package/dist/lib/types/components/benefits-app-host/services/authentication.query.d.ts +0 -13
  335. package/dist/lib/types/components/benefits-app-host/services/authentication.service.d.ts +0 -25
  336. package/dist/lib/types/components/benefits-app-host/services/session.store.d.ts +0 -25
  337. package/dist/lib/types/components/cars-calculator-app/api/api-client.d.ts +0 -2
  338. package/dist/lib/types/components/cars-calculator-app/api/cars-calculator-events.model.d.ts +0 -39
  339. package/dist/lib/types/components/cars-calculator-app/api/cars-calculator.api.d.ts +0 -100
  340. package/dist/lib/types/components/cars-calculator-app/api/event-tracking.api.d.ts +0 -6
  341. package/dist/lib/types/components/cars-calculator-app/cars-calculator-app.d.ts +0 -18
  342. package/dist/lib/types/components/cars-calculator-app/notifications-section/notifications-section.d.ts +0 -5
  343. package/dist/lib/types/components/cars-calculator-app/pages/asset.component.d.ts +0 -4
  344. package/dist/lib/types/components/cars-calculator-app/pages/choose-vehicle-section.component.d.ts +0 -23
  345. package/dist/lib/types/components/cars-calculator-app/pages/complete-section.component.d.ts +0 -5
  346. package/dist/lib/types/components/cars-calculator-app/pages/cost-breakdown-section.component.d.ts +0 -6
  347. package/dist/lib/types/components/cars-calculator-app/pages/model-variants-section.component.d.ts +0 -12
  348. package/dist/lib/types/components/cars-calculator-app/pages/personal-info-section.component.d.ts +0 -10
  349. package/dist/lib/types/components/cars-calculator-app/pages/quote-result-section.component.d.ts +0 -16
  350. package/dist/lib/types/components/cars-calculator-app/pages/submit-quote-section.component.d.ts +0 -12
  351. package/dist/lib/types/components/cars-calculator-app/services/app-configuration.service.d.ts +0 -7
  352. package/dist/lib/types/components/cars-calculator-app/services/cars-calculator.service.d.ts +0 -11
  353. package/dist/lib/types/components/cars-calculator-app/services/event-tracking.service.d.ts +0 -13
  354. package/dist/lib/types/components/cars-calculator-app/services/notifications.service.d.ts +0 -15
  355. package/dist/lib/types/components/cars-calculator-app/services/notifications.store.d.ts +0 -14
  356. package/dist/lib/types/components/cars-calculator-app/services/session.query.d.ts +0 -26
  357. package/dist/lib/types/components/cars-calculator-app/services/session.store.d.ts +0 -78
  358. package/dist/lib/types/components/cars-calculator-app/services/view.service.d.ts +0 -8
  359. package/dist/lib/types/components/shared/file-icon/file-icon.d.ts +0 -11
  360. package/dist/lib/types/components/shared/icon.d.ts +0 -7
  361. package/dist/lib/types/components/shared/icons-library.d.ts +0 -1
  362. package/dist/lib/types/components/shared/modal-section.d.ts +0 -16
  363. package/dist/lib/types/components/shared/tooltip.d.ts +0 -13
  364. package/dist/lib/types/components/shared/ui-container/ui-container.d.ts +0 -5
  365. package/dist/lib/types/components.d.ts +0 -606
  366. package/dist/lib/types/global/config.d.ts +0 -2
  367. package/dist/lib/types/global/main.d.ts +0 -1
  368. package/dist/lib/types/global/main.dev.d.ts +0 -1
  369. package/dist/lib/types/index.d.ts +0 -2
  370. package/dist/lib/types/stencil-public-runtime.d.ts +0 -1555
  371. package/dist/lib/types/utils/config.d.ts +0 -2
  372. package/dist/lib/types/utils/index.d.ts +0 -10
  373. package/dist/lib/types/utils/lazy.d.ts +0 -12
  374. package/dist/lib/types/utils/promise.d.ts +0 -1
  375. package/readme.md +0 -1
@@ -1,2772 +0,0 @@
1
- import { r as registerInstance, h, H as Host, e as getAssetPath } from './index-d4b319a7.js';
2
- import { i as isNone, a as fromNullable, p as pipe, g as getOrElse, f as fold, n as none, s as some, h as getOrElseW } from './index-1351f893.js';
3
- import { b as getOrDefault, g as getOrError, t as toSelectInputOptionsArray } from './index-8676bf1e.js';
4
- import { b as backendApi, c as carsCalculatorService } from './cars-calculator.service-1278f563.js';
5
- import { s as sessionQuery, b as sessionStore, e as eventTrackingService } from './event-tracking.service-27d79066.js';
6
- import { v as viewService } from './view.service-6adbec31.js';
7
- import './Option-53ef163a.js';
8
- import './datorama-akita-e42d9911.js';
9
- import './scheduleArray-b9669898.js';
10
- import './delay-d08c267f.js';
11
- import './filter-aeb65cac.js';
12
-
13
- var __asyncValues = (undefined && undefined.__asyncValues) || function (o) {
14
- if (!Symbol.asyncIterator)
15
- throw new TypeError("Symbol.asyncIterator is not defined.");
16
- var m = o[Symbol.asyncIterator], i;
17
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
18
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
19
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
20
- };
21
- const ChooseVehicleSection = class {
22
- constructor(hostRef) {
23
- registerInstance(this, hostRef);
24
- this.toCapitalCase = (str) => str === null || str === void 0 ? void 0 : str.split(' ').map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()).join(' ');
25
- sessionQuery.vehicle$.subscribe((state) => (this.vehicleInfo = state));
26
- sessionQuery.makeList$.subscribe((state) => (this.makeList = getOrDefault(state, [])));
27
- sessionQuery.modelList$.subscribe((state) => (this.modelList = getOrDefault(state, [])));
28
- sessionQuery.yearList$.subscribe((state) => (this.yearList = getOrDefault(state, [])));
29
- sessionQuery.bodyTypeList$.subscribe((state) => (this.bodyTypeList = getOrDefault(state, [])));
30
- }
31
- render() {
32
- return (h(Host, null, h("div", { class: "d-flex flex-column flex-wrap flex-md-row align-items-center justify-content-center h4" }, h("div", { class: "d-flex align-items-center" }, "I'm looking to buy a"), h("div", { class: "d-flex mx-2 my-2 my-md-0" }, h("div", { class: "btn-group", role: "group", "aria-label": "New or used vehicle" }, h("button", { type: "button", class: {
33
- 'btn btn-outline-dark px-5': true,
34
- active: !this.isUsedCarSelected()
35
- }, onClick: (_event) => {
36
- sessionStore.setVehicleState('isUsedCarRequested', false);
37
- eventTrackingService.trackInputChangedAsync({
38
- key: 'isUsedCar',
39
- value: 'false'
40
- });
41
- } }, "New"), h("button", { type: "button", class: {
42
- 'btn btn-outline-dark px-5': true,
43
- active: this.isUsedCarSelected()
44
- }, onClick: (_event) => {
45
- sessionStore.setVehicleState('isUsedCarRequested', true);
46
- eventTrackingService.trackInputChangedAsync({
47
- key: 'isUsedCar',
48
- value: 'true'
49
- });
50
- } }, "Used"))), this.isUsedCarSelected() ? (h("div", { class: "d-flex flex-column flex-md-row align-items-center justify-content-center my-0 my-md-2 my-xl-0" }, h("span", { class: "pr-0 pr-sm-2 d-flex text-center" }, "vehicle, with a purchase price of"), h("input", { placeholder: "25000", type: "text", class: "form-control d-flex w-auto mt-2 mt-md-0", value: '$' + this.getVehicleInfo('approximatePrice'), onInput: (e) => {
51
- const el = e.target;
52
- el.value = el.value.replace(/\D/g, '');
53
- }, onFocus: (e) => {
54
- const el = e.target;
55
- el.value = el.value.replace('$', '');
56
- }, onBlur: (e) => {
57
- const el = e.target;
58
- el.value = '$' + el.value;
59
- }, onChange: (e) => {
60
- const elmValue = e.target.value;
61
- const newValue = (elmValue === null || elmValue === void 0 ? void 0 : elmValue.length) > 0 ? parseFloat(elmValue) : null;
62
- sessionStore.setVehicleState('approximatePrice', newValue);
63
- eventTrackingService.trackInputChangedAsync({
64
- key: 'approximatePrice',
65
- value: String(newValue)
66
- });
67
- } }))) : (h("div", { class: "d-flex align-items-center" }, "vehicle"))), h("div", { class: "d-flex flex-wrap flex-column flex-md-row align-items-center justify-content-center mt-5 h4" }, h("div", { class: "d-flex align-items-center" }, "I'm interested in a"), h("div", { class: "d-flex mx-2 my-2 my-md-0" }, h("fl-dropdown", { options: this.makeList, requiredValidationMessage: "Select an option", placeholder: "select make", value: this.getVehicleInfo('makeId'), onValueChanged: (e) => this.chooseMake(e.detail.label, e.detail.value) })), h("div", { class: "d-flex mx-2 my-2 my-md-0" }, h("fl-dropdown", { options: this.modelList, requiredValidationMessage: "Select an option", placeholder: "select model", value: this.getVehicleInfo('modelId'), disabled: isNone(this.vehicleInfo.makeId), onValueChanged: (e) => this.chooseModel(e.detail.label, e.detail.value) })), h("div", { class: "d-flex mx-2 my-2 my-xl-0" }, h("fl-dropdown", { options: this.yearList, requiredValidationMessage: "Select an option", placeholder: "select year", value: this.getVehicleInfo('year'), disabled: isNone(this.vehicleInfo.modelId), onValueChanged: (e) => this.chooseYear(e.detail.value) }))), h("div", { class: "d-flex align-items-center justify-content-center justify-content-md-start mt-5" }, h("div", { class: "btn-group flex-wrap", role: "group", "aria-label": "Body types" }, this.bodyTypeList.map((bodyType) => (h("button", { type: "button", class: {
68
- 'btn btn-sm btn-outline-dark px-5': true,
69
- active: this.isBodyTypeSelected(bodyType.value)
70
- }, onClick: (_event) => this.chooseBodyType(bodyType.label, bodyType.value) }, bodyType.label)))))));
71
- }
72
- async componentDidLoad() {
73
- var _a;
74
- if (((_a = this.makeList) === null || _a === void 0 ? void 0 : _a.length) > 0)
75
- return;
76
- const carsMakes = await backendApi.getCarsMakes();
77
- sessionStore.updateList('makeList', carsMakes.map((make) => ({
78
- label: this.toCapitalCase(make.name),
79
- value: make.make_id
80
- })));
81
- eventTrackingService.trackStepProgressedAsync({ stepName: 'carSelection' });
82
- }
83
- async chooseMake(make, makeId) {
84
- var _a;
85
- this.clearModelStates();
86
- this.clearYearStates();
87
- this.clearBodyTypeStates();
88
- this.clearVariantsList();
89
- if (((_a = this.modelList) === null || _a === void 0 ? void 0 : _a.length) === 0) {
90
- sessionStore.updateList('modelList', (await backendApi.getCarsModels(makeId)).map((model) => ({
91
- label: this.toCapitalCase(model.model_code),
92
- value: model.model_id
93
- })));
94
- }
95
- sessionStore.setVehicleState('make', make);
96
- sessionStore.setVehicleState('makeId', makeId);
97
- eventTrackingService.trackInputChangedAsync({
98
- key: 'make',
99
- value: make
100
- });
101
- }
102
- async chooseModel(model, modelId) {
103
- var _a;
104
- this.clearYearStates();
105
- this.clearBodyTypeStates();
106
- this.clearVariantsList();
107
- if (((_a = this.yearList) === null || _a === void 0 ? void 0 : _a.length) === 0) {
108
- sessionStore.updateList('yearList', (await backendApi.getCarsModelYears(modelId))
109
- .sort()
110
- .reverse()
111
- .map((year) => ({
112
- label: year.toString(),
113
- value: year
114
- })));
115
- }
116
- sessionStore.setVehicleState('model', model);
117
- sessionStore.setVehicleState('modelId', modelId);
118
- eventTrackingService.trackInputChangedAsync({
119
- key: 'model',
120
- value: model
121
- });
122
- }
123
- async chooseYear(year) {
124
- var _a;
125
- this.clearBodyTypeStates();
126
- this.clearVariantsList();
127
- const modelId = getOrError(this.vehicleInfo.modelId);
128
- if (((_a = this.bodyTypeList) === null || _a === void 0 ? void 0 : _a.length) === 0) {
129
- sessionStore.updateList('bodyTypeList', (await backendApi.getCarsModelBodyTypes(modelId, year)).map((bodyType) => ({
130
- label: bodyType.body_type,
131
- value: bodyType.body_type_id
132
- })));
133
- }
134
- sessionStore.setVehicleState('year', year);
135
- this.chooseBodyType(this.bodyTypeList[0].label, this.bodyTypeList[0].value);
136
- eventTrackingService.trackInputChangedAsync({
137
- key: 'year',
138
- value: year.toString()
139
- });
140
- }
141
- async chooseBodyType(bodyType, bodyTypeId) {
142
- var e_1, _a;
143
- this.clearVariantsList();
144
- sessionStore.setVehicleState('bodyType', bodyType);
145
- sessionStore.setVehicleState('bodyTypeId', bodyTypeId);
146
- const modelId = getOrError(this.vehicleInfo.modelId);
147
- const year = getOrError(this.vehicleInfo.year);
148
- const variantPromises = (await backendApi.getCarsModelVariant(modelId, year, bodyTypeId)).map(async (variant) => {
149
- var _a;
150
- const photoUri = await backendApi.getCarsVariantPhotos(variant.variant_id);
151
- return {
152
- variantId: variant.variant_id,
153
- description: variant.short_description,
154
- buildYear: variant.build_year,
155
- modelMonth: variant.model_month,
156
- listPriceGross: variant.list_price_gross,
157
- engineLitres: variant.engine_litres,
158
- transmission: variant.transmission,
159
- fuelTypeId: variant.fuel_type_translation_id,
160
- photoUri: fromNullable((_a = photoUri === null || photoUri === void 0 ? void 0 : photoUri[0]) === null || _a === void 0 ? void 0 : _a.photo_uri)
161
- };
162
- });
163
- const variantList = [];
164
- try {
165
- for (var variantPromises_1 = __asyncValues(variantPromises), variantPromises_1_1; variantPromises_1_1 = await variantPromises_1.next(), !variantPromises_1_1.done;) {
166
- const variant = variantPromises_1_1.value;
167
- variantList.push(variant);
168
- }
169
- }
170
- catch (e_1_1) {
171
- e_1 = { error: e_1_1 };
172
- }
173
- finally {
174
- try {
175
- if (variantPromises_1_1 && !variantPromises_1_1.done && (_a = variantPromises_1.return))
176
- await _a.call(variantPromises_1);
177
- }
178
- finally {
179
- if (e_1)
180
- throw e_1.error;
181
- }
182
- }
183
- sessionStore.updateList('modelVariantsList', variantList);
184
- eventTrackingService.trackStepProgressedAsync({ stepName: 'variantSelection' });
185
- eventTrackingService.trackInputChangedAsync({
186
- key: 'bodyType',
187
- value: bodyType
188
- });
189
- }
190
- clearModelStates() {
191
- this.modelList = [];
192
- this.clearVehicleState('model');
193
- this.clearVehicleState('modelId');
194
- }
195
- clearYearStates() {
196
- this.yearList = [];
197
- this.clearVehicleState('year');
198
- }
199
- clearBodyTypeStates() {
200
- this.bodyTypeList = [];
201
- this.clearVehicleState('bodyType');
202
- this.clearVehicleState('bodyTypeId');
203
- }
204
- clearVariantsList() {
205
- sessionStore.updateList('modelVariantsList', []);
206
- }
207
- clearVehicleState(key) {
208
- sessionStore.setVehicleState(key, null);
209
- }
210
- getVehicleInfo(key) {
211
- return pipe(this.vehicleInfo[key], getOrElse(() => ''));
212
- }
213
- isBodyTypeSelected(bodyTypeId) {
214
- return pipe(this.vehicleInfo.bodyTypeId, fold(() => false, (selectedBodyTypeId) => selectedBodyTypeId === bodyTypeId));
215
- }
216
- isUsedCarSelected() {
217
- return pipe(this.vehicleInfo.isUsedCarRequested, getOrElse(() => false));
218
- }
219
- };
220
-
221
- function toInteger(dirtyNumber) {
222
- if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
223
- return NaN;
224
- }
225
-
226
- var number = Number(dirtyNumber);
227
-
228
- if (isNaN(number)) {
229
- return number;
230
- }
231
-
232
- return number < 0 ? Math.ceil(number) : Math.floor(number);
233
- }
234
-
235
- function requiredArgs(required, args) {
236
- if (args.length < required) {
237
- throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
238
- }
239
- }
240
-
241
- /**
242
- * @name toDate
243
- * @category Common Helpers
244
- * @summary Convert the given argument to an instance of Date.
245
- *
246
- * @description
247
- * Convert the given argument to an instance of Date.
248
- *
249
- * If the argument is an instance of Date, the function returns its clone.
250
- *
251
- * If the argument is a number, it is treated as a timestamp.
252
- *
253
- * If the argument is none of the above, the function returns Invalid Date.
254
- *
255
- * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
256
- *
257
- * @param {Date|Number} argument - the value to convert
258
- * @returns {Date} the parsed date in the local time zone
259
- * @throws {TypeError} 1 argument required
260
- *
261
- * @example
262
- * // Clone the date:
263
- * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
264
- * //=> Tue Feb 11 2014 11:30:30
265
- *
266
- * @example
267
- * // Convert the timestamp to date:
268
- * const result = toDate(1392098430000)
269
- * //=> Tue Feb 11 2014 11:30:30
270
- */
271
-
272
- function toDate(argument) {
273
- requiredArgs(1, arguments);
274
- var argStr = Object.prototype.toString.call(argument); // Clone the date
275
-
276
- if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]') {
277
- // Prevent the date to lose the milliseconds when passed to new Date() in IE10
278
- return new Date(argument.getTime());
279
- } else if (typeof argument === 'number' || argStr === '[object Number]') {
280
- return new Date(argument);
281
- } else {
282
- if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
283
- // eslint-disable-next-line no-console
284
- console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"); // eslint-disable-next-line no-console
285
-
286
- console.warn(new Error().stack);
287
- }
288
-
289
- return new Date(NaN);
290
- }
291
- }
292
-
293
- /**
294
- * @name addMilliseconds
295
- * @category Millisecond Helpers
296
- * @summary Add the specified number of milliseconds to the given date.
297
- *
298
- * @description
299
- * Add the specified number of milliseconds to the given date.
300
- *
301
- * ### v2.0.0 breaking changes:
302
- *
303
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
304
- *
305
- * @param {Date|Number} date - the date to be changed
306
- * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
307
- * @returns {Date} the new date with the milliseconds added
308
- * @throws {TypeError} 2 arguments required
309
- *
310
- * @example
311
- * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
312
- * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
313
- * //=> Thu Jul 10 2014 12:45:30.750
314
- */
315
-
316
- function addMilliseconds(dirtyDate, dirtyAmount) {
317
- requiredArgs(2, arguments);
318
- var timestamp = toDate(dirtyDate).getTime();
319
- var amount = toInteger(dirtyAmount);
320
- return new Date(timestamp + amount);
321
- }
322
-
323
- /**
324
- * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
325
- * They usually appear for dates that denote time before the timezones were introduced
326
- * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
327
- * and GMT+01:00:00 after that date)
328
- *
329
- * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
330
- * which would lead to incorrect calculations.
331
- *
332
- * This function returns the timezone offset in milliseconds that takes seconds in account.
333
- */
334
- function getTimezoneOffsetInMilliseconds(date) {
335
- var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
336
- utcDate.setUTCFullYear(date.getFullYear());
337
- return date.getTime() - utcDate.getTime();
338
- }
339
-
340
- /**
341
- * @name isValid
342
- * @category Common Helpers
343
- * @summary Is the given date valid?
344
- *
345
- * @description
346
- * Returns false if argument is Invalid Date and true otherwise.
347
- * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
348
- * Invalid Date is a Date, whose time value is NaN.
349
- *
350
- * Time value of Date: http://es5.github.io/#x15.9.1.1
351
- *
352
- * ### v2.0.0 breaking changes:
353
- *
354
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
355
- *
356
- * - Now `isValid` doesn't throw an exception
357
- * if the first argument is not an instance of Date.
358
- * Instead, argument is converted beforehand using `toDate`.
359
- *
360
- * Examples:
361
- *
362
- * | `isValid` argument | Before v2.0.0 | v2.0.0 onward |
363
- * |---------------------------|---------------|---------------|
364
- * | `new Date()` | `true` | `true` |
365
- * | `new Date('2016-01-01')` | `true` | `true` |
366
- * | `new Date('')` | `false` | `false` |
367
- * | `new Date(1488370835081)` | `true` | `true` |
368
- * | `new Date(NaN)` | `false` | `false` |
369
- * | `'2016-01-01'` | `TypeError` | `false` |
370
- * | `''` | `TypeError` | `false` |
371
- * | `1488370835081` | `TypeError` | `true` |
372
- * | `NaN` | `TypeError` | `false` |
373
- *
374
- * We introduce this change to make *date-fns* consistent with ECMAScript behavior
375
- * that try to coerce arguments to the expected type
376
- * (which is also the case with other *date-fns* functions).
377
- *
378
- * @param {*} date - the date to check
379
- * @returns {Boolean} the date is valid
380
- * @throws {TypeError} 1 argument required
381
- *
382
- * @example
383
- * // For the valid date:
384
- * var result = isValid(new Date(2014, 1, 31))
385
- * //=> true
386
- *
387
- * @example
388
- * // For the value, convertable into a date:
389
- * var result = isValid(1393804800000)
390
- * //=> true
391
- *
392
- * @example
393
- * // For the invalid date:
394
- * var result = isValid(new Date(''))
395
- * //=> false
396
- */
397
-
398
- function isValid(dirtyDate) {
399
- requiredArgs(1, arguments);
400
- var date = toDate(dirtyDate);
401
- return !isNaN(date);
402
- }
403
-
404
- var formatDistanceLocale = {
405
- lessThanXSeconds: {
406
- one: 'less than a second',
407
- other: 'less than {{count}} seconds'
408
- },
409
- xSeconds: {
410
- one: '1 second',
411
- other: '{{count}} seconds'
412
- },
413
- halfAMinute: 'half a minute',
414
- lessThanXMinutes: {
415
- one: 'less than a minute',
416
- other: 'less than {{count}} minutes'
417
- },
418
- xMinutes: {
419
- one: '1 minute',
420
- other: '{{count}} minutes'
421
- },
422
- aboutXHours: {
423
- one: 'about 1 hour',
424
- other: 'about {{count}} hours'
425
- },
426
- xHours: {
427
- one: '1 hour',
428
- other: '{{count}} hours'
429
- },
430
- xDays: {
431
- one: '1 day',
432
- other: '{{count}} days'
433
- },
434
- aboutXWeeks: {
435
- one: 'about 1 week',
436
- other: 'about {{count}} weeks'
437
- },
438
- xWeeks: {
439
- one: '1 week',
440
- other: '{{count}} weeks'
441
- },
442
- aboutXMonths: {
443
- one: 'about 1 month',
444
- other: 'about {{count}} months'
445
- },
446
- xMonths: {
447
- one: '1 month',
448
- other: '{{count}} months'
449
- },
450
- aboutXYears: {
451
- one: 'about 1 year',
452
- other: 'about {{count}} years'
453
- },
454
- xYears: {
455
- one: '1 year',
456
- other: '{{count}} years'
457
- },
458
- overXYears: {
459
- one: 'over 1 year',
460
- other: 'over {{count}} years'
461
- },
462
- almostXYears: {
463
- one: 'almost 1 year',
464
- other: 'almost {{count}} years'
465
- }
466
- };
467
- function formatDistance(token, count, options) {
468
- options = options || {};
469
- var result;
470
-
471
- if (typeof formatDistanceLocale[token] === 'string') {
472
- result = formatDistanceLocale[token];
473
- } else if (count === 1) {
474
- result = formatDistanceLocale[token].one;
475
- } else {
476
- result = formatDistanceLocale[token].other.replace('{{count}}', count);
477
- }
478
-
479
- if (options.addSuffix) {
480
- if (options.comparison > 0) {
481
- return 'in ' + result;
482
- } else {
483
- return result + ' ago';
484
- }
485
- }
486
-
487
- return result;
488
- }
489
-
490
- function buildFormatLongFn(args) {
491
- return function (dirtyOptions) {
492
- var options = dirtyOptions || {};
493
- var width = options.width ? String(options.width) : args.defaultWidth;
494
- var format = args.formats[width] || args.formats[args.defaultWidth];
495
- return format;
496
- };
497
- }
498
-
499
- var dateFormats = {
500
- full: 'EEEE, MMMM do, y',
501
- long: 'MMMM do, y',
502
- medium: 'MMM d, y',
503
- short: 'MM/dd/yyyy'
504
- };
505
- var timeFormats = {
506
- full: 'h:mm:ss a zzzz',
507
- long: 'h:mm:ss a z',
508
- medium: 'h:mm:ss a',
509
- short: 'h:mm a'
510
- };
511
- var dateTimeFormats = {
512
- full: "{{date}} 'at' {{time}}",
513
- long: "{{date}} 'at' {{time}}",
514
- medium: '{{date}}, {{time}}',
515
- short: '{{date}}, {{time}}'
516
- };
517
- var formatLong = {
518
- date: buildFormatLongFn({
519
- formats: dateFormats,
520
- defaultWidth: 'full'
521
- }),
522
- time: buildFormatLongFn({
523
- formats: timeFormats,
524
- defaultWidth: 'full'
525
- }),
526
- dateTime: buildFormatLongFn({
527
- formats: dateTimeFormats,
528
- defaultWidth: 'full'
529
- })
530
- };
531
-
532
- var formatRelativeLocale = {
533
- lastWeek: "'last' eeee 'at' p",
534
- yesterday: "'yesterday at' p",
535
- today: "'today at' p",
536
- tomorrow: "'tomorrow at' p",
537
- nextWeek: "eeee 'at' p",
538
- other: 'P'
539
- };
540
- function formatRelative(token, _date, _baseDate, _options) {
541
- return formatRelativeLocale[token];
542
- }
543
-
544
- function buildLocalizeFn(args) {
545
- return function (dirtyIndex, dirtyOptions) {
546
- var options = dirtyOptions || {};
547
- var context = options.context ? String(options.context) : 'standalone';
548
- var valuesArray;
549
-
550
- if (context === 'formatting' && args.formattingValues) {
551
- var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
552
- var width = options.width ? String(options.width) : defaultWidth;
553
- valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
554
- } else {
555
- var _defaultWidth = args.defaultWidth;
556
-
557
- var _width = options.width ? String(options.width) : args.defaultWidth;
558
-
559
- valuesArray = args.values[_width] || args.values[_defaultWidth];
560
- }
561
-
562
- var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
563
- return valuesArray[index];
564
- };
565
- }
566
-
567
- var eraValues = {
568
- narrow: ['B', 'A'],
569
- abbreviated: ['BC', 'AD'],
570
- wide: ['Before Christ', 'Anno Domini']
571
- };
572
- var quarterValues = {
573
- narrow: ['1', '2', '3', '4'],
574
- abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
575
- wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter'] // Note: in English, the names of days of the week and months are capitalized.
576
- // If you are making a new locale based on this one, check if the same is true for the language you're working on.
577
- // Generally, formatted dates should look like they are in the middle of a sentence,
578
- // e.g. in Spanish language the weekdays and months should be in the lowercase.
579
-
580
- };
581
- var monthValues = {
582
- narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
583
- abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
584
- wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
585
- };
586
- var dayValues = {
587
- narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
588
- short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
589
- abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
590
- wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
591
- };
592
- var dayPeriodValues = {
593
- narrow: {
594
- am: 'a',
595
- pm: 'p',
596
- midnight: 'mi',
597
- noon: 'n',
598
- morning: 'morning',
599
- afternoon: 'afternoon',
600
- evening: 'evening',
601
- night: 'night'
602
- },
603
- abbreviated: {
604
- am: 'AM',
605
- pm: 'PM',
606
- midnight: 'midnight',
607
- noon: 'noon',
608
- morning: 'morning',
609
- afternoon: 'afternoon',
610
- evening: 'evening',
611
- night: 'night'
612
- },
613
- wide: {
614
- am: 'a.m.',
615
- pm: 'p.m.',
616
- midnight: 'midnight',
617
- noon: 'noon',
618
- morning: 'morning',
619
- afternoon: 'afternoon',
620
- evening: 'evening',
621
- night: 'night'
622
- }
623
- };
624
- var formattingDayPeriodValues = {
625
- narrow: {
626
- am: 'a',
627
- pm: 'p',
628
- midnight: 'mi',
629
- noon: 'n',
630
- morning: 'in the morning',
631
- afternoon: 'in the afternoon',
632
- evening: 'in the evening',
633
- night: 'at night'
634
- },
635
- abbreviated: {
636
- am: 'AM',
637
- pm: 'PM',
638
- midnight: 'midnight',
639
- noon: 'noon',
640
- morning: 'in the morning',
641
- afternoon: 'in the afternoon',
642
- evening: 'in the evening',
643
- night: 'at night'
644
- },
645
- wide: {
646
- am: 'a.m.',
647
- pm: 'p.m.',
648
- midnight: 'midnight',
649
- noon: 'noon',
650
- morning: 'in the morning',
651
- afternoon: 'in the afternoon',
652
- evening: 'in the evening',
653
- night: 'at night'
654
- }
655
- };
656
-
657
- function ordinalNumber(dirtyNumber, _dirtyOptions) {
658
- var number = Number(dirtyNumber); // If ordinal numbers depend on context, for example,
659
- // if they are different for different grammatical genders,
660
- // use `options.unit`:
661
- //
662
- // var options = dirtyOptions || {}
663
- // var unit = String(options.unit)
664
- //
665
- // where `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
666
- // 'day', 'hour', 'minute', 'second'
667
-
668
- var rem100 = number % 100;
669
-
670
- if (rem100 > 20 || rem100 < 10) {
671
- switch (rem100 % 10) {
672
- case 1:
673
- return number + 'st';
674
-
675
- case 2:
676
- return number + 'nd';
677
-
678
- case 3:
679
- return number + 'rd';
680
- }
681
- }
682
-
683
- return number + 'th';
684
- }
685
-
686
- var localize = {
687
- ordinalNumber: ordinalNumber,
688
- era: buildLocalizeFn({
689
- values: eraValues,
690
- defaultWidth: 'wide'
691
- }),
692
- quarter: buildLocalizeFn({
693
- values: quarterValues,
694
- defaultWidth: 'wide',
695
- argumentCallback: function (quarter) {
696
- return Number(quarter) - 1;
697
- }
698
- }),
699
- month: buildLocalizeFn({
700
- values: monthValues,
701
- defaultWidth: 'wide'
702
- }),
703
- day: buildLocalizeFn({
704
- values: dayValues,
705
- defaultWidth: 'wide'
706
- }),
707
- dayPeriod: buildLocalizeFn({
708
- values: dayPeriodValues,
709
- defaultWidth: 'wide',
710
- formattingValues: formattingDayPeriodValues,
711
- defaultFormattingWidth: 'wide'
712
- })
713
- };
714
-
715
- function buildMatchPatternFn(args) {
716
- return function (dirtyString, dirtyOptions) {
717
- var string = String(dirtyString);
718
- var options = dirtyOptions || {};
719
- var matchResult = string.match(args.matchPattern);
720
-
721
- if (!matchResult) {
722
- return null;
723
- }
724
-
725
- var matchedString = matchResult[0];
726
- var parseResult = string.match(args.parsePattern);
727
-
728
- if (!parseResult) {
729
- return null;
730
- }
731
-
732
- var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
733
- value = options.valueCallback ? options.valueCallback(value) : value;
734
- return {
735
- value: value,
736
- rest: string.slice(matchedString.length)
737
- };
738
- };
739
- }
740
-
741
- function buildMatchFn(args) {
742
- return function (dirtyString, dirtyOptions) {
743
- var string = String(dirtyString);
744
- var options = dirtyOptions || {};
745
- var width = options.width;
746
- var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
747
- var matchResult = string.match(matchPattern);
748
-
749
- if (!matchResult) {
750
- return null;
751
- }
752
-
753
- var matchedString = matchResult[0];
754
- var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
755
- var value;
756
-
757
- if (Object.prototype.toString.call(parsePatterns) === '[object Array]') {
758
- value = findIndex(parsePatterns, function (pattern) {
759
- return pattern.test(matchedString);
760
- });
761
- } else {
762
- value = findKey(parsePatterns, function (pattern) {
763
- return pattern.test(matchedString);
764
- });
765
- }
766
-
767
- value = args.valueCallback ? args.valueCallback(value) : value;
768
- value = options.valueCallback ? options.valueCallback(value) : value;
769
- return {
770
- value: value,
771
- rest: string.slice(matchedString.length)
772
- };
773
- };
774
- }
775
-
776
- function findKey(object, predicate) {
777
- for (var key in object) {
778
- if (object.hasOwnProperty(key) && predicate(object[key])) {
779
- return key;
780
- }
781
- }
782
- }
783
-
784
- function findIndex(array, predicate) {
785
- for (var key = 0; key < array.length; key++) {
786
- if (predicate(array[key])) {
787
- return key;
788
- }
789
- }
790
- }
791
-
792
- var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
793
- var parseOrdinalNumberPattern = /\d+/i;
794
- var matchEraPatterns = {
795
- narrow: /^(b|a)/i,
796
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
797
- wide: /^(before christ|before common era|anno domini|common era)/i
798
- };
799
- var parseEraPatterns = {
800
- any: [/^b/i, /^(a|c)/i]
801
- };
802
- var matchQuarterPatterns = {
803
- narrow: /^[1234]/i,
804
- abbreviated: /^q[1234]/i,
805
- wide: /^[1234](th|st|nd|rd)? quarter/i
806
- };
807
- var parseQuarterPatterns = {
808
- any: [/1/i, /2/i, /3/i, /4/i]
809
- };
810
- var matchMonthPatterns = {
811
- narrow: /^[jfmasond]/i,
812
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
813
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
814
- };
815
- var parseMonthPatterns = {
816
- narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
817
- any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
818
- };
819
- var matchDayPatterns = {
820
- narrow: /^[smtwf]/i,
821
- short: /^(su|mo|tu|we|th|fr|sa)/i,
822
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
823
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
824
- };
825
- var parseDayPatterns = {
826
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
827
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
828
- };
829
- var matchDayPeriodPatterns = {
830
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
831
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
832
- };
833
- var parseDayPeriodPatterns = {
834
- any: {
835
- am: /^a/i,
836
- pm: /^p/i,
837
- midnight: /^mi/i,
838
- noon: /^no/i,
839
- morning: /morning/i,
840
- afternoon: /afternoon/i,
841
- evening: /evening/i,
842
- night: /night/i
843
- }
844
- };
845
- var match = {
846
- ordinalNumber: buildMatchPatternFn({
847
- matchPattern: matchOrdinalNumberPattern,
848
- parsePattern: parseOrdinalNumberPattern,
849
- valueCallback: function (value) {
850
- return parseInt(value, 10);
851
- }
852
- }),
853
- era: buildMatchFn({
854
- matchPatterns: matchEraPatterns,
855
- defaultMatchWidth: 'wide',
856
- parsePatterns: parseEraPatterns,
857
- defaultParseWidth: 'any'
858
- }),
859
- quarter: buildMatchFn({
860
- matchPatterns: matchQuarterPatterns,
861
- defaultMatchWidth: 'wide',
862
- parsePatterns: parseQuarterPatterns,
863
- defaultParseWidth: 'any',
864
- valueCallback: function (index) {
865
- return index + 1;
866
- }
867
- }),
868
- month: buildMatchFn({
869
- matchPatterns: matchMonthPatterns,
870
- defaultMatchWidth: 'wide',
871
- parsePatterns: parseMonthPatterns,
872
- defaultParseWidth: 'any'
873
- }),
874
- day: buildMatchFn({
875
- matchPatterns: matchDayPatterns,
876
- defaultMatchWidth: 'wide',
877
- parsePatterns: parseDayPatterns,
878
- defaultParseWidth: 'any'
879
- }),
880
- dayPeriod: buildMatchFn({
881
- matchPatterns: matchDayPeriodPatterns,
882
- defaultMatchWidth: 'any',
883
- parsePatterns: parseDayPeriodPatterns,
884
- defaultParseWidth: 'any'
885
- })
886
- };
887
-
888
- /**
889
- * @type {Locale}
890
- * @category Locales
891
- * @summary English locale (United States).
892
- * @language English
893
- * @iso-639-2 eng
894
- * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
895
- * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
896
- */
897
-
898
- var locale = {
899
- code: 'en-US',
900
- formatDistance: formatDistance,
901
- formatLong: formatLong,
902
- formatRelative: formatRelative,
903
- localize: localize,
904
- match: match,
905
- options: {
906
- weekStartsOn: 0
907
- /* Sunday */
908
- ,
909
- firstWeekContainsDate: 1
910
- }
911
- };
912
-
913
- /**
914
- * @name subMilliseconds
915
- * @category Millisecond Helpers
916
- * @summary Subtract the specified number of milliseconds from the given date.
917
- *
918
- * @description
919
- * Subtract the specified number of milliseconds from the given date.
920
- *
921
- * ### v2.0.0 breaking changes:
922
- *
923
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
924
- *
925
- * @param {Date|Number} date - the date to be changed
926
- * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
927
- * @returns {Date} the new date with the milliseconds subtracted
928
- * @throws {TypeError} 2 arguments required
929
- *
930
- * @example
931
- * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
932
- * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
933
- * //=> Thu Jul 10 2014 12:45:29.250
934
- */
935
-
936
- function subMilliseconds(dirtyDate, dirtyAmount) {
937
- requiredArgs(2, arguments);
938
- var amount = toInteger(dirtyAmount);
939
- return addMilliseconds(dirtyDate, -amount);
940
- }
941
-
942
- function addLeadingZeros(number, targetLength) {
943
- var sign = number < 0 ? '-' : '';
944
- var output = Math.abs(number).toString();
945
-
946
- while (output.length < targetLength) {
947
- output = '0' + output;
948
- }
949
-
950
- return sign + output;
951
- }
952
-
953
- /*
954
- * | | Unit | | Unit |
955
- * |-----|--------------------------------|-----|--------------------------------|
956
- * | a | AM, PM | A* | |
957
- * | d | Day of month | D | |
958
- * | h | Hour [1-12] | H | Hour [0-23] |
959
- * | m | Minute | M | Month |
960
- * | s | Second | S | Fraction of second |
961
- * | y | Year (abs) | Y | |
962
- *
963
- * Letters marked by * are not implemented but reserved by Unicode standard.
964
- */
965
-
966
- var formatters$1 = {
967
- // Year
968
- y: function (date, token) {
969
- // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
970
- // | Year | y | yy | yyy | yyyy | yyyyy |
971
- // |----------|-------|----|-------|-------|-------|
972
- // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
973
- // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
974
- // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
975
- // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
976
- // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
977
- var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
978
-
979
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
980
- return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
981
- },
982
- // Month
983
- M: function (date, token) {
984
- var month = date.getUTCMonth();
985
- return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
986
- },
987
- // Day of the month
988
- d: function (date, token) {
989
- return addLeadingZeros(date.getUTCDate(), token.length);
990
- },
991
- // AM or PM
992
- a: function (date, token) {
993
- var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
994
-
995
- switch (token) {
996
- case 'a':
997
- case 'aa':
998
- return dayPeriodEnumValue.toUpperCase();
999
-
1000
- case 'aaa':
1001
- return dayPeriodEnumValue;
1002
-
1003
- case 'aaaaa':
1004
- return dayPeriodEnumValue[0];
1005
-
1006
- case 'aaaa':
1007
- default:
1008
- return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
1009
- }
1010
- },
1011
- // Hour [1-12]
1012
- h: function (date, token) {
1013
- return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
1014
- },
1015
- // Hour [0-23]
1016
- H: function (date, token) {
1017
- return addLeadingZeros(date.getUTCHours(), token.length);
1018
- },
1019
- // Minute
1020
- m: function (date, token) {
1021
- return addLeadingZeros(date.getUTCMinutes(), token.length);
1022
- },
1023
- // Second
1024
- s: function (date, token) {
1025
- return addLeadingZeros(date.getUTCSeconds(), token.length);
1026
- },
1027
- // Fraction of second
1028
- S: function (date, token) {
1029
- var numberOfDigits = token.length;
1030
- var milliseconds = date.getUTCMilliseconds();
1031
- var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
1032
- return addLeadingZeros(fractionalSeconds, token.length);
1033
- }
1034
- };
1035
-
1036
- var MILLISECONDS_IN_DAY = 86400000; // This function will be a part of public API when UTC function will be implemented.
1037
- // See issue: https://github.com/date-fns/date-fns/issues/376
1038
-
1039
- function getUTCDayOfYear(dirtyDate) {
1040
- requiredArgs(1, arguments);
1041
- var date = toDate(dirtyDate);
1042
- var timestamp = date.getTime();
1043
- date.setUTCMonth(0, 1);
1044
- date.setUTCHours(0, 0, 0, 0);
1045
- var startOfYearTimestamp = date.getTime();
1046
- var difference = timestamp - startOfYearTimestamp;
1047
- return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
1048
- }
1049
-
1050
- // See issue: https://github.com/date-fns/date-fns/issues/376
1051
-
1052
- function startOfUTCISOWeek(dirtyDate) {
1053
- requiredArgs(1, arguments);
1054
- var weekStartsOn = 1;
1055
- var date = toDate(dirtyDate);
1056
- var day = date.getUTCDay();
1057
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
1058
- date.setUTCDate(date.getUTCDate() - diff);
1059
- date.setUTCHours(0, 0, 0, 0);
1060
- return date;
1061
- }
1062
-
1063
- // See issue: https://github.com/date-fns/date-fns/issues/376
1064
-
1065
- function getUTCISOWeekYear(dirtyDate) {
1066
- requiredArgs(1, arguments);
1067
- var date = toDate(dirtyDate);
1068
- var year = date.getUTCFullYear();
1069
- var fourthOfJanuaryOfNextYear = new Date(0);
1070
- fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
1071
- fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
1072
- var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
1073
- var fourthOfJanuaryOfThisYear = new Date(0);
1074
- fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
1075
- fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
1076
- var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
1077
-
1078
- if (date.getTime() >= startOfNextYear.getTime()) {
1079
- return year + 1;
1080
- } else if (date.getTime() >= startOfThisYear.getTime()) {
1081
- return year;
1082
- } else {
1083
- return year - 1;
1084
- }
1085
- }
1086
-
1087
- // See issue: https://github.com/date-fns/date-fns/issues/376
1088
-
1089
- function startOfUTCISOWeekYear(dirtyDate) {
1090
- requiredArgs(1, arguments);
1091
- var year = getUTCISOWeekYear(dirtyDate);
1092
- var fourthOfJanuary = new Date(0);
1093
- fourthOfJanuary.setUTCFullYear(year, 0, 4);
1094
- fourthOfJanuary.setUTCHours(0, 0, 0, 0);
1095
- var date = startOfUTCISOWeek(fourthOfJanuary);
1096
- return date;
1097
- }
1098
-
1099
- var MILLISECONDS_IN_WEEK$1 = 604800000; // This function will be a part of public API when UTC function will be implemented.
1100
- // See issue: https://github.com/date-fns/date-fns/issues/376
1101
-
1102
- function getUTCISOWeek(dirtyDate) {
1103
- requiredArgs(1, arguments);
1104
- var date = toDate(dirtyDate);
1105
- var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime(); // Round the number of days to the nearest integer
1106
- // because the number of milliseconds in a week is not constant
1107
- // (e.g. it's different in the week of the daylight saving time clock shift)
1108
-
1109
- return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
1110
- }
1111
-
1112
- // See issue: https://github.com/date-fns/date-fns/issues/376
1113
-
1114
- function startOfUTCWeek(dirtyDate, dirtyOptions) {
1115
- requiredArgs(1, arguments);
1116
- var options = dirtyOptions || {};
1117
- var locale = options.locale;
1118
- var localeWeekStartsOn = locale && locale.options && locale.options.weekStartsOn;
1119
- var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
1120
- var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
1121
-
1122
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
1123
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
1124
- }
1125
-
1126
- var date = toDate(dirtyDate);
1127
- var day = date.getUTCDay();
1128
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
1129
- date.setUTCDate(date.getUTCDate() - diff);
1130
- date.setUTCHours(0, 0, 0, 0);
1131
- return date;
1132
- }
1133
-
1134
- // See issue: https://github.com/date-fns/date-fns/issues/376
1135
-
1136
- function getUTCWeekYear(dirtyDate, dirtyOptions) {
1137
- requiredArgs(1, arguments);
1138
- var date = toDate(dirtyDate, dirtyOptions);
1139
- var year = date.getUTCFullYear();
1140
- var options = dirtyOptions || {};
1141
- var locale = options.locale;
1142
- var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate;
1143
- var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
1144
- var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
1145
-
1146
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
1147
- throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
1148
- }
1149
-
1150
- var firstWeekOfNextYear = new Date(0);
1151
- firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
1152
- firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
1153
- var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, dirtyOptions);
1154
- var firstWeekOfThisYear = new Date(0);
1155
- firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
1156
- firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
1157
- var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, dirtyOptions);
1158
-
1159
- if (date.getTime() >= startOfNextYear.getTime()) {
1160
- return year + 1;
1161
- } else if (date.getTime() >= startOfThisYear.getTime()) {
1162
- return year;
1163
- } else {
1164
- return year - 1;
1165
- }
1166
- }
1167
-
1168
- // See issue: https://github.com/date-fns/date-fns/issues/376
1169
-
1170
- function startOfUTCWeekYear(dirtyDate, dirtyOptions) {
1171
- requiredArgs(1, arguments);
1172
- var options = dirtyOptions || {};
1173
- var locale = options.locale;
1174
- var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate;
1175
- var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
1176
- var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate);
1177
- var year = getUTCWeekYear(dirtyDate, dirtyOptions);
1178
- var firstWeek = new Date(0);
1179
- firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
1180
- firstWeek.setUTCHours(0, 0, 0, 0);
1181
- var date = startOfUTCWeek(firstWeek, dirtyOptions);
1182
- return date;
1183
- }
1184
-
1185
- var MILLISECONDS_IN_WEEK = 604800000; // This function will be a part of public API when UTC function will be implemented.
1186
- // See issue: https://github.com/date-fns/date-fns/issues/376
1187
-
1188
- function getUTCWeek(dirtyDate, options) {
1189
- requiredArgs(1, arguments);
1190
- var date = toDate(dirtyDate);
1191
- var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime(); // Round the number of days to the nearest integer
1192
- // because the number of milliseconds in a week is not constant
1193
- // (e.g. it's different in the week of the daylight saving time clock shift)
1194
-
1195
- return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
1196
- }
1197
-
1198
- var dayPeriodEnum = {
1199
- am: 'am',
1200
- pm: 'pm',
1201
- midnight: 'midnight',
1202
- noon: 'noon',
1203
- morning: 'morning',
1204
- afternoon: 'afternoon',
1205
- evening: 'evening',
1206
- night: 'night'
1207
- /*
1208
- * | | Unit | | Unit |
1209
- * |-----|--------------------------------|-----|--------------------------------|
1210
- * | a | AM, PM | A* | Milliseconds in day |
1211
- * | b | AM, PM, noon, midnight | B | Flexible day period |
1212
- * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
1213
- * | d | Day of month | D | Day of year |
1214
- * | e | Local day of week | E | Day of week |
1215
- * | f | | F* | Day of week in month |
1216
- * | g* | Modified Julian day | G | Era |
1217
- * | h | Hour [1-12] | H | Hour [0-23] |
1218
- * | i! | ISO day of week | I! | ISO week of year |
1219
- * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
1220
- * | k | Hour [1-24] | K | Hour [0-11] |
1221
- * | l* | (deprecated) | L | Stand-alone month |
1222
- * | m | Minute | M | Month |
1223
- * | n | | N | |
1224
- * | o! | Ordinal number modifier | O | Timezone (GMT) |
1225
- * | p! | Long localized time | P! | Long localized date |
1226
- * | q | Stand-alone quarter | Q | Quarter |
1227
- * | r* | Related Gregorian year | R! | ISO week-numbering year |
1228
- * | s | Second | S | Fraction of second |
1229
- * | t! | Seconds timestamp | T! | Milliseconds timestamp |
1230
- * | u | Extended year | U* | Cyclic year |
1231
- * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
1232
- * | w | Local week of year | W* | Week of month |
1233
- * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
1234
- * | y | Year (abs) | Y | Local week-numbering year |
1235
- * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
1236
- *
1237
- * Letters marked by * are not implemented but reserved by Unicode standard.
1238
- *
1239
- * Letters marked by ! are non-standard, but implemented by date-fns:
1240
- * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
1241
- * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
1242
- * i.e. 7 for Sunday, 1 for Monday, etc.
1243
- * - `I` is ISO week of year, as opposed to `w` which is local week of year.
1244
- * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
1245
- * `R` is supposed to be used in conjunction with `I` and `i`
1246
- * for universal ISO week-numbering date, whereas
1247
- * `Y` is supposed to be used in conjunction with `w` and `e`
1248
- * for week-numbering date specific to the locale.
1249
- * - `P` is long localized date format
1250
- * - `p` is long localized time format
1251
- */
1252
-
1253
- };
1254
- var formatters = {
1255
- // Era
1256
- G: function (date, token, localize) {
1257
- var era = date.getUTCFullYear() > 0 ? 1 : 0;
1258
-
1259
- switch (token) {
1260
- // AD, BC
1261
- case 'G':
1262
- case 'GG':
1263
- case 'GGG':
1264
- return localize.era(era, {
1265
- width: 'abbreviated'
1266
- });
1267
- // A, B
1268
-
1269
- case 'GGGGG':
1270
- return localize.era(era, {
1271
- width: 'narrow'
1272
- });
1273
- // Anno Domini, Before Christ
1274
-
1275
- case 'GGGG':
1276
- default:
1277
- return localize.era(era, {
1278
- width: 'wide'
1279
- });
1280
- }
1281
- },
1282
- // Year
1283
- y: function (date, token, localize) {
1284
- // Ordinal number
1285
- if (token === 'yo') {
1286
- var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
1287
-
1288
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
1289
- return localize.ordinalNumber(year, {
1290
- unit: 'year'
1291
- });
1292
- }
1293
-
1294
- return formatters$1.y(date, token);
1295
- },
1296
- // Local week-numbering year
1297
- Y: function (date, token, localize, options) {
1298
- var signedWeekYear = getUTCWeekYear(date, options); // Returns 1 for 1 BC (which is year 0 in JavaScript)
1299
-
1300
- var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; // Two digit year
1301
-
1302
- if (token === 'YY') {
1303
- var twoDigitYear = weekYear % 100;
1304
- return addLeadingZeros(twoDigitYear, 2);
1305
- } // Ordinal number
1306
-
1307
-
1308
- if (token === 'Yo') {
1309
- return localize.ordinalNumber(weekYear, {
1310
- unit: 'year'
1311
- });
1312
- } // Padding
1313
-
1314
-
1315
- return addLeadingZeros(weekYear, token.length);
1316
- },
1317
- // ISO week-numbering year
1318
- R: function (date, token) {
1319
- var isoWeekYear = getUTCISOWeekYear(date); // Padding
1320
-
1321
- return addLeadingZeros(isoWeekYear, token.length);
1322
- },
1323
- // Extended year. This is a single number designating the year of this calendar system.
1324
- // The main difference between `y` and `u` localizers are B.C. years:
1325
- // | Year | `y` | `u` |
1326
- // |------|-----|-----|
1327
- // | AC 1 | 1 | 1 |
1328
- // | BC 1 | 1 | 0 |
1329
- // | BC 2 | 2 | -1 |
1330
- // Also `yy` always returns the last two digits of a year,
1331
- // while `uu` pads single digit years to 2 characters and returns other years unchanged.
1332
- u: function (date, token) {
1333
- var year = date.getUTCFullYear();
1334
- return addLeadingZeros(year, token.length);
1335
- },
1336
- // Quarter
1337
- Q: function (date, token, localize) {
1338
- var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
1339
-
1340
- switch (token) {
1341
- // 1, 2, 3, 4
1342
- case 'Q':
1343
- return String(quarter);
1344
- // 01, 02, 03, 04
1345
-
1346
- case 'QQ':
1347
- return addLeadingZeros(quarter, 2);
1348
- // 1st, 2nd, 3rd, 4th
1349
-
1350
- case 'Qo':
1351
- return localize.ordinalNumber(quarter, {
1352
- unit: 'quarter'
1353
- });
1354
- // Q1, Q2, Q3, Q4
1355
-
1356
- case 'QQQ':
1357
- return localize.quarter(quarter, {
1358
- width: 'abbreviated',
1359
- context: 'formatting'
1360
- });
1361
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1362
-
1363
- case 'QQQQQ':
1364
- return localize.quarter(quarter, {
1365
- width: 'narrow',
1366
- context: 'formatting'
1367
- });
1368
- // 1st quarter, 2nd quarter, ...
1369
-
1370
- case 'QQQQ':
1371
- default:
1372
- return localize.quarter(quarter, {
1373
- width: 'wide',
1374
- context: 'formatting'
1375
- });
1376
- }
1377
- },
1378
- // Stand-alone quarter
1379
- q: function (date, token, localize) {
1380
- var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
1381
-
1382
- switch (token) {
1383
- // 1, 2, 3, 4
1384
- case 'q':
1385
- return String(quarter);
1386
- // 01, 02, 03, 04
1387
-
1388
- case 'qq':
1389
- return addLeadingZeros(quarter, 2);
1390
- // 1st, 2nd, 3rd, 4th
1391
-
1392
- case 'qo':
1393
- return localize.ordinalNumber(quarter, {
1394
- unit: 'quarter'
1395
- });
1396
- // Q1, Q2, Q3, Q4
1397
-
1398
- case 'qqq':
1399
- return localize.quarter(quarter, {
1400
- width: 'abbreviated',
1401
- context: 'standalone'
1402
- });
1403
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1404
-
1405
- case 'qqqqq':
1406
- return localize.quarter(quarter, {
1407
- width: 'narrow',
1408
- context: 'standalone'
1409
- });
1410
- // 1st quarter, 2nd quarter, ...
1411
-
1412
- case 'qqqq':
1413
- default:
1414
- return localize.quarter(quarter, {
1415
- width: 'wide',
1416
- context: 'standalone'
1417
- });
1418
- }
1419
- },
1420
- // Month
1421
- M: function (date, token, localize) {
1422
- var month = date.getUTCMonth();
1423
-
1424
- switch (token) {
1425
- case 'M':
1426
- case 'MM':
1427
- return formatters$1.M(date, token);
1428
- // 1st, 2nd, ..., 12th
1429
-
1430
- case 'Mo':
1431
- return localize.ordinalNumber(month + 1, {
1432
- unit: 'month'
1433
- });
1434
- // Jan, Feb, ..., Dec
1435
-
1436
- case 'MMM':
1437
- return localize.month(month, {
1438
- width: 'abbreviated',
1439
- context: 'formatting'
1440
- });
1441
- // J, F, ..., D
1442
-
1443
- case 'MMMMM':
1444
- return localize.month(month, {
1445
- width: 'narrow',
1446
- context: 'formatting'
1447
- });
1448
- // January, February, ..., December
1449
-
1450
- case 'MMMM':
1451
- default:
1452
- return localize.month(month, {
1453
- width: 'wide',
1454
- context: 'formatting'
1455
- });
1456
- }
1457
- },
1458
- // Stand-alone month
1459
- L: function (date, token, localize) {
1460
- var month = date.getUTCMonth();
1461
-
1462
- switch (token) {
1463
- // 1, 2, ..., 12
1464
- case 'L':
1465
- return String(month + 1);
1466
- // 01, 02, ..., 12
1467
-
1468
- case 'LL':
1469
- return addLeadingZeros(month + 1, 2);
1470
- // 1st, 2nd, ..., 12th
1471
-
1472
- case 'Lo':
1473
- return localize.ordinalNumber(month + 1, {
1474
- unit: 'month'
1475
- });
1476
- // Jan, Feb, ..., Dec
1477
-
1478
- case 'LLL':
1479
- return localize.month(month, {
1480
- width: 'abbreviated',
1481
- context: 'standalone'
1482
- });
1483
- // J, F, ..., D
1484
-
1485
- case 'LLLLL':
1486
- return localize.month(month, {
1487
- width: 'narrow',
1488
- context: 'standalone'
1489
- });
1490
- // January, February, ..., December
1491
-
1492
- case 'LLLL':
1493
- default:
1494
- return localize.month(month, {
1495
- width: 'wide',
1496
- context: 'standalone'
1497
- });
1498
- }
1499
- },
1500
- // Local week of year
1501
- w: function (date, token, localize, options) {
1502
- var week = getUTCWeek(date, options);
1503
-
1504
- if (token === 'wo') {
1505
- return localize.ordinalNumber(week, {
1506
- unit: 'week'
1507
- });
1508
- }
1509
-
1510
- return addLeadingZeros(week, token.length);
1511
- },
1512
- // ISO week of year
1513
- I: function (date, token, localize) {
1514
- var isoWeek = getUTCISOWeek(date);
1515
-
1516
- if (token === 'Io') {
1517
- return localize.ordinalNumber(isoWeek, {
1518
- unit: 'week'
1519
- });
1520
- }
1521
-
1522
- return addLeadingZeros(isoWeek, token.length);
1523
- },
1524
- // Day of the month
1525
- d: function (date, token, localize) {
1526
- if (token === 'do') {
1527
- return localize.ordinalNumber(date.getUTCDate(), {
1528
- unit: 'date'
1529
- });
1530
- }
1531
-
1532
- return formatters$1.d(date, token);
1533
- },
1534
- // Day of year
1535
- D: function (date, token, localize) {
1536
- var dayOfYear = getUTCDayOfYear(date);
1537
-
1538
- if (token === 'Do') {
1539
- return localize.ordinalNumber(dayOfYear, {
1540
- unit: 'dayOfYear'
1541
- });
1542
- }
1543
-
1544
- return addLeadingZeros(dayOfYear, token.length);
1545
- },
1546
- // Day of week
1547
- E: function (date, token, localize) {
1548
- var dayOfWeek = date.getUTCDay();
1549
-
1550
- switch (token) {
1551
- // Tue
1552
- case 'E':
1553
- case 'EE':
1554
- case 'EEE':
1555
- return localize.day(dayOfWeek, {
1556
- width: 'abbreviated',
1557
- context: 'formatting'
1558
- });
1559
- // T
1560
-
1561
- case 'EEEEE':
1562
- return localize.day(dayOfWeek, {
1563
- width: 'narrow',
1564
- context: 'formatting'
1565
- });
1566
- // Tu
1567
-
1568
- case 'EEEEEE':
1569
- return localize.day(dayOfWeek, {
1570
- width: 'short',
1571
- context: 'formatting'
1572
- });
1573
- // Tuesday
1574
-
1575
- case 'EEEE':
1576
- default:
1577
- return localize.day(dayOfWeek, {
1578
- width: 'wide',
1579
- context: 'formatting'
1580
- });
1581
- }
1582
- },
1583
- // Local day of week
1584
- e: function (date, token, localize, options) {
1585
- var dayOfWeek = date.getUTCDay();
1586
- var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1587
-
1588
- switch (token) {
1589
- // Numerical value (Nth day of week with current locale or weekStartsOn)
1590
- case 'e':
1591
- return String(localDayOfWeek);
1592
- // Padded numerical value
1593
-
1594
- case 'ee':
1595
- return addLeadingZeros(localDayOfWeek, 2);
1596
- // 1st, 2nd, ..., 7th
1597
-
1598
- case 'eo':
1599
- return localize.ordinalNumber(localDayOfWeek, {
1600
- unit: 'day'
1601
- });
1602
-
1603
- case 'eee':
1604
- return localize.day(dayOfWeek, {
1605
- width: 'abbreviated',
1606
- context: 'formatting'
1607
- });
1608
- // T
1609
-
1610
- case 'eeeee':
1611
- return localize.day(dayOfWeek, {
1612
- width: 'narrow',
1613
- context: 'formatting'
1614
- });
1615
- // Tu
1616
-
1617
- case 'eeeeee':
1618
- return localize.day(dayOfWeek, {
1619
- width: 'short',
1620
- context: 'formatting'
1621
- });
1622
- // Tuesday
1623
-
1624
- case 'eeee':
1625
- default:
1626
- return localize.day(dayOfWeek, {
1627
- width: 'wide',
1628
- context: 'formatting'
1629
- });
1630
- }
1631
- },
1632
- // Stand-alone local day of week
1633
- c: function (date, token, localize, options) {
1634
- var dayOfWeek = date.getUTCDay();
1635
- var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1636
-
1637
- switch (token) {
1638
- // Numerical value (same as in `e`)
1639
- case 'c':
1640
- return String(localDayOfWeek);
1641
- // Padded numerical value
1642
-
1643
- case 'cc':
1644
- return addLeadingZeros(localDayOfWeek, token.length);
1645
- // 1st, 2nd, ..., 7th
1646
-
1647
- case 'co':
1648
- return localize.ordinalNumber(localDayOfWeek, {
1649
- unit: 'day'
1650
- });
1651
-
1652
- case 'ccc':
1653
- return localize.day(dayOfWeek, {
1654
- width: 'abbreviated',
1655
- context: 'standalone'
1656
- });
1657
- // T
1658
-
1659
- case 'ccccc':
1660
- return localize.day(dayOfWeek, {
1661
- width: 'narrow',
1662
- context: 'standalone'
1663
- });
1664
- // Tu
1665
-
1666
- case 'cccccc':
1667
- return localize.day(dayOfWeek, {
1668
- width: 'short',
1669
- context: 'standalone'
1670
- });
1671
- // Tuesday
1672
-
1673
- case 'cccc':
1674
- default:
1675
- return localize.day(dayOfWeek, {
1676
- width: 'wide',
1677
- context: 'standalone'
1678
- });
1679
- }
1680
- },
1681
- // ISO day of week
1682
- i: function (date, token, localize) {
1683
- var dayOfWeek = date.getUTCDay();
1684
- var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
1685
-
1686
- switch (token) {
1687
- // 2
1688
- case 'i':
1689
- return String(isoDayOfWeek);
1690
- // 02
1691
-
1692
- case 'ii':
1693
- return addLeadingZeros(isoDayOfWeek, token.length);
1694
- // 2nd
1695
-
1696
- case 'io':
1697
- return localize.ordinalNumber(isoDayOfWeek, {
1698
- unit: 'day'
1699
- });
1700
- // Tue
1701
-
1702
- case 'iii':
1703
- return localize.day(dayOfWeek, {
1704
- width: 'abbreviated',
1705
- context: 'formatting'
1706
- });
1707
- // T
1708
-
1709
- case 'iiiii':
1710
- return localize.day(dayOfWeek, {
1711
- width: 'narrow',
1712
- context: 'formatting'
1713
- });
1714
- // Tu
1715
-
1716
- case 'iiiiii':
1717
- return localize.day(dayOfWeek, {
1718
- width: 'short',
1719
- context: 'formatting'
1720
- });
1721
- // Tuesday
1722
-
1723
- case 'iiii':
1724
- default:
1725
- return localize.day(dayOfWeek, {
1726
- width: 'wide',
1727
- context: 'formatting'
1728
- });
1729
- }
1730
- },
1731
- // AM or PM
1732
- a: function (date, token, localize) {
1733
- var hours = date.getUTCHours();
1734
- var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1735
-
1736
- switch (token) {
1737
- case 'a':
1738
- case 'aa':
1739
- return localize.dayPeriod(dayPeriodEnumValue, {
1740
- width: 'abbreviated',
1741
- context: 'formatting'
1742
- });
1743
-
1744
- case 'aaa':
1745
- return localize.dayPeriod(dayPeriodEnumValue, {
1746
- width: 'abbreviated',
1747
- context: 'formatting'
1748
- }).toLowerCase();
1749
-
1750
- case 'aaaaa':
1751
- return localize.dayPeriod(dayPeriodEnumValue, {
1752
- width: 'narrow',
1753
- context: 'formatting'
1754
- });
1755
-
1756
- case 'aaaa':
1757
- default:
1758
- return localize.dayPeriod(dayPeriodEnumValue, {
1759
- width: 'wide',
1760
- context: 'formatting'
1761
- });
1762
- }
1763
- },
1764
- // AM, PM, midnight, noon
1765
- b: function (date, token, localize) {
1766
- var hours = date.getUTCHours();
1767
- var dayPeriodEnumValue;
1768
-
1769
- if (hours === 12) {
1770
- dayPeriodEnumValue = dayPeriodEnum.noon;
1771
- } else if (hours === 0) {
1772
- dayPeriodEnumValue = dayPeriodEnum.midnight;
1773
- } else {
1774
- dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1775
- }
1776
-
1777
- switch (token) {
1778
- case 'b':
1779
- case 'bb':
1780
- return localize.dayPeriod(dayPeriodEnumValue, {
1781
- width: 'abbreviated',
1782
- context: 'formatting'
1783
- });
1784
-
1785
- case 'bbb':
1786
- return localize.dayPeriod(dayPeriodEnumValue, {
1787
- width: 'abbreviated',
1788
- context: 'formatting'
1789
- }).toLowerCase();
1790
-
1791
- case 'bbbbb':
1792
- return localize.dayPeriod(dayPeriodEnumValue, {
1793
- width: 'narrow',
1794
- context: 'formatting'
1795
- });
1796
-
1797
- case 'bbbb':
1798
- default:
1799
- return localize.dayPeriod(dayPeriodEnumValue, {
1800
- width: 'wide',
1801
- context: 'formatting'
1802
- });
1803
- }
1804
- },
1805
- // in the morning, in the afternoon, in the evening, at night
1806
- B: function (date, token, localize) {
1807
- var hours = date.getUTCHours();
1808
- var dayPeriodEnumValue;
1809
-
1810
- if (hours >= 17) {
1811
- dayPeriodEnumValue = dayPeriodEnum.evening;
1812
- } else if (hours >= 12) {
1813
- dayPeriodEnumValue = dayPeriodEnum.afternoon;
1814
- } else if (hours >= 4) {
1815
- dayPeriodEnumValue = dayPeriodEnum.morning;
1816
- } else {
1817
- dayPeriodEnumValue = dayPeriodEnum.night;
1818
- }
1819
-
1820
- switch (token) {
1821
- case 'B':
1822
- case 'BB':
1823
- case 'BBB':
1824
- return localize.dayPeriod(dayPeriodEnumValue, {
1825
- width: 'abbreviated',
1826
- context: 'formatting'
1827
- });
1828
-
1829
- case 'BBBBB':
1830
- return localize.dayPeriod(dayPeriodEnumValue, {
1831
- width: 'narrow',
1832
- context: 'formatting'
1833
- });
1834
-
1835
- case 'BBBB':
1836
- default:
1837
- return localize.dayPeriod(dayPeriodEnumValue, {
1838
- width: 'wide',
1839
- context: 'formatting'
1840
- });
1841
- }
1842
- },
1843
- // Hour [1-12]
1844
- h: function (date, token, localize) {
1845
- if (token === 'ho') {
1846
- var hours = date.getUTCHours() % 12;
1847
- if (hours === 0) hours = 12;
1848
- return localize.ordinalNumber(hours, {
1849
- unit: 'hour'
1850
- });
1851
- }
1852
-
1853
- return formatters$1.h(date, token);
1854
- },
1855
- // Hour [0-23]
1856
- H: function (date, token, localize) {
1857
- if (token === 'Ho') {
1858
- return localize.ordinalNumber(date.getUTCHours(), {
1859
- unit: 'hour'
1860
- });
1861
- }
1862
-
1863
- return formatters$1.H(date, token);
1864
- },
1865
- // Hour [0-11]
1866
- K: function (date, token, localize) {
1867
- var hours = date.getUTCHours() % 12;
1868
-
1869
- if (token === 'Ko') {
1870
- return localize.ordinalNumber(hours, {
1871
- unit: 'hour'
1872
- });
1873
- }
1874
-
1875
- return addLeadingZeros(hours, token.length);
1876
- },
1877
- // Hour [1-24]
1878
- k: function (date, token, localize) {
1879
- var hours = date.getUTCHours();
1880
- if (hours === 0) hours = 24;
1881
-
1882
- if (token === 'ko') {
1883
- return localize.ordinalNumber(hours, {
1884
- unit: 'hour'
1885
- });
1886
- }
1887
-
1888
- return addLeadingZeros(hours, token.length);
1889
- },
1890
- // Minute
1891
- m: function (date, token, localize) {
1892
- if (token === 'mo') {
1893
- return localize.ordinalNumber(date.getUTCMinutes(), {
1894
- unit: 'minute'
1895
- });
1896
- }
1897
-
1898
- return formatters$1.m(date, token);
1899
- },
1900
- // Second
1901
- s: function (date, token, localize) {
1902
- if (token === 'so') {
1903
- return localize.ordinalNumber(date.getUTCSeconds(), {
1904
- unit: 'second'
1905
- });
1906
- }
1907
-
1908
- return formatters$1.s(date, token);
1909
- },
1910
- // Fraction of second
1911
- S: function (date, token) {
1912
- return formatters$1.S(date, token);
1913
- },
1914
- // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1915
- X: function (date, token, _localize, options) {
1916
- var originalDate = options._originalDate || date;
1917
- var timezoneOffset = originalDate.getTimezoneOffset();
1918
-
1919
- if (timezoneOffset === 0) {
1920
- return 'Z';
1921
- }
1922
-
1923
- switch (token) {
1924
- // Hours and optional minutes
1925
- case 'X':
1926
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
1927
- // Hours, minutes and optional seconds without `:` delimiter
1928
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1929
- // so this token always has the same output as `XX`
1930
-
1931
- case 'XXXX':
1932
- case 'XX':
1933
- // Hours and minutes without `:` delimiter
1934
- return formatTimezone(timezoneOffset);
1935
- // Hours, minutes and optional seconds with `:` delimiter
1936
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1937
- // so this token always has the same output as `XXX`
1938
-
1939
- case 'XXXXX':
1940
- case 'XXX': // Hours and minutes with `:` delimiter
1941
-
1942
- default:
1943
- return formatTimezone(timezoneOffset, ':');
1944
- }
1945
- },
1946
- // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1947
- x: function (date, token, _localize, options) {
1948
- var originalDate = options._originalDate || date;
1949
- var timezoneOffset = originalDate.getTimezoneOffset();
1950
-
1951
- switch (token) {
1952
- // Hours and optional minutes
1953
- case 'x':
1954
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
1955
- // Hours, minutes and optional seconds without `:` delimiter
1956
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1957
- // so this token always has the same output as `xx`
1958
-
1959
- case 'xxxx':
1960
- case 'xx':
1961
- // Hours and minutes without `:` delimiter
1962
- return formatTimezone(timezoneOffset);
1963
- // Hours, minutes and optional seconds with `:` delimiter
1964
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1965
- // so this token always has the same output as `xxx`
1966
-
1967
- case 'xxxxx':
1968
- case 'xxx': // Hours and minutes with `:` delimiter
1969
-
1970
- default:
1971
- return formatTimezone(timezoneOffset, ':');
1972
- }
1973
- },
1974
- // Timezone (GMT)
1975
- O: function (date, token, _localize, options) {
1976
- var originalDate = options._originalDate || date;
1977
- var timezoneOffset = originalDate.getTimezoneOffset();
1978
-
1979
- switch (token) {
1980
- // Short
1981
- case 'O':
1982
- case 'OO':
1983
- case 'OOO':
1984
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1985
- // Long
1986
-
1987
- case 'OOOO':
1988
- default:
1989
- return 'GMT' + formatTimezone(timezoneOffset, ':');
1990
- }
1991
- },
1992
- // Timezone (specific non-location)
1993
- z: function (date, token, _localize, options) {
1994
- var originalDate = options._originalDate || date;
1995
- var timezoneOffset = originalDate.getTimezoneOffset();
1996
-
1997
- switch (token) {
1998
- // Short
1999
- case 'z':
2000
- case 'zz':
2001
- case 'zzz':
2002
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
2003
- // Long
2004
-
2005
- case 'zzzz':
2006
- default:
2007
- return 'GMT' + formatTimezone(timezoneOffset, ':');
2008
- }
2009
- },
2010
- // Seconds timestamp
2011
- t: function (date, token, _localize, options) {
2012
- var originalDate = options._originalDate || date;
2013
- var timestamp = Math.floor(originalDate.getTime() / 1000);
2014
- return addLeadingZeros(timestamp, token.length);
2015
- },
2016
- // Milliseconds timestamp
2017
- T: function (date, token, _localize, options) {
2018
- var originalDate = options._originalDate || date;
2019
- var timestamp = originalDate.getTime();
2020
- return addLeadingZeros(timestamp, token.length);
2021
- }
2022
- };
2023
-
2024
- function formatTimezoneShort(offset, dirtyDelimiter) {
2025
- var sign = offset > 0 ? '-' : '+';
2026
- var absOffset = Math.abs(offset);
2027
- var hours = Math.floor(absOffset / 60);
2028
- var minutes = absOffset % 60;
2029
-
2030
- if (minutes === 0) {
2031
- return sign + String(hours);
2032
- }
2033
-
2034
- var delimiter = dirtyDelimiter || '';
2035
- return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
2036
- }
2037
-
2038
- function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
2039
- if (offset % 60 === 0) {
2040
- var sign = offset > 0 ? '-' : '+';
2041
- return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
2042
- }
2043
-
2044
- return formatTimezone(offset, dirtyDelimiter);
2045
- }
2046
-
2047
- function formatTimezone(offset, dirtyDelimiter) {
2048
- var delimiter = dirtyDelimiter || '';
2049
- var sign = offset > 0 ? '-' : '+';
2050
- var absOffset = Math.abs(offset);
2051
- var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
2052
- var minutes = addLeadingZeros(absOffset % 60, 2);
2053
- return sign + hours + delimiter + minutes;
2054
- }
2055
-
2056
- function dateLongFormatter(pattern, formatLong) {
2057
- switch (pattern) {
2058
- case 'P':
2059
- return formatLong.date({
2060
- width: 'short'
2061
- });
2062
-
2063
- case 'PP':
2064
- return formatLong.date({
2065
- width: 'medium'
2066
- });
2067
-
2068
- case 'PPP':
2069
- return formatLong.date({
2070
- width: 'long'
2071
- });
2072
-
2073
- case 'PPPP':
2074
- default:
2075
- return formatLong.date({
2076
- width: 'full'
2077
- });
2078
- }
2079
- }
2080
-
2081
- function timeLongFormatter(pattern, formatLong) {
2082
- switch (pattern) {
2083
- case 'p':
2084
- return formatLong.time({
2085
- width: 'short'
2086
- });
2087
-
2088
- case 'pp':
2089
- return formatLong.time({
2090
- width: 'medium'
2091
- });
2092
-
2093
- case 'ppp':
2094
- return formatLong.time({
2095
- width: 'long'
2096
- });
2097
-
2098
- case 'pppp':
2099
- default:
2100
- return formatLong.time({
2101
- width: 'full'
2102
- });
2103
- }
2104
- }
2105
-
2106
- function dateTimeLongFormatter(pattern, formatLong) {
2107
- var matchResult = pattern.match(/(P+)(p+)?/);
2108
- var datePattern = matchResult[1];
2109
- var timePattern = matchResult[2];
2110
-
2111
- if (!timePattern) {
2112
- return dateLongFormatter(pattern, formatLong);
2113
- }
2114
-
2115
- var dateTimeFormat;
2116
-
2117
- switch (datePattern) {
2118
- case 'P':
2119
- dateTimeFormat = formatLong.dateTime({
2120
- width: 'short'
2121
- });
2122
- break;
2123
-
2124
- case 'PP':
2125
- dateTimeFormat = formatLong.dateTime({
2126
- width: 'medium'
2127
- });
2128
- break;
2129
-
2130
- case 'PPP':
2131
- dateTimeFormat = formatLong.dateTime({
2132
- width: 'long'
2133
- });
2134
- break;
2135
-
2136
- case 'PPPP':
2137
- default:
2138
- dateTimeFormat = formatLong.dateTime({
2139
- width: 'full'
2140
- });
2141
- break;
2142
- }
2143
-
2144
- return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
2145
- }
2146
-
2147
- var longFormatters = {
2148
- p: timeLongFormatter,
2149
- P: dateTimeLongFormatter
2150
- };
2151
-
2152
- var protectedDayOfYearTokens = ['D', 'DD'];
2153
- var protectedWeekYearTokens = ['YY', 'YYYY'];
2154
- function isProtectedDayOfYearToken(token) {
2155
- return protectedDayOfYearTokens.indexOf(token) !== -1;
2156
- }
2157
- function isProtectedWeekYearToken(token) {
2158
- return protectedWeekYearTokens.indexOf(token) !== -1;
2159
- }
2160
- function throwProtectedError(token, format, input) {
2161
- if (token === 'YYYY') {
2162
- throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
2163
- } else if (token === 'YY') {
2164
- throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
2165
- } else if (token === 'D') {
2166
- throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr"));
2167
- } else if (token === 'DD') {
2168
- throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr"));
2169
- }
2170
- }
2171
-
2172
- // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
2173
- // (one of the certain letters followed by `o`)
2174
- // - (\w)\1* matches any sequences of the same letter
2175
- // - '' matches two quote characters in a row
2176
- // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
2177
- // except a single quote symbol, which ends the sequence.
2178
- // Two quote characters do not end the sequence.
2179
- // If there is no matching single quote
2180
- // then the sequence will continue until the end of the string.
2181
- // - . matches any single character unmatched by previous parts of the RegExps
2182
-
2183
- var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; // This RegExp catches symbols escaped by quotes, and also
2184
- // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
2185
-
2186
- var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2187
- var escapedStringRegExp = /^'([^]*?)'?$/;
2188
- var doubleQuoteRegExp = /''/g;
2189
- var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2190
- /**
2191
- * @name format
2192
- * @category Common Helpers
2193
- * @summary Format the date.
2194
- *
2195
- * @description
2196
- * Return the formatted date string in the given format. The result may vary by locale.
2197
- *
2198
- * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
2199
- * > See: https://git.io/fxCyr
2200
- *
2201
- * The characters wrapped between two single quotes characters (') are escaped.
2202
- * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
2203
- * (see the last example)
2204
- *
2205
- * Format of the string is based on Unicode Technical Standard #35:
2206
- * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
2207
- * with a few additions (see note 7 below the table).
2208
- *
2209
- * Accepted patterns:
2210
- * | Unit | Pattern | Result examples | Notes |
2211
- * |---------------------------------|---------|-----------------------------------|-------|
2212
- * | Era | G..GGG | AD, BC | |
2213
- * | | GGGG | Anno Domini, Before Christ | 2 |
2214
- * | | GGGGG | A, B | |
2215
- * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
2216
- * | | yo | 44th, 1st, 0th, 17th | 5,7 |
2217
- * | | yy | 44, 01, 00, 17 | 5 |
2218
- * | | yyy | 044, 001, 1900, 2017 | 5 |
2219
- * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
2220
- * | | yyyyy | ... | 3,5 |
2221
- * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
2222
- * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
2223
- * | | YY | 44, 01, 00, 17 | 5,8 |
2224
- * | | YYY | 044, 001, 1900, 2017 | 5 |
2225
- * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
2226
- * | | YYYYY | ... | 3,5 |
2227
- * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
2228
- * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
2229
- * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
2230
- * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
2231
- * | | RRRRR | ... | 3,5,7 |
2232
- * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
2233
- * | | uu | -43, 01, 1900, 2017 | 5 |
2234
- * | | uuu | -043, 001, 1900, 2017 | 5 |
2235
- * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
2236
- * | | uuuuu | ... | 3,5 |
2237
- * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
2238
- * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
2239
- * | | QQ | 01, 02, 03, 04 | |
2240
- * | | QQQ | Q1, Q2, Q3, Q4 | |
2241
- * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
2242
- * | | QQQQQ | 1, 2, 3, 4 | 4 |
2243
- * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
2244
- * | | qo | 1st, 2nd, 3rd, 4th | 7 |
2245
- * | | qq | 01, 02, 03, 04 | |
2246
- * | | qqq | Q1, Q2, Q3, Q4 | |
2247
- * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
2248
- * | | qqqqq | 1, 2, 3, 4 | 4 |
2249
- * | Month (formatting) | M | 1, 2, ..., 12 | |
2250
- * | | Mo | 1st, 2nd, ..., 12th | 7 |
2251
- * | | MM | 01, 02, ..., 12 | |
2252
- * | | MMM | Jan, Feb, ..., Dec | |
2253
- * | | MMMM | January, February, ..., December | 2 |
2254
- * | | MMMMM | J, F, ..., D | |
2255
- * | Month (stand-alone) | L | 1, 2, ..., 12 | |
2256
- * | | Lo | 1st, 2nd, ..., 12th | 7 |
2257
- * | | LL | 01, 02, ..., 12 | |
2258
- * | | LLL | Jan, Feb, ..., Dec | |
2259
- * | | LLLL | January, February, ..., December | 2 |
2260
- * | | LLLLL | J, F, ..., D | |
2261
- * | Local week of year | w | 1, 2, ..., 53 | |
2262
- * | | wo | 1st, 2nd, ..., 53th | 7 |
2263
- * | | ww | 01, 02, ..., 53 | |
2264
- * | ISO week of year | I | 1, 2, ..., 53 | 7 |
2265
- * | | Io | 1st, 2nd, ..., 53th | 7 |
2266
- * | | II | 01, 02, ..., 53 | 7 |
2267
- * | Day of month | d | 1, 2, ..., 31 | |
2268
- * | | do | 1st, 2nd, ..., 31st | 7 |
2269
- * | | dd | 01, 02, ..., 31 | |
2270
- * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
2271
- * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
2272
- * | | DD | 01, 02, ..., 365, 366 | 9 |
2273
- * | | DDD | 001, 002, ..., 365, 366 | |
2274
- * | | DDDD | ... | 3 |
2275
- * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
2276
- * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
2277
- * | | EEEEE | M, T, W, T, F, S, S | |
2278
- * | | EEEEEE | Mo, Tu, We, Th, Fr, Su, Sa | |
2279
- * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
2280
- * | | io | 1st, 2nd, ..., 7th | 7 |
2281
- * | | ii | 01, 02, ..., 07 | 7 |
2282
- * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
2283
- * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
2284
- * | | iiiii | M, T, W, T, F, S, S | 7 |
2285
- * | | iiiiii | Mo, Tu, We, Th, Fr, Su, Sa | 7 |
2286
- * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
2287
- * | | eo | 2nd, 3rd, ..., 1st | 7 |
2288
- * | | ee | 02, 03, ..., 01 | |
2289
- * | | eee | Mon, Tue, Wed, ..., Sun | |
2290
- * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
2291
- * | | eeeee | M, T, W, T, F, S, S | |
2292
- * | | eeeeee | Mo, Tu, We, Th, Fr, Su, Sa | |
2293
- * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2294
- * | | co | 2nd, 3rd, ..., 1st | 7 |
2295
- * | | cc | 02, 03, ..., 01 | |
2296
- * | | ccc | Mon, Tue, Wed, ..., Sun | |
2297
- * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2298
- * | | ccccc | M, T, W, T, F, S, S | |
2299
- * | | cccccc | Mo, Tu, We, Th, Fr, Su, Sa | |
2300
- * | AM, PM | a..aa | AM, PM | |
2301
- * | | aaa | am, pm | |
2302
- * | | aaaa | a.m., p.m. | 2 |
2303
- * | | aaaaa | a, p | |
2304
- * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2305
- * | | bbb | am, pm, noon, midnight | |
2306
- * | | bbbb | a.m., p.m., noon, midnight | 2 |
2307
- * | | bbbbb | a, p, n, mi | |
2308
- * | Flexible day period | B..BBB | at night, in the morning, ... | |
2309
- * | | BBBB | at night, in the morning, ... | 2 |
2310
- * | | BBBBB | at night, in the morning, ... | |
2311
- * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2312
- * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2313
- * | | hh | 01, 02, ..., 11, 12 | |
2314
- * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2315
- * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2316
- * | | HH | 00, 01, 02, ..., 23 | |
2317
- * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2318
- * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2319
- * | | KK | 01, 02, ..., 11, 00 | |
2320
- * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2321
- * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2322
- * | | kk | 24, 01, 02, ..., 23 | |
2323
- * | Minute | m | 0, 1, ..., 59 | |
2324
- * | | mo | 0th, 1st, ..., 59th | 7 |
2325
- * | | mm | 00, 01, ..., 59 | |
2326
- * | Second | s | 0, 1, ..., 59 | |
2327
- * | | so | 0th, 1st, ..., 59th | 7 |
2328
- * | | ss | 00, 01, ..., 59 | |
2329
- * | Fraction of second | S | 0, 1, ..., 9 | |
2330
- * | | SS | 00, 01, ..., 99 | |
2331
- * | | SSS | 000, 001, ..., 999 | |
2332
- * | | SSSS | ... | 3 |
2333
- * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2334
- * | | XX | -0800, +0530, Z | |
2335
- * | | XXX | -08:00, +05:30, Z | |
2336
- * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2337
- * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2338
- * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2339
- * | | xx | -0800, +0530, +0000 | |
2340
- * | | xxx | -08:00, +05:30, +00:00 | 2 |
2341
- * | | xxxx | -0800, +0530, +0000, +123456 | |
2342
- * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2343
- * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2344
- * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2345
- * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2346
- * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2347
- * | Seconds timestamp | t | 512969520 | 7 |
2348
- * | | tt | ... | 3,7 |
2349
- * | Milliseconds timestamp | T | 512969520900 | 7 |
2350
- * | | TT | ... | 3,7 |
2351
- * | Long localized date | P | 04/29/1453 | 7 |
2352
- * | | PP | Apr 29, 1453 | 7 |
2353
- * | | PPP | April 29th, 1453 | 7 |
2354
- * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2355
- * | Long localized time | p | 12:00 AM | 7 |
2356
- * | | pp | 12:00:00 AM | 7 |
2357
- * | | ppp | 12:00:00 AM GMT+2 | 7 |
2358
- * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2359
- * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2360
- * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2361
- * | | PPPppp | April 29th, 1453 at ... | 7 |
2362
- * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2363
- * Notes:
2364
- * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2365
- * are the same as "stand-alone" units, but are different in some languages.
2366
- * "Formatting" units are declined according to the rules of the language
2367
- * in the context of a date. "Stand-alone" units are always nominative singular:
2368
- *
2369
- * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2370
- *
2371
- * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2372
- *
2373
- * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2374
- * the single quote characters (see below).
2375
- * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2376
- * the output will be the same as default pattern for this unit, usually
2377
- * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2378
- * are marked with "2" in the last column of the table.
2379
- *
2380
- * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2381
- *
2382
- * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2383
- *
2384
- * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2385
- *
2386
- * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2387
- *
2388
- * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2389
- *
2390
- * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2391
- * The output will be padded with zeros to match the length of the pattern.
2392
- *
2393
- * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2394
- *
2395
- * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2396
- * These tokens represent the shortest form of the quarter.
2397
- *
2398
- * 5. The main difference between `y` and `u` patterns are B.C. years:
2399
- *
2400
- * | Year | `y` | `u` |
2401
- * |------|-----|-----|
2402
- * | AC 1 | 1 | 1 |
2403
- * | BC 1 | 1 | 0 |
2404
- * | BC 2 | 2 | -1 |
2405
- *
2406
- * Also `yy` always returns the last two digits of a year,
2407
- * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2408
- *
2409
- * | Year | `yy` | `uu` |
2410
- * |------|------|------|
2411
- * | 1 | 01 | 01 |
2412
- * | 14 | 14 | 14 |
2413
- * | 376 | 76 | 376 |
2414
- * | 1453 | 53 | 1453 |
2415
- *
2416
- * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2417
- * except local week-numbering years are dependent on `options.weekStartsOn`
2418
- * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2419
- * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2420
- *
2421
- * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2422
- * so right now these tokens fall back to GMT timezones.
2423
- *
2424
- * 7. These patterns are not in the Unicode Technical Standard #35:
2425
- * - `i`: ISO day of week
2426
- * - `I`: ISO week of year
2427
- * - `R`: ISO week-numbering year
2428
- * - `t`: seconds timestamp
2429
- * - `T`: milliseconds timestamp
2430
- * - `o`: ordinal number modifier
2431
- * - `P`: long localized date
2432
- * - `p`: long localized time
2433
- *
2434
- * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2435
- * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://git.io/fxCyr
2436
- *
2437
- * 9. `D` and `DD` tokens represent days of the year but they are ofthen confused with days of the month.
2438
- * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://git.io/fxCyr
2439
- *
2440
- * ### v2.0.0 breaking changes:
2441
- *
2442
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
2443
- *
2444
- * - The second argument is now required for the sake of explicitness.
2445
- *
2446
- * ```javascript
2447
- * // Before v2.0.0
2448
- * format(new Date(2016, 0, 1))
2449
- *
2450
- * // v2.0.0 onward
2451
- * format(new Date(2016, 0, 1), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")
2452
- * ```
2453
- *
2454
- * - New format string API for `format` function
2455
- * which is based on [Unicode Technical Standard #35](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table).
2456
- * See [this post](https://blog.date-fns.org/post/unicode-tokens-in-date-fns-v2-sreatyki91jg) for more details.
2457
- *
2458
- * - Characters are now escaped using single quote symbols (`'`) instead of square brackets.
2459
- *
2460
- * @param {Date|Number} date - the original date
2461
- * @param {String} format - the string of tokens
2462
- * @param {Object} [options] - an object with options.
2463
- * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2464
- * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2465
- * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2466
- * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2467
- * see: https://git.io/fxCyr
2468
- * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2469
- * see: https://git.io/fxCyr
2470
- * @returns {String} the formatted date string
2471
- * @throws {TypeError} 2 arguments required
2472
- * @throws {RangeError} `date` must not be Invalid Date
2473
- * @throws {RangeError} `options.locale` must contain `localize` property
2474
- * @throws {RangeError} `options.locale` must contain `formatLong` property
2475
- * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2476
- * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2477
- * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://git.io/fxCyr
2478
- * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://git.io/fxCyr
2479
- * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://git.io/fxCyr
2480
- * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://git.io/fxCyr
2481
- * @throws {RangeError} format string contains an unescaped latin alphabet character
2482
- *
2483
- * @example
2484
- * // Represent 11 February 2014 in middle-endian format:
2485
- * var result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2486
- * //=> '02/11/2014'
2487
- *
2488
- * @example
2489
- * // Represent 2 July 2014 in Esperanto:
2490
- * import { eoLocale } from 'date-fns/locale/eo'
2491
- * var result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2492
- * locale: eoLocale
2493
- * })
2494
- * //=> '2-a de julio 2014'
2495
- *
2496
- * @example
2497
- * // Escape string by single quote characters:
2498
- * var result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2499
- * //=> "3 o'clock"
2500
- */
2501
-
2502
- function format(dirtyDate, dirtyFormatStr, dirtyOptions) {
2503
- requiredArgs(2, arguments);
2504
- var formatStr = String(dirtyFormatStr);
2505
- var options = dirtyOptions || {};
2506
- var locale$1 = options.locale || locale;
2507
- var localeFirstWeekContainsDate = locale$1.options && locale$1.options.firstWeekContainsDate;
2508
- var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
2509
- var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2510
-
2511
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2512
- throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2513
- }
2514
-
2515
- var localeWeekStartsOn = locale$1.options && locale$1.options.weekStartsOn;
2516
- var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
2517
- var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2518
-
2519
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2520
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2521
- }
2522
-
2523
- if (!locale$1.localize) {
2524
- throw new RangeError('locale must contain localize property');
2525
- }
2526
-
2527
- if (!locale$1.formatLong) {
2528
- throw new RangeError('locale must contain formatLong property');
2529
- }
2530
-
2531
- var originalDate = toDate(dirtyDate);
2532
-
2533
- if (!isValid(originalDate)) {
2534
- throw new RangeError('Invalid time value');
2535
- } // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2536
- // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2537
- // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2538
-
2539
-
2540
- var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2541
- var utcDate = subMilliseconds(originalDate, timezoneOffset);
2542
- var formatterOptions = {
2543
- firstWeekContainsDate: firstWeekContainsDate,
2544
- weekStartsOn: weekStartsOn,
2545
- locale: locale$1,
2546
- _originalDate: originalDate
2547
- };
2548
- var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2549
- var firstCharacter = substring[0];
2550
-
2551
- if (firstCharacter === 'p' || firstCharacter === 'P') {
2552
- var longFormatter = longFormatters[firstCharacter];
2553
- return longFormatter(substring, locale$1.formatLong, formatterOptions);
2554
- }
2555
-
2556
- return substring;
2557
- }).join('').match(formattingTokensRegExp).map(function (substring) {
2558
- // Replace two single quote characters with one single quote character
2559
- if (substring === "''") {
2560
- return "'";
2561
- }
2562
-
2563
- var firstCharacter = substring[0];
2564
-
2565
- if (firstCharacter === "'") {
2566
- return cleanEscapedString(substring);
2567
- }
2568
-
2569
- var formatter = formatters[firstCharacter];
2570
-
2571
- if (formatter) {
2572
- if (!options.useAdditionalWeekYearTokens && isProtectedWeekYearToken(substring)) {
2573
- throwProtectedError(substring, dirtyFormatStr, dirtyDate);
2574
- }
2575
-
2576
- if (!options.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(substring)) {
2577
- throwProtectedError(substring, dirtyFormatStr, dirtyDate);
2578
- }
2579
-
2580
- return formatter(utcDate, substring, locale$1.localize, formatterOptions);
2581
- }
2582
-
2583
- if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2584
- throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2585
- }
2586
-
2587
- return substring;
2588
- }).join('');
2589
- return result;
2590
- }
2591
-
2592
- function cleanEscapedString(input) {
2593
- return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, "'");
2594
- }
2595
-
2596
- const modelVariantsSectionComponentCss = ".abe-car-icon{max-width:120px;height:80px;object-fit:contain}.abe-fade-in-bottom{-webkit-animation:fade-in-bottom 0.3s cubic-bezier(0.39, 0.575, 0.565, 1) both;animation:fade-in-bottom 0.3s cubic-bezier(0.39, 0.575, 0.565, 1) both}@-webkit-keyframes fade-in-bottom{0%{-webkit-transform:translateY(50px);transform:translateY(50px);opacity:0}100%{-webkit-transform:translateY(0);transform:translateY(0);opacity:1}}@keyframes fade-in-bottom{0%{-webkit-transform:translateY(50px);transform:translateY(50px);opacity:0}100%{-webkit-transform:translateY(0);transform:translateY(0);opacity:1}}";
2597
-
2598
- const ModelVariantsSection = class {
2599
- constructor(hostRef) {
2600
- registerInstance(this, hostRef);
2601
- this.variantsList = [];
2602
- this.selectedVariant = none;
2603
- this.placeholderImage = getAssetPath('./assets/car-placeholder.svg');
2604
- }
2605
- componentWillLoad() {
2606
- sessionQuery.selectedVariant$.subscribe((state) => {
2607
- this.selectedVariant = state;
2608
- });
2609
- sessionQuery.modelVariantsList$.subscribe((state) => {
2610
- this.variantsList = getOrDefault(state, []);
2611
- });
2612
- }
2613
- render() {
2614
- return (h(Host, { class: "d-flex flex-column justify-content-start align-items-center abe-fade-in-bottom" }, isNone(this.selectedVariant) ? (this.variantsList.length > 0 ? (this.variantsList.map((variant) => this.variantCard(variant, false))) : (h("fl-loading-indicator", { class: "mt-5" }))) : (this.variantCard(this.selectedVariant.value, true))));
2615
- }
2616
- variantCard(variant, isSelected) {
2617
- const imgSrc = getOrDefault(variant.photoUri, this.placeholderImage);
2618
- const toVariantFuelType = (fuelTypeId) => {
2619
- switch (fuelTypeId) {
2620
- case 100029:
2621
- case 100032:
2622
- return 'Diesel';
2623
- case 100035:
2624
- return 'Electric';
2625
- case 100030:
2626
- case 100031:
2627
- return 'LPG';
2628
- case 100033:
2629
- case 100034:
2630
- return 'Petrol';
2631
- default:
2632
- return '';
2633
- }
2634
- };
2635
- const toEngineDescription = (variant) => {
2636
- return `${variant.engineLitres.toFixed(1)}L ${toVariantFuelType(variant.fuelTypeId)}`.trimEnd();
2637
- };
2638
- const toVariantDescription = (variant) => `${variant.description.toLowerCase().trimEnd()}, ${toEngineDescription(variant)}, ${variant.transmission.toLowerCase()}`;
2639
- return (h("div", { class: "card d-flex w-100 flex-row justify-content-between align-items-center mt-3" }, h("img", { class: "abe-car-icon mx-4 d-none d-md-flex", src: imgSrc, alt: "", onError: (e) => this.handleImgError(e) }), h("div", { class: "d-flex flex-column align-items-start flex-grow-1 px-3 py-2 p-md-0" }, h("h5", { class: "card-title text-capitalize mb-0" }, toVariantDescription(variant)), h("p", { class: "card-text text-muted" }, "Built from ", this.toMonthName(variant.modelMonth), " ", variant.buildYear)), isSelected ? (h("fl-button", { class: "ml-3 mr-4", variant: "secondary", onClick: () => this.resetVariant() }, h("span", { class: "px-3" }, "Change"))) : (h("fl-button", { class: "ml-3 mr-4", onClick: () => this.chooseVariant(variant) }, h("span", { class: "px-3" }, "Select")))));
2640
- }
2641
- toMonthName(monthNumber) {
2642
- return format(new Date().setMonth(monthNumber), 'MMMM');
2643
- }
2644
- resetVariant() {
2645
- carsCalculatorService.selectVariant(none);
2646
- eventTrackingService.trackStepProgressedAsync({ stepName: 'variantSelection' });
2647
- }
2648
- chooseVariant(variant) {
2649
- viewService.scrollToTop();
2650
- carsCalculatorService.selectVariant(some(variant));
2651
- eventTrackingService.trackStepProgressedAsync({ stepName: 'leaseInformation' });
2652
- eventTrackingService.trackInputChangedAsync({
2653
- key: 'variant',
2654
- value: variant.description
2655
- });
2656
- }
2657
- handleImgError(event) {
2658
- event.target.src = this.placeholderImage;
2659
- }
2660
- static get assetsDirs() { return ["assets"]; }
2661
- };
2662
- ModelVariantsSection.style = modelVariantsSectionComponentCss;
2663
-
2664
- const generateTermsOptionsArray = (years) => [...Array(years).keys()]
2665
- .map((n) => n + 1)
2666
- .map((n) => ({
2667
- label: `${n} Year${n > 1 ? 's' : ''}`,
2668
- value: n
2669
- }));
2670
- const PersonalInfoSection = class {
2671
- constructor(hostRef) {
2672
- registerInstance(this, hostRef);
2673
- this.terms = generateTermsOptionsArray(5);
2674
- this.states = ['ACT', 'NSW', 'NT', 'QLD', 'SA', 'TAS', 'VIC', 'WA'];
2675
- this.paymentPeriods = ['Monthly', 'Fortnightly', 'Weekly'];
2676
- sessionQuery.user$.subscribe((state) => (this.userInfo = state));
2677
- }
2678
- render() {
2679
- return (h(Host, { class: "d-flex flex-column align-items-start justify-content-between" }, h("div", { class: "d-flex flex-column flex-lg-row align-items-start align-items-lg-center justify-content-center mt-2 h4" }, h("span", { class: "pr-0 pr-sm-2 d-flex text-center" }, "My annual salary before tax is"), h("input", { placeholder: "50000", type: "text", class: "form-control d-flex w-auto mt-2 mt-lg-0", value: '$' + this.getUserInfo('annualSalary'), onInput: (e) => {
2680
- const el = e.target;
2681
- el.value = el.value.replace(/\D/g, '');
2682
- }, onFocus: (e) => {
2683
- const el = e.target;
2684
- el.value = el.value.replace('$', '');
2685
- }, onBlur: (e) => {
2686
- const el = e.target;
2687
- el.value = '$' + el.value;
2688
- }, onChange: (e) => this.updateUserInfo('annualSalary', parseFloat(e.target.value.trim())) })), h("div", { class: "d-flex flex-column flex-lg-row align-items-start align-items-lg-center justify-content-center mt-4 h4" }, h("span", { class: "pr-0 pr-sm-2 d-flex text-center" }, "I get paid"), h("fl-dropdown", { class: "d-flex my-2 my-lg-0", options: toSelectInputOptionsArray(this.paymentPeriods), requiredValidationMessage: "Select an option", placeholder: "Select...", value: this.getUserInfo('paymentPeriod'), onValueChanged: (e) => this.updateUserInfo('paymentPeriod', e.detail.value) })), h("div", { class: "d-flex flex-column flex-lg-row align-items-start align-items-lg-center justify-content-center mt-4 h4" }, h("span", { class: "pr-0 pr-sm-2 d-flex text-center" }, "Every year I expect to drive"), h("input", { placeholder: "10000", type: "text", class: "form-control d-flex w-auto mt-2 mt-lg-0", value: this.getUserInfo('annualKms') + ' km', onInput: (e) => {
2689
- const el = e.target;
2690
- el.value = el.value.replace(/\D/g, '');
2691
- }, onFocus: (e) => {
2692
- const el = e.target;
2693
- el.value = el.value.replace(' km', '');
2694
- }, onBlur: (e) => {
2695
- const el = e.target;
2696
- el.value += ' km';
2697
- }, onChange: (ev) => this.updateUserInfo('annualKms', parseInt(ev.target.value.trim())) })), h("div", { class: "d-flex flex-column flex-lg-row align-items-start align-items-lg-center justify-content-center mt-4 h4" }, h("span", { class: "pr-0 pr-sm-2 d-flex text-center" }, "I live in"), h("fl-dropdown", { class: "d-flex my-2 my-lg-0", options: toSelectInputOptionsArray(this.states), requiredValidationMessage: "Select an option", placeholder: "select state", value: this.getUserInfo('state'), onValueChanged: (e) => this.updateUserInfo('state', e.detail.value) })), h("div", { class: "d-flex flex-column flex-lg-row align-items-start align-items-lg-center justify-content-center mt-4 h4" }, h("span", { class: "pr-0 pr-sm-2 d-flex text-center" }, "I want my lease term to be"), h("fl-dropdown", { class: "d-flex my-2 my-lg-0", options: this.terms, requiredValidationMessage: "Select an option", placeholder: "Select...", value: this.getUserInfo('term'), onValueChanged: (e) => this.updateUserInfo('term', e.detail.value) }))));
2698
- }
2699
- updateUserInfo(key, value) {
2700
- sessionStore.update({ user: Object.assign(Object.assign({}, this.userInfo), { [key]: some(value) }) });
2701
- eventTrackingService.trackInputChangedAsync({
2702
- key: key,
2703
- value: value.toString()
2704
- });
2705
- }
2706
- getUserInfo(key) {
2707
- return pipe(this.userInfo[key], getOrElseW(() => ''));
2708
- }
2709
- };
2710
-
2711
- const QuoteResultSection = class {
2712
- constructor(hostRef) {
2713
- registerInstance(this, hostRef);
2714
- this.showRequestQuoteModal = false;
2715
- this.showBreakdownModal = false;
2716
- this.showCompletePage = false;
2717
- this.getRenderedPaymentPeriod = () => {
2718
- const selectedPaymentPeriod = getOrElse(() => 'Monthly')(sessionQuery.user.paymentPeriod);
2719
- let renderedPaymentPeriod = 'month';
2720
- switch (selectedPaymentPeriod) {
2721
- case 'Monthly':
2722
- renderedPaymentPeriod = 'month';
2723
- break;
2724
- case 'Fortnightly':
2725
- renderedPaymentPeriod = 'fortnight';
2726
- break;
2727
- case 'Weekly':
2728
- renderedPaymentPeriod = 'week';
2729
- }
2730
- return `Cost per ${renderedPaymentPeriod}`;
2731
- };
2732
- this.renderQuoteField = (quoteField) => {
2733
- var _a;
2734
- return (h("span", null, "$", this.quote.quoteState === 'Calculation pending' ? (h("fl-loading-indicator", { class: "ml-2" })) : ((_a = getOrDefault(quoteField, null)) === null || _a === void 0 ? void 0 : _a.toFixed(0))));
2735
- };
2736
- this.leaseInclusion = (props) => (h("p", { class: "font-weight-light d-inline-flex align-items-center" }, h("img", { class: "pr-1", src: getAssetPath('./assets/check.svg') }), props.inclusionName));
2737
- }
2738
- componentWillLoad() {
2739
- this.subscription = sessionQuery.result$.subscribe((_state) => {
2740
- this.quote = sessionQuery.result;
2741
- });
2742
- }
2743
- disconnectedCallback() {
2744
- this.subscription.unsubscribe();
2745
- }
2746
- render() {
2747
- return (h(Host, { class: "card d-flex flex-column justify-content-between w-100 h-100" }, h("div", { class: "d-flex flex-column flex-grow-1 justify-content-between p-4" }, h("span", { class: "mb-3 text-left" }, h("p", { class: "h1 text-muted font-weight-bold mb-0" }, this.renderQuoteField(this.quote.afterTaxEffectPerPayCycle)), h("p", { class: "mb-0 pt-1 h5" }, h("span", { ref: (el) => (this.costTitleElement = el) }, this.getRenderedPaymentPeriod(), h("ap-ben-asset", { class: "pl-2", image: "icon-info.svg" })), h("ap-ben-tooltip", { target: this.costTitleElement, style: { 'max-width': '15rem' } }, h("p", { class: "px-3 h6 py-2 mb-0 text-left text-break text-wrap" }, "The cost to you each pay cycle including all running costs.")))), h("span", { class: "mb-3 text-left" }, h("p", { class: "h1 text-info font-weight-bold mb-0" }, this.renderQuoteField(this.quote.taxSaving)), h("p", { class: "mb-0 pt-1 h5" }, h("span", { ref: (el) => (this.totalSavingsTitleElement = el) }, "Total tax savings", h("ap-ben-asset", { class: "pl-2", image: "icon-info.svg" })), h("ap-ben-tooltip", { target: this.totalSavingsTitleElement, style: { 'max-width': '15rem' } }, h("p", { class: "px-3 h6 py-2 mb-0 text-left text-break text-wrap" }, "The total amount you will save over the life of your lease term by salary packaging this vehicle.")))), h("span", { class: "mb-3 text-left" }, h("p", { class: "h1 text-muted font-weight-bold mb-0" }, this.renderQuoteField(this.quote.residualValue)), h("p", { class: "mb-0 pt-1 h5" }, h("span", { ref: (el) => (this.residualValueTitleElement = el) }, "Residual value", h("ap-ben-asset", { class: "pl-2", image: "icon-info.svg" })), h("ap-ben-tooltip", { target: this.residualValueTitleElement, style: { 'max-width': '15rem' } }, h("p", { class: "px-3 h6 py-2 mb-0 text-left text-break text-wrap" }, "The outstanding amount at the end of the lease term.")))), h("fl-button", { class: "mt-2", isBlockElement: true, onClick: () => {
2748
- this.showRequestQuoteModal = true;
2749
- eventTrackingService.trackStepProgressedAsync({ stepName: 'quote' });
2750
- eventTrackingService.trackModalViewedAsync({ modal: 'quoteRequest' });
2751
- } }, "Request a quote")), h("div", { class: "bg-light px-4 py-3" }, h("p", { class: "font-weight-bold text-center" }, "Your lease includes"), h("div", { class: "d-flex flex-row align-items-center justify-content-between" }, h("span", { class: "d-flex flex-column" }, h(this.leaseInclusion, { inclusionName: "Finance" }), h(this.leaseInclusion, { inclusionName: "Servicing" })), h("span", { class: "d-flex flex-column" }, h(this.leaseInclusion, { inclusionName: "Insurance" }), h(this.leaseInclusion, { inclusionName: "Registration" })), h("span", { class: "d-flex flex-column" }, h(this.leaseInclusion, { inclusionName: "Fuel" }), h(this.leaseInclusion, { inclusionName: "Tyres" }))), h("fl-button", { class: "mt-2", isBlockElement: true, variant: "secondary", onClick: () => {
2752
- this.showBreakdownModal = true;
2753
- eventTrackingService.trackModalViewedAsync({ modal: 'runningCostBreakdown' });
2754
- } }, "View running cost breakdown")), h("ap-ben-modal-section", { show: this.showRequestQuoteModal, showHeader: true, onModalClosed: () => {
2755
- this.showRequestQuoteModal = false;
2756
- this.showCompletePage = false;
2757
- eventTrackingService.trackStepProgressedAsync({ stepName: 'leaseInformation' });
2758
- eventTrackingService.trackModalClosedAsync({ modal: 'quoteRequest' });
2759
- } }, this.showCompletePage ? (h("ap-ben-complete-section", { onClosed: () => {
2760
- this.showRequestQuoteModal = false;
2761
- this.showCompletePage = false;
2762
- } })) : (h("ap-ben-submit-quote-section", { onEnquirySubmitted: () => {
2763
- this.showCompletePage = true;
2764
- } }))), h("ap-ben-modal-section", { show: this.showBreakdownModal, modalTitle: "Running cost breakdown", onModalClosed: () => {
2765
- this.showBreakdownModal = false;
2766
- eventTrackingService.trackModalClosedAsync({ modal: 'runningCostBreakdown' });
2767
- }, showHeader: true, showFooter: true }, h("ap-ben-cost-breakdown-section", { quote: this.quote }))));
2768
- }
2769
- static get assetsDirs() { return ["assets"]; }
2770
- };
2771
-
2772
- export { ChooseVehicleSection as ap_ben_choose_vehicle_section, ModelVariantsSection as ap_ben_model_variants_section, PersonalInfoSection as ap_ben_personal_info_section, QuoteResultSection as ap_ben_quote_result_section };