@justifi/webcomponents 4.2.1-rc.4 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (380) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/{Api-11362403.js → Api-7303478d.js} +3 -2
  3. package/dist/cjs/Api-7303478d.js.map +1 -0
  4. package/dist/cjs/business-form-schema-63b311b2.js +132 -0
  5. package/dist/cjs/business-form-schema-63b311b2.js.map +1 -0
  6. package/dist/cjs/form-control-select_2.cjs.entry.js +61 -0
  7. package/dist/cjs/form-control-select_2.cjs.entry.js.map +1 -0
  8. package/dist/cjs/{index-34312a38.js → index-83b2ec02.js} +136 -20
  9. package/dist/cjs/index-83b2ec02.js.map +1 -0
  10. package/dist/cjs/{index.esm-bcf90c56.js → index.esm-7e12ce07.js} +301 -14
  11. package/dist/cjs/index.esm-7e12ce07.js.map +1 -0
  12. package/dist/cjs/justifi-bank-account-form.cjs.entry.js +8 -3
  13. package/dist/cjs/justifi-bank-account-form.cjs.entry.js.map +1 -1
  14. package/dist/cjs/justifi-billing-form_2.cjs.entry.js +5 -5
  15. package/dist/cjs/justifi-billing-form_2.cjs.entry.js.map +1 -1
  16. package/dist/cjs/justifi-business-address-form.cjs.entry.js +37 -0
  17. package/dist/cjs/justifi-business-address-form.cjs.entry.js.map +1 -0
  18. package/dist/cjs/justifi-business-form.cjs.entry.js +751 -0
  19. package/dist/cjs/justifi-business-form.cjs.entry.js.map +1 -0
  20. package/dist/cjs/justifi-business-generic-info_3.cjs.entry.js +148 -0
  21. package/dist/cjs/justifi-business-generic-info_3.cjs.entry.js.map +1 -0
  22. package/dist/cjs/justifi-card-form.cjs.entry.js +8 -3
  23. package/dist/cjs/justifi-card-form.cjs.entry.js.map +1 -1
  24. package/dist/cjs/justifi-payment-form.cjs.entry.js +24 -7
  25. package/dist/cjs/justifi-payment-form.cjs.entry.js.map +1 -1
  26. package/dist/cjs/justifi-payment-method-form.cjs.entry.js +22 -17
  27. package/dist/cjs/justifi-payment-method-form.cjs.entry.js.map +1 -1
  28. package/dist/cjs/justifi-payments-list.cjs.entry.js +75 -4038
  29. package/dist/cjs/justifi-payments-list.cjs.entry.js.map +1 -1
  30. package/dist/cjs/justifi-payouts-list.cjs.entry.js +113 -0
  31. package/dist/cjs/justifi-payouts-list.cjs.entry.js.map +1 -0
  32. package/dist/cjs/loader.cjs.js +3 -12
  33. package/dist/cjs/loader.cjs.js.map +1 -1
  34. package/dist/cjs/select-input_2.cjs.entry.js +6 -6
  35. package/dist/cjs/select-input_2.cjs.entry.js.map +1 -1
  36. package/dist/cjs/{state-options-efeaa587.js → state-options-83b52cd1.js} +1 -1
  37. package/dist/{esm/state-options-188acc34.js.map → cjs/state-options-83b52cd1.js.map} +1 -1
  38. package/dist/cjs/utils-4ee7e080.js +3979 -0
  39. package/dist/cjs/utils-4ee7e080.js.map +1 -0
  40. package/dist/cjs/webcomponents.cjs.js +3 -6
  41. package/dist/cjs/webcomponents.cjs.js.map +1 -1
  42. package/dist/collection/api/Api.js +3 -2
  43. package/dist/collection/api/Api.js.map +1 -1
  44. package/dist/collection/api/Payout.js +33 -0
  45. package/dist/collection/api/Payout.js.map +1 -0
  46. package/dist/collection/api/index.js +1 -0
  47. package/dist/collection/api/index.js.map +1 -1
  48. package/dist/collection/api/mockData/MockPayments.js +1 -1
  49. package/dist/collection/collection-manifest.json +18 -12
  50. package/dist/collection/components/bank-account-form/bank-account-form.js +38 -10
  51. package/dist/collection/components/bank-account-form/bank-account-form.js.map +1 -1
  52. package/dist/collection/components/bank-account-form/bank-account-form.stories.js +2 -0
  53. package/dist/collection/components/bank-account-form/bank-account-form.stories.js.map +1 -1
  54. package/dist/collection/components/bank-account-form/test/bank-account-form.e2e.js +1 -1
  55. package/dist/collection/components/bank-account-form/test/bank-account-form.spec.js +3 -3
  56. package/dist/collection/components/billing-form/billing-form-schema.js +1 -1
  57. package/dist/collection/components/billing-form/billing-form.css +212 -39
  58. package/dist/collection/components/billing-form/billing-form.js +16 -10
  59. package/dist/collection/components/billing-form/billing-form.js.map +1 -1
  60. package/dist/collection/components/billing-form/test/billing-form.spec.js +51 -24
  61. package/dist/collection/components/billing-form/test/billing-form.spec.js.map +1 -1
  62. package/dist/collection/components/{business-address/business-address-schema.js → business-form/business-address/business-address-form-schema.js} +2 -2
  63. package/dist/collection/components/business-form/business-address/business-address-form-schema.js.map +1 -0
  64. package/dist/collection/components/business-form/business-address/business-address-form.css +2532 -0
  65. package/dist/collection/components/business-form/business-address/business-address-form.js +98 -0
  66. package/dist/collection/components/business-form/business-address/business-address-form.js.map +1 -0
  67. package/dist/collection/components/business-form/business-address/test/business-address.e2e.js +10 -0
  68. package/dist/collection/components/business-form/business-address/test/business-address.e2e.js.map +1 -0
  69. package/dist/collection/components/business-form/business-address/test/business-address.spec.js +72 -0
  70. package/dist/collection/components/business-form/business-address/test/business-address.spec.js.map +1 -0
  71. package/dist/collection/components/business-form/business-form-schema.js +149 -0
  72. package/dist/collection/components/business-form/business-form-schema.js.map +1 -0
  73. package/dist/collection/components/business-form/business-form.css +2532 -0
  74. package/dist/collection/components/business-form/business-form.js +76 -0
  75. package/dist/collection/components/business-form/business-form.js.map +1 -0
  76. package/dist/collection/components/{business-info/business-info.css → business-form/business-generic-info/business-generic-info.css} +745 -530
  77. package/dist/collection/components/business-form/business-generic-info/business-generic-info.js +79 -0
  78. package/dist/collection/components/business-form/business-generic-info/business-generic-info.js.map +1 -0
  79. package/dist/collection/components/business-form/business-owners/business-owners.css +2489 -0
  80. package/dist/collection/components/business-form/business-owners/business-owners.js +120 -0
  81. package/dist/collection/components/business-form/business-owners/business-owners.js.map +1 -0
  82. package/dist/collection/components/business-form/business-representative/business-representative-schema.js +2 -0
  83. package/dist/collection/components/business-form/business-representative/business-representative-schema.js.map +1 -0
  84. package/dist/collection/components/business-form/business-representative/business-representative.css +2489 -0
  85. package/dist/collection/components/business-form/business-representative/business-representative.js +76 -0
  86. package/dist/collection/components/business-form/business-representative/business-representative.js.map +1 -0
  87. package/dist/collection/components/business-form/businessForm.stories.js +115 -0
  88. package/dist/collection/components/business-form/businessForm.stories.js.map +1 -0
  89. package/dist/collection/components/card-form/card-form.js +38 -10
  90. package/dist/collection/components/card-form/card-form.js.map +1 -1
  91. package/dist/collection/components/card-form/card-form.stories.js +5 -2
  92. package/dist/collection/components/card-form/card-form.stories.js.map +1 -1
  93. package/dist/collection/components/card-form/test/card-form.e2e.js +1 -1
  94. package/dist/collection/components/card-form/test/card-form.spec.js +3 -3
  95. package/dist/collection/components/{business-address/business-address.css → form/form-control-select.css} +344 -1212
  96. package/dist/collection/components/form/form-control-select.js +168 -0
  97. package/dist/collection/components/form/form-control-select.js.map +1 -0
  98. package/dist/collection/components/form/form-control-text.css +1794 -0
  99. package/dist/collection/components/form/form-control-text.js +152 -0
  100. package/dist/collection/components/form/form-control-text.js.map +1 -0
  101. package/dist/collection/components/form/form.js +85 -0
  102. package/dist/collection/components/form/form.js.map +1 -0
  103. package/dist/collection/components/payment-form/payment-form.css +220 -45
  104. package/dist/collection/components/payment-form/payment-form.js +47 -7
  105. package/dist/collection/components/payment-form/payment-form.js.map +1 -1
  106. package/dist/collection/components/payment-form/payment-form.stories.js +3 -2
  107. package/dist/collection/components/payment-form/payment-form.stories.js.map +1 -1
  108. package/dist/collection/components/payment-form/payment-method-selector.css +348 -145
  109. package/dist/collection/components/payment-form/payment-method-selector.js +5 -3
  110. package/dist/collection/components/payment-form/payment-method-selector.js.map +1 -1
  111. package/dist/collection/components/payment-form/test/payment-form.e2e.js +1 -1
  112. package/dist/collection/components/payment-form/test/payment-form.spec.js +4 -3
  113. package/dist/collection/components/payment-form/test/payment-form.spec.js.map +1 -1
  114. package/dist/collection/components/payment-method-form/get-computed-theme.js +2 -0
  115. package/dist/collection/components/payment-method-form/get-computed-theme.js.map +1 -1
  116. package/dist/collection/components/payment-method-form/payment-method-form.js +19 -11
  117. package/dist/collection/components/payment-method-form/payment-method-form.js.map +1 -1
  118. package/dist/collection/components/payment-method-form/test/payment-method-form.e2e.js +1 -1
  119. package/dist/collection/components/payment-method-form/test/payment-method-form.spec.js +3 -3
  120. package/dist/collection/components/payment-method-form/theme.js.map +1 -1
  121. package/dist/collection/components/payments-list/example.js +12 -0
  122. package/dist/collection/components/payments-list/payments-list.css +7954 -1
  123. package/dist/collection/components/payments-list/payments-list.js +104 -27
  124. package/dist/collection/components/payments-list/payments-list.js.map +1 -1
  125. package/dist/collection/components/payments-list/payments-list.stories.js +78 -0
  126. package/dist/collection/components/payments-list/payments-list.stories.js.map +1 -0
  127. package/dist/collection/components/payments-list/test/payments-list.spec.js +82 -18
  128. package/dist/collection/components/payments-list/test/payments-list.spec.js.map +1 -1
  129. package/dist/collection/components/payouts-list/payouts-list.css +7983 -0
  130. package/dist/collection/components/payouts-list/payouts-list.js +181 -0
  131. package/dist/collection/components/payouts-list/payouts-list.js.map +1 -0
  132. package/dist/collection/components/payouts-list/payouts-list.stories.js +69 -0
  133. package/dist/collection/components/payouts-list/payouts-list.stories.js.map +1 -0
  134. package/dist/collection/components/select-input/select-input.css +344 -141
  135. package/dist/collection/components/select-input/select-input.js +5 -4
  136. package/dist/collection/components/select-input/select-input.js.map +1 -1
  137. package/dist/collection/components/select-input/test/select-input.spec.js +72 -28
  138. package/dist/collection/components/select-input/test/select-input.spec.js.map +1 -1
  139. package/dist/collection/components/text-input/test/text-input.spec.js +47 -5
  140. package/dist/collection/components/text-input/test/text-input.spec.js.map +1 -1
  141. package/dist/collection/components/text-input/text-input.css +344 -141
  142. package/dist/collection/components/text-input/text-input.js +2 -2
  143. package/dist/collection/components/text-input/text-input.js.map +1 -1
  144. package/dist/collection/utils/utils.js +7 -2
  145. package/dist/collection/utils/utils.js.map +1 -1
  146. package/dist/components/Api.js +2 -1
  147. package/dist/components/Api.js.map +1 -1
  148. package/dist/components/billing-form.js +2 -2
  149. package/dist/components/billing-form.js.map +1 -1
  150. package/dist/components/business-address-form.js +65 -0
  151. package/dist/components/business-address-form.js.map +1 -0
  152. package/dist/components/business-generic-info.js +190 -0
  153. package/dist/components/business-generic-info.js.map +1 -0
  154. package/dist/components/business-owners.js +102 -0
  155. package/dist/components/business-owners.js.map +1 -0
  156. package/dist/components/business-representative.js +75 -0
  157. package/dist/components/business-representative.js.map +1 -0
  158. package/dist/components/{justifi-business-info.d.ts → form-control-select.d.ts} +4 -4
  159. package/dist/components/form-control-select.js +8 -0
  160. package/dist/components/form-control-select.js.map +1 -0
  161. package/dist/components/form-control-select2.js +53 -0
  162. package/dist/components/form-control-select2.js.map +1 -0
  163. package/dist/components/form-control-text.d.ts +11 -0
  164. package/dist/components/form-control-text.js +8 -0
  165. package/dist/components/form-control-text.js.map +1 -0
  166. package/dist/components/form-control-text2.js +51 -0
  167. package/dist/components/form-control-text2.js.map +1 -0
  168. package/dist/components/index.esm.js +298 -14
  169. package/dist/components/index.esm.js.map +1 -1
  170. package/dist/components/justifi-bank-account-form.js +7 -2
  171. package/dist/components/justifi-bank-account-form.js.map +1 -1
  172. package/dist/components/justifi-business-address-form.d.ts +11 -0
  173. package/dist/components/justifi-business-address-form.js +8 -0
  174. package/dist/components/justifi-business-address-form.js.map +1 -0
  175. package/dist/components/justifi-business-form.d.ts +11 -0
  176. package/dist/components/justifi-business-form.js +802 -0
  177. package/dist/components/justifi-business-form.js.map +1 -0
  178. package/dist/components/justifi-business-generic-info.d.ts +11 -0
  179. package/dist/components/justifi-business-generic-info.js +8 -0
  180. package/dist/components/justifi-business-generic-info.js.map +1 -0
  181. package/dist/components/justifi-business-owners.d.ts +11 -0
  182. package/dist/components/justifi-business-owners.js +8 -0
  183. package/dist/components/justifi-business-owners.js.map +1 -0
  184. package/dist/components/justifi-business-representative.d.ts +11 -0
  185. package/dist/components/justifi-business-representative.js +8 -0
  186. package/dist/components/justifi-business-representative.js.map +1 -0
  187. package/dist/components/justifi-card-form.js +7 -2
  188. package/dist/components/justifi-card-form.js.map +1 -1
  189. package/dist/components/justifi-payment-form.js +23 -4
  190. package/dist/components/justifi-payment-form.js.map +1 -1
  191. package/dist/components/justifi-payments-list.js +78 -4038
  192. package/dist/components/justifi-payments-list.js.map +1 -1
  193. package/dist/components/justifi-payouts-list.d.ts +11 -0
  194. package/dist/components/justifi-payouts-list.js +134 -0
  195. package/dist/components/justifi-payouts-list.js.map +1 -0
  196. package/dist/components/payment-method-form.js +21 -16
  197. package/dist/components/payment-method-form.js.map +1 -1
  198. package/dist/components/payment-method-selector.js +1 -1
  199. package/dist/components/payment-method-selector.js.map +1 -1
  200. package/dist/components/select-input2.js +3 -3
  201. package/dist/components/select-input2.js.map +1 -1
  202. package/dist/components/state-options.js.map +1 -1
  203. package/dist/components/text-input2.js +2 -2
  204. package/dist/components/text-input2.js.map +1 -1
  205. package/dist/components/utils.js +3972 -0
  206. package/dist/components/utils.js.map +1 -0
  207. package/dist/esm/{Api-a07f0057.js → Api-436dfa09.js} +3 -2
  208. package/dist/esm/Api-436dfa09.js.map +1 -0
  209. package/dist/esm/business-form-schema-30c48693.js +128 -0
  210. package/dist/esm/business-form-schema-30c48693.js.map +1 -0
  211. package/dist/esm/form-control-select_2.entry.js +56 -0
  212. package/dist/esm/form-control-select_2.entry.js.map +1 -0
  213. package/dist/esm/{index-044f93fc.js → index-c8f391de.js} +136 -20
  214. package/dist/esm/index-c8f391de.js.map +1 -0
  215. package/dist/esm/{index.esm-5624a5ed.js → index.esm-be2cd327.js} +299 -15
  216. package/dist/esm/index.esm-be2cd327.js.map +1 -0
  217. package/dist/esm/justifi-bank-account-form.entry.js +8 -3
  218. package/dist/esm/justifi-bank-account-form.entry.js.map +1 -1
  219. package/dist/esm/justifi-billing-form_2.entry.js +5 -5
  220. package/dist/esm/justifi-billing-form_2.entry.js.map +1 -1
  221. package/dist/esm/justifi-business-address-form.entry.js +33 -0
  222. package/dist/esm/justifi-business-address-form.entry.js.map +1 -0
  223. package/dist/esm/justifi-business-form.entry.js +747 -0
  224. package/dist/esm/justifi-business-form.entry.js.map +1 -0
  225. package/dist/esm/justifi-business-generic-info_3.entry.js +142 -0
  226. package/dist/esm/justifi-business-generic-info_3.entry.js.map +1 -0
  227. package/dist/esm/justifi-card-form.entry.js +8 -3
  228. package/dist/esm/justifi-card-form.entry.js.map +1 -1
  229. package/dist/esm/justifi-payment-form.entry.js +21 -4
  230. package/dist/esm/justifi-payment-form.entry.js.map +1 -1
  231. package/dist/esm/justifi-payment-method-form.entry.js +22 -17
  232. package/dist/esm/justifi-payment-method-form.entry.js.map +1 -1
  233. package/dist/esm/justifi-payments-list.entry.js +75 -4038
  234. package/dist/esm/justifi-payments-list.entry.js.map +1 -1
  235. package/dist/esm/justifi-payouts-list.entry.js +109 -0
  236. package/dist/esm/justifi-payouts-list.entry.js.map +1 -0
  237. package/dist/esm/loader.js +4 -13
  238. package/dist/esm/loader.js.map +1 -1
  239. package/dist/esm/select-input_2.entry.js +6 -6
  240. package/dist/esm/select-input_2.entry.js.map +1 -1
  241. package/dist/esm/{state-options-188acc34.js → state-options-ece00aa2.js} +1 -1
  242. package/dist/esm/state-options-ece00aa2.js.map +1 -0
  243. package/dist/esm/utils-e7782126.js +3972 -0
  244. package/dist/esm/utils-e7782126.js.map +1 -0
  245. package/dist/esm/webcomponents.js +4 -7
  246. package/dist/esm/webcomponents.js.map +1 -1
  247. package/dist/types/api/Payout.d.ts +62 -0
  248. package/dist/types/api/index.d.ts +1 -0
  249. package/dist/types/components/business-form/business-address/business-address-form.d.ts +9 -0
  250. package/dist/types/components/{business-info/business-info-schema.d.ts → business-form/business-form-schema.d.ts} +55 -4
  251. package/dist/types/components/business-form/business-form.d.ts +14 -0
  252. package/dist/types/components/business-form/business-generic-info/business-generic-info.d.ts +16 -0
  253. package/dist/types/components/business-form/business-owners/business-owners.d.ts +32 -0
  254. package/dist/types/components/business-form/business-representative/business-representative-schema.d.ts +15 -0
  255. package/dist/types/components/business-form/business-representative/business-representative.d.ts +12 -0
  256. package/dist/types/components/business-form/businessForm.stories.d.ts +21 -0
  257. package/dist/types/components/form/form-control-select.d.ts +16 -0
  258. package/dist/types/components/form/form-control-text.d.ts +12 -0
  259. package/dist/types/components/form/form.d.ts +21 -0
  260. package/dist/types/components/payment-form/payment-form.d.ts +2 -0
  261. package/dist/types/components/payment-method-form/theme.d.ts +2 -0
  262. package/dist/types/components/payments-list/payments-list.d.ts +38 -5
  263. package/dist/types/components/payments-list/payments-list.stories.d.ts +17 -0
  264. package/dist/types/components/payouts-list/payouts-list.d.ts +45 -0
  265. package/dist/types/components/payouts-list/payouts-list.stories.d.ts +16 -0
  266. package/dist/types/components.d.ts +339 -26
  267. package/dist/types/stencil-public-runtime.d.ts +14 -2
  268. package/dist/types/utils/utils.d.ts +1 -0
  269. package/dist/webcomponents/p-0fd4aae2.js +2 -0
  270. package/dist/webcomponents/p-0fd4aae2.js.map +1 -0
  271. package/dist/webcomponents/p-1953797f.entry.js +2 -0
  272. package/dist/webcomponents/p-1953797f.entry.js.map +1 -0
  273. package/dist/webcomponents/p-1a1f2196.js +2 -0
  274. package/dist/webcomponents/p-1a1f2196.js.map +1 -0
  275. package/dist/webcomponents/p-23e9c7d4.entry.js +2 -0
  276. package/dist/webcomponents/p-23e9c7d4.entry.js.map +1 -0
  277. package/dist/webcomponents/p-309a886f.entry.js +2 -0
  278. package/dist/webcomponents/p-309a886f.entry.js.map +1 -0
  279. package/dist/webcomponents/p-33d69eb5.entry.js +2 -0
  280. package/dist/webcomponents/p-33d69eb5.entry.js.map +1 -0
  281. package/dist/webcomponents/p-3a80a2ec.entry.js +2 -0
  282. package/dist/webcomponents/p-3a80a2ec.entry.js.map +1 -0
  283. package/dist/webcomponents/p-45fea6a8.entry.js +2 -0
  284. package/dist/webcomponents/p-45fea6a8.entry.js.map +1 -0
  285. package/dist/webcomponents/{p-0ea23153.js → p-47bc59b5.js} +1 -1
  286. package/dist/webcomponents/p-47bc59b5.js.map +1 -0
  287. package/dist/webcomponents/p-7041a637.entry.js +2 -0
  288. package/dist/webcomponents/p-7041a637.entry.js.map +1 -0
  289. package/dist/webcomponents/p-79456add.js +2 -0
  290. package/dist/webcomponents/p-79456add.js.map +1 -0
  291. package/dist/webcomponents/{p-1f151d49.js → p-af080b21.js} +2 -2
  292. package/dist/webcomponents/p-af080b21.js.map +1 -0
  293. package/dist/webcomponents/p-bc969904.js +3 -0
  294. package/dist/webcomponents/p-bc969904.js.map +1 -0
  295. package/dist/webcomponents/p-cd097ce9.entry.js +2 -0
  296. package/dist/webcomponents/p-cd097ce9.entry.js.map +1 -0
  297. package/dist/webcomponents/p-d5bc9f22.entry.js +2 -0
  298. package/dist/webcomponents/p-d5bc9f22.entry.js.map +1 -0
  299. package/dist/webcomponents/p-d5cadc78.entry.js +2 -0
  300. package/dist/webcomponents/p-d5cadc78.entry.js.map +1 -0
  301. package/dist/webcomponents/p-dd1ebc0b.entry.js +2 -0
  302. package/dist/webcomponents/p-dd1ebc0b.entry.js.map +1 -0
  303. package/dist/webcomponents/p-e05e0c6b.entry.js +2 -0
  304. package/dist/webcomponents/p-e05e0c6b.entry.js.map +1 -0
  305. package/dist/webcomponents/webcomponents.css +1 -1
  306. package/dist/webcomponents/webcomponents.esm.js +1 -1
  307. package/dist/webcomponents/webcomponents.esm.js.map +1 -1
  308. package/loader/index.d.ts +1 -1
  309. package/package.json +12 -14
  310. package/CHANGELOG.md +0 -196
  311. package/changelog-template.hbs +0 -10
  312. package/dist/cjs/Api-11362403.js.map +0 -1
  313. package/dist/cjs/Payment-ac4dea02.js +0 -73
  314. package/dist/cjs/Payment-ac4dea02.js.map +0 -1
  315. package/dist/cjs/index-34312a38.js.map +0 -1
  316. package/dist/cjs/index.esm-bcf90c56.js.map +0 -1
  317. package/dist/cjs/justifi-business-address.cjs.entry.js +0 -69
  318. package/dist/cjs/justifi-business-address.cjs.entry.js.map +0 -1
  319. package/dist/cjs/justifi-business-info.cjs.entry.js +0 -174
  320. package/dist/cjs/justifi-business-info.cjs.entry.js.map +0 -1
  321. package/dist/cjs/state-options-efeaa587.js.map +0 -1
  322. package/dist/collection/components/business-address/business-address-schema.js.map +0 -1
  323. package/dist/collection/components/business-address/business-address.js +0 -100
  324. package/dist/collection/components/business-address/business-address.js.map +0 -1
  325. package/dist/collection/components/business-address/test/business-address.e2e.js +0 -10
  326. package/dist/collection/components/business-address/test/business-address.e2e.js.map +0 -1
  327. package/dist/collection/components/business-address/test/business-address.spec.js +0 -18
  328. package/dist/collection/components/business-address/test/business-address.spec.js.map +0 -1
  329. package/dist/collection/components/business-info/business-info-schema.js +0 -94
  330. package/dist/collection/components/business-info/business-info-schema.js.map +0 -1
  331. package/dist/collection/components/business-info/business-info.js +0 -168
  332. package/dist/collection/components/business-info/business-info.js.map +0 -1
  333. package/dist/components/Payment.js +0 -71
  334. package/dist/components/Payment.js.map +0 -1
  335. package/dist/components/justifi-business-address.d.ts +0 -11
  336. package/dist/components/justifi-business-address.js +0 -99
  337. package/dist/components/justifi-business-address.js.map +0 -1
  338. package/dist/components/justifi-business-info.js +0 -207
  339. package/dist/components/justifi-business-info.js.map +0 -1
  340. package/dist/esm/Api-a07f0057.js.map +0 -1
  341. package/dist/esm/Payment-c86e1e84.js +0 -71
  342. package/dist/esm/Payment-c86e1e84.js.map +0 -1
  343. package/dist/esm/index-044f93fc.js.map +0 -1
  344. package/dist/esm/index.esm-5624a5ed.js.map +0 -1
  345. package/dist/esm/justifi-business-address.entry.js +0 -65
  346. package/dist/esm/justifi-business-address.entry.js.map +0 -1
  347. package/dist/esm/justifi-business-info.entry.js +0 -170
  348. package/dist/esm/justifi-business-info.entry.js.map +0 -1
  349. package/dist/esm/polyfills/css-shim.js +0 -1
  350. package/dist/types/components/bank-account-form/bank-account-form.d.ts +0 -56
  351. package/dist/types/components/business-address/business-address.d.ts +0 -11
  352. package/dist/types/components/business-info/business-info.d.ts +0 -20
  353. package/dist/types/components/card-form/card-form.d.ts +0 -62
  354. package/dist/webcomponents/p-0969db8f.entry.js +0 -2
  355. package/dist/webcomponents/p-0969db8f.entry.js.map +0 -1
  356. package/dist/webcomponents/p-0ea23153.js.map +0 -1
  357. package/dist/webcomponents/p-1ca0646b.js +0 -2
  358. package/dist/webcomponents/p-1ca0646b.js.map +0 -1
  359. package/dist/webcomponents/p-1f151d49.js.map +0 -1
  360. package/dist/webcomponents/p-255b1284.entry.js +0 -2
  361. package/dist/webcomponents/p-255b1284.entry.js.map +0 -1
  362. package/dist/webcomponents/p-2b8c281e.entry.js +0 -2
  363. package/dist/webcomponents/p-2b8c281e.entry.js.map +0 -1
  364. package/dist/webcomponents/p-3aa91155.js +0 -3
  365. package/dist/webcomponents/p-3aa91155.js.map +0 -1
  366. package/dist/webcomponents/p-90c0d9e1.entry.js +0 -2
  367. package/dist/webcomponents/p-90c0d9e1.entry.js.map +0 -1
  368. package/dist/webcomponents/p-bd5352d6.entry.js +0 -2
  369. package/dist/webcomponents/p-bd5352d6.entry.js.map +0 -1
  370. package/dist/webcomponents/p-c903cc5a.entry.js +0 -2
  371. package/dist/webcomponents/p-c903cc5a.entry.js.map +0 -1
  372. package/dist/webcomponents/p-d87b0711.entry.js +0 -2
  373. package/dist/webcomponents/p-d87b0711.entry.js.map +0 -1
  374. package/dist/webcomponents/p-dbf7100f.entry.js +0 -2
  375. package/dist/webcomponents/p-dbf7100f.entry.js.map +0 -1
  376. package/dist/webcomponents/p-e0054bc3.js +0 -2
  377. package/dist/webcomponents/p-e0054bc3.js.map +0 -1
  378. package/dist/webcomponents/p-f30d1567.entry.js +0 -2
  379. package/dist/webcomponents/p-f30d1567.entry.js.map +0 -1
  380. /package/dist/types/components/{business-address/business-address-schema.d.ts → business-form/business-address/business-address-form-schema.d.ts} +0 -0
