@justifi/webcomponents 4.6.4 → 4.7.0-rc.1

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