@@ -0,0 +1,3972 @@
1
+ var CaptureStrategy;
2
+ (function (CaptureStrategy) {
3
+ CaptureStrategy["automatic"] = "automatic";
4
+ CaptureStrategy["manual"] = "manual";
5
+ })(CaptureStrategy || (CaptureStrategy = {}));
6
+ var PaymentMethodTypes;
7
+ (function (PaymentMethodTypes) {
8
+ PaymentMethodTypes["card"] = "card";
9
+ PaymentMethodTypes["bankAccount"] = "bankAccount";
10
+ })(PaymentMethodTypes || (PaymentMethodTypes = {}));
11
+ var PaymentStatuses;
12
+ (function (PaymentStatuses) {
13
+ PaymentStatuses["pending"] = "pending";
14
+ PaymentStatuses["authorized"] = "authorized";
15
+ PaymentStatuses["succeeded"] = "succeeded";
16
+ PaymentStatuses["failed"] = "failed";
17
+ PaymentStatuses["disputed"] = "disputed";
18
+ PaymentStatuses["fully_refunded"] = "fully_refunded";
19
+ PaymentStatuses["partially_refunded"] = "partially_refunded";
20
+ })(PaymentStatuses || (PaymentStatuses = {}));
21
+ var PaymentDisputedStatuses;
22
+ (function (PaymentDisputedStatuses) {
23
+ // if a dispute is 'won', we don't show a dispute status, just general status
24
+ PaymentDisputedStatuses["lost"] = "lost";
25
+ PaymentDisputedStatuses["open"] = "open";
26
+ })(PaymentDisputedStatuses || (PaymentDisputedStatuses = {}));
27
+ class Payment {
28
+ constructor(payment) {
29
+ this.id = payment.id;
30
+ this.account_id = payment.account_id;
31
+ this.amount = payment.amount;
32
+ this.amount_disputed = payment.amount_disputed;
33
+ this.amount_refundable = payment.amount_refundable;
34
+ this.amount_refunded = payment.amount_refunded;
35
+ this.balance = payment.balance;
36
+ this.captured = payment.captured;
37
+ this.capture_strategy = payment.capture_strategy;
38
+ this.currency = payment.currency;
39
+ this.description = payment.description;
40
+ this.disputed = payment.disputed;
41
+ this.disputes = payment.disputes;
42
+ this.error_code = payment.error_code;
43
+ this.error_description = payment.error_description;
44
+ this.fee_amount = payment.fee_amount;
45
+ this.is_test = payment.is_test;
46
+ this.metadata = payment.metadata;
47
+ this.payment_method = payment.payment_method;
48
+ this.payment_intent_id = payment.payment_intent_id;
49
+ this.refunded = payment.refunded;
50
+ this.status = payment.status;
51
+ this.created_at = payment.created_at;
52
+ this.updated_at = payment.updated_at;
53
+ }
54
+ get disputedStatus() {
55
+ const lost = this.disputes.some(dispute => dispute.status === PaymentDisputedStatuses.lost);
56
+ // if a dispute is 'won', we don't show a dispute status, just general status
57
+ if (!this.disputed) {
58
+ return null;
59
+ }
60
+ else if (lost) {
61
+ return PaymentDisputedStatuses.lost;
62
+ }
63
+ else {
64
+ return PaymentDisputedStatuses.open;
65
+ }
66
+ }
67
+ }
68
+
69
+ var PayoutStatuses;
70
+ (function (PayoutStatuses) {
71
+ PayoutStatuses["paid"] = "paid";
72
+ PayoutStatuses["failed"] = "failed";
73
+ PayoutStatuses["forwarded"] = "forwarded";
74
+ PayoutStatuses["scheduled"] = "scheduled";
75
+ PayoutStatuses["in_transit"] = "in_transit";
76
+ PayoutStatuses["canceled"] = "canceled";
77
+ })(PayoutStatuses || (PayoutStatuses = {}));
78
+ class Payout {
79
+ constructor(payout) {
80
+ this.id = payout.id;
81
+ this.account_id = payout.account_id;
82
+ this.amount = payout.amount;
83
+ this.bank_account = payout.bank_account;
84
+ this.currency = payout.currency;
85
+ this.delivery_method = payout.delivery_method || 'standard';
86
+ this.description = payout.description;
87
+ this.deposits_at = payout.deposits_at;
88
+ this.fees_total = payout.fees_total;
89
+ this.refunds_count = payout.refunds_count;
90
+ this.refunds_total = payout.refunds_total;
91
+ this.payments_count = payout.payments_count;
92
+ this.payments_total = payout.payments_total;
93
+ this.payout_type = payout.payout_type;
94
+ this.other_total = payout.other_total;
95
+ this.status = payout.status;
96
+ this.metadata = payout.metadata;
97
+ this.created_at = payout.created_at;
98
+ this.updated_at = payout.updated_at;
99
+ }
100
+ }
101
+
102
+ function _typeof$1(obj) {
103
+ "@babel/helpers - typeof";
104
+
105
+ return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
106
+ return typeof obj;
107
+ } : function (obj) {
108
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
109
+ }, _typeof$1(obj);
110
+ }
111
+
112
+ function toInteger(dirtyNumber) {
113
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
114
+ return NaN;
115
+ }
116
+ var number = Number(dirtyNumber);
117
+ if (isNaN(number)) {
118
+ return number;
119
+ }
120
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
121
+ }
122
+
123
+ function requiredArgs(required, args) {
124
+ if (args.length < required) {
125
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
126
+ }
127
+ }
128
+
129
+ /**
130
+ * @name toDate
131
+ * @category Common Helpers
132
+ * @summary Convert the given argument to an instance of Date.
133
+ *
134
+ * @description
135
+ * Convert the given argument to an instance of Date.
136
+ *
137
+ * If the argument is an instance of Date, the function returns its clone.
138
+ *
139
+ * If the argument is a number, it is treated as a timestamp.
140
+ *
141
+ * If the argument is none of the above, the function returns Invalid Date.
142
+ *
143
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
144
+ *
145
+ * @param {Date|Number} argument - the value to convert
146
+ * @returns {Date} the parsed date in the local time zone
147
+ * @throws {TypeError} 1 argument required
148
+ *
149
+ * @example
150
+ * // Clone the date:
151
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
152
+ * //=> Tue Feb 11 2014 11:30:30
153
+ *
154
+ * @example
155
+ * // Convert the timestamp to date:
156
+ * const result = toDate(1392098430000)
157
+ * //=> Tue Feb 11 2014 11:30:30
158
+ */
159
+ function toDate(argument) {
160
+ requiredArgs(1, arguments);
161
+ var argStr = Object.prototype.toString.call(argument);
162
+
163
+ // Clone the date
164
+ if (argument instanceof Date || _typeof$1(argument) === 'object' && argStr === '[object Date]') {
165
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
166
+ return new Date(argument.getTime());
167
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
168
+ return new Date(argument);
169
+ } else {
170
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
171
+ // eslint-disable-next-line no-console
172
+ 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://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments");
173
+ // eslint-disable-next-line no-console
174
+ console.warn(new Error().stack);
175
+ }
176
+ return new Date(NaN);
177
+ }
178
+ }
179
+
180
+ /**
181
+ * @name addMilliseconds
182
+ * @category Millisecond Helpers
183
+ * @summary Add the specified number of milliseconds to the given date.
184
+ *
185
+ * @description
186
+ * Add the specified number of milliseconds to the given date.
187
+ *
188
+ * @param {Date|Number} date - the date to be changed
189
+ * @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`.
190
+ * @returns {Date} the new date with the milliseconds added
191
+ * @throws {TypeError} 2 arguments required
192
+ *
193
+ * @example
194
+ * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
195
+ * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
196
+ * //=> Thu Jul 10 2014 12:45:30.750
197
+ */
198
+ function addMilliseconds(dirtyDate, dirtyAmount) {
199
+ requiredArgs(2, arguments);
200
+ var timestamp = toDate(dirtyDate).getTime();
201
+ var amount = toInteger(dirtyAmount);
202
+ return new Date(timestamp + amount);
203
+ }
204
+
205
+ var defaultOptions = {};
206
+ function getDefaultOptions() {
207
+ return defaultOptions;
208
+ }
209
+
210
+ /**
211
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
212
+ * They usually appear for dates that denote time before the timezones were introduced
213
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
214
+ * and GMT+01:00:00 after that date)
215
+ *
216
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
217
+ * which would lead to incorrect calculations.
218
+ *
219
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
220
+ */
221
+ function getTimezoneOffsetInMilliseconds(date) {
222
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
223
+ utcDate.setUTCFullYear(date.getFullYear());
224
+ return date.getTime() - utcDate.getTime();
225
+ }
226
+
227
+ /**
228
+ * @name isDate
229
+ * @category Common Helpers
230
+ * @summary Is the given value a date?
231
+ *
232
+ * @description
233
+ * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
234
+ *
235
+ * @param {*} value - the value to check
236
+ * @returns {boolean} true if the given value is a date
237
+ * @throws {TypeError} 1 arguments required
238
+ *
239
+ * @example
240
+ * // For a valid date:
241
+ * const result = isDate(new Date())
242
+ * //=> true
243
+ *
244
+ * @example
245
+ * // For an invalid date:
246
+ * const result = isDate(new Date(NaN))
247
+ * //=> true
248
+ *
249
+ * @example
250
+ * // For some value:
251
+ * const result = isDate('2014-02-31')
252
+ * //=> false
253
+ *
254
+ * @example
255
+ * // For an object:
256
+ * const result = isDate({})
257
+ * //=> false
258
+ */
259
+ function isDate(value) {
260
+ requiredArgs(1, arguments);
261
+ return value instanceof Date || _typeof$1(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
262
+ }
263
+
264
+ /**
265
+ * @name isValid
266
+ * @category Common Helpers
267
+ * @summary Is the given date valid?
268
+ *
269
+ * @description
270
+ * Returns false if argument is Invalid Date and true otherwise.
271
+ * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
272
+ * Invalid Date is a Date, whose time value is NaN.
273
+ *
274
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
275
+ *
276
+ * @param {*} date - the date to check
277
+ * @returns {Boolean} the date is valid
278
+ * @throws {TypeError} 1 argument required
279
+ *
280
+ * @example
281
+ * // For the valid date:
282
+ * const result = isValid(new Date(2014, 1, 31))
283
+ * //=> true
284
+ *
285
+ * @example
286
+ * // For the value, convertable into a date:
287
+ * const result = isValid(1393804800000)
288
+ * //=> true
289
+ *
290
+ * @example
291
+ * // For the invalid date:
292
+ * const result = isValid(new Date(''))
293
+ * //=> false
294
+ */
295
+ function isValid(dirtyDate) {
296
+ requiredArgs(1, arguments);
297
+ if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
298
+ return false;
299
+ }
300
+ var date = toDate(dirtyDate);
301
+ return !isNaN(Number(date));
302
+ }
303
+
304
+ /**
305
+ * @name subMilliseconds
306
+ * @category Millisecond Helpers
307
+ * @summary Subtract the specified number of milliseconds from the given date.
308
+ *
309
+ * @description
310
+ * Subtract the specified number of milliseconds from the given date.
311
+ *
312
+ * @param {Date|Number} date - the date to be changed
313
+ * @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`.
314
+ * @returns {Date} the new date with the milliseconds subtracted
315
+ * @throws {TypeError} 2 arguments required
316
+ *
317
+ * @example
318
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
319
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
320
+ * //=> Thu Jul 10 2014 12:45:29.250
321
+ */
322
+ function subMilliseconds(dirtyDate, dirtyAmount) {
323
+ requiredArgs(2, arguments);
324
+ var amount = toInteger(dirtyAmount);
325
+ return addMilliseconds(dirtyDate, -amount);
326
+ }
327
+
328
+ var MILLISECONDS_IN_DAY = 86400000;
329
+ function getUTCDayOfYear(dirtyDate) {
330
+ requiredArgs(1, arguments);
331
+ var date = toDate(dirtyDate);
332
+ var timestamp = date.getTime();
333
+ date.setUTCMonth(0, 1);
334
+ date.setUTCHours(0, 0, 0, 0);
335
+ var startOfYearTimestamp = date.getTime();
336
+ var difference = timestamp - startOfYearTimestamp;
337
+ return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
338
+ }
339
+
340
+ function startOfUTCISOWeek(dirtyDate) {
341
+ requiredArgs(1, arguments);
342
+ var weekStartsOn = 1;
343
+ var date = toDate(dirtyDate);
344
+ var day = date.getUTCDay();
345
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
346
+ date.setUTCDate(date.getUTCDate() - diff);
347
+ date.setUTCHours(0, 0, 0, 0);
348
+ return date;
349
+ }
350
+
351
+ function getUTCISOWeekYear(dirtyDate) {
352
+ requiredArgs(1, arguments);
353
+ var date = toDate(dirtyDate);
354
+ var year = date.getUTCFullYear();
355
+ var fourthOfJanuaryOfNextYear = new Date(0);
356
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
357
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
358
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
359
+ var fourthOfJanuaryOfThisYear = new Date(0);
360
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
361
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
362
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
363
+ if (date.getTime() >= startOfNextYear.getTime()) {
364
+ return year + 1;
365
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
366
+ return year;
367
+ } else {
368
+ return year - 1;
369
+ }
370
+ }
371
+
372
+ function startOfUTCISOWeekYear(dirtyDate) {
373
+ requiredArgs(1, arguments);
374
+ var year = getUTCISOWeekYear(dirtyDate);
375
+ var fourthOfJanuary = new Date(0);
376
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
377
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
378
+ var date = startOfUTCISOWeek(fourthOfJanuary);
379
+ return date;
380
+ }
381
+
382
+ var MILLISECONDS_IN_WEEK$1 = 604800000;
383
+ function getUTCISOWeek(dirtyDate) {
384
+ requiredArgs(1, arguments);
385
+ var date = toDate(dirtyDate);
386
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
387
+
388
+ // Round the number of days to the nearest integer
389
+ // because the number of milliseconds in a week is not constant
390
+ // (e.g. it's different in the week of the daylight saving time clock shift)
391
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
392
+ }
393
+
394
+ function startOfUTCWeek(dirtyDate, options) {
395
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
396
+ requiredArgs(1, arguments);
397
+ var defaultOptions = getDefaultOptions();
398
+ var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
399
+
400
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
401
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
402
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
403
+ }
404
+ var date = toDate(dirtyDate);
405
+ var day = date.getUTCDay();
406
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
407
+ date.setUTCDate(date.getUTCDate() - diff);
408
+ date.setUTCHours(0, 0, 0, 0);
409
+ return date;
410
+ }
411
+
412
+ function getUTCWeekYear(dirtyDate, options) {
413
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
414
+ requiredArgs(1, arguments);
415
+ var date = toDate(dirtyDate);
416
+ var year = date.getUTCFullYear();
417
+ var defaultOptions = getDefaultOptions();
418
+ var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
419
+
420
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
421
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
422
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
423
+ }
424
+ var firstWeekOfNextYear = new Date(0);
425
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
426
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
427
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
428
+ var firstWeekOfThisYear = new Date(0);
429
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
430
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
431
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
432
+ if (date.getTime() >= startOfNextYear.getTime()) {
433
+ return year + 1;
434
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
435
+ return year;
436
+ } else {
437
+ return year - 1;
438
+ }
439
+ }
440
+
441
+ function startOfUTCWeekYear(dirtyDate, options) {
442
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
443
+ requiredArgs(1, arguments);
444
+ var defaultOptions = getDefaultOptions();
445
+ var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
446
+ var year = getUTCWeekYear(dirtyDate, options);
447
+ var firstWeek = new Date(0);
448
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
449
+ firstWeek.setUTCHours(0, 0, 0, 0);
450
+ var date = startOfUTCWeek(firstWeek, options);
451
+ return date;
452
+ }
453
+
454
+ var MILLISECONDS_IN_WEEK = 604800000;
455
+ function getUTCWeek(dirtyDate, options) {
456
+ requiredArgs(1, arguments);
457
+ var date = toDate(dirtyDate);
458
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
459
+
460
+ // Round the number of days to the nearest integer
461
+ // because the number of milliseconds in a week is not constant
462
+ // (e.g. it's different in the week of the daylight saving time clock shift)
463
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
464
+ }
465
+
466
+ function addLeadingZeros(number, targetLength) {
467
+ var sign = number < 0 ? '-' : '';
468
+ var output = Math.abs(number).toString();
469
+ while (output.length < targetLength) {
470
+ output = '0' + output;
471
+ }
472
+ return sign + output;
473
+ }
474
+
475
+ /*
476
+ * | | Unit | | Unit |
477
+ * |-----|--------------------------------|-----|--------------------------------|
478
+ * | a | AM, PM | A* | |
479
+ * | d | Day of month | D | |
480
+ * | h | Hour [1-12] | H | Hour [0-23] |
481
+ * | m | Minute | M | Month |
482
+ * | s | Second | S | Fraction of second |
483
+ * | y | Year (abs) | Y | |
484
+ *
485
+ * Letters marked by * are not implemented but reserved by Unicode standard.
486
+ */
487
+ var formatters$1 = {
488
+ // Year
489
+ y: function y(date, token) {
490
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
491
+ // | Year | y | yy | yyy | yyyy | yyyyy |
492
+ // |----------|-------|----|-------|-------|-------|
493
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
494
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
495
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
496
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
497
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
498
+
499
+ var signedYear = date.getUTCFullYear();
500
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
501
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
502
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
503
+ },
504
+ // Month
505
+ M: function M(date, token) {
506
+ var month = date.getUTCMonth();
507
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
508
+ },
509
+ // Day of the month
510
+ d: function d(date, token) {
511
+ return addLeadingZeros(date.getUTCDate(), token.length);
512
+ },
513
+ // AM or PM
514
+ a: function a(date, token) {
515
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
516
+ switch (token) {
517
+ case 'a':
518
+ case 'aa':
519
+ return dayPeriodEnumValue.toUpperCase();
520
+ case 'aaa':
521
+ return dayPeriodEnumValue;
522
+ case 'aaaaa':
523
+ return dayPeriodEnumValue[0];
524
+ case 'aaaa':
525
+ default:
526
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
527
+ }
528
+ },
529
+ // Hour [1-12]
530
+ h: function h(date, token) {
531
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
532
+ },
533
+ // Hour [0-23]
534
+ H: function H(date, token) {
535
+ return addLeadingZeros(date.getUTCHours(), token.length);
536
+ },
537
+ // Minute
538
+ m: function m(date, token) {
539
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
540
+ },
541
+ // Second
542
+ s: function s(date, token) {
543
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
544
+ },
545
+ // Fraction of second
546
+ S: function S(date, token) {
547
+ var numberOfDigits = token.length;
548
+ var milliseconds = date.getUTCMilliseconds();
549
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
550
+ return addLeadingZeros(fractionalSeconds, token.length);
551
+ }
552
+ };
553
+
554
+ var dayPeriodEnum = {
555
+ am: 'am',
556
+ pm: 'pm',
557
+ midnight: 'midnight',
558
+ noon: 'noon',
559
+ morning: 'morning',
560
+ afternoon: 'afternoon',
561
+ evening: 'evening',
562
+ night: 'night'
563
+ };
564
+ /*
565
+ * | | Unit | | Unit |
566
+ * |-----|--------------------------------|-----|--------------------------------|
567
+ * | a | AM, PM | A* | Milliseconds in day |
568
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
569
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
570
+ * | d | Day of month | D | Day of year |
571
+ * | e | Local day of week | E | Day of week |
572
+ * | f | | F* | Day of week in month |
573
+ * | g* | Modified Julian day | G | Era |
574
+ * | h | Hour [1-12] | H | Hour [0-23] |
575
+ * | i! | ISO day of week | I! | ISO week of year |
576
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
577
+ * | k | Hour [1-24] | K | Hour [0-11] |
578
+ * | l* | (deprecated) | L | Stand-alone month |
579
+ * | m | Minute | M | Month |
580
+ * | n | | N | |
581
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
582
+ * | p! | Long localized time | P! | Long localized date |
583
+ * | q | Stand-alone quarter | Q | Quarter |
584
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
585
+ * | s | Second | S | Fraction of second |
586
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
587
+ * | u | Extended year | U* | Cyclic year |
588
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
589
+ * | w | Local week of year | W* | Week of month |
590
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
591
+ * | y | Year (abs) | Y | Local week-numbering year |
592
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
593
+ *
594
+ * Letters marked by * are not implemented but reserved by Unicode standard.
595
+ *
596
+ * Letters marked by ! are non-standard, but implemented by date-fns:
597
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
598
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
599
+ * i.e. 7 for Sunday, 1 for Monday, etc.
600
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
601
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
602
+ * `R` is supposed to be used in conjunction with `I` and `i`
603
+ * for universal ISO week-numbering date, whereas
604
+ * `Y` is supposed to be used in conjunction with `w` and `e`
605
+ * for week-numbering date specific to the locale.
606
+ * - `P` is long localized date format
607
+ * - `p` is long localized time format
608
+ */
609
+
610
+ var formatters = {
611
+ // Era
612
+ G: function G(date, token, localize) {
613
+ var era = date.getUTCFullYear() > 0 ? 1 : 0;
614
+ switch (token) {
615
+ // AD, BC
616
+ case 'G':
617
+ case 'GG':
618
+ case 'GGG':
619
+ return localize.era(era, {
620
+ width: 'abbreviated'
621
+ });
622
+ // A, B
623
+ case 'GGGGG':
624
+ return localize.era(era, {
625
+ width: 'narrow'
626
+ });
627
+ // Anno Domini, Before Christ
628
+ case 'GGGG':
629
+ default:
630
+ return localize.era(era, {
631
+ width: 'wide'
632
+ });
633
+ }
634
+ },
635
+ // Year
636
+ y: function y(date, token, localize) {
637
+ // Ordinal number
638
+ if (token === 'yo') {
639
+ var signedYear = date.getUTCFullYear();
640
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
641
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
642
+ return localize.ordinalNumber(year, {
643
+ unit: 'year'
644
+ });
645
+ }
646
+ return formatters$1.y(date, token);
647
+ },
648
+ // Local week-numbering year
649
+ Y: function Y(date, token, localize, options) {
650
+ var signedWeekYear = getUTCWeekYear(date, options);
651
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
652
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
653
+
654
+ // Two digit year
655
+ if (token === 'YY') {
656
+ var twoDigitYear = weekYear % 100;
657
+ return addLeadingZeros(twoDigitYear, 2);
658
+ }
659
+
660
+ // Ordinal number
661
+ if (token === 'Yo') {
662
+ return localize.ordinalNumber(weekYear, {
663
+ unit: 'year'
664
+ });
665
+ }
666
+
667
+ // Padding
668
+ return addLeadingZeros(weekYear, token.length);
669
+ },
670
+ // ISO week-numbering year
671
+ R: function R(date, token) {
672
+ var isoWeekYear = getUTCISOWeekYear(date);
673
+
674
+ // Padding
675
+ return addLeadingZeros(isoWeekYear, token.length);
676
+ },
677
+ // Extended year. This is a single number designating the year of this calendar system.
678
+ // The main difference between `y` and `u` localizers are B.C. years:
679
+ // | Year | `y` | `u` |
680
+ // |------|-----|-----|
681
+ // | AC 1 | 1 | 1 |
682
+ // | BC 1 | 1 | 0 |
683
+ // | BC 2 | 2 | -1 |
684
+ // Also `yy` always returns the last two digits of a year,
685
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
686
+ u: function u(date, token) {
687
+ var year = date.getUTCFullYear();
688
+ return addLeadingZeros(year, token.length);
689
+ },
690
+ // Quarter
691
+ Q: function Q(date, token, localize) {
692
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
693
+ switch (token) {
694
+ // 1, 2, 3, 4
695
+ case 'Q':
696
+ return String(quarter);
697
+ // 01, 02, 03, 04
698
+ case 'QQ':
699
+ return addLeadingZeros(quarter, 2);
700
+ // 1st, 2nd, 3rd, 4th
701
+ case 'Qo':
702
+ return localize.ordinalNumber(quarter, {
703
+ unit: 'quarter'
704
+ });
705
+ // Q1, Q2, Q3, Q4
706
+ case 'QQQ':
707
+ return localize.quarter(quarter, {
708
+ width: 'abbreviated',
709
+ context: 'formatting'
710
+ });
711
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
712
+ case 'QQQQQ':
713
+ return localize.quarter(quarter, {
714
+ width: 'narrow',
715
+ context: 'formatting'
716
+ });
717
+ // 1st quarter, 2nd quarter, ...
718
+ case 'QQQQ':
719
+ default:
720
+ return localize.quarter(quarter, {
721
+ width: 'wide',
722
+ context: 'formatting'
723
+ });
724
+ }
725
+ },
726
+ // Stand-alone quarter
727
+ q: function q(date, token, localize) {
728
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
729
+ switch (token) {
730
+ // 1, 2, 3, 4
731
+ case 'q':
732
+ return String(quarter);
733
+ // 01, 02, 03, 04
734
+ case 'qq':
735
+ return addLeadingZeros(quarter, 2);
736
+ // 1st, 2nd, 3rd, 4th
737
+ case 'qo':
738
+ return localize.ordinalNumber(quarter, {
739
+ unit: 'quarter'
740
+ });
741
+ // Q1, Q2, Q3, Q4
742
+ case 'qqq':
743
+ return localize.quarter(quarter, {
744
+ width: 'abbreviated',
745
+ context: 'standalone'
746
+ });
747
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
748
+ case 'qqqqq':
749
+ return localize.quarter(quarter, {
750
+ width: 'narrow',
751
+ context: 'standalone'
752
+ });
753
+ // 1st quarter, 2nd quarter, ...
754
+ case 'qqqq':
755
+ default:
756
+ return localize.quarter(quarter, {
757
+ width: 'wide',
758
+ context: 'standalone'
759
+ });
760
+ }
761
+ },
762
+ // Month
763
+ M: function M(date, token, localize) {
764
+ var month = date.getUTCMonth();
765
+ switch (token) {
766
+ case 'M':
767
+ case 'MM':
768
+ return formatters$1.M(date, token);
769
+ // 1st, 2nd, ..., 12th
770
+ case 'Mo':
771
+ return localize.ordinalNumber(month + 1, {
772
+ unit: 'month'
773
+ });
774
+ // Jan, Feb, ..., Dec
775
+ case 'MMM':
776
+ return localize.month(month, {
777
+ width: 'abbreviated',
778
+ context: 'formatting'
779
+ });
780
+ // J, F, ..., D
781
+ case 'MMMMM':
782
+ return localize.month(month, {
783
+ width: 'narrow',
784
+ context: 'formatting'
785
+ });
786
+ // January, February, ..., December
787
+ case 'MMMM':
788
+ default:
789
+ return localize.month(month, {
790
+ width: 'wide',
791
+ context: 'formatting'
792
+ });
793
+ }
794
+ },
795
+ // Stand-alone month
796
+ L: function L(date, token, localize) {
797
+ var month = date.getUTCMonth();
798
+ switch (token) {
799
+ // 1, 2, ..., 12
800
+ case 'L':
801
+ return String(month + 1);
802
+ // 01, 02, ..., 12
803
+ case 'LL':
804
+ return addLeadingZeros(month + 1, 2);
805
+ // 1st, 2nd, ..., 12th
806
+ case 'Lo':
807
+ return localize.ordinalNumber(month + 1, {
808
+ unit: 'month'
809
+ });
810
+ // Jan, Feb, ..., Dec
811
+ case 'LLL':
812
+ return localize.month(month, {
813
+ width: 'abbreviated',
814
+ context: 'standalone'
815
+ });
816
+ // J, F, ..., D
817
+ case 'LLLLL':
818
+ return localize.month(month, {
819
+ width: 'narrow',
820
+ context: 'standalone'
821
+ });
822
+ // January, February, ..., December
823
+ case 'LLLL':
824
+ default:
825
+ return localize.month(month, {
826
+ width: 'wide',
827
+ context: 'standalone'
828
+ });
829
+ }
830
+ },
831
+ // Local week of year
832
+ w: function w(date, token, localize, options) {
833
+ var week = getUTCWeek(date, options);
834
+ if (token === 'wo') {
835
+ return localize.ordinalNumber(week, {
836
+ unit: 'week'
837
+ });
838
+ }
839
+ return addLeadingZeros(week, token.length);
840
+ },
841
+ // ISO week of year
842
+ I: function I(date, token, localize) {
843
+ var isoWeek = getUTCISOWeek(date);
844
+ if (token === 'Io') {
845
+ return localize.ordinalNumber(isoWeek, {
846
+ unit: 'week'
847
+ });
848
+ }
849
+ return addLeadingZeros(isoWeek, token.length);
850
+ },
851
+ // Day of the month
852
+ d: function d(date, token, localize) {
853
+ if (token === 'do') {
854
+ return localize.ordinalNumber(date.getUTCDate(), {
855
+ unit: 'date'
856
+ });
857
+ }
858
+ return formatters$1.d(date, token);
859
+ },
860
+ // Day of year
861
+ D: function D(date, token, localize) {
862
+ var dayOfYear = getUTCDayOfYear(date);
863
+ if (token === 'Do') {
864
+ return localize.ordinalNumber(dayOfYear, {
865
+ unit: 'dayOfYear'
866
+ });
867
+ }
868
+ return addLeadingZeros(dayOfYear, token.length);
869
+ },
870
+ // Day of week
871
+ E: function E(date, token, localize) {
872
+ var dayOfWeek = date.getUTCDay();
873
+ switch (token) {
874
+ // Tue
875
+ case 'E':
876
+ case 'EE':
877
+ case 'EEE':
878
+ return localize.day(dayOfWeek, {
879
+ width: 'abbreviated',
880
+ context: 'formatting'
881
+ });
882
+ // T
883
+ case 'EEEEE':
884
+ return localize.day(dayOfWeek, {
885
+ width: 'narrow',
886
+ context: 'formatting'
887
+ });
888
+ // Tu
889
+ case 'EEEEEE':
890
+ return localize.day(dayOfWeek, {
891
+ width: 'short',
892
+ context: 'formatting'
893
+ });
894
+ // Tuesday
895
+ case 'EEEE':
896
+ default:
897
+ return localize.day(dayOfWeek, {
898
+ width: 'wide',
899
+ context: 'formatting'
900
+ });
901
+ }
902
+ },
903
+ // Local day of week
904
+ e: function e(date, token, localize, options) {
905
+ var dayOfWeek = date.getUTCDay();
906
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
907
+ switch (token) {
908
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
909
+ case 'e':
910
+ return String(localDayOfWeek);
911
+ // Padded numerical value
912
+ case 'ee':
913
+ return addLeadingZeros(localDayOfWeek, 2);
914
+ // 1st, 2nd, ..., 7th
915
+ case 'eo':
916
+ return localize.ordinalNumber(localDayOfWeek, {
917
+ unit: 'day'
918
+ });
919
+ case 'eee':
920
+ return localize.day(dayOfWeek, {
921
+ width: 'abbreviated',
922
+ context: 'formatting'
923
+ });
924
+ // T
925
+ case 'eeeee':
926
+ return localize.day(dayOfWeek, {
927
+ width: 'narrow',
928
+ context: 'formatting'
929
+ });
930
+ // Tu
931
+ case 'eeeeee':
932
+ return localize.day(dayOfWeek, {
933
+ width: 'short',
934
+ context: 'formatting'
935
+ });
936
+ // Tuesday
937
+ case 'eeee':
938
+ default:
939
+ return localize.day(dayOfWeek, {
940
+ width: 'wide',
941
+ context: 'formatting'
942
+ });
943
+ }
944
+ },
945
+ // Stand-alone local day of week
946
+ c: function c(date, token, localize, options) {
947
+ var dayOfWeek = date.getUTCDay();
948
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
949
+ switch (token) {
950
+ // Numerical value (same as in `e`)
951
+ case 'c':
952
+ return String(localDayOfWeek);
953
+ // Padded numerical value
954
+ case 'cc':
955
+ return addLeadingZeros(localDayOfWeek, token.length);
956
+ // 1st, 2nd, ..., 7th
957
+ case 'co':
958
+ return localize.ordinalNumber(localDayOfWeek, {
959
+ unit: 'day'
960
+ });
961
+ case 'ccc':
962
+ return localize.day(dayOfWeek, {
963
+ width: 'abbreviated',
964
+ context: 'standalone'
965
+ });
966
+ // T
967
+ case 'ccccc':
968
+ return localize.day(dayOfWeek, {
969
+ width: 'narrow',
970
+ context: 'standalone'
971
+ });
972
+ // Tu
973
+ case 'cccccc':
974
+ return localize.day(dayOfWeek, {
975
+ width: 'short',
976
+ context: 'standalone'
977
+ });
978
+ // Tuesday
979
+ case 'cccc':
980
+ default:
981
+ return localize.day(dayOfWeek, {
982
+ width: 'wide',
983
+ context: 'standalone'
984
+ });
985
+ }
986
+ },
987
+ // ISO day of week
988
+ i: function i(date, token, localize) {
989
+ var dayOfWeek = date.getUTCDay();
990
+ var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
991
+ switch (token) {
992
+ // 2
993
+ case 'i':
994
+ return String(isoDayOfWeek);
995
+ // 02
996
+ case 'ii':
997
+ return addLeadingZeros(isoDayOfWeek, token.length);
998
+ // 2nd
999
+ case 'io':
1000
+ return localize.ordinalNumber(isoDayOfWeek, {
1001
+ unit: 'day'
1002
+ });
1003
+ // Tue
1004
+ case 'iii':
1005
+ return localize.day(dayOfWeek, {
1006
+ width: 'abbreviated',
1007
+ context: 'formatting'
1008
+ });
1009
+ // T
1010
+ case 'iiiii':
1011
+ return localize.day(dayOfWeek, {
1012
+ width: 'narrow',
1013
+ context: 'formatting'
1014
+ });
1015
+ // Tu
1016
+ case 'iiiiii':
1017
+ return localize.day(dayOfWeek, {
1018
+ width: 'short',
1019
+ context: 'formatting'
1020
+ });
1021
+ // Tuesday
1022
+ case 'iiii':
1023
+ default:
1024
+ return localize.day(dayOfWeek, {
1025
+ width: 'wide',
1026
+ context: 'formatting'
1027
+ });
1028
+ }
1029
+ },
1030
+ // AM or PM
1031
+ a: function a(date, token, localize) {
1032
+ var hours = date.getUTCHours();
1033
+ var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1034
+ switch (token) {
1035
+ case 'a':
1036
+ case 'aa':
1037
+ return localize.dayPeriod(dayPeriodEnumValue, {
1038
+ width: 'abbreviated',
1039
+ context: 'formatting'
1040
+ });
1041
+ case 'aaa':
1042
+ return localize.dayPeriod(dayPeriodEnumValue, {
1043
+ width: 'abbreviated',
1044
+ context: 'formatting'
1045
+ }).toLowerCase();
1046
+ case 'aaaaa':
1047
+ return localize.dayPeriod(dayPeriodEnumValue, {
1048
+ width: 'narrow',
1049
+ context: 'formatting'
1050
+ });
1051
+ case 'aaaa':
1052
+ default:
1053
+ return localize.dayPeriod(dayPeriodEnumValue, {
1054
+ width: 'wide',
1055
+ context: 'formatting'
1056
+ });
1057
+ }
1058
+ },
1059
+ // AM, PM, midnight, noon
1060
+ b: function b(date, token, localize) {
1061
+ var hours = date.getUTCHours();
1062
+ var dayPeriodEnumValue;
1063
+ if (hours === 12) {
1064
+ dayPeriodEnumValue = dayPeriodEnum.noon;
1065
+ } else if (hours === 0) {
1066
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
1067
+ } else {
1068
+ dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1069
+ }
1070
+ switch (token) {
1071
+ case 'b':
1072
+ case 'bb':
1073
+ return localize.dayPeriod(dayPeriodEnumValue, {
1074
+ width: 'abbreviated',
1075
+ context: 'formatting'
1076
+ });
1077
+ case 'bbb':
1078
+ return localize.dayPeriod(dayPeriodEnumValue, {
1079
+ width: 'abbreviated',
1080
+ context: 'formatting'
1081
+ }).toLowerCase();
1082
+ case 'bbbbb':
1083
+ return localize.dayPeriod(dayPeriodEnumValue, {
1084
+ width: 'narrow',
1085
+ context: 'formatting'
1086
+ });
1087
+ case 'bbbb':
1088
+ default:
1089
+ return localize.dayPeriod(dayPeriodEnumValue, {
1090
+ width: 'wide',
1091
+ context: 'formatting'
1092
+ });
1093
+ }
1094
+ },
1095
+ // in the morning, in the afternoon, in the evening, at night
1096
+ B: function B(date, token, localize) {
1097
+ var hours = date.getUTCHours();
1098
+ var dayPeriodEnumValue;
1099
+ if (hours >= 17) {
1100
+ dayPeriodEnumValue = dayPeriodEnum.evening;
1101
+ } else if (hours >= 12) {
1102
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
1103
+ } else if (hours >= 4) {
1104
+ dayPeriodEnumValue = dayPeriodEnum.morning;
1105
+ } else {
1106
+ dayPeriodEnumValue = dayPeriodEnum.night;
1107
+ }
1108
+ switch (token) {
1109
+ case 'B':
1110
+ case 'BB':
1111
+ case 'BBB':
1112
+ return localize.dayPeriod(dayPeriodEnumValue, {
1113
+ width: 'abbreviated',
1114
+ context: 'formatting'
1115
+ });
1116
+ case 'BBBBB':
1117
+ return localize.dayPeriod(dayPeriodEnumValue, {
1118
+ width: 'narrow',
1119
+ context: 'formatting'
1120
+ });
1121
+ case 'BBBB':
1122
+ default:
1123
+ return localize.dayPeriod(dayPeriodEnumValue, {
1124
+ width: 'wide',
1125
+ context: 'formatting'
1126
+ });
1127
+ }
1128
+ },
1129
+ // Hour [1-12]
1130
+ h: function h(date, token, localize) {
1131
+ if (token === 'ho') {
1132
+ var hours = date.getUTCHours() % 12;
1133
+ if (hours === 0) hours = 12;
1134
+ return localize.ordinalNumber(hours, {
1135
+ unit: 'hour'
1136
+ });
1137
+ }
1138
+ return formatters$1.h(date, token);
1139
+ },
1140
+ // Hour [0-23]
1141
+ H: function H(date, token, localize) {
1142
+ if (token === 'Ho') {
1143
+ return localize.ordinalNumber(date.getUTCHours(), {
1144
+ unit: 'hour'
1145
+ });
1146
+ }
1147
+ return formatters$1.H(date, token);
1148
+ },
1149
+ // Hour [0-11]
1150
+ K: function K(date, token, localize) {
1151
+ var hours = date.getUTCHours() % 12;
1152
+ if (token === 'Ko') {
1153
+ return localize.ordinalNumber(hours, {
1154
+ unit: 'hour'
1155
+ });
1156
+ }
1157
+ return addLeadingZeros(hours, token.length);
1158
+ },
1159
+ // Hour [1-24]
1160
+ k: function k(date, token, localize) {
1161
+ var hours = date.getUTCHours();
1162
+ if (hours === 0) hours = 24;
1163
+ if (token === 'ko') {
1164
+ return localize.ordinalNumber(hours, {
1165
+ unit: 'hour'
1166
+ });
1167
+ }
1168
+ return addLeadingZeros(hours, token.length);
1169
+ },
1170
+ // Minute
1171
+ m: function m(date, token, localize) {
1172
+ if (token === 'mo') {
1173
+ return localize.ordinalNumber(date.getUTCMinutes(), {
1174
+ unit: 'minute'
1175
+ });
1176
+ }
1177
+ return formatters$1.m(date, token);
1178
+ },
1179
+ // Second
1180
+ s: function s(date, token, localize) {
1181
+ if (token === 'so') {
1182
+ return localize.ordinalNumber(date.getUTCSeconds(), {
1183
+ unit: 'second'
1184
+ });
1185
+ }
1186
+ return formatters$1.s(date, token);
1187
+ },
1188
+ // Fraction of second
1189
+ S: function S(date, token) {
1190
+ return formatters$1.S(date, token);
1191
+ },
1192
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1193
+ X: function X(date, token, _localize, options) {
1194
+ var originalDate = options._originalDate || date;
1195
+ var timezoneOffset = originalDate.getTimezoneOffset();
1196
+ if (timezoneOffset === 0) {
1197
+ return 'Z';
1198
+ }
1199
+ switch (token) {
1200
+ // Hours and optional minutes
1201
+ case 'X':
1202
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1203
+
1204
+ // Hours, minutes and optional seconds without `:` delimiter
1205
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1206
+ // so this token always has the same output as `XX`
1207
+ case 'XXXX':
1208
+ case 'XX':
1209
+ // Hours and minutes without `:` delimiter
1210
+ return formatTimezone(timezoneOffset);
1211
+
1212
+ // Hours, minutes and optional seconds with `:` delimiter
1213
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1214
+ // so this token always has the same output as `XXX`
1215
+ case 'XXXXX':
1216
+ case 'XXX': // Hours and minutes with `:` delimiter
1217
+ default:
1218
+ return formatTimezone(timezoneOffset, ':');
1219
+ }
1220
+ },
1221
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1222
+ x: function x(date, token, _localize, options) {
1223
+ var originalDate = options._originalDate || date;
1224
+ var timezoneOffset = originalDate.getTimezoneOffset();
1225
+ switch (token) {
1226
+ // Hours and optional minutes
1227
+ case 'x':
1228
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1229
+
1230
+ // Hours, minutes and optional seconds without `:` delimiter
1231
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1232
+ // so this token always has the same output as `xx`
1233
+ case 'xxxx':
1234
+ case 'xx':
1235
+ // Hours and minutes without `:` delimiter
1236
+ return formatTimezone(timezoneOffset);
1237
+
1238
+ // Hours, minutes and optional seconds with `:` delimiter
1239
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1240
+ // so this token always has the same output as `xxx`
1241
+ case 'xxxxx':
1242
+ case 'xxx': // Hours and minutes with `:` delimiter
1243
+ default:
1244
+ return formatTimezone(timezoneOffset, ':');
1245
+ }
1246
+ },
1247
+ // Timezone (GMT)
1248
+ O: function O(date, token, _localize, options) {
1249
+ var originalDate = options._originalDate || date;
1250
+ var timezoneOffset = originalDate.getTimezoneOffset();
1251
+ switch (token) {
1252
+ // Short
1253
+ case 'O':
1254
+ case 'OO':
1255
+ case 'OOO':
1256
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1257
+ // Long
1258
+ case 'OOOO':
1259
+ default:
1260
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1261
+ }
1262
+ },
1263
+ // Timezone (specific non-location)
1264
+ z: function z(date, token, _localize, options) {
1265
+ var originalDate = options._originalDate || date;
1266
+ var timezoneOffset = originalDate.getTimezoneOffset();
1267
+ switch (token) {
1268
+ // Short
1269
+ case 'z':
1270
+ case 'zz':
1271
+ case 'zzz':
1272
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1273
+ // Long
1274
+ case 'zzzz':
1275
+ default:
1276
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1277
+ }
1278
+ },
1279
+ // Seconds timestamp
1280
+ t: function t(date, token, _localize, options) {
1281
+ var originalDate = options._originalDate || date;
1282
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
1283
+ return addLeadingZeros(timestamp, token.length);
1284
+ },
1285
+ // Milliseconds timestamp
1286
+ T: function T(date, token, _localize, options) {
1287
+ var originalDate = options._originalDate || date;
1288
+ var timestamp = originalDate.getTime();
1289
+ return addLeadingZeros(timestamp, token.length);
1290
+ }
1291
+ };
1292
+ function formatTimezoneShort(offset, dirtyDelimiter) {
1293
+ var sign = offset > 0 ? '-' : '+';
1294
+ var absOffset = Math.abs(offset);
1295
+ var hours = Math.floor(absOffset / 60);
1296
+ var minutes = absOffset % 60;
1297
+ if (minutes === 0) {
1298
+ return sign + String(hours);
1299
+ }
1300
+ var delimiter = dirtyDelimiter || '';
1301
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1302
+ }
1303
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1304
+ if (offset % 60 === 0) {
1305
+ var sign = offset > 0 ? '-' : '+';
1306
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1307
+ }
1308
+ return formatTimezone(offset, dirtyDelimiter);
1309
+ }
1310
+ function formatTimezone(offset, dirtyDelimiter) {
1311
+ var delimiter = dirtyDelimiter || '';
1312
+ var sign = offset > 0 ? '-' : '+';
1313
+ var absOffset = Math.abs(offset);
1314
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1315
+ var minutes = addLeadingZeros(absOffset % 60, 2);
1316
+ return sign + hours + delimiter + minutes;
1317
+ }
1318
+
1319
+ var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1320
+ switch (pattern) {
1321
+ case 'P':
1322
+ return formatLong.date({
1323
+ width: 'short'
1324
+ });
1325
+ case 'PP':
1326
+ return formatLong.date({
1327
+ width: 'medium'
1328
+ });
1329
+ case 'PPP':
1330
+ return formatLong.date({
1331
+ width: 'long'
1332
+ });
1333
+ case 'PPPP':
1334
+ default:
1335
+ return formatLong.date({
1336
+ width: 'full'
1337
+ });
1338
+ }
1339
+ };
1340
+ var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1341
+ switch (pattern) {
1342
+ case 'p':
1343
+ return formatLong.time({
1344
+ width: 'short'
1345
+ });
1346
+ case 'pp':
1347
+ return formatLong.time({
1348
+ width: 'medium'
1349
+ });
1350
+ case 'ppp':
1351
+ return formatLong.time({
1352
+ width: 'long'
1353
+ });
1354
+ case 'pppp':
1355
+ default:
1356
+ return formatLong.time({
1357
+ width: 'full'
1358
+ });
1359
+ }
1360
+ };
1361
+ var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1362
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
1363
+ var datePattern = matchResult[1];
1364
+ var timePattern = matchResult[2];
1365
+ if (!timePattern) {
1366
+ return dateLongFormatter(pattern, formatLong);
1367
+ }
1368
+ var dateTimeFormat;
1369
+ switch (datePattern) {
1370
+ case 'P':
1371
+ dateTimeFormat = formatLong.dateTime({
1372
+ width: 'short'
1373
+ });
1374
+ break;
1375
+ case 'PP':
1376
+ dateTimeFormat = formatLong.dateTime({
1377
+ width: 'medium'
1378
+ });
1379
+ break;
1380
+ case 'PPP':
1381
+ dateTimeFormat = formatLong.dateTime({
1382
+ width: 'long'
1383
+ });
1384
+ break;
1385
+ case 'PPPP':
1386
+ default:
1387
+ dateTimeFormat = formatLong.dateTime({
1388
+ width: 'full'
1389
+ });
1390
+ break;
1391
+ }
1392
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1393
+ };
1394
+ var longFormatters = {
1395
+ p: timeLongFormatter,
1396
+ P: dateTimeLongFormatter
1397
+ };
1398
+
1399
+ var protectedDayOfYearTokens = ['D', 'DD'];
1400
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
1401
+ function isProtectedDayOfYearToken(token) {
1402
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
1403
+ }
1404
+ function isProtectedWeekYearToken(token) {
1405
+ return protectedWeekYearTokens.indexOf(token) !== -1;
1406
+ }
1407
+ function throwProtectedError(token, format, input) {
1408
+ if (token === 'YYYY') {
1409
+ throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1410
+ } else if (token === 'YY') {
1411
+ throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1412
+ } else if (token === 'D') {
1413
+ throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1414
+ } else if (token === 'DD') {
1415
+ throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1416
+ }
1417
+ }
1418
+
1419
+ var formatDistanceLocale = {
1420
+ lessThanXSeconds: {
1421
+ one: 'less than a second',
1422
+ other: 'less than {{count}} seconds'
1423
+ },
1424
+ xSeconds: {
1425
+ one: '1 second',
1426
+ other: '{{count}} seconds'
1427
+ },
1428
+ halfAMinute: 'half a minute',
1429
+ lessThanXMinutes: {
1430
+ one: 'less than a minute',
1431
+ other: 'less than {{count}} minutes'
1432
+ },
1433
+ xMinutes: {
1434
+ one: '1 minute',
1435
+ other: '{{count}} minutes'
1436
+ },
1437
+ aboutXHours: {
1438
+ one: 'about 1 hour',
1439
+ other: 'about {{count}} hours'
1440
+ },
1441
+ xHours: {
1442
+ one: '1 hour',
1443
+ other: '{{count}} hours'
1444
+ },
1445
+ xDays: {
1446
+ one: '1 day',
1447
+ other: '{{count}} days'
1448
+ },
1449
+ aboutXWeeks: {
1450
+ one: 'about 1 week',
1451
+ other: 'about {{count}} weeks'
1452
+ },
1453
+ xWeeks: {
1454
+ one: '1 week',
1455
+ other: '{{count}} weeks'
1456
+ },
1457
+ aboutXMonths: {
1458
+ one: 'about 1 month',
1459
+ other: 'about {{count}} months'
1460
+ },
1461
+ xMonths: {
1462
+ one: '1 month',
1463
+ other: '{{count}} months'
1464
+ },
1465
+ aboutXYears: {
1466
+ one: 'about 1 year',
1467
+ other: 'about {{count}} years'
1468
+ },
1469
+ xYears: {
1470
+ one: '1 year',
1471
+ other: '{{count}} years'
1472
+ },
1473
+ overXYears: {
1474
+ one: 'over 1 year',
1475
+ other: 'over {{count}} years'
1476
+ },
1477
+ almostXYears: {
1478
+ one: 'almost 1 year',
1479
+ other: 'almost {{count}} years'
1480
+ }
1481
+ };
1482
+ var formatDistance = function formatDistance(token, count, options) {
1483
+ var result;
1484
+ var tokenValue = formatDistanceLocale[token];
1485
+ if (typeof tokenValue === 'string') {
1486
+ result = tokenValue;
1487
+ } else if (count === 1) {
1488
+ result = tokenValue.one;
1489
+ } else {
1490
+ result = tokenValue.other.replace('{{count}}', count.toString());
1491
+ }
1492
+ if (options !== null && options !== void 0 && options.addSuffix) {
1493
+ if (options.comparison && options.comparison > 0) {
1494
+ return 'in ' + result;
1495
+ } else {
1496
+ return result + ' ago';
1497
+ }
1498
+ }
1499
+ return result;
1500
+ };
1501
+
1502
+ function buildFormatLongFn(args) {
1503
+ return function () {
1504
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1505
+ // TODO: Remove String()
1506
+ var width = options.width ? String(options.width) : args.defaultWidth;
1507
+ var format = args.formats[width] || args.formats[args.defaultWidth];
1508
+ return format;
1509
+ };
1510
+ }
1511
+
1512
+ var dateFormats = {
1513
+ full: 'EEEE, MMMM do, y',
1514
+ long: 'MMMM do, y',
1515
+ medium: 'MMM d, y',
1516
+ short: 'MM/dd/yyyy'
1517
+ };
1518
+ var timeFormats = {
1519
+ full: 'h:mm:ss a zzzz',
1520
+ long: 'h:mm:ss a z',
1521
+ medium: 'h:mm:ss a',
1522
+ short: 'h:mm a'
1523
+ };
1524
+ var dateTimeFormats = {
1525
+ full: "{{date}} 'at' {{time}}",
1526
+ long: "{{date}} 'at' {{time}}",
1527
+ medium: '{{date}}, {{time}}',
1528
+ short: '{{date}}, {{time}}'
1529
+ };
1530
+ var formatLong = {
1531
+ date: buildFormatLongFn({
1532
+ formats: dateFormats,
1533
+ defaultWidth: 'full'
1534
+ }),
1535
+ time: buildFormatLongFn({
1536
+ formats: timeFormats,
1537
+ defaultWidth: 'full'
1538
+ }),
1539
+ dateTime: buildFormatLongFn({
1540
+ formats: dateTimeFormats,
1541
+ defaultWidth: 'full'
1542
+ })
1543
+ };
1544
+
1545
+ var formatRelativeLocale = {
1546
+ lastWeek: "'last' eeee 'at' p",
1547
+ yesterday: "'yesterday at' p",
1548
+ today: "'today at' p",
1549
+ tomorrow: "'tomorrow at' p",
1550
+ nextWeek: "eeee 'at' p",
1551
+ other: 'P'
1552
+ };
1553
+ var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1554
+ return formatRelativeLocale[token];
1555
+ };
1556
+
1557
+ function buildLocalizeFn(args) {
1558
+ return function (dirtyIndex, options) {
1559
+ var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1560
+ var valuesArray;
1561
+ if (context === 'formatting' && args.formattingValues) {
1562
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1563
+ var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1564
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1565
+ } else {
1566
+ var _defaultWidth = args.defaultWidth;
1567
+ var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1568
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
1569
+ }
1570
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1571
+ // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
1572
+ return valuesArray[index];
1573
+ };
1574
+ }
1575
+
1576
+ var eraValues = {
1577
+ narrow: ['B', 'A'],
1578
+ abbreviated: ['BC', 'AD'],
1579
+ wide: ['Before Christ', 'Anno Domini']
1580
+ };
1581
+ var quarterValues = {
1582
+ narrow: ['1', '2', '3', '4'],
1583
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1584
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1585
+ };
1586
+
1587
+ // Note: in English, the names of days of the week and months are capitalized.
1588
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1589
+ // Generally, formatted dates should look like they are in the middle of a sentence,
1590
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
1591
+ var monthValues = {
1592
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1593
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1594
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1595
+ };
1596
+ var dayValues = {
1597
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1598
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1599
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1600
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1601
+ };
1602
+ var dayPeriodValues = {
1603
+ narrow: {
1604
+ am: 'a',
1605
+ pm: 'p',
1606
+ midnight: 'mi',
1607
+ noon: 'n',
1608
+ morning: 'morning',
1609
+ afternoon: 'afternoon',
1610
+ evening: 'evening',
1611
+ night: 'night'
1612
+ },
1613
+ abbreviated: {
1614
+ am: 'AM',
1615
+ pm: 'PM',
1616
+ midnight: 'midnight',
1617
+ noon: 'noon',
1618
+ morning: 'morning',
1619
+ afternoon: 'afternoon',
1620
+ evening: 'evening',
1621
+ night: 'night'
1622
+ },
1623
+ wide: {
1624
+ am: 'a.m.',
1625
+ pm: 'p.m.',
1626
+ midnight: 'midnight',
1627
+ noon: 'noon',
1628
+ morning: 'morning',
1629
+ afternoon: 'afternoon',
1630
+ evening: 'evening',
1631
+ night: 'night'
1632
+ }
1633
+ };
1634
+ var formattingDayPeriodValues = {
1635
+ narrow: {
1636
+ am: 'a',
1637
+ pm: 'p',
1638
+ midnight: 'mi',
1639
+ noon: 'n',
1640
+ morning: 'in the morning',
1641
+ afternoon: 'in the afternoon',
1642
+ evening: 'in the evening',
1643
+ night: 'at night'
1644
+ },
1645
+ abbreviated: {
1646
+ am: 'AM',
1647
+ pm: 'PM',
1648
+ midnight: 'midnight',
1649
+ noon: 'noon',
1650
+ morning: 'in the morning',
1651
+ afternoon: 'in the afternoon',
1652
+ evening: 'in the evening',
1653
+ night: 'at night'
1654
+ },
1655
+ wide: {
1656
+ am: 'a.m.',
1657
+ pm: 'p.m.',
1658
+ midnight: 'midnight',
1659
+ noon: 'noon',
1660
+ morning: 'in the morning',
1661
+ afternoon: 'in the afternoon',
1662
+ evening: 'in the evening',
1663
+ night: 'at night'
1664
+ }
1665
+ };
1666
+ var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1667
+ var number = Number(dirtyNumber);
1668
+
1669
+ // If ordinal numbers depend on context, for example,
1670
+ // if they are different for different grammatical genders,
1671
+ // use `options.unit`.
1672
+ //
1673
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1674
+ // 'day', 'hour', 'minute', 'second'.
1675
+
1676
+ var rem100 = number % 100;
1677
+ if (rem100 > 20 || rem100 < 10) {
1678
+ switch (rem100 % 10) {
1679
+ case 1:
1680
+ return number + 'st';
1681
+ case 2:
1682
+ return number + 'nd';
1683
+ case 3:
1684
+ return number + 'rd';
1685
+ }
1686
+ }
1687
+ return number + 'th';
1688
+ };
1689
+ var localize = {
1690
+ ordinalNumber: ordinalNumber,
1691
+ era: buildLocalizeFn({
1692
+ values: eraValues,
1693
+ defaultWidth: 'wide'
1694
+ }),
1695
+ quarter: buildLocalizeFn({
1696
+ values: quarterValues,
1697
+ defaultWidth: 'wide',
1698
+ argumentCallback: function argumentCallback(quarter) {
1699
+ return quarter - 1;
1700
+ }
1701
+ }),
1702
+ month: buildLocalizeFn({
1703
+ values: monthValues,
1704
+ defaultWidth: 'wide'
1705
+ }),
1706
+ day: buildLocalizeFn({
1707
+ values: dayValues,
1708
+ defaultWidth: 'wide'
1709
+ }),
1710
+ dayPeriod: buildLocalizeFn({
1711
+ values: dayPeriodValues,
1712
+ defaultWidth: 'wide',
1713
+ formattingValues: formattingDayPeriodValues,
1714
+ defaultFormattingWidth: 'wide'
1715
+ })
1716
+ };
1717
+
1718
+ function buildMatchFn(args) {
1719
+ return function (string) {
1720
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1721
+ var width = options.width;
1722
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1723
+ var matchResult = string.match(matchPattern);
1724
+ if (!matchResult) {
1725
+ return null;
1726
+ }
1727
+ var matchedString = matchResult[0];
1728
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1729
+ var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1730
+ return pattern.test(matchedString);
1731
+ }) : findKey(parsePatterns, function (pattern) {
1732
+ return pattern.test(matchedString);
1733
+ });
1734
+ var value;
1735
+ value = args.valueCallback ? args.valueCallback(key) : key;
1736
+ value = options.valueCallback ? options.valueCallback(value) : value;
1737
+ var rest = string.slice(matchedString.length);
1738
+ return {
1739
+ value: value,
1740
+ rest: rest
1741
+ };
1742
+ };
1743
+ }
1744
+ function findKey(object, predicate) {
1745
+ for (var key in object) {
1746
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
1747
+ return key;
1748
+ }
1749
+ }
1750
+ return undefined;
1751
+ }
1752
+ function findIndex(array, predicate) {
1753
+ for (var key = 0; key < array.length; key++) {
1754
+ if (predicate(array[key])) {
1755
+ return key;
1756
+ }
1757
+ }
1758
+ return undefined;
1759
+ }
1760
+
1761
+ function buildMatchPatternFn(args) {
1762
+ return function (string) {
1763
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1764
+ var matchResult = string.match(args.matchPattern);
1765
+ if (!matchResult) return null;
1766
+ var matchedString = matchResult[0];
1767
+ var parseResult = string.match(args.parsePattern);
1768
+ if (!parseResult) return null;
1769
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1770
+ value = options.valueCallback ? options.valueCallback(value) : value;
1771
+ var rest = string.slice(matchedString.length);
1772
+ return {
1773
+ value: value,
1774
+ rest: rest
1775
+ };
1776
+ };
1777
+ }
1778
+
1779
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1780
+ var parseOrdinalNumberPattern = /\d+/i;
1781
+ var matchEraPatterns = {
1782
+ narrow: /^(b|a)/i,
1783
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1784
+ wide: /^(before christ|before common era|anno domini|common era)/i
1785
+ };
1786
+ var parseEraPatterns = {
1787
+ any: [/^b/i, /^(a|c)/i]
1788
+ };
1789
+ var matchQuarterPatterns = {
1790
+ narrow: /^[1234]/i,
1791
+ abbreviated: /^q[1234]/i,
1792
+ wide: /^[1234](th|st|nd|rd)? quarter/i
1793
+ };
1794
+ var parseQuarterPatterns = {
1795
+ any: [/1/i, /2/i, /3/i, /4/i]
1796
+ };
1797
+ var matchMonthPatterns = {
1798
+ narrow: /^[jfmasond]/i,
1799
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1800
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
1801
+ };
1802
+ var parseMonthPatterns = {
1803
+ 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],
1804
+ 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]
1805
+ };
1806
+ var matchDayPatterns = {
1807
+ narrow: /^[smtwf]/i,
1808
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
1809
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
1810
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
1811
+ };
1812
+ var parseDayPatterns = {
1813
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
1814
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
1815
+ };
1816
+ var matchDayPeriodPatterns = {
1817
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
1818
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
1819
+ };
1820
+ var parseDayPeriodPatterns = {
1821
+ any: {
1822
+ am: /^a/i,
1823
+ pm: /^p/i,
1824
+ midnight: /^mi/i,
1825
+ noon: /^no/i,
1826
+ morning: /morning/i,
1827
+ afternoon: /afternoon/i,
1828
+ evening: /evening/i,
1829
+ night: /night/i
1830
+ }
1831
+ };
1832
+ var match = {
1833
+ ordinalNumber: buildMatchPatternFn({
1834
+ matchPattern: matchOrdinalNumberPattern,
1835
+ parsePattern: parseOrdinalNumberPattern,
1836
+ valueCallback: function valueCallback(value) {
1837
+ return parseInt(value, 10);
1838
+ }
1839
+ }),
1840
+ era: buildMatchFn({
1841
+ matchPatterns: matchEraPatterns,
1842
+ defaultMatchWidth: 'wide',
1843
+ parsePatterns: parseEraPatterns,
1844
+ defaultParseWidth: 'any'
1845
+ }),
1846
+ quarter: buildMatchFn({
1847
+ matchPatterns: matchQuarterPatterns,
1848
+ defaultMatchWidth: 'wide',
1849
+ parsePatterns: parseQuarterPatterns,
1850
+ defaultParseWidth: 'any',
1851
+ valueCallback: function valueCallback(index) {
1852
+ return index + 1;
1853
+ }
1854
+ }),
1855
+ month: buildMatchFn({
1856
+ matchPatterns: matchMonthPatterns,
1857
+ defaultMatchWidth: 'wide',
1858
+ parsePatterns: parseMonthPatterns,
1859
+ defaultParseWidth: 'any'
1860
+ }),
1861
+ day: buildMatchFn({
1862
+ matchPatterns: matchDayPatterns,
1863
+ defaultMatchWidth: 'wide',
1864
+ parsePatterns: parseDayPatterns,
1865
+ defaultParseWidth: 'any'
1866
+ }),
1867
+ dayPeriod: buildMatchFn({
1868
+ matchPatterns: matchDayPeriodPatterns,
1869
+ defaultMatchWidth: 'any',
1870
+ parsePatterns: parseDayPeriodPatterns,
1871
+ defaultParseWidth: 'any'
1872
+ })
1873
+ };
1874
+
1875
+ /**
1876
+ * @type {Locale}
1877
+ * @category Locales
1878
+ * @summary English locale (United States).
1879
+ * @language English
1880
+ * @iso-639-2 eng
1881
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
1882
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
1883
+ */
1884
+ var locale = {
1885
+ code: 'en-US',
1886
+ formatDistance: formatDistance,
1887
+ formatLong: formatLong,
1888
+ formatRelative: formatRelative,
1889
+ localize: localize,
1890
+ match: match,
1891
+ options: {
1892
+ weekStartsOn: 0 /* Sunday */,
1893
+ firstWeekContainsDate: 1
1894
+ }
1895
+ };
1896
+
1897
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
1898
+ // (one of the certain letters followed by `o`)
1899
+ // - (\w)\1* matches any sequences of the same letter
1900
+ // - '' matches two quote characters in a row
1901
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
1902
+ // except a single quote symbol, which ends the sequence.
1903
+ // Two quote characters do not end the sequence.
1904
+ // If there is no matching single quote
1905
+ // then the sequence will continue until the end of the string.
1906
+ // - . matches any single character unmatched by previous parts of the RegExps
1907
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
1908
+
1909
+ // This RegExp catches symbols escaped by quotes, and also
1910
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
1911
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
1912
+ var escapedStringRegExp = /^'([^]*?)'?$/;
1913
+ var doubleQuoteRegExp = /''/g;
1914
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
1915
+
1916
+ /**
1917
+ * @name format
1918
+ * @category Common Helpers
1919
+ * @summary Format the date.
1920
+ *
1921
+ * @description
1922
+ * Return the formatted date string in the given format. The result may vary by locale.
1923
+ *
1924
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
1925
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
1926
+ *
1927
+ * The characters wrapped between two single quotes characters (') are escaped.
1928
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
1929
+ * (see the last example)
1930
+ *
1931
+ * Format of the string is based on Unicode Technical Standard #35:
1932
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
1933
+ * with a few additions (see note 7 below the table).
1934
+ *
1935
+ * Accepted patterns:
1936
+ * | Unit | Pattern | Result examples | Notes |
1937
+ * |---------------------------------|---------|-----------------------------------|-------|
1938
+ * | Era | G..GGG | AD, BC | |
1939
+ * | | GGGG | Anno Domini, Before Christ | 2 |
1940
+ * | | GGGGG | A, B | |
1941
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
1942
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
1943
+ * | | yy | 44, 01, 00, 17 | 5 |
1944
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
1945
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
1946
+ * | | yyyyy | ... | 3,5 |
1947
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
1948
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
1949
+ * | | YY | 44, 01, 00, 17 | 5,8 |
1950
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
1951
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
1952
+ * | | YYYYY | ... | 3,5 |
1953
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
1954
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
1955
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
1956
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
1957
+ * | | RRRRR | ... | 3,5,7 |
1958
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
1959
+ * | | uu | -43, 01, 1900, 2017 | 5 |
1960
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
1961
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
1962
+ * | | uuuuu | ... | 3,5 |
1963
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
1964
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
1965
+ * | | QQ | 01, 02, 03, 04 | |
1966
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
1967
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
1968
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
1969
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
1970
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
1971
+ * | | qq | 01, 02, 03, 04 | |
1972
+ * | | qqq | Q1, Q2, Q3, Q4 | |
1973
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
1974
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
1975
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
1976
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
1977
+ * | | MM | 01, 02, ..., 12 | |
1978
+ * | | MMM | Jan, Feb, ..., Dec | |
1979
+ * | | MMMM | January, February, ..., December | 2 |
1980
+ * | | MMMMM | J, F, ..., D | |
1981
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
1982
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
1983
+ * | | LL | 01, 02, ..., 12 | |
1984
+ * | | LLL | Jan, Feb, ..., Dec | |
1985
+ * | | LLLL | January, February, ..., December | 2 |
1986
+ * | | LLLLL | J, F, ..., D | |
1987
+ * | Local week of year | w | 1, 2, ..., 53 | |
1988
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
1989
+ * | | ww | 01, 02, ..., 53 | |
1990
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
1991
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
1992
+ * | | II | 01, 02, ..., 53 | 7 |
1993
+ * | Day of month | d | 1, 2, ..., 31 | |
1994
+ * | | do | 1st, 2nd, ..., 31st | 7 |
1995
+ * | | dd | 01, 02, ..., 31 | |
1996
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
1997
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
1998
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
1999
+ * | | DDD | 001, 002, ..., 365, 366 | |
2000
+ * | | DDDD | ... | 3 |
2001
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
2002
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
2003
+ * | | EEEEE | M, T, W, T, F, S, S | |
2004
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
2005
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
2006
+ * | | io | 1st, 2nd, ..., 7th | 7 |
2007
+ * | | ii | 01, 02, ..., 07 | 7 |
2008
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
2009
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
2010
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
2011
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
2012
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
2013
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
2014
+ * | | ee | 02, 03, ..., 01 | |
2015
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
2016
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
2017
+ * | | eeeee | M, T, W, T, F, S, S | |
2018
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
2019
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2020
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
2021
+ * | | cc | 02, 03, ..., 01 | |
2022
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
2023
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2024
+ * | | ccccc | M, T, W, T, F, S, S | |
2025
+ * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2026
+ * | AM, PM | a..aa | AM, PM | |
2027
+ * | | aaa | am, pm | |
2028
+ * | | aaaa | a.m., p.m. | 2 |
2029
+ * | | aaaaa | a, p | |
2030
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2031
+ * | | bbb | am, pm, noon, midnight | |
2032
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
2033
+ * | | bbbbb | a, p, n, mi | |
2034
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
2035
+ * | | BBBB | at night, in the morning, ... | 2 |
2036
+ * | | BBBBB | at night, in the morning, ... | |
2037
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2038
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2039
+ * | | hh | 01, 02, ..., 11, 12 | |
2040
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2041
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2042
+ * | | HH | 00, 01, 02, ..., 23 | |
2043
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2044
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2045
+ * | | KK | 01, 02, ..., 11, 00 | |
2046
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2047
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2048
+ * | | kk | 24, 01, 02, ..., 23 | |
2049
+ * | Minute | m | 0, 1, ..., 59 | |
2050
+ * | | mo | 0th, 1st, ..., 59th | 7 |
2051
+ * | | mm | 00, 01, ..., 59 | |
2052
+ * | Second | s | 0, 1, ..., 59 | |
2053
+ * | | so | 0th, 1st, ..., 59th | 7 |
2054
+ * | | ss | 00, 01, ..., 59 | |
2055
+ * | Fraction of second | S | 0, 1, ..., 9 | |
2056
+ * | | SS | 00, 01, ..., 99 | |
2057
+ * | | SSS | 000, 001, ..., 999 | |
2058
+ * | | SSSS | ... | 3 |
2059
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2060
+ * | | XX | -0800, +0530, Z | |
2061
+ * | | XXX | -08:00, +05:30, Z | |
2062
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2063
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2064
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2065
+ * | | xx | -0800, +0530, +0000 | |
2066
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
2067
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
2068
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2069
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2070
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2071
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2072
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2073
+ * | Seconds timestamp | t | 512969520 | 7 |
2074
+ * | | tt | ... | 3,7 |
2075
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
2076
+ * | | TT | ... | 3,7 |
2077
+ * | Long localized date | P | 04/29/1453 | 7 |
2078
+ * | | PP | Apr 29, 1453 | 7 |
2079
+ * | | PPP | April 29th, 1453 | 7 |
2080
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2081
+ * | Long localized time | p | 12:00 AM | 7 |
2082
+ * | | pp | 12:00:00 AM | 7 |
2083
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
2084
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2085
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2086
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2087
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
2088
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2089
+ * Notes:
2090
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2091
+ * are the same as "stand-alone" units, but are different in some languages.
2092
+ * "Formatting" units are declined according to the rules of the language
2093
+ * in the context of a date. "Stand-alone" units are always nominative singular:
2094
+ *
2095
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2096
+ *
2097
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2098
+ *
2099
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2100
+ * the single quote characters (see below).
2101
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2102
+ * the output will be the same as default pattern for this unit, usually
2103
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2104
+ * are marked with "2" in the last column of the table.
2105
+ *
2106
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2107
+ *
2108
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2109
+ *
2110
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2111
+ *
2112
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2113
+ *
2114
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2115
+ *
2116
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2117
+ * The output will be padded with zeros to match the length of the pattern.
2118
+ *
2119
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2120
+ *
2121
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2122
+ * These tokens represent the shortest form of the quarter.
2123
+ *
2124
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
2125
+ *
2126
+ * | Year | `y` | `u` |
2127
+ * |------|-----|-----|
2128
+ * | AC 1 | 1 | 1 |
2129
+ * | BC 1 | 1 | 0 |
2130
+ * | BC 2 | 2 | -1 |
2131
+ *
2132
+ * Also `yy` always returns the last two digits of a year,
2133
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2134
+ *
2135
+ * | Year | `yy` | `uu` |
2136
+ * |------|------|------|
2137
+ * | 1 | 01 | 01 |
2138
+ * | 14 | 14 | 14 |
2139
+ * | 376 | 76 | 376 |
2140
+ * | 1453 | 53 | 1453 |
2141
+ *
2142
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2143
+ * except local week-numbering years are dependent on `options.weekStartsOn`
2144
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2145
+ * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2146
+ *
2147
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2148
+ * so right now these tokens fall back to GMT timezones.
2149
+ *
2150
+ * 7. These patterns are not in the Unicode Technical Standard #35:
2151
+ * - `i`: ISO day of week
2152
+ * - `I`: ISO week of year
2153
+ * - `R`: ISO week-numbering year
2154
+ * - `t`: seconds timestamp
2155
+ * - `T`: milliseconds timestamp
2156
+ * - `o`: ordinal number modifier
2157
+ * - `P`: long localized date
2158
+ * - `p`: long localized time
2159
+ *
2160
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2161
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2162
+ *
2163
+ * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2164
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2165
+ *
2166
+ * @param {Date|Number} date - the original date
2167
+ * @param {String} format - the string of tokens
2168
+ * @param {Object} [options] - an object with options.
2169
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2170
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2171
+ * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2172
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2173
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2174
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2175
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2176
+ * @returns {String} the formatted date string
2177
+ * @throws {TypeError} 2 arguments required
2178
+ * @throws {RangeError} `date` must not be Invalid Date
2179
+ * @throws {RangeError} `options.locale` must contain `localize` property
2180
+ * @throws {RangeError} `options.locale` must contain `formatLong` property
2181
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2182
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2183
+ * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2184
+ * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2185
+ * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2186
+ * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2187
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
2188
+ *
2189
+ * @example
2190
+ * // Represent 11 February 2014 in middle-endian format:
2191
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2192
+ * //=> '02/11/2014'
2193
+ *
2194
+ * @example
2195
+ * // Represent 2 July 2014 in Esperanto:
2196
+ * import { eoLocale } from 'date-fns/locale/eo'
2197
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2198
+ * locale: eoLocale
2199
+ * })
2200
+ * //=> '2-a de julio 2014'
2201
+ *
2202
+ * @example
2203
+ * // Escape string by single quote characters:
2204
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2205
+ * //=> "3 o'clock"
2206
+ */
2207
+
2208
+ function format(dirtyDate, dirtyFormatStr, options) {
2209
+ var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;
2210
+ requiredArgs(2, arguments);
2211
+ var formatStr = String(dirtyFormatStr);
2212
+ var defaultOptions = getDefaultOptions();
2213
+ var locale$1 = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : locale;
2214
+ var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1);
2215
+
2216
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2217
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2218
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2219
+ }
2220
+ var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0);
2221
+
2222
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2223
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2224
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2225
+ }
2226
+ if (!locale$1.localize) {
2227
+ throw new RangeError('locale must contain localize property');
2228
+ }
2229
+ if (!locale$1.formatLong) {
2230
+ throw new RangeError('locale must contain formatLong property');
2231
+ }
2232
+ var originalDate = toDate(dirtyDate);
2233
+ if (!isValid(originalDate)) {
2234
+ throw new RangeError('Invalid time value');
2235
+ }
2236
+
2237
+ // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2238
+ // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2239
+ // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2240
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2241
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
2242
+ var formatterOptions = {
2243
+ firstWeekContainsDate: firstWeekContainsDate,
2244
+ weekStartsOn: weekStartsOn,
2245
+ locale: locale$1,
2246
+ _originalDate: originalDate
2247
+ };
2248
+ var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2249
+ var firstCharacter = substring[0];
2250
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
2251
+ var longFormatter = longFormatters[firstCharacter];
2252
+ return longFormatter(substring, locale$1.formatLong);
2253
+ }
2254
+ return substring;
2255
+ }).join('').match(formattingTokensRegExp).map(function (substring) {
2256
+ // Replace two single quote characters with one single quote character
2257
+ if (substring === "''") {
2258
+ return "'";
2259
+ }
2260
+ var firstCharacter = substring[0];
2261
+ if (firstCharacter === "'") {
2262
+ return cleanEscapedString(substring);
2263
+ }
2264
+ var formatter = formatters[firstCharacter];
2265
+ if (formatter) {
2266
+ if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2267
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2268
+ }
2269
+ if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2270
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2271
+ }
2272
+ return formatter(utcDate, substring, locale$1.localize, formatterOptions);
2273
+ }
2274
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2275
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2276
+ }
2277
+ return substring;
2278
+ }).join('');
2279
+ return result;
2280
+ }
2281
+ function cleanEscapedString(input) {
2282
+ var matched = input.match(escapedStringRegExp);
2283
+ if (!matched) {
2284
+ return input;
2285
+ }
2286
+ return matched[1].replace(doubleQuoteRegExp, "'");
2287
+ }
2288
+
2289
+ /**
2290
+ * Default values for all Dinero objects.
2291
+ *
2292
+ * You can override default values for all subsequent Dinero objects by changing them directly on the global `Dinero` object.
2293
+ * Existing instances won't be affected.
2294
+ *
2295
+ * @property {Number} defaultAmount - The default amount for new Dinero objects (see {@link module:Dinero Dinero} for format).
2296
+ * @property {String} defaultCurrency - The default currency for new Dinero objects (see {@link module:Dinero Dinero} for format).
2297
+ * @property {Number} defaultPrecision - The default precision for new Dinero objects (see {@link module:Dinero Dinero} for format).
2298
+ *
2299
+ * @example
2300
+ * // Will set currency to 'EUR' for all Dinero objects.
2301
+ * Dinero.defaultCurrency = 'EUR'
2302
+ *
2303
+ * @type {Object}
2304
+ */
2305
+ var Defaults = {
2306
+ defaultAmount: 0,
2307
+ defaultCurrency: 'USD',
2308
+ defaultPrecision: 2
2309
+ };
2310
+ /**
2311
+ * Global settings for all Dinero objects.
2312
+ *
2313
+ * You can override global values for all subsequent Dinero objects by changing them directly on the global `Dinero` object.
2314
+ * Existing instances won't be affected.
2315
+ *
2316
+ * @property {String} globalLocale - The global locale for new Dinero objects (see {@link module:Dinero~setLocale setLocale} for format).
2317
+ * @property {String} globalFormat - The global format for new Dinero objects (see {@link module:Dinero~toFormat toFormat} for format).
2318
+ * @property {String} globalRoundingMode - The global rounding mode for new Dinero objects (see {@link module:Dinero~multiply multiply} or {@link module:Dinero~divide divide} for format).
2319
+ * @property {String} globalFormatRoundingMode - The global rounding mode to format new Dinero objects (see {@link module:Dinero~toFormat toFormat} or {@link module:Dinero~toRoundedUnit toRoundedUnit} for format).
2320
+ * @property {(String|Promise)} globalExchangeRatesApi.endpoint - The global exchange rate API endpoint for new Dinero objects, or the global promise that resolves to the exchanges rates (see {@link module:Dinero~convert convert} for format).
2321
+ * @property {String} globalExchangeRatesApi.propertyPath - The global exchange rate API property path for new Dinero objects (see {@link module:Dinero~convert convert} for format).
2322
+ * @property {Object} globalExchangeRatesApi.headers - The global exchange rate API headers for new Dinero objects (see {@link module:Dinero~convert convert} for format).
2323
+ *
2324
+ * @example
2325
+ * // Will set locale to 'fr-FR' for all Dinero objects.
2326
+ * Dinero.globalLocale = 'fr-FR'
2327
+ * @example
2328
+ * // Will set global exchange rate API parameters for all Dinero objects.
2329
+ * Dinero.globalExchangeRatesApi = {
2330
+ * endpoint: 'https://yourexchangerates.api/latest?base={{from}}',
2331
+ * propertyPath: 'data.rates.{{to}}',
2332
+ * headers: {
2333
+ * 'user-key': 'xxxxxxxxx'
2334
+ * }
2335
+ * }
2336
+ *
2337
+ * @type {Object}
2338
+ */
2339
+
2340
+ var Globals = {
2341
+ globalLocale: 'en-US',
2342
+ globalFormat: '$0,0.00',
2343
+ globalRoundingMode: 'HALF_EVEN',
2344
+ globalFormatRoundingMode: 'HALF_AWAY_FROM_ZERO',
2345
+ globalExchangeRatesApi: {
2346
+ endpoint: undefined,
2347
+ headers: undefined,
2348
+ propertyPath: undefined
2349
+ }
2350
+ };
2351
+
2352
+ function _typeof(obj) {
2353
+ "@babel/helpers - typeof";
2354
+
2355
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
2356
+ _typeof = function (obj) {
2357
+ return typeof obj;
2358
+ };
2359
+ } else {
2360
+ _typeof = function (obj) {
2361
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
2362
+ };
2363
+ }
2364
+
2365
+ return _typeof(obj);
2366
+ }
2367
+
2368
+ function _toArray(arr) {
2369
+ return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
2370
+ }
2371
+
2372
+ function _arrayWithHoles(arr) {
2373
+ if (Array.isArray(arr)) return arr;
2374
+ }
2375
+
2376
+ function _iterableToArray(iter) {
2377
+ if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
2378
+ }
2379
+
2380
+ function _unsupportedIterableToArray(o, minLen) {
2381
+ if (!o) return;
2382
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
2383
+ var n = Object.prototype.toString.call(o).slice(8, -1);
2384
+ if (n === "Object" && o.constructor) n = o.constructor.name;
2385
+ if (n === "Map" || n === "Set") return Array.from(o);
2386
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
2387
+ }
2388
+
2389
+ function _arrayLikeToArray(arr, len) {
2390
+ if (len == null || len > arr.length) len = arr.length;
2391
+
2392
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
2393
+
2394
+ return arr2;
2395
+ }
2396
+
2397
+ function _nonIterableRest() {
2398
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2399
+ }
2400
+
2401
+ /**
2402
+ * Static methods for Dinero.
2403
+ * @ignore
2404
+ *
2405
+ * @type {Object}
2406
+ */
2407
+ var Static = {
2408
+ /**
2409
+ * Returns an array of Dinero objects, normalized to the same precision (the highest).
2410
+ *
2411
+ * @memberof module:Dinero
2412
+ * @method
2413
+ *
2414
+ * @param {Dinero[]} objects - An array of Dinero objects
2415
+ *
2416
+ * @example
2417
+ * // returns an array of Dinero objects
2418
+ * // both with a precision of 3
2419
+ * // and an amount of 1000
2420
+ * Dinero.normalizePrecision([
2421
+ * Dinero({ amount: 100, precision: 2 }),
2422
+ * Dinero({ amount: 1000, precision: 3 })
2423
+ * ])
2424
+ *
2425
+ * @return {Dinero[]}
2426
+ */
2427
+ normalizePrecision: function normalizePrecision(objects) {
2428
+ var highestPrecision = objects.reduce(function (a, b) {
2429
+ return Math.max(a.getPrecision(), b.getPrecision());
2430
+ });
2431
+ return objects.map(function (object) {
2432
+ return object.getPrecision() !== highestPrecision ? object.convertPrecision(highestPrecision) : object;
2433
+ });
2434
+ },
2435
+
2436
+ /**
2437
+ * Returns the smallest Dinero object from an array of Dinero objects
2438
+ *
2439
+ * @memberof module:Dinero
2440
+ * @method
2441
+ *
2442
+ * @param {Dinero[]} objects - An array of Dinero objects
2443
+ *
2444
+ * @example
2445
+ * // returns the smallest Dinero object with amount of 500 from an array of Dinero objects with different precisions
2446
+ * Dinero.minimum([
2447
+ * Dinero({ amount: 500, precision: 3 }),
2448
+ * Dinero({ amount: 100, precision: 2 })
2449
+ * ])
2450
+ * @example
2451
+ * // returns the smallest Dinero object with amount of 50 from an array of Dinero objects
2452
+ * Dinero.minimum([
2453
+ * Dinero({ amount: 50 }),
2454
+ * Dinero({ amount: 100 })
2455
+ * ])
2456
+ *
2457
+ * @return {Dinero[]}
2458
+ */
2459
+ minimum: function minimum(objects) {
2460
+ var _objects = _toArray(objects),
2461
+ firstObject = _objects[0],
2462
+ tailObjects = _objects.slice(1);
2463
+
2464
+ var currentMinimum = firstObject;
2465
+ tailObjects.forEach(function (obj) {
2466
+ currentMinimum = currentMinimum.lessThan(obj) ? currentMinimum : obj;
2467
+ });
2468
+ return currentMinimum;
2469
+ },
2470
+
2471
+ /**
2472
+ * Returns the biggest Dinero object from an array of Dinero objects
2473
+ *
2474
+ * @memberof module:Dinero
2475
+ * @method
2476
+ *
2477
+ * @param {Dinero[]} objects - An array of Dinero objects
2478
+ *
2479
+ * @example
2480
+ * // returns the biggest Dinero object with amount of 20, from an array of Dinero objects with different precisions
2481
+ * Dinero.maximum([
2482
+ * Dinero({ amount: 20, precision: 2 }),
2483
+ * Dinero({ amount: 150, precision: 3 })
2484
+ * ])
2485
+ * @example
2486
+ * // returns the biggest Dinero object with amount of 100, from an array of Dinero objects
2487
+ * Dinero.maximum([
2488
+ * Dinero({ amount: 100 }),
2489
+ * Dinero({ amount: 50 })
2490
+ * ])
2491
+ *
2492
+ * @return {Dinero[]}
2493
+ */
2494
+ maximum: function maximum(objects) {
2495
+ var _objects2 = _toArray(objects),
2496
+ firstObject = _objects2[0],
2497
+ tailObjects = _objects2.slice(1);
2498
+
2499
+ var currentMaximum = firstObject;
2500
+ tailObjects.forEach(function (obj) {
2501
+ currentMaximum = currentMaximum.greaterThan(obj) ? currentMaximum : obj;
2502
+ });
2503
+ return currentMaximum;
2504
+ }
2505
+ };
2506
+
2507
+ /**
2508
+ * Returns whether a value is numeric.
2509
+ * @ignore
2510
+ *
2511
+ * @param {} value - The value to test.
2512
+ *
2513
+ * @return {Boolean}
2514
+ */
2515
+ function isNumeric(value) {
2516
+ return !isNaN(parseInt(value)) && isFinite(value);
2517
+ }
2518
+ /**
2519
+ * Returns whether a value is a percentage.
2520
+ * @ignore
2521
+ *
2522
+ * @param {} percentage - The percentage to test.
2523
+ *
2524
+ * @return {Boolean}
2525
+ */
2526
+
2527
+ function isPercentage(percentage) {
2528
+ return isNumeric(percentage) && percentage <= 100 && percentage >= 0;
2529
+ }
2530
+ /**
2531
+ * Returns whether an array of ratios is valid.
2532
+ * @ignore
2533
+ *
2534
+ * @param {} ratios - The ratios to test.
2535
+ *
2536
+ * @return {Boolean}
2537
+ */
2538
+
2539
+ function areValidRatios(ratios) {
2540
+ return ratios.length > 0 && ratios.every(function (ratio) {
2541
+ return ratio >= 0;
2542
+ }) && ratios.some(function (ratio) {
2543
+ return ratio > 0;
2544
+ });
2545
+ }
2546
+ /**
2547
+ * Returns whether a value is even.
2548
+ * @ignore
2549
+ *
2550
+ * @param {Number} value - The value to test.
2551
+ *
2552
+ * @return {Boolean}
2553
+ */
2554
+
2555
+ function isEven(value) {
2556
+ return value % 2 === 0;
2557
+ }
2558
+ /**
2559
+ * Returns whether a value is a float.
2560
+ * @ignore
2561
+ *
2562
+ * @param {} value - The value to test.
2563
+ *
2564
+ * @return {Boolean}
2565
+ */
2566
+
2567
+ function isFloat(value) {
2568
+ return isNumeric(value) && !Number.isInteger(value);
2569
+ }
2570
+ /**
2571
+ * Returns how many fraction digits a number has.
2572
+ * @ignore
2573
+ *
2574
+ * @param {Number} [number=0] - The number to test.
2575
+ *
2576
+ * @return {Number}
2577
+ */
2578
+
2579
+ function countFractionDigits() {
2580
+ var number = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
2581
+ var stringRepresentation = number.toString();
2582
+
2583
+ if (stringRepresentation.indexOf('e-') > 0) {
2584
+ // It's too small for a normal string representation, e.g. 1e-7 instead of 0.00000001
2585
+ return parseInt(stringRepresentation.split('e-')[1]);
2586
+ } else {
2587
+ var fractionDigits = stringRepresentation.split('.')[1];
2588
+ return fractionDigits ? fractionDigits.length : 0;
2589
+ }
2590
+ }
2591
+ /**
2592
+ * Returns whether a number is half.
2593
+ * @ignore
2594
+ *
2595
+ * @param {Number} number - The number to test.
2596
+ *
2597
+ * @return {Number}
2598
+ */
2599
+
2600
+ function isHalf(number) {
2601
+ return Math.abs(number) % 1 === 0.5;
2602
+ }
2603
+ /**
2604
+ * Fetches a JSON resource.
2605
+ * @ignore
2606
+ *
2607
+ * @param {String} url - The resource to fetch.
2608
+ * @param {Object} [options.headers] - The headers to pass.
2609
+ *
2610
+ * @throws {Error} If `request.status` is lesser than 200 or greater or equal to 400.
2611
+ * @throws {Error} If network fails.
2612
+ *
2613
+ * @return {JSON}
2614
+ */
2615
+
2616
+ function getJSON(url) {
2617
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2618
+ return new Promise(function (resolve, reject) {
2619
+ var request = Object.assign(new XMLHttpRequest(), {
2620
+ onreadystatechange: function onreadystatechange() {
2621
+ if (request.readyState === 4) {
2622
+ if (request.status >= 200 && request.status < 400) resolve(JSON.parse(request.responseText));else reject(new Error(request.statusText));
2623
+ }
2624
+ },
2625
+ onerror: function onerror() {
2626
+ reject(new Error('Network error'));
2627
+ }
2628
+ });
2629
+ request.open('GET', url, true);
2630
+ setXHRHeaders(request, options.headers);
2631
+ request.send();
2632
+ });
2633
+ }
2634
+ /**
2635
+ * Returns an XHR object with attached headers.
2636
+ * @ignore
2637
+ *
2638
+ * @param {XMLHttpRequest} xhr - The XHR request to set headers to.
2639
+ * @param {Object} headers - The headers to set.
2640
+ *
2641
+ * @return {XMLHttpRequest}
2642
+ */
2643
+
2644
+ function setXHRHeaders(xhr) {
2645
+ var headers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2646
+
2647
+ for (var header in headers) {
2648
+ xhr.setRequestHeader(header, headers[header]);
2649
+ }
2650
+
2651
+ return xhr;
2652
+ }
2653
+ /**
2654
+ * Returns whether a value is undefined.
2655
+ * @ignore
2656
+ *
2657
+ * @param {} value - The value to test.
2658
+ *
2659
+ * @return {Boolean}
2660
+ */
2661
+
2662
+ function isUndefined(value) {
2663
+ return typeof value === 'undefined';
2664
+ }
2665
+ /**
2666
+ * Returns an object flattened to one level deep.
2667
+ * @ignore
2668
+ *
2669
+ * @param {Object} object - The object to flatten.
2670
+ * @param {String} separator - The separator to use between flattened nodes.
2671
+ *
2672
+ * @return {Object}
2673
+ */
2674
+
2675
+ function flattenObject(object) {
2676
+ var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '.';
2677
+ var finalObject = {};
2678
+ Object.entries(object).forEach(function (item) {
2679
+ if (_typeof(item[1]) === 'object') {
2680
+ var flatObject = flattenObject(item[1]);
2681
+ Object.entries(flatObject).forEach(function (node) {
2682
+ finalObject[item[0] + separator + node[0]] = node[1];
2683
+ });
2684
+ } else {
2685
+ finalObject[item[0]] = item[1];
2686
+ }
2687
+ });
2688
+ return finalObject;
2689
+ }
2690
+ /**
2691
+ * Returns whether a value is thenable.
2692
+ * @ignore
2693
+ *
2694
+ * @param {} value - The value to test.
2695
+ *
2696
+ * @return {Boolean}
2697
+ */
2698
+
2699
+ function isThenable(value) {
2700
+ return Boolean(value) && (_typeof(value) === 'object' || typeof value === 'function') && typeof value.then === 'function';
2701
+ }
2702
+
2703
+ function Calculator() {
2704
+ var floatMultiply = function floatMultiply(a, b) {
2705
+ var getFactor = function getFactor(number) {
2706
+ return Math.pow(10, countFractionDigits(number));
2707
+ };
2708
+
2709
+ var factor = Math.max(getFactor(a), getFactor(b));
2710
+ return Math.round(a * factor) * Math.round(b * factor) / (factor * factor);
2711
+ };
2712
+
2713
+ var roundingModes = {
2714
+ HALF_ODD: function HALF_ODD(number) {
2715
+ var rounded = Math.round(number);
2716
+ return isHalf(number) ? isEven(rounded) ? rounded - 1 : rounded : rounded;
2717
+ },
2718
+ HALF_EVEN: function HALF_EVEN(number) {
2719
+ var rounded = Math.round(number);
2720
+ return isHalf(number) ? isEven(rounded) ? rounded : rounded - 1 : rounded;
2721
+ },
2722
+ HALF_UP: function HALF_UP(number) {
2723
+ return Math.round(number);
2724
+ },
2725
+ HALF_DOWN: function HALF_DOWN(number) {
2726
+ return isHalf(number) ? Math.floor(number) : Math.round(number);
2727
+ },
2728
+ HALF_TOWARDS_ZERO: function HALF_TOWARDS_ZERO(number) {
2729
+ return isHalf(number) ? Math.sign(number) * Math.floor(Math.abs(number)) : Math.round(number);
2730
+ },
2731
+ HALF_AWAY_FROM_ZERO: function HALF_AWAY_FROM_ZERO(number) {
2732
+ return isHalf(number) ? Math.sign(number) * Math.ceil(Math.abs(number)) : Math.round(number);
2733
+ },
2734
+ DOWN: function DOWN(number) {
2735
+ return Math.floor(number);
2736
+ }
2737
+ };
2738
+ return {
2739
+ /**
2740
+ * Returns the sum of two numbers.
2741
+ * @ignore
2742
+ *
2743
+ * @param {Number} a - The first number to add.
2744
+ * @param {Number} b - The second number to add.
2745
+ *
2746
+ * @return {Number}
2747
+ */
2748
+ add: function add(a, b) {
2749
+ return a + b;
2750
+ },
2751
+
2752
+ /**
2753
+ * Returns the difference of two numbers.
2754
+ * @ignore
2755
+ *
2756
+ * @param {Number} a - The first number to subtract.
2757
+ * @param {Number} b - The second number to subtract.
2758
+ *
2759
+ * @return {Number}
2760
+ */
2761
+ subtract: function subtract(a, b) {
2762
+ return a - b;
2763
+ },
2764
+
2765
+ /**
2766
+ * Returns the product of two numbers.
2767
+ * @ignore
2768
+ *
2769
+ * @param {Number} a - The first number to multiply.
2770
+ * @param {Number} b - The second number to multiply.
2771
+ *
2772
+ * @return {Number}
2773
+ */
2774
+ multiply: function multiply(a, b) {
2775
+ return isFloat(a) || isFloat(b) ? floatMultiply(a, b) : a * b;
2776
+ },
2777
+
2778
+ /**
2779
+ * Returns the quotient of two numbers.
2780
+ * @ignore
2781
+ *
2782
+ * @param {Number} a - The first number to divide.
2783
+ * @param {Number} b - The second number to divide.
2784
+ *
2785
+ * @return {Number}
2786
+ */
2787
+ divide: function divide(a, b) {
2788
+ return a / b;
2789
+ },
2790
+
2791
+ /**
2792
+ * Returns the remainder of two numbers.
2793
+ * @ignore
2794
+ *
2795
+ * @param {Number} a - The first number to divide.
2796
+ * @param {Number} b - The second number to divide.
2797
+ *
2798
+ * @return {Number}
2799
+ */
2800
+ modulo: function modulo(a, b) {
2801
+ return a % b;
2802
+ },
2803
+
2804
+ /**
2805
+ * Returns a rounded number based off a specific rounding mode.
2806
+ * @ignore
2807
+ *
2808
+ * @param {Number} number - The number to round.
2809
+ * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use.
2810
+ *
2811
+ * @returns {Number}
2812
+ */
2813
+ round: function round(number) {
2814
+ var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'HALF_EVEN';
2815
+ return roundingModes[roundingMode](number);
2816
+ }
2817
+ };
2818
+ }
2819
+
2820
+ var calculator = Calculator();
2821
+ function Format(format) {
2822
+ var matches = /^(?:(\$|USD)?0(?:(,)0)?(\.)?(0+)?|0(?:(,)0)?(\.)?(0+)?\s?(dollar)?)$/gm.exec(format);
2823
+ return {
2824
+ /**
2825
+ * Returns the matches.
2826
+ * @ignore
2827
+ *
2828
+ * @return {Array}
2829
+ */
2830
+ getMatches: function getMatches() {
2831
+ return matches !== null ? matches.slice(1).filter(function (match) {
2832
+ return !isUndefined(match);
2833
+ }) : [];
2834
+ },
2835
+
2836
+ /**
2837
+ * Returns the amount of fraction digits to display.
2838
+ * @ignore
2839
+ *
2840
+ * @return {Number}
2841
+ */
2842
+ getMinimumFractionDigits: function getMinimumFractionDigits() {
2843
+ var decimalPosition = function decimalPosition(match) {
2844
+ return match === '.';
2845
+ };
2846
+
2847
+ return !isUndefined(this.getMatches().find(decimalPosition)) ? this.getMatches()[calculator.add(this.getMatches().findIndex(decimalPosition), 1)].split('').length : 0;
2848
+ },
2849
+
2850
+ /**
2851
+ * Returns the currency display mode.
2852
+ * @ignore
2853
+ *
2854
+ * @return {String}
2855
+ */
2856
+ getCurrencyDisplay: function getCurrencyDisplay() {
2857
+ var modes = {
2858
+ USD: 'code',
2859
+ dollar: 'name',
2860
+ $: 'symbol'
2861
+ };
2862
+ return modes[this.getMatches().find(function (match) {
2863
+ return match === 'USD' || match === 'dollar' || match === '$';
2864
+ })];
2865
+ },
2866
+
2867
+ /**
2868
+ * Returns the formatting style.
2869
+ * @ignore
2870
+ *
2871
+ * @return {String}
2872
+ */
2873
+ getStyle: function getStyle() {
2874
+ return !isUndefined(this.getCurrencyDisplay(this.getMatches())) ? 'currency' : 'decimal';
2875
+ },
2876
+
2877
+ /**
2878
+ * Returns whether grouping should be used or not.
2879
+ * @ignore
2880
+ *
2881
+ * @return {Boolean}
2882
+ */
2883
+ getUseGrouping: function getUseGrouping() {
2884
+ return !isUndefined(this.getMatches().find(function (match) {
2885
+ return match === ',';
2886
+ }));
2887
+ }
2888
+ };
2889
+ }
2890
+
2891
+ function CurrencyConverter(options) {
2892
+ /* istanbul ignore next */
2893
+ var mergeTags = function mergeTags() {
2894
+ var string = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
2895
+ var tags = arguments.length > 1 ? arguments[1] : undefined;
2896
+
2897
+ for (var tag in tags) {
2898
+ string = string.replace("{{".concat(tag, "}}"), tags[tag]);
2899
+ }
2900
+
2901
+ return string;
2902
+ };
2903
+ /* istanbul ignore next */
2904
+
2905
+
2906
+ var getRatesFromRestApi = function getRatesFromRestApi(from, to) {
2907
+ return getJSON(mergeTags(options.endpoint, {
2908
+ from: from,
2909
+ to: to
2910
+ }), {
2911
+ headers: options.headers
2912
+ });
2913
+ };
2914
+
2915
+ return {
2916
+ /**
2917
+ * Returns the exchange rate.
2918
+ * @ignore
2919
+ *
2920
+ * @param {String} from - The base currency.
2921
+ * @param {String} to - The destination currency.
2922
+ *
2923
+ * @return {Promise}
2924
+ */
2925
+ getExchangeRate: function getExchangeRate(from, to) {
2926
+ return (isThenable(options.endpoint) ? options.endpoint : getRatesFromRestApi(from, to)).then(function (data) {
2927
+ return flattenObject(data)[mergeTags(options.propertyPath, {
2928
+ from: from,
2929
+ to: to
2930
+ })];
2931
+ });
2932
+ }
2933
+ };
2934
+ }
2935
+
2936
+ /**
2937
+ * Performs an assertion.
2938
+ * @ignore
2939
+ *
2940
+ * @param {Boolean} condition - The expression to assert.
2941
+ * @param {String} errorMessage - The message to throw if the assertion fails
2942
+ * @param {ErrorConstructor} [ErrorType=Error] - The error to throw if the assertion fails.
2943
+ *
2944
+ * @throws {Error} If `condition` returns `false`.
2945
+ */
2946
+
2947
+ function assert(condition, errorMessage) {
2948
+ var ErrorType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Error;
2949
+ if (!condition) throw new ErrorType(errorMessage);
2950
+ }
2951
+ /**
2952
+ * Asserts a value is a percentage.
2953
+ * @ignore
2954
+ *
2955
+ * @param {} percentage - The percentage to test.
2956
+ *
2957
+ * @throws {RangeError} If `percentage` is out of range.
2958
+ */
2959
+
2960
+ function assertPercentage(percentage) {
2961
+ assert(isPercentage(percentage), 'You must provide a numeric value between 0 and 100.', RangeError);
2962
+ }
2963
+ /**
2964
+ * Asserts an array of ratios is valid.
2965
+ * @ignore
2966
+ *
2967
+ * @param {} ratios - The ratios to test.
2968
+ *
2969
+ * @throws {TypeError} If `ratios` are invalid.
2970
+ */
2971
+
2972
+ function assertValidRatios(ratios) {
2973
+ assert(areValidRatios(ratios), 'You must provide a non-empty array of numeric values greater than 0.', TypeError);
2974
+ }
2975
+ /**
2976
+ * Asserts a value is an integer.
2977
+ * @ignore
2978
+ *
2979
+ * @param {} number - The value to test.
2980
+ *
2981
+ * @throws {TypeError}
2982
+ */
2983
+
2984
+ function assertInteger(number) {
2985
+ assert(Number.isInteger(number), 'You must provide an integer.', TypeError);
2986
+ }
2987
+
2988
+ var calculator$1 = Calculator();
2989
+ /**
2990
+ * A Dinero object is an immutable data structure representing a specific monetary value.
2991
+ * It comes with methods for creating, parsing, manipulating, testing, transforming and formatting them.
2992
+ *
2993
+ * A Dinero object has:
2994
+ *
2995
+ * * An `amount`, expressed in minor currency units, as an integer.
2996
+ * * A `currency`, expressed as an {@link https://en.wikipedia.org/wiki/ISO_4217#Active_codes ISO 4217 currency code}.
2997
+ * * A `precision`, expressed as an integer, to represent the number of decimal places in the `amount`.
2998
+ * This is helpful when you want to represent fractional minor currency units (e.g.: $10.4545).
2999
+ * You can also use it to represent a currency with a different [exponent](https://en.wikipedia.org/wiki/ISO_4217#Treatment_of_minor_currency_units_.28the_.22exponent.22.29) than `2` (e.g.: Iraqi dinar with 1000 fils in 1 dinar (exponent of `3`), Japanese yen with no sub-units (exponent of `0`)).
3000
+ * * An optional `locale` property that affects how output strings are formatted.
3001
+ *
3002
+ * Here's an overview of the public API:
3003
+ *
3004
+ * * **Access:** {@link module:Dinero~getAmount getAmount}, {@link module:Dinero~getCurrency getCurrency}, {@link module:Dinero~getLocale getLocale} and {@link module:Dinero~getPrecision getPrecision}.
3005
+ * * **Manipulation:** {@link module:Dinero~add add}, {@link module:Dinero~subtract subtract}, {@link module:Dinero~multiply multiply}, {@link module:Dinero~divide divide}, {@link module:Dinero~percentage percentage}, {@link module:Dinero~allocate allocate} and {@link module:Dinero~convert convert}.
3006
+ * * **Testing:** {@link module:Dinero~equalsTo equalsTo}, {@link module:Dinero~lessThan lessThan}, {@link module:Dinero~lessThanOrEqual lessThanOrEqual}, {@link module:Dinero~greaterThan greaterThan}, {@link module:Dinero~greaterThanOrEqual greaterThanOrEqual}, {@link module:Dinero~isZero isZero}, {@link module:Dinero~isPositive isPositive}, {@link module:Dinero~isNegative isNegative}, {@link module:Dinero~hasSubUnits hasSubUnits}, {@link module:Dinero~hasSameCurrency hasSameCurrency} and {@link module:Dinero~hasSameAmount hasSameAmount}.
3007
+ * * **Configuration:** {@link module:Dinero~setLocale setLocale}.
3008
+ * * **Conversion & formatting:** {@link module:Dinero~toFormat toFormat}, {@link module:Dinero~toUnit toUnit}, {@link module:Dinero~toRoundedUnit toRoundedUnit}, {@link module:Dinero~toObject toObject}, {@link module:Dinero~toJSON toJSON}, {@link module:Dinero~convertPrecision convertPrecision} and {@link module:Dinero.normalizePrecision normalizePrecision}.
3009
+ *
3010
+ * Dinero.js uses `number`s under the hood, so it's constrained by the [double-precision floating-point format](https://en.wikipedia.org/wiki/Double-precision_floating-point_format). Using values over [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MAX_SAFE_INTEGER) or below [`Number.MIN_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MIN_SAFE_INTEGER) will yield unpredictable results.
3011
+ * Same goes with performing calculations: once the internal `amount` value exceeds those limits, precision is no longer guaranteed.
3012
+ *
3013
+ * @module Dinero
3014
+ * @param {Number} [options.amount=0] - The amount in minor currency units (as an integer).
3015
+ * @param {String} [options.currency='USD'] - An ISO 4217 currency code.
3016
+ * @param {String} [options.precision=2] - The number of decimal places to represent.
3017
+ *
3018
+ * @throws {TypeError} If `amount` or `precision` is invalid. Integers over [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MAX_SAFE_INTEGER) or below [`Number.MIN_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MIN_SAFE_INTEGER) are considered valid, even though they can lead to imprecise amounts.
3019
+ *
3020
+ * @return {Object}
3021
+ */
3022
+
3023
+ var Dinero = function Dinero(options) {
3024
+ var _Object$assign = Object.assign({}, {
3025
+ amount: Dinero.defaultAmount,
3026
+ currency: Dinero.defaultCurrency,
3027
+ precision: Dinero.defaultPrecision
3028
+ }, options),
3029
+ amount = _Object$assign.amount,
3030
+ currency = _Object$assign.currency,
3031
+ precision = _Object$assign.precision;
3032
+
3033
+ assertInteger(amount);
3034
+ assertInteger(precision);
3035
+ var globalLocale = Dinero.globalLocale,
3036
+ globalFormat = Dinero.globalFormat,
3037
+ globalRoundingMode = Dinero.globalRoundingMode,
3038
+ globalFormatRoundingMode = Dinero.globalFormatRoundingMode;
3039
+ var globalExchangeRatesApi = Object.assign({}, Dinero.globalExchangeRatesApi);
3040
+ /**
3041
+ * Uses ES5 function notation so `this` can be passed through call, apply and bind
3042
+ * @ignore
3043
+ */
3044
+
3045
+ var create = function create(options) {
3046
+ var obj = Object.assign({}, Object.assign({}, {
3047
+ amount: amount,
3048
+ currency: currency,
3049
+ precision: precision
3050
+ }, options), Object.assign({}, {
3051
+ locale: this.locale
3052
+ }, options));
3053
+ return Object.assign(Dinero({
3054
+ amount: obj.amount,
3055
+ currency: obj.currency,
3056
+ precision: obj.precision
3057
+ }), {
3058
+ locale: obj.locale
3059
+ });
3060
+ };
3061
+ /**
3062
+ * Uses ES5 function notation so `this` can be passed through call, apply and bind
3063
+ * @ignore
3064
+ */
3065
+
3066
+
3067
+ var assertSameCurrency = function assertSameCurrency(comparator) {
3068
+ assert(this.hasSameCurrency(comparator), 'You must provide a Dinero instance with the same currency.', TypeError);
3069
+ };
3070
+
3071
+ return {
3072
+ /**
3073
+ * Returns the amount.
3074
+ *
3075
+ * @example
3076
+ * // returns 500
3077
+ * Dinero({ amount: 500 }).getAmount()
3078
+ *
3079
+ * @return {Number}
3080
+ */
3081
+ getAmount: function getAmount() {
3082
+ return amount;
3083
+ },
3084
+
3085
+ /**
3086
+ * Returns the currency.
3087
+ *
3088
+ * @example
3089
+ * // returns 'EUR'
3090
+ * Dinero({ currency: 'EUR' }).getCurrency()
3091
+ *
3092
+ * @return {String}
3093
+ */
3094
+ getCurrency: function getCurrency() {
3095
+ return currency;
3096
+ },
3097
+
3098
+ /**
3099
+ * Returns the locale.
3100
+ *
3101
+ * @example
3102
+ * // returns 'fr-FR'
3103
+ * Dinero().setLocale('fr-FR').getLocale()
3104
+ *
3105
+ * @return {String}
3106
+ */
3107
+ getLocale: function getLocale() {
3108
+ return this.locale || globalLocale;
3109
+ },
3110
+
3111
+ /**
3112
+ * Returns a new Dinero object with an embedded locale.
3113
+ *
3114
+ * @param {String} newLocale - The new locale as an {@link http://tools.ietf.org/html/rfc5646 BCP 47 language tag}.
3115
+ *
3116
+ * @example
3117
+ * // Returns a Dinero object with locale 'ja-JP'
3118
+ * Dinero().setLocale('ja-JP')
3119
+ *
3120
+ * @return {Dinero}
3121
+ */
3122
+ setLocale: function setLocale(newLocale) {
3123
+ return create.call(this, {
3124
+ locale: newLocale
3125
+ });
3126
+ },
3127
+
3128
+ /**
3129
+ * Returns the precision.
3130
+ *
3131
+ * @example
3132
+ * // returns 3
3133
+ * Dinero({ precision: 3 }).getPrecision()
3134
+ *
3135
+ * @return {Number}
3136
+ */
3137
+ getPrecision: function getPrecision() {
3138
+ return precision;
3139
+ },
3140
+
3141
+ /**
3142
+ * Returns a new Dinero object with a new precision and a converted amount.
3143
+ *
3144
+ * By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
3145
+ * This can be necessary when you need to convert objects to a smaller precision.
3146
+ *
3147
+ * Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent conversions for safer results.
3148
+ * You can also specify a different `roundingMode` to better fit your needs.
3149
+ *
3150
+ * @param {Number} newPrecision - The new precision.
3151
+ * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3152
+ *
3153
+ * @example
3154
+ * // Returns a Dinero object with precision 3 and amount 1000
3155
+ * Dinero({ amount: 100, precision: 2 }).convertPrecision(3)
3156
+ *
3157
+ * @throws {TypeError} If `newPrecision` is invalid.
3158
+ *
3159
+ * @return {Dinero}
3160
+ */
3161
+ convertPrecision: function convertPrecision(newPrecision) {
3162
+ var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalFormatRoundingMode;
3163
+ assertInteger(newPrecision);
3164
+ var precision = this.getPrecision();
3165
+ var isNewPrecisionLarger = newPrecision > precision;
3166
+ var operation = isNewPrecisionLarger ? calculator$1.multiply : calculator$1.divide;
3167
+ var terms = isNewPrecisionLarger ? [newPrecision, precision] : [precision, newPrecision];
3168
+ var factor = Math.pow(10, calculator$1.subtract.apply(calculator$1, terms));
3169
+ return create.call(this, {
3170
+ amount: calculator$1.round(operation(this.getAmount(), factor), roundingMode),
3171
+ precision: newPrecision
3172
+ });
3173
+ },
3174
+
3175
+ /**
3176
+ * Returns a new Dinero object that represents the sum of this and an other Dinero object.
3177
+ *
3178
+ * If Dinero objects have a different `precision`, they will be first converted to the highest.
3179
+ *
3180
+ * @param {Dinero} addend - The Dinero object to add.
3181
+ *
3182
+ * @example
3183
+ * // returns a Dinero object with amount 600
3184
+ * Dinero({ amount: 400 }).add(Dinero({ amount: 200 }))
3185
+ * @example
3186
+ * // returns a Dinero object with amount 144545 and precision 4
3187
+ * Dinero({ amount: 400 }).add(Dinero({ amount: 104545, precision: 4 }))
3188
+ *
3189
+ * @throws {TypeError} If `addend` has a different currency.
3190
+ *
3191
+ * @return {Dinero}
3192
+ */
3193
+ add: function add(addend) {
3194
+ assertSameCurrency.call(this, addend);
3195
+ var addends = Dinero.normalizePrecision([this, addend]);
3196
+ return create.call(this, {
3197
+ amount: calculator$1.add(addends[0].getAmount(), addends[1].getAmount()),
3198
+ precision: addends[0].getPrecision()
3199
+ });
3200
+ },
3201
+
3202
+ /**
3203
+ * Returns a new Dinero object that represents the difference of this and an other Dinero object.
3204
+ *
3205
+ * If Dinero objects have a different `precision`, they will be first converted to the highest.
3206
+ *
3207
+ * @param {Dinero} subtrahend - The Dinero object to subtract.
3208
+ *
3209
+ * @example
3210
+ * // returns a Dinero object with amount 200
3211
+ * Dinero({ amount: 400 }).subtract(Dinero({ amount: 200 }))
3212
+ * @example
3213
+ * // returns a Dinero object with amount 64545 and precision 4
3214
+ * Dinero({ amount: 104545, precision: 4 }).subtract(Dinero({ amount: 400 }))
3215
+ *
3216
+ * @throws {TypeError} If `subtrahend` has a different currency.
3217
+ *
3218
+ * @return {Dinero}
3219
+ */
3220
+ subtract: function subtract(subtrahend) {
3221
+ assertSameCurrency.call(this, subtrahend);
3222
+ var subtrahends = Dinero.normalizePrecision([this, subtrahend]);
3223
+ return create.call(this, {
3224
+ amount: calculator$1.subtract(subtrahends[0].getAmount(), subtrahends[1].getAmount()),
3225
+ precision: subtrahends[0].getPrecision()
3226
+ });
3227
+ },
3228
+
3229
+ /**
3230
+ * Returns a new Dinero object that represents the multiplied value by the given factor.
3231
+ *
3232
+ * By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
3233
+ *
3234
+ * Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent calculations for safer results.
3235
+ * You can also specify a different `roundingMode` to better fit your needs.
3236
+ *
3237
+ * @param {Number} multiplier - The factor to multiply by.
3238
+ * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3239
+ *
3240
+ * @example
3241
+ * // returns a Dinero object with amount 1600
3242
+ * Dinero({ amount: 400 }).multiply(4)
3243
+ * @example
3244
+ * // returns a Dinero object with amount 800
3245
+ * Dinero({ amount: 400 }).multiply(2.001)
3246
+ * @example
3247
+ * // returns a Dinero object with amount 801
3248
+ * Dinero({ amount: 400 }).multiply(2.00125, 'HALF_UP')
3249
+ *
3250
+ * @return {Dinero}
3251
+ */
3252
+ multiply: function multiply(multiplier) {
3253
+ var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalRoundingMode;
3254
+ return create.call(this, {
3255
+ amount: calculator$1.round(calculator$1.multiply(this.getAmount(), multiplier), roundingMode)
3256
+ });
3257
+ },
3258
+
3259
+ /**
3260
+ * Returns a new Dinero object that represents the divided value by the given factor.
3261
+ *
3262
+ * By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
3263
+ *
3264
+ * Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent calculations for safer results.
3265
+ * You can also specify a different `roundingMode` to better fit your needs.
3266
+ *
3267
+ * As rounding is applied, precision may be lost in the process. If you want to accurately split a Dinero object, use {@link module:Dinero~allocate allocate} instead.
3268
+ *
3269
+ * @param {Number} divisor - The factor to divide by.
3270
+ * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3271
+ *
3272
+ * @example
3273
+ * // returns a Dinero object with amount 100
3274
+ * Dinero({ amount: 400 }).divide(4)
3275
+ * @example
3276
+ * // returns a Dinero object with amount 52
3277
+ * Dinero({ amount: 105 }).divide(2)
3278
+ * @example
3279
+ * // returns a Dinero object with amount 53
3280
+ * Dinero({ amount: 105 }).divide(2, 'HALF_UP')
3281
+ *
3282
+ * @return {Dinero}
3283
+ */
3284
+ divide: function divide(divisor) {
3285
+ var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalRoundingMode;
3286
+ return create.call(this, {
3287
+ amount: calculator$1.round(calculator$1.divide(this.getAmount(), divisor), roundingMode)
3288
+ });
3289
+ },
3290
+
3291
+ /**
3292
+ * Returns a new Dinero object that represents a percentage of this.
3293
+ *
3294
+ * As rounding is applied, precision may be lost in the process. If you want to accurately split a Dinero object, use {@link module:Dinero~allocate allocate} instead.
3295
+ *
3296
+ * @param {Number} percentage - The percentage to extract (between 0 and 100).
3297
+ * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3298
+ *
3299
+ * @example
3300
+ * // returns a Dinero object with amount 5000
3301
+ * Dinero({ amount: 10000 }).percentage(50)
3302
+ * @example
3303
+ * // returns a Dinero object with amount 29
3304
+ * Dinero({ amount: 57 }).percentage(50, "HALF_ODD")
3305
+ *
3306
+ * @throws {RangeError} If `percentage` is out of range.
3307
+ *
3308
+ * @return {Dinero}
3309
+ */
3310
+ percentage: function percentage(_percentage) {
3311
+ var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalRoundingMode;
3312
+ assertPercentage(_percentage);
3313
+ return this.multiply(calculator$1.divide(_percentage, 100), roundingMode);
3314
+ },
3315
+
3316
+ /**
3317
+ * Allocates the amount of a Dinero object according to a list of ratios.
3318
+ *
3319
+ * Sometimes you need to split monetary values but percentages can't cut it without adding or losing pennies.
3320
+ * A good example is invoicing: let's say you need to bill $1,000.03 and you want a 50% downpayment.
3321
+ * If you use {@link module:Dinero~percentage percentage}, you'll get an accurate Dinero object but the amount won't be billable: you can't split a penny.
3322
+ * If you round it, you'll bill a penny extra.
3323
+ * With {@link module:Dinero~allocate allocate}, you can split a monetary amount then distribute the remainder as evenly as possible.
3324
+ *
3325
+ * You can use percentage style or ratio style for `ratios`: `[25, 75]` and `[1, 3]` will do the same thing.
3326
+ *
3327
+ * Since v1.8.0, you can use zero ratios (such as [0, 50, 50]). If there's a remainder to distribute, zero ratios are skipped and return a Dinero object with amount zero.
3328
+ *
3329
+ * @param {Number[]} ratios - The ratios to allocate the money to.
3330
+ *
3331
+ * @example
3332
+ * // returns an array of two Dinero objects
3333
+ * // the first one with an amount of 502
3334
+ * // the second one with an amount of 501
3335
+ * Dinero({ amount: 1003 }).allocate([50, 50])
3336
+ * @example
3337
+ * // returns an array of two Dinero objects
3338
+ * // the first one with an amount of 25
3339
+ * // the second one with an amount of 75
3340
+ * Dinero({ amount: 100 }).allocate([1, 3])
3341
+ * @example
3342
+ * // since version 1.8.0
3343
+ * // returns an array of three Dinero objects
3344
+ * // the first one with an amount of 0
3345
+ * // the second one with an amount of 502
3346
+ * // the third one with an amount of 501
3347
+ * Dinero({ amount: 1003 }).allocate([0, 50, 50])
3348
+ *
3349
+ * @throws {TypeError} If ratios are invalid.
3350
+ *
3351
+ * @return {Dinero[]}
3352
+ */
3353
+ allocate: function allocate(ratios) {
3354
+ var _this = this;
3355
+
3356
+ assertValidRatios(ratios);
3357
+ var total = ratios.reduce(function (a, b) {
3358
+ return calculator$1.add(a, b);
3359
+ });
3360
+ var remainder = this.getAmount();
3361
+ var shares = ratios.map(function (ratio) {
3362
+ var share = Math.floor(calculator$1.divide(calculator$1.multiply(_this.getAmount(), ratio), total));
3363
+ remainder = calculator$1.subtract(remainder, share);
3364
+ return create.call(_this, {
3365
+ amount: share
3366
+ });
3367
+ });
3368
+ var i = 0;
3369
+
3370
+ while (remainder > 0) {
3371
+ if (ratios[i] > 0) {
3372
+ shares[i] = shares[i].add(create.call(this, {
3373
+ amount: 1
3374
+ }));
3375
+ remainder = calculator$1.subtract(remainder, 1);
3376
+ }
3377
+
3378
+ i += 1;
3379
+ }
3380
+
3381
+ return shares;
3382
+ },
3383
+
3384
+ /**
3385
+ * Returns a Promise containing a new Dinero object converted to another currency.
3386
+ *
3387
+ * You have two options to provide the exchange rates:
3388
+ *
3389
+ * 1. **Use an exchange rate REST API, and let Dinero handle the fetching and conversion.**
3390
+ * This is a simple option if you have access to an exchange rate REST API and want Dinero to do the rest.
3391
+ * 2. **Fetch the exchange rates on your own and provide them directly.**
3392
+ * This is useful if you're fetching your rates from somewhere else (a file, a database), use a different protocol or query language than REST (SOAP, GraphQL) or want to fetch rates once and cache them instead of making new requests every time.
3393
+ *
3394
+ * **If you want to use a REST API**, you must provide a third-party endpoint yourself. Dinero doesn't come bundled with an exchange rates endpoint.
3395
+ *
3396
+ * Here are some exchange rate APIs you can use:
3397
+ *
3398
+ * * [Fixer](https://fixer.io)
3399
+ * * [Open Exchange Rates](https://openexchangerates.org)
3400
+ * * [Coinbase](https://api.coinbase.com/v2/exchange-rates)
3401
+ * * More [foreign](https://github.com/toddmotto/public-apis#currency-exchange) and [crypto](https://github.com/toddmotto/public-apis#cryptocurrency) exchange rate APIs.
3402
+ *
3403
+ * **If you want to fetch your own rates and provide them directly**, you need to pass a promise that resolves to the exchanges rates.
3404
+ *
3405
+ * In both cases, you need to specify at least:
3406
+ *
3407
+ * * a **destination currency**: the currency in which you want to convert your Dinero object. You can specify it with `currency`.
3408
+ * * an **endpoint**: the API URL to query exchange rates, with parameters, or a promise that resolves to the exchange rates. You can specify it with `options.endpoint`.
3409
+ * * a **property path**: the path to access the wanted rate in your API's JSON response (or the custom promise's payload). For example, with a response of:
3410
+ * ```json
3411
+ * {
3412
+ * "data": {
3413
+ * "base": "USD",
3414
+ * "destination": "EUR",
3415
+ * "rate": "0.827728919"
3416
+ * }
3417
+ * }
3418
+ * ```
3419
+ * Then the property path is `'data.rate'`. You can specify it with `options.propertyPath`.
3420
+ *
3421
+ * The base currency (the one of your Dinero object) and the destination currency can be used as "merge tags" with the mustache syntax, respectively `{{from}}` and `{{to}}`.
3422
+ * You can use these tags to refer to these values in `options.endpoint` and `options.propertyPath`.
3423
+ *
3424
+ * For example, if you need to specify the base currency as a query parameter, you can do the following:
3425
+ *
3426
+ * ```js
3427
+ * {
3428
+ * endpoint: 'https://yourexchangerates.api/latest?base={{from}}'
3429
+ * }
3430
+ * ```
3431
+ *
3432
+ * @param {String} currency - The destination currency, expressed as an {@link https://en.wikipedia.org/wiki/ISO_4217#Active_codes ISO 4217 currency code}.
3433
+ * @param {(String|Promise)} options.endpoint - The API endpoint to retrieve exchange rates. You can substitute this with a promise that resolves to the exchanges rates if you already have them.
3434
+ * @param {String} [options.propertyPath='rates.{{to}}'] - The property path to the rate.
3435
+ * @param {Object} [options.headers] - The HTTP headers to provide, if needed.
3436
+ * @param {String} [options.roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3437
+ *
3438
+ * @example
3439
+ * // your global API parameters
3440
+ * Dinero.globalExchangeRatesApi = { ... }
3441
+ *
3442
+ * // returns a Promise containing a Dinero object with the destination currency
3443
+ * // and the initial amount converted to the new currency.
3444
+ * Dinero({ amount: 500 }).convert('EUR')
3445
+ * @example
3446
+ * // returns a Promise containing a Dinero object,
3447
+ * // with specific API parameters and rounding mode for this specific instance.
3448
+ * Dinero({ amount: 500 })
3449
+ * .convert('XBT', {
3450
+ * endpoint: 'https://yourexchangerates.api/latest?base={{from}}',
3451
+ * propertyPath: 'data.rates.{{to}}',
3452
+ * headers: {
3453
+ * 'user-key': 'xxxxxxxxx'
3454
+ * },
3455
+ * roundingMode: 'HALF_UP'
3456
+ * })
3457
+ * @example
3458
+ * // usage with exchange rates provided as a custom promise
3459
+ * // using the default `propertyPath` format (so it doesn't have to be specified)
3460
+ * const rates = {
3461
+ * rates: {
3462
+ * EUR: 0.81162
3463
+ * }
3464
+ * }
3465
+ *
3466
+ * Dinero({ amount: 500 })
3467
+ * .convert('EUR', {
3468
+ * endpoint: new Promise(resolve => resolve(rates))
3469
+ * })
3470
+ * @example
3471
+ * // usage with Promise.prototype.then and Promise.prototype.catch
3472
+ * Dinero({ amount: 500 })
3473
+ * .convert('EUR')
3474
+ * .then(dinero => {
3475
+ * dinero.getCurrency() // returns 'EUR'
3476
+ * })
3477
+ * .catch(err => {
3478
+ * // handle errors
3479
+ * })
3480
+ * @example
3481
+ * // usage with async/await
3482
+ * (async () => {
3483
+ * const price = await Dinero({ amount: 500 }).convert('EUR')
3484
+ * price.getCurrency() // returns 'EUR'
3485
+ * })()
3486
+ *
3487
+ * @return {Promise}
3488
+ */
3489
+ convert: function convert(currency) {
3490
+ var _this2 = this;
3491
+
3492
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
3493
+ _ref$endpoint = _ref.endpoint,
3494
+ endpoint = _ref$endpoint === void 0 ? globalExchangeRatesApi.endpoint : _ref$endpoint,
3495
+ _ref$propertyPath = _ref.propertyPath,
3496
+ propertyPath = _ref$propertyPath === void 0 ? globalExchangeRatesApi.propertyPath || 'rates.{{to}}' : _ref$propertyPath,
3497
+ _ref$headers = _ref.headers,
3498
+ headers = _ref$headers === void 0 ? globalExchangeRatesApi.headers : _ref$headers,
3499
+ _ref$roundingMode = _ref.roundingMode,
3500
+ roundingMode = _ref$roundingMode === void 0 ? globalRoundingMode : _ref$roundingMode;
3501
+
3502
+ var options = Object.assign({}, {
3503
+ endpoint: endpoint,
3504
+ propertyPath: propertyPath,
3505
+ headers: headers,
3506
+ roundingMode: roundingMode
3507
+ });
3508
+ return CurrencyConverter(options).getExchangeRate(this.getCurrency(), currency).then(function (rate) {
3509
+ assert(!isUndefined(rate), "No rate was found for the destination currency \"".concat(currency, "\"."), TypeError);
3510
+ return create.call(_this2, {
3511
+ amount: calculator$1.round(calculator$1.multiply(_this2.getAmount(), parseFloat(rate)), options.roundingMode),
3512
+ currency: currency
3513
+ });
3514
+ });
3515
+ },
3516
+
3517
+ /**
3518
+ * Checks whether the value represented by this object equals to the other.
3519
+ *
3520
+ * @param {Dinero} comparator - The Dinero object to compare to.
3521
+ *
3522
+ * @example
3523
+ * // returns true
3524
+ * Dinero({ amount: 500, currency: 'EUR' }).equalsTo(Dinero({ amount: 500, currency: 'EUR' }))
3525
+ * @example
3526
+ * // returns false
3527
+ * Dinero({ amount: 500, currency: 'EUR' }).equalsTo(Dinero({ amount: 800, currency: 'EUR' }))
3528
+ * @example
3529
+ * // returns false
3530
+ * Dinero({ amount: 500, currency: 'USD' }).equalsTo(Dinero({ amount: 500, currency: 'EUR' }))
3531
+ * @example
3532
+ * // returns false
3533
+ * Dinero({ amount: 500, currency: 'USD' }).equalsTo(Dinero({ amount: 800, currency: 'EUR' }))
3534
+ * @example
3535
+ * // returns true
3536
+ * Dinero({ amount: 1000, currency: 'EUR', precision: 2 }).equalsTo(Dinero({ amount: 10000, currency: 'EUR', precision: 3 }))
3537
+ * @example
3538
+ * // returns false
3539
+ * Dinero({ amount: 10000, currency: 'EUR', precision: 2 }).equalsTo(Dinero({ amount: 10000, currency: 'EUR', precision: 3 }))
3540
+ *
3541
+ * @return {Boolean}
3542
+ */
3543
+ equalsTo: function equalsTo(comparator) {
3544
+ return this.hasSameAmount(comparator) && this.hasSameCurrency(comparator);
3545
+ },
3546
+
3547
+ /**
3548
+ * Checks whether the value represented by this object is less than the other.
3549
+ *
3550
+ * @param {Dinero} comparator - The Dinero object to compare to.
3551
+ *
3552
+ * @example
3553
+ * // returns true
3554
+ * Dinero({ amount: 500 }).lessThan(Dinero({ amount: 800 }))
3555
+ * @example
3556
+ * // returns false
3557
+ * Dinero({ amount: 800 }).lessThan(Dinero({ amount: 500 }))
3558
+ * @example
3559
+ * // returns true
3560
+ * Dinero({ amount: 5000, precision: 3 }).lessThan(Dinero({ amount: 800 }))
3561
+ * @example
3562
+ * // returns false
3563
+ * Dinero({ amount: 800 }).lessThan(Dinero({ amount: 5000, precision: 3 }))
3564
+ *
3565
+ * @throws {TypeError} If `comparator` has a different currency.
3566
+ *
3567
+ * @return {Boolean}
3568
+ */
3569
+ lessThan: function lessThan(comparator) {
3570
+ assertSameCurrency.call(this, comparator);
3571
+ var comparators = Dinero.normalizePrecision([this, comparator]);
3572
+ return comparators[0].getAmount() < comparators[1].getAmount();
3573
+ },
3574
+
3575
+ /**
3576
+ * Checks whether the value represented by this object is less than or equal to the other.
3577
+ *
3578
+ * @param {Dinero} comparator - The Dinero object to compare to.
3579
+ *
3580
+ * @example
3581
+ * // returns true
3582
+ * Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 800 }))
3583
+ * @example
3584
+ * // returns true
3585
+ * Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 500 }))
3586
+ * @example
3587
+ * // returns false
3588
+ * Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 300 }))
3589
+ * @example
3590
+ * // returns true
3591
+ * Dinero({ amount: 5000, precision: 3 }).lessThanOrEqual(Dinero({ amount: 800 }))
3592
+ * @example
3593
+ * // returns true
3594
+ * Dinero({ amount: 5000, precision: 3 }).lessThanOrEqual(Dinero({ amount: 500 }))
3595
+ * @example
3596
+ * // returns false
3597
+ * Dinero({ amount: 800 }).lessThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
3598
+ *
3599
+ * @throws {TypeError} If `comparator` has a different currency.
3600
+ *
3601
+ * @return {Boolean}
3602
+ */
3603
+ lessThanOrEqual: function lessThanOrEqual(comparator) {
3604
+ assertSameCurrency.call(this, comparator);
3605
+ var comparators = Dinero.normalizePrecision([this, comparator]);
3606
+ return comparators[0].getAmount() <= comparators[1].getAmount();
3607
+ },
3608
+
3609
+ /**
3610
+ * Checks whether the value represented by this object is greater than the other.
3611
+ *
3612
+ * @param {Dinero} comparator - The Dinero object to compare to.
3613
+ *
3614
+ * @example
3615
+ * // returns false
3616
+ * Dinero({ amount: 500 }).greaterThan(Dinero({ amount: 800 }))
3617
+ * @example
3618
+ * // returns true
3619
+ * Dinero({ amount: 800 }).greaterThan(Dinero({ amount: 500 }))
3620
+ * @example
3621
+ * // returns true
3622
+ * Dinero({ amount: 800 }).greaterThan(Dinero({ amount: 5000, precision: 3 }))
3623
+ * @example
3624
+ * // returns false
3625
+ * Dinero({ amount: 5000, precision: 3 }).greaterThan(Dinero({ amount: 800 }))
3626
+ *
3627
+ * @throws {TypeError} If `comparator` has a different currency.
3628
+ *
3629
+ * @return {Boolean}
3630
+ */
3631
+ greaterThan: function greaterThan(comparator) {
3632
+ assertSameCurrency.call(this, comparator);
3633
+ var comparators = Dinero.normalizePrecision([this, comparator]);
3634
+ return comparators[0].getAmount() > comparators[1].getAmount();
3635
+ },
3636
+
3637
+ /**
3638
+ * Checks whether the value represented by this object is greater than or equal to the other.
3639
+ *
3640
+ * @param {Dinero} comparator - The Dinero object to compare to.
3641
+ *
3642
+ * @example
3643
+ * // returns true
3644
+ * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 300 }))
3645
+ * @example
3646
+ * // returns true
3647
+ * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 500 }))
3648
+ * @example
3649
+ * // returns false
3650
+ * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 800 }))
3651
+ * @example
3652
+ * // returns true
3653
+ * Dinero({ amount: 800 }).greaterThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
3654
+ * @example
3655
+ * // returns true
3656
+ * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
3657
+ * @example
3658
+ * // returns false
3659
+ * Dinero({ amount: 5000, precision: 3 }).greaterThanOrEqual(Dinero({ amount: 800 }))
3660
+ *
3661
+ * @throws {TypeError} If `comparator` has a different currency.
3662
+ *
3663
+ * @return {Boolean}
3664
+ */
3665
+ greaterThanOrEqual: function greaterThanOrEqual(comparator) {
3666
+ assertSameCurrency.call(this, comparator);
3667
+ var comparators = Dinero.normalizePrecision([this, comparator]);
3668
+ return comparators[0].getAmount() >= comparators[1].getAmount();
3669
+ },
3670
+
3671
+ /**
3672
+ * Checks if the value represented by this object is zero.
3673
+ *
3674
+ * @example
3675
+ * // returns true
3676
+ * Dinero({ amount: 0 }).isZero()
3677
+ * @example
3678
+ * // returns false
3679
+ * Dinero({ amount: 100 }).isZero()
3680
+ *
3681
+ * @return {Boolean}
3682
+ */
3683
+ isZero: function isZero() {
3684
+ return this.getAmount() === 0;
3685
+ },
3686
+
3687
+ /**
3688
+ * Checks if the value represented by this object is positive.
3689
+ *
3690
+ * @example
3691
+ * // returns false
3692
+ * Dinero({ amount: -10 }).isPositive()
3693
+ * @example
3694
+ * // returns true
3695
+ * Dinero({ amount: 10 }).isPositive()
3696
+ * @example
3697
+ * // returns true
3698
+ * Dinero({ amount: 0 }).isPositive()
3699
+ *
3700
+ * @return {Boolean}
3701
+ */
3702
+ isPositive: function isPositive() {
3703
+ return this.getAmount() >= 0;
3704
+ },
3705
+
3706
+ /**
3707
+ * Checks if the value represented by this object is negative.
3708
+ *
3709
+ * @example
3710
+ * // returns true
3711
+ * Dinero({ amount: -10 }).isNegative()
3712
+ * @example
3713
+ * // returns false
3714
+ * Dinero({ amount: 10 }).isNegative()
3715
+ * @example
3716
+ * // returns false
3717
+ * Dinero({ amount: 0 }).isNegative()
3718
+ *
3719
+ * @return {Boolean}
3720
+ */
3721
+ isNegative: function isNegative() {
3722
+ return this.getAmount() < 0;
3723
+ },
3724
+
3725
+ /**
3726
+ * Checks if this has minor currency units.
3727
+ * Deprecates {@link module:Dinero~hasCents hasCents}.
3728
+ *
3729
+ * @example
3730
+ * // returns false
3731
+ * Dinero({ amount: 1100 }).hasSubUnits()
3732
+ * @example
3733
+ * // returns true
3734
+ * Dinero({ amount: 1150 }).hasSubUnits()
3735
+ *
3736
+ * @return {Boolean}
3737
+ */
3738
+ hasSubUnits: function hasSubUnits() {
3739
+ return calculator$1.modulo(this.getAmount(), Math.pow(10, precision)) !== 0;
3740
+ },
3741
+
3742
+ /**
3743
+ * Checks if this has minor currency units.
3744
+ *
3745
+ * @deprecated since version 1.4.0, will be removed in 2.0.0
3746
+ * Use {@link module:Dinero~hasSubUnits hasSubUnits} instead.
3747
+ *
3748
+ * @example
3749
+ * // returns false
3750
+ * Dinero({ amount: 1100 }).hasCents()
3751
+ * @example
3752
+ * // returns true
3753
+ * Dinero({ amount: 1150 }).hasCents()
3754
+ *
3755
+ * @return {Boolean}
3756
+ */
3757
+ hasCents: function hasCents() {
3758
+ return calculator$1.modulo(this.getAmount(), Math.pow(10, precision)) !== 0;
3759
+ },
3760
+
3761
+ /**
3762
+ * Checks whether the currency represented by this object equals to the other.
3763
+ *
3764
+ * @param {Dinero} comparator - The Dinero object to compare to.
3765
+ *
3766
+ * @example
3767
+ * // returns true
3768
+ * Dinero({ amount: 2000, currency: 'EUR' }).hasSameCurrency(Dinero({ amount: 1000, currency: 'EUR' }))
3769
+ * @example
3770
+ * // returns false
3771
+ * Dinero({ amount: 1000, currency: 'EUR' }).hasSameCurrency(Dinero({ amount: 1000, currency: 'USD' }))
3772
+ *
3773
+ * @return {Boolean}
3774
+ */
3775
+ hasSameCurrency: function hasSameCurrency(comparator) {
3776
+ return this.getCurrency() === comparator.getCurrency();
3777
+ },
3778
+
3779
+ /**
3780
+ * Checks whether the amount represented by this object equals to the other.
3781
+ *
3782
+ * @param {Dinero} comparator - The Dinero object to compare to.
3783
+ *
3784
+ * @example
3785
+ * // returns true
3786
+ * Dinero({ amount: 1000, currency: 'EUR' }).hasSameAmount(Dinero({ amount: 1000 }))
3787
+ * @example
3788
+ * // returns false
3789
+ * Dinero({ amount: 2000, currency: 'EUR' }).hasSameAmount(Dinero({ amount: 1000, currency: 'EUR' }))
3790
+ * @example
3791
+ * // returns true
3792
+ * Dinero({ amount: 1000, currency: 'EUR', precision: 2 }).hasSameAmount(Dinero({ amount: 10000, precision: 3 }))
3793
+ * @example
3794
+ * // returns false
3795
+ * Dinero({ amount: 10000, currency: 'EUR', precision: 2 }).hasSameAmount(Dinero({ amount: 10000, precision: 3 }))
3796
+ *
3797
+ * @return {Boolean}
3798
+ */
3799
+ hasSameAmount: function hasSameAmount(comparator) {
3800
+ var comparators = Dinero.normalizePrecision([this, comparator]);
3801
+ return comparators[0].getAmount() === comparators[1].getAmount();
3802
+ },
3803
+
3804
+ /**
3805
+ * Returns this object formatted as a string.
3806
+ *
3807
+ * The format is a mask which defines how the output string will be formatted.
3808
+ * It defines whether to display a currency, in what format, how many fraction digits to display and whether to use grouping separators.
3809
+ * The output is formatted according to the applying locale.
3810
+ *
3811
+ * Object | Format | String
3812
+ * :--------------------------- | :---------------- | :---
3813
+ * `Dinero({ amount: 500050 })` | `'$0,0.00'` | $5,000.50
3814
+ * `Dinero({ amount: 500050 })` | `'$0,0'` | $5,001
3815
+ * `Dinero({ amount: 500050 })` | `'$0'` | $5001
3816
+ * `Dinero({ amount: 500050 })` | `'$0.0'` | $5000.5
3817
+ * `Dinero({ amount: 500050 })` | `'USD0,0.0'` | USD5,000.5
3818
+ * `Dinero({ amount: 500050 })` | `'0,0.0 dollar'` | 5,000.5 dollars
3819
+ *
3820
+ * Don't try to substitute the `$` sign or the `USD` code with your target currency, nor adapt the format string to the exact format you want.
3821
+ * The format is a mask which defines a pattern and returns a valid, localized currency string.
3822
+ * If you want to display the object in a custom way, either use {@link module:Dinero~getAmount getAmount}, {@link module:Dinero~toUnit toUnit} or {@link module:Dinero~toRoundedUnit toRoundedUnit} and manipulate the output string as you wish.
3823
+ *
3824
+ * {@link module:Dinero~toFormat toFormat} wraps around `Number.prototype.toLocaleString`. For that reason, **format will vary depending on how it's implemented in the end user's environment**.
3825
+ *
3826
+ * You can also use `toLocaleString` directly:
3827
+ * `Dinero().toRoundedUnit(digits, roundingMode).toLocaleString(locale, options)`.
3828
+ *
3829
+ * By default, amounts are rounded using the **half away from zero** rule ([commercial rounding](https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero)).
3830
+ * You can also specify a different `roundingMode` to better fit your needs.
3831
+ *
3832
+ * @param {String} [format='$0,0.00'] - The format mask to format to.
3833
+ * @param {String} [roundingMode='HALF_AWAY_FROM_ZERO'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3834
+ *
3835
+ * @example
3836
+ * // returns $2,000
3837
+ * Dinero({ amount: 200000 }).toFormat('$0,0')
3838
+ * @example
3839
+ * // returns €50.5
3840
+ * Dinero({ amount: 5050, currency: 'EUR' }).toFormat('$0,0.0')
3841
+ * @example
3842
+ * // returns 100 euros
3843
+ * Dinero({ amount: 10000, currency: 'EUR' }).setLocale('fr-FR').toFormat('0,0 dollar')
3844
+ * @example
3845
+ * // returns 2000
3846
+ * Dinero({ amount: 200000, currency: 'EUR' }).toFormat()
3847
+ * @example
3848
+ * // returns $10
3849
+ * Dinero({ amount: 1050 }).toFormat('$0', 'HALF_EVEN')
3850
+ *
3851
+ * @return {String}
3852
+ */
3853
+ toFormat: function toFormat() {
3854
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : globalFormat;
3855
+ var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalFormatRoundingMode;
3856
+ var formatter = Format(format);
3857
+ return this.toRoundedUnit(formatter.getMinimumFractionDigits(), roundingMode).toLocaleString(this.getLocale(), {
3858
+ currencyDisplay: formatter.getCurrencyDisplay(),
3859
+ useGrouping: formatter.getUseGrouping(),
3860
+ minimumFractionDigits: formatter.getMinimumFractionDigits(),
3861
+ style: formatter.getStyle(),
3862
+ currency: this.getCurrency()
3863
+ });
3864
+ },
3865
+
3866
+ /**
3867
+ * Returns the amount represented by this object in units.
3868
+ *
3869
+ * @example
3870
+ * // returns 10.5
3871
+ * Dinero({ amount: 1050 }).toUnit()
3872
+ * @example
3873
+ * // returns 10.545
3874
+ * Dinero({ amount: 10545, precision: 3 }).toUnit()
3875
+ *
3876
+ * @return {Number}
3877
+ */
3878
+ toUnit: function toUnit() {
3879
+ return calculator$1.divide(this.getAmount(), Math.pow(10, precision));
3880
+ },
3881
+
3882
+ /**
3883
+ * Returns the amount represented by this object in rounded units.
3884
+ *
3885
+ * By default, the method uses the **half away from zero** rule ([commercial rounding](https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero)).
3886
+ * You can also specify a different `roundingMode` to better fit your needs.
3887
+ *
3888
+ * @example
3889
+ * // returns 10.6
3890
+ * Dinero({ amount: 1055 }).toRoundedUnit(1)
3891
+ * @example
3892
+ * // returns 10
3893
+ * Dinero({ amount: 1050 }).toRoundedUnit(0, 'HALF_EVEN')
3894
+ *
3895
+ * @param {Number} digits - The number of fraction digits to round to.
3896
+ * @param {String} [roundingMode='HALF_AWAY_FROM_ZERO'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3897
+ *
3898
+ * @return {Number}
3899
+ */
3900
+ toRoundedUnit: function toRoundedUnit(digits) {
3901
+ var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalFormatRoundingMode;
3902
+ var factor = Math.pow(10, digits);
3903
+ return calculator$1.divide(calculator$1.round(calculator$1.multiply(this.toUnit(), factor), roundingMode), factor);
3904
+ },
3905
+
3906
+ /**
3907
+ * Returns the object's data as an object literal.
3908
+ *
3909
+ * @example
3910
+ * // returns { amount: 500, currency: 'EUR', precision: 2 }
3911
+ * Dinero({ amount: 500, currency: 'EUR', precision: 2 }).toObject()
3912
+ *
3913
+ * @return {Object}
3914
+ */
3915
+ toObject: function toObject() {
3916
+ return {
3917
+ amount: amount,
3918
+ currency: currency,
3919
+ precision: precision
3920
+ };
3921
+ },
3922
+
3923
+ /**
3924
+ * Returns the object's data as an object literal.
3925
+ *
3926
+ * Alias of {@link module:Dinero~toObject toObject}.
3927
+ * It is defined so that calling `JSON.stringify` on a Dinero object will automatically extract the relevant data.
3928
+ *
3929
+ * @example
3930
+ * // returns '{"amount":500,"currency":"EUR","precision":2}'
3931
+ * JSON.stringify(Dinero({ amount: 500, currency: 'EUR', precision: 2 }))
3932
+ *
3933
+ * @return {Object}
3934
+ */
3935
+ toJSON: function toJSON() {
3936
+ return this.toObject();
3937
+ }
3938
+ };
3939
+ };
3940
+
3941
+ var dinero = Object.assign(Dinero, Defaults, Globals, Static);
3942
+
3943
+ function formatCurrency(amount, withSymbol = true) {
3944
+ if (!amount)
3945
+ amount = 0;
3946
+ function format(amount) {
3947
+ const formattedString = withSymbol ? '$0,0.00' : '0,0.00';
3948
+ return dinero({ amount: amount, currency: 'USD' }).toFormat(formattedString);
3949
+ }
3950
+ return amount < 0 ? `(${format(-amount)})` : format(amount);
3951
+ }
3952
+ function formatDate(dateString) {
3953
+ if (!dateString)
3954
+ return '';
3955
+ const date = new Date(dateString);
3956
+ return format(date, 'MMM d, yyyy');
3957
+ }
3958
+ function formatTime(dateString) {
3959
+ if (!dateString)
3960
+ return '';
3961
+ const date = new Date(dateString);
3962
+ return format(date, 'h:mmaaa');
3963
+ }
3964
+ function extractComputedFontsToLoad() {
3965
+ var _a;
3966
+ const computedStyles = getComputedStyle(document.body);
3967
+ return ((_a = computedStyles === null || computedStyles === void 0 ? void 0 : computedStyles.getPropertyValue('--jfi-load-google-font')) === null || _a === void 0 ? void 0 : _a.trim().replace(/'|"/g, '').replace(' ', '+')) || null;
3968
+ }
3969
+
3970
+ export { PaymentMethodTypes as P, Payment as a, formatTime as b, formatCurrency as c, PayoutStatuses as d, extractComputedFontsToLoad as e, formatDate as f, Payout as g };
3971
+
3972
+ //# sourceMappingURL=utils-e7782126.js.